@moncircle/sdk 1.0.0 → 1.0.1
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/package.json +2 -2
- package/scripts/postinstall.js +22 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moncircle/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Self-hosted MON loyalty reward infrastructure for e-commerce platforms. Supports SINGLE, MULTI, and HYBRID reward modes with Monad on-chain settlement.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -50,4 +50,4 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"express": ">=4.0.0"
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* mon-loyalty-api postinstall hook
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Smart detection:
|
|
7
|
-
* - Skips in CI environments (CI=true)
|
|
8
|
-
* - Skips if .env already exists in the consumer's project
|
|
9
|
-
* - Skips if not running in an interactive terminal (piped/non-TTY)
|
|
10
|
-
* - Writes .env to INIT_CWD (the consumer's project root, not node_modules)
|
|
4
|
+
* Note: npm pipes stdin during install so interactive prompts can't run here.
|
|
5
|
+
* We print a clear banner directing devs to run the setup wizard.
|
|
11
6
|
*/
|
|
12
7
|
|
|
13
8
|
const fs = require("fs")
|
|
14
9
|
const path = require("path")
|
|
15
|
-
const { execSync } = require("child_process")
|
|
16
10
|
|
|
17
11
|
const CYAN = "\x1b[36m"
|
|
18
12
|
const GREEN = "\x1b[32m"
|
|
@@ -20,43 +14,30 @@ const YELLOW = "\x1b[33m"
|
|
|
20
14
|
const BOLD = "\x1b[1m"
|
|
21
15
|
const RESET = "\x1b[0m"
|
|
22
16
|
|
|
23
|
-
// Where the consumer ran `npm install` (their project root)
|
|
24
17
|
const projectRoot = process.env.INIT_CWD || process.cwd()
|
|
25
|
-
const
|
|
26
|
-
const setupScript = path.join(__dirname, "setup.js")
|
|
18
|
+
const envExists = fs.existsSync(path.join(projectRoot, ".env"))
|
|
27
19
|
|
|
28
|
-
console.log(
|
|
20
|
+
console.log(`
|
|
21
|
+
${BOLD}${CYAN}╔══════════════════════════════════════════════════════╗
|
|
22
|
+
║ ✅ @moncircle/sdk installed! ║
|
|
23
|
+
╚══════════════════════════════════════════════════════╝${RESET}
|
|
24
|
+
`)
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
console.log(` ${
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
if (envExists) {
|
|
27
|
+
console.log(` ${GREEN}✓ .env found — you're already configured.${RESET}`)
|
|
28
|
+
console.log(` Run ${CYAN}npx mon-loyalty-setup${RESET} to reconfigure anytime.\n`)
|
|
29
|
+
} else {
|
|
30
|
+
console.log(` ${YELLOW}${BOLD}⚠ No .env file found.${RESET}`)
|
|
31
|
+
console.log(`
|
|
32
|
+
Run the interactive setup wizard now:
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
if (!process.stdin.isTTY) {
|
|
39
|
-
console.log(` ${YELLOW}⚠ Non-interactive terminal — skipping setup wizard.${RESET}`)
|
|
40
|
-
console.log(` Run ${CYAN}npm run setup${RESET} to configure your .env\n`)
|
|
41
|
-
process.exit(0)
|
|
42
|
-
}
|
|
34
|
+
${BOLD}${CYAN} npx mon-loyalty-setup${RESET}
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
process.exit(0)
|
|
49
|
-
}
|
|
36
|
+
It will ask for your MongoDB URI, Monad wallet, and other
|
|
37
|
+
config, then write your .env file automatically.
|
|
38
|
+
|
|
39
|
+
Then start the server:
|
|
50
40
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
execSync(`node ${setupScript}`, {
|
|
55
|
-
stdio: "inherit",
|
|
56
|
-
cwd: projectRoot,
|
|
57
|
-
env: { ...process.env, MON_LOYALTY_ENV_PATH: envPath }
|
|
58
|
-
})
|
|
59
|
-
} catch {
|
|
60
|
-
// User may have Ctrl+C'd — that's fine
|
|
61
|
-
console.log(`\n ${YELLOW}Setup cancelled. Run ${CYAN}npm run setup${RESET}${YELLOW} anytime to configure.${RESET}\n`)
|
|
41
|
+
${BOLD}${CYAN} npx mon-loyalty-api start${RESET}
|
|
42
|
+
`)
|
|
62
43
|
}
|