create-newt-app 0.31.6 → 0.31.8

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
@@ -9,12 +9,9 @@ import { execa } from "execa";
9
9
  import ejs from "ejs";
10
10
  import { existsSync, promises } from "fs";
11
11
  import path from "path";
12
- import { homedir } from "node:os";
13
- import { promises as promises$1 } from "node:fs";
14
12
  import https from "node:https";
15
- import path$1 from "node:path";
16
13
  //#region package.json
17
- var version = "0.31.6";
14
+ var version = "0.31.8";
18
15
  var engines = { "node": ">=24.0.0" };
19
16
  //#endregion
20
17
  //#region src/templates/root/index.ts
@@ -12609,8 +12606,7 @@ async function initGit(cwd) {
12609
12606
  //#endregion
12610
12607
  //#region src/telemetry.ts
12611
12608
  const ENDPOINT = "https://newt-telemetry.newt-app.workers.dev";
12612
- const SEND_TIMEOUT_MS = 2e3;
12613
- const UNREACHABLE_BACKOFF_MS = 2592e6;
12609
+ const SEND_TIMEOUT_MS = 1e3;
12614
12610
  const CI_PROVIDERS = [
12615
12611
  ["GITHUB_ACTIONS", "github-actions"],
12616
12612
  ["GITLAB_CI", "gitlab-ci"],
@@ -12637,24 +12633,6 @@ function isOptedOut(env = process.env) {
12637
12633
  function isEnabled(env = process.env) {
12638
12634
  return Boolean(ENDPOINT) && !isOptedOut(env);
12639
12635
  }
12640
- function statePath() {
12641
- const base = process.env.XDG_STATE_HOME ?? path$1.join(homedir(), ".local", "state");
12642
- return path$1.join(base, "create-newt-app", "telemetry.json");
12643
- }
12644
- async function readState() {
12645
- try {
12646
- return JSON.parse(await promises$1.readFile(statePath(), "utf8"));
12647
- } catch {
12648
- return {};
12649
- }
12650
- }
12651
- async function writeState(next) {
12652
- try {
12653
- const file = statePath();
12654
- await promises$1.mkdir(path$1.dirname(file), { recursive: true });
12655
- await promises$1.writeFile(file, JSON.stringify(next), "utf8");
12656
- } catch {}
12657
- }
12658
12636
  function nodeMajor(version = process.version) {
12659
12637
  const match = /^v?(\d+)/.exec(version);
12660
12638
  return match ? `v${match[1]}` : "other";
@@ -12691,49 +12669,22 @@ function post(body) {
12691
12669
  });
12692
12670
  req.on("response", (res) => {
12693
12671
  res.resume();
12694
- const status = res.statusCode ?? 0;
12695
- res.on("end", () => resolve(status >= 200 && status < 300));
12672
+ res.on("end", () => resolve());
12696
12673
  });
12697
12674
  req.on("timeout", () => {
12698
12675
  req.destroy();
12699
- resolve(false);
12676
+ resolve();
12700
12677
  });
12701
- req.on("error", () => resolve(false));
12678
+ req.on("error", () => resolve());
12702
12679
  req.end(body);
12703
12680
  } catch {
12704
- resolve(false);
12681
+ resolve();
12705
12682
  }
12706
12683
  });
12707
12684
  }
12708
- const NOTICE = [
12709
- "create-newt-app sends one anonymous event per scaffold: the options you chose,",
12710
- "the CLI and Node major versions, your platform, whether prompts or flags were",
12711
- "used, and whether this is CI. No project name, no paths, no file contents, and",
12712
- "no identifier of any kind.",
12713
- "Opt out with DO_NOT_TRACK=1 or NEWT_TELEMETRY_DISABLED=1."
12714
- ].join("\n");
12715
12685
  async function reportRun(report) {
12716
12686
  if (!isEnabled()) return;
12717
- const state = await readState();
12718
- if (state.unreachableUntil && state.unreachableUntil > Date.now()) return;
12719
- if (!state.notifiedAt) {
12720
- console.log();
12721
- console.log(NOTICE);
12722
- console.log();
12723
- await writeState({
12724
- ...state,
12725
- notifiedAt: Date.now()
12726
- });
12727
- }
12728
- if (!await post(JSON.stringify(buildPayload(report)))) await writeState({
12729
- ...state,
12730
- notifiedAt: state.notifiedAt ?? Date.now(),
12731
- unreachableUntil: Date.now() + UNREACHABLE_BACKOFF_MS
12732
- });
12733
- else if (state.unreachableUntil) await writeState({
12734
- ...state,
12735
- unreachableUntil: void 0
12736
- });
12687
+ await post(JSON.stringify(buildPayload(report)));
12737
12688
  }
12738
12689
  //#endregion
12739
12690
  //#region src/index.ts