@zenstackhq/cli 3.4.3 → 3.4.4
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.cjs +172 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +152 -131
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -34,16 +34,23 @@ var import_colors12 = __toESM(require("colors"), 1);
|
|
|
34
34
|
var import_commander = require("commander");
|
|
35
35
|
|
|
36
36
|
// src/actions/check.ts
|
|
37
|
+
var import_ast2 = require("@zenstackhq/language/ast");
|
|
37
38
|
var import_colors2 = __toESM(require("colors"), 1);
|
|
39
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
38
40
|
|
|
39
41
|
// src/actions/action-utils.ts
|
|
42
|
+
var import_common_helpers = require("@zenstackhq/common-helpers");
|
|
40
43
|
var import_language = require("@zenstackhq/language");
|
|
41
44
|
var import_ast = require("@zenstackhq/language/ast");
|
|
42
45
|
var import_sdk = require("@zenstackhq/sdk");
|
|
43
46
|
var import_colors = __toESM(require("colors"), 1);
|
|
47
|
+
var import_jiti = require("jiti");
|
|
44
48
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
45
49
|
var import_node_module = require("module");
|
|
46
50
|
var import_node_path = __toESM(require("path"), 1);
|
|
51
|
+
var import_node_url = require("url");
|
|
52
|
+
var import_terminal_link = __toESM(require("terminal-link"), 1);
|
|
53
|
+
var import_zod = require("zod");
|
|
47
54
|
|
|
48
55
|
// src/cli-error.ts
|
|
49
56
|
var CliError = class extends Error {
|
|
@@ -53,8 +60,6 @@ var CliError = class extends Error {
|
|
|
53
60
|
};
|
|
54
61
|
|
|
55
62
|
// src/actions/action-utils.ts
|
|
56
|
-
var import_terminal_link = __toESM(require("terminal-link"), 1);
|
|
57
|
-
var import_zod = require("zod");
|
|
58
63
|
function getSchemaFile(file) {
|
|
59
64
|
if (file) {
|
|
60
65
|
if (!import_node_fs.default.existsSync(file)) {
|
|
@@ -230,6 +235,80 @@ async function getZenStackPackages(searchPath) {
|
|
|
230
235
|
return result.filter((p) => !!p);
|
|
231
236
|
}
|
|
232
237
|
__name(getZenStackPackages, "getZenStackPackages");
|
|
238
|
+
function getPluginProvider(plugin3) {
|
|
239
|
+
const providerField = plugin3.fields.find((f) => f.name === "provider");
|
|
240
|
+
(0, import_common_helpers.invariant)(providerField, `Plugin ${plugin3.name} does not have a provider field`);
|
|
241
|
+
const provider = providerField.value.value;
|
|
242
|
+
return provider;
|
|
243
|
+
}
|
|
244
|
+
__name(getPluginProvider, "getPluginProvider");
|
|
245
|
+
async function loadPluginModule(provider, basePath) {
|
|
246
|
+
if (provider.toLowerCase().endsWith(".zmodel")) {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
let moduleSpec = provider;
|
|
250
|
+
if (moduleSpec.startsWith(".")) {
|
|
251
|
+
moduleSpec = import_node_path.default.resolve(basePath, moduleSpec);
|
|
252
|
+
}
|
|
253
|
+
const importAsEsm = /* @__PURE__ */ __name(async (spec) => {
|
|
254
|
+
try {
|
|
255
|
+
const result = (await import(spec)).default;
|
|
256
|
+
return result;
|
|
257
|
+
} catch (err) {
|
|
258
|
+
throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
|
|
259
|
+
}
|
|
260
|
+
}, "importAsEsm");
|
|
261
|
+
const jiti = (0, import_jiti.createJiti)((0, import_node_url.pathToFileURL)(basePath).toString());
|
|
262
|
+
const importAsTs = /* @__PURE__ */ __name(async (spec) => {
|
|
263
|
+
try {
|
|
264
|
+
const result = await jiti.import(spec, {
|
|
265
|
+
default: true
|
|
266
|
+
});
|
|
267
|
+
return result;
|
|
268
|
+
} catch (err) {
|
|
269
|
+
throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
|
|
270
|
+
}
|
|
271
|
+
}, "importAsTs");
|
|
272
|
+
const esmSuffixes = [
|
|
273
|
+
".js",
|
|
274
|
+
".mjs"
|
|
275
|
+
];
|
|
276
|
+
const tsSuffixes = [
|
|
277
|
+
".ts",
|
|
278
|
+
".mts"
|
|
279
|
+
];
|
|
280
|
+
if (import_node_fs.default.existsSync(moduleSpec) && import_node_fs.default.statSync(moduleSpec).isFile()) {
|
|
281
|
+
if (esmSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
|
|
282
|
+
return await importAsEsm((0, import_node_url.pathToFileURL)(moduleSpec).toString());
|
|
283
|
+
}
|
|
284
|
+
if (tsSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
|
|
285
|
+
return await importAsTs(moduleSpec);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
for (const suffix of esmSuffixes) {
|
|
289
|
+
const indexPath = import_node_path.default.join(moduleSpec, `index${suffix}`);
|
|
290
|
+
if (import_node_fs.default.existsSync(indexPath)) {
|
|
291
|
+
return await importAsEsm((0, import_node_url.pathToFileURL)(indexPath).toString());
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
for (const suffix of tsSuffixes) {
|
|
295
|
+
const indexPath = import_node_path.default.join(moduleSpec, `index${suffix}`);
|
|
296
|
+
if (import_node_fs.default.existsSync(indexPath)) {
|
|
297
|
+
return await importAsTs(indexPath);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
try {
|
|
301
|
+
const mod = await import(moduleSpec);
|
|
302
|
+
return mod.default;
|
|
303
|
+
} catch (err) {
|
|
304
|
+
const errorCode = err?.code;
|
|
305
|
+
if (errorCode === "ERR_MODULE_NOT_FOUND" || errorCode === "MODULE_NOT_FOUND") {
|
|
306
|
+
throw new CliError(`Cannot find plugin module "${provider}". Please make sure the package exists.`);
|
|
307
|
+
}
|
|
308
|
+
throw new CliError(`Failed to load plugin module "${provider}": ${err.message}`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
__name(loadPluginModule, "loadPluginModule");
|
|
233
312
|
var FETCH_CLI_MAX_TIME = 1e3;
|
|
234
313
|
var CLI_CONFIG_ENDPOINT = "https://zenstack.dev/config/cli-v3.json";
|
|
235
314
|
var usageTipsSchema = import_zod.z.object({
|
|
@@ -287,7 +366,8 @@ __name(startUsageTipsFetch, "startUsageTipsFetch");
|
|
|
287
366
|
async function run(options) {
|
|
288
367
|
const schemaFile = getSchemaFile(options.schema);
|
|
289
368
|
try {
|
|
290
|
-
await loadSchemaDocument(schemaFile);
|
|
369
|
+
const model = await loadSchemaDocument(schemaFile);
|
|
370
|
+
await checkPluginResolution(schemaFile, model);
|
|
291
371
|
console.log(import_colors2.default.green("\u2713 Schema validation completed successfully."));
|
|
292
372
|
} catch (error) {
|
|
293
373
|
console.error(import_colors2.default.red("\u2717 Schema validation failed."));
|
|
@@ -295,13 +375,23 @@ async function run(options) {
|
|
|
295
375
|
}
|
|
296
376
|
}
|
|
297
377
|
__name(run, "run");
|
|
378
|
+
async function checkPluginResolution(schemaFile, model) {
|
|
379
|
+
const plugins = model.declarations.filter(import_ast2.isPlugin);
|
|
380
|
+
for (const plugin3 of plugins) {
|
|
381
|
+
const provider = getPluginProvider(plugin3);
|
|
382
|
+
if (!provider.startsWith("@core/")) {
|
|
383
|
+
await loadPluginModule(provider, import_node_path2.default.dirname(schemaFile));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
__name(checkPluginResolution, "checkPluginResolution");
|
|
298
388
|
|
|
299
389
|
// src/actions/db.ts
|
|
300
390
|
var import_language2 = require("@zenstackhq/language");
|
|
301
|
-
var
|
|
391
|
+
var import_ast5 = require("@zenstackhq/language/ast");
|
|
302
392
|
var import_colors4 = __toESM(require("colors"), 1);
|
|
303
393
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
304
|
-
var
|
|
394
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
305
395
|
var import_ora = __toESM(require("ora"), 1);
|
|
306
396
|
|
|
307
397
|
// src/utils/exec-utils.ts
|
|
@@ -354,13 +444,13 @@ __name(execPrisma, "execPrisma");
|
|
|
354
444
|
|
|
355
445
|
// src/actions/pull/index.ts
|
|
356
446
|
var import_colors3 = __toESM(require("colors"), 1);
|
|
357
|
-
var
|
|
447
|
+
var import_ast4 = require("@zenstackhq/language/ast");
|
|
358
448
|
var import_factory = require("@zenstackhq/language/factory");
|
|
359
449
|
var import_langium = require("langium");
|
|
360
|
-
var
|
|
450
|
+
var import_common_helpers2 = require("@zenstackhq/common-helpers");
|
|
361
451
|
|
|
362
452
|
// src/actions/pull/utils.ts
|
|
363
|
-
var
|
|
453
|
+
var import_ast3 = require("@zenstackhq/language/ast");
|
|
364
454
|
var import_utils = require("@zenstackhq/language/utils");
|
|
365
455
|
function isDatabaseManagedAttribute(name) {
|
|
366
456
|
return [
|
|
@@ -378,7 +468,7 @@ function getDatasource(model) {
|
|
|
378
468
|
const urlField = datasource.fields.find((f) => f.name === "url");
|
|
379
469
|
if (!urlField) throw new CliError(`No url field found in the datasource declaration.`);
|
|
380
470
|
let url = (0, import_utils.getStringLiteral)(urlField.value);
|
|
381
|
-
if (!url && (0,
|
|
471
|
+
if (!url && (0, import_ast3.isInvocationExpr)(urlField.value)) {
|
|
382
472
|
const envName = (0, import_utils.getStringLiteral)(urlField.value.args[0]?.value);
|
|
383
473
|
if (!envName) {
|
|
384
474
|
throw new CliError("The url field must be a string literal or an env().");
|
|
@@ -561,7 +651,7 @@ function syncEnums({ dbEnums, model, oldModel, provider, options, services, defa
|
|
|
561
651
|
const dummyBuildReference = /* @__PURE__ */ __name((_node, _property, _refNode, refText) => ({
|
|
562
652
|
$refText: refText
|
|
563
653
|
}), "dummyBuildReference");
|
|
564
|
-
oldModel.declarations.filter((d) => (0,
|
|
654
|
+
oldModel.declarations.filter((d) => (0, import_ast4.isEnum)(d)).forEach((d) => {
|
|
565
655
|
const copy = import_langium.AstUtils.copyAstNode(d, dummyBuildReference);
|
|
566
656
|
copy.$container = model;
|
|
567
657
|
model.declarations.push(copy);
|
|
@@ -625,7 +715,7 @@ function syncTable({ model, provider, table, services, options, defaultSchema })
|
|
|
625
715
|
if (column.computed) {
|
|
626
716
|
typeBuilder.setUnsupported((unsupportedBuilder) => unsupportedBuilder.setValue((lt) => lt.StringLiteral.setValue(column.datatype)));
|
|
627
717
|
} else if (column.datatype === "enum") {
|
|
628
|
-
const ref = model.declarations.find((d) => (0,
|
|
718
|
+
const ref = model.declarations.find((d) => (0, import_ast4.isEnum)(d) && getDbName(d) === column.datatype_name);
|
|
629
719
|
if (!ref) {
|
|
630
720
|
throw new CliError(`Enum ${column.datatype_name} not found`);
|
|
631
721
|
}
|
|
@@ -789,9 +879,9 @@ function syncRelation({ model, relation, services, options, selfRelation, simila
|
|
|
789
879
|
const relationName = `${relation.table}${similarRelations > 0 ? `_${firstColumn}` : ""}To${relation.references.table}`;
|
|
790
880
|
const sourceNameFromReference = firstSourceField.name.toLowerCase().endsWith("id") ? `${resolveNameCasing(options.fieldCasing, firstSourceField.name.slice(0, -2)).name}${relation.type === "many" ? "s" : ""}` : void 0;
|
|
791
881
|
const sourceFieldFromReference = sourceModel.fields.find((f) => f.name === sourceNameFromReference);
|
|
792
|
-
let { name: sourceFieldName } = resolveNameCasing(options.fieldCasing, similarRelations > 0 ? `${fieldPrefix}${(0,
|
|
882
|
+
let { name: sourceFieldName } = resolveNameCasing(options.fieldCasing, similarRelations > 0 ? `${fieldPrefix}${(0, import_common_helpers2.lowerCaseFirst)(sourceModel.name)}_${firstColumn}` : `${(!sourceFieldFromReference ? sourceNameFromReference : void 0) || (0, import_common_helpers2.lowerCaseFirst)(resolveNameCasing(options.fieldCasing, targetModel.name).name)}${relation.type === "many" ? "s" : ""}`);
|
|
793
883
|
if (sourceModel.fields.find((f) => f.name === sourceFieldName)) {
|
|
794
|
-
sourceFieldName = `${sourceFieldName}To${(0,
|
|
884
|
+
sourceFieldName = `${sourceFieldName}To${(0, import_common_helpers2.lowerCaseFirst)(targetModel.name)}_${relation.references.columns[0]}`;
|
|
795
885
|
}
|
|
796
886
|
const sourceFieldFactory = new import_factory.DataFieldFactory().setContainer(sourceModel).setName(sourceFieldName).setType((tb) => tb.setOptional(relation.nullable).setArray(relation.type === "many").setReference(targetModel));
|
|
797
887
|
sourceFieldFactory.addAttribute((ab) => {
|
|
@@ -832,9 +922,9 @@ function syncRelation({ model, relation, services, options, selfRelation, simila
|
|
|
832
922
|
});
|
|
833
923
|
sourceModel.fields.splice(firstSourceFieldId, 0, sourceFieldFactory.node);
|
|
834
924
|
const oppositeFieldPrefix = /[0-9]/g.test(targetModel.name.charAt(0)) ? "_" : "";
|
|
835
|
-
let { name: oppositeFieldName } = resolveNameCasing(options.fieldCasing, similarRelations > 0 ? `${oppositeFieldPrefix}${(0,
|
|
925
|
+
let { name: oppositeFieldName } = resolveNameCasing(options.fieldCasing, similarRelations > 0 ? `${oppositeFieldPrefix}${(0, import_common_helpers2.lowerCaseFirst)(sourceModel.name)}_${firstColumn}` : `${(0, import_common_helpers2.lowerCaseFirst)(resolveNameCasing(options.fieldCasing, sourceModel.name).name)}${relation.references.type === "many" ? "s" : ""}`);
|
|
836
926
|
if (targetModel.fields.find((f) => f.name === oppositeFieldName)) {
|
|
837
|
-
({ name: oppositeFieldName } = resolveNameCasing(options.fieldCasing, `${(0,
|
|
927
|
+
({ name: oppositeFieldName } = resolveNameCasing(options.fieldCasing, `${(0, import_common_helpers2.lowerCaseFirst)(sourceModel.name)}_${firstColumn}To${relation.references.table}_${relation.references.columns[0]}`));
|
|
838
928
|
}
|
|
839
929
|
const targetFieldFactory = new import_factory.DataFieldFactory().setContainer(targetModel).setName(oppositeFieldName).setType((tb) => tb.setOptional(relation.references.type === "one").setArray(relation.references.type === "many").setReference(sourceModel));
|
|
840
930
|
if (includeRelationName) targetFieldFactory.addAttribute((ab) => ab.setDecl(relationAttribute).addArg((ab2) => ab2.StringLiteral.setValue(relationName)));
|
|
@@ -842,7 +932,7 @@ function syncRelation({ model, relation, services, options, selfRelation, simila
|
|
|
842
932
|
}
|
|
843
933
|
__name(syncRelation, "syncRelation");
|
|
844
934
|
function consolidateEnums({ newModel, oldModel }) {
|
|
845
|
-
const newEnums = newModel.declarations.filter((d) => (0,
|
|
935
|
+
const newEnums = newModel.declarations.filter((d) => (0, import_ast4.isEnum)(d));
|
|
846
936
|
const newDataModels = newModel.declarations.filter((d) => d.$type === "DataModel");
|
|
847
937
|
const oldDataModels = oldModel.declarations.filter((d) => d.$type === "DataModel");
|
|
848
938
|
const enumMapping = /* @__PURE__ */ new Map();
|
|
@@ -855,7 +945,7 @@ function consolidateEnums({ newModel, oldModel }) {
|
|
|
855
945
|
const oldField = oldDM.fields.find((f) => getDbName(f) === getDbName(field));
|
|
856
946
|
if (!oldField || oldField.$type !== "DataField" || !oldField.type.reference?.ref) continue;
|
|
857
947
|
const oldEnum = oldField.type.reference.ref;
|
|
858
|
-
if (!(0,
|
|
948
|
+
if (!(0, import_ast4.isEnum)(oldEnum)) continue;
|
|
859
949
|
enumMapping.set(newEnum, oldEnum);
|
|
860
950
|
break;
|
|
861
951
|
}
|
|
@@ -2533,8 +2623,8 @@ async function runPull(options) {
|
|
|
2533
2623
|
const spinner = (0, import_ora.default)();
|
|
2534
2624
|
try {
|
|
2535
2625
|
const schemaFile = getSchemaFile(options.schema);
|
|
2536
|
-
const outPath = options.output ?
|
|
2537
|
-
const treatAsFile = !!outPath && (import_node_fs2.default.existsSync(outPath) && import_node_fs2.default.lstatSync(outPath).isFile() ||
|
|
2626
|
+
const outPath = options.output ? import_node_path3.default.resolve(options.output) : void 0;
|
|
2627
|
+
const treatAsFile = !!outPath && (import_node_fs2.default.existsSync(outPath) && import_node_fs2.default.lstatSync(outPath).isFile() || import_node_path3.default.extname(outPath) !== "");
|
|
2538
2628
|
const { model, services } = await loadSchemaDocument(schemaFile, {
|
|
2539
2629
|
returnServices: true,
|
|
2540
2630
|
mergeImports: treatAsFile
|
|
@@ -2608,7 +2698,7 @@ async function runPull(options) {
|
|
|
2608
2698
|
oldModel: model
|
|
2609
2699
|
});
|
|
2610
2700
|
console.log(import_colors4.default.blue("Schema synced"));
|
|
2611
|
-
const baseDir =
|
|
2701
|
+
const baseDir = import_node_path3.default.dirname(import_node_path3.default.resolve(schemaFile));
|
|
2612
2702
|
const baseDirUrlPath = new URL(`file://${baseDir}`).pathname;
|
|
2613
2703
|
const docs = services.shared.workspace.LangiumDocuments.all.filter(({ uri }) => uri.path.toLowerCase().startsWith(baseDirUrlPath.toLowerCase())).toArray();
|
|
2614
2704
|
const docsSet = new Set(docs.map((d) => d.uri.toString()));
|
|
@@ -2644,8 +2734,8 @@ async function runPull(options) {
|
|
|
2644
2734
|
deletedEnums.push(import_colors4.default.red(`- Enum ${decl.name} deleted`));
|
|
2645
2735
|
});
|
|
2646
2736
|
newModel.declarations.filter((d) => [
|
|
2647
|
-
|
|
2648
|
-
|
|
2737
|
+
import_ast5.DataModel,
|
|
2738
|
+
import_ast5.Enum
|
|
2649
2739
|
].includes(d.$type)).forEach((_declaration) => {
|
|
2650
2740
|
const newDataModel = _declaration;
|
|
2651
2741
|
const declarations = services.shared.workspace.IndexManager.allElements(newDataModel.$type, docsSet).toArray();
|
|
@@ -2893,7 +2983,7 @@ async function runPull(options) {
|
|
|
2893
2983
|
if (treatAsFile) {
|
|
2894
2984
|
const zmodelSchema = await (0, import_language2.formatDocument)(generator.generate(newModel));
|
|
2895
2985
|
console.log(import_colors4.default.blue(`Writing to ${outPath}`));
|
|
2896
|
-
import_node_fs2.default.mkdirSync(
|
|
2986
|
+
import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(outPath), {
|
|
2897
2987
|
recursive: true
|
|
2898
2988
|
});
|
|
2899
2989
|
import_node_fs2.default.writeFileSync(outPath, zmodelSchema);
|
|
@@ -2901,12 +2991,12 @@ async function runPull(options) {
|
|
|
2901
2991
|
import_node_fs2.default.mkdirSync(outPath, {
|
|
2902
2992
|
recursive: true
|
|
2903
2993
|
});
|
|
2904
|
-
const baseDir2 =
|
|
2994
|
+
const baseDir2 = import_node_path3.default.dirname(import_node_path3.default.resolve(schemaFile));
|
|
2905
2995
|
for (const { uri, parseResult: { value: documentModel } } of docs) {
|
|
2906
2996
|
const zmodelSchema = await (0, import_language2.formatDocument)(generator.generate(documentModel));
|
|
2907
|
-
const relPath =
|
|
2908
|
-
const targetFile =
|
|
2909
|
-
import_node_fs2.default.mkdirSync(
|
|
2997
|
+
const relPath = import_node_path3.default.relative(baseDir2, uri.fsPath);
|
|
2998
|
+
const targetFile = import_node_path3.default.join(outPath, relPath);
|
|
2999
|
+
import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(targetFile), {
|
|
2910
3000
|
recursive: true
|
|
2911
3001
|
});
|
|
2912
3002
|
console.log(import_colors4.default.blue(`Writing to ${targetFile}`));
|
|
@@ -2916,7 +3006,7 @@ async function runPull(options) {
|
|
|
2916
3006
|
} else {
|
|
2917
3007
|
for (const { uri, parseResult: { value: documentModel } } of docs) {
|
|
2918
3008
|
const zmodelSchema = await (0, import_language2.formatDocument)(generator.generate(documentModel));
|
|
2919
|
-
console.log(import_colors4.default.blue(`Writing to ${
|
|
3009
|
+
console.log(import_colors4.default.blue(`Writing to ${import_node_path3.default.relative(process.cwd(), uri.fsPath).replace(/\\/g, "/")}`));
|
|
2920
3010
|
import_node_fs2.default.writeFileSync(uri.fsPath, zmodelSchema);
|
|
2921
3011
|
}
|
|
2922
3012
|
}
|
|
@@ -2948,16 +3038,13 @@ async function run3(options) {
|
|
|
2948
3038
|
__name(run3, "run");
|
|
2949
3039
|
|
|
2950
3040
|
// src/actions/generate.ts
|
|
2951
|
-
var
|
|
3041
|
+
var import_common_helpers3 = require("@zenstackhq/common-helpers");
|
|
2952
3042
|
var import_language4 = require("@zenstackhq/language");
|
|
2953
|
-
var
|
|
3043
|
+
var import_ast6 = require("@zenstackhq/language/ast");
|
|
2954
3044
|
var import_utils7 = require("@zenstackhq/language/utils");
|
|
2955
3045
|
var import_chokidar = require("chokidar");
|
|
2956
3046
|
var import_colors6 = __toESM(require("colors"), 1);
|
|
2957
|
-
var
|
|
2958
|
-
var import_node_fs6 = __toESM(require("fs"), 1);
|
|
2959
|
-
var import_node_path5 = __toESM(require("path"), 1);
|
|
2960
|
-
var import_node_url = require("url");
|
|
3047
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
2961
3048
|
var import_ora2 = __toESM(require("ora"), 1);
|
|
2962
3049
|
var import_semver = __toESM(require("semver"), 1);
|
|
2963
3050
|
|
|
@@ -2971,16 +3058,16 @@ __export(plugins_exports, {
|
|
|
2971
3058
|
// src/plugins/prisma.ts
|
|
2972
3059
|
var import_sdk2 = require("@zenstackhq/sdk");
|
|
2973
3060
|
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
2974
|
-
var
|
|
3061
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
2975
3062
|
var plugin = {
|
|
2976
3063
|
name: "Prisma Schema Generator",
|
|
2977
3064
|
statusText: "Generating Prisma schema",
|
|
2978
3065
|
async generate({ model, defaultOutputPath, pluginOptions }) {
|
|
2979
|
-
let outFile =
|
|
3066
|
+
let outFile = import_node_path4.default.join(defaultOutputPath, "schema.prisma");
|
|
2980
3067
|
if (typeof pluginOptions["output"] === "string") {
|
|
2981
|
-
outFile =
|
|
2982
|
-
if (!import_node_fs4.default.existsSync(
|
|
2983
|
-
import_node_fs4.default.mkdirSync(
|
|
3068
|
+
outFile = import_node_path4.default.resolve(defaultOutputPath, pluginOptions["output"]);
|
|
3069
|
+
if (!import_node_fs4.default.existsSync(import_node_path4.default.dirname(outFile))) {
|
|
3070
|
+
import_node_fs4.default.mkdirSync(import_node_path4.default.dirname(outFile), {
|
|
2984
3071
|
recursive: true
|
|
2985
3072
|
});
|
|
2986
3073
|
}
|
|
@@ -2994,14 +3081,14 @@ var prisma_default = plugin;
|
|
|
2994
3081
|
// src/plugins/typescript.ts
|
|
2995
3082
|
var import_sdk3 = require("@zenstackhq/sdk");
|
|
2996
3083
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
2997
|
-
var
|
|
3084
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
2998
3085
|
var plugin2 = {
|
|
2999
3086
|
name: "TypeScript Schema Generator",
|
|
3000
3087
|
statusText: "Generating TypeScript schema",
|
|
3001
3088
|
async generate({ model, defaultOutputPath, pluginOptions }) {
|
|
3002
3089
|
let outDir = defaultOutputPath;
|
|
3003
3090
|
if (typeof pluginOptions["output"] === "string") {
|
|
3004
|
-
outDir =
|
|
3091
|
+
outDir = import_node_path5.default.resolve(defaultOutputPath, pluginOptions["output"]);
|
|
3005
3092
|
if (!import_node_fs5.default.existsSync(outDir)) {
|
|
3006
3093
|
import_node_fs5.default.mkdirSync(outDir, {
|
|
3007
3094
|
recursive: true
|
|
@@ -3062,7 +3149,7 @@ ${logPaths}`);
|
|
|
3062
3149
|
ignorePermissionErrors: true,
|
|
3063
3150
|
ignored: /* @__PURE__ */ __name((at) => !schemaExtensions.some((ext) => at.endsWith(ext)), "ignored")
|
|
3064
3151
|
});
|
|
3065
|
-
const reGenerateSchema = (0,
|
|
3152
|
+
const reGenerateSchema = (0, import_common_helpers3.singleDebounce)(async () => {
|
|
3066
3153
|
if (logsEnabled) {
|
|
3067
3154
|
console.log("Got changes, run generation!");
|
|
3068
3155
|
}
|
|
@@ -3125,7 +3212,7 @@ async function pureGenerate(options, fromWatch) {
|
|
|
3125
3212
|
|
|
3126
3213
|
\`\`\`ts
|
|
3127
3214
|
import { ZenStackClient } from '@zenstackhq/orm';
|
|
3128
|
-
import { schema } from '${
|
|
3215
|
+
import { schema } from '${import_node_path6.default.relative(".", outputPath)}/schema';
|
|
3129
3216
|
|
|
3130
3217
|
const client = new ZenStackClient(schema, {
|
|
3131
3218
|
dialect: { ... }
|
|
@@ -3139,7 +3226,7 @@ Check documentation: https://zenstack.dev/docs/`);
|
|
|
3139
3226
|
}
|
|
3140
3227
|
__name(pureGenerate, "pureGenerate");
|
|
3141
3228
|
async function runPlugins(schemaFile, model, outputPath, options) {
|
|
3142
|
-
const plugins = model.declarations.filter(
|
|
3229
|
+
const plugins = model.declarations.filter(import_ast6.isPlugin);
|
|
3143
3230
|
const processedPlugins = [];
|
|
3144
3231
|
for (const plugin3 of plugins) {
|
|
3145
3232
|
const provider = getPluginProvider(plugin3);
|
|
@@ -3150,7 +3237,7 @@ async function runPlugins(schemaFile, model, outputPath, options) {
|
|
|
3150
3237
|
throw new CliError(`Unknown core plugin: ${provider}`);
|
|
3151
3238
|
}
|
|
3152
3239
|
} else {
|
|
3153
|
-
cliPlugin = await loadPluginModule(provider,
|
|
3240
|
+
cliPlugin = await loadPluginModule(provider, import_node_path6.default.dirname(schemaFile));
|
|
3154
3241
|
}
|
|
3155
3242
|
if (cliPlugin) {
|
|
3156
3243
|
const pluginOptions = getPluginOptions(plugin3);
|
|
@@ -3194,7 +3281,7 @@ async function runPlugins(schemaFile, model, outputPath, options) {
|
|
|
3194
3281
|
}
|
|
3195
3282
|
});
|
|
3196
3283
|
for (const { cliPlugin, pluginOptions } of processedPlugins) {
|
|
3197
|
-
(0,
|
|
3284
|
+
(0, import_common_helpers3.invariant)(typeof cliPlugin.generate === "function", `Plugin ${cliPlugin.name} does not have a generate function`);
|
|
3198
3285
|
let spinner;
|
|
3199
3286
|
if (!options.silent) {
|
|
3200
3287
|
spinner = (0, import_ora2.default)(cliPlugin.statusText ?? `Running plugin ${cliPlugin.name}`).start();
|
|
@@ -3214,13 +3301,6 @@ async function runPlugins(schemaFile, model, outputPath, options) {
|
|
|
3214
3301
|
}
|
|
3215
3302
|
}
|
|
3216
3303
|
__name(runPlugins, "runPlugins");
|
|
3217
|
-
function getPluginProvider(plugin3) {
|
|
3218
|
-
const providerField = plugin3.fields.find((f) => f.name === "provider");
|
|
3219
|
-
(0, import_common_helpers2.invariant)(providerField, `Plugin ${plugin3.name} does not have a provider field`);
|
|
3220
|
-
const provider = providerField.value.value;
|
|
3221
|
-
return provider;
|
|
3222
|
-
}
|
|
3223
|
-
__name(getPluginProvider, "getPluginProvider");
|
|
3224
3304
|
function getPluginOptions(plugin3) {
|
|
3225
3305
|
const result = {};
|
|
3226
3306
|
for (const field of plugin3.fields) {
|
|
@@ -3237,65 +3317,6 @@ function getPluginOptions(plugin3) {
|
|
|
3237
3317
|
return result;
|
|
3238
3318
|
}
|
|
3239
3319
|
__name(getPluginOptions, "getPluginOptions");
|
|
3240
|
-
async function loadPluginModule(provider, basePath) {
|
|
3241
|
-
let moduleSpec = provider;
|
|
3242
|
-
if (moduleSpec.startsWith(".")) {
|
|
3243
|
-
moduleSpec = import_node_path5.default.resolve(basePath, moduleSpec);
|
|
3244
|
-
}
|
|
3245
|
-
const importAsEsm = /* @__PURE__ */ __name(async (spec) => {
|
|
3246
|
-
try {
|
|
3247
|
-
const result = (await import(spec)).default;
|
|
3248
|
-
return result;
|
|
3249
|
-
} catch (err) {
|
|
3250
|
-
throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
|
|
3251
|
-
}
|
|
3252
|
-
}, "importAsEsm");
|
|
3253
|
-
const jiti = (0, import_jiti.createJiti)((0, import_node_url.pathToFileURL)(basePath).toString());
|
|
3254
|
-
const importAsTs = /* @__PURE__ */ __name(async (spec) => {
|
|
3255
|
-
try {
|
|
3256
|
-
const result = await jiti.import(spec, {
|
|
3257
|
-
default: true
|
|
3258
|
-
});
|
|
3259
|
-
return result;
|
|
3260
|
-
} catch (err) {
|
|
3261
|
-
throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
|
|
3262
|
-
}
|
|
3263
|
-
}, "importAsTs");
|
|
3264
|
-
const esmSuffixes = [
|
|
3265
|
-
".js",
|
|
3266
|
-
".mjs"
|
|
3267
|
-
];
|
|
3268
|
-
const tsSuffixes = [
|
|
3269
|
-
".ts",
|
|
3270
|
-
".mts"
|
|
3271
|
-
];
|
|
3272
|
-
if (import_node_fs6.default.existsSync(moduleSpec) && import_node_fs6.default.statSync(moduleSpec).isFile()) {
|
|
3273
|
-
if (esmSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
|
|
3274
|
-
return await importAsEsm((0, import_node_url.pathToFileURL)(moduleSpec).toString());
|
|
3275
|
-
}
|
|
3276
|
-
if (tsSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
|
|
3277
|
-
return await importAsTs(moduleSpec);
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
for (const suffix of esmSuffixes) {
|
|
3281
|
-
const indexPath = import_node_path5.default.join(moduleSpec, `index${suffix}`);
|
|
3282
|
-
if (import_node_fs6.default.existsSync(indexPath)) {
|
|
3283
|
-
return await importAsEsm((0, import_node_url.pathToFileURL)(indexPath).toString());
|
|
3284
|
-
}
|
|
3285
|
-
}
|
|
3286
|
-
for (const suffix of tsSuffixes) {
|
|
3287
|
-
const indexPath = import_node_path5.default.join(moduleSpec, `index${suffix}`);
|
|
3288
|
-
if (import_node_fs6.default.existsSync(indexPath)) {
|
|
3289
|
-
return await importAsTs(indexPath);
|
|
3290
|
-
}
|
|
3291
|
-
}
|
|
3292
|
-
try {
|
|
3293
|
-
return (await import(moduleSpec)).default;
|
|
3294
|
-
} catch {
|
|
3295
|
-
return void 0;
|
|
3296
|
-
}
|
|
3297
|
-
}
|
|
3298
|
-
__name(loadPluginModule, "loadPluginModule");
|
|
3299
3320
|
async function checkForMismatchedPackages(projectPath) {
|
|
3300
3321
|
const packages = await getZenStackPackages(projectPath);
|
|
3301
3322
|
if (!packages.length) {
|
|
@@ -3355,8 +3376,8 @@ __name(run5, "run");
|
|
|
3355
3376
|
|
|
3356
3377
|
// src/actions/init.ts
|
|
3357
3378
|
var import_colors8 = __toESM(require("colors"), 1);
|
|
3358
|
-
var
|
|
3359
|
-
var
|
|
3379
|
+
var import_node_fs6 = __toESM(require("fs"), 1);
|
|
3380
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
3360
3381
|
var import_ora3 = __toESM(require("ora"), 1);
|
|
3361
3382
|
var import_package_manager_detector = require("package-manager-detector");
|
|
3362
3383
|
|
|
@@ -3435,11 +3456,11 @@ async function run6(projectPath) {
|
|
|
3435
3456
|
}
|
|
3436
3457
|
}
|
|
3437
3458
|
const generationFolder = "zenstack";
|
|
3438
|
-
if (!
|
|
3439
|
-
|
|
3459
|
+
if (!import_node_fs6.default.existsSync(import_node_path7.default.join(projectPath, generationFolder))) {
|
|
3460
|
+
import_node_fs6.default.mkdirSync(import_node_path7.default.join(projectPath, generationFolder));
|
|
3440
3461
|
}
|
|
3441
|
-
if (!
|
|
3442
|
-
|
|
3462
|
+
if (!import_node_fs6.default.existsSync(import_node_path7.default.join(projectPath, generationFolder, "schema.zmodel"))) {
|
|
3463
|
+
import_node_fs6.default.writeFileSync(import_node_path7.default.join(projectPath, generationFolder, "schema.zmodel"), STARTER_ZMODEL);
|
|
3443
3464
|
} else {
|
|
3444
3465
|
console.log(import_colors8.default.yellow("Schema file already exists. Skipping generation of sample."));
|
|
3445
3466
|
}
|
|
@@ -3450,8 +3471,8 @@ async function run6(projectPath) {
|
|
|
3450
3471
|
__name(run6, "run");
|
|
3451
3472
|
|
|
3452
3473
|
// src/actions/migrate.ts
|
|
3453
|
-
var
|
|
3454
|
-
var
|
|
3474
|
+
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
3475
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
3455
3476
|
|
|
3456
3477
|
// src/actions/seed.ts
|
|
3457
3478
|
var import_colors9 = __toESM(require("colors"), 1);
|
|
@@ -3484,7 +3505,7 @@ __name(run7, "run");
|
|
|
3484
3505
|
async function run8(command, options) {
|
|
3485
3506
|
const schemaFile = getSchemaFile(options.schema);
|
|
3486
3507
|
await requireDataSourceUrl(schemaFile);
|
|
3487
|
-
const prismaSchemaDir = options.migrations ?
|
|
3508
|
+
const prismaSchemaDir = options.migrations ? import_node_path8.default.dirname(options.migrations) : void 0;
|
|
3488
3509
|
const prismaSchemaFile = await generateTempPrismaSchema(schemaFile, prismaSchemaDir);
|
|
3489
3510
|
try {
|
|
3490
3511
|
switch (command) {
|
|
@@ -3505,8 +3526,8 @@ async function run8(command, options) {
|
|
|
3505
3526
|
break;
|
|
3506
3527
|
}
|
|
3507
3528
|
} finally {
|
|
3508
|
-
if (
|
|
3509
|
-
|
|
3529
|
+
if (import_node_fs7.default.existsSync(prismaSchemaFile)) {
|
|
3530
|
+
import_node_fs7.default.unlinkSync(prismaSchemaFile);
|
|
3510
3531
|
}
|
|
3511
3532
|
}
|
|
3512
3533
|
}
|
|
@@ -3595,7 +3616,7 @@ function handleSubProcessError2(err) {
|
|
|
3595
3616
|
__name(handleSubProcessError2, "handleSubProcessError");
|
|
3596
3617
|
|
|
3597
3618
|
// src/actions/proxy.ts
|
|
3598
|
-
var
|
|
3619
|
+
var import_ast7 = require("@zenstackhq/language/ast");
|
|
3599
3620
|
var import_utils8 = require("@zenstackhq/language/utils");
|
|
3600
3621
|
var import_orm = require("@zenstackhq/orm");
|
|
3601
3622
|
var import_mysql2 = require("@zenstackhq/orm/dialects/mysql");
|
|
@@ -3607,12 +3628,12 @@ var import_colors11 = __toESM(require("colors"), 1);
|
|
|
3607
3628
|
var import_cors = __toESM(require("cors"), 1);
|
|
3608
3629
|
var import_express2 = __toESM(require("express"), 1);
|
|
3609
3630
|
var import_jiti2 = require("jiti");
|
|
3610
|
-
var
|
|
3631
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
3611
3632
|
|
|
3612
3633
|
// src/utils/version-utils.ts
|
|
3613
3634
|
var import_colors10 = __toESM(require("colors"), 1);
|
|
3614
|
-
var
|
|
3615
|
-
var
|
|
3635
|
+
var import_node_fs8 = __toESM(require("fs"), 1);
|
|
3636
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
3616
3637
|
var import_node_url2 = require("url");
|
|
3617
3638
|
var import_semver2 = __toESM(require("semver"), 1);
|
|
3618
3639
|
var import_meta2 = {};
|
|
@@ -3620,8 +3641,8 @@ var CHECK_VERSION_TIMEOUT = 2e3;
|
|
|
3620
3641
|
var VERSION_CHECK_TAG = "latest";
|
|
3621
3642
|
function getVersion() {
|
|
3622
3643
|
try {
|
|
3623
|
-
const _dirname = typeof __dirname !== "undefined" ? __dirname :
|
|
3624
|
-
return JSON.parse(
|
|
3644
|
+
const _dirname = typeof __dirname !== "undefined" ? __dirname : import_node_path9.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
3645
|
+
return JSON.parse(import_node_fs8.default.readFileSync(import_node_path9.default.join(_dirname, "../package.json"), "utf8")).version;
|
|
3625
3646
|
} catch {
|
|
3626
3647
|
return void 0;
|
|
3627
3648
|
}
|
|
@@ -3669,11 +3690,11 @@ async function run9(options) {
|
|
|
3669
3690
|
const schemaFile = getSchemaFile(options.schema);
|
|
3670
3691
|
console.log(import_colors11.default.gray(`Loading ZModel schema from: ${schemaFile}`));
|
|
3671
3692
|
let outputPath = getOutputPath(options, schemaFile);
|
|
3672
|
-
if (!
|
|
3673
|
-
outputPath =
|
|
3693
|
+
if (!import_node_path10.default.isAbsolute(outputPath)) {
|
|
3694
|
+
outputPath = import_node_path10.default.resolve(process.cwd(), outputPath);
|
|
3674
3695
|
}
|
|
3675
3696
|
const model = await loadSchemaDocument(schemaFile);
|
|
3676
|
-
const dataSource = model.declarations.find(
|
|
3697
|
+
const dataSource = model.declarations.find(import_ast7.isDataSource);
|
|
3677
3698
|
let databaseUrl = options.databaseUrl;
|
|
3678
3699
|
if (!databaseUrl) {
|
|
3679
3700
|
const schemaUrl = dataSource?.fields.find((f) => f.name === "url")?.value;
|
|
@@ -3686,18 +3707,18 @@ async function run9(options) {
|
|
|
3686
3707
|
const dialect = await createDialect(provider, databaseUrl, outputPath);
|
|
3687
3708
|
const fileUrl = typeof __filename !== "undefined" ? __filename : import_meta3.url;
|
|
3688
3709
|
const jiti = (0, import_jiti2.createJiti)(fileUrl);
|
|
3689
|
-
const schemaModule = await jiti.import(
|
|
3710
|
+
const schemaModule = await jiti.import(import_node_path10.default.join(outputPath, "schema"));
|
|
3690
3711
|
const schema = schemaModule.schema;
|
|
3691
3712
|
const omit = {};
|
|
3692
3713
|
for (const [modelName, modelDef] of Object.entries(schema.models)) {
|
|
3693
|
-
const
|
|
3714
|
+
const omitFields = {};
|
|
3694
3715
|
for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) {
|
|
3695
|
-
if (fieldDef.computed === true) {
|
|
3696
|
-
|
|
3716
|
+
if (fieldDef.computed === true || fieldDef.type === "Unsupported") {
|
|
3717
|
+
omitFields[fieldName] = true;
|
|
3697
3718
|
}
|
|
3698
3719
|
}
|
|
3699
|
-
if (Object.keys(
|
|
3700
|
-
omit[modelName] =
|
|
3720
|
+
if (Object.keys(omitFields).length > 0) {
|
|
3721
|
+
omit[modelName] = omitFields;
|
|
3701
3722
|
}
|
|
3702
3723
|
}
|
|
3703
3724
|
const db = new import_orm.ZenStackClient(schema, {
|
|
@@ -3715,9 +3736,9 @@ async function run9(options) {
|
|
|
3715
3736
|
}
|
|
3716
3737
|
__name(run9, "run");
|
|
3717
3738
|
function evaluateUrl(schemaUrl) {
|
|
3718
|
-
if ((0,
|
|
3739
|
+
if ((0, import_ast7.isLiteralExpr)(schemaUrl)) {
|
|
3719
3740
|
return (0, import_utils8.getStringLiteral)(schemaUrl);
|
|
3720
|
-
} else if ((0,
|
|
3741
|
+
} else if ((0, import_ast7.isInvocationExpr)(schemaUrl)) {
|
|
3721
3742
|
const envFunction = schemaUrl;
|
|
3722
3743
|
const envName = (0, import_utils8.getStringLiteral)(envFunction.args[0]?.value);
|
|
3723
3744
|
const envValue = process.env[envName];
|
|
@@ -3757,8 +3778,8 @@ async function createDialect(provider, databaseUrl, outputPath) {
|
|
|
3757
3778
|
let resolvedUrl = databaseUrl.trim();
|
|
3758
3779
|
if (resolvedUrl.startsWith("file:")) {
|
|
3759
3780
|
const filePath = resolvedUrl.substring("file:".length);
|
|
3760
|
-
if (!
|
|
3761
|
-
resolvedUrl =
|
|
3781
|
+
if (!import_node_path10.default.isAbsolute(filePath)) {
|
|
3782
|
+
resolvedUrl = import_node_path10.default.join(outputPath, filePath);
|
|
3762
3783
|
}
|
|
3763
3784
|
}
|
|
3764
3785
|
console.log(import_colors11.default.gray(`Connecting to SQLite database at: ${resolvedUrl}`));
|
|
@@ -3856,7 +3877,7 @@ __name(startServer, "startServer");
|
|
|
3856
3877
|
// src/telemetry.ts
|
|
3857
3878
|
var import_mixpanel = require("mixpanel");
|
|
3858
3879
|
var import_node_crypto2 = require("crypto");
|
|
3859
|
-
var
|
|
3880
|
+
var import_node_fs12 = __toESM(require("fs"), 1);
|
|
3860
3881
|
var os2 = __toESM(require("os"), 1);
|
|
3861
3882
|
|
|
3862
3883
|
// src/constants.ts
|
|
@@ -3867,14 +3888,14 @@ var import_node_process = require("process");
|
|
|
3867
3888
|
var isInCi = import_node_process.env["CI"] !== "0" && import_node_process.env["CI"] !== "false" && ("CI" in import_node_process.env || "CONTINUOUS_INTEGRATION" in import_node_process.env || Object.keys(import_node_process.env).some((key) => key.startsWith("CI_")));
|
|
3868
3889
|
|
|
3869
3890
|
// src/utils/is-container.ts
|
|
3870
|
-
var
|
|
3891
|
+
var import_node_fs10 = __toESM(require("fs"), 1);
|
|
3871
3892
|
|
|
3872
3893
|
// src/utils/is-docker.ts
|
|
3873
|
-
var
|
|
3894
|
+
var import_node_fs9 = __toESM(require("fs"), 1);
|
|
3874
3895
|
var isDockerCached;
|
|
3875
3896
|
function hasDockerEnv() {
|
|
3876
3897
|
try {
|
|
3877
|
-
|
|
3898
|
+
import_node_fs9.default.statSync("/.dockerenv");
|
|
3878
3899
|
return true;
|
|
3879
3900
|
} catch {
|
|
3880
3901
|
return false;
|
|
@@ -3883,7 +3904,7 @@ function hasDockerEnv() {
|
|
|
3883
3904
|
__name(hasDockerEnv, "hasDockerEnv");
|
|
3884
3905
|
function hasDockerCGroup() {
|
|
3885
3906
|
try {
|
|
3886
|
-
return
|
|
3907
|
+
return import_node_fs9.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
3887
3908
|
} catch {
|
|
3888
3909
|
return false;
|
|
3889
3910
|
}
|
|
@@ -3901,7 +3922,7 @@ __name(isDocker, "isDocker");
|
|
|
3901
3922
|
var cachedResult;
|
|
3902
3923
|
var hasContainerEnv = /* @__PURE__ */ __name(() => {
|
|
3903
3924
|
try {
|
|
3904
|
-
|
|
3925
|
+
import_node_fs10.default.statSync("/run/.containerenv");
|
|
3905
3926
|
return true;
|
|
3906
3927
|
} catch {
|
|
3907
3928
|
return false;
|
|
@@ -3918,7 +3939,7 @@ __name(isInContainer, "isInContainer");
|
|
|
3918
3939
|
// src/utils/is-wsl.ts
|
|
3919
3940
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
3920
3941
|
var import_node_os = __toESM(require("os"), 1);
|
|
3921
|
-
var
|
|
3942
|
+
var import_node_fs11 = __toESM(require("fs"), 1);
|
|
3922
3943
|
var isWsl = /* @__PURE__ */ __name(() => {
|
|
3923
3944
|
if (import_node_process2.default.platform !== "linux") {
|
|
3924
3945
|
return false;
|
|
@@ -3927,7 +3948,7 @@ var isWsl = /* @__PURE__ */ __name(() => {
|
|
|
3927
3948
|
return true;
|
|
3928
3949
|
}
|
|
3929
3950
|
try {
|
|
3930
|
-
return
|
|
3951
|
+
return import_node_fs11.default.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
|
|
3931
3952
|
} catch {
|
|
3932
3953
|
return false;
|
|
3933
3954
|
}
|
|
@@ -4084,7 +4105,7 @@ var Telemetry = class {
|
|
|
4084
4105
|
try {
|
|
4085
4106
|
const packageJsonPath = import_meta4.resolve("prisma/package.json");
|
|
4086
4107
|
const packageJsonUrl = new URL(packageJsonPath);
|
|
4087
|
-
const packageJson = JSON.parse(
|
|
4108
|
+
const packageJson = JSON.parse(import_node_fs12.default.readFileSync(packageJsonUrl, "utf8"));
|
|
4088
4109
|
return packageJson.version;
|
|
4089
4110
|
} catch {
|
|
4090
4111
|
return void 0;
|