@forge-ts/cli 0.15.0 → 0.17.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-57QAENSK.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;
@@ -840,18 +899,8 @@ var DEFAULT_CONFIG_CONTENT = `import { defineConfig } from "@forge-ts/core";
840
899
 
841
900
  export default defineConfig({
842
901
  rootDir: ".",
843
- tsconfig: "tsconfig.json",
844
902
  outDir: "docs/generated",
845
- enforce: {
846
- enabled: true,
847
- minVisibility: "public",
848
- strict: false,
849
- },
850
903
  gen: {
851
- enabled: true,
852
- formats: ["mdx"],
853
- llmsTxt: true,
854
- readmeSync: false,
855
904
  ssgTarget: "mintlify",
856
905
  },
857
906
  });
@@ -859,7 +908,7 @@ export default defineConfig({
859
908
  var DEFAULT_TSDOC_CONTENT = JSON.stringify(
860
909
  {
861
910
  $schema: "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
862
- extends: ["@forge-ts/tsdoc-config/tsdoc.json"]
911
+ extends: ["@forge-ts/core/tsdoc-preset/tsdoc.json"]
863
912
  },
864
913
  null,
865
914
  " "
@@ -901,18 +950,18 @@ async function runDoctor(args) {
901
950
  const tsdocPath = join(rootDir, "tsdoc.json");
902
951
  if (existsSync(tsdocPath)) {
903
952
  const tsdoc = readJsonSafe(tsdocPath);
904
- if (tsdoc?.extends && tsdoc.extends.includes("@forge-ts/tsdoc-config/tsdoc.json")) {
953
+ if (tsdoc?.extends?.includes("@forge-ts/core/tsdoc-preset/tsdoc.json")) {
905
954
  checks.push({
906
955
  name: "tsdoc.json",
907
956
  status: "pass",
908
- message: "tsdoc.json \u2014 extends @forge-ts/tsdoc-config",
957
+ message: "tsdoc.json \u2014 extends @forge-ts/core/tsdoc-preset",
909
958
  fixable: false
910
959
  });
911
960
  } else {
912
961
  checks.push({
913
962
  name: "tsdoc.json",
914
963
  status: "warn",
915
- message: "tsdoc.json \u2014 does not extend @forge-ts/tsdoc-config",
964
+ message: "tsdoc.json \u2014 does not extend @forge-ts/core/tsdoc-preset",
916
965
  fixable: false
917
966
  });
918
967
  }
@@ -934,38 +983,25 @@ async function runDoctor(args) {
934
983
  fixable: true
935
984
  });
936
985
  }
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";
986
+ const coreModulePath = join(rootDir, "node_modules", "@forge-ts", "core", "package.json");
987
+ if (existsSync(coreModulePath)) {
988
+ const corePkg = readJsonSafe(coreModulePath);
989
+ const version = corePkg?.version ?? "unknown";
949
990
  checks.push({
950
- name: "@forge-ts/tsdoc-config",
991
+ name: "@forge-ts/core",
951
992
  status: "pass",
952
- message: `@forge-ts/tsdoc-config \u2014 installed (${version})`,
993
+ message: `@forge-ts/core \u2014 installed (${version})`,
953
994
  fixable: false
954
995
  });
955
996
  } else {
956
997
  checks.push({
957
- name: "@forge-ts/tsdoc-config",
998
+ name: "@forge-ts/core",
958
999
  status: "warn",
959
- message: "@forge-ts/tsdoc-config \u2014 MISSING (run npm install @forge-ts/tsdoc-config)",
1000
+ message: "@forge-ts/core \u2014 MISSING (run npm install @forge-ts/core)",
960
1001
  fixable: false
961
1002
  });
962
1003
  }
963
- const tsPkgPath = join(
964
- rootDir,
965
- "node_modules",
966
- "typescript",
967
- "package.json"
968
- );
1004
+ const tsPkgPath = join(rootDir, "node_modules", "typescript", "package.json");
969
1005
  if (existsSync(tsPkgPath)) {
970
1006
  const tsPkg = readJsonSafe(tsPkgPath);
971
1007
  const version = tsPkg?.version ?? "unknown";
@@ -1106,9 +1142,7 @@ async function runDoctor(args) {
1106
1142
  const records = readJsonSafe(bypassPath);
1107
1143
  if (records && Array.isArray(records)) {
1108
1144
  const now = /* @__PURE__ */ new Date();
1109
- const active = records.filter(
1110
- (r) => r.expiresAt && new Date(r.expiresAt) > now
1111
- );
1145
+ const active = records.filter((r) => r.expiresAt && new Date(r.expiresAt) > now);
1112
1146
  const expired = records.length - active.length;
1113
1147
  if (active.length > 0) {
1114
1148
  checks.push({
@@ -1231,13 +1265,11 @@ function formatDoctorHuman(result) {
1231
1265
  ` Summary: ${result.summary.passed} passed, ${result.summary.warnings} warning${result.summary.warnings !== 1 ? "s" : ""}, ${result.summary.errors} error${result.summary.errors !== 1 ? "s" : ""}`
1232
1266
  );
1233
1267
  if (result.summary.errors > 0 || result.summary.warnings > 0) {
1234
- lines.push(
1235
- " Run: forge-ts doctor --fix to auto-fix resolvable issues"
1236
- );
1268
+ lines.push(" Run: forge-ts doctor --fix to auto-fix resolvable issues");
1237
1269
  }
1238
1270
  return lines.join("\n");
1239
1271
  }
1240
- var doctorCommand = defineCommand5({
1272
+ var doctorCommand = defineCommand6({
1241
1273
  meta: {
1242
1274
  name: "doctor",
1243
1275
  description: "Project integrity check and repair"
@@ -1294,68 +1326,6 @@ var doctorCommand = defineCommand5({
1294
1326
  }
1295
1327
  });
1296
1328
 
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
1329
  // src/commands/init-docs.ts
1360
1330
  import { existsSync as existsSync2 } from "fs";
1361
1331
  import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
@@ -1454,7 +1424,7 @@ async function runInitDocs(args) {
1454
1424
  const tsdocContent = JSON.stringify(
1455
1425
  {
1456
1426
  $schema: "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
1457
- extends: ["@forge-ts/tsdoc-config/tsdoc.json"]
1427
+ extends: ["@forge-ts/core/tsdoc-preset/tsdoc.json"]
1458
1428
  },
1459
1429
  null,
1460
1430
  " "
@@ -1581,9 +1551,8 @@ var initDocsCommand = defineCommand7({
1581
1551
  };
1582
1552
  emitResult(output, flags, (data, cmd) => {
1583
1553
  if (!cmd.success) {
1584
- const logger = createLogger();
1585
1554
  const msg = cmd.errors?.[0]?.message ?? "Scaffold failed";
1586
- logger.error(msg);
1555
+ forgeLogger.error(msg);
1587
1556
  return "";
1588
1557
  }
1589
1558
  return formatInitDocsHuman(data);
@@ -1799,9 +1768,8 @@ var initHooksCommand = defineCommand8({
1799
1768
  };
1800
1769
  emitResult(output, flags, (data, cmd) => {
1801
1770
  if (!cmd.success) {
1802
- const logger = createLogger();
1803
1771
  const msg = cmd.errors?.[0]?.message ?? "Hook scaffolding failed";
1804
- logger.error(msg);
1772
+ forgeLogger.error(msg);
1805
1773
  return "";
1806
1774
  }
1807
1775
  return formatInitHooksHuman(data);
@@ -2069,8 +2037,7 @@ var prepublishCommand = defineCommand10({
2069
2037
  };
2070
2038
  emitResult(output, flags, (data, cmd) => {
2071
2039
  if (!cmd.success) {
2072
- const logger = createLogger();
2073
- logger.error("Prepublish gate failed");
2040
+ forgeLogger.error("Prepublish gate failed");
2074
2041
  }
2075
2042
  return formatPrepublishHuman(data);
2076
2043
  });
@@ -2303,9 +2270,7 @@ var unlockCommand = defineCommand12({
2303
2270
  },
2304
2271
  async run({ args }) {
2305
2272
  if (!args.reason) {
2306
- console.error(
2307
- "[forge-ts] error: --reason is required. Provide a reason for unlocking the config."
2308
- );
2273
+ forgeLogger.error("--reason is required. Provide a reason for unlocking the config.");
2309
2274
  process.exit(1);
2310
2275
  }
2311
2276
  const output = await runUnlock({
@@ -2376,9 +2341,9 @@ var initCommand2 = defineCommand13({
2376
2341
  if (hasSubCommand) {
2377
2342
  return;
2378
2343
  }
2379
- const { runInitProject: runInitProject2 } = await import("./init-project-5DESIZ73.js");
2344
+ const { runInitProject: runInitProject2 } = await import("./init-project-PT4XOWV2.js");
2380
2345
  const { emitResult: emitResult2, resolveExitCode: resolveExitCode2 } = await import("./output-OSCHMPOX.js");
2381
- const { createLogger: createLogger3 } = await import("./logger-MMBBZG6U.js");
2346
+ const { forgeLogger: forgeLogger2 } = await import("./forge-logger-RTOBEKWH.js");
2382
2347
  const output = await runInitProject2({
2383
2348
  cwd: args.cwd,
2384
2349
  mvi: args.mvi
@@ -2391,9 +2356,8 @@ var initCommand2 = defineCommand13({
2391
2356
  };
2392
2357
  emitResult2(output, flags, (data, cmd) => {
2393
2358
  if (!cmd.success) {
2394
- const logger = createLogger3();
2395
2359
  const msg = cmd.errors?.[0]?.message ?? "Init failed";
2396
- logger.error(msg);
2360
+ forgeLogger2.error(msg);
2397
2361
  return "";
2398
2362
  }
2399
2363
  const lines = [];
@@ -2474,10 +2438,11 @@ export {
2474
2438
  buildCommand,
2475
2439
  bypassCommand,
2476
2440
  checkCommand,
2477
- createLogger,
2441
+ configureLogger,
2478
2442
  docsDevCommand,
2479
2443
  doctorCommand,
2480
2444
  emitResult,
2445
+ forgeLogger,
2481
2446
  initDocsCommand,
2482
2447
  initHooksCommand,
2483
2448
  initProjectCommand,