Skip to content

Commit

Permalink
Merge pull request #860 from zowe/add-webpack-out
Browse files Browse the repository at this point in the history
Weback with localization and logging
  • Loading branch information
zFernand0 authored Jul 15, 2020
2 parents e69bd9b + 757f445 commit 91c2fbc
Show file tree
Hide file tree
Showing 39 changed files with 2,063 additions and 129 deletions.
10 changes: 10 additions & 0 deletions .vscode/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* This program and the accompanying materials are made available under the terms of the *
* Eclipse Public License v2.0 which accompanies this distribution, and is available at *
* https://www.eclipse.org/legal/epl-v20.html *
* *
* SPDX-License-Identifier: EPL-2.0 *
* *
* Copyright Contributors to the Zowe Project. *
* *
*/
8 changes: 5 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
"--extensionDevelopmentPath=${workspaceFolder}",
"--verbose"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
"preLaunchTask": "build dev watch",
"smartStep": true
},
{
"name": "Integration Tests (Mocha)",
Expand All @@ -42,7 +44,7 @@
"outFiles": [
"${workspaceFolder}/out/__tests__/**/*.js"
],
"preLaunchTask": "npm: watch"
"preLaunchTask": "Pretest"
}
]
}
53 changes: 53 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,65 @@
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build dev watch",
"group": "build",
"isBackground": true,
"type":"shell",
"command": "npm",
"args": [
"run",
"watch"
],
"problemMatcher":[
{
"owner": "typescript",
"source": "ts",
"applyTo": "closedDocuments",
"fileLocation": "absolute",
"severity": "error",
"pattern": [
{
"regexp": "\\[tsl\\] ERROR in (.*)?\\((\\d+),(\\d+)\\)",
"file": 1,
"line": 2,
"column": 3
},
{
"regexp": "\\s*TS\\d+:\\s*(.*)",
"message": 1
}
],
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "Compilation (.*?)starting…"
},
"endsPattern": {
"regexp": "Compilation (.*?)finished"
}
}
}
]
},
{
"label": "Pretest",
"group": "build",
"isBackground": false,
"type": "shell",
"command":"npm",
"args": [
"run",
"build:integration"
]
}
]
}
15 changes: 14 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ out/__tests__/**
out/src/__mocks__/**
out/resources/testProfileData.*
out/**/*.map
resources/testProfileData.example.ts
resources/testProfileData.ts
resources/Favorites.txt
results/**
Expand All @@ -15,4 +16,16 @@ src/**
tsconfig.json
tslint.json
*.vsix
logs/**
logs/**
.markdownlint.json
CODEOWNERS
gulpfile.js
Jenkinsfile
LICENSE_HEADER
webpack.config.js
dco_signoffs
docs
i18n
scripts
node_modules/**
!node_modules/vscode-nls/**
11 changes: 10 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,16 @@ All localized strings must be string literals, you cannot include variables or u
2. There are two places to localize strings: in the package.json file and in the typescript files in the src directory.
- If you want to add a new string to the package.json file, replace the string with your key enclosed by the percent sign as such \% __key__ \% i.e. `"This is a string"` becomes `"%exampleProperty.exDescription%"`. Then go to the package.nls.json file found in the root directory of the repository and include your newly created key and string inside as a json key/value pair.

- If you want to add a new string to a typescript file, you will need to include the following library in your file (if not already included). `import * as nls from 'vscode-nls';` You will also need to include the following function `const localize = nls.config({ messageFormat: nls.MessageFormat.file })();` Next wrap your string with the localize function in this format `localize('key', 'string') i.e. localize('addEntry','Successfully called add entry.')`
- If you want to add a new string to a typescript file, you will need to include the following library in your file (if not already included). `import * as nls from 'vscode-nls';`
- You will also need to include the following code:

```Typescript
// Set up localization
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
```

- Next wrap your string with the localize function in this format `localize('key', 'string') i.e. localize('addEntry','Successfully called add entry.')`

3. After adding/updating/removing any string, run `npm run package`. This will update the sample directory under the i18n folder with the newly added strings. Upload these files to Zanata or email a maintainer to do so.

Expand Down
81 changes: 28 additions & 53 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/*
* This program and the accompanying materials are made available under the terms of the *
* Eclipse Public License v2.0 which accompanies this distribution, and is available at *
* https://www.eclipse.org/legal/epl-v20.html *
* *
* SPDX-License-Identifier: EPL-2.0 *
* *
* Copyright Contributors to the Zowe Project. *
* *
*/

const gulp = require('gulp');
const path = require('path');
const filter = require('gulp-filter');

const ts = require('gulp-typescript');
const typescript = require('typescript');
const sourcemaps = require('gulp-sourcemaps');
const del = require('del');
const runSequence = require('run-sequence');
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';
const outDest = 'out/src';

// If all VS Code languages are supported, you can use nls.coreLanguages
// For new languages, add { folderName: 'ISO-639-3-Code-for-language', id: 'vscode-locale-id' } to array below
Expand All @@ -31,59 +31,34 @@ const cleanTask = function() {
return del(['out/**', 'package.nls.*.json', 'vscode-extension-for-zowe*.vsix']);
}

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

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

const addI18nTask = function() {
const generateI18nTask = 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()
const generateLocalizationBundle = () => {
// Transpile the TS to JS, and let vscode-nls-dev scan the files for calls to localize
// PROJECT ID is "<PUBLISHER>.<NAME>" (found in package.json)
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject()).js
.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
.pipe(buildNls ? nls.createAdditionalLanguageFiles(languages, 'i18n') : 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));
.pipe(tsProject()).js
.pipe(nls.createMetaDataFiles())
.pipe(nls.createAdditionalLanguageFiles(languages, "i18n"))
.pipe(nls.bundleMetaDataFiles('Zowe.vscode-extension-for-zowe', outDest))
.pipe(nls.bundleLanguageFiles())
.pipe(filter(['**/nls.bundle.*.json', '**/nls.metadata.header.json', '**/nls.metadata.json']))
.pipe(gulp.dest(outDest));
}

const vscePublishTask = function() {
return vsce.publish();
};
const localizationTask = gulp.series(cleanTask, generateLocalizationBundle, generateI18nTask);

const vscePackageTask = function() {
return vsce.createVSIX();
};
const buildTask = gulp.series(localizationTask);

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('localization', localizationTask);

gulp.task('package', gulp.series(buildTask, vscePackageTask));
gulp.task('build', buildTask);
4 changes: 0 additions & 4 deletions i18n/sample/src/generators/messages/items/dataset.i18n.json

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions i18n/sample/src/mvs/mvsNodeActions.i18n.json

This file was deleted.

9 changes: 6 additions & 3 deletions log4jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@
"layout": {
"type": "pattern",
"pattern": "[%d{yyyy/MM/dd} %d{hh:mm:ss.SSS}] [%p] %m"
}
},
"filename": "logs/imperative.log"
},
"imperative": {
"type": "fileSync",
"layout": {
"type": "pattern",
"pattern": "[%d{yyyy/MM/dd} %d{hh:mm:ss.SSS}] [%p] %m"
}
},
"filename":"logs/imperative.log"
},
"app": {
"type": "fileSync",
"layout": {
"type": "pattern",
"pattern": "[%d{yyyy/MM/dd} %d{hh:mm:ss.SSS}] [%p] %m"
}
},
"filename": "logs/zowe.log"
}
},
"categories": {
Expand Down
Loading

0 comments on commit 91c2fbc

Please sign in to comment.