@zenstackhq/cli 3.3.1-beta.1 → 3.3.1
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 +18 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -29,7 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var import_config = require("dotenv/config");
|
|
32
|
-
var
|
|
32
|
+
var import_language4 = require("@zenstackhq/language");
|
|
33
33
|
var import_colors10 = __toESM(require("colors"), 1);
|
|
34
34
|
var import_commander = require("commander");
|
|
35
35
|
|
|
@@ -931,7 +931,6 @@ function handleSubProcessError2(err) {
|
|
|
931
931
|
__name(handleSubProcessError2, "handleSubProcessError");
|
|
932
932
|
|
|
933
933
|
// src/actions/proxy.ts
|
|
934
|
-
var import_language4 = require("@zenstackhq/language");
|
|
935
934
|
var import_ast3 = require("@zenstackhq/language/ast");
|
|
936
935
|
var import_utils2 = require("@zenstackhq/language/utils");
|
|
937
936
|
var import_orm = require("@zenstackhq/orm");
|
|
@@ -1001,6 +1000,11 @@ __name(getLatestVersion, "getLatestVersion");
|
|
|
1001
1000
|
// src/actions/proxy.ts
|
|
1002
1001
|
var import_meta3 = {};
|
|
1003
1002
|
async function run9(options) {
|
|
1003
|
+
const allowedLogLevels = [
|
|
1004
|
+
"error",
|
|
1005
|
+
"query"
|
|
1006
|
+
];
|
|
1007
|
+
const log = options.logLevel?.filter((level) => allowedLogLevels.includes(level));
|
|
1004
1008
|
const schemaFile = getSchemaFile(options.schema);
|
|
1005
1009
|
console.log(import_colors9.default.gray(`Loading ZModel schema from: ${schemaFile}`));
|
|
1006
1010
|
let outputPath = getOutputPath(options, schemaFile);
|
|
@@ -1015,19 +1019,12 @@ async function run9(options) {
|
|
|
1015
1019
|
if (!schemaUrl) {
|
|
1016
1020
|
throw new CliError(`The schema's "datasource" does not have a "url" field, please provide it with -d option.`);
|
|
1017
1021
|
}
|
|
1018
|
-
|
|
1019
|
-
const url = zModelGenerator.generate(schemaUrl);
|
|
1020
|
-
databaseUrl = evaluateUrl(url);
|
|
1022
|
+
databaseUrl = evaluateUrl(schemaUrl);
|
|
1021
1023
|
}
|
|
1022
1024
|
const provider = (0, import_utils2.getStringLiteral)(dataSource?.fields.find((f) => f.name === "provider")?.value);
|
|
1023
1025
|
const dialect = createDialect(provider, databaseUrl, outputPath);
|
|
1024
1026
|
const jiti = (0, import_jiti2.createJiti)(import_meta3.url);
|
|
1025
1027
|
const schemaModule = await jiti.import(import_node_path9.default.join(outputPath, "schema"));
|
|
1026
|
-
const allowedLogLevels = [
|
|
1027
|
-
"error",
|
|
1028
|
-
"query"
|
|
1029
|
-
];
|
|
1030
|
-
const log = options.logLevel?.filter((level) => allowedLogLevels.includes(level));
|
|
1031
1028
|
const db = new import_orm.ZenStackClient(schemaModule.schema, {
|
|
1032
1029
|
dialect,
|
|
1033
1030
|
log: log && log.length > 0 ? log : void 0
|
|
@@ -1040,17 +1037,19 @@ async function run9(options) {
|
|
|
1040
1037
|
startServer(db, schemaModule.schema, options);
|
|
1041
1038
|
}
|
|
1042
1039
|
__name(run9, "run");
|
|
1043
|
-
function evaluateUrl(
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
const
|
|
1040
|
+
function evaluateUrl(schemaUrl) {
|
|
1041
|
+
if ((0, import_ast3.isLiteralExpr)(schemaUrl)) {
|
|
1042
|
+
return (0, import_utils2.getStringLiteral)(schemaUrl);
|
|
1043
|
+
} else if ((0, import_ast3.isInvocationExpr)(schemaUrl)) {
|
|
1044
|
+
const envFunction = schemaUrl;
|
|
1045
|
+
const envName = (0, import_utils2.getStringLiteral)(envFunction.args[0]?.value);
|
|
1046
|
+
const envValue = process.env[envName];
|
|
1048
1047
|
if (!envValue) {
|
|
1049
|
-
throw new CliError(`Environment variable ${
|
|
1048
|
+
throw new CliError(`Environment variable ${envName} is not set`);
|
|
1050
1049
|
}
|
|
1051
1050
|
return envValue;
|
|
1052
1051
|
} else {
|
|
1053
|
-
|
|
1052
|
+
throw new CliError(`Unable to resolve the "url" field value.`);
|
|
1054
1053
|
}
|
|
1055
1054
|
}
|
|
1056
1055
|
__name(evaluateUrl, "evaluateUrl");
|
|
@@ -1159,7 +1158,7 @@ var import_node_fs13 = __toESM(require("fs"), 1);
|
|
|
1159
1158
|
var os2 = __toESM(require("os"), 1);
|
|
1160
1159
|
|
|
1161
1160
|
// src/constants.ts
|
|
1162
|
-
var TELEMETRY_TRACKING_TOKEN = "
|
|
1161
|
+
var TELEMETRY_TRACKING_TOKEN = "74944eb779d7d3b4ce185be843fde9fc";
|
|
1163
1162
|
|
|
1164
1163
|
// src/utils/is-ci.ts
|
|
1165
1164
|
var import_node_process = require("process");
|
|
@@ -1422,7 +1421,7 @@ var proxyAction = /* @__PURE__ */ __name(async (options) => {
|
|
|
1422
1421
|
}, "proxyAction");
|
|
1423
1422
|
function createProgram() {
|
|
1424
1423
|
const program = new import_commander.Command("zen").alias("zenstack").helpOption("-h, --help", "Show this help message").version(getVersion(), "-v --version", "Show CLI version");
|
|
1425
|
-
const schemaExtensions =
|
|
1424
|
+
const schemaExtensions = import_language4.ZModelLanguageMetaData.fileExtensions.join(", ");
|
|
1426
1425
|
program.description(`${import_colors10.default.bold.blue("\u03B6")} ZenStack is the modern data layer for TypeScript apps.
|
|
1427
1426
|
|
|
1428
1427
|
Documentation: https://zenstack.dev/docs`).showHelpAfterError().showSuggestionAfterError();
|