@pie-element/cli 0.1.1 → 0.1.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +405 -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 +52 -0
  105. package/dist/lib/upstream/sync-presets.js +175 -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 +25 -8
  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,194 +0,0 @@
1
- /**
2
- * MathQuill synchronization utilities
3
- *
4
- * Handles syncing the PIE MathQuill fork from ../mathquill to packages/shared/mathquill
5
- * and regenerating the concatenated bundle.
6
- */
7
- import { existsSync } from 'node:fs';
8
- import { readFile, writeFile, mkdir, cp } from 'node:fs/promises';
9
- import { join } from 'node:path';
10
- import type { Logger } from '../../utils/logger.js';
11
-
12
- export interface MathQuillSyncConfig {
13
- upstreamMathQuillPath: string;
14
- sharedMathQuillPath: string;
15
- logger: Logger;
16
- }
17
-
18
- /**
19
- * Sync MathQuill source files from upstream
20
- */
21
- export async function syncMathQuillSources(config: MathQuillSyncConfig): Promise<boolean> {
22
- const { upstreamMathQuillPath, sharedMathQuillPath, logger } = config;
23
-
24
- if (!existsSync(upstreamMathQuillPath)) {
25
- logger.warn(
26
- `⚠️ Upstream MathQuill not found at ${upstreamMathQuillPath} - skipping MathQuill sync`
27
- );
28
- return false;
29
- }
30
-
31
- logger.info('📦 Syncing MathQuill sources from upstream...');
32
-
33
- try {
34
- // Ensure destination directories exist
35
- await mkdir(join(sharedMathQuillPath, 'src'), { recursive: true });
36
-
37
- // Copy core JavaScript files
38
- const coreFiles = [
39
- 'intro.js',
40
- 'outro.js',
41
- 'tree.js',
42
- 'cursor.js',
43
- 'controller.js',
44
- 'publicapi.js',
45
- ];
46
- for (const file of coreFiles) {
47
- const src = join(upstreamMathQuillPath, 'src', file);
48
- const dest = join(sharedMathQuillPath, 'src', file);
49
- if (existsSync(src)) {
50
- await cp(src, dest);
51
- logger.debug(` Copied ${file}`);
52
- }
53
- }
54
-
55
- // Copy directories
56
- const directories = ['services', 'commands', 'css', 'fonts'];
57
- for (const dir of directories) {
58
- const src = join(upstreamMathQuillPath, 'src', dir);
59
- const dest = join(sharedMathQuillPath, 'src', dir);
60
- if (existsSync(src)) {
61
- await cp(src, dest, { recursive: true });
62
- logger.debug(` Copied ${dir}/`);
63
- }
64
- }
65
-
66
- // Copy documentation
67
- const docs = ['README.md', 'CHANGELOG.md'];
68
- for (const doc of docs) {
69
- const src = join(upstreamMathQuillPath, doc);
70
- const dest = join(sharedMathQuillPath, doc);
71
- if (existsSync(src)) {
72
- await cp(src, dest);
73
- logger.debug(` Copied ${doc}`);
74
- }
75
- }
76
-
77
- logger.success('✅ MathQuill sources synced');
78
- return true;
79
- } catch (error) {
80
- logger.error(`❌ Failed to sync MathQuill sources: ${error}`);
81
- return false;
82
- }
83
- }
84
-
85
- /**
86
- * Regenerate the MathQuill bundle from source files
87
- */
88
- export async function regenerateMathQuillBundle(config: MathQuillSyncConfig): Promise<boolean> {
89
- const { upstreamMathQuillPath, sharedMathQuillPath, logger } = config;
90
-
91
- logger.info('🔨 Regenerating MathQuill bundle...');
92
-
93
- try {
94
- // Check for pjs library in upstream
95
- const pjsPath = join(upstreamMathQuillPath, 'node_modules/pjs/src/p.js');
96
- if (!existsSync(pjsPath)) {
97
- logger.warn(
98
- `⚠️ pjs library not found in upstream. Install it first: cd ${upstreamMathQuillPath} && npm install pjs`
99
- );
100
- return false;
101
- }
102
-
103
- // Read pjs
104
- const pjsContent = await readFile(pjsPath, 'utf-8');
105
-
106
- // Read all source files in order
107
- const srcDir = join(sharedMathQuillPath, 'src');
108
- const fileOrder = [
109
- 'intro.js',
110
- // pjs is inserted here programmatically
111
- 'tree.js',
112
- 'cursor.js',
113
- 'controller.js',
114
- 'publicapi.js',
115
- ];
116
-
117
- // Concatenate main files
118
- let bundle = '';
119
- for (const file of fileOrder) {
120
- if (file === 'intro.js') {
121
- const content = await readFile(join(srcDir, file), 'utf-8');
122
- bundle += content + '\n';
123
- bundle += pjsContent + '\n'; // Insert pjs after intro
124
- } else {
125
- const content = await readFile(join(srcDir, file), 'utf-8');
126
- bundle += content + '\n';
127
- }
128
- }
129
-
130
- // Add service utilities (*.util.js files first)
131
- const servicesDir = join(srcDir, 'services');
132
- const serviceFiles = await readdir(servicesDir);
133
- const utilFiles = serviceFiles.filter((f: string) => f.endsWith('.util.js'));
134
- const otherServiceFiles = serviceFiles.filter(
135
- (f: string) => f.endsWith('.js') && !f.endsWith('.util.js')
136
- );
137
-
138
- for (const file of [...utilFiles, ...otherServiceFiles]) {
139
- const content = await readFile(join(servicesDir, file), 'utf-8');
140
- bundle += content + '\n';
141
- }
142
-
143
- // Add commands
144
- const commandsDir = join(srcDir, 'commands');
145
- bundle += (await readFile(join(commandsDir, 'math.js'), 'utf-8')) + '\n';
146
- bundle += (await readFile(join(commandsDir, 'text.js'), 'utf-8')) + '\n';
147
-
148
- // Add math commands
149
- const mathCommandsDir = join(commandsDir, 'math');
150
- const mathFiles = await readdir(mathCommandsDir);
151
- for (const file of mathFiles.filter((f: string) => f.endsWith('.js'))) {
152
- const content = await readFile(join(mathCommandsDir, file), 'utf-8');
153
- bundle += content + '\n';
154
- }
155
-
156
- // Add outro
157
- bundle += (await readFile(join(srcDir, 'outro.js'), 'utf-8')) + '\n';
158
-
159
- // Write bundle
160
- const legacyDir = join(srcDir, 'legacy');
161
- await mkdir(legacyDir, { recursive: true });
162
- const bundlePath = join(legacyDir, 'mathquill-bundle.js');
163
- await writeFile(bundlePath, bundle, 'utf-8');
164
-
165
- const lineCount = bundle.split('\n').length;
166
- logger.success(`✅ Bundle regenerated: ${lineCount} lines`);
167
- logger.info(` Output: src/legacy/mathquill-bundle.js`);
168
-
169
- return true;
170
- } catch (error) {
171
- logger.error(`❌ Failed to regenerate bundle: ${error}`);
172
- return false;
173
- }
174
- }
175
-
176
- /**
177
- * Sync MathQuill: copy sources and regenerate bundle
178
- */
179
- export async function syncMathQuill(config: MathQuillSyncConfig): Promise<boolean> {
180
- const sourcesSynced = await syncMathQuillSources(config);
181
- if (!sourcesSynced) {
182
- return false;
183
- }
184
-
185
- const bundleRegenerated = await regenerateMathQuillBundle(config);
186
- return bundleRegenerated;
187
- }
188
-
189
- // Helper to read directory (wraps fs/promises)
190
- async function readdir(path: string): Promise<string[]> {
191
- const { readdir: fsReaddir } = await import('node:fs/promises');
192
- const entries = await fsReaddir(path, { withFileTypes: true });
193
- return entries.filter((e) => e.isFile()).map((e) => e.name);
194
- }
@@ -1,86 +0,0 @@
1
- /**
2
- * Package.json utilities for sync operations
3
- */
4
- import type { PackageJson } from '../../utils/package-json.js';
5
-
6
- /**
7
- * Get all dependencies from a package.json (dependencies + optionalDependencies + devDependencies)
8
- */
9
- export function getAllDeps(
10
- pkg: PackageJson | null,
11
- includeDevDeps = false
12
- ): Record<string, string> {
13
- if (!pkg) {
14
- return {};
15
- }
16
-
17
- const optionalDependencies =
18
- (pkg.optionalDependencies as Record<string, string> | undefined) ?? {};
19
-
20
- return {
21
- ...(pkg.dependencies ?? {}),
22
- ...optionalDependencies,
23
- ...(includeDevDeps && pkg.devDependencies ? pkg.devDependencies : {}),
24
- };
25
- }
26
-
27
- /**
28
- * Extract @pie-lib/* dependencies from a dependencies object
29
- */
30
- export function extractPieLibDeps(deps: Record<string, string>): string[] {
31
- return Object.keys(deps)
32
- .filter((dep) => dep.startsWith('@pie-lib/'))
33
- .map((dep) => dep.replace('@pie-lib/', ''));
34
- }
35
-
36
- /**
37
- * Extract @pie-element/* dependencies from a dependencies object
38
- */
39
- export function extractPieElementDeps(deps: Record<string, string>): string[] {
40
- return Object.keys(deps)
41
- .filter((dep) => dep.startsWith('@pie-element/'))
42
- .map((dep) => dep.replace('@pie-element/', ''));
43
- }
44
-
45
- /**
46
- * Generate ESM-compatible package.json exports for an element package
47
- */
48
- export function generateElementExports(options: {
49
- hasController: boolean;
50
- hasConfigure: boolean;
51
- }): Record<string, unknown> {
52
- const exports: Record<string, unknown> = {
53
- '.': {
54
- types: './dist/index.d.ts',
55
- default: './dist/index.js',
56
- },
57
- };
58
-
59
- if (options.hasController) {
60
- exports['./controller'] = {
61
- types: './dist/controller/index.d.ts',
62
- default: './dist/controller/index.js',
63
- };
64
- }
65
-
66
- if (options.hasConfigure) {
67
- exports['./configure'] = {
68
- types: './dist/configure/index.d.ts',
69
- default: './dist/configure/index.js',
70
- };
71
- }
72
-
73
- return exports;
74
- }
75
-
76
- /**
77
- * Generate ESM-compatible package.json exports for a pie-lib package
78
- */
79
- export function generatePieLibExports(): Record<string, unknown> {
80
- return {
81
- '.': {
82
- types: './dist/index.d.ts',
83
- default: './dist/index.js',
84
- },
85
- };
86
- }