Skip to content

Commit 1dffeb9

Browse files
authored
Merge pull request #167 from dbartol/dbartol/version
A few versioning fixes
2 parents d29f749 + 27c171c commit 1dffeb9

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

extensions/ql-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "CodeQL for Visual Studio Code",
55
"author": "GitHub",
66
"private": true,
7-
"version": "1.0.0",
7+
"version": "1.0.1",
88
"publisher": "GitHub",
99
"license": "MIT",
1010
"icon": "media/VS-marketplace-CodeQL-icon.png",

tools/build-tasks/src/deploy.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ interface IPackageInfo {
1919

2020
async 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

Comments
 (0)