@cedarjs/cli 5.0.0-canary.2573 → 5.0.0-canary.2575

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.
Files changed (2) hide show
  1. package/dist/lib/exec.js +18 -7
  2. package/package.json +12 -12
package/dist/lib/exec.js CHANGED
@@ -1,4 +1,4 @@
1
- import { existsSync } from "node:fs";
1
+ import { existsSync, statSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { createServer, isRunnableDevEnvironment } from "vite";
4
4
  import { getPaths, importStatementPath } from "@cedarjs/project-config";
@@ -11,8 +11,8 @@ import {
11
11
  cedarAutoImportsPlugin,
12
12
  cedarCjsCompatPlugin
13
13
  } from "@cedarjs/vite";
14
- function resolveExtension(id) {
15
- if (existsSync(id)) {
14
+ function resolveId(id) {
15
+ if (existsSync(id) && statSync(id).isFile()) {
16
16
  return id;
17
17
  }
18
18
  const withoutExt = /\.jsx?$/.test(id) ? id.replace(/\.jsx?$/, "") : id;
@@ -21,6 +21,16 @@ function resolveExtension(id) {
21
21
  return withoutExt + ext;
22
22
  }
23
23
  }
24
+ if (existsSync(id) && statSync(id).isDirectory()) {
25
+ for (const base of ["index", path.basename(id)]) {
26
+ for (const ext of [".ts", ".tsx", ".js", ".jsx"]) {
27
+ const candidate = path.join(id, base + ext);
28
+ if (existsSync(candidate)) {
29
+ return candidate;
30
+ }
31
+ }
32
+ }
33
+ }
24
34
  return id;
25
35
  }
26
36
  async function runScriptFunction({
@@ -69,12 +79,12 @@ async function runScriptFunction({
69
79
  const webImportBase = importStatementPath(getPaths().web.base);
70
80
  if (importer?.startsWith(apiImportBase)) {
71
81
  const apiImportSrc = importStatementPath(getPaths().api.src);
72
- const resolvedId = id.replace("src", apiImportSrc);
73
- return { id: resolveExtension(resolvedId) };
82
+ const apiId = id.replace("src", apiImportSrc);
83
+ return { id: resolveId(apiId) };
74
84
  } else if (importer?.startsWith(webImportBase)) {
75
85
  const webImportSrc = importStatementPath(getPaths().web.src);
76
- const resolvedId = id.replace("src", webImportSrc);
77
- return { id: resolveExtension(resolvedId) };
86
+ const webId = id.replace("src", webImportSrc);
87
+ return { id: resolveId(webId) };
78
88
  }
79
89
  return null;
80
90
  }
@@ -118,5 +128,6 @@ async function runScriptFunction({
118
128
  return returnValue;
119
129
  }
120
130
  export {
131
+ resolveId,
121
132
  runScriptFunction
122
133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "5.0.0-canary.2573",
3
+ "version": "5.0.0-canary.2575",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,17 +33,17 @@
33
33
  "dependencies": {
34
34
  "@babel/parser": "7.29.7",
35
35
  "@babel/preset-typescript": "7.29.7",
36
- "@cedarjs/api-server": "5.0.0-canary.2573",
37
- "@cedarjs/cli-helpers": "5.0.0-canary.2573",
38
- "@cedarjs/fastify-web": "5.0.0-canary.2573",
39
- "@cedarjs/internal": "5.0.0-canary.2573",
40
- "@cedarjs/prerender": "5.0.0-canary.2573",
41
- "@cedarjs/project-config": "5.0.0-canary.2573",
42
- "@cedarjs/structure": "5.0.0-canary.2573",
43
- "@cedarjs/telemetry": "5.0.0-canary.2573",
44
- "@cedarjs/utils": "5.0.0-canary.2573",
45
- "@cedarjs/vite": "5.0.0-canary.2573",
46
- "@cedarjs/web-server": "5.0.0-canary.2573",
36
+ "@cedarjs/api-server": "5.0.0-canary.2575",
37
+ "@cedarjs/cli-helpers": "5.0.0-canary.2575",
38
+ "@cedarjs/fastify-web": "5.0.0-canary.2575",
39
+ "@cedarjs/internal": "5.0.0-canary.2575",
40
+ "@cedarjs/prerender": "5.0.0-canary.2575",
41
+ "@cedarjs/project-config": "5.0.0-canary.2575",
42
+ "@cedarjs/structure": "5.0.0-canary.2575",
43
+ "@cedarjs/telemetry": "5.0.0-canary.2575",
44
+ "@cedarjs/utils": "5.0.0-canary.2575",
45
+ "@cedarjs/vite": "5.0.0-canary.2575",
46
+ "@cedarjs/web-server": "5.0.0-canary.2575",
47
47
  "@listr2/prompt-adapter-enquirer": "4.2.1",
48
48
  "@opentelemetry/api": "1.9.1",
49
49
  "@opentelemetry/core": "1.30.1",