create-swdg-frontend 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -1,14 +1,17 @@
1
1
  # create-swdg-frontend
2
2
 
3
- 从 SWDG 模板生成新项目。npm 包名 **`create-swdg-frontend`**,对应命令:
3
+ 从 SWDG 模板生成新项目。
4
+
5
+ **官方命令:**
4
6
 
5
7
  ```bash
6
8
  pnpm create swdg-frontend my-app
7
- # 或
8
- pnpm dlx create-swdg-frontend my-app
9
9
  ```
10
10
 
11
- > `pnpm create swdg` 会去找包 `create-swdg`(与本包无关),请使用上面的 `swdg-frontend`。
11
+ | | |
12
+ |---|---|
13
+ | ✅ | `pnpm create swdg-frontend` / `pnpm dlx create-swdg-frontend` |
14
+ | ❌ | `pnpm create swdg`(会解析为不存在的 npm 包 `create-swdg`) |
12
15
 
13
16
  ### 常用参数
14
17
 
package/lib/constants.js CHANGED
@@ -6,7 +6,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
6
  export const PACKAGE_ROOT = path.resolve(__dirname, '..');
7
7
  export const TEMPLATE_DIR = path.join(PACKAGE_ROOT, 'template');
8
8
  export const STUBS_DIR = path.join(PACKAGE_ROOT, 'stubs');
9
- export const SCAFFOLD_VERSION = '0.2.1';
9
+ export const SCAFFOLD_VERSION = '0.2.2';
10
10
 
11
11
  /** 可选特性:重型依赖默认关闭,创建时 opt-in */
12
12
  export const FEATURES = {
package/lib/gis.js CHANGED
@@ -86,6 +86,8 @@ export async function removeGisIntegration(destDir) {
86
86
  await removePathIfExists(destDir, relativePath);
87
87
  }
88
88
  await patchPackageWithoutGis(destDir);
89
+ // package.json 已去掉 cesium 等依赖,旧 lockfile 会导致 pnpm frozen install 失败
90
+ await fs.rm(path.join(destDir, 'pnpm-lock.yaml'), { force: true });
89
91
  await patchReadmeWithoutGis(destDir);
90
92
  await applyNoGisStubs(destDir);
91
93
  await upsertEnvFeature(destDir, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-swdg-frontend",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Scaffold a new SWDG frontend project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,12 +32,18 @@ pnpm dev # http://localhost:3000 ,改 .env 后需重启
32
32
 
33
33
  ## 创建新项目(脚手架)
34
34
 
35
+ **官方命令(请只用这一条):**
36
+
35
37
  ```bash
36
38
  pnpm create swdg-frontend my-app
37
- # 或
38
- npx create-swdg-frontend my-app
39
39
  ```
40
40
 
41
+ | 命令 | 说明 |
42
+ |------|------|
43
+ | `pnpm create swdg-frontend my-app` | ✅ 正确,对应 npm 包 `create-swdg-frontend` |
44
+ | `npx create-swdg-frontend my-app` | ✅ 同上 |
45
+ | `pnpm create swdg my-app` | ❌ 会去找不存在的包 `create-swdg`,不要用 |
46
+
41
47
  交互会询问:项目名、**是否 GIS(默认否)**、是否安装依赖、是否 Git、是否 typecheck 校验。
42
48
 
43
49
  ```bash
@@ -34,7 +34,9 @@ frontend-framework/ # 模板源仓库(本仓库)
34
34
  # 1. 提交并推到 GitHub(main 上 CI 会跑 test:ci)
35
35
  git push github main
36
36
 
37
- # 2. 打 tag 并推送(版本号与 tag 一致,格式 vX.Y.Z;Release workflow 会再跑 test:ci 后 publish)
37
+ # 2. 打 tag 并推送(版本号与 tag 一致,格式 vX.Y.Z;Release workflow 会跑 test:ci 后 publish)
38
+
39
+ 用户创建项目请统一文档为:`pnpm create swdg-frontend <name>`(不要用 `pnpm create swdg`)。
38
40
  git tag v0.2.1
39
41
  git push github v0.2.1
40
42
  ```
@@ -82,7 +82,7 @@ src/
82
82
  ├── api/ # 接口请求
83
83
  ├── stores/ # Pinia
84
84
  ├── utils/ # 工具、composables、cesium 封装
85
- ├── styles/ # 全局样式(global.css、shell.css)
85
+ ├── styles/ # tokens / global / responsive / shell / alerts
86
86
  ├── router/ # 路由入口(一般不用改)
87
87
  interface/ # 业务 TS 类型
88
88
  types/ # 全局类型、env.d.ts
@@ -111,6 +111,24 @@ import { useFeatureGis } from '@composables/useFeatureGis';
111
111
  import MyCard from '@components/MyCard/index.vue';
112
112
  ```
113
113
 
114
+ ### 样式与自适应(推荐做法)
115
+
116
+ 模板 **不默认引入** Tailwind 或重型 UI 库,布局用 **原生 CSS**(成熟、无运行时):
117
+
118
+ | 文件 | 作用 |
119
+ | ---- | ---- |
120
+ | `tokens.css` | 断点变量、`clamp()` 间距与字号 |
121
+ | `responsive.css` | 遗留工具类 `.grid-h-*` 的响应式列数 |
122
+ | `shell.css` | 首页壳层、`repeat(auto-fill, minmax(...))` 卡片网格 |
123
+
124
+ 断点与业界常用值对齐:**640 / 768 / 1024 / 1280 px**。新页面优先:
125
+
126
+ - `clamp()` / `min()` / `%` 做流体尺寸
127
+ - **CSS Grid** `auto-fill` + `minmax()` 做卡片列表
128
+ - 需要组件级适配时再用 `@media`,一般不必为自适应单独加 npm 包
129
+
130
+ 若团队已标准化 **Element Plus / Ant Design Vue**,可在业务仓库自行安装;本模板保持样式中立。
131
+
114
132
  ---
115
133
 
116
134
  ## 六、约定式路由(重要)
@@ -8,19 +8,22 @@
8
8
  | -------------------- | --------------------------------------- | ----------------- |
9
9
  | `pnpm verify` | typecheck + eslint | 日常提交前 |
10
10
  | `pnpm test:unit` | Vitest 单元测试 | 开发中 |
11
- | `pnpm test:scaffold` | 脚手架集成(无 install | 改 create-swdg 后 |
11
+ | `pnpm test:scaffold` | 脚手架集成(含 --no-gis 生成项目 build | 改 create-swdg 后 |
12
12
  | `pnpm test:template` | sync + template install/typecheck/build | 改模板后 |
13
- | **`pnpm test:ci`** | **完整发布门禁(四阶段)** | **PR / 发布前** |
13
+ | `pnpm test:pack` | npm pack 后从 tarball 跑 CLI 并 build | 改发布物前 |
14
+ | **`pnpm test:ci`** | **完整发布门禁(五阶段)** | **PR / tag 发布** |
14
15
 
15
16
  ## 发布门禁管道(`pnpm test:ci`)
16
17
 
17
18
  顺序固定,任一失败即 `exit 1`:
18
19
 
19
20
  ```
21
+ 0. sync 生成 create-swdg/template
20
22
  1. verify 根项目 typecheck + eslint
21
23
  2. unit vitest 单元测试
22
- 3. scaffold --no-gis / --gis 产物、manifest、CLI smoke
23
- 4. template sync-template → template 目录 install → typecheck → build
24
+ 3. scaffold 产物/manifest/CLI + --no-gis 项目 install/build
25
+ 4. template template install → typecheck → build(GIS on)
26
+ 5. pack npm pack → 从 tarball 创建无 GIS 项目并 build
24
27
  ```
25
28
 
26
29
  `pnpm release x.y.z` 会在改版本号、打 npm 包 **之前** 自动执行 `test:ci`。
@@ -59,6 +62,20 @@
59
62
  - 合法参数能退出 0
60
63
  - 非法项目名退出非 0
61
64
 
65
+ **--no-gis 构建**
66
+
67
+ - 生成项目 `pnpm install` → `typecheck` → `build` 通过(无 Cesium)
68
+
69
+ ## 发布物测试(pack)
70
+
71
+ `scripts/test-pack.mjs`:
72
+
73
+ 1. 在 `create-swdg/` 执行 `npm pack`
74
+ 2. 从 tarball 安装并运行 CLI(`--no-gis`)
75
+ 3. 生成项目 `install` + `typecheck` + `build`
76
+
77
+ 模拟用户 `pnpm create swdg-frontend` 拿到的 npm 包内容。
78
+
62
79
  ## 模板测试(template)
63
80
 
64
81
  `scripts/test-template.mjs`:
@@ -98,7 +115,8 @@ pnpm release 0.2.1
98
115
  | 失败阶段 | 常见原因 |
99
116
  | -------- | ------------------------------------------------ |
100
117
  | verify | TS 错误、ESLint、单元测试红 |
101
- | scaffold | GIS 剥离不完整、manifest 版本与 constants 不一致 |
118
+ | scaffold | GIS 剥离不完整、无 GIS 项目 build 失败 |
102
119
  | template | 未 sync、template build 失败(Cesium/路由等) |
120
+ | pack | tarball 缺 template、packed CLI 行为异常 |
103
121
 
104
122
  template 阶段最慢(install + build),本地可先 `pnpm test:scaffold` 快速迭代脚手架逻辑。
@@ -22,6 +22,7 @@
22
22
  "test:unit": "vitest run",
23
23
  "test:run": "vitest run",
24
24
  "test:scaffold": "node scripts/test-scaffold.mjs",
25
+ "test:pack": "node scripts/test-pack.mjs",
25
26
  "test:template": "node scripts/test-template.mjs",
26
27
  "test:ci": "node scripts/test-pipeline.mjs",
27
28
  "verify": "node scripts/verify.mjs"
@@ -64,11 +65,9 @@
64
65
  "fs-extra": "^11.3.5",
65
66
  "husky": "^9.1.7",
66
67
  "jsdom": "^29.1.1",
67
- "less": "^4.6.4",
68
68
  "lint-staged": "^17.0.5",
69
69
  "prettier": "^3.8.3",
70
70
  "rollup-plugin-copy": "^3.5.0",
71
- "sass-embedded": "^1.100.0",
72
71
  "stylelint": "^17.12.0",
73
72
  "stylelint-config-recommended-vue": "^1.6.1",
74
73
  "stylelint-config-standard": "^40.0.0",