generated from meshery/meshery
-
Notifications
You must be signed in to change notification settings - Fork 29
/
publish-npm-package.js
47 lines (42 loc) · 1.08 KB
/
publish-npm-package.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const fs = require("fs");
const path = require("path");
// for building and release the package
// bump version
const bump = (version) => {
const packagePath = path.resolve(__dirname, "package.json");
const package = require(packagePath);
package.version = version;
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2));
console.log("bumped version to " + version);
};
// build
const build = () => {
const execSync = require("child_process").execSync;
execSync("npm run build ", { stdio: [0, 1, 2] });
console.log("built typscript files");
};
const publish = () => {
// publish to npm
const execSync = require("child_process").execSync;
execSync("npm publish --verbose", { stdio: [0, 1, 2] });
console.log("published to npm");
};
// main
const main = () => {
const args = process.argv.slice(2);
const version = args[0];
if (!version) {
console.error("version is required");
process.exit(1);
}
try {
bump(version);
build();
publish();
console.log("done");
} catch (e) {
console.error(e);
process.exit(1);
}
};
main();