@kmlckj/licos-ai-cli 1.0.20 → 1.0.22

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.
@@ -1,123 +1,123 @@
1
-
2
-
3
- import { spawn } from 'child_process';
4
- import { resolve, join, basename, dirname } from 'path';
5
- import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
6
- import { fileURLToPath } from 'url';
7
-
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
-
11
-
12
-
13
-
14
-
15
-
16
- const description = `Next.js(复杂项目):\`licos init \${LICOS_PROJECT_PATH} --template nextjs\`
17
- - 适用:全栈应用、复杂多页面等复杂项目
18
- - 使用默认nextjs项目规范
19
- - **目录规范**: 默认开启src目录(打开--src-dir选项):项目文件(如 app 目录、pages 目录、components 等)初始化到 src/ 目录下。
20
- - **项目理解加速**:初始可以依赖项目下 \`package.json\` 文件理解项目类型,如果没有或无法理解退化成阅读其他文件。
21
- - **UI设计与组件规范**:Next.js项目**必须默认**采用 shadcn/ui 风格和规范,\`shadcn/ui\`组件默认完整的预装在\`src/components/ui/\`目录下`;
22
-
23
- export const paramsSchema = {
24
- type: 'object',
25
- properties: {
26
- appName: {
27
- type: 'string',
28
- minLength: 1,
29
- pattern: '^[a-z0-9-]+$',
30
- description:
31
- 'Application name (lowercase, alphanumeric and hyphens only)',
32
- },
33
- port: {
34
- type: 'number',
35
- default: 5000,
36
- minimum: 1024,
37
- maximum: 65535,
38
- description: 'Development server port (for Next.js dev server)',
39
- },
40
- },
41
- required: [],
42
- additionalProperties: false,
43
- };
44
-
45
- const config = {
46
- description: description,
47
- paramsSchema,
48
-
49
- // 显式定义默认参数,确保在渲染时可用
50
- defaultParams: {
51
- port: 5000,
52
- appName: 'projects',
53
- },
54
-
55
- onBeforeRender: async context => {
56
- console.log(`Creating Next.js project: ${context.appName}`);
57
- return context;
58
- },
59
-
60
- onAfterRender: async (_context, outputPath) => {
61
- console.log(`\nProject created at: ${outputPath}`);
62
- console.log('\nConfiguration:');
63
- console.log(' - Framework: Next.js');
64
- console.log(' - TypeScript: enabled');
65
- console.log(' - App Router: enabled');
66
- console.log(` - Port: ${_context.port}`);
67
- },
68
-
69
- onComplete: async (_context, outputPath) => {
70
- if (process.env.NODE_ENV === 'test') {
71
- console.log('⊘ Skipping dependency install in test environment');
72
- return;
73
- }
74
- if (_context.options?.skipInstall) {
75
- console.log('⊘ Skipping dependency install because --skip-install was provided');
76
- return;
77
- }
78
-
79
- const cmd = 'bash';
80
- const args = [
81
- '-lc',
82
- 'pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline --reporter=append-only || pnpm install --registry=https://registry.npmjs.org --no-frozen-lockfile --reporter=append-only',
83
- ];
84
- console.log(
85
- `\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
86
- );
87
-
88
- try {
89
- const projectRoot = resolve(outputPath);
90
-
91
- const logDir = process.env.LICOS_LOG_DIR || resolve(__dirname, '../.log');
92
- mkdirSync(logDir, { recursive: true });
93
-
94
- const projectName = basename(projectRoot);
95
- const logFile = join(logDir, `${projectName}-init.log`);
96
-
97
- const timestamp = new Date().toISOString();
98
- appendFileSync(
99
- logFile,
100
- `\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
101
- );
102
-
103
- const logFd = openSync(logFile, 'a');
104
-
105
- const child = spawn(cmd, args, {
106
- cwd: projectRoot,
107
- detached: true,
108
- stdio: ['ignore', logFd, logFd],
109
- });
110
-
111
- child.unref();
112
- closeSync(logFd);
113
-
114
- console.log('✓ pnpm install triggered (running in background)');
115
- console.log(` Log file: ${logFile}`);
116
- } catch (error) {
117
- console.error('✗ Failed to trigger pnpm install:', error);
118
- console.log(' You can manually run: pnpm install --registry=https://registry.npmmirror.com || pnpm install --registry=https://registry.npmjs.org --no-frozen-lockfile');
119
- }
120
- },
121
- };
122
-
123
- export default config;
1
+
2
+
3
+ import { spawn } from 'child_process';
4
+ import { resolve, join, basename, dirname } from 'path';
5
+ import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+
12
+
13
+
14
+
15
+
16
+ const description = `Next.js(复杂项目):\`licos init \${LICOS_PROJECT_PATH} --template nextjs\`
17
+ - 适用:全栈应用、复杂多页面等复杂项目
18
+ - 使用默认nextjs项目规范
19
+ - **目录规范**: 默认开启src目录(打开--src-dir选项):项目文件(如 app 目录、pages 目录、components 等)初始化到 src/ 目录下。
20
+ - **项目理解加速**:初始可以依赖项目下 \`package.json\` 文件理解项目类型,如果没有或无法理解退化成阅读其他文件。
21
+ - **UI设计与组件规范**:Next.js项目**必须默认**采用 shadcn/ui 风格和规范,\`shadcn/ui\`组件默认完整的预装在\`src/components/ui/\`目录下`;
22
+
23
+ export const paramsSchema = {
24
+ type: 'object',
25
+ properties: {
26
+ appName: {
27
+ type: 'string',
28
+ minLength: 1,
29
+ pattern: '^[a-z0-9-]+$',
30
+ description:
31
+ 'Application name (lowercase, alphanumeric and hyphens only)',
32
+ },
33
+ port: {
34
+ type: 'number',
35
+ default: 5000,
36
+ minimum: 1024,
37
+ maximum: 65535,
38
+ description: 'Development server port (for Next.js dev server)',
39
+ },
40
+ },
41
+ required: [],
42
+ additionalProperties: false,
43
+ };
44
+
45
+ const config = {
46
+ description: description,
47
+ paramsSchema,
48
+
49
+ // 显式定义默认参数,确保在渲染时可用
50
+ defaultParams: {
51
+ port: 5000,
52
+ appName: 'projects',
53
+ },
54
+
55
+ onBeforeRender: async context => {
56
+ console.log(`Creating Next.js project: ${context.appName}`);
57
+ return context;
58
+ },
59
+
60
+ onAfterRender: async (_context, outputPath) => {
61
+ console.log(`\nProject created at: ${outputPath}`);
62
+ console.log('\nConfiguration:');
63
+ console.log(' - Framework: Next.js');
64
+ console.log(' - TypeScript: enabled');
65
+ console.log(' - App Router: enabled');
66
+ console.log(` - Port: ${_context.port}`);
67
+ },
68
+
69
+ onComplete: async (_context, outputPath) => {
70
+ if (process.env.NODE_ENV === 'test') {
71
+ console.log('⊘ Skipping dependency install in test environment');
72
+ return;
73
+ }
74
+ if (_context.options?.skipInstall) {
75
+ console.log('⊘ Skipping dependency install because --skip-install was provided');
76
+ return;
77
+ }
78
+
79
+ const cmd = 'bash';
80
+ const args = [
81
+ '-lc',
82
+ 'pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline --reporter=append-only || pnpm install --registry=https://registry.npmjs.org --no-frozen-lockfile --reporter=append-only',
83
+ ];
84
+ console.log(
85
+ `\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
86
+ );
87
+
88
+ try {
89
+ const projectRoot = resolve(outputPath);
90
+
91
+ const logDir = process.env.LICOS_LOG_DIR || resolve(__dirname, '../.log');
92
+ mkdirSync(logDir, { recursive: true });
93
+
94
+ const projectName = basename(projectRoot);
95
+ const logFile = join(logDir, `${projectName}-init.log`);
96
+
97
+ const timestamp = new Date().toISOString();
98
+ appendFileSync(
99
+ logFile,
100
+ `\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
101
+ );
102
+
103
+ const logFd = openSync(logFile, 'a');
104
+
105
+ const child = spawn(cmd, args, {
106
+ cwd: projectRoot,
107
+ detached: true,
108
+ stdio: ['ignore', logFd, logFd],
109
+ });
110
+
111
+ child.unref();
112
+ closeSync(logFd);
113
+
114
+ console.log('✓ pnpm install triggered (running in background)');
115
+ console.log(` Log file: ${logFile}`);
116
+ } catch (error) {
117
+ console.error('✗ Failed to trigger pnpm install:', error);
118
+ console.log(' You can manually run: pnpm install --registry=https://registry.npmmirror.com || pnpm install --registry=https://registry.npmjs.org --no-frozen-lockfile');
119
+ }
120
+ },
121
+ };
122
+
123
+ export default config;
@@ -6,7 +6,7 @@
6
6
  "scripts": {
7
7
  "build": "bash ./scripts/build.sh",
8
8
  "dev": "bash ./scripts/dev.sh",
9
- "ensure:deps": "node -e \"const fs=require('fs'); const bins=['node_modules/.bin/nuxt']; 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 || pnpm install --registry=https://registry.npmjs.org --no-frozen-lockfile --reporter=append-only",
9
+ "ensure:deps": "node -e \"const fs=require('fs'); const bins=['node_modules/.bin/nuxt']; 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 || pnpm install --registry=https://registry.npmjs.org --no-frozen-lockfile --reporter=append-only",
10
10
  "generate": "nuxt generate",
11
11
  "prebuild": "pnpm run ensure:deps",
12
12
  "predev": "pnpm run ensure:deps",