-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.js
65 lines (62 loc) · 1.88 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
import * as fs_ from "node:fs/promises";
// import * as pacote_ from "pacote";
// import * as arborist_ from "@npmcli/arborist";
// import * as libNpmPublish_ from "libnpmpublish";
import * as path_ from "node:path";
const packageJson = JSON.parse(
await fs_.readFile("./package.json", { encoding: "utf-8" })
);
const packagePath = path_.resolve(process.cwd(), "./packages/@reflame/cli");
await fs_.mkdir(packagePath, { recursive: true });
// await fs_.mkdir("./packages/reflame-cli", { recursive: true });
await Promise.all([
fs_.cp("./build/deps.mjs", `${packagePath}/deps.mjs`),
fs_.cp("./README.md", `${packagePath}/README.md`),
fs_
.readFile("./build/entry.mjs", { encoding: "utf-8" })
.then((code) =>
fs_.writeFile(`${packagePath}/entry.mjs`, `#!/usr/bin/env node\n${code}`)
),
fs_.writeFile(
`${packagePath}/package.json`,
JSON.stringify(
{
name: packageJson.name,
version: packageJson.version,
bin: {
reflame: "./entry.mjs",
cli: "./entry.mjs",
},
repository: packageJson.repository,
},
undefined,
" "
)
),
]);
// const manifest = await pacote_.manifest(packagePath);
// const tarData = await pacote_.tarball(packagePath, {
// Arborist: arborist_.Arborist,
// });
// try {
// await libNpmPublish_.publish(manifest, tarData, {
// npmVersion: `${packageJson.name}@${packageJson.version}`,
// forceAuth: {
// token: process.env.NPM_TOKEN,
// },
// // Seems to be erroring in Bun...
// provenance: true,
// access: "public",
// });
// console.log(`Published ${packageJson.version}`);
// } catch (error) {
// if (
// error.message.endsWith(
// `You cannot publish over the previously published versions: ${packageJson.version}.`
// )
// ) {
// console.log(`Skipped ${packageJson.version}`);
// } else {
// throw error;
// }
// }