@rien7/seji 0.0.0 → 0.6.0
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/bin/design-surface.mjs +6 -0
- package/bin/postinstall.mjs +19 -0
- package/bin/seji.mjs +573 -0
- package/dist/agent/host.d.mts +34 -0
- package/dist/agent/host.mjs +387 -0
- package/dist/agent/messages.d.mts +9 -0
- package/dist/agent/messages.mjs +70 -0
- package/dist/agent/runtimes.mjs +157 -0
- package/dist/cli/app.mjs +321 -0
- package/dist/cli/appScan.mjs +284 -0
- package/dist/cli/catalog.mjs +78 -0
- package/dist/cli/component.mjs +165 -0
- package/dist/cli/consolidate.mjs +159 -0
- package/dist/cli/cssImport.mjs +68 -0
- package/dist/cli/dev.mjs +335 -0
- package/dist/cli/doctor.mjs +306 -0
- package/dist/cli/init.mjs +338 -0
- package/dist/cli/legacyNames.mjs +266 -0
- package/dist/cli/migrate.mjs +163 -0
- package/dist/cli/prompt.mjs +34 -0
- package/dist/cli/propose.mjs +208 -0
- package/dist/cli/providers.mjs +344 -0
- package/dist/cli/reviewOps.mjs +110 -0
- package/dist/cli/semver.mjs +45 -0
- package/dist/cli/setup.mjs +357 -0
- package/dist/cli/sketches.mjs +47 -0
- package/dist/cli/skills.mjs +150 -0
- package/dist/cli/snapshot.mjs +107 -0
- package/dist/cli/tokenOps.mjs +120 -0
- package/dist/cli/types.mjs +191 -0
- package/dist/cli/updater.mjs +274 -0
- package/dist/components/astIndex.mjs +992 -0
- package/dist/components/ops.mjs +1069 -0
- package/dist/editor/AgentProposalCard.d.ts +10 -0
- package/dist/editor/AgentProposalCard.d.ts.map +1 -0
- package/dist/editor/AgentProposalCard.js +31 -0
- package/dist/editor/AgentProposalCard.js.map +1 -0
- package/dist/editor/App.d.ts +2 -0
- package/dist/editor/App.d.ts.map +1 -0
- package/dist/editor/App.js +2832 -0
- package/dist/editor/App.js.map +1 -0
- package/dist/editor/CanvasHud.d.ts +12 -0
- package/dist/editor/CanvasHud.d.ts.map +1 -0
- package/dist/editor/CanvasHud.js +13 -0
- package/dist/editor/CanvasHud.js.map +1 -0
- package/dist/editor/CanvasSurface.d.ts +31 -0
- package/dist/editor/CanvasSurface.d.ts.map +1 -0
- package/dist/editor/CanvasSurface.js +270 -0
- package/dist/editor/CanvasSurface.js.map +1 -0
- package/dist/editor/CommentPopover.d.ts +17 -0
- package/dist/editor/CommentPopover.d.ts.map +1 -0
- package/dist/editor/CommentPopover.js +62 -0
- package/dist/editor/CommentPopover.js.map +1 -0
- package/dist/editor/Comments.d.ts +13 -0
- package/dist/editor/Comments.d.ts.map +1 -0
- package/dist/editor/Comments.js +41 -0
- package/dist/editor/Comments.js.map +1 -0
- package/dist/editor/ComponentPage.d.ts +28 -0
- package/dist/editor/ComponentPage.d.ts.map +1 -0
- package/dist/editor/ComponentPage.js +55 -0
- package/dist/editor/ComponentPage.js.map +1 -0
- package/dist/editor/ComponentPanel.d.ts +38 -0
- package/dist/editor/ComponentPanel.d.ts.map +1 -0
- package/dist/editor/ComponentPanel.js +275 -0
- package/dist/editor/ComponentPanel.js.map +1 -0
- package/dist/editor/Glyph.d.ts +51 -0
- package/dist/editor/Glyph.d.ts.map +1 -0
- package/dist/editor/Glyph.js +50 -0
- package/dist/editor/Glyph.js.map +1 -0
- package/dist/editor/History.d.ts +7 -0
- package/dist/editor/History.d.ts.map +1 -0
- package/dist/editor/History.js +51 -0
- package/dist/editor/History.js.map +1 -0
- package/dist/editor/Inspector.d.ts +56 -0
- package/dist/editor/Inspector.d.ts.map +1 -0
- package/dist/editor/Inspector.js +510 -0
- package/dist/editor/Inspector.js.map +1 -0
- package/dist/editor/LazyMount.d.ts +10 -0
- package/dist/editor/LazyMount.d.ts.map +1 -0
- package/dist/editor/LazyMount.js +29 -0
- package/dist/editor/LazyMount.js.map +1 -0
- package/dist/editor/LocaleSwitch.d.ts +3 -0
- package/dist/editor/LocaleSwitch.d.ts.map +1 -0
- package/dist/editor/LocaleSwitch.js +9 -0
- package/dist/editor/LocaleSwitch.js.map +1 -0
- package/dist/editor/PreviewFrame.d.ts +10 -0
- package/dist/editor/PreviewFrame.d.ts.map +1 -0
- package/dist/editor/PreviewFrame.js +22 -0
- package/dist/editor/PreviewFrame.js.map +1 -0
- package/dist/editor/ProjectIndex.d.ts +12 -0
- package/dist/editor/ProjectIndex.d.ts.map +1 -0
- package/dist/editor/ProjectIndex.js +43 -0
- package/dist/editor/ProjectIndex.js.map +1 -0
- package/dist/editor/PromoteComponent.d.ts +28 -0
- package/dist/editor/PromoteComponent.d.ts.map +1 -0
- package/dist/editor/PromoteComponent.js +33 -0
- package/dist/editor/PromoteComponent.js.map +1 -0
- package/dist/editor/PromoteForm.d.ts +18 -0
- package/dist/editor/PromoteForm.d.ts.map +1 -0
- package/dist/editor/PromoteForm.js +35 -0
- package/dist/editor/PromoteForm.js.map +1 -0
- package/dist/editor/PromoteToken.d.ts +31 -0
- package/dist/editor/PromoteToken.d.ts.map +1 -0
- package/dist/editor/PromoteToken.js +94 -0
- package/dist/editor/PromoteToken.js.map +1 -0
- package/dist/editor/StatePreviews.d.ts +28 -0
- package/dist/editor/StatePreviews.d.ts.map +1 -0
- package/dist/editor/StatePreviews.js +113 -0
- package/dist/editor/StatePreviews.js.map +1 -0
- package/dist/editor/ValueCombo.d.ts +51 -0
- package/dist/editor/ValueCombo.d.ts.map +1 -0
- package/dist/editor/ValueCombo.js +260 -0
- package/dist/editor/ValueCombo.js.map +1 -0
- package/dist/editor/agent/AgentPanel.d.ts +19 -0
- package/dist/editor/agent/AgentPanel.d.ts.map +1 -0
- package/dist/editor/agent/AgentPanel.js +271 -0
- package/dist/editor/agent/AgentPanel.js.map +1 -0
- package/dist/editor/agent/Markdown.d.ts +5 -0
- package/dist/editor/agent/Markdown.d.ts.map +1 -0
- package/dist/editor/agent/Markdown.js +28 -0
- package/dist/editor/agent/Markdown.js.map +1 -0
- package/dist/editor/agent/agentApi.d.ts +106 -0
- package/dist/editor/agent/agentApi.d.ts.map +1 -0
- package/dist/editor/agent/agentApi.js +66 -0
- package/dist/editor/agent/agentApi.js.map +1 -0
- package/dist/editor/agent/toolLines.d.ts +38 -0
- package/dist/editor/agent/toolLines.d.ts.map +1 -0
- package/dist/editor/agent/toolLines.js +159 -0
- package/dist/editor/agent/toolLines.js.map +1 -0
- package/dist/editor/agent/useAgent.d.ts +15 -0
- package/dist/editor/agent/useAgent.d.ts.map +1 -0
- package/dist/editor/agent/useAgent.js +65 -0
- package/dist/editor/agent/useAgent.js.map +1 -0
- package/dist/editor/api.d.ts +378 -0
- package/dist/editor/api.d.ts.map +1 -0
- package/dist/editor/api.js +247 -0
- package/dist/editor/api.js.map +1 -0
- package/dist/editor/camera.d.ts +18 -0
- package/dist/editor/camera.d.ts.map +1 -0
- package/dist/editor/camera.js +40 -0
- package/dist/editor/camera.js.map +1 -0
- package/dist/editor/canvas.d.ts +25 -0
- package/dist/editor/canvas.d.ts.map +1 -0
- package/dist/editor/canvas.js +35 -0
- package/dist/editor/canvas.js.map +1 -0
- package/dist/editor/changes/ChangesPage.d.ts +25 -0
- package/dist/editor/changes/ChangesPage.d.ts.map +1 -0
- package/dist/editor/changes/ChangesPage.js +132 -0
- package/dist/editor/changes/ChangesPage.js.map +1 -0
- package/dist/editor/changes/changeModel.d.ts +25 -0
- package/dist/editor/changes/changeModel.d.ts.map +1 -0
- package/dist/editor/changes/changeModel.js +81 -0
- package/dist/editor/changes/changeModel.js.map +1 -0
- package/dist/editor/changes/changeState.d.mts +29 -0
- package/dist/editor/changes/changeState.mjs +187 -0
- package/dist/editor/chrome/EditorChrome.d.ts +49 -0
- package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
- package/dist/editor/chrome/EditorChrome.js +21 -0
- package/dist/editor/chrome/EditorChrome.js.map +1 -0
- package/dist/editor/drafts.d.ts +46 -0
- package/dist/editor/drafts.d.ts.map +1 -0
- package/dist/editor/drafts.js +38 -0
- package/dist/editor/drafts.js.map +1 -0
- package/dist/editor/i18n.d.ts +29 -0
- package/dist/editor/i18n.d.ts.map +1 -0
- package/dist/editor/i18n.js +2320 -0
- package/dist/editor/i18n.js.map +1 -0
- package/dist/editor/iconStroke.d.ts +6 -0
- package/dist/editor/iconStroke.d.ts.map +1 -0
- package/dist/editor/iconStroke.js +6 -0
- package/dist/editor/iconStroke.js.map +1 -0
- package/dist/editor/main.d.ts +2 -0
- package/dist/editor/main.d.ts.map +1 -0
- package/dist/editor/main.js +14 -0
- package/dist/editor/main.js.map +1 -0
- package/dist/editor/model.d.ts +16 -0
- package/dist/editor/model.d.ts.map +1 -0
- package/dist/editor/model.js +11 -0
- package/dist/editor/model.js.map +1 -0
- package/dist/editor/reasons.d.ts +44 -0
- package/dist/editor/reasons.d.ts.map +1 -0
- package/dist/editor/reasons.js +131 -0
- package/dist/editor/reasons.js.map +1 -0
- package/dist/editor/reviewLifecycle.d.ts +8 -0
- package/dist/editor/reviewLifecycle.d.ts.map +1 -0
- package/dist/editor/reviewLifecycle.js +21 -0
- package/dist/editor/reviewLifecycle.js.map +1 -0
- package/dist/editor/styles.css +8737 -0
- package/dist/editor/tokenMatch.d.ts +59 -0
- package/dist/editor/tokenMatch.d.ts.map +1 -0
- package/dist/editor/tokenMatch.js +198 -0
- package/dist/editor/tokenMatch.js.map +1 -0
- package/dist/editor/tokens/ConsolidatePage.d.ts +16 -0
- package/dist/editor/tokens/ConsolidatePage.d.ts.map +1 -0
- package/dist/editor/tokens/ConsolidatePage.js +244 -0
- package/dist/editor/tokens/ConsolidatePage.js.map +1 -0
- package/dist/editor/tokens/TokenActivity.d.ts +18 -0
- package/dist/editor/tokens/TokenActivity.d.ts.map +1 -0
- package/dist/editor/tokens/TokenActivity.js +18 -0
- package/dist/editor/tokens/TokenActivity.js.map +1 -0
- package/dist/editor/tokens/TokenDialogs.d.ts +26 -0
- package/dist/editor/tokens/TokenDialogs.d.ts.map +1 -0
- package/dist/editor/tokens/TokenDialogs.js +119 -0
- package/dist/editor/tokens/TokenDialogs.js.map +1 -0
- package/dist/editor/tokens/TokenList.d.ts +21 -0
- package/dist/editor/tokens/TokenList.d.ts.map +1 -0
- package/dist/editor/tokens/TokenList.js +98 -0
- package/dist/editor/tokens/TokenList.js.map +1 -0
- package/dist/editor/tokens/TokenPage.d.ts +25 -0
- package/dist/editor/tokens/TokenPage.d.ts.map +1 -0
- package/dist/editor/tokens/TokenPage.js +108 -0
- package/dist/editor/tokens/TokenPage.js.map +1 -0
- package/dist/editor/tokens/tokenModel.d.ts +35 -0
- package/dist/editor/tokens/tokenModel.d.ts.map +1 -0
- package/dist/editor/tokens/tokenModel.js +72 -0
- package/dist/editor/tokens/tokenModel.js.map +1 -0
- package/dist/editor/ui/Button.d.ts +3 -0
- package/dist/editor/ui/Button.d.ts.map +1 -0
- package/dist/editor/ui/Button.js +6 -0
- package/dist/editor/ui/Button.js.map +1 -0
- package/dist/editor/ui/CommentBox.d.ts +23 -0
- package/dist/editor/ui/CommentBox.d.ts.map +1 -0
- package/dist/editor/ui/CommentBox.js +41 -0
- package/dist/editor/ui/CommentBox.js.map +1 -0
- package/dist/editor/ui/Icon.d.ts +8 -0
- package/dist/editor/ui/Icon.d.ts.map +1 -0
- package/dist/editor/ui/Icon.js +6 -0
- package/dist/editor/ui/Icon.js.map +1 -0
- package/dist/editor/ui/IconButton.d.ts +11 -0
- package/dist/editor/ui/IconButton.d.ts.map +1 -0
- package/dist/editor/ui/IconButton.js +6 -0
- package/dist/editor/ui/IconButton.js.map +1 -0
- package/dist/editor/ui/NumberInput.d.ts +14 -0
- package/dist/editor/ui/NumberInput.d.ts.map +1 -0
- package/dist/editor/ui/NumberInput.js +6 -0
- package/dist/editor/ui/NumberInput.js.map +1 -0
- package/dist/editor/ui/PageLine.d.ts +14 -0
- package/dist/editor/ui/PageLine.d.ts.map +1 -0
- package/dist/editor/ui/PageLine.js +7 -0
- package/dist/editor/ui/PageLine.js.map +1 -0
- package/dist/editor/ui/SearchPicker.d.ts +41 -0
- package/dist/editor/ui/SearchPicker.d.ts.map +1 -0
- package/dist/editor/ui/SearchPicker.js +82 -0
- package/dist/editor/ui/SearchPicker.js.map +1 -0
- package/dist/editor/ui/Select.d.ts +19 -0
- package/dist/editor/ui/Select.d.ts.map +1 -0
- package/dist/editor/ui/Select.js +12 -0
- package/dist/editor/ui/Select.js.map +1 -0
- package/dist/editor/ui/TokenField.d.ts +14 -0
- package/dist/editor/ui/TokenField.d.ts.map +1 -0
- package/dist/editor/ui/TokenField.js +41 -0
- package/dist/editor/ui/TokenField.js.map +1 -0
- package/dist/editor/ui/TokenPicker.d.ts +31 -0
- package/dist/editor/ui/TokenPicker.d.ts.map +1 -0
- package/dist/editor/ui/TokenPicker.js +26 -0
- package/dist/editor/ui/TokenPicker.js.map +1 -0
- package/dist/editor/useBuildError.d.ts +7 -0
- package/dist/editor/useBuildError.d.ts.map +1 -0
- package/dist/editor/useBuildError.js +30 -0
- package/dist/editor/useBuildError.js.map +1 -0
- package/dist/editor/useLatestRequest.d.ts +22 -0
- package/dist/editor/useLatestRequest.d.ts.map +1 -0
- package/dist/editor/useLatestRequest.js +49 -0
- package/dist/editor/useLatestRequest.js.map +1 -0
- package/dist/editor-bundle/editor.css +2 -0
- package/dist/editor-bundle/editor.js +83 -0
- package/dist/editor-ui.d.ts +15 -0
- package/dist/editor-ui.d.ts.map +1 -0
- package/dist/editor-ui.js +14 -0
- package/dist/editor-ui.js.map +1 -0
- package/dist/inspector/runtime.d.ts +18 -0
- package/dist/inspector/runtime.d.ts.map +1 -0
- package/dist/inspector/runtime.js +1280 -0
- package/dist/inspector/runtime.js.map +1 -0
- package/dist/preview/main.d.ts +3 -0
- package/dist/preview/main.d.ts.map +1 -0
- package/dist/preview/main.js +320 -0
- package/dist/preview/main.js.map +1 -0
- package/dist/preview/preview.css +40 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/shared/buildError.d.mts +27 -0
- package/dist/shared/buildError.mjs +141 -0
- package/dist/shared/cameraFit.d.mts +16 -0
- package/dist/shared/cameraFit.mjs +47 -0
- package/dist/shared/canvasLayout.d.mts +13 -0
- package/dist/shared/canvasLayout.mjs +171 -0
- package/dist/shared/commentShots.d.mts +12 -0
- package/dist/shared/commentShots.mjs +53 -0
- package/dist/shared/componentExtract.d.mts +43 -0
- package/dist/shared/componentExtract.mjs +136 -0
- package/dist/shared/componentMeta.d.mts +26 -0
- package/dist/shared/componentMeta.mjs +87 -0
- package/dist/shared/componentOps.d.mts +70 -0
- package/dist/shared/componentOps.mjs +407 -0
- package/dist/shared/componentTarget.d.mts +15 -0
- package/dist/shared/componentTarget.mjs +58 -0
- package/dist/shared/components.d.mts +30 -0
- package/dist/shared/components.mjs +106 -0
- package/dist/shared/consolidateCategories.d.mts +2 -0
- package/dist/shared/consolidateCategories.mjs +6 -0
- package/dist/shared/env.d.mts +4 -0
- package/dist/shared/env.mjs +18 -0
- package/dist/shared/gitChanges.d.mts +2 -0
- package/dist/shared/gitChanges.mjs +30 -0
- package/dist/shared/oklab.d.mts +6 -0
- package/dist/shared/oklab.mjs +56 -0
- package/dist/shared/optimizeEntries.d.mts +5 -0
- package/dist/shared/optimizeEntries.mjs +24 -0
- package/dist/shared/packages.d.mts +11 -0
- package/dist/shared/packages.mjs +96 -0
- package/dist/shared/projectFiles.d.mts +23 -0
- package/dist/shared/projectFiles.mjs +72 -0
- package/dist/shared/prompt.d.mts +20 -0
- package/dist/shared/prompt.mjs +201 -0
- package/dist/shared/proposals.d.mts +11 -0
- package/dist/shared/proposals.mjs +42 -0
- package/dist/shared/protocol.d.ts +122 -0
- package/dist/shared/protocol.d.ts.map +1 -0
- package/dist/shared/protocol.js +7 -0
- package/dist/shared/protocol.js.map +1 -0
- package/dist/shared/reviewArchive.d.mts +4 -0
- package/dist/shared/reviewArchive.mjs +19 -0
- package/dist/shared/reviewStore.d.mts +30 -0
- package/dist/shared/reviewStore.mjs +218 -0
- package/dist/shared/reviewVerify.d.mts +21 -0
- package/dist/shared/reviewVerify.mjs +158 -0
- package/dist/shared/sizeModes.d.mts +15 -0
- package/dist/shared/sizeModes.mjs +53 -0
- package/dist/shared/sketches.d.mts +10 -0
- package/dist/shared/sketches.mjs +64 -0
- package/dist/shared/snapshotCheck.d.mts +13 -0
- package/dist/shared/snapshotCheck.mjs +81 -0
- package/dist/shared/timeout.d.mts +1 -0
- package/dist/shared/timeout.mjs +15 -0
- package/dist/shared/tokens.d.ts +2 -0
- package/dist/shared/tokens.d.ts.map +1 -0
- package/dist/shared/tokens.js +2 -0
- package/dist/shared/tokens.js.map +1 -0
- package/dist/shared/types.d.ts +689 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +13 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/wheelRouting.d.mts +9 -0
- package/dist/shared/wheelRouting.mjs +31 -0
- package/dist/shared/writeScope.mjs +96 -0
- package/dist/snapshots/diff.d.mts +28 -0
- package/dist/snapshots/diff.mjs +263 -0
- package/dist/snapshots/index.d.mts +110 -0
- package/dist/snapshots/index.mjs +638 -0
- package/dist/snapshots/render.d.mts +24 -0
- package/dist/snapshots/render.mjs +250 -0
- package/dist/snapshots/toolOps.d.mts +25 -0
- package/dist/snapshots/toolOps.mjs +69 -0
- package/dist/tokens/adapters/css.mjs +51 -0
- package/dist/tokens/adapters/cssInCode.mjs +314 -0
- package/dist/tokens/adapters/oxcShared.mjs +80 -0
- package/dist/tokens/adapters/preprocessor.mjs +63 -0
- package/dist/tokens/adapters/registry.mjs +53 -0
- package/dist/tokens/adapters/tailwindcss.mjs +424 -0
- package/dist/tokens/adapters/types.mjs +117 -0
- package/dist/tokens/consolidate/index.d.mts +42 -0
- package/dist/tokens/consolidate/index.mjs +111 -0
- package/dist/tokens/consolidate/normalize.mjs +479 -0
- package/dist/tokens/consolidate/plan.mjs +726 -0
- package/dist/tokens/consolidate/scan.mjs +928 -0
- package/dist/tokens/extract.mjs +441 -0
- package/dist/tokens/moduleData.d.mts +14 -0
- package/dist/tokens/moduleData.mjs +32 -0
- package/dist/tokens/opLock.d.mts +4 -0
- package/dist/tokens/opLock.mjs +108 -0
- package/dist/tokens/ops.d.mts +71 -0
- package/dist/tokens/ops.mjs +1511 -0
- package/dist/tokens/pipeline.mjs +813 -0
- package/dist/tokens/report.d.mts +47 -0
- package/dist/tokens/report.mjs +257 -0
- package/dist/tokens/rewrite/code.mjs +172 -0
- package/dist/tokens/rewrite/css.mjs +154 -0
- package/dist/tokens/rewrite/index.mjs +244 -0
- package/dist/tokens/rewrite/tailwind.mjs +288 -0
- package/dist/tokens/rewrite/text.mjs +116 -0
- package/dist/tokens/rewrite/value.mjs +115 -0
- package/dist/tokens/usage.d.mts +97 -0
- package/dist/tokens/usage.mjs +680 -0
- package/dist/vite/agent.d.ts +21 -0
- package/dist/vite/agent.d.ts.map +1 -0
- package/dist/vite/agent.js +165 -0
- package/dist/vite/agent.js.map +1 -0
- package/dist/vite/events.d.ts +27 -0
- package/dist/vite/events.d.ts.map +1 -0
- package/dist/vite/events.js +156 -0
- package/dist/vite/events.js.map +1 -0
- package/dist/vite/layout.d.ts +2 -0
- package/dist/vite/layout.d.ts.map +1 -0
- package/dist/vite/layout.js +4 -0
- package/dist/vite/layout.js.map +1 -0
- package/dist/vite/plugin.d.ts +40 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +1255 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/requestGuard.d.mts +3 -0
- package/dist/vite/requestGuard.mjs +43 -0
- package/dist/vite/review.d.ts +11 -0
- package/dist/vite/review.d.ts.map +1 -0
- package/dist/vite/review.js +283 -0
- package/dist/vite/review.js.map +1 -0
- package/package.json +106 -1
- package/skills/seji/SKILL.md +395 -0
- package/skills/seji-authoring/SKILL.md +397 -0
- package/skills/seji-tokens/SKILL.md +432 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
// The design/ scaffold `seji setup` writes once (the user's files: never
|
|
2
|
+
// overwritten), and the small package.json helpers setup and doctor share. No installs: the
|
|
3
|
+
// runtime comes from the running CLI (vite/plugin.ts aliases it), types from
|
|
4
|
+
// design/.seji/types (cli/types.mjs).
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
6
|
+
import { dirname, join } from 'node:path'
|
|
7
|
+
|
|
8
|
+
export { SKILL_NAMES, SKILLS_ROOT, listFiles, syncToolOwnedDir } from './skills.mjs'
|
|
9
|
+
export { compareVersions, sameMinor } from './semver.mjs'
|
|
10
|
+
export const PACKAGE_VERSION = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version
|
|
11
|
+
export const RUNTIME_PACKAGE = '@rien7/design-surface-runtime'
|
|
12
|
+
export const DESIGN_PACKAGE = '@rien7/seji'
|
|
13
|
+
/** The global bin (`npm i -g @rien7/seji@latest`). */
|
|
14
|
+
export const CLI = 'seji'
|
|
15
|
+
|
|
16
|
+
export const readPackageJson = (root) => {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
|
|
19
|
+
} catch {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Range declared in package.json (any dependency section), or null. */
|
|
25
|
+
export function declaredRange(root, name) {
|
|
26
|
+
const pkg = readPackageJson(root)
|
|
27
|
+
if (!pkg) return null
|
|
28
|
+
for (const section of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
|
|
29
|
+
if (typeof pkg[section]?.[name] === 'string') return pkg[section][name]
|
|
30
|
+
}
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Version installed in node_modules, or null. */
|
|
35
|
+
export function installedVersion(root, name) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(readFileSync(join(root, 'node_modules', ...name.split('/'), 'package.json'), 'utf8')).version ?? null
|
|
38
|
+
} catch {
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const STARTER_PRIMITIVE = {
|
|
44
|
+
color: {
|
|
45
|
+
$extensions: {
|
|
46
|
+
'design-surface': {
|
|
47
|
+
tier: 'primitive',
|
|
48
|
+
group: 'color',
|
|
49
|
+
label: 'Color',
|
|
50
|
+
labelZh: '颜色',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
$type: 'color',
|
|
54
|
+
ink: {
|
|
55
|
+
$type: 'color',
|
|
56
|
+
$value: '#18181b',
|
|
57
|
+
$extensions: {
|
|
58
|
+
'design-surface': {
|
|
59
|
+
label: 'Ink',
|
|
60
|
+
labelZh: '墨色',
|
|
61
|
+
uiType: 'color',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
surface: {
|
|
66
|
+
$type: 'color',
|
|
67
|
+
$value: '#ffffff',
|
|
68
|
+
$extensions: {
|
|
69
|
+
'design-surface': {
|
|
70
|
+
label: 'Surface',
|
|
71
|
+
labelZh: '表面',
|
|
72
|
+
uiType: 'color',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
canvas: {
|
|
77
|
+
$type: 'color',
|
|
78
|
+
$value: '#f4f4f5',
|
|
79
|
+
$extensions: {
|
|
80
|
+
'design-surface': {
|
|
81
|
+
label: 'Canvas',
|
|
82
|
+
labelZh: '画布',
|
|
83
|
+
uiType: 'color',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
primary: {
|
|
88
|
+
$type: 'color',
|
|
89
|
+
$value: '#2563eb',
|
|
90
|
+
$extensions: {
|
|
91
|
+
'design-surface': {
|
|
92
|
+
label: 'Primary',
|
|
93
|
+
labelZh: '主色',
|
|
94
|
+
uiType: 'color',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
space: {
|
|
100
|
+
$extensions: {
|
|
101
|
+
'design-surface': {
|
|
102
|
+
tier: 'primitive',
|
|
103
|
+
group: 'space',
|
|
104
|
+
label: 'Space',
|
|
105
|
+
labelZh: '间距',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
$type: 'dimension',
|
|
109
|
+
card: {
|
|
110
|
+
$type: 'dimension',
|
|
111
|
+
$value: { value: 24, unit: 'px' },
|
|
112
|
+
$extensions: {
|
|
113
|
+
'design-surface': {
|
|
114
|
+
label: 'Card padding',
|
|
115
|
+
labelZh: '卡片内边距',
|
|
116
|
+
uiType: 'length',
|
|
117
|
+
min: 8,
|
|
118
|
+
max: 64,
|
|
119
|
+
step: 2,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
radius: {
|
|
125
|
+
$extensions: {
|
|
126
|
+
'design-surface': {
|
|
127
|
+
tier: 'primitive',
|
|
128
|
+
group: 'shape',
|
|
129
|
+
label: 'Shape',
|
|
130
|
+
labelZh: '形状',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
$type: 'dimension',
|
|
134
|
+
card: {
|
|
135
|
+
$type: 'dimension',
|
|
136
|
+
$value: { value: 12, unit: 'px' },
|
|
137
|
+
$extensions: {
|
|
138
|
+
'design-surface': {
|
|
139
|
+
label: 'Card radius',
|
|
140
|
+
labelZh: '卡片圆角',
|
|
141
|
+
uiType: 'length',
|
|
142
|
+
min: 0,
|
|
143
|
+
max: 32,
|
|
144
|
+
step: 1,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const STARTER_SEMANTIC = {
|
|
152
|
+
surface: {
|
|
153
|
+
$extensions: {
|
|
154
|
+
'design-surface': {
|
|
155
|
+
tier: 'semantic',
|
|
156
|
+
group: 'semantic-color',
|
|
157
|
+
label: 'Semantic color',
|
|
158
|
+
labelZh: '语义颜色',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
$type: 'color',
|
|
162
|
+
bg: {
|
|
163
|
+
$type: 'color',
|
|
164
|
+
$value: '{color.canvas}',
|
|
165
|
+
$extensions: {
|
|
166
|
+
'design-surface': {
|
|
167
|
+
label: 'Background',
|
|
168
|
+
labelZh: '背景',
|
|
169
|
+
uiType: 'color',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
card: {
|
|
174
|
+
$type: 'color',
|
|
175
|
+
$value: '{color.surface}',
|
|
176
|
+
$extensions: {
|
|
177
|
+
'design-surface': {
|
|
178
|
+
label: 'Card',
|
|
179
|
+
labelZh: '卡片',
|
|
180
|
+
uiType: 'color',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
text: {
|
|
185
|
+
$type: 'color',
|
|
186
|
+
$value: '{color.ink}',
|
|
187
|
+
$extensions: {
|
|
188
|
+
'design-surface': {
|
|
189
|
+
label: 'Text',
|
|
190
|
+
labelZh: '文字',
|
|
191
|
+
uiType: 'color',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
accent: {
|
|
196
|
+
$type: 'color',
|
|
197
|
+
$value: '{color.primary}',
|
|
198
|
+
$extensions: {
|
|
199
|
+
'design-surface': {
|
|
200
|
+
label: 'Accent',
|
|
201
|
+
labelZh: '强调色',
|
|
202
|
+
uiType: 'color',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export const STARTER_TOKENS_TS = `export {
|
|
210
|
+
tokenAliases,
|
|
211
|
+
tokenGroups,
|
|
212
|
+
tokenHealth,
|
|
213
|
+
tokenSourceHash,
|
|
214
|
+
tokenSources,
|
|
215
|
+
tokenValues,
|
|
216
|
+
} from './.seji/tokens.generated'
|
|
217
|
+
export type { TokenDef, TokenGroup, TokenTier, TokenType } from '@rien7/design-surface-runtime'
|
|
218
|
+
`
|
|
219
|
+
|
|
220
|
+
export const STARTER_PROVIDERS_TSX = `import type { ReactNode } from 'react'
|
|
221
|
+
|
|
222
|
+
export function Providers({ children }: { children: ReactNode }) {
|
|
223
|
+
return <>{children}</>
|
|
224
|
+
}
|
|
225
|
+
`
|
|
226
|
+
|
|
227
|
+
export const STARTER_COMPONENTS_TS = `export const componentPages: Record<string, { design: string; page: string }> = {}
|
|
228
|
+
`
|
|
229
|
+
|
|
230
|
+
const STARTER_TOKEN_FRAME = `function StarterFrame() {
|
|
231
|
+
return (
|
|
232
|
+
<div
|
|
233
|
+
data-ds="starter-shell"
|
|
234
|
+
style={{
|
|
235
|
+
minHeight: '100vh',
|
|
236
|
+
display: 'grid',
|
|
237
|
+
placeItems: 'center',
|
|
238
|
+
padding: 'var(--space-card, 24px)',
|
|
239
|
+
background: 'var(--surface-bg, #f4f4f5)',
|
|
240
|
+
color: 'var(--surface-text, #18181b)',
|
|
241
|
+
}}
|
|
242
|
+
>
|
|
243
|
+
<div
|
|
244
|
+
data-ds="starter-card"
|
|
245
|
+
style={{
|
|
246
|
+
padding: 'var(--space-card, 24px)',
|
|
247
|
+
borderRadius: 'var(--radius-card, 12px)',
|
|
248
|
+
background: 'var(--surface-card, #ffffff)',
|
|
249
|
+
border: '1px solid #e4e4e7',
|
|
250
|
+
maxWidth: 420,
|
|
251
|
+
}}
|
|
252
|
+
>
|
|
253
|
+
<h1 style={{ margin: '0 0 8px', fontSize: 18 }}>seji ready</h1>
|
|
254
|
+
<p style={{ margin: 0, fontSize: 13, lineHeight: 1.6, opacity: 0.75 }}>
|
|
255
|
+
These tokens live in design/tokens/. Mount real components from your app in frames.
|
|
256
|
+
</p>
|
|
257
|
+
</div>
|
|
258
|
+
</div>
|
|
259
|
+
)
|
|
260
|
+
}`
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* design/starter/design.tsx: a token card page, plus one page rendering a real component of the
|
|
264
|
+
* app when there is one (`component: { name, importLine, label }`).
|
|
265
|
+
*/
|
|
266
|
+
export function starterDesign(component) {
|
|
267
|
+
const appPage = component
|
|
268
|
+
? `
|
|
269
|
+
{
|
|
270
|
+
id: 'app',
|
|
271
|
+
title: ${JSON.stringify(component.label)},
|
|
272
|
+
size: [1280, 800],
|
|
273
|
+
board: StarterBoard,
|
|
274
|
+
frames: [
|
|
275
|
+
{
|
|
276
|
+
id: 'default',
|
|
277
|
+
title: ${JSON.stringify(component.label)},
|
|
278
|
+
size: [1280, 800],
|
|
279
|
+
component: AppFrame,
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
},`
|
|
283
|
+
: ''
|
|
284
|
+
return `import { defineDesign, type PageBoardProps } from '@rien7/design-surface-runtime'
|
|
285
|
+
${component ? `${component.importLine}
|
|
286
|
+
` : ''}
|
|
287
|
+
export default defineDesign({
|
|
288
|
+
title: 'Starter',
|
|
289
|
+
titleZh: '示例画板',
|
|
290
|
+
pages: [
|
|
291
|
+
{
|
|
292
|
+
id: 'main',
|
|
293
|
+
title: 'Tokens',
|
|
294
|
+
titleZh: '令牌',
|
|
295
|
+
size: [960, 640],
|
|
296
|
+
board: StarterBoard,
|
|
297
|
+
frames: [
|
|
298
|
+
{
|
|
299
|
+
id: 'default',
|
|
300
|
+
title: 'Default',
|
|
301
|
+
titleZh: '默认状态',
|
|
302
|
+
size: [960, 640],
|
|
303
|
+
component: StarterFrame,
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
},${appPage}
|
|
307
|
+
],
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
function StarterBoard({ frames, renderFrame }: PageBoardProps) {
|
|
311
|
+
return <div style={{ display: 'flex', gap: 24 }}>{frames.map(renderFrame)}</div>
|
|
312
|
+
}
|
|
313
|
+
${component ? `
|
|
314
|
+
function AppFrame() {
|
|
315
|
+
return <${component.name} />
|
|
316
|
+
}
|
|
317
|
+
` : ''}
|
|
318
|
+
${STARTER_TOKEN_FRAME}
|
|
319
|
+
`
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Write `files` ([{ rel, content }]) that do not exist yet. `[{ file, status: created | skipped }]`. */
|
|
323
|
+
export function writeScaffold(root, files, { dryRun = false } = {}) {
|
|
324
|
+
const results = []
|
|
325
|
+
for (const entry of files) {
|
|
326
|
+
const abs = join(root, entry.rel)
|
|
327
|
+
if (existsSync(abs)) {
|
|
328
|
+
results.push({ file: entry.rel, status: 'skipped' })
|
|
329
|
+
continue
|
|
330
|
+
}
|
|
331
|
+
if (!dryRun) {
|
|
332
|
+
mkdirSync(dirname(abs), { recursive: true })
|
|
333
|
+
writeFileSync(abs, entry.content)
|
|
334
|
+
}
|
|
335
|
+
results.push({ file: entry.rel, status: 'created', ...(entry.detail ? { detail: entry.detail } : {}) })
|
|
336
|
+
}
|
|
337
|
+
return results
|
|
338
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// 0.6.x compat for projects set up by design-surface 0.5.x (the tool was renamed to seji in 0.6.0):
|
|
2
|
+
//
|
|
3
|
+
// design/.design-surface/ → design/.seji/ (renamed as a whole: comments, screenshots,
|
|
4
|
+
// snapshots, consolidate plans move with it), and the
|
|
5
|
+
// files that name it: design/.gitignore, design/tokens.ts,
|
|
6
|
+
// design/tsconfig.json, design/tokens.config.json, the
|
|
7
|
+
// `shot` paths in design/<design>/review.json
|
|
8
|
+
// '@rien7/design-surface[/<sub>]' → '@rien7/seji[/<sub>]' in the app's code (vite config, src/, design/)
|
|
9
|
+
// package.json @rien7/design-surface → @rien7/seji (same range style, this version)
|
|
10
|
+
//
|
|
11
|
+
// `@rien7/design-surface-runtime` is a different package seji still uses: never touched.
|
|
12
|
+
// Every function reports `[{ file, status, detail }]` like the rest of setup.
|
|
13
|
+
import { existsSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'
|
|
14
|
+
import { join, relative, resolve, sep } from 'node:path'
|
|
15
|
+
|
|
16
|
+
import { CACHE_DIR, CACHE_DIR_NAME, GITIGNORE_ENTRY } from '../shared/projectFiles.mjs'
|
|
17
|
+
import { SAFE_DESIGN_ID, mutateReview } from '../shared/reviewStore.mjs'
|
|
18
|
+
|
|
19
|
+
export const OLD_PACKAGE = '@rien7/design-surface'
|
|
20
|
+
export const NEW_PACKAGE = '@rien7/seji'
|
|
21
|
+
export const LEGACY_CACHE_DIR_NAME = '.design-surface'
|
|
22
|
+
export const LEGACY_CACHE_DIR = `design/${LEGACY_CACHE_DIR_NAME}`
|
|
23
|
+
|
|
24
|
+
const OLD_GITIGNORE_HEADER = '# design-surface tool cache: regenerated by design-surface setup / dev / tokens build. Delete anytime.'
|
|
25
|
+
const NEW_GITIGNORE_HEADER = '# seji tool cache: regenerated by seji setup / dev / tokens build. Delete anytime.'
|
|
26
|
+
const OLD_IGNORE_LINE = /^(\s*\/?)\.design-surface(\/?(?:\*\*)?\s*)$/
|
|
27
|
+
|
|
28
|
+
const toPosix = (file) => file.split(sep).join('/')
|
|
29
|
+
const readText = (file) => {
|
|
30
|
+
try {
|
|
31
|
+
return readFileSync(file, 'utf8')
|
|
32
|
+
} catch {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Rewrite `file` with `edit(text)`; one result when it changed. */
|
|
38
|
+
function editFile(home, file, edit, detail, { dryRun }) {
|
|
39
|
+
const text = readText(file)
|
|
40
|
+
if (text === null) return []
|
|
41
|
+
const next = edit(text)
|
|
42
|
+
if (next === text) return []
|
|
43
|
+
if (!dryRun) writeFileSync(file, next)
|
|
44
|
+
return [{ file: toPosix(relative(home, file)), status: 'updated', detail }]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `home` is the directory holding design/. Only `.design-surface/` → renamed to `.seji/`; both →
|
|
49
|
+
* `.seji/` is used, the old one is left alone (status 'skipped', `warning` set). The references
|
|
50
|
+
* to the old dir are pointed at `.seji/` either way.
|
|
51
|
+
*/
|
|
52
|
+
export function migrateCacheDir(home, { dryRun = false } = {}) {
|
|
53
|
+
const designDir = resolve(home, 'design')
|
|
54
|
+
const oldDir = join(designDir, LEGACY_CACHE_DIR_NAME)
|
|
55
|
+
const newDir = join(designDir, CACHE_DIR_NAME)
|
|
56
|
+
const results = []
|
|
57
|
+
if (!existsSync(designDir)) return results
|
|
58
|
+
const hasOld = existsSync(oldDir)
|
|
59
|
+
const both = hasOld && existsSync(newDir)
|
|
60
|
+
if (hasOld && !both) {
|
|
61
|
+
if (!dryRun) renameSync(oldDir, newDir)
|
|
62
|
+
results.push({ file: `${LEGACY_CACHE_DIR}/`, status: 'moved', detail: `→ ${CACHE_DIR}/ (renamed with comments, screenshots and snapshots)` })
|
|
63
|
+
} else if (both) {
|
|
64
|
+
results.push({
|
|
65
|
+
file: `${LEGACY_CACHE_DIR}/`,
|
|
66
|
+
status: 'skipped',
|
|
67
|
+
detail: `${CACHE_DIR}/ exists and is used; the old cache was left as it is (delete it when nothing in it is needed)`,
|
|
68
|
+
warning: true,
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
results.push(
|
|
73
|
+
...editFile(home, join(designDir, '.gitignore'), (text) => {
|
|
74
|
+
const lines = text.split('\n')
|
|
75
|
+
const ignoresNew = lines.some((line) => /^\s*\/?\.seji\/?(?:\*\*)?\s*$/.test(line))
|
|
76
|
+
// With both dirs present the old line keeps ignoring the old dir; .seji/ gets its own line.
|
|
77
|
+
if (both) return ignoresNew ? text : `${text}${text.endsWith('\n') || !text ? '' : '\n'}${GITIGNORE_ENTRY}\n`
|
|
78
|
+
const out = []
|
|
79
|
+
for (const line of lines) {
|
|
80
|
+
if (line === OLD_GITIGNORE_HEADER) out.push(NEW_GITIGNORE_HEADER)
|
|
81
|
+
else if (OLD_IGNORE_LINE.test(line)) {
|
|
82
|
+
if (!ignoresNew) out.push(line.replace(OLD_IGNORE_LINE, '$1.seji$2'))
|
|
83
|
+
} else out.push(line)
|
|
84
|
+
}
|
|
85
|
+
return out.join('\n')
|
|
86
|
+
}, `${LEGACY_CACHE_DIR_NAME}/ → ${CACHE_DIR_NAME}/`, { dryRun }),
|
|
87
|
+
)
|
|
88
|
+
results.push(
|
|
89
|
+
...editFile(home, join(designDir, 'tokens.ts'), (text) => text.replace(/(['"])\.\/\.design-surface\/tokens\.generated((?:\.ts)?)\1/g, '$1./.seji/tokens.generated$2$1'), "imports './.seji/tokens.generated'", { dryRun }),
|
|
90
|
+
)
|
|
91
|
+
results.push(
|
|
92
|
+
...editFile(home, join(designDir, 'tsconfig.json'), (text) => text.replace(/(["'])((?:\.\/)?)\.design-surface\/tsconfig\.json\1/g, '$1$2.seji/tsconfig.json$1'), 'extends ./.seji/tsconfig.json', { dryRun }),
|
|
93
|
+
)
|
|
94
|
+
results.push(
|
|
95
|
+
...editFile(home, join(designDir, 'tokens.config.json'), (text) => text.replace(/(["'])design\/\.design-surface\//g, '$1design/.seji/'), `tsOut / manifestOut → ${CACHE_DIR}/`, { dryRun }),
|
|
96
|
+
)
|
|
97
|
+
if (!both) results.push(...migrateShotPaths(home, { dryRun }))
|
|
98
|
+
return results
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** `shot` fields recorded under design/.design-surface/comments/ now point into design/.seji/. */
|
|
102
|
+
function migrateShotPaths(home, { dryRun }) {
|
|
103
|
+
const designDir = resolve(home, 'design')
|
|
104
|
+
const results = []
|
|
105
|
+
const oldPrefix = `${LEGACY_CACHE_DIR}/`
|
|
106
|
+
const newPrefix = `${CACHE_DIR}/`
|
|
107
|
+
for (const entry of readdirSync(designDir, { withFileTypes: true })) {
|
|
108
|
+
if (!entry.isDirectory() || !SAFE_DESIGN_ID.test(entry.name)) continue
|
|
109
|
+
const text = readText(join(designDir, entry.name, 'review.json'))
|
|
110
|
+
if (!text || !text.includes(oldPrefix)) continue
|
|
111
|
+
let count = 0
|
|
112
|
+
const fix = (items) =>
|
|
113
|
+
(items ?? []).map((item) => {
|
|
114
|
+
if (typeof item?.shot !== 'string' || !item.shot.startsWith(oldPrefix)) return item
|
|
115
|
+
count += 1
|
|
116
|
+
return { ...item, shot: `${newPrefix}${item.shot.slice(oldPrefix.length)}` }
|
|
117
|
+
})
|
|
118
|
+
try {
|
|
119
|
+
if (dryRun) {
|
|
120
|
+
fix(JSON.parse(text).items)
|
|
121
|
+
} else {
|
|
122
|
+
mutateReview(home, entry.name, (review) => {
|
|
123
|
+
const items = fix(review.items)
|
|
124
|
+
return count ? { ...review, items } : undefined
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
} catch {
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
if (count) results.push({ file: `design/${entry.name}/review.json`, status: 'updated', detail: `${count} comment screenshot path(s) → ${CACHE_DIR}/comments/` })
|
|
131
|
+
}
|
|
132
|
+
return results
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ---- '@rien7/design-surface' imports ------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
const CODE_FILE = /\.(?:[cm]?[jt]sx?)$/
|
|
138
|
+
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'build', CACHE_DIR_NAME, LEGACY_CACHE_DIR_NAME, '.next', 'coverage'])
|
|
139
|
+
// A quoted '@rien7/design-surface' or '@rien7/design-surface/<sub>'; '-runtime' does not match.
|
|
140
|
+
const OLD_SPECIFIER = /(['"`])@rien7\/design-surface((?:\/[^'"`\s]*)?)\1/g
|
|
141
|
+
|
|
142
|
+
/** Code files to scan: top-level config files of each root, plus src/ and design/ under it. */
|
|
143
|
+
function codeFiles(roots) {
|
|
144
|
+
const files = new Set()
|
|
145
|
+
const walk = (dir) => {
|
|
146
|
+
let entries
|
|
147
|
+
try {
|
|
148
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
149
|
+
} catch {
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
for (const entry of entries) {
|
|
153
|
+
if (entry.isDirectory()) {
|
|
154
|
+
if (!SKIP_DIRS.has(entry.name)) walk(join(dir, entry.name))
|
|
155
|
+
} else if (CODE_FILE.test(entry.name) && !entry.name.endsWith('.d.ts')) files.add(join(dir, entry.name))
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const root of new Set(roots.map((dir) => resolve(dir)))) {
|
|
159
|
+
try {
|
|
160
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
161
|
+
if (entry.isFile() && CODE_FILE.test(entry.name)) files.add(join(root, entry.name))
|
|
162
|
+
}
|
|
163
|
+
} catch {
|
|
164
|
+
continue
|
|
165
|
+
}
|
|
166
|
+
for (const sub of ['src', 'design']) if (existsSync(join(root, sub)) && statSync(join(root, sub)).isDirectory()) walk(join(root, sub))
|
|
167
|
+
}
|
|
168
|
+
return [...files].sort()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const countOld = (text) => (text.match(OLD_SPECIFIER) ?? []).length
|
|
172
|
+
|
|
173
|
+
/** Files under `roots` that import '@rien7/design-surface[/<sub>]': `[{ file (relative to roots[0]), count }]`. */
|
|
174
|
+
export function findOldImports(roots) {
|
|
175
|
+
const base = resolve(roots[0])
|
|
176
|
+
const found = []
|
|
177
|
+
for (const file of codeFiles(roots)) {
|
|
178
|
+
const text = readText(file)
|
|
179
|
+
const count = text ? countOld(text) : 0
|
|
180
|
+
if (count) found.push({ file: toPosix(relative(base, file)), count })
|
|
181
|
+
}
|
|
182
|
+
return found
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Rewrite those imports to '@rien7/seji[/<sub>]'. */
|
|
186
|
+
export function rewriteOldImports(roots, { dryRun = false } = {}) {
|
|
187
|
+
const base = resolve(roots[0])
|
|
188
|
+
const results = []
|
|
189
|
+
for (const file of codeFiles(roots)) {
|
|
190
|
+
const text = readText(file)
|
|
191
|
+
if (!text) continue
|
|
192
|
+
const count = countOld(text)
|
|
193
|
+
if (!count) continue
|
|
194
|
+
if (!dryRun) writeFileSync(file, text.replace(OLD_SPECIFIER, `$1${NEW_PACKAGE}$2$1`))
|
|
195
|
+
results.push({ file: toPosix(relative(base, file)), status: 'updated', detail: `${count} import(s) ${OLD_PACKAGE} → ${NEW_PACKAGE}` })
|
|
196
|
+
}
|
|
197
|
+
return results
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// ---- package.json -------------------------------------------------------------------------------
|
|
201
|
+
|
|
202
|
+
const DEP_SECTIONS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
|
|
203
|
+
|
|
204
|
+
/** The same range style pointing at `version`: '^0.5.1' → '^0.6.0', '0.5.1' → '0.6.0'; 'latest', '*', 'workspace:…' kept. */
|
|
205
|
+
export function swapRange(range, version) {
|
|
206
|
+
const match = /^\s*(\^|~|>=|=)?v?\d+(?:\.\d+){0,2}(?:-[\w.]+)?\s*$/.exec(String(range))
|
|
207
|
+
return match ? `${match[1] ?? ''}${version}` : range
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Sections of `root`/package.json that declare @rien7/design-surface: `[{ section, range }]`. */
|
|
211
|
+
export function oldDependency(root) {
|
|
212
|
+
const pkg = (() => {
|
|
213
|
+
try {
|
|
214
|
+
return JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
|
|
215
|
+
} catch {
|
|
216
|
+
return null
|
|
217
|
+
}
|
|
218
|
+
})()
|
|
219
|
+
if (!pkg) return []
|
|
220
|
+
return DEP_SECTIONS.filter((section) => typeof pkg[section]?.[OLD_PACKAGE] === 'string').map((section) => ({ section, range: pkg[section][OLD_PACKAGE] }))
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Replace @rien7/design-surface with @rien7/seji in package.json, in place (key order and indentation kept). */
|
|
224
|
+
export function swapOldDependency(root, { version, dryRun = false } = {}) {
|
|
225
|
+
const file = join(root, 'package.json')
|
|
226
|
+
const text = readText(file)
|
|
227
|
+
if (!text) return []
|
|
228
|
+
let pkg
|
|
229
|
+
try {
|
|
230
|
+
pkg = JSON.parse(text)
|
|
231
|
+
} catch {
|
|
232
|
+
return []
|
|
233
|
+
}
|
|
234
|
+
const changes = []
|
|
235
|
+
for (const section of DEP_SECTIONS) {
|
|
236
|
+
const deps = pkg[section]
|
|
237
|
+
if (!deps || typeof deps[OLD_PACKAGE] !== 'string') continue
|
|
238
|
+
const range = deps[OLD_PACKAGE]
|
|
239
|
+
const next = {}
|
|
240
|
+
for (const [name, value] of Object.entries(deps)) {
|
|
241
|
+
if (name === OLD_PACKAGE) {
|
|
242
|
+
if (!(NEW_PACKAGE in deps)) next[NEW_PACKAGE] = swapRange(range, version)
|
|
243
|
+
} else next[name] = value
|
|
244
|
+
}
|
|
245
|
+
pkg[section] = next
|
|
246
|
+
changes.push(`${section}: ${OLD_PACKAGE} ${range} → ${NEW_PACKAGE} ${next[NEW_PACKAGE] ?? deps[NEW_PACKAGE]}`)
|
|
247
|
+
}
|
|
248
|
+
if (!changes.length) return []
|
|
249
|
+
const indent = /^[{[]\r?\n([ \t]+)/.exec(text)?.[1] ?? ' '
|
|
250
|
+
if (!dryRun) writeFileSync(file, `${JSON.stringify(pkg, null, indent)}${text.endsWith('\n') ? '\n' : ''}`)
|
|
251
|
+
return [{ file: 'package.json', status: 'updated', detail: changes.join('; ') }]
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** For doctor: what of 0.5.x naming is still in the project. */
|
|
255
|
+
export function oldNameState({ home, appRoot }) {
|
|
256
|
+
const roots = [appRoot, ...(resolve(home) === resolve(appRoot) ? [] : [home])]
|
|
257
|
+
return {
|
|
258
|
+
cache: existsSync(join(home, LEGACY_CACHE_DIR)),
|
|
259
|
+
imports: findOldImports(roots),
|
|
260
|
+
dependency: [...new Set(roots)].flatMap((dir) => oldDependency(dir).map((entry) => ({ ...entry, dir }))),
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** One line per result, for the CLI's stderr (commands other than setup). */
|
|
265
|
+
export const formatCacheMigration = (results) =>
|
|
266
|
+
results.map((item) => `seji: ${item.status === 'moved' ? 'renamed' : item.status === 'skipped' ? 'kept' : 'updated'} ${item.file} ${item.detail ?? ''}`.trimEnd())
|