@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.
- package/README.md +48 -10
- package/dist/commands/dev/demo/index.d.ts +1 -1
- package/dist/commands/dev/demo/index.js +21 -0
- package/dist/commands/dev/demo/index.js.map +1 -1
- package/dist/commands/dev/test-bundler.d.ts +0 -1
- package/dist/commands/dev/test-bundler.js +2 -10
- package/dist/commands/dev/test-bundler.js.map +1 -1
- package/dist/commands/docs/generate.d.ts +16 -0
- package/dist/commands/docs/generate.js +150 -0
- package/dist/commands/docs/generate.js.map +1 -0
- package/dist/commands/docs/verify.d.ts +12 -0
- package/dist/commands/docs/verify.js +40 -0
- package/dist/commands/docs/verify.js.map +1 -0
- package/dist/commands/packages/create-controllers.d.ts +0 -1
- package/dist/commands/packages/create-controllers.js.map +1 -1
- package/dist/commands/packages/create-lib-react.d.ts +0 -1
- package/dist/commands/packages/create-lib-react.js +1 -3
- package/dist/commands/packages/create-lib-react.js.map +1 -1
- package/dist/commands/packages/create-react-elements.d.ts +0 -1
- package/dist/commands/packages/create-react-elements.js +2 -3
- package/dist/commands/packages/create-react-elements.js.map +1 -1
- package/dist/commands/packages/enable-publishing.d.ts +0 -1
- package/dist/commands/packages/enable-publishing.js +26 -23
- package/dist/commands/packages/enable-publishing.js.map +1 -1
- package/dist/commands/packages/init-synced-elements.d.ts +0 -1
- package/dist/commands/packages/init-synced-elements.js +1 -1
- package/dist/commands/packages/init-synced-elements.js.map +1 -1
- package/dist/commands/upstream/analyze-esm.d.ts +0 -1
- package/dist/commands/upstream/analyze-esm.js +5 -1
- package/dist/commands/upstream/analyze-esm.js.map +1 -1
- package/dist/commands/upstream/check.d.ts +0 -1
- package/dist/commands/upstream/check.js.map +1 -1
- package/dist/commands/upstream/deps.d.ts +0 -1
- package/dist/commands/upstream/deps.js.map +1 -1
- package/dist/commands/upstream/sync.d.ts +11 -2
- package/dist/commands/upstream/sync.js +364 -25
- package/dist/commands/upstream/sync.js.map +1 -1
- package/dist/commands/upstream/track.d.ts +0 -1
- package/dist/commands/upstream/track.js.map +1 -1
- package/dist/commands/upstream/update.d.ts +0 -1
- package/dist/commands/upstream/update.js +37 -7
- package/dist/commands/upstream/update.js.map +1 -1
- package/dist/commands/verify/controllers.d.ts +0 -1
- package/dist/commands/verify/controllers.js +213 -59
- package/dist/commands/verify/controllers.js.map +1 -1
- package/dist/commands/verify/dependency-integrity.d.ts +18 -0
- package/dist/commands/verify/dependency-integrity.js +147 -0
- package/dist/commands/verify/dependency-integrity.js.map +1 -0
- package/dist/commands/verify/react-build.d.ts +0 -1
- package/dist/commands/verify/react-build.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/docs/contract-validator.d.ts +12 -0
- package/dist/lib/docs/contract-validator.js +38 -0
- package/dist/lib/docs/contract-validator.js.map +1 -0
- package/dist/lib/docs/contracts.d.ts +11 -0
- package/dist/lib/docs/contracts.js +241 -0
- package/dist/lib/docs/contracts.js.map +1 -0
- package/dist/lib/docs/discovery.d.ts +10 -0
- package/dist/lib/docs/discovery.js +91 -0
- package/dist/lib/docs/discovery.js.map +1 -0
- package/dist/lib/docs/generator.d.ts +14 -0
- package/dist/lib/docs/generator.js +450 -0
- package/dist/lib/docs/generator.js.map +1 -0
- package/dist/lib/docs/source-extractor.d.ts +2 -0
- package/dist/lib/docs/source-extractor.js +209 -0
- package/dist/lib/docs/source-extractor.js.map +1 -0
- package/dist/lib/docs/types.d.ts +77 -0
- package/dist/lib/docs/types.js +2 -0
- package/dist/lib/docs/types.js.map +1 -0
- package/dist/lib/upstream/repo-utils.d.ts +0 -1
- package/dist/lib/upstream/repo-utils.js.map +1 -1
- package/dist/lib/upstream/sync-compatibility.d.ts +0 -1
- package/dist/lib/upstream/sync-compatibility.js.map +1 -1
- package/dist/lib/upstream/sync-constants.d.ts +35 -7
- package/dist/lib/upstream/sync-constants.js +40 -11
- package/dist/lib/upstream/sync-constants.js.map +1 -1
- package/dist/lib/upstream/sync-controllers-strategy.d.ts +0 -1
- package/dist/lib/upstream/sync-controllers-strategy.js +14 -4
- package/dist/lib/upstream/sync-controllers-strategy.js.map +1 -1
- package/dist/lib/upstream/sync-demo-metadata.d.ts +0 -1
- package/dist/lib/upstream/sync-demo-metadata.js +1 -1
- package/dist/lib/upstream/sync-demo-metadata.js.map +1 -1
- package/dist/lib/upstream/sync-entry-discovery.d.ts +3 -0
- package/dist/lib/upstream/sync-entry-discovery.js +23 -0
- package/dist/lib/upstream/sync-entry-discovery.js.map +1 -0
- package/dist/lib/upstream/sync-externals.d.ts +7 -7
- package/dist/lib/upstream/sync-externals.js +51 -35
- package/dist/lib/upstream/sync-externals.js.map +1 -1
- package/dist/lib/upstream/sync-filesystem.d.ts +0 -1
- package/dist/lib/upstream/sync-filesystem.js.map +1 -1
- package/dist/lib/upstream/sync-imports.d.ts +82 -62
- package/dist/lib/upstream/sync-imports.js +658 -185
- package/dist/lib/upstream/sync-imports.js.map +1 -1
- package/dist/lib/upstream/sync-package-json.d.ts +0 -1
- package/dist/lib/upstream/sync-package-json.js +7 -0
- package/dist/lib/upstream/sync-package-json.js.map +1 -1
- package/dist/lib/upstream/sync-package-manager.d.ts +14 -4
- package/dist/lib/upstream/sync-package-manager.js +405 -72
- package/dist/lib/upstream/sync-package-manager.js.map +1 -1
- package/dist/lib/upstream/sync-pielib-strategy.d.ts +2 -1
- package/dist/lib/upstream/sync-pielib-strategy.js +228 -110
- package/dist/lib/upstream/sync-pielib-strategy.js.map +1 -1
- package/dist/lib/upstream/sync-presets.d.ts +52 -0
- package/dist/lib/upstream/sync-presets.js +175 -0
- package/dist/lib/upstream/sync-presets.js.map +1 -0
- package/dist/lib/upstream/sync-react-strategy.d.ts +6 -1
- package/dist/lib/upstream/sync-react-strategy.js +342 -134
- package/dist/lib/upstream/sync-react-strategy.js.map +1 -1
- package/dist/lib/upstream/sync-source-edit.d.ts +14 -0
- package/dist/lib/upstream/sync-source-edit.js +89 -0
- package/dist/lib/upstream/sync-source-edit.js.map +1 -0
- package/dist/lib/upstream/sync-source-tree.d.ts +22 -0
- package/dist/lib/upstream/sync-source-tree.js +99 -0
- package/dist/lib/upstream/sync-source-tree.js.map +1 -0
- package/dist/lib/upstream/sync-strategy.d.ts +1 -1
- package/dist/lib/upstream/sync-strategy.js.map +1 -1
- package/dist/lib/upstream/sync-summary.d.ts +0 -1
- package/dist/lib/upstream/sync-summary.js.map +1 -1
- package/dist/lib/upstream/sync-transforms.d.ts +13 -11
- package/dist/lib/upstream/sync-transforms.js +23 -17
- package/dist/lib/upstream/sync-transforms.js.map +1 -1
- package/dist/lib/upstream/sync-vite-config.d.ts +13 -1
- package/dist/lib/upstream/sync-vite-config.js +65 -46
- package/dist/lib/upstream/sync-vite-config.js.map +1 -1
- package/dist/utils/compatibility.d.ts +13 -1
- package/dist/utils/compatibility.js +143 -2
- package/dist/utils/compatibility.js.map +1 -1
- package/dist/utils/conversion.d.ts +0 -1
- package/dist/utils/conversion.js.map +1 -1
- package/dist/utils/dependency-integrity.d.ts +37 -0
- package/dist/utils/dependency-integrity.js +557 -0
- package/dist/utils/dependency-integrity.js.map +1 -0
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/package-json.d.ts +0 -1
- package/dist/utils/package-json.js.map +1 -1
- package/package.json +25 -8
- package/.compatibility/report.json +0 -2491
- package/.turbo/turbo-build.log +0 -1
- package/CHANGELOG.md +0 -8
- package/REFACTORING.md +0 -131
- package/bin/dev.js +0 -5
- package/dist/commands/dev/demo/index.d.ts.map +0 -1
- package/dist/commands/dev/test-bundler.d.ts.map +0 -1
- package/dist/commands/mathquill/migrate.d.ts +0 -20
- package/dist/commands/mathquill/migrate.d.ts.map +0 -1
- package/dist/commands/mathquill/migrate.js +0 -240
- package/dist/commands/mathquill/migrate.js.map +0 -1
- package/dist/commands/mathquill/status.d.ts +0 -20
- package/dist/commands/mathquill/status.d.ts.map +0 -1
- package/dist/commands/mathquill/status.js +0 -231
- package/dist/commands/mathquill/status.js.map +0 -1
- package/dist/commands/packages/create-controllers.d.ts.map +0 -1
- package/dist/commands/packages/create-lib-react.d.ts.map +0 -1
- package/dist/commands/packages/create-react-elements.d.ts.map +0 -1
- package/dist/commands/packages/enable-publishing.d.ts.map +0 -1
- package/dist/commands/packages/init-synced-elements.d.ts.map +0 -1
- package/dist/commands/upstream/analyze-esm.d.ts.map +0 -1
- package/dist/commands/upstream/check.d.ts.map +0 -1
- package/dist/commands/upstream/deps.d.ts.map +0 -1
- package/dist/commands/upstream/sync-mathquill.d.ts +0 -12
- package/dist/commands/upstream/sync-mathquill.d.ts.map +0 -1
- package/dist/commands/upstream/sync-mathquill.js +0 -97
- package/dist/commands/upstream/sync-mathquill.js.map +0 -1
- package/dist/commands/upstream/sync.d.ts.map +0 -1
- package/dist/commands/upstream/track.d.ts.map +0 -1
- package/dist/commands/upstream/update.d.ts.map +0 -1
- package/dist/commands/verify/controllers.d.ts.map +0 -1
- package/dist/commands/verify/react-build.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/mathquill/extension-generator.d.ts +0 -9
- package/dist/lib/mathquill/extension-generator.d.ts.map +0 -1
- package/dist/lib/mathquill/extension-generator.js +0 -107
- package/dist/lib/mathquill/extension-generator.js.map +0 -1
- package/dist/lib/mathquill/khan-extractor.d.ts +0 -16
- package/dist/lib/mathquill/khan-extractor.d.ts.map +0 -1
- package/dist/lib/mathquill/khan-extractor.js +0 -148
- package/dist/lib/mathquill/khan-extractor.js.map +0 -1
- package/dist/lib/mathquill/learnosity-extractor.d.ts +0 -15
- package/dist/lib/mathquill/learnosity-extractor.d.ts.map +0 -1
- package/dist/lib/mathquill/learnosity-extractor.js +0 -170
- package/dist/lib/mathquill/learnosity-extractor.js.map +0 -1
- package/dist/lib/mathquill/migration-orchestrator.d.ts +0 -77
- package/dist/lib/mathquill/migration-orchestrator.d.ts.map +0 -1
- package/dist/lib/mathquill/migration-orchestrator.js +0 -391
- package/dist/lib/mathquill/migration-orchestrator.js.map +0 -1
- package/dist/lib/mathquill/package-updater.d.ts +0 -9
- package/dist/lib/mathquill/package-updater.d.ts.map +0 -1
- package/dist/lib/mathquill/package-updater.js +0 -103
- package/dist/lib/mathquill/package-updater.js.map +0 -1
- package/dist/lib/mathquill/pie-extractor.d.ts +0 -14
- package/dist/lib/mathquill/pie-extractor.d.ts.map +0 -1
- package/dist/lib/mathquill/pie-extractor.js +0 -167
- package/dist/lib/mathquill/pie-extractor.js.map +0 -1
- package/dist/lib/upstream/repo-utils.d.ts.map +0 -1
- package/dist/lib/upstream/sync-compatibility.d.ts.map +0 -1
- package/dist/lib/upstream/sync-constants.d.ts.map +0 -1
- package/dist/lib/upstream/sync-controllers-strategy.d.ts.map +0 -1
- package/dist/lib/upstream/sync-demo-metadata.d.ts.map +0 -1
- package/dist/lib/upstream/sync-dev-exports.d.ts +0 -13
- package/dist/lib/upstream/sync-dev-exports.d.ts.map +0 -1
- package/dist/lib/upstream/sync-dev-exports.js +0 -115
- package/dist/lib/upstream/sync-dev-exports.js.map +0 -1
- package/dist/lib/upstream/sync-externals.d.ts.map +0 -1
- package/dist/lib/upstream/sync-filesystem.d.ts.map +0 -1
- package/dist/lib/upstream/sync-imports.d.ts.map +0 -1
- package/dist/lib/upstream/sync-mathquill.d.ts +0 -19
- package/dist/lib/upstream/sync-mathquill.d.ts.map +0 -1
- package/dist/lib/upstream/sync-mathquill.js +0 -160
- package/dist/lib/upstream/sync-mathquill.js.map +0 -1
- package/dist/lib/upstream/sync-package-json.d.ts.map +0 -1
- package/dist/lib/upstream/sync-package-manager.d.ts.map +0 -1
- package/dist/lib/upstream/sync-pielib-strategy.d.ts.map +0 -1
- package/dist/lib/upstream/sync-react-strategy.d.ts.map +0 -1
- package/dist/lib/upstream/sync-strategy.d.ts.map +0 -1
- package/dist/lib/upstream/sync-summary.d.ts.map +0 -1
- package/dist/lib/upstream/sync-transforms.d.ts.map +0 -1
- package/dist/lib/upstream/sync-vite-config.d.ts.map +0 -1
- package/dist/utils/compatibility.d.ts.map +0 -1
- package/dist/utils/conversion.d.ts.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/package-json.d.ts.map +0 -1
- package/packages/cli/bin/dev.js +0 -5
- package/packages/cli/bin/run.js +0 -5
- package/src/commands/dev/demo/index.ts +0 -313
- package/src/commands/dev/test-bundler.ts +0 -345
- package/src/commands/mathquill/migrate.ts +0 -269
- package/src/commands/mathquill/status.ts +0 -267
- package/src/commands/packages/create-controllers.ts +0 -127
- package/src/commands/packages/create-lib-react.ts +0 -279
- package/src/commands/packages/create-react-elements.ts +0 -306
- package/src/commands/packages/enable-publishing.ts +0 -161
- package/src/commands/packages/init-synced-elements.ts +0 -259
- package/src/commands/upstream/README.md +0 -444
- package/src/commands/upstream/analyze-esm.ts +0 -1973
- package/src/commands/upstream/check.ts +0 -228
- package/src/commands/upstream/deps.ts +0 -222
- package/src/commands/upstream/sync-mathquill.ts +0 -108
- package/src/commands/upstream/sync.ts +0 -687
- package/src/commands/upstream/track.ts +0 -145
- package/src/commands/upstream/update.ts +0 -110
- package/src/commands/verify/controllers.ts +0 -166
- package/src/commands/verify/react-build.ts +0 -171
- package/src/index.ts +0 -1
- package/src/lib/mathquill/extension-generator.ts +0 -111
- package/src/lib/mathquill/khan-extractor.ts +0 -175
- package/src/lib/mathquill/learnosity-extractor.ts +0 -198
- package/src/lib/mathquill/migration-orchestrator.ts +0 -513
- package/src/lib/mathquill/package-updater.ts +0 -120
- package/src/lib/mathquill/pie-extractor.ts +0 -194
- package/src/lib/upstream/repo-utils.ts +0 -18
- package/src/lib/upstream/sync-compatibility.ts +0 -89
- package/src/lib/upstream/sync-constants.ts +0 -77
- package/src/lib/upstream/sync-controllers-strategy.ts +0 -291
- package/src/lib/upstream/sync-demo-metadata.ts +0 -199
- package/src/lib/upstream/sync-dev-exports.ts +0 -151
- package/src/lib/upstream/sync-externals.ts +0 -159
- package/src/lib/upstream/sync-filesystem.ts +0 -87
- package/src/lib/upstream/sync-imports.ts +0 -992
- package/src/lib/upstream/sync-mathquill.ts +0 -194
- package/src/lib/upstream/sync-package-json.ts +0 -86
- package/src/lib/upstream/sync-package-manager.ts +0 -694
- package/src/lib/upstream/sync-pielib-strategy.ts +0 -441
- package/src/lib/upstream/sync-react-strategy.ts +0 -945
- package/src/lib/upstream/sync-strategy.ts +0 -61
- package/src/lib/upstream/sync-summary.ts +0 -194
- package/src/lib/upstream/sync-transforms.ts +0 -154
- package/src/lib/upstream/sync-vite-config.ts +0 -243
- package/src/types/es-module-lexer.d.ts +0 -4
- package/src/utils/compatibility.ts +0 -182
- package/src/utils/conversion.ts +0 -153
- package/src/utils/git.ts +0 -63
- package/src/utils/logger.ts +0 -69
- package/src/utils/package-json.ts +0 -43
- package/tests/sync-package-manager.test.ts +0 -112
- package/tests/transform-assign-props.test.ts +0 -101
- package/tsconfig.json +0 -15
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import type { Logger } from '../../utils/logger.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* PIE Feature Extractor
|
|
7
|
-
*
|
|
8
|
-
* Extracts PIE-specific customizations from the legacy bundle:
|
|
9
|
-
* - Matrix commands (pmatrix, bmatrix, vmatrix)
|
|
10
|
-
* - LRN exponent notation
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface PIEExtractionResult {
|
|
14
|
-
features: string[];
|
|
15
|
-
files: string[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function extractPIEFeatures(
|
|
19
|
-
_mathquillPath: string,
|
|
20
|
-
outputPath: string,
|
|
21
|
-
logger: Logger
|
|
22
|
-
): Promise<PIEExtractionResult> {
|
|
23
|
-
const features: string[] = [];
|
|
24
|
-
const files: string[] = [];
|
|
25
|
-
|
|
26
|
-
// Extract matrices
|
|
27
|
-
logger.progress(' Extracting matrix commands...');
|
|
28
|
-
const matricesFile = join(outputPath, 'matrices.ts');
|
|
29
|
-
writeFileSync(matricesFile, generateMatricesCode());
|
|
30
|
-
features.push('matrices');
|
|
31
|
-
files.push(matricesFile);
|
|
32
|
-
|
|
33
|
-
// Extract LRN exponent
|
|
34
|
-
logger.progress(' Extracting LRN exponent...');
|
|
35
|
-
const lrnExponentFile = join(outputPath, 'lrn-exponent.ts');
|
|
36
|
-
writeFileSync(lrnExponentFile, generateLRNExponentCode());
|
|
37
|
-
features.push('lrn-exponent');
|
|
38
|
-
files.push(lrnExponentFile);
|
|
39
|
-
|
|
40
|
-
// Copy matrix styles
|
|
41
|
-
logger.progress(' Creating matrix styles...');
|
|
42
|
-
const stylesFile = join(outputPath, 'styles.css');
|
|
43
|
-
writeFileSync(stylesFile, generateMatrixStyles());
|
|
44
|
-
files.push(stylesFile);
|
|
45
|
-
|
|
46
|
-
// Create index file
|
|
47
|
-
const indexFile = join(outputPath, 'index.ts');
|
|
48
|
-
writeFileSync(indexFile, generatePIEIndexCode());
|
|
49
|
-
files.push(indexFile);
|
|
50
|
-
|
|
51
|
-
return { features, files };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function generateMatricesCode(): string {
|
|
55
|
-
return `/**
|
|
56
|
-
* Matrix Commands (PIE)
|
|
57
|
-
*
|
|
58
|
-
* Source: PIE fork (2019)
|
|
59
|
-
* File: src/legacy/mathquill-bundle.js lines 6600-6980
|
|
60
|
-
*
|
|
61
|
-
* Adds support for LaTeX matrix commands:
|
|
62
|
-
* - \\pmatrix: Matrix with parentheses ()
|
|
63
|
-
* - \\bmatrix: Matrix with square brackets []
|
|
64
|
-
* - \\vmatrix: Matrix with vertical bars ||
|
|
65
|
-
*
|
|
66
|
-
* These are standard LaTeX matrix types used in mathematics education.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
import type { MathQuillInterface } from 'mathquill';
|
|
70
|
-
import './styles.css';
|
|
71
|
-
|
|
72
|
-
export function addMatrixCommands(MQ: MathQuillInterface): void {
|
|
73
|
-
// Access MathQuill internals
|
|
74
|
-
const mqInternal = MQ as any;
|
|
75
|
-
|
|
76
|
-
if (!mqInternal.L?.LatexCmds) {
|
|
77
|
-
console.warn('MathQuill internals not accessible for matrix commands');
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// NOTE: This is a placeholder implementation
|
|
82
|
-
// The full PIE matrix implementation from the legacy bundle is complex
|
|
83
|
-
// and needs to be carefully ported to work with the Desmos fork.
|
|
84
|
-
//
|
|
85
|
-
// The legacy implementation (lines 6600-6980 in mathquill-bundle.js) includes:
|
|
86
|
-
// - Matrix base class with row/column management
|
|
87
|
-
// - Cell navigation and editing
|
|
88
|
-
// - LaTeX parsing and generation
|
|
89
|
-
// - HTML template generation
|
|
90
|
-
// - Reflow and sizing logic
|
|
91
|
-
//
|
|
92
|
-
// For the initial migration, we document that this needs implementation.
|
|
93
|
-
// The matrices from the legacy bundle should be extracted and adapted
|
|
94
|
-
// to work with the modern TypeScript Desmos fork.
|
|
95
|
-
|
|
96
|
-
// TODO: Extract and port full matrix implementation from legacy bundle
|
|
97
|
-
// Lines 6600-6980 in packages/shared/mathquill/src/legacy/mathquill-bundle.js
|
|
98
|
-
|
|
99
|
-
console.info('Matrix commands (pmatrix, bmatrix, vmatrix) need implementation');
|
|
100
|
-
console.info('See: packages/shared/mathquill/src/legacy/mathquill-bundle.js lines 6600-6980');
|
|
101
|
-
}
|
|
102
|
-
`;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function generateLRNExponentCode(): string {
|
|
106
|
-
return `/**
|
|
107
|
-
* LRN Exponent Command (PIE)
|
|
108
|
-
*
|
|
109
|
-
* Source: PIE fork (2019)
|
|
110
|
-
* File: src/legacy/mathquill-bundle.js
|
|
111
|
-
*
|
|
112
|
-
* Custom exponent notation for learning platforms.
|
|
113
|
-
* Provides a specialized exponent input format.
|
|
114
|
-
*
|
|
115
|
-
* Usage: \\lrnexponent{base}{exponent}
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
import type { MathQuillInterface } from 'mathquill';
|
|
119
|
-
|
|
120
|
-
export function addLRNExponent(MQ: MathQuillInterface): void {
|
|
121
|
-
// Access MathQuill internals
|
|
122
|
-
const mqInternal = MQ as any;
|
|
123
|
-
|
|
124
|
-
if (!mqInternal.L?.LatexCmds) {
|
|
125
|
-
console.warn('MathQuill internals not accessible for LRN exponent');
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// NOTE: This is a placeholder implementation
|
|
130
|
-
// The full PIE lrnexponent implementation needs to be extracted
|
|
131
|
-
// from the legacy bundle and ported to TypeScript.
|
|
132
|
-
//
|
|
133
|
-
// The legacy implementation includes:
|
|
134
|
-
// - Custom HTML template with specific styling
|
|
135
|
-
// - Special handling for base and exponent parts
|
|
136
|
-
// - Text template for plain text representation
|
|
137
|
-
//
|
|
138
|
-
// TODO: Extract and port lrnexponent implementation from legacy bundle
|
|
139
|
-
// Search for 'lrnexponent' in packages/shared/mathquill/src/legacy/mathquill-bundle.js
|
|
140
|
-
|
|
141
|
-
console.info('LRN exponent command needs implementation');
|
|
142
|
-
console.info('See: packages/shared/mathquill/src/legacy/mathquill-bundle.js (search: lrnexponent)');
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function generateMatrixStyles(): string {
|
|
148
|
-
return `/**
|
|
149
|
-
* Matrix Styles (PIE)
|
|
150
|
-
*
|
|
151
|
-
* CSS styling for matrix rendering
|
|
152
|
-
* Ported from packages/shared/mathquill/src/css/matrixed.less
|
|
153
|
-
*/
|
|
154
|
-
|
|
155
|
-
.mq-math-mode .mq-matrix {
|
|
156
|
-
display: inline-block;
|
|
157
|
-
vertical-align: middle;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.mq-math-mode .mq-matrix table {
|
|
161
|
-
border-collapse: collapse;
|
|
162
|
-
border-spacing: 0;
|
|
163
|
-
margin: 0.1em 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.mq-math-mode .mq-matrix td {
|
|
167
|
-
padding: 0.2em 0.4em;
|
|
168
|
-
text-align: center;
|
|
169
|
-
vertical-align: middle;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.mq-math-mode .mq-matrix .mq-paren {
|
|
173
|
-
font-size: 1.2em;
|
|
174
|
-
vertical-align: middle;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.mq-math-mode .mq-matrix .mq-scaled {
|
|
178
|
-
display: inline-block;
|
|
179
|
-
transform-origin: center;
|
|
180
|
-
}
|
|
181
|
-
`;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function generatePIEIndexCode(): string {
|
|
185
|
-
return `/**
|
|
186
|
-
* PIE Extensions
|
|
187
|
-
*
|
|
188
|
-
* PIE-specific customizations for educational assessment
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
|
-
export { addMatrixCommands } from './matrices.js';
|
|
192
|
-
export { addLRNExponent } from './lrn-exponent.js';
|
|
193
|
-
`;
|
|
194
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
|
|
3
|
-
type RepoSpec = {
|
|
4
|
-
label: string;
|
|
5
|
-
path: string;
|
|
6
|
-
extraMessage?: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const formatRepoNotFound = (label: string, path: string, extraMessage?: string): string =>
|
|
10
|
-
`${label} not found at ${path}${extraMessage ? `\n${extraMessage}` : ''}`;
|
|
11
|
-
|
|
12
|
-
export const assertReposExist = (repos: RepoSpec[]): void => {
|
|
13
|
-
for (const repo of repos) {
|
|
14
|
-
if (!existsSync(repo.path)) {
|
|
15
|
-
throw new Error(formatRepoNotFound(repo.label, repo.path, repo.extraMessage));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility checking utilities for upstream sync operations
|
|
3
|
-
*
|
|
4
|
-
* Consolidates subdirectory-level ESM compatibility checks that were
|
|
5
|
-
* duplicated across controllers-strategy and react-strategy.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { SyncContext } from './sync-strategy.js';
|
|
9
|
-
|
|
10
|
-
export type SubdirectoryType = 'src' | 'configure' | 'controller';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Check if a subdirectory is ESM-compatible based on the compatibility report
|
|
14
|
-
*
|
|
15
|
-
* This function consolidates the duplicated compatibility checking logic from
|
|
16
|
-
* ControllersStrategy and ReactComponentsStrategy.
|
|
17
|
-
*
|
|
18
|
-
* @param elementName - Name of the element (e.g., "multiple-choice")
|
|
19
|
-
* @param subdir - Subdirectory to check ("src", "configure", or "controller")
|
|
20
|
-
* @param context - Sync context containing the compatibility report
|
|
21
|
-
* @returns true if compatible or no report available, false if incompatible
|
|
22
|
-
*/
|
|
23
|
-
export function isSubdirectoryCompatible(
|
|
24
|
-
elementName: string,
|
|
25
|
-
subdir: SubdirectoryType,
|
|
26
|
-
context: SyncContext
|
|
27
|
-
): boolean {
|
|
28
|
-
// If no compatibility report, assume compatible (backward compatibility)
|
|
29
|
-
if (!context.compatibilityReport) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const elementDetail = context.compatibilityReport.elementDetails[elementName];
|
|
34
|
-
if (!elementDetail) {
|
|
35
|
-
return true; // Element not in report, assume compatible
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Check subdirectory-specific compatibility
|
|
39
|
-
switch (subdir) {
|
|
40
|
-
case 'configure':
|
|
41
|
-
return elementDetail.configure?.compatible ?? elementDetail.compatible;
|
|
42
|
-
case 'controller':
|
|
43
|
-
return elementDetail.controller?.compatible ?? elementDetail.compatible;
|
|
44
|
-
case 'src':
|
|
45
|
-
return elementDetail.studentUI?.compatible ?? elementDetail.compatible;
|
|
46
|
-
default:
|
|
47
|
-
return elementDetail.compatible;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Check if an element is ESM-compatible overall
|
|
53
|
-
*/
|
|
54
|
-
export function isElementCompatible(elementName: string, context: SyncContext): boolean {
|
|
55
|
-
if (!context.compatibilityReport) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return context.compatibilityReport.elements.includes(elementName);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Get compatibility blockers for an element subdirectory
|
|
64
|
-
*/
|
|
65
|
-
export function getCompatibilityBlockers(
|
|
66
|
-
elementName: string,
|
|
67
|
-
subdir: SubdirectoryType,
|
|
68
|
-
context: SyncContext
|
|
69
|
-
): string[] {
|
|
70
|
-
if (!context.compatibilityReport) {
|
|
71
|
-
return [];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const elementDetail = context.compatibilityReport.elementDetails[elementName];
|
|
75
|
-
if (!elementDetail) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
switch (subdir) {
|
|
80
|
-
case 'configure':
|
|
81
|
-
return elementDetail.configure?.blockers ?? [];
|
|
82
|
-
case 'controller':
|
|
83
|
-
return elementDetail.controller?.blockers ?? [];
|
|
84
|
-
case 'src':
|
|
85
|
-
return elementDetail.studentUI?.blockers ?? [];
|
|
86
|
-
default:
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared constants for upstream sync operations
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Default repository paths
|
|
6
|
-
export const DEFAULT_PATHS = {
|
|
7
|
-
PIE_ELEMENTS: '../pie-elements',
|
|
8
|
-
PIE_LIB: '../pie-lib',
|
|
9
|
-
PIE_ELEMENTS_NG: '.',
|
|
10
|
-
} as const;
|
|
11
|
-
|
|
12
|
-
// Workspace dependency patterns
|
|
13
|
-
export const WORKSPACE = {
|
|
14
|
-
VERSION: 'workspace:*',
|
|
15
|
-
PIE_LIB_PREFIX: '@pie-lib/',
|
|
16
|
-
PIE_ELEMENT_PREFIX: '@pie-element/',
|
|
17
|
-
PIE_FRAMEWORK_PREFIX: '@pie-framework/',
|
|
18
|
-
} as const;
|
|
19
|
-
|
|
20
|
-
// Upstream element packages intentionally excluded from sync.
|
|
21
|
-
// These templates are not used in pie-elements-ng runtime or are temporarily disabled.
|
|
22
|
-
export const EXCLUDED_UPSTREAM_ELEMENTS = [
|
|
23
|
-
'boilerplate-item-type',
|
|
24
|
-
'math-inline',
|
|
25
|
-
'math-templated',
|
|
26
|
-
] as const;
|
|
27
|
-
|
|
28
|
-
// Build tool versions
|
|
29
|
-
export const BUILD_TOOLS = {
|
|
30
|
-
VITE: '^6.0.0',
|
|
31
|
-
TYPESCRIPT: '^5.9.3',
|
|
32
|
-
VITE_REACT_PLUGIN: '^4.2.0',
|
|
33
|
-
LODASH_ES: '^4.17.22',
|
|
34
|
-
} as const;
|
|
35
|
-
|
|
36
|
-
// React versions
|
|
37
|
-
export const REACT = {
|
|
38
|
-
VERSION: '^18.0.0',
|
|
39
|
-
TYPES_VERSION: '^18.2.0',
|
|
40
|
-
} as const;
|
|
41
|
-
|
|
42
|
-
// Directory patterns to skip
|
|
43
|
-
export const SKIP_PATTERNS = {
|
|
44
|
-
TEST_DIRS: ['__tests__', '__mocks__'],
|
|
45
|
-
FILE_EXTENSIONS: ['.js', '.jsx', '.ts', '.tsx'],
|
|
46
|
-
} as const;
|
|
47
|
-
|
|
48
|
-
// File types
|
|
49
|
-
export const FILE_TYPES = {
|
|
50
|
-
JS: '.js',
|
|
51
|
-
JSX: '.jsx',
|
|
52
|
-
TS: '.ts',
|
|
53
|
-
TSX: '.tsx',
|
|
54
|
-
} as const;
|
|
55
|
-
|
|
56
|
-
// Package.json defaults
|
|
57
|
-
export const PACKAGE_DEFAULTS = {
|
|
58
|
-
TYPE: 'module',
|
|
59
|
-
SIDE_EFFECTS: false,
|
|
60
|
-
FILES: ['dist', 'src'],
|
|
61
|
-
} as const;
|
|
62
|
-
|
|
63
|
-
// Build scripts
|
|
64
|
-
export const SCRIPTS = {
|
|
65
|
-
BUILD: 'bun x vite build && bun x tsc --emitDeclarationOnly',
|
|
66
|
-
BUILD_WITH_IIFE:
|
|
67
|
-
'bun x vite build && bun x vite build --config vite.config.iife.ts && bun x tsc --emitDeclarationOnly',
|
|
68
|
-
DEV: 'bun x vite',
|
|
69
|
-
DEMO: 'bun x vite --mode demo',
|
|
70
|
-
TEST: 'bun x vitest run',
|
|
71
|
-
} as const;
|
|
72
|
-
|
|
73
|
-
// Compatibility report file
|
|
74
|
-
export const COMPATIBILITY_FILE = './.compatibility/report.json';
|
|
75
|
-
|
|
76
|
-
// Upstream history file
|
|
77
|
-
export const HISTORY_FILE = '.upstream-sync-history.json';
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Controller sync strategy - syncs controller logic from upstream pie-elements
|
|
3
|
-
*
|
|
4
|
-
* Synced from: pie-elements/packages/{element}/controller/src/
|
|
5
|
-
* Target: packages/elements-react/{element}/src/controller/
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { existsSync } from 'node:fs';
|
|
9
|
-
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
10
|
-
import { dirname, join } from 'node:path';
|
|
11
|
-
import { convertJsToTs } from '../../utils/conversion.js';
|
|
12
|
-
import { getCurrentCommit } from '../../utils/git.js';
|
|
13
|
-
import type { SyncStrategy, SyncContext, SyncConfig, SyncResult } from './sync-strategy.js';
|
|
14
|
-
import { cleanDirectory, existsAny, readdir } from './sync-filesystem.js';
|
|
15
|
-
import { createExternalFunction } from './sync-externals.js';
|
|
16
|
-
import { createControllerTransformPipeline } from './sync-transforms.js';
|
|
17
|
-
import { ensureElementPackageJson } from './sync-package-manager.js';
|
|
18
|
-
import { isSubdirectoryCompatible } from './sync-compatibility.js';
|
|
19
|
-
import { EXCLUDED_UPSTREAM_ELEMENTS } from './sync-constants.js';
|
|
20
|
-
|
|
21
|
-
interface InternalSyncResult {
|
|
22
|
-
filesChecked: number;
|
|
23
|
-
filesCopied: number;
|
|
24
|
-
filesSkipped: number;
|
|
25
|
-
filesUpdated: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class ControllersStrategy implements SyncStrategy {
|
|
29
|
-
private touchedElementPackages = new Set<string>();
|
|
30
|
-
private result: InternalSyncResult = {
|
|
31
|
-
filesChecked: 0,
|
|
32
|
-
filesCopied: 0,
|
|
33
|
-
filesSkipped: 0,
|
|
34
|
-
filesUpdated: 0,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
getName(): string {
|
|
38
|
-
return 'controllers';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getDescription(): string {
|
|
42
|
-
return 'controllers';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
shouldRun(config: SyncConfig): boolean {
|
|
46
|
-
return config.syncControllers;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async execute(context: SyncContext): Promise<SyncResult> {
|
|
50
|
-
const { config, logger } = context;
|
|
51
|
-
this.touchedElementPackages.clear();
|
|
52
|
-
this.result = {
|
|
53
|
-
filesChecked: 0,
|
|
54
|
-
filesCopied: 0,
|
|
55
|
-
filesSkipped: 0,
|
|
56
|
-
filesUpdated: 0,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (!logger.isVerbose()) {
|
|
60
|
-
logger.progressStart('Syncing controllers...');
|
|
61
|
-
} else {
|
|
62
|
-
logger.section('📦 Syncing controllers');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const upstreamElementsDir = join(config.pieElements, 'packages');
|
|
66
|
-
const targetBaseDir = join(config.pieElementsNg, 'packages/elements-react');
|
|
67
|
-
|
|
68
|
-
const upstreamCommit = getCurrentCommit(config.pieElements);
|
|
69
|
-
|
|
70
|
-
const packages = await readdir(upstreamElementsDir);
|
|
71
|
-
|
|
72
|
-
for (const pkg of packages) {
|
|
73
|
-
if (EXCLUDED_UPSTREAM_ELEMENTS.includes(pkg as (typeof EXCLUDED_UPSTREAM_ELEMENTS)[number])) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (context.packageFilter && pkg !== context.packageFilter) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Check if controller exists upstream
|
|
82
|
-
const controllerPath = join(upstreamElementsDir, pkg, 'controller/src/index.js');
|
|
83
|
-
if (!existsSync(controllerPath)) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Check if controller subdirectory is ESM-compatible
|
|
88
|
-
const controllerCompatible = isSubdirectoryCompatible(pkg, 'controller', context);
|
|
89
|
-
if (!controllerCompatible) {
|
|
90
|
-
if (logger.isVerbose()) {
|
|
91
|
-
logger.info(` ⏭️ ${pkg}: skipping controller/ (not ESM-compatible)`);
|
|
92
|
-
}
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.result.filesChecked++;
|
|
97
|
-
|
|
98
|
-
// Target: packages/elements-react/{element}/src/controller/index.ts
|
|
99
|
-
const targetDir = join(targetBaseDir, pkg, 'src/controller');
|
|
100
|
-
const targetPath = join(targetDir, 'index.ts');
|
|
101
|
-
|
|
102
|
-
// Clean target controller subtree first so removed upstream files don't linger
|
|
103
|
-
await this.cleanTargetDir(targetDir, `elements-react/${pkg}/src/controller`, logger);
|
|
104
|
-
|
|
105
|
-
// Read source
|
|
106
|
-
let sourceContent = await readFile(controllerPath, 'utf-8');
|
|
107
|
-
|
|
108
|
-
// Apply all standard transformations
|
|
109
|
-
const transformPipeline = createControllerTransformPipeline();
|
|
110
|
-
sourceContent = transformPipeline(sourceContent);
|
|
111
|
-
|
|
112
|
-
// Convert JS to TS
|
|
113
|
-
const { code: converted } = convertJsToTs(sourceContent, {
|
|
114
|
-
sourcePath: `pie-elements/packages/${pkg}/controller/src/index.js`,
|
|
115
|
-
commit: upstreamCommit,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
let elementChanged = false;
|
|
119
|
-
|
|
120
|
-
// Sync index.ts
|
|
121
|
-
// NOTE: This comparison is exact (===) to ensure any changes in:
|
|
122
|
-
// - Upstream source code
|
|
123
|
-
// - Transformation logic (lodash-es, event packages, etc.)
|
|
124
|
-
// - Sync version (tracked in @sync-version header)
|
|
125
|
-
// will trigger a file update. This prioritizes correctness over speed.
|
|
126
|
-
const isNew = !existsSync(targetPath);
|
|
127
|
-
if (!isNew) {
|
|
128
|
-
const currentContent = await readFile(targetPath, 'utf-8');
|
|
129
|
-
if (currentContent === converted) {
|
|
130
|
-
this.result.filesSkipped++;
|
|
131
|
-
} else {
|
|
132
|
-
this.result.filesUpdated++;
|
|
133
|
-
elementChanged = true;
|
|
134
|
-
await mkdir(dirname(targetPath), { recursive: true });
|
|
135
|
-
await writeFile(targetPath, converted, 'utf-8');
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
this.result.filesCopied++;
|
|
139
|
-
elementChanged = true;
|
|
140
|
-
await mkdir(dirname(targetPath), { recursive: true });
|
|
141
|
-
await writeFile(targetPath, converted, 'utf-8');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Also sync related files (defaults.js, utils.js, scoring.js, tickUtils.js)
|
|
145
|
-
const relatedFiles = ['defaults.js', 'utils.js', 'scoring.js', 'tickUtils.js'];
|
|
146
|
-
for (const file of relatedFiles) {
|
|
147
|
-
const relatedPath = join(upstreamElementsDir, pkg, 'controller/src', file);
|
|
148
|
-
if (existsSync(relatedPath)) {
|
|
149
|
-
const relatedTarget = join(targetDir, file.replace('.js', '.ts'));
|
|
150
|
-
let relatedContent = await readFile(relatedPath, 'utf-8');
|
|
151
|
-
|
|
152
|
-
// Apply all standard transformations
|
|
153
|
-
relatedContent = transformPipeline(relatedContent);
|
|
154
|
-
|
|
155
|
-
const { code: relatedConverted } = convertJsToTs(relatedContent, {
|
|
156
|
-
sourcePath: `pie-elements/packages/${pkg}/controller/src/${file}`,
|
|
157
|
-
commit: upstreamCommit,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const relatedIsNew = !existsSync(relatedTarget);
|
|
161
|
-
if (!relatedIsNew) {
|
|
162
|
-
const currentRelated = await readFile(relatedTarget, 'utf-8');
|
|
163
|
-
if (currentRelated === relatedConverted) {
|
|
164
|
-
this.result.filesSkipped++;
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
this.result.filesUpdated++;
|
|
168
|
-
elementChanged = true;
|
|
169
|
-
} else {
|
|
170
|
-
this.result.filesCopied++;
|
|
171
|
-
elementChanged = true;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
await mkdir(dirname(relatedTarget), { recursive: true });
|
|
175
|
-
await writeFile(relatedTarget, relatedConverted, 'utf-8');
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Ensure package.json has ESM module support (even in controller-only sync)
|
|
180
|
-
let wrotePkgJson = false;
|
|
181
|
-
const elementDir = join(targetBaseDir, pkg);
|
|
182
|
-
wrotePkgJson = await ensureElementPackageJson(pkg, elementDir, config);
|
|
183
|
-
await this.ensureElementViteConfig(pkg, elementDir, logger);
|
|
184
|
-
|
|
185
|
-
if (elementChanged || wrotePkgJson) {
|
|
186
|
-
if (logger.isVerbose()) {
|
|
187
|
-
logger.success(` 🔄 ${pkg}: controller package updated`);
|
|
188
|
-
}
|
|
189
|
-
this.touchedElementPackages.add(pkg);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (!logger.isVerbose()) {
|
|
194
|
-
logger.progressCompleteWithCount(this.touchedElementPackages.size, 'packages');
|
|
195
|
-
} else {
|
|
196
|
-
logger.info(`\nSynced ${this.touchedElementPackages.size} controller package(s)`);
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
count: this.touchedElementPackages.size,
|
|
200
|
-
packageNames: Array.from(this.touchedElementPackages).sort(),
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
private async cleanTargetDir(targetDir: string, label: string, logger: any): Promise<void> {
|
|
205
|
-
await cleanDirectory(targetDir, label, { dryRun: false, verbose: false }, logger);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
private async ensureElementViteConfig(
|
|
209
|
-
_elementName: string,
|
|
210
|
-
elementDir: string,
|
|
211
|
-
_logger: any
|
|
212
|
-
): Promise<void> {
|
|
213
|
-
if (!existsSync(elementDir)) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const viteConfigPath = join(elementDir, 'vite.config.ts');
|
|
218
|
-
|
|
219
|
-
// Always regenerate to reflect current directory structure
|
|
220
|
-
// (e.g., if configure/ was skipped due to ESM incompatibility)
|
|
221
|
-
|
|
222
|
-
// Detect entry points
|
|
223
|
-
const entryPoints: Record<string, string> = {};
|
|
224
|
-
const indexEntry = existsAny([
|
|
225
|
-
join(elementDir, 'src/index.ts'),
|
|
226
|
-
join(elementDir, 'src/index.tsx'),
|
|
227
|
-
]);
|
|
228
|
-
if (indexEntry) {
|
|
229
|
-
entryPoints.index = 'src/index.ts';
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const hasController = existsAny([
|
|
233
|
-
join(elementDir, 'src/controller/index.ts'),
|
|
234
|
-
join(elementDir, 'src/controller/index.tsx'),
|
|
235
|
-
]);
|
|
236
|
-
if (hasController) {
|
|
237
|
-
entryPoints['controller/index'] = 'src/controller/index.ts';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const hasConfigure = existsAny([
|
|
241
|
-
join(elementDir, 'src/configure/index.ts'),
|
|
242
|
-
join(elementDir, 'src/configure/index.tsx'),
|
|
243
|
-
]);
|
|
244
|
-
if (hasConfigure) {
|
|
245
|
-
entryPoints['configure/index'] = 'src/configure/index.ts';
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const hasDelivery = existsAny([
|
|
249
|
-
join(elementDir, 'src/delivery/index.ts'),
|
|
250
|
-
join(elementDir, 'src/delivery/index.tsx'),
|
|
251
|
-
]);
|
|
252
|
-
if (hasDelivery) {
|
|
253
|
-
entryPoints['delivery/index'] = 'src/delivery/index.ts';
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (Object.keys(entryPoints).length === 0) {
|
|
257
|
-
return; // No entry points, skip vite config
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Format entry points for vite config
|
|
261
|
-
const entryLines = Object.entries(entryPoints)
|
|
262
|
-
.map(([key, value]) => ` '${key}': resolve(__dirname, '${value}'),`)
|
|
263
|
-
.join('\n');
|
|
264
|
-
|
|
265
|
-
const viteConfig = `import { resolve } from 'node:path';
|
|
266
|
-
import react from '@vitejs/plugin-react';
|
|
267
|
-
import { defineConfig } from 'vite';
|
|
268
|
-
|
|
269
|
-
export default defineConfig({
|
|
270
|
-
plugins: [react()],
|
|
271
|
-
build: {
|
|
272
|
-
lib: {
|
|
273
|
-
entry: {
|
|
274
|
-
${entryLines}
|
|
275
|
-
},
|
|
276
|
-
formats: ['es'],
|
|
277
|
-
},
|
|
278
|
-
rollupOptions: {
|
|
279
|
-
external: ${createExternalFunction('pielib')},
|
|
280
|
-
output: {
|
|
281
|
-
preserveModules: true,
|
|
282
|
-
preserveModulesRoot: 'src',
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
});
|
|
287
|
-
`;
|
|
288
|
-
|
|
289
|
-
await writeFile(viteConfigPath, viteConfig, 'utf-8');
|
|
290
|
-
}
|
|
291
|
-
}
|