@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.
Files changed (3) hide show
  1. package/README.md +17 -17
  2. package/bin.js +28 -5
  3. 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
- Tạo project AI-Portal mới bằng một lệnh (giống `create-strapi-app`).
3
+ Create a new AI-Portal project with one command (like `create-strapi-app`).
4
4
 
5
- ## Cách dùng
5
+ ## Usage
6
6
 
7
7
  ```bash
8
8
  npx @lampx83/create-ai-portal@latest
9
9
  ```
10
10
 
11
- Tạo thư mục `ai-portal-app` trong thư mục hiện tại.
11
+ Creates an `ai-portal-app` folder in the current directory.
12
12
 
13
- Hoặc chỉ định tên thư mục:
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 sẽ:
19
+ The CLI will:
20
20
 
21
- 1. Tải bản mới nhất của [AI-Portal](https://github.com/Lampx83/AI-Portal) từ GitHub.
22
- 2. Giải nén vào thư mục bạn chọn.
23
- 3. Tạo file `.env` từ `.env.example`.
24
- 4. Hỏi chạy Docker ngay không; nếu thì chạy `docker compose up -d`.
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
- ## Yêu cầu
26
+ ## Requirements
27
27
 
28
- - **Node.js 18+** (để chạy `npx @lampx83/create-ai-portal`).
29
- - **Docker & Docker Compose** (để chạy ứng dụng).
28
+ - **Node.js 18+** (to run `npx @lampx83/create-ai-portal`).
29
+ - **Docker & Docker Compose** (to run the application).
30
30
 
31
- ## Publish lên npm
31
+ ## Publishing to npm
32
32
 
33
- Từ thư mục `create-ai-portal`:
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
- Sau đó mọi người thể chạy `npx @lampx83/create-ai-portal@latest` không cần clone repo. Scoped package cần: `npm publish --access public`.
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
- const projectName = process.argv[2] || 'ai-portal-app';
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.copyFileSync(envExample, envPath);
67
- console.log(' Created .env from .env.example.');
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lampx83/create-ai-portal",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Scaffold a new AI-Portal project with one command (like create-strapi-app)",
5
5
  "main": "bin.js",
6
6
  "bin": {