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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thecore-auth",
3
3
  "private": false,
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
5
5
  "type": "module",
6
6
  "main": "dist/thecore-auth.cjs.js",
7
7
  "module": "dist/thecore-auth.esm.js",
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 di verifica delle dipendenze
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 'fs';
2
- import path from 'path';
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
- console.log('๐Ÿ“Œ Avvio dello script di installazione dipendenze...');
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 = process.cwd();
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
- throw new Error("โŒ package.json non trovato in nessuna directory superiore.");
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
- const appRoot = findAppRoot();
24
- const packageJsonPath = path.join(appRoot, "package.json");
25
-
26
- const installDependencies = (dependencies, isDev = false) => {
27
- Object.keys(dependencies).forEach((pkg) => {
28
- try {
29
- const installedVersion = execSync(`npm list ${pkg} --depth=0 --json`, { cwd: appRoot, encoding: "utf8" });
30
- const parsedVersion = JSON.parse(installedVersion).dependencies?.[pkg]?.version;
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
+ }