sg-frontend-starter 1.0.8 → 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.
- package/package.json +1 -1
- package/postinstall.js +38 -28
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -14,36 +14,36 @@ const targetPackageJson = path.join(projectRoot, 'package.json');
|
|
|
14
14
|
const sourcePackageJson = path.join(source, 'package.json');
|
|
15
15
|
|
|
16
16
|
if (fs.existsSync(source)) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
}
|
|
36
37
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.log('✓ sg-frontend-starter tartalma sikeresen áthelyezve');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
console.log('✓ sg-frontend-starter tartalma sikeresen áthelyezve');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// Biztosítja, hogy a cél package.json
|
|
44
|
-
|
|
43
|
+
// Biztosítja, hogy a cél package.json dependencies, devDependencies és scripts kulcsai a sablonnal egyezzenek
|
|
44
|
+
syncPackageJsonDependencies(targetPackageJson, sourcePackageJson);
|
|
45
45
|
|
|
46
|
-
function
|
|
46
|
+
function syncPackageJsonDependencies(targetPath, templatePath) {
|
|
47
47
|
if (!fs.existsSync(templatePath)) {
|
|
48
48
|
console.error('Nem található a sablon package.json:', templatePath);
|
|
49
49
|
return;
|
|
@@ -53,8 +53,18 @@ function syncPackageJson(targetPath, templatePath) {
|
|
|
53
53
|
const templateRaw = fs.readFileSync(templatePath, 'utf8');
|
|
54
54
|
const templatePkg = JSON.parse(templateRaw);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
let targetPkg = {};
|
|
57
|
+
if (fs.existsSync(targetPath)) {
|
|
58
|
+
const targetRaw = fs.readFileSync(targetPath, 'utf8');
|
|
59
|
+
targetPkg = JSON.parse(targetRaw);
|
|
60
|
+
}
|
|
61
|
+
|
|
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');
|
|
58
68
|
} catch (error) {
|
|
59
69
|
console.error('Hiba a package.json szinkronizálása során:', error);
|
|
60
70
|
}
|