@@ -19,7 +19,19 @@ interface IPackageInfo {
1919
2020async function copyPackage ( packageFiles : IPackageInfo , destPath : string ) : Promise < void > {
2121 for ( const file of packageFiles . files ) {
22- await fs . copy ( path . resolve ( packageFiles . sourcePath , file ) , path . resolve ( destPath , file ) ) ;
22+ const sourceFilePath = path . resolve ( packageFiles . sourcePath , file ) ;
23+ const destFilePath = path . resolve ( destPath , file ) ;
24+ if ( packageFiles . isRoot && ( file === 'package.json' ) ) {
25+ // For non-release builds, we tweak the version number of the extension to add a prerelease
26+ // suffix. Rather than just copying `package.json`, we'll parse the original copy, update the
27+ // `version` property, and write it out to the new location.
28+ const packageJson = jsonc . parse ( ( await fs . readFile ( sourceFilePath ) ) . toString ( ) ) ;
29+ packageJson . version = packageFiles . version ;
30+ await fs . writeFile ( destFilePath , JSON . stringify ( packageJson ) ) ;
31+ }
32+ else {
33+ await fs . copy ( sourceFilePath , destFilePath ) ;
34+ }
2335 }
2436}
2537
@@ -142,14 +154,17 @@ export async function deployPackage(packageJsonPath: string): Promise<DeployedPa
142154
143155 if ( isDevBuild ) {
144156 // NOTE: rootPackage.name had better not have any regex metacharacters
145- const oldDevBuildPattern = new RegExp ( '^' + rootPackage . name + '[^/]+-dev\\d+ .vsix$' ) ;
157+ const oldDevBuildPattern = new RegExp ( '^' + rootPackage . name + '[^/]+-dev[0-9.]+\\ .vsix$' ) ;
146158 // Dev package filenames are of the form
147- // vscode-codeql-0.0.1-dev20190927195520723 .vsix
148- fs . readdirSync ( distDir ) . filter ( name => name . match ( oldDevBuildPattern ) ) . map ( build => {
159+ // vscode-codeql-0.0.1-dev.2019.9.27.19.55.20 .vsix
160+ ( await fs . readdir ( distDir ) ) . filter ( name => name . match ( oldDevBuildPattern ) ) . map ( build => {
149161 console . log ( `Deleting old dev build ${ build } ...` ) ;
150162 fs . unlinkSync ( path . join ( distDir , build ) ) ;
151163 } ) ;
152- rootPackage . version = rootPackage . version + '-dev' + new Date ( ) . toISOString ( ) . replace ( / [ ^ 0 - 9 ] / g, '' ) ;
164+ const now = new Date ( ) ;
165+ rootPackage . version = rootPackage . version +
166+ `-dev.${ now . getUTCFullYear ( ) } .${ now . getUTCMonth ( ) + 1 } .${ now . getUTCDate ( ) } ` +
167+ `.${ now . getUTCHours ( ) } .${ now . getUTCMinutes ( ) } .${ now . getUTCSeconds ( ) } ` ;
153168 }
154169
155170 const distPath = path . join ( distDir , rootPackage . name ) ;
0 commit comments