@eventmodelers/cli 1.0.2 → 1.0.3
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/cli.js +42 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -932,6 +932,7 @@ async function installStack(stackKey, stackCfg, options = {}) {
|
|
|
932
932
|
// even without a token yet — the file only ever holds the env-var
|
|
933
933
|
// placeholder, never the literal secret (see connect/SKILL.md's Security notes).
|
|
934
934
|
ensureMcpRegistered(targetDir, config.baseUrl || DEFAULT_BASE_URL);
|
|
935
|
+
ensureEnvToken(targetDir, config.token);
|
|
935
936
|
|
|
936
937
|
// --- 6. Install manifest (drives precise `uninstall` later) ---
|
|
937
938
|
// Only the footprint listed here is ever removed by `uninstall` — the root
|
|
@@ -1155,6 +1156,46 @@ function ensureMcpRegistered(projectDir, baseUrl) {
|
|
|
1155
1156
|
writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
|
|
1156
1157
|
}
|
|
1157
1158
|
|
|
1159
|
+
// Companion to ensureMcpRegistered: that function deliberately never writes the
|
|
1160
|
+
// token itself, on the assumption the caller sets EVENTMODELERS_TOKEN in whatever
|
|
1161
|
+
// process spawns `claude` (true for `run --modeling`'s own spawn). It is NOT true
|
|
1162
|
+
// for an interactive session opened directly in the project right after
|
|
1163
|
+
// `init`/`init-config` — that `claude` process inherits the user's shell env,
|
|
1164
|
+
// which never had a reason to already have this var set. Without a `.env` to
|
|
1165
|
+
// resolve it from, `.mcp.json`'s `${EVENTMODELERS_TOKEN}` placeholder resolves to
|
|
1166
|
+
// empty, the MCP server gets an empty x-token header, and the connection fails —
|
|
1167
|
+
// silently, until something happens to trigger the `connect` skill's own Step 3.5,
|
|
1168
|
+
// which writes this same file. Do it here too so a fresh interactive session works
|
|
1169
|
+
// without depending on that skill having run first.
|
|
1170
|
+
function ensureEnvToken(targetDir, token) {
|
|
1171
|
+
if (!token) return;
|
|
1172
|
+
const envPath = join(targetDir, '.env');
|
|
1173
|
+
const line = `EVENTMODELERS_TOKEN=${token}`;
|
|
1174
|
+
|
|
1175
|
+
if (existsSync(envPath)) {
|
|
1176
|
+
const content = readFileSync(envPath, 'utf-8');
|
|
1177
|
+
if (/^EVENTMODELERS_TOKEN=/m.test(content)) {
|
|
1178
|
+
const updated = content.replace(/^EVENTMODELERS_TOKEN=.*$/m, line);
|
|
1179
|
+
if (updated !== content) writeFileSync(envPath, updated);
|
|
1180
|
+
} else {
|
|
1181
|
+
appendFileSync(envPath, `${content === '' || content.endsWith('\n') ? '' : '\n'}${line}\n`);
|
|
1182
|
+
}
|
|
1183
|
+
} else {
|
|
1184
|
+
writeFileSync(envPath, `${line}\n`);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
const gitignorePath = join(targetDir, '.gitignore');
|
|
1188
|
+
if (existsSync(gitignorePath)) {
|
|
1189
|
+
const content = readFileSync(gitignorePath, 'utf-8');
|
|
1190
|
+
if (!content.split('\n').map((l) => l.trim()).includes('.env')) {
|
|
1191
|
+
appendFileSync(gitignorePath, `${content === '' || content.endsWith('\n') ? '' : '\n'}.env\n`);
|
|
1192
|
+
}
|
|
1193
|
+
} else {
|
|
1194
|
+
writeFileSync(gitignorePath, '.env\n');
|
|
1195
|
+
}
|
|
1196
|
+
console.log(' ✓ Wrote EVENTMODELERS_TOKEN to .env (gitignored)');
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1158
1199
|
// `run --modeling`: modeling-kit's one and only runtime mode — there is no
|
|
1159
1200
|
// cold-spawn/tasks.json loop for this kit (that's a build-kit concept; see the
|
|
1160
1201
|
// `run` command's build-kit-vs-modeling-kit gate above). It keeps ONE Claude
|
|
@@ -1650,6 +1691,7 @@ credentialFlags(program
|
|
|
1650
1691
|
// stale MCP registration pointing at the wrong host is worse than none
|
|
1651
1692
|
// (see the beta-api protected-resource-metadata incident this fixed).
|
|
1652
1693
|
ensureMcpRegistered(targetDir, cfg.baseUrl || DEFAULT_BASE_URL);
|
|
1694
|
+
ensureEnvToken(targetDir, cfg.token);
|
|
1653
1695
|
}
|
|
1654
1696
|
});
|
|
1655
1697
|
|
package/package.json
CHANGED