@coze-arch/cli 0.0.1-alpha.dee5d9 → 0.0.1-alpha.e02657
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/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/pnpm-lock.yaml +293 -176
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +56 -0
- package/lib/__templates__/nextjs/src/app/page.tsx +4 -2
- package/lib/__templates__/nextjs/template.config.js +49 -14
- package/lib/__templates__/taro/.coze +1 -1
- package/lib/__templates__/templates.json +0 -37
- package/lib/__templates__/vite/src/main.ts +2 -2
- package/lib/__templates__/vite/template.config.js +49 -14
- package/lib/cli.js +38 -4
- package/package.json +1 -1
- /package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { resolve, join, basename } from 'path';
|
|
5
|
+
import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
|
|
@@ -45,6 +48,59 @@ const config = {
|
|
|
45
48
|
console.log(` - Framework: Expo`);
|
|
46
49
|
console.log(` - Port: ${context.port}`);
|
|
47
50
|
},
|
|
51
|
+
onComplete: async (_context, outputPath) => {
|
|
52
|
+
// Skip pnpm update in test environment to avoid monorepo workspace issues
|
|
53
|
+
if (process.env.NODE_ENV === 'test') {
|
|
54
|
+
console.log('⊘ Skipping dependency update in test environment');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const cmd = 'pnpm';
|
|
59
|
+
const args = ['-r', 'up', 'coze-coding-dev-sdk@^0.7.0'];
|
|
60
|
+
console.log(
|
|
61
|
+
`\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const projectRoot = resolve(outputPath);
|
|
66
|
+
|
|
67
|
+
// Determine log directory
|
|
68
|
+
const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
|
|
69
|
+
mkdirSync(logDir, { recursive: true });
|
|
70
|
+
|
|
71
|
+
// Use project name in log file to avoid conflicts
|
|
72
|
+
const projectName = basename(projectRoot);
|
|
73
|
+
const logFile = join(logDir, `${projectName}-init.log`);
|
|
74
|
+
|
|
75
|
+
// Write log header
|
|
76
|
+
const timestamp = new Date().toISOString();
|
|
77
|
+
appendFileSync(
|
|
78
|
+
logFile,
|
|
79
|
+
`\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// Open log file for appending
|
|
83
|
+
const logFd = openSync(logFile, 'a');
|
|
84
|
+
|
|
85
|
+
// Spawn in detached mode
|
|
86
|
+
const child = spawn(cmd, args, {
|
|
87
|
+
cwd: projectRoot,
|
|
88
|
+
detached: true,
|
|
89
|
+
stdio: ['ignore', logFd, logFd],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
child.unref();
|
|
93
|
+
closeSync(logFd);
|
|
94
|
+
|
|
95
|
+
console.log(
|
|
96
|
+
'✓ coze-coding-dev-sdk update triggered (running in background)',
|
|
97
|
+
);
|
|
98
|
+
console.log(` Log file: ${logFile}`);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error('✗ Failed to trigger coze-coding-dev-sdk update:', error);
|
|
101
|
+
console.log(' You can manually run: pnpm update coze-coding-dev-sdk');
|
|
102
|
+
}
|
|
103
|
+
},
|
|
48
104
|
};
|
|
49
105
|
|
|
50
106
|
export default config;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Metadata } from 'next';
|
|
2
|
+
import Image from 'next/image';
|
|
2
3
|
|
|
3
4
|
export const metadata: Metadata = {
|
|
4
5
|
title: '扣子编程 - AI 开发伙伴',
|
|
@@ -7,11 +8,12 @@ export const metadata: Metadata = {
|
|
|
7
8
|
|
|
8
9
|
export default function Home() {
|
|
9
10
|
return (
|
|
10
|
-
<div className="flex h-full items-center justify-center bg-background text-foreground transition-colors duration-300 dark:bg-background dark:text-foreground overflow-hidden">
|
|
11
|
+
<div className="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
12
|
{/* 主容器 */}
|
|
12
13
|
<main className="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
|
|
13
14
|
<div className="flex flex-col items-center justify-between gap-4">
|
|
14
|
-
|
|
15
|
+
<Image
|
|
16
|
+
className="dark:invert"
|
|
15
17
|
src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
|
|
16
18
|
alt="扣子编程 Logo"
|
|
17
19
|
width={156}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { resolve } from 'path';
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { resolve, join, basename } from 'path';
|
|
5
|
+
import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
@@ -52,32 +53,66 @@ const config = {
|
|
|
52
53
|
return context;
|
|
53
54
|
},
|
|
54
55
|
|
|
55
|
-
onAfterRender: async (
|
|
56
|
+
onAfterRender: async (_context, outputPath) => {
|
|
56
57
|
console.log(`\nProject created at: ${outputPath}`);
|
|
57
58
|
console.log('\nConfiguration:');
|
|
58
59
|
console.log(' - Framework: Next.js');
|
|
59
60
|
console.log(' - TypeScript: enabled');
|
|
60
61
|
console.log(' - App Router: enabled');
|
|
61
|
-
console.log(` - Port: ${
|
|
62
|
+
console.log(` - Port: ${_context.port}`);
|
|
63
|
+
},
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
onComplete: async (_context, outputPath) => {
|
|
66
|
+
// Skip pnpm update in test environment to avoid monorepo workspace issues
|
|
64
67
|
if (process.env.NODE_ENV === 'test') {
|
|
65
68
|
console.log('⊘ Skipping dependency update in test environment');
|
|
66
69
|
return;
|
|
67
70
|
}
|
|
68
71
|
|
|
69
|
-
const cmd =
|
|
70
|
-
|
|
72
|
+
const cmd = 'pnpm';
|
|
73
|
+
const args = ['update', 'coze-coding-dev-sdk@^0.7.0'];
|
|
74
|
+
console.log(
|
|
75
|
+
`\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
|
|
76
|
+
);
|
|
77
|
+
|
|
71
78
|
try {
|
|
72
79
|
const projectRoot = resolve(outputPath);
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
|
|
81
|
+
// Determine log directory
|
|
82
|
+
const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
|
|
83
|
+
mkdirSync(logDir, { recursive: true });
|
|
84
|
+
|
|
85
|
+
// Use project name in log file to avoid conflicts
|
|
86
|
+
const projectName = basename(projectRoot);
|
|
87
|
+
const logFile = join(logDir, `${projectName}-init.log`);
|
|
88
|
+
|
|
89
|
+
// Write log header
|
|
90
|
+
const timestamp = new Date().toISOString();
|
|
91
|
+
appendFileSync(
|
|
92
|
+
logFile,
|
|
93
|
+
`\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// Open log file for appending
|
|
97
|
+
const logFd = openSync(logFile, 'a');
|
|
98
|
+
|
|
99
|
+
// Spawn in detached mode
|
|
100
|
+
const child = spawn(cmd, args, {
|
|
101
|
+
cwd: projectRoot,
|
|
102
|
+
detached: true,
|
|
103
|
+
stdio: ['ignore', logFd, logFd],
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
child.unref();
|
|
107
|
+
closeSync(logFd);
|
|
108
|
+
|
|
109
|
+
console.log(
|
|
110
|
+
'✓ coze-coding-dev-sdk update triggered (running in background)',
|
|
111
|
+
);
|
|
112
|
+
console.log(` Log file: ${logFile}`);
|
|
78
113
|
} catch (error) {
|
|
79
|
-
console.error('✗ Failed to
|
|
80
|
-
|
|
114
|
+
console.error('✗ Failed to trigger coze-coding-dev-sdk update:', error);
|
|
115
|
+
console.log(' You can manually run: pnpm update coze-coding-dev-sdk');
|
|
81
116
|
}
|
|
82
117
|
},
|
|
83
118
|
};
|
|
@@ -6,7 +6,7 @@ requires = ["nodejs-24"]
|
|
|
6
6
|
build = ["bash", ".cozeproj/scripts/dev_build.sh"]
|
|
7
7
|
run = ["bash", ".cozeproj/scripts/dev_run.sh"]
|
|
8
8
|
deps = ["git"] # -> apt install git
|
|
9
|
-
pack = ["bash", "
|
|
9
|
+
pack = ["bash", ".cozeproj/scripts/pack.sh"]
|
|
10
10
|
|
|
11
11
|
[deploy]
|
|
12
12
|
build = ["bash", ".cozeproj/scripts/deploy_build.sh"]
|
|
@@ -83,43 +83,6 @@
|
|
|
83
83
|
"additionalProperties": false
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
{
|
|
87
|
-
"name": "test-only",
|
|
88
|
-
"description": "Test template showcasing all template hooks and features",
|
|
89
|
-
"location": "./test-only",
|
|
90
|
-
"paramsSchema": {
|
|
91
|
-
"type": "object",
|
|
92
|
-
"properties": {
|
|
93
|
-
"appName": {
|
|
94
|
-
"type": "string",
|
|
95
|
-
"minLength": 1,
|
|
96
|
-
"pattern": "^[a-z0-9-]+$",
|
|
97
|
-
"description": "Application name (lowercase, alphanumeric and hyphens only)"
|
|
98
|
-
},
|
|
99
|
-
"port": {
|
|
100
|
-
"type": "number",
|
|
101
|
-
"default": 5000,
|
|
102
|
-
"minimum": 1024,
|
|
103
|
-
"maximum": 65535,
|
|
104
|
-
"description": "Development server port"
|
|
105
|
-
},
|
|
106
|
-
"includeTests": {
|
|
107
|
-
"type": "boolean",
|
|
108
|
-
"default": true,
|
|
109
|
-
"nullable": true,
|
|
110
|
-
"description": "Include test files"
|
|
111
|
-
},
|
|
112
|
-
"addCopyright": {
|
|
113
|
-
"type": "boolean",
|
|
114
|
-
"default": false,
|
|
115
|
-
"nullable": true,
|
|
116
|
-
"description": "Add copyright header to source files"
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
"required": [],
|
|
120
|
-
"additionalProperties": false
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
86
|
{
|
|
124
87
|
"name": "vite",
|
|
125
88
|
"description": "Vite(简单项目):`coze init ${COZE_WORKSPACE_PATH} --template vite`\n- 适用:轻量级 SPA、纯前端交互、仪表盘等轻量级项目。",
|
|
@@ -7,8 +7,7 @@ export function initApp(): void {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
app.innerHTML = `
|
|
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">
|
|
11
|
-
{/* 主容器 */}
|
|
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">
|
|
12
11
|
<main class="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
|
|
13
12
|
<div class="flex flex-col items-center justify-between gap-4">
|
|
14
13
|
<img
|
|
@@ -16,6 +15,7 @@ export function initApp(): void {
|
|
|
16
15
|
alt="扣子编程 Logo"
|
|
17
16
|
width={156}
|
|
18
17
|
height={130}
|
|
18
|
+
style="width: 156px; height: 130px; object-fit: contain;"
|
|
19
19
|
/>
|
|
20
20
|
<div>
|
|
21
21
|
<div class="flex flex-col items-center gap-2 text-center sm:items-center sm:text-center">
|
|
@@ -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
|
@@ -2011,6 +2011,19 @@ const executeAfterRenderHook = async (
|
|
|
2011
2011
|
}
|
|
2012
2012
|
};
|
|
2013
2013
|
|
|
2014
|
+
/**
|
|
2015
|
+
* 执行完成钩子
|
|
2016
|
+
*/
|
|
2017
|
+
const executeCompleteHook = async (
|
|
2018
|
+
templateConfig,
|
|
2019
|
+
context,
|
|
2020
|
+
outputPath,
|
|
2021
|
+
) => {
|
|
2022
|
+
if (templateConfig.onComplete) {
|
|
2023
|
+
await templateConfig.onComplete(context, outputPath);
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
|
|
2014
2027
|
/**
|
|
2015
2028
|
* 准备输出目录
|
|
2016
2029
|
*/
|
|
@@ -2020,6 +2033,18 @@ const prepareOutputDirectory = (outputPath) => {
|
|
|
2020
2033
|
return absolutePath;
|
|
2021
2034
|
};
|
|
2022
2035
|
|
|
2036
|
+
/**
|
|
2037
|
+
* 模板引擎执行结果
|
|
2038
|
+
*/
|
|
2039
|
+
|
|
2040
|
+
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
|
|
2023
2048
|
/**
|
|
2024
2049
|
* 执行完整的模板渲染流程
|
|
2025
2050
|
*/
|
|
@@ -2056,7 +2081,11 @@ const execute = async (
|
|
|
2056
2081
|
// 7. 执行 onAfterRender 钩子
|
|
2057
2082
|
await executeAfterRenderHook(templateConfig, context, absoluteOutputPath);
|
|
2058
2083
|
|
|
2059
|
-
return
|
|
2084
|
+
return {
|
|
2085
|
+
outputPath: absoluteOutputPath,
|
|
2086
|
+
templateConfig,
|
|
2087
|
+
context,
|
|
2088
|
+
};
|
|
2060
2089
|
};
|
|
2061
2090
|
|
|
2062
2091
|
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
@@ -2219,12 +2248,13 @@ const executeInit = async (
|
|
|
2219
2248
|
logger.info(`Initializing project with template: ${templateName}`);
|
|
2220
2249
|
timer.logPhase('Initialization');
|
|
2221
2250
|
|
|
2222
|
-
//
|
|
2223
|
-
const
|
|
2251
|
+
// 执行模板引擎,返回结果对象
|
|
2252
|
+
const result = await execute({
|
|
2224
2253
|
templateName,
|
|
2225
2254
|
outputPath,
|
|
2226
2255
|
command,
|
|
2227
2256
|
});
|
|
2257
|
+
const { outputPath: absoluteOutputPath, templateConfig, context } = result;
|
|
2228
2258
|
|
|
2229
2259
|
timer.logPhase('Template engine execution');
|
|
2230
2260
|
logger.success('Project created successfully!');
|
|
@@ -2245,6 +2275,10 @@ const executeInit = async (
|
|
|
2245
2275
|
}
|
|
2246
2276
|
}
|
|
2247
2277
|
|
|
2278
|
+
// 执行 onComplete 钩子(在 pnpm install 之后)
|
|
2279
|
+
await executeCompleteHook(templateConfig, context, absoluteOutputPath);
|
|
2280
|
+
timer.logPhase('Complete hook execution');
|
|
2281
|
+
|
|
2248
2282
|
// 如果没有跳过 git,则初始化 git 仓库
|
|
2249
2283
|
if (!skipGit) {
|
|
2250
2284
|
runGitInit(absoluteOutputPath);
|
|
@@ -2597,7 +2631,7 @@ const registerCommand = program => {
|
|
|
2597
2631
|
});
|
|
2598
2632
|
};
|
|
2599
2633
|
|
|
2600
|
-
var version = "0.0.1-alpha.
|
|
2634
|
+
var version = "0.0.1-alpha.e02657";
|
|
2601
2635
|
var packageJson = {
|
|
2602
2636
|
version: version};
|
|
2603
2637
|
|
package/package.json
CHANGED
|
File without changes
|