@dropi/ui-components 1.0.6 → 1.0.8

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.
Files changed (2) hide show
  1. package/package.json +4 -1
  2. package/scripts/init.js +49 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dropi/ui-components",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Dropi UI Components - Framework-agnostic Web Components library built with Angular Elements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -18,6 +18,9 @@
18
18
  "build:complete": "npm run build && npm run copy:tokens",
19
19
  "postinstall": "node scripts/init.js"
20
20
  },
21
+ "bin": {
22
+ "dropi-setup": "./scripts/init.js"
23
+ },
21
24
  "peerDependencies": {
22
25
  "@angular/common": "^18.2.0",
23
26
  "@angular/core": "^18.2.0",
package/scripts/init.js CHANGED
@@ -7,12 +7,35 @@ if (process.env.CI) {
7
7
  process.exit(0);
8
8
  }
9
9
 
10
- // Skip if running locally (not in node_modules)
11
- if (!__dirname.includes("node_modules")) {
12
- console.log(" ➜ Modo desarrollo detectado: Saltando setup interactivo.");
10
+ // 1. Check for Environment Variable (Silent Mode)
11
+ const installMode = process.env.DROPI_INSTALL_MODE; // 'standalone' | 'micro'
12
+
13
+ if (installMode) {
14
+ if (installMode.toLowerCase() === "standalone") {
15
+ installDeps();
16
+ } else {
17
+ console.log(
18
+ "\nℹ️ Modo Micro Frontend seleccionado via variable de entorno.",
19
+ );
20
+ }
13
21
  process.exit(0);
14
22
  }
15
23
 
24
+ // 2. Check for Interactive TTY
25
+ if (!process.stdout.isTTY || !process.stdin.isTTY) {
26
+ console.log("\x1b[36m%s\x1b[0m", "\n👋 @dropi/ui-components instalada.");
27
+ console.log(
28
+ "\x1b[33m%s\x1b[0m",
29
+ "⚠️ No se detectó una terminal interactiva (se omitió la configuración automática).",
30
+ );
31
+ console.log(
32
+ "\nPara configurar las dependencias (si es una app Standalone), ejecuta manualmente:",
33
+ );
34
+ console.log("\x1b[1m%s\x1b[0m", " npx dropi-setup\n");
35
+ process.exit(0);
36
+ }
37
+
38
+ // 3. Interactive Mode
16
39
  const rl = readline.createInterface({
17
40
  input: process.stdin,
18
41
  output: process.stdout,
@@ -21,9 +44,7 @@ const rl = readline.createInterface({
21
44
  console.log(
22
45
  "\x1b[36m%s\x1b[0m",
23
46
  "\n👋 Completando instalación de @dropi/ui-components...",
24
- );
25
- console.log(
26
- "Para funcionar correctamente, esta librería necesita el entorno de ejecución de Angular.",
47
+ "\n Configuración de entorno Angular.",
27
48
  );
28
49
 
29
50
  rl.question(
@@ -32,25 +53,7 @@ rl.question(
32
53
  const isYes = ["s", "si", "y", "yes"].includes(answer.toLowerCase().trim());
33
54
 
34
55
  if (isYes) {
35
- console.log(
36
- "\n📦 Instalando dependencias requeridas (Angular v18 + Zone.js)...",
37
- );
38
- try {
39
- // Install as dependencies
40
- execSync(
41
- "npm install zone.js @angular/core@^18.2.0 @angular/common@^18.2.0 @angular/compiler@^18.2.0 @angular/platform-browser@^18.2.0 @angular/platform-browser-dynamic@^18.2.0",
42
- { stdio: "inherit" },
43
- );
44
- console.log(
45
- "\x1b[32m%s\x1b[0m",
46
- "\n✅ Dependencias instaladas correctamente.\n",
47
- );
48
- } catch (e) {
49
- console.error(
50
- "\x1b[31m%s\x1b[0m",
51
- "\n❌ Error al instalar dependencias. Intenta ejecutar manualmente npm install.",
52
- );
53
- }
56
+ installDeps();
54
57
  } else {
55
58
  console.log(
56
59
  "\x1b[33m%s\x1b[0m",
@@ -63,3 +66,24 @@ rl.question(
63
66
  rl.close();
64
67
  },
65
68
  );
69
+
70
+ function installDeps() {
71
+ console.log(
72
+ "\n📦 Instalando dependencias requeridas (Angular v18 + Zone.js)...",
73
+ );
74
+ try {
75
+ execSync(
76
+ "npm install zone.js @angular/core@^18.2.0 @angular/common@^18.2.0 @angular/compiler@^18.2.0 @angular/platform-browser@^18.2.0 @angular/platform-browser-dynamic@^18.2.0",
77
+ { stdio: "inherit" },
78
+ );
79
+ console.log(
80
+ "\x1b[32m%s\x1b[0m",
81
+ "\n✅ Dependencias instaladas correctamente.\n",
82
+ );
83
+ } catch (e) {
84
+ console.error(
85
+ "\x1b[31m%s\x1b[0m",
86
+ "\n❌ Error al instalar dependencias. Intenta ejecutar manualmente npm install.",
87
+ );
88
+ }
89
+ }