@dropi/ui-components 1.0.13 → 1.0.15

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.
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ const readline = require("readline");
3
+ const { execSync } = require("child_process");
4
+
5
+ // Check if running in CI used to avoid blocking builds
6
+ if (process.env.CI) {
7
+ process.exit(0);
8
+ }
9
+
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
+ }
21
+ process.exit(0);
22
+ }
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
39
+ const rl = readline.createInterface({
40
+ input: process.stdin,
41
+ output: process.stdout,
42
+ });
43
+
44
+ console.log(
45
+ "\x1b[36m%s\x1b[0m",
46
+ "\n👋 Completando instalación de @dropi/ui-components...",
47
+ "\n Configuración de entorno Angular.",
48
+ );
49
+
50
+ rl.question(
51
+ "\n¿Es este un proyecto Standalone (React/Vue/Vanilla) que necesita descargar las dependencias? (s/N): ",
52
+ (answer) => {
53
+ const isYes = ["s", "si", "y", "yes"].includes(answer.toLowerCase().trim());
54
+
55
+ if (isYes) {
56
+ installDeps();
57
+ } else {
58
+ console.log(
59
+ "\x1b[33m%s\x1b[0m",
60
+ "\nℹ️ Modo Micro Frontend: No se instalaron dependencias adicionales.",
61
+ );
62
+ console.log(
63
+ " Asegúrate de que tu Host provea Angular y Zone.js vía Module Federation.\n",
64
+ );
65
+ }
66
+ rl.close();
67
+ },
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 @angular/router@^18.2.0 @angular/elements@^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
+ }
@@ -0,0 +1,20 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const packageJsonPath = path.join(__dirname, "../dist/package.json");
5
+
6
+ try {
7
+ const packageJson = require(packageJsonPath);
8
+
9
+ if (!packageJson.scripts) {
10
+ packageJson.scripts = {};
11
+ }
12
+
13
+ packageJson.scripts.postinstall = "node scripts/init.js";
14
+
15
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
16
+ console.log("✅ Restored postinstall script in dist/package.json");
17
+ } catch (error) {
18
+ console.error("❌ Error restoring postinstall script:", error);
19
+ process.exit(1);
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dropi/ui-components",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Dropi UI Components - Framework-agnostic Web Components library built with Angular Elements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -15,7 +15,9 @@
15
15
  "scripts": {
16
16
  "build": "ng-packagr -p ng-package.json",
17
17
  "copy:tokens": "cp src/styles.scss ./dist/dropi-tokens.css",
18
- "build:complete": "npm run build && npm run copy:tokens",
18
+ "copy:scripts": "cp -r scripts ./dist/scripts",
19
+ "restore:postinstall": "node scripts/restore-postinstall.js",
20
+ "build:complete": "npm run build && npm run copy:tokens && npm run copy:scripts && npm run restore:postinstall",
19
21
  "postinstall": "node scripts/init.js"
20
22
  },
21
23
  "bin": {
package/scripts/init.js CHANGED
@@ -73,7 +73,7 @@ function installDeps() {
73
73
  );
74
74
  try {
75
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",
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 @angular/router@^18.2.0 @angular/elements@^18.2.0",
77
77
  { stdio: "inherit" },
78
78
  );
79
79
  console.log(
@@ -0,0 +1,20 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const packageJsonPath = path.join(__dirname, "../dist/package.json");
5
+
6
+ try {
7
+ const packageJson = require(packageJsonPath);
8
+
9
+ if (!packageJson.scripts) {
10
+ packageJson.scripts = {};
11
+ }
12
+
13
+ packageJson.scripts.postinstall = "node scripts/init.js";
14
+
15
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
16
+ console.log("✅ Restored postinstall script in dist/package.json");
17
+ } catch (error) {
18
+ console.error("❌ Error restoring postinstall script:", error);
19
+ process.exit(1);
20
+ }