@cedarjs/project-config 7.0.0 → 8.0.0-canary.3263

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.
@@ -1,376 +0,0 @@
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
- test: {
138
- autoConsentToDbReset: false
139
- },
140
- experimental: {
141
- opentelemetry: {
142
- enabled: false,
143
- wrapApi: true
144
- },
145
- cli: {
146
- autoInstall: true,
147
- plugins: [
148
- {
149
- package: "@cedarjs/cli-storybook-vite"
150
- },
151
- {
152
- package: "@cedarjs/cli-data-migrate"
153
- }
154
- ]
155
- },
156
- useSDLCodeGenForGraphQLTypes: false,
157
- streamingSsr: {
158
- enabled: false
159
- },
160
- rsc: {
161
- enabled: false
162
- },
163
- realtime: {
164
- enabled: false
165
- },
166
- reactCompiler: {
167
- enabled: false,
168
- lintOnly: false
169
- },
170
- packagesWorkspace: {
171
- enabled: false
172
- },
173
- gqlorm: {
174
- enabled: false,
175
- organizationModel: "Organization",
176
- membershipModel: "Membership",
177
- membershipUserField: "userId",
178
- membershipOrganizationField: "organizationId"
179
- }
180
- }
181
- };
182
- function getConfig(configPath) {
183
- const config = (0, import_deepmerge.default)(DEFAULT_CONFIG, getRawConfig(configPath));
184
- return config;
185
- }
186
- function getRawConfig(configPath = getConfigPath()) {
187
- try {
188
- return toml.parse((0, import_string_env_interpolation.env)(import_node_fs2.default.readFileSync(configPath, "utf8")));
189
- } catch (e) {
190
- throw new Error(`Could not parse "${configPath}": ${e}`);
191
- }
192
- }
193
-
194
- // src/generatedDataDir.ts
195
- var import_node_fs3 = __toESM(require("node:fs"), 1);
196
- var import_node_path = __toESM(require("node:path"), 1);
197
- function getGeneratedDataDirPath(cwd = process.env.CEDAR_CWD ?? process.env.RWJS_CWD ?? process.cwd()) {
198
- const configPath = getConfigPath(cwd);
199
- const projectRoot = import_node_path.default.dirname(configPath);
200
- const rootDotCedarDir = import_node_path.default.join(projectRoot, ".cedar");
201
- const rootDotRedwoodDir = import_node_path.default.join(projectRoot, ".redwood");
202
- const generatedDirPath = import_node_fs3.default.existsSync(rootDotCedarDir) ? rootDotCedarDir : import_node_fs3.default.existsSync(rootDotRedwoodDir) ? rootDotRedwoodDir : rootDotCedarDir;
203
- return generatedDirPath;
204
- }
205
-
206
- // src/paths.ts
207
- var getBaseDir = (configPath = getConfigPath()) => {
208
- return import_path2.default.dirname(configPath);
209
- };
210
- var resolveFile = (filePath, extensions = [".js", ".tsx", ".ts", ".jsx", ".mjs", ".mts", ".cjs"]) => {
211
- for (const extension of extensions) {
212
- const p = `${filePath}${extension}`;
213
- if (import_node_fs4.default.existsSync(p)) {
214
- return p;
215
- }
216
- }
217
- return null;
218
- };
219
- var getPathsCache = /* @__PURE__ */ new Map();
220
- function getPaths(BASE_DIR = getBaseDir()) {
221
- if (getPathsCache.has(BASE_DIR)) {
222
- return getPathsCache.get(BASE_DIR);
223
- }
224
- const routes = resolveFile(import_path2.default.join(BASE_DIR, "web/src/Routes"));
225
- const { prismaConfig: prismaConfigFromConfig } = getConfig(
226
- getConfigPath(BASE_DIR)
227
- ).api;
228
- const prismaConfigBase = import_path2.default.join(
229
- BASE_DIR,
230
- prismaConfigFromConfig.replace(/\.[^.]+$/, "")
231
- );
232
- const prismaConfig = resolveFile(prismaConfigBase) || import_path2.default.join(BASE_DIR, prismaConfigFromConfig);
233
- const viteConfig = resolveFile(
234
- import_path2.default.join(BASE_DIR, "web/vite.config")
235
- );
236
- const generatedBase = getGeneratedDataDirPath(BASE_DIR);
237
- const paths = {
238
- base: BASE_DIR,
239
- generated: {
240
- base: generatedBase,
241
- schema: import_path2.default.join(generatedBase, "schema.graphql"),
242
- types: {
243
- includes: import_path2.default.join(generatedBase, "types/includes"),
244
- mirror: import_path2.default.join(generatedBase, "types/mirror")
245
- },
246
- prebuild: import_path2.default.join(generatedBase, "prebuild")
247
- },
248
- scripts: import_path2.default.join(BASE_DIR, "scripts"),
249
- packages: import_path2.default.join(BASE_DIR, "packages"),
250
- generatorTemplates: import_path2.default.join(BASE_DIR, "generatorTemplates"),
251
- api: {
252
- base: import_path2.default.join(BASE_DIR, "api"),
253
- prismaConfig,
254
- functions: import_path2.default.join(BASE_DIR, "api/src/functions"),
255
- graphql: import_path2.default.join(BASE_DIR, "api/src/graphql"),
256
- lib: import_path2.default.join(BASE_DIR, "api/src/lib"),
257
- config: import_path2.default.join(BASE_DIR, "api/src/config"),
258
- services: import_path2.default.join(BASE_DIR, "api/src/services"),
259
- directives: import_path2.default.join(BASE_DIR, "api/src/directives"),
260
- subscriptions: import_path2.default.join(BASE_DIR, "api/src/subscriptions"),
261
- src: import_path2.default.join(BASE_DIR, "api/src"),
262
- dist: import_path2.default.join(BASE_DIR, "api/dist"),
263
- types: import_path2.default.join(BASE_DIR, "api/types"),
264
- models: import_path2.default.join(BASE_DIR, "api/src/models"),
265
- mail: import_path2.default.join(BASE_DIR, "api/src", "mail"),
266
- jobs: import_path2.default.join(BASE_DIR, "api/src/jobs"),
267
- distJobs: import_path2.default.join(BASE_DIR, "api/dist/jobs"),
268
- jobsConfig: resolveFile(import_path2.default.join(BASE_DIR, "api/src/lib", "jobs")),
269
- distJobsConfig: resolveFile(
270
- import_path2.default.join(BASE_DIR, "api/dist", "lib", "jobs")
271
- ),
272
- logger: resolveFile(import_path2.default.join(BASE_DIR, "api/src/lib", "logger"))
273
- },
274
- web: {
275
- routes,
276
- base: import_path2.default.join(BASE_DIR, "web"),
277
- pages: import_path2.default.join(BASE_DIR, "web/src/pages/"),
278
- components: import_path2.default.join(BASE_DIR, "web/src/components"),
279
- layouts: import_path2.default.join(BASE_DIR, "web/src/layouts/"),
280
- src: import_path2.default.join(BASE_DIR, "web/src"),
281
- storybook: import_path2.default.join(BASE_DIR, "web/.storybook"),
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/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"module"}