Skip to content

Commit 822b565

Browse files
author
Dave Bartolomeo
committed
A few versioning fixes
- Bumps the version of the extension to 1.0.1. We should bump the version immediately after every official release, so that any builds that happen after the release are treated as prerelease versions of the next release. - Separates the components of the timestamp in the version number for non-release builds. This just makes it easier to read. I also left off the milliseconds, which were kind of overkill, and switched to using UTC time to avoid time-zone ambiguity. - Updates the version number in the copy of the extension's `package.json` that winds up in the actual .vsix, so VS Code actually sees the version as being the proper prelease version.
1 parent f1e44ef commit 822b565

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)