thecore-auth 0.0.20 → 0.0.22

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.20",
4
+ "version": "0.0.22",
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,14 @@ 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
10
- const scriptPath = path.join(__dirname, "scripts", "check-peer-dependencies.js");
9
+ // Percorso corretto dello script
10
+ const scriptPath = path.join(__dirname, "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
14
  execSync(`node ${scriptPath}`, { stdio: "inherit" });
15
- console.log("check-peer-dependencies.js eseguito con successo!");
15
+ console.log("check-peer-dependencies.js eseguito con successo!");
16
16
  } 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);
17
+ console.error("Errore nell'esecuzione di check-peer-dependencies.js", error);
28
18
  process.exit(1);
29
19
  }
@@ -1,136 +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('Sono entrato nello script');
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 not found in any parent directory.");
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 installPeerDependencies = () => {
27
- const peerDependencies = {
28
- "react-router-dom": "^7.0.0",
29
- axios: "^1.0.0",
30
- tailwindcss: "^3.0.0",
31
- "react-icons": "^5.4.0",
32
- "jwt-decode": "^3.1.2"
33
- };
34
-
35
- if (!fs.existsSync(packageJsonPath)) {
36
- console.error("Error: package.json not found");
37
- return;
38
- }
39
-
40
- Object.keys(peerDependencies).forEach((pkg) => {
41
- try {
42
- const installedVersion = execSync(`npm list ${pkg} --depth=0 --json`, { cwd: appRoot, encoding: "utf8" });
43
- const parsedVersion = JSON.parse(installedVersion).dependencies?.[pkg]?.version;
44
-
45
- if (!parsedVersion) {
46
- console.log(`📦 Installing ${pkg}@${peerDependencies[pkg]}...`);
47
- execSync(`npm install ${pkg}@${peerDependencies[pkg]}`, { stdio: "inherit", cwd: appRoot });
48
- } else {
49
- console.log(`✅ ${pkg} already installed (version: ${parsedVersion}).`);
50
- }
51
- } catch (error) {
52
- console.log(`📦 Installing ${pkg}@${peerDependencies[pkg]}...`);
53
- execSync(`npm install ${pkg}@${peerDependencies[pkg]}`, { stdio: "inherit", cwd: appRoot });
54
- }
55
- });
56
- };
57
-
58
- const installTailwind = () => {
59
- console.log("Checking if Tailwind CSS is installed...");
60
-
61
- try {
62
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
63
-
64
- if (!packageJson.devDependencies?.tailwindcss) {
65
- console.log("📦 Installing Tailwind CSS...");
66
- execSync("npm install -D tailwindcss@3", { stdio: "inherit", cwd: appRoot });
67
- execSync("npx tailwindcss init", { stdio: "inherit", cwd: appRoot });
68
- console.log("✅ Tailwind CSS installed.");
69
- } else {
70
- console.log("✅ Tailwind CSS already installed.");
71
- }
72
- } catch (error) {
73
- console.error("❌ Error installing Tailwind CSS:", error);
74
- }
75
- };
76
-
77
- const modifyTailwindConfig = () => {
78
- const tailwindConfigPath = path.join(appRoot, "tailwind.config.js");
79
-
80
- if (fs.existsSync(tailwindConfigPath)) {
81
- console.log("Modifying tailwind.config.js...");
82
- const configContent = fs.readFileSync(tailwindConfigPath, "utf8");
83
-
84
- if (!configContent.includes("content:")) {
85
- const updatedConfigContent = configContent.replace(
86
- /module\.exports\s*=\s*{/,
87
- `module.exports = {
88
- content: [
89
- "./src/**/*.{js,jsx,ts,tsx}",
90
- "./public/index.html",
91
- ],`
92
- );
93
-
94
- fs.writeFileSync(tailwindConfigPath, updatedConfigContent);
95
- console.log("Added content path to tailwind.config.js.");
96
- } else {
97
- console.log("content path already present in tailwind.config.js.");
98
- }
99
- } else {
100
- console.error("tailwind.config.js not found");
101
- }
102
- };
103
-
104
- const modifyIndexCss = () => {
105
- const cssPath = path.join(appRoot, "src", "index.css");
106
-
107
- if (!fs.existsSync(cssPath)) {
108
- console.log("index.css not found, creating it...");
109
- fs.writeFileSync(cssPath, "");
110
- }
111
-
112
- if (fs.existsSync(cssPath)) {
113
- console.log("Adding Tailwind directives to the beginning of index.css...");
114
- const cssContent = fs.readFileSync(cssPath, "utf8");
115
- const tailwindDirectives = `@tailwind base;\n@tailwind components;\n@tailwind utilities;\n`;
116
-
117
- if (!cssContent.startsWith(tailwindDirectives)) {
118
- const updatedCssContent = tailwindDirectives + cssContent;
119
- fs.writeFileSync(cssPath, updatedCssContent);
120
- console.log("Tailwind directives added to index.css.");
121
- } else {
122
- console.log("Tailwind directives already present in index.css.");
123
- }
124
- } else {
125
- console.error("index.css not found");
126
- }
127
- };
128
-
129
- const checkAndInstallDependencies = () => {
130
- installPeerDependencies();
131
- installTailwind();
132
- modifyTailwindConfig();
133
- modifyIndexCss();
134
- };
135
-
136
- 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
+ }