sg-frontend-starter 1.0.9 → 1.0.10

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 +15 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sg-frontend-starter",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
package/postinstall.js CHANGED
@@ -13,6 +13,17 @@ const projectRoot = path.join(__dirname, '..', '..');
13
13
  const targetPackageJson = path.join(projectRoot, 'package.json');
14
14
  const sourcePackageJson = path.join(source, 'package.json');
15
15
 
16
+ // Az eredeti package.json tartalmát olvassuk be, mielőtt másolnánk
17
+ let templatePkg = null;
18
+ if (fs.existsSync(sourcePackageJson)) {
19
+ try {
20
+ const raw = fs.readFileSync(sourcePackageJson, 'utf8');
21
+ templatePkg = JSON.parse(raw);
22
+ } catch (error) {
23
+ console.error('Hiba az eredeti package.json beolvasása során:', error);
24
+ }
25
+ }
26
+
16
27
  if (fs.existsSync(source)) {
17
28
  // Az sg-frontend-starter mappájában lévő összes fájlt és mappát másolja ki
18
29
  const files = fs.readdirSync(source);
@@ -41,18 +52,15 @@ if (fs.existsSync(source)) {
41
52
  }
42
53
 
43
54
  // Biztosítja, hogy a cél package.json dependencies, devDependencies és scripts kulcsai a sablonnal egyezzenek
44
- syncPackageJsonDependencies(targetPackageJson, sourcePackageJson);
55
+ syncPackageJsonDependencies(targetPackageJson, templatePkg);
45
56
 
46
- function syncPackageJsonDependencies(targetPath, templatePath) {
47
- if (!fs.existsSync(templatePath)) {
48
- console.error('Nem található a sablon package.json:', templatePath);
57
+ function syncPackageJsonDependencies(targetPath, templatePkg) {
58
+ if (!templatePkg) {
59
+ console.error('Nincs sablon package.json adat');
49
60
  return;
50
61
  }
51
62
 
52
63
  try {
53
- const templateRaw = fs.readFileSync(templatePath, 'utf8');
54
- const templatePkg = JSON.parse(templateRaw);
55
-
56
64
  let targetPkg = {};
57
65
  if (fs.existsSync(targetPath)) {
58
66
  const targetRaw = fs.readFileSync(targetPath, 'utf8');