1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add script to generate npm publish script

This commit is contained in:
Nick O'Leary 2019-10-14 15:50:48 +01:00
parent 07fe5b247b
commit e94634544c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 52 additions and 1 deletions

View File

@ -562,7 +562,20 @@ module.exports = function(grunt) {
return false;
}
});
grunt.registerTask('generatePublishScript',
'Generates a script to publish build output to npm',
function () {
const done = this.async();
const generatePublishScript = require("./scripts/generate-publish-script.js");
generatePublishScript().then(function(output) {
grunt.log.writeln(output);
const filePath = path.join(grunt.config.get('paths.dist'),"modules","publish.sh");
grunt.file.write(filePath,output);
done();
});
});
grunt.registerTask('setDevEnv',
'Sets NODE_ENV=development so non-minified assets are used',
function () {
@ -605,7 +618,7 @@ module.exports = function(grunt) {
grunt.registerTask('release',
'Create distribution zip file',
['build','verifyPackageDependencies','clean:release','mkdir:release','chmod:release','compress:release','pack-modules']);
['build','verifyPackageDependencies','clean:release','mkdir:release','chmod:release','compress:release','pack-modules','generatePublishScript']);
grunt.registerTask('pack-modules',
'Create module pack files for release',

View File

@ -0,0 +1,38 @@
#!/usr/bin/env node
const path = require("path");
const fs = require("fs-extra");
const should = require("should");
function generateScript() {
return new Promise((resolve, reject) => {
const packages = [
"node-red-util",
"node-red-runtime",
"node-red-registry",
"node-red-nodes",
"node-red-editor-client",
"node-red-editor-api",
"node-red"
];
const rootPackage = require(path.join(__dirname,"..","package.json"));
const version = rootPackage.version;
const tagArg = /-/.test(version) ? "--tag next" : ""
const lines = [];
packages.forEach(name => {
lines.push(`npm publish ${name}-${version}.tgz ${tagArg}\n`);
})
resolve(lines.join(""))
});
}
if (require.main === module) {
generateScript().then(output => {
console.log(output);
});
} else {
module.exports = generateScript;
}