@kmlckj/licos-ai-cli 1.0.24 → 1.0.26

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.
@@ -12,9 +12,9 @@ const normalizeBaseUrl = (value?: string) => {
12
12
  return `/${trimmed.replace(/^\/+|\/+$/g, '')}`;
13
13
  };
14
14
 
15
- const baseUrl = process.env.LICOS_PREVIEW_BASE_PATH
16
- ? undefined
17
- : normalizeBaseUrl(process.env.BASE_PATH || process.env.EXPO_PUBLIC_BASE_PATH);
15
+ const baseUrl = process.env.LICOS_PREVIEW_BASE_PATH
16
+ ? undefined
17
+ : normalizeBaseUrl(process.env.BASE_PATH || process.env.EXPO_PUBLIC_BASE_PATH);
18
18
 
19
19
  export default ({ config }: ConfigContext): ExpoConfig => {
20
20
  return {
@@ -1,34 +1,34 @@
1
- const previewBase =
2
- typeof window !== 'undefined' ? window.__LICOS_PREVIEW_BASE_PATH__ : undefined;
3
-
4
- let originalUrl;
5
- const rawReplaceState =
6
- typeof History !== 'undefined' && History.prototype.replaceState
7
- ? History.prototype.replaceState
8
- : typeof window !== 'undefined'
9
- ? window.history.replaceState
10
- : undefined;
11
-
12
- const replaceStateWithoutPreviewRewrite = (url) => {
13
- if (!rawReplaceState || typeof window === 'undefined') return;
14
- rawReplaceState.call(window.history, window.history.state, document.title, url);
15
- };
16
-
17
- if (
18
- typeof window !== 'undefined' &&
19
- previewBase &&
20
- window.location.pathname.startsWith(previewBase)
21
- ) {
22
- const rest = window.location.pathname.slice(previewBase.length) || '/';
23
- const appPath = rest.startsWith('/') ? rest : `/${rest}`;
24
- originalUrl = `${window.location.pathname}${window.location.search}${window.location.hash}`;
25
- replaceStateWithoutPreviewRewrite(`${appPath}${window.location.search}${window.location.hash}`);
26
- }
27
-
28
- require('expo-router/entry');
29
-
30
- if (typeof window !== 'undefined' && originalUrl) {
31
- window.addEventListener('load', () => {
32
- replaceStateWithoutPreviewRewrite(originalUrl);
33
- }, { once: true });
34
- }
1
+ const previewBase =
2
+ typeof window !== 'undefined' ? window.__LICOS_PREVIEW_BASE_PATH__ : undefined;
3
+
4
+ let originalUrl;
5
+ const rawReplaceState =
6
+ typeof History !== 'undefined' && History.prototype.replaceState
7
+ ? History.prototype.replaceState
8
+ : typeof window !== 'undefined'
9
+ ? window.history.replaceState
10
+ : undefined;
11
+
12
+ const replaceStateWithoutPreviewRewrite = (url) => {
13
+ if (!rawReplaceState || typeof window === 'undefined') return;
14
+ rawReplaceState.call(window.history, window.history.state, document.title, url);
15
+ };
16
+
17
+ if (
18
+ typeof window !== 'undefined' &&
19
+ previewBase &&
20
+ window.location.pathname.startsWith(previewBase)
21
+ ) {
22
+ const rest = window.location.pathname.slice(previewBase.length) || '/';
23
+ const appPath = rest.startsWith('/') ? rest : `/${rest}`;
24
+ originalUrl = `${window.location.pathname}${window.location.search}${window.location.hash}`;
25
+ replaceStateWithoutPreviewRewrite(`${appPath}${window.location.search}${window.location.hash}`);
26
+ }
27
+
28
+ require('expo-router/entry');
29
+
30
+ if (typeof window !== 'undefined' && originalUrl) {
31
+ window.addEventListener('load', () => {
32
+ replaceStateWithoutPreviewRewrite(originalUrl);
33
+ }, { once: true });
34
+ }
@@ -1,100 +1,100 @@
1
- {
2
- "name": "expo-app",
3
- "description": "<%= appName %>",
4
- "main": "./entry.js",
5
- "private": true,
6
- "scripts": {
7
- "check-deps": "pnpm exec depcheck",
8
- "install-missing": "node ./scripts/install-missing-deps.js",
9
- "lint": "tsc --noEmit; eslint ./ -f ./scripts/formatter.mjs --quiet",
10
- "start": "expo start --web --clear",
11
- "test": "jest --watchAll"
12
- },
13
- "jest": {
14
- "preset": "jest-expo"
15
- },
16
- "dependencies": {
17
- "@expo/metro-runtime": "~6.1.2",
18
- "@expo/vector-icons": "^15.0.3",
19
- "@react-native-async-storage/async-storage": "2.2.0",
20
- "@react-native-community/datetimepicker": "8.4.4",
21
- "@react-native-community/slider": "5.0.1",
22
- "@react-native-masked-view/masked-view": "0.3.2",
23
- "@react-native-picker/picker": "2.11.1",
24
- "@react-navigation/bottom-tabs": "^7.2.0",
25
- "@react-navigation/native": "^7.0.14",
26
- "dayjs": "^1.11.19",
27
- "expo": "54.0.33",
28
- "expo-auth-session": "~7.0.10",
29
- "expo-av": "~16.0.8",
30
- "expo-blur": "~15.0.8",
31
- "expo-camera": "~17.0.10",
32
- "expo-constants": "~18.0.13",
33
- "expo-crypto": "~15.0.8",
34
- "expo-file-system": "~19.0.21",
35
- "expo-font": "~14.0.11",
36
- "expo-haptics": "~15.0.8",
37
- "expo-image": "~3.0.11",
38
- "expo-image-picker": "~17.0.10",
39
- "expo-linear-gradient": "~15.0.8",
40
- "expo-linking": "~8.0.11",
41
- "expo-location": "~19.0.8",
42
- "expo-router": "~6.0.23",
43
- "expo-splash-screen": "~31.0.13",
44
- "expo-status-bar": "~3.0.9",
45
- "expo-symbols": "~1.0.8",
46
- "expo-system-ui": "~6.0.9",
47
- "expo-web-browser": "~15.0.10",
48
- "js-base64": "^3.7.7",
49
- "react": "19.1.0",
50
- "react-dom": "19.1.0",
51
- "react-native": "0.81.5",
52
- "react-native-chart-kit": "^6.12.0",
53
- "react-native-gesture-handler": "~2.28.0",
54
- "react-native-keyboard-aware-scroll-view": "^0.9.5",
55
- "react-native-modal-datetime-picker": "18.0.0",
56
- "react-native-reanimated": "~4.1.1",
57
- "react-native-safe-area-context": "~5.6.0",
58
- "react-native-screens": "~4.16.0",
59
- "react-native-svg": "15.12.1",
60
- "react-native-toast-message": "^2.3.3",
61
- "react-native-web": "~0.21.0",
62
- "react-native-webview": "13.15.0",
63
- "react-native-worklets": "0.5.1",
64
- "zod": "^4.2.1",
65
- "@gorhom/bottom-sheet": "^5.2.8",
66
- "tailwind-merge": "^3.4.0",
67
- "tailwind-variants": "^3.2.2"
68
- },
69
- "devDependencies": {
70
- "@babel/core": "^7.25.2",
71
- "@eslint/js": "^9.27.0",
72
- "@types/jest": "^29.5.12",
73
- "@types/react": "~19.1.0",
74
- "@types/react-test-renderer": "19.1.0",
75
- "babel-plugin-module-resolver": "^5.0.2",
76
- "babel-preset-expo": "^54.0.9",
77
- "chalk": "^4.1.2",
78
- "connect": "^3.7.0",
79
- "depcheck": "^1.4.7",
80
- "esbuild": "0.27.2",
81
- "eslint": "^9.39.2",
82
- "eslint-formatter-compact": "^9.0.1",
83
- "eslint-import-resolver-typescript": "^4.4.4",
84
- "eslint-plugin-import": "^2.32.0",
85
- "eslint-plugin-react": "^7.37.5",
86
- "eslint-plugin-react-hooks": "^7.0.1",
87
- "eslint-plugin-regexp": "^2.10.0",
88
- "globals": "^16.1.0",
89
- "http-proxy-middleware": "^3.0.5",
90
- "jest": "^29.2.1",
91
- "jest-expo": "~54.0.17",
92
- "react-test-renderer": "19.1.0",
93
- "tsx": "^4.21.0",
94
- "typescript": "^5.8.3",
95
- "typescript-eslint": "^8.32.1",
96
- "axios": "^1.13.6",
97
- "tailwindcss": "^4.1.18",
98
- "uniwind": "^1.2.7"
99
- }
100
- }
1
+ {
2
+ "name": "expo-app",
3
+ "description": "<%= appName %>",
4
+ "main": "./entry.js",
5
+ "private": true,
6
+ "scripts": {
7
+ "check-deps": "pnpm exec depcheck",
8
+ "install-missing": "node ./scripts/install-missing-deps.js",
9
+ "lint": "tsc --noEmit; eslint ./ -f ./scripts/formatter.mjs --quiet",
10
+ "start": "expo start --web --clear",
11
+ "test": "jest --watchAll"
12
+ },
13
+ "jest": {
14
+ "preset": "jest-expo"
15
+ },
16
+ "dependencies": {
17
+ "@expo/metro-runtime": "~6.1.2",
18
+ "@expo/vector-icons": "^15.0.3",
19
+ "@react-native-async-storage/async-storage": "2.2.0",
20
+ "@react-native-community/datetimepicker": "8.4.4",
21
+ "@react-native-community/slider": "5.0.1",
22
+ "@react-native-masked-view/masked-view": "0.3.2",
23
+ "@react-native-picker/picker": "2.11.1",
24
+ "@react-navigation/bottom-tabs": "^7.2.0",
25
+ "@react-navigation/native": "^7.0.14",
26
+ "dayjs": "^1.11.19",
27
+ "expo": "54.0.33",
28
+ "expo-auth-session": "~7.0.10",
29
+ "expo-av": "~16.0.8",
30
+ "expo-blur": "~15.0.8",
31
+ "expo-camera": "~17.0.10",
32
+ "expo-constants": "~18.0.13",
33
+ "expo-crypto": "~15.0.8",
34
+ "expo-file-system": "~19.0.21",
35
+ "expo-font": "~14.0.11",
36
+ "expo-haptics": "~15.0.8",
37
+ "expo-image": "~3.0.11",
38
+ "expo-image-picker": "~17.0.10",
39
+ "expo-linear-gradient": "~15.0.8",
40
+ "expo-linking": "~8.0.11",
41
+ "expo-location": "~19.0.8",
42
+ "expo-router": "~6.0.23",
43
+ "expo-splash-screen": "~31.0.13",
44
+ "expo-status-bar": "~3.0.9",
45
+ "expo-symbols": "~1.0.8",
46
+ "expo-system-ui": "~6.0.9",
47
+ "expo-web-browser": "~15.0.10",
48
+ "js-base64": "^3.7.7",
49
+ "react": "19.1.0",
50
+ "react-dom": "19.1.0",
51
+ "react-native": "0.81.5",
52
+ "react-native-chart-kit": "^6.12.0",
53
+ "react-native-gesture-handler": "~2.28.0",
54
+ "react-native-keyboard-aware-scroll-view": "^0.9.5",
55
+ "react-native-modal-datetime-picker": "18.0.0",
56
+ "react-native-reanimated": "~4.1.1",
57
+ "react-native-safe-area-context": "~5.6.0",
58
+ "react-native-screens": "~4.16.0",
59
+ "react-native-svg": "15.12.1",
60
+ "react-native-toast-message": "^2.3.3",
61
+ "react-native-web": "~0.21.0",
62
+ "react-native-webview": "13.15.0",
63
+ "react-native-worklets": "0.5.1",
64
+ "zod": "^4.2.1",
65
+ "@gorhom/bottom-sheet": "^5.2.8",
66
+ "tailwind-merge": "^3.4.0",
67
+ "tailwind-variants": "^3.2.2"
68
+ },
69
+ "devDependencies": {
70
+ "@babel/core": "^7.25.2",
71
+ "@eslint/js": "^9.27.0",
72
+ "@types/jest": "^29.5.12",
73
+ "@types/react": "~19.1.0",
74
+ "@types/react-test-renderer": "19.1.0",
75
+ "babel-plugin-module-resolver": "^5.0.2",
76
+ "babel-preset-expo": "^54.0.9",
77
+ "chalk": "^4.1.2",
78
+ "connect": "^3.7.0",
79
+ "depcheck": "^1.4.7",
80
+ "esbuild": "0.27.2",
81
+ "eslint": "^9.39.2",
82
+ "eslint-formatter-compact": "^9.0.1",
83
+ "eslint-import-resolver-typescript": "^4.4.4",
84
+ "eslint-plugin-import": "^2.32.0",
85
+ "eslint-plugin-react": "^7.37.5",
86
+ "eslint-plugin-react-hooks": "^7.0.1",
87
+ "eslint-plugin-regexp": "^2.10.0",
88
+ "globals": "^16.1.0",
89
+ "http-proxy-middleware": "^3.0.5",
90
+ "jest": "^29.2.1",
91
+ "jest-expo": "~54.0.17",
92
+ "react-test-renderer": "19.1.0",
93
+ "tsx": "^4.21.0",
94
+ "typescript": "^5.8.3",
95
+ "typescript-eslint": "^8.32.1",
96
+ "axios": "^1.13.6",
97
+ "tailwindcss": "^4.1.18",
98
+ "uniwind": "^1.2.7"
99
+ }
100
+ }
@@ -193,14 +193,17 @@ export default defineConfig<'vite'>(async (merge, _env) => {
193
193
  sourceRoot: 'src',
194
194
  outputRoot,
195
195
  plugins: ['@tarojs/plugin-generator', ...buildMiniCIPluginConfig()],
196
- defineConstants: {
197
- PROJECT_DOMAIN: JSON.stringify(
198
- process.env.PROJECT_DOMAIN ||
199
- process.env.LICOS_PROJECT_DOMAIN_DEFAULT ||
200
- '',
201
- ),
202
- LICOS_TARO_ENV: JSON.stringify(process.env.TARO_ENV || ''),
203
- },
196
+ defineConstants: {
197
+ PROJECT_DOMAIN: JSON.stringify(
198
+ process.env.PROJECT_DOMAIN ||
199
+ process.env.LICOS_PROJECT_DOMAIN_DEFAULT ||
200
+ '',
201
+ ),
202
+ LICOS_H5_BASE_PATH: JSON.stringify(
203
+ deployBasePath.replace(/\/+$/g, ''),
204
+ ),
205
+ LICOS_TARO_ENV: JSON.stringify(process.env.TARO_ENV || ''),
206
+ },
204
207
  copy: {
205
208
  patterns: [],
206
209
  options: {},
@@ -9,11 +9,36 @@ import Taro from '@tarojs/taro'
9
9
  * IMPORTANT: 除非你需要添加全局参数,如给所有请求加上 header,否则不能修改此文件
10
10
  */
11
11
  export namespace Network {
12
+ const normalizeBase = (value?: string): string => {
13
+ const trimmed = (value || '').trim()
14
+ if (!trimmed || trimmed === '/') {
15
+ return ''
16
+ }
17
+ return trimmed.replace(/\/+$/g, '')
18
+ }
19
+
20
+ const inferH5BasePath = (): string => {
21
+ if (typeof window === 'undefined') {
22
+ return ''
23
+ }
24
+ const pathname = window.location?.pathname || ''
25
+ const matched = pathname.match(/^(\/p\/[^/]+)(?:\/|$)/)
26
+ return matched ? matched[1] : ''
27
+ }
28
+
29
+ const requestBase = (): string => {
30
+ return normalizeBase(PROJECT_DOMAIN)
31
+ || normalizeBase(LICOS_H5_BASE_PATH)
32
+ || normalizeBase(inferH5BasePath())
33
+ }
34
+
12
35
  const createUrl = (url: string): string => {
13
36
  if (url.startsWith('http://') || url.startsWith('https://')) {
14
37
  return url
15
38
  }
16
- return `${PROJECT_DOMAIN}${url}`
39
+ const path = url.startsWith('/') ? url : `/${url}`
40
+ const base = requestBase()
41
+ return base ? `${base}${path}` : path
17
42
  }
18
43
 
19
44
  export const request: typeof Taro.request = option => {
@@ -1,6 +1,7 @@
1
1
  /// <reference types="@tarojs/taro" />
2
2
 
3
3
  declare const PROJECT_DOMAIN: string | undefined;
4
+ declare const LICOS_H5_BASE_PATH: string | undefined;
4
5
  declare const LICOS_TARO_ENV: "weapp" | "h5" | "tt" | string | undefined;
5
6
 
6
7
  declare module '*.png';
@@ -28,4 +29,3 @@ declare namespace NodeJS {
28
29
  TARO_APP_ID: string
29
30
  }
30
31
  }
31
-
package/lib/cli.js CHANGED
@@ -2109,7 +2109,7 @@ const EventBuilder = {
2109
2109
  };
2110
2110
 
2111
2111
  var name = "@kmlckj/licos-ai-cli";
2112
- var version = "1.0.24";
2112
+ var version = "1.0.26";
2113
2113
  var description = "LICOS AI coding workspace CLI - project template engine and dev tools";
2114
2114
  var license = "MIT";
2115
2115
  var author = "kmlckj";
@@ -8970,8 +8970,8 @@ const runPnpmInstall = (projectPath) => {
8970
8970
  /**
8971
8971
  * 运行 git 命令的辅助函数
8972
8972
  */
8973
- const runGitCommand = (command, projectPath) => {
8974
- logger.info(`Executing: ${command}`);
8973
+ const runGitCommand = (command, projectPath) => {
8974
+ logger.info(`Executing: ${command}`);
8975
8975
 
8976
8976
  const result = shelljs.exec(command, {
8977
8977
  cwd: projectPath,
@@ -8997,12 +8997,82 @@ const runGitCommand = (command, projectPath) => {
8997
8997
  .join('');
8998
8998
 
8999
8999
  throw new Error(errorMessage);
9000
- }
9001
- };
9002
-
9003
- /**
9004
- * 初始化 git 仓库
9005
- * 如果目录中已存在 .git,则跳过初始化
9000
+ }
9001
+ };
9002
+
9003
+ const runGitCommandArgs = (args, projectPath, options = {}) => {
9004
+ const command = ['git', ...args]
9005
+ .map(arg => (/\s/.test(arg) ? `"${arg}"` : arg))
9006
+ .join(' ');
9007
+ if (options.log !== false) {
9008
+ logger.info(`Executing: ${command}`);
9009
+ }
9010
+
9011
+ const result = child_process.spawnSync('git', args, {
9012
+ cwd: projectPath,
9013
+ encoding: 'utf-8',
9014
+ });
9015
+
9016
+ if (result.stdout) {
9017
+ process.stdout.write(result.stdout);
9018
+ }
9019
+
9020
+ if (result.stderr) {
9021
+ process.stderr.write(result.stderr);
9022
+ }
9023
+
9024
+ if (result.status !== 0) {
9025
+ const errorMessage = [
9026
+ `${command} failed with exit code ${result.status}`,
9027
+ result.stderr ? `\nStderr:\n${result.stderr}` : '',
9028
+ result.stdout ? `\nStdout:\n${result.stdout}` : '',
9029
+ ]
9030
+ .filter(Boolean)
9031
+ .join('');
9032
+
9033
+ throw new Error(errorMessage);
9034
+ }
9035
+
9036
+ return result.stdout ? result.stdout.trim() : '';
9037
+ };
9038
+
9039
+ const readGitConfig = (projectPath, key) => {
9040
+ const result = child_process.spawnSync('git', ['config', '--get', key], {
9041
+ cwd: projectPath,
9042
+ encoding: 'utf-8',
9043
+ });
9044
+ return result.status === 0 && result.stdout ? result.stdout.trim() : '';
9045
+ };
9046
+
9047
+ const ensureGitCommitIdentity = (projectPath) => {
9048
+ const existingName = readGitConfig(projectPath, 'user.name');
9049
+ const existingEmail = readGitConfig(projectPath, 'user.email');
9050
+
9051
+ if (existingName && existingEmail) {
9052
+ return;
9053
+ }
9054
+
9055
+ const fallbackName =
9056
+ process.env.LICOS_GIT_USER_NAME ||
9057
+ process.env.GIT_AUTHOR_NAME ||
9058
+ 'LicOS Agent';
9059
+ const fallbackEmail =
9060
+ process.env.LICOS_GIT_USER_EMAIL ||
9061
+ process.env.GIT_AUTHOR_EMAIL ||
9062
+ 'agent@licos.local';
9063
+
9064
+ logger.info('Configuring local git commit identity...');
9065
+ if (!existingName) {
9066
+ runGitCommandArgs(['config', '--local', 'user.name', fallbackName], projectPath);
9067
+ }
9068
+ if (!existingEmail) {
9069
+ runGitCommandArgs(['config', '--local', 'user.email', fallbackEmail], projectPath);
9070
+ }
9071
+ };
9072
+
9073
+ /**
9074
+ * 初始化 git 仓库
9075
+ * 如果目录中已存在 .git,则跳过初始化
9006
9076
  */
9007
9077
  const runGitInit = (projectPath) => {
9008
9078
  // 检查是否已存在 .git 目录
@@ -9040,11 +9110,12 @@ const commitChanges = (projectPath) => {
9040
9110
  return;
9041
9111
  }
9042
9112
 
9043
- try {
9044
- logger.info('\nCommitting initialized files...');
9045
- runGitCommand('git add --all', projectPath);
9046
- runGitCommand('git commit -m "chore: init env"', projectPath);
9047
- logger.success('Changes committed successfully!');
9113
+ try {
9114
+ logger.info('\nCommitting initialized files...');
9115
+ ensureGitCommitIdentity(projectPath);
9116
+ runGitCommand('git add --all', projectPath);
9117
+ runGitCommand('git commit -m "chore: init env"', projectPath);
9118
+ logger.success('Changes committed successfully!');
9048
9119
  } catch (error) {
9049
9120
  // Commit 失败不应该导致整个流程失败
9050
9121
  const errorMessage = error instanceof Error ? error.message : String(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmlckj/licos-ai-cli",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "LICOS AI coding workspace CLI - project template engine and dev tools",
5
5
  "license": "MIT",
6
6
  "author": "kmlckj",