2019-10-14 16:50:48 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const path = require("path");
|
|
|
|
const fs = require("fs-extra");
|
|
|
|
const should = require("should");
|
|
|
|
|
2022-08-04 15:08:04 +02:00
|
|
|
const LATEST = "3";
|
2021-07-30 14:19:36 +02:00
|
|
|
|
2019-10-14 16:50:48 +02:00
|
|
|
function generateScript() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const packages = [
|
2021-10-25 11:05:23 +02:00
|
|
|
"@node-red/util",
|
|
|
|
"@node-red/runtime",
|
|
|
|
"@node-red/registry",
|
|
|
|
"@node-red/nodes",
|
|
|
|
"@node-red/editor-client",
|
|
|
|
"@node-red/editor-api",
|
2019-10-14 16:50:48 +02:00
|
|
|
"node-red"
|
|
|
|
];
|
|
|
|
const rootPackage = require(path.join(__dirname,"..","package.json"));
|
|
|
|
const version = rootPackage.version;
|
|
|
|
|
2021-07-30 14:19:36 +02:00
|
|
|
const versionParts = version.split(".");
|
2021-10-25 11:05:23 +02:00
|
|
|
let updateNextToLatest = false;
|
2021-07-30 14:19:36 +02:00
|
|
|
let tagArg = "";
|
|
|
|
if (versionParts[0] !== LATEST) {
|
|
|
|
tagArg = `--tag v${versionParts[0]}-maintenance`
|
|
|
|
} else if (/-/.test(version)) {
|
|
|
|
tagArg = "--tag next"
|
2021-10-25 11:05:23 +02:00
|
|
|
} else {
|
|
|
|
updateNextToLatest = true;
|
2021-07-30 14:19:36 +02:00
|
|
|
}
|
2019-10-14 16:50:48 +02:00
|
|
|
|
|
|
|
const lines = [];
|
|
|
|
|
|
|
|
packages.forEach(name => {
|
2021-10-25 11:05:23 +02:00
|
|
|
const tarName = name.replace(/@/,"").replace(/\//,"-")
|
|
|
|
lines.push(`npm publish ${tarName}-${version}.tgz ${tagArg}\n`);
|
|
|
|
if (updateNextToLatest) {
|
|
|
|
lines.push(`npm dist-tag add ${name}@${version} next\n`);
|
|
|
|
}
|
2019-10-14 16:50:48 +02:00
|
|
|
})
|
|
|
|
resolve(lines.join(""))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (require.main === module) {
|
|
|
|
generateScript().then(output => {
|
|
|
|
console.log(output);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
module.exports = generateScript;
|
|
|
|
}
|