vault-cortex 0.9.0-beta.44 → 0.9.0-beta.45

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/dist/init.js +30 -0
  2. package/package.json +1 -1
package/dist/init.js CHANGED
@@ -119,6 +119,26 @@ const askVaultName = async (prompts) => {
119
119
  const keepExisting = async () => false;
120
120
  /** Interactive conflict policy: ask per differing file, defaulting to keep. */
121
121
  const confirmOverwrite = (prompts) => (name) => prompts.confirm(`${name} already exists and differs — overwrite?`, false);
122
+ /**
123
+ * Re-init guard, fired the moment the target dir is known (prompt answer or
124
+ * --dir flag): an existing .env there means a live deployment, so the flow
125
+ * checks intent before any further questions are spent — re-running init over
126
+ * a deployment is usually an accident, and settings changes belong to
127
+ * `configure`. Declining (the default) backs out with pointers; accepting
128
+ * continues, still protected by the per-file overwrite confirms at write time.
129
+ */
130
+ const confirmReinitOverExistingEnv = async (targetDir, prompts) => {
131
+ if (!existsSync(join(targetDir, ".env")))
132
+ return true;
133
+ prompts.log(`Found an existing deployment in ${targetDir}.`);
134
+ const reinitAnyway = await prompts.confirm("Re-run setup for this directory anyway?", false);
135
+ if (reinitAnyway)
136
+ return true;
137
+ // No outro here: declining still exits 0, and the runInit wrapper owns the
138
+ // closing outro (mirroring configure's declined-restart path).
139
+ prompts.log(`Nothing changed. To adjust settings instead: npx vault-cortex@latest configure --dir "${targetDir}"`);
140
+ return false;
141
+ };
122
142
  const reportWrites = (params, prompts) => {
123
143
  const { targetDir, results } = params;
124
144
  for (const result of results) {
@@ -209,6 +229,13 @@ const runLocalInit = async (flags, deps) => {
209
229
  defaultValue: DEFAULT_TARGET_DIR,
210
230
  placeholder: DEFAULT_TARGET_DIR,
211
231
  }))));
232
+ // --yes skips the guard: it's non-interactive by contract, and its own
233
+ // conflict policy (refuse to overwrite, exit 1) already protects the dir.
234
+ if (!flags.yes) {
235
+ const continueReinit = await confirmReinitOverExistingEnv(targetDir, prompts);
236
+ if (!continueReinit)
237
+ return 0;
238
+ }
212
239
  const token = generateToken();
213
240
  // Guided optional settings: the chooser reads current values from the
214
241
  // generated defaults; enter with nothing picked keeps them all. --yes
@@ -266,6 +293,9 @@ const runRemoteInit = async (flags, deps) => {
266
293
  defaultValue: DEFAULT_TARGET_DIR,
267
294
  placeholder: DEFAULT_TARGET_DIR,
268
295
  }))));
296
+ const continueReinit = await confirmReinitOverExistingEnv(targetDir, prompts);
297
+ if (!continueReinit)
298
+ return 0;
269
299
  const publicUrl = await askPublicUrl(prompts);
270
300
  const vaultName = await askVaultName(prompts);
271
301
  // Auto-capture the Obsidian Sync token via a Docker volume mount when
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vault-cortex",
3
- "version": "0.9.0-beta.44",
3
+ "version": "0.9.0-beta.45",
4
4
  "description": "Set up a Vault Cortex MCP server for your Obsidian vault in one command: npx vault-cortex init",
5
5
  "license": "MIT",
6
6
  "type": "module",