@suryasairus/create-projectx 1.0.1 → 1.0.3
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/index.js +22 -21
- package/package.json +9 -8
package/index.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { execSync } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const projectName = process.argv[2] || 'my-app';
|
|
6
|
+
const projectPath = path.join(process.cwd(), projectName);
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{ name: 'dbHost', message: 'Database Host:', default: 'localhost' },
|
|
12
|
-
{ name: 'dbUser', message: 'Database User:' }
|
|
13
|
-
]);
|
|
8
|
+
// 1. Create folder
|
|
9
|
+
fs.mkdirSync(projectPath, { recursive: true });
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
// 2. Create the user's package.json
|
|
12
|
+
const pkgJson = {
|
|
13
|
+
name: projectName,
|
|
14
|
+
version: "1.0.0",
|
|
15
|
+
scripts: {
|
|
16
|
+
"build": "next build node_modules/@suryasairus/projectx-core"
|
|
17
|
+
},
|
|
18
|
+
dependencies: {
|
|
19
|
+
"next": "latest",
|
|
20
|
+
"@suryasairus/projectx-core": "latest" // This package contains your code
|
|
21
|
+
}
|
|
22
|
+
};
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
const envData = `DATABASE_URL=postgresql://${answers.dbUser}@${answers.dbHost}:5432/mydb`;
|
|
20
|
-
fs.writeFileSync(`${projectName}/.env`, envData);
|
|
24
|
+
fs.writeFileSync(path.join(projectPath, 'package.json'), JSON.stringify(pkgJson, null, 2));
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
execSync(`npx degit your-github-username/projectx-template ${projectName}`);
|
|
26
|
+
// 3. Write .env (from your CLI questions)
|
|
27
|
+
fs.writeFileSync(path.join(projectPath, '.env'), "DATABASE_URL=your_value_here");
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
run();
|
|
29
|
+
console.log(`Project ${projectName} created! Now run: cd ${projectName} && npm install`);
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suryasairus/create-projectx",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "CLI to scaffold ProjectX",
|
|
5
5
|
"license": "ISC",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-projectx": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js"
|
|
12
|
+
]
|
|
12
13
|
}
|