Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-protocol/scripts/publish.js
2498 views
1
/**
2
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
// @ts-check
8
9
const fs = require("fs");
10
const path = require("path");
11
const child_process = require("child_process");
12
const qualifier = process.argv[2];
13
14
const rootDir = process.cwd();
15
const pckDir = path.join(rootDir, process.argv[3]);
16
17
if (process.env.DO_PUBLISH === "false") {
18
console.warn("Skipping publishing per request.");
19
process.exit(0);
20
}
21
22
if (process.env.NPM_AUTH_TOKEN) {
23
fs.writeFileSync(
24
path.join(pckDir, ".npmrc"),
25
`//registry.npmjs.org/:_authToken=${process.env.NPM_AUTH_TOKEN}\n`,
26
"utf-8",
27
);
28
} else {
29
console.warn("NPM_AUTH_TOKEN env variable is not set");
30
}
31
32
const pck = JSON.parse(fs.readFileSync(path.join(pckDir, "package.json"), "utf-8"));
33
pck.version = `${pck.version}-${qualifier}`;
34
fs.writeFileSync(path.join(pckDir, "package.json"), JSON.stringify(pck, undefined, 2), "utf-8");
35
36
const tag = qualifier.substr(0, qualifier.lastIndexOf("."));
37
38
child_process.execSync(
39
[
40
"yarn",
41
"--cwd",
42
pckDir,
43
"publish",
44
"--tag",
45
tag,
46
"--access",
47
"public",
48
"--ignore-scripts",
49
"--network-timeout",
50
"300000",
51
].join(" "),
52
{ stdio: "inherit" },
53
);
54
55