@cakejp/design-system 0.3.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.
Files changed (131) hide show
  1. package/AGENTS.md +144 -0
  2. package/CHANGELOG.md +115 -0
  3. package/CLAUDE.md +188 -0
  4. package/CLAUDE_PRODUCTION.md +121 -0
  5. package/MIGRATION.md +228 -0
  6. package/README.md +79 -0
  7. package/RELEASE.md +205 -0
  8. package/bin/init.js +134 -0
  9. package/component-registry.json +1146 -0
  10. package/contracts/components.json +730 -0
  11. package/contracts/rules.json +559 -0
  12. package/dist/index.css +1 -0
  13. package/dist/index.js +9344 -0
  14. package/dist/types/components/ec/_mypage-menu-data.d.ts +15 -0
  15. package/dist/types/components/ec/admin-layout.d.ts +31 -0
  16. package/dist/types/components/ec/anniversary-card.d.ts +50 -0
  17. package/dist/types/components/ec/cake-logo.d.ts +22 -0
  18. package/dist/types/components/ec/chart-controls.d.ts +16 -0
  19. package/dist/types/components/ec/countdown-timer.d.ts +24 -0
  20. package/dist/types/components/ec/coupon-card.d.ts +47 -0
  21. package/dist/types/components/ec/delivery-calendar.d.ts +36 -0
  22. package/dist/types/components/ec/order-section.d.ts +29 -0
  23. package/dist/types/components/ec/order-summary.d.ts +36 -0
  24. package/dist/types/components/ec/payment-method.d.ts +41 -0
  25. package/dist/types/components/ec/product-card.d.ts +77 -0
  26. package/dist/types/components/ec/product-carousel.d.ts +56 -0
  27. package/dist/types/components/ec/product-cta.d.ts +35 -0
  28. package/dist/types/components/ec/product-detail-bar.d.ts +62 -0
  29. package/dist/types/components/ec/product-detail-sidebar.d.ts +115 -0
  30. package/dist/types/components/ec/product-list-item.d.ts +90 -0
  31. package/dist/types/components/ec/product-option.d.ts +62 -0
  32. package/dist/types/components/ec/rating-stars.d.ts +30 -0
  33. package/dist/types/components/ec/review-card.d.ts +44 -0
  34. package/dist/types/components/ec/review-form.d.ts +40 -0
  35. package/dist/types/components/ec/review-summary.d.ts +53 -0
  36. package/dist/types/components/ec/shop-card.d.ts +48 -0
  37. package/dist/types/components/ec/stat-card.d.ts +44 -0
  38. package/dist/types/components/foundations/accordion.d.ts +7 -0
  39. package/dist/types/components/foundations/alert-dialog.d.ts +18 -0
  40. package/dist/types/components/foundations/alert.d.ts +42 -0
  41. package/dist/types/components/foundations/aspect-ratio.d.ts +3 -0
  42. package/dist/types/components/foundations/avatar.d.ts +11 -0
  43. package/dist/types/components/foundations/badge.d.ts +9 -0
  44. package/dist/types/components/foundations/breadcrumb.d.ts +11 -0
  45. package/dist/types/components/foundations/button.d.ts +10 -0
  46. package/dist/types/components/foundations/calendar.d.ts +8 -0
  47. package/dist/types/components/foundations/card.d.ts +9 -0
  48. package/dist/types/components/foundations/checkbox-card.d.ts +30 -0
  49. package/dist/types/components/foundations/checkbox-group.d.ts +53 -0
  50. package/dist/types/components/foundations/checkbox.d.ts +4 -0
  51. package/dist/types/components/foundations/collapsible.d.ts +5 -0
  52. package/dist/types/components/foundations/command.d.ts +18 -0
  53. package/dist/types/components/foundations/context-menu.d.ts +25 -0
  54. package/dist/types/components/foundations/data-table.d.ts +104 -0
  55. package/dist/types/components/foundations/dialog.d.ts +17 -0
  56. package/dist/types/components/foundations/drawer.d.ts +13 -0
  57. package/dist/types/components/foundations/dropdown-menu.d.ts +25 -0
  58. package/dist/types/components/foundations/form.d.ts +24 -0
  59. package/dist/types/components/foundations/hover-card.d.ts +6 -0
  60. package/dist/types/components/foundations/input.d.ts +3 -0
  61. package/dist/types/components/foundations/label.d.ts +7 -0
  62. package/dist/types/components/foundations/menubar.d.ts +26 -0
  63. package/dist/types/components/foundations/navigation-menu.d.ts +14 -0
  64. package/dist/types/components/foundations/pagination.d.ts +13 -0
  65. package/dist/types/components/foundations/popover.d.ts +10 -0
  66. package/dist/types/components/foundations/progress.d.ts +4 -0
  67. package/dist/types/components/foundations/radio-group.d.ts +9 -0
  68. package/dist/types/components/foundations/responsive-dialog.d.ts +52 -0
  69. package/dist/types/components/foundations/scroll-area.d.ts +5 -0
  70. package/dist/types/components/foundations/select.d.ts +15 -0
  71. package/dist/types/components/foundations/separator.d.ts +4 -0
  72. package/dist/types/components/foundations/sheet.d.ts +14 -0
  73. package/dist/types/components/foundations/skeleton.d.ts +2 -0
  74. package/dist/types/components/foundations/slider.d.ts +4 -0
  75. package/dist/types/components/foundations/sonner.d.ts +3 -0
  76. package/dist/types/components/foundations/spinner.d.ts +6 -0
  77. package/dist/types/components/foundations/switch.d.ts +13 -0
  78. package/dist/types/components/foundations/table.d.ts +10 -0
  79. package/dist/types/components/foundations/tabs.d.ts +12 -0
  80. package/dist/types/components/foundations/textarea.d.ts +3 -0
  81. package/dist/types/components/foundations/toggle-group.d.ts +23 -0
  82. package/dist/types/components/foundations/toggle.d.ts +9 -0
  83. package/dist/types/components/foundations/tooltip.d.ts +7 -0
  84. package/dist/types/components/pages/cake/_mypage-shell.d.ts +41 -0
  85. package/dist/types/components/primitives/banner-carousel.d.ts +54 -0
  86. package/dist/types/components/primitives/bottom-tab-bar.d.ts +39 -0
  87. package/dist/types/components/primitives/bulk-action-bar.d.ts +32 -0
  88. package/dist/types/components/primitives/category-scroll.d.ts +70 -0
  89. package/dist/types/components/primitives/category-shortcuts.d.ts +44 -0
  90. package/dist/types/components/primitives/chip.d.ts +44 -0
  91. package/dist/types/components/primitives/coach-mark.d.ts +28 -0
  92. package/dist/types/components/primitives/empty-state.d.ts +36 -0
  93. package/dist/types/components/primitives/error-state.d.ts +41 -0
  94. package/dist/types/components/primitives/filter-bar.d.ts +56 -0
  95. package/dist/types/components/primitives/footer.d.ts +81 -0
  96. package/dist/types/components/primitives/form-field.d.ts +46 -0
  97. package/dist/types/components/primitives/header.d.ts +69 -0
  98. package/dist/types/components/primitives/image-carousel.d.ts +52 -0
  99. package/dist/types/components/primitives/image-gallery.d.ts +35 -0
  100. package/dist/types/components/primitives/image-uploader.d.ts +19 -0
  101. package/dist/types/components/primitives/kebab-menu.d.ts +38 -0
  102. package/dist/types/components/primitives/list-item.d.ts +60 -0
  103. package/dist/types/components/primitives/menu-drawer.d.ts +75 -0
  104. package/dist/types/components/primitives/notification-badge.d.ts +30 -0
  105. package/dist/types/components/primitives/notification-list.d.ts +45 -0
  106. package/dist/types/components/primitives/price-display.d.ts +33 -0
  107. package/dist/types/components/primitives/progress-steps.d.ts +27 -0
  108. package/dist/types/components/primitives/quantity-selector.d.ts +50 -0
  109. package/dist/types/components/primitives/search-bar.d.ts +31 -0
  110. package/dist/types/components/primitives/search-panel.d.ts +41 -0
  111. package/dist/types/components/primitives/section-header.d.ts +51 -0
  112. package/dist/types/components/primitives/share-buttons.d.ts +23 -0
  113. package/dist/types/components/primitives/side-nav.d.ts +62 -0
  114. package/dist/types/components/primitives/social-login-button.d.ts +24 -0
  115. package/dist/types/components/primitives/status-count-tabs.d.ts +14 -0
  116. package/dist/types/components/primitives/sticky-action-bar.d.ts +7 -0
  117. package/dist/types/components/primitives/sub-nav.d.ts +34 -0
  118. package/dist/types/components/primitives/tag.d.ts +19 -0
  119. package/dist/types/index.d.ts +109 -0
  120. package/dist/types/lib/utils.d.ts +2 -0
  121. package/package.json +186 -0
  122. package/scripts/codemod/check-migration.mjs +97 -0
  123. package/scripts/codemod/v0.2-to-v0.3.mjs +192 -0
  124. package/src/preset-standalone.css +109 -0
  125. package/src/preset.css +288 -0
  126. package/src/styles/primitive.css +139 -0
  127. package/src/styles/semantic.css +203 -0
  128. package/src/styles/typography.css +129 -0
  129. package/templates/AGENTS.md +56 -0
  130. package/templates/CLAUDE.md +56 -0
  131. package/tokens.json +127 -0
package/package.json ADDED
@@ -0,0 +1,186 @@
1
+ {
2
+ "name": "@cakejp/design-system",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "description": "Cake.jp Design System — UI コンポーネント・カラートークン・タイポグラフィ",
6
+ "license": "UNLICENSED",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/flashpark/cake-design-system.git"
10
+ },
11
+ "homepage": "https://flashpark.github.io/cake-design-system/",
12
+ "bugs": {
13
+ "url": "https://github.com/flashpark/cake-design-system/issues"
14
+ },
15
+ "keywords": [
16
+ "cakejp",
17
+ "design-system",
18
+ "react",
19
+ "ui-components",
20
+ "shadcn",
21
+ "tailwindcss"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org/"
26
+ },
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/types/index.d.ts",
30
+ "bin": {
31
+ "cakejp-ds": "./bin/init.js"
32
+ },
33
+ "files": [
34
+ "AGENTS.md",
35
+ "CHANGELOG.md",
36
+ "CLAUDE.md",
37
+ "CLAUDE_PRODUCTION.md",
38
+ "MIGRATION.md",
39
+ "RELEASE.md",
40
+ "bin",
41
+ "component-registry.json",
42
+ "contracts",
43
+ "dist",
44
+ "scripts/codemod",
45
+ "src/preset-standalone.css",
46
+ "src/preset.css",
47
+ "src/styles",
48
+ "templates",
49
+ "tokens.json"
50
+ ],
51
+ "exports": {
52
+ ".": {
53
+ "types": "./dist/types/index.d.ts",
54
+ "import": "./dist/index.js",
55
+ "default": "./dist/index.js"
56
+ },
57
+ "./package.json": "./package.json",
58
+ "./dist/index.css": {
59
+ "style": "./dist/index.css",
60
+ "default": "./dist/index.css"
61
+ },
62
+ "./preset": "./src/preset.css",
63
+ "./preset-standalone": "./src/preset-standalone.css",
64
+ "./styles": "./src/preset.css",
65
+ "./tokens/primitive": "./src/styles/primitive.css",
66
+ "./tokens/semantic": "./src/styles/semantic.css",
67
+ "./tokens/typography": "./src/styles/typography.css"
68
+ },
69
+ "sideEffects": [
70
+ "*.css"
71
+ ],
72
+ "scripts": {
73
+ "dev": "vite",
74
+ "build": "tsc -b && vite build",
75
+ "build:lib": "vite build --config vite.config.lib.ts && tsc --project tsconfig.lib.json && tsc-alias --project tsconfig.lib.json",
76
+ "prepack": "npm run build:lib",
77
+ "postinstall": "node ./bin/init.js postinstall",
78
+ "lint": "eslint .",
79
+ "preview": "vite preview",
80
+ "storybook": "storybook dev -p 6006",
81
+ "build-storybook": "storybook build",
82
+ "lint:scratch": "bash scripts/lint-scratch.sh",
83
+ "lint:reuse": "bash scripts/check-story-reuse.sh",
84
+ "generate:lint-rules": "node scripts/generate-lint-rules.mjs",
85
+ "check": "tsc --noEmit && bash scripts/check-deps.sh && bash scripts/check-drift.sh && bash scripts/lint-scratch.sh && bash scripts/check-story-reuse.sh && bash scripts/check-responsive.sh",
86
+ "test": "vitest run --config vitest.config.ts"
87
+ },
88
+ "dependencies": {
89
+ "class-variance-authority": "^0.7.1",
90
+ "clsx": "^2.1.1",
91
+ "tailwind-merge": "^3.5.0"
92
+ },
93
+ "peerDependencies": {
94
+ "@hookform/resolvers": "^5.0.0",
95
+ "cmdk": "^1.0.0",
96
+ "date-fns": "^4.0.0",
97
+ "iconsax-reactjs": "^0.0.8",
98
+ "lucide-react": ">=0.400.0",
99
+ "next-themes": "^0.4.0",
100
+ "radix-ui": "^1.0.0",
101
+ "react": "^18.0.0 || ^19.0.0",
102
+ "react-day-picker": "^9.0.0",
103
+ "react-dom": "^18.0.0 || ^19.0.0",
104
+ "react-hook-form": "^7.0.0",
105
+ "sonner": "^2.0.0",
106
+ "tailwindcss": "^4.0.0",
107
+ "vaul": "^1.0.0",
108
+ "zod": "^4.0.0"
109
+ },
110
+ "peerDependenciesMeta": {
111
+ "@hookform/resolvers": {
112
+ "optional": true
113
+ },
114
+ "react-hook-form": {
115
+ "optional": true
116
+ },
117
+ "zod": {
118
+ "optional": true
119
+ },
120
+ "react-day-picker": {
121
+ "optional": true
122
+ },
123
+ "date-fns": {
124
+ "optional": true
125
+ },
126
+ "cmdk": {
127
+ "optional": true
128
+ },
129
+ "next-themes": {
130
+ "optional": true
131
+ },
132
+ "vaul": {
133
+ "optional": true
134
+ },
135
+ "sonner": {
136
+ "optional": true
137
+ }
138
+ },
139
+ "devDependencies": {
140
+ "@chromatic-com/storybook": "^5.1.1",
141
+ "@eslint/js": "^9.39.1",
142
+ "@hookform/resolvers": "^5.2.2",
143
+ "@storybook/addon-a11y": "^10.3.3",
144
+ "@storybook/addon-docs": "^10.3.3",
145
+ "@storybook/addon-mcp": "^0.4.2",
146
+ "@storybook/addon-onboarding": "^10.3.3",
147
+ "@storybook/addon-vitest": "^10.3.3",
148
+ "@storybook/react-vite": "^10.3.3",
149
+ "@tailwindcss/vite": "^4.2.1",
150
+ "@types/node": "^24.10.1",
151
+ "@types/react": "^19.2.7",
152
+ "@types/react-dom": "^19.2.3",
153
+ "@vitejs/plugin-react": "^5.1.1",
154
+ "@vitest/browser-playwright": "^4.1.0",
155
+ "@vitest/coverage-v8": "^4.1.0",
156
+ "@xyflow/react": "^12.10.1",
157
+ "cmdk": "^1.1.1",
158
+ "date-fns": "^4.1.0",
159
+ "eslint": "^9.39.1",
160
+ "eslint-plugin-react-hooks": "^7.0.1",
161
+ "eslint-plugin-react-refresh": "^0.4.24",
162
+ "eslint-plugin-storybook": "^10.3.3",
163
+ "globals": "^16.5.0",
164
+ "iconsax-reactjs": "^0.0.8",
165
+ "lucide-react": "^0.577.0",
166
+ "next-themes": "^0.4.6",
167
+ "playwright": "^1.58.2",
168
+ "radix-ui": "^1.4.3",
169
+ "react": "^19.2.0",
170
+ "react-day-picker": "^9.14.0",
171
+ "react-dom": "^19.2.0",
172
+ "react-hook-form": "^7.71.2",
173
+ "shadcn": "^3.8.5",
174
+ "sonner": "^2.0.7",
175
+ "storybook": "^10.3.3",
176
+ "tailwindcss": "^4.2.1",
177
+ "tsc-alias": "^1.8.16",
178
+ "tw-animate-css": "^1.4.0",
179
+ "typescript": "~5.9.3",
180
+ "typescript-eslint": "^8.48.0",
181
+ "vaul": "^1.1.2",
182
+ "vite": "^7.3.1",
183
+ "vitest": "^4.1.0",
184
+ "zod": "^4.3.6"
185
+ }
186
+ }
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Migration progress checker
4
+ *
5
+ * 利用側プロジェクトで旧 API 利用箇所を検出してリストアップする。
6
+ * 実際の変更は行わない(read-only)。
7
+ *
8
+ * 使い方:
9
+ * npx @cakejp/design-system check-migration ./src
10
+ */
11
+
12
+ import fs from "node:fs"
13
+ import path from "node:path"
14
+
15
+ const DEPRECATED_NAMES = [
16
+ "TopAppBar",
17
+ "TopAppBarProps",
18
+ "TopAppBarAction",
19
+ "TopAppBarNavItem",
20
+ "BottomNavigation",
21
+ "BottomNavigationProps",
22
+ "BottomNavigationItem",
23
+ "BottomAction",
24
+ "Balloon",
25
+ "BalloonProps",
26
+ "BalloonDirection",
27
+ "NavigationRibbon",
28
+ "NavigationRibbonProps",
29
+ "NavigationRibbonItem",
30
+ "CategoryIconStrip",
31
+ "CategoryIconStripProps",
32
+ "CategoryIconItem",
33
+ "MypageSidebar",
34
+ "MypageSidebarProps",
35
+ "MypageSidebarItem",
36
+ "MypageSidebarGroup",
37
+ "mypageSidebarDefaultGroups",
38
+ ]
39
+
40
+ const targetDir = process.argv[2] || "./src"
41
+ if (!fs.existsSync(targetDir)) {
42
+ console.error(`✗ Directory not found: ${targetDir}`)
43
+ process.exit(1)
44
+ }
45
+
46
+ console.log(`\n🔍 Migration check\n Target: ${path.resolve(targetDir)}\n`)
47
+
48
+ function findFiles(dir) {
49
+ const results = []
50
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
51
+ const full = path.join(dir, entry.name)
52
+ if (entry.isDirectory()) {
53
+ if (entry.name === "node_modules" || entry.name === "dist" || entry.name.startsWith(".")) continue
54
+ results.push(...findFiles(full))
55
+ } else if (/\.(ts|tsx|js|jsx|mjs|cjs)$/.test(entry.name)) {
56
+ results.push(full)
57
+ }
58
+ }
59
+ return results
60
+ }
61
+
62
+ const findings = {}
63
+ let totalFindings = 0
64
+
65
+ for (const file of findFiles(targetDir)) {
66
+ const text = fs.readFileSync(file, "utf-8")
67
+ if (!/@cakejp\/design-system/.test(text)) continue
68
+ for (const name of DEPRECATED_NAMES) {
69
+ const re = new RegExp(`\\b${name}\\b`, "g")
70
+ const matches = text.match(re)
71
+ if (matches) {
72
+ findings[name] = (findings[name] || 0) + matches.length
73
+ totalFindings += matches.length
74
+ }
75
+ }
76
+ }
77
+
78
+ if (totalFindings === 0) {
79
+ console.log("✓ 旧 API の利用は見つかりませんでした。移行完了 🎉")
80
+ process.exit(0)
81
+ }
82
+
83
+ console.log(`📊 旧 API 利用箇所: ${totalFindings} 件\n`)
84
+ console.log(` API Count`)
85
+ console.log(` ─────────────────────────────────── ─────`)
86
+
87
+ const sorted = Object.entries(findings).sort((a, b) => b[1] - a[1])
88
+ for (const [name, count] of sorted) {
89
+ console.log(` ${name.padEnd(36)} ${count.toString().padStart(5)}`)
90
+ }
91
+
92
+ console.log("")
93
+ console.log("💡 自動移行コマンド:")
94
+ console.log(" npx @cakejp/design-system codemod v0.2-to-v0.3 " + targetDir)
95
+ console.log("")
96
+ console.log("📖 詳細: https://github.com/flashpark/cake-design-system/blob/main/MIGRATION.md")
97
+ process.exit(1)
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Codemod: @cakejp/design-system v0.2.x → v0.3.0
4
+ *
5
+ * 利用側プロジェクトで実行して、旧 API 名を新 API 名に自動置換する。
6
+ *
7
+ * 使い方:
8
+ * npx @cakejp/design-system codemod v0.2-to-v0.3 ./src
9
+ * または
10
+ * node node_modules/@cakejp/design-system/scripts/codemod/v0.2-to-v0.3.mjs ./src
11
+ *
12
+ * 対象:
13
+ * - import { TopAppBar } from '@cakejp/design-system' → import { Header }
14
+ * - <TopAppBar ... /> → <Header ... />
15
+ * - type X = TopAppBarProps → type X = HeaderProps
16
+ * - 全 7 個の rename + MypageSidebar
17
+ *
18
+ * 注意:
19
+ * - 正規表現ベースなので 100% 正確ではない(複雑なケースは手動確認推奨)
20
+ * - --dry オプションで事前確認可能
21
+ * - 必ずコミット済みの状態で実行すること(git diff で変更確認)
22
+ */
23
+
24
+ import fs from "node:fs"
25
+ import path from "node:path"
26
+
27
+ // ============================================================
28
+ // 置換ルール
29
+ // ============================================================
30
+
31
+ /** 完全な単語境界マッチ(識別子の一部にならないよう) */
32
+ const RENAMES = [
33
+ // [old, new]
34
+ ["TopAppBar", "Header"],
35
+ ["TopAppBarProps", "HeaderProps"],
36
+ ["TopAppBarAction", "HeaderAction"],
37
+ ["TopAppBarNavItem", "HeaderNavItem"],
38
+
39
+ ["BottomNavigation", "BottomTabBar"],
40
+ ["BottomNavigationProps", "BottomTabBarProps"],
41
+ ["BottomNavigationItem", "BottomTabBarItem"],
42
+
43
+ ["BottomAction", "StickyActionBar"],
44
+
45
+ ["Balloon", "CoachMark"],
46
+ ["BalloonProps", "CoachMarkProps"],
47
+ ["BalloonDirection", "CoachMarkDirection"],
48
+
49
+ ["NavigationRibbon", "SubNav"],
50
+ ["NavigationRibbonProps", "SubNavProps"],
51
+ ["NavigationRibbonItem", "SubNavItem"],
52
+
53
+ ["CategoryIconStrip", "CategoryShortcuts"],
54
+ ["CategoryIconStripProps", "CategoryShortcutsProps"],
55
+ ["CategoryIconItem", "CategoryShortcutsItem"],
56
+
57
+ ["mypageSidebarDefaultGroups", "mypageMenuGroups"],
58
+
59
+ // MypageSidebar の関連型は SideNav* に移行
60
+ ["MypageSidebarProps", "SideNavProps"],
61
+ ["MypageSidebarItem", "SideNavItem"],
62
+ ["MypageSidebarGroup", "SideNavGroup"],
63
+ ]
64
+
65
+ // 長い名前から順にマッチさせる(部分マッチ防止)
66
+ RENAMES.sort((a, b) => b[0].length - a[0].length)
67
+
68
+ // ============================================================
69
+ // CLI 引数
70
+ // ============================================================
71
+
72
+ const args = process.argv.slice(2)
73
+ const dry = args.includes("--dry")
74
+ const targetDir = args.find((a) => !a.startsWith("--")) || "./src"
75
+
76
+ if (!fs.existsSync(targetDir)) {
77
+ console.error(`✗ Directory not found: ${targetDir}`)
78
+ process.exit(1)
79
+ }
80
+
81
+ console.log(`\n🔧 Codemod v0.2 → v0.3`)
82
+ console.log(` Target: ${path.resolve(targetDir)}`)
83
+ console.log(` Mode: ${dry ? "DRY RUN (no changes written)" : "APPLY"}`)
84
+ console.log("")
85
+
86
+ // ============================================================
87
+ // ファイル探索
88
+ // ============================================================
89
+
90
+ /** @returns {string[]} */
91
+ function findFiles(dir) {
92
+ const results = []
93
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
94
+ const full = path.join(dir, entry.name)
95
+ if (entry.isDirectory()) {
96
+ if (entry.name === "node_modules" || entry.name === "dist" || entry.name.startsWith(".")) continue
97
+ results.push(...findFiles(full))
98
+ } else if (/\.(ts|tsx|js|jsx|mjs|cjs)$/.test(entry.name)) {
99
+ results.push(full)
100
+ }
101
+ }
102
+ return results
103
+ }
104
+
105
+ // ============================================================
106
+ // 変換
107
+ // ============================================================
108
+
109
+ let totalFiles = 0
110
+ let totalChanges = 0
111
+ const fileChanges = []
112
+
113
+ for (const file of findFiles(targetDir)) {
114
+ const original = fs.readFileSync(file, "utf-8")
115
+ let updated = original
116
+ let fileChangeCount = 0
117
+
118
+ // @cakejp/design-system からの import がある or 単純に旧名を含むファイルのみ対象
119
+ // (誤爆防止: 関係ない identifier は触らない)
120
+ const usesPackage = /@cakejp\/design-system/.test(original)
121
+ if (!usesPackage) continue
122
+
123
+ for (const [oldName, newName] of RENAMES) {
124
+ // \b は識別子境界
125
+ const re = new RegExp(`\\b${oldName}\\b`, "g")
126
+ const matches = updated.match(re)
127
+ if (matches) {
128
+ updated = updated.replace(re, newName)
129
+ fileChangeCount += matches.length
130
+ }
131
+ }
132
+
133
+ // MypageSidebar コンポーネント自体は wrapper があるが、
134
+ // 利用側に SideNav + mypageMenuGroups への明示的な書き換えを促す
135
+ // (ここは正規表現では難しいので警告のみ)
136
+ if (/\bMypageSidebar\b/.test(original)) {
137
+ console.log(` ⚠ ${file}: MypageSidebar の利用が見つかりました。`)
138
+ console.log(` SideNav + mypageMenuGroups への手動移行を推奨します。`)
139
+ console.log(` 詳細: MIGRATION.md`)
140
+ }
141
+
142
+ // Banner は Alert (variant="notice-*") に統合。
143
+ // variant 値の変換が必要なため警告のみ(自動置換は誤爆リスク高)
144
+ if (/\bBanner\b/.test(original) && !/\bBannerCarousel\b/.test(original.replace(/\bBanner\b/g, ''))) {
145
+ console.log(` ⚠ ${file}: Banner の利用が見つかりました。`)
146
+ console.log(` Alert (variant="notice-*") への手動移行を推奨します。`)
147
+ console.log(` 例: <Banner variant="caution" ... /> → <Alert variant="notice-caution" ... />`)
148
+ console.log(` 詳細: MIGRATION.md`)
149
+ }
150
+
151
+ if (fileChangeCount > 0) {
152
+ totalFiles++
153
+ totalChanges += fileChangeCount
154
+ fileChanges.push({ file, count: fileChangeCount })
155
+ if (!dry) {
156
+ fs.writeFileSync(file, updated, "utf-8")
157
+ }
158
+ }
159
+ }
160
+
161
+ // ============================================================
162
+ // 結果
163
+ // ============================================================
164
+
165
+ console.log("")
166
+ if (totalFiles === 0) {
167
+ console.log("✓ 旧 API の利用箇所は見つかりませんでした。移行は完了しています。")
168
+ process.exit(0)
169
+ }
170
+
171
+ console.log(`📊 結果`)
172
+ console.log(` 変換対象ファイル: ${totalFiles}`)
173
+ console.log(` 置換箇所合計: ${totalChanges}`)
174
+ console.log("")
175
+ console.log(`📝 ファイル別変更箇所:`)
176
+ for (const { file, count } of fileChanges.sort((a, b) => b.count - a.count)) {
177
+ console.log(` ${count.toString().padStart(3)}× ${file}`)
178
+ }
179
+
180
+ if (dry) {
181
+ console.log("")
182
+ console.log(`💡 DRY RUN 完了。実際に適用するには '--dry' を外して再実行:`)
183
+ console.log(` node scripts/codemod/v0.2-to-v0.3.mjs ${targetDir}`)
184
+ } else {
185
+ console.log("")
186
+ console.log(`✓ 変換完了。'git diff' で変更内容を確認し、テストを実行してください。`)
187
+ console.log(` git diff`)
188
+ console.log(` npm test`)
189
+ console.log("")
190
+ console.log(`💡 残作業: MypageSidebar 利用箇所があれば、SideNav + mypageMenuGroups への手動移行を推奨。`)
191
+ console.log(` 詳細: MIGRATION.md`)
192
+ }
@@ -0,0 +1,109 @@
1
+ /* ============================================
2
+ * Cake.jp Design System — Standalone Preset
3
+ * ============================================
4
+ *
5
+ * Tailwind CSS を使わないプロジェクト(CakePHP本番等)向けの
6
+ * スタンドアロン版トークンファイル。
7
+ *
8
+ * CSS変数のみを定義し、技術スタックに依存しない。
9
+ * CakePHP, Next.js, Flutter(値のみ), 素のHTML で使用可能。
10
+ *
11
+ * 使い方:
12
+ * <link rel="stylesheet" href="preset-standalone.css">
13
+ * または
14
+ * @import url("preset-standalone.css");
15
+ *
16
+ * これで以下が有効になる:
17
+ * - Primitive カラートークン(--Primitive-*)
18
+ * - Semantic カラートークン(--Text-*, --Surface-*, --Border-* 等)
19
+ * - ダークモード自動切替(.dark クラス)
20
+ * - shadcn bridge トークン(--primary, --foreground 等)
21
+ * - シャドウ・角丸トークン
22
+ *
23
+ * タイポグラフィ(typo-*)は Tailwind v4 の @utility に依存するため、
24
+ * このファイルには含まれない。代わりに typo-* と同等のクラス定義を
25
+ * 以下の「Typography Helper」セクションで提供する。
26
+ * ============================================ */
27
+
28
+ /* --- Layer 1: Primitive Colors --- */
29
+ @import "./styles/primitive.css";
30
+
31
+ /* --- Layer 2: Semantic Colors (+ dark mode) --- */
32
+ @import "./styles/semantic.css";
33
+
34
+ /* --- Bridge: Semantic → shadcn tokens --- */
35
+ :root {
36
+ --radius: 0.625rem;
37
+
38
+ --background: var(--Surface-Primary);
39
+ --foreground: var(--Text-High-Emphasis);
40
+ --card: var(--Surface-Secondary);
41
+ --card-foreground: var(--Text-High-Emphasis);
42
+ --popover: var(--Surface-Primary);
43
+ --popover-foreground: var(--Text-High-Emphasis);
44
+ --primary: var(--Brand-Cake-Orange);
45
+ --primary-foreground: var(--Text-on-Inverse);
46
+ --secondary: var(--Surface-Secondary);
47
+ --secondary-foreground: var(--Text-Medium-Emphasis);
48
+ --muted: var(--Surface-Tertiary);
49
+ --muted-foreground: var(--Text-Low-Emphasis);
50
+ --accent: var(--Surface-Secondary);
51
+ --accent-foreground: var(--Text-High-Emphasis);
52
+ --destructive: var(--Object-Caution);
53
+ --border: var(--Border-Medium-Emphasis);
54
+ --input: var(--Border-Medium-Emphasis);
55
+ --ring: var(--Focus-High-Emphasis);
56
+ }
57
+
58
+ .dark {
59
+ --background: var(--Surface-Primary);
60
+ --foreground: var(--Text-High-Emphasis);
61
+ --card: var(--Surface-Secondary);
62
+ --card-foreground: var(--Text-High-Emphasis);
63
+ --popover: var(--Surface-Primary);
64
+ --popover-foreground: var(--Text-High-Emphasis);
65
+ --primary: var(--Brand-Cake-Orange);
66
+ --primary-foreground: var(--Text-on-Inverse);
67
+ --secondary: var(--Surface-Tertiary);
68
+ --secondary-foreground: var(--Text-Medium-Emphasis);
69
+ --muted: var(--Surface-Tertiary);
70
+ --muted-foreground: var(--Text-Low-Emphasis);
71
+ --accent: var(--Surface-Secondary);
72
+ --accent-foreground: var(--Text-High-Emphasis);
73
+ --destructive: var(--Object-Caution);
74
+ --border: var(--Border-Medium-Emphasis);
75
+ --input: var(--Border-Medium-Emphasis);
76
+ --ring: var(--Focus-High-Emphasis);
77
+ }
78
+
79
+ /* --- Shadow tokens --- */
80
+ :root {
81
+ --shadow-md: 0px 7px 7px 0px rgba(0, 0, 0, 0.07), 0px 2px 16px 0px rgba(0, 0, 0, 0.12);
82
+ --shadow-lg: 0px 12px 32px -4px rgba(24, 39, 75, 0.12), 0px 8px 16px -6px rgba(24, 39, 75, 0.12), 0px 1px 4px 1px rgba(0, 0, 0, 0.2);
83
+ --shadow-tooltip: 0px 8px 8px -4px rgba(24, 39, 75, 0.08), 0px 4px 6px -4px rgba(24, 39, 75, 0.12);
84
+ }
85
+
86
+ /* --- Typography Helper Classes ---
87
+ * Tailwindのtypo-*と同等のCSSクラス。
88
+ * 本番CSSでこれらのクラスを使えば、DSと同じタイポグラフィが適用される。
89
+ */
90
+
91
+ /* Heading */
92
+ .typo-heading-3xl { font-size: 28px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
93
+ .typo-heading-2xl { font-size: 24px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
94
+ .typo-heading-xl { font-size: 21px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
95
+ .typo-heading-lg { font-size: 18px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
96
+ .typo-heading-md { font-size: 16px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
97
+ .typo-heading-sm { font-size: 14px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
98
+
99
+ /* Body */
100
+ .typo-body-lg { font-size: 16px; line-height: 1.75; font-weight: 400; }
101
+ .typo-body-md { font-size: 14px; line-height: 1.75; font-weight: 400; }
102
+ .typo-body-sm { font-size: 12px; line-height: 1.5; font-weight: 400; }
103
+ .typo-body-xs { font-size: 10px; line-height: 1.5; font-weight: 400; }
104
+
105
+ /* Label */
106
+ .typo-label-lg { font-size: 16px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
107
+ .typo-label-md { font-size: 14px; line-height: 1.5; letter-spacing: 0.04em; font-weight: 700; }
108
+ .typo-label-sm { font-size: 12px; line-height: 1.5; font-weight: 500; }
109
+ .typo-label-xs { font-size: 10px; line-height: 1.5; font-weight: 500; }