@lampx83/create-ai-portal 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/README.md +17 -17
- package/bin.js +28 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
# create-ai-portal
|
|
1
|
+
# @lampx83/create-ai-portal
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create a new AI-Portal project with one command (like `create-strapi-app`).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npx @lampx83/create-ai-portal@latest
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Creates an `ai-portal-app` folder in the current directory.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Or specify a folder name:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npx @lampx83/create-ai-portal@latest my-portal
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
CLI
|
|
19
|
+
The CLI will:
|
|
20
20
|
|
|
21
|
-
1.
|
|
22
|
-
2.
|
|
23
|
-
3.
|
|
24
|
-
4.
|
|
21
|
+
1. Download the latest [AI-Portal](https://github.com/Lampx83/AI-Portal) from GitHub.
|
|
22
|
+
2. Extract it into your chosen folder.
|
|
23
|
+
3. Create `.env` from `.env.example`.
|
|
24
|
+
4. Ask whether to run Docker now; if yes, runs `docker compose up -d`.
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Requirements
|
|
27
27
|
|
|
28
|
-
- **Node.js 18+** (
|
|
29
|
-
- **Docker & Docker Compose** (
|
|
28
|
+
- **Node.js 18+** (to run `npx @lampx83/create-ai-portal`).
|
|
29
|
+
- **Docker & Docker Compose** (to run the application).
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Publishing to npm
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
From the `create-ai-portal` directory:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
npm login
|
|
37
|
-
npm publish
|
|
37
|
+
npm publish --access public
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
Scoped packages require `--access public` to be installable by everyone. After publishing, anyone can run `npx @lampx83/create-ai-portal@latest` without cloning the repo.
|
package/bin.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const crypto = require('crypto');
|
|
5
6
|
const { spawnSync } = require('child_process');
|
|
6
7
|
const readline = require('readline');
|
|
7
8
|
const tar = require('tar');
|
|
@@ -27,11 +28,30 @@ function ask(question, defaultAnswer = 'n') {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
function askFolderName(question, defaultName = 'ai-portal-app') {
|
|
32
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
rl.question(`${question} (${defaultName}) `, (answer) => {
|
|
35
|
+
rl.close();
|
|
36
|
+
const name = (answer || defaultName).trim() || defaultName;
|
|
37
|
+
resolve(name.replace(/[/\\]/g, '')); // strip path separators
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
30
42
|
async function main() {
|
|
31
|
-
|
|
43
|
+
let projectName = process.argv[2];
|
|
44
|
+
if (projectName === undefined || projectName === '') {
|
|
45
|
+
console.log('\n create-ai-portal\n');
|
|
46
|
+
projectName = await askFolderName(' What is the project folder name?', 'ai-portal-app');
|
|
47
|
+
if (!projectName) {
|
|
48
|
+
console.error(' Error: Folder name cannot be empty.');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
console.log('\n create-ai-portal\n');
|
|
53
|
+
}
|
|
32
54
|
const targetDir = path.resolve(process.cwd(), projectName);
|
|
33
|
-
|
|
34
|
-
console.log('\n create-ai-portal\n');
|
|
35
55
|
console.log(' Creating a new AI-Portal project in:', targetDir);
|
|
36
56
|
console.log('');
|
|
37
57
|
|
|
@@ -63,8 +83,11 @@ async function main() {
|
|
|
63
83
|
const envExample = path.join(targetDir, '.env.example');
|
|
64
84
|
const envPath = path.join(targetDir, '.env');
|
|
65
85
|
if (fs.existsSync(envExample)) {
|
|
66
|
-
fs.
|
|
67
|
-
|
|
86
|
+
let envContent = fs.readFileSync(envExample, 'utf8');
|
|
87
|
+
const secret = crypto.randomBytes(32).toString('base64');
|
|
88
|
+
envContent = envContent.replace(/^NEXTAUTH_SECRET=.*/m, `NEXTAUTH_SECRET=${secret}`);
|
|
89
|
+
fs.writeFileSync(envPath, envContent);
|
|
90
|
+
console.log(' Created .env from .env.example (NEXTAUTH_SECRET generated).');
|
|
68
91
|
}
|
|
69
92
|
|
|
70
93
|
// Remove create-ai-portal from the scaffold (user doesn't need it in their project)
|