@stryke/capnp 0.12.80 → 0.12.81

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.
@@ -1,4 +1,4 @@
1
- const require_helpers = require('./helpers-B7k70mjp.cjs');
1
+ const require_helpers = require('./helpers-CJFuoRwm.cjs');
2
2
  const require_capnp_es_GpvEvMIK = require('./capnp-es.GpvEvMIK-BY4gHyC5.cjs');
3
3
  let __stryke_fs_exists = require("@stryke/fs/exists");
4
4
  let typescript = require("typescript");
package/dist/compile.cjs CHANGED
@@ -1,5 +1,5 @@
1
- require('./helpers-B7k70mjp.cjs');
2
- const require_compile = require('./compile-BU-HlLfU.cjs');
1
+ require('./helpers-CJFuoRwm.cjs');
2
+ const require_compile = require('./compile-DaPDjVFU.cjs');
3
3
 
4
4
  exports.capnpc = require_compile.capnpc;
5
5
  exports.compile = require_compile.compile;
package/dist/compile.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./helpers-DPPIVk-O.mjs";
2
- import { n as compile, t as capnpc } from "./compile-CJ8KYCju.mjs";
1
+ import "./helpers-CJpyoOE6.mjs";
2
+ import { n as compile, t as capnpc } from "./compile-BFDF_9ct.mjs";
3
3
 
4
4
  export { capnpc, compile };
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  //#endregion
29
29
  let __stryke_fs_exists = require("@stryke/fs/exists");
30
30
  let typescript = require("typescript");
31
+ let __stryke_fs = require("@stryke/fs");
31
32
  let __stryke_fs_json = require("@stryke/fs/json");
32
33
  let __stryke_fs_list_files = require("@stryke/fs/list-files");
33
34
  let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
@@ -2877,6 +2878,7 @@ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? DEFAULT_COLOR_CON
2877
2878
  };
2878
2879
  var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
2879
2880
  var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
2881
+ var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
2880
2882
  var MAX_DEPTH = 6;
2881
2883
  var formatLogMessage = (message, options = {}, depth = 0) => {
2882
2884
  if (depth > MAX_DEPTH) return "<max depth>";
@@ -2923,11 +2925,27 @@ function toArray(array) {
2923
2925
  */
2924
2926
  async function resolveOptions(options) {
2925
2927
  const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.json");
2926
- 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));
2928
+ const schemas = [];
2929
+ 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));
2930
+ 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");
2927
2931
  let resolvedTsconfig;
2928
2932
  if (options.tsconfig) resolvedTsconfig = options.tsconfig;
2929
2933
  else {
2930
- if (!tsconfigPath || !(0, __stryke_fs_exists.existsSync)(tsconfigPath)) {
2934
+ let resolvedTsconfigPath = tsconfigPath;
2935
+ if (!(0, __stryke_fs_exists.existsSync)(resolvedTsconfigPath)) {
2936
+ const found = [
2937
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.json"),
2938
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.lib.json"),
2939
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.app.json"),
2940
+ (0, __stryke_path_join_paths.joinPaths)(options.projectRoot, "tsconfig.capnp.json"),
2941
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.json"),
2942
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.lib.json"),
2943
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.app.json"),
2944
+ (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tsconfig.capnp.json")
2945
+ ].find((path) => (0, __stryke_fs_exists.existsSync)(path));
2946
+ if (found) resolvedTsconfigPath = found;
2947
+ }
2948
+ if (!resolvedTsconfigPath || !(0, __stryke_fs_exists.existsSync)(resolvedTsconfigPath)) {
2931
2949
  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.";
2932
2950
  writeFatal(errorMessage, { logLevel: "all" });
2933
2951
  throw new Error(errorMessage);
@@ -2954,6 +2972,15 @@ async function resolveOptions(options) {
2954
2972
  return null;
2955
2973
  }
2956
2974
  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])));
2975
+ if (!(0, __stryke_fs_exists.existsSync)(output)) {
2976
+ if ((0, __stryke_fs.isFile)(output)) {
2977
+ const errorMessage = `✖ The specified output path "${output}" is a file. Please provide a valid directory path.`;
2978
+ writeFatal(errorMessage, { logLevel: "all" });
2979
+ throw new Error(errorMessage);
2980
+ }
2981
+ writeInfo(`Output directory "${output}" does not exist. It will be created automatically.`, { logLevel: "all" });
2982
+ await (0, __stryke_fs.createDirectory)(output);
2983
+ }
2957
2984
  resolvedTsconfig.options.outDir = output;
2958
2985
  return {
2959
2986
  ...options,
@@ -1,8 +1,9 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { existsSync } from "@stryke/fs/exists";
3
3
  import { parseJsonConfigFileContent, sys } from "typescript";
4
+ import { createDirectory, isFile } from "@stryke/fs";
4
5
  import { readJsonFile } from "@stryke/fs/json";
5
- import { listFiles } from "@stryke/fs/list-files";
6
+ import { listFiles, listSync } from "@stryke/fs/list-files";
6
7
  import { findFilePath, relativePath } from "@stryke/path/file-path-fns";
7
8
  import { joinPaths } from "@stryke/path/join-paths";
8
9
 
@@ -2879,6 +2880,7 @@ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? DEFAULT_COLOR_CON
2879
2880
  };
2880
2881
  var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
2881
2882
  var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
2883
+ var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
2882
2884
  var MAX_DEPTH = 6;
2883
2885
  var formatLogMessage = (message, options = {}, depth = 0) => {
2884
2886
  if (depth > MAX_DEPTH) return "<max depth>";
@@ -2925,11 +2927,27 @@ function toArray(array) {
2925
2927
  */
2926
2928
  async function resolveOptions(options) {
2927
2929
  const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : joinPaths(options.projectRoot, "tsconfig.json");
2928
- 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));
2930
+ const schemas = [];
2931
+ 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(schema) && listSync(joinPaths(schema, "**/*.capnp")).length > 0 ? schema : existsSync(joinPaths(options.projectRoot, schema)) && listSync(joinPaths(options.projectRoot, schema, "**/*.capnp")).length > 0 ? joinPaths(options.projectRoot, schema, "**/*.capnp") : existsSync(joinPaths(options.workspaceRoot, schema)) && listSync(joinPaths(options.workspaceRoot, schema, "**/*.capnp")).length > 0 ? joinPaths(options.workspaceRoot, schema, "**/*.capnp") : schema));
2932
+ else schemas.push(existsSync(joinPaths(options.projectRoot, "schemas/**/*.capnp")) && listSync(joinPaths(options.projectRoot, "schemas/**/*.capnp")).length > 0 ? joinPaths(options.projectRoot, "schemas/**/*.capnp") : existsSync(joinPaths(options.workspaceRoot, "schemas/**/*.capnp")) && listSync(joinPaths(options.workspaceRoot, "schemas/**/*.capnp")).length > 0 ? joinPaths(options.workspaceRoot, "schemas/**/*.capnp") : "schemas/**/*.capnp");
2929
2933
  let resolvedTsconfig;
2930
2934
  if (options.tsconfig) resolvedTsconfig = options.tsconfig;
2931
2935
  else {
2932
- if (!tsconfigPath || !existsSync(tsconfigPath)) {
2936
+ let resolvedTsconfigPath = tsconfigPath;
2937
+ if (!existsSync(resolvedTsconfigPath)) {
2938
+ const found = [
2939
+ joinPaths(options.projectRoot, "tsconfig.json"),
2940
+ joinPaths(options.projectRoot, "tsconfig.lib.json"),
2941
+ joinPaths(options.projectRoot, "tsconfig.app.json"),
2942
+ joinPaths(options.projectRoot, "tsconfig.capnp.json"),
2943
+ joinPaths(options.workspaceRoot, "tsconfig.json"),
2944
+ joinPaths(options.workspaceRoot, "tsconfig.lib.json"),
2945
+ joinPaths(options.workspaceRoot, "tsconfig.app.json"),
2946
+ joinPaths(options.workspaceRoot, "tsconfig.capnp.json")
2947
+ ].find((path) => existsSync(path));
2948
+ if (found) resolvedTsconfigPath = found;
2949
+ }
2950
+ if (!resolvedTsconfigPath || !existsSync(resolvedTsconfigPath)) {
2933
2951
  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.";
2934
2952
  writeFatal(errorMessage, { logLevel: "all" });
2935
2953
  throw new Error(errorMessage);
@@ -2956,6 +2974,15 @@ async function resolveOptions(options) {
2956
2974
  return null;
2957
2975
  }
2958
2976
  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])));
2977
+ if (!existsSync(output)) {
2978
+ if (isFile(output)) {
2979
+ const errorMessage = `✖ The specified output path "${output}" is a file. Please provide a valid directory path.`;
2980
+ writeFatal(errorMessage, { logLevel: "all" });
2981
+ throw new Error(errorMessage);
2982
+ }
2983
+ writeInfo(`Output directory "${output}" does not exist. It will be created automatically.`, { logLevel: "all" });
2984
+ await createDirectory(output);
2985
+ }
2959
2986
  resolvedTsconfig.options.outDir = output;
2960
2987
  return {
2961
2988
  ...options,
@@ -2973,4 +3000,4 @@ async function resolveOptions(options) {
2973
3000
 
2974
3001
  //#endregion
2975
3002
  export { writeWarning as n, resolveOptions as t };
2976
- //# sourceMappingURL=helpers-DPPIVk-O.mjs.map
3003
+ //# sourceMappingURL=helpers-CJpyoOE6.mjs.map