Skip to content

Commit

Permalink
[develop] fix(package): i18n, dependences
Browse files Browse the repository at this point in the history
  • Loading branch information
tomandco-rafalwolak committed Jul 29, 2019
1 parent 17e46a0 commit bf6c033
Show file tree
Hide file tree
Showing 31 changed files with 225 additions and 539 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/out
/node_modules
node_modules
.vscode-test/
*.vsix
*.code-workspace
*.lock
*.log
src/constants.json
coverage/
package-lock.json
18 changes: 6 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: watch"
},
{
Expand All @@ -30,11 +26,9 @@
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm: test-compile"
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "npm: test:compile"
}
]
}
23 changes: 5 additions & 18 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,10 @@
out/test/**
test/**
src/**
.commitlintrc.yml
.gitignore
.prettierrc.yml
.releaserc.yml
.travis.yml
vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
*.code-workspace
*.log
node_modules
!node_modules/uuid
!node_modules/verror
!node_modules/assert-plus
!node_modules/extsprintf
!node_modules/core-util-is
package-lock.json
yarn.lock
*.lock
*.vsix
.gitignore
tsconfig.json
vsc-extension-quickstart.md
87 changes: 87 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const gulp = require('gulp');

const ts = require('gulp-typescript');
const typescript = require('typescript');
const sourcemaps = require('gulp-sourcemaps');
const del = require('del');
const es = require('event-stream');
const vsce = require('vsce');
const nls = require('vscode-nls-dev');

const tsProject = ts.createProject('./tsconfig.json', { typescript });

const inlineMap = true;
const inlineSource = false;
const outDest = 'out';

// If all VS Code langaues are support you can use nls.coreLanguages
const languages = [{ folderName: 'pl', id: 'pl' }];

const cleanTask = function() {
return del(['out/**', 'package.nls.*.json', 'i18n-sample*.vsix']);
};

const internalCompileTask = function() {
return doCompile(false);
};

const internalNlsCompileTask = function() {
return doCompile(true);
};

const addI18nTask = function() {
return gulp
.src(['package.nls.json'])
.pipe(nls.createAdditionalLanguageFiles(languages, 'i18n'))
.pipe(gulp.dest('.'));
};

const buildTask = gulp.series(cleanTask, internalNlsCompileTask, addI18nTask);

const doCompile = function(buildNls) {
var r = tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
.pipe(
buildNls
? nls.createAdditionalLanguageFiles(languages, 'i18n', 'out')
: es.through()
);

if (inlineMap && inlineSource) {
r = r.pipe(sourcemaps.write());
} else {
r = r.pipe(
sourcemaps.write('../out', {
// no inlined source
includeContent: inlineSource,
// Return relative source map root directories per file.
sourceRoot: '../src'
})
);
}

return r.pipe(gulp.dest(outDest));
};

const vscePublishTask = function() {
return vsce.publish();
};

const vscePackageTask = function() {
return vsce.createVSIX();
};

gulp.task('default', buildTask);

gulp.task('clean', cleanTask);

gulp.task('compile', gulp.series(cleanTask, internalCompileTask));

gulp.task('build', buildTask);

gulp.task('publish', gulp.series(buildTask, vscePublishTask));

gulp.task('package', gulp.series(buildTask, vscePackageTask));
1 change: 0 additions & 1 deletion i18n/pl/extension.i18n.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"noWorkspacesFound.text": "No workspaces found"
}
4 changes: 0 additions & 4 deletions i18n/pl/out/common.i18n.json

This file was deleted.

9 changes: 6 additions & 3 deletions i18n/pl/package.i18n.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"configuration.title": "vscode-workspace-manager configuration",
"configuration.paths": "Paths of directories when `.code-workspace` files can be saved and then read from",
"configuration.title": "Workspace Manager",
"configuration.includeGlobPattern": "Paths of directories when `.code-workspace` files can be saved and then read from",
"configuration.excludeGlobPattern": "Paths of directories when `.code-workspace` files can be saved and then read from",
"configuration.codeExecutable": "Path to the executable file for VS Code",
"configuration.codeInsidersExecutable": "Path to the executable file for VS Code Insiders",
"configuration.showInActivityBar": "Whether or not to show the activity bar tree view container",
"configuration.showInExplorer": "Whether or not to show the list of workspaces in the explorer tree view container",
"command.refreshTreeData.title": "Workspace Manager: Odśwież Obszar Roboczy",
"command.cacheWorkspace.title": "Workspace Manager: Odśwież Pamięć Podręczną Obszaru Roboczego",
"command.saveWorkspace.title": "Workspace Manager: Zapisz Obszar Roboczy",
"command.switchWorkspace.title": "Workspace Manager: Przełącz Obszar Roboczy",
"command.switchWorkspaceInNewWindow.title": "Workspace Manager: Przełącz Obszar Roboczy w Nowym Oknie",
"command.deleteWorkspace.title": "Workspace Manager: Usuń Obszar Roboczy",
"command.reloadWorkspaces.title": "Workspace Manager: Odśwież Obszary Robocze",
"command.closeWorkspace.title": "Workspace Manager: Zamknij Obszar Roboczy",
"viewsContainers.activitybar.title": "Workspace Manager",
"views.vscodeWorkspaceManagerViewContainer.title": "Obszary Robocze",
"views.workspaceManager.title": "Obszary Robocze",
"views.explorer.title": "Obszary Robocze"
}
25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,31 @@
"keywords": [
"workspace",
"save",
"manager",
"switch"
],
"main": "./out/src/extension.js",
"main": "./out/extension.js",
"scripts": {
"vscode:prepublish": "yarn run compile",
"publish": "vsce publish --yarn",
"package": "vsce package --yarn",
"clean": "rimraf out",
"compile": "yarn run clean && tsc -p ./",
"watch": "tsc -watch -p ./",
"publish": "gulp publish",
"package": "gulp package",
"clean": "gulp clean",
"compile": "tsc -b",
"watch": "tsc -b -w",
"commit": "commit",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "yarn run compile",
"test:compile": "yarn run compile",
"release": "./node_modules/.bin/semantic-release"
},
"dependencies": {
"applicationinsights": "^1.4.0",
"fast-glob": "^3.0.4",
"lodash": "^4.17.15",
"mkdirp": "^0.5.1",
"fast-glob": "^3.0.4",
"path-dirname": "^1.0.2",
"semver": "^6.3.0",
"to-regex": "^3.0.2",
"uuid": "^3.3.2",
"verror": "^1.10.0",
"vscode-nls": "^4.1.1"
Expand All @@ -60,13 +64,18 @@
"@types/uuid": "^3.4.5",
"@types/verror": "^1.10.3",
"decache": "^4.5.1",
"del": "^5.0.0",
"event-stream": "^4.0.1",
"gulp": "^4.0.2",
"gulp-filter": "^6.0.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-typescript": "^5.0.1",
"husky": "^2.4.1",
"minimist": "^1.2.0",
"prettier": "^1.18.2",
"rimraf": "^2.6.3",
"semantic-release": "^15.13.16",
"semantic-release-vsce": "^2.2.8",
"ts-loader": "^6.0.4",
"tslint": "^5.12.1",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.3.1",
Expand Down
10 changes: 6 additions & 4 deletions package.nls.pl.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"configuration.title": "vscode-workspace-manager configuration",
"configuration.paths": "Paths of directories when `.code-workspace` files can be saved and then read from",
"configuration.title": "Workspace Manager",
"configuration.includeGlobPattern": "Paths of directories when `.code-workspace` files can be saved and then read from",
"configuration.excludeGlobPattern": "Paths of directories when `.code-workspace` files can be saved and then read from",
"configuration.codeExecutable": "Path to the executable file for VS Code",
"configuration.codeInsidersExecutable": "Path to the executable file for VS Code Insiders",
"configuration.showInActivityBar": "Whether or not to show the activity bar tree view container",
Expand All @@ -9,9 +10,10 @@
"command.switchWorkspace.title": "Workspace Manager: Przełącz Obszar Roboczy",
"command.switchWorkspaceInNewWindow.title": "Workspace Manager: Przełącz Obszar Roboczy w Nowym Oknie",
"command.deleteWorkspace.title": "Workspace Manager: Usuń Obszar Roboczy",
"command.reloadWorkspaces.title": "Workspace Manager: Odśwież Obszary Robocze",
"command.refreshTreeData.title": "Workspace Manager: Odśwież Obszar Roboczy",
"command.closeWorkspace.title": "Workspace Manager: Zamknij Obszar Roboczy",
"command.cacheWorkspace.title": "Workspace Manager: Odśwież Pamięć Podręczną Obszaru Roboczego",
"viewsContainers.activitybar.title": "Workspace Manager",
"views.vscodeWorkspaceManagerViewContainer.title": "Obszary Robocze",
"views.workspaceManager.title": "Obszary Robocze",
"views.explorer.title": "Obszary Robocze"
}
12 changes: 6 additions & 6 deletions src/cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const now = (): number => Math.floor(Date.now() / 1000);
export class Cache {
context: ExtensionContext;
namespace: string;
cache: object;
cache: any;

constructor(namespace?: string) {
// ExtensionContext
this.context = state.context;
this.context = <ExtensionContext>state.context;

// Namespace of the context's globalState
this.namespace = namespace || 'cache';
Expand Down Expand Up @@ -68,7 +68,7 @@ export class Cache {
* @param {any} [defaultValue] - The optional default value to return if the cached item does not exist or is expired
* @returns {any} Returns the cached value or optional defaultValue
*/
get<T>(key: string, defaultValue: T): T {
get<T>(key: string, defaultValue: T): T | undefined {
// If doesn't exist
if (typeof this.cache[key] === 'undefined') {
// Return default value
Expand All @@ -88,7 +88,7 @@ export class Cache {
}

// Alias of get
fetch<T>(key: string, defaultValue: T): T {
fetch<T>(key: string, defaultValue: T): T | undefined {
return this.get<T>(key, defaultValue);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ export class Cache {
* @return {object}
*/
all(): object {
let items = {};
let items: any = {};

for (let key in this.cache) {
items[key] = this.cache[key].value;
Expand Down Expand Up @@ -204,7 +204,7 @@ export class Cache {
* @param {string} key - The unique key for the cached item
* @return {number} Unix Timestamp in seconds
*/
getExpiration(key: string): number {
getExpiration(key: string): number | undefined {
if (
typeof this.cache[key] === 'undefined' ||
typeof this.cache[key].expiration === 'undefined'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/abstractCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type CommandContext =

export abstract class AbstractCommand implements Disposable {
protected trackSuccess: boolean = false;
protected eventName: string;
protected eventName?: string;

protected readonly contextParsingOptions: CommandContextParsingOptions = {
editor: false,
Expand Down
5 changes: 3 additions & 2 deletions src/commands/workspace/deleteWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { window, QuickPickItem, QuickPickOptions } from 'vscode';
import { deleteWorkspace } from '../../util/deleteWorkspace';
import { Command, Commands } from '../common';
import { AbstractCommand } from '../abstractCommand';
import { WorkspaceEntry } from '../../model/workspace';

const localize = nls.loadMessageBundle();

Expand Down Expand Up @@ -45,11 +46,11 @@ export class DeleteWorkspaceCommand extends AbstractCommand {

window.showQuickPick(workspaceItems, options).then(
(workspaceItem?: QuickPickItem) => {
if (!workspaceItem) {
if (!workspaceItem || !workspaceEntries) {
return;
}

const entry = workspaceEntries.find(
const entry: WorkspaceEntry | undefined = workspaceEntries.find(
entry => entry.path === workspaceItem.description
);

Expand Down
2 changes: 1 addition & 1 deletion src/commands/workspace/switchToWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SwitchToWorkspaceCommand extends AbstractCommand {

const app = getApp();
const command = `${app} ${args.inNewWindow ? '-n' : '-r'} "${
args.workspaceEntry.path
args.workspaceEntry!.path
}"`;

exec(command, onCommandRun);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/workspace/switchWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class SwitchWorkspaceCommand extends AbstractCommand {
return;
}

const entry: WorkspaceEntry = workspaceEntries.find(
const entry: WorkspaceEntry | undefined = workspaceEntries.find(
entry => entry.path === workspaceItem.description
);

Expand Down
2 changes: 1 addition & 1 deletion src/commands/workspace/switchWorkspaceInNewWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class SwitchWorkspaceInNewWindowCommand extends AbstractCommand {
return;
}

const entry: WorkspaceEntry = workspaceEntries.find(
const entry: WorkspaceEntry | undefined = workspaceEntries.find(
entry => entry.path === workspaceItem.description
);

Expand Down
Loading

0 comments on commit bf6c033

Please sign in to comment.