create-walpole-ar 2.2.3 → 2.3.3

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/index.html ADDED
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>webpole-restaurante</title>
6
+ <link rel="manifest" href="/manifest.json">
7
+ <meta name="theme-color" content="">
8
+ <style>
9
+ body{font-family:sans-serif;text-align:center;padding:40px;}
10
+ button{padding:12px 20px;border:none;background-color:#c43434;border-radius:8px;}
11
+ </style>
12
+ </head>
13
+ <body>
14
+
15
+ <h1>webpole-restaurante</h1>
16
+ <p>Powered by WebPole-AR PWA Core</p>
17
+ <button id="btnInstallApp" style="display:none;">Instalar App</button>
18
+
19
+ <script src="/core/install-manager.js"></script>
20
+ <script src="/core/update-manager.js"></script>
21
+
22
+ <script>
23
+ if ("serviceWorker" in navigator) {
24
+ window.addEventListener("load", () => {
25
+ navigator.serviceWorker.register("/core/sw-core.js");
26
+ });
27
+ }
28
+ </script>
29
+
30
+ </body>
31
+ </html>
package/index.js CHANGED
@@ -8,38 +8,39 @@ const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
9
9
 
10
10
  const args = process.argv.slice(2);
11
- const projectName = args[0];
12
11
  const initMode = args.includes("--init");
13
-
14
- if (!projectName && !initMode) {
15
- console.log("⚠ Debes indicar un nombre para el proyecto o usar --init.");
16
- process.exit(1);
17
- }
12
+ const projectNameArg = args.find(arg => arg !== "--init");
13
+ const projectName = projectNameArg || path.basename(process.cwd());
18
14
 
19
15
  const projectPath = initMode ? process.cwd() : path.join(process.cwd(), projectName);
20
16
  const templatePath = path.join(__dirname, "template");
21
17
 
22
- // Evitar sobreescribir proyecto
18
+ // Evitar sobreescribir proyecto nuevo
23
19
  if (!initMode && fs.existsSync(projectPath)) {
24
20
  console.log("⚠ La carpeta ya existe.");
25
21
  process.exit(1);
26
22
  }
27
23
 
28
- // Crear carpeta si es proyecto nuevo
24
+ // Crear carpeta para proyecto nuevo
29
25
  if (!initMode) fs.mkdirSync(projectPath);
30
26
 
31
- // Función para copiar todos los archivos de template
27
+ // Función para copiar archivos del template
32
28
  function copyTemplateFiles() {
33
29
  fs.readdirSync(templatePath).forEach(file => {
30
+ const targetFile = path.join(projectPath, file);
31
+
32
+ // Si es init y ya existe index.html, no sobrescribir
33
+ if (initMode && file === "index.html" && fs.existsSync(targetFile)) return;
34
+
34
35
  const content = fs.readFileSync(path.join(templatePath, file), "utf-8");
35
- const finalContent = content.replace(/{{projectName}}/g, projectName || "MiProyecto");
36
- fs.writeFileSync(path.join(projectPath, file), finalContent);
36
+ const finalContent = content.replace(/{{projectName}}/g, projectName);
37
+ fs.writeFileSync(targetFile, finalContent);
37
38
  });
38
39
  }
39
40
 
40
41
  copyTemplateFiles();
41
42
 
42
- // Si es init, insertar manifest y registrar SW en index.html existente
43
+ // Para init, actualizar index.html existente con manifest y SW
43
44
  if (initMode) {
44
45
  const indexFile = path.join(projectPath, "index.html");
45
46
  if (fs.existsSync(indexFile)) {
@@ -66,4 +67,5 @@ if('serviceWorker' in navigator){
66
67
  }
67
68
 
68
69
  console.log("✅ Operación completada. 🚀");
69
- if (!initMode) console.log(`👉 cd ${projectName} && code .`);
70
+ if (!initMode) console.log(`👉 cd ${projectName} && code .`);
71
+ if (initMode) console.log("👉 Proyecto existente actualizado con PWA");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-walpole-ar",
3
- "version": "2.2.3",
3
+ "version": "2.3.3",
4
4
  "description": "CLI para crear PWAs listas para producción",
5
5
  "bin": {
6
6
  "create-walpole-ar": "./index.js"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "{{projectName}}",
3
3
  "short_name": "{{projectName}}",
4
- "description": "Version 2.1.3 - WebPole AR PWA Core",
4
+ "description": "Version 2.3.3 - WebPole AR PWA Core",
5
5
  "start_url": ".",
6
6
  "display": "standalone",
7
7
  "background_color": "#ffffff",
package/template/sw,js CHANGED
@@ -1,4 +1,4 @@
1
- const CACHE_NAME = "walpole-ar-v6";
1
+ const CACHE_NAME = "walpole-ar-v7";
2
2
 
3
3
  const FILES_TO_CACHE = [
4
4
  "/",