sg-frontend-starter 1.0.7 → 1.0.9

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 +43 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sg-frontend-starter",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
package/postinstall.js CHANGED
@@ -11,71 +11,62 @@ const source = path.join(__dirname);
11
11
  const projectRoot = path.join(__dirname, '..', '..');
12
12
 
13
13
  const targetPackageJson = path.join(projectRoot, 'package.json');
14
+ const sourcePackageJson = path.join(source, 'package.json');
14
15
 
15
16
  if (fs.existsSync(source)) {
16
- // Az sg-frontend-starter mappájában lévő összes fájlt és mappát másolja ki
17
- const files = fs.readdirSync(source);
18
-
19
- files.forEach(file => {
20
- // Kihagyja a node_modules-t, package.json-t és magát a postinstall.js-t
21
- if (file !== 'node_modules' && file !== 'package.json' && file !== 'postinstall.js') {
22
- const srcPath = path.join(source, file);
23
- const destPath = path.join(projectRoot, file);
24
-
25
- if (fs.existsSync(destPath)) {
26
- fs.rmSync(destPath, { recursive: true, force: true });
27
- }
28
-
29
- // Másolja a fájlt/mappát
30
- const stat = fs.statSync(srcPath);
31
- if (stat.isDirectory()) {
32
- copyDir(srcPath, destPath);
33
- } else {
34
- fs.copyFileSync(srcPath, destPath);
17
+ // Az sg-frontend-starter mappájában lévő összes fájlt és mappát másolja ki
18
+ const files = fs.readdirSync(source);
19
+
20
+ files.forEach(file => {
21
+ // Kihagyja a node_modules-t, package.json-t és magát a postinstall.js-t
22
+ if (file !== 'node_modules' && file !== 'package.json' && file !== 'postinstall.js') {
23
+ const srcPath = path.join(source, file);
24
+ const destPath = path.join(projectRoot, file);
25
+
26
+ if (fs.existsSync(destPath)) {
27
+ fs.rmSync(destPath, { recursive: true, force: true });
28
+ }
29
+
30
+ // Másolja a fájlt/mappát
31
+ const stat = fs.statSync(srcPath);
32
+ if (stat.isDirectory()) {
33
+ copyDir(srcPath, destPath);
34
+ } else {
35
+ fs.copyFileSync(srcPath, destPath);
36
+ }
35
37
  }
36
- }
37
- });
38
-
39
- console.log('✓ sg-frontend-starter tartalma sikeresen áthelyezve');
38
+ });
39
+
40
+ console.log('✓ sg-frontend-starter tartalma sikeresen áthelyezve');
40
41
  }
41
42
 
42
- // Biztosítja, hogy a cél package.json tartalmazza a dev scriptet
43
- ensureDevScript(targetPackageJson);
44
-
45
- function ensureDevScript(packageJsonPath) {
46
- let pkg = null;
47
- let changed = false;
43
+ // Biztosítja, hogy a cél package.json dependencies, devDependencies és scripts kulcsai a sablonnal egyezzenek
44
+ syncPackageJsonDependencies(targetPackageJson, sourcePackageJson);
48
45
 
49
- if (fs.existsSync(packageJsonPath)) {
50
- try {
51
- const raw = fs.readFileSync(packageJsonPath, 'utf8');
52
- pkg = JSON.parse(raw);
53
- } catch (error) {
54
- console.error('Hiba a package.json beolvasása során:', error);
55
- return;
56
- }
57
- } else {
58
- pkg = { name: 'app', private: true, scripts: {} };
59
- changed = true;
46
+ function syncPackageJsonDependencies(targetPath, templatePath) {
47
+ if (!fs.existsSync(templatePath)) {
48
+ console.error('Nem található a sablon package.json:', templatePath);
49
+ return;
60
50
  }
61
51
 
62
52
  try {
63
- if (!pkg.scripts) {
64
- pkg.scripts = {};
65
- changed = true;
66
- }
53
+ const templateRaw = fs.readFileSync(templatePath, 'utf8');
54
+ const templatePkg = JSON.parse(templateRaw);
67
55
 
68
- if (!pkg.scripts.dev) {
69
- pkg.scripts.dev = 'vite';
70
- changed = true;
56
+ let targetPkg = {};
57
+ if (fs.existsSync(targetPath)) {
58
+ const targetRaw = fs.readFileSync(targetPath, 'utf8');
59
+ targetPkg = JSON.parse(targetRaw);
71
60
  }
72
61
 
73
- if (changed) {
74
- fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + '\n');
75
- console.log('✓ dev script hozzáadva a package.json-hoz');
76
- }
62
+ targetPkg.dependencies = templatePkg.dependencies || {};
63
+ targetPkg.devDependencies = templatePkg.devDependencies || {};
64
+ targetPkg.scripts = templatePkg.scripts || {};
65
+
66
+ fs.writeFileSync(targetPath, JSON.stringify(targetPkg, null, 2) + '\n');
67
+ console.log('✓ package.json scripts/dependencies szinkronizálva a sablonnal');
77
68
  } catch (error) {
78
- console.error('Hiba a package.json frissítése során:', error);
69
+ console.error('Hiba a package.json szinkronizálása során:', error);
79
70
  }
80
71
  }
81
72