sg-frontend-starter 1.0.9 → 1.0.11
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 +1 -1
- package/postinstall.js +18 -7
package/package.json
CHANGED
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,
|
|
55
|
+
syncPackageJsonDependencies(targetPackageJson, templatePkg);
|
|
45
56
|
|
|
46
|
-
function syncPackageJsonDependencies(targetPath,
|
|
47
|
-
if (!
|
|
48
|
-
console.error('
|
|
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');
|
|
@@ -63,6 +71,9 @@ function syncPackageJsonDependencies(targetPath, templatePath) {
|
|
|
63
71
|
targetPkg.devDependencies = templatePkg.devDependencies || {};
|
|
64
72
|
targetPkg.scripts = templatePkg.scripts || {};
|
|
65
73
|
|
|
74
|
+
// Eltávolítjuk az sg-frontend-starter függőséget
|
|
75
|
+
delete targetPkg.dependencies['sg-frontend-starter'];
|
|
76
|
+
|
|
66
77
|
fs.writeFileSync(targetPath, JSON.stringify(targetPkg, null, 2) + '\n');
|
|
67
78
|
console.log('✓ package.json scripts/dependencies szinkronizálva a sablonnal');
|
|
68
79
|
} catch (error) {
|