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.
- package/package.json +1 -1
- package/postinstall.js +43 -52
package/package.json
CHANGED
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
43
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
changed = true;
|
|
66
|
-
}
|
|
53
|
+
const templateRaw = fs.readFileSync(templatePath, 'utf8');
|
|
54
|
+
const templatePkg = JSON.parse(templateRaw);
|
|
67
55
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
69
|
+
console.error('Hiba a package.json szinkronizálása során:', error);
|
|
79
70
|
}
|
|
80
71
|
}
|
|
81
72
|
|