@kmlckj/licos-ai-cli 1.0.26 → 1.1.0
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/lib/__templates__/expo/pnpm-lock.yaml +12942 -12942
- package/lib/__templates__/taro/config/index.ts +11 -11
- package/lib/__templates__/taro/src/network.ts +64 -64
- package/lib/__templates__/taro/types/global.d.ts +31 -31
- package/lib/cli.js +83 -85
- package/package.json +1 -1
|
@@ -193,17 +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_H5_BASE_PATH: JSON.stringify(
|
|
203
|
-
deployBasePath.replace(/\/+$/g, ''),
|
|
204
|
-
),
|
|
205
|
-
LICOS_TARO_ENV: JSON.stringify(process.env.TARO_ENV || ''),
|
|
206
|
-
},
|
|
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
|
+
},
|
|
207
207
|
copy: {
|
|
208
208
|
patterns: [],
|
|
209
209
|
options: {},
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 网络请求模块
|
|
5
|
-
* 封装 Taro.request、Taro.uploadFile、Taro.downloadFile,自动添加项目域名前缀
|
|
6
|
-
* 如果请求的 url 以 http:// 或 https:// 开头,则不会添加域名前缀
|
|
7
|
-
*
|
|
8
|
-
* IMPORTANT: 项目已经全局注入 PROJECT_DOMAIN
|
|
9
|
-
* IMPORTANT: 除非你需要添加全局参数,如给所有请求加上 header,否则不能修改此文件
|
|
10
|
-
*/
|
|
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
|
-
|
|
35
|
-
const createUrl = (url: string): string => {
|
|
36
|
-
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
37
|
-
return url
|
|
38
|
-
}
|
|
39
|
-
const path = url.startsWith('/') ? url : `/${url}`
|
|
40
|
-
const base = requestBase()
|
|
41
|
-
return base ? `${base}${path}` : path
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const request: typeof Taro.request = option => {
|
|
45
|
-
return Taro.request({
|
|
46
|
-
...option,
|
|
47
|
-
url: createUrl(option.url),
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const uploadFile: typeof Taro.uploadFile = option => {
|
|
52
|
-
return Taro.uploadFile({
|
|
53
|
-
...option,
|
|
54
|
-
url: createUrl(option.url),
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const downloadFile: typeof Taro.downloadFile = option => {
|
|
59
|
-
return Taro.downloadFile({
|
|
60
|
-
...option,
|
|
61
|
-
url: createUrl(option.url),
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 网络请求模块
|
|
5
|
+
* 封装 Taro.request、Taro.uploadFile、Taro.downloadFile,自动添加项目域名前缀
|
|
6
|
+
* 如果请求的 url 以 http:// 或 https:// 开头,则不会添加域名前缀
|
|
7
|
+
*
|
|
8
|
+
* IMPORTANT: 项目已经全局注入 PROJECT_DOMAIN
|
|
9
|
+
* IMPORTANT: 除非你需要添加全局参数,如给所有请求加上 header,否则不能修改此文件
|
|
10
|
+
*/
|
|
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
|
+
|
|
35
|
+
const createUrl = (url: string): string => {
|
|
36
|
+
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
37
|
+
return url
|
|
38
|
+
}
|
|
39
|
+
const path = url.startsWith('/') ? url : `/${url}`
|
|
40
|
+
const base = requestBase()
|
|
41
|
+
return base ? `${base}${path}` : path
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const request: typeof Taro.request = option => {
|
|
45
|
+
return Taro.request({
|
|
46
|
+
...option,
|
|
47
|
+
url: createUrl(option.url),
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const uploadFile: typeof Taro.uploadFile = option => {
|
|
52
|
+
return Taro.uploadFile({
|
|
53
|
+
...option,
|
|
54
|
+
url: createUrl(option.url),
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const downloadFile: typeof Taro.downloadFile = option => {
|
|
59
|
+
return Taro.downloadFile({
|
|
60
|
+
...option,
|
|
61
|
+
url: createUrl(option.url),
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/// <reference types="@tarojs/taro" />
|
|
2
|
-
|
|
3
|
-
declare const PROJECT_DOMAIN: string | undefined;
|
|
4
|
-
declare const LICOS_H5_BASE_PATH: string | undefined;
|
|
5
|
-
declare const LICOS_TARO_ENV: "weapp" | "h5" | "tt" | string | undefined;
|
|
6
|
-
|
|
7
|
-
declare module '*.png';
|
|
8
|
-
declare module '*.gif';
|
|
9
|
-
declare module '*.jpg';
|
|
10
|
-
declare module '*.jpeg';
|
|
11
|
-
declare module '*.svg';
|
|
12
|
-
declare module '*.css';
|
|
13
|
-
declare module '*.less';
|
|
14
|
-
declare module '*.scss';
|
|
15
|
-
declare module '*.sass';
|
|
16
|
-
declare module '*.styl';
|
|
17
|
-
|
|
18
|
-
declare namespace NodeJS {
|
|
19
|
-
interface ProcessEnv {
|
|
20
|
-
/** NODE 内置环境变量, 会影响到最终构建生成产物 */
|
|
21
|
-
NODE_ENV: 'development' | 'production',
|
|
22
|
-
/** 当前构建的平台 */
|
|
23
|
-
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
|
|
24
|
-
/**
|
|
25
|
-
* 当前构建的小程序 appid
|
|
26
|
-
* @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
|
|
27
|
-
* @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
|
|
28
|
-
*/
|
|
29
|
-
TARO_APP_ID: string
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
/// <reference types="@tarojs/taro" />
|
|
2
|
+
|
|
3
|
+
declare const PROJECT_DOMAIN: string | undefined;
|
|
4
|
+
declare const LICOS_H5_BASE_PATH: string | undefined;
|
|
5
|
+
declare const LICOS_TARO_ENV: "weapp" | "h5" | "tt" | string | undefined;
|
|
6
|
+
|
|
7
|
+
declare module '*.png';
|
|
8
|
+
declare module '*.gif';
|
|
9
|
+
declare module '*.jpg';
|
|
10
|
+
declare module '*.jpeg';
|
|
11
|
+
declare module '*.svg';
|
|
12
|
+
declare module '*.css';
|
|
13
|
+
declare module '*.less';
|
|
14
|
+
declare module '*.scss';
|
|
15
|
+
declare module '*.sass';
|
|
16
|
+
declare module '*.styl';
|
|
17
|
+
|
|
18
|
+
declare namespace NodeJS {
|
|
19
|
+
interface ProcessEnv {
|
|
20
|
+
/** NODE 内置环境变量, 会影响到最终构建生成产物 */
|
|
21
|
+
NODE_ENV: 'development' | 'production',
|
|
22
|
+
/** 当前构建的平台 */
|
|
23
|
+
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
|
|
24
|
+
/**
|
|
25
|
+
* 当前构建的小程序 appid
|
|
26
|
+
* @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
|
|
27
|
+
* @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
|
|
28
|
+
*/
|
|
29
|
+
TARO_APP_ID: string
|
|
30
|
+
}
|
|
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
|
|
2112
|
+
var version = "1.1.0";
|
|
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,82 +8997,80 @@ const runGitCommand = (command, projectPath) => {
|
|
|
8997
8997
|
.join('');
|
|
8998
8998
|
|
|
8999
8999
|
throw new Error(errorMessage);
|
|
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
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
const
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
* 初始化 git 仓库
|
|
9075
|
-
* 如果目录中已存在 .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
|
+
const userId = (process.env.AGENT_USER_ID || process.env.LICOS_USER_ID || '').trim();
|
|
9051
|
+
const desiredName = userId || process.env.LICOS_GIT_USER_NAME || process.env.GIT_AUTHOR_NAME || '';
|
|
9052
|
+
const desiredEmail = userId
|
|
9053
|
+
? `${userId}@aios.licos.com`
|
|
9054
|
+
: process.env.LICOS_GIT_USER_EMAIL || process.env.GIT_AUTHOR_EMAIL || '';
|
|
9055
|
+
const shouldSetName = desiredName && existingName !== desiredName;
|
|
9056
|
+
const shouldSetEmail = desiredEmail && existingEmail !== desiredEmail;
|
|
9057
|
+
|
|
9058
|
+
if (!shouldSetName && !shouldSetEmail) {
|
|
9059
|
+
return;
|
|
9060
|
+
}
|
|
9061
|
+
|
|
9062
|
+
logger.info('Configuring local git commit identity...');
|
|
9063
|
+
if (shouldSetName) {
|
|
9064
|
+
runGitCommandArgs(['config', '--local', 'user.name', desiredName], projectPath);
|
|
9065
|
+
}
|
|
9066
|
+
if (shouldSetEmail) {
|
|
9067
|
+
runGitCommandArgs(['config', '--local', 'user.email', desiredEmail], projectPath);
|
|
9068
|
+
}
|
|
9069
|
+
};
|
|
9070
|
+
|
|
9071
|
+
/**
|
|
9072
|
+
* 初始化 git 仓库
|
|
9073
|
+
* 如果目录中已存在 .git,则跳过初始化
|
|
9076
9074
|
*/
|
|
9077
9075
|
const runGitInit = (projectPath) => {
|
|
9078
9076
|
// 检查是否已存在 .git 目录
|
|
@@ -9110,12 +9108,12 @@ const commitChanges = (projectPath) => {
|
|
|
9110
9108
|
return;
|
|
9111
9109
|
}
|
|
9112
9110
|
|
|
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!');
|
|
9111
|
+
try {
|
|
9112
|
+
logger.info('\nCommitting initialized files...');
|
|
9113
|
+
ensureGitCommitIdentity(projectPath);
|
|
9114
|
+
runGitCommand('git add --all', projectPath);
|
|
9115
|
+
runGitCommand('git commit -m "chore: init env"', projectPath);
|
|
9116
|
+
logger.success('Changes committed successfully!');
|
|
9119
9117
|
} catch (error) {
|
|
9120
9118
|
// Commit 失败不应该导致整个流程失败
|
|
9121
9119
|
const errorMessage = error instanceof Error ? error.message : String(error);
|