@forge-ts/cli 0.15.0 → 0.16.0

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 CHANGED
@@ -2,14 +2,15 @@
2
2
  import {
3
3
  initProjectCommand,
4
4
  runInitProject
5
- } from "./chunk-CINQWGH7.js";
5
+ } from "./chunk-DV33Y4E2.js";
6
+ import {
7
+ configureLogger,
8
+ forgeLogger
9
+ } from "./chunk-CNINN7IQ.js";
6
10
  import {
7
11
  emitResult,
8
12
  resolveExitCode
9
13
  } from "./chunk-ZFFY4AQX.js";
10
- import {
11
- createLogger
12
- } from "./chunk-7UPSAG3L.js";
13
14
 
14
15
  // src/index.ts
15
16
  import { createRequire } from "module";
@@ -96,8 +97,8 @@ var auditCommand = defineCommand({
96
97
  run({ args }) {
97
98
  const eventType = args.type;
98
99
  if (eventType && !VALID_EVENT_TYPES.includes(eventType)) {
99
- console.error(
100
- `Error: invalid event type "${eventType}". Valid types: ${VALID_EVENT_TYPES.join(", ")}`
100
+ forgeLogger.error(
101
+ `Invalid event type "${eventType}". Valid types: ${VALID_EVENT_TYPES.join(", ")}`
101
102
  );
102
103
  process.exit(1);
103
104
  }
@@ -283,15 +284,15 @@ var buildCommand = defineCommand2({
283
284
  mvi: args.mvi
284
285
  };
285
286
  emitResult(output, flags, (data) => {
286
- const logger = createLogger();
287
287
  for (const step of data.steps) {
288
288
  if (step.status === "failed") {
289
289
  for (const err of step.errors ?? []) {
290
- logger.error(`[${step.name}] ${err.message}`);
290
+ forgeLogger.error(`[${step.name}] ${err.message}`);
291
291
  }
292
292
  } else if (step.status === "success") {
293
293
  const detail = step.name === "api" && step.outputPath != null ? `Generated OpenAPI spec \u2192 ${step.outputPath}` : `Step complete`;
294
- logger.step(step.name.toUpperCase(), detail, step.duration);
294
+ const durationStr = step.duration !== void 0 ? ` (${step.duration}ms)` : "";
295
+ forgeLogger.success(`${step.name.toUpperCase()}: ${detail}${durationStr}`);
295
296
  }
296
297
  }
297
298
  if (output.success) {
@@ -458,9 +459,7 @@ var bypassCommand = defineCommand3({
458
459
  return;
459
460
  }
460
461
  if (!args.reason) {
461
- console.error(
462
- "[forge-ts] error: --reason is required. Provide a justification for the bypass."
463
- );
462
+ forgeLogger.error("--reason is required. Provide a justification for the bypass.");
464
463
  process.exit(1);
465
464
  }
466
465
  const output = await runBypassCreate({
@@ -820,11 +819,71 @@ var checkCommand = defineCommand4({
820
819
  }
821
820
  });
822
821
 
822
+ // src/commands/docs-dev.ts
823
+ import { spawn } from "child_process";
824
+ import { resolve } from "path";
825
+ import { loadConfig as loadConfig4 } from "@forge-ts/core";
826
+ import { DEFAULT_TARGET, getAdapter } from "@forge-ts/gen";
827
+ import { defineCommand as defineCommand5 } from "citty";
828
+ async function runDocsDev(args) {
829
+ const config = await loadConfig4(args.cwd);
830
+ const target = args.target ?? config.gen.ssgTarget ?? DEFAULT_TARGET;
831
+ const adapter = getAdapter(target);
832
+ const outDir = resolve(config.outDir);
833
+ const devCmd = adapter.getDevCommand(outDir);
834
+ forgeLogger.info(`Starting ${devCmd.label}...`);
835
+ forgeLogger.info(` Target: ${target}`);
836
+ forgeLogger.info(` Directory: ${outDir}`);
837
+ forgeLogger.info(` URL: ${devCmd.url}`);
838
+ const spawnArgs = [...devCmd.args];
839
+ if (args.port) {
840
+ spawnArgs.push("--port", args.port);
841
+ }
842
+ const proc = spawn(devCmd.bin, spawnArgs, {
843
+ cwd: devCmd.cwd,
844
+ stdio: "inherit",
845
+ shell: true
846
+ });
847
+ return new Promise((_resolve, reject) => {
848
+ proc.on("close", (code) => {
849
+ if (code === 0) {
850
+ _resolve();
851
+ } else {
852
+ reject(new Error(`${devCmd.label} exited with code ${code}`));
853
+ }
854
+ });
855
+ proc.on("error", reject);
856
+ });
857
+ }
858
+ var docsDevCommand = defineCommand5({
859
+ meta: {
860
+ name: "dev",
861
+ description: "Start a local doc preview server"
862
+ },
863
+ args: {
864
+ cwd: {
865
+ type: "string",
866
+ description: "Project root directory"
867
+ },
868
+ target: {
869
+ type: "string",
870
+ description: "SSG target override (reads from config by default)"
871
+ },
872
+ port: {
873
+ type: "string",
874
+ description: "Port for the dev server"
875
+ }
876
+ },
877
+ async run({ args }) {
878
+ await runDocsDev(args);
879
+ }
880
+ });
881
+
823
882
  // src/commands/doctor.ts
824
883
  import { existsSync, readFileSync } from "fs";
825
884
  import { mkdir, writeFile } from "fs/promises";
826
885
  import { join } from "path";
827
- import { defineCommand as defineCommand5 } from "citty";
886
+ import { defineCommand as defineCommand6 } from "citty";
828
887
  function readJsonSafe(filePath) {
829
888
  if (!existsSync(filePath)) {
830
889
  return null;
@@ -859,7 +918,7 @@ export default defineConfig({
859
918
  var DEFAULT_TSDOC_CONTENT = JSON.stringify(
860
919
  {
861
920
  $schema: "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
862
- extends: ["@forge-ts/tsdoc-config/tsdoc.json"]
921
+ extends: ["@forge-ts/core/tsdoc-preset/tsdoc.json"]
863
922
  },
864
923
  null,
865
924
  " "
@@ -901,18 +960,18 @@ async function runDoctor(args) {
901
960
  const tsdocPath = join(rootDir, "tsdoc.json");
902
961
  if (existsSync(tsdocPath)) {
903
962
  const tsdoc = readJsonSafe(tsdocPath);
904
- if (tsdoc?.extends && tsdoc.extends.includes("@forge-ts/tsdoc-config/tsdoc.json")) {
963
+ if (tsdoc?.extends?.includes("@forge-ts/core/tsdoc-preset/tsdoc.json")) {
905
964
  checks.push({
906
965
  name: "tsdoc.json",
907
966
  status: "pass",
908
- message: "tsdoc.json \u2014 extends @forge-ts/tsdoc-config",
967
+ message: "tsdoc.json \u2014 extends @forge-ts/core/tsdoc-preset",
909
968
  fixable: false
910
969
  });
911
970
  } else {
912
971
  checks.push({
913
972
  name: "tsdoc.json",
914
973
  status: "warn",
915
- message: "tsdoc.json \u2014 does not extend @forge-ts/tsdoc-config",
974
+ message: "tsdoc.json \u2014 does not extend @forge-ts/core/tsdoc-preset",
916
975
  fixable: false
917
976
  });
918
977
  }
@@ -934,38 +993,25 @@ async function runDoctor(args) {
934
993
  fixable: true
935
994
  });
936
995
  }
937
- const tsdocConfigModulePath = join(
938
- rootDir,
939
- "node_modules",
940
- "@forge-ts",
941
- "tsdoc-config",
942
- "package.json"
943
- );
944
- if (existsSync(tsdocConfigModulePath)) {
945
- const tsdocPkg = readJsonSafe(
946
- tsdocConfigModulePath
947
- );
948
- const version = tsdocPkg?.version ?? "unknown";
996
+ const coreModulePath = join(rootDir, "node_modules", "@forge-ts", "core", "package.json");
997
+ if (existsSync(coreModulePath)) {
998
+ const corePkg = readJsonSafe(coreModulePath);
999
+ const version = corePkg?.version ?? "unknown";
949
1000
  checks.push({
950
- name: "@forge-ts/tsdoc-config",
1001
+ name: "@forge-ts/core",
951
1002
  status: "pass",
952
- message: `@forge-ts/tsdoc-config \u2014 installed (${version})`,
1003
+ message: `@forge-ts/core \u2014 installed (${version})`,
953
1004
  fixable: false
954
1005
  });
955
1006
  } else {
956
1007
  checks.push({
957
- name: "@forge-ts/tsdoc-config",
1008
+ name: "@forge-ts/core",
958
1009
  status: "warn",
959
- message: "@forge-ts/tsdoc-config \u2014 MISSING (run npm install @forge-ts/tsdoc-config)",
1010
+ message: "@forge-ts/core \u2014 MISSING (run npm install @forge-ts/core)",
960
1011
  fixable: false
961
1012
  });
962
1013
  }
963
- const tsPkgPath = join(
964
- rootDir,
965
- "node_modules",
966
- "typescript",
967
- "package.json"
968
- );
1014
+ const tsPkgPath = join(rootDir, "node_modules", "typescript", "package.json");
969
1015
  if (existsSync(tsPkgPath)) {
970
1016
  const tsPkg = readJsonSafe(tsPkgPath);
971
1017
  const version = tsPkg?.version ?? "unknown";
@@ -1106,9 +1152,7 @@ async function runDoctor(args) {
1106
1152
  const records = readJsonSafe(bypassPath);
1107
1153
  if (records && Array.isArray(records)) {
1108
1154
  const now = /* @__PURE__ */ new Date();
1109
- const active = records.filter(
1110
- (r) => r.expiresAt && new Date(r.expiresAt) > now
1111
- );
1155
+ const active = records.filter((r) => r.expiresAt && new Date(r.expiresAt) > now);
1112
1156
  const expired = records.length - active.length;
1113
1157
  if (active.length > 0) {
1114
1158
  checks.push({
@@ -1231,13 +1275,11 @@ function formatDoctorHuman(result) {
1231
1275
  ` Summary: ${result.summary.passed} passed, ${result.summary.warnings} warning${result.summary.warnings !== 1 ? "s" : ""}, ${result.summary.errors} error${result.summary.errors !== 1 ? "s" : ""}`
1232
1276
  );
1233
1277
  if (result.summary.errors > 0 || result.summary.warnings > 0) {
1234
- lines.push(
1235
- " Run: forge-ts doctor --fix to auto-fix resolvable issues"
1236
- );
1278
+ lines.push(" Run: forge-ts doctor --fix to auto-fix resolvable issues");
1237
1279
  }
1238
1280
  return lines.join("\n");
1239
1281
  }
1240
- var doctorCommand = defineCommand5({
1282
+ var doctorCommand = defineCommand6({
1241
1283
  meta: {
1242
1284
  name: "doctor",
1243
1285
  description: "Project integrity check and repair"
@@ -1294,68 +1336,6 @@ var doctorCommand = defineCommand5({
1294
1336
  }
1295
1337
  });
1296
1338
 
1297
- // src/commands/docs-dev.ts
1298
- import { spawn } from "child_process";
1299
- import { resolve } from "path";
1300
- import { loadConfig as loadConfig4 } from "@forge-ts/core";
1301
- import { DEFAULT_TARGET, getAdapter } from "@forge-ts/gen";
1302
- import { defineCommand as defineCommand6 } from "citty";
1303
- async function runDocsDev(args) {
1304
- const logger = createLogger();
1305
- const config = await loadConfig4(args.cwd);
1306
- const target = args.target ?? config.gen.ssgTarget ?? DEFAULT_TARGET;
1307
- const adapter = getAdapter(target);
1308
- const outDir = resolve(config.outDir);
1309
- const devCmd = adapter.getDevCommand(outDir);
1310
- logger.info(`Starting ${devCmd.label}...`);
1311
- logger.info(` Target: ${target}`);
1312
- logger.info(` Directory: ${outDir}`);
1313
- logger.info(` URL: ${devCmd.url}`);
1314
- logger.info("");
1315
- const spawnArgs = [...devCmd.args];
1316
- if (args.port) {
1317
- spawnArgs.push("--port", args.port);
1318
- }
1319
- const proc = spawn(devCmd.bin, spawnArgs, {
1320
- cwd: devCmd.cwd,
1321
- stdio: "inherit",
1322
- shell: true
1323
- });
1324
- return new Promise((_resolve, reject) => {
1325
- proc.on("close", (code) => {
1326
- if (code === 0) {
1327
- _resolve();
1328
- } else {
1329
- reject(new Error(`${devCmd.label} exited with code ${code}`));
1330
- }
1331
- });
1332
- proc.on("error", reject);
1333
- });
1334
- }
1335
- var docsDevCommand = defineCommand6({
1336
- meta: {
1337
- name: "dev",
1338
- description: "Start a local doc preview server"
1339
- },
1340
- args: {
1341
- cwd: {
1342
- type: "string",
1343
- description: "Project root directory"
1344
- },
1345
- target: {
1346
- type: "string",
1347
- description: "SSG target override (reads from config by default)"
1348
- },
1349
- port: {
1350
- type: "string",
1351
- description: "Port for the dev server"
1352
- }
1353
- },
1354
- async run({ args }) {
1355
- await runDocsDev(args);
1356
- }
1357
- });
1358
-
1359
1339
  // src/commands/init-docs.ts
1360
1340
  import { existsSync as existsSync2 } from "fs";
1361
1341
  import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
@@ -1454,7 +1434,7 @@ async function runInitDocs(args) {
1454
1434
  const tsdocContent = JSON.stringify(
1455
1435
  {
1456
1436
  $schema: "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
1457
- extends: ["@forge-ts/tsdoc-config/tsdoc.json"]
1437
+ extends: ["@forge-ts/core/tsdoc-preset/tsdoc.json"]
1458
1438
  },
1459
1439
  null,
1460
1440
  " "
@@ -1581,9 +1561,8 @@ var initDocsCommand = defineCommand7({
1581
1561
  };
1582
1562
  emitResult(output, flags, (data, cmd) => {
1583
1563
  if (!cmd.success) {
1584
- const logger = createLogger();
1585
1564
  const msg = cmd.errors?.[0]?.message ?? "Scaffold failed";
1586
- logger.error(msg);
1565
+ forgeLogger.error(msg);
1587
1566
  return "";
1588
1567
  }
1589
1568
  return formatInitDocsHuman(data);
@@ -1799,9 +1778,8 @@ var initHooksCommand = defineCommand8({
1799
1778
  };
1800
1779
  emitResult(output, flags, (data, cmd) => {
1801
1780
  if (!cmd.success) {
1802
- const logger = createLogger();
1803
1781
  const msg = cmd.errors?.[0]?.message ?? "Hook scaffolding failed";
1804
- logger.error(msg);
1782
+ forgeLogger.error(msg);
1805
1783
  return "";
1806
1784
  }
1807
1785
  return formatInitHooksHuman(data);
@@ -2069,8 +2047,7 @@ var prepublishCommand = defineCommand10({
2069
2047
  };
2070
2048
  emitResult(output, flags, (data, cmd) => {
2071
2049
  if (!cmd.success) {
2072
- const logger = createLogger();
2073
- logger.error("Prepublish gate failed");
2050
+ forgeLogger.error("Prepublish gate failed");
2074
2051
  }
2075
2052
  return formatPrepublishHuman(data);
2076
2053
  });
@@ -2303,9 +2280,7 @@ var unlockCommand = defineCommand12({
2303
2280
  },
2304
2281
  async run({ args }) {
2305
2282
  if (!args.reason) {
2306
- console.error(
2307
- "[forge-ts] error: --reason is required. Provide a reason for unlocking the config."
2308
- );
2283
+ forgeLogger.error("--reason is required. Provide a reason for unlocking the config.");
2309
2284
  process.exit(1);
2310
2285
  }
2311
2286
  const output = await runUnlock({
@@ -2376,9 +2351,9 @@ var initCommand2 = defineCommand13({
2376
2351
  if (hasSubCommand) {
2377
2352
  return;
2378
2353
  }
2379
- const { runInitProject: runInitProject2 } = await import("./init-project-5DESIZ73.js");
2354
+ const { runInitProject: runInitProject2 } = await import("./init-project-5AWZ2LAI.js");
2380
2355
  const { emitResult: emitResult2, resolveExitCode: resolveExitCode2 } = await import("./output-OSCHMPOX.js");
2381
- const { createLogger: createLogger3 } = await import("./logger-MMBBZG6U.js");
2356
+ const { forgeLogger: forgeLogger2 } = await import("./forge-logger-RTOBEKWH.js");
2382
2357
  const output = await runInitProject2({
2383
2358
  cwd: args.cwd,
2384
2359
  mvi: args.mvi
@@ -2391,9 +2366,8 @@ var initCommand2 = defineCommand13({
2391
2366
  };
2392
2367
  emitResult2(output, flags, (data, cmd) => {
2393
2368
  if (!cmd.success) {
2394
- const logger = createLogger3();
2395
2369
  const msg = cmd.errors?.[0]?.message ?? "Init failed";
2396
- logger.error(msg);
2370
+ forgeLogger2.error(msg);
2397
2371
  return "";
2398
2372
  }
2399
2373
  const lines = [];
@@ -2474,10 +2448,11 @@ export {
2474
2448
  buildCommand,
2475
2449
  bypassCommand,
2476
2450
  checkCommand,
2477
- createLogger,
2451
+ configureLogger,
2478
2452
  docsDevCommand,
2479
2453
  doctorCommand,
2480
2454
  emitResult,
2455
+ forgeLogger,
2481
2456
  initDocsCommand,
2482
2457
  initHooksCommand,
2483
2458
  initProjectCommand,