@cedarjs/telemetry 5.0.4-next.167 → 5.0.4-rc.3

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.js CHANGED
@@ -1 +1,22 @@
1
- export * from "./telemetry.js";
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 index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./telemetry.js"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./telemetry.js")
22
+ });
@@ -1,4 +1,5 @@
1
- import { sendTelemetry } from "../sendTelemetry.js";
1
+ "use strict";
2
+ var import_sendTelemetry = require("../sendTelemetry.js");
2
3
  (async function() {
3
- await sendTelemetry();
4
+ await (0, import_sendTelemetry.sendTelemetry)();
4
5
  })();
@@ -1 +1 @@
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,M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AC,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;AAiGD,eAAO,MAAM,aAAa,qBAsCzB,CAAA"}
@@ -1,14 +1,47 @@
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";
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");
12
45
  const SENSITIVE_ARG_POSITIONS = {
13
46
  exec: {
14
47
  positions: [1],
@@ -34,7 +67,7 @@ const SENSITIVE_ARG_POSITIONS = {
34
67
  };
35
68
  const getInfo = async (presets = {}) => {
36
69
  const info = JSON.parse(
37
- await envinfo.run(
70
+ await import_envinfo.default.run(
38
71
  {
39
72
  System: ["OS", "Shell"],
40
73
  Binaries: ["Node", "Yarn", "npm"],
@@ -50,9 +83,9 @@ const getInfo = async (presets = {}) => {
50
83
  } else if (shell?.path.match("\\")) {
51
84
  info.System.Shell.name = info.System.Shell.path.split("\\").pop();
52
85
  }
53
- const cpu = await system.cpu();
54
- const mem = await system.mem();
55
- const experiments = Object.keys(getRawConfig()["experimental"] || {});
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"] || {});
56
89
  return {
57
90
  os: info.System?.OS?.split(" ")[0],
58
91
  osVersion: info.System?.OS?.split(" ")[1],
@@ -101,7 +134,7 @@ const sanitizeArgv = (argv) => {
101
134
  const buildPayload = async () => {
102
135
  let payload = {};
103
136
  const processArgv = [...process.argv];
104
- if (os.type() === "Windows_NT") {
137
+ if (import_os.default.type() === "Windows_NT") {
105
138
  const argvIndex = processArgv.findIndex((arg) => arg === "--argv") + 1;
106
139
  let argvFormatted = argvIndex !== 0 ? processArgv[argvIndex] : null;
107
140
  if (argvFormatted) {
@@ -111,28 +144,23 @@ const buildPayload = async () => {
111
144
  processArgv[argvIndex] = argvFormatted;
112
145
  }
113
146
  }
114
- const rawArgv = yargsParser(processArgv.slice(2)).parseSync();
115
- const argvFlag = typeof rawArgv.argv === "string" ? rawArgv.argv : void 0;
116
- const typeFlag = typeof rawArgv.type === "string" ? rawArgv.type : void 0;
117
- const durationFlag = typeof rawArgv.duration === "string" ? rawArgv.duration : void 0;
118
- const rwVersionFlag = typeof rawArgv.rwVersion === "string" ? rawArgv.rwVersion : void 0;
119
- const errorFlag = typeof rawArgv.error === "string" ? rawArgv.error : void 0;
120
- const command = argvFlag ? sanitizeArgv(JSON.parse(argvFlag)) : "";
147
+ const argv = require("yargs/yargs")(processArgv.slice(2)).parse();
148
+ const command = argv.argv ? sanitizeArgv(JSON.parse(argv.argv)) : "";
121
149
  payload = {
122
- type: typeFlag || "command",
150
+ type: argv.type || "command",
123
151
  command,
124
- duration: durationFlag ? parseInt(durationFlag) : null,
152
+ duration: argv.duration ? parseInt(argv.duration) : null,
125
153
  uid: uniqueId(),
126
- ci: ci.isCI,
154
+ ci: import_ci_info.default.isCI,
127
155
  cedarCi: !!process.env.CEDAR_CI,
128
156
  NODE_ENV: process.env.NODE_ENV || null,
129
- ...await getInfo({ cedarVersion: rwVersionFlag, command })
157
+ ...await getInfo({ cedarVersion: argv.rwVersion, command })
130
158
  };
131
- if (errorFlag) {
159
+ if (argv.error) {
132
160
  payload.type = "error";
133
- payload.error = errorFlag.split("\n")[0].replace(/(\/[@\-\.\w]+)/g, "[path]");
161
+ payload.error = argv.error.split("\n")[0].replace(/(\/[@\-\.\w]+)/g, "[path]");
134
162
  }
135
- const project = new RWProject();
163
+ const project = new import_RWProject.RWProject();
136
164
  const routes = project.getRouter().routes;
137
165
  const prerenderedRoutes = routes.filter((route) => route.hasPrerender);
138
166
  payload = {
@@ -143,25 +171,25 @@ const buildPayload = async () => {
143
171
  return payload;
144
172
  };
145
173
  function uniqueId() {
146
- const telemetryCachePath = path.join(
147
- getPaths().generated.base,
174
+ const telemetryCachePath = import_path.default.join(
175
+ (0, import_project_config.getPaths)().generated.base,
148
176
  "telemetry.txt"
149
177
  );
150
178
  const now = Date.now();
151
179
  const expires = now - 24 * 60 * 60 * 1e3;
152
180
  let uuid;
153
- if (!fs.existsSync(telemetryCachePath) || fs.statSync(telemetryCachePath).mtimeMs < expires) {
154
- uuid = uuidv4();
181
+ if (!import_node_fs.default.existsSync(telemetryCachePath) || import_node_fs.default.statSync(telemetryCachePath).mtimeMs < expires) {
182
+ uuid = (0, import_uuid.v4)();
155
183
  try {
156
- if (!fs.existsSync(path.dirname(telemetryCachePath))) {
157
- fs.mkdirSync(path.dirname(telemetryCachePath), { recursive: true });
184
+ if (!import_node_fs.default.existsSync(import_path.default.dirname(telemetryCachePath))) {
185
+ import_node_fs.default.mkdirSync(import_path.default.dirname(telemetryCachePath), { recursive: true });
158
186
  }
159
- fs.writeFileSync(telemetryCachePath, uuid);
187
+ import_node_fs.default.writeFileSync(telemetryCachePath, uuid);
160
188
  } catch {
161
189
  console.error("\nCould not create telemetry.txt file\n");
162
190
  }
163
191
  } else {
164
- uuid = fs.readFileSync(telemetryCachePath).toString();
192
+ uuid = import_node_fs.default.readFileSync(telemetryCachePath).toString();
165
193
  }
166
194
  return uuid;
167
195
  }
@@ -173,7 +201,7 @@ const sendTelemetry = async () => {
173
201
  if (verboseTelemetry) {
174
202
  console.info("Cedar Telemetry Payload", payload);
175
203
  }
176
- const response = await fetch(telemetryUrl, {
204
+ const response = await (0, import_fetch.fetch)(telemetryUrl, {
177
205
  method: "post",
178
206
  body: JSON.stringify(payload),
179
207
  headers: { "Content-Type": "application/json" }
@@ -190,7 +218,8 @@ const sendTelemetry = async () => {
190
218
  }
191
219
  }
192
220
  };
193
- export {
221
+ // Annotate the CommonJS export names for ESM import in node:
222
+ 0 && (module.exports = {
194
223
  sanitizeArgv,
195
224
  sendTelemetry
196
- };
225
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAsDA,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"}
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAmDA,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,8 +1,43 @@
1
- import { spawn } from "child_process";
2
- import os from "os";
3
- import path from "path";
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 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"));
4
39
  const spawnProcess = (...args) => {
5
- const isWindows = os.type() === "Windows_NT";
40
+ const isWindows = import_os.default.type() === "Windows_NT";
6
41
  const execPath = isWindows ? `"${process.execPath}"` : process.execPath;
7
42
  const spawnOptions = isWindows ? {
8
43
  stdio: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? ["ignore", "inherit", "inherit"] : "ignore",
@@ -16,14 +51,11 @@ const spawnProcess = (...args) => {
16
51
  detached: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? false : true,
17
52
  windowsHide: true
18
53
  };
19
- const scriptArgs = [
20
- path.join(import.meta.dirname, "scripts", "invoke.js"),
21
- ...args
22
- ];
54
+ const scriptArgs = [import_path.default.join(__dirname, "scripts", "invoke.js"), ...args];
23
55
  if (isWindows) {
24
- spawn([execPath, ...scriptArgs].join(" "), [], spawnOptions).unref();
56
+ (0, import_child_process.spawn)([execPath, ...scriptArgs].join(" "), [], spawnOptions).unref();
25
57
  } else {
26
- spawn(process.execPath, scriptArgs, spawnOptions).unref();
58
+ (0, import_child_process.spawn)(process.execPath, scriptArgs, spawnOptions).unref();
27
59
  }
28
60
  };
29
61
  const timedTelemetry = async (argv, options, func) => {
@@ -55,8 +87,9 @@ const telemetryMiddleware = async () => {
55
87
  }
56
88
  spawnProcess("--argv", JSON.stringify(process.argv));
57
89
  };
58
- export {
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
59
92
  errorTelemetry,
60
93
  telemetryMiddleware,
61
94
  timedTelemetry
62
- };
95
+ });
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
2
  "name": "@cedarjs/telemetry",
3
- "version": "5.0.4-next.167",
3
+ "version": "5.0.4-rc.3",
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
+ "type": "commonjs",
11
11
  "main": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
14
14
  "dist"
15
15
  ],
16
16
  "scripts": {
17
- "build": "node build.mts",
17
+ "build": "node build.mts && yarn build:types",
18
18
  "build:pack": "yarn pack -o cedarjs-telemetry.tgz",
19
- "build:types": "tsc --build --verbose ./tsconfig.build.json",
19
+ "build:types": "tsc --build --verbose",
20
20
  "prepublishOnly": "NODE_ENV=production yarn build",
21
21
  "test": "vitest run",
22
22
  "test:watch": "vitest watch"
23
23
  },
24
24
  "dependencies": {
25
- "@cedarjs/project-config": "5.0.4-next.167",
26
- "@cedarjs/structure": "5.0.4-next.167",
25
+ "@cedarjs/project-config": "5.0.4-rc.3",
26
+ "@cedarjs/structure": "5.0.4-rc.3",
27
27
  "@whatwg-node/fetch": "0.10.13",
28
28
  "ci-info": "4.4.0",
29
29
  "envinfo": "7.21.0",
@@ -35,7 +35,7 @@
35
35
  "@types/envinfo": "7.8.4",
36
36
  "@types/yargs": "17.0.35",
37
37
  "typescript": "5.9.3",
38
- "vitest": "4.1.10"
38
+ "vitest": "3.2.6"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=24"