pkg-pr-new 0.0.9 → 0.0.10
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 +48 -6
- package/index.ts +48 -3
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -61,7 +61,7 @@ const main = defineCommand({
|
|
|
61
61
|
run: async ({ args }) => {
|
|
62
62
|
const paths = (args._.length ? args._ : ["."])
|
|
63
63
|
.flatMap((p) => (fg.isDynamicPattern(p) ? fg.sync(p) : p))
|
|
64
|
-
.map((p) => path.resolve(p));
|
|
64
|
+
.map((p) => path.resolve(p.trim()));
|
|
65
65
|
|
|
66
66
|
const templates = (
|
|
67
67
|
typeof args.template === "string"
|
|
@@ -69,7 +69,7 @@ const main = defineCommand({
|
|
|
69
69
|
: ([...(args.template || [])] as string[])
|
|
70
70
|
)
|
|
71
71
|
.flatMap((p) => (fg.isDynamicPattern(p) ? fg.sync(p) : p))
|
|
72
|
-
.map((p) => path.resolve(p));
|
|
72
|
+
.map((p) => path.resolve(p.trim()));
|
|
73
73
|
|
|
74
74
|
const formData = new FormData();
|
|
75
75
|
|
|
@@ -124,12 +124,18 @@ const main = defineCommand({
|
|
|
124
124
|
const deps: Map<string, string> = new Map();
|
|
125
125
|
|
|
126
126
|
for (const p of paths) {
|
|
127
|
+
if (!(await hasPackageJson(p))) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
127
130
|
const pJsonPath = path.resolve(p, "package.json");
|
|
128
131
|
const pJson = await readPackageJSON(pJsonPath);
|
|
129
132
|
|
|
130
133
|
if (!pJson.name) {
|
|
131
134
|
throw new Error(`"name" field in ${pJsonPath} should be defined`);
|
|
132
135
|
}
|
|
136
|
+
if (pJson.private) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
133
139
|
|
|
134
140
|
if (isCompact) {
|
|
135
141
|
await verifyCompactMode(pJson.name);
|
|
@@ -145,12 +151,24 @@ const main = defineCommand({
|
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
for (const templateDir of templates) {
|
|
154
|
+
if (!(await hasPackageJson(templateDir))) {
|
|
155
|
+
console.log(
|
|
156
|
+
`skipping ${templateDir} because there's no package.json file`,
|
|
157
|
+
);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
148
160
|
const pJsonPath = path.resolve(templateDir, "package.json");
|
|
149
161
|
const pJson = await readPackageJSON(pJsonPath);
|
|
150
162
|
|
|
151
163
|
if (!pJson.name) {
|
|
152
164
|
throw new Error(`"name" field in ${pJsonPath} should be defined`);
|
|
153
165
|
}
|
|
166
|
+
if (pJson.private) {
|
|
167
|
+
console.log(
|
|
168
|
+
`skipping ${templateDir} because the package is private`,
|
|
169
|
+
);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
154
172
|
|
|
155
173
|
console.log("preparing template:", pJson.name);
|
|
156
174
|
|
|
@@ -207,11 +225,25 @@ const main = defineCommand({
|
|
|
207
225
|
Awaited<ReturnType<typeof writeDeps>>
|
|
208
226
|
>();
|
|
209
227
|
for (const p of paths) {
|
|
228
|
+
if (!(await hasPackageJson(p))) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const pJsonPath = path.resolve(p, "package.json");
|
|
232
|
+
const pJson = await readPackageJSON(pJsonPath);
|
|
233
|
+
|
|
234
|
+
if (pJson.private) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
|
|
210
238
|
restoreMap.set(p, await writeDeps(p, deps));
|
|
211
239
|
}
|
|
212
240
|
|
|
213
241
|
const shasums: Record<string, string> = {};
|
|
214
242
|
for (const p of paths) {
|
|
243
|
+
if (!(await hasPackageJson(p))) {
|
|
244
|
+
console.log(`skipping ${p} because there's no package.json file`);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
215
247
|
const pJsonPath = path.resolve(p, "package.json");
|
|
216
248
|
try {
|
|
217
249
|
const pJson = await readPackageJSON(pJsonPath);
|
|
@@ -221,6 +253,10 @@ const main = defineCommand({
|
|
|
221
253
|
`"name" field in ${pJsonPath} should be defined`,
|
|
222
254
|
);
|
|
223
255
|
}
|
|
256
|
+
if (pJson.private) {
|
|
257
|
+
console.log(`skipping ${p} because the package is private`);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
224
260
|
|
|
225
261
|
const { filename, shasum } = await resolveTarball(
|
|
226
262
|
isPnpm ? "pnpm" : "npm",
|
|
@@ -237,7 +273,7 @@ const main = defineCommand({
|
|
|
237
273
|
});
|
|
238
274
|
formData.append(`package:${pJson.name}`, blob, filename);
|
|
239
275
|
} finally {
|
|
240
|
-
await restoreMap.get(
|
|
276
|
+
await restoreMap.get(p)!();
|
|
241
277
|
}
|
|
242
278
|
}
|
|
243
279
|
|
|
@@ -358,3 +394,12 @@ ${instruction}`,
|
|
|
358
394
|
);
|
|
359
395
|
}
|
|
360
396
|
}
|
|
397
|
+
|
|
398
|
+
async function hasPackageJson(p: string) {
|
|
399
|
+
try {
|
|
400
|
+
await fs.access(path.resolve(p, "package.json"), fs.constants.F_OK);
|
|
401
|
+
return true;
|
|
402
|
+
} catch {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
}
|