pkg-pr-new 0.0.17 → 0.0.19
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 +22 -6
- package/index.ts +18 -5
- package/package.json +6 -1
package/index.ts
CHANGED
|
@@ -44,6 +44,12 @@ const main = defineCommand({
|
|
|
44
44
|
description:
|
|
45
45
|
"compact urls. The shortest form of urls like pkg.pr.new/tinybench@a832a55)",
|
|
46
46
|
},
|
|
47
|
+
peerDeps: {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
description:
|
|
50
|
+
"handle peerDependencies by setting the workspace version instead of what has been set in the peerDeps itself. --peerDeps not being true would leave peerDependencies to the package manager itself (npm, pnpm)",
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
47
53
|
pnpm: {
|
|
48
54
|
type: "boolean",
|
|
49
55
|
description: "use `pnpm pack` instead of `npm pack --json`",
|
|
@@ -76,6 +82,7 @@ const main = defineCommand({
|
|
|
76
82
|
|
|
77
83
|
const isCompact = !!args.compact;
|
|
78
84
|
const isPnpm = !!args.pnpm;
|
|
85
|
+
const isPeerDepsEnabled = !!args.peerDeps
|
|
79
86
|
|
|
80
87
|
const comment: Comment = args.comment as Comment;
|
|
81
88
|
|
|
@@ -122,7 +129,8 @@ const main = defineCommand({
|
|
|
122
129
|
const { sha } = await checkResponse.json();
|
|
123
130
|
const abbreviatedSha = abbreviateCommitHash(sha);
|
|
124
131
|
|
|
125
|
-
const deps: Map<string, string> = new Map();
|
|
132
|
+
const deps: Map<string, string> = new Map(); // pkg.pr.new versions of the package
|
|
133
|
+
const realDeps: Map<string, string> | null = isPeerDepsEnabled ? new Map() : null // real versions of the package, useful for peerDependencies
|
|
126
134
|
|
|
127
135
|
for (const p of paths) {
|
|
128
136
|
if (!(await hasPackageJson(p))) {
|
|
@@ -150,6 +158,7 @@ const main = defineCommand({
|
|
|
150
158
|
pJson.name,
|
|
151
159
|
depUrl,
|
|
152
160
|
);
|
|
161
|
+
realDeps?.set(pJson.name, pJson.version ?? depUrl)
|
|
153
162
|
|
|
154
163
|
const resource = await fetch(depUrl)
|
|
155
164
|
if (resource.ok) {
|
|
@@ -173,7 +182,7 @@ const main = defineCommand({
|
|
|
173
182
|
|
|
174
183
|
console.log("preparing template:", pJson.name);
|
|
175
184
|
|
|
176
|
-
const restore = await writeDeps(templateDir, deps);
|
|
185
|
+
const restore = await writeDeps(templateDir, deps, realDeps);
|
|
177
186
|
|
|
178
187
|
const gitignorePath = path.join(templateDir, ".gitignore");
|
|
179
188
|
const ig = ignore()
|
|
@@ -210,7 +219,7 @@ const main = defineCommand({
|
|
|
210
219
|
|
|
211
220
|
const noDefaultTemplate = args.template === false;
|
|
212
221
|
|
|
213
|
-
if (!
|
|
222
|
+
if (!noDefaultTemplate) {
|
|
214
223
|
const project = createDefaultTemplate(
|
|
215
224
|
Object.fromEntries(deps.entries()),
|
|
216
225
|
);
|
|
@@ -238,7 +247,7 @@ const main = defineCommand({
|
|
|
238
247
|
continue;
|
|
239
248
|
}
|
|
240
249
|
|
|
241
|
-
restoreMap.set(p, await writeDeps(p, deps));
|
|
250
|
+
restoreMap.set(p, await writeDeps(p, deps, realDeps));
|
|
242
251
|
}
|
|
243
252
|
|
|
244
253
|
const shasums: Record<string, string> = {};
|
|
@@ -340,7 +349,7 @@ async function resolveTarball(pm: "npm" | "pnpm", p: string) {
|
|
|
340
349
|
return { filename, shasum };
|
|
341
350
|
}
|
|
342
351
|
|
|
343
|
-
async function writeDeps(p: string, deps: Map<string, string>) {
|
|
352
|
+
async function writeDeps(p: string, deps: Map<string, string>, realDeps: Map<string, string> | null) {
|
|
344
353
|
const pJsonPath = path.resolve(p, "package.json");
|
|
345
354
|
const content = await fs.readFile(pJsonPath, "utf-8");
|
|
346
355
|
|
|
@@ -349,6 +358,10 @@ async function writeDeps(p: string, deps: Map<string, string>) {
|
|
|
349
358
|
hijackDeps(deps, pJson.dependencies);
|
|
350
359
|
hijackDeps(deps, pJson.devDependencies);
|
|
351
360
|
|
|
361
|
+
if (realDeps) {
|
|
362
|
+
hijackDeps(realDeps, pJson.peerDependencies);
|
|
363
|
+
}
|
|
364
|
+
|
|
352
365
|
await writePackageJSON(pJsonPath, pJson);
|
|
353
366
|
|
|
354
367
|
return () => fs.writeFile(pJsonPath, content);
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pkg-pr-new",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"pkg-pr-new": "bin/cli.js"
|
|
9
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/stackblitz-labs/pkg.pr.new",
|
|
13
|
+
"directory": "packages/cli"
|
|
14
|
+
},
|
|
10
15
|
"scripts": {
|
|
11
16
|
"dev": "tsup --watch",
|
|
12
17
|
"build": "tsup",
|