@zenstackhq/cli 3.8.0-beta.1 → 3.8.0-beta.3
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 +9 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import "dotenv/config";
|
|
|
6
6
|
import { DataModel, Enum, isDataField, isDataSource, isEnum, isInvocationExpr, isLiteralExpr, isPlugin } from "@zenstackhq/language/ast";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { invariant, lowerCaseFirst, singleDebounce } from "@zenstackhq/common-helpers";
|
|
9
|
-
import { PrismaSchemaGenerator, TsSchemaGenerator } from "@zenstackhq/sdk";
|
|
9
|
+
import { PrismaSchemaGenerator, TsSchemaGenerator, detectImportFileExtension } from "@zenstackhq/sdk";
|
|
10
10
|
import { createJiti } from "jiti";
|
|
11
11
|
import crypto, { createHash, randomUUID } from "node:crypto";
|
|
12
12
|
import fs from "node:fs";
|
|
@@ -31,7 +31,7 @@ import { RPCApiHandler } from "@zenstackhq/server/api";
|
|
|
31
31
|
import { ZenStackMiddleware } from "@zenstackhq/server/express";
|
|
32
32
|
import cors from "cors";
|
|
33
33
|
import express from "express";
|
|
34
|
-
import
|
|
34
|
+
import "mixpanel";
|
|
35
35
|
import * as os$1 from "os";
|
|
36
36
|
import process$1, { env } from "node:process";
|
|
37
37
|
import os from "node:os";
|
|
@@ -289,7 +289,7 @@ async function checkPluginResolution(schemaFile, model) {
|
|
|
289
289
|
for (const plugin of plugins) {
|
|
290
290
|
const provider = getPluginProvider(plugin);
|
|
291
291
|
if (!provider.startsWith("@core/")) {
|
|
292
|
-
const pluginSourcePath = plugin.$cstNode?.
|
|
292
|
+
const pluginSourcePath = plugin.$cstNode?.container?.astNode.$document?.uri?.fsPath ?? schemaFile;
|
|
293
293
|
await loadPluginModule(provider, path.dirname(pluginSourcePath));
|
|
294
294
|
}
|
|
295
295
|
}
|
|
@@ -2305,7 +2305,7 @@ async function runPull(options) {
|
|
|
2305
2305
|
model.declarations.splice(index, 1);
|
|
2306
2306
|
deletedEnums.push(colors.red(`- Enum ${decl.name} deleted`));
|
|
2307
2307
|
});
|
|
2308
|
-
newModel.declarations.filter((d) =>
|
|
2308
|
+
newModel.declarations.filter((d) => d.$type === DataModel.$type || d.$type === Enum.$type).forEach((_declaration) => {
|
|
2309
2309
|
const newDataModel = _declaration;
|
|
2310
2310
|
const declarations = services.shared.workspace.IndexManager.allElements(newDataModel.$type, docsSet).toArray();
|
|
2311
2311
|
const originalDataModel = declarations.find((d) => getDbName(d.node) === getDbName(newDataModel))?.node;
|
|
@@ -2602,8 +2602,9 @@ const plugin = {
|
|
|
2602
2602
|
}
|
|
2603
2603
|
const lite = pluginOptions["lite"] === true;
|
|
2604
2604
|
const liteOnly = pluginOptions["liteOnly"] === true;
|
|
2605
|
-
|
|
2606
|
-
if (importWithFileExtension
|
|
2605
|
+
let importWithFileExtension = pluginOptions["importWithFileExtension"];
|
|
2606
|
+
if (importWithFileExtension === void 0) importWithFileExtension = detectImportFileExtension(outDir);
|
|
2607
|
+
else if (typeof importWithFileExtension !== "string") throw new Error("The \"importWithFileExtension\" option must be a string if specified.");
|
|
2607
2608
|
const generateModelTypes = pluginOptions["generateModels"] !== false;
|
|
2608
2609
|
const generateInputTypes = pluginOptions["generateInput"] !== false;
|
|
2609
2610
|
await new TsSchemaGenerator().generate(model, {
|
|
@@ -2640,7 +2641,7 @@ async function run$5(options) {
|
|
|
2640
2641
|
const logsEnabled = !options.silent;
|
|
2641
2642
|
if (logsEnabled) console.log(colors.green(`\nEnabled watch mode!`));
|
|
2642
2643
|
const schemaExtensions = ZModelLanguageMetaData.fileExtensions;
|
|
2643
|
-
const getRootModelWatchPaths = (model) => new Set(model.declarations.filter((v) => v.$cstNode?.
|
|
2644
|
+
const getRootModelWatchPaths = (model) => new Set(model.declarations.filter((v) => v.$cstNode?.container?.astNode.$type === "Model" && !!v.$cstNode.container.astNode.$document?.uri?.fsPath).map((v) => v.$cstNode.container.astNode.$document.uri.fsPath));
|
|
2644
2645
|
const watchedPaths = getRootModelWatchPaths(model);
|
|
2645
2646
|
if (logsEnabled) {
|
|
2646
2647
|
const logPaths = [...watchedPaths].map((at) => `- ${at}`).join("\n");
|
|
@@ -2722,7 +2723,7 @@ async function runPlugins(schemaFile, model, outputPath, options) {
|
|
|
2722
2723
|
cliPlugin = plugins_exports[provider.slice(6)];
|
|
2723
2724
|
if (!cliPlugin) throw new CliError(`Unknown core plugin: ${provider}`);
|
|
2724
2725
|
} else {
|
|
2725
|
-
const pluginSourcePath = plugin.$cstNode?.
|
|
2726
|
+
const pluginSourcePath = plugin.$cstNode?.container?.astNode.$document?.uri?.fsPath ?? schemaFile;
|
|
2726
2727
|
cliPlugin = await loadPluginModule(provider, path.dirname(pluginSourcePath));
|
|
2727
2728
|
}
|
|
2728
2729
|
if (cliPlugin) {
|
|
@@ -3193,9 +3194,6 @@ function startServer(client, schema, options) {
|
|
|
3193
3194
|
});
|
|
3194
3195
|
}
|
|
3195
3196
|
//#endregion
|
|
3196
|
-
//#region src/constants.ts
|
|
3197
|
-
const TELEMETRY_TRACKING_TOKEN = "<TELEMETRY_TRACKING_TOKEN>";
|
|
3198
|
-
//#endregion
|
|
3199
3197
|
//#region src/utils/is-ci.ts
|
|
3200
3198
|
const isInCi = env["CI"] !== "0" && env["CI"] !== "false" && ("CI" in env || "CONTINUOUS_INTEGRATION" in env || Object.keys(env).some((key) => key.startsWith("CI_")));
|
|
3201
3199
|
//#endregion
|
|
@@ -3304,9 +3302,7 @@ var Telemetry = class {
|
|
|
3304
3302
|
isWsl = isWsl();
|
|
3305
3303
|
isContainer = isInContainer();
|
|
3306
3304
|
isCi = isInCi;
|
|
3307
|
-
constructor() {
|
|
3308
|
-
if (process.env["DO_NOT_TRACK"] !== "1" && "<TELEMETRY_TRACKING_TOKEN>") this.mixpanel = init(TELEMETRY_TRACKING_TOKEN, { geolocate: true });
|
|
3309
|
-
}
|
|
3305
|
+
constructor() {}
|
|
3310
3306
|
get isTracking() {
|
|
3311
3307
|
return !!this.mixpanel;
|
|
3312
3308
|
}
|