@oj-module/cli 0.2.5 → 0.2.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oj-module/cli",
3
3
  "type": "module",
4
- "version": "0.2.5",
4
+ "version": "0.2.6",
5
5
  "description": "React Antd Admin 模块工程命令行工具(含预构建宿主 shell-dist)",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -49,7 +49,7 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "@faker-js/faker": "^10.4.0",
52
- "@oj-module/runtime": "0.2.5",
52
+ "@oj-module/runtime": "0.2.6",
53
53
  "@redocly/cli": "^2.51.0",
54
54
  "@tailwindcss/vite": "^4.3.0",
55
55
  "esbuild": "^0.28.2",
@@ -256,10 +256,10 @@ function getAppInfo() {
256
256
  return {
257
257
  "pkg": {
258
258
  "name": "@oj-module/runtime",
259
- "version": "0.2.5",
259
+ "version": "0.2.6",
260
260
  "license": "MIT"
261
261
  },
262
- "lastBuildTime": "2026-10-19 10:55:08"
262
+ "lastBuildTime": "2026-10-19 12:08:59"
263
263
  };
264
264
  }
265
265
  var init_get_app_info = __esmMin((() => {}));
@@ -5,9 +5,9 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" href="/favicon.ico" />
7
7
  <title>React Antd Admin · Shell</title>
8
- <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self' https://modules.cdn.example.com 'wasm-unsafe-eval' 'nonce-O1CJWdo1CXHlXEClzw+t4w=='; script-src-attr 'none'; connect-src 'self' data: https://modules.cdn.example.com; style-src 'self' https://modules.cdn.example.com 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; frame-src https://ant.design https://react.dev https://condorheroblog.github.io; form-action 'none'; base-uri 'none'; object-src 'none'; upgrade-insecure-requests" />
8
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self' https://modules.cdn.example.com 'wasm-unsafe-eval' 'nonce-p4BgRegxexzGkBE95NQxKA=='; script-src-attr 'none'; connect-src 'self' data: https://modules.cdn.example.com; style-src 'self' https://modules.cdn.example.com 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; frame-src https://ant.design https://react.dev https://condorheroblog.github.io; form-action 'none'; base-uri 'none'; object-src 'none'; upgrade-insecure-requests" />
9
9
 
10
- <script type="importmap" nonce="O1CJWdo1CXHlXEClzw+t4w==">{
10
+ <script type="importmap" nonce="p4BgRegxexzGkBE95NQxKA==">{
11
11
  "imports": {
12
12
  "react": "/assets/react.js",
13
13
  "react/jsx-runtime": "/assets/jsx-runtime.js",
@@ -7,9 +7,9 @@
7
7
  "react-router": "7.18.2",
8
8
  "react-router/dom": "7.18.2",
9
9
  "@tanstack/react-query": "5.102.8",
10
- "@oj-module/runtime": "0.2.5",
11
- "@oj-module/runtime/contract": "0.2.5",
12
- "@oj-module/runtime/contract/errors": "0.2.5",
10
+ "@oj-module/runtime": "0.2.6",
11
+ "@oj-module/runtime/contract": "0.2.6",
12
+ "@oj-module/runtime/contract/errors": "0.2.6",
13
13
  "@plane/kit": "0.1.20",
14
14
  "@plane/editor": "0.1.20",
15
15
  "antd": "6.6.1",
package/src/init.ts CHANGED
@@ -146,6 +146,13 @@ export async function initProject(destDir: string, opts: InitOptions = {}): Prom
146
146
  // 的「已存在即跳过」会把审批挡在门外(0.1.0 发布实测)——必须合并
147
147
  ensureAllowBuilds(destDir, report);
148
148
 
149
+ // 5c) .gitignore:模板自带一份(模板兼作可运行 demo 用),但 npm/pnpm pack
150
+ // 会剥离 `.gitignore` 点文件(npm-packlist always-exclude,`files` 字段
151
+ // 绕不过),收录进 init.include.yaml 只会让安装包缺文件、readInitInclude
152
+ // fail-fast 把整个 init 打挂(0.2.5 发布实测:目标目录只剩空壳)——
153
+ // 与 pnpm-workspace.yaml 同型,改由 init 现场生成
154
+ ensureGitignore(destDir, report);
155
+
149
156
  console.log(`[ojm] init 完成:${destDir}`);
150
157
  console.log(`[ojm] 新增 ${report.created.length} 项,跳过(已存在)${report.skipped.length} 项`);
151
158
  for (const item of report.skipped)
@@ -360,6 +367,41 @@ function copyIfAbsent(src: string, dest: string, report: InitReport): void {
360
367
  report.created.push(path.relative(process.cwd(), dest) || path.basename(dest));
361
368
  }
362
369
 
370
+ /**
371
+ * 新工程 .gitignore:不存在则生成;已存在则幂等跳过(用户规则永不覆盖)。
372
+ *
373
+ * 内容与 templates/.gitignore 对齐(模板兼作可运行 demo,ignore 的是同一套
374
+ * 现场产物):dev 下载的 bin/oj、sqlite/日志/现场签发的私钥与证书、构建产物。
375
+ * 它不能随模板拷贝——npm/pnpm pack 剥离 `.gitignore`,详见 initProject 5c。
376
+ */
377
+ const SCAFFOLD_GITIGNORE = `# 由 ojm init 生成。
378
+ node_modules/
379
+ bin/
380
+ .ojm-tmp-*
381
+ # 本地 sqlite 与运行日志
382
+ api/db.sqlite
383
+ api/db.sqlite-shm
384
+ api/db.sqlite-wal
385
+ api/logs/
386
+ # 现场签发的开发证书与凭据私钥(ojm dev 缺证时自动签发,见 oj-cert.ts);私钥绝不入仓
387
+ api/config/*.pem
388
+ api/config/cert.jws
389
+ # 构建产物
390
+ api/dist/
391
+ web/dist/
392
+ modules/dist/
393
+ `;
394
+
395
+ function ensureGitignore(destDir: string, report: InitReport): void {
396
+ const gitignorePath = path.join(destDir, ".gitignore");
397
+ if (fs.existsSync(gitignorePath)) {
398
+ report.skipped.push(".gitignore");
399
+ return;
400
+ }
401
+ fs.writeFileSync(gitignorePath, SCAFFOLD_GITIGNORE);
402
+ report.created.push(".gitignore");
403
+ }
404
+
363
405
  /**
364
406
  * 确保工程根 pnpm-workspace.yaml 的 allowBuilds 含 `esbuild: true`。
365
407
  * - 文件不存在(本函数即唯一来源,见下)→ 按 SCAFFOLD_WORKSPACE_YAML 生成
@@ -13,6 +13,13 @@
13
13
  # 共享同一把私钥。
14
14
  # 4. 模板自用元数据——本清单自身。
15
15
  #
16
+ # 另有两类文件「故意不进清单」:package.json / pnpm-workspace.yaml / .gitignore
17
+ # 由 init 现场生成(见 init.ts)。其中 .gitignore 是硬约束:npm/pnpm pack 会
18
+ # 剥离 `.gitignore` 点文件,收录它只会让安装包缺文件、readInitInclude fail-fast
19
+ # 把整个 init 打挂(0.2.5 发布实测);本模板目录自带的 .gitignore 仅供模板自身
20
+ # `pnpm dev` 时忽略产物,不进发布包、也不进用户工程。守卫:
21
+ # tests/cli/release-manifest.test.ts 逐条核对清单条目落在 tarball 内。
22
+ #
16
23
  # 注意 web/src/{demo,home}/__client 不在清单:其 api 模块(api/src/demo、
17
24
  # api/src/home)是 demo-only 不进脚手架,client 生成物留着会指向不存在的端点,
18
25
  # 故 demo/home 只列页面源码(entry/locales/pages),不列整棵模块目录。
@@ -23,7 +30,6 @@ include:
23
30
  - env.d.ts
24
31
  - web.config.ts
25
32
  - openapi.json
26
- - .gitignore
27
33
  - web/src/styles.css
28
34
  # —— api 后端:配置 / 种子 / 测试 / 默认模块 ——
29
35
  - api/config.yaml
@@ -8,9 +8,9 @@
8
8
  "react-router": "7.18.2",
9
9
  "react-router/dom": "7.18.2",
10
10
  "@tanstack/react-query": "5.102.8",
11
- "@oj-module/runtime": "0.2.5",
12
- "@oj-module/runtime/contract": "0.2.5",
13
- "@oj-module/runtime/contract/errors": "0.2.5",
11
+ "@oj-module/runtime": "0.2.6",
12
+ "@oj-module/runtime/contract": "0.2.6",
13
+ "@oj-module/runtime/contract/errors": "0.2.6",
14
14
  "@plane/kit": "0.1.20",
15
15
  "@plane/editor": "0.1.20",
16
16
  "antd": "6.6.1",