@kmlckj/licos-ai-cli 0.0.28 → 0.0.29

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 (42) hide show
  1. package/lib/__templates__/expo/.licosproj/scripts/dev_build.sh +3 -1
  2. package/lib/__templates__/expo/.licosproj/scripts/dev_run.sh +2 -2
  3. package/lib/__templates__/expo/.licosproj/scripts/prod_build.sh +2 -2
  4. package/lib/__templates__/expo/.licosproj/scripts/prod_run.sh +1 -1
  5. package/lib/__templates__/expo/.licosproj/scripts/server_dev_run.sh +1 -1
  6. package/lib/__templates__/expo/AGENTS.md +5 -5
  7. package/lib/__templates__/expo/README.md +5 -5
  8. package/lib/__templates__/expo/client/package.json +1 -1
  9. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +11 -6
  10. package/lib/__templates__/expo/package.json +10 -4
  11. package/lib/__templates__/expo/server/package.json +5 -5
  12. package/lib/__templates__/expo/template.config.js +8 -2
  13. package/lib/__templates__/nextjs/AGENTS.md +3 -3
  14. package/lib/__templates__/nextjs/README.md +3 -3
  15. package/lib/__templates__/nextjs/package.json +16 -12
  16. package/lib/__templates__/nextjs/pnpm-lock.yaml +16 -273
  17. package/lib/__templates__/nextjs/scripts/build.sh +1 -1
  18. package/lib/__templates__/nextjs/scripts/prepare.sh +1 -1
  19. package/lib/__templates__/nextjs/template.config.js +8 -2
  20. package/lib/__templates__/nuxt-vue/AGENTS.md +3 -3
  21. package/lib/__templates__/nuxt-vue/README.md +1 -1
  22. package/lib/__templates__/nuxt-vue/package.json +15 -11
  23. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +6 -401
  24. package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
  25. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +1 -1
  26. package/lib/__templates__/taro/.licosproj/scripts/deploy_build.sh +1 -1
  27. package/lib/__templates__/taro/.licosproj/scripts/dev_build.sh +1 -1
  28. package/lib/__templates__/taro/.licosproj/scripts/dev_run.sh +1 -1
  29. package/lib/__templates__/taro/AGENTS.md +6 -6
  30. package/lib/__templates__/taro/README.md +7 -7
  31. package/lib/__templates__/taro/package.json +3 -4
  32. package/lib/__templates__/taro/pnpm-lock.yaml +7 -206
  33. package/lib/__templates__/taro/server/src/main.ts +2 -2
  34. package/lib/__templates__/vite/AGENTS.md +3 -3
  35. package/lib/__templates__/vite/README.md +7 -7
  36. package/lib/__templates__/vite/package.json +16 -12
  37. package/lib/__templates__/vite/pnpm-lock.yaml +0 -417
  38. package/lib/__templates__/vite/scripts/build.sh +1 -1
  39. package/lib/__templates__/vite/scripts/prepare.sh +1 -1
  40. package/lib/__templates__/vite/template.config.js +8 -2
  41. package/lib/cli.js +14 -9
  42. package/package.json +1 -1
@@ -12,6 +12,7 @@ CHECK_HASH_SCRIPT="$ROOT_DIR/check_hash.py"
12
12
  check_command() {
13
13
  if ! command -v "$1" &> /dev/null; then
14
14
  echo "error:命令 $1 未找到,请先安装"
15
+ exit 1
15
16
  fi
16
17
  }
17
18
 
@@ -32,9 +33,10 @@ check_command "npm"
32
33
  echo "==================== 安装项目依赖 ===================="
33
34
  if [ ! -f "package.json" ]; then
34
35
  echo "项目目录下无 package.json,不是合法的 Node.js 项目"
36
+ exit 1
35
37
  fi
36
38
  # 步骤 2.1/2.2:安装项目依赖
37
- pnpm install --registry=https://registry.npmmirror.com || echo "Expo 项目依赖安装失败(pnpm 执行出错)"
39
+ pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline --reporter=append-only
38
40
 
39
41
  echo "检查根目录 post_install.py"
40
42
  if [ -f "$PREVIEW_DIR/post_install.py" ]; then
@@ -129,10 +129,10 @@ start_expo() {
129
129
 
130
130
  if [ "$offline" = "1" ]; then
131
131
  ( EXPO_OFFLINE=1 EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_LICOS_PROJECT_ID="$EXPO_PUBLIC_LICOS_PROJECT_ID" \
132
- nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
132
+ nohup pnpm exec expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
133
133
  else
134
134
  ( EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_LICOS_PROJECT_ID="$EXPO_PUBLIC_LICOS_PROJECT_ID" \
135
- nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
135
+ nohup pnpm exec expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
136
136
  fi
137
137
  EXPO_PID=$!
138
138
  disown $EXPO_PID 2>/dev/null || true
@@ -32,8 +32,8 @@ info "==================== 安装 Node 依赖 ===================="
32
32
  info "开始安装 Node 依赖"
33
33
  if [ -f "$ROOT_DIR/package.json" ]; then
34
34
  info "进入目录:$ROOT_DIR"
35
- info "正在执行:pnpm install"
36
- (cd "$ROOT_DIR" && pnpm install --registry=https://registry.npmmirror.com) || error "Node 依赖安装失败"
35
+ info "正在执行:pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline"
36
+ (cd "$ROOT_DIR" && pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline --reporter=append-only) || error "Node 依赖安装失败"
37
37
  else
38
38
  warn "未找到 $ROOT_DIR/package.json 文件,请检查路径是否正确"
39
39
  fi
@@ -5,7 +5,7 @@ set -euo pipefail
5
5
  ROOT_DIR="$(pwd)"
6
6
 
7
7
  HOST="${HOST:-0.0.0.0}"
8
- PORT="${PORT:-5000}"
8
+ PORT="${DEPLOY_RUN_PORT:-${PORT:-5000}}"
9
9
 
10
10
  # ==================== 工具函数 ====================
11
11
  info() {
@@ -51,4 +51,4 @@ kill_old_server
51
51
 
52
52
  echo "启动 server 服务..."
53
53
  cd "$SERVER_DIR"
54
- NODE_ENV=development PORT="$SERVER_PORT" npx tsx watch ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
54
+ NODE_ENV=development PORT="$SERVER_PORT" pnpm exec tsx watch ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
@@ -221,18 +221,18 @@ export { default } from "@/screens/home";
221
221
 
222
222
  | 目录 | 安装命令 | 说明 |
223
223
  |------|----------|------|
224
- | `client/` | `npx expo install <package>` | Expo 会自动选择与 SDK 兼容的版本 |
225
- | `server/` | `pnpm add <package>` | 使用 pnpm 管理后端依赖 |
224
+ | `client/` | `NPM_CONFIG_REGISTRY=https://registry.npmmirror.com pnpm --dir client exec expo install <package>` | Expo 会自动选择与 SDK 兼容的版本 |
225
+ | `server/` | `pnpm add --registry=https://registry.npmmirror.com <package>` | 使用 pnpm 管理后端依赖 |
226
226
 
227
227
  ```bash
228
228
  # client 目录(Expo 项目)
229
- cd client && npx expo install expo-camera expo-image-picker
229
+ NPM_CONFIG_REGISTRY=https://registry.npmmirror.com pnpm --dir client exec expo install expo-camera expo-image-picker
230
230
 
231
231
  # server 目录(Express 项目)
232
- cd server && pnpm add axios cors
232
+ cd server && pnpm add --registry=https://registry.npmmirror.com axios cors
233
233
  ```
234
234
 
235
- **网络问题处理**:`npx expo install` 可能因网络原因失败,失败时重试 2 次,仍失败则改用 `pnpm add` 安装
235
+ **网络问题处理**:`pnpm --dir client exec expo install` 可能因网络原因失败,失败时重试 2 次,仍失败则改用 `pnpm --dir client add --registry=https://registry.npmmirror.com` 安装
236
236
 
237
237
  ## Expo 开发规范
238
238
 
@@ -221,18 +221,18 @@ export { default } from "@/screens/home";
221
221
 
222
222
  | 目录 | 安装命令 | 说明 |
223
223
  |------|----------|------|
224
- | `client/` | `npx expo install <package>` | Expo 会自动选择与 SDK 兼容的版本 |
225
- | `server/` | `pnpm add <package>` | 使用 pnpm 管理后端依赖 |
224
+ | `client/` | `NPM_CONFIG_REGISTRY=https://registry.npmmirror.com pnpm --dir client exec expo install <package>` | Expo 会自动选择与 SDK 兼容的版本 |
225
+ | `server/` | `pnpm add --registry=https://registry.npmmirror.com <package>` | 使用 pnpm 管理后端依赖 |
226
226
 
227
227
  ```bash
228
228
  # client 目录(Expo 项目)
229
- cd client && npx expo install expo-camera expo-image-picker
229
+ NPM_CONFIG_REGISTRY=https://registry.npmmirror.com pnpm --dir client exec expo install expo-camera expo-image-picker
230
230
 
231
231
  # server 目录(Express 项目)
232
- cd server && pnpm add axios cors
232
+ cd server && pnpm add --registry=https://registry.npmmirror.com axios cors
233
233
  ```
234
234
 
235
- **网络问题处理**:`npx expo install` 可能因网络原因失败,失败时重试 2 次,仍失败则改用 `pnpm add` 安装
235
+ **网络问题处理**:`pnpm --dir client exec expo install` 可能因网络原因失败,失败时重试 2 次,仍失败则改用 `pnpm --dir client add --registry=https://registry.npmmirror.com` 安装
236
236
 
237
237
  ## Expo 开发规范
238
238
 
@@ -4,7 +4,7 @@
4
4
  "main": "expo-router/entry",
5
5
  "private": true,
6
6
  "scripts": {
7
- "check-deps": "npx depcheck",
7
+ "check-deps": "pnpm exec depcheck",
8
8
  "install-missing": "node ./scripts/install-missing-deps.js",
9
9
  "lint": "tsc --noEmit; eslint ./ -f ./scripts/formatter.mjs --quiet",
10
10
  "start": "expo start --web --clear",
@@ -16,7 +16,7 @@ try {
16
16
  // 注意:depcheck 发现问题时会返回非零退出码,但这不是错误
17
17
  let depcheckOutput;
18
18
  try {
19
- depcheckOutput = execSync('npx depcheck --json', {
19
+ depcheckOutput = execSync('pnpm exec depcheck --json', {
20
20
  encoding: 'utf-8',
21
21
  stdio: ['pipe', 'pipe', 'pipe'],
22
22
  });
@@ -80,24 +80,29 @@ try {
80
80
  const packagesToInstall = missingPackages.join(' ');
81
81
 
82
82
  try {
83
- execSync(`pnpm expo install ${packagesToInstall}`, {
83
+ execSync(`pnpm exec expo install ${packagesToInstall}`, {
84
84
  stdio: 'inherit',
85
+ env: {
86
+ ...process.env,
87
+ NPM_CONFIG_REGISTRY: 'https://registry.npmmirror.com',
88
+ npm_config_registry: 'https://registry.npmmirror.com',
89
+ },
85
90
  });
86
91
 
87
92
  console.log('\n所有缺失的依赖已安装完成');
88
93
  } catch (installError) {
89
- console.log('\nexpo install 失败,尝试使用 npm install...\n');
94
+ console.log('\nexpo install 失败,尝试使用 pnpm add --registry=https://registry.npmmirror.com...\n');
90
95
 
91
- execSync(`npm install ${packagesToInstall}`, {
96
+ execSync(`pnpm add --registry=https://registry.npmmirror.com ${packagesToInstall}`, {
92
97
  stdio: 'inherit',
93
98
  });
94
99
 
95
- console.log('\n所有缺失的依赖已通过 npm 安装完成');
100
+ console.log('\n所有缺失的依赖已通过 pnpm 安装完成');
96
101
  }
97
102
  } catch (error) {
98
103
  if (error.message.includes('depcheck')) {
99
104
  console.error('depcheck 未安装或运行失败');
100
- console.log('尝试运行: npm install -g depcheck');
105
+ console.log('尝试运行: pnpm add --registry=https://registry.npmmirror.com -D depcheck');
101
106
  } else {
102
107
  console.error('发生错误:', error.message);
103
108
  }
@@ -6,10 +6,16 @@
6
6
  "dev": "bash .licosproj/scripts/dev_run.sh",
7
7
  "build": "bash .licosproj/scripts/prod_build.sh",
8
8
  "start": "bash .licosproj/scripts/prod_run.sh",
9
- "preinstall": "npx only-allow pnpm",
10
- "lint:client": "npm run lint --prefix ./client",
11
- "lint:server": "npm run lint --prefix ./server",
12
- "lint:all": "npm run lint --prefix ./client; npm run lint --prefix ./server"
9
+ "ensure:deps": "node -e \"const fs=require('fs'); const bins=['client/node_modules/.bin/expo','server/node_modules/.bin/tsx','server/node_modules/.bin/tsc']; process.exit(bins.every((p)=>fs.existsSync(p)||fs.existsSync(p+'.cmd'))?0:1)\" || pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline --reporter=append-only",
10
+ "prebuild": "pnpm run ensure:deps",
11
+ "predev": "pnpm run ensure:deps",
12
+ "preinstall": "node -e \"const ua=process.env.npm_config_user_agent||''; if(!ua.includes('pnpm')){console.error('Use pnpm to install dependencies.'); process.exit(1)}\"",
13
+ "prelint:all": "pnpm run ensure:deps",
14
+ "prelint:client": "pnpm run ensure:deps",
15
+ "prelint:server": "pnpm run ensure:deps",
16
+ "lint:client": "pnpm --dir ./client lint",
17
+ "lint:server": "pnpm --dir ./server lint",
18
+ "lint:all": "pnpm --dir ./client lint && pnpm --dir ./server lint"
13
19
  },
14
20
  "dependencies": {},
15
21
  "devDependencies": {},
@@ -2,11 +2,11 @@
2
2
  "name": "server",
3
3
  "private": true,
4
4
  "type": "module",
5
- "scripts": {
6
- "build": "node build.js",
7
- "dev": "bash ../.licosproj/scripts/server_dev_run.sh",
8
- "preinstall": "npx only-allow pnpm",
9
- "start": "NODE_ENV=production PORT=${PORT:-5000} node dist/index.js",
5
+ "scripts": {
6
+ "build": "node build.js",
7
+ "dev": "bash ../.licosproj/scripts/server_dev_run.sh",
8
+ "preinstall": "node -e \"const ua=process.env.npm_config_user_agent||''; if(!ua.includes('pnpm')){console.error('Use pnpm to install dependencies.'); process.exit(1)}\"",
9
+ "start": "NODE_ENV=production PORT=${PORT:-5000} node dist/index.js",
10
10
  "lint": "tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
@@ -59,7 +59,13 @@ const config = {
59
59
  }
60
60
 
61
61
  const cmd = 'pnpm';
62
- const args = ['install'];
62
+ const args = [
63
+ 'install',
64
+ '--registry=https://registry.npmmirror.com',
65
+ '--prefer-frozen-lockfile',
66
+ '--prefer-offline',
67
+ '--reporter=append-only',
68
+ ];
63
69
  console.log(
64
70
  `\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
65
71
  );
@@ -94,7 +100,7 @@ const config = {
94
100
  console.log(` Log file: ${logFile}`);
95
101
  } catch (error) {
96
102
  console.error('✗ Failed to trigger pnpm install:', error);
97
- console.log(' You can manually run: pnpm install');
103
+ console.log(' You can manually run: pnpm install --registry=https://registry.npmmirror.com');
98
104
  }
99
105
  },
100
106
  };
@@ -35,9 +35,9 @@
35
35
 
36
36
  **仅允许使用 pnpm** 作为包管理器,**严禁使用 npm 或 yarn**。
37
37
  **常用命令**:
38
- - 安装依赖:`pnpm add <package>`
39
- - 安装开发依赖:`pnpm add -D <package>`
40
- - 安装所有依赖:`pnpm install`
38
+ - 安装依赖:`pnpm add --registry=https://registry.npmmirror.com <package>`
39
+ - 安装开发依赖:`pnpm add --registry=https://registry.npmmirror.com -D <package>`
40
+ - 安装所有依赖:`pnpm install --registry=https://registry.npmmirror.com`
41
41
  - 移除依赖:`pnpm remove <package>`
42
42
 
43
43
  ## 开发规范
@@ -164,13 +164,13 @@ export async function POST(request: Request) {
164
164
 
165
165
  ```bash
166
166
  # ✅ 安装依赖
167
- pnpm install
167
+ pnpm install --registry=https://registry.npmmirror.com
168
168
 
169
169
  # ✅ 添加新依赖
170
- pnpm add package-name
170
+ pnpm add --registry=https://registry.npmmirror.com package-name
171
171
 
172
172
  # ✅ 添加开发依赖
173
- pnpm add -D package-name
173
+ pnpm add --registry=https://registry.npmmirror.com -D package-name
174
174
 
175
175
  # ❌ 禁止使用 npm 或 yarn
176
176
  # npm install # 错误!
@@ -2,13 +2,18 @@
2
2
  "name": "<%= appName %>",
3
3
  "version": "0.1.0",
4
4
  "private": true,
5
- "scripts": {
6
- "build": "bash ./scripts/build.sh",
7
- "dev": "bash ./scripts/dev.sh",
8
- "preinstall": "npx only-allow pnpm",
9
- "lint": "eslint",
10
- "start": "bash ./scripts/start.sh",
11
- "ts-check": "tsc -p tsconfig.json"
5
+ "scripts": {
6
+ "build": "bash ./scripts/build.sh",
7
+ "dev": "bash ./scripts/dev.sh",
8
+ "ensure:deps": "node -e \"const fs=require('fs'); const bins=['node_modules/.bin/next','node_modules/.bin/tsx','node_modules/.bin/tsup','node_modules/.bin/eslint','node_modules/.bin/tsc']; process.exit(bins.every((p)=>fs.existsSync(p)||fs.existsSync(p+'.cmd'))?0:1)\" || pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline --reporter=append-only",
9
+ "prebuild": "pnpm run ensure:deps",
10
+ "predev": "pnpm run ensure:deps",
11
+ "preinstall": "node -e \"const ua=process.env.npm_config_user_agent||''; if(!ua.includes('pnpm')){console.error('Use pnpm to install dependencies.'); process.exit(1)}\"",
12
+ "prelint": "pnpm run ensure:deps",
13
+ "prets-check": "pnpm run ensure:deps",
14
+ "lint": "eslint",
15
+ "start": "bash ./scripts/start.sh",
16
+ "ts-check": "tsc -p tsconfig.json"
12
17
  },
13
18
  "dependencies": {
14
19
  "@kmlckj/licos-platform-sdk": "0.6.1",
@@ -74,11 +79,10 @@
74
79
  "@types/node": "^20",
75
80
  "@types/pg": "^8.16.0",
76
81
  "@types/react": "^19",
77
- "@types/react-dom": "^19",
78
- "eslint": "^9",
79
- "eslint-config-next": "16.1.1",
80
- "only-allow": "^1.2.2",
81
- "react-dev-inspector": "^2.0.1",
82
+ "@types/react-dom": "^19",
83
+ "eslint": "^9",
84
+ "eslint-config-next": "16.1.1",
85
+ "react-dev-inspector": "^2.0.1",
82
86
  "shadcn": "latest",
83
87
  "tailwindcss": "^4",
84
88
  "tsup": "^8.3.5",