@cedarjs/project-config 5.0.7-next.186 → 5.0.7-next.239

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.
@@ -0,0 +1,32 @@
1
+ interface ReadEnvVarOptions {
2
+ /**
3
+ * The pre-fork `REDWOOD_`-prefixed name for this env var. Still read, so
4
+ * projects don't break on upgrade, but the `CEDAR_`-prefixed name wins.
5
+ */
6
+ deprecatedAlias: string;
7
+ }
8
+ /**
9
+ * Read an env var that was renamed when Cedar forked from Redwood.
10
+ *
11
+ * The `CEDAR_`-prefixed name wins. The `REDWOOD_`-prefixed one keeps working
12
+ * so existing projects don't break on upgrade.
13
+ *
14
+ * Empty strings are treated as unset, matching how a `.env` file with a blank
15
+ * value behaves.
16
+ */
17
+ export declare function readEnvVar(name: string, { deprecatedAlias }: ReadEnvVarOptions): string | undefined;
18
+ /**
19
+ * Parse a port from an env var, rejecting anything that isn't a usable port.
20
+ *
21
+ * `parseInt` alone is not enough here: it stops at the first non-digit, so
22
+ * `"8080abc"` would become `8080` and `"1.5"` would become `1`. Silently
23
+ * binding a port the user didn't ask for is how a deployment ends up
24
+ * unreachable, so the whole value has to look like an integer.
25
+ *
26
+ * Out-of-range values are rejected here too, so a bad env var is reported as
27
+ * a bad env var rather than surfacing later as a `ERR_SOCKET_BAD_PORT` from
28
+ * `listen()`. Port 0 is allowed — it means "pick a free port".
29
+ */
30
+ export declare function parsePort(value: string, envVarName: string): number;
31
+ export {};
32
+ //# sourceMappingURL=envVars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envVars.d.ts","sourceRoot":"","sources":["../../src/envVars.ts"],"names":[],"mappings":"AAAA,UAAU,iBAAiB;IACzB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,EAAE,eAAe,EAAE,EAAE,iBAAiB,GACrC,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAkBnE"}
@@ -1,5 +1,6 @@
1
1
  export * from './config.js';
2
2
  export * from './configPath.js';
3
+ export * from './envVars.js';
3
4
  export * from './generatedDataDir.js';
4
5
  export * from './paths.js';
5
6
  export * from './findUp.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA"}
package/dist/cjs/index.js CHANGED
@@ -47,6 +47,7 @@ __export(index_exports, {
47
47
  getGeneratedDataDirPath: () => getGeneratedDataDirPath,
48
48
  getMigrationsPath: () => getMigrationsPath,
49
49
  getPaths: () => getPaths,
50
+ getPrismaDatasourceProvider: () => getPrismaDatasourceProvider,
50
51
  getPrismaSchemas: () => getPrismaSchemas,
51
52
  getRawConfig: () => getRawConfig,
52
53
  getRouteHookForPage: () => getRouteHookForPage,
@@ -54,10 +55,12 @@ __export(index_exports, {
54
55
  importStatementPath: () => importStatementPath,
55
56
  isTypeScriptProject: () => isTypeScriptProject,
56
57
  loadPrismaConfig: () => loadPrismaConfig,
58
+ parsePort: () => parsePort,
57
59
  processPagesDir: () => processPagesDir,
58
60
  projectIsEsm: () => projectIsEsm,
59
61
  projectRootIsEsm: () => projectRootIsEsm,
60
62
  projectSideIsEsm: () => projectSideIsEsm,
63
+ readEnvVar: () => readEnvVar,
61
64
  resolveFile: () => resolveFile,
62
65
  resolveGeneratedPrismaClient: () => resolveGeneratedPrismaClient
63
66
  });
@@ -213,6 +216,26 @@ function getRawConfig(configPath = getConfigPath()) {
213
216
  }
214
217
  }
215
218
 
219
+ // src/envVars.ts
220
+ function readEnvVar(name, { deprecatedAlias }) {
221
+ return process.env[name] || process.env[deprecatedAlias] || void 0;
222
+ }
223
+ function parsePort(value, envVarName) {
224
+ const trimmed = value.trim();
225
+ if (!/^\d+$/.test(trimmed)) {
226
+ throw new Error(
227
+ `Invalid ${envVarName} env var value: "${value}". Must be an integer.`
228
+ );
229
+ }
230
+ const port = Number(trimmed);
231
+ if (port > 65535) {
232
+ throw new Error(
233
+ `Invalid ${envVarName} env var value: "${value}". Must be between 0 and 65535.`
234
+ );
235
+ }
236
+ return port;
237
+ }
238
+
216
239
  // src/generatedDataDir.ts
217
240
  var import_node_fs3 = __toESM(require("node:fs"), 1);
218
241
  var import_node_path = __toESM(require("node:path"), 1);
@@ -530,6 +553,13 @@ async function getPrismaSchemas() {
530
553
  });
531
554
  return getSchemaWithPath({ schemaPath: schemaPathInput });
532
555
  }
556
+ async function getPrismaDatasourceProvider() {
557
+ const mod = await import("@prisma/internals");
558
+ const { getConfig: getConfig3 } = mod.default || mod;
559
+ const { schemas } = await getPrismaSchemas();
560
+ const config = await getConfig3({ datamodel: schemas });
561
+ return config.datasources[0].activeProvider;
562
+ }
533
563
  async function getMigrationsPath(prismaConfigPath) {
534
564
  const config = await loadPrismaConfig(prismaConfigPath);
535
565
  const configDir = import_node_path3.default.dirname(prismaConfigPath);
@@ -649,6 +679,7 @@ function getEnvVarDefinitions() {
649
679
  getGeneratedDataDirPath,
650
680
  getMigrationsPath,
651
681
  getPaths,
682
+ getPrismaDatasourceProvider,
652
683
  getPrismaSchemas,
653
684
  getRawConfig,
654
685
  getRouteHookForPage,
@@ -656,10 +687,12 @@ function getEnvVarDefinitions() {
656
687
  importStatementPath,
657
688
  isTypeScriptProject,
658
689
  loadPrismaConfig,
690
+ parsePort,
659
691
  processPagesDir,
660
692
  projectIsEsm,
661
693
  projectRootIsEsm,
662
694
  projectSideIsEsm,
695
+ readEnvVar,
663
696
  resolveFile,
664
697
  resolveGeneratedPrismaClient
665
698
  });
@@ -19,6 +19,11 @@ export declare function getSchemaPath(prismaConfigPath: string): Promise<string>
19
19
  * Gets the Prisma schemas for the current project's default schema location.
20
20
  */
21
21
  export declare function getPrismaSchemas(): Promise<import("@prisma/schema-files-loader").GetSchemaResult>;
22
+ /**
23
+ * Gets the active datasource provider (e.g. `postgresql`, `mysql`, `sqlite`)
24
+ * configured in the project's `schema.prisma`.
25
+ */
26
+ export declare function getPrismaDatasourceProvider(): Promise<string>;
22
27
  /**
23
28
  * Gets the migrations path from Prisma config.
24
29
  * Defaults to 'migrations' in the same directory as the schema.
@@ -1 +1 @@
1
- {"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/prisma.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAQ1C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,yBA8B9D;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,gBAAgB,EAAE,MAAM,mBAY3D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,mEAgBrC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAA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;CAAE,CAAA;AAErD,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAwD/E"}
@@ -0,0 +1,32 @@
1
+ interface ReadEnvVarOptions {
2
+ /**
3
+ * The pre-fork `REDWOOD_`-prefixed name for this env var. Still read, so
4
+ * projects don't break on upgrade, but the `CEDAR_`-prefixed name wins.
5
+ */
6
+ deprecatedAlias: string;
7
+ }
8
+ /**
9
+ * Read an env var that was renamed when Cedar forked from Redwood.
10
+ *
11
+ * The `CEDAR_`-prefixed name wins. The `REDWOOD_`-prefixed one keeps working
12
+ * so existing projects don't break on upgrade.
13
+ *
14
+ * Empty strings are treated as unset, matching how a `.env` file with a blank
15
+ * value behaves.
16
+ */
17
+ export declare function readEnvVar(name: string, { deprecatedAlias }: ReadEnvVarOptions): string | undefined;
18
+ /**
19
+ * Parse a port from an env var, rejecting anything that isn't a usable port.
20
+ *
21
+ * `parseInt` alone is not enough here: it stops at the first non-digit, so
22
+ * `"8080abc"` would become `8080` and `"1.5"` would become `1`. Silently
23
+ * binding a port the user didn't ask for is how a deployment ends up
24
+ * unreachable, so the whole value has to look like an integer.
25
+ *
26
+ * Out-of-range values are rejected here too, so a bad env var is reported as
27
+ * a bad env var rather than surfacing later as a `ERR_SOCKET_BAD_PORT` from
28
+ * `listen()`. Port 0 is allowed — it means "pick a free port".
29
+ */
30
+ export declare function parsePort(value: string, envVarName: string): number;
31
+ export {};
32
+ //# sourceMappingURL=envVars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envVars.d.ts","sourceRoot":"","sources":["../src/envVars.ts"],"names":[],"mappings":"AAAA,UAAU,iBAAiB;IACzB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,EAAE,eAAe,EAAE,EAAE,iBAAiB,GACrC,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAkBnE"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './config.js';
2
2
  export * from './configPath.js';
3
+ export * from './envVars.js';
3
4
  export * from './generatedDataDir.js';
4
5
  export * from './paths.js';
5
6
  export * from './findUp.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA"}
package/dist/index.js CHANGED
@@ -148,6 +148,26 @@ function getRawConfig(configPath = getConfigPath()) {
148
148
  }
149
149
  }
150
150
 
151
+ // src/envVars.ts
152
+ function readEnvVar(name, { deprecatedAlias }) {
153
+ return process.env[name] || process.env[deprecatedAlias] || void 0;
154
+ }
155
+ function parsePort(value, envVarName) {
156
+ const trimmed = value.trim();
157
+ if (!/^\d+$/.test(trimmed)) {
158
+ throw new Error(
159
+ `Invalid ${envVarName} env var value: "${value}". Must be an integer.`
160
+ );
161
+ }
162
+ const port = Number(trimmed);
163
+ if (port > 65535) {
164
+ throw new Error(
165
+ `Invalid ${envVarName} env var value: "${value}". Must be between 0 and 65535.`
166
+ );
167
+ }
168
+ return port;
169
+ }
170
+
151
171
  // src/generatedDataDir.ts
152
172
  import fs3 from "node:fs";
153
173
  import path2 from "node:path";
@@ -465,6 +485,13 @@ async function getPrismaSchemas() {
465
485
  });
466
486
  return getSchemaWithPath({ schemaPath: schemaPathInput });
467
487
  }
488
+ async function getPrismaDatasourceProvider() {
489
+ const mod = await import("@prisma/internals");
490
+ const { getConfig: getConfig3 } = mod.default || mod;
491
+ const { schemas } = await getPrismaSchemas();
492
+ const config = await getConfig3({ datamodel: schemas });
493
+ return config.datasources[0].activeProvider;
494
+ }
468
495
  async function getMigrationsPath(prismaConfigPath) {
469
496
  const config = await loadPrismaConfig(prismaConfigPath);
470
497
  const configDir = path5.dirname(prismaConfigPath);
@@ -583,6 +610,7 @@ export {
583
610
  getGeneratedDataDirPath,
584
611
  getMigrationsPath,
585
612
  getPaths,
613
+ getPrismaDatasourceProvider,
586
614
  getPrismaSchemas,
587
615
  getRawConfig,
588
616
  getRouteHookForPage,
@@ -590,10 +618,12 @@ export {
590
618
  importStatementPath,
591
619
  isTypeScriptProject,
592
620
  loadPrismaConfig,
621
+ parsePort,
593
622
  processPagesDir,
594
623
  projectIsEsm,
595
624
  projectRootIsEsm,
596
625
  projectSideIsEsm,
626
+ readEnvVar,
597
627
  resolveFile,
598
628
  resolveGeneratedPrismaClient
599
629
  };
package/dist/prisma.d.ts CHANGED
@@ -19,6 +19,11 @@ export declare function getSchemaPath(prismaConfigPath: string): Promise<string>
19
19
  * Gets the Prisma schemas for the current project's default schema location.
20
20
  */
21
21
  export declare function getPrismaSchemas(): Promise<import("@prisma/schema-files-loader").GetSchemaResult>;
22
+ /**
23
+ * Gets the active datasource provider (e.g. `postgresql`, `mysql`, `sqlite`)
24
+ * configured in the project's `schema.prisma`.
25
+ */
26
+ export declare function getPrismaDatasourceProvider(): Promise<string>;
22
27
  /**
23
28
  * Gets the migrations path from Prisma config.
24
29
  * Defaults to 'migrations' in the same directory as the schema.
@@ -1 +1 @@
1
- {"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../src/prisma.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAQ1C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,yBA8B9D;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,gBAAgB,EAAE,MAAM,mBAY3D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,mEAgBrC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQxE;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAKjB;AAED,KAAK,iBAAiB,GAClB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACxC;IAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAwD/E"}
1
+ {"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../src/prisma.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAQ1C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,yBA8B9D;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,gBAAgB,EAAE,MAAM,mBAY3D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,mEAgBrC;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,MAAM,CAAC,CAWnE;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQxE;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAKjB;AAED,KAAK,iBAAiB,GAClB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACxC;IAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAwD/E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/project-config",
3
- "version": "5.0.7-next.186",
3
+ "version": "5.0.7-next.239",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -64,10 +64,10 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@arethetypeswrong/cli": "0.18.5",
67
- "@cedarjs/framework-tools": "5.0.7-next.186",
67
+ "@cedarjs/framework-tools": "5.0.7-next.239",
68
68
  "concurrently": "9.2.4",
69
69
  "prisma": "7.8.0",
70
- "publint": "0.3.22",
70
+ "publint": "0.3.23",
71
71
  "rimraf": "6.1.3",
72
72
  "typescript": "5.9.3",
73
73
  "vitest": "4.1.10"