forked from remix-run/remix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.js
78 lines (68 loc) · 1.92 KB
/
publish.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const path = require("node:path");
const { execSync } = require("node:child_process");
const semver = require("semver");
const buildDir = path.resolve(__dirname, "../build/node_modules");
const packageDir = path.resolve(__dirname, "../packages");
function getTaggedVersion() {
let output = execSync("git tag --list --points-at HEAD").toString().trim();
return output.replace(/^v/g, "");
}
/**
* @param {string} dir
* @param {string} tag
*/
function publish(dir, tag) {
execSync(`npm publish --access public --tag ${tag} ${dir}`, {
stdio: "inherit",
});
}
async function run() {
// Make sure there's a current tag
let taggedVersion = getTaggedVersion();
if (taggedVersion === "") {
console.error("Missing release version. Run the version script first.");
process.exit(1);
}
let prerelease = semver.prerelease(taggedVersion);
let prereleaseTag = prerelease ? String(prerelease[0]) : undefined;
let tag = prereleaseTag
? prereleaseTag.includes("nightly")
? "nightly"
: prereleaseTag.includes("experimental")
? "experimental"
: prereleaseTag
: "latest";
// Publish eslint config directly from the package directory
publish(path.join(packageDir, "remix-eslint-config"), tag);
// Publish all @remix-run/* packages
for (let name of [
"dev",
"server-runtime", // publish before platforms
"cloudflare",
"cloudflare-pages",
"cloudflare-workers",
"deno",
"node", // publish node before node servers
"architect",
"express", // publish express before serve
"react",
"serve",
"css-bundle",
"testing",
]) {
publish(path.join(buildDir, "@remix-run", name), tag);
}
// Publish create-remix
publish(path.join(buildDir, "create-remix"), tag);
// Publish remix package
publish(path.join(buildDir, "remix"), tag);
}
run().then(
() => {
process.exit(0);
},
(error) => {
console.error(error);
process.exit(1);
}
);