codeplay-common 3.1.7 → 3.1.8

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.
@@ -327,13 +327,16 @@ checkAppUniqueId();
327
327
 
328
328
  const jsDir = path.join(__dirname, "..", "src", "js");
329
329
 
330
- // ✅ OLD structure check
330
+ // 🔍 Detect OLD structure
331
331
  const oldEditorDirs = fs.readdirSync(jsDir)
332
332
  .filter(name => /^editor-\d+\.\d+$/.test(name));
333
333
 
334
- // ✅ NEW structure path
334
+ // 📁 New structure path (optional, not mandatory)
335
335
  const newEditorBaseDir = path.join(jsDir, "editor");
336
336
 
337
+ // ======================================================
338
+ // ❌ CASE 1: OLD STRUCTURE FOUND → STOP
339
+ // ======================================================
337
340
  if (oldEditorDirs.length > 0) {
338
341
 
339
342
  console.error(`
@@ -342,127 +345,98 @@ if (oldEditorDirs.length > 0) {
342
345
  You are using outdated folder structure:
343
346
  src/js/editor-x.x/
344
347
 
345
- 🚨 This structure is no longer supported.
348
+ 🚨 This is no longer supported.
346
349
 
347
- ✅ NEW STRUCTURE REQUIRED:
348
- src/js/editor/editor-x.x/
349
-
350
- đŸ“Ļ Your existing folders:
350
+ đŸ“Ļ Found folders:
351
351
  ${oldEditorDirs.map(d => " - " + d).join("\n")}
352
352
 
353
- 👉 Please move them manually like this:
353
+ 👉 Please move them manually:
354
354
 
355
355
  src/js/editor-1.6
356
- âŦ‡ MOVE TO
356
+ âŦ‡
357
357
  src/js/editor/editor-1.6
358
358
 
359
- âš ī¸ After moving, re-run the build.
359
+ âš ī¸ Also ensure:
360
+ src/js/editor/configuration.json exists
360
361
 
361
- ❌ Build stopped to prevent runtime errors.
362
+ ❌ Build stopped.
362
363
  `);
363
364
 
364
365
  process.exit(1);
365
366
  }
366
367
 
367
- // ✅ Ensure new structure exists
368
- if (!fs.existsSync(newEditorBaseDir)) {
369
-
370
- console.error(`
371
- ❌ MISSING EDITOR DIRECTORY
372
-
373
- Expected path:
374
- src/js/editor/
375
-
376
- But it was not found.
377
-
378
- 👉 Please create the folder and move editor-x.x inside it.
379
-
380
- Example:
381
- src/js/editor/editor-1.6/
382
- `);
383
-
384
- process.exit(1);
385
- }
368
+ // ======================================================
369
+ // ✅ CASE 2: NEW STRUCTURE EXISTS → VALIDATE
370
+ // ======================================================
371
+ if (fs.existsSync(newEditorBaseDir)) {
386
372
 
373
+ // 🔍 Find editor-x.x inside new folder
374
+ const editorDirs = fs.readdirSync(newEditorBaseDir)
375
+ .filter(name => /^editor-\d+\.\d+$/.test(name));
387
376
 
377
+ // 👉 If editor folder exists but no versions → skip safely
378
+ if (editorDirs.length === 0) {
379
+ console.log("â„šī¸ No editor-x.x folders found inside src/js/editor/");
380
+ return;
381
+ }
388
382
 
389
- // ======================================================
390
- // Validate editor configuration structure
391
- // ======================================================
383
+ // ======================================================
384
+ // ✅ Validate configuration.json (NEW RULE)
385
+ // ======================================================
392
386
 
393
- const editorConfigPath = path.join(newEditorBaseDir, "configuration.json");
387
+ const editorConfigPath = path.join(newEditorBaseDir, "configuration.json");
394
388
 
395
- // ❌ Check if configuration.json exists in correct place
396
- if (!fs.existsSync(editorConfigPath)) {
397
- console.error(`
389
+ // ❌ Missing config
390
+ if (!fs.existsSync(editorConfigPath)) {
391
+ console.error(`
398
392
  ❌ MISSING EDITOR CONFIGURATION FILE
399
393
 
400
- Required file not found:
394
+ Required:
401
395
  src/js/editor/configuration.json
402
396
 
403
- 👉 This file is mandatory in new editor structure.
404
-
405
- đŸ“Ļ Please ensure:
406
- src/js/editor/configuration.json exists
407
-
408
397
  ❌ Build stopped.
409
398
  `);
410
- process.exit(1);
411
- }
412
-
413
- // ❌ Check for OLD structure mistake inside version folders
414
- const invalidConfigLocations = [];
415
-
416
- const editorSubDirs = fs.readdirSync(newEditorBaseDir)
417
- .filter(name => /^editor-\d+\.\d+$/.test(name));
399
+ process.exit(1);
400
+ }
418
401
 
419
- editorSubDirs.forEach(dir => {
420
- const wrongPath = path.join(newEditorBaseDir, dir, "configuration.json");
402
+ // ❌ Check wrong placement
403
+ const invalidConfigs = [];
421
404
 
422
- if (fs.existsSync(wrongPath)) {
423
- invalidConfigLocations.push(`src/js/editor/${dir}/configuration.json`);
424
- }
425
- });
405
+ editorDirs.forEach(dir => {
406
+ const wrongPath = path.join(newEditorBaseDir, dir, "configuration.json");
407
+ if (fs.existsSync(wrongPath)) {
408
+ invalidConfigs.push(`src/js/editor/${dir}/configuration.json`);
409
+ }
410
+ });
426
411
 
427
- if (invalidConfigLocations.length > 0) {
428
- console.error(`
429
- ❌ INVALID EDITOR CONFIGURATION STRUCTURE DETECTED
412
+ if (invalidConfigs.length > 0) {
413
+ console.error(`
414
+ ❌ INVALID CONFIGURATION LOCATION
430
415
 
431
416
  đŸšĢ configuration.json must NOT be inside version folders.
432
417
 
433
- Found invalid files:
434
- ${invalidConfigLocations.map(p => " - " + p).join("\n")}
418
+ Found:
419
+ ${invalidConfigs.map(p => " - " + p).join("\n")}
435
420
 
436
- ✅ Correct structure:
421
+ ✅ Correct:
437
422
  src/js/editor/configuration.json
438
423
 
439
- 👉 Please MOVE or DELETE the above files.
440
-
441
424
  ❌ Build stopped.
442
425
  `);
443
- process.exit(1);
444
- }
445
-
446
- console.log("✅ Editor configuration structure validated.");
447
-
426
+ process.exit(1);
427
+ }
448
428
 
429
+ console.log("✅ Editor structure validated.");
449
430
 
431
+ // ======================================================
432
+ // 🚀 Continue execution (run.js)
433
+ // ======================================================
450
434
 
451
- // ✅ Now use new structure
452
- const editorDirs = fs.readdirSync(newEditorBaseDir)
453
- .filter(name => /^editor-\d+\.\d+$/.test(name))
454
- .sort((a, b) => {
455
- const getVersion = str => str.match(/(\d+)\.(\d+)/).slice(1).map(Number);
456
- const [aMajor, aMinor] = getVersion(a);
457
- const [bMajor, bMinor] = getVersion(b);
458
- return bMajor - aMajor || bMinor - aMinor;
459
- });
460
-
461
- if (editorDirs.length === 0) {
462
- console.log("@Codemirror editor(s) not found inside src/js/editor/");
463
- } else {
464
-
465
- const latestEditorDir = editorDirs[0];
435
+ const latestEditorDir = editorDirs.sort((a, b) => {
436
+ const vA = parseFloat(a.split('-')[1]);
437
+ const vB = parseFloat(b.split('-')[1]);
438
+ return vB - vA;
439
+ })[0];
466
440
 
467
441
  const runJsPath = path.join(newEditorBaseDir, latestEditorDir, "run.js");
468
442
 
@@ -475,6 +449,13 @@ if (editorDirs.length === 0) {
475
449
  execSync(`node "${runJsPath}"`, { stdio: "inherit" });
476
450
  }
477
451
 
452
+ // ======================================================
453
+ // ✅ CASE 3: NOTHING EXISTS → DO NOTHING
454
+ // ======================================================
455
+ else {
456
+ console.log("â„šī¸ Editor not used in this project. Skipping...");
457
+ }
458
+
478
459
  //@Codemirror check and install/uninstall the packages END
479
460
 
480
461
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",