@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
@@ -40,6 +40,45 @@ fi
40
40
  info "==================== 依赖安装完成!====================\n"
41
41
 
42
42
  info "==================== dist打包 ===================="
43
+ info "开始执行:expo export --platform web (client)"
44
+ rm -rf "$ROOT_DIR/server/public"
45
+ (pushd "$ROOT_DIR/client" > /dev/null && pnpm expo export --platform web --output-dir ../server/public; popd > /dev/null) || error "client web 打包失败"
46
+
47
+ BASE_URL="${BASE_PATH:-/}"
48
+ if [ "${BASE_URL}" != "/" ]; then
49
+ BASE_URL="/$(printf '%s' "${BASE_URL}" | sed 's#^/*##; s#/*$##')/"
50
+ fi
51
+ if [ "${BASE_URL}" != "/" ]; then
52
+ info "重写 Expo Web 静态资源前缀:${BASE_URL}"
53
+ BASE_URL="${BASE_URL}" python3 - <<'PY'
54
+ import os
55
+ from pathlib import Path
56
+
57
+ base = os.environ["BASE_URL"]
58
+ public_dir = Path("server/public")
59
+ replacements = [
60
+ ('"/_expo/', f'"{base}_expo/'),
61
+ ("'/_expo/", f"'{base}_expo/"),
62
+ ('"/assets/', f'"{base}assets/'),
63
+ ("'/assets/", f"'{base}assets/"),
64
+ ('"/favicon.ico"', f'"{base}favicon.ico"'),
65
+ ("'/favicon.ico'", f"'{base}favicon.ico'"),
66
+ ("url(/assets/", f"url({base}assets/"),
67
+ ('url("/assets/', f'url("{base}assets/'),
68
+ ("url('/assets/", f"url('{base}assets/"),
69
+ ]
70
+ for path in public_dir.rglob("*"):
71
+ if path.suffix not in {".html", ".js", ".css"}:
72
+ continue
73
+ text = path.read_text(encoding="utf-8")
74
+ updated = text
75
+ for old, new in replacements:
76
+ updated = updated.replace(old, new)
77
+ if updated != text:
78
+ path.write_text(updated, encoding="utf-8")
79
+ PY
80
+ fi
81
+
43
82
  info "开始执行:pnpm run build (server)"
44
83
  (pushd "$ROOT_DIR/server" > /dev/null && pnpm run build; popd > /dev/null) || error "dist打包失败"
45
84
  info "==================== dist打包完成!====================\n"
@@ -1,5 +1,7 @@
1
1
  import express from "express";
2
2
  import cors from "cors";
3
+ import fs from "fs";
4
+ import path from "path";
3
5
 
4
6
  const app = express();
5
7
  const port = process.env.PORT || 5001;
@@ -14,6 +16,16 @@ app.get('/api/v1/health', (req, res) => {
14
16
  res.status(200).json({ status: 'ok' });
15
17
  });
16
18
 
19
+ const publicDir = path.resolve(process.cwd(), "public");
20
+ if (fs.existsSync(publicDir)) {
21
+ app.use(express.static(publicDir));
22
+ app.get("*", (req, res, next) => {
23
+ if (req.path.startsWith("/api/")) {
24
+ return next();
25
+ }
26
+ res.sendFile(path.join(publicDir, "index.html"));
27
+ });
28
+ }
17
29
 
18
30
  app.listen(port, () => {
19
31
  console.log(`Server listening at http://localhost:${port}/`);
@@ -3,9 +3,9 @@ entrypoint = "index.html"
3
3
  requires = ["python-3.12"]
4
4
 
5
5
  [dev]
6
- build = []
6
+ build = ["sh", "-lc", "true"]
7
7
  run = ["python", "-m", "http.server", "5000", "--bind", "0.0.0.0"]
8
8
 
9
9
  [deploy]
10
- build = []
10
+ build = ["sh", "-lc", "true"]
11
11
  run = ["python", "-m", "http.server", "5000", "--bind", "0.0.0.0"]
@@ -6,8 +6,15 @@ function normalizeBasePath(value?: string): string | undefined {
6
6
  return `/${trimmed.replace(/^\/+|\/+$/g, '')}`;
7
7
  }
8
8
 
9
- const basePath =
10
- process.env.LICOS_PROJECT_ENV === 'PROD' ? normalizeBasePath(process.env.BASE_PATH) : undefined;
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.BASE_PATH;
15
+ const shouldUseBasePath = Boolean(deployBasePath) || isProdProjectEnv(process.env.LICOS_PROJECT_ENV);
16
+
17
+ const basePath = shouldUseBasePath ? normalizeBasePath(deployBasePath) : undefined;
11
18
 
12
19
  const nextConfig: NextConfig = {
13
20
  ...(basePath ? { basePath } : {}),
@@ -2,7 +2,12 @@ import { createServer } from 'http';
2
2
  import { parse } from 'url';
3
3
  import next from 'next';
4
4
 
5
- const dev = process.env.LICOS_PROJECT_ENV !== 'PROD';
5
+ function isProdProjectEnv(value?: string): boolean {
6
+ const normalized = value?.trim().toLowerCase();
7
+ return normalized === 'prod' || normalized === 'production' || normalized === 'release';
8
+ }
9
+
10
+ const dev = !isProdProjectEnv(process.env.LICOS_PROJECT_ENV);
6
11
  const hostname = process.env.HOSTNAME || 'localhost';
7
12
  const port = parseInt(process.env.PORT || '<%= port %>', 10);
8
13
 
@@ -11,18 +11,31 @@ function normalizeBaseURL(value?: string): string {
11
11
  return `/${trimmed.replace(/^\/+|\/+$/g, '')}/`;
12
12
  }
13
13
 
14
+ function isProdProjectEnv(value?: string): boolean {
15
+ const normalized = value?.trim().toLowerCase();
16
+ return normalized === 'prod' || normalized === 'production' || normalized === 'release';
17
+ }
18
+
19
+ const isProd = isProdProjectEnv(process.env.LICOS_PROJECT_ENV);
20
+ const deployBaseURL = process.env.NUXT_PUBLIC_BASE_URL || process.env.BASE_PATH;
21
+ const shouldUseBaseURL = Boolean(deployBaseURL) || isProd;
22
+
23
+ const publicBaseURL = shouldUseBaseURL ? normalizeBaseURL(deployBaseURL) : '/';
24
+
14
25
  export default defineNuxtConfig({
15
26
  compatibilityDate: '2025-07-15',
16
27
  // Disable devtools in CI/test environments (prevents hanging in headless mode)
17
28
  devtools: {
18
- enabled: process.env.CI !== 'true' && process.env.LICOS_PROJECT_ENV !== 'PROD',
29
+ enabled: process.env.CI !== 'true' && !isProd,
19
30
  },
20
31
  telemetry: false,
21
32
 
22
33
  // App head configuration
23
34
  app: {
24
- baseURL:
25
- process.env.LICOS_PROJECT_ENV === 'PROD' ? normalizeBaseURL(process.env.BASE_PATH) : '/',
35
+ // The cluster ingress rewrites /p/{projectId}/... to backend /...
36
+ // Keep Nuxt's server base at / and prefix only generated asset URLs.
37
+ baseURL: '/',
38
+ buildAssetsDir: publicBaseURL === '/' ? '/_nuxt/' : `${publicBaseURL}_nuxt/`,
26
39
  head: {
27
40
  title: '新应用 | LICOS AI',
28
41
  titleTemplate: '%s | LICOS AI',
@@ -63,15 +76,17 @@ export default defineNuxtConfig({
63
76
  },
64
77
 
65
78
  // Nuxt modules
66
- // Skip @nuxt/image in CI (requires sharp binaries not available in headless environments)
67
- modules:
68
- process.env.CI === 'true'
69
- ? ['@nuxtjs/tailwindcss']
70
- : ['@nuxt/image', '@nuxtjs/tailwindcss'],
79
+ modules: ['@nuxt/image', '@nuxtjs/tailwindcss'],
71
80
 
72
81
  // Global CSS
73
82
  css: [resolve(__dirname, 'assets/css/main.css')],
74
83
 
84
+ runtimeConfig: {
85
+ public: {
86
+ baseURL: publicBaseURL,
87
+ },
88
+ },
89
+
75
90
  // Development server configuration
76
91
  devServer: {
77
92
  port: parseInt(process.env.PORT || '<%= port %>', 10),
@@ -115,23 +130,16 @@ export default defineNuxtConfig({
115
130
  },
116
131
  },
117
132
 
118
- // Image optimization (similar to Next.js images config)
119
- // Using @nuxt/image module for image optimization
120
- // https://image.nuxt.com/
121
- // Skip image config in CI (when @nuxt/image module is disabled)
122
- ...(process.env.CI !== 'true' && {
123
- image: {
124
- domains: ['placeholder.local'],
125
- // Remote patterns configuration
126
- remotePatterns: [
127
- {
128
- protocol: 'https',
129
- hostname: 'placeholder.local',
130
- pathname: '/**',
131
- },
132
- ],
133
- },
134
- }),
133
+ image: {
134
+ domains: ['placeholder.local'],
135
+ remotePatterns: [
136
+ {
137
+ protocol: 'https',
138
+ hostname: 'placeholder.local',
139
+ pathname: '/**',
140
+ },
141
+ ],
142
+ },
135
143
 
136
144
  // Security headers (Content Security Policy)
137
145
  nitro: {
@@ -18,20 +18,26 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@kmlckj/licos-platform-sdk": "0.6.3",
21
- "@nuxt/image": "^1.8.1",
22
- "nuxt": "^4.3.1",
23
- "tailwind-merge": "^2.6.0",
24
- "vue": "^3.5.30",
25
- "vue-router": "^4.6.4"
26
- },
27
- "devDependencies": {
28
- "@nuxtjs/tailwindcss": "^6.14.0",
29
- "@types/node": "^20",
30
- "autoprefixer": "^10.4.20",
31
- "postcss": "^8.4.49",
32
- "tailwindcss": "^3.4.17",
33
- "typescript": "^5"
34
- },
21
+ "@nuxt/image": "2.0.0",
22
+ "nuxt": "4.3.1",
23
+ "tailwind-merge": "2.6.0",
24
+ "vue": "3.5.30",
25
+ "vue-router": "4.6.4"
26
+ },
27
+ "devDependencies": {
28
+ "@nuxtjs/tailwindcss": "6.14.0",
29
+ "@types/node": "20.19.25",
30
+ "autoprefixer": "10.4.20",
31
+ "postcss": "8.4.49",
32
+ "tailwindcss": "3.4.17",
33
+ "typescript": "5.9.3"
34
+ },
35
+ "pnpm": {
36
+ "overrides": {
37
+ "ipx": "3.1.1",
38
+ "sharp": "0.34.5"
39
+ }
40
+ },
35
41
  "packageManager": "pnpm@9.0.0",
36
42
  "engines": {
37
43
  "pnpm": ">=9.0.0"