mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 17:25:39 +01:00
Generate nightly version based on latest npm version
This commit is contained in:
parent
83f13054ad
commit
13a4caf0cd
1 changed files with 33 additions and 5 deletions
38
.github/workflows/nightly/setNightlyVersion.js
vendored
38
.github/workflows/nightly/setNightlyVersion.js
vendored
|
|
@ -6,6 +6,7 @@
|
||||||
//@ts-check
|
//@ts-check
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const cp = require('child_process');
|
||||||
|
|
||||||
if (process.argv.length !== 3) {
|
if (process.argv.length !== 3) {
|
||||||
console.error(`usage: node updateVersion.js <PATH_TO_PACKAGE_JSON_FILE>`);
|
console.error(`usage: node updateVersion.js <PATH_TO_PACKAGE_JSON_FILE>`);
|
||||||
|
|
@ -13,10 +14,37 @@ if (process.argv.length !== 3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const packagejson = JSON.parse(fs.readFileSync(process.argv[2]).toString());
|
const packagejson = JSON.parse(fs.readFileSync(process.argv[2]).toString());
|
||||||
|
const packageName = packagejson.name;
|
||||||
|
if (packageName !== 'monaco-editor' && packageName !== 'monaco-editor-core') {
|
||||||
|
console.error(`expected name to be 'monaco-editor' or 'monaco-editor-core'`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const date = new Date();
|
/** @type {string} */
|
||||||
packagejson.version += `-dev.${date.getUTCFullYear()}${String(date.getUTCMonth() + 1).padStart(
|
const latestVersion = (() => {
|
||||||
2,
|
const output = cp.execSync(`npm show ${packageName} version`).toString();
|
||||||
'0'
|
const version = output.split(/\r\n|\r|\n/g)[0];
|
||||||
)}${String(date.getUTCDate()).padStart(2, '0')}`;
|
if (!/\d+\.\d+\.\d+/.test(version)) {
|
||||||
|
console.log('unrecognized package.json version: ' + version);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (!/^0\.(\d+)\.(\d+)$/.test(latestVersion)) {
|
||||||
|
console.error(`version ${latestVersion} does not match 0.x.y`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const devVersion = (() => {
|
||||||
|
const pieces = latestVersion.split('.');
|
||||||
|
const minor = parseInt(pieces[1], 10);
|
||||||
|
const date = new Date();
|
||||||
|
const yyyy = date.getUTCFullYear();
|
||||||
|
const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
|
||||||
|
const dd = String(date.getUTCDate()).padStart(2, '0');
|
||||||
|
return `0.${minor + 1}.0-dev.${yyyy}${mm}${dd}`;
|
||||||
|
})();
|
||||||
|
|
||||||
|
packagejson.version = devVersion;
|
||||||
fs.writeFileSync(process.argv[2], JSON.stringify(packagejson, null, '\t') + '\n');
|
fs.writeFileSync(process.argv[2], JSON.stringify(packagejson, null, '\t') + '\n');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue