@cedarjs/project-config 4.2.0 → 4.2.1-next.258

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/cjs/index.js CHANGED
@@ -312,7 +312,7 @@ function getPaths(BASE_DIR = getBaseDir()) {
312
312
  generators: import_path2.default.join(BASE_DIR, "web/generators"),
313
313
  app: resolveFile(import_path2.default.join(BASE_DIR, "web/src/App")),
314
314
  document: resolveFile(import_path2.default.join(BASE_DIR, "web/src/Document")),
315
- html: import_path2.default.join(BASE_DIR, "web/src/index.html"),
315
+ html: import_path2.default.join(BASE_DIR, "web/index.html"),
316
316
  config: import_path2.default.join(BASE_DIR, "web/config"),
317
317
  viteConfig,
318
318
  postcss: import_path2.default.join(BASE_DIR, "web/config/postcss.config.cjs"),
@@ -279,7 +279,7 @@ function getPaths(BASE_DIR = getBaseDir()) {
279
279
  generators: import_path2.default.join(BASE_DIR, "web/generators"),
280
280
  app: resolveFile(import_path2.default.join(BASE_DIR, "web/src/App")),
281
281
  document: resolveFile(import_path2.default.join(BASE_DIR, "web/src/Document")),
282
- html: import_path2.default.join(BASE_DIR, "web/src/index.html"),
282
+ html: import_path2.default.join(BASE_DIR, "web/index.html"),
283
283
  config: import_path2.default.join(BASE_DIR, "web/config"),
284
284
  viteConfig,
285
285
  postcss: import_path2.default.join(BASE_DIR, "web/config/postcss.config.cjs"),
@@ -0,0 +1,2 @@
1
+ export declare function getNonApiWebWorkspaces(baseDir: string): string[];
2
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../src/workspaces.ts"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAQhE"}
@@ -0,0 +1,376 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/workspaces.ts
31
+ var workspaces_exports = {};
32
+ __export(workspaces_exports, {
33
+ getNonApiWebWorkspaces: () => getNonApiWebWorkspaces
34
+ });
35
+ module.exports = __toCommonJS(workspaces_exports);
36
+ var import_node_fs6 = __toESM(require("node:fs"), 1);
37
+ var import_node_path3 = __toESM(require("node:path"), 1);
38
+
39
+ // src/packageManager.ts
40
+ var import_node_fs5 = __toESM(require("node:fs"), 1);
41
+ var import_node_path2 = __toESM(require("node:path"), 1);
42
+
43
+ // src/paths.ts
44
+ var import_node_fs4 = __toESM(require("node:fs"), 1);
45
+ var import_path2 = __toESM(require("path"), 1);
46
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
47
+
48
+ // src/config.ts
49
+ var import_node_fs2 = __toESM(require("node:fs"), 1);
50
+ var import_deepmerge = __toESM(require("deepmerge"), 1);
51
+ var toml = __toESM(require("smol-toml"), 1);
52
+ var import_string_env_interpolation = require("string-env-interpolation");
53
+
54
+ // src/findUp.ts
55
+ var import_node_fs = __toESM(require("node:fs"), 1);
56
+ var import_path = __toESM(require("path"), 1);
57
+ function findUp(file, startingDirectory = process.cwd()) {
58
+ const possibleFilepath = import_path.default.join(startingDirectory, file);
59
+ if (import_node_fs.default.existsSync(possibleFilepath)) {
60
+ return possibleFilepath;
61
+ }
62
+ const parentDirectory = import_path.default.dirname(startingDirectory);
63
+ if (parentDirectory === startingDirectory) {
64
+ return null;
65
+ }
66
+ return findUp(file, parentDirectory);
67
+ }
68
+
69
+ // src/configPath.ts
70
+ var CONFIG_FILE_NAMES = ["cedar.toml", "redwood.toml"];
71
+ var getConfigPathCache = /* @__PURE__ */ new Map();
72
+ var getConfigPath = (cwd = process.env.CEDAR_CWD ?? process.env.RWJS_CWD ?? process.cwd()) => {
73
+ const cachedPath = getConfigPathCache.get(cwd);
74
+ if (cachedPath) {
75
+ return cachedPath;
76
+ }
77
+ const configPath = findUp("cedar.toml", cwd) || findUp("redwood.toml", cwd);
78
+ if (!configPath) {
79
+ throw new Error(
80
+ `Could not find a "${CONFIG_FILE_NAMES.join('" or "')}" file, are you sure you're in a Cedar project?`
81
+ );
82
+ }
83
+ getConfigPathCache.set(cwd, configPath);
84
+ return configPath;
85
+ };
86
+
87
+ // src/config.ts
88
+ var DEFAULT_CONFIG = {
89
+ web: {
90
+ title: "Cedar App",
91
+ port: 8910,
92
+ path: "./web",
93
+ target: "browser" /* BROWSER */,
94
+ includeEnvironmentVariables: [],
95
+ apiUrl: "/.api/functions",
96
+ fastRefresh: true,
97
+ a11y: true,
98
+ sourceMap: false
99
+ },
100
+ api: {
101
+ title: "Cedar App",
102
+ port: 8911,
103
+ path: "./api",
104
+ target: "node" /* NODE */,
105
+ prismaConfig: "./api/prisma.config.cjs",
106
+ prismaGenerateArgs: [],
107
+ serverConfig: "./api/server.config.js",
108
+ debugPort: void 0
109
+ },
110
+ graphql: {
111
+ fragments: false,
112
+ trustedDocuments: false,
113
+ includeScalars: { File: true }
114
+ },
115
+ browser: {
116
+ open: false
117
+ },
118
+ generate: {
119
+ tests: true,
120
+ stories: true,
121
+ nestScaffoldByModel: true
122
+ },
123
+ notifications: {
124
+ versionUpdates: []
125
+ },
126
+ studio: {
127
+ basePort: 4318,
128
+ graphiql: {
129
+ authImpersonation: {
130
+ authProvider: void 0,
131
+ userId: void 0,
132
+ email: void 0,
133
+ jwtSecret: "secret"
134
+ }
135
+ }
136
+ },
137
+ experimental: {
138
+ opentelemetry: {
139
+ enabled: false,
140
+ wrapApi: true
141
+ },
142
+ cli: {
143
+ autoInstall: true,
144
+ plugins: [
145
+ {
146
+ package: "@cedarjs/cli-storybook-vite"
147
+ },
148
+ {
149
+ package: "@cedarjs/cli-data-migrate"
150
+ }
151
+ ]
152
+ },
153
+ useSDLCodeGenForGraphQLTypes: false,
154
+ streamingSsr: {
155
+ enabled: false
156
+ },
157
+ rsc: {
158
+ enabled: false
159
+ },
160
+ realtime: {
161
+ enabled: false
162
+ },
163
+ reactCompiler: {
164
+ enabled: false,
165
+ lintOnly: false
166
+ },
167
+ packagesWorkspace: {
168
+ enabled: false
169
+ },
170
+ gqlorm: {
171
+ enabled: false,
172
+ organizationModel: "Organization",
173
+ membershipModel: "Membership",
174
+ membershipUserField: "userId",
175
+ membershipOrganizationField: "organizationId"
176
+ }
177
+ },
178
+ eslintLegacyConfigWarning: true
179
+ };
180
+ function getConfig(configPath) {
181
+ const config = (0, import_deepmerge.default)(DEFAULT_CONFIG, getRawConfig(configPath));
182
+ return config;
183
+ }
184
+ function getRawConfig(configPath = getConfigPath()) {
185
+ try {
186
+ return toml.parse((0, import_string_env_interpolation.env)(import_node_fs2.default.readFileSync(configPath, "utf8")));
187
+ } catch (e) {
188
+ throw new Error(`Could not parse "${configPath}": ${e}`);
189
+ }
190
+ }
191
+
192
+ // src/generatedDataDir.ts
193
+ var import_node_fs3 = __toESM(require("node:fs"), 1);
194
+ var import_node_path = __toESM(require("node:path"), 1);
195
+ function getGeneratedDataDirPath(cwd = process.env.CEDAR_CWD ?? process.env.RWJS_CWD ?? process.cwd()) {
196
+ const configPath = getConfigPath(cwd);
197
+ const projectRoot = import_node_path.default.dirname(configPath);
198
+ const rootDotCedarDir = import_node_path.default.join(projectRoot, ".cedar");
199
+ const rootDotRedwoodDir = import_node_path.default.join(projectRoot, ".redwood");
200
+ const generatedDirPath = import_node_fs3.default.existsSync(rootDotCedarDir) ? rootDotCedarDir : import_node_fs3.default.existsSync(rootDotRedwoodDir) ? rootDotRedwoodDir : rootDotCedarDir;
201
+ return generatedDirPath;
202
+ }
203
+
204
+ // src/paths.ts
205
+ var getBaseDir = (configPath = getConfigPath()) => {
206
+ return import_path2.default.dirname(configPath);
207
+ };
208
+ var resolveFile = (filePath, extensions = [".js", ".tsx", ".ts", ".jsx", ".mjs", ".mts", ".cjs"]) => {
209
+ for (const extension of extensions) {
210
+ const p = `${filePath}${extension}`;
211
+ if (import_node_fs4.default.existsSync(p)) {
212
+ return p;
213
+ }
214
+ }
215
+ return null;
216
+ };
217
+ var getPathsCache = /* @__PURE__ */ new Map();
218
+ function getPaths(BASE_DIR = getBaseDir()) {
219
+ if (getPathsCache.has(BASE_DIR)) {
220
+ return getPathsCache.get(BASE_DIR);
221
+ }
222
+ const routes = resolveFile(import_path2.default.join(BASE_DIR, "web/src/Routes"));
223
+ const { prismaConfig: prismaConfigFromConfig } = getConfig(
224
+ getConfigPath(BASE_DIR)
225
+ ).api;
226
+ const prismaConfigBase = import_path2.default.join(
227
+ BASE_DIR,
228
+ prismaConfigFromConfig.replace(/\.[^.]+$/, "")
229
+ );
230
+ const prismaConfig = resolveFile(prismaConfigBase) || import_path2.default.join(BASE_DIR, prismaConfigFromConfig);
231
+ const viteConfig = resolveFile(
232
+ import_path2.default.join(BASE_DIR, "web/vite.config")
233
+ );
234
+ const generatedBase = getGeneratedDataDirPath(BASE_DIR);
235
+ const paths = {
236
+ base: BASE_DIR,
237
+ generated: {
238
+ base: generatedBase,
239
+ schema: import_path2.default.join(generatedBase, "schema.graphql"),
240
+ types: {
241
+ includes: import_path2.default.join(generatedBase, "types/includes"),
242
+ mirror: import_path2.default.join(generatedBase, "types/mirror")
243
+ },
244
+ prebuild: import_path2.default.join(generatedBase, "prebuild")
245
+ },
246
+ scripts: import_path2.default.join(BASE_DIR, "scripts"),
247
+ packages: import_path2.default.join(BASE_DIR, "packages"),
248
+ generatorTemplates: import_path2.default.join(BASE_DIR, "generatorTemplates"),
249
+ api: {
250
+ base: import_path2.default.join(BASE_DIR, "api"),
251
+ prismaConfig,
252
+ functions: import_path2.default.join(BASE_DIR, "api/src/functions"),
253
+ graphql: import_path2.default.join(BASE_DIR, "api/src/graphql"),
254
+ lib: import_path2.default.join(BASE_DIR, "api/src/lib"),
255
+ generators: import_path2.default.join(BASE_DIR, "api/generators"),
256
+ config: import_path2.default.join(BASE_DIR, "api/src/config"),
257
+ services: import_path2.default.join(BASE_DIR, "api/src/services"),
258
+ directives: import_path2.default.join(BASE_DIR, "api/src/directives"),
259
+ subscriptions: import_path2.default.join(BASE_DIR, "api/src/subscriptions"),
260
+ src: import_path2.default.join(BASE_DIR, "api/src"),
261
+ dist: import_path2.default.join(BASE_DIR, "api/dist"),
262
+ types: import_path2.default.join(BASE_DIR, "api/types"),
263
+ models: import_path2.default.join(BASE_DIR, "api/src/models"),
264
+ mail: import_path2.default.join(BASE_DIR, "api/src", "mail"),
265
+ jobs: import_path2.default.join(BASE_DIR, "api/src/jobs"),
266
+ distJobs: import_path2.default.join(BASE_DIR, "api/dist/jobs"),
267
+ jobsConfig: resolveFile(import_path2.default.join(BASE_DIR, "api/src/lib", "jobs")),
268
+ distJobsConfig: resolveFile(
269
+ import_path2.default.join(BASE_DIR, "api/dist", "lib", "jobs")
270
+ ),
271
+ logger: resolveFile(import_path2.default.join(BASE_DIR, "api/src/lib", "logger"))
272
+ },
273
+ web: {
274
+ routes,
275
+ base: import_path2.default.join(BASE_DIR, "web"),
276
+ pages: import_path2.default.join(BASE_DIR, "web/src/pages/"),
277
+ components: import_path2.default.join(BASE_DIR, "web/src/components"),
278
+ layouts: import_path2.default.join(BASE_DIR, "web/src/layouts/"),
279
+ src: import_path2.default.join(BASE_DIR, "web/src"),
280
+ storybook: import_path2.default.join(BASE_DIR, "web/.storybook"),
281
+ generators: import_path2.default.join(BASE_DIR, "web/generators"),
282
+ app: resolveFile(import_path2.default.join(BASE_DIR, "web/src/App")),
283
+ document: resolveFile(import_path2.default.join(BASE_DIR, "web/src/Document")),
284
+ html: import_path2.default.join(BASE_DIR, "web/index.html"),
285
+ config: import_path2.default.join(BASE_DIR, "web/config"),
286
+ viteConfig,
287
+ postcss: import_path2.default.join(BASE_DIR, "web/config/postcss.config.cjs"),
288
+ storybookConfig: import_path2.default.join(BASE_DIR, "web/.storybook/main.js"),
289
+ storybookPreviewConfig: resolveFile(
290
+ import_path2.default.join(BASE_DIR, "web/.storybook/preview")
291
+ ),
292
+ storybookManagerConfig: import_path2.default.join(BASE_DIR, "web/.storybook/manager.js"),
293
+ dist: import_path2.default.join(BASE_DIR, "web/dist"),
294
+ distBrowser: import_path2.default.join(BASE_DIR, "web/dist/browser"),
295
+ distRsc: import_path2.default.join(BASE_DIR, "web/dist/rsc"),
296
+ distSsr: import_path2.default.join(BASE_DIR, "web/dist/ssr"),
297
+ distSsrDocument: import_path2.default.join(BASE_DIR, "web/dist/ssr/Document"),
298
+ distSsrEntryServer: import_path2.default.join(BASE_DIR, "web/dist/ssr/entry.server"),
299
+ distRouteHooks: import_path2.default.join(BASE_DIR, "web/dist/ssr/routeHooks"),
300
+ distRscEntries: import_path2.default.join(BASE_DIR, "web/dist/rsc/entries.mjs"),
301
+ routeManifest: import_path2.default.join(BASE_DIR, "web/dist/ssr/route-manifest.json"),
302
+ types: import_path2.default.join(BASE_DIR, "web/types"),
303
+ entryClient: resolveFile(import_path2.default.join(BASE_DIR, "web/src/entry.client")),
304
+ // new vite/stream entry point for client
305
+ entryServer: resolveFile(import_path2.default.join(BASE_DIR, "web/src/entry.server")),
306
+ graphql: import_path2.default.join(BASE_DIR, "web/src/graphql")
307
+ }
308
+ };
309
+ import_node_fs4.default.mkdirSync(paths.generated.types.includes, { recursive: true });
310
+ import_node_fs4.default.mkdirSync(paths.generated.types.mirror, { recursive: true });
311
+ getPathsCache.set(BASE_DIR, paths);
312
+ return paths;
313
+ }
314
+
315
+ // src/packageManager.ts
316
+ var packageManagerCache;
317
+ function getPackageManager() {
318
+ if (packageManagerCache) {
319
+ return packageManagerCache;
320
+ }
321
+ const base = getPaths().base;
322
+ packageManagerCache = "yarn";
323
+ const envPackageManager = process.env.npm_config_user_agent?.split(" ")[0]?.split("/")[0];
324
+ if (isPackageManager(envPackageManager)) {
325
+ packageManagerCache = envPackageManager;
326
+ } else if (import_node_fs5.default.existsSync(import_node_path2.default.join(base, "yarn.lock"))) {
327
+ packageManagerCache = "yarn";
328
+ } else if (import_node_fs5.default.existsSync(import_node_path2.default.join(base, "pnpm-lock.yaml"))) {
329
+ packageManagerCache = "pnpm";
330
+ } else if (import_node_fs5.default.existsSync(import_node_path2.default.join(base, "package-lock.json"))) {
331
+ packageManagerCache = "npm";
332
+ }
333
+ return packageManagerCache;
334
+ }
335
+ function isPackageManager(pm) {
336
+ return pm === "yarn" || pm === "npm" || pm === "pnpm";
337
+ }
338
+
339
+ // src/workspaces.ts
340
+ function getNonApiWebWorkspaces(baseDir) {
341
+ const pm = getPackageManager();
342
+ const workspaces = pm === "pnpm" ? readPnpmWorkspaces(baseDir) : readPackageJsonWorkspaces(baseDir);
343
+ return workspaces.filter((w) => w !== "api" && w !== "web");
344
+ }
345
+ function readPackageJsonWorkspaces(baseDir) {
346
+ const pkgPath = import_node_path3.default.join(baseDir, "package.json");
347
+ if (!import_node_fs6.default.existsSync(pkgPath)) {
348
+ return [];
349
+ }
350
+ try {
351
+ const pkg = JSON.parse(import_node_fs6.default.readFileSync(pkgPath, "utf8"));
352
+ return Array.isArray(pkg.workspaces) ? pkg.workspaces : [];
353
+ } catch {
354
+ return [];
355
+ }
356
+ }
357
+ function readPnpmWorkspaces(baseDir) {
358
+ const yamlPath = import_node_path3.default.join(baseDir, "pnpm-workspace.yaml");
359
+ if (!import_node_fs6.default.existsSync(yamlPath)) {
360
+ return [];
361
+ }
362
+ try {
363
+ const content = import_node_fs6.default.readFileSync(yamlPath, "utf8");
364
+ const match = content.match(/^packages:\n([\s\S]*?)(?=^\w|(?![\s\S]))/m);
365
+ if (!match) {
366
+ return [];
367
+ }
368
+ return match[1].split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2).trim()).filter(Boolean);
369
+ } catch {
370
+ return [];
371
+ }
372
+ }
373
+ // Annotate the CommonJS export names for ESM import in node:
374
+ 0 && (module.exports = {
375
+ getNonApiWebWorkspaces
376
+ });
package/dist/index.js CHANGED
@@ -247,7 +247,7 @@ function getPaths(BASE_DIR = getBaseDir()) {
247
247
  generators: path3.join(BASE_DIR, "web/generators"),
248
248
  app: resolveFile(path3.join(BASE_DIR, "web/src/App")),
249
249
  document: resolveFile(path3.join(BASE_DIR, "web/src/Document")),
250
- html: path3.join(BASE_DIR, "web/src/index.html"),
250
+ html: path3.join(BASE_DIR, "web/index.html"),
251
251
  config: path3.join(BASE_DIR, "web/config"),
252
252
  viteConfig,
253
253
  postcss: path3.join(BASE_DIR, "web/config/postcss.config.cjs"),
@@ -243,7 +243,7 @@ function getPaths(BASE_DIR = getBaseDir()) {
243
243
  generators: path3.join(BASE_DIR, "web/generators"),
244
244
  app: resolveFile(path3.join(BASE_DIR, "web/src/App")),
245
245
  document: resolveFile(path3.join(BASE_DIR, "web/src/Document")),
246
- html: path3.join(BASE_DIR, "web/src/index.html"),
246
+ html: path3.join(BASE_DIR, "web/index.html"),
247
247
  config: path3.join(BASE_DIR, "web/config"),
248
248
  viteConfig,
249
249
  postcss: path3.join(BASE_DIR, "web/config/postcss.config.cjs"),
@@ -0,0 +1,2 @@
1
+ export declare function getNonApiWebWorkspaces(baseDir: string): string[];
2
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAQhE"}
@@ -0,0 +1,341 @@
1
+ // src/workspaces.ts
2
+ import fs6 from "node:fs";
3
+ import path5 from "node:path";
4
+
5
+ // src/packageManager.ts
6
+ import fs5 from "node:fs";
7
+ import path4 from "node:path";
8
+
9
+ // src/paths.ts
10
+ import fs4 from "node:fs";
11
+ import path3 from "path";
12
+ import fg from "fast-glob";
13
+
14
+ // src/config.ts
15
+ import fs2 from "node:fs";
16
+ import merge from "deepmerge";
17
+ import * as toml from "smol-toml";
18
+ import { env as envInterpolation } from "string-env-interpolation";
19
+
20
+ // src/findUp.ts
21
+ import fs from "node:fs";
22
+ import path from "path";
23
+ function findUp(file, startingDirectory = process.cwd()) {
24
+ const possibleFilepath = path.join(startingDirectory, file);
25
+ if (fs.existsSync(possibleFilepath)) {
26
+ return possibleFilepath;
27
+ }
28
+ const parentDirectory = path.dirname(startingDirectory);
29
+ if (parentDirectory === startingDirectory) {
30
+ return null;
31
+ }
32
+ return findUp(file, parentDirectory);
33
+ }
34
+
35
+ // src/configPath.ts
36
+ var CONFIG_FILE_NAMES = ["cedar.toml", "redwood.toml"];
37
+ var getConfigPathCache = /* @__PURE__ */ new Map();
38
+ var getConfigPath = (cwd = process.env.CEDAR_CWD ?? process.env.RWJS_CWD ?? process.cwd()) => {
39
+ const cachedPath = getConfigPathCache.get(cwd);
40
+ if (cachedPath) {
41
+ return cachedPath;
42
+ }
43
+ const configPath = findUp("cedar.toml", cwd) || findUp("redwood.toml", cwd);
44
+ if (!configPath) {
45
+ throw new Error(
46
+ `Could not find a "${CONFIG_FILE_NAMES.join('" or "')}" file, are you sure you're in a Cedar project?`
47
+ );
48
+ }
49
+ getConfigPathCache.set(cwd, configPath);
50
+ return configPath;
51
+ };
52
+
53
+ // src/config.ts
54
+ var DEFAULT_CONFIG = {
55
+ web: {
56
+ title: "Cedar App",
57
+ port: 8910,
58
+ path: "./web",
59
+ target: "browser" /* BROWSER */,
60
+ includeEnvironmentVariables: [],
61
+ apiUrl: "/.api/functions",
62
+ fastRefresh: true,
63
+ a11y: true,
64
+ sourceMap: false
65
+ },
66
+ api: {
67
+ title: "Cedar App",
68
+ port: 8911,
69
+ path: "./api",
70
+ target: "node" /* NODE */,
71
+ prismaConfig: "./api/prisma.config.cjs",
72
+ prismaGenerateArgs: [],
73
+ serverConfig: "./api/server.config.js",
74
+ debugPort: void 0
75
+ },
76
+ graphql: {
77
+ fragments: false,
78
+ trustedDocuments: false,
79
+ includeScalars: { File: true }
80
+ },
81
+ browser: {
82
+ open: false
83
+ },
84
+ generate: {
85
+ tests: true,
86
+ stories: true,
87
+ nestScaffoldByModel: true
88
+ },
89
+ notifications: {
90
+ versionUpdates: []
91
+ },
92
+ studio: {
93
+ basePort: 4318,
94
+ graphiql: {
95
+ authImpersonation: {
96
+ authProvider: void 0,
97
+ userId: void 0,
98
+ email: void 0,
99
+ jwtSecret: "secret"
100
+ }
101
+ }
102
+ },
103
+ experimental: {
104
+ opentelemetry: {
105
+ enabled: false,
106
+ wrapApi: true
107
+ },
108
+ cli: {
109
+ autoInstall: true,
110
+ plugins: [
111
+ {
112
+ package: "@cedarjs/cli-storybook-vite"
113
+ },
114
+ {
115
+ package: "@cedarjs/cli-data-migrate"
116
+ }
117
+ ]
118
+ },
119
+ useSDLCodeGenForGraphQLTypes: false,
120
+ streamingSsr: {
121
+ enabled: false
122
+ },
123
+ rsc: {
124
+ enabled: false
125
+ },
126
+ realtime: {
127
+ enabled: false
128
+ },
129
+ reactCompiler: {
130
+ enabled: false,
131
+ lintOnly: false
132
+ },
133
+ packagesWorkspace: {
134
+ enabled: false
135
+ },
136
+ gqlorm: {
137
+ enabled: false,
138
+ organizationModel: "Organization",
139
+ membershipModel: "Membership",
140
+ membershipUserField: "userId",
141
+ membershipOrganizationField: "organizationId"
142
+ }
143
+ },
144
+ eslintLegacyConfigWarning: true
145
+ };
146
+ function getConfig(configPath) {
147
+ const config = merge(DEFAULT_CONFIG, getRawConfig(configPath));
148
+ return config;
149
+ }
150
+ function getRawConfig(configPath = getConfigPath()) {
151
+ try {
152
+ return toml.parse(envInterpolation(fs2.readFileSync(configPath, "utf8")));
153
+ } catch (e) {
154
+ throw new Error(`Could not parse "${configPath}": ${e}`);
155
+ }
156
+ }
157
+
158
+ // src/generatedDataDir.ts
159
+ import fs3 from "node:fs";
160
+ import path2 from "node:path";
161
+ function getGeneratedDataDirPath(cwd = process.env.CEDAR_CWD ?? process.env.RWJS_CWD ?? process.cwd()) {
162
+ const configPath = getConfigPath(cwd);
163
+ const projectRoot = path2.dirname(configPath);
164
+ const rootDotCedarDir = path2.join(projectRoot, ".cedar");
165
+ const rootDotRedwoodDir = path2.join(projectRoot, ".redwood");
166
+ const generatedDirPath = fs3.existsSync(rootDotCedarDir) ? rootDotCedarDir : fs3.existsSync(rootDotRedwoodDir) ? rootDotRedwoodDir : rootDotCedarDir;
167
+ return generatedDirPath;
168
+ }
169
+
170
+ // src/paths.ts
171
+ var getBaseDir = (configPath = getConfigPath()) => {
172
+ return path3.dirname(configPath);
173
+ };
174
+ var resolveFile = (filePath, extensions = [".js", ".tsx", ".ts", ".jsx", ".mjs", ".mts", ".cjs"]) => {
175
+ for (const extension of extensions) {
176
+ const p = `${filePath}${extension}`;
177
+ if (fs4.existsSync(p)) {
178
+ return p;
179
+ }
180
+ }
181
+ return null;
182
+ };
183
+ var getPathsCache = /* @__PURE__ */ new Map();
184
+ function getPaths(BASE_DIR = getBaseDir()) {
185
+ if (getPathsCache.has(BASE_DIR)) {
186
+ return getPathsCache.get(BASE_DIR);
187
+ }
188
+ const routes = resolveFile(path3.join(BASE_DIR, "web/src/Routes"));
189
+ const { prismaConfig: prismaConfigFromConfig } = getConfig(
190
+ getConfigPath(BASE_DIR)
191
+ ).api;
192
+ const prismaConfigBase = path3.join(
193
+ BASE_DIR,
194
+ prismaConfigFromConfig.replace(/\.[^.]+$/, "")
195
+ );
196
+ const prismaConfig = resolveFile(prismaConfigBase) || path3.join(BASE_DIR, prismaConfigFromConfig);
197
+ const viteConfig = resolveFile(
198
+ path3.join(BASE_DIR, "web/vite.config")
199
+ );
200
+ const generatedBase = getGeneratedDataDirPath(BASE_DIR);
201
+ const paths = {
202
+ base: BASE_DIR,
203
+ generated: {
204
+ base: generatedBase,
205
+ schema: path3.join(generatedBase, "schema.graphql"),
206
+ types: {
207
+ includes: path3.join(generatedBase, "types/includes"),
208
+ mirror: path3.join(generatedBase, "types/mirror")
209
+ },
210
+ prebuild: path3.join(generatedBase, "prebuild")
211
+ },
212
+ scripts: path3.join(BASE_DIR, "scripts"),
213
+ packages: path3.join(BASE_DIR, "packages"),
214
+ generatorTemplates: path3.join(BASE_DIR, "generatorTemplates"),
215
+ api: {
216
+ base: path3.join(BASE_DIR, "api"),
217
+ prismaConfig,
218
+ functions: path3.join(BASE_DIR, "api/src/functions"),
219
+ graphql: path3.join(BASE_DIR, "api/src/graphql"),
220
+ lib: path3.join(BASE_DIR, "api/src/lib"),
221
+ generators: path3.join(BASE_DIR, "api/generators"),
222
+ config: path3.join(BASE_DIR, "api/src/config"),
223
+ services: path3.join(BASE_DIR, "api/src/services"),
224
+ directives: path3.join(BASE_DIR, "api/src/directives"),
225
+ subscriptions: path3.join(BASE_DIR, "api/src/subscriptions"),
226
+ src: path3.join(BASE_DIR, "api/src"),
227
+ dist: path3.join(BASE_DIR, "api/dist"),
228
+ types: path3.join(BASE_DIR, "api/types"),
229
+ models: path3.join(BASE_DIR, "api/src/models"),
230
+ mail: path3.join(BASE_DIR, "api/src", "mail"),
231
+ jobs: path3.join(BASE_DIR, "api/src/jobs"),
232
+ distJobs: path3.join(BASE_DIR, "api/dist/jobs"),
233
+ jobsConfig: resolveFile(path3.join(BASE_DIR, "api/src/lib", "jobs")),
234
+ distJobsConfig: resolveFile(
235
+ path3.join(BASE_DIR, "api/dist", "lib", "jobs")
236
+ ),
237
+ logger: resolveFile(path3.join(BASE_DIR, "api/src/lib", "logger"))
238
+ },
239
+ web: {
240
+ routes,
241
+ base: path3.join(BASE_DIR, "web"),
242
+ pages: path3.join(BASE_DIR, "web/src/pages/"),
243
+ components: path3.join(BASE_DIR, "web/src/components"),
244
+ layouts: path3.join(BASE_DIR, "web/src/layouts/"),
245
+ src: path3.join(BASE_DIR, "web/src"),
246
+ storybook: path3.join(BASE_DIR, "web/.storybook"),
247
+ generators: path3.join(BASE_DIR, "web/generators"),
248
+ app: resolveFile(path3.join(BASE_DIR, "web/src/App")),
249
+ document: resolveFile(path3.join(BASE_DIR, "web/src/Document")),
250
+ html: path3.join(BASE_DIR, "web/index.html"),
251
+ config: path3.join(BASE_DIR, "web/config"),
252
+ viteConfig,
253
+ postcss: path3.join(BASE_DIR, "web/config/postcss.config.cjs"),
254
+ storybookConfig: path3.join(BASE_DIR, "web/.storybook/main.js"),
255
+ storybookPreviewConfig: resolveFile(
256
+ path3.join(BASE_DIR, "web/.storybook/preview")
257
+ ),
258
+ storybookManagerConfig: path3.join(BASE_DIR, "web/.storybook/manager.js"),
259
+ dist: path3.join(BASE_DIR, "web/dist"),
260
+ distBrowser: path3.join(BASE_DIR, "web/dist/browser"),
261
+ distRsc: path3.join(BASE_DIR, "web/dist/rsc"),
262
+ distSsr: path3.join(BASE_DIR, "web/dist/ssr"),
263
+ distSsrDocument: path3.join(BASE_DIR, "web/dist/ssr/Document"),
264
+ distSsrEntryServer: path3.join(BASE_DIR, "web/dist/ssr/entry.server"),
265
+ distRouteHooks: path3.join(BASE_DIR, "web/dist/ssr/routeHooks"),
266
+ distRscEntries: path3.join(BASE_DIR, "web/dist/rsc/entries.mjs"),
267
+ routeManifest: path3.join(BASE_DIR, "web/dist/ssr/route-manifest.json"),
268
+ types: path3.join(BASE_DIR, "web/types"),
269
+ entryClient: resolveFile(path3.join(BASE_DIR, "web/src/entry.client")),
270
+ // new vite/stream entry point for client
271
+ entryServer: resolveFile(path3.join(BASE_DIR, "web/src/entry.server")),
272
+ graphql: path3.join(BASE_DIR, "web/src/graphql")
273
+ }
274
+ };
275
+ fs4.mkdirSync(paths.generated.types.includes, { recursive: true });
276
+ fs4.mkdirSync(paths.generated.types.mirror, { recursive: true });
277
+ getPathsCache.set(BASE_DIR, paths);
278
+ return paths;
279
+ }
280
+
281
+ // src/packageManager.ts
282
+ var packageManagerCache;
283
+ function getPackageManager() {
284
+ if (packageManagerCache) {
285
+ return packageManagerCache;
286
+ }
287
+ const base = getPaths().base;
288
+ packageManagerCache = "yarn";
289
+ const envPackageManager = process.env.npm_config_user_agent?.split(" ")[0]?.split("/")[0];
290
+ if (isPackageManager(envPackageManager)) {
291
+ packageManagerCache = envPackageManager;
292
+ } else if (fs5.existsSync(path4.join(base, "yarn.lock"))) {
293
+ packageManagerCache = "yarn";
294
+ } else if (fs5.existsSync(path4.join(base, "pnpm-lock.yaml"))) {
295
+ packageManagerCache = "pnpm";
296
+ } else if (fs5.existsSync(path4.join(base, "package-lock.json"))) {
297
+ packageManagerCache = "npm";
298
+ }
299
+ return packageManagerCache;
300
+ }
301
+ function isPackageManager(pm) {
302
+ return pm === "yarn" || pm === "npm" || pm === "pnpm";
303
+ }
304
+
305
+ // src/workspaces.ts
306
+ function getNonApiWebWorkspaces(baseDir) {
307
+ const pm = getPackageManager();
308
+ const workspaces = pm === "pnpm" ? readPnpmWorkspaces(baseDir) : readPackageJsonWorkspaces(baseDir);
309
+ return workspaces.filter((w) => w !== "api" && w !== "web");
310
+ }
311
+ function readPackageJsonWorkspaces(baseDir) {
312
+ const pkgPath = path5.join(baseDir, "package.json");
313
+ if (!fs6.existsSync(pkgPath)) {
314
+ return [];
315
+ }
316
+ try {
317
+ const pkg = JSON.parse(fs6.readFileSync(pkgPath, "utf8"));
318
+ return Array.isArray(pkg.workspaces) ? pkg.workspaces : [];
319
+ } catch {
320
+ return [];
321
+ }
322
+ }
323
+ function readPnpmWorkspaces(baseDir) {
324
+ const yamlPath = path5.join(baseDir, "pnpm-workspace.yaml");
325
+ if (!fs6.existsSync(yamlPath)) {
326
+ return [];
327
+ }
328
+ try {
329
+ const content = fs6.readFileSync(yamlPath, "utf8");
330
+ const match = content.match(/^packages:\n([\s\S]*?)(?=^\w|(?![\s\S]))/m);
331
+ if (!match) {
332
+ return [];
333
+ }
334
+ return match[1].split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2).trim()).filter(Boolean);
335
+ } catch {
336
+ return [];
337
+ }
338
+ }
339
+ export {
340
+ getNonApiWebWorkspaces
341
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/project-config",
3
- "version": "4.2.0",
3
+ "version": "4.2.1-next.258",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -28,6 +28,16 @@
28
28
  "types": "./dist/cjs/packageManager.d.ts",
29
29
  "default": "./dist/cjs/packageManager.js"
30
30
  }
31
+ },
32
+ "./workspaces": {
33
+ "import": {
34
+ "types": "./dist/workspaces.d.ts",
35
+ "default": "./dist/workspaces.js"
36
+ },
37
+ "default": {
38
+ "types": "./dist/cjs/workspaces.d.ts",
39
+ "default": "./dist/cjs/workspaces.js"
40
+ }
31
41
  }
32
42
  },
33
43
  "types": "./dist/index.d.ts",
@@ -39,7 +49,7 @@
39
49
  "build:pack": "yarn pack -o cedarjs-project-config.tgz",
40
50
  "build:types": "tsc --build --verbose ./tsconfig.json ./tsconfig.cjs.json",
41
51
  "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
42
- "check:attw": "yarn attw -P",
52
+ "check:attw": "yarn cedar-fwtools-attw",
43
53
  "check:package": "concurrently npm:check:attw yarn:publint",
44
54
  "prepublishOnly": "NODE_ENV=production yarn build",
45
55
  "test": "vitest run",
@@ -53,15 +63,15 @@
53
63
  "string-env-interpolation": "1.0.1"
54
64
  },
55
65
  "devDependencies": {
56
- "@arethetypeswrong/cli": "0.18.2",
66
+ "@arethetypeswrong/cli": "0.18.4",
57
67
  "@cedarjs/framework-tools": "4.2.0",
58
68
  "concurrently": "9.2.1",
59
69
  "prisma": "7.8.0",
60
- "publint": "0.3.20",
70
+ "publint": "0.3.21",
61
71
  "rimraf": "6.1.3",
62
- "tsx": "4.21.0",
72
+ "tsx": "4.22.4",
63
73
  "typescript": "5.9.3",
64
- "vitest": "3.2.4"
74
+ "vitest": "3.2.6"
65
75
  },
66
76
  "engines": {
67
77
  "node": ">=24"