@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,61 +0,0 @@
1
- /**
2
- * Strategy pattern for sync operations
3
- */
4
- import type { Logger } from '../../utils/logger.js';
5
- import type { CompatibilityReport } from '../../utils/compatibility.js';
6
-
7
- export interface SyncConfig {
8
- pieElements: string;
9
- pieLib: string;
10
- pieElementsNg: string;
11
-
12
- // What to sync
13
- syncControllers: boolean;
14
- syncReactComponents: boolean;
15
- syncPieLib: boolean;
16
-
17
- // Filters
18
- pieLibPackages?: string[];
19
-
20
- // Options
21
- skipDemos: boolean;
22
- upstreamCommit: string;
23
- }
24
-
25
- export interface SyncContext {
26
- config: SyncConfig;
27
- logger: Logger;
28
- packageFilter?: string;
29
- compatibilityReport?: CompatibilityReport;
30
- }
31
-
32
- export interface SyncResult {
33
- count: number;
34
- packageNames: string[];
35
- }
36
-
37
- /**
38
- * Base interface for sync strategies
39
- */
40
- export interface SyncStrategy {
41
- /**
42
- * Get the name of this strategy
43
- */
44
- getName(): string;
45
-
46
- /**
47
- * Check if this strategy should run based on config
48
- */
49
- shouldRun(config: SyncConfig): boolean;
50
-
51
- /**
52
- * Execute the sync operation
53
- * @returns Sync result with count and package names
54
- */
55
- execute(context: SyncContext): Promise<SyncResult>;
56
-
57
- /**
58
- * Get a human-readable description of what this strategy syncs
59
- */
60
- getDescription(): string;
61
- }
@@ -1,194 +0,0 @@
1
- /**
2
- * Summary utilities for sync operations
3
- */
4
- import { existsSync, readdirSync } from 'node:fs';
5
- import { join } from 'node:path';
6
- import type { Logger } from '../../utils/logger.js';
7
- import type { CompatibilityReport } from '../../utils/compatibility.js';
8
- import { EXCLUDED_UPSTREAM_ELEMENTS } from './sync-constants.js';
9
-
10
- export interface SyncSummary {
11
- controllersSync: number;
12
- reactComponentsSynced: number;
13
- pieLibPackagesSynced: number;
14
- totalPackagesSynced: number;
15
- blockedElements: number;
16
- blockedPieLib: number;
17
- syncedPackageNames: string[];
18
- }
19
-
20
- /**
21
- * Get all currently synced elements from packages/elements-react directory
22
- */
23
- function getAllSyncedElements(pieElementsNgPath: string): string[] {
24
- try {
25
- const elementsReactPath = join(pieElementsNgPath, 'packages', 'elements-react');
26
- const entries = readdirSync(elementsReactPath, { withFileTypes: true });
27
- return entries
28
- .filter((entry) => {
29
- if (!entry.isDirectory() || entry.name.startsWith('.')) {
30
- return false;
31
- }
32
- if (
33
- EXCLUDED_UPSTREAM_ELEMENTS.includes(
34
- entry.name as (typeof EXCLUDED_UPSTREAM_ELEMENTS)[number]
35
- )
36
- ) {
37
- return false;
38
- }
39
- return existsSync(join(elementsReactPath, entry.name, 'package.json'));
40
- })
41
- .map((entry) => entry.name)
42
- .sort();
43
- } catch (error) {
44
- return [];
45
- }
46
- }
47
-
48
- /**
49
- * Print a concise summary of the sync operation
50
- */
51
- export function printSyncSummary(
52
- summary: SyncSummary,
53
- compatibilityReport: CompatibilityReport | null,
54
- pieElementsNgPath: string,
55
- logger: Logger
56
- ): void {
57
- logger.info('');
58
- logger.info('─'.repeat(60));
59
- logger.info('');
60
-
61
- // Show changes from this sync run
62
- if (summary.syncedPackageNames.length > 0) {
63
- const elementCount = summary.syncedPackageNames.length;
64
- logger.success(`${elementCount} element${elementCount > 1 ? 's' : ''} synced in this run`);
65
- for (const pkg of summary.syncedPackageNames.sort()) {
66
- logger.info(` • ${pkg}`);
67
- }
68
- logger.info('');
69
- }
70
-
71
- // Show complete overview of all synced and blocked elements
72
- logger.info('Complete Overview:');
73
- logger.info('');
74
-
75
- // All currently synced elements
76
- const allSyncedElements = getAllSyncedElements(pieElementsNgPath);
77
- if (allSyncedElements.length > 0) {
78
- logger.success(`${allSyncedElements.length} elements currently synced`);
79
- for (const element of allSyncedElements) {
80
- logger.info(` • ${element}`);
81
- }
82
- } else {
83
- logger.info('No elements synced');
84
- }
85
-
86
- const totalBlocked = summary.blockedElements + summary.blockedPieLib;
87
- if (totalBlocked > 0 && compatibilityReport) {
88
- logger.info('');
89
- logger.warn(`${totalBlocked} packages blocked from sync (ESM incompatible)`);
90
-
91
- // List blocked elements
92
- const blockedElementNames = Object.keys(compatibilityReport.blockedElements).sort();
93
- if (blockedElementNames.length > 0) {
94
- logger.info('');
95
- logger.info('Blocked elements:');
96
- for (const element of blockedElementNames) {
97
- const blockers = compatibilityReport.blockedElements[element];
98
- const firstBlocker = blockers[0] || 'Unknown blocker';
99
- logger.info(` • ${element}: ${firstBlocker}`);
100
- }
101
- }
102
-
103
- // List blocked pie-lib packages
104
- const blockedPieLibNames = Object.entries(compatibilityReport.pieLibDetails)
105
- .filter(([, details]) => !details.compatible)
106
- .map(([pkg]) => pkg)
107
- .sort();
108
-
109
- if (blockedPieLibNames.length > 0) {
110
- logger.info('');
111
- logger.info('Blocked @pie-lib packages:');
112
- for (const pkg of blockedPieLibNames) {
113
- const details = compatibilityReport.pieLibDetails[pkg];
114
- const firstBlocker = details.blockers[0] || 'Unknown blocker';
115
- logger.info(` • @pie-lib/${pkg}: ${firstBlocker}`);
116
- }
117
- }
118
-
119
- // Show summary of blocker types
120
- if (logger.isVerbose()) {
121
- logger.info('');
122
- logger.info('Blocker summary by type:');
123
-
124
- // Group blockers by type
125
- const blockersByType = new Map<string, string[]>();
126
-
127
- // Analyze element blockers
128
- for (const [element, blockers] of Object.entries(compatibilityReport.blockedElements)) {
129
- for (const blocker of blockers) {
130
- const match = blocker.match(/^(.+?)\s*-\s*(.+)$/);
131
- if (match) {
132
- const [, dep, reason] = match;
133
- const key = `${dep}: ${reason}`;
134
- if (!blockersByType.has(key)) {
135
- blockersByType.set(key, []);
136
- }
137
- const pkgList = blockersByType.get(key);
138
- if (pkgList) {
139
- pkgList.push(element);
140
- }
141
- }
142
- }
143
- }
144
-
145
- // Analyze pie-lib blockers
146
- for (const [pkg, details] of Object.entries(compatibilityReport.pieLibDetails)) {
147
- if (!details.compatible) {
148
- for (const blocker of details.blockers) {
149
- const match = blocker.match(/^(.+?)\s*-\s*(.+)$/);
150
- if (match) {
151
- const [, dep, reason] = match;
152
- const key = `${dep}: ${reason}`;
153
- if (!blockersByType.has(key)) {
154
- blockersByType.set(key, []);
155
- }
156
- const pkgList = blockersByType.get(key);
157
- if (pkgList) {
158
- pkgList.push(`@pie-lib/${pkg}`);
159
- }
160
- }
161
- }
162
- }
163
- }
164
-
165
- const sortedBlockers = Array.from(blockersByType.entries()).sort(
166
- (a, b) => b[1].length - a[1].length
167
- );
168
-
169
- for (const [blocker, packages] of sortedBlockers) {
170
- logger.info(` • ${packages.length} package${packages.length > 1 ? 's' : ''}: ${blocker}`);
171
- for (const pkg of packages) {
172
- logger.info(` - ${pkg}`);
173
- }
174
- }
175
- }
176
- }
177
-
178
- logger.info('');
179
- }
180
-
181
- /**
182
- * Create an empty summary
183
- */
184
- export function createEmptySummary(): SyncSummary {
185
- return {
186
- controllersSync: 0,
187
- reactComponentsSynced: 0,
188
- pieLibPackagesSynced: 0,
189
- totalPackagesSynced: 0,
190
- blockedElements: 0,
191
- blockedPieLib: 0,
192
- syncedPackageNames: [],
193
- };
194
- }
@@ -1,154 +0,0 @@
1
- /**
2
- * Centralized transformation pipeline for upstream sync operations
3
- *
4
- * This module consolidates all source code transformations into a single,
5
- * composable pipeline to reduce duplication and ensure consistent transformations
6
- * across all sync strategies.
7
- */
8
-
9
- import {
10
- transformLodashToLodashEs,
11
- transformPieFrameworkEventImports,
12
- transformControllerUtilsImports,
13
- transformSharedPackageImports,
14
- transformMathquillImports,
15
- inlineEditableHtmlConstants,
16
- reexportTokenTypes,
17
- transformSsrRequireToReactLazy,
18
- inlineConfigureDefaults,
19
- transformConfigureUtilsImports,
20
- transformSelfReferentialImports,
21
- transformPackageJsonLodash,
22
- transformPackageJsonRecharts,
23
- transformPackageJsonPieEvents,
24
- transformPackageJsonControllerUtils,
25
- transformPackageJsonSharedPackages,
26
- transformPackageJsonMathquill,
27
- fixStyledComponentTypes,
28
- fixExportedFunctionTypes,
29
- transformMenuToInlineMenu,
30
- addInlineMenuExport,
31
- transformMathQuillInterface,
32
- } from './sync-imports.js';
33
- import type { PackageJson } from '../../utils/package-json.js';
34
-
35
- export interface TransformOptions {
36
- /** Path relative to package root (e.g., "configure/src/utils.js") */
37
- relativePath?: string;
38
- /** Source file path for context (e.g., "/path/to/file.js") */
39
- sourcePath?: string;
40
- /** Package name (e.g., "@pie-element/fraction-model") */
41
- packageName?: string;
42
- /** Whether to include configure-specific transforms */
43
- includeConfigure?: boolean;
44
- /** Whether to include pie-lib-specific transforms */
45
- includePieLib?: boolean;
46
- }
47
-
48
- /**
49
- * Apply all standard source code transformations in the correct order
50
- *
51
- * This ensures consistent transformation across all sync strategies:
52
- * 1. lodash → lodash-es (ESM compatibility)
53
- * 2. @pie-framework event packages → internal packages
54
- * 3. @pie-lib/controller-utils → @pie-framework/controller-utils
55
- * 4. @pie-lib shared packages → @pie-element/shared-*
56
- * 5. @pie-framework/mathquill → @pie-element/shared-mathquill
57
- * 6. @mui/material/Menu → InlineMenu from @pie-lib/render-ui
58
- * 7. Self-referential imports → relative imports
59
- * 8. Configure-specific transforms (if enabled)
60
- * 9. Pie-lib-specific transforms (if enabled)
61
- * 10. Fix styled component TypeScript type inference errors
62
- */
63
- export function applySourceTransforms(content: string, options: TransformOptions = {}): string {
64
- let transformed = content;
65
-
66
- // Core transforms (always applied)
67
- transformed = transformLodashToLodashEs(transformed);
68
- transformed = transformPieFrameworkEventImports(transformed);
69
- transformed = transformControllerUtilsImports(transformed);
70
- transformed = transformSharedPackageImports(transformed);
71
- transformed = transformMathquillImports(transformed);
72
- transformed = transformMathQuillInterface(transformed);
73
- transformed = transformMenuToInlineMenu(transformed);
74
-
75
- // Transform self-referential imports to relative paths
76
- if (options.packageName && options.relativePath) {
77
- transformed = transformSelfReferentialImports(
78
- transformed,
79
- options.packageName,
80
- options.relativePath
81
- );
82
- }
83
-
84
- // Configure-specific transforms
85
- if (options.includeConfigure) {
86
- transformed = inlineConfigureDefaults(transformed);
87
- if (options.relativePath) {
88
- transformed = transformConfigureUtilsImports(transformed, options.relativePath);
89
- }
90
- }
91
-
92
- // Pie-lib-specific transforms
93
- if (options.includePieLib) {
94
- transformed = inlineEditableHtmlConstants(transformed);
95
- if (options.sourcePath) {
96
- transformed = reexportTokenTypes(transformed, options.sourcePath);
97
- transformed = addInlineMenuExport(transformed, options.sourcePath);
98
- }
99
- transformed = transformSsrRequireToReactLazy(transformed);
100
- }
101
-
102
- // TypeScript fixes (always applied)
103
- transformed = fixStyledComponentTypes(transformed);
104
- transformed = fixExportedFunctionTypes(transformed, options.sourcePath);
105
-
106
- return transformed;
107
- }
108
-
109
- /**
110
- * Apply all standard package.json transformations
111
- *
112
- * Ensures consistent dependency transformations across all packages:
113
- * 1. lodash → lodash-es
114
- * 2. @pie-framework event packages → internal packages
115
- * 3. @pie-lib/controller-utils → @pie-framework/controller-utils
116
- * 4. @pie-lib shared packages → @pie-element/shared-*
117
- * 5. @pie-framework/mathquill → @pie-element/shared-mathquill
118
- */
119
- export function applyPackageJsonTransforms<T extends PackageJson>(pkg: T): T {
120
- let transformed = pkg;
121
-
122
- transformed = transformPackageJsonLodash(transformed);
123
- transformed = transformPackageJsonRecharts(transformed);
124
- transformed = transformPackageJsonPieEvents(transformed);
125
- transformed = transformPackageJsonControllerUtils(transformed);
126
- transformed = transformPackageJsonSharedPackages(transformed);
127
- transformed = transformPackageJsonMathquill(transformed);
128
-
129
- return transformed;
130
- }
131
-
132
- /**
133
- * Create a transform pipeline for controller files
134
- */
135
- export function createControllerTransformPipeline(packageName?: string) {
136
- return (content: string, relativePath?: string) =>
137
- applySourceTransforms(content, { relativePath, packageName, includeConfigure: false });
138
- }
139
-
140
- /**
141
- * Create a transform pipeline for React component files
142
- */
143
- export function createReactComponentTransformPipeline(packageName?: string) {
144
- return (content: string, relativePath?: string) =>
145
- applySourceTransforms(content, { relativePath, packageName, includeConfigure: true });
146
- }
147
-
148
- /**
149
- * Create a transform pipeline for pie-lib files
150
- */
151
- export function createPieLibTransformPipeline() {
152
- return (content: string, sourcePath?: string) =>
153
- applySourceTransforms(content, { sourcePath, includePieLib: true });
154
- }
@@ -1,243 +0,0 @@
1
- /**
2
- * Vite configuration generation for sync operations
3
- */
4
- import { existsSync } from 'node:fs';
5
- import { join } from 'node:path';
6
- import { createExternalFunction } from './sync-externals.js';
7
-
8
- /**
9
- * Detect the actual file extension for a source file
10
- */
11
- function detectFileExtension(basePath: string): string | null {
12
- if (existsSync(`${basePath}.tsx`)) return '.tsx';
13
- if (existsSync(`${basePath}.ts`)) return '.ts';
14
- return null;
15
- }
16
-
17
- /**
18
- * Detect entry points for an element package
19
- */
20
- export function detectElementEntryPoints(elementDir: string): Record<string, string> {
21
- const entryPoints: Record<string, string> = {};
22
-
23
- // Main index
24
- const indexExt = detectFileExtension(join(elementDir, 'src/index'));
25
- if (indexExt) {
26
- entryPoints.index = `src/index${indexExt}`;
27
- }
28
-
29
- // Controller
30
- const controllerExt = detectFileExtension(join(elementDir, 'src/controller/index'));
31
- if (controllerExt) {
32
- entryPoints['controller/index'] = `src/controller/index${controllerExt}`;
33
- }
34
-
35
- // Configure
36
- const configureExt = detectFileExtension(join(elementDir, 'src/configure/index'));
37
- if (configureExt) {
38
- entryPoints['configure/index'] = `src/configure/index${configureExt}`;
39
- }
40
-
41
- // Delivery
42
- const deliveryExt = detectFileExtension(join(elementDir, 'src/delivery/index'));
43
- if (deliveryExt) {
44
- entryPoints['delivery/index'] = `src/delivery/index${deliveryExt}`;
45
- }
46
-
47
- return entryPoints;
48
- }
49
-
50
- /**
51
- * Generate Vite config content for an element package
52
- */
53
- export function generateElementViteConfig(entryPoints: Record<string, string>): string {
54
- if (Object.keys(entryPoints).length === 0) {
55
- throw new Error('No entry points found for element');
56
- }
57
-
58
- const entryJson = JSON.stringify(entryPoints, null, 8).replace(/^/gm, ' ');
59
-
60
- return `import { resolve } from 'node:path';
61
- import react from '@vitejs/plugin-react';
62
- import { defineConfig } from 'vite';
63
-
64
- export default defineConfig(({ mode }) => {
65
- // Demo mode: serve the docs/demo directory
66
- if (mode === 'demo') {
67
- return {
68
- plugins: [react()],
69
- root: 'docs/demo',
70
- server: {
71
- port: 5174,
72
- },
73
- };
74
- }
75
-
76
- // Build mode: build the library
77
- return {
78
- plugins: [react()],
79
- build: {
80
- lib: {
81
- entry: ${entryJson.trimStart()},
82
- formats: ['es'],
83
- },
84
- rollupOptions: {
85
- external: ${createExternalFunction('element')},
86
- output: {
87
- preserveModules: true,
88
- preserveModulesRoot: 'src',
89
- },
90
- },
91
- },
92
- };
93
- });
94
- `;
95
- }
96
-
97
- /**
98
- * Generate Vite config content for a pie-lib package
99
- */
100
- export function generatePieLibViteConfig(packageName?: string, packageDir?: string): string {
101
- // Detect entry point extension if package directory provided
102
- let entryPoint = 'src/index.ts';
103
- if (packageDir) {
104
- const ext = detectFileExtension(join(packageDir, 'src/index'));
105
- if (ext) {
106
- entryPoint = `src/index${ext}`;
107
- }
108
- }
109
-
110
- // Special config for math-rendering wrapper (externalizes adapter package)
111
- if (packageName === 'math-rendering') {
112
- return `import { resolve } from 'node:path';
113
- import { defineConfig } from 'vite';
114
-
115
- export default defineConfig({
116
- build: {
117
- lib: {
118
- entry: {
119
- index: resolve(__dirname, '${entryPoint}'),
120
- },
121
- formats: ['es'],
122
- },
123
- rollupOptions: {
124
- external: (id) => {
125
- return (
126
- /^@pie-element\\/shared-/.test(id) ||
127
- id === '@pie-element/shared-math-rendering-mathjax' ||
128
- /^@pie-lib\\//.test(id) ||
129
- ['debug'].includes(id)
130
- );
131
- },
132
- output: {
133
- preserveModules: true,
134
- preserveModulesRoot: 'src',
135
- },
136
- },
137
- },
138
- });
139
- `;
140
- }
141
-
142
- // Special config for test-utils (includes testing library externals)
143
- if (packageName === 'test-utils') {
144
- return `import { resolve } from 'node:path';
145
- import react from '@vitejs/plugin-react';
146
- import { defineConfig } from 'vite';
147
-
148
- export default defineConfig({
149
- plugins: [react()],
150
- build: {
151
- lib: {
152
- entry: {
153
- index: resolve(__dirname, '${entryPoint}'),
154
- },
155
- formats: ['es'],
156
- },
157
- rollupOptions: {
158
- external: ${createExternalFunction('pielib')},
159
- output: {
160
- preserveModules: true,
161
- preserveModulesRoot: 'src',
162
- },
163
- },
164
- },
165
- });
166
- `;
167
- }
168
-
169
- // Special config for editable-html-tip-tap (externalizes prosemirror and tiptap)
170
- if (packageName === 'editable-html-tip-tap') {
171
- return `import { resolve } from 'node:path';
172
- import react from '@vitejs/plugin-react';
173
- import { defineConfig } from 'vite';
174
-
175
- export default defineConfig({
176
- plugins: [react()],
177
- build: {
178
- lib: {
179
- entry: {
180
- index: resolve(__dirname, '${entryPoint}'),
181
- },
182
- formats: ['es'],
183
- },
184
- rollupOptions: {
185
- external: (id) => {
186
- return (
187
- /^react($|\\/)/.test(id) ||
188
- /^react-dom($|\\/)/.test(id) ||
189
- /^@pie-lib\\//.test(id) ||
190
- /^@pie-element\\//.test(id) ||
191
- /^@pie-element\\//.test(id) ||
192
- /^@pie-framework\\//.test(id) ||
193
- /^@mui\\//.test(id) ||
194
- /^@emotion\\//.test(id) ||
195
- /^d3-/.test(id) ||
196
- /^@testing-library\\//.test(id) ||
197
- id === 'lodash-es' ||
198
- /^lodash-es\\//.test(id) ||
199
- /^styled-components/.test(id) ||
200
- id === 'konva' || /^konva\\//.test(id) ||
201
- id === 'react-konva' || /^react-konva\\//.test(id) ||
202
- id === '@mdi/react' || /^@mdi\\/react\\//.test(id) ||
203
- id === '@mdi/js' || /^@mdi\\/js\\//.test(id) ||
204
- /^prosemirror-/.test(id) ||
205
- /^@tiptap\\//.test(id) ||
206
- ['prop-types', 'classnames', 'debug', 'i18next', 'humps', 'mathjs', 'react-jss', 'js-combinatorics', '@dnd-kit/core', 'react-transition-group'].includes(id)
207
- );
208
- },
209
- output: {
210
- preserveModules: true,
211
- preserveModulesRoot: 'src',
212
- },
213
- },
214
- },
215
- });
216
- `;
217
- }
218
-
219
- // Default pie-lib config
220
- return `import { resolve } from 'node:path';
221
- import react from '@vitejs/plugin-react';
222
- import { defineConfig } from 'vite';
223
-
224
- export default defineConfig({
225
- plugins: [react()],
226
- build: {
227
- lib: {
228
- entry: {
229
- index: resolve(__dirname, '${entryPoint}'),
230
- },
231
- formats: ['es'],
232
- },
233
- rollupOptions: {
234
- external: ${createExternalFunction('pielib')},
235
- output: {
236
- preserveModules: true,
237
- preserveModulesRoot: 'src',
238
- },
239
- },
240
- },
241
- });
242
- `;
243
- }
@@ -1,4 +0,0 @@
1
- declare module 'es-module-lexer' {
2
- export const init: Promise<void>;
3
- export function parse(source: string): [Array<{ s: number; e: number }>, unknown];
4
- }