Skip to content

Commit 7c9bcf7

Browse files
Using new vscode-engineering feature to abstract away gulp (#19063)
* try new format * remove nls gulp stuff * back on main * maybe use ../../ * try this * try setting to where bundles are * try new locBundleDestination * try another * try just src * try * try root dir
1 parent d6e1563 commit 7c9bcf7

6 files changed

+13
-823
lines changed

build/azure-pipeline.pre-release.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,14 @@ resources:
1515
- repository: templates
1616
type: github
1717
name: microsoft/vscode-engineering
18-
ref: main
18+
ref: tyler/allow-bundle-destination
1919
endpoint: Monaco
2020

2121
extends:
2222
template: azure-pipelines/extension/pre-release.yml@templates
2323
parameters:
24-
locPushSteps:
25-
- script: npm ci
26-
displayName: Install NPM dependencies
27-
- script: npm run translations-export
28-
displayName: Run translations-export
29-
- pwsh: Move-Item "$(Pipeline.Workspace)/ms-python.python/*" "$(SetTranslationsPath.EnglishStrings)" -Force
30-
displayName: Move vscode-python-translations-export to translations path
31-
32-
locPullSteps:
33-
- script: npm ci
34-
displayName: Install NPM dependencies
35-
- script: gulp translations-import --location "$(SetTranslationsPath.TranslatedStrings)"
36-
displayName: Run translations-import
37-
- script: gulp translations-generate
38-
displayName: Generate translations
39-
24+
locTsConfigs: $(Build.SourcesDirectory)/tsconfig.json
25+
locBundleDestination: $(Build.SourcesDirectory)/out/client
4026
buildSteps:
4127
- task: NodeTool@0
4228
inputs:

build/azure-pipeline.stable.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,7 @@ extends:
2525
parameters:
2626
publishExtension: ${{ parameters.publishExtension }}
2727

28-
locPushSteps:
29-
- script: npm ci
30-
displayName: Install NPM dependencies
31-
- script: npm run translations-export
32-
displayName: Run translations-export
33-
- pwsh: Move-Item "$(Pipeline.Workspace)/ms-python.python/*" "$(SetTranslationsPath.EnglishStrings)" -Force
34-
displayName: Move vscode-python-translations-export to translations path
35-
36-
locPullSteps:
37-
- script: npm ci
38-
displayName: Install NPM dependencies
39-
- script: gulp translations-import --location "$(SetTranslationsPath.TranslatedStrings)"
40-
displayName: Run translations-import
41-
- script: gulp translations-generate
42-
displayName: Generate translations
28+
locTsConfigs: $(Build.SourcesDirectory)/tsconfig.json
4329

4430
buildSteps:
4531
- task: NodeTool@0

build/webpack/webpack.extension.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const config = {
2929
{
3030
loader: 'vscode-nls-dev/lib/webpack-loader',
3131
options: {
32-
// points to where the entrypoint is (the extension.ts)
33-
base: path.join(__dirname, '../../src/client'),
32+
base: constants.ExtensionRootDir,
3433
},
3534
},
3635
{

gulpfile.js

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@ const flat = require('flat');
2121
const { argv } = require('yargs');
2222
const os = require('os');
2323
const rmrf = require('rimraf');
24-
const nls = require('vscode-nls-dev');
25-
const sourcemaps = require('gulp-sourcemaps');
2624
const typescript = require('typescript');
27-
const es = require('event-stream');
28-
const minimist = require('minimist');
2925

3026
const tsProject = ts.createProject('./tsconfig.json', { typescript });
31-
const filter = require('gulp-filter');
3227

3328
const isCI = process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined;
3429

@@ -360,122 +355,3 @@ function hasNativeDependencies() {
360355
}
361356
return false;
362357
}
363-
364-
const translationProjectName = 'ms-python.python';
365-
const translationExtensionName = 'vscode-python';
366-
367-
const defaultLanguages = [
368-
{ id: 'de', folderName: 'de' },
369-
{ id: 'fr', folderName: 'fr' },
370-
{ id: 'es', folderName: 'es' },
371-
{ id: 'cs', folderName: 'cs' },
372-
{ id: 'it', folderName: 'it' },
373-
{ id: 'ja', folderName: 'ja' },
374-
{ id: 'ko', folderName: 'ko' },
375-
{ id: 'pl', folderName: 'pl' },
376-
{ id: 'pt-BR', folderName: 'pt-br' },
377-
{ id: 'ru', folderName: 'ru' },
378-
{ id: 'tr', folderName: 'tr' },
379-
{ id: 'zh-Hans', folderName: 'zh-Hans' },
380-
{ id: 'zh-Hant', folderName: 'zh-Hant' },
381-
{ id: 'qps-ploc', folderName: 'qps-ploc' },
382-
];
383-
384-
// You can find a more complex implementation of the translations in the CPP Extension repository.
385-
// See: https://github.com/microsoft/vscode-cpptools/blob/main/Extension/gulpfile.js#L76
386-
387-
// ****************************
388-
// Command: translations-generate
389-
// The following is used to import an i18n directory structure and generate files used at runtime.
390-
// ****************************
391-
392-
// Generate package.nls.*.json files from: ./i18n/*/package.i18n.json
393-
// Outputs to root path, as these nls files need to be along side package.json
394-
395-
const generateAdditionalLocFiles = () =>
396-
gulp
397-
.src(['package.nls.json'])
398-
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n'))
399-
.pipe(gulp.dest('.'));
400-
401-
// Generates ./out/nls.bundle.<language_id>.json from files in ./i18n/** *//<src_path>/<filename>.i18n.json
402-
// Localized strings are read from these files at runtime.
403-
const generateSrcLocBundle = () =>
404-
// Transpile the TS to JS, and let vscode-nls-dev scan the files for calls to localize.
405-
tsProject
406-
.src()
407-
.pipe(sourcemaps.init())
408-
.pipe(tsProject())
409-
.js.pipe(nls.createMetaDataFiles())
410-
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n'))
411-
.pipe(nls.bundleMetaDataFiles('ms-vscode.python', 'out'))
412-
.pipe(nls.bundleLanguageFiles())
413-
.pipe(filter(['**/nls.bundle.*.json', '**/nls.metadata.header.json', '**/nls.metadata.json']))
414-
.pipe(gulp.dest('out'));
415-
416-
gulp.task('translations-generate', gulp.series(generateSrcLocBundle, generateAdditionalLocFiles));
417-
418-
// ****************************
419-
// Command: translations-export
420-
// The following is used to export and XLF file containing english strings for translations.
421-
// The result will be written to: ../vscode-extensions-localization-export/ms-vscode/
422-
// ****************************
423-
const exportTranslations = (done) => {
424-
const jsStream = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject()).js.pipe(nls.createMetaDataFiles());
425-
426-
// Merge files from all source streams
427-
jsStream
428-
429-
// Filter down to only the files we need
430-
.pipe(filter(['**/*.nls.json', '**/*.nls.metadata.json']))
431-
432-
// Consoldate them into nls.metadata.json, which the xlf is built from.
433-
.pipe(nls.bundleMetaDataFiles('ms-vscode.python', '.'))
434-
435-
// filter down to just the resulting metadata files
436-
.pipe(filter(['**/nls.metadata.header.json', '**/nls.metadata.json']))
437-
438-
// Add package.nls.json, used to localized package.json
439-
.pipe(gulp.src(['package.nls.json']))
440-
441-
// package.nls.json and nls.metadata.json are used to generate the xlf file
442-
// Does not re-queue any files to the stream. Outputs only the XLF file
443-
.pipe(nls.createXlfFiles(translationProjectName, translationExtensionName))
444-
.pipe(gulp.dest('../'))
445-
.pipe(
446-
es.wait(() => {
447-
done();
448-
}),
449-
);
450-
};
451-
452-
gulp.task('translations-export', exportTranslations);
453-
454-
// ****************************
455-
// Command: translations-import
456-
// The following is used to import an XLF file containing all language strings.
457-
// This results in a i18n directory, which should be checked in.
458-
// ****************************
459-
460-
// Imports translations from raw localized MLCP strings to VS Code .i18n.json files
461-
gulp.task('translations-import', (done) => {
462-
const options = minimist(process.argv.slice(2), {
463-
string: 'location',
464-
default: {
465-
location: '../vscode-translations-import',
466-
},
467-
});
468-
es.merge(
469-
defaultLanguages.map((language) => {
470-
const id = language.transifexId || language.id;
471-
return gulp
472-
.src(path.join(options.location, id, `${translationExtensionName}.xlf`))
473-
.pipe(nls.prepareJsonFiles())
474-
.pipe(gulp.dest(path.join('./i18n', language.folderName)));
475-
}),
476-
).pipe(
477-
es.wait(() => {
478-
done();
479-
}),
480-
);
481-
});

0 commit comments

Comments
 (0)