@pie-element/cli 0.1.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.
Files changed (255) hide show
  1. package/.compatibility/report.json +2491 -0
  2. package/.turbo/turbo-build.log +1 -0
  3. package/CHANGELOG.md +8 -0
  4. package/README.md +240 -0
  5. package/REFACTORING.md +131 -0
  6. package/bin/dev.js +5 -0
  7. package/bin/run.js +5 -0
  8. package/dist/commands/dev/demo/index.d.ts +33 -0
  9. package/dist/commands/dev/demo/index.d.ts.map +1 -0
  10. package/dist/commands/dev/demo/index.js +274 -0
  11. package/dist/commands/dev/demo/index.js.map +1 -0
  12. package/dist/commands/dev/test-bundler.d.ts +18 -0
  13. package/dist/commands/dev/test-bundler.d.ts.map +1 -0
  14. package/dist/commands/dev/test-bundler.js +284 -0
  15. package/dist/commands/dev/test-bundler.js.map +1 -0
  16. package/dist/commands/mathquill/migrate.d.ts +20 -0
  17. package/dist/commands/mathquill/migrate.d.ts.map +1 -0
  18. package/dist/commands/mathquill/migrate.js +240 -0
  19. package/dist/commands/mathquill/migrate.js.map +1 -0
  20. package/dist/commands/mathquill/status.d.ts +20 -0
  21. package/dist/commands/mathquill/status.d.ts.map +1 -0
  22. package/dist/commands/mathquill/status.js +231 -0
  23. package/dist/commands/mathquill/status.js.map +1 -0
  24. package/dist/commands/packages/create-controllers.d.ts +13 -0
  25. package/dist/commands/packages/create-controllers.d.ts.map +1 -0
  26. package/dist/commands/packages/create-controllers.js +103 -0
  27. package/dist/commands/packages/create-controllers.js.map +1 -0
  28. package/dist/commands/packages/create-lib-react.d.ts +17 -0
  29. package/dist/commands/packages/create-lib-react.d.ts.map +1 -0
  30. package/dist/commands/packages/create-lib-react.js +228 -0
  31. package/dist/commands/packages/create-lib-react.js.map +1 -0
  32. package/dist/commands/packages/create-react-elements.d.ts +16 -0
  33. package/dist/commands/packages/create-react-elements.d.ts.map +1 -0
  34. package/dist/commands/packages/create-react-elements.js +259 -0
  35. package/dist/commands/packages/create-react-elements.js.map +1 -0
  36. package/dist/commands/packages/enable-publishing.d.ts +11 -0
  37. package/dist/commands/packages/enable-publishing.d.ts.map +1 -0
  38. package/dist/commands/packages/enable-publishing.js +117 -0
  39. package/dist/commands/packages/enable-publishing.js.map +1 -0
  40. package/dist/commands/packages/init-synced-elements.d.ts +16 -0
  41. package/dist/commands/packages/init-synced-elements.d.ts.map +1 -0
  42. package/dist/commands/packages/init-synced-elements.js +204 -0
  43. package/dist/commands/packages/init-synced-elements.js.map +1 -0
  44. package/dist/commands/upstream/analyze-esm.d.ts +59 -0
  45. package/dist/commands/upstream/analyze-esm.d.ts.map +1 -0
  46. package/dist/commands/upstream/analyze-esm.js +1481 -0
  47. package/dist/commands/upstream/analyze-esm.js.map +1 -0
  48. package/dist/commands/upstream/check.d.ts +15 -0
  49. package/dist/commands/upstream/check.d.ts.map +1 -0
  50. package/dist/commands/upstream/check.js +165 -0
  51. package/dist/commands/upstream/check.js.map +1 -0
  52. package/dist/commands/upstream/deps.d.ts +15 -0
  53. package/dist/commands/upstream/deps.d.ts.map +1 -0
  54. package/dist/commands/upstream/deps.js +174 -0
  55. package/dist/commands/upstream/deps.js.map +1 -0
  56. package/dist/commands/upstream/sync-mathquill.d.ts +12 -0
  57. package/dist/commands/upstream/sync-mathquill.d.ts.map +1 -0
  58. package/dist/commands/upstream/sync-mathquill.js +97 -0
  59. package/dist/commands/upstream/sync-mathquill.js.map +1 -0
  60. package/dist/commands/upstream/sync.d.ts +25 -0
  61. package/dist/commands/upstream/sync.d.ts.map +1 -0
  62. package/dist/commands/upstream/sync.js +552 -0
  63. package/dist/commands/upstream/sync.js.map +1 -0
  64. package/dist/commands/upstream/track.d.ts +15 -0
  65. package/dist/commands/upstream/track.d.ts.map +1 -0
  66. package/dist/commands/upstream/track.js +115 -0
  67. package/dist/commands/upstream/track.js.map +1 -0
  68. package/dist/commands/upstream/update.d.ts +15 -0
  69. package/dist/commands/upstream/update.d.ts.map +1 -0
  70. package/dist/commands/upstream/update.js +98 -0
  71. package/dist/commands/upstream/update.js.map +1 -0
  72. package/dist/commands/verify/controllers.d.ts +12 -0
  73. package/dist/commands/verify/controllers.d.ts.map +1 -0
  74. package/dist/commands/verify/controllers.js +138 -0
  75. package/dist/commands/verify/controllers.js.map +1 -0
  76. package/dist/commands/verify/react-build.d.ts +13 -0
  77. package/dist/commands/verify/react-build.d.ts.map +1 -0
  78. package/dist/commands/verify/react-build.js +135 -0
  79. package/dist/commands/verify/react-build.js.map +1 -0
  80. package/dist/index.d.ts +2 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +2 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/lib/mathquill/extension-generator.d.ts +9 -0
  85. package/dist/lib/mathquill/extension-generator.d.ts.map +1 -0
  86. package/dist/lib/mathquill/extension-generator.js +107 -0
  87. package/dist/lib/mathquill/extension-generator.js.map +1 -0
  88. package/dist/lib/mathquill/khan-extractor.d.ts +16 -0
  89. package/dist/lib/mathquill/khan-extractor.d.ts.map +1 -0
  90. package/dist/lib/mathquill/khan-extractor.js +148 -0
  91. package/dist/lib/mathquill/khan-extractor.js.map +1 -0
  92. package/dist/lib/mathquill/learnosity-extractor.d.ts +15 -0
  93. package/dist/lib/mathquill/learnosity-extractor.d.ts.map +1 -0
  94. package/dist/lib/mathquill/learnosity-extractor.js +170 -0
  95. package/dist/lib/mathquill/learnosity-extractor.js.map +1 -0
  96. package/dist/lib/mathquill/migration-orchestrator.d.ts +77 -0
  97. package/dist/lib/mathquill/migration-orchestrator.d.ts.map +1 -0
  98. package/dist/lib/mathquill/migration-orchestrator.js +391 -0
  99. package/dist/lib/mathquill/migration-orchestrator.js.map +1 -0
  100. package/dist/lib/mathquill/package-updater.d.ts +9 -0
  101. package/dist/lib/mathquill/package-updater.d.ts.map +1 -0
  102. package/dist/lib/mathquill/package-updater.js +103 -0
  103. package/dist/lib/mathquill/package-updater.js.map +1 -0
  104. package/dist/lib/mathquill/pie-extractor.d.ts +14 -0
  105. package/dist/lib/mathquill/pie-extractor.d.ts.map +1 -0
  106. package/dist/lib/mathquill/pie-extractor.js +167 -0
  107. package/dist/lib/mathquill/pie-extractor.js.map +1 -0
  108. package/dist/lib/upstream/repo-utils.d.ts +9 -0
  109. package/dist/lib/upstream/repo-utils.d.ts.map +1 -0
  110. package/dist/lib/upstream/repo-utils.js +10 -0
  111. package/dist/lib/upstream/repo-utils.js.map +1 -0
  112. package/dist/lib/upstream/sync-compatibility.d.ts +29 -0
  113. package/dist/lib/upstream/sync-compatibility.d.ts.map +1 -0
  114. package/dist/lib/upstream/sync-compatibility.js +70 -0
  115. package/dist/lib/upstream/sync-compatibility.js.map +1 -0
  116. package/dist/lib/upstream/sync-constants.d.ts +50 -0
  117. package/dist/lib/upstream/sync-constants.d.ts.map +1 -0
  118. package/dist/lib/upstream/sync-constants.js +66 -0
  119. package/dist/lib/upstream/sync-constants.js.map +1 -0
  120. package/dist/lib/upstream/sync-controllers-strategy.d.ts +18 -0
  121. package/dist/lib/upstream/sync-controllers-strategy.d.ts.map +1 -0
  122. package/dist/lib/upstream/sync-controllers-strategy.js +243 -0
  123. package/dist/lib/upstream/sync-controllers-strategy.js.map +1 -0
  124. package/dist/lib/upstream/sync-demo-metadata.d.ts +15 -0
  125. package/dist/lib/upstream/sync-demo-metadata.d.ts.map +1 -0
  126. package/dist/lib/upstream/sync-demo-metadata.js +165 -0
  127. package/dist/lib/upstream/sync-demo-metadata.js.map +1 -0
  128. package/dist/lib/upstream/sync-dev-exports.d.ts +13 -0
  129. package/dist/lib/upstream/sync-dev-exports.d.ts.map +1 -0
  130. package/dist/lib/upstream/sync-dev-exports.js +115 -0
  131. package/dist/lib/upstream/sync-dev-exports.js.map +1 -0
  132. package/dist/lib/upstream/sync-externals.d.ts +29 -0
  133. package/dist/lib/upstream/sync-externals.d.ts.map +1 -0
  134. package/dist/lib/upstream/sync-externals.js +164 -0
  135. package/dist/lib/upstream/sync-externals.js.map +1 -0
  136. package/dist/lib/upstream/sync-filesystem.d.ts +21 -0
  137. package/dist/lib/upstream/sync-filesystem.d.ts.map +1 -0
  138. package/dist/lib/upstream/sync-filesystem.js +64 -0
  139. package/dist/lib/upstream/sync-filesystem.js.map +1 -0
  140. package/dist/lib/upstream/sync-imports.d.ts +284 -0
  141. package/dist/lib/upstream/sync-imports.d.ts.map +1 -0
  142. package/dist/lib/upstream/sync-imports.js +816 -0
  143. package/dist/lib/upstream/sync-imports.js.map +1 -0
  144. package/dist/lib/upstream/sync-mathquill.d.ts +19 -0
  145. package/dist/lib/upstream/sync-mathquill.d.ts.map +1 -0
  146. package/dist/lib/upstream/sync-mathquill.js +160 -0
  147. package/dist/lib/upstream/sync-mathquill.js.map +1 -0
  148. package/dist/lib/upstream/sync-package-json.d.ts +28 -0
  149. package/dist/lib/upstream/sync-package-json.d.ts.map +1 -0
  150. package/dist/lib/upstream/sync-package-json.js +66 -0
  151. package/dist/lib/upstream/sync-package-json.js.map +1 -0
  152. package/dist/lib/upstream/sync-package-manager.d.ts +50 -0
  153. package/dist/lib/upstream/sync-package-manager.d.ts.map +1 -0
  154. package/dist/lib/upstream/sync-package-manager.js +570 -0
  155. package/dist/lib/upstream/sync-package-manager.js.map +1 -0
  156. package/dist/lib/upstream/sync-pielib-strategy.d.ts +26 -0
  157. package/dist/lib/upstream/sync-pielib-strategy.d.ts.map +1 -0
  158. package/dist/lib/upstream/sync-pielib-strategy.js +345 -0
  159. package/dist/lib/upstream/sync-pielib-strategy.js.map +1 -0
  160. package/dist/lib/upstream/sync-react-strategy.d.ts +54 -0
  161. package/dist/lib/upstream/sync-react-strategy.d.ts.map +1 -0
  162. package/dist/lib/upstream/sync-react-strategy.js +733 -0
  163. package/dist/lib/upstream/sync-react-strategy.js.map +1 -0
  164. package/dist/lib/upstream/sync-strategy.d.ts +49 -0
  165. package/dist/lib/upstream/sync-strategy.d.ts.map +1 -0
  166. package/dist/lib/upstream/sync-strategy.js +2 -0
  167. package/dist/lib/upstream/sync-strategy.js.map +1 -0
  168. package/dist/lib/upstream/sync-summary.d.ts +20 -0
  169. package/dist/lib/upstream/sync-summary.d.ts.map +1 -0
  170. package/dist/lib/upstream/sync-summary.js +157 -0
  171. package/dist/lib/upstream/sync-summary.js.map +1 -0
  172. package/dist/lib/upstream/sync-transforms.d.ts +60 -0
  173. package/dist/lib/upstream/sync-transforms.d.ts.map +1 -0
  174. package/dist/lib/upstream/sync-transforms.js +97 -0
  175. package/dist/lib/upstream/sync-transforms.js.map +1 -0
  176. package/dist/lib/upstream/sync-vite-config.d.ts +13 -0
  177. package/dist/lib/upstream/sync-vite-config.d.ts.map +1 -0
  178. package/dist/lib/upstream/sync-vite-config.js +231 -0
  179. package/dist/lib/upstream/sync-vite-config.js.map +1 -0
  180. package/dist/utils/compatibility.d.ts +129 -0
  181. package/dist/utils/compatibility.d.ts.map +1 -0
  182. package/dist/utils/compatibility.js +44 -0
  183. package/dist/utils/compatibility.js.map +1 -0
  184. package/dist/utils/conversion.d.ts +25 -0
  185. package/dist/utils/conversion.d.ts.map +1 -0
  186. package/dist/utils/conversion.js +123 -0
  187. package/dist/utils/conversion.js.map +1 -0
  188. package/dist/utils/git.d.ts +7 -0
  189. package/dist/utils/git.d.ts.map +1 -0
  190. package/dist/utils/git.js +63 -0
  191. package/dist/utils/git.js.map +1 -0
  192. package/dist/utils/logger.d.ts +29 -0
  193. package/dist/utils/logger.d.ts.map +1 -0
  194. package/dist/utils/logger.js +63 -0
  195. package/dist/utils/logger.js.map +1 -0
  196. package/dist/utils/package-json.d.ts +12 -0
  197. package/dist/utils/package-json.d.ts.map +1 -0
  198. package/dist/utils/package-json.js +29 -0
  199. package/dist/utils/package-json.js.map +1 -0
  200. package/package.json +59 -0
  201. package/packages/cli/bin/dev.js +5 -0
  202. package/packages/cli/bin/run.js +5 -0
  203. package/src/commands/dev/demo/index.ts +313 -0
  204. package/src/commands/dev/test-bundler.ts +345 -0
  205. package/src/commands/mathquill/migrate.ts +269 -0
  206. package/src/commands/mathquill/status.ts +267 -0
  207. package/src/commands/packages/create-controllers.ts +127 -0
  208. package/src/commands/packages/create-lib-react.ts +279 -0
  209. package/src/commands/packages/create-react-elements.ts +306 -0
  210. package/src/commands/packages/enable-publishing.ts +161 -0
  211. package/src/commands/packages/init-synced-elements.ts +259 -0
  212. package/src/commands/upstream/README.md +444 -0
  213. package/src/commands/upstream/analyze-esm.ts +1973 -0
  214. package/src/commands/upstream/check.ts +228 -0
  215. package/src/commands/upstream/deps.ts +222 -0
  216. package/src/commands/upstream/sync-mathquill.ts +108 -0
  217. package/src/commands/upstream/sync.ts +687 -0
  218. package/src/commands/upstream/track.ts +145 -0
  219. package/src/commands/upstream/update.ts +110 -0
  220. package/src/commands/verify/controllers.ts +166 -0
  221. package/src/commands/verify/react-build.ts +171 -0
  222. package/src/index.ts +1 -0
  223. package/src/lib/mathquill/extension-generator.ts +111 -0
  224. package/src/lib/mathquill/khan-extractor.ts +175 -0
  225. package/src/lib/mathquill/learnosity-extractor.ts +198 -0
  226. package/src/lib/mathquill/migration-orchestrator.ts +513 -0
  227. package/src/lib/mathquill/package-updater.ts +120 -0
  228. package/src/lib/mathquill/pie-extractor.ts +194 -0
  229. package/src/lib/upstream/repo-utils.ts +18 -0
  230. package/src/lib/upstream/sync-compatibility.ts +89 -0
  231. package/src/lib/upstream/sync-constants.ts +77 -0
  232. package/src/lib/upstream/sync-controllers-strategy.ts +291 -0
  233. package/src/lib/upstream/sync-demo-metadata.ts +199 -0
  234. package/src/lib/upstream/sync-dev-exports.ts +151 -0
  235. package/src/lib/upstream/sync-externals.ts +159 -0
  236. package/src/lib/upstream/sync-filesystem.ts +87 -0
  237. package/src/lib/upstream/sync-imports.ts +992 -0
  238. package/src/lib/upstream/sync-mathquill.ts +194 -0
  239. package/src/lib/upstream/sync-package-json.ts +86 -0
  240. package/src/lib/upstream/sync-package-manager.ts +694 -0
  241. package/src/lib/upstream/sync-pielib-strategy.ts +441 -0
  242. package/src/lib/upstream/sync-react-strategy.ts +945 -0
  243. package/src/lib/upstream/sync-strategy.ts +61 -0
  244. package/src/lib/upstream/sync-summary.ts +194 -0
  245. package/src/lib/upstream/sync-transforms.ts +154 -0
  246. package/src/lib/upstream/sync-vite-config.ts +243 -0
  247. package/src/types/es-module-lexer.d.ts +4 -0
  248. package/src/utils/compatibility.ts +182 -0
  249. package/src/utils/conversion.ts +153 -0
  250. package/src/utils/git.ts +63 -0
  251. package/src/utils/logger.ts +69 -0
  252. package/src/utils/package-json.ts +43 -0
  253. package/tests/sync-package-manager.test.ts +112 -0
  254. package/tests/transform-assign-props.test.ts +101 -0
  255. package/tsconfig.json +15 -0
@@ -0,0 +1 @@
1
+ $ tsc
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # @pie-element/cli
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e131840]
8
+ - @pie-element/bundler-shared@0.1.1
package/README.md ADDED
@@ -0,0 +1,240 @@
1
+ # @pie-element/cli
2
+
3
+ CLI tools for managing PIE Elements NG - synchronization, package generation, and verification.
4
+
5
+ ## Installation
6
+
7
+ From the root of the monorepo:
8
+
9
+ ```bash
10
+ bun install
11
+ cd tools/cli
12
+ bun run build
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ From the root of the monorepo:
18
+
19
+ ```bash
20
+ # Show help
21
+ bun run cli --help
22
+
23
+ # Show command help
24
+ bun run cli upstream:sync --help
25
+ ```
26
+
27
+ ## Commands
28
+
29
+ ### Development
30
+
31
+ #### `dev:demo`
32
+
33
+ Start a demo server for an element using `apps/element-demo`.
34
+
35
+ ```bash
36
+ # Start demo for an element
37
+ bun run cli dev:demo hotspot
38
+
39
+ # Custom port, skip builds, and don't auto-open browser
40
+ bun run cli dev:demo multiple-choice --port 5180 --skip-build --no-open
41
+ ```
42
+
43
+ ### Upstream Synchronization
44
+
45
+ #### `upstream:sync`
46
+
47
+ Synchronize code from upstream pie-elements repository.
48
+
49
+ ```bash
50
+ # Dry run to preview changes
51
+ bun run cli upstream:sync --dry-run
52
+
53
+ # Sync specific element
54
+ bun run cli upstream:sync --element multiple-choice
55
+
56
+ # Sync all compatible elements (controllers + React UI + demos)
57
+ bun run cli upstream:sync
58
+
59
+ # Verbose output
60
+ bun run cli upstream:sync --verbose
61
+ ```
62
+
63
+ #### `upstream:check`
64
+
65
+ Check for changes in upstream repositories.
66
+
67
+ ```bash
68
+ # Check all elements
69
+ bun run cli upstream:check
70
+
71
+ # Check specific element
72
+ bun run cli upstream:check --element multiple-choice
73
+
74
+ # Verbose output
75
+ bun run cli upstream:check --verbose
76
+ ```
77
+
78
+ #### `upstream:track`
79
+
80
+ Track upstream repository changes.
81
+
82
+ ```bash
83
+ # Show new commits since last check
84
+ bun run cli upstream:track show
85
+
86
+ # Record current upstream state
87
+ bun run cli upstream:track record
88
+
89
+ # Compare with specific commit
90
+ bun run cli upstream:track compare <commit-sha>
91
+ ```
92
+
93
+ #### `upstream:deps`
94
+
95
+ Compare dependencies with upstream repositories.
96
+
97
+ ```bash
98
+ bun run cli upstream:deps
99
+ ```
100
+
101
+ #### `upstream:analyze-esm`
102
+
103
+ Analyze ESM compatibility of elements and packages.
104
+
105
+ ```bash
106
+ # Analyze and generate report
107
+ bun run cli upstream:analyze-esm
108
+
109
+ # Verbose output
110
+ bun run cli upstream:analyze-esm --verbose
111
+
112
+ # Custom output path
113
+ bun run cli upstream:analyze-esm --output ./my-report.json
114
+ ```
115
+
116
+ #### `upstream:update`
117
+
118
+ Recommended wrapper that runs analyze + sync.
119
+
120
+ ```bash
121
+ bun run cli upstream:update
122
+ ```
123
+
124
+ #### `upstream:sync-mathquill`
125
+
126
+ Sync the MathQuill fork used by the project.
127
+
128
+ ```bash
129
+ bun run cli upstream:sync-mathquill
130
+ ```
131
+
132
+ ### Package Management
133
+
134
+ #### `packages:enable-publishing`
135
+
136
+ Enable React package publishing (remove private flags).
137
+
138
+ ```bash
139
+ # Dry run
140
+ bun run cli packages:enable-publishing --dry-run
141
+
142
+ # Enable publishing
143
+ bun run cli packages:enable-publishing
144
+ ```
145
+
146
+ #### `packages:create-controllers`
147
+
148
+ Generate package.json files for controller packages.
149
+
150
+ ```bash
151
+ bun run cli packages:create-controllers
152
+ ```
153
+
154
+ #### `packages:create-lib-react`
155
+
156
+ Generate configuration files for @pie-lib React packages.
157
+
158
+ ```bash
159
+ # Dry run
160
+ bun run cli packages:create-lib-react --dry-run
161
+
162
+ # Generate files
163
+ bun run cli packages:create-lib-react
164
+ ```
165
+
166
+ #### `packages:create-react-elements`
167
+
168
+ Generate configuration files for React element packages.
169
+
170
+ ```bash
171
+ bun run cli packages:create-react-elements
172
+ ```
173
+
174
+ #### `packages:init-synced-elements`
175
+
176
+ Initialize package scaffolding for synced elements.
177
+
178
+ ```bash
179
+ bun run cli packages:init-synced-elements
180
+ ```
181
+
182
+ ### Verification
183
+
184
+ #### `verify:controllers`
185
+
186
+ Verify controller package exports before publishing.
187
+
188
+ ```bash
189
+ bun run cli verify:controllers
190
+ ```
191
+
192
+ #### `verify:react-build`
193
+
194
+ Verify that all React elements build successfully.
195
+
196
+ ```bash
197
+ bun run cli verify:react-build
198
+ ```
199
+
200
+ ## CLI Development
201
+
202
+ ```bash
203
+ # Build the CLI
204
+ bun run build
205
+
206
+ # Run in development mode (with source maps)
207
+ bun run dev upstream:sync --help
208
+
209
+ # Lint
210
+ bun run lint
211
+ ```
212
+
213
+ ## Architecture
214
+
215
+ The CLI is built with [oclif](https://oclif.io/), following the same architecture as the pie-qti CLI.
216
+
217
+ - **Commands**: Located in `src/commands/` organized by topic
218
+ - **Utilities**: Shared utilities in `src/utils/`
219
+ - **Topics**: Commands are grouped into topics (upstream, packages, verify)
220
+
221
+ ## Migration from Scripts
222
+
223
+ This CLI replaces the scripts in `./scripts` directory:
224
+
225
+ | Old Script | New CLI Command |
226
+ | ------------------------------------------- | -------------------------------------------- |
227
+ | `bun scripts/sync-upstream.ts` | `bun run cli upstream:sync` |
228
+ | `bun scripts/check-upstream.ts` | `bun run cli upstream:check` |
229
+ | `bun scripts/track-upstream.ts show` | `bun run cli upstream:track show` |
230
+ | `bun scripts/check-deps.ts` | `bun run cli upstream:deps` |
231
+ | `bun scripts/analyze-esm-compatibility.ts` | `bun run cli upstream:analyze-esm` |
232
+ | `bun scripts/enable-react-publishing.ts` | `bun run cli packages:enable-publishing` |
233
+ | `bun scripts/create-controller-packages.ts` | `bun run cli packages:create-controllers` |
234
+ | `bun scripts/create-lib-react-packages.ts` | `bun run cli packages:create-lib-react` |
235
+ | `bun scripts/create-react-packages.ts` | `bun run cli packages:create-react-elements` |
236
+ | `bun scripts/verify-react-build.ts` | `bun run cli verify:react-build` |
237
+
238
+ ## License
239
+
240
+ Same as parent project.
package/REFACTORING.md ADDED
@@ -0,0 +1,131 @@
1
+ # Sync Command Refactoring
2
+
3
+ ## Summary
4
+
5
+ The sync command has been refactored to extract reusable utilities and reduce code duplication.
6
+
7
+ ## Changes Made
8
+
9
+ ### 1. Extracted File System Utilities
10
+ **File**: `src/commands/upstream/sync-filesystem.ts`
11
+
12
+ Extracted functions:
13
+ - `cleanDirectory()` - Clean a directory with optional subdirectory preservation
14
+ - `existsAny()` - Check if any paths in a list exist
15
+ - `readdir()` - Safe directory reading with error handling
16
+
17
+ **Impact**: Removed ~30 lines from main file, improved testability
18
+
19
+ ### 2. Extracted Package.json Utilities
20
+ **File**: `src/commands/upstream/sync-package-json.ts`
21
+
22
+ Extracted functions:
23
+ - `getAllDeps()` - Get all dependencies from package.json
24
+ - `extractPieLibDeps()` - Extract @pie-lib/* dependencies
25
+ - `extractPieElementDeps()` - Extract @pie-element/* dependencies
26
+ - `generateElementExports()` - Generate ESM exports for elements
27
+ - `generatePieLibExports()` - Generate ESM exports for pie-lib packages
28
+
29
+ **Impact**: Improved reusability, prepared for future use
30
+
31
+ ### 3. Extracted Vite Config Utilities
32
+ **File**: `src/commands/upstream/sync-vite-config.ts`
33
+
34
+ Extracted functions:
35
+ - `detectElementEntryPoints()` - Detect available entry points for elements
36
+ - `generateElementViteConfig()` - Generate Vite config for element packages
37
+ - `generatePieLibViteConfig()` - Generate Vite config for pie-lib packages
38
+
39
+ **Impact**: Improved reusability for build configuration
40
+
41
+ ### 4. Extracted Import Utilities
42
+ **File**: `src/commands/upstream/sync-imports.ts`
43
+
44
+ Extracted functions:
45
+ - `fixImportsInFile()` - Handle default export conversions
46
+ - `containsJsx()` - Detect JSX syntax in code
47
+ - `shouldUseTsxExtension()` - Determine file extension based on content
48
+
49
+ **Impact**: Improved code organization and testability
50
+
51
+ ### 6. Implemented Strategy Pattern
52
+ **Files**: `sync-strategy.ts`, `sync-controllers-strategy.ts`, `sync-react-strategy.ts`, `sync-pielib-strategy.ts`
53
+
54
+ Created strategy pattern for sync operations:
55
+ - `SyncStrategy` interface defining contract for sync strategies
56
+ - `ControllersStrategy` - Handles controller file synchronization (455 lines)
57
+ - `ReactComponentsStrategy` - Handles React component synchronization (536 lines)
58
+ - `PieLibStrategy` - Handles @pie-lib package synchronization (322 lines)
59
+
60
+ Each strategy is:
61
+ - Self-contained with all related logic and helper methods
62
+ - Independently executable and testable
63
+ - Responsible for one specific sync type
64
+
65
+ **Impact**: Major code organization improvement, true separation of concerns
66
+
67
+ ### 7. Updated sync.ts
68
+ - Removed duplicate utility methods
69
+ - Replaced inline demo generation with utility calls
70
+ - Extracted three large sync methods into strategies
71
+ - Removed 9 helper methods that moved to strategies
72
+ - Now focuses purely on orchestration and coordination
73
+
74
+ **Result**:
75
+ - File size reduced from 1,571 to 644 lines (927 lines removed, ~59% reduction)
76
+ - Better separation of concerns
77
+ - Each strategy independently testable
78
+ - Cleaner, more focused main command file
79
+ - No breaking changes to CLI interface
80
+
81
+ **Total extraction across all files:**
82
+ - 5 utility modules (filesystem, package-json, vite-config, demo, imports)
83
+ - 3 strategy modules (controllers, react, pie-lib)
84
+ - 1 strategy interface (strategy)
85
+ - Main file reduced by 59%
86
+
87
+ ## Benefits
88
+
89
+ 1. **Testability**: Utilities can be unit tested independently
90
+ 2. **Reusability**: Functions available for other commands
91
+ 3. **Maintainability**: Clearer responsibilities, less duplication
92
+ 4. **No Breaking Changes**: Internal refactor only, CLI works the same
93
+
94
+ ## Completed Improvements
95
+
96
+ All planned refactoring has been completed:
97
+
98
+ 1. ✅ **Extracted utilities**:
99
+ - Vite config generation (sync-vite-config.ts)
100
+ - Demo generation (sync-demo.ts)
101
+ - Import rewriting logic (sync-imports.ts)
102
+ - File system operations (sync-filesystem.ts)
103
+ - Package.json manipulation (sync-package-json.ts)
104
+
105
+ 2. ✅ **Implemented strategy pattern**:
106
+ - ControllersStrategy (sync-controllers-strategy.ts)
107
+ - ReactComponentsStrategy (sync-react-strategy.ts)
108
+ - PieLibStrategy (sync-pielib-strategy.ts)
109
+
110
+ 3. ✅ **Refactored main sync.ts**:
111
+ - Reduced from 1,571 to 644 lines (59% reduction)
112
+ - Focuses on orchestration only
113
+ - All sync logic extracted to strategies
114
+
115
+ ## Next Steps (Optional)
116
+
117
+ To further improve the codebase:
118
+
119
+ 1. **Add unit tests** for extracted utilities and strategies
120
+
121
+ 2. **Extract long methods** in remaining code (>100 lines) into smaller, focused functions
122
+
123
+ 3. **Consider extracting demo sync** into its own strategy if it grows in complexity
124
+
125
+ ## Testing
126
+
127
+ All existing functionality verified:
128
+ - ✅ Controllers sync correctly
129
+ - ✅ React components sync correctly
130
+ - ✅ ESM analysis works correctly
131
+ - ✅ Build completes successfully
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execute } from '@oclif/core';
4
+
5
+ await execute({ development: true, dir: import.meta.url });
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execute } from '@oclif/core';
4
+
5
+ await execute({ development: false, dir: import.meta.url });
@@ -0,0 +1,33 @@
1
+ import { Command } from '@oclif/core';
2
+ /**
3
+ * Start unified demo application for all PIE elements.
4
+ *
5
+ * This command starts the apps/element-demo SvelteKit application which provides
6
+ * a unified demo experience for all 27 PIE elements with multiple demo configurations.
7
+ */
8
+ export default class DevDemo extends Command {
9
+ static description: string;
10
+ static examples: string[];
11
+ static flags: {
12
+ port: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
13
+ build: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ static args: {};
17
+ private viteProcess;
18
+ private lockFilePath;
19
+ private bundlerInstanceDir;
20
+ run(): Promise<void>;
21
+ private buildAllElements;
22
+ private startVite;
23
+ private openBrowser;
24
+ private installDependencies;
25
+ private cleanup;
26
+ private sleep;
27
+ private acquireLock;
28
+ private getLockFilePath;
29
+ private createBundlerInstanceDir;
30
+ private releaseLock;
31
+ private isProcessRunning;
32
+ }
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/dev/demo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAM7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAC1C,OAAgB,WAAW,SAAqE;IAEhG,OAAgB,QAAQ,WAKtB;IAEF,OAAgB,KAAK;;;;MAiBnB;IAEF,OAAgB,IAAI,KAAM;IAE1B,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,kBAAkB,CAAM;IAEnB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAyFnB,gBAAgB;YAiChB,SAAS;YAsBT,WAAW;YAUX,mBAAmB;IAmBjC,OAAO,CAAC,OAAO;IAsBf,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,WAAW;IA+BnB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,gBAAgB;CAQzB"}