codeplay-common 3.2.0 → 3.2.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.
|
@@ -465,6 +465,88 @@ else {
|
|
|
465
465
|
|
|
466
466
|
|
|
467
467
|
|
|
468
|
+
//editor-x.x import old style check and stop execution START
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
const ROOT_DIR = path.join(__dirname, "..", "src");
|
|
478
|
+
|
|
479
|
+
// Match: editor/editor-2.3, editor/editor-2.3.1, etc.
|
|
480
|
+
const FORBIDDEN_REGEX = /editor\/editor-\d+(\.\d+)+/;
|
|
481
|
+
|
|
482
|
+
let hasError = false;
|
|
483
|
+
|
|
484
|
+
const ERROR_MESSAGE = `const ERROR_MESSAGE = ❌ Invalid import detected!
|
|
485
|
+
|
|
486
|
+
You are using a direct version-based path like: editor/editor-x.x/editor.js
|
|
487
|
+
|
|
488
|
+
🚫 This is NOT allowed.
|
|
489
|
+
|
|
490
|
+
👉 Please use the proper alias or updated import method.
|
|
491
|
+
Example: import { ... } from '@editor'
|
|
492
|
+
|
|
493
|
+
⚠️ Do not use version-based paths in imports.
|
|
494
|
+
👉 Please add this manually in vite.config.js:
|
|
495
|
+
|
|
496
|
+
alias: {
|
|
497
|
+
'@editor': path.resolve(__dirname, './src/js/editor/editor-x.x')
|
|
498
|
+
}`
|
|
499
|
+
|
|
500
|
+
function scanDir(dir) {
|
|
501
|
+
const files = fs.readdirSync(dir);
|
|
502
|
+
|
|
503
|
+
for (const file of files) {
|
|
504
|
+
const fullPath = path.join(dir, file);
|
|
505
|
+
const stat = fs.statSync(fullPath);
|
|
506
|
+
|
|
507
|
+
if (stat.isDirectory()) {
|
|
508
|
+
scanDir(fullPath);
|
|
509
|
+
} else if (file.endsWith(".js") || file.endsWith(".ts") || file.endsWith(".f7")) {
|
|
510
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
511
|
+
|
|
512
|
+
const lines = content.split("\n");
|
|
513
|
+
|
|
514
|
+
lines.forEach((line, index) => {
|
|
515
|
+
if (FORBIDDEN_REGEX.test(line)) {
|
|
516
|
+
console.error(
|
|
517
|
+
`❌ Forbidden import found:\nFile: ${fullPath}\nLine: ${index + 1}\nCode: ${line.trim()}\n`,
|
|
518
|
+
ERROR_MESSAGE
|
|
519
|
+
);
|
|
520
|
+
hasError = true;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Run scan
|
|
528
|
+
scanDir(ROOT_DIR);
|
|
529
|
+
|
|
530
|
+
// Throw error (exit process)
|
|
531
|
+
if (hasError) {
|
|
532
|
+
console.error("🚫 Build failed due to forbidden editor imports.");
|
|
533
|
+
process.exit(1);
|
|
534
|
+
} else {
|
|
535
|
+
console.log("✅ No forbidden imports found.");
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
//editor-x.x import old style check and stop execution START
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
468
550
|
|
|
469
551
|
|
|
470
552
|
|