create-tldraw 5.4.0-canary.042da660fa66 → 5.4.0-canary.059d049864ed

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-cjs/main.cjs CHANGED
@@ -4391,9 +4391,7 @@ async function uncancel(promise) {
4391
4391
  function getPackageManager() {
4392
4392
  const userAgent = process.env.npm_config_user_agent;
4393
4393
  if (!userAgent) return "npm";
4394
- const pkgSpec = userAgent.split(" ")[0];
4395
- const pkgSpecArr = pkgSpec.split("/");
4396
- const manager = pkgSpecArr[0];
4394
+ const manager = userAgent.split(" ")[0].split("/")[0];
4397
4395
  if (manager === "pnpm") return "pnpm";
4398
4396
  if (manager === "yarn") return "yarn";
4399
4397
  return "npm";
@@ -4459,48 +4457,45 @@ main().catch((err) => {
4459
4457
  import_node_process4.default.exit(1);
4460
4458
  });
4461
4459
  async function templatePicker(argOption, noTelemetry) {
4460
+ let template;
4462
4461
  if (argOption) {
4463
- const template2 = TEMPLATES.find((t) => formatTemplateId(t) === argOption.toLowerCase().trim());
4464
- if (!template2) {
4462
+ const found = TEMPLATES.find((t) => formatTemplateId(t) === argOption.toLowerCase().trim());
4463
+ if (!found) {
4465
4464
  Fe(`Template ${argOption} not found`);
4466
4465
  import_node_process4.default.exit(1);
4467
4466
  }
4468
- trackStarterKitChoice(template2.name, noTelemetry);
4469
- return template2;
4470
- }
4471
- const template = await uncancel(
4472
- groupSelect({
4473
- message: "Select a tldraw starter kit:",
4474
- options: TEMPLATES.map(
4475
- (template2) => ({
4476
- label: template2.name,
4477
- hint: template2.description,
4478
- value: template2
4479
- })
4480
- )
4481
- })
4482
- );
4467
+ template = found;
4468
+ } else {
4469
+ template = await uncancel(
4470
+ groupSelect({
4471
+ message: "Select a tldraw starter kit:",
4472
+ options: TEMPLATES.map(
4473
+ (template2) => ({
4474
+ label: template2.name,
4475
+ hint: template2.description,
4476
+ value: template2
4477
+ })
4478
+ )
4479
+ })
4480
+ );
4481
+ }
4483
4482
  trackStarterKitChoice(template.name, noTelemetry);
4484
4483
  return template;
4485
4484
  }
4485
+ var TELEMETRY_URLS = [
4486
+ "https://dashboard.tldraw.pro/api/starter-kit-choice",
4487
+ "https://teamldraw.com/api/starter-kit-choice"
4488
+ ];
4486
4489
  function trackStarterKitChoice(templateId, noTelemetry) {
4487
4490
  if (noTelemetry) return;
4488
- fetch("https://dashboard.tldraw.pro/api/starter-kit-choice", {
4489
- method: "POST",
4490
- headers: {
4491
- "Content-Type": "application/json"
4492
- },
4493
- body: JSON.stringify({ id: templateId })
4494
- }).catch(() => {
4495
- });
4496
- fetch("https://teamldraw.com/api/starter-kit-choice", {
4497
- method: "POST",
4498
- headers: {
4499
- "Content-Type": "application/json"
4500
- },
4501
- body: JSON.stringify({ id: templateId })
4502
- }).catch(() => {
4503
- });
4491
+ for (const url of TELEMETRY_URLS) {
4492
+ fetch(url, {
4493
+ method: "POST",
4494
+ headers: { "Content-Type": "application/json" },
4495
+ body: JSON.stringify({ id: templateId })
4496
+ }).catch(() => {
4497
+ });
4498
+ }
4504
4499
  }
4505
4500
  async function namePicker(argOption) {
4506
4501
  if (argOption) {
@@ -4575,66 +4570,46 @@ function getHelp() {
4575
4570
  { flags: "-t, --template NAME", description: "Use a specific template." },
4576
4571
  { flags: "--no-telemetry", description: "Disable anonymous usage tracking." }
4577
4572
  ];
4573
+ const templates = TEMPLATES.map((t) => ({
4574
+ name: formatTemplateId(t),
4575
+ description: t.shortDescription ?? t.description
4576
+ }));
4578
4577
  const GAP_SIZE = 2;
4579
4578
  const optionPrefix = " ";
4580
4579
  const templatePrefix = " \u2022 ";
4581
- const idealIndentSize = Math.max(
4582
- ...options.map((o2) => o2.flags.length),
4583
- ...TEMPLATES.map((t) => formatTemplateId(t).length)
4584
- ) + GAP_SIZE + templatePrefix.length;
4585
- const isNarrow = import_node_process4.default.stdout.columns < idealIndentSize + 50;
4586
- const lines = [
4580
+ const idealIndentSize = Math.max(...options.map((o2) => o2.flags.length), ...templates.map((t) => t.name.length)) + GAP_SIZE + templatePrefix.length;
4581
+ const columns = import_node_process4.default.stdout.columns;
4582
+ const isNarrow = columns < idealIndentSize + 50;
4583
+ function formatRows(prefix, rows) {
4584
+ if (isNarrow) {
4585
+ const indent2 = " ".repeat(prefix.length + GAP_SIZE);
4586
+ return rows.flatMap((row) => [
4587
+ `${prefix}${row.name}`,
4588
+ wrapAnsi(`${indent2}${row.description}`, columns, { indent: indent2 })
4589
+ ]);
4590
+ }
4591
+ const indent = " ".repeat(idealIndentSize);
4592
+ return rows.map((row) => {
4593
+ const start = `${prefix}${row.name}`.padEnd(idealIndentSize, " ");
4594
+ return wrapAnsi(`${start}${row.description}`, columns, { indent });
4595
+ });
4596
+ }
4597
+ return [
4587
4598
  import_picocolors4.default.bold("Usage: create-tldraw [OPTION]... [DIRECTORY]"),
4588
4599
  "",
4589
4600
  "Create a new tldraw project from a starter kit.",
4590
4601
  "With no arguments, you'll be guided through an interactive setup.",
4591
4602
  "",
4592
- import_picocolors4.default.bold("Options:")
4593
- ];
4594
- if (isNarrow) {
4595
- const indent = " ".repeat(optionPrefix.length + GAP_SIZE);
4596
- for (const option of options) {
4597
- lines.push(`${optionPrefix}${option.flags}`);
4598
- lines.push(wrapAnsi(`${indent}${option.description}`, import_node_process4.default.stdout.columns, { indent }));
4599
- }
4600
- } else {
4601
- const indent = " ".repeat(idealIndentSize);
4602
- for (const option of options) {
4603
- const start = `${optionPrefix}${option.flags}`.padEnd(idealIndentSize, " ");
4604
- lines.push(wrapAnsi(`${start}${option.description}`, import_node_process4.default.stdout.columns, { indent }));
4605
- }
4606
- }
4607
- lines.push("");
4608
- lines.push(import_picocolors4.default.bold("Available starter kits:"));
4609
- if (isNarrow) {
4610
- const indent = " ".repeat(templatePrefix.length + GAP_SIZE);
4611
- for (const template of TEMPLATES) {
4612
- lines.push(`${templatePrefix}${formatTemplateId(template)}`);
4613
- lines.push(
4614
- wrapAnsi(
4615
- `${indent}${template.shortDescription ?? template.description}`,
4616
- import_node_process4.default.stdout.columns,
4617
- { indent }
4618
- )
4619
- );
4620
- }
4621
- } else {
4622
- const indent = " ".repeat(idealIndentSize);
4623
- for (const template of TEMPLATES) {
4624
- const start = `${templatePrefix}${formatTemplateId(template)}`.padEnd(idealIndentSize, " ");
4625
- lines.push(
4626
- wrapAnsi(
4627
- `${start}${template.shortDescription ?? template.description}`,
4628
- import_node_process4.default.stdout.columns,
4629
- {
4630
- indent
4631
- }
4632
- )
4633
- );
4634
- }
4635
- }
4636
- lines.push("");
4637
- return lines.join("\n");
4603
+ import_picocolors4.default.bold("Options:"),
4604
+ ...formatRows(
4605
+ optionPrefix,
4606
+ options.map((o2) => ({ name: o2.flags, description: o2.description }))
4607
+ ),
4608
+ "",
4609
+ import_picocolors4.default.bold("Available starter kits:"),
4610
+ ...formatRows(templatePrefix, templates),
4611
+ ""
4612
+ ].join("\n");
4638
4613
  }
4639
4614
  /*!
4640
4615
  * This is a fork of wrap-ansi, adding the ability to customize the string inserted at the start of each wrapped line.