@dashai/cli 0.14.0 → 0.14.2

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/bin.js CHANGED
@@ -8890,12 +8890,22 @@ async function queryCommand(options) {
8890
8890
  );
8891
8891
  return 1;
8892
8892
  }
8893
- async function runInline(expression, projectRoot, _generatedPath, jsonCompact, explain, stream) {
8893
+ async function runInline(expression, projectRoot, generatedPath, jsonCompact, explain, stream) {
8894
+ let entryUrl;
8895
+ try {
8896
+ entryUrl = generatedEntryUrl(generatedPath);
8897
+ } catch (err) {
8898
+ fail(err.message);
8899
+ info(
8900
+ `Try running ${code("dashwise module generate")} to refresh the typed wrappers.`
8901
+ );
8902
+ return 1;
8903
+ }
8894
8904
  const tmpDir = mkdtempSync(join(tmpdir(), "dashwise-query-"));
8895
8905
  const tmpFile = join(tmpDir, "inline.mjs");
8896
8906
  const cleanedExpr = expression.trim().replace(/;\s*$/, "");
8897
8907
  const source = [
8898
- "import { qb, deps, db } from '@dashai/generated';",
8908
+ `import { qb, deps, db } from ${JSON.stringify(entryUrl)};`,
8899
8909
  `export default (async () => (${cleanedExpr}))();`,
8900
8910
  ""
8901
8911
  ].join("\n");
@@ -9005,13 +9015,15 @@ async function importAndPrint(file, projectRoot, jsonCompact, explain, stream) {
9005
9015
  process.chdir(originalCwd);
9006
9016
  }
9007
9017
  }
9008
- async function dynamicImportFromPath(generatedDir) {
9018
+ function generatedEntryUrl(generatedDir) {
9009
9019
  const entry = join(generatedDir, "index.js");
9010
9020
  if (!existsSync(entry)) {
9011
9021
  throw new Error(`Expected ${entry} to exist. Did 'dashwise module generate' run?`);
9012
9022
  }
9013
- const url = pathToFileURL(entry).toString();
9014
- return await import(url);
9023
+ return pathToFileURL(entry).toString();
9024
+ }
9025
+ async function dynamicImportFromPath(generatedDir) {
9026
+ return await import(generatedEntryUrl(generatedDir));
9015
9027
  }
9016
9028
  function hydrateEnvFromDotenvLocal(projectRoot) {
9017
9029
  const envFile = join(projectRoot, ".env.local");
@@ -10071,7 +10083,7 @@ fieldCmd.command("set-type <table-slug> <field-slug> <new-type>").description(
10071
10083
  }
10072
10084
  })();
10073
10085
  function getVersion() {
10074
- return "0.14.0";
10086
+ return "0.14.2";
10075
10087
  }
10076
10088
  function parseIntOption(value) {
10077
10089
  const n = Number.parseInt(value, 10);