pkg-pr-new 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +996 -8413
- package/index.ts +33 -10
- package/package.json +4 -3
package/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Octokit } from "@octokit/action";
|
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
10
|
import { getPackageManifest } from "query-registry";
|
|
11
11
|
import { extractOwnerAndRepo, extractRepository } from "@pkg-pr-new/utils";
|
|
12
|
+
import fg from "fast-glob";
|
|
12
13
|
import "./environments";
|
|
13
14
|
import pkg from "./package.json" with { type: "json" };
|
|
14
15
|
|
|
@@ -35,6 +36,19 @@ const {
|
|
|
35
36
|
|
|
36
37
|
const [owner, repo] = GITHUB_REPOSITORY.split("/");
|
|
37
38
|
|
|
39
|
+
const checkResponse = await fetch(new URL("/check", API_URL), {
|
|
40
|
+
method: "POST",
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
owner,
|
|
43
|
+
repo,
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!checkResponse.ok) {
|
|
48
|
+
console.log(await checkResponse.text());
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
38
52
|
const commit = await octokit.git.getCommit({
|
|
39
53
|
owner,
|
|
40
54
|
repo,
|
|
@@ -73,9 +87,9 @@ const main = defineCommand({
|
|
|
73
87
|
run: async ({ args }) => {
|
|
74
88
|
const compact = !!args.compact;
|
|
75
89
|
|
|
76
|
-
const paths = (args._.length ? args._ : ["."])
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
const paths = (args._.length ? args._ : ["."])
|
|
91
|
+
.flatMap((p) => (fg.isDynamicPattern(p) ? fg.sync(p) : p))
|
|
92
|
+
.map((p) => path.resolve(p));
|
|
79
93
|
|
|
80
94
|
const deps: Map<string, string> = new Map();
|
|
81
95
|
const pJsonContent: Map<string, string> = new Map();
|
|
@@ -106,19 +120,27 @@ const main = defineCommand({
|
|
|
106
120
|
await fs.writeFile(pJsonPath, JSON.stringify(pJson));
|
|
107
121
|
}
|
|
108
122
|
const formData = new FormData();
|
|
123
|
+
const shasums: Record<string, string> = {};
|
|
109
124
|
for (const p of paths) {
|
|
110
125
|
const pJsonPath = path.resolve(p, "package.json");
|
|
111
126
|
try {
|
|
112
|
-
const { name
|
|
113
|
-
await ezSpawn.async("npm pack", {
|
|
127
|
+
const { name } = await importPackageJson(pJsonPath);
|
|
128
|
+
const { stdout } = await ezSpawn.async("npm pack --json", {
|
|
129
|
+
stdio: "overlapped",
|
|
130
|
+
cwd: p,
|
|
131
|
+
});
|
|
132
|
+
const { filename, shasum }: { filename: string; shasum: string } =
|
|
133
|
+
JSON.parse(stdout)[0];
|
|
134
|
+
|
|
135
|
+
shasums[name] = shasum;
|
|
136
|
+
console.log(`shasum for ${name}(${filename}): ${shasum}`);
|
|
114
137
|
|
|
115
|
-
const
|
|
116
|
-
const file = await fs.readFile(path.resolve(p, fileName));
|
|
138
|
+
const file = await fs.readFile(path.resolve(p, filename));
|
|
117
139
|
|
|
118
140
|
const blob = new Blob([file], {
|
|
119
141
|
type: "application/octet-stream",
|
|
120
142
|
});
|
|
121
|
-
formData.append(name, blob,
|
|
143
|
+
formData.append(name, blob, filename);
|
|
122
144
|
} finally {
|
|
123
145
|
await fs.writeFile(pJsonPath, pJsonContent.get(pJsonPath)!);
|
|
124
146
|
}
|
|
@@ -129,6 +151,7 @@ const main = defineCommand({
|
|
|
129
151
|
headers: {
|
|
130
152
|
"sb-compact": `${compact}`,
|
|
131
153
|
"sb-key": key,
|
|
154
|
+
"sb-shasums": JSON.stringify(shasums),
|
|
132
155
|
"sb-commit-timestamp": commitTimestamp.toString(),
|
|
133
156
|
},
|
|
134
157
|
body: formData,
|
|
@@ -140,9 +163,9 @@ const main = defineCommand({
|
|
|
140
163
|
`publishing failed: ${await res.text()}`,
|
|
141
164
|
);
|
|
142
165
|
|
|
166
|
+
console.log("\n");
|
|
143
167
|
console.log(
|
|
144
|
-
`⚡️ Your npm packages are published.
|
|
145
|
-
${[...formData.keys()].map((name, i) => `${name}: \`npm i ${laterRes.urls[i]}\``).join("\n")}`,
|
|
168
|
+
`⚡️ Your npm packages are published.\n${[...formData.keys()].map((name, i) => `${name}: \`npm i ${laterRes.urls[i]}\``).join("\n")}`,
|
|
146
169
|
);
|
|
147
170
|
},
|
|
148
171
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pkg-pr-new",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@jsdevtools/ez-spawn": "^3.0.4",
|
|
20
|
-
"
|
|
20
|
+
"fast-glob": "^3.3.2",
|
|
21
|
+
"query-registry": "^3.0.0",
|
|
22
|
+
"@octokit/action": "^6.1.0"
|
|
21
23
|
},
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@pkg-pr-new/utils": "workspace:^",
|
|
24
26
|
"citty": "^0.1.6",
|
|
25
|
-
"query-registry": "^3.0.0",
|
|
26
27
|
"tsup": "^8.0.2"
|
|
27
28
|
}
|
|
28
29
|
}
|