@moncircle/sdk 1.0.0 → 1.0.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moncircle/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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",
@@ -19,8 +19,7 @@
19
19
  "setup": "node scripts/setup.js",
20
20
  "dev": "ts-node-dev --respawn --transpile-only src/bin.ts",
21
21
  "build": "tsc",
22
- "start": "node dist/bin.js",
23
- "prepublishOnly": "npm run build"
22
+ "start": "node dist/bin.js"
24
23
  },
25
24
  "keywords": [
26
25
  "loyalty",
@@ -1,18 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * mon-loyalty-api postinstall hook
4
- *
5
- * Runs automatically after: npm install mon-loyalty-api
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 envPath = path.join(projectRoot, ".env")
26
- const setupScript = path.join(__dirname, "setup.js")
18
+ const envExists = fs.existsSync(path.join(projectRoot, ".env"))
27
19
 
28
- console.log(`\n${BOLD}${CYAN} mon-loyalty-api installed!${RESET}`)
20
+ console.log(`
21
+ ${BOLD}${CYAN}╔══════════════════════════════════════════════════════╗
22
+ ║ ✅ @moncircle/sdk installed! ║
23
+ ╚══════════════════════════════════════════════════════╝${RESET}
24
+ `)
29
25
 
30
- // Skip in CI
31
- if (process.env.CI === "true" || process.env.CI === "1") {
32
- console.log(` ${YELLOW}⚠ CI environment detected — skipping interactive setup.${RESET}`)
33
- console.log(` Run ${CYAN}npx mon-loyalty-setup${RESET} manually to configure your .env\n`)
34
- process.exit(0)
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
- // Skip if not interactive TTY (e.g. piped output)
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
- // Skip if .env already exists (don't overwrite a dev's existing config)
45
- if (fs.existsSync(envPath)) {
46
- console.log(` ${GREEN}✓ .env already exists at: ${envPath}${RESET}`)
47
- console.log(` Run ${CYAN}npm run setup${RESET} to reconfigure.\n`)
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
- // Run the interactive setup wizard
52
- console.log(` ${BOLD}Let's configure your environment...\n${RESET}`)
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
  }