@kmlckj/licos-ai-cli 0.0.32 → 0.0.35

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.
Files changed (28) hide show
  1. package/lib/__templates__/expo/.licosproj/scripts/prod_build.sh +39 -0
  2. package/lib/__templates__/expo/server/src/index.ts +12 -0
  3. package/lib/__templates__/native-static/.licos +2 -2
  4. package/lib/__templates__/nextjs/next.config.ts +9 -2
  5. package/lib/__templates__/nextjs/src/server.ts +6 -1
  6. package/lib/__templates__/nuxt-vue/nuxt.config.ts +33 -25
  7. package/lib/__templates__/nuxt-vue/package.json +20 -14
  8. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +451 -460
  9. package/lib/__templates__/nuxt-vue/scripts/build.sh +10 -0
  10. package/lib/__templates__/nuxt-vue/scripts/start.sh +10 -0
  11. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +2 -1
  12. package/lib/__templates__/taro/.licosproj/scripts/deploy_run.sh +1 -1
  13. package/lib/__templates__/taro/AGENTS.md +37 -0
  14. package/lib/__templates__/taro/README.md +4 -3
  15. package/lib/__templates__/taro/config/index.ts +1 -1
  16. package/lib/__templates__/taro/eslint.config.mjs +1 -1
  17. package/lib/__templates__/taro/package.json +2 -1
  18. package/lib/__templates__/taro/pnpm-lock.yaml +42 -1978
  19. package/lib/__templates__/taro/server/package.json +3 -12
  20. package/lib/__templates__/taro/server/src/main.ts +17 -0
  21. package/lib/__templates__/taro/src/presets/env.ts +1 -1
  22. package/lib/__templates__/taro/types/global.d.ts +1 -2
  23. package/lib/__templates__/vite/scripts/build.sh +1 -0
  24. package/lib/__templates__/vite/server/server.ts +6 -1
  25. package/lib/__templates__/vite/server/vite.ts +11 -3
  26. package/lib/__templates__/vite/vite.config.ts +9 -1
  27. package/lib/cli.js +20 -1
  28. package/package.json +1 -1
@@ -12,28 +12,19 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@kmlckj/licos-platform-sdk": "0.6.3",
15
- "@aws-sdk/client-s3": "^3.958.0",
16
- "@aws-sdk/lib-storage": "^3.958.0",
17
15
  "@nestjs/common": "^10.4.15",
18
16
  "@nestjs/core": "^10.4.15",
19
17
  "@nestjs/platform-express": "^10.4.15",
20
- "better-sqlite3": "^11.9.1",
21
18
  "dotenv": "^17.2.3",
22
- "drizzle-kit": "^0.31.8",
23
- "drizzle-orm": "^0.45.1",
24
- "drizzle-zod": "^0.8.3",
25
- "express": "5.2.1",
26
- "pg": "^8.16.3",
19
+ "express": "5.2.1",
27
20
  "rxjs": "^7.8.1",
28
21
  "zod": "^4.3.5"
29
22
  },
30
23
  "devDependencies": {
31
24
  "@nestjs/cli": "^10.4.9",
32
25
  "@nestjs/schematics": "^10.2.3",
33
- "@types/better-sqlite3": "^7.6.13",
34
- "@types/express": "5.0.6",
35
- "@types/node": "^22.10.2",
36
- "drizzle-kit": "^0.31.8",
26
+ "@types/express": "5.0.6",
27
+ "@types/node": "^22.10.2",
37
28
  "typescript": "^5.7.2"
38
29
  }
39
30
  }
@@ -1,6 +1,8 @@
1
1
  import { NestFactory } from '@nestjs/core';
2
2
  import { AppModule } from '@/app.module';
3
3
  import * as express from 'express';
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
4
6
  import { HttpStatusInterceptor } from '@/interceptors/http-status.interceptor';
5
7
 
6
8
  function parsePort(): number {
@@ -26,6 +28,21 @@ async function bootstrap() {
26
28
  app.use(express.json({ limit: '50mb' }));
27
29
  app.use(express.urlencoded({ limit: '50mb', extended: true }));
28
30
 
31
+ const staticDir = path.resolve(__dirname, '../../dist-web');
32
+ const indexHtml = path.join(staticDir, 'index.html');
33
+ if (fs.existsSync(indexHtml)) {
34
+ app.use(express.static(staticDir));
35
+ app.use((req, res, next) => {
36
+ if (req.path.startsWith('/api')) {
37
+ return next();
38
+ }
39
+ if (req.method === 'GET' && req.accepts('html')) {
40
+ return res.sendFile(indexHtml);
41
+ }
42
+ return next();
43
+ });
44
+ }
45
+
29
46
  // 全局拦截器:统一将 POST 请求的 201 状态码改为 200
30
47
  app.useGlobalInterceptors(new HttpStatusInterceptor());
31
48
  // 1. 开启优雅关闭 Hooks (关键!)
@@ -1 +1 @@
1
- export const IS_H5_ENV = TARO_ENV === 'h5';
1
+ export const IS_H5_ENV = LICOS_TARO_ENV === 'h5';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="@tarojs/taro" />
2
2
 
3
3
  declare const PROJECT_DOMAIN: string | undefined;
4
- declare const TARO_ENV: "weapp" | "h5" | undefined;
4
+ declare const LICOS_TARO_ENV: "weapp" | "h5" | "tt" | string | undefined;
5
5
 
6
6
  declare module '*.png';
7
7
  declare module '*.gif';
@@ -29,4 +29,3 @@ declare namespace NodeJS {
29
29
  }
30
30
  }
31
31
 
32
-
@@ -9,6 +9,7 @@ echo "Installing dependencies..."
9
9
  pnpm install --registry=https://registry.npmmirror.com --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
10
10
 
11
11
  echo "Building frontend with Vite..."
12
+ export VITE_BASE_PATH="${VITE_BASE_PATH:-${BASE_PATH:-/}}"
12
13
  pnpm vite build
13
14
 
14
15
  echo "Bundling server with tsup..."
@@ -6,7 +6,12 @@ import express from 'express';
6
6
  import router from './routes/index';
7
7
  import { setupVite } from './vite';
8
8
 
9
- const isDev = process.env.LICOS_PROJECT_ENV !== 'PROD';
9
+ function isProdProjectEnv(value?: string): boolean {
10
+ const normalized = value?.trim().toLowerCase();
11
+ return normalized === 'prod' || normalized === 'production' || normalized === 'release';
12
+ }
13
+
14
+ const isDev = !isProdProjectEnv(process.env.LICOS_PROJECT_ENV);
10
15
  const port = parseInt(process.env.PORT || '<%= port %>', 10);
11
16
  const hostname = process.env.HOSTNAME || 'localhost';
12
17
  const app = express();
@@ -5,15 +5,23 @@ import type { Application, Request, Response } from 'express';
5
5
  import express from 'express';
6
6
  import path from 'path';
7
7
  import fs from 'fs';
8
- import { createServer as createViteServer } from 'vite';
9
- import viteConfig from '../vite.config';
10
8
 
11
- const isDev = process.env.LICOS_PROJECT_ENV !== 'PROD';
9
+ function isProdProjectEnv(value?: string): boolean {
10
+ const normalized = value?.trim().toLowerCase();
11
+ return normalized === 'prod' || normalized === 'production' || normalized === 'release';
12
+ }
13
+
14
+ const isDev = !isProdProjectEnv(process.env.LICOS_PROJECT_ENV);
12
15
 
13
16
  /**
14
17
  * 集成 Vite 开发服务器(中间件模式)
15
18
  */
16
19
  export async function setupViteMiddleware(app: Application) {
20
+ const [{ createServer: createViteServer }, { default: viteConfig }] = await Promise.all([
21
+ import('vite'),
22
+ import('../vite.config'),
23
+ ]);
24
+
17
25
  const vite = await createViteServer({
18
26
  ...viteConfig,
19
27
  server: {
@@ -6,8 +6,16 @@ function normalizeBasePath(value?: string): string {
6
6
  return `/${trimmed.replace(/^\/+|\/+$/g, '')}/`;
7
7
  }
8
8
 
9
+ function isProdProjectEnv(value?: string): boolean {
10
+ const normalized = value?.trim().toLowerCase();
11
+ return normalized === 'prod' || normalized === 'production' || normalized === 'release';
12
+ }
13
+
14
+ const deployBasePath = process.env.VITE_BASE_PATH || process.env.BASE_PATH;
15
+ const shouldUseBasePath = Boolean(deployBasePath) || isProdProjectEnv(process.env.LICOS_PROJECT_ENV);
16
+
9
17
  export default defineConfig({
10
- base: process.env.LICOS_PROJECT_ENV === 'PROD' ? normalizeBasePath(process.env.BASE_PATH) : '/',
18
+ base: shouldUseBasePath ? normalizeBasePath(deployBasePath) : '/',
11
19
  server: {
12
20
  port: <%= port %>,
13
21
  host: '0.0.0.0',
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 = "0.0.32";
2112
+ var version = "0.0.35";
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";
@@ -5940,6 +5940,10 @@ const getCommandConfig = (
5940
5940
  throw new Error(`Unknown command: ${commandName}`);
5941
5941
  }
5942
5942
 
5943
+ if (commandName === 'build' && Array.isArray(commandConfig)) {
5944
+ return commandConfig;
5945
+ }
5946
+
5943
5947
  if (!commandConfig || commandConfig.length === 0) {
5944
5948
  throw new Error(
5945
5949
  `Command '${commandName}' is not configured in .licos file.\n` +
@@ -7003,6 +7007,21 @@ const executeRun = async (
7003
7007
  const config = await loadLicosConfig();
7004
7008
  const commandArgs = getCommandConfig(config, commandName);
7005
7009
 
7010
+ if (commandName === 'build' && commandArgs.length === 0) {
7011
+ const buildDuration = Date.now() - buildStartTime;
7012
+ logger.info('Build command is empty; skipping build step');
7013
+ reportCommandComplete(commandName, true, Date.now() - cmdStartTime, {
7014
+ args: JSON.stringify(options),
7015
+ categories: {
7016
+ fixDuration: String(fixDuration),
7017
+ buildDuration: String(buildDuration),
7018
+ exitCode: '0',
7019
+ projectType,
7020
+ },
7021
+ });
7022
+ return;
7023
+ }
7024
+
7006
7025
  // 3. 准备日志
7007
7026
  const logFilePath = resolveLogFilePath(options.logFile);
7008
7027
  const logStream = createLogStream(logFilePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmlckj/licos-ai-cli",
3
- "version": "0.0.32",
3
+ "version": "0.0.35",
4
4
  "description": "LICOS AI coding workspace CLI - project template engine and dev tools",
5
5
  "license": "MIT",
6
6
  "author": "kmlckj",