tthr 0.0.7 → 0.0.9

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.
Files changed (2) hide show
  1. package/dist/index.js +79 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ import ora from "ora";
60
60
  import fs2 from "fs-extra";
61
61
  import path2 from "path";
62
62
  var isDev = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
63
- var API_URL = isDev ? "http://localhost:3001/api/v1" : "https://tthr.io/api/v1";
63
+ var API_URL = isDev ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
64
64
  async function deployCommand(options) {
65
65
  const credentials = await requireAuth();
66
66
  const configPath = path2.resolve(process.cwd(), "tether.config.ts");
@@ -116,7 +116,7 @@ async function deploySchemaToServer(projectId, token, dryRun) {
116
116
  }
117
117
  const sql = generateSchemaSQL(tables);
118
118
  spinner.text = "Deploying schema...";
119
- const response = await fetch(`${API_URL}/${projectId}/deploy/schema`, {
119
+ const response = await fetch(`${API_URL}/projects/${projectId}/deploy/schema`, {
120
120
  method: "POST",
121
121
  headers: {
122
122
  "Content-Type": "application/json",
@@ -173,7 +173,7 @@ async function deployFunctionsToServer(projectId, token, dryRun) {
173
173
  return;
174
174
  }
175
175
  spinner.text = "Deploying functions...";
176
- const response = await fetch(`${API_URL}/${projectId}/deploy/functions`, {
176
+ const response = await fetch(`${API_URL}/projects/${projectId}/deploy/functions`, {
177
177
  method: "POST",
178
178
  headers: {
179
179
  "Content-Type": "application/json",
@@ -355,7 +355,7 @@ function parseFunctions(moduleName, source) {
355
355
 
356
356
  // src/commands/init.ts
357
357
  var isDev2 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
358
- var API_URL2 = isDev2 ? "http://localhost:3001/api/v1" : "https://tthr.io/api/v1";
358
+ var API_URL2 = isDev2 ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
359
359
  async function getLatestVersion(packageName) {
360
360
  try {
361
361
  const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
@@ -368,6 +368,14 @@ async function getLatestVersion(packageName) {
368
368
  return "latest";
369
369
  }
370
370
  }
371
+ function isPackageManagerInstalled(pm) {
372
+ try {
373
+ execSync(`${pm} --version`, { stdio: "pipe" });
374
+ return true;
375
+ } catch {
376
+ return false;
377
+ }
378
+ }
371
379
  async function initCommand(name, options) {
372
380
  const credentials = await requireAuth();
373
381
  console.log(chalk3.bold("\n\u26A1 Create a new Tether project\n"));
@@ -385,6 +393,26 @@ async function initCommand(name, options) {
385
393
  process.exit(1);
386
394
  }
387
395
  }
396
+ const pmResponse = await prompts({
397
+ type: "select",
398
+ name: "packageManager",
399
+ message: "Select a package manager:",
400
+ choices: [
401
+ { title: "npm", value: "npm", description: "Node Package Manager (default)" },
402
+ { title: "pnpm", value: "pnpm", description: "Fast, disk space efficient package manager" },
403
+ { title: "yarn", value: "yarn", description: "Fast, reliable, and secure dependency management" },
404
+ { title: "bun", value: "bun", description: "All-in-one JavaScript runtime and toolkit" }
405
+ ],
406
+ initial: 0
407
+ });
408
+ const packageManager = pmResponse.packageManager || "npm";
409
+ if (!isPackageManagerInstalled(packageManager)) {
410
+ console.log(chalk3.red(`
411
+ ${packageManager} is not installed on your system.`));
412
+ console.log(chalk3.dim(`Please install ${packageManager} and try again.
413
+ `));
414
+ process.exit(1);
415
+ }
388
416
  let template = options.template;
389
417
  if (options.template === "vue") {
390
418
  const response = await prompts({
@@ -436,11 +464,11 @@ async function initCommand(name, options) {
436
464
  apiKey = data.apiKey;
437
465
  spinner.text = `Scaffolding ${template} project...`;
438
466
  if (template === "nuxt") {
439
- await scaffoldNuxtProject(projectName, projectPath, spinner);
467
+ await scaffoldNuxtProject(projectName, projectPath, spinner, packageManager);
440
468
  } else if (template === "next") {
441
- await scaffoldNextProject(projectName, projectPath, spinner);
469
+ await scaffoldNextProject(projectName, projectPath, spinner, packageManager);
442
470
  } else if (template === "sveltekit") {
443
- await scaffoldSvelteKitProject(projectName, projectPath, spinner);
471
+ await scaffoldSvelteKitProject(projectName, projectPath, spinner, packageManager);
444
472
  } else {
445
473
  await scaffoldVanillaProject(projectName, projectPath, spinner);
446
474
  }
@@ -449,7 +477,7 @@ async function initCommand(name, options) {
449
477
  spinner.text = "Configuring framework integration...";
450
478
  await configureFramework(projectPath, template);
451
479
  spinner.text = "Installing Tether packages...";
452
- await installTetherPackages(projectPath, template);
480
+ await installTetherPackages(projectPath, template, packageManager);
453
481
  spinner.text = "Creating demo page...";
454
482
  await createDemoPage(projectPath, template);
455
483
  spinner.succeed("Project created successfully!");
@@ -465,9 +493,9 @@ async function initCommand(name, options) {
465
493
  console.log("Next steps:\n");
466
494
  console.log(chalk3.cyan(` cd ${projectName}`));
467
495
  if (template === "vanilla") {
468
- console.log(chalk3.cyan(" npm install"));
496
+ console.log(chalk3.cyan(` ${packageManager} install`));
469
497
  }
470
- console.log(chalk3.cyan(" npm run dev"));
498
+ console.log(chalk3.cyan(` ${packageManager} run dev`));
471
499
  console.log("\n" + chalk3.dim("For more information, visit https://tthr.io/docs\n"));
472
500
  } catch (error) {
473
501
  spinner.fail("Failed to create project");
@@ -475,12 +503,25 @@ async function initCommand(name, options) {
475
503
  process.exit(1);
476
504
  }
477
505
  }
478
- async function scaffoldNuxtProject(projectName, projectPath, spinner) {
506
+ function getPackageRunnerCommand(pm) {
507
+ switch (pm) {
508
+ case "pnpm":
509
+ return "pnpm dlx";
510
+ case "yarn":
511
+ return "yarn dlx";
512
+ case "bun":
513
+ return "bunx";
514
+ default:
515
+ return "npx";
516
+ }
517
+ }
518
+ async function scaffoldNuxtProject(projectName, projectPath, spinner, packageManager) {
479
519
  const parentDir = path3.dirname(projectPath);
520
+ const runner = getPackageRunnerCommand(packageManager);
480
521
  spinner.stop();
481
522
  console.log(chalk3.dim("\nRunning nuxi init...\n"));
482
523
  try {
483
- execSync(`npx nuxi@latest init ${projectName} --packageManager npm --gitInit false`, {
524
+ execSync(`${runner} nuxi@latest init ${projectName} --packageManager ${packageManager} --gitInit false`, {
484
525
  cwd: parentDir,
485
526
  stdio: "inherit"
486
527
  });
@@ -493,15 +534,17 @@ async function scaffoldNuxtProject(projectName, projectPath, spinner) {
493
534
  if (error instanceof Error && error.message.includes("package.json missing")) {
494
535
  throw error;
495
536
  }
496
- throw new Error("Failed to create Nuxt project. Make sure you have npx installed.");
537
+ throw new Error(`Failed to create Nuxt project. Make sure you have ${packageManager} installed.`);
497
538
  }
498
539
  }
499
- async function scaffoldNextProject(projectName, projectPath, spinner) {
540
+ async function scaffoldNextProject(projectName, projectPath, spinner, packageManager) {
500
541
  const parentDir = path3.dirname(projectPath);
542
+ const runner = getPackageRunnerCommand(packageManager);
543
+ const pmFlag = packageManager === "npm" ? "--use-npm" : packageManager === "pnpm" ? "--use-pnpm" : packageManager === "yarn" ? "--use-yarn" : "--use-bun";
501
544
  spinner.stop();
502
545
  console.log(chalk3.dim("\nRunning create-next-app...\n"));
503
546
  try {
504
- execSync(`npx create-next-app@latest ${projectName} --typescript --eslint --tailwind --src-dir --app --import-alias "@/*" --use-npm`, {
547
+ execSync(`${runner} create-next-app@latest ${projectName} --typescript --eslint --tailwind --src-dir --app --import-alias "@/*" ${pmFlag}`, {
505
548
  cwd: parentDir,
506
549
  stdio: "inherit"
507
550
  });
@@ -514,15 +557,16 @@ async function scaffoldNextProject(projectName, projectPath, spinner) {
514
557
  if (error instanceof Error && error.message.includes("package.json missing")) {
515
558
  throw error;
516
559
  }
517
- throw new Error("Failed to create Next.js project. Make sure you have npx installed.");
560
+ throw new Error(`Failed to create Next.js project. Make sure you have ${packageManager} installed.`);
518
561
  }
519
562
  }
520
- async function scaffoldSvelteKitProject(projectName, projectPath, spinner) {
563
+ async function scaffoldSvelteKitProject(projectName, projectPath, spinner, packageManager) {
521
564
  const parentDir = path3.dirname(projectPath);
565
+ const runner = getPackageRunnerCommand(packageManager);
522
566
  spinner.stop();
523
567
  console.log(chalk3.dim("\nRunning sv create...\n"));
524
568
  try {
525
- execSync(`npx sv create ${projectName} --template minimal --types ts --no-add-ons --no-install`, {
569
+ execSync(`${runner} sv create ${projectName} --template minimal --types ts --no-add-ons --no-install`, {
526
570
  cwd: parentDir,
527
571
  stdio: "inherit"
528
572
  });
@@ -530,12 +574,17 @@ async function scaffoldSvelteKitProject(projectName, projectPath, spinner) {
530
574
  throw new Error("SvelteKit project was not created successfully - package.json missing");
531
575
  }
532
576
  spinner.start();
577
+ spinner.text = "Installing dependencies...";
578
+ execSync(`${packageManager} install`, {
579
+ cwd: projectPath,
580
+ stdio: "pipe"
581
+ });
533
582
  } catch (error) {
534
583
  spinner.start();
535
584
  if (error instanceof Error && error.message.includes("package.json missing")) {
536
585
  throw error;
537
586
  }
538
- throw new Error("Failed to create SvelteKit project. Make sure you have npx installed.");
587
+ throw new Error(`Failed to create SvelteKit project. Make sure you have ${packageManager} installed.`);
539
588
  }
540
589
  }
541
590
  async function scaffoldVanillaProject(projectName, projectPath, spinner) {
@@ -820,7 +869,7 @@ export const remove = mutation({
820
869
  );
821
870
  const envContent = `# Tether Configuration
822
871
  TETHER_PROJECT_ID=${projectId}
823
- TETHER_URL=${isDev2 ? "http://localhost:3001" : "https://tthr.io"}
872
+ TETHER_URL=${isDev2 ? "http://localhost:3001" : "https://tether-api.strands.gg"}
824
873
  TETHER_API_KEY=${apiKey}
825
874
  `;
826
875
  const envPath = path3.join(projectPath, ".env");
@@ -980,7 +1029,11 @@ PUBLIC_TETHER_URL=\${TETHER_URL}
980
1029
  }
981
1030
  }
982
1031
  }
983
- async function installTetherPackages(projectPath, template) {
1032
+ function getInstallCommand(pm, isDev4 = false) {
1033
+ const devFlag = isDev4 ? pm === "npm" ? "-D" : pm === "yarn" ? "-D" : pm === "pnpm" ? "-D" : "-d" : "";
1034
+ return `${pm} ${pm === "npm" ? "install" : "add"} ${devFlag}`.trim();
1035
+ }
1036
+ async function installTetherPackages(projectPath, template, packageManager) {
984
1037
  const [
985
1038
  tthrClientVersion,
986
1039
  tthrSchemaVersion,
@@ -1011,11 +1064,13 @@ async function installTetherPackages(projectPath, template) {
1011
1064
  packages.push(`@tthr/svelte@${tthrSvelteVersion}`);
1012
1065
  }
1013
1066
  try {
1014
- execSync(`npm install ${packages.join(" ")}`, {
1067
+ const installCmd = getInstallCommand(packageManager);
1068
+ const devInstallCmd = getInstallCommand(packageManager, true);
1069
+ execSync(`${installCmd} ${packages.join(" ")}`, {
1015
1070
  cwd: projectPath,
1016
1071
  stdio: "pipe"
1017
1072
  });
1018
- execSync(`npm install -D ${devPackages.join(" ")}`, {
1073
+ execSync(`${devInstallCmd} ${devPackages.join(" ")}`, {
1019
1074
  cwd: projectPath,
1020
1075
  stdio: "pipe"
1021
1076
  });
@@ -1696,7 +1751,7 @@ import ora6 from "ora";
1696
1751
  import os from "os";
1697
1752
  var isDev3 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
1698
1753
  var API_URL3 = isDev3 ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
1699
- var AUTH_URL = isDev3 ? "http://localhost:3000/cli" : "https://tether.strands.gg/cli";
1754
+ var AUTH_URL = isDev3 ? "http://localhost:3000/cli" : "https://tthr.io/cli";
1700
1755
  async function loginCommand() {
1701
1756
  console.log(chalk7.bold("\u26A1 Login to Tether\n"));
1702
1757
  const existing = await getCredentials();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tthr",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Tether CLI - project scaffolding, migrations, and deployment",
5
5
  "type": "module",
6
6
  "bin": {