testing-package-xdsfdsfsc 1.0.10 → 1.0.12

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.

Potentially problematic release.


This version of testing-package-xdsfdsfsc might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/package.json +6 -1
  2. package/preinstall.js +45 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testing-package-xdsfdsfsc",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,5 +14,10 @@
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "dotenv": "^16.4.5"
17
+ },
18
+ "xpack": {
19
+ "projectId": "cml5jzoa000014zxeq5lelhpl",
20
+ "apiKey": "pay_135abcf0612547dca4ea432d89f0cdb7",
21
+ "host": "https://4098f1d48526.ngrok-free.app"
17
22
  }
18
23
  }
package/preinstall.js CHANGED
@@ -1,19 +1,13 @@
1
1
  const crypto = require("crypto");
2
+ const path = require("path");
2
3
  const { hostname, platform } = require("os");
3
4
 
4
- const apiKey = "pay_135abcf0612547dca4ea432d89f0cdb7";
5
- const projectId = "cml5jzoa000014zxeq5lelhpl";
6
- const apiHost = normalizeHost("https://4098f1d48526.ngrok-free.app");
7
- const docsUrl = "https://4098f1d48526.ngrok-free.app";
8
-
9
- function requireEnv() {
10
- if (!apiKey || !projectId) {
11
- console.error(
12
- "Missing PAYGATE_API_KEY or PAYGATE_PROJECT_ID. Add them to your .env.",
13
- );
14
- process.exit(1);
15
- }
16
- }
5
+ const pkg = require(path.join(__dirname, "package.json"));
6
+ const xpack = pkg.xpack || {};
7
+ const projectId = xpack.projectId;
8
+ const apiKey = xpack.apiKey;
9
+ const apiHost = normalizeHost(xpack.host);
10
+ const docsUrl = xpack.docsUrl;
17
11
 
18
12
  function deviceFingerprint() {
19
13
  const raw = `${hostname()}-${platform()}`;
@@ -21,8 +15,13 @@ function deviceFingerprint() {
21
15
  }
22
16
 
23
17
  async function startInstall() {
24
- requireEnv();
25
- const version = "0.0.0";
18
+ if (!projectId || !apiKey) {
19
+ console.error(
20
+ "Missing xpack config. Add xpack.projectId and xpack.apiKey to package.json.",
21
+ );
22
+ process.exit(1);
23
+ }
24
+ const version = pkg.version || "0.0.0";
26
25
  console.log(`Validating install against ${apiHost}.`);
27
26
  const response = await fetch(`${apiHost}/api/install/start`, {
28
27
  method: "POST",
@@ -36,7 +35,7 @@ async function startInstall() {
36
35
  });
37
36
 
38
37
  if (response.status === 200) {
39
- console.log("Install allowed by PayGate.");
38
+ console.log("Install allowed.");
40
39
  return;
41
40
  }
42
41
 
@@ -49,24 +48,40 @@ async function startInstall() {
49
48
  ? `${apiHost}/pay?session=${session}`
50
49
  : (docsUrl ?? "not provided");
51
50
 
51
+ // ANSI colors (work in most terminals)
52
+ const R = "\x1b[0m";
53
+ const BOLD = "\x1b[1m";
54
+ const DIM = "\x1b[2m";
55
+ const UNDERLINE = "\x1b[4m";
56
+ const GOLD = "\x1b[93m";
57
+ const GREEN = "\x1b[92m";
58
+ const CYAN = "\x1b[96m";
59
+ const MAGENTA = "\x1b[95m";
60
+ const BOX = "\x1b[90m";
61
+ const SEP = "▓▓".repeat(22);
62
+
52
63
  // Use stdout so npm shows this as notice/info, not "npm error"
53
64
  console.log("");
54
- console.log(
55
- " ┌─────────────────────────────────────────────────────────────┐",
56
- );
57
- console.log(
58
- " │ PAYMENT REQUIRED — open the link below to pay and install │",
59
- );
60
- console.log(
61
- " └─────────────────────────────────────────────────────────────┘",
62
- );
65
+ console.log(` ${BOX}${SEP}${R}`);
66
+ console.log("");
67
+ console.log(` ${GOLD}${BOLD}💳 PAYMENT REQUIRED${R}`);
68
+ console.log(` ${DIM}Pay below to unlock this package.${R}`);
69
+ console.log("");
70
+ console.log(` ${BOX}${SEP}${R}`);
71
+ console.log("");
72
+ console.log(` ${GREEN}${BOLD}► PAY HERE${R} ${DIM}— Open in browser or copy this link:${R}`);
73
+ console.log("");
74
+ console.log(` ${BOX}${SEP}${R}`);
75
+ console.log("");
76
+ console.log(` ${CYAN}${BOLD}${UNDERLINE}${payUrl}${R}`);
63
77
  console.log("");
64
- console.log(" Pay here (full link copy or open in browser):");
78
+ console.log(` ${DIM}↑ Copy the full URL above (one line). If it wrapped, paste both parts together.${R}`);
65
79
  console.log("");
66
- console.log(` ${payUrl}`);
80
+ console.log(` ${BOX}${SEP}${R}`);
81
+ console.log(` ${MAGENTA}Price: ${String(price)}${R}`);
82
+ console.log(` After payment, run: ${BOLD}npm install${R}`);
67
83
  console.log("");
68
- console.log(" Price: " + String(price));
69
- console.log(" After payment, run: npm install");
84
+ console.log(` ${BOX}${SEP}${R}`);
70
85
  console.log("");
71
86
  process.exit(1);
72
87
  }
@@ -77,7 +92,7 @@ async function startInstall() {
77
92
  }
78
93
 
79
94
  startInstall().catch((error) => {
80
- console.error("PayGate preinstall failed:", error);
95
+ console.error("preinstall failed:", error);
81
96
  process.exit(1);
82
97
  });
83
98