@arkstack/console 0.15.5 → 0.16.1

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.
Files changed (2) hide show
  1. package/dist/index.js +81 -23
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { t as ArkstackConsoleApp } from "./app-Ek2hTWvh.js";
3
3
  import { n as BaseTCConfig, r as TSConfig, t as BuildInterfaces } from "./BuildInterfaces-BBAwvchK.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { Publisher, abort, abortIf, assertFound, config, discoverCommands, env, importFile, initializeGlobalContext, loadPrototypes, outputDir, rebuildOutput } from "@arkstack/common";
6
- import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
6
+ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
7
7
  import { fileURLToPath, pathToFileURL } from "node:url";
8
8
  import path, { dirname, join } from "node:path";
9
9
  import { Arkstack } from "@arkstack/contract";
@@ -13,7 +13,6 @@ import { spawn } from "node:child_process";
13
13
  import { randomBytes } from "node:crypto";
14
14
  import { resolve } from "path";
15
15
  import { writeFile } from "fs/promises";
16
- import { CliApp as CliApp$1 } from "arkormx";
17
16
  import chalk from "chalk";
18
17
  import { str } from "@h3ravel/support";
19
18
 
@@ -248,7 +247,8 @@ var MakeController = class extends Command {
248
247
  this.app.command = this;
249
248
  if (!this.argument("name")) return void this.error("Error: Controller name is required.");
250
249
  const name = this.app.makeController(this.argument("name"), this.options());
251
- const app = new CliApp$1();
250
+ const { CliApp } = await import("arkormx");
251
+ const app = new CliApp();
252
252
  app.command = this;
253
253
  const model = this.option("model") ? app.makeModel(this.option("model"), this.options()) : null;
254
254
  this.success("Controller created successfully!");
@@ -285,7 +285,8 @@ var MakeFullResource = class extends Command {
285
285
  api: true,
286
286
  force: this.option("force")
287
287
  }));
288
- const app = new CliApp$1();
288
+ const { CliApp } = await import("arkormx");
289
+ const app = new CliApp();
289
290
  const model = this.option("model") ? app.makeModel(this.argument("prefix"), {
290
291
  ...this.options(),
291
292
  force: false
@@ -349,36 +350,93 @@ var PublishCommand = class extends Command {
349
350
  package: this.option("package"),
350
351
  tag: this.option("tag")
351
352
  };
352
- const groups = Publisher.publishables(filter);
353
- if (groups.length < 1) {
354
- this.warn(`No publishable artifacts found${this.describeFilter(filter)}.`);
353
+ if (this.option("list")) {
354
+ this.listGroups(Publisher.publishables(filter));
355
355
  return;
356
356
  }
357
- if (this.option("list")) {
358
- this.listGroups(groups);
357
+ const { choices, gated } = await this.resolveConfirmations(filter);
358
+ const groups = Publisher.publishables(filter).filter((group) => !gated.has(group.tag ?? "") || choices.get(group.package)?.tag === group.tag);
359
+ if (groups.length < 1) {
360
+ this.warn(`No publishable artifacts found${this.describeFilter(filter)}.`);
359
361
  return;
360
362
  }
361
363
  let published = 0;
362
364
  let skipped = 0;
363
- for (const group of groups) for (const entry of group.entries) {
364
- if (!existsSync(entry.from)) {
365
- this.warn(`[${group.package}] Source not found, skipping: ${entry.from}`);
365
+ for (const group of groups) {
366
+ const choice = choices.get(group.package);
367
+ for (const entry of group.entries) {
368
+ if (!existsSync(entry.from)) {
369
+ this.warn(`[${group.package}] Source not found, skipping: ${entry.from}`);
370
+ continue;
371
+ }
372
+ const to = stripStubSuffix(entry.to);
373
+ const dest = join(Arkstack.rootDir(), to);
374
+ if (existsSync(dest) && !this.option("force")) {
375
+ this.warn(`Exists, skipped (use --force): ${to}`);
376
+ skipped++;
377
+ continue;
378
+ }
379
+ let content = readFileSync(entry.from, "utf-8");
380
+ if (choice?.callback) content = await choice.callback(choice.tag, content);
381
+ mkdirSync(dirname(dest), { recursive: true });
382
+ writeFileSync(dest, content, { encoding: "utf-8" });
383
+ if (statSync(dest).isDirectory()) this.stripStubsInTree(dest);
384
+ this.success(`Published [${group.package}] -> ${to}`);
385
+ published++;
386
+ }
387
+ }
388
+ this.info(`Done. ${published} published, ${skipped} skipped.`);
389
+ }
390
+ /**
391
+ * Resolve package confirmations into the user's choices.
392
+ *
393
+ * Each confirmation lets a package prompt for a value (typically a tag); the
394
+ * picked tag selects which gated group publishes, and the confirmation's
395
+ * `callback` transforms the published stubs. An explicit `--tag` bypasses the
396
+ * prompt (and still applies the matching callback); `--no-interaction` skips
397
+ * prompting, so gated tags are left unpublished.
398
+ *
399
+ * @param filter The active package/tag filter.
400
+ * @returns The per-package choices and the set of gated tags.
401
+ */
402
+ async resolveConfirmations({ package: pkg, tag }) {
403
+ const confirmations = Publisher.confirmables(pkg || true);
404
+ const choices = /* @__PURE__ */ new Map();
405
+ const gated = /* @__PURE__ */ new Set();
406
+ const interactive = this.option("interaction") !== false;
407
+ for (const confirmation of confirmations) {
408
+ const values = this.choiceValues(confirmation.options);
409
+ values.forEach((value) => gated.add(value));
410
+ if (tag) {
411
+ if (values.includes(tag)) choices.set(confirmation.package, {
412
+ tag,
413
+ callback: confirmation.callback
414
+ });
366
415
  continue;
367
416
  }
368
- const to = stripStubSuffix(entry.to);
369
- const dest = join(Arkstack.rootDir(), to);
370
- if (existsSync(dest) && !this.option("force")) {
371
- this.warn(`Exists, skipped (use --force): ${to}`);
372
- skipped++;
417
+ if (!interactive) {
418
+ this.warn(`[${confirmation.package}] Skipped "${confirmation.message}" (no-interaction); pass --tag to publish a specific option.`);
373
419
  continue;
374
420
  }
375
- mkdirSync(dirname(dest), { recursive: true });
376
- cpSync(entry.from, dest, { recursive: true });
377
- if (statSync(dest).isDirectory()) this.stripStubsInTree(dest);
378
- this.success(`Published [${group.package}] -> ${to}`);
379
- published++;
421
+ const _tag = await this.choice(`[${confirmation.package}] ${confirmation.message}`, confirmation.options);
422
+ choices.set(confirmation.package, {
423
+ tag: _tag,
424
+ callback: confirmation.callback
425
+ });
380
426
  }
381
- this.info(`Done. ${published} published, ${skipped} skipped.`);
427
+ return {
428
+ choices,
429
+ gated
430
+ };
431
+ }
432
+ /**
433
+ * Extract the selectable values from a confirmation's choices.
434
+ *
435
+ * @param options
436
+ * @returns
437
+ */
438
+ choiceValues(options) {
439
+ return options.map((option) => typeof option === "string" ? option : option.value);
382
440
  }
383
441
  /**
384
442
  * Recursively rename `*.stub` files within a published directory to their
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/console",
3
- "version": "0.15.5",
3
+ "version": "0.16.1",
4
4
  "type": "module",
5
5
  "description": "Console module for Arkstack, providing the command-line runtime and console integration layer.",
6
6
  "homepage": "https://arkstack.toneflix.net/guide/cli",
@@ -47,12 +47,12 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@h3ravel/musket": "^2.2.1",
50
- "@h3ravel/support": "^2.2.0",
50
+ "@h3ravel/support": "^2.2.1",
51
51
  "chalk": "^5.6.2",
52
52
  "resora": "^1.3.27",
53
53
  "ts-morph": "^28.0.0",
54
- "@arkstack/common": "^0.15.5",
55
- "@arkstack/contract": "^0.15.5"
54
+ "@arkstack/common": "^0.16.1",
55
+ "@arkstack/contract": "^0.16.1"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "arkormx": {