@coze-arch/cli 0.0.1-alpha.d85d9d → 0.0.1-alpha.de5a13
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/.cozeproj/scripts/dev_run.sh +13 -12
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
- package/lib/__templates__/expo/client/package.json +35 -35
- package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
- package/lib/__templates__/expo/package.json +1 -1
- package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +3 -2
- package/lib/__templates__/expo/pnpm-lock.yaml +336 -1735
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +56 -0
- package/lib/__templates__/nextjs/.babelrc +0 -3
- package/lib/__templates__/nextjs/package.json +3 -1
- package/lib/__templates__/nextjs/pnpm-lock.yaml +116 -106
- package/lib/__templates__/nextjs/src/app/page.tsx +18 -60
- package/lib/__templates__/nextjs/template.config.js +49 -14
- package/lib/__templates__/taro/.coze +1 -1
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +5 -6
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +6 -8
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -15
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +28 -5
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/config/index.ts +3 -2
- package/lib/__templates__/taro/eslint.config.mjs +57 -0
- package/lib/__templates__/taro/package.json +30 -32
- package/lib/__templates__/taro/pnpm-lock.yaml +466 -679
- package/lib/__templates__/taro/server/package.json +8 -7
- package/lib/__templates__/taro/server/src/main.ts +14 -2
- package/lib/__templates__/taro/src/app.css +29 -18
- package/lib/__templates__/taro/src/app.ts +11 -25
- package/lib/__templates__/taro/src/index.html +20 -1
- package/lib/__templates__/taro/src/pages/index/index.tsx +14 -11
- package/lib/__templates__/taro/src/utils/wx-debug.ts +23 -0
- package/lib/__templates__/vite/package.json +3 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +142 -1659
- package/lib/__templates__/vite/src/main.ts +17 -47
- package/lib/__templates__/vite/template.config.js +49 -14
- package/lib/cli.js +42 -62
- package/package.json +1 -1
- package/lib/__templates__/taro/.eslintrc +0 -40
- package/lib/__templates__/taro/commitlint.config.mjs +0 -1
|
@@ -7,56 +7,26 @@ export function initApp(): void {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
app.innerHTML = `
|
|
10
|
-
<div class="flex
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<!-- 头部:Logo 和 产品名称 -->
|
|
14
|
-
<div class="flex items-center gap-3">
|
|
10
|
+
<div class="flex h-full items-center justify-center bg-background text-foreground transition-colors duration-300 dark:bg-background dark:text-foreground overflow-hidden min-h-screen">
|
|
11
|
+
<main class="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
|
|
12
|
+
<div class="flex flex-col items-center justify-between gap-4">
|
|
15
13
|
<img
|
|
16
|
-
src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/
|
|
14
|
+
src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
|
|
17
15
|
alt="扣子编程 Logo"
|
|
18
|
-
width=
|
|
19
|
-
height=
|
|
20
|
-
style="width:
|
|
16
|
+
width={156}
|
|
17
|
+
height={130}
|
|
18
|
+
style="width: 156px; height: 130px; object-fit: contain;"
|
|
21
19
|
/>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</
|
|
32
|
-
<p class="max-w-2xl text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
|
33
|
-
当前是空白入口文件,项目正在开发中,请稍候...
|
|
34
|
-
<br />
|
|
35
|
-
开发完成后界面将自动更新。如未自动更新成功,可以手动点击右上角刷新或重启按钮查看效果。
|
|
36
|
-
</p>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<!-- 底部按钮区 -->
|
|
40
|
-
<div class="flex w-full flex-col gap-4 text-base font-medium sm:w-auto sm:flex-row">
|
|
41
|
-
<!-- 按钮 1:前往首页 -->
|
|
42
|
-
<a
|
|
43
|
-
class="flex h-12 w-full min-w-[160px] items-center justify-center gap-2 rounded-full bg-black px-8 text-white transition-colors hover:bg-zinc-800 dark:bg-white dark:text-black dark:hover:bg-zinc-200 md:w-auto"
|
|
44
|
-
href="https://code.coze.cn/"
|
|
45
|
-
target="_blank"
|
|
46
|
-
rel="noopener noreferrer"
|
|
47
|
-
>
|
|
48
|
-
前往首页
|
|
49
|
-
</a>
|
|
50
|
-
|
|
51
|
-
<!-- 按钮 2:查看文档 -->
|
|
52
|
-
<a
|
|
53
|
-
class="flex h-12 w-full min-w-[160px] items-center justify-center rounded-full border border-solid border-black/[.08] px-8 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-auto"
|
|
54
|
-
href="https://docs.coze.cn/"
|
|
55
|
-
target="_blank"
|
|
56
|
-
rel="noopener noreferrer"
|
|
57
|
-
>
|
|
58
|
-
查看文档
|
|
59
|
-
</a>
|
|
20
|
+
<div>
|
|
21
|
+
<div class="flex flex-col items-center gap-2 text-center sm:items-center sm:text-center">
|
|
22
|
+
<h1 class="max-w-xl text-base font-semibold leading-tight tracking-tight text-foreground dark:text-foreground">
|
|
23
|
+
应用开发中
|
|
24
|
+
</h1>
|
|
25
|
+
<p class="max-w-2xl text-sm-14 leading-8 text-muted-foreground dark:text-muted-foreground">
|
|
26
|
+
请稍后,页面即将呈现
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
60
30
|
</div>
|
|
61
31
|
</main>
|
|
62
32
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
import { resolve } from 'path';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { resolve, join, basename } from 'path';
|
|
4
|
+
import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -59,32 +60,66 @@ const config = {
|
|
|
59
60
|
return context;
|
|
60
61
|
},
|
|
61
62
|
|
|
62
|
-
onAfterRender: async (
|
|
63
|
+
onAfterRender: async (_context, outputPath) => {
|
|
63
64
|
console.log(`\nProject created at: ${outputPath}`);
|
|
64
65
|
console.log('\nConfiguration:');
|
|
65
66
|
console.log(' - Framework: vite');
|
|
66
67
|
console.log(' - TypeScript: enabled');
|
|
67
68
|
console.log(' - App Router: enabled');
|
|
68
|
-
console.log(` - Port: ${
|
|
69
|
+
console.log(` - Port: ${_context.port}`);
|
|
70
|
+
},
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
onComplete: async (_context, outputPath) => {
|
|
73
|
+
// Skip pnpm update in test environment to avoid monorepo workspace issues
|
|
71
74
|
if (process.env.NODE_ENV === 'test') {
|
|
72
75
|
console.log('⊘ Skipping dependency update in test environment');
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
const cmd =
|
|
77
|
-
|
|
79
|
+
const cmd = 'pnpm';
|
|
80
|
+
const args = ['update', 'coze-coding-dev-sdk@^0.7.0'];
|
|
81
|
+
console.log(
|
|
82
|
+
`\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
|
|
83
|
+
);
|
|
84
|
+
|
|
78
85
|
try {
|
|
79
86
|
const projectRoot = resolve(outputPath);
|
|
80
|
-
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
|
|
88
|
+
// Determine log directory
|
|
89
|
+
const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
|
|
90
|
+
mkdirSync(logDir, { recursive: true });
|
|
91
|
+
|
|
92
|
+
// Use project name in log file to avoid conflicts
|
|
93
|
+
const projectName = basename(projectRoot);
|
|
94
|
+
const logFile = join(logDir, `${projectName}-init.log`);
|
|
95
|
+
|
|
96
|
+
// Write log header
|
|
97
|
+
const timestamp = new Date().toISOString();
|
|
98
|
+
appendFileSync(
|
|
99
|
+
logFile,
|
|
100
|
+
`\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// Open log file for appending
|
|
104
|
+
const logFd = openSync(logFile, 'a');
|
|
105
|
+
|
|
106
|
+
// Spawn in detached mode
|
|
107
|
+
const child = spawn(cmd, args, {
|
|
108
|
+
cwd: projectRoot,
|
|
109
|
+
detached: true,
|
|
110
|
+
stdio: ['ignore', logFd, logFd],
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
child.unref();
|
|
114
|
+
closeSync(logFd);
|
|
115
|
+
|
|
116
|
+
console.log(
|
|
117
|
+
'✓ coze-coding-dev-sdk update triggered (running in background)',
|
|
118
|
+
);
|
|
119
|
+
console.log(` Log file: ${logFile}`);
|
|
85
120
|
} catch (error) {
|
|
86
|
-
console.error('✗ Failed to
|
|
87
|
-
|
|
121
|
+
console.error('✗ Failed to trigger coze-coding-dev-sdk update:', error);
|
|
122
|
+
console.log(' You can manually run: pnpm update coze-coding-dev-sdk');
|
|
88
123
|
}
|
|
89
124
|
},
|
|
90
125
|
};
|
package/lib/cli.js
CHANGED
|
@@ -1511,46 +1511,6 @@ const convertDotfileName = (filePath) => {
|
|
|
1511
1511
|
|
|
1512
1512
|
return filePath;
|
|
1513
1513
|
};
|
|
1514
|
-
|
|
1515
|
-
/**
|
|
1516
|
-
* 复制 node_modules 目录(如果存在)
|
|
1517
|
-
*
|
|
1518
|
-
* @param sourceNodeModules - 源 node_modules 路径
|
|
1519
|
-
* @param targetNodeModules - 目标 node_modules 路径
|
|
1520
|
-
*/
|
|
1521
|
-
const copyNodeModules = (
|
|
1522
|
-
sourceNodeModules,
|
|
1523
|
-
targetNodeModules,
|
|
1524
|
-
) => {
|
|
1525
|
-
if (!fs.existsSync(sourceNodeModules)) {
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
logger.info('\nCopying node_modules from pre-warmed template...');
|
|
1530
|
-
logger.verbose(` From: ${sourceNodeModules}`);
|
|
1531
|
-
logger.verbose(` To: ${targetNodeModules}`);
|
|
1532
|
-
|
|
1533
|
-
const result = shelljs.exec(`cp -R "${sourceNodeModules}" "${targetNodeModules}"`, {
|
|
1534
|
-
silent: true,
|
|
1535
|
-
});
|
|
1536
|
-
|
|
1537
|
-
if (result.stdout) {
|
|
1538
|
-
process.stdout.write(result.stdout);
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
if (result.stderr) {
|
|
1542
|
-
process.stderr.write(result.stderr);
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
if (result.code === 0) {
|
|
1546
|
-
logger.success('✓ node_modules copied successfully');
|
|
1547
|
-
} else {
|
|
1548
|
-
logger.warn(
|
|
1549
|
-
`Failed to copy node_modules: ${result.stderr || 'unknown error'}`,
|
|
1550
|
-
);
|
|
1551
|
-
logger.info('Will need to run pnpm install manually');
|
|
1552
|
-
}
|
|
1553
|
-
};
|
|
1554
1514
|
// end_aigc
|
|
1555
1515
|
|
|
1556
1516
|
// ABOUTME: File rendering utilities for template processing
|
|
@@ -1925,11 +1885,7 @@ const processTemplateFiles = async (options
|
|
|
1925
1885
|
|
|
1926
1886
|
logger.verbose('✓ All files processed successfully');
|
|
1927
1887
|
|
|
1928
|
-
//
|
|
1929
|
-
const sourceNodeModules = path.join(templatePath, 'node_modules');
|
|
1930
|
-
const targetNodeModules = path.join(outputPath, 'node_modules');
|
|
1931
|
-
|
|
1932
|
-
copyNodeModules(sourceNodeModules, targetNodeModules);
|
|
1888
|
+
// node_modules 将由 pnpm install 处理(利用缓存和硬链接机制)
|
|
1933
1889
|
};
|
|
1934
1890
|
// end_aigc
|
|
1935
1891
|
|
|
@@ -2011,6 +1967,19 @@ const executeAfterRenderHook = async (
|
|
|
2011
1967
|
}
|
|
2012
1968
|
};
|
|
2013
1969
|
|
|
1970
|
+
/**
|
|
1971
|
+
* 执行完成钩子
|
|
1972
|
+
*/
|
|
1973
|
+
const executeCompleteHook = async (
|
|
1974
|
+
templateConfig,
|
|
1975
|
+
context,
|
|
1976
|
+
outputPath,
|
|
1977
|
+
) => {
|
|
1978
|
+
if (templateConfig.onComplete) {
|
|
1979
|
+
await templateConfig.onComplete(context, outputPath);
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1982
|
+
|
|
2014
1983
|
/**
|
|
2015
1984
|
* 准备输出目录
|
|
2016
1985
|
*/
|
|
@@ -2020,6 +1989,18 @@ const prepareOutputDirectory = (outputPath) => {
|
|
|
2020
1989
|
return absolutePath;
|
|
2021
1990
|
};
|
|
2022
1991
|
|
|
1992
|
+
/**
|
|
1993
|
+
* 模板引擎执行结果
|
|
1994
|
+
*/
|
|
1995
|
+
|
|
1996
|
+
|
|
1997
|
+
|
|
1998
|
+
|
|
1999
|
+
|
|
2000
|
+
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
|
+
|
|
2023
2004
|
/**
|
|
2024
2005
|
* 执行完整的模板渲染流程
|
|
2025
2006
|
*/
|
|
@@ -2056,7 +2037,11 @@ const execute = async (
|
|
|
2056
2037
|
// 7. 执行 onAfterRender 钩子
|
|
2057
2038
|
await executeAfterRenderHook(templateConfig, context, absoluteOutputPath);
|
|
2058
2039
|
|
|
2059
|
-
return
|
|
2040
|
+
return {
|
|
2041
|
+
outputPath: absoluteOutputPath,
|
|
2042
|
+
templateConfig,
|
|
2043
|
+
context,
|
|
2044
|
+
};
|
|
2060
2045
|
};
|
|
2061
2046
|
|
|
2062
2047
|
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
@@ -2219,32 +2204,27 @@ const executeInit = async (
|
|
|
2219
2204
|
logger.info(`Initializing project with template: ${templateName}`);
|
|
2220
2205
|
timer.logPhase('Initialization');
|
|
2221
2206
|
|
|
2222
|
-
//
|
|
2223
|
-
const
|
|
2207
|
+
// 执行模板引擎,返回结果对象
|
|
2208
|
+
const result = await execute({
|
|
2224
2209
|
templateName,
|
|
2225
2210
|
outputPath,
|
|
2226
2211
|
command,
|
|
2227
2212
|
});
|
|
2213
|
+
const { outputPath: absoluteOutputPath, templateConfig, context } = result;
|
|
2228
2214
|
|
|
2229
2215
|
timer.logPhase('Template engine execution');
|
|
2230
2216
|
logger.success('Project created successfully!');
|
|
2231
2217
|
|
|
2232
|
-
//
|
|
2218
|
+
// 安装依赖(始终使用 pnpm install,利用缓存机制)
|
|
2233
2219
|
if (!skipInstall) {
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
if (hasNodeModules) {
|
|
2238
|
-
logger.info(
|
|
2239
|
-
'\n💡 Using pre-warmed node_modules, skipping pnpm install',
|
|
2240
|
-
);
|
|
2241
|
-
timer.logPhase('Node modules (pre-warmed)');
|
|
2242
|
-
} else {
|
|
2243
|
-
runPnpmInstall(absoluteOutputPath);
|
|
2244
|
-
timer.logPhase('Dependencies installation');
|
|
2245
|
-
}
|
|
2220
|
+
runPnpmInstall(absoluteOutputPath);
|
|
2221
|
+
timer.logPhase('Dependencies installation');
|
|
2246
2222
|
}
|
|
2247
2223
|
|
|
2224
|
+
// 执行 onComplete 钩子(在 pnpm install 之后)
|
|
2225
|
+
await executeCompleteHook(templateConfig, context, absoluteOutputPath);
|
|
2226
|
+
timer.logPhase('Complete hook execution');
|
|
2227
|
+
|
|
2248
2228
|
// 如果没有跳过 git,则初始化 git 仓库
|
|
2249
2229
|
if (!skipGit) {
|
|
2250
2230
|
runGitInit(absoluteOutputPath);
|
|
@@ -2597,7 +2577,7 @@ const registerCommand = program => {
|
|
|
2597
2577
|
});
|
|
2598
2578
|
};
|
|
2599
2579
|
|
|
2600
|
-
var version = "0.0.1-alpha.
|
|
2580
|
+
var version = "0.0.1-alpha.de5a13";
|
|
2601
2581
|
var packageJson = {
|
|
2602
2582
|
version: version};
|
|
2603
2583
|
|
package/package.json
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["taro/react"],
|
|
3
|
-
"rules": {
|
|
4
|
-
"react/jsx-uses-react": "off",
|
|
5
|
-
"react/react-in-jsx-scope": "off"
|
|
6
|
-
},
|
|
7
|
-
"overrides": [
|
|
8
|
-
{
|
|
9
|
-
"files": ["src/**/*.{js,jsx,ts,tsx}"],
|
|
10
|
-
"excludedFiles": ["src/network.ts"],
|
|
11
|
-
"rules": {
|
|
12
|
-
"no-restricted-syntax": [
|
|
13
|
-
"error",
|
|
14
|
-
{
|
|
15
|
-
"selector": "MemberExpression[object.name='process'][property.name='env']",
|
|
16
|
-
"message": "请勿在 src 目录下直接使用 process.env\n如需获取 URL 请求前缀,请使用已经注入全局的 PROJECT_DOMAIN()"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"no-restricted-properties": [
|
|
20
|
-
"error",
|
|
21
|
-
{
|
|
22
|
-
"object": "Taro",
|
|
23
|
-
"property": "request",
|
|
24
|
-
"message": "请使用 Network.request 替代 Taro.request"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"object": "Taro",
|
|
28
|
-
"property": "uploadFile",
|
|
29
|
-
"message": "请使用 Network.uploadFile 替代 Taro.uploadFile"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"object": "Taro",
|
|
33
|
-
"property": "downloadFile",
|
|
34
|
-
"message": "请使用 Network.downloadFile 替代 Taro.downloadFile"
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default { extends: ["@commitlint/config-conventional"] };
|