@finedesign/cli 0.8.0 → 0.8.1

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.
@@ -2,17 +2,15 @@
2
2
  "schemaVersion": 1,
3
3
  "version": "1.25.0",
4
4
  "sourceKind": "repository-snapshot",
5
- "sourceRevision": "c9d380a665f17001c406dbb081b1fcd91f6befa7",
5
+ "sourceRevision": "92a59ee18e00b27b76e666638c27534e2f3be53a",
6
6
  "sourceDirty": false,
7
- "contentHash": "b4069c8284ff843f8824b5685dad688e867eb13622832cedc36cfbe48da584a3",
8
- "catalogSha256": "63de4489e56aaf268d6363a65f35bd57cede27cd679afba7ae45bcc49ae16500",
7
+ "contentHash": "4bbd31b489ef7fbe290d88499038147053f7dd148a502ba5553e6bf1dce6b7f7",
8
+ "catalogSha256": "118ce4717d01727ee24291b62aa06ee1740cbd129bebb18734fbcaa4e1b045e3",
9
9
  "skillFiles": {
10
- "references/component-guide.md": "a91d47075e1c9fc90e8c4a5160e645a4d6ba7d12903688014cd1a22b0c5ef627",
10
+ "references/component-guide.md": "e48d32c664034bae5cf3aaf2d8c294f99e3374645e2b8482844e79e82b8548b6",
11
11
  "references/docs-slug-map.md": "440ce5cf137fd22eabfcc5b51c3f55b85174aa643773ef0cedd5df542e77bbc2",
12
- "references/imports-and-setup.md": "12278a80918a003a2285da510a77e77521a2771d47ae7bd0c8ea3f9a181d8398",
13
- "references/standalone-task-page.md": "97f05c06e1a4e7a9517d53ed6a358d9515d799e1b8c8731cbd50ccf060f3eaea",
14
- "references/task-list.js": "8e9f7daea7b8a003b0eb4cc1fc510b4a2d37f6812c846c882c01fa23be5adf19",
12
+ "references/imports-and-setup.md": "012baad54842ba16f4b770295f3f9beabcd090ecbcee78dade9c663e740edd3c",
15
13
  "references/theme-and-dark-mode.md": "2eccae4930ea993e7088eee03a4b4a0f1c839033079db5f21f8c60e0fe8168d1",
16
- "SKILL.md": "ad0bb8cf8a588b28e06a2a786483cb54124198a1e2bdf2e99a4c178147cd7968"
14
+ "SKILL.md": "e1024432c8b37d88057cfd851d40d3f1747b8b0354d12f9c4d510810757d62c8"
17
15
  }
18
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finedesign/cli",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Versioned Fine Design docs, code checks and agent setup for coding agents",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -31,5 +31,4 @@ Use the project-local `npx fine-design` when installed, otherwise the global `fi
31
31
  | Condition | Reference |
32
32
  | --- | --- |
33
33
  | Version mismatch, installation failures, unavailable docs, imports, or standalone setup | [imports-and-setup.md](references/imports-and-setup.md) |
34
- | New standalone table with filters, pagination and draft editing, or offline runtime export | [standalone-task-page.md](references/standalone-task-page.md) |
35
34
  | Theme, dark mode, or scoped themes | [theme-and-dark-mode.md](references/theme-and-dark-mode.md) |
@@ -67,6 +67,6 @@ render: (_value, record) => {
67
67
  - Verify affected behavior: change a filter from a later page; cancel then confirm removal; submit an invalid draft; cancel an edit; save and reopen another row. Choose checks for the actual change rather than testing every example.
68
68
  - Check business wording against actual predicates (calendar week versus rolling days), ensure actions report real results, and verify keyboard access to filters, cards and actions. New multi-project records must select or inherit the intended project. CLI lint does not verify these business contracts.
69
69
 
70
- For standalone HTML, see the bundled [task page](standalone-task-page.md). Use shared semantic tokens for page surfaces/text instead of recoloring every component; select exact theme tokens through `token` when needed.
70
+ Use shared semantic tokens for page surfaces/text instead of recoloring every component; select exact theme tokens through `token` when needed.
71
71
 
72
72
  For full page patterns in this repository, consult `playground/product-list/index.tsx`. Outside it, reuse local project examples. These are references, not dependencies for single-file outputs.
@@ -56,7 +56,7 @@ Run `npx -y @finedesign/cli runtime list --format json` first and check its exit
56
56
  3. The host retains only the current release files. Old URLs may disappear on upgrade; save matching resources yourself for long-lived standalone pages. Do not claim historical runtime availability from the CLI's offline catalog.
57
57
  4. If the manifest cannot be retrieved, report the failure and use an explicitly selected verified host or previously saved matching resources. The old unversioned website resources have been removed; do not fall back to them or substitute another component version.
58
58
 
59
- For offline or CSP-restricted previews, use `fine-design runtime --fd-version <exact-version> --output ./demo` with a new destination directory. `--dry-run --format json` previews file paths. The export verifies sizes/SHA-256 before writing local resources, preserves SRI and records their remote provenance in `runtime-lock.json`; it also includes a working [task page](standalone-task-page.md). Initial export needs network access; subsequent pages reference only local resources. The host must still permit page scripts/styles. Existing destinations are rejected rather than overwritten.
59
+ For offline or CSP-restricted previews, use `fine-design runtime --fd-version <exact-version> --output ./demo` with a new destination directory. `--dry-run --format json` previews file paths. The export verifies sizes/SHA-256 before writing local resources, preserves SRI and records their remote provenance in `runtime-lock.json`. Initial export needs network access; subsequent pages reference only local resources. The host must still permit page scripts/styles. Existing destinations are rejected rather than overwritten.
60
60
 
61
61
  Load `fineDesignCss`, then `react`, `reactDOM`, `fineDesign`. Pin exact URLs and integrity in generated HTML and use `crossorigin="anonymous"`; the host must provide CORS. Do not drop SRI from a selected versioned runtime to hide an error. Avoid async scripts and conflicting second React instances. If an embedding host lacks compatible React globals, use a separate document/iframe.
62
62
 
package/src/core/html.cjs CHANGED
@@ -1,4 +1,4 @@
1
- function exampleHTML(resources, prefix, appScript) {
1
+ function exampleHTML(resources, prefix) {
2
2
  const url = (entry) => entry.url || `${prefix}${entry.path}`;
3
3
  const escape = (value) => String(value).replace(/[&<>"']/g, (char) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]);
4
4
  const css = resources.fineDesignCss;
@@ -8,14 +8,6 @@ function exampleHTML(resources, prefix, appScript) {
8
8
  const entry = resources[name];
9
9
  return `<script defer src="${escape(url(entry))}" integrity="${escape(entry.integrity)}" crossorigin="anonymous" ${events(name)}></script>`;
10
10
  }).join('\n');
11
- const state = appScript ? '' : 'const [count, setCount] = React.useState(0);';
12
- const demo = appScript ? 'return h(window.FineDesignTaskList);' : `return h('div', { className: 'demo' },
13
- h('p', null, '每一次交互,都由真实组件驱动'),
14
- h('output', { className: 'demo-count', 'aria-live': 'polite' }, String(count).padStart(2, '0')),
15
- h('p', null, '试着点击按钮,开始你的第一次交互。'),
16
- h('div', { className: 'demo-actions' },
17
- h(FineDesign.Button, { type: 'primary', onClick: () => setCount(count + 1) }, '已点击 ' + count + ' 次'),
18
- h(FineDesign.Button, { type: 'normal', onClick: () => setCount(0) }, '重置')));`;
19
11
  return `<!doctype html>
20
12
  <html lang="zh-CN">
21
13
  <head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
@@ -96,7 +88,7 @@ function exampleHTML(resources, prefix, appScript) {
96
88
  </main>
97
89
  <footer><span>Fine Design ${escape(resources.fineDesign.version)} / React ${escape(resources.react.version)}</span><span>组件通过 window.FineDesign 提供</span></footer>
98
90
  </div>
99
- ${appScript ? `<script src="${escape(appScript)}"></script>\n` : ''}<script>
91
+ <script>
100
92
  (() => {
101
93
  const loaded = new Set();
102
94
  const status = document.getElementById('runtime-status');
@@ -116,13 +108,19 @@ ${appScript ? `<script src="${escape(appScript)}"></script>\n` : ''}<script>
116
108
  if (!window.React || !window.FineDesign || !window.ReactDOM || typeof ReactDOM.createRoot !== 'function') throw new Error('Missing runtime');
117
109
  const h = React.createElement;
118
110
  function App() {
119
- ${state}
111
+ const [count, setCount] = React.useState(0);
120
112
  React.useEffect(() => {
121
113
  document.body.dataset.state = 'ready';
122
114
  document.getElementById('root').setAttribute('aria-busy', 'false');
123
115
  status.textContent = '运行时已就绪';
124
116
  }, []);
125
- ${demo}
117
+ return h('div', { className: 'demo' },
118
+ h('p', null, '每一次交互,都由真实组件驱动'),
119
+ h('output', { className: 'demo-count', 'aria-live': 'polite' }, String(count).padStart(2, '0')),
120
+ h('p', null, '试着点击按钮,开始你的第一次交互。'),
121
+ h('div', { className: 'demo-actions' },
122
+ h(FineDesign.Button, { type: 'primary', onClick: () => setCount(count + 1) }, '已点击 ' + count + ' 次'),
123
+ h(FineDesign.Button, { type: 'normal', onClick: () => setCount(0) }, '重置')));
126
124
  }
127
125
  ReactDOM.createRoot(document.getElementById('root')).render(h(App));
128
126
  }
@@ -82,7 +82,7 @@ export async function exportRuntime(runtime, output, dryRun = false) {
82
82
  const entry = runtime.resources[name];
83
83
  return [name, { ...entry, localPath: `vendor/${path.posix.basename(new URL(entry.url).pathname)}` }];
84
84
  }));
85
- const plannedFiles = ['index.html', 'task-list.html', 'task-list.js', 'runtime-lock.json', ...Object.values(resources).map((entry) => entry.localPath)];
85
+ const plannedFiles = ['index.html', 'runtime-lock.json', ...Object.values(resources).map((entry) => entry.localPath)];
86
86
  const report = { version: runtime.version, targetDir, plannedFiles, writtenFiles: [], dryRun };
87
87
  if (dryRun) return report;
88
88
  const files = new Map();
@@ -107,8 +107,6 @@ export async function exportRuntime(runtime, output, dryRun = false) {
107
107
  }
108
108
  const localResources = Object.fromEntries(Object.entries(resources).map(([name, entry]) => [name, { ...entry, url: entry.localPath }]));
109
109
  files.set('index.html', html.exampleHTML(localResources, './'));
110
- files.set('task-list.html', html.exampleHTML(localResources, './', 'task-list.js'));
111
- files.set('task-list.js', fs.readFileSync(new URL('../../skills/fine-design/references/task-list.js', import.meta.url)));
112
110
  files.set('runtime-lock.json', JSON.stringify({ schemaVersion: 1, version: runtime.version, manifestURL: runtime.manifestURL, resources }, null, 2) + '\n');
113
111
  const parent = path.dirname(targetDir);
114
112
  fs.mkdirSync(parent, { recursive: true });
@@ -1,30 +0,0 @@
1
- # Standalone Task Page
2
-
3
- Use this reference for a new standalone table with filters, pagination and draft editing. Preserve existing project components instead of replacing them with this sample.
4
-
5
- After discovering the hosted version, run:
6
-
7
- ```sh
8
- fine-design runtime --fd-version <exact-version> --output ./task-demo
9
- ```
10
-
11
- The destination must not exist. `--dry-run --format json` previews paths without downloading assets or writing files. Export downloads the four required resources once, checks their declared sizes and SHA-256, then installs the directory. Download, integrity or conflict failures leave the destination untouched. The current browser starter uses React 18's `createRoot`; verify compatibility when targeting a different React major.
12
-
13
- - `index.html`: existing button/runtime smoke example.
14
- - `task-list.html` and `task-list.js`: working local task example. No JSX transformer or extra dependency.
15
- - `vendor/`: pinned React, ReactDOM, Fine Design JavaScript and stylesheet.
16
- - `runtime-lock.json`: source manifest URL, exact resource metadata and local paths. This is an archive record, not a hosting manifest.
17
-
18
- Use the target host's normal local preview. Resource URLs are local and SRI is retained; the host must still permit the page's scripts and styles. No CDN fallback is needed for an exported directory. Keep the whole directory together when copying it.
19
-
20
- The complete [task-list.js](task-list.js) is also bundled with this Skill. It is a reference, not a runtime dependency: copy it into the deliverable before linking it. Its component is `window.FineDesignTaskList`; mount it after the runtime is loaded. The example stores status codes consistently, enables Radio keyboard focus, labels text inputs, keeps edits in a separate draft, and binds deletion to `PopConfirm.onOk`.
21
-
22
- ## Verify The Business Contract
23
-
24
- 1. From a later page, filter by keyword/status and reset; verify the matching rows and page number.
25
- 2. Create a task, reject an empty name, save a valid task, edit it, cancel an edit, then reopen it.
26
- 3. Cancel deletion, then confirm deletion; remove the last row on a later page and verify pagination clamps.
27
- 4. Use Tab and the component's supported keys to reach filters and actions; check focus and the actual accessible names in the target preview.
28
- 5. For extensions, define calendar-week versus rolling-date semantics explicitly. An export action must create a file or report a real result; mark intentionally unfinished actions. If tasks belong to multiple projects, new tasks must select or inherit the intended project.
29
-
30
- CLI lint checks API usage, not business correctness, accessibility compliance or visual layout. Report syntax/API tests, DOM behavior tests and actual browser/host checks separately. DOM-only checks cannot verify clipping, colors or responsive layout.
@@ -1,82 +0,0 @@
1
- /* 独立页面组合参考:运行时加载后用 React.createElement(window.FineDesignTaskList) 渲染。 */
2
- window.FineDesignTaskList = function FineDesignTaskList() {
3
- const React = window.React;
4
- const h = React.createElement;
5
- const { Button, Input, Select, Radio, NextTable, Pagination, Drawer, PopConfirm, Tag } = window.FineDesign;
6
- const [rows, setRows] = React.useState([
7
- { id: 1, name: '整理需求', status: 'todo' },
8
- { id: 2, name: '接口联调', status: 'doing' },
9
- { id: 3, name: '组件验收', status: 'done' },
10
- { id: 4, name: '补充用例', status: 'todo' },
11
- { id: 5, name: '检查交付', status: 'doing' }
12
- ]);
13
- const [keyword, setKeyword] = React.useState('');
14
- const [status, setStatus] = React.useState('all');
15
- const [page, setPage] = React.useState(1);
16
- const [size, setSize] = React.useState(2);
17
- const [draft, setDraft] = React.useState(null);
18
- const [error, setError] = React.useState('');
19
- const statuses = [{ label: '待规划', value: 'todo' }, { label: '进行中', value: 'doing' }, { label: '已完成', value: 'done' }];
20
- const filtered = rows.filter(row => (status === 'all' || row.status === status) && row.name.includes(keyword.trim()));
21
- const maxPage = Math.max(1, Math.ceil(filtered.length / size));
22
- React.useEffect(() => { if (page > maxPage) setPage(maxPage); }, [page, maxPage]);
23
-
24
- function edit(row) { setDraft({ ...row }); setError(''); }
25
- function close() { setDraft(null); setError(''); }
26
- function save() {
27
- const name = draft.name.trim();
28
- if (!name) { setError('请填写任务名称'); return; }
29
- const saved = { ...draft, name, id: draft.id ?? Math.max(0, ...rows.map(row => row.id)) + 1 };
30
- setRows(draft.id == null ? [saved, ...rows] : rows.map(row => row.id === saved.id ? saved : row));
31
- if (draft.id == null) setPage(1);
32
- close();
33
- }
34
- function column(title, width, render) {
35
- return h(NextTable.Column, { width }, h(NextTable.HeaderCell, null, title),
36
- h(NextTable.Cell, null, row => row?.id != null ? render(row) : null));
37
- }
38
- const fieldStyle = { display: 'grid', gap: 8 };
39
- return h('div', { style: { display: 'grid', gap: 16, padding: 20, color: 'var(--fd-color-text)' } },
40
- h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 12 } },
41
- h('strong', { 'aria-live': 'polite' }, '任务清单 · ' + filtered.length + ' 项'),
42
- h(Button, { type: 'primary', onClick: () => edit({ id: null, name: '', status: 'todo' }) }, '新建任务')),
43
- h('label', { style: fieldStyle }, '任务关键词', h(Input, {
44
- value: keyword, placeholder: '输入任务名称', allowClear: true,
45
- onChange: value => { setKeyword(value); setPage(1); }
46
- })),
47
- h(Radio.Group, { value: status, tabFocus: true, direction: 'horizontal', optionType: 'button', block: false,
48
- onChange: value => { setStatus(value); setPage(1); }
49
- }, [{ label: '全部任务', value: 'all' }, ...statuses].map(item => h(Radio, { key: item.value, value: item.value }, item.label))),
50
- h(Button, { onClick: () => { setKeyword(''); setStatus('all'); setPage(1); } }, '重置筛选'),
51
- h('div', { style: { overflowX: 'auto', minWidth: 0 } }, h(NextTable, {
52
- data: filtered.slice((page - 1) * size, page * size), rowKey: 'id', width: 780, autoHeight: true, fillHeight: false,
53
- renderEmpty: () => h('p', null, '暂无符合条件的任务')
54
- },
55
- column('编号', 100, row => String(row.id)),
56
- column('名称', 340, row => row.name),
57
- column('状态', 140, row => h(Tag, { type: row.status === 'done' ? 'success' : 'info' }, statuses.find(item => item.value === row.status).label)),
58
- column('操作', 200, row => h('div', { style: { display: 'flex', gap: 8 } },
59
- h(Button, { type: 'text', onClick: () => edit(row) }, '编辑'),
60
- h(PopConfirm, { content: '确认删除“' + row.name + '”?', text4Ok: '确认删除', text4Cancel: '取消',
61
- onOk: () => setRows(rows.filter(item => item.id !== row.id))
62
- }, h(Button, { type: 'text', danger: true }, '删除'))))
63
- )),
64
- h(Pagination, { page, size, sizeSet: [2, 5], count: filtered.length, showPageSize: value => value + ' 条/页',
65
- showTotal: count => '共 ' + count + ' 项', onPageChange: setPage,
66
- onSizeChange: value => { setSize(value); setPage(1); }
67
- }),
68
- draft && h(Drawer, { visible: true, placement: 'right', edge: { width: 'min(520px, 100vw)', top: 0 },
69
- title: draft.id == null ? '新建任务' : '编辑任务', onClose: close,
70
- footer: h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8 } },
71
- h(Button, { onClick: close }, '取消'), h(Button, { type: 'primary', onClick: save }, '保存'))
72
- }, h('div', { style: { display: 'grid', gap: 16 } },
73
- h('label', { style: fieldStyle }, '任务名称(必填)', h(Input, { value: draft.name,
74
- inputState: error ? 'error' : 'normal', onChange: value => { setDraft({ ...draft, name: value }); setError(''); }
75
- })),
76
- error && h('p', { role: 'alert' }, error),
77
- h('div', { style: fieldStyle }, h('span', null, '任务状态'), h(Select, { value: draft.status, options: statuses, 'aria-label': '任务状态',
78
- onChange: value => setDraft({ ...draft, status: value })
79
- })))
80
- )
81
- );
82
- };