@@ -104,7 +104,6 @@ const optimizeVSCodeTask = util.task.series(
104104 } )
105105) ;
106106optimizeVSCodeTask . displayName = 'optimize-vscode' ;
107- gulp . task ( optimizeVSCodeTask . displayName , optimizeVSCodeTask ) ;
108107
109108
110109const optimizeIndexJSTask = util . task . series (
@@ -492,30 +491,40 @@ const apiHostname = process.env.TRANSIFEX_API_URL;
492491const apiName = process . env . TRANSIFEX_API_NAME ;
493492const apiToken = process . env . TRANSIFEX_API_TOKEN ;
494493
495- gulp . task ( 'vscode-translations-push' , [ 'optimize-vscode' ] , function ( ) {
496- const pathToMetadata = './out-vscode/nls.metadata.json' ;
497- const pathToExtensions = './extensions/*' ;
498- const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}' ;
499-
500- return es . merge (
501- gulp . src ( pathToMetadata ) . pipe ( i18n . createXlfFilesForCoreBundle ( ) ) ,
502- gulp . src ( pathToSetup ) . pipe ( i18n . createXlfFilesForIsl ( ) ) ,
503- gulp . src ( pathToExtensions ) . pipe ( i18n . createXlfFilesForExtensions ( ) )
504- ) . pipe ( i18n . findObsoleteResources ( apiHostname , apiName , apiToken )
505- ) . pipe ( i18n . pushXlfFiles ( apiHostname , apiName , apiToken ) ) ;
506- } ) ;
507-
508- gulp . task ( 'vscode-translations-export' , [ 'optimize-vscode' ] , function ( ) {
509- const pathToMetadata = './out-vscode/nls.metadata.json' ;
510- const pathToExtensions = './extensions/*' ;
511- const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}' ;
494+ gulp . task ( 'vscode-translations-push' ,
495+ util . task . series (
496+ optimizeVSCodeTask ,
497+ function ( ) {
498+ const pathToMetadata = './out-vscode/nls.metadata.json' ;
499+ const pathToExtensions = './extensions/*' ;
500+ const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}' ;
501+
502+ return es . merge (
503+ gulp . src ( pathToMetadata ) . pipe ( i18n . createXlfFilesForCoreBundle ( ) ) ,
504+ gulp . src ( pathToSetup ) . pipe ( i18n . createXlfFilesForIsl ( ) ) ,
505+ gulp . src ( pathToExtensions ) . pipe ( i18n . createXlfFilesForExtensions ( ) )
506+ ) . pipe ( i18n . findObsoleteResources ( apiHostname , apiName , apiToken )
507+ ) . pipe ( i18n . pushXlfFiles ( apiHostname , apiName , apiToken ) ) ;
508+ }
509+ )
510+ ) ;
512511
513- return es . merge (
514- gulp . src ( pathToMetadata ) . pipe ( i18n . createXlfFilesForCoreBundle ( ) ) ,
515- gulp . src ( pathToSetup ) . pipe ( i18n . createXlfFilesForIsl ( ) ) ,
516- gulp . src ( pathToExtensions ) . pipe ( i18n . createXlfFilesForExtensions ( ) )
517- ) . pipe ( vfs . dest ( '../vscode-translations-export' ) ) ;
518- } ) ;
512+ gulp . task ( 'vscode-translations-export' ,
513+ util . task . series (
514+ optimizeVSCodeTask ,
515+ function ( ) {
516+ const pathToMetadata = './out-vscode/nls.metadata.json' ;
517+ const pathToExtensions = './extensions/*' ;
518+ const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}' ;
519+
520+ return es . merge (
521+ gulp . src ( pathToMetadata ) . pipe ( i18n . createXlfFilesForCoreBundle ( ) ) ,
522+ gulp . src ( pathToSetup ) . pipe ( i18n . createXlfFilesForIsl ( ) ) ,
523+ gulp . src ( pathToExtensions ) . pipe ( i18n . createXlfFilesForExtensions ( ) )
524+ ) . pipe ( vfs . dest ( '../vscode-translations-export' ) ) ;
525+ }
526+ )
527+ ) ;
519528
520529gulp . task ( 'vscode-translations-pull' , function ( ) {
521530 return es . merge ( [ ...i18n . defaultLanguages , ...i18n . extraLanguages ] . map ( language => {
@@ -565,57 +574,8 @@ gulp.task('upload-vscode-sourcemaps', () => {
565574 } ) ) ;
566575} ) ;
567576
568- const allConfigDetailsPath = path . join ( os . tmpdir ( ) , 'configuration.json' ) ;
569- gulp . task ( 'upload-vscode-configuration' , [ 'generate-vscode-configuration' ] , ( ) => {
570- if ( ! shouldSetupSettingsSearch ( ) ) {
571- const branch = process . env . BUILD_SOURCEBRANCH ;
572- console . log ( `Only runs on master and release branches, not ${ branch } ` ) ;
573- return ;
574- }
575-
576- if ( ! fs . existsSync ( allConfigDetailsPath ) ) {
577- throw new Error ( `configuration file at ${ allConfigDetailsPath } does not exist` ) ;
578- }
579-
580- const settingsSearchBuildId = getSettingsSearchBuildId ( packageJson ) ;
581- if ( ! settingsSearchBuildId ) {
582- throw new Error ( 'Failed to compute build number' ) ;
583- }
584-
585- return gulp . src ( allConfigDetailsPath )
586- . pipe ( azure . upload ( {
587- account : process . env . AZURE_STORAGE_ACCOUNT ,
588- key : process . env . AZURE_STORAGE_ACCESS_KEY ,
589- container : 'configuration' ,
590- prefix : `${ settingsSearchBuildId } /${ commit } /`
591- } ) ) ;
592- } ) ;
593-
594- function shouldSetupSettingsSearch ( ) {
595- const branch = process . env . BUILD_SOURCEBRANCH ;
596- return branch && ( / \/ m a s t e r $ / . test ( branch ) || branch . indexOf ( '/release/' ) >= 0 ) ;
597- }
598-
599- function getSettingsSearchBuildId ( packageJson ) {
600- try {
601- const branch = process . env . BUILD_SOURCEBRANCH ;
602- const branchId = branch . indexOf ( '/release/' ) >= 0 ? 0 :
603- / \/ m a s t e r $ / . test ( branch ) ? 1 :
604- 2 ; // Some unexpected branch
605-
606- const out = cp . execSync ( `git rev-list HEAD --count` ) ;
607- const count = parseInt ( out . toString ( ) ) ;
608-
609- // <version number><commit count><branchId (avoid unlikely conflicts)>
610- // 1.25.1, 1,234,567 commits, master = 1250112345671
611- return util . versionStringToNumber ( packageJson . version ) * 1e8 + count * 10 + branchId ;
612- } catch ( e ) {
613- throw new Error ( 'Could not determine build number: ' + e . toString ( ) ) ;
614- }
615- }
616-
617577// This task is only run for the MacOS build
618- gulp . task ( 'generate-vscode-configuration' , ( ) => {
578+ const generateVSCodeConfigurationTask = ( ) => {
619579 return new Promise ( ( resolve , reject ) => {
620580 const buildDir = process . env [ 'AGENT_BUILDDIRECTORY' ] ;
621581 if ( ! buildDir ) {
@@ -650,4 +610,60 @@ gulp.task('generate-vscode-configuration', () => {
650610 reject ( err ) ;
651611 } ) ;
652612 } ) ;
653- } ) ;
613+ } ;
614+ generateVSCodeConfigurationTask . displayName = 'generate-vscode-configuration' ;
615+
616+ const allConfigDetailsPath = path . join ( os . tmpdir ( ) , 'configuration.json' ) ;
617+ gulp . task ( 'upload-vscode-configuration' ,
618+ util . task . series (
619+ generateVSCodeConfigurationTask ,
620+ ( ) => {
621+ if ( ! shouldSetupSettingsSearch ( ) ) {
622+ const branch = process . env . BUILD_SOURCEBRANCH ;
623+ console . log ( `Only runs on master and release branches, not ${ branch } ` ) ;
624+ return ;
625+ }
626+
627+ if ( ! fs . existsSync ( allConfigDetailsPath ) ) {
628+ throw new Error ( `configuration file at ${ allConfigDetailsPath } does not exist` ) ;
629+ }
630+
631+ const settingsSearchBuildId = getSettingsSearchBuildId ( packageJson ) ;
632+ if ( ! settingsSearchBuildId ) {
633+ throw new Error ( 'Failed to compute build number' ) ;
634+ }
635+
636+ return gulp . src ( allConfigDetailsPath )
637+ . pipe ( azure . upload ( {
638+ account : process . env . AZURE_STORAGE_ACCOUNT ,
639+ key : process . env . AZURE_STORAGE_ACCESS_KEY ,
640+ container : 'configuration' ,
641+ prefix : `${ settingsSearchBuildId } /${ commit } /`
642+ } ) ) ;
643+ }
644+ )
645+ ) ;
646+
647+ function shouldSetupSettingsSearch ( ) {
648+ const branch = process . env . BUILD_SOURCEBRANCH ;
649+ return branch && ( / \/ m a s t e r $ / . test ( branch ) || branch . indexOf ( '/release/' ) >= 0 ) ;
650+ }
651+
652+ function getSettingsSearchBuildId ( packageJson ) {
653+ try {
654+ const branch = process . env . BUILD_SOURCEBRANCH ;
655+ const branchId = branch . indexOf ( '/release/' ) >= 0 ? 0 :
656+ / \/ m a s t e r $ / . test ( branch ) ? 1 :
657+ 2 ; // Some unexpected branch
658+
659+ const out = cp . execSync ( `git rev-list HEAD --count` ) ;
660+ const count = parseInt ( out . toString ( ) ) ;
661+
662+ // <version number><commit count><branchId (avoid unlikely conflicts)>
663+ // 1.25.1, 1,234,567 commits, master = 1250112345671
664+ return util . versionStringToNumber ( packageJson . version ) * 1e8 + count * 10 + branchId ;
665+ } catch ( e ) {
666+ throw new Error ( 'Could not determine build number: ' + e . toString ( ) ) ;
667+ }
668+ }
669+
0 commit comments