@pie-element/cli 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.compatibility/report.json +2491 -0
- package/.turbo/turbo-build.log +1 -0
- package/CHANGELOG.md +8 -0
- package/README.md +240 -0
- package/REFACTORING.md +131 -0
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/commands/dev/demo/index.d.ts +33 -0
- package/dist/commands/dev/demo/index.d.ts.map +1 -0
- package/dist/commands/dev/demo/index.js +274 -0
- package/dist/commands/dev/demo/index.js.map +1 -0
- package/dist/commands/dev/test-bundler.d.ts +18 -0
- package/dist/commands/dev/test-bundler.d.ts.map +1 -0
- package/dist/commands/dev/test-bundler.js +284 -0
- package/dist/commands/dev/test-bundler.js.map +1 -0
- package/dist/commands/mathquill/migrate.d.ts +20 -0
- package/dist/commands/mathquill/migrate.d.ts.map +1 -0
- package/dist/commands/mathquill/migrate.js +240 -0
- package/dist/commands/mathquill/migrate.js.map +1 -0
- package/dist/commands/mathquill/status.d.ts +20 -0
- package/dist/commands/mathquill/status.d.ts.map +1 -0
- package/dist/commands/mathquill/status.js +231 -0
- package/dist/commands/mathquill/status.js.map +1 -0
- package/dist/commands/packages/create-controllers.d.ts +13 -0
- package/dist/commands/packages/create-controllers.d.ts.map +1 -0
- package/dist/commands/packages/create-controllers.js +103 -0
- package/dist/commands/packages/create-controllers.js.map +1 -0
- package/dist/commands/packages/create-lib-react.d.ts +17 -0
- package/dist/commands/packages/create-lib-react.d.ts.map +1 -0
- package/dist/commands/packages/create-lib-react.js +228 -0
- package/dist/commands/packages/create-lib-react.js.map +1 -0
- package/dist/commands/packages/create-react-elements.d.ts +16 -0
- package/dist/commands/packages/create-react-elements.d.ts.map +1 -0
- package/dist/commands/packages/create-react-elements.js +259 -0
- package/dist/commands/packages/create-react-elements.js.map +1 -0
- package/dist/commands/packages/enable-publishing.d.ts +11 -0
- package/dist/commands/packages/enable-publishing.d.ts.map +1 -0
- package/dist/commands/packages/enable-publishing.js +117 -0
- package/dist/commands/packages/enable-publishing.js.map +1 -0
- package/dist/commands/packages/init-synced-elements.d.ts +16 -0
- package/dist/commands/packages/init-synced-elements.d.ts.map +1 -0
- package/dist/commands/packages/init-synced-elements.js +204 -0
- package/dist/commands/packages/init-synced-elements.js.map +1 -0
- package/dist/commands/upstream/analyze-esm.d.ts +59 -0
- package/dist/commands/upstream/analyze-esm.d.ts.map +1 -0
- package/dist/commands/upstream/analyze-esm.js +1481 -0
- package/dist/commands/upstream/analyze-esm.js.map +1 -0
- package/dist/commands/upstream/check.d.ts +15 -0
- package/dist/commands/upstream/check.d.ts.map +1 -0
- package/dist/commands/upstream/check.js +165 -0
- package/dist/commands/upstream/check.js.map +1 -0
- package/dist/commands/upstream/deps.d.ts +15 -0
- package/dist/commands/upstream/deps.d.ts.map +1 -0
- package/dist/commands/upstream/deps.js +174 -0
- package/dist/commands/upstream/deps.js.map +1 -0
- package/dist/commands/upstream/sync-mathquill.d.ts +12 -0
- package/dist/commands/upstream/sync-mathquill.d.ts.map +1 -0
- package/dist/commands/upstream/sync-mathquill.js +97 -0
- package/dist/commands/upstream/sync-mathquill.js.map +1 -0
- package/dist/commands/upstream/sync.d.ts +25 -0
- package/dist/commands/upstream/sync.d.ts.map +1 -0
- package/dist/commands/upstream/sync.js +552 -0
- package/dist/commands/upstream/sync.js.map +1 -0
- package/dist/commands/upstream/track.d.ts +15 -0
- package/dist/commands/upstream/track.d.ts.map +1 -0
- package/dist/commands/upstream/track.js +115 -0
- package/dist/commands/upstream/track.js.map +1 -0
- package/dist/commands/upstream/update.d.ts +15 -0
- package/dist/commands/upstream/update.d.ts.map +1 -0
- package/dist/commands/upstream/update.js +98 -0
- package/dist/commands/upstream/update.js.map +1 -0
- package/dist/commands/verify/controllers.d.ts +12 -0
- package/dist/commands/verify/controllers.d.ts.map +1 -0
- package/dist/commands/verify/controllers.js +138 -0
- package/dist/commands/verify/controllers.js.map +1 -0
- package/dist/commands/verify/react-build.d.ts +13 -0
- package/dist/commands/verify/react-build.d.ts.map +1 -0
- package/dist/commands/verify/react-build.js +135 -0
- package/dist/commands/verify/react-build.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/mathquill/extension-generator.d.ts +9 -0
- package/dist/lib/mathquill/extension-generator.d.ts.map +1 -0
- package/dist/lib/mathquill/extension-generator.js +107 -0
- package/dist/lib/mathquill/extension-generator.js.map +1 -0
- package/dist/lib/mathquill/khan-extractor.d.ts +16 -0
- package/dist/lib/mathquill/khan-extractor.d.ts.map +1 -0
- package/dist/lib/mathquill/khan-extractor.js +148 -0
- package/dist/lib/mathquill/khan-extractor.js.map +1 -0
- package/dist/lib/mathquill/learnosity-extractor.d.ts +15 -0
- package/dist/lib/mathquill/learnosity-extractor.d.ts.map +1 -0
- package/dist/lib/mathquill/learnosity-extractor.js +170 -0
- package/dist/lib/mathquill/learnosity-extractor.js.map +1 -0
- package/dist/lib/mathquill/migration-orchestrator.d.ts +77 -0
- package/dist/lib/mathquill/migration-orchestrator.d.ts.map +1 -0
- package/dist/lib/mathquill/migration-orchestrator.js +391 -0
- package/dist/lib/mathquill/migration-orchestrator.js.map +1 -0
- package/dist/lib/mathquill/package-updater.d.ts +9 -0
- package/dist/lib/mathquill/package-updater.d.ts.map +1 -0
- package/dist/lib/mathquill/package-updater.js +103 -0
- package/dist/lib/mathquill/package-updater.js.map +1 -0
- package/dist/lib/mathquill/pie-extractor.d.ts +14 -0
- package/dist/lib/mathquill/pie-extractor.d.ts.map +1 -0
- package/dist/lib/mathquill/pie-extractor.js +167 -0
- package/dist/lib/mathquill/pie-extractor.js.map +1 -0
- package/dist/lib/upstream/repo-utils.d.ts +9 -0
- package/dist/lib/upstream/repo-utils.d.ts.map +1 -0
- package/dist/lib/upstream/repo-utils.js +10 -0
- package/dist/lib/upstream/repo-utils.js.map +1 -0
- package/dist/lib/upstream/sync-compatibility.d.ts +29 -0
- package/dist/lib/upstream/sync-compatibility.d.ts.map +1 -0
- package/dist/lib/upstream/sync-compatibility.js +70 -0
- package/dist/lib/upstream/sync-compatibility.js.map +1 -0
- package/dist/lib/upstream/sync-constants.d.ts +50 -0
- package/dist/lib/upstream/sync-constants.d.ts.map +1 -0
- package/dist/lib/upstream/sync-constants.js +66 -0
- package/dist/lib/upstream/sync-constants.js.map +1 -0
- package/dist/lib/upstream/sync-controllers-strategy.d.ts +18 -0
- package/dist/lib/upstream/sync-controllers-strategy.d.ts.map +1 -0
- package/dist/lib/upstream/sync-controllers-strategy.js +243 -0
- package/dist/lib/upstream/sync-controllers-strategy.js.map +1 -0
- package/dist/lib/upstream/sync-demo-metadata.d.ts +15 -0
- package/dist/lib/upstream/sync-demo-metadata.d.ts.map +1 -0
- package/dist/lib/upstream/sync-demo-metadata.js +165 -0
- package/dist/lib/upstream/sync-demo-metadata.js.map +1 -0
- package/dist/lib/upstream/sync-dev-exports.d.ts +13 -0
- package/dist/lib/upstream/sync-dev-exports.d.ts.map +1 -0
- package/dist/lib/upstream/sync-dev-exports.js +115 -0
- package/dist/lib/upstream/sync-dev-exports.js.map +1 -0
- package/dist/lib/upstream/sync-externals.d.ts +29 -0
- package/dist/lib/upstream/sync-externals.d.ts.map +1 -0
- package/dist/lib/upstream/sync-externals.js +164 -0
- package/dist/lib/upstream/sync-externals.js.map +1 -0
- package/dist/lib/upstream/sync-filesystem.d.ts +21 -0
- package/dist/lib/upstream/sync-filesystem.d.ts.map +1 -0
- package/dist/lib/upstream/sync-filesystem.js +64 -0
- package/dist/lib/upstream/sync-filesystem.js.map +1 -0
- package/dist/lib/upstream/sync-imports.d.ts +284 -0
- package/dist/lib/upstream/sync-imports.d.ts.map +1 -0
- package/dist/lib/upstream/sync-imports.js +816 -0
- package/dist/lib/upstream/sync-imports.js.map +1 -0
- package/dist/lib/upstream/sync-mathquill.d.ts +19 -0
- package/dist/lib/upstream/sync-mathquill.d.ts.map +1 -0
- package/dist/lib/upstream/sync-mathquill.js +160 -0
- package/dist/lib/upstream/sync-mathquill.js.map +1 -0
- package/dist/lib/upstream/sync-package-json.d.ts +28 -0
- package/dist/lib/upstream/sync-package-json.d.ts.map +1 -0
- package/dist/lib/upstream/sync-package-json.js +66 -0
- package/dist/lib/upstream/sync-package-json.js.map +1 -0
- package/dist/lib/upstream/sync-package-manager.d.ts +50 -0
- package/dist/lib/upstream/sync-package-manager.d.ts.map +1 -0
- package/dist/lib/upstream/sync-package-manager.js +570 -0
- package/dist/lib/upstream/sync-package-manager.js.map +1 -0
- package/dist/lib/upstream/sync-pielib-strategy.d.ts +26 -0
- package/dist/lib/upstream/sync-pielib-strategy.d.ts.map +1 -0
- package/dist/lib/upstream/sync-pielib-strategy.js +345 -0
- package/dist/lib/upstream/sync-pielib-strategy.js.map +1 -0
- package/dist/lib/upstream/sync-react-strategy.d.ts +54 -0
- package/dist/lib/upstream/sync-react-strategy.d.ts.map +1 -0
- package/dist/lib/upstream/sync-react-strategy.js +733 -0
- package/dist/lib/upstream/sync-react-strategy.js.map +1 -0
- package/dist/lib/upstream/sync-strategy.d.ts +49 -0
- package/dist/lib/upstream/sync-strategy.d.ts.map +1 -0
- package/dist/lib/upstream/sync-strategy.js +2 -0
- package/dist/lib/upstream/sync-strategy.js.map +1 -0
- package/dist/lib/upstream/sync-summary.d.ts +20 -0
- package/dist/lib/upstream/sync-summary.d.ts.map +1 -0
- package/dist/lib/upstream/sync-summary.js +157 -0
- package/dist/lib/upstream/sync-summary.js.map +1 -0
- package/dist/lib/upstream/sync-transforms.d.ts +60 -0
- package/dist/lib/upstream/sync-transforms.d.ts.map +1 -0
- package/dist/lib/upstream/sync-transforms.js +97 -0
- package/dist/lib/upstream/sync-transforms.js.map +1 -0
- package/dist/lib/upstream/sync-vite-config.d.ts +13 -0
- package/dist/lib/upstream/sync-vite-config.d.ts.map +1 -0
- package/dist/lib/upstream/sync-vite-config.js +231 -0
- package/dist/lib/upstream/sync-vite-config.js.map +1 -0
- package/dist/utils/compatibility.d.ts +129 -0
- package/dist/utils/compatibility.d.ts.map +1 -0
- package/dist/utils/compatibility.js +44 -0
- package/dist/utils/compatibility.js.map +1 -0
- package/dist/utils/conversion.d.ts +25 -0
- package/dist/utils/conversion.d.ts.map +1 -0
- package/dist/utils/conversion.js +123 -0
- package/dist/utils/conversion.js.map +1 -0
- package/dist/utils/git.d.ts +7 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +63 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/logger.d.ts +29 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +63 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/package-json.d.ts +12 -0
- package/dist/utils/package-json.d.ts.map +1 -0
- package/dist/utils/package-json.js +29 -0
- package/dist/utils/package-json.js.map +1 -0
- package/package.json +59 -0
- package/packages/cli/bin/dev.js +5 -0
- package/packages/cli/bin/run.js +5 -0
- package/src/commands/dev/demo/index.ts +313 -0
- package/src/commands/dev/test-bundler.ts +345 -0
- package/src/commands/mathquill/migrate.ts +269 -0
- package/src/commands/mathquill/status.ts +267 -0
- package/src/commands/packages/create-controllers.ts +127 -0
- package/src/commands/packages/create-lib-react.ts +279 -0
- package/src/commands/packages/create-react-elements.ts +306 -0
- package/src/commands/packages/enable-publishing.ts +161 -0
- package/src/commands/packages/init-synced-elements.ts +259 -0
- package/src/commands/upstream/README.md +444 -0
- package/src/commands/upstream/analyze-esm.ts +1973 -0
- package/src/commands/upstream/check.ts +228 -0
- package/src/commands/upstream/deps.ts +222 -0
- package/src/commands/upstream/sync-mathquill.ts +108 -0
- package/src/commands/upstream/sync.ts +687 -0
- package/src/commands/upstream/track.ts +145 -0
- package/src/commands/upstream/update.ts +110 -0
- package/src/commands/verify/controllers.ts +166 -0
- package/src/commands/verify/react-build.ts +171 -0
- package/src/index.ts +1 -0
- package/src/lib/mathquill/extension-generator.ts +111 -0
- package/src/lib/mathquill/khan-extractor.ts +175 -0
- package/src/lib/mathquill/learnosity-extractor.ts +198 -0
- package/src/lib/mathquill/migration-orchestrator.ts +513 -0
- package/src/lib/mathquill/package-updater.ts +120 -0
- package/src/lib/mathquill/pie-extractor.ts +194 -0
- package/src/lib/upstream/repo-utils.ts +18 -0
- package/src/lib/upstream/sync-compatibility.ts +89 -0
- package/src/lib/upstream/sync-constants.ts +77 -0
- package/src/lib/upstream/sync-controllers-strategy.ts +291 -0
- package/src/lib/upstream/sync-demo-metadata.ts +199 -0
- package/src/lib/upstream/sync-dev-exports.ts +151 -0
- package/src/lib/upstream/sync-externals.ts +159 -0
- package/src/lib/upstream/sync-filesystem.ts +87 -0
- package/src/lib/upstream/sync-imports.ts +992 -0
- package/src/lib/upstream/sync-mathquill.ts +194 -0
- package/src/lib/upstream/sync-package-json.ts +86 -0
- package/src/lib/upstream/sync-package-manager.ts +694 -0
- package/src/lib/upstream/sync-pielib-strategy.ts +441 -0
- package/src/lib/upstream/sync-react-strategy.ts +945 -0
- package/src/lib/upstream/sync-strategy.ts +61 -0
- package/src/lib/upstream/sync-summary.ts +194 -0
- package/src/lib/upstream/sync-transforms.ts +154 -0
- package/src/lib/upstream/sync-vite-config.ts +243 -0
- package/src/types/es-module-lexer.d.ts +4 -0
- package/src/utils/compatibility.ts +182 -0
- package/src/utils/conversion.ts +153 -0
- package/src/utils/git.ts +63 -0
- package/src/utils/logger.ts +69 -0
- package/src/utils/package-json.ts +43 -0
- package/tests/sync-package-manager.test.ts +112 -0
- package/tests/transform-assign-props.test.ts +101 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { Logger } from '../../utils/logger.js';
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
export default class MathQuillStatus extends Command {
|
|
7
|
+
static override description = `Show MathQuill migration status
|
|
8
|
+
|
|
9
|
+
Displays the current state of the MathQuill migration:
|
|
10
|
+
- Current version and source
|
|
11
|
+
- Migration state (pending, in-progress, complete)
|
|
12
|
+
- Installed fork versions (Desmos, Khan patches, Learnosity features)
|
|
13
|
+
- Extracted features and extensions
|
|
14
|
+
- Test results
|
|
15
|
+
- Next steps
|
|
16
|
+
|
|
17
|
+
Use this to verify migration success or check what needs to be done.
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
static override examples = [
|
|
21
|
+
{
|
|
22
|
+
description: 'Show migration status',
|
|
23
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
description: 'Verbose output with file details',
|
|
27
|
+
command: '<%= config.bin %> <%= command.id %> --verbose',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
static override flags = {
|
|
32
|
+
verbose: Flags.boolean({
|
|
33
|
+
char: 'v',
|
|
34
|
+
description: 'Show detailed information',
|
|
35
|
+
default: false,
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
async run(): Promise<void> {
|
|
40
|
+
const { flags } = await this.parse(MathQuillStatus);
|
|
41
|
+
const logger = new Logger(flags.verbose);
|
|
42
|
+
|
|
43
|
+
const workspaceRoot = process.cwd();
|
|
44
|
+
const mathquillPath = join(workspaceRoot, 'packages/shared/mathquill');
|
|
45
|
+
|
|
46
|
+
if (!existsSync(mathquillPath)) {
|
|
47
|
+
logger.error('MathQuill package not found at: packages/shared/mathquill');
|
|
48
|
+
this.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
logger.section('📊 MathQuill Status');
|
|
52
|
+
|
|
53
|
+
// Read package.json
|
|
54
|
+
const pkgPath = join(mathquillPath, 'package.json');
|
|
55
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
56
|
+
|
|
57
|
+
// Determine migration state
|
|
58
|
+
const isLegacy = existsSync(join(mathquillPath, 'src/legacy/mathquill-bundle.js'));
|
|
59
|
+
const hasExtensions = existsSync(join(mathquillPath, 'src/extensions'));
|
|
60
|
+
const hasLoader = existsSync(join(mathquillPath, 'src/extensions/index.ts'));
|
|
61
|
+
const migrationConfig = this.loadMigrationConfig(mathquillPath);
|
|
62
|
+
|
|
63
|
+
// Current state
|
|
64
|
+
this.log('\n📦 Current Configuration:');
|
|
65
|
+
this.log(` Package: ${pkg.name}@${pkg.version}`);
|
|
66
|
+
this.log(` Source: ${this.detectSource(pkg, isLegacy, hasExtensions)}`);
|
|
67
|
+
|
|
68
|
+
if (pkg.dependencies?.mathquill) {
|
|
69
|
+
const dep = pkg.dependencies.mathquill;
|
|
70
|
+
if (dep.includes('desmosinc')) {
|
|
71
|
+
this.log(` Fork: Desmos (${dep})`);
|
|
72
|
+
} else if (dep.includes('Khan')) {
|
|
73
|
+
this.log(` Fork: Khan Academy (${dep})`);
|
|
74
|
+
} else if (dep.includes('Learnosity')) {
|
|
75
|
+
this.log(` Fork: Learnosity (${dep})`);
|
|
76
|
+
} else {
|
|
77
|
+
this.log(` Fork: ${dep}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Migration state
|
|
82
|
+
this.log('\n🔄 Migration State:');
|
|
83
|
+
const migrationState = this.determineMigrationState(
|
|
84
|
+
isLegacy,
|
|
85
|
+
hasExtensions,
|
|
86
|
+
hasLoader,
|
|
87
|
+
migrationConfig
|
|
88
|
+
);
|
|
89
|
+
this.log(` Status: ${migrationState.status} ${migrationState.icon}`);
|
|
90
|
+
if (migrationState.detail) {
|
|
91
|
+
this.log(` Detail: ${migrationState.detail}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Extension state
|
|
95
|
+
if (hasExtensions) {
|
|
96
|
+
this.log('\n🔧 Extensions:');
|
|
97
|
+
this.showExtensionStatus(mathquillPath, flags.verbose, logger);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Migration metadata
|
|
101
|
+
if (migrationConfig) {
|
|
102
|
+
this.log('\n📋 Migration Metadata:');
|
|
103
|
+
this.showMigrationMetadata(migrationConfig);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Next steps
|
|
107
|
+
this.log('\n📝 Next Steps:');
|
|
108
|
+
this.showNextSteps(migrationState.status, isLegacy, hasExtensions);
|
|
109
|
+
|
|
110
|
+
this.log('');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private detectSource(_pkg: any, isLegacy: boolean, hasExtensions: boolean): string {
|
|
114
|
+
if (hasExtensions && !isLegacy) {
|
|
115
|
+
return 'Desmos fork + patches (migrated)';
|
|
116
|
+
}
|
|
117
|
+
if (isLegacy) {
|
|
118
|
+
return 'PIE fork (legacy - needs migration)';
|
|
119
|
+
}
|
|
120
|
+
return 'Unknown';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private determineMigrationState(
|
|
124
|
+
isLegacy: boolean,
|
|
125
|
+
hasExtensions: boolean,
|
|
126
|
+
hasLoader: boolean,
|
|
127
|
+
_config: any
|
|
128
|
+
): { status: string; icon: string; detail?: string } {
|
|
129
|
+
if (!isLegacy && hasExtensions && hasLoader) {
|
|
130
|
+
return {
|
|
131
|
+
status: 'Complete',
|
|
132
|
+
icon: '✅',
|
|
133
|
+
detail: 'Migration successful',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (hasExtensions && !hasLoader) {
|
|
138
|
+
return {
|
|
139
|
+
status: 'In Progress',
|
|
140
|
+
icon: '⚠️',
|
|
141
|
+
detail: 'Extensions exist but loader missing',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (isLegacy && !hasExtensions) {
|
|
146
|
+
return {
|
|
147
|
+
status: 'Pending',
|
|
148
|
+
icon: '📋',
|
|
149
|
+
detail: 'Legacy fork still in use',
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (isLegacy && hasExtensions) {
|
|
154
|
+
return {
|
|
155
|
+
status: 'Transitioning',
|
|
156
|
+
icon: '🔄',
|
|
157
|
+
detail: 'Both legacy and new extensions present',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
status: 'Unknown',
|
|
163
|
+
icon: '❓',
|
|
164
|
+
detail: 'Unexpected state',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private showExtensionStatus(mathquillPath: string, verbose: boolean, _logger: Logger): void {
|
|
169
|
+
const extensionDirs = [
|
|
170
|
+
{ name: 'Khan', path: 'src/extensions/khan' },
|
|
171
|
+
{ name: 'Learnosity', path: 'src/extensions/learnosity' },
|
|
172
|
+
{ name: 'PIE', path: 'src/extensions/pie' },
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
for (const ext of extensionDirs) {
|
|
176
|
+
const fullPath = join(mathquillPath, ext.path);
|
|
177
|
+
if (existsSync(fullPath)) {
|
|
178
|
+
const files = this.countTypeScriptFiles(fullPath);
|
|
179
|
+
this.log(` ${ext.name}: ${files} file(s) ✓`);
|
|
180
|
+
|
|
181
|
+
if (verbose) {
|
|
182
|
+
const indexExists = existsSync(join(fullPath, 'index.ts'));
|
|
183
|
+
this.log(` • index.ts: ${indexExists ? '✓' : '✗'}`);
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
this.log(` ${ext.name}: Not found ✗`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const loaderPath = join(mathquillPath, 'src/extensions/index.ts');
|
|
191
|
+
if (existsSync(loaderPath)) {
|
|
192
|
+
this.log(` Loader: ✓`);
|
|
193
|
+
} else {
|
|
194
|
+
this.log(` Loader: ✗ (Missing extension loader)`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private countTypeScriptFiles(dir: string): number {
|
|
199
|
+
if (!existsSync(dir)) return 0;
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
const { readdirSync } = require('node:fs');
|
|
203
|
+
const files = readdirSync(dir);
|
|
204
|
+
return files.filter((f: string) => f.endsWith('.ts') || f.endsWith('.tsx')).length;
|
|
205
|
+
} catch {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private loadMigrationConfig(mathquillPath: string): any {
|
|
211
|
+
const configPath = join(mathquillPath, 'migration-config.json');
|
|
212
|
+
if (!existsSync(configPath)) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
try {
|
|
217
|
+
return JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
218
|
+
} catch {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private showMigrationMetadata(config: any): void {
|
|
224
|
+
if (config.version) {
|
|
225
|
+
this.log(` Version: ${config.version}`);
|
|
226
|
+
}
|
|
227
|
+
if (config.lastMigration) {
|
|
228
|
+
this.log(` Last run: ${new Date(config.lastMigration).toLocaleString()}`);
|
|
229
|
+
}
|
|
230
|
+
if (config.base?.installed) {
|
|
231
|
+
this.log(` Base fork: ${config.base.fork}@${config.base.installed}`);
|
|
232
|
+
}
|
|
233
|
+
if (config.migrationState) {
|
|
234
|
+
this.log(` State: ${config.migrationState}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private showNextSteps(status: string, isLegacy: boolean, _hasExtensions: boolean): void {
|
|
239
|
+
if (status === 'Complete') {
|
|
240
|
+
this.log(' ✅ Migration complete!');
|
|
241
|
+
this.log(' • Build: cd packages/shared/mathquill && bun run build');
|
|
242
|
+
this.log(' • Test: bun test packages/lib-react/math-input');
|
|
243
|
+
this.log(' • Demo: bun run dev:demo');
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (status === 'Pending' && isLegacy) {
|
|
248
|
+
this.log(' 📋 Migration needed');
|
|
249
|
+
this.log(' 1. Run: pie mathquill:migrate --dry-run');
|
|
250
|
+
this.log(' 2. Review the migration plan');
|
|
251
|
+
this.log(' 3. Run: pie mathquill:migrate');
|
|
252
|
+
this.log(' 4. Test thoroughly before committing');
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (status === 'In Progress' || status === 'Transitioning') {
|
|
257
|
+
this.log(' ⚠️ Migration incomplete');
|
|
258
|
+
this.log(' 1. Check for errors: pie mathquill:migrate --verbose');
|
|
259
|
+
this.log(' 2. Or re-run: pie mathquill:migrate --force');
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
this.log(' ❓ Unknown state - check documentation');
|
|
264
|
+
this.log(' • See: docs/MATHQUILL_MIGRATION_PLAN.md');
|
|
265
|
+
this.log(' • See: docs/MATHQUILL_MIGRATION_CLI_PLAN.md');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { Logger } from '../../utils/logger.js';
|
|
3
|
+
import { extractDependencies } from '../../utils/package-json.js';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { readdir, readFile, writeFile } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
const SHARED_DIR = 'packages/shared';
|
|
9
|
+
|
|
10
|
+
export default class CreateControllers extends Command {
|
|
11
|
+
static override description = 'Create package.json files for synced controllers';
|
|
12
|
+
|
|
13
|
+
static override examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
|
+
|
|
15
|
+
static override flags = {
|
|
16
|
+
verbose: Flags.boolean({
|
|
17
|
+
char: 'v',
|
|
18
|
+
description: 'Show detailed output',
|
|
19
|
+
default: false,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
private logger = new Logger();
|
|
24
|
+
|
|
25
|
+
public async run(): Promise<void> {
|
|
26
|
+
const { flags } = await this.parse(CreateControllers);
|
|
27
|
+
|
|
28
|
+
this.logger = new Logger(flags.verbose);
|
|
29
|
+
|
|
30
|
+
this.logger.section('📦 Creating package.json files for controllers');
|
|
31
|
+
|
|
32
|
+
const controllers = await readdir(SHARED_DIR);
|
|
33
|
+
let created = 0;
|
|
34
|
+
let skipped = 0;
|
|
35
|
+
|
|
36
|
+
for (const controller of controllers) {
|
|
37
|
+
const controllerDir = join(SHARED_DIR, controller);
|
|
38
|
+
const packageJsonPath = join(controllerDir, 'package.json');
|
|
39
|
+
|
|
40
|
+
// Skip if package.json already exists
|
|
41
|
+
if (existsSync(packageJsonPath)) {
|
|
42
|
+
this.logger.info(` ⏭️ ${controller}: package.json already exists`);
|
|
43
|
+
skipped++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Scan for dependencies
|
|
48
|
+
const deps = await this.scanController(controllerDir);
|
|
49
|
+
|
|
50
|
+
// Generate package.json
|
|
51
|
+
const content = this.generatePackageJson(controller, deps);
|
|
52
|
+
|
|
53
|
+
// Write file
|
|
54
|
+
await writeFile(packageJsonPath, content, 'utf-8');
|
|
55
|
+
this.logger.success(` ✅ ${controller}: Created package.json (${deps.length} dependencies)`);
|
|
56
|
+
created++;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this.logger.section(`\n📊 Summary: ${created} created, ${skipped} skipped`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private async scanController(controllerDir: string): Promise<string[]> {
|
|
63
|
+
const srcDir = join(controllerDir, 'src');
|
|
64
|
+
const deps = new Set<string>();
|
|
65
|
+
|
|
66
|
+
if (!existsSync(srcDir)) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const files = await readdir(srcDir);
|
|
71
|
+
|
|
72
|
+
for (const file of files) {
|
|
73
|
+
if (!file.endsWith('.ts')) continue;
|
|
74
|
+
|
|
75
|
+
const filePath = join(srcDir, file);
|
|
76
|
+
const content = await readFile(filePath, 'utf-8');
|
|
77
|
+
const fileDeps = extractDependencies(content);
|
|
78
|
+
|
|
79
|
+
for (const dep of fileDeps) deps.add(dep);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return Array.from(deps).sort();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private generatePackageJson(name: string, deps: string[]): string {
|
|
86
|
+
const dependencies: Record<string, string> = {};
|
|
87
|
+
|
|
88
|
+
for (const dep of deps) {
|
|
89
|
+
// Use * for external dependencies (they're in root package.json)
|
|
90
|
+
dependencies[dep] = '*';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const pkg = {
|
|
94
|
+
name: `@pie-element/${name}`,
|
|
95
|
+
version: '0.1.0',
|
|
96
|
+
description: `Framework-agnostic ${name.replace('-controller', '')} controller synced from pie-elements`,
|
|
97
|
+
type: 'module',
|
|
98
|
+
main: './src/index.ts',
|
|
99
|
+
types: './src/index.ts',
|
|
100
|
+
exports: {
|
|
101
|
+
'.': {
|
|
102
|
+
types: './src/index.ts',
|
|
103
|
+
default: './src/index.ts',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
files: ['src'],
|
|
107
|
+
scripts: {
|
|
108
|
+
build: "echo 'Controllers are consumed as TypeScript source'",
|
|
109
|
+
lint: 'biome check .',
|
|
110
|
+
'lint:fix': 'biome check --write .',
|
|
111
|
+
},
|
|
112
|
+
dependencies: Object.keys(dependencies).length > 0 ? dependencies : undefined,
|
|
113
|
+
keywords: ['pie', 'pie-element', 'controller', name.replace('-controller', ''), 'assessment'],
|
|
114
|
+
license: 'ISC',
|
|
115
|
+
repository: {
|
|
116
|
+
type: 'git',
|
|
117
|
+
url: 'https://github.com/pie-framework/pie-elements-ng.git',
|
|
118
|
+
directory: `packages/shared/${name}`,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Remove undefined fields
|
|
123
|
+
const cleaned = JSON.parse(JSON.stringify(pkg));
|
|
124
|
+
|
|
125
|
+
return `${JSON.stringify(cleaned, null, 2)}\n`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { Logger } from '../../utils/logger.js';
|
|
3
|
+
import { loadPackageJson } from '../../utils/package-json.js';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { mkdir, readdir, writeFile, stat as fsStat } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
interface PackageJson {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
description: string;
|
|
12
|
+
type: string;
|
|
13
|
+
main: string;
|
|
14
|
+
types: string;
|
|
15
|
+
exports: Record<string, unknown>;
|
|
16
|
+
files: string[];
|
|
17
|
+
scripts: Record<string, string>;
|
|
18
|
+
dependencies?: Record<string, string>;
|
|
19
|
+
peerDependencies?: Record<string, string>;
|
|
20
|
+
devDependencies?: Record<string, string>;
|
|
21
|
+
keywords: string[];
|
|
22
|
+
license: string;
|
|
23
|
+
repository: {
|
|
24
|
+
type: string;
|
|
25
|
+
url: string;
|
|
26
|
+
directory: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default class CreateLibReact extends Command {
|
|
31
|
+
static override description = 'Create package.json files for synced @pie-lib packages';
|
|
32
|
+
|
|
33
|
+
static override examples = [
|
|
34
|
+
'<%= config.bin %> <%= command.id %>',
|
|
35
|
+
'<%= config.bin %> <%= command.id %> --dry-run',
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
static override flags = {
|
|
39
|
+
'dry-run': Flags.boolean({
|
|
40
|
+
description: 'Show what would be created without making changes',
|
|
41
|
+
default: false,
|
|
42
|
+
}),
|
|
43
|
+
verbose: Flags.boolean({
|
|
44
|
+
char: 'v',
|
|
45
|
+
description: 'Show detailed output',
|
|
46
|
+
default: false,
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
private logger = new Logger();
|
|
51
|
+
|
|
52
|
+
public async run(): Promise<void> {
|
|
53
|
+
const { flags } = await this.parse(CreateLibReact);
|
|
54
|
+
|
|
55
|
+
this.logger = new Logger(flags.verbose);
|
|
56
|
+
|
|
57
|
+
this.logger.section('📦 Creating package.json files for @pie-lib packages');
|
|
58
|
+
this.logger.info(` Mode: ${flags['dry-run'] ? 'DRY RUN' : 'LIVE'}\n`);
|
|
59
|
+
|
|
60
|
+
const libReactDir = 'packages/lib-react';
|
|
61
|
+
const packages = await readdir(libReactDir);
|
|
62
|
+
|
|
63
|
+
let created = 0;
|
|
64
|
+
let skipped = 0;
|
|
65
|
+
|
|
66
|
+
for (const pkg of packages) {
|
|
67
|
+
const pkgPath = join(libReactDir, pkg);
|
|
68
|
+
const statResult = await fsStat(pkgPath);
|
|
69
|
+
|
|
70
|
+
if (!statResult.isDirectory() || pkg === 'node_modules') {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check if src directory exists
|
|
75
|
+
const srcPath = join(pkgPath, 'src');
|
|
76
|
+
if (!existsSync(srcPath)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const packageJsonPath = join(pkgPath, 'package.json');
|
|
82
|
+
if (existsSync(packageJsonPath)) {
|
|
83
|
+
skipped++;
|
|
84
|
+
this.logger.info(` ⏭️ ${pkg}: Already configured`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
await this.createPackageJson(pkg, flags['dry-run']);
|
|
89
|
+
await this.createViteConfig(pkg, flags['dry-run']);
|
|
90
|
+
await this.createTsConfig(pkg, flags['dry-run']);
|
|
91
|
+
created++;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
this.logger.error(` ❌ ${pkg}: Error - ${error}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.logger.success(`\n✅ Created ${created} package configurations`);
|
|
98
|
+
this.logger.info(`⏭️ Skipped ${skipped} existing packages`);
|
|
99
|
+
|
|
100
|
+
if (!flags['dry-run'] && created > 0) {
|
|
101
|
+
this.logger.section('\n💡 Next steps');
|
|
102
|
+
this.logger.info(' 1. Run: bun install (to link workspace packages)');
|
|
103
|
+
this.logger.info(' 2. Run: bun run build --filter="@pie-lib/*" (to build all lib packages)');
|
|
104
|
+
this.logger.info(' 3. Update React elements to use the new workspace dependencies\n');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private async getUpstreamPackageJson(pkgName: string): Promise<PackageJson | null> {
|
|
109
|
+
const upstreamPath = join('../pie-lib/packages', pkgName, 'package.json');
|
|
110
|
+
if (existsSync(upstreamPath)) {
|
|
111
|
+
return (await loadPackageJson(upstreamPath)) as unknown as PackageJson;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private convertDependencies(deps: Record<string, string> | undefined): Record<string, string> {
|
|
117
|
+
if (!deps) return {};
|
|
118
|
+
|
|
119
|
+
const converted: Record<string, string> = {};
|
|
120
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
121
|
+
if (name.startsWith('@pie-lib/')) {
|
|
122
|
+
// Convert to workspace dependency
|
|
123
|
+
converted[name] = 'workspace:*';
|
|
124
|
+
} else {
|
|
125
|
+
// Keep external dependencies as-is
|
|
126
|
+
converted[name] = version;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return converted;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private async createPackageJson(pkgName: string, dryRun: boolean = false): Promise<void> {
|
|
133
|
+
const targetDir = join('packages/lib-react', pkgName);
|
|
134
|
+
const targetPath = join(targetDir, 'package.json');
|
|
135
|
+
|
|
136
|
+
// Skip if package.json already exists
|
|
137
|
+
if (existsSync(targetPath)) {
|
|
138
|
+
this.logger.info(` ⏭️ ${pkgName}: package.json already exists`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Get upstream package.json for dependencies
|
|
143
|
+
const upstream = await this.getUpstreamPackageJson(pkgName);
|
|
144
|
+
|
|
145
|
+
const packageJson: PackageJson = {
|
|
146
|
+
name: `@pie-lib/${pkgName}`,
|
|
147
|
+
version: '0.1.0',
|
|
148
|
+
description:
|
|
149
|
+
upstream?.description || `React implementation of @pie-lib/${pkgName} synced from pie-lib`,
|
|
150
|
+
type: 'module',
|
|
151
|
+
main: './dist/index.js',
|
|
152
|
+
types: './dist/index.d.ts',
|
|
153
|
+
exports: {
|
|
154
|
+
'.': {
|
|
155
|
+
types: './dist/index.d.ts',
|
|
156
|
+
default: './dist/index.js',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
files: ['dist', 'src'],
|
|
160
|
+
scripts: {
|
|
161
|
+
build: 'vite build && tsc --emitDeclarationOnly',
|
|
162
|
+
lint: 'biome check .',
|
|
163
|
+
'lint:fix': 'biome check --write .',
|
|
164
|
+
},
|
|
165
|
+
keywords: ['pie', 'pie-lib', 'react', pkgName],
|
|
166
|
+
license: 'ISC',
|
|
167
|
+
repository: {
|
|
168
|
+
type: 'git',
|
|
169
|
+
url: 'https://github.com/pie-framework/pie-elements-ng.git',
|
|
170
|
+
directory: `packages/lib-react/${pkgName}`,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// Convert dependencies
|
|
175
|
+
if (upstream?.dependencies) {
|
|
176
|
+
packageJson.dependencies = this.convertDependencies(upstream.dependencies);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (upstream?.peerDependencies) {
|
|
180
|
+
packageJson.peerDependencies = this.convertDependencies(upstream.peerDependencies);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Add common devDependencies
|
|
184
|
+
packageJson.devDependencies = {
|
|
185
|
+
'@types/react': '^18.2.0',
|
|
186
|
+
'@types/react-dom': '^18.2.0',
|
|
187
|
+
'@vitejs/plugin-react': '^4.2.0',
|
|
188
|
+
typescript: '^5.9.3',
|
|
189
|
+
vite: '^6.0.0',
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
if (dryRun) {
|
|
193
|
+
this.logger.info(` 🔍 ${pkgName}: Would create package.json`);
|
|
194
|
+
} else {
|
|
195
|
+
await mkdir(targetDir, { recursive: true });
|
|
196
|
+
await writeFile(targetPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf-8');
|
|
197
|
+
this.logger.success(` ✨ ${pkgName}: Created package.json`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private async createViteConfig(pkgName: string, dryRun: boolean = false): Promise<void> {
|
|
202
|
+
const targetDir = join('packages/lib-react', pkgName);
|
|
203
|
+
const targetPath = join(targetDir, 'vite.config.ts');
|
|
204
|
+
|
|
205
|
+
// Skip if vite.config.ts already exists
|
|
206
|
+
if (existsSync(targetPath)) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const viteConfig = `import react from '@vitejs/plugin-react';
|
|
211
|
+
import { defineConfig } from 'vite';
|
|
212
|
+
|
|
213
|
+
export default defineConfig({
|
|
214
|
+
plugins: [react()],
|
|
215
|
+
build: {
|
|
216
|
+
lib: {
|
|
217
|
+
entry: './src/index.ts',
|
|
218
|
+
formats: ['es'],
|
|
219
|
+
fileName: () => 'index.js',
|
|
220
|
+
},
|
|
221
|
+
rollupOptions: {
|
|
222
|
+
external: [
|
|
223
|
+
'react',
|
|
224
|
+
'react-dom',
|
|
225
|
+
'react/jsx-runtime',
|
|
226
|
+
'prop-types',
|
|
227
|
+
'lodash',
|
|
228
|
+
'debug',
|
|
229
|
+
'classnames',
|
|
230
|
+
/^@pie-lib\\//,
|
|
231
|
+
/^@pie-framework\\//,
|
|
232
|
+
/^@pie-element\\//,
|
|
233
|
+
/^@mui\\//,
|
|
234
|
+
/^@emotion\\//,
|
|
235
|
+
/^@dnd-kit\\//,
|
|
236
|
+
/^react-transition-group/,
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
outDir: 'dist',
|
|
240
|
+
emptyOutDir: true,
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
`;
|
|
244
|
+
|
|
245
|
+
if (dryRun) {
|
|
246
|
+
this.logger.info(` 🔍 ${pkgName}: Would create vite.config.ts`);
|
|
247
|
+
} else {
|
|
248
|
+
await writeFile(targetPath, viteConfig, 'utf-8');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private async createTsConfig(pkgName: string, dryRun: boolean = false): Promise<void> {
|
|
253
|
+
const targetDir = join('packages/lib-react', pkgName);
|
|
254
|
+
const targetPath = join(targetDir, 'tsconfig.json');
|
|
255
|
+
|
|
256
|
+
// Skip if tsconfig.json already exists
|
|
257
|
+
if (existsSync(targetPath)) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const tsConfig = {
|
|
262
|
+
extends: '../../../tsconfig.base.json',
|
|
263
|
+
compilerOptions: {
|
|
264
|
+
outDir: './dist',
|
|
265
|
+
rootDir: './src',
|
|
266
|
+
declaration: true,
|
|
267
|
+
emitDeclarationOnly: false,
|
|
268
|
+
},
|
|
269
|
+
include: ['src/**/*'],
|
|
270
|
+
exclude: ['node_modules', 'dist', '**/*.spec.ts', '**/*.spec.tsx'],
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
if (dryRun) {
|
|
274
|
+
this.logger.info(` 🔍 ${pkgName}: Would create tsconfig.json`);
|
|
275
|
+
} else {
|
|
276
|
+
await writeFile(targetPath, `${JSON.stringify(tsConfig, null, 2)}\n`, 'utf-8');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|