@cedarjs/project-config 8.0.0-canary.3428 → 8.0.0-canary.3429

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/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './configPath.js';
3
3
  export * from './envVars.js';
4
4
  export * from './generatedDataDir.js';
5
5
  export * from './paths.js';
6
+ export * from './processMeta.js';
6
7
  export * from './findUp.js';
7
8
  export * from './prisma.js';
8
9
  export { getEnvVarDefinitions } from './envVarDefinitions.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,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"}
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,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA"}
package/dist/index.js CHANGED
@@ -388,19 +388,19 @@ var processPagesDir = (webPagesDir = getPaths().web.pages) => {
388
388
  };
389
389
  });
390
390
  };
391
- var ensurePosixPath = (path7) => {
392
- let posixPath = path7;
391
+ var ensurePosixPath = (path8) => {
392
+ let posixPath = path8;
393
393
  if (process.platform === "win32") {
394
- if (/^[A-Z]:\\/.test(path7)) {
395
- const drive = path7[0].toLowerCase();
396
- posixPath = `/${drive}/${path7.substring(3)}`;
394
+ if (/^[A-Z]:\\/.test(path8)) {
395
+ const drive = path8[0].toLowerCase();
396
+ posixPath = `/${drive}/${path8.substring(3)}`;
397
397
  }
398
398
  posixPath = posixPath.replace(/\\/g, "/");
399
399
  }
400
400
  return posixPath;
401
401
  };
402
- var importStatementPath = (path7) => {
403
- let importPath = path7;
402
+ var importStatementPath = (path8) => {
403
+ let importPath = path8;
404
404
  if (process.platform === "win32") {
405
405
  importPath = importPath.replaceAll("\\", "/");
406
406
  }
@@ -411,15 +411,44 @@ var isTypeScriptProject = () => {
411
411
  return fs4.existsSync(path3.join(paths.web.base, "tsconfig.json")) || fs4.existsSync(path3.join(paths.api.base, "tsconfig.json"));
412
412
  };
413
413
 
414
+ // src/processMeta.ts
415
+ import fs5 from "node:fs";
416
+ import path4 from "node:path";
417
+ var PROCESS_META_DIR_NAME = "process-meta";
418
+ var API_PROCESS_META_FILE_NAME = "api.json";
419
+ function writeApiProcessMeta({
420
+ port,
421
+ host,
422
+ rootPath
423
+ }) {
424
+ const processMetaDir = path4.join(
425
+ getGeneratedDataDirPath(),
426
+ PROCESS_META_DIR_NAME
427
+ );
428
+ const metaPath = path4.join(processMetaDir, API_PROCESS_META_FILE_NAME);
429
+ const tmpPath = `${metaPath}.${process.pid}.tmp`;
430
+ const meta = {
431
+ version: 1,
432
+ port,
433
+ host,
434
+ ...rootPath !== void 0 ? { rootPath } : {},
435
+ pid: process.pid,
436
+ startedAt: new Date(Date.now() - process.uptime() * 1e3).toISOString()
437
+ };
438
+ fs5.mkdirSync(processMetaDir, { recursive: true });
439
+ fs5.writeFileSync(tmpPath, JSON.stringify(meta, null, 2) + "\n");
440
+ fs5.renameSync(tmpPath, metaPath);
441
+ }
442
+
414
443
  // src/prisma.ts
415
- import fs6 from "node:fs";
416
- import path5 from "node:path";
444
+ import fs7 from "node:fs";
445
+ import path6 from "node:path";
417
446
  import { pathToFileURL } from "node:url";
418
447
  import { Worker } from "node:worker_threads";
419
448
 
420
449
  // src/packageManager.ts
421
- import fs5 from "node:fs";
422
- import path4 from "node:path";
450
+ import fs6 from "node:fs";
451
+ import path5 from "node:path";
423
452
  var packageManagerCache;
424
453
  function getPackageManager() {
425
454
  if (packageManagerCache) {
@@ -430,11 +459,11 @@ function getPackageManager() {
430
459
  const envPackageManager = process.env.npm_config_user_agent?.split(" ")[0]?.split("/")[0];
431
460
  if (isPackageManager(envPackageManager)) {
432
461
  packageManagerCache = envPackageManager;
433
- } else if (fs5.existsSync(path4.join(base, "yarn.lock"))) {
462
+ } else if (fs6.existsSync(path5.join(base, "yarn.lock"))) {
434
463
  packageManagerCache = "yarn";
435
- } else if (fs5.existsSync(path4.join(base, "pnpm-lock.yaml"))) {
464
+ } else if (fs6.existsSync(path5.join(base, "pnpm-lock.yaml"))) {
436
465
  packageManagerCache = "pnpm";
437
- } else if (fs5.existsSync(path4.join(base, "package-lock.json"))) {
466
+ } else if (fs6.existsSync(path5.join(base, "package-lock.json"))) {
438
467
  packageManagerCache = "npm";
439
468
  }
440
469
  return packageManagerCache;
@@ -451,7 +480,7 @@ function prettyPrintCedarCommand(args) {
451
480
  // src/prisma.ts
452
481
  var configCache = /* @__PURE__ */ new Map();
453
482
  async function loadPrismaConfig(prismaConfigPath) {
454
- if (!fs6.existsSync(prismaConfigPath)) {
483
+ if (!fs7.existsSync(prismaConfigPath)) {
455
484
  throw new Error(`Prisma config file not found at: ${prismaConfigPath}`);
456
485
  }
457
486
  if (configCache.has(prismaConfigPath)) {
@@ -475,18 +504,18 @@ async function loadPrismaConfig(prismaConfigPath) {
475
504
  }
476
505
  async function getSchemaPath(prismaConfigPath) {
477
506
  const config = await loadPrismaConfig(prismaConfigPath);
478
- const configDir = path5.dirname(prismaConfigPath);
507
+ const configDir = path6.dirname(prismaConfigPath);
479
508
  if (config.schema) {
480
- return path5.isAbsolute(config.schema) ? config.schema : path5.resolve(configDir, config.schema);
509
+ return path6.isAbsolute(config.schema) ? config.schema : path6.resolve(configDir, config.schema);
481
510
  }
482
- return path5.join(configDir, "schema.prisma");
511
+ return path6.join(configDir, "schema.prisma");
483
512
  }
484
513
  async function getPrismaSchemas() {
485
514
  const mod = await import("@prisma/internals");
486
515
  const { createSchemaPathInput, getSchemaWithPath } = mod.default || mod;
487
516
  const schemaPath = await getSchemaPath(getPaths().api.prismaConfig);
488
517
  const schemaPathInput = createSchemaPathInput({
489
- baseDir: fs6.lstatSync(schemaPath).isDirectory() ? schemaPath : path5.dirname(schemaPath),
518
+ baseDir: fs7.lstatSync(schemaPath).isDirectory() ? schemaPath : path6.dirname(schemaPath),
490
519
  schemaPathFromConfig: schemaPath
491
520
  });
492
521
  return getSchemaWithPath({ schemaPath: schemaPathInput });
@@ -500,25 +529,25 @@ async function getPrismaDatasourceProvider() {
500
529
  }
501
530
  async function getMigrationsPath(prismaConfigPath) {
502
531
  const config = await loadPrismaConfig(prismaConfigPath);
503
- const configDir = path5.dirname(prismaConfigPath);
532
+ const configDir = path6.dirname(prismaConfigPath);
504
533
  if (config.migrations?.path) {
505
- return path5.isAbsolute(config.migrations.path) ? config.migrations.path : path5.resolve(configDir, config.migrations.path);
534
+ return path6.isAbsolute(config.migrations.path) ? config.migrations.path : path6.resolve(configDir, config.migrations.path);
506
535
  }
507
536
  const schemaPath = await getSchemaPath(prismaConfigPath);
508
- const schemaDir = fs6.statSync(schemaPath).isDirectory() ? schemaPath : path5.dirname(schemaPath);
509
- return path5.join(schemaDir, "migrations");
537
+ const schemaDir = fs7.statSync(schemaPath).isDirectory() ? schemaPath : path6.dirname(schemaPath);
538
+ return path6.join(schemaDir, "migrations");
510
539
  }
511
540
  async function getDbDir(prismaConfigPath) {
512
541
  const schemaPath = await getSchemaPath(prismaConfigPath);
513
- if (fs6.existsSync(schemaPath) && fs6.statSync(schemaPath).isDirectory()) {
542
+ if (fs7.existsSync(schemaPath) && fs7.statSync(schemaPath).isDirectory()) {
514
543
  return schemaPath;
515
544
  }
516
- return path5.dirname(schemaPath);
545
+ return path6.dirname(schemaPath);
517
546
  }
518
547
  async function getDataMigrationsPath(prismaConfigPath) {
519
548
  const migrationsPath = await getMigrationsPath(prismaConfigPath);
520
- const migrationsDir = path5.dirname(migrationsPath);
521
- return path5.join(migrationsDir, "dataMigrations");
549
+ const migrationsDir = path6.dirname(migrationsPath);
550
+ return path6.join(migrationsDir, "dataMigrations");
522
551
  }
523
552
  async function getPrismaClientOutputDirs() {
524
553
  try {
@@ -531,7 +560,7 @@ async function getPrismaClientOutputDirs() {
531
560
  generator.provider.value ?? ""
532
561
  )
533
562
  ).map((generator) => generator.output?.value).filter((output) => Boolean(output)).map(
534
- (output) => path5.isAbsolute(output) ? output : path5.resolve(schemaRootDir, output)
563
+ (output) => path6.isAbsolute(output) ? output : path6.resolve(schemaRootDir, output)
535
564
  );
536
565
  } catch {
537
566
  return [];
@@ -563,8 +592,8 @@ function createPrismaClientFileMatcher(resolveOutputDirs = getPrismaClientOutput
563
592
  },
564
593
  matches: async (filePath) => {
565
594
  return (await getOutputDirs()).some((dir) => {
566
- const relativePath = path5.relative(dir, filePath);
567
- return relativePath !== "" && !relativePath.startsWith("..") && !path5.isAbsolute(relativePath);
595
+ const relativePath = path6.relative(dir, filePath);
596
+ return relativePath !== "" && !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
568
597
  });
569
598
  }
570
599
  };
@@ -585,12 +614,12 @@ async function resolveGeneratedPrismaClient() {
585
614
  ext = resolvedExtension;
586
615
  }
587
616
  if (output) {
588
- generatorOutputPath = path5.isAbsolute(output) ? output : path5.resolve(schemaRootDir, output);
617
+ generatorOutputPath = path6.isAbsolute(output) ? output : path6.resolve(schemaRootDir, output);
589
618
  }
590
619
  } catch {
591
620
  }
592
- const prismaClientEntry = typeof generatorOutputPath === "string" ? path5.join(generatorOutputPath, "client." + ext) : void 0;
593
- if (!prismaClientEntry || !fs6.existsSync(prismaClientEntry)) {
621
+ const prismaClientEntry = typeof generatorOutputPath === "string" ? path6.join(generatorOutputPath, "client." + ext) : void 0;
622
+ if (!prismaClientEntry || !fs7.existsSync(prismaClientEntry)) {
594
623
  const checked = prismaClientEntry ?? "(could not determine output path)";
595
624
  const pmCommand = prettyPrintCedarCommand(["prisma", "generate"]);
596
625
  return {
@@ -605,7 +634,7 @@ async function resolveGeneratedPrismaClient() {
605
634
  }
606
635
 
607
636
  // src/envVarDefinitions.ts
608
- import path6 from "node:path";
637
+ import path7 from "node:path";
609
638
  import { getConfig as getConfig2, getPaths as getPaths2 } from "@cedarjs/project-config";
610
639
  function getEnvVarDefinitions() {
611
640
  const rwConfig = getConfig2();
@@ -614,7 +643,7 @@ function getEnvVarDefinitions() {
614
643
  RWJS_ENV: {
615
644
  RWJS_API_GRAPHQL_URL: rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql",
616
645
  RWJS_API_URL: rwConfig.web.apiUrl,
617
- __REDWOOD__APP_TITLE: rwConfig.web.title || path6.basename(rwPaths.base),
646
+ __REDWOOD__APP_TITLE: rwConfig.web.title || path7.basename(rwPaths.base),
618
647
  RWJS_EXP_STREAMING_SSR: rwConfig.experimental.streamingSsr?.enabled,
619
648
  RWJS_EXP_RSC: rwConfig.experimental?.rsc?.enabled
620
649
  },
@@ -648,7 +677,9 @@ function getEnvVarDefinitions() {
648
677
  };
649
678
  }
650
679
  export {
680
+ API_PROCESS_META_FILE_NAME,
651
681
  DEFAULT_CONFIG,
682
+ PROCESS_META_DIR_NAME,
652
683
  TargetEnum,
653
684
  createPrismaClientFileMatcher,
654
685
  ensurePosixPath,
@@ -681,5 +712,6 @@ export {
681
712
  processPagesDir,
682
713
  readEnvVar,
683
714
  resolveFile,
684
- resolveGeneratedPrismaClient
715
+ resolveGeneratedPrismaClient,
716
+ writeApiProcessMeta
685
717
  };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Directory, in the generated data directory (`.cedar/`), where running
3
+ * processes record information about themselves, one file per kind of
4
+ * process. Deploys read it on the server to find out how the processes were
5
+ * started, which `--apiPort`, `CEDAR_API_PORT` or `PORT` can decide there
6
+ */
7
+ export declare const PROCESS_META_DIR_NAME = "process-meta";
8
+ /** File in the process meta directory that the api server writes */
9
+ export declare const API_PROCESS_META_FILE_NAME = "api.json";
10
+ /** What a running api server records about itself */
11
+ export interface ApiProcessMeta {
12
+ /** Version of this file's format */
13
+ version: 1;
14
+ /** Port the api server listens on */
15
+ port: number;
16
+ /** Address the api server listens on, like `::` or `127.0.0.1` */
17
+ host: string;
18
+ /**
19
+ * Path the api functions and GraphQL are served under, like `/` or `/api/`.
20
+ * Left out by the Universal Deploy server, whose root path is set when it's
21
+ * built
22
+ */
23
+ rootPath?: string;
24
+ /** Id of the process */
25
+ pid: number;
26
+ /** When the process started, as an ISO 8601 timestamp */
27
+ startedAt: string;
28
+ }
29
+ /**
30
+ * Writes what the running api server records about itself to
31
+ * `process-meta/api.json` in the project's generated data directory. The file
32
+ * is written to a temporary name and then renamed, so a reader never sees it
33
+ * half written
34
+ */
35
+ export declare function writeApiProcessMeta({ port, host, rootPath, }: Pick<ApiProcessMeta, 'port' | 'host' | 'rootPath'>): void;
36
+ //# sourceMappingURL=processMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processMeta.d.ts","sourceRoot":"","sources":["../src/processMeta.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,iBAAiB,CAAA;AAEnD,oEAAoE;AACpE,eAAO,MAAM,0BAA0B,aAAa,CAAA;AAEpD,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,OAAO,EAAE,CAAC,CAAA;IACV,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,IAAI,EACJ,QAAQ,GACT,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC,QAoBpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/project-config",
3
- "version": "8.0.0-canary.3428",
3
+ "version": "8.0.0-canary.3429",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@arethetypeswrong/cli": "0.18.5",
49
- "@cedarjs/framework-tools": "8.0.0-canary.3428",
49
+ "@cedarjs/framework-tools": "8.0.0-canary.3429",
50
50
  "concurrently": "9.2.5",
51
51
  "prisma": "7.10.0",
52
52
  "publint": "0.3.25",