@cedarjs/telemetry 9.0.0-canary.1784 → 9.0.0-canary.3124

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/README.md CHANGED
@@ -28,10 +28,11 @@ Here is an example JSON packet containing the telemetry data for running yarn rw
28
28
 
29
29
  ## How do I turn it off?
30
30
 
31
- Set an environment variable, either in your app's .env file, or anywhere that creates variables for your user space, like `.bashrc` or `.bash_profile`:
31
+ Set an environment variable, either in your app's .env file, or anywhere that
32
+ creates variables for your user space, like `.bashrc` or `.bash_profile`:
32
33
 
33
34
  ```terminal
34
- REDWOOD_DISABLE_TELEMETRY=1
35
+ CEDAR_DISABLE_TELEMETRY=1
35
36
  ```
36
37
 
37
38
  ## About
@@ -40,10 +41,11 @@ See: https://telemetry.redwoodjs.com
40
41
 
41
42
  ## Troubleshooting
42
43
 
43
- If you suspect problems with telemetry when running CRWA, you can set the verbose flag to help diagnose issues.
44
+ If you suspect problems with telemetry when running CCA, you can set the verbose
45
+ flag to help diagnose issues.
44
46
 
45
47
  For example,
46
48
 
47
49
  ```terminal
48
- REDWOOD_VERBOSE_TELEMETRY=true yarn create-cedar-app bazinga
50
+ CEDAR_VERBOSE_TELEMETRY=true yarn create-cedar-app bazinga
49
51
  ```
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './telemetry';
1
+ export * from './telemetry.js';
2
2
  //# 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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -1,22 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var src_exports = {};
17
- module.exports = __toCommonJS(src_exports);
18
- __reExport(src_exports, require("./telemetry"), module.exports);
19
- // Annotate the CommonJS export names for ESM import in node:
20
- 0 && (module.exports = {
21
- ...require("./telemetry")
22
- });
1
+ export * from "./telemetry.js";
@@ -1,5 +1,4 @@
1
- "use strict";
2
- var import_sendTelemetry = require("../sendTelemetry");
1
+ import { sendTelemetry } from "../sendTelemetry.js";
3
2
  (async function() {
4
- await (0, import_sendTelemetry.sendTelemetry)();
3
+ await sendTelemetry();
5
4
  })();
@@ -1 +1 @@
1
- {"version":3,"file":"sendTelemetry.d.ts","sourceRoot":"","sources":["../src/sendTelemetry.ts"],"names":[],"mappings":"AAaA,UAAU,qBAAqB;IAC7B,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;IACD,CAAC,EAAE;QACD,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,MAAM,EAAE;QACN,SAAS,CAAC,EAAE,KAAK,CAAA;QACjB,OAAO,EAAE,MAAM,EAAE,CAAA;QACjB,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,IAAI,EAAE;QACJ,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;QACpB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;CACF;AA+ED,eAAO,MAAM,YAAY,GACvB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,EAAE,GAAG,MAAM,EAAE,CAAC,WAyCjE,CAAA;AAyGD,eAAO,MAAM,aAAa,qBAmCzB,CAAA"}
1
+ {"version":3,"file":"sendTelemetry.d.ts","sourceRoot":"","sources":["../src/sendTelemetry.ts"],"names":[],"mappings":"AAcA,UAAU,qBAAqB;IAC7B,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;IACD,CAAC,EAAE;QACD,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,MAAM,EAAE;QACN,SAAS,CAAC,EAAE,KAAK,CAAA;QACjB,OAAO,EAAE,MAAM,EAAE,CAAA;QACjB,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,IAAI,EAAE;QACJ,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;QACpB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;CACF;AA8ED,eAAO,MAAM,YAAY,GACvB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,EAAE,GAAG,MAAM,EAAE,CAAC,WAyCjE,CAAA;AA2GD,eAAO,MAAM,aAAa,qBAsCzB,CAAA"}
@@ -1,47 +1,14 @@
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
- var sendTelemetry_exports = {};
30
- __export(sendTelemetry_exports, {
31
- sanitizeArgv: () => sanitizeArgv,
32
- sendTelemetry: () => sendTelemetry
33
- });
34
- module.exports = __toCommonJS(sendTelemetry_exports);
35
- var import_node_fs = __toESM(require("node:fs"));
36
- var import_os = __toESM(require("os"));
37
- var import_path = __toESM(require("path"));
38
- var import_fetch = require("@whatwg-node/fetch");
39
- var import_ci_info = __toESM(require("ci-info"));
40
- var import_envinfo = __toESM(require("envinfo"));
41
- var import_systeminformation = __toESM(require("systeminformation"));
42
- var import_uuid = require("uuid");
43
- var import_project_config = require("@cedarjs/project-config");
44
- var import_RWProject = require("@cedarjs/structure/dist/model/RWProject");
1
+ import fs from "node:fs";
2
+ import os from "os";
3
+ import path from "path";
4
+ import { fetch } from "@whatwg-node/fetch";
5
+ import ci from "ci-info";
6
+ import envinfo from "envinfo";
7
+ import system from "systeminformation";
8
+ import { v4 as uuidv4 } from "uuid";
9
+ import yargsParser from "yargs/yargs";
10
+ import { getRawConfig, getPaths } from "@cedarjs/project-config";
11
+ import { RWProject } from "@cedarjs/structure/dist/model/RWProject";
45
12
  const SENSITIVE_ARG_POSITIONS = {
46
13
  exec: {
47
14
  positions: [1],
@@ -67,7 +34,7 @@ const SENSITIVE_ARG_POSITIONS = {
67
34
  };
68
35
  const getInfo = async (presets = {}) => {
69
36
  const info = JSON.parse(
70
- await import_envinfo.default.run(
37
+ await envinfo.run(
71
38
  {
72
39
  System: ["OS", "Shell"],
73
40
  Binaries: ["Node", "Yarn", "npm"],
@@ -83,9 +50,9 @@ const getInfo = async (presets = {}) => {
83
50
  } else if (shell?.path.match("\\")) {
84
51
  info.System.Shell.name = info.System.Shell.path.split("\\").pop();
85
52
  }
86
- const cpu = await import_systeminformation.default.cpu();
87
- const mem = await import_systeminformation.default.mem();
88
- const experiments = Object.keys((0, import_project_config.getRawConfig)()["experimental"] || {});
53
+ const cpu = await system.cpu();
54
+ const mem = await system.mem();
55
+ const experiments = Object.keys(getRawConfig()["experimental"] || {});
89
56
  return {
90
57
  os: info.System?.OS?.split(" ")[0],
91
58
  osVersion: info.System?.OS?.split(" ")[1],
@@ -94,10 +61,8 @@ const getInfo = async (presets = {}) => {
94
61
  yarnVersion: info.Binaries?.Yarn?.version,
95
62
  npmVersion: info.Binaries?.npm?.version,
96
63
  vsCodeVersion: info.IDEs?.VSCode?.version,
97
- redwoodVersion: presets.redwoodVersion || info.npmPackages?.["@cedarjs/core"]?.installed,
64
+ cedarVersion: presets.cedarVersion || info.npmPackages?.["@cedarjs/core"]?.installed,
98
65
  system: `${cpu.physicalCores}.${Math.round(mem.total / 1073741824)}`,
99
- webBundler: "vite",
100
- // Hardcoded as this is now the only supported bundler
101
66
  experiments
102
67
  };
103
68
  };
@@ -133,9 +98,8 @@ const sanitizeArgv = (argv) => {
133
98
  };
134
99
  const buildPayload = async () => {
135
100
  let payload = {};
136
- let project;
137
101
  const processArgv = [...process.argv];
138
- if (import_os.default.type() === "Windows_NT") {
102
+ if (os.type() === "Windows_NT") {
139
103
  const argvIndex = processArgv.findIndex((arg) => arg === "--argv") + 1;
140
104
  let argvFormatted = argvIndex !== 0 ? processArgv[argvIndex] : null;
141
105
  if (argvFormatted) {
@@ -145,85 +109,86 @@ const buildPayload = async () => {
145
109
  processArgv[argvIndex] = argvFormatted;
146
110
  }
147
111
  }
148
- const argv = require("yargs/yargs")(processArgv.slice(2)).parse();
149
- const rootDir = argv.root;
150
- const command = argv.argv ? sanitizeArgv(JSON.parse(argv.argv)) : "";
112
+ const rawArgv = yargsParser(processArgv.slice(2)).parseSync();
113
+ const argvFlag = typeof rawArgv.argv === "string" ? rawArgv.argv : void 0;
114
+ const typeFlag = typeof rawArgv.type === "string" ? rawArgv.type : void 0;
115
+ const durationFlag = typeof rawArgv.duration === "string" ? rawArgv.duration : void 0;
116
+ const rwVersionFlag = typeof rawArgv.rwVersion === "string" ? rawArgv.rwVersion : void 0;
117
+ const errorFlag = typeof rawArgv.error === "string" ? rawArgv.error : void 0;
118
+ const command = argvFlag ? sanitizeArgv(JSON.parse(argvFlag)) : "";
151
119
  payload = {
152
- type: argv.type || "command",
120
+ type: typeFlag || "command",
153
121
  command,
154
- duration: argv.duration ? parseInt(argv.duration) : null,
155
- uid: uniqueId(rootDir) || null,
156
- ci: import_ci_info.default.isCI,
157
- redwoodCi: !!process.env.REDWOOD_CI,
122
+ duration: durationFlag ? parseInt(durationFlag) : null,
123
+ uid: uniqueId(),
124
+ ci: ci.isCI,
125
+ cedarCi: !!process.env.CEDAR_CI,
158
126
  NODE_ENV: process.env.NODE_ENV || null,
159
- ...await getInfo({ redwoodVersion: argv.rwVersion, command })
127
+ ...await getInfo({ cedarVersion: rwVersionFlag, command })
160
128
  };
161
- if (argv.error) {
129
+ if (errorFlag) {
162
130
  payload.type = "error";
163
- payload.error = argv.error.split("\n")[0].replace(/(\/[@\-\.\w]+)/g, "[path]");
164
- }
165
- if (rootDir) {
166
- project = new import_RWProject.RWProject({ projectRoot: rootDir });
167
- const routes = project.getRouter().routes;
168
- const prerenderedRoutes = routes.filter((route) => route.hasPrerender);
169
- payload = {
170
- ...payload,
171
- complexity: `${routes.length}.${prerenderedRoutes.length}.${project.services.length}.${project.cells.length}.${project.pages.length}`,
172
- sides: project.sides.join(",")
173
- };
131
+ payload.error = errorFlag.split("\n")[0].replace(/(\/[@\-\.\w]+)/g, "[path]");
174
132
  }
133
+ const project = new RWProject();
134
+ const routes = project.getRouter().routes;
135
+ const prerenderedRoutes = routes.filter((route) => route.hasPrerender);
136
+ payload = {
137
+ ...payload,
138
+ complexity: `${routes.length}.${prerenderedRoutes.length}.${project.services.length}.${project.cells.length}.${project.pages.length}`,
139
+ sides: project.sides.join(",")
140
+ };
175
141
  return payload;
176
142
  };
177
- const uniqueId = (rootDir) => {
178
- const telemetryCachePath = import_path.default.join(
179
- rootDir || "/tmp",
180
- ".redwood",
143
+ function uniqueId() {
144
+ const telemetryCachePath = path.join(
145
+ getPaths().generated.base,
181
146
  "telemetry.txt"
182
147
  );
183
148
  const now = Date.now();
184
149
  const expires = now - 24 * 60 * 60 * 1e3;
185
150
  let uuid;
186
- if (!import_node_fs.default.existsSync(telemetryCachePath) || import_node_fs.default.statSync(telemetryCachePath).mtimeMs < expires) {
187
- uuid = (0, import_uuid.v4)();
151
+ if (!fs.existsSync(telemetryCachePath) || fs.statSync(telemetryCachePath).mtimeMs < expires) {
152
+ uuid = uuidv4();
188
153
  try {
189
- if (!import_node_fs.default.existsSync(import_path.default.dirname(telemetryCachePath))) {
190
- import_node_fs.default.mkdirSync(import_path.default.dirname(telemetryCachePath), { recursive: true });
154
+ if (!fs.existsSync(path.dirname(telemetryCachePath))) {
155
+ fs.mkdirSync(path.dirname(telemetryCachePath), { recursive: true });
191
156
  }
192
- import_node_fs.default.writeFileSync(telemetryCachePath, uuid);
157
+ fs.writeFileSync(telemetryCachePath, uuid);
193
158
  } catch {
194
159
  console.error("\nCould not create telemetry.txt file\n");
195
160
  }
196
161
  } else {
197
- uuid = import_node_fs.default.readFileSync(telemetryCachePath).toString();
162
+ uuid = fs.readFileSync(telemetryCachePath).toString();
198
163
  }
199
164
  return uuid;
200
- };
165
+ }
201
166
  const sendTelemetry = async () => {
202
- const telemetryUrl = process.env.REDWOOD_REDIRECT_TELEMETRY || "https://telemetry.redwoodjs.com/api/v1/telemetry";
167
+ const telemetryUrl = process.env.CEDAR_REDIRECT_TELEMETRY || process.env.REDWOOD_REDIRECT_TELEMETRY || "https://telemetry.redwoodjs.com/api/v1/telemetry";
168
+ const verboseTelemetry = process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY;
203
169
  try {
204
170
  const payload = await buildPayload();
205
- if (process.env.REDWOOD_VERBOSE_TELEMETRY) {
206
- console.info("Redwood Telemetry Payload", payload);
171
+ if (verboseTelemetry) {
172
+ console.info("Cedar Telemetry Payload", payload);
207
173
  }
208
- const response = await (0, import_fetch.fetch)(telemetryUrl, {
174
+ const response = await fetch(telemetryUrl, {
209
175
  method: "post",
210
176
  body: JSON.stringify(payload),
211
177
  headers: { "Content-Type": "application/json" }
212
178
  });
213
- if (process.env.REDWOOD_VERBOSE_TELEMETRY) {
214
- console.info("Redwood Telemetry Response:", response);
179
+ if (verboseTelemetry) {
180
+ console.info("Cedar Telemetry Response:", response);
215
181
  }
216
- if (process.env.REDWOOD_VERBOSE_TELEMETRY && response.status !== 200) {
182
+ if (verboseTelemetry && response.status !== 200) {
217
183
  console.error("Error from telemetry insert:", await response.text());
218
184
  }
219
185
  } catch (e) {
220
- if (process.env.REDWOOD_VERBOSE_TELEMETRY) {
186
+ if (verboseTelemetry) {
221
187
  console.error("Uncaught error in telemetry:", e);
222
188
  }
223
189
  }
224
190
  };
225
- // Annotate the CommonJS export names for ESM import in node:
226
- 0 && (module.exports = {
191
+ export {
227
192
  sanitizeArgv,
228
193
  sendTelemetry
229
- });
194
+ };
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Quotes a single argument for a Windows shell command string.
3
+ *
4
+ * On Windows we spawn with `shell: true` and a command string, so every
5
+ * argument is re-parsed by the shell. Without quoting, anything containing a
6
+ * space is split: a project at `C:\Users\Ada Lovelace\app` makes node try to
7
+ * load `C:\Users\Ada`, and the process dies with MODULE_NOT_FOUND. The JSON
8
+ * payloads passed below need it too, since they contain double quotes.
9
+ *
10
+ * Follows the usual Windows argument-encoding rules: backslashes immediately
11
+ * before a double quote are doubled, the quote itself is escaped, and trailing
12
+ * backslashes are doubled so they can't escape the closing quote.
13
+ */
14
+ export declare function quoteForWindowsShell(arg: string): string;
1
15
  export declare const timedTelemetry: (argv: string[], options: Record<string, unknown>, func: (...args: any[]) => any) => Promise<any>;
2
16
  export declare const errorTelemetry: (argv: string[], error: any) => Promise<void>;
3
17
  export declare const telemetryMiddleware: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAkDA,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EAAE,EACd,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,iBAoB9B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,EAAE,EAAE,OAAO,GAAG,kBAM9D,CAAA;AAGD,eAAO,MAAM,mBAAmB,qBAM/B,CAAA"}
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,UAuB/C;AAsDD,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EAAE,EACd,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,iBAuB9B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,EAAE,EAAE,OAAO,GAAG,kBAS9D,CAAA;AAGD,eAAO,MAAM,mBAAmB,qBAS/B,CAAA"}
package/dist/telemetry.js CHANGED
@@ -1,71 +1,50 @@
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 });
1
+ import { spawn } from "child_process";
2
+ import os from "os";
3
+ import path from "path";
4
+ function quoteForWindowsShell(arg) {
5
+ let quoted = '"';
6
+ let backslashes = 0;
7
+ for (const char of arg) {
8
+ if (char === "\\") {
9
+ backslashes += 1;
10
+ continue;
11
+ }
12
+ if (char === '"') {
13
+ quoted += "\\".repeat(backslashes * 2 + 1) + '"';
14
+ } else {
15
+ quoted += "\\".repeat(backslashes) + char;
16
+ }
17
+ backslashes = 0;
17
18
  }
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
- var telemetry_exports = {};
30
- __export(telemetry_exports, {
31
- errorTelemetry: () => errorTelemetry,
32
- telemetryMiddleware: () => telemetryMiddleware,
33
- timedTelemetry: () => timedTelemetry
34
- });
35
- module.exports = __toCommonJS(telemetry_exports);
36
- var import_child_process = require("child_process");
37
- var import_os = __toESM(require("os"));
38
- var import_path = __toESM(require("path"));
39
- var import_project_config = require("@cedarjs/project-config");
19
+ return quoted + "\\".repeat(backslashes * 2) + '"';
20
+ }
40
21
  const spawnProcess = (...args) => {
41
- const isWindows = import_os.default.type() === "Windows_NT";
42
- const execPath = isWindows ? `"${process.execPath}"` : process.execPath;
22
+ const isWindows = os.type() === "Windows_NT";
43
23
  const spawnOptions = isWindows ? {
44
- stdio: process.env.REDWOOD_VERBOSE_TELEMETRY ? ["ignore", "inherit", "inherit"] : "ignore",
24
+ stdio: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? ["ignore", "inherit", "inherit"] : "ignore",
45
25
  // The following options run the process in the background without a console window, even though they don't look like they would.
46
26
  // See https://github.com/nodejs/node/issues/21825#issuecomment-503766781 for information
47
27
  detached: false,
48
28
  windowsHide: false,
49
29
  shell: true
50
30
  } : {
51
- stdio: process.env.REDWOOD_VERBOSE_TELEMETRY ? ["ignore", "inherit", "inherit"] : "ignore",
52
- detached: process.env.REDWOOD_VERBOSE_TELEMETRY ? false : true,
31
+ stdio: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? ["ignore", "inherit", "inherit"] : "ignore",
32
+ detached: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? false : true,
53
33
  windowsHide: true
54
34
  };
55
35
  const scriptArgs = [
56
- import_path.default.join(__dirname, "scripts", "invoke.js"),
57
- ...args,
58
- "--root",
59
- (0, import_project_config.getPaths)().base
36
+ path.join(import.meta.dirname, "scripts", "invoke.js"),
37
+ ...args
60
38
  ];
61
39
  if (isWindows) {
62
- (0, import_child_process.spawn)([execPath, ...scriptArgs].join(" "), [], spawnOptions).unref();
40
+ const command = [process.execPath, ...scriptArgs].map(quoteForWindowsShell).join(" ");
41
+ spawn(command, [], spawnOptions).unref();
63
42
  } else {
64
- (0, import_child_process.spawn)(process.execPath, scriptArgs, spawnOptions).unref();
43
+ spawn(process.execPath, scriptArgs, spawnOptions).unref();
65
44
  }
66
45
  };
67
46
  const timedTelemetry = async (argv, options, func) => {
68
- if (process.env.REDWOOD_DISABLE_TELEMETRY) {
47
+ if (process.env.CEDAR_DISABLE_TELEMETRY || process.env.REDWOOD_DISABLE_TELEMETRY) {
69
48
  return func.call(void 0);
70
49
  }
71
50
  const start = /* @__PURE__ */ new Date();
@@ -82,20 +61,20 @@ const timedTelemetry = async (argv, options, func) => {
82
61
  return result;
83
62
  };
84
63
  const errorTelemetry = async (argv, error) => {
85
- if (process.env.REDWOOD_DISABLE_TELEMETRY) {
64
+ if (process.env.CEDAR_DISABLE_TELEMETRY || process.env.REDWOOD_DISABLE_TELEMETRY) {
86
65
  return;
87
66
  }
88
67
  spawnProcess("--argv", JSON.stringify(argv), "--error", JSON.stringify(error));
89
68
  };
90
69
  const telemetryMiddleware = async () => {
91
- if (process.env.REDWOOD_DISABLE_TELEMETRY) {
70
+ if (process.env.CEDAR_DISABLE_TELEMETRY || process.env.REDWOOD_DISABLE_TELEMETRY) {
92
71
  return;
93
72
  }
94
73
  spawnProcess("--argv", JSON.stringify(process.argv));
95
74
  };
96
- // Annotate the CommonJS export names for ESM import in node:
97
- 0 && (module.exports = {
75
+ export {
98
76
  errorTelemetry,
77
+ quoteForWindowsShell,
99
78
  telemetryMiddleware,
100
79
  timedTelemetry
101
- });
80
+ };
package/package.json CHANGED
@@ -1,44 +1,47 @@
1
1
  {
2
2
  "name": "@cedarjs/telemetry",
3
- "version": "9.0.0-canary.1784+baa47810a",
3
+ "version": "9.0.0-canary.3124",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
7
7
  "directory": "packages/telemetry"
8
8
  },
9
9
  "license": "MIT",
10
+ "type": "module",
10
11
  "main": "./dist/index.js",
11
12
  "types": "./dist/index.d.ts",
12
13
  "files": [
13
14
  "dist"
14
15
  ],
15
16
  "scripts": {
16
- "build": "tsx build.mts && yarn build:types",
17
+ "build": "node build.mts",
17
18
  "build:pack": "yarn pack -o cedarjs-telemetry.tgz",
18
- "build:types": "tsc --build --verbose",
19
+ "build:types": "tsc --build --verbose ./tsconfig.build.json",
19
20
  "prepublishOnly": "NODE_ENV=production yarn build",
20
21
  "test": "vitest run",
21
22
  "test:watch": "vitest watch"
22
23
  },
23
24
  "dependencies": {
24
- "@cedarjs/project-config": "9.0.0-canary.1784",
25
- "@cedarjs/structure": "9.0.0-canary.1784",
25
+ "@cedarjs/project-config": "9.0.0-canary.3124",
26
+ "@cedarjs/structure": "9.0.0-canary.3124",
26
27
  "@whatwg-node/fetch": "0.10.13",
27
28
  "ci-info": "4.4.0",
28
29
  "envinfo": "7.21.0",
29
- "systeminformation": "5.30.7",
30
+ "systeminformation": "5.33.8",
30
31
  "uuid": "11.1.0",
31
- "yargs": "17.7.2"
32
+ "yargs": "17.7.3"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/envinfo": "7.8.4",
35
36
  "@types/yargs": "17.0.35",
36
- "tsx": "4.21.0",
37
37
  "typescript": "5.9.3",
38
- "vitest": "3.2.4"
38
+ "vitest": "4.1.11"
39
+ },
40
+ "engines": {
41
+ "node": ">=24"
39
42
  },
40
43
  "publishConfig": {
41
44
  "access": "public"
42
45
  },
43
- "gitHead": "baa47810a7defb73de27fdf513b815d679509b5e"
46
+ "gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
44
47
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Cedar
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.