@stryke/capnp 0.10.3 → 0.10.5
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 +127 -8
- package/bin/capnpc.js +127 -8
- package/dist/{chunk-SW7GJVYC.js → chunk-FP42YKAZ.js} +19 -3
- package/dist/{chunk-I7MRPN6I.cjs → chunk-GTDJDX77.cjs} +20 -4
- package/dist/{chunk-XU7T5EQG.js → chunk-NKATTHKT.js} +114 -7
- package/dist/{chunk-L3LVFSZK.cjs → chunk-SH2ISQVR.cjs} +117 -10
- package/dist/compile.cjs +3 -3
- package/dist/compile.js +2 -2
- package/dist/helpers.cjs +2 -2
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/schemas/persistent.cjs +20 -20
- package/schemas/persistent.js +1 -1
- package/schemas/rpc-twoparty.cjs +32 -32
- package/schemas/rpc-twoparty.js +1 -1
- package/schemas/rpc.cjs +495 -495
- package/schemas/rpc.js +1 -1
- package/schemas/schema.cjs +675 -675
- package/schemas/schema.js +1 -1
- package/schemas/{chunk-OKQBZPI3.js → chunk-YDIMDO2B.js} +6 -6
- package/schemas/{chunk-ERVRKJ2S.cjs → chunk-Z7HGBQR4.cjs} +6 -6
package/bin/capnpc.cjs
CHANGED
|
@@ -210,6 +210,20 @@ function slash(path) {
|
|
|
210
210
|
}
|
|
211
211
|
__name(slash, "slash");
|
|
212
212
|
|
|
213
|
+
// ../path/src/is-file.ts
|
|
214
|
+
function isFile(path, additionalPath) {
|
|
215
|
+
return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path) : path, {
|
|
216
|
+
throwIfNoEntry: false
|
|
217
|
+
})?.isFile());
|
|
218
|
+
}
|
|
219
|
+
__name(isFile, "isFile");
|
|
220
|
+
function isDirectory(path, additionalPath) {
|
|
221
|
+
return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path) : path, {
|
|
222
|
+
throwIfNoEntry: false
|
|
223
|
+
})?.isDirectory());
|
|
224
|
+
}
|
|
225
|
+
__name(isDirectory, "isDirectory");
|
|
226
|
+
|
|
213
227
|
// ../path/src/correct-path.ts
|
|
214
228
|
function normalizeWindowsPath2(input = "") {
|
|
215
229
|
if (!input) {
|
|
@@ -222,6 +236,99 @@ __name(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
|
222
236
|
// ../path/src/get-workspace-root.ts
|
|
223
237
|
var import_config_tools = require("@storm-software/config-tools");
|
|
224
238
|
|
|
239
|
+
// ../path/src/get-parent-path.ts
|
|
240
|
+
var resolveParentPath = /* @__PURE__ */ __name((path, count = 1) => {
|
|
241
|
+
let parentPath = path.replaceAll(/\/+$/g, "");
|
|
242
|
+
for (let i = 0; i < count; i++) {
|
|
243
|
+
parentPath = joinPaths(parentPath, "..");
|
|
244
|
+
}
|
|
245
|
+
return parentPath;
|
|
246
|
+
}, "resolveParentPath");
|
|
247
|
+
var getParentPath = /* @__PURE__ */ __name((name, cwd, options) => {
|
|
248
|
+
const ignoreCase = options?.ignoreCase ?? true;
|
|
249
|
+
const skipCwd = options?.skipCwd ?? false;
|
|
250
|
+
const targetType = options?.targetType ?? "both";
|
|
251
|
+
let dir = cwd;
|
|
252
|
+
if (skipCwd) {
|
|
253
|
+
dir = resolveParentPath(cwd);
|
|
254
|
+
}
|
|
255
|
+
let names = Array.isArray(name) ? name : [
|
|
256
|
+
name
|
|
257
|
+
];
|
|
258
|
+
if (ignoreCase) {
|
|
259
|
+
names = names.map((name2) => name2.toLowerCase());
|
|
260
|
+
}
|
|
261
|
+
while (true) {
|
|
262
|
+
const target = names.find((name2) => isFile(joinPaths(dir, name2)) && (targetType === "file" || targetType === "both") || isDirectory(joinPaths(dir, name2)) && (targetType === "directory" || targetType === "both"));
|
|
263
|
+
if (target) {
|
|
264
|
+
return joinPaths(dir, target);
|
|
265
|
+
}
|
|
266
|
+
const parentDir = resolveParentPath(dir);
|
|
267
|
+
if (parentDir === dir) {
|
|
268
|
+
return void 0;
|
|
269
|
+
}
|
|
270
|
+
dir = parentDir;
|
|
271
|
+
}
|
|
272
|
+
}, "getParentPath");
|
|
273
|
+
|
|
274
|
+
// ../path/src/is-root-dir.ts
|
|
275
|
+
var isSystemRoot = /* @__PURE__ */ __name((dir) => {
|
|
276
|
+
return Boolean(dir === "/" || dir === "c:\\" || dir === "C:\\");
|
|
277
|
+
}, "isSystemRoot");
|
|
278
|
+
|
|
279
|
+
// ../path/src/get-workspace-root.ts
|
|
280
|
+
var WORKSPACE_ROOT_CONTENT = [
|
|
281
|
+
"package-lock.json",
|
|
282
|
+
"yarn.lock",
|
|
283
|
+
"pnpm-lock.yaml",
|
|
284
|
+
"bun.lock",
|
|
285
|
+
"nx.json",
|
|
286
|
+
"knip.json",
|
|
287
|
+
"pnpm-workspace.yaml",
|
|
288
|
+
"LICENSE",
|
|
289
|
+
".all-contributorsrc",
|
|
290
|
+
".whitesource",
|
|
291
|
+
"syncpack.config.js",
|
|
292
|
+
"syncpack.json",
|
|
293
|
+
"socket.yaml",
|
|
294
|
+
"lefthook.yaml",
|
|
295
|
+
".npmrc",
|
|
296
|
+
".log4brains.yml",
|
|
297
|
+
".huskyrc",
|
|
298
|
+
".husky",
|
|
299
|
+
".lintstagedrc",
|
|
300
|
+
".commitlintrc",
|
|
301
|
+
"lefthook.yml",
|
|
302
|
+
".github",
|
|
303
|
+
".nx",
|
|
304
|
+
".vscode",
|
|
305
|
+
"patches"
|
|
306
|
+
];
|
|
307
|
+
function getWorkspaceRoot(dir = process.cwd()) {
|
|
308
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
309
|
+
return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
|
|
310
|
+
}
|
|
311
|
+
const root = (0, import_config_tools.findWorkspaceRootSafe)(dir);
|
|
312
|
+
if (root) {
|
|
313
|
+
return root;
|
|
314
|
+
}
|
|
315
|
+
let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);
|
|
316
|
+
if (result) {
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
result = dir;
|
|
320
|
+
while (result && !isSystemRoot(result)) {
|
|
321
|
+
result = getParentPath("storm-workspace.json", result, {
|
|
322
|
+
skipCwd: true
|
|
323
|
+
});
|
|
324
|
+
if (result) {
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return dir;
|
|
329
|
+
}
|
|
330
|
+
__name(getWorkspaceRoot, "getWorkspaceRoot");
|
|
331
|
+
|
|
225
332
|
// ../path/src/file-path-fns.ts
|
|
226
333
|
function findFileName(filePath, options = {}) {
|
|
227
334
|
const { requireExtension = false, withExtension = true } = options;
|
|
@@ -255,6 +362,20 @@ var import_promises5 = require("fs/promises");
|
|
|
255
362
|
// src/compile.ts
|
|
256
363
|
var import_console2 = require("@storm-software/config-tools/logger/console");
|
|
257
364
|
|
|
365
|
+
// ../path/src/is-parent-path.ts
|
|
366
|
+
function isParentPath(childPath, parentPath) {
|
|
367
|
+
const normalizedChild = slash(childPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
368
|
+
const normalizedParent = slash(parentPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
369
|
+
return normalizedChild !== normalizedParent && normalizedChild.startsWith(`${normalizedParent}/`);
|
|
370
|
+
}
|
|
371
|
+
__name(isParentPath, "isParentPath");
|
|
372
|
+
|
|
373
|
+
// ../path/src/replace.ts
|
|
374
|
+
function replacePath(childPath, parentPath = process.cwd()) {
|
|
375
|
+
return isParentPath(childPath, parentPath) ? slash(childPath).replace(slash(parentPath), "").replace(/^\//, "") : childPath;
|
|
376
|
+
}
|
|
377
|
+
__name(replacePath, "replacePath");
|
|
378
|
+
|
|
258
379
|
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=503a440bd2bef41c0cb22819bc4ced5a7f04993fb999f0d944e284220f14916b_typescript@5.9.2/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
|
|
259
380
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
260
381
|
|
|
@@ -7928,7 +8049,7 @@ __name(listFiles, "listFiles");
|
|
|
7928
8049
|
var import_typescript3 = require("typescript");
|
|
7929
8050
|
async function resolveOptions(options) {
|
|
7930
8051
|
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
7931
|
-
const schemas = toArray(options.schemas ?
|
|
8052
|
+
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));
|
|
7932
8053
|
let resolvedTsconfig;
|
|
7933
8054
|
if (options.tsconfig) {
|
|
7934
8055
|
resolvedTsconfig = options.tsconfig;
|
|
@@ -7956,13 +8077,11 @@ async function resolveOptions(options) {
|
|
|
7956
8077
|
}
|
|
7957
8078
|
const resolvedSchemas = [];
|
|
7958
8079
|
for (const schema of schemas) {
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
}
|
|
7963
|
-
} else {
|
|
7964
|
-
resolvedSchemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
8080
|
+
let formattedSchema = schema;
|
|
8081
|
+
if (!schema.endsWith(".capnp") && !schema.includes("*")) {
|
|
8082
|
+
formattedSchema = `${schema.replace(/\/$/g, "")}/*.capnp`;
|
|
7965
8083
|
}
|
|
8084
|
+
resolvedSchemas.push(...await listFiles(formattedSchema));
|
|
7966
8085
|
}
|
|
7967
8086
|
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
7968
8087
|
(0, import_console.writeWarning)(`\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
@@ -8010,7 +8129,7 @@ async function capnpc(options) {
|
|
|
8010
8129
|
if (output) {
|
|
8011
8130
|
if (!existsSync(output)) {
|
|
8012
8131
|
(0, import_console2.writeWarning)(`Output directory "${output}" does not exist, it will be created...`);
|
|
8013
|
-
await createDirectory(output);
|
|
8132
|
+
await createDirectory(replacePath(output, getWorkspaceRoot()));
|
|
8014
8133
|
}
|
|
8015
8134
|
opts.push(`-o-:${output}`);
|
|
8016
8135
|
} else {
|
package/bin/capnpc.js
CHANGED
|
@@ -179,6 +179,20 @@ function slash(path) {
|
|
|
179
179
|
}
|
|
180
180
|
__name(slash, "slash");
|
|
181
181
|
|
|
182
|
+
// ../path/src/is-file.ts
|
|
183
|
+
function isFile(path, additionalPath) {
|
|
184
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, {
|
|
185
|
+
throwIfNoEntry: false
|
|
186
|
+
})?.isFile());
|
|
187
|
+
}
|
|
188
|
+
__name(isFile, "isFile");
|
|
189
|
+
function isDirectory(path, additionalPath) {
|
|
190
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, {
|
|
191
|
+
throwIfNoEntry: false
|
|
192
|
+
})?.isDirectory());
|
|
193
|
+
}
|
|
194
|
+
__name(isDirectory, "isDirectory");
|
|
195
|
+
|
|
182
196
|
// ../path/src/correct-path.ts
|
|
183
197
|
function normalizeWindowsPath2(input = "") {
|
|
184
198
|
if (!input) {
|
|
@@ -191,6 +205,99 @@ __name(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
|
191
205
|
// ../path/src/get-workspace-root.ts
|
|
192
206
|
import { findWorkspaceRootSafe } from "@storm-software/config-tools";
|
|
193
207
|
|
|
208
|
+
// ../path/src/get-parent-path.ts
|
|
209
|
+
var resolveParentPath = /* @__PURE__ */ __name((path, count = 1) => {
|
|
210
|
+
let parentPath = path.replaceAll(/\/+$/g, "");
|
|
211
|
+
for (let i = 0; i < count; i++) {
|
|
212
|
+
parentPath = joinPaths(parentPath, "..");
|
|
213
|
+
}
|
|
214
|
+
return parentPath;
|
|
215
|
+
}, "resolveParentPath");
|
|
216
|
+
var getParentPath = /* @__PURE__ */ __name((name, cwd, options) => {
|
|
217
|
+
const ignoreCase = options?.ignoreCase ?? true;
|
|
218
|
+
const skipCwd = options?.skipCwd ?? false;
|
|
219
|
+
const targetType = options?.targetType ?? "both";
|
|
220
|
+
let dir = cwd;
|
|
221
|
+
if (skipCwd) {
|
|
222
|
+
dir = resolveParentPath(cwd);
|
|
223
|
+
}
|
|
224
|
+
let names = Array.isArray(name) ? name : [
|
|
225
|
+
name
|
|
226
|
+
];
|
|
227
|
+
if (ignoreCase) {
|
|
228
|
+
names = names.map((name2) => name2.toLowerCase());
|
|
229
|
+
}
|
|
230
|
+
while (true) {
|
|
231
|
+
const target = names.find((name2) => isFile(joinPaths(dir, name2)) && (targetType === "file" || targetType === "both") || isDirectory(joinPaths(dir, name2)) && (targetType === "directory" || targetType === "both"));
|
|
232
|
+
if (target) {
|
|
233
|
+
return joinPaths(dir, target);
|
|
234
|
+
}
|
|
235
|
+
const parentDir = resolveParentPath(dir);
|
|
236
|
+
if (parentDir === dir) {
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
dir = parentDir;
|
|
240
|
+
}
|
|
241
|
+
}, "getParentPath");
|
|
242
|
+
|
|
243
|
+
// ../path/src/is-root-dir.ts
|
|
244
|
+
var isSystemRoot = /* @__PURE__ */ __name((dir) => {
|
|
245
|
+
return Boolean(dir === "/" || dir === "c:\\" || dir === "C:\\");
|
|
246
|
+
}, "isSystemRoot");
|
|
247
|
+
|
|
248
|
+
// ../path/src/get-workspace-root.ts
|
|
249
|
+
var WORKSPACE_ROOT_CONTENT = [
|
|
250
|
+
"package-lock.json",
|
|
251
|
+
"yarn.lock",
|
|
252
|
+
"pnpm-lock.yaml",
|
|
253
|
+
"bun.lock",
|
|
254
|
+
"nx.json",
|
|
255
|
+
"knip.json",
|
|
256
|
+
"pnpm-workspace.yaml",
|
|
257
|
+
"LICENSE",
|
|
258
|
+
".all-contributorsrc",
|
|
259
|
+
".whitesource",
|
|
260
|
+
"syncpack.config.js",
|
|
261
|
+
"syncpack.json",
|
|
262
|
+
"socket.yaml",
|
|
263
|
+
"lefthook.yaml",
|
|
264
|
+
".npmrc",
|
|
265
|
+
".log4brains.yml",
|
|
266
|
+
".huskyrc",
|
|
267
|
+
".husky",
|
|
268
|
+
".lintstagedrc",
|
|
269
|
+
".commitlintrc",
|
|
270
|
+
"lefthook.yml",
|
|
271
|
+
".github",
|
|
272
|
+
".nx",
|
|
273
|
+
".vscode",
|
|
274
|
+
"patches"
|
|
275
|
+
];
|
|
276
|
+
function getWorkspaceRoot(dir = process.cwd()) {
|
|
277
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
278
|
+
return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
|
|
279
|
+
}
|
|
280
|
+
const root = findWorkspaceRootSafe(dir);
|
|
281
|
+
if (root) {
|
|
282
|
+
return root;
|
|
283
|
+
}
|
|
284
|
+
let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);
|
|
285
|
+
if (result) {
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
result = dir;
|
|
289
|
+
while (result && !isSystemRoot(result)) {
|
|
290
|
+
result = getParentPath("storm-workspace.json", result, {
|
|
291
|
+
skipCwd: true
|
|
292
|
+
});
|
|
293
|
+
if (result) {
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return dir;
|
|
298
|
+
}
|
|
299
|
+
__name(getWorkspaceRoot, "getWorkspaceRoot");
|
|
300
|
+
|
|
194
301
|
// ../path/src/file-path-fns.ts
|
|
195
302
|
function findFileName(filePath, options = {}) {
|
|
196
303
|
const { requireExtension = false, withExtension = true } = options;
|
|
@@ -224,6 +331,20 @@ import { writeFile as writeFile2 } from "node:fs/promises";
|
|
|
224
331
|
// src/compile.ts
|
|
225
332
|
import { writeWarning as writeWarning2 } from "@storm-software/config-tools/logger/console";
|
|
226
333
|
|
|
334
|
+
// ../path/src/is-parent-path.ts
|
|
335
|
+
function isParentPath(childPath, parentPath) {
|
|
336
|
+
const normalizedChild = slash(childPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
337
|
+
const normalizedParent = slash(parentPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
338
|
+
return normalizedChild !== normalizedParent && normalizedChild.startsWith(`${normalizedParent}/`);
|
|
339
|
+
}
|
|
340
|
+
__name(isParentPath, "isParentPath");
|
|
341
|
+
|
|
342
|
+
// ../path/src/replace.ts
|
|
343
|
+
function replacePath(childPath, parentPath = process.cwd()) {
|
|
344
|
+
return isParentPath(childPath, parentPath) ? slash(childPath).replace(slash(parentPath), "").replace(/^\//, "") : childPath;
|
|
345
|
+
}
|
|
346
|
+
__name(replacePath, "replacePath");
|
|
347
|
+
|
|
227
348
|
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=503a440bd2bef41c0cb22819bc4ced5a7f04993fb999f0d944e284220f14916b_typescript@5.9.2/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
|
|
228
349
|
import ts from "typescript";
|
|
229
350
|
|
|
@@ -7897,7 +8018,7 @@ __name(listFiles, "listFiles");
|
|
|
7897
8018
|
import { parseJsonConfigFileContent, sys } from "typescript";
|
|
7898
8019
|
async function resolveOptions(options) {
|
|
7899
8020
|
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
7900
|
-
const schemas = toArray(options.schemas ?
|
|
8021
|
+
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));
|
|
7901
8022
|
let resolvedTsconfig;
|
|
7902
8023
|
if (options.tsconfig) {
|
|
7903
8024
|
resolvedTsconfig = options.tsconfig;
|
|
@@ -7925,13 +8046,11 @@ async function resolveOptions(options) {
|
|
|
7925
8046
|
}
|
|
7926
8047
|
const resolvedSchemas = [];
|
|
7927
8048
|
for (const schema of schemas) {
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
}
|
|
7932
|
-
} else {
|
|
7933
|
-
resolvedSchemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
8049
|
+
let formattedSchema = schema;
|
|
8050
|
+
if (!schema.endsWith(".capnp") && !schema.includes("*")) {
|
|
8051
|
+
formattedSchema = `${schema.replace(/\/$/g, "")}/*.capnp`;
|
|
7934
8052
|
}
|
|
8053
|
+
resolvedSchemas.push(...await listFiles(formattedSchema));
|
|
7935
8054
|
}
|
|
7936
8055
|
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
7937
8056
|
writeWarning(`\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
@@ -7979,7 +8098,7 @@ async function capnpc(options) {
|
|
|
7979
8098
|
if (output) {
|
|
7980
8099
|
if (!existsSync(output)) {
|
|
7981
8100
|
writeWarning2(`Output directory "${output}" does not exist, it will be created...`);
|
|
7982
|
-
await createDirectory(output);
|
|
8101
|
+
await createDirectory(replacePath(output, getWorkspaceRoot()));
|
|
7983
8102
|
}
|
|
7984
8103
|
opts.push(`-o-:${output}`);
|
|
7985
8104
|
} else {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDirectory,
|
|
3
3
|
existsSync,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
getWorkspaceRoot,
|
|
5
|
+
resolveOptions,
|
|
6
|
+
slash
|
|
7
|
+
} from "./chunk-NKATTHKT.js";
|
|
6
8
|
import {
|
|
7
9
|
CompositeList,
|
|
8
10
|
Message,
|
|
@@ -56,6 +58,20 @@ import {
|
|
|
56
58
|
// src/compile.ts
|
|
57
59
|
import { writeWarning } from "@storm-software/config-tools/logger/console";
|
|
58
60
|
|
|
61
|
+
// ../path/src/is-parent-path.ts
|
|
62
|
+
function isParentPath(childPath, parentPath) {
|
|
63
|
+
const normalizedChild = slash(childPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
64
|
+
const normalizedParent = slash(parentPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
65
|
+
return normalizedChild !== normalizedParent && normalizedChild.startsWith(`${normalizedParent}/`);
|
|
66
|
+
}
|
|
67
|
+
__name(isParentPath, "isParentPath");
|
|
68
|
+
|
|
69
|
+
// ../path/src/replace.ts
|
|
70
|
+
function replacePath(childPath, parentPath = process.cwd()) {
|
|
71
|
+
return isParentPath(childPath, parentPath) ? slash(childPath).replace(slash(parentPath), "").replace(/^\//, "") : childPath;
|
|
72
|
+
}
|
|
73
|
+
__name(replacePath, "replacePath");
|
|
74
|
+
|
|
59
75
|
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=503a440bd2bef41c0cb22819bc4ced5a7f04993fb999f0d944e284220f14916b_typescript@5.9.2/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
|
|
60
76
|
import ts from "typescript";
|
|
61
77
|
|
|
@@ -4057,7 +4073,7 @@ async function capnpc(options) {
|
|
|
4057
4073
|
if (output) {
|
|
4058
4074
|
if (!existsSync(output)) {
|
|
4059
4075
|
writeWarning(`Output directory "${output}" does not exist, it will be created...`);
|
|
4060
|
-
await createDirectory(output);
|
|
4076
|
+
await createDirectory(replacePath(output, getWorkspaceRoot()));
|
|
4061
4077
|
}
|
|
4062
4078
|
opts.push(`-o-:${output}`);
|
|
4063
4079
|
} else {
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkSH2ISQVRcjs = require('./chunk-SH2ISQVR.cjs');
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
|
|
@@ -56,6 +58,20 @@ var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
|
|
|
56
58
|
// src/compile.ts
|
|
57
59
|
var _console = require('@storm-software/config-tools/logger/console');
|
|
58
60
|
|
|
61
|
+
// ../path/src/is-parent-path.ts
|
|
62
|
+
function isParentPath(childPath, parentPath) {
|
|
63
|
+
const normalizedChild = _chunkSH2ISQVRcjs.slash.call(void 0, childPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
64
|
+
const normalizedParent = _chunkSH2ISQVRcjs.slash.call(void 0, parentPath.replace(/\\/g, "/").replace(/\/$/, ""));
|
|
65
|
+
return normalizedChild !== normalizedParent && normalizedChild.startsWith(`${normalizedParent}/`);
|
|
66
|
+
}
|
|
67
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, isParentPath, "isParentPath");
|
|
68
|
+
|
|
69
|
+
// ../path/src/replace.ts
|
|
70
|
+
function replacePath(childPath, parentPath = process.cwd()) {
|
|
71
|
+
return isParentPath(childPath, parentPath) ? _chunkSH2ISQVRcjs.slash.call(void 0, childPath).replace(_chunkSH2ISQVRcjs.slash.call(void 0, parentPath), "").replace(/^\//, "") : childPath;
|
|
72
|
+
}
|
|
73
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, replacePath, "replacePath");
|
|
74
|
+
|
|
59
75
|
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=503a440bd2bef41c0cb22819bc4ced5a7f04993fb999f0d944e284220f14916b_typescript@5.9.2/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
|
|
60
76
|
var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
|
|
61
77
|
|
|
@@ -4055,9 +4071,9 @@ async function capnpc(options) {
|
|
|
4055
4071
|
if (dataBuf.byteLength === 0) {
|
|
4056
4072
|
const opts = [];
|
|
4057
4073
|
if (output) {
|
|
4058
|
-
if (!
|
|
4074
|
+
if (!_chunkSH2ISQVRcjs.existsSync.call(void 0, output)) {
|
|
4059
4075
|
_console.writeWarning.call(void 0, `Output directory "${output}" does not exist, it will be created...`);
|
|
4060
|
-
await
|
|
4076
|
+
await _chunkSH2ISQVRcjs.createDirectory.call(void 0, replacePath(output, _chunkSH2ISQVRcjs.getWorkspaceRoot.call(void 0, )));
|
|
4061
4077
|
}
|
|
4062
4078
|
opts.push(`-o-:${output}`);
|
|
4063
4079
|
} else {
|
|
@@ -4086,7 +4102,7 @@ async function capnpc(options) {
|
|
|
4086
4102
|
}
|
|
4087
4103
|
_chunkUSNT2KNTcjs.__name.call(void 0, capnpc, "capnpc");
|
|
4088
4104
|
async function compile(dataBuf, options) {
|
|
4089
|
-
const resolvedOptions = await
|
|
4105
|
+
const resolvedOptions = await _chunkSH2ISQVRcjs.resolveOptions.call(void 0, options);
|
|
4090
4106
|
if (!resolvedOptions) {
|
|
4091
4107
|
_console.writeWarning.call(void 0, "\u2716 Unable to resolve Cap'n Proto compiler options - the program will terminate", {
|
|
4092
4108
|
logLevel: "all"
|
|
@@ -735,6 +735,20 @@ function slash(path) {
|
|
|
735
735
|
}
|
|
736
736
|
__name(slash, "slash");
|
|
737
737
|
|
|
738
|
+
// ../path/src/is-file.ts
|
|
739
|
+
function isFile(path, additionalPath) {
|
|
740
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, {
|
|
741
|
+
throwIfNoEntry: false
|
|
742
|
+
})?.isFile());
|
|
743
|
+
}
|
|
744
|
+
__name(isFile, "isFile");
|
|
745
|
+
function isDirectory(path, additionalPath) {
|
|
746
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, {
|
|
747
|
+
throwIfNoEntry: false
|
|
748
|
+
})?.isDirectory());
|
|
749
|
+
}
|
|
750
|
+
__name(isDirectory, "isDirectory");
|
|
751
|
+
|
|
738
752
|
// ../path/src/correct-path.ts
|
|
739
753
|
function normalizeWindowsPath2(input = "") {
|
|
740
754
|
if (!input) {
|
|
@@ -760,6 +774,99 @@ import { relative } from "node:path";
|
|
|
760
774
|
// ../path/src/get-workspace-root.ts
|
|
761
775
|
import { findWorkspaceRootSafe } from "@storm-software/config-tools";
|
|
762
776
|
|
|
777
|
+
// ../path/src/get-parent-path.ts
|
|
778
|
+
var resolveParentPath = /* @__PURE__ */ __name((path, count = 1) => {
|
|
779
|
+
let parentPath = path.replaceAll(/\/+$/g, "");
|
|
780
|
+
for (let i = 0; i < count; i++) {
|
|
781
|
+
parentPath = joinPaths(parentPath, "..");
|
|
782
|
+
}
|
|
783
|
+
return parentPath;
|
|
784
|
+
}, "resolveParentPath");
|
|
785
|
+
var getParentPath = /* @__PURE__ */ __name((name, cwd, options) => {
|
|
786
|
+
const ignoreCase = options?.ignoreCase ?? true;
|
|
787
|
+
const skipCwd = options?.skipCwd ?? false;
|
|
788
|
+
const targetType = options?.targetType ?? "both";
|
|
789
|
+
let dir = cwd;
|
|
790
|
+
if (skipCwd) {
|
|
791
|
+
dir = resolveParentPath(cwd);
|
|
792
|
+
}
|
|
793
|
+
let names = Array.isArray(name) ? name : [
|
|
794
|
+
name
|
|
795
|
+
];
|
|
796
|
+
if (ignoreCase) {
|
|
797
|
+
names = names.map((name2) => name2.toLowerCase());
|
|
798
|
+
}
|
|
799
|
+
while (true) {
|
|
800
|
+
const target = names.find((name2) => isFile(joinPaths(dir, name2)) && (targetType === "file" || targetType === "both") || isDirectory(joinPaths(dir, name2)) && (targetType === "directory" || targetType === "both"));
|
|
801
|
+
if (target) {
|
|
802
|
+
return joinPaths(dir, target);
|
|
803
|
+
}
|
|
804
|
+
const parentDir = resolveParentPath(dir);
|
|
805
|
+
if (parentDir === dir) {
|
|
806
|
+
return void 0;
|
|
807
|
+
}
|
|
808
|
+
dir = parentDir;
|
|
809
|
+
}
|
|
810
|
+
}, "getParentPath");
|
|
811
|
+
|
|
812
|
+
// ../path/src/is-root-dir.ts
|
|
813
|
+
var isSystemRoot = /* @__PURE__ */ __name((dir) => {
|
|
814
|
+
return Boolean(dir === "/" || dir === "c:\\" || dir === "C:\\");
|
|
815
|
+
}, "isSystemRoot");
|
|
816
|
+
|
|
817
|
+
// ../path/src/get-workspace-root.ts
|
|
818
|
+
var WORKSPACE_ROOT_CONTENT = [
|
|
819
|
+
"package-lock.json",
|
|
820
|
+
"yarn.lock",
|
|
821
|
+
"pnpm-lock.yaml",
|
|
822
|
+
"bun.lock",
|
|
823
|
+
"nx.json",
|
|
824
|
+
"knip.json",
|
|
825
|
+
"pnpm-workspace.yaml",
|
|
826
|
+
"LICENSE",
|
|
827
|
+
".all-contributorsrc",
|
|
828
|
+
".whitesource",
|
|
829
|
+
"syncpack.config.js",
|
|
830
|
+
"syncpack.json",
|
|
831
|
+
"socket.yaml",
|
|
832
|
+
"lefthook.yaml",
|
|
833
|
+
".npmrc",
|
|
834
|
+
".log4brains.yml",
|
|
835
|
+
".huskyrc",
|
|
836
|
+
".husky",
|
|
837
|
+
".lintstagedrc",
|
|
838
|
+
".commitlintrc",
|
|
839
|
+
"lefthook.yml",
|
|
840
|
+
".github",
|
|
841
|
+
".nx",
|
|
842
|
+
".vscode",
|
|
843
|
+
"patches"
|
|
844
|
+
];
|
|
845
|
+
function getWorkspaceRoot(dir = process.cwd()) {
|
|
846
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
847
|
+
return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
|
|
848
|
+
}
|
|
849
|
+
const root = findWorkspaceRootSafe(dir);
|
|
850
|
+
if (root) {
|
|
851
|
+
return root;
|
|
852
|
+
}
|
|
853
|
+
let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);
|
|
854
|
+
if (result) {
|
|
855
|
+
return result;
|
|
856
|
+
}
|
|
857
|
+
result = dir;
|
|
858
|
+
while (result && !isSystemRoot(result)) {
|
|
859
|
+
result = getParentPath("storm-workspace.json", result, {
|
|
860
|
+
skipCwd: true
|
|
861
|
+
});
|
|
862
|
+
if (result) {
|
|
863
|
+
return result;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return dir;
|
|
867
|
+
}
|
|
868
|
+
__name(getWorkspaceRoot, "getWorkspaceRoot");
|
|
869
|
+
|
|
763
870
|
// ../path/src/file-path-fns.ts
|
|
764
871
|
function findFileName(filePath, options = {}) {
|
|
765
872
|
const { requireExtension = false, withExtension = true } = options;
|
|
@@ -847,7 +954,7 @@ __name(listFiles, "listFiles");
|
|
|
847
954
|
import { parseJsonConfigFileContent, sys } from "typescript";
|
|
848
955
|
async function resolveOptions(options) {
|
|
849
956
|
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
850
|
-
const schemas = toArray(options.schemas ?
|
|
957
|
+
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));
|
|
851
958
|
let resolvedTsconfig;
|
|
852
959
|
if (options.tsconfig) {
|
|
853
960
|
resolvedTsconfig = options.tsconfig;
|
|
@@ -875,13 +982,11 @@ async function resolveOptions(options) {
|
|
|
875
982
|
}
|
|
876
983
|
const resolvedSchemas = [];
|
|
877
984
|
for (const schema of schemas) {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
} else {
|
|
883
|
-
resolvedSchemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
985
|
+
let formattedSchema = schema;
|
|
986
|
+
if (!schema.endsWith(".capnp") && !schema.includes("*")) {
|
|
987
|
+
formattedSchema = `${schema.replace(/\/$/g, "")}/*.capnp`;
|
|
884
988
|
}
|
|
989
|
+
resolvedSchemas.push(...await listFiles(formattedSchema));
|
|
885
990
|
}
|
|
886
991
|
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
887
992
|
writeWarning(`\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
@@ -907,5 +1012,7 @@ __name(resolveOptions, "resolveOptions");
|
|
|
907
1012
|
export {
|
|
908
1013
|
existsSync2 as existsSync,
|
|
909
1014
|
createDirectory,
|
|
1015
|
+
slash,
|
|
1016
|
+
getWorkspaceRoot,
|
|
910
1017
|
resolveOptions
|
|
911
1018
|
};
|