create-moncircle 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.
Files changed (2) hide show
  1. package/index.js +25 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,18 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * create-moncircle
3
+ * create-moncircle — Interactive setup wizard for @moncircle/sdk
4
4
  *
5
- * Usage: npx create-moncircle
5
+ * Usage:
6
+ * npx create-moncircle (standalone)
7
+ * npm install @moncircle/sdk (auto-triggered via postinstall)
6
8
  *
7
- * Walks devs through setting up @moncircle/sdk in their project.
8
- * Runs as a foreground process (visible output, interactive TTY).
9
+ * Supports:
10
+ * - NEW mode: creates .env from scratch
11
+ * - EDIT mode: updates existing .env without destroying it
9
12
  */
10
13
 
11
14
  const readline = require("readline")
12
15
  const fs = require("fs")
13
16
  const path = require("path")
17
+ const { execSync } = require("child_process")
14
18
 
15
- const ENV_PATH = path.join(process.cwd(), ".env")
19
+ const ENV_PATH = process.env.MON_LOYALTY_ENV_PATH || path.join(process.cwd(), ".env")
20
+ const PKG_PATH = path.join(process.cwd(), "package.json")
16
21
 
17
22
  const CYAN = "\x1b[36m"
18
23
  const GREEN = "\x1b[32m"
@@ -133,6 +138,10 @@ function writeFreshEnv(values) {
133
138
  fs.writeFileSync(ENV_PATH, lines.join("\n"), "utf-8")
134
139
  }
135
140
 
141
+ function sdkIsInstalled() {
142
+ return fs.existsSync(path.join(process.cwd(), "node_modules", "@moncircle", "sdk"))
143
+ }
144
+
136
145
  async function main() {
137
146
  const existing = loadExistingEnv()
138
147
  const isEditMode = Object.keys(existing).length > 0
@@ -144,7 +153,6 @@ async function main() {
144
153
  if (isEditMode) {
145
154
  console.log(` ${GREEN}✓ Existing .env found.${RESET} ${DIM}Press Enter to keep current values.${RESET}\n`)
146
155
  } else {
147
- console.log(` ${DIM}No .env found — let's create one.${RESET}`)
148
156
  console.log(` ${DIM}Writing to: ${ENV_PATH}${RESET}\n`)
149
157
  }
150
158
 
@@ -180,6 +188,17 @@ async function main() {
180
188
  console.log(`${GREEN}${BOLD} ✅ .env created successfully!${RESET}\n`)
181
189
  }
182
190
 
191
+ // Auto-install @moncircle/sdk if not in node_modules
192
+ if (!sdkIsInstalled()) {
193
+ console.log(` ${YELLOW}Installing @moncircle/sdk...${RESET}`)
194
+ try {
195
+ execSync("npm install @moncircle/sdk --save", { stdio: "inherit", cwd: process.cwd() })
196
+ console.log(` ${GREEN}✓ @moncircle/sdk installed!${RESET}\n`)
197
+ } catch {
198
+ console.log(` ${YELLOW}⚠ Run ${CYAN}npm install @moncircle/sdk${RESET}${YELLOW} manually.${RESET}\n`)
199
+ }
200
+ }
201
+
183
202
  console.log(` Next steps:\n`)
184
203
  console.log(` ${CYAN}npx mon-loyalty-api start${RESET} — start the server`)
185
204
  console.log(` ${CYAN}npx create-moncircle${RESET} — reconfigure anytime\n`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-moncircle",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Interactive setup wizard for @moncircle/sdk — run via npx create-moncircle",
5
5
  "bin": {
6
6
  "create-moncircle": "index.js"