@cedarjs/project-config 8.0.0-canary.3601 → 8.0.0-canary.3604

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
@@ -6,5 +6,6 @@ export * from './paths.js';
6
6
  export * from './processMeta.js';
7
7
  export * from './findUp.js';
8
8
  export * from './prisma.js';
9
+ export * from './otel.js';
9
10
  export { getEnvVarDefinitions } from './envVarDefinitions.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -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,kBAAkB,CAAA;AAChC,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,cAAc,WAAW,CAAA;AACzB,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 = (path8) => {
392
- let posixPath = path8;
391
+ var ensurePosixPath = (path9) => {
392
+ let posixPath = path9;
393
393
  if (process.platform === "win32") {
394
- if (/^[A-Z]:\\/.test(path8)) {
395
- const drive = path8[0].toLowerCase();
396
- posixPath = `/${drive}/${path8.substring(3)}`;
394
+ if (/^[A-Z]:\\/.test(path9)) {
395
+ const drive = path9[0].toLowerCase();
396
+ posixPath = `/${drive}/${path9.substring(3)}`;
397
397
  }
398
398
  posixPath = posixPath.replace(/\\/g, "/");
399
399
  }
400
400
  return posixPath;
401
401
  };
402
- var importStatementPath = (path8) => {
403
- let importPath = path8;
402
+ var importStatementPath = (path9) => {
403
+ let importPath = path9;
404
404
  if (process.platform === "win32") {
405
405
  importPath = importPath.replaceAll("\\", "/");
406
406
  }
@@ -633,8 +633,46 @@ async function resolveGeneratedPrismaClient() {
633
633
  };
634
634
  }
635
635
 
636
- // src/envVarDefinitions.ts
636
+ // src/otel.ts
637
+ import fs8 from "node:fs";
637
638
  import path7 from "node:path";
639
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
640
+ function getOTelSetupFileUrl() {
641
+ let configPath;
642
+ try {
643
+ configPath = getConfigPath();
644
+ } catch {
645
+ return void 0;
646
+ }
647
+ if (!fs8.existsSync(configPath)) {
648
+ return void 0;
649
+ }
650
+ const enabled = getConfig().experimental.opentelemetry.enabled;
651
+ if (!enabled) {
652
+ return void 0;
653
+ }
654
+ const setupFilePath = path7.join(getPaths().api.dist, "opentelemetry.js");
655
+ if (!fs8.existsSync(setupFilePath)) {
656
+ console.warn(
657
+ `OpenTelemetry is enabled, but the setup file does not exist at ${setupFilePath}. Run \`cedar build api\` to build it, after running \`cedar experimental setup-opentelemetry\` if your project doesn't have an \`api/src/opentelemetry\` file yet.`
658
+ );
659
+ return void 0;
660
+ }
661
+ return pathToFileURL2(setupFilePath).href;
662
+ }
663
+ function getOTelImportArgs() {
664
+ const setupFileUrl = getOTelSetupFileUrl();
665
+ return setupFileUrl === void 0 ? [] : [`--import=${setupFileUrl}`];
666
+ }
667
+ function quoteOTelImportArgs(args, platform = process.platform) {
668
+ if (platform === "win32") {
669
+ return args.map((arg) => `"${arg}"`);
670
+ }
671
+ return args.map((arg) => `'${arg.replaceAll("'", `'\\''`)}'`);
672
+ }
673
+
674
+ // src/envVarDefinitions.ts
675
+ import path8 from "node:path";
638
676
  import { getConfig as getConfig2, getPaths as getPaths2 } from "@cedarjs/project-config";
639
677
  function getEnvVarDefinitions() {
640
678
  const rwConfig = getConfig2();
@@ -643,7 +681,7 @@ function getEnvVarDefinitions() {
643
681
  RWJS_ENV: {
644
682
  RWJS_API_GRAPHQL_URL: rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql",
645
683
  RWJS_API_URL: rwConfig.web.apiUrl,
646
- __REDWOOD__APP_TITLE: rwConfig.web.title || path7.basename(rwPaths.base),
684
+ __REDWOOD__APP_TITLE: rwConfig.web.title || path8.basename(rwPaths.base),
647
685
  RWJS_EXP_STREAMING_SSR: rwConfig.experimental.streamingSsr?.enabled,
648
686
  RWJS_EXP_RSC: rwConfig.experimental?.rsc?.enabled
649
687
  },
@@ -696,6 +734,8 @@ export {
696
734
  getEnvVarDefinitions,
697
735
  getGeneratedDataDirPath,
698
736
  getMigrationsPath,
737
+ getOTelImportArgs,
738
+ getOTelSetupFileUrl,
699
739
  getParsedScalars,
700
740
  getPaths,
701
741
  getPrismaClientOutputDirs,
@@ -710,6 +750,7 @@ export {
710
750
  loadPrismaConfig,
711
751
  parsePort,
712
752
  processPagesDir,
753
+ quoteOTelImportArgs,
713
754
  readEnvVar,
714
755
  resolveFile,
715
756
  resolveGeneratedPrismaClient,
package/dist/otel.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The file URL of the project's built OpenTelemetry SDK setup file, or
3
+ * `undefined` when OpenTelemetry is disabled, the current directory is not
4
+ * a Cedar project, or the setup file does not exist.
5
+ *
6
+ * This is the single source of truth for locating the setup file: the
7
+ * `--import` argv entries that `getOTelImportArgs()` builds for child
8
+ * processes and the in-process `import()` performed by process launchers
9
+ * both consume it.
10
+ */
11
+ export declare function getOTelSetupFileUrl(): string | undefined;
12
+ /**
13
+ * The `--import` argv entries that load the project's OpenTelemetry SDK
14
+ * setup file in a child process, or an empty array when OpenTelemetry is
15
+ * disabled.
16
+ *
17
+ * The setup file is the built `api/dist/opentelemetry.js`. `--import` is
18
+ * used rather than `--require` because Cedar apps are `"type": "module"`,
19
+ * and a setup file using top-level await cannot be loaded through
20
+ * `require`. The path is returned as a file URL, which Node resolves as an
21
+ * ESM specifier on every platform.
22
+ *
23
+ * Note that loading the setup file this early only lets instrumentations
24
+ * patch modules that are loaded afterwards through CommonJS
25
+ * (require-in-the-middle). Modules loaded as ESM are only patched when the
26
+ * setup file registers an ESM loader hook (`module.register`), which the
27
+ * generated setup template currently does not do.
28
+ *
29
+ * Returns nothing when the current directory is not a Cedar project: these
30
+ * args are consumed by process launchers (the dev server watcher, the
31
+ * production API server, the job workers), which are also run from inside
32
+ * framework packages during their own test suites.
33
+ */
34
+ export declare function getOTelImportArgs(): string[];
35
+ /**
36
+ * Quote the `--import` argv entries from `getOTelImportArgs()` for a command
37
+ * string that will be run through a shell (`sh -c` on macOS/Linux,
38
+ * `cmd.exe /s /c` on Windows, as `concurrently` does).
39
+ *
40
+ * On POSIX a single-quoted string protects everything except a single quote
41
+ * itself, which is closed and re-escaped as `'\''`. On Windows `cmd.exe`
42
+ * treats single quotes as literal characters, so double quotes are used
43
+ * there; a double quote cannot appear in a file URL (it is percent-encoded
44
+ * by `pathToFileURL`), which is what these arguments wrap.
45
+ */
46
+ export declare function quoteOTelImportArgs(args: string[], platform?: NodeJS.Platform): string[];
47
+ //# sourceMappingURL=otel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAmCxD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAI5C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,EAAE,CAMV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/project-config",
3
- "version": "8.0.0-canary.3601",
3
+ "version": "8.0.0-canary.3604",
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.3601",
49
+ "@cedarjs/framework-tools": "8.0.0-canary.3604",
50
50
  "concurrently": "9.2.5",
51
51
  "prisma": "7.10.1",
52
52
  "publint": "0.3.25",