@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.js
CHANGED
|
@@ -914,8 +914,7 @@ function handleSubProcessError2(err) {
|
|
|
914
914
|
__name(handleSubProcessError2, "handleSubProcessError");
|
|
915
915
|
|
|
916
916
|
// src/actions/proxy.ts
|
|
917
|
-
import {
|
|
918
|
-
import { isDataSource as isDataSource2 } from "@zenstackhq/language/ast";
|
|
917
|
+
import { isDataSource as isDataSource2, isInvocationExpr, isLiteralExpr } from "@zenstackhq/language/ast";
|
|
919
918
|
import { getStringLiteral } from "@zenstackhq/language/utils";
|
|
920
919
|
import { ZenStackClient } from "@zenstackhq/orm";
|
|
921
920
|
import { MysqlDialect } from "@zenstackhq/orm/dialects/mysql";
|
|
@@ -982,6 +981,11 @@ __name(getLatestVersion, "getLatestVersion");
|
|
|
982
981
|
|
|
983
982
|
// src/actions/proxy.ts
|
|
984
983
|
async function run9(options) {
|
|
984
|
+
const allowedLogLevels = [
|
|
985
|
+
"error",
|
|
986
|
+
"query"
|
|
987
|
+
];
|
|
988
|
+
const log = options.logLevel?.filter((level) => allowedLogLevels.includes(level));
|
|
985
989
|
const schemaFile = getSchemaFile(options.schema);
|
|
986
990
|
console.log(colors9.gray(`Loading ZModel schema from: ${schemaFile}`));
|
|
987
991
|
let outputPath = getOutputPath(options, schemaFile);
|
|
@@ -996,19 +1000,12 @@ async function run9(options) {
|
|
|
996
1000
|
if (!schemaUrl) {
|
|
997
1001
|
throw new CliError(`The schema's "datasource" does not have a "url" field, please provide it with -d option.`);
|
|
998
1002
|
}
|
|
999
|
-
|
|
1000
|
-
const url = zModelGenerator.generate(schemaUrl);
|
|
1001
|
-
databaseUrl = evaluateUrl(url);
|
|
1003
|
+
databaseUrl = evaluateUrl(schemaUrl);
|
|
1002
1004
|
}
|
|
1003
1005
|
const provider = getStringLiteral(dataSource?.fields.find((f) => f.name === "provider")?.value);
|
|
1004
1006
|
const dialect = createDialect(provider, databaseUrl, outputPath);
|
|
1005
1007
|
const jiti = createJiti2(import.meta.url);
|
|
1006
1008
|
const schemaModule = await jiti.import(path9.join(outputPath, "schema"));
|
|
1007
|
-
const allowedLogLevels = [
|
|
1008
|
-
"error",
|
|
1009
|
-
"query"
|
|
1010
|
-
];
|
|
1011
|
-
const log = options.logLevel?.filter((level) => allowedLogLevels.includes(level));
|
|
1012
1009
|
const db = new ZenStackClient(schemaModule.schema, {
|
|
1013
1010
|
dialect,
|
|
1014
1011
|
log: log && log.length > 0 ? log : void 0
|
|
@@ -1021,17 +1018,19 @@ async function run9(options) {
|
|
|
1021
1018
|
startServer(db, schemaModule.schema, options);
|
|
1022
1019
|
}
|
|
1023
1020
|
__name(run9, "run");
|
|
1024
|
-
function evaluateUrl(
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
const
|
|
1021
|
+
function evaluateUrl(schemaUrl) {
|
|
1022
|
+
if (isLiteralExpr(schemaUrl)) {
|
|
1023
|
+
return getStringLiteral(schemaUrl);
|
|
1024
|
+
} else if (isInvocationExpr(schemaUrl)) {
|
|
1025
|
+
const envFunction = schemaUrl;
|
|
1026
|
+
const envName = getStringLiteral(envFunction.args[0]?.value);
|
|
1027
|
+
const envValue = process.env[envName];
|
|
1029
1028
|
if (!envValue) {
|
|
1030
|
-
throw new CliError(`Environment variable ${
|
|
1029
|
+
throw new CliError(`Environment variable ${envName} is not set`);
|
|
1031
1030
|
}
|
|
1032
1031
|
return envValue;
|
|
1033
1032
|
} else {
|
|
1034
|
-
|
|
1033
|
+
throw new CliError(`Unable to resolve the "url" field value.`);
|
|
1035
1034
|
}
|
|
1036
1035
|
}
|
|
1037
1036
|
__name(evaluateUrl, "evaluateUrl");
|
|
@@ -1140,7 +1139,7 @@ import fs13 from "fs";
|
|
|
1140
1139
|
import * as os2 from "os";
|
|
1141
1140
|
|
|
1142
1141
|
// src/constants.ts
|
|
1143
|
-
var TELEMETRY_TRACKING_TOKEN = "
|
|
1142
|
+
var TELEMETRY_TRACKING_TOKEN = "74944eb779d7d3b4ce185be843fde9fc";
|
|
1144
1143
|
|
|
1145
1144
|
// src/utils/is-ci.ts
|
|
1146
1145
|
import { env } from "process";
|