create-tanstack-app 1.0.2 → 1.1.4

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/index.js +58 -19
  2. package/package.json +16 -13
package/index.js CHANGED
@@ -1,28 +1,67 @@
1
- const degit = require('degit');
2
- const path = require('path');
3
- const fs = require('fs');
1
+ #!/usr/bin/env node
4
2
 
5
- async function initApp() {
6
- const projectName = process.argv[2] || 'my-tanstack-app'; // default to 'my-tanstack-app' if no name is provided
7
- const dest = path.join(process.cwd(), projectName);
3
+ const { execSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const readline = require("readline");
8
7
 
9
- // Check if the destination already exists
10
- if (fs.existsSync(dest)) {
11
- console.log('Directory already exists. Please choose another name or delete the existing directory.');
12
- return;
13
- }
8
+ // Prompt the user for input
9
+ const rl = readline.createInterface({
10
+ input: process.stdin,
11
+ output: process.stdout,
12
+ });
14
13
 
15
- console.log(`Downloading Tanstack app template from GitHub...`);
16
-
17
- // Use degit to download the template
18
- const emitter = degit('SH20RAJ/tanstack-start', { cache: false, force: true });
19
- emitter.on('info', info => console.log(info));
14
+ async function getFolderName(defaultName) {
15
+ return new Promise((resolve) => {
16
+ rl.question(
17
+ `Enter the folder name (or use './' for the current directory) [${defaultName}]: `,
18
+ (input) => {
19
+ resolve(input || defaultName);
20
+ }
21
+ );
22
+ });
23
+ }
20
24
 
25
+ async function initApp() {
21
26
  try {
22
- await emitter.clone(dest);
23
- console.log(`Template successfully downloaded! Navigate to ${dest} and start working on your project.`);
27
+ // Get the folder name from the user or command-line argument
28
+ const argFolderName = process.argv[2];
29
+ const folderName = argFolderName || (await getFolderName("my-tanstack-app"));
30
+ rl.close();
31
+
32
+ const dest =
33
+ folderName === "./" ? process.cwd() : path.join(process.cwd(), folderName);
34
+
35
+ // Check if the destination already exists
36
+ if (fs.existsSync(dest)) {
37
+ console.log(
38
+ "āŒ Directory already exists. Please choose another name or delete the existing directory."
39
+ );
40
+ return;
41
+ }
42
+
43
+ console.log("šŸ“„ Cloning TanStack app template from GitHub...");
44
+
45
+ // Clone the repository
46
+ execSync(
47
+ `git clone https://github.com/SH20RAJ/tanstack-start.git ${dest}`,
48
+ {
49
+ stdio: "inherit",
50
+ }
51
+ );
52
+
53
+ console.log("āœ… Template successfully cloned!");
54
+
55
+ // Install dependencies
56
+ console.log("šŸ“¦ Installing dependencies...");
57
+ execSync("npm install", { cwd: dest, stdio: "inherit" });
58
+
59
+ console.log(`šŸŽ‰ Setup complete! Navigate to your project folder:\n`);
60
+ console.log(` cd ${folderName === "./" ? "." : folderName}`);
61
+ console.log(` npm run dev`);
62
+ console.log("\nšŸš€ Happy coding with TanStack!");
24
63
  } catch (error) {
25
- console.error('Error during template download:', error);
64
+ console.error("āŒ Error during setup:", error.message);
26
65
  }
27
66
  }
28
67
 
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
- "name": "create-tanstack-app",
3
- "version": "1.0.2",
4
- "main": "index.js",
5
- "bin": {
6
- "create-gi": "./index.js"
7
- },
8
- "author": "sh20raj",
9
- "license": "ISC",
10
- "description": "A CLI tool to create a Tanstack app",
11
- "dependencies": {
12
- "degit": "^2.8.4"
13
- }
14
- }
2
+ "name": "create-tanstack-app",
3
+ "version": "1.1.4",
4
+ "main": "index.js",
5
+ "bin": {
6
+ "create-tanstack-app": "./index.js"
7
+ },
8
+ "author": "Shaswat Raj",
9
+ "license": "ISC",
10
+ "description": "A CLI tool to create a Tanstack app",
11
+ "keywords": ["TanStack", "create-app", "React", "TypeScript"],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/SH20RAJ/create-tanstack-app.git"
15
+ },
16
+ "dependencies": {}
17
+ }