sg-frontend-starter 1.0.3 → 1.0.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +52 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sg-frontend-starter",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
package/postinstall.js CHANGED
@@ -1,16 +1,56 @@
1
- const fs = require('fs');
2
- const path = require('path');
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
3
4
 
4
- const source = path.join(__dirname, 'node_modules', 'sg-frontend-starter');
5
- const dest = path.join(__dirname, 'sg-frontend-starter');
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ // Az sg-frontend-starter modulban belül keresünk
9
+ const source = path.join(__dirname);
10
+ // A végső cél: a node_modules/sg-frontend-starter szülőjéhez képest (ahol az npm install fut)
11
+ const projectRoot = path.join(__dirname, '..', '..');
6
12
 
7
- // Ha létezik a modul a node_modules-ban
8
13
  if (fs.existsSync(source)) {
9
- // Ha már létezik a célhelyen, töröld ki
10
- if (fs.existsSync(dest)) {
11
- fs.rmSync(dest, { recursive: true, force: true });
12
- }
13
- // Mozgasd ki a node_modules-ból
14
- fs.renameSync(source, dest);
15
- console.log('sg-frontend-starter modul sikeresen áthelyezve');
14
+ // Az sg-frontend-starter mappájában lévő összes fájlt és mappát másolja ki
15
+ const files = fs.readdirSync(source);
16
+
17
+ files.forEach(file => {
18
+ // Kihagyja a node_modules-t, package.json-t és magát a postinstall.js-t
19
+ if (file !== 'node_modules' && file !== 'package.json' && file !== 'postinstall.js') {
20
+ const srcPath = path.join(source, file);
21
+ const destPath = path.join(projectRoot, file);
22
+
23
+ if (fs.existsSync(destPath)) {
24
+ fs.rmSync(destPath, { recursive: true, force: true });
25
+ }
26
+
27
+ // Másolja a fájlt/mappát
28
+ const stat = fs.statSync(srcPath);
29
+ if (stat.isDirectory()) {
30
+ copyDir(srcPath, destPath);
31
+ } else {
32
+ fs.copyFileSync(srcPath, destPath);
33
+ }
34
+ }
35
+ });
36
+
37
+ console.log('✓ sg-frontend-starter tartalma sikeresen áthelyezve');
16
38
  }
39
+
40
+ // Segédfunkció a mappák rekurzív másolásához
41
+ function copyDir(src, dest) {
42
+ fs.mkdirSync(dest, { recursive: true });
43
+ const files = fs.readdirSync(src);
44
+
45
+ files.forEach(file => {
46
+ const srcPath = path.join(src, file);
47
+ const destPath = path.join(dest, file);
48
+ const stat = fs.statSync(srcPath);
49
+
50
+ if (stat.isDirectory()) {
51
+ copyDir(srcPath, destPath);
52
+ } else {
53
+ fs.copyFileSync(srcPath, destPath);
54
+ }
55
+ });
56
+ }