create-tanstack-app 1.0.1 → 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 (3) hide show
  1. package/index.js +64 -6
  2. package/package.json +10 -7
  3. package/create.js +0 -29
package/index.js CHANGED
@@ -1,10 +1,68 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { exec } = require('child_process');
4
- const path = require('path');
3
+ const { execSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const readline = require("readline");
5
7
 
6
- // Require the create.js script to handle the initialization
7
- require('./create');
8
+ // Prompt the user for input
9
+ const rl = readline.createInterface({
10
+ input: process.stdin,
11
+ output: process.stdout,
12
+ });
8
13
 
9
- // If you want to call the script from `create.js` directly, you can also define it here.
10
- // If needed, you could also provide further customization options for users or more handling.
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
+ }
24
+
25
+ async function initApp() {
26
+ try {
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!");
63
+ } catch (error) {
64
+ console.error("āŒ Error during setup:", error.message);
65
+ }
66
+ }
67
+
68
+ initApp();
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "create-tanstack-app",
3
- "version": "1.0.1",
3
+ "version": "1.1.4",
4
4
  "main": "index.js",
5
- "scripts": {
6
- "create": "node create.js"
5
+ "bin": {
6
+ "create-tanstack-app": "./index.js"
7
7
  },
8
- "author": "",
8
+ "author": "Shaswat Raj",
9
9
  "license": "ISC",
10
10
  "description": "A CLI tool to create a Tanstack app",
11
- "dependencies": {
12
- "degit": "^2.8.4"
13
- }
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": {}
14
17
  }
package/create.js DELETED
@@ -1,29 +0,0 @@
1
- const degit = require('degit');
2
- const path = require('path');
3
- const fs = require('fs');
4
-
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);
8
-
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
- }
14
-
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));
20
-
21
- try {
22
- await emitter.clone(dest);
23
- console.log(`Template successfully downloaded! Navigate to ${dest} and start working on your project.`);
24
- } catch (error) {
25
- console.error('Error during template download:', error);
26
- }
27
- }
28
-
29
- initApp();