thecore-auth 0.0.21 โ 0.0.23
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 +5 -14
- package/scripts/check-peer-dependencies.js +16 -115
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -6,24 +6,15 @@ import path from "path";
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = path.dirname(__filename);
|
|
8
8
|
|
|
9
|
-
// Percorso dello script
|
|
9
|
+
// Percorso corretto dello script (aggiungendo "scripts/")
|
|
10
10
|
const scriptPath = path.join(__dirname, "scripts", "check-peer-dependencies.js");
|
|
11
11
|
|
|
12
12
|
try {
|
|
13
|
-
console.log("Eseguendo check-peer-dependencies.js...");
|
|
13
|
+
console.log("๐ Eseguendo check-peer-dependencies.js...");
|
|
14
|
+
console.log("๐ Percorso dello script:", scriptPath); // Debug
|
|
14
15
|
execSync(`node ${scriptPath}`, { stdio: "inherit" });
|
|
15
|
-
console.log("check-peer-dependencies.js eseguito con successo!");
|
|
16
|
+
console.log("โ
check-peer-dependencies.js eseguito con successo!");
|
|
16
17
|
} catch (error) {
|
|
17
|
-
console.error("Errore nell'esecuzione di check-peer-dependencies.js", error);
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Installa le dipendenze nella root dell'app principale
|
|
22
|
-
try {
|
|
23
|
-
console.log("Installando dipendenze nella root dell'app...");
|
|
24
|
-
execSync("npm install", { stdio: "inherit", cwd: process.cwd() });
|
|
25
|
-
console.log("Dipendenze installate con successo!");
|
|
26
|
-
} catch (error) {
|
|
27
|
-
console.error("Errore nell'installazione delle dipendenze:", error);
|
|
18
|
+
console.error("โ Errore nell'esecuzione di check-peer-dependencies.js", error);
|
|
28
19
|
process.exit(1);
|
|
29
20
|
}
|
|
@@ -1,130 +1,31 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import { execSync } from 'child_process';
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
4
3
|
import { fileURLToPath } from "url";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// Trova il percorso assoluto dello script
|
|
8
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
7
|
const __dirname = path.dirname(__filename);
|
|
10
8
|
|
|
9
|
+
// Funzione per trovare il package.json dell'applicazione principale
|
|
11
10
|
const findAppRoot = () => {
|
|
12
|
-
let dir =
|
|
11
|
+
let dir = path.resolve(__dirname, "../.."); // Risali dalla directory del pacchetto (node_modules/thecore-auth)
|
|
12
|
+
|
|
13
13
|
while (!fs.existsSync(path.join(dir, "package.json"))) {
|
|
14
14
|
const parentDir = path.dirname(dir);
|
|
15
15
|
if (parentDir === dir) {
|
|
16
|
-
|
|
16
|
+
console.error("โ package.json dell'applicazione non trovato.");
|
|
17
|
+
process.exit(1);
|
|
17
18
|
}
|
|
18
19
|
dir = parentDir;
|
|
19
20
|
}
|
|
20
21
|
return dir;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!parsedVersion) {
|
|
33
|
-
console.log(`๐ฆ Installing ${pkg}@${dependencies[pkg]}...`);
|
|
34
|
-
execSync(`npm install ${isDev ? "-D" : ""} ${pkg}@${dependencies[pkg]}`, { stdio: "inherit", cwd: appRoot });
|
|
35
|
-
} else {
|
|
36
|
-
console.log(`โ
${pkg} giร installato (versione: ${parsedVersion}).`);
|
|
37
|
-
}
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.log(`๐ฆ Installing ${pkg}@${dependencies[pkg]}...`);
|
|
40
|
-
execSync(`npm install ${isDev ? "-D" : ""} ${pkg}@${dependencies[pkg]}`, { stdio: "inherit", cwd: appRoot });
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const installPeerDependencies = () => {
|
|
46
|
-
const peerDependencies = {
|
|
47
|
-
"react-router-dom": "^7.0.0",
|
|
48
|
-
axios: "^1.0.0",
|
|
49
|
-
tailwindcss: "^3.0.0",
|
|
50
|
-
"react-icons": "^5.4.0",
|
|
51
|
-
"jwt-decode": "^3.1.2"
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
installDependencies(peerDependencies);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const installTailwind = () => {
|
|
58
|
-
console.log("๐ Controllo installazione Tailwind CSS...");
|
|
59
|
-
try {
|
|
60
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
61
|
-
if (!packageJson.devDependencies?.tailwindcss) {
|
|
62
|
-
console.log("๐ฆ Installazione Tailwind CSS...");
|
|
63
|
-
installDependencies({ tailwindcss: "^3.0.0" }, true);
|
|
64
|
-
execSync("npx tailwindcss init", { stdio: "inherit", cwd: appRoot });
|
|
65
|
-
console.log("โ
Tailwind CSS installato con successo.");
|
|
66
|
-
} else {
|
|
67
|
-
console.log("โ
Tailwind CSS giร installato.");
|
|
68
|
-
}
|
|
69
|
-
} catch (error) {
|
|
70
|
-
console.error("โ Errore durante l'installazione di Tailwind CSS:", error);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const modifyTailwindConfig = () => {
|
|
75
|
-
const tailwindConfigPath = path.join(appRoot, "tailwind.config.js");
|
|
76
|
-
if (fs.existsSync(tailwindConfigPath)) {
|
|
77
|
-
console.log("โ๏ธ Modifica tailwind.config.js...");
|
|
78
|
-
const configContent = fs.readFileSync(tailwindConfigPath, "utf8");
|
|
79
|
-
|
|
80
|
-
if (!configContent.includes("content:")) {
|
|
81
|
-
const updatedConfigContent = configContent.replace(
|
|
82
|
-
/module\.exports\s*=\s*{/,
|
|
83
|
-
`module.exports = {
|
|
84
|
-
content: [
|
|
85
|
-
\"./src/**/*.{js,jsx,ts,tsx}\",
|
|
86
|
-
\"./public/index.html\",
|
|
87
|
-
],`
|
|
88
|
-
);
|
|
89
|
-
fs.writeFileSync(tailwindConfigPath, updatedConfigContent);
|
|
90
|
-
console.log("โ
Percorsi content aggiunti a tailwind.config.js.");
|
|
91
|
-
} else {
|
|
92
|
-
console.log("โ
Il file tailwind.config.js รจ giร configurato correttamente.");
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
console.error("โ tailwind.config.js non trovato");
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const modifyIndexCss = () => {
|
|
100
|
-
const cssPath = path.join(appRoot, "src", "index.css");
|
|
101
|
-
|
|
102
|
-
if (!fs.existsSync(cssPath)) {
|
|
103
|
-
console.log("๐ Creazione file index.css...");
|
|
104
|
-
fs.writeFileSync(cssPath, "");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (fs.existsSync(cssPath)) {
|
|
108
|
-
console.log("โ๏ธ Aggiunta direttive Tailwind a index.css...");
|
|
109
|
-
const cssContent = fs.readFileSync(cssPath, "utf8");
|
|
110
|
-
const tailwindDirectives = `@tailwind base;\n@tailwind components;\n@tailwind utilities;\n`;
|
|
111
|
-
|
|
112
|
-
if (!cssContent.startsWith(tailwindDirectives)) {
|
|
113
|
-
fs.writeFileSync(cssPath, tailwindDirectives + cssContent);
|
|
114
|
-
console.log("โ
Direttive Tailwind aggiunte a index.css.");
|
|
115
|
-
} else {
|
|
116
|
-
console.log("โ
Le direttive Tailwind sono giร presenti in index.css.");
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
console.error("โ index.css non trovato");
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const checkAndInstallDependencies = () => {
|
|
124
|
-
installPeerDependencies();
|
|
125
|
-
installTailwind();
|
|
126
|
-
modifyTailwindConfig();
|
|
127
|
-
modifyIndexCss();
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
checkAndInstallDependencies();
|
|
24
|
+
try {
|
|
25
|
+
const appRoot = findAppRoot();
|
|
26
|
+
const packageJsonPath = path.join(appRoot, "package.json");
|
|
27
|
+
console.log("โ
package.json trovato in:", packageJsonPath);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error("โ Errore nella ricerca del package.json:", error);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|