@pure-ds/core 0.5.22 → 0.5.24

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pure-ds/core",
3
3
  "shortname": "pds",
4
- "version": "0.5.22",
4
+ "version": "0.5.24",
5
5
  "description": "Pure Design System - Why develop a Design System when you can generate one?",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { readFile, writeFile, mkdir, access } from 'fs/promises';
3
+ import { readFile, writeFile, mkdir, access, rename, rm } from 'fs/promises';
4
4
  import { existsSync } from 'fs';
5
5
  import path from 'path';
6
6
  import { spawn } from 'child_process';
@@ -546,8 +546,54 @@ async function runDevServer() {
546
546
 
547
547
  async function ensurePdsAssets() {
548
548
  const pdsAssetsDir = path.join(projectRoot, 'public', 'assets', 'pds');
549
+ const repoAssetsDir = path.join(projectRoot, 'assets', 'pds');
550
+ const repoAssetsRoot = path.join(projectRoot, 'assets');
551
+ const repoInstallJson = path.join(repoAssetsRoot, '.pds-install.json');
552
+ const publicAssetsRoot = path.join(projectRoot, 'public', 'assets');
553
+ const publicInstallJson = path.join(publicAssetsRoot, '.pds-install.json');
554
+
555
+ const normalizeAssetsLocation = async () => {
556
+ if (!existsSync(repoAssetsDir)) return;
557
+
558
+ if (!existsSync(pdsAssetsDir)) {
559
+ await ensureDir(path.dirname(pdsAssetsDir));
560
+ await rename(repoAssetsDir, pdsAssetsDir);
561
+ log('✅ Moved assets/pds to public/assets/pds');
562
+ return true;
563
+ }
564
+
565
+ await rm(repoAssetsDir, { recursive: true, force: true });
566
+ log('🧹 Removed duplicate assets/pds folder');
567
+ return false;
568
+ };
569
+
570
+ const moveInstallJson = async () => {
571
+ if (!existsSync(repoInstallJson)) return;
572
+ await ensureDir(publicAssetsRoot);
573
+ await rename(repoInstallJson, publicInstallJson);
574
+ log('✅ Moved assets/.pds-install.json to public/assets/.pds-install.json');
575
+ };
576
+
577
+ const cleanupAssetsRoot = async () => {
578
+ if (!existsSync(repoAssetsRoot)) return;
579
+ const remaining = ['pds', '.pds-install.json']
580
+ .map((name) => path.join(repoAssetsRoot, name))
581
+ .filter((target) => existsSync(target));
582
+ if (remaining.length === 0) {
583
+ await rm(repoAssetsRoot, { recursive: true, force: true });
584
+ log('🧹 Removed root assets folder');
585
+ }
586
+ };
587
+
588
+ const movedAssets = await normalizeAssetsLocation();
589
+ await moveInstallJson();
590
+ await cleanupAssetsRoot();
591
+ if (movedAssets) {
592
+ return;
593
+ }
594
+
549
595
  if (existsSync(pdsAssetsDir)) {
550
- log('↪️ PDS assets already present');
596
+ log('↪️ public/assets/pds already present');
551
597
  return;
552
598
  }
553
599
 
@@ -566,6 +612,10 @@ async function ensurePdsAssets() {
566
612
  else reject(new Error(`npm run pds:build exited with code ${code}`));
567
613
  });
568
614
  });
615
+
616
+ await normalizeAssetsLocation();
617
+ await moveInstallJson();
618
+ await cleanupAssetsRoot();
569
619
  }
570
620
 
571
621
  async function main() {