@stryke/capnp 0.12.80 → 0.12.82

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/bin/capnpc.cjs CHANGED
@@ -38,10 +38,11 @@ let typescript = require("typescript");
38
38
  typescript = __toESM(typescript);
39
39
  require("defu");
40
40
  let node_buffer = require("node:buffer");
41
+ let __stryke_fs = require("@stryke/fs");
41
42
  let __stryke_fs_json = require("@stryke/fs/json");
42
43
  let __stryke_fs_list_files = require("@stryke/fs/list-files");
43
44
 
44
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-DJB7XLHA.js
45
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-DJB7XLHA.js
45
46
  var DEFAULT_COLOR_CONFIG = {
46
47
  light: {
47
48
  background: "#fafafa",
@@ -86,6 +87,23 @@ var DEFAULT_COLOR_CONFIG = {
86
87
  ]
87
88
  }
88
89
  };
90
+ function getColors(config) {
91
+ if (!config?.colors || typeof config.colors !== "object" || !config.colors["dark"] && (!config.colors["base"] || typeof config.colors !== "object" || !config.colors["base"]?.["dark"])) return DEFAULT_COLOR_CONFIG;
92
+ if (config.colors["base"]) {
93
+ if (typeof config.colors["base"]["dark"] === "object") return config.colors["base"]["dark"];
94
+ else if (config.colors["base"]["dark"] === "string") return config.colors["base"];
95
+ }
96
+ if (typeof config.colors["dark"] === "object") return config.colors["dark"];
97
+ return config.colors ?? DEFAULT_COLOR_CONFIG;
98
+ }
99
+ function getColor(key, config) {
100
+ const colors = getColors(config);
101
+ const result = (typeof colors["dark"] === "object" ? colors["dark"][key] : colors[key]) || DEFAULT_COLOR_CONFIG["dark"][key] || DEFAULT_COLOR_CONFIG[key];
102
+ if (result) return result;
103
+ if (key === "link" || key === "debug") return getColor("info", config);
104
+ else if (key === "fatal") return getColor("danger", config);
105
+ return getColor("brand", config);
106
+ }
89
107
 
90
108
  //#endregion
91
109
  //#region ../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js
@@ -2218,7 +2236,7 @@ var require_source = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2218
2236
  }));
2219
2237
 
2220
2238
  //#endregion
2221
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-HVVJHTFS.js
2239
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-HVVJHTFS.js
2222
2240
  var import_source = /* @__PURE__ */ __toESM(require_source(), 1);
2223
2241
  var chalkDefault = {
2224
2242
  hex: (_) => (message) => message,
@@ -2250,14 +2268,14 @@ var getChalk = () => {
2250
2268
  };
2251
2269
 
2252
2270
  //#endregion
2253
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-G2MK47WL.js
2271
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-G2MK47WL.js
2254
2272
  function isUnicodeSupported() {
2255
2273
  if (process.platform !== "win32") return process.env.TERM !== "linux";
2256
2274
  return Boolean(process.env.WT_SESSION) || Boolean(process.env.TERMINUS_SUBLIME) || process.env.ConEmuTask === "{cmd::Cmder}" || process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERM === "rxvt-unicode" || process.env.TERM === "rxvt-unicode-256color" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2257
2275
  }
2258
2276
 
2259
2277
  //#endregion
2260
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-POXTJ6GF.js
2278
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-POXTJ6GF.js
2261
2279
  var LogLevel = {
2262
2280
  SILENT: 0,
2263
2281
  FATAL: 10,
@@ -2282,7 +2300,7 @@ var LogLevelLabel = {
2282
2300
  };
2283
2301
 
2284
2302
  //#endregion
2285
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-AITAR5W5.js
2303
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-AITAR5W5.js
2286
2304
  var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
2287
2305
  var CONSOLE_ICONS = {
2288
2306
  [LogLevelLabel.ERROR]: useIcon("✘", "×"),
@@ -2296,13 +2314,13 @@ var CONSOLE_ICONS = {
2296
2314
  };
2297
2315
 
2298
2316
  //#endregion
2299
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-CZ4IE2QN.js
2317
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-CZ4IE2QN.js
2300
2318
  var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
2301
2319
  return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
2302
2320
  };
2303
2321
 
2304
2322
  //#endregion
2305
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-K4CDYUQR.js
2323
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-K4CDYUQR.js
2306
2324
  var getLogLevel = (label) => {
2307
2325
  switch (label) {
2308
2326
  case "all": return LogLevel.ALL;
@@ -2318,7 +2336,7 @@ var getLogLevel = (label) => {
2318
2336
  };
2319
2337
 
2320
2338
  //#endregion
2321
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-SPHE3YEH.js
2339
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-SPHE3YEH.js
2322
2340
  var daysInYear = 365.2425;
2323
2341
  -(Math.pow(10, 8) * 24 * 60 * 60 * 1e3);
2324
2342
  var secondsInDay = 3600 * 24;
@@ -2911,9 +2929,10 @@ var _isFunction = (value) => {
2911
2929
  return false;
2912
2930
  }
2913
2931
  };
2932
+ var brandIcon = (config = {}, _chalk = getChalk()) => _chalk.hex(getColor("brand", config))("🗲");
2914
2933
 
2915
2934
  //#endregion
2916
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-T4YVVO6G.js
2935
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-T4YVVO6G.js
2917
2936
  var exitWithError = (config) => {
2918
2937
  writeFatal("Exiting script with an error status...", config);
2919
2938
  process.exit(1);
@@ -2948,7 +2967,7 @@ Stacktrace: ${error.stack}`, config);
2948
2967
  };
2949
2968
 
2950
2969
  //#endregion
2951
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-RUKM6FCF.js
2970
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-RUKM6FCF.js
2952
2971
  var MAX_PATH_SEARCH_DEPTH = 30;
2953
2972
  var depth = 0;
2954
2973
  function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
@@ -2959,7 +2978,7 @@ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
2959
2978
  }
2960
2979
 
2961
2980
  //#endregion
2962
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-V3GMJ4TX.js
2981
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-V3GMJ4TX.js
2963
2982
  var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2964
2983
  function normalizeWindowsPath(input = "") {
2965
2984
  if (!input) return input;
@@ -3041,7 +3060,7 @@ var isAbsolute = function(p) {
3041
3060
  };
3042
3061
 
3043
3062
  //#endregion
3044
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-LF3SAK2O.js
3063
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-LF3SAK2O.js
3045
3064
  var rootFiles = [
3046
3065
  "storm-workspace.json",
3047
3066
  "storm-workspace.yaml",
@@ -11864,11 +11883,27 @@ function toArray(array) {
11864
11883
  */
11865
11884
  async function resolveOptions(options) {
11866
11885
  const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.json");
11867
- const schemas = toArray(options.schemas ? options.schemas : (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "schemas/**/*.capnp")).filter(Boolean).map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot));
11886
+ const schemas = [];
11887
+ if (options.schemas) schemas.push(...toArray(options.schemas).filter(Boolean).map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot)).map((schema) => schema.includes("*") || schema.endsWith(".capnp") || (0, __stryke_fs_exists.existsSync)(schema) && (0, __stryke_fs_list_files.listSync)((0, __stryke_path_join_paths.joinPaths)(schema, "**/*.capnp")).length > 0 ? schema : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)(options.projectRoot, schema)) && (0, __stryke_fs_list_files.listSync)((0, __stryke_path_join_paths.joinPaths)(options.projectRoot, schema, "**/*.capnp")).length > 0 ? (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, schema, "**/*.capnp") : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, schema)) && (0, __stryke_fs_list_files.listSync)((0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, schema, "**/*.capnp")).length > 0 ? (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, schema, "**/*.capnp") : schema));
11888
+ else schemas.push((0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "schemas/**/*.capnp")) && (0, __stryke_fs_list_files.listSync)((0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "schemas/**/*.capnp")).length > 0 ? (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "schemas/**/*.capnp") : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "schemas/**/*.capnp")) && (0, __stryke_fs_list_files.listSync)((0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "schemas/**/*.capnp")).length > 0 ? (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "schemas/**/*.capnp") : "schemas/**/*.capnp");
11868
11889
  let resolvedTsconfig;
11869
11890
  if (options.tsconfig) resolvedTsconfig = options.tsconfig;
11870
11891
  else {
11871
- if (!tsconfigPath || !(0, __stryke_fs_exists.existsSync)(tsconfigPath)) {
11892
+ let resolvedTsconfigPath = tsconfigPath;
11893
+ if (!(0, __stryke_fs_exists.existsSync)(resolvedTsconfigPath)) {
11894
+ const found = [
11895
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.json"),
11896
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.lib.json"),
11897
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.app.json"),
11898
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.capnp.json"),
11899
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.json"),
11900
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.lib.json"),
11901
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.app.json"),
11902
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.capnp.json")
11903
+ ].find((path$1) => (0, __stryke_fs_exists.existsSync)(path$1));
11904
+ if (found) resolvedTsconfigPath = found;
11905
+ }
11906
+ if (!resolvedTsconfigPath || !(0, __stryke_fs_exists.existsSync)(resolvedTsconfigPath)) {
11872
11907
  const errorMessage = tsconfigPath ? `✖ The specified TypeScript configuration file "${tsconfigPath}" does not exist. Please provide a valid path.` : "✖ The specified TypeScript configuration file does not exist. Please provide a valid path.";
11873
11908
  writeFatal(errorMessage, { logLevel: "all" });
11874
11909
  throw new Error(errorMessage);
@@ -11895,6 +11930,15 @@ async function resolveOptions(options) {
11895
11930
  return null;
11896
11931
  }
11897
11932
  const output = options.output ? options.output.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, (0, __stryke_path_file_path_fns.relativePath)(tsconfigPath ? (0, __stryke_path_file_path_fns.findFilePath)(tsconfigPath) : options.projectRoot, (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, resolvedSchemas[0].endsWith(".capnp") ? (0, __stryke_path_file_path_fns.findFilePath)(resolvedSchemas[0]) : resolvedSchemas[0])));
11933
+ if (!(0, __stryke_fs_exists.existsSync)(output)) {
11934
+ if ((0, __stryke_fs.isFile)(output)) {
11935
+ const errorMessage = `✖ The specified output path "${output}" is a file. Please provide a valid directory path.`;
11936
+ writeFatal(errorMessage, { logLevel: "all" });
11937
+ throw new Error(errorMessage);
11938
+ }
11939
+ writeInfo(`Output directory "${output}" does not exist. It will be created automatically.`, { logLevel: "all" });
11940
+ await (0, __stryke_fs.createDirectory)(output);
11941
+ }
11898
11942
  resolvedTsconfig.options.outDir = output;
11899
11943
  return {
11900
11944
  ...options,
@@ -11975,13 +12019,13 @@ const compileAction = (workspaceRoot) => async (options) => {
11975
12019
  writeWarning("✖ Unable to resolve Cap'n Proto compiler options - the program will terminate", { logLevel: "all" });
11976
12020
  return;
11977
12021
  }
11978
- writeInfo(`📦 Storm Cap'n Proto Compiler will output ${resolvedOptions.ts ? "TypeScript code" : ""}${resolvedOptions.js ? resolvedOptions.ts ? ", JavaScript code" : "JavaScript code" : ""}${resolvedOptions.dts ? resolvedOptions.ts || resolvedOptions.js ? ", TypeScript declarations" : "TypeScript declarations" : ""} files from schemas at ${options.schema ? options.schema.replace("{projectRoot}", resolvedOptions.projectRoot).replace("{workspaceRoot}", resolvedOptions.workspaceRoot) : resolvedOptions.projectRoot} to ${resolvedOptions.tsconfig.options.outDir}...`, { logLevel: "all" });
12022
+ writeInfo(`Storm Cap'n Proto Compiler will output ${resolvedOptions.ts ? "TypeScript code" : ""}${resolvedOptions.js ? resolvedOptions.ts ? ", JavaScript code" : "JavaScript code" : ""}${resolvedOptions.dts ? resolvedOptions.ts || resolvedOptions.js ? ", TypeScript declarations" : "TypeScript declarations" : ""} files from schemas at ${options.schema ? options.schema.replace("{projectRoot}", resolvedOptions.projectRoot).replace("{workspaceRoot}", resolvedOptions.workspaceRoot) : resolvedOptions.projectRoot} to ${resolvedOptions.tsconfig.options.outDir}...`, { logLevel: "all" });
11979
12023
  const result = await capnpc(resolvedOptions);
11980
12024
  if (result.files.size === 0) {
11981
- writeWarning("⚠️ No files were generated. Please check your schema files.", { logLevel: "all" });
12025
+ writeWarning("No files were generated. Please check your schema files.", { logLevel: "all" });
11982
12026
  return;
11983
12027
  }
11984
- writeInfo(`📋 Writing ${result.files.size} generated files to disk...`, { logLevel: "all" });
12028
+ writeInfo(`Writing ${result.files.size} generated files to disk...`, { logLevel: "all" });
11985
12029
  for (const [fileName, content] of result.files) {
11986
12030
  let filePath = fileName;
11987
12031
  if (!(0, __stryke_fs_exists.existsSync)((0, __stryke_path_file_path_fns.findFilePath)(filePath))) {
@@ -11994,17 +12038,23 @@ const compileAction = (workspaceRoot) => async (options) => {
11994
12038
  }
11995
12039
  await (0, node_fs_promises.writeFile)(filePath, content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2)));
11996
12040
  }
11997
- writeSuccess("⚡ Storm Cap'n Proto Compiler completed successfully.", { logLevel: "all" });
12041
+ writeSuccess(`✔ Storm Cap'n Proto Compiler completed successfully.`, { logLevel: "all" });
11998
12042
  };
12043
+ /**
12044
+ * Creates and configures the Cap'n Proto compiler CLI program.
12045
+ *
12046
+ * @returns The configured Command instance for the Cap'n Proto compiler CLI.
12047
+ */
11999
12048
  function createProgram() {
12000
- writeInfo("⚡ Running Storm Cap'n Proto Compiler Tools", { logLevel: "all" });
12001
- const root = findWorkspaceRootSafe(process.cwd());
12002
- process.env.STORM_WORKSPACE_ROOT ??= root;
12003
- process.env.NX_WORKSPACE_ROOT_PATH ??= root;
12004
- if (root) process.chdir(root);
12049
+ writeInfo(`${brandIcon()} Running Storm Cap'n Proto Compiler Tools`, { logLevel: "all" });
12050
+ const workspaceRoot = findWorkspaceRootSafe(process.cwd());
12051
+ process.env.STORM_WORKSPACE_ROOT ??= workspaceRoot;
12052
+ process.env.NX_WORKSPACE_ROOT_PATH ??= workspaceRoot;
12053
+ let projectRoot;
12054
+ if (workspaceRoot !== process.cwd() && ((0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)(process.cwd(), "package.json")) || (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)(process.cwd(), "project.json")))) projectRoot = process.cwd();
12005
12055
  const program$1 = new Command();
12006
12056
  program$1.name("storm-capnpc").description("Run the Storm Cap'n Proto compiler").version("1.0.0", "-v --version", "display CLI version");
12007
- program$1.command("compile", { isDefault: true }).option("-p --project-root <path>", "The path to the project root directory").option("-s --schema <path>", "The directory (or a glob to the directory) containing the Cap'n Proto schema files to compile (default: current working directory)").option("-o --output <path>", "The directory to output the generated files to").option("--tsconfig <path>", "The path to the TypeScript configuration file to use for compilation").option("--skip-generating-id", "Skip generating a new 64-bit unique ID for use in a Cap'n Proto schema").option("--no-standard-imports", "Skip adding default import paths; use only those specified by -I").option("--no-ts", "An indicator to disable generation of TypeScript files").option("--js", "An indicator to generate JavaScript files").option("--dts", "An indicator to generate TypeScript declaration files").option("--no-dts", "An indicator to disable generation of TypeScript declaration files").option("-w --workspace-root <path>", "The path to the workspace root directory", root || process.cwd()).option("--tty", "An indicator to enable TTY mode for the compiler").action(compileAction(root));
12057
+ program$1.command("compile", { isDefault: true }).option("-p --project-root <path>", "The path to the project root directory", projectRoot).option("-s --schema <path>", "The directory (or a glob to the directory) containing the Cap'n Proto schema files to compile (default: current working directory)").option("-o --output <path>", "The directory to output the generated files to").option("--tsconfig <path>", "The path to the TypeScript configuration file to use for compilation").option("--skip-generating-id", "Skip generating a new 64-bit unique ID for use in a Cap'n Proto schema").option("--no-standard-imports", "Skip adding default import paths; use only those specified by -I").option("--no-ts", "An indicator to disable generation of TypeScript files").option("--js", "An indicator to generate JavaScript files").option("--dts", "An indicator to generate TypeScript declaration files").option("--no-dts", "An indicator to disable generation of TypeScript declaration files").option("-w --workspace-root <path>", "The path to the workspace root directory", workspaceRoot || process.cwd()).option("--tty", "An indicator to enable TTY mode for the compiler").action(compileAction(workspaceRoot));
12008
12058
  return program$1;
12009
12059
  }
12010
12060
  (async () => {
package/bin/capnpc.d.cts CHANGED
@@ -2,6 +2,12 @@
2
2
  import { Command } from "commander";
3
3
 
4
4
  //#region bin/capnpc.d.ts
5
+
6
+ /**
7
+ * Creates and configures the Cap'n Proto compiler CLI program.
8
+ *
9
+ * @returns The configured Command instance for the Cap'n Proto compiler CLI.
10
+ */
5
11
  declare function createProgram(): Command;
6
12
  //#endregion
7
13
  export { createProgram };
@@ -1 +1 @@
1
- {"version":3,"file":"capnpc.d.cts","names":[],"sources":["../../bin/capnpc.ts"],"sourcesContent":[],"mappings":";;;;iBA0IgB,aAAA,CAAA,GAAa"}
1
+ {"version":3,"file":"capnpc.d.cts","names":[],"sources":["../../bin/capnpc.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6IA;;;iBAAgB,aAAA,CAAA,GAAa"}
package/bin/capnpc.d.mts CHANGED
@@ -2,6 +2,12 @@
2
2
  import { Command } from "commander";
3
3
 
4
4
  //#region bin/capnpc.d.ts
5
+
6
+ /**
7
+ * Creates and configures the Cap'n Proto compiler CLI program.
8
+ *
9
+ * @returns The configured Command instance for the Cap'n Proto compiler CLI.
10
+ */
5
11
  declare function createProgram(): Command;
6
12
  //#endregion
7
13
  export { createProgram };
@@ -1 +1 @@
1
- {"version":3,"file":"capnpc.d.mts","names":[],"sources":["../../bin/capnpc.ts"],"sourcesContent":[],"mappings":";;;;iBA0IgB,aAAA,CAAA,GAAa"}
1
+ {"version":3,"file":"capnpc.d.mts","names":[],"sources":["../../bin/capnpc.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6IA;;;iBAAgB,aAAA,CAAA,GAAa"}
package/bin/capnpc.mjs CHANGED
@@ -10,8 +10,9 @@ import { joinPaths } from "@stryke/path/join-paths";
10
10
  import ts, { parseJsonConfigFileContent, sys } from "typescript";
11
11
  import "defu";
12
12
  import { Buffer as Buffer$1 } from "node:buffer";
13
+ import { createDirectory, isFile } from "@stryke/fs";
13
14
  import { readJsonFile } from "@stryke/fs/json";
14
- import { listFiles } from "@stryke/fs/list-files";
15
+ import { listFiles, listSync } from "@stryke/fs/list-files";
15
16
 
16
17
  //#region rolldown:runtime
17
18
  var __create = Object.create;
@@ -42,7 +43,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
42
43
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
43
44
 
44
45
  //#endregion
45
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-DJB7XLHA.js
46
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-DJB7XLHA.js
46
47
  var DEFAULT_COLOR_CONFIG = {
47
48
  light: {
48
49
  background: "#fafafa",
@@ -87,6 +88,23 @@ var DEFAULT_COLOR_CONFIG = {
87
88
  ]
88
89
  }
89
90
  };
91
+ function getColors(config) {
92
+ if (!config?.colors || typeof config.colors !== "object" || !config.colors["dark"] && (!config.colors["base"] || typeof config.colors !== "object" || !config.colors["base"]?.["dark"])) return DEFAULT_COLOR_CONFIG;
93
+ if (config.colors["base"]) {
94
+ if (typeof config.colors["base"]["dark"] === "object") return config.colors["base"]["dark"];
95
+ else if (config.colors["base"]["dark"] === "string") return config.colors["base"];
96
+ }
97
+ if (typeof config.colors["dark"] === "object") return config.colors["dark"];
98
+ return config.colors ?? DEFAULT_COLOR_CONFIG;
99
+ }
100
+ function getColor(key, config) {
101
+ const colors = getColors(config);
102
+ const result = (typeof colors["dark"] === "object" ? colors["dark"][key] : colors[key]) || DEFAULT_COLOR_CONFIG["dark"][key] || DEFAULT_COLOR_CONFIG[key];
103
+ if (result) return result;
104
+ if (key === "link" || key === "debug") return getColor("info", config);
105
+ else if (key === "fatal") return getColor("danger", config);
106
+ return getColor("brand", config);
107
+ }
90
108
 
91
109
  //#endregion
92
110
  //#region ../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js
@@ -2219,7 +2237,7 @@ var require_source = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2219
2237
  }));
2220
2238
 
2221
2239
  //#endregion
2222
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-HVVJHTFS.js
2240
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-HVVJHTFS.js
2223
2241
  var import_source = /* @__PURE__ */ __toESM(require_source(), 1);
2224
2242
  var chalkDefault = {
2225
2243
  hex: (_) => (message) => message,
@@ -2251,14 +2269,14 @@ var getChalk = () => {
2251
2269
  };
2252
2270
 
2253
2271
  //#endregion
2254
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-G2MK47WL.js
2272
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-G2MK47WL.js
2255
2273
  function isUnicodeSupported() {
2256
2274
  if (process.platform !== "win32") return process.env.TERM !== "linux";
2257
2275
  return Boolean(process.env.WT_SESSION) || Boolean(process.env.TERMINUS_SUBLIME) || process.env.ConEmuTask === "{cmd::Cmder}" || process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERM === "rxvt-unicode" || process.env.TERM === "rxvt-unicode-256color" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2258
2276
  }
2259
2277
 
2260
2278
  //#endregion
2261
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-POXTJ6GF.js
2279
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-POXTJ6GF.js
2262
2280
  var LogLevel = {
2263
2281
  SILENT: 0,
2264
2282
  FATAL: 10,
@@ -2283,7 +2301,7 @@ var LogLevelLabel = {
2283
2301
  };
2284
2302
 
2285
2303
  //#endregion
2286
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-AITAR5W5.js
2304
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-AITAR5W5.js
2287
2305
  var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
2288
2306
  var CONSOLE_ICONS = {
2289
2307
  [LogLevelLabel.ERROR]: useIcon("✘", "×"),
@@ -2297,13 +2315,13 @@ var CONSOLE_ICONS = {
2297
2315
  };
2298
2316
 
2299
2317
  //#endregion
2300
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-CZ4IE2QN.js
2318
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-CZ4IE2QN.js
2301
2319
  var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
2302
2320
  return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
2303
2321
  };
2304
2322
 
2305
2323
  //#endregion
2306
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-K4CDYUQR.js
2324
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-K4CDYUQR.js
2307
2325
  var getLogLevel = (label) => {
2308
2326
  switch (label) {
2309
2327
  case "all": return LogLevel.ALL;
@@ -2319,7 +2337,7 @@ var getLogLevel = (label) => {
2319
2337
  };
2320
2338
 
2321
2339
  //#endregion
2322
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-SPHE3YEH.js
2340
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-SPHE3YEH.js
2323
2341
  var daysInYear = 365.2425;
2324
2342
  -(Math.pow(10, 8) * 24 * 60 * 60 * 1e3);
2325
2343
  var secondsInDay = 3600 * 24;
@@ -2912,9 +2930,10 @@ var _isFunction = (value) => {
2912
2930
  return false;
2913
2931
  }
2914
2932
  };
2933
+ var brandIcon = (config = {}, _chalk = getChalk()) => _chalk.hex(getColor("brand", config))("🗲");
2915
2934
 
2916
2935
  //#endregion
2917
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-T4YVVO6G.js
2936
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-T4YVVO6G.js
2918
2937
  var exitWithError = (config) => {
2919
2938
  writeFatal("Exiting script with an error status...", config);
2920
2939
  process.exit(1);
@@ -2949,7 +2968,7 @@ Stacktrace: ${error.stack}`, config);
2949
2968
  };
2950
2969
 
2951
2970
  //#endregion
2952
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-RUKM6FCF.js
2971
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-RUKM6FCF.js
2953
2972
  var MAX_PATH_SEARCH_DEPTH = 30;
2954
2973
  var depth = 0;
2955
2974
  function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
@@ -2960,7 +2979,7 @@ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
2960
2979
  }
2961
2980
 
2962
2981
  //#endregion
2963
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-V3GMJ4TX.js
2982
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-V3GMJ4TX.js
2964
2983
  var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2965
2984
  function normalizeWindowsPath(input = "") {
2966
2985
  if (!input) return input;
@@ -3042,7 +3061,7 @@ var isAbsolute = function(p) {
3042
3061
  };
3043
3062
 
3044
3063
  //#endregion
3045
- //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.21/node_modules/@storm-software/config-tools/dist/chunk-LF3SAK2O.js
3064
+ //#region ../../node_modules/.pnpm/@storm-software+config-tools@1.189.22/node_modules/@storm-software/config-tools/dist/chunk-LF3SAK2O.js
3046
3065
  var rootFiles = [
3047
3066
  "storm-workspace.json",
3048
3067
  "storm-workspace.yaml",
@@ -11865,11 +11884,27 @@ function toArray(array) {
11865
11884
  */
11866
11885
  async function resolveOptions(options) {
11867
11886
  const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : joinPaths(options.projectRoot, "tsconfig.json");
11868
- const schemas = toArray(options.schemas ? options.schemas : joinPaths(options.projectRoot, "schemas/**/*.capnp")).filter(Boolean).map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot));
11887
+ const schemas = [];
11888
+ if (options.schemas) schemas.push(...toArray(options.schemas).filter(Boolean).map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot)).map((schema) => schema.includes("*") || schema.endsWith(".capnp") || existsSync$1(schema) && listSync(joinPaths(schema, "**/*.capnp")).length > 0 ? schema : existsSync$1(joinPaths(options.projectRoot, schema)) && listSync(joinPaths(options.projectRoot, schema, "**/*.capnp")).length > 0 ? joinPaths(options.projectRoot, schema, "**/*.capnp") : existsSync$1(joinPaths(options.workspaceRoot, schema)) && listSync(joinPaths(options.workspaceRoot, schema, "**/*.capnp")).length > 0 ? joinPaths(options.workspaceRoot, schema, "**/*.capnp") : schema));
11889
+ else schemas.push(existsSync$1(joinPaths(options.projectRoot, "schemas/**/*.capnp")) && listSync(joinPaths(options.projectRoot, "schemas/**/*.capnp")).length > 0 ? joinPaths(options.projectRoot, "schemas/**/*.capnp") : existsSync$1(joinPaths(options.workspaceRoot, "schemas/**/*.capnp")) && listSync(joinPaths(options.workspaceRoot, "schemas/**/*.capnp")).length > 0 ? joinPaths(options.workspaceRoot, "schemas/**/*.capnp") : "schemas/**/*.capnp");
11869
11890
  let resolvedTsconfig;
11870
11891
  if (options.tsconfig) resolvedTsconfig = options.tsconfig;
11871
11892
  else {
11872
- if (!tsconfigPath || !existsSync$1(tsconfigPath)) {
11893
+ let resolvedTsconfigPath = tsconfigPath;
11894
+ if (!existsSync$1(resolvedTsconfigPath)) {
11895
+ const found = [
11896
+ joinPaths(options.projectRoot, "tsconfig.json"),
11897
+ joinPaths(options.projectRoot, "tsconfig.lib.json"),
11898
+ joinPaths(options.projectRoot, "tsconfig.app.json"),
11899
+ joinPaths(options.projectRoot, "tsconfig.capnp.json"),
11900
+ joinPaths(options.workspaceRoot, "tsconfig.json"),
11901
+ joinPaths(options.workspaceRoot, "tsconfig.lib.json"),
11902
+ joinPaths(options.workspaceRoot, "tsconfig.app.json"),
11903
+ joinPaths(options.workspaceRoot, "tsconfig.capnp.json")
11904
+ ].find((path$1) => existsSync$1(path$1));
11905
+ if (found) resolvedTsconfigPath = found;
11906
+ }
11907
+ if (!resolvedTsconfigPath || !existsSync$1(resolvedTsconfigPath)) {
11873
11908
  const errorMessage = tsconfigPath ? `✖ The specified TypeScript configuration file "${tsconfigPath}" does not exist. Please provide a valid path.` : "✖ The specified TypeScript configuration file does not exist. Please provide a valid path.";
11874
11909
  writeFatal(errorMessage, { logLevel: "all" });
11875
11910
  throw new Error(errorMessage);
@@ -11896,6 +11931,15 @@ async function resolveOptions(options) {
11896
11931
  return null;
11897
11932
  }
11898
11933
  const output = options.output ? options.output.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : joinPaths(options.projectRoot, relativePath(tsconfigPath ? findFilePath(tsconfigPath) : options.projectRoot, joinPaths(options.workspaceRoot, resolvedSchemas[0].endsWith(".capnp") ? findFilePath(resolvedSchemas[0]) : resolvedSchemas[0])));
11934
+ if (!existsSync$1(output)) {
11935
+ if (isFile(output)) {
11936
+ const errorMessage = `✖ The specified output path "${output}" is a file. Please provide a valid directory path.`;
11937
+ writeFatal(errorMessage, { logLevel: "all" });
11938
+ throw new Error(errorMessage);
11939
+ }
11940
+ writeInfo(`Output directory "${output}" does not exist. It will be created automatically.`, { logLevel: "all" });
11941
+ await createDirectory(output);
11942
+ }
11899
11943
  resolvedTsconfig.options.outDir = output;
11900
11944
  return {
11901
11945
  ...options,
@@ -11976,13 +12020,13 @@ const compileAction = (workspaceRoot) => async (options) => {
11976
12020
  writeWarning("✖ Unable to resolve Cap'n Proto compiler options - the program will terminate", { logLevel: "all" });
11977
12021
  return;
11978
12022
  }
11979
- writeInfo(`📦 Storm Cap'n Proto Compiler will output ${resolvedOptions.ts ? "TypeScript code" : ""}${resolvedOptions.js ? resolvedOptions.ts ? ", JavaScript code" : "JavaScript code" : ""}${resolvedOptions.dts ? resolvedOptions.ts || resolvedOptions.js ? ", TypeScript declarations" : "TypeScript declarations" : ""} files from schemas at ${options.schema ? options.schema.replace("{projectRoot}", resolvedOptions.projectRoot).replace("{workspaceRoot}", resolvedOptions.workspaceRoot) : resolvedOptions.projectRoot} to ${resolvedOptions.tsconfig.options.outDir}...`, { logLevel: "all" });
12023
+ writeInfo(`Storm Cap'n Proto Compiler will output ${resolvedOptions.ts ? "TypeScript code" : ""}${resolvedOptions.js ? resolvedOptions.ts ? ", JavaScript code" : "JavaScript code" : ""}${resolvedOptions.dts ? resolvedOptions.ts || resolvedOptions.js ? ", TypeScript declarations" : "TypeScript declarations" : ""} files from schemas at ${options.schema ? options.schema.replace("{projectRoot}", resolvedOptions.projectRoot).replace("{workspaceRoot}", resolvedOptions.workspaceRoot) : resolvedOptions.projectRoot} to ${resolvedOptions.tsconfig.options.outDir}...`, { logLevel: "all" });
11980
12024
  const result = await capnpc(resolvedOptions);
11981
12025
  if (result.files.size === 0) {
11982
- writeWarning("⚠️ No files were generated. Please check your schema files.", { logLevel: "all" });
12026
+ writeWarning("No files were generated. Please check your schema files.", { logLevel: "all" });
11983
12027
  return;
11984
12028
  }
11985
- writeInfo(`📋 Writing ${result.files.size} generated files to disk...`, { logLevel: "all" });
12029
+ writeInfo(`Writing ${result.files.size} generated files to disk...`, { logLevel: "all" });
11986
12030
  for (const [fileName, content] of result.files) {
11987
12031
  let filePath = fileName;
11988
12032
  if (!existsSync$1(findFilePath(filePath))) {
@@ -11995,17 +12039,23 @@ const compileAction = (workspaceRoot) => async (options) => {
11995
12039
  }
11996
12040
  await writeFile(filePath, content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2)));
11997
12041
  }
11998
- writeSuccess("⚡ Storm Cap'n Proto Compiler completed successfully.", { logLevel: "all" });
12042
+ writeSuccess(`✔ Storm Cap'n Proto Compiler completed successfully.`, { logLevel: "all" });
11999
12043
  };
12044
+ /**
12045
+ * Creates and configures the Cap'n Proto compiler CLI program.
12046
+ *
12047
+ * @returns The configured Command instance for the Cap'n Proto compiler CLI.
12048
+ */
12000
12049
  function createProgram() {
12001
- writeInfo("⚡ Running Storm Cap'n Proto Compiler Tools", { logLevel: "all" });
12002
- const root = findWorkspaceRootSafe(process.cwd());
12003
- process.env.STORM_WORKSPACE_ROOT ??= root;
12004
- process.env.NX_WORKSPACE_ROOT_PATH ??= root;
12005
- if (root) process.chdir(root);
12050
+ writeInfo(`${brandIcon()} Running Storm Cap'n Proto Compiler Tools`, { logLevel: "all" });
12051
+ const workspaceRoot = findWorkspaceRootSafe(process.cwd());
12052
+ process.env.STORM_WORKSPACE_ROOT ??= workspaceRoot;
12053
+ process.env.NX_WORKSPACE_ROOT_PATH ??= workspaceRoot;
12054
+ let projectRoot;
12055
+ if (workspaceRoot !== process.cwd() && (existsSync$1(joinPaths(process.cwd(), "package.json")) || existsSync$1(joinPaths(process.cwd(), "project.json")))) projectRoot = process.cwd();
12006
12056
  const program$1 = new Command();
12007
12057
  program$1.name("storm-capnpc").description("Run the Storm Cap'n Proto compiler").version("1.0.0", "-v --version", "display CLI version");
12008
- program$1.command("compile", { isDefault: true }).option("-p --project-root <path>", "The path to the project root directory").option("-s --schema <path>", "The directory (or a glob to the directory) containing the Cap'n Proto schema files to compile (default: current working directory)").option("-o --output <path>", "The directory to output the generated files to").option("--tsconfig <path>", "The path to the TypeScript configuration file to use for compilation").option("--skip-generating-id", "Skip generating a new 64-bit unique ID for use in a Cap'n Proto schema").option("--no-standard-imports", "Skip adding default import paths; use only those specified by -I").option("--no-ts", "An indicator to disable generation of TypeScript files").option("--js", "An indicator to generate JavaScript files").option("--dts", "An indicator to generate TypeScript declaration files").option("--no-dts", "An indicator to disable generation of TypeScript declaration files").option("-w --workspace-root <path>", "The path to the workspace root directory", root || process.cwd()).option("--tty", "An indicator to enable TTY mode for the compiler").action(compileAction(root));
12058
+ program$1.command("compile", { isDefault: true }).option("-p --project-root <path>", "The path to the project root directory", projectRoot).option("-s --schema <path>", "The directory (or a glob to the directory) containing the Cap'n Proto schema files to compile (default: current working directory)").option("-o --output <path>", "The directory to output the generated files to").option("--tsconfig <path>", "The path to the TypeScript configuration file to use for compilation").option("--skip-generating-id", "Skip generating a new 64-bit unique ID for use in a Cap'n Proto schema").option("--no-standard-imports", "Skip adding default import paths; use only those specified by -I").option("--no-ts", "An indicator to disable generation of TypeScript files").option("--js", "An indicator to generate JavaScript files").option("--dts", "An indicator to generate TypeScript declaration files").option("--no-dts", "An indicator to disable generation of TypeScript declaration files").option("-w --workspace-root <path>", "The path to the workspace root directory", workspaceRoot || process.cwd()).option("--tty", "An indicator to enable TTY mode for the compiler").action(compileAction(workspaceRoot));
12009
12059
  return program$1;
12010
12060
  }
12011
12061
  (async () => {