thecore-auth 0.0.178 → 0.0.179

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.
@@ -4,15 +4,12 @@ console.log("Script di deploy eseguito! 🚀");
4
4
 
5
5
  import fs from 'fs';
6
6
  import path from 'path';
7
- import { fileURLToPath } from 'url';
8
7
  import readline from 'readline';
9
8
 
10
- // Percorso corrente in ES Module
11
- const __filename = fileURLToPath(import.meta.url);
12
- const __dirname = path.dirname(__filename);
13
-
14
- // Cartella installations nella root
15
- const installationsDir = path.join(__dirname, '..', 'installations');
9
+ // -------------------- CONFIG ROOT -------------------- //
10
+ // root del progetto dove viene lanciato lo script (non del pacchetto)
11
+ const rootDir = process.cwd();
12
+ const installationsDir = path.join(rootDir, 'installations');
16
13
 
17
14
  // -------------------- FUNZIONI -------------------- //
18
15
 
@@ -73,7 +70,7 @@ const checkAndCreateDevFiles = (devDir) => {
73
70
 
74
71
  // Controlla e crea .gitlab-ci.yml nella root
75
72
  const checkAndCreateGitlabCI = () => {
76
- const gitlabFile = path.join(__dirname, '..', '.gitlab-ci.yml');
73
+ const gitlabFile = path.join(rootDir, '.gitlab-ci.yml');
77
74
  if (fs.existsSync(gitlabFile)) {
78
75
  console.log('File ".gitlab-ci.yml" esiste già ✅');
79
76
  } else {
@@ -83,15 +80,13 @@ const checkAndCreateGitlabCI = () => {
83
80
  }
84
81
  };
85
82
 
86
- // Legge e logga il contenuto dei file Docker dentro installations
83
+ // Funzione per leggere e loggare i file docker (facoltativo)
87
84
  const readDockerFiles = () => {
88
85
  const dockerFiles = ['docker-compose.net.yml', 'docker-compose.yml', 'Dockerfile'];
89
-
90
86
  dockerFiles.forEach(fileName => {
91
87
  const filePath = path.join(installationsDir, fileName);
92
88
  if (fs.existsSync(filePath)) {
93
89
  const content = fs.readFileSync(filePath, 'utf-8');
94
- // console.log(`\nContenuto di "${fileName}":\n${content}`);
95
90
  } else {
96
91
  console.log(`File "${fileName}" non trovato ❌`);
97
92
  }
@@ -115,7 +110,6 @@ const askAppName = () => {
115
110
  // Sincronizza un singolo file con il template
116
111
  const syncFileWithDefault = (sourcePath, targetPath) => {
117
112
  const defaultContent = fs.readFileSync(sourcePath, 'utf-8');
118
-
119
113
  let needsUpdate = false;
120
114
 
121
115
  if (fs.existsSync(targetPath)) {
@@ -136,9 +130,7 @@ const syncFileWithDefault = (sourcePath, targetPath) => {
136
130
  };
137
131
 
138
132
  // Sincronizza più file da templates
139
- const syncFilesFromTemplates = (files, targetDir) => {
140
- const templatesDir = path.join(__dirname, 'templates');
141
-
133
+ const syncFilesFromTemplates = (files, targetDir, templatesDir) => {
142
134
  files.forEach(fileName => {
143
135
  const source = path.join(templatesDir, fileName);
144
136
  const target = path.join(targetDir, fileName);
@@ -160,7 +152,6 @@ const syncDockerEnvWithAppName = async (templatePath, targetPath) => {
160
152
  return; // non serve fare nulla
161
153
  }
162
154
 
163
- // Se non c'è o è vuoto, chiediamo il nome all'utente
164
155
  const appName = await askAppName();
165
156
  let content = fs.readFileSync(templatePath, 'utf-8');
166
157
  content = content.replace(/{{APP_NAME}}/g, appName);
@@ -170,7 +161,6 @@ const syncDockerEnvWithAppName = async (templatePath, targetPath) => {
170
161
  };
171
162
 
172
163
  // -------------------- ESECUZIONE PRINCIPALE -------------------- //
173
-
174
164
  const main = async () => {
175
165
  checkAndCreateDir();
176
166
  checkAndCreateFiles();
@@ -182,17 +172,28 @@ const main = async () => {
182
172
 
183
173
  readDockerFiles();
184
174
 
185
- // Sincronizzazione con template
175
+ // Individua templates (sviluppo locale o pacchetto installato)
176
+ let templatesDir;
177
+ const localTemplates = path.join(process.cwd(), 'deploy-scripts', 'templates');
178
+ const packageTemplates = path.join(rootDir, 'node_modules', 'thecore-auth', 'deploy-scripts', 'templates');
179
+
180
+ if (fs.existsSync(localTemplates)) {
181
+ templatesDir = localTemplates; // sviluppo locale
182
+ } else {
183
+ templatesDir = packageTemplates; // pacchetto installato via npx
184
+ }
185
+
186
+ // Sincronizzazione file
186
187
  const installationsFiles = ['docker-compose.net.yml', 'docker-compose.yml', 'Dockerfile'];
187
- const abslabsDevFiles = ['docker_host']; // docker.env lo gestiamo a parte
188
+ const abslabsDevFiles = ['docker_host']; // docker.env gestito a parte
188
189
  const rootFiles = ['.gitlab-ci.yml'];
189
190
 
190
- syncFilesFromTemplates(installationsFiles, installationsDir);
191
- syncFilesFromTemplates(abslabsDevFiles, devDir);
192
- syncFilesFromTemplates(rootFiles, path.join(__dirname, '..'));
191
+ syncFilesFromTemplates(installationsFiles, installationsDir, templatesDir);
192
+ syncFilesFromTemplates(abslabsDevFiles, devDir, templatesDir);
193
+ syncFilesFromTemplates(rootFiles, rootDir, templatesDir);
193
194
 
194
195
  // docker.env dinamico
195
- const dockerEnvTemplate = path.join(__dirname, 'templates', 'docker.env');
196
+ const dockerEnvTemplate = path.join(templatesDir, 'docker.env');
196
197
  const dockerEnvTarget = path.join(devDir, 'docker.env');
197
198
  await syncDockerEnvWithAppName(dockerEnvTemplate, dockerEnvTarget);
198
199
  };
@@ -28,7 +28,7 @@ React keys must be passed directly to JSX without using spread:
28
28
 
29
29
  Check the render method of \``+j+"`."),O||(g=e(g))&&(O=`
30
30
 
31
- Check the top-level render call using <`+g+">."),O}var T=p,M=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),B=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),he=Symbol.for("react.suspense"),Se=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),ye=Symbol.for("react.offscreen"),q=Symbol.iterator,G=Symbol.for("react.client.reference"),se=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,pe=Object.assign,Nt=Symbol.for("react.client.reference"),qe=Array.isArray,Ye=0,re,ee,W,oe,Y,Pe,Ke;i.__reactDisabledLog=!0;var Xe,Ze,dt=!1,Bt=new(typeof WeakMap=="function"?WeakMap:Map),$n=Symbol.for("react.client.reference"),Je,ft={},ht={},_e={};mn.Fragment=R,mn.jsx=function(g,O,j,H,le){return y(g,O,j,!1,H,le)},mn.jsxs=function(g,O,j,H,le){return y(g,O,j,!0,H,le)}}()),mn}var xr;function $c(){return xr||(xr=1,process.env.NODE_ENV==="production"?Wn.exports=_c():Wn.exports=Fc()),Wn.exports}var h=$c();const la=p.createContext(),zc=({children:e,defaultComponent:t})=>{const[n,i]=p.useState(!1),[s,o]=p.useState({}),[r,a]=p.useState(t),c={isLoading:n,setIsLoading:i,loadingProps:s,setLoadingProps:o,loadingComponent:r,setLoadingComponent:a,showLoadingFor:(u=2e3,d={})=>{o(d),i(!0),setTimeout(()=>{i(!1)},u)}};return h.jsx(la.Provider,{value:c,children:e})},It=()=>{const e=p.useContext(la);if(e===void 0)throw new Error("Non puoi settare il loading");return e},Uc="0.0.178",ca=({errorMessage:e,errorShow:t})=>h.jsx("section",{className:t?"":"hidden",children:h.jsxs("div",{className:"container mx-auto",children:[h.jsx("h1",{className:"text-center text-8xl my-12",children:"Errore"}),h.jsx("pre",{className:"text-xl",children:e})]})}),ua=p.createContext(),Hc=({children:e})=>{const[t,n]=p.useState({}),[i,s]=p.useState(!1),o=p.useRef(!1),r=`Creare un file config.json in public per il corretto funzionamento
31
+ Check the top-level render call using <`+g+">."),O}var T=p,M=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),B=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),he=Symbol.for("react.suspense"),Se=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),ye=Symbol.for("react.offscreen"),q=Symbol.iterator,G=Symbol.for("react.client.reference"),se=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,pe=Object.assign,Nt=Symbol.for("react.client.reference"),qe=Array.isArray,Ye=0,re,ee,W,oe,Y,Pe,Ke;i.__reactDisabledLog=!0;var Xe,Ze,dt=!1,Bt=new(typeof WeakMap=="function"?WeakMap:Map),$n=Symbol.for("react.client.reference"),Je,ft={},ht={},_e={};mn.Fragment=R,mn.jsx=function(g,O,j,H,le){return y(g,O,j,!1,H,le)},mn.jsxs=function(g,O,j,H,le){return y(g,O,j,!0,H,le)}}()),mn}var xr;function $c(){return xr||(xr=1,process.env.NODE_ENV==="production"?Wn.exports=_c():Wn.exports=Fc()),Wn.exports}var h=$c();const la=p.createContext(),zc=({children:e,defaultComponent:t})=>{const[n,i]=p.useState(!1),[s,o]=p.useState({}),[r,a]=p.useState(t),c={isLoading:n,setIsLoading:i,loadingProps:s,setLoadingProps:o,loadingComponent:r,setLoadingComponent:a,showLoadingFor:(u=2e3,d={})=>{o(d),i(!0),setTimeout(()=>{i(!1)},u)}};return h.jsx(la.Provider,{value:c,children:e})},It=()=>{const e=p.useContext(la);if(e===void 0)throw new Error("Non puoi settare il loading");return e},Uc="0.0.179",ca=({errorMessage:e,errorShow:t})=>h.jsx("section",{className:t?"":"hidden",children:h.jsxs("div",{className:"container mx-auto",children:[h.jsx("h1",{className:"text-center text-8xl my-12",children:"Errore"}),h.jsx("pre",{className:"text-xl",children:e})]})}),ua=p.createContext(),Hc=({children:e})=>{const[t,n]=p.useState({}),[i,s]=p.useState(!1),o=p.useRef(!1),r=`Creare un file config.json in public per il corretto funzionamento
32
32
  Esempio di config.json:
33
33
 
34
34
  {
@@ -459,7 +459,7 @@ const xa = Nt(), g0 = ({ children: t, defaultComponent: e }) => {
459
459
  const t = ct(xa);
460
460
  if (t === void 0) throw new Error("Non puoi settare il loading");
461
461
  return t;
462
- }, Xc = "0.0.178", Zc = ({ errorMessage: t, errorShow: e }) => /* @__PURE__ */ h.jsx("section", { className: e ? "" : "hidden", children: /* @__PURE__ */ h.jsxs("div", { className: "container mx-auto", children: [
462
+ }, Xc = "0.0.179", Zc = ({ errorMessage: t, errorShow: e }) => /* @__PURE__ */ h.jsx("section", { className: e ? "" : "hidden", children: /* @__PURE__ */ h.jsxs("div", { className: "container mx-auto", children: [
463
463
  /* @__PURE__ */ h.jsx("h1", { className: "text-center text-8xl my-12", children: "Errore" }),
464
464
  /* @__PURE__ */ h.jsx("pre", { className: "text-xl", children: t })
465
465
  ] }) }), wa = Nt(), y0 = ({ children: t }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thecore-auth",
3
3
  "private": false,
4
- "version": "0.0.178",
4
+ "version": "0.0.179",
5
5
  "type": "module",
6
6
  "main": "dist/thecore-auth.cjs.js",
7
7
  "style": "dist/thecore-auth.css",