@pie-element/cli 0.1.1 → 0.1.2-next.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 (281) hide show
  1. package/README.md +48 -10
  2. package/dist/commands/dev/demo/index.d.ts +1 -1
  3. package/dist/commands/dev/demo/index.js +21 -0
  4. package/dist/commands/dev/demo/index.js.map +1 -1
  5. package/dist/commands/dev/test-bundler.d.ts +0 -1
  6. package/dist/commands/dev/test-bundler.js +2 -10
  7. package/dist/commands/dev/test-bundler.js.map +1 -1
  8. package/dist/commands/docs/generate.d.ts +16 -0
  9. package/dist/commands/docs/generate.js +150 -0
  10. package/dist/commands/docs/generate.js.map +1 -0
  11. package/dist/commands/docs/verify.d.ts +12 -0
  12. package/dist/commands/docs/verify.js +40 -0
  13. package/dist/commands/docs/verify.js.map +1 -0
  14. package/dist/commands/packages/create-controllers.d.ts +0 -1
  15. package/dist/commands/packages/create-controllers.js.map +1 -1
  16. package/dist/commands/packages/create-lib-react.d.ts +0 -1
  17. package/dist/commands/packages/create-lib-react.js +1 -3
  18. package/dist/commands/packages/create-lib-react.js.map +1 -1
  19. package/dist/commands/packages/create-react-elements.d.ts +0 -1
  20. package/dist/commands/packages/create-react-elements.js +2 -3
  21. package/dist/commands/packages/create-react-elements.js.map +1 -1
  22. package/dist/commands/packages/enable-publishing.d.ts +0 -1
  23. package/dist/commands/packages/enable-publishing.js +26 -23
  24. package/dist/commands/packages/enable-publishing.js.map +1 -1
  25. package/dist/commands/packages/init-synced-elements.d.ts +0 -1
  26. package/dist/commands/packages/init-synced-elements.js +1 -1
  27. package/dist/commands/packages/init-synced-elements.js.map +1 -1
  28. package/dist/commands/upstream/analyze-esm.d.ts +0 -1
  29. package/dist/commands/upstream/analyze-esm.js +5 -1
  30. package/dist/commands/upstream/analyze-esm.js.map +1 -1
  31. package/dist/commands/upstream/check.d.ts +0 -1
  32. package/dist/commands/upstream/check.js.map +1 -1
  33. package/dist/commands/upstream/deps.d.ts +0 -1
  34. package/dist/commands/upstream/deps.js.map +1 -1
  35. package/dist/commands/upstream/sync.d.ts +11 -2
  36. package/dist/commands/upstream/sync.js +364 -25
  37. package/dist/commands/upstream/sync.js.map +1 -1
  38. package/dist/commands/upstream/track.d.ts +0 -1
  39. package/dist/commands/upstream/track.js.map +1 -1
  40. package/dist/commands/upstream/update.d.ts +0 -1
  41. package/dist/commands/upstream/update.js +37 -7
  42. package/dist/commands/upstream/update.js.map +1 -1
  43. package/dist/commands/verify/controllers.d.ts +0 -1
  44. package/dist/commands/verify/controllers.js +213 -59
  45. package/dist/commands/verify/controllers.js.map +1 -1
  46. package/dist/commands/verify/dependency-integrity.d.ts +18 -0
  47. package/dist/commands/verify/dependency-integrity.js +147 -0
  48. package/dist/commands/verify/dependency-integrity.js.map +1 -0
  49. package/dist/commands/verify/react-build.d.ts +0 -1
  50. package/dist/commands/verify/react-build.js.map +1 -1
  51. package/dist/index.d.ts +0 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/lib/docs/contract-validator.d.ts +12 -0
  54. package/dist/lib/docs/contract-validator.js +38 -0
  55. package/dist/lib/docs/contract-validator.js.map +1 -0
  56. package/dist/lib/docs/contracts.d.ts +11 -0
  57. package/dist/lib/docs/contracts.js +241 -0
  58. package/dist/lib/docs/contracts.js.map +1 -0
  59. package/dist/lib/docs/discovery.d.ts +10 -0
  60. package/dist/lib/docs/discovery.js +91 -0
  61. package/dist/lib/docs/discovery.js.map +1 -0
  62. package/dist/lib/docs/generator.d.ts +14 -0
  63. package/dist/lib/docs/generator.js +450 -0
  64. package/dist/lib/docs/generator.js.map +1 -0
  65. package/dist/lib/docs/source-extractor.d.ts +2 -0
  66. package/dist/lib/docs/source-extractor.js +209 -0
  67. package/dist/lib/docs/source-extractor.js.map +1 -0
  68. package/dist/lib/docs/types.d.ts +77 -0
  69. package/dist/lib/docs/types.js +2 -0
  70. package/dist/lib/docs/types.js.map +1 -0
  71. package/dist/lib/upstream/repo-utils.d.ts +0 -1
  72. package/dist/lib/upstream/repo-utils.js.map +1 -1
  73. package/dist/lib/upstream/sync-compatibility.d.ts +0 -1
  74. package/dist/lib/upstream/sync-compatibility.js.map +1 -1
  75. package/dist/lib/upstream/sync-constants.d.ts +35 -7
  76. package/dist/lib/upstream/sync-constants.js +40 -11
  77. package/dist/lib/upstream/sync-constants.js.map +1 -1
  78. package/dist/lib/upstream/sync-controllers-strategy.d.ts +0 -1
  79. package/dist/lib/upstream/sync-controllers-strategy.js +14 -4
  80. package/dist/lib/upstream/sync-controllers-strategy.js.map +1 -1
  81. package/dist/lib/upstream/sync-demo-metadata.d.ts +0 -1
  82. package/dist/lib/upstream/sync-demo-metadata.js +1 -1
  83. package/dist/lib/upstream/sync-demo-metadata.js.map +1 -1
  84. package/dist/lib/upstream/sync-entry-discovery.d.ts +3 -0
  85. package/dist/lib/upstream/sync-entry-discovery.js +23 -0
  86. package/dist/lib/upstream/sync-entry-discovery.js.map +1 -0
  87. package/dist/lib/upstream/sync-externals.d.ts +7 -7
  88. package/dist/lib/upstream/sync-externals.js +51 -35
  89. package/dist/lib/upstream/sync-externals.js.map +1 -1
  90. package/dist/lib/upstream/sync-filesystem.d.ts +0 -1
  91. package/dist/lib/upstream/sync-filesystem.js.map +1 -1
  92. package/dist/lib/upstream/sync-imports.d.ts +82 -62
  93. package/dist/lib/upstream/sync-imports.js +658 -185
  94. package/dist/lib/upstream/sync-imports.js.map +1 -1
  95. package/dist/lib/upstream/sync-package-json.d.ts +0 -1
  96. package/dist/lib/upstream/sync-package-json.js +7 -0
  97. package/dist/lib/upstream/sync-package-json.js.map +1 -1
  98. package/dist/lib/upstream/sync-package-manager.d.ts +14 -4
  99. package/dist/lib/upstream/sync-package-manager.js +408 -72
  100. package/dist/lib/upstream/sync-package-manager.js.map +1 -1
  101. package/dist/lib/upstream/sync-pielib-strategy.d.ts +2 -1
  102. package/dist/lib/upstream/sync-pielib-strategy.js +228 -110
  103. package/dist/lib/upstream/sync-pielib-strategy.js.map +1 -1
  104. package/dist/lib/upstream/sync-presets.d.ts +53 -0
  105. package/dist/lib/upstream/sync-presets.js +203 -0
  106. package/dist/lib/upstream/sync-presets.js.map +1 -0
  107. package/dist/lib/upstream/sync-react-strategy.d.ts +6 -1
  108. package/dist/lib/upstream/sync-react-strategy.js +342 -134
  109. package/dist/lib/upstream/sync-react-strategy.js.map +1 -1
  110. package/dist/lib/upstream/sync-source-edit.d.ts +14 -0
  111. package/dist/lib/upstream/sync-source-edit.js +89 -0
  112. package/dist/lib/upstream/sync-source-edit.js.map +1 -0
  113. package/dist/lib/upstream/sync-source-tree.d.ts +22 -0
  114. package/dist/lib/upstream/sync-source-tree.js +99 -0
  115. package/dist/lib/upstream/sync-source-tree.js.map +1 -0
  116. package/dist/lib/upstream/sync-strategy.d.ts +1 -1
  117. package/dist/lib/upstream/sync-strategy.js.map +1 -1
  118. package/dist/lib/upstream/sync-summary.d.ts +0 -1
  119. package/dist/lib/upstream/sync-summary.js.map +1 -1
  120. package/dist/lib/upstream/sync-transforms.d.ts +13 -11
  121. package/dist/lib/upstream/sync-transforms.js +23 -17
  122. package/dist/lib/upstream/sync-transforms.js.map +1 -1
  123. package/dist/lib/upstream/sync-vite-config.d.ts +13 -1
  124. package/dist/lib/upstream/sync-vite-config.js +65 -46
  125. package/dist/lib/upstream/sync-vite-config.js.map +1 -1
  126. package/dist/utils/compatibility.d.ts +13 -1
  127. package/dist/utils/compatibility.js +143 -2
  128. package/dist/utils/compatibility.js.map +1 -1
  129. package/dist/utils/conversion.d.ts +0 -1
  130. package/dist/utils/conversion.js.map +1 -1
  131. package/dist/utils/dependency-integrity.d.ts +37 -0
  132. package/dist/utils/dependency-integrity.js +557 -0
  133. package/dist/utils/dependency-integrity.js.map +1 -0
  134. package/dist/utils/git.d.ts +0 -1
  135. package/dist/utils/git.js.map +1 -1
  136. package/dist/utils/logger.d.ts +0 -1
  137. package/dist/utils/logger.js.map +1 -1
  138. package/dist/utils/package-json.d.ts +0 -1
  139. package/dist/utils/package-json.js.map +1 -1
  140. package/package.json +24 -12
  141. package/.compatibility/report.json +0 -2491
  142. package/.turbo/turbo-build.log +0 -1
  143. package/CHANGELOG.md +0 -8
  144. package/REFACTORING.md +0 -131
  145. package/bin/dev.js +0 -5
  146. package/dist/commands/dev/demo/index.d.ts.map +0 -1
  147. package/dist/commands/dev/test-bundler.d.ts.map +0 -1
  148. package/dist/commands/mathquill/migrate.d.ts +0 -20
  149. package/dist/commands/mathquill/migrate.d.ts.map +0 -1
  150. package/dist/commands/mathquill/migrate.js +0 -240
  151. package/dist/commands/mathquill/migrate.js.map +0 -1
  152. package/dist/commands/mathquill/status.d.ts +0 -20
  153. package/dist/commands/mathquill/status.d.ts.map +0 -1
  154. package/dist/commands/mathquill/status.js +0 -231
  155. package/dist/commands/mathquill/status.js.map +0 -1
  156. package/dist/commands/packages/create-controllers.d.ts.map +0 -1
  157. package/dist/commands/packages/create-lib-react.d.ts.map +0 -1
  158. package/dist/commands/packages/create-react-elements.d.ts.map +0 -1
  159. package/dist/commands/packages/enable-publishing.d.ts.map +0 -1
  160. package/dist/commands/packages/init-synced-elements.d.ts.map +0 -1
  161. package/dist/commands/upstream/analyze-esm.d.ts.map +0 -1
  162. package/dist/commands/upstream/check.d.ts.map +0 -1
  163. package/dist/commands/upstream/deps.d.ts.map +0 -1
  164. package/dist/commands/upstream/sync-mathquill.d.ts +0 -12
  165. package/dist/commands/upstream/sync-mathquill.d.ts.map +0 -1
  166. package/dist/commands/upstream/sync-mathquill.js +0 -97
  167. package/dist/commands/upstream/sync-mathquill.js.map +0 -1
  168. package/dist/commands/upstream/sync.d.ts.map +0 -1
  169. package/dist/commands/upstream/track.d.ts.map +0 -1
  170. package/dist/commands/upstream/update.d.ts.map +0 -1
  171. package/dist/commands/verify/controllers.d.ts.map +0 -1
  172. package/dist/commands/verify/react-build.d.ts.map +0 -1
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/lib/mathquill/extension-generator.d.ts +0 -9
  175. package/dist/lib/mathquill/extension-generator.d.ts.map +0 -1
  176. package/dist/lib/mathquill/extension-generator.js +0 -107
  177. package/dist/lib/mathquill/extension-generator.js.map +0 -1
  178. package/dist/lib/mathquill/khan-extractor.d.ts +0 -16
  179. package/dist/lib/mathquill/khan-extractor.d.ts.map +0 -1
  180. package/dist/lib/mathquill/khan-extractor.js +0 -148
  181. package/dist/lib/mathquill/khan-extractor.js.map +0 -1
  182. package/dist/lib/mathquill/learnosity-extractor.d.ts +0 -15
  183. package/dist/lib/mathquill/learnosity-extractor.d.ts.map +0 -1
  184. package/dist/lib/mathquill/learnosity-extractor.js +0 -170
  185. package/dist/lib/mathquill/learnosity-extractor.js.map +0 -1
  186. package/dist/lib/mathquill/migration-orchestrator.d.ts +0 -77
  187. package/dist/lib/mathquill/migration-orchestrator.d.ts.map +0 -1
  188. package/dist/lib/mathquill/migration-orchestrator.js +0 -391
  189. package/dist/lib/mathquill/migration-orchestrator.js.map +0 -1
  190. package/dist/lib/mathquill/package-updater.d.ts +0 -9
  191. package/dist/lib/mathquill/package-updater.d.ts.map +0 -1
  192. package/dist/lib/mathquill/package-updater.js +0 -103
  193. package/dist/lib/mathquill/package-updater.js.map +0 -1
  194. package/dist/lib/mathquill/pie-extractor.d.ts +0 -14
  195. package/dist/lib/mathquill/pie-extractor.d.ts.map +0 -1
  196. package/dist/lib/mathquill/pie-extractor.js +0 -167
  197. package/dist/lib/mathquill/pie-extractor.js.map +0 -1
  198. package/dist/lib/upstream/repo-utils.d.ts.map +0 -1
  199. package/dist/lib/upstream/sync-compatibility.d.ts.map +0 -1
  200. package/dist/lib/upstream/sync-constants.d.ts.map +0 -1
  201. package/dist/lib/upstream/sync-controllers-strategy.d.ts.map +0 -1
  202. package/dist/lib/upstream/sync-demo-metadata.d.ts.map +0 -1
  203. package/dist/lib/upstream/sync-dev-exports.d.ts +0 -13
  204. package/dist/lib/upstream/sync-dev-exports.d.ts.map +0 -1
  205. package/dist/lib/upstream/sync-dev-exports.js +0 -115
  206. package/dist/lib/upstream/sync-dev-exports.js.map +0 -1
  207. package/dist/lib/upstream/sync-externals.d.ts.map +0 -1
  208. package/dist/lib/upstream/sync-filesystem.d.ts.map +0 -1
  209. package/dist/lib/upstream/sync-imports.d.ts.map +0 -1
  210. package/dist/lib/upstream/sync-mathquill.d.ts +0 -19
  211. package/dist/lib/upstream/sync-mathquill.d.ts.map +0 -1
  212. package/dist/lib/upstream/sync-mathquill.js +0 -160
  213. package/dist/lib/upstream/sync-mathquill.js.map +0 -1
  214. package/dist/lib/upstream/sync-package-json.d.ts.map +0 -1
  215. package/dist/lib/upstream/sync-package-manager.d.ts.map +0 -1
  216. package/dist/lib/upstream/sync-pielib-strategy.d.ts.map +0 -1
  217. package/dist/lib/upstream/sync-react-strategy.d.ts.map +0 -1
  218. package/dist/lib/upstream/sync-strategy.d.ts.map +0 -1
  219. package/dist/lib/upstream/sync-summary.d.ts.map +0 -1
  220. package/dist/lib/upstream/sync-transforms.d.ts.map +0 -1
  221. package/dist/lib/upstream/sync-vite-config.d.ts.map +0 -1
  222. package/dist/utils/compatibility.d.ts.map +0 -1
  223. package/dist/utils/conversion.d.ts.map +0 -1
  224. package/dist/utils/git.d.ts.map +0 -1
  225. package/dist/utils/logger.d.ts.map +0 -1
  226. package/dist/utils/package-json.d.ts.map +0 -1
  227. package/packages/cli/bin/dev.js +0 -5
  228. package/packages/cli/bin/run.js +0 -5
  229. package/src/commands/dev/demo/index.ts +0 -313
  230. package/src/commands/dev/test-bundler.ts +0 -345
  231. package/src/commands/mathquill/migrate.ts +0 -269
  232. package/src/commands/mathquill/status.ts +0 -267
  233. package/src/commands/packages/create-controllers.ts +0 -127
  234. package/src/commands/packages/create-lib-react.ts +0 -279
  235. package/src/commands/packages/create-react-elements.ts +0 -306
  236. package/src/commands/packages/enable-publishing.ts +0 -161
  237. package/src/commands/packages/init-synced-elements.ts +0 -259
  238. package/src/commands/upstream/README.md +0 -444
  239. package/src/commands/upstream/analyze-esm.ts +0 -1973
  240. package/src/commands/upstream/check.ts +0 -228
  241. package/src/commands/upstream/deps.ts +0 -222
  242. package/src/commands/upstream/sync-mathquill.ts +0 -108
  243. package/src/commands/upstream/sync.ts +0 -687
  244. package/src/commands/upstream/track.ts +0 -145
  245. package/src/commands/upstream/update.ts +0 -110
  246. package/src/commands/verify/controllers.ts +0 -166
  247. package/src/commands/verify/react-build.ts +0 -171
  248. package/src/index.ts +0 -1
  249. package/src/lib/mathquill/extension-generator.ts +0 -111
  250. package/src/lib/mathquill/khan-extractor.ts +0 -175
  251. package/src/lib/mathquill/learnosity-extractor.ts +0 -198
  252. package/src/lib/mathquill/migration-orchestrator.ts +0 -513
  253. package/src/lib/mathquill/package-updater.ts +0 -120
  254. package/src/lib/mathquill/pie-extractor.ts +0 -194
  255. package/src/lib/upstream/repo-utils.ts +0 -18
  256. package/src/lib/upstream/sync-compatibility.ts +0 -89
  257. package/src/lib/upstream/sync-constants.ts +0 -77
  258. package/src/lib/upstream/sync-controllers-strategy.ts +0 -291
  259. package/src/lib/upstream/sync-demo-metadata.ts +0 -199
  260. package/src/lib/upstream/sync-dev-exports.ts +0 -151
  261. package/src/lib/upstream/sync-externals.ts +0 -159
  262. package/src/lib/upstream/sync-filesystem.ts +0 -87
  263. package/src/lib/upstream/sync-imports.ts +0 -992
  264. package/src/lib/upstream/sync-mathquill.ts +0 -194
  265. package/src/lib/upstream/sync-package-json.ts +0 -86
  266. package/src/lib/upstream/sync-package-manager.ts +0 -694
  267. package/src/lib/upstream/sync-pielib-strategy.ts +0 -441
  268. package/src/lib/upstream/sync-react-strategy.ts +0 -945
  269. package/src/lib/upstream/sync-strategy.ts +0 -61
  270. package/src/lib/upstream/sync-summary.ts +0 -194
  271. package/src/lib/upstream/sync-transforms.ts +0 -154
  272. package/src/lib/upstream/sync-vite-config.ts +0 -243
  273. package/src/types/es-module-lexer.d.ts +0 -4
  274. package/src/utils/compatibility.ts +0 -182
  275. package/src/utils/conversion.ts +0 -153
  276. package/src/utils/git.ts +0 -63
  277. package/src/utils/logger.ts +0 -69
  278. package/src/utils/package-json.ts +0 -43
  279. package/tests/sync-package-manager.test.ts +0 -112
  280. package/tests/transform-assign-props.test.ts +0 -101
  281. package/tsconfig.json +0 -15
@@ -1,444 +0,0 @@
1
- # Upstream Commands
2
-
3
- This directory contains commands for managing the synchronization between the upstream PIE repositories and this project.
4
-
5
- **Audience:** These commands are for maintainers who sync from upstream. Regular developers don't need these commands - synced packages are already committed to git, so just `git pull` to get updates.
6
-
7
- ## Overview
8
-
9
- The PIE Elements NG project syncs code from two upstream repositories:
10
-
11
- - **pie-elements** - Contains element controllers and React components
12
- - **pie-lib** - Contains shared library packages
13
-
14
- These commands help manage that synchronization process, analyze ESM compatibility, and track what's been synced.
15
-
16
- Synced packages (`packages/elements-react/*` and `packages/lib-react/*`) are committed to git, so regular developers can work without checking out the upstream repositories.
17
-
18
- At a high level, the update workflow does more than copy files. It:
19
-
20
- - Filters upstream packages via ESM compatibility analysis
21
- - Syncs controllers, React UI, and pie-lib sources into local packages
22
- - Converts source files to TypeScript (`.js`→`.ts`, `.jsx`→`.tsx`)
23
- - Rewrites package metadata (exports, entrypoints, sideEffects)
24
- - Generates element-specific Vite config and demo metadata
25
- - Cleans workspace deps and installs updated dependencies
26
-
27
- ## Commands
28
-
29
- ### `update` (Recommended)
30
-
31
- **The main command you should use!** Combines ESM analysis and syncing in one step.
32
-
33
- **Usage:**
34
-
35
- ```bash
36
- # Update everything (analyze + sync)
37
- bun cli upstream:update
38
-
39
- # Dry run to see what would change
40
- bun cli upstream:update --dry-run
41
-
42
- # Update specific element
43
- bun cli upstream:update --element=multiple-choice
44
-
45
- # Verbose output
46
- bun cli upstream:update --verbose
47
- ```
48
-
49
- **What it does:**
50
-
51
- 1. **Analyzes** ESM compatibility of all upstream packages
52
- 2. **Syncs** all compatible packages automatically
53
- 3. **Builds** touched packages (unless --skip-build)
54
-
55
- This is the recommended workflow as it ensures the analysis is always fresh before syncing.
56
-
57
- ---
58
-
59
- ### `analyze-esm`
60
-
61
- Analyzes ESM compatibility of upstream packages to determine what can be safely synced.
62
-
63
- **When to use:** When you only want to check compatibility without syncing, or for debugging.
64
-
65
- **Usage:**
66
-
67
- ```bash
68
- # Analyze all packages
69
- bun cli upstream:analyze-esm
70
-
71
- # Verbose output with dependency details
72
- bun cli upstream:analyze-esm --verbose
73
-
74
- # Include dev dependencies in analysis
75
- bun cli upstream:analyze-esm --include-dev-deps
76
-
77
- # Validate with runtime checks
78
- bun cli upstream:analyze-esm --validate
79
- ```
80
-
81
- **What it does:**
82
-
83
- 1. Scans all upstream packages for ESM blockers (CommonJS-only dependencies)
84
- 2. Checks element-to-element dependencies for transitive compatibility
85
- 3. Tracks @pie-lib dependencies used by elements
86
- 4. Generates compatibility report at `.compatibility/report.json`
87
- 5. Optional: Runtime validation by actually loading packages
88
-
89
- **Output:**
90
-
91
- - Lists ESM-compatible elements
92
- - Lists blocked elements with reasons
93
- - Shows @pie-lib package compatibility
94
- - Provides recommendations for fixing issues
95
-
96
- **Why run this first?**
97
- The sync command uses this report to automatically filter out incompatible packages, ensuring you only sync elements that will work as ESM modules.
98
-
99
- ### `sync`
100
-
101
- Synchronizes ESM-compatible code from upstream repositories to this project.
102
-
103
- **When to use:** When you've already run `analyze-esm` and want to sync without re-analyzing, or for advanced workflows.
104
-
105
- **Usage:**
106
-
107
- ```bash
108
- # Sync everything (automatically filters to ESM-compatible packages)
109
- bun cli upstream:sync
110
-
111
- # Dry run to see what would change
112
- bun cli upstream:sync --dry-run
113
-
114
- # Sync specific element
115
- bun cli upstream:sync --element=multiple-choice
116
-
117
- # Verbose output
118
- bun cli upstream:sync --verbose
119
- ```
120
-
121
- **What it does:**
122
-
123
- 1. **Reads compatibility report** from `analyze-esm` to filter packages
124
- 2. **Controllers**: Syncs from `pie-elements/packages/{element}/controller/src/` to `packages/elements-react/{element}/src/controller/`
125
- 3. **React Components**: Syncs from `pie-elements/packages/{element}/src/` to `packages/elements-react/{element}/src/`
126
- 4. **Pie-Lib**: Syncs from `pie-lib/packages/{package}/src/` to `packages/lib-react/{package}/src/`
127
- 5. **Conversions**: Automatically converts `.js` → `.ts` and `.jsx` → `.tsx`
128
- 6. **Package.json**: Generates ESM-compatible package.json with proper exports
129
- 7. **Build**: Automatically builds touched packages after sync
130
-
131
- **Strategy Pattern:**
132
- The sync command uses the strategy pattern for clean separation:
133
-
134
- - `ControllersStrategy` - Handles controller syncing
135
- - `ReactComponentsStrategy` - Handles React component syncing
136
- - `PieLibStrategy` - Handles pie-lib package syncing
137
-
138
- Each strategy is self-contained and independently testable.
139
-
140
- ### `track`
141
-
142
- Tracks synced packages and their upstream status.
143
-
144
- **Usage:**
145
-
146
- ```bash
147
- # Show sync status for all packages
148
- bun cli upstream:track
149
-
150
- # Check specific element
151
- bun cli upstream:track --element=multiple-choice
152
- ```
153
-
154
- **What it does:**
155
-
156
- 1. Shows which packages have been synced
157
- 2. Displays upstream commit hash for each package
158
- 3. Identifies packages that may need updates
159
-
160
- ## Workflow
161
-
162
- ### Initial Setup (Maintainers Only)
163
-
164
- **Note:** Only needed if you're a maintainer syncing from upstream. Regular developers can skip this.
165
-
166
- 1. Clone the upstream repositories as siblings to this repo:
167
-
168
- ```bash
169
- cd /path/to/projects
170
- git clone https://github.com/PieLabs/pie-elements.git
171
- git clone https://github.com/PieLabs/pie-lib.git
172
- git clone https://github.com/pie-framework/pie-elements-ng.git
173
- cd pie-elements-ng
174
- ```
175
-
176
- 2. Run initial analysis to see what's available:
177
-
178
- ```bash
179
- bun cli upstream:analyze-esm --verbose
180
- ```
181
-
182
- ### Regular Update Workflow (Simple)
183
-
184
- The simplest workflow using the combined `update` command:
185
-
186
- 1. **Pull upstream changes:**
187
-
188
- ```bash
189
- cd ../pie-elements && git pull
190
- cd ../pie-lib && git pull
191
- cd ../pie-element
192
- ```
193
-
194
- 2. **Check what would change** (dry run):
195
-
196
- ```bash
197
- bun cli upstream:update --dry-run --verbose
198
- ```
199
-
200
- 3. **Update everything:**
201
-
202
- ```bash
203
- bun cli upstream:update
204
- ```
205
-
206
- 4. **Review, test, and commit:**
207
-
208
- ```bash
209
- git diff
210
- bun test
211
- git add .
212
- git commit -m "sync: update from upstream"
213
- git push
214
- ```
215
-
216
- ### Incremental Update Workflow (Safer)
217
-
218
- For testing changes to individual elements first:
219
-
220
- 1. **Pull upstream changes:**
221
-
222
- ```bash
223
- cd ../pie-elements && git pull
224
- cd ../pie-lib && git pull
225
- cd ../pie-element
226
- ```
227
-
228
- 2. **Update specific element** (with dry run first):
229
-
230
- ```bash
231
- bun cli upstream:update --element=multiple-choice --dry-run
232
- bun cli upstream:update --element=multiple-choice
233
- ```
234
-
235
- 3. **Test the element:**
236
-
237
- ```bash
238
- bun test packages/elements-react/multiple-choice
239
- ```
240
-
241
- 4. **If good, update all:**
242
-
243
- ```bash
244
- bun cli upstream:update
245
- ```
246
-
247
- 5. **Commit and push:**
248
-
249
- ```bash
250
- git add .
251
- git commit -m "sync: update from upstream"
252
- git push
253
- ```
254
-
255
- ### Working with Blocked Elements
256
-
257
- If an element is blocked from ESM compatibility:
258
-
259
- 1. **Check why it's blocked:**
260
-
261
- ```bash
262
- bun cli upstream:analyze-esm --verbose | grep element-name
263
- ```
264
-
265
- 2. **Common blockers:**
266
- - `lodash` → Replace with native JS or `lodash-es`
267
- - `react-dnd` → Upgrade to v16+ (ESM compatible)
268
- - Sibling dependencies → Fix the dependency first
269
-
270
- 3. **Fix in upstream** (preferred):
271
- - Create PR in pie-elements to fix the blocker
272
- - Wait for merge
273
- - Re-analyze and sync
274
-
275
- 4. **Fix locally** (if urgent):
276
- - Sync the element
277
- - Manually fix the blocker in the local copy
278
- - Document the change
279
- - Create upstream PR later
280
-
281
- ## Advanced Features
282
-
283
- ### Always-Include Pie-Lib Packages
284
-
285
- Some @pie-lib packages (like `controller-utils`) are imported directly in controller code but not declared in element package.json files. To ensure these are always synced, they're defined in the `ALWAYS_INCLUDE_PIE_LIB` constant in [analyze-esm.ts](./analyze-esm.ts):
286
-
287
- ```typescript
288
- // PIE lib packages that should always be included if compatible
289
- // These are packages that may be imported directly in code (e.g., controllers)
290
- // but not declared in package.json dependencies
291
- const ALWAYS_INCLUDE_PIE_LIB = [
292
- "controller-utils", // Used in controller code via direct imports
293
- ];
294
- ```
295
-
296
- **When to add a package here:**
297
-
298
- - Package is imported in controller/component code
299
- - Package is NOT in element package.json dependencies
300
- - Package should be available for all elements that need it
301
-
302
- ### Element-Specific Build Configuration
303
-
304
- Some elements require special vite configuration (e.g., bundling specific dependencies instead of externalizing them). This is handled automatically by [sync-react-strategy.ts](./sync-react-strategy.ts).
305
-
306
- #### Konva Bundling Example
307
-
308
- Elements using konva/react-konva (like hotspot, drawing-response) bundle these libraries instead of externalizing them to avoid runtime resolution issues with transitive dependencies:
309
-
310
- ```typescript
311
- // In sync-react-strategy.ts
312
- const konvaElements = ["hotspot", "drawing-response"];
313
- const shouldBundleKonva = konvaElements.includes(elementName);
314
- ```
315
-
316
- This generates a special vite.config.ts that:
317
-
318
- - Bundles konva, react-konva, scheduler, and react-reconciler (not externalized)
319
- - Uses `preserveModules: true` to maintain proper import statements for other externals
320
- - Avoids CDN import map issues with complex dependency chains while preserving lodash imports
321
-
322
- **When to add an element to konvaElements:**
323
-
324
- - Element imports konva or react-konva
325
- - Seeing "schedulerExports is not defined" or similar runtime errors
326
- - Dependencies have complex transitive chains not suitable for CDN loading
327
-
328
- **Why bundle instead of externalize?**
329
-
330
- - Element-specific libraries (only 2-3 elements use konva)
331
- - Complex transitive dependencies (scheduler, react-reconciler)
332
- - CDN (esm.sh) import paths don't match local import maps
333
- - Better reliability and performance for specialized packages
334
-
335
- ### Demo Mode Configuration
336
-
337
- Elements with a `docs/demo` directory automatically get demo mode support in their vite.config.ts:
338
-
339
- ```typescript
340
- export default defineConfig(({ mode, command }) => ({
341
- plugins: [react()],
342
- // Only change root for demo mode when serving (not building)
343
- root:
344
- mode === "demo" && command === "serve"
345
- ? resolve(__dirname, "docs/demo")
346
- : __dirname,
347
- // ... rest of config
348
- }));
349
- ```
350
-
351
- This allows running `bun run demo` in the element package to serve the demo application.
352
-
353
- ## File Organization
354
-
355
- ```
356
- tools/cli/src/commands/upstream/
357
- ├── README.md # This file
358
- ├── update.ts # Combined update command (recommended)
359
- ├── analyze-esm.ts # ESM compatibility analyzer
360
- ├── sync.ts # Sync command (orchestration)
361
- ├── track.ts # Package tracking command
362
- ├── sync-strategy.ts # Strategy interface
363
- ├── sync-controllers-strategy.ts # Controller sync strategy
364
- ├── sync-react-strategy.ts # React component sync strategy
365
- ├── sync-pielib-strategy.ts # Pie-lib sync strategy
366
- ├── sync-filesystem.ts # File system utilities
367
- ├── sync-package-json.ts # Package.json utilities
368
- ├── sync-vite-config.ts # Vite config generation
369
- ├── sync-demo.ts # Demo generation utilities
370
- └── sync-imports.ts # Import fixing utilities
371
- ```
372
-
373
- ## Best Practices
374
-
375
- ### Do's ✅
376
-
377
- - **Always dry-run first** to see what will change
378
- - **Sync one element at a time** when testing
379
- - **Review diffs carefully** before committing
380
- - **Test after syncing** to ensure functionality
381
- - **Keep upstream siblings up to date** (git pull regularly)
382
- - **Use ESM-compatible dependencies** to unblock packages
383
- - **Document breaking changes** in commit messages
384
-
385
- ### Don'ts ❌
386
-
387
- - **Don't modify synced files directly** - changes will be overwritten on next sync
388
- - **Don't skip the build** - it catches issues early
389
- - **Don't force-sync incompatible elements** - they won't work as ESM
390
- - **Don't commit without testing** - broken elements affect everyone
391
- - **Don't sync without upstream being clean** - use stable commits
392
-
393
- ## Troubleshooting
394
-
395
- ### Sync fails with "file not found"
396
-
397
- Check that upstream repositories are at the expected locations:
398
-
399
- ```bash
400
- ls -la ../pie-elements ../pie-lib
401
- ```
402
-
403
- ### Build fails after sync
404
-
405
- 1. Check if dependencies changed in upstream package.json
406
- 2. Run `bun install` to update dependencies
407
- 3. Check for TypeScript errors in synced files
408
-
409
- ### Element marked as incompatible
410
-
411
- Run detailed analysis:
412
-
413
- ```bash
414
- bun cli upstream:analyze-esm --verbose --element=element-name
415
- ```
416
-
417
- Fix the blockers (see "Working with Blocked Elements" above).
418
-
419
- ### Import errors after sync
420
-
421
- The sync automatically fixes default exports, but some edge cases may require manual fixes:
422
-
423
- ```typescript
424
- // If you see errors like "X is not exported from Y"
425
- // Check if the import needs to be a named import
426
- import { something } from "./file"; // Instead of default import
427
- ```
428
-
429
- ## Contributing
430
-
431
- When adding new functionality to the sync process:
432
-
433
- 1. **Utilities** → Add to appropriate utility file (sync-\*.ts)
434
- 2. **New sync type** → Create a new strategy file
435
- 3. **Strategy changes** → Modify the specific strategy file
436
- 4. **Orchestration** → Update sync.ts (main command)
437
-
438
- Keep the strategy pattern clean - each strategy should be self-contained.
439
-
440
- ## Related Documentation
441
-
442
- - [REFACTORING.md](../../REFACTORING.md) - Details on the refactoring work
443
- - [Main CLI README](../../../README.md) - General CLI usage
444
- - [UPSTREAM_SYNC_GUIDE.md](../../../../../docs/migration/UPSTREAM_SYNC_GUIDE.md) - Detailed sync guide