sg-frontend-starter 1.0.4 → 1.0.6
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 +32 -4
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -6,17 +6,19 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = path.dirname(__filename);
|
|
7
7
|
|
|
8
8
|
// Az sg-frontend-starter modulban belül keresünk
|
|
9
|
-
const source = path.join(__dirname
|
|
10
|
-
// A végső cél: a
|
|
9
|
+
const source = path.join(__dirname);
|
|
10
|
+
// A végső cél: a node_modules/sg-frontend-starter szülőjéhez képest (ahol az npm install fut)
|
|
11
11
|
const projectRoot = path.join(__dirname, '..', '..');
|
|
12
12
|
|
|
13
|
+
const targetPackageJson = path.join(projectRoot, 'package.json');
|
|
14
|
+
|
|
13
15
|
if (fs.existsSync(source)) {
|
|
14
16
|
// Az sg-frontend-starter mappájában lévő összes fájlt és mappát másolja ki
|
|
15
17
|
const files = fs.readdirSync(source);
|
|
16
18
|
|
|
17
19
|
files.forEach(file => {
|
|
18
|
-
// Kihagyja a node_modules-t
|
|
19
|
-
if (file !== 'node_modules' && file !== 'package.json') {
|
|
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') {
|
|
20
22
|
const srcPath = path.join(source, file);
|
|
21
23
|
const destPath = path.join(projectRoot, file);
|
|
22
24
|
|
|
@@ -37,6 +39,32 @@ if (fs.existsSync(source)) {
|
|
|
37
39
|
console.log('✓ sg-frontend-starter tartalma sikeresen áthelyezve');
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
// Biztosítja, hogy a cél package.json tartalmazza a dev scriptet
|
|
43
|
+
ensureDevScript(targetPackageJson);
|
|
44
|
+
|
|
45
|
+
function ensureDevScript(packageJsonPath) {
|
|
46
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const raw = fs.readFileSync(packageJsonPath, 'utf8');
|
|
52
|
+
const pkg = JSON.parse(raw);
|
|
53
|
+
|
|
54
|
+
if (!pkg.scripts) {
|
|
55
|
+
pkg.scripts = {};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!pkg.scripts.dev) {
|
|
59
|
+
pkg.scripts.dev = 'vite';
|
|
60
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
61
|
+
console.log('✓ dev script hozzáadva a package.json-hoz');
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Hiba a package.json frissítése során:', error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
40
68
|
// Segédfunkció a mappák rekurzív másolásához
|
|
41
69
|
function copyDir(src, dest) {
|
|
42
70
|
fs.mkdirSync(dest, { recursive: true });
|