@powerhousedao/ph-cli 6.0.0-dev.195 → 6.0.0-dev.197
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/cli.mjs +414 -30
- package/dist/cli.mjs.map +1 -1
- package/dist/generate-all-B2zuJ01M.mjs +10 -0
- package/dist/generate-all-B2zuJ01M.mjs.map +1 -0
- package/dist/generate-app-DKShBXn7.mjs +31 -0
- package/dist/generate-app-DKShBXn7.mjs.map +1 -0
- package/dist/generate-document-model-wud-Ezfp.mjs +17 -0
- package/dist/generate-document-model-wud-Ezfp.mjs.map +1 -0
- package/dist/generate-editor-BJbBk8c5.mjs +31 -0
- package/dist/generate-editor-BJbBk8c5.mjs.map +1 -0
- package/dist/generate-processor-BF3yxDSa.mjs +22 -0
- package/dist/generate-processor-BF3yxDSa.mjs.map +1 -0
- package/dist/generate-subgraph-mkgADj_1.mjs +20 -0
- package/dist/generate-subgraph-mkgADj_1.mjs.map +1 -0
- package/dist/{init-rIIiKQI4.mjs → init-iDbH337G.mjs} +2 -2
- package/dist/{init-rIIiKQI4.mjs.map → init-iDbH337G.mjs.map} +1 -1
- package/dist/{inspect-Qn_mykOH.mjs → inspect-C5s3gQIQ.mjs} +1 -1
- package/dist/{inspect-Qn_mykOH.mjs.map → inspect-C5s3gQIQ.mjs.map} +1 -1
- package/dist/{migrate-Cmd8Ouyk.mjs → migrate-CIBhw4np.mjs} +1 -1
- package/dist/{migrate-Cmd8Ouyk.mjs.map → migrate-CIBhw4np.mjs.map} +1 -1
- package/dist/scripts/generate-commands-docs.ts +14 -0
- package/dist/switchboard-CiIwAwyR.mjs +2 -0
- package/dist/{switchboard-migrate-Cwx-8MnF.mjs → switchboard-migrate-COGf5HBF.mjs} +1 -1
- package/dist/{switchboard-migrate-Cwx-8MnF.mjs.map → switchboard-migrate-COGf5HBF.mjs.map} +1 -1
- package/dist/{switchboard-BclxuF4j.mjs → switchboard-vPgnxFrM.mjs} +1 -1
- package/dist/switchboard-vPgnxFrM.mjs.map +1 -0
- package/dist/{vetra-D3mHCtDl.mjs → vetra-B7ofmdqk.mjs} +67 -9
- package/dist/vetra-B7ofmdqk.mjs.map +1 -0
- package/package.json +10 -10
- package/dist/generate-UNkoTojF.mjs +0 -46
- package/dist/generate-UNkoTojF.mjs.map +0 -1
- package/dist/switchboard-BclxuF4j.mjs.map +0 -1
- package/dist/switchboard-DXF1APL1.mjs +0 -2
- package/dist/vetra-D3mHCtDl.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runBuild } from "./build-BflSHYLP.mjs";
|
|
3
3
|
import { a as updateStylesFile, i as updateConfigFile, r as removeStylesImports } from "./utils-CFkM2mAC.mjs";
|
|
4
|
-
import { DEFAULT_EXPIRY_SECONDS, accessTokenArgs, assertNodeVersion, buildArgs, captureCliError, connectBuildArgs, connectPreviewArgs, connectStudioArgs,
|
|
5
|
-
import { command, run, subcommands } from "cmd-ts";
|
|
4
|
+
import { DEFAULT_EXPIRY_SECONDS, accessTokenArgs, assertNodeVersion, buildArgs, captureCliError, connectBuildArgs, connectPreviewArgs, connectStudioArgs, debugArgs, getPowerhouseProjectInfo, getPowerhouseProjectUninstallCommand, initArgs, initCliTelemetry, inspectArgs, installArgs, listArgs, loginArgs, makeDependenciesWithVersions, migrateArgs, phCliHelpCommands, publishArgs, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs } from "@powerhousedao/shared/clis";
|
|
5
|
+
import { array, boolean, command, flag, multioption, oneOf, option, optional, run, string, subcommands } from "cmd-ts";
|
|
6
6
|
import { AGENTS, resolveCommand } from "package-manager-detector";
|
|
7
|
-
import {
|
|
7
|
+
import { Directory, File } from "cmd-ts/dist/cjs/batteries/fs.js";
|
|
8
|
+
import { generateDBSchema } from "@powerhousedao/codegen";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { PROCESSOR_APPS } from "@powerhousedao/shared/processors";
|
|
11
|
+
import { checkNpmAuth, npmPublish, npmUnpublish, resolveRegistryUrl } from "@powerhousedao/shared/registry";
|
|
8
12
|
import { execSync } from "child_process";
|
|
9
13
|
import { getConfig as getConfig$1 } from "@powerhousedao/config/node";
|
|
14
|
+
import { readPackageSync } from "read-pkg";
|
|
15
|
+
import { prerelease } from "semver";
|
|
16
|
+
import { createInterface } from "node:readline/promises";
|
|
10
17
|
//#region src/get-version.ts
|
|
11
18
|
function getVersion() {
|
|
12
19
|
return process.env.WORKSPACE_VERSION || process.env.npm_package_version || "unknown";
|
|
@@ -157,28 +164,261 @@ NOTE: You must run \`ph connect build\` first
|
|
|
157
164
|
}
|
|
158
165
|
});
|
|
159
166
|
//#endregion
|
|
160
|
-
//#region src/commands/generate.ts
|
|
161
|
-
const
|
|
162
|
-
name: "
|
|
163
|
-
description:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
//#region src/commands/generate-all.ts
|
|
168
|
+
const generateAllCmd = command({
|
|
169
|
+
name: "all",
|
|
170
|
+
description: "Re-generate all modules in the current project",
|
|
171
|
+
args: {},
|
|
172
|
+
handler: async () => {
|
|
173
|
+
const { startGenerateAll } = await import("./generate-all-B2zuJ01M.mjs");
|
|
174
|
+
await startGenerateAll(process.cwd());
|
|
175
|
+
process.exit(0);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/commands/generate-app.ts
|
|
180
|
+
const generateAppCmd = command({
|
|
181
|
+
name: "app",
|
|
182
|
+
description: "Generate a drive app",
|
|
183
|
+
args: {
|
|
184
|
+
name: option({
|
|
185
|
+
type: optional(string),
|
|
186
|
+
long: "name",
|
|
187
|
+
short: "n",
|
|
188
|
+
description: "The name of the drive app to generate"
|
|
189
|
+
}),
|
|
190
|
+
allowedDocumentTypes: multioption({
|
|
191
|
+
type: optional(array(string)),
|
|
192
|
+
long: "document-types",
|
|
193
|
+
short: "t",
|
|
194
|
+
description: "The document types allowed by the new app"
|
|
195
|
+
}),
|
|
196
|
+
dir: option({
|
|
197
|
+
type: optional(Directory),
|
|
198
|
+
long: "dir",
|
|
199
|
+
short: "d",
|
|
200
|
+
description: "Name of the directory of an existing app to re-generate"
|
|
201
|
+
}),
|
|
202
|
+
disableDragAndDrop: flag({
|
|
203
|
+
type: boolean,
|
|
204
|
+
long: "disable-drag-and-drop",
|
|
205
|
+
description: "Do not allow drag and drop in this drive app.",
|
|
206
|
+
defaultValue: () => false,
|
|
207
|
+
defaultValueIsSerializable: true
|
|
208
|
+
}),
|
|
209
|
+
all: flag({
|
|
210
|
+
long: "all",
|
|
211
|
+
short: "a",
|
|
212
|
+
description: "Re-generate all existing apps in the current project"
|
|
213
|
+
}),
|
|
214
|
+
...debugArgs
|
|
215
|
+
},
|
|
174
216
|
handler: async (args) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
await startGenerate(args);
|
|
217
|
+
const { startGenerateApp } = await import("./generate-app-DKShBXn7.mjs");
|
|
218
|
+
await startGenerateApp(args, process.cwd());
|
|
178
219
|
process.exit(0);
|
|
179
220
|
}
|
|
180
221
|
});
|
|
181
222
|
//#endregion
|
|
223
|
+
//#region src/commands/generate-document-model.ts
|
|
224
|
+
const generateDocumentModelCmd = command({
|
|
225
|
+
name: "document-model",
|
|
226
|
+
aliases: ["doc"],
|
|
227
|
+
description: "Generate a document model",
|
|
228
|
+
args: {
|
|
229
|
+
file: option({
|
|
230
|
+
type: optional(File),
|
|
231
|
+
long: "file",
|
|
232
|
+
short: "f",
|
|
233
|
+
description: "Path to the file to generate the document model from"
|
|
234
|
+
}),
|
|
235
|
+
dir: option({
|
|
236
|
+
type: optional(Directory),
|
|
237
|
+
long: "dir",
|
|
238
|
+
short: "d",
|
|
239
|
+
description: "Name of the directory of an existing document model to re-generate"
|
|
240
|
+
}),
|
|
241
|
+
all: flag({
|
|
242
|
+
long: "all",
|
|
243
|
+
short: "a",
|
|
244
|
+
description: "Re-generate all existing document models in the current project"
|
|
245
|
+
}),
|
|
246
|
+
...debugArgs
|
|
247
|
+
},
|
|
248
|
+
handler: async (args) => {
|
|
249
|
+
const { startGenerateDocumentModel } = await import("./generate-document-model-wud-Ezfp.mjs");
|
|
250
|
+
await startGenerateDocumentModel(args, process.cwd());
|
|
251
|
+
process.exit(0);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/commands/generate-editor.ts
|
|
256
|
+
const generateEditorCmd = command({
|
|
257
|
+
name: "editor",
|
|
258
|
+
description: "Generate a document editor",
|
|
259
|
+
args: {
|
|
260
|
+
name: option({
|
|
261
|
+
type: optional(string),
|
|
262
|
+
long: "name",
|
|
263
|
+
short: "n",
|
|
264
|
+
description: "The name of the document editor to generate"
|
|
265
|
+
}),
|
|
266
|
+
documentType: option({
|
|
267
|
+
type: optional(string),
|
|
268
|
+
long: "document-type",
|
|
269
|
+
short: "t",
|
|
270
|
+
description: "The document type for the new editor"
|
|
271
|
+
}),
|
|
272
|
+
dir: option({
|
|
273
|
+
type: optional(Directory),
|
|
274
|
+
long: "dir",
|
|
275
|
+
short: "d",
|
|
276
|
+
description: "Name of the directory of an existing editor to re-generate"
|
|
277
|
+
}),
|
|
278
|
+
all: flag({
|
|
279
|
+
long: "all",
|
|
280
|
+
short: "a",
|
|
281
|
+
description: "Re-generate all existing editors in the current project"
|
|
282
|
+
}),
|
|
283
|
+
...debugArgs
|
|
284
|
+
},
|
|
285
|
+
handler: async (args) => {
|
|
286
|
+
const { startGenerateEditor } = await import("./generate-editor-BJbBk8c5.mjs");
|
|
287
|
+
await startGenerateEditor(args, process.cwd());
|
|
288
|
+
process.exit(0);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/commands/generate-migration-file.ts
|
|
293
|
+
const generateMigrationFileCmd = command({
|
|
294
|
+
name: "migration-file",
|
|
295
|
+
description: "Generate a migration file",
|
|
296
|
+
args: {
|
|
297
|
+
migrationFile: option({
|
|
298
|
+
type: string,
|
|
299
|
+
long: "path",
|
|
300
|
+
short: "p",
|
|
301
|
+
description: "Path to the migration file"
|
|
302
|
+
}),
|
|
303
|
+
schemaFile: option({
|
|
304
|
+
type: optional(string),
|
|
305
|
+
long: "schema-file",
|
|
306
|
+
description: "Path to the output file. Defaults to './schema.ts'"
|
|
307
|
+
}),
|
|
308
|
+
...debugArgs
|
|
309
|
+
},
|
|
310
|
+
handler: async ({ migrationFile, schemaFile }) => {
|
|
311
|
+
await generateDBSchema({
|
|
312
|
+
migrationFile: path.join(process.cwd(), migrationFile),
|
|
313
|
+
schemaFile: schemaFile ? path.join(process.cwd(), schemaFile) : void 0
|
|
314
|
+
});
|
|
315
|
+
process.exit(0);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
const generateProcessorCmd = command({
|
|
319
|
+
name: "processor",
|
|
320
|
+
description: "Generate a processor",
|
|
321
|
+
args: {
|
|
322
|
+
name: option({
|
|
323
|
+
type: optional(string),
|
|
324
|
+
long: "name",
|
|
325
|
+
short: "n",
|
|
326
|
+
description: "The name of the processor to generate"
|
|
327
|
+
}),
|
|
328
|
+
type: option({
|
|
329
|
+
type: oneOf(["analytics", "relationalDb"]),
|
|
330
|
+
long: "type",
|
|
331
|
+
description: "The type of processor to generate",
|
|
332
|
+
defaultValue: () => "analytics",
|
|
333
|
+
defaultValueIsSerializable: true
|
|
334
|
+
}),
|
|
335
|
+
documentTypes: multioption({
|
|
336
|
+
type: array(string),
|
|
337
|
+
long: "document-types",
|
|
338
|
+
short: "t",
|
|
339
|
+
description: "The document types the processor will run on",
|
|
340
|
+
defaultValue: () => [],
|
|
341
|
+
defaultValueIsSerializable: true
|
|
342
|
+
}),
|
|
343
|
+
apps: multioption({
|
|
344
|
+
long: "apps",
|
|
345
|
+
type: { from(processorApps) {
|
|
346
|
+
if (processorApps.length === 0) throw new Error(`No arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
|
|
347
|
+
if (processorApps.length > 2) throw new Error(`Too many arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
|
|
348
|
+
const allowed = new Set(PROCESSOR_APPS);
|
|
349
|
+
if (!processorApps.every((p) => allowed.has(p))) throw new Error(`Processor apps can only be "connect" and/or "switchboard".`);
|
|
350
|
+
return Promise.resolve(processorApps);
|
|
351
|
+
} },
|
|
352
|
+
description: "Whether the processor will run in switchboard (nodejs), connect (browser), or both",
|
|
353
|
+
defaultValue: () => ["switchboard", "connect"],
|
|
354
|
+
defaultValueIsSerializable: true
|
|
355
|
+
}),
|
|
356
|
+
dir: option({
|
|
357
|
+
type: optional(Directory),
|
|
358
|
+
long: "dir",
|
|
359
|
+
short: "d",
|
|
360
|
+
description: "Name of the directory of an existing processor to re-generate"
|
|
361
|
+
}),
|
|
362
|
+
all: flag({
|
|
363
|
+
long: "all",
|
|
364
|
+
short: "a",
|
|
365
|
+
description: "Re-generate all existing processors in the current project"
|
|
366
|
+
}),
|
|
367
|
+
...debugArgs
|
|
368
|
+
},
|
|
369
|
+
handler: async (args) => {
|
|
370
|
+
const { startGenerateProcessor } = await import("./generate-processor-BF3yxDSa.mjs");
|
|
371
|
+
await startGenerateProcessor(args, process.cwd());
|
|
372
|
+
process.exit(0);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/commands/generate-subgraph.ts
|
|
377
|
+
const generateSubgraphCmd = command({
|
|
378
|
+
name: "subgraph",
|
|
379
|
+
description: "Generate a subgraph",
|
|
380
|
+
args: {
|
|
381
|
+
name: option({
|
|
382
|
+
type: optional(string),
|
|
383
|
+
long: "name",
|
|
384
|
+
short: "n",
|
|
385
|
+
description: "The name of the subgraph to generate"
|
|
386
|
+
}),
|
|
387
|
+
dir: option({
|
|
388
|
+
type: optional(Directory),
|
|
389
|
+
long: "dir",
|
|
390
|
+
short: "d",
|
|
391
|
+
description: "Name of the directory of an existing subgraph to re-generate"
|
|
392
|
+
}),
|
|
393
|
+
all: flag({
|
|
394
|
+
long: "all",
|
|
395
|
+
short: "a",
|
|
396
|
+
description: "Re-generate all existing subgraphs in the current project"
|
|
397
|
+
}),
|
|
398
|
+
...debugArgs
|
|
399
|
+
},
|
|
400
|
+
handler: async (args) => {
|
|
401
|
+
const { startGenerateSubgraph } = await import("./generate-subgraph-mkgADj_1.mjs");
|
|
402
|
+
await startGenerateSubgraph(args, process.cwd());
|
|
403
|
+
process.exit(0);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/commands/generate.ts
|
|
408
|
+
const generate = subcommands({
|
|
409
|
+
name: "generate",
|
|
410
|
+
description: `The generate command creates code for Powerhouse modules. It helps you create new code from scratch, or to re-generate existing code in your project.`,
|
|
411
|
+
cmds: {
|
|
412
|
+
all: generateAllCmd,
|
|
413
|
+
"document-model": generateDocumentModelCmd,
|
|
414
|
+
editor: generateEditorCmd,
|
|
415
|
+
app: generateAppCmd,
|
|
416
|
+
processor: generateProcessorCmd,
|
|
417
|
+
subgraph: generateSubgraphCmd,
|
|
418
|
+
"migration-file": generateMigrationFileCmd
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
//#endregion
|
|
182
422
|
//#region src/commands/init.ts
|
|
183
423
|
const init = command({
|
|
184
424
|
name: "init",
|
|
@@ -186,7 +426,7 @@ const init = command({
|
|
|
186
426
|
args: initArgs,
|
|
187
427
|
handler: async (args) => {
|
|
188
428
|
if (args.debug) console.log({ args });
|
|
189
|
-
const { startInit } = await import("./init-
|
|
429
|
+
const { startInit } = await import("./init-iDbH337G.mjs");
|
|
190
430
|
await startInit(args);
|
|
191
431
|
process.exit(0);
|
|
192
432
|
}
|
|
@@ -209,7 +449,7 @@ This command:
|
|
|
209
449
|
args: inspectArgs,
|
|
210
450
|
handler: async (args) => {
|
|
211
451
|
if (args.debug) console.log(args);
|
|
212
|
-
const { startInspect } = await import("./inspect-
|
|
452
|
+
const { startInspect } = await import("./inspect-C5s3gQIQ.mjs");
|
|
213
453
|
startInspect(args);
|
|
214
454
|
process.exit(0);
|
|
215
455
|
}
|
|
@@ -447,19 +687,41 @@ The logout command removes an existing session created with 'ph login'`,
|
|
|
447
687
|
});
|
|
448
688
|
//#endregion
|
|
449
689
|
//#region src/commands/migrate.ts
|
|
450
|
-
const migrate = command({
|
|
690
|
+
const migrate$1 = command({
|
|
451
691
|
name: "migrate",
|
|
452
692
|
args: migrateArgs,
|
|
453
693
|
description: "Run migrations",
|
|
454
694
|
handler: async (args) => {
|
|
455
695
|
if (args.debug) console.log(args);
|
|
456
|
-
const { startMigrate } = await import("./migrate-
|
|
696
|
+
const { startMigrate } = await import("./migrate-CIBhw4np.mjs");
|
|
457
697
|
await startMigrate(args);
|
|
458
698
|
process.exit(0);
|
|
459
699
|
}
|
|
460
700
|
});
|
|
461
701
|
//#endregion
|
|
462
702
|
//#region src/commands/publish.ts
|
|
703
|
+
function hasTagFlag(args) {
|
|
704
|
+
return args.some((a) => a === "--tag" || a.startsWith("--tag="));
|
|
705
|
+
}
|
|
706
|
+
function isInteractive() {
|
|
707
|
+
return Boolean(process.stdin.isTTY) && !process.env.CI;
|
|
708
|
+
}
|
|
709
|
+
function readPrereleaseTag(projectPath) {
|
|
710
|
+
try {
|
|
711
|
+
const pkg = readPackageSync({ cwd: projectPath });
|
|
712
|
+
if (!pkg.version) return null;
|
|
713
|
+
const parts = prerelease(pkg.version);
|
|
714
|
+
if (!parts || parts.length === 0) return null;
|
|
715
|
+
const label = String(parts[0]);
|
|
716
|
+
if (!/^[a-z][a-z0-9-]*$/i.test(label)) return null;
|
|
717
|
+
return {
|
|
718
|
+
version: pkg.version,
|
|
719
|
+
tag: label
|
|
720
|
+
};
|
|
721
|
+
} catch {
|
|
722
|
+
return null;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
463
725
|
const publish = command({
|
|
464
726
|
name: "publish",
|
|
465
727
|
description: `
|
|
@@ -488,12 +750,45 @@ This command:
|
|
|
488
750
|
console.error(`Run: npm adduser --registry ${registryUrl}`);
|
|
489
751
|
process.exit(1);
|
|
490
752
|
}
|
|
491
|
-
|
|
753
|
+
let forwardedArgs = args.forwardedArgs;
|
|
754
|
+
if (!hasTagFlag(forwardedArgs)) {
|
|
755
|
+
const prereleaseInfo = readPrereleaseTag(projectPath);
|
|
756
|
+
if (prereleaseInfo) {
|
|
757
|
+
const { version, tag } = prereleaseInfo;
|
|
758
|
+
if (!isInteractive()) {
|
|
759
|
+
console.error(`Detected prerelease version ${version}. npm requires an explicit dist-tag for prerelease publishes.`);
|
|
760
|
+
console.error(`Re-run with --tag <label> (e.g. --tag ${tag}) to proceed.`);
|
|
761
|
+
process.exit(1);
|
|
762
|
+
}
|
|
763
|
+
const enquirer = await import("enquirer");
|
|
764
|
+
let confirmed = false;
|
|
765
|
+
try {
|
|
766
|
+
confirmed = (await enquirer.default.prompt({
|
|
767
|
+
type: "confirm",
|
|
768
|
+
name: "confirmed",
|
|
769
|
+
message: `Detected prerelease version ${version}. Publish with --tag ${tag}?`,
|
|
770
|
+
initial: true
|
|
771
|
+
})).confirmed;
|
|
772
|
+
} catch {
|
|
773
|
+
confirmed = false;
|
|
774
|
+
}
|
|
775
|
+
if (!confirmed) {
|
|
776
|
+
console.error(`Aborted. To publish manually: npm publish --registry ${registryUrl} --tag <label>`);
|
|
777
|
+
process.exit(1);
|
|
778
|
+
}
|
|
779
|
+
forwardedArgs = [
|
|
780
|
+
"--tag",
|
|
781
|
+
tag,
|
|
782
|
+
...forwardedArgs
|
|
783
|
+
];
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (args.debug) console.log(">>> command", `npm publish --registry ${registryUrl} ${forwardedArgs.join(" ")}`);
|
|
492
787
|
console.log(`Publishing to ${registryUrl}...`);
|
|
493
788
|
const result = await npmPublish({
|
|
494
789
|
registryUrl,
|
|
495
790
|
cwd: projectPath,
|
|
496
|
-
args:
|
|
791
|
+
args: forwardedArgs
|
|
497
792
|
});
|
|
498
793
|
if (result.stdout) console.log(result.stdout);
|
|
499
794
|
process.exit(0);
|
|
@@ -521,14 +816,14 @@ This command:
|
|
|
521
816
|
const { basePath, dbPath, migrate, migrateStatus } = args;
|
|
522
817
|
if (basePath) process.env.BASE_PATH = basePath;
|
|
523
818
|
if (migrate || migrateStatus) {
|
|
524
|
-
const { runSwitchboardMigrations } = await import("./switchboard-migrate-
|
|
819
|
+
const { runSwitchboardMigrations } = await import("./switchboard-migrate-COGf5HBF.mjs");
|
|
525
820
|
await runSwitchboardMigrations({
|
|
526
821
|
dbPath,
|
|
527
822
|
statusOnly: migrateStatus
|
|
528
823
|
});
|
|
529
824
|
process.exit(0);
|
|
530
825
|
}
|
|
531
|
-
const { startSwitchboard } = await import("./switchboard-
|
|
826
|
+
const { startSwitchboard } = await import("./switchboard-CiIwAwyR.mjs");
|
|
532
827
|
const { defaultDriveUrl, renown } = await startSwitchboard(args);
|
|
533
828
|
console.log(" ➜ Switchboard:", defaultDriveUrl);
|
|
534
829
|
if (renown) console.log(" ➜ Identity:", renown.did);
|
|
@@ -593,6 +888,94 @@ This command:
|
|
|
593
888
|
}
|
|
594
889
|
});
|
|
595
890
|
//#endregion
|
|
891
|
+
//#region src/commands/unpublish.ts
|
|
892
|
+
const unpublish = command({
|
|
893
|
+
name: "unpublish",
|
|
894
|
+
description: `
|
|
895
|
+
Unpublish a package from the Powerhouse registry. This is a thin wrapper around
|
|
896
|
+
npm unpublish that automatically targets the Powerhouse registry and never
|
|
897
|
+
reaches npmjs.org.
|
|
898
|
+
|
|
899
|
+
Forms:
|
|
900
|
+
ph unpublish # unpublish <name>@<version> from cwd's package.json
|
|
901
|
+
ph unpublish <name> # unpublish the whole package (all versions)
|
|
902
|
+
ph unpublish <name>@<version> # unpublish a single version
|
|
903
|
+
|
|
904
|
+
Flags:
|
|
905
|
+
--registry <url> # override registry URL
|
|
906
|
+
--yes, -y # skip the confirmation prompt
|
|
907
|
+
`,
|
|
908
|
+
args: unpublishArgs,
|
|
909
|
+
handler: async (args) => {
|
|
910
|
+
if (args.debug) console.log(args);
|
|
911
|
+
const { projectPath } = await getPowerhouseProjectInfo();
|
|
912
|
+
if (!projectPath) throw new Error("Could not find project path.");
|
|
913
|
+
const registryUrl = resolveRegistryUrl({
|
|
914
|
+
registry: args.registry,
|
|
915
|
+
projectPath
|
|
916
|
+
});
|
|
917
|
+
const spec = resolveSpec(args.spec, projectPath);
|
|
918
|
+
if (!spec) {
|
|
919
|
+
console.error("No package spec provided and could not read name/version from package.json.");
|
|
920
|
+
process.exit(1);
|
|
921
|
+
}
|
|
922
|
+
if (args.debug) {
|
|
923
|
+
console.log(">>> registryUrl", registryUrl);
|
|
924
|
+
console.log(">>> spec", spec);
|
|
925
|
+
}
|
|
926
|
+
try {
|
|
927
|
+
await checkNpmAuth(registryUrl);
|
|
928
|
+
} catch {
|
|
929
|
+
console.error(`Not authenticated with registry: ${registryUrl}`);
|
|
930
|
+
console.error(`Run: npm adduser --registry ${registryUrl}`);
|
|
931
|
+
process.exit(1);
|
|
932
|
+
}
|
|
933
|
+
if (!args.yes) {
|
|
934
|
+
if (!await confirm(`Unpublish ${spec} from ${registryUrl}? [y/N] `)) {
|
|
935
|
+
console.log("Aborted.");
|
|
936
|
+
process.exit(0);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (args.debug) console.log(">>> command", `npm unpublish ${spec} --registry ${registryUrl} --force ${args.forwardedArgs.join(" ")}`);
|
|
940
|
+
console.log(`Unpublishing ${spec} from ${registryUrl}...`);
|
|
941
|
+
try {
|
|
942
|
+
const result = await npmUnpublish({
|
|
943
|
+
registryUrl,
|
|
944
|
+
cwd: projectPath,
|
|
945
|
+
spec,
|
|
946
|
+
args: args.forwardedArgs
|
|
947
|
+
});
|
|
948
|
+
if (result.stdout) console.log(result.stdout);
|
|
949
|
+
process.exit(0);
|
|
950
|
+
} catch (err) {
|
|
951
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
952
|
+
process.exit(1);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
function resolveSpec(explicit, projectPath) {
|
|
957
|
+
if (explicit) return explicit;
|
|
958
|
+
try {
|
|
959
|
+
const pkg = readPackageSync({ cwd: projectPath });
|
|
960
|
+
if (!pkg.name) return null;
|
|
961
|
+
return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name;
|
|
962
|
+
} catch {
|
|
963
|
+
return null;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
async function confirm(prompt) {
|
|
967
|
+
const rl = createInterface({
|
|
968
|
+
input: process.stdin,
|
|
969
|
+
output: process.stdout
|
|
970
|
+
});
|
|
971
|
+
try {
|
|
972
|
+
const answer = await rl.question(prompt);
|
|
973
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
974
|
+
} finally {
|
|
975
|
+
rl.close();
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
//#endregion
|
|
596
979
|
//#region src/commands/ph-cli-commands.ts
|
|
597
980
|
const phCliCommands = {
|
|
598
981
|
init,
|
|
@@ -612,17 +995,18 @@ This command:
|
|
|
612
995
|
args: vetraArgs,
|
|
613
996
|
handler: async (args) => {
|
|
614
997
|
if (args.debug) console.log(args);
|
|
615
|
-
const { startVetra } = await import("./vetra-
|
|
998
|
+
const { startVetra } = await import("./vetra-B7ofmdqk.mjs");
|
|
616
999
|
await startVetra(args);
|
|
617
1000
|
}
|
|
618
1001
|
}),
|
|
619
1002
|
connect,
|
|
620
1003
|
build: build$1,
|
|
621
1004
|
publish,
|
|
1005
|
+
unpublish,
|
|
622
1006
|
"access-token": accessToken,
|
|
623
1007
|
inspect,
|
|
624
1008
|
list,
|
|
625
|
-
migrate,
|
|
1009
|
+
migrate: migrate$1,
|
|
626
1010
|
switchboard,
|
|
627
1011
|
login,
|
|
628
1012
|
logout,
|