@hol-org/hashnet-mcp 1.0.3 → 1.0.5
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/dist/cli/up.js +17 -6
- package/dist/cli/up.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/up.js
CHANGED
|
@@ -135,16 +135,27 @@ function runServer(pm, transport2) {
|
|
|
135
135
|
if (!["stdio", "sse"].includes(transport2)) {
|
|
136
136
|
throw new Error(`Unsupported transport "${transport2}". Use stdio or sse.`);
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
const distEntry = path.join(projectRoot, "dist", "index.js");
|
|
139
|
+
const env = { ...process.env, MCP_TRANSPORT: transport2 };
|
|
140
|
+
if (!existsSync(distEntry)) {
|
|
141
|
+
console.log("dist/index.js not found. Building project before start...");
|
|
142
|
+
const buildResult = spawnSync(pm, ["run", "build"], {
|
|
143
|
+
cwd: projectRoot,
|
|
144
|
+
stdio: "inherit",
|
|
145
|
+
env
|
|
146
|
+
});
|
|
147
|
+
if (buildResult.status !== 0) {
|
|
148
|
+
throw new Error(`${pm} run build exited with code ${buildResult.status}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
console.log(`Starting ${transport2} transport via ${pm} run start...`);
|
|
152
|
+
const child = spawnSync(pm, ["run", "start"], {
|
|
142
153
|
cwd: projectRoot,
|
|
143
154
|
stdio: "inherit",
|
|
144
|
-
env
|
|
155
|
+
env
|
|
145
156
|
});
|
|
146
157
|
if (child.status !== 0) {
|
|
147
|
-
throw new Error(`${pm} run
|
|
158
|
+
throw new Error(`${pm} run start exited with code ${child.status}`);
|
|
148
159
|
}
|
|
149
160
|
}
|
|
150
161
|
//# sourceMappingURL=up.js.map
|
package/dist/cli/up.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/up.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { copyFileSync, existsSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(dirname, '../..');\n\nconst args = process.argv.slice(2);\nconst command = args[0];\n\nif (!command || command === '--help' || command === '-h') {\n printHelp();\n process.exit(0);\n}\n\nif (command !== 'up') {\n console.error(`Unknown command: ${command}`);\n printHelp();\n process.exit(1);\n}\n\nconst flags = parseFlags(args.slice(1));\nconst transport = (flags.transport ?? 'stdio').toLowerCase();\nconst installOnly = Boolean(flags['install-only']);\n\ntry {\n ensureNodeVersion();\n const packageManager = detectPackageManager();\n ensurePnpmConfig();\n installDependencies(packageManager);\n ensureEnvFile();\n\n if (installOnly) {\n console.log('Dependencies installed. Skipping server launch (--install-only set).');\n process.exit(0);\n }\n\n runServer(packageManager, transport);\n} catch (error) {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n}\n\nfunction printHelp() {\n console.log(`Usage: npx @hol-org/hashnet-mcp up [options]\\n\\nOptions:\\n --transport <stdio|sse> Choose the transport to start (default: stdio)\\n --install-only Install deps and sync .env, then exit\\n -h, --help Show this help message`);\n}\n\nfunction parseFlags(values: string[]) {\n const cloned = [...values];\n return cloned.reduce<Record<string, any>>((acc, entry, index) => {\n if (entry.startsWith('--')) {\n const [key, inlineValue] = entry.split('=');\n const normalized = key.replace(/^--/, '');\n if (inlineValue !== undefined) {\n acc[normalized] = inlineValue;\n } else {\n const next = cloned[index + 1];\n if (next && !next.startsWith('--')) {\n acc[normalized] = next;\n cloned.splice(index + 1, 1);\n } else {\n acc[normalized] = true;\n }\n }\n }\n return acc;\n }, {});\n}\n\nfunction ensureNodeVersion() {\n const major = Number(process.versions.node.split('.')[0]);\n if (Number.isNaN(major) || major < 18) {\n throw new Error(`Node.js 18+ is required (detected ${process.versions.node}).`);\n }\n}\n\nfunction detectPackageManager(): 'pnpm' | 'npm' {\n if (commandExists('pnpm')) {\n return 'pnpm';\n }\n\n console.warn('pnpm not detected. Attempting to enable via corepack...');\n const enabled = spawnSync('corepack', ['enable', 'pnpm'], { stdio: 'inherit' });\n if (enabled.status === 0 && commandExists('pnpm')) {\n return 'pnpm';\n }\n\n console.warn('Falling back to npm. Install pnpm globally for faster installs.');\n return 'npm';\n}\n\nfunction commandExists(bin: string) {\n try {\n const result = spawnSync(bin, ['--version'], { stdio: 'ignore' });\n return result.status === 0;\n } catch {\n return false;\n }\n}\n\nfunction installDependencies(pm: 'pnpm' | 'npm') {\n console.log(`Installing dependencies with ${pm}...`);\n const baseEnv = {\n ...process.env,\n NODE_OPTIONS: process.env.NODE_OPTIONS ?? '--max-old-space-size=8192',\n };\n\n const npmArgs = ['install', '--legacy-peer-deps'];\n\n const installResult = spawnSync(pm, pm === 'pnpm' ? ['install'] : npmArgs, {\n cwd: projectRoot,\n stdio: 'inherit',\n env: baseEnv,\n });\n if (installResult.status !== 0) {\n throw new Error(`${pm} install failed.`);\n }\n}\n\nfunction ensurePnpmConfig() {\n const npmrcPath = path.join(projectRoot, '.npmrc');\n if (existsSync(npmrcPath)) {\n return;\n }\n\n const content = [\n 'node-linker=isolated',\n 'shamefully-hoist=false',\n 'strict-peer-dependencies=false',\n 'auto-install-peers=false',\n 'resolution-mode=lowest-direct',\n 'node-options=--max-old-space-size=8192',\n 'child-concurrency=4',\n ].join('\\n');\n\n writeFileSync(npmrcPath, content);\n}\n\nfunction ensureEnvFile() {\n const envPath = path.join(projectRoot, '.env');\n const examplePath = path.join(projectRoot, '.env.example');\n if (!existsSync(envPath) && existsSync(examplePath)) {\n copyFileSync(examplePath, envPath);\n console.log('Created .env from .env.example. Remember to fill in your credentials.');\n }\n}\n\nfunction runServer(pm: 'pnpm' | 'npm', transport: string) {\n if (!['stdio', 'sse'].includes(transport)) {\n throw new Error(`Unsupported transport \"${transport}\". Use stdio or sse.`);\n }\n const
|
|
1
|
+
{"version":3,"sources":["../../src/cli/up.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { copyFileSync, existsSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(dirname, '../..');\n\nconst args = process.argv.slice(2);\nconst command = args[0];\n\nif (!command || command === '--help' || command === '-h') {\n printHelp();\n process.exit(0);\n}\n\nif (command !== 'up') {\n console.error(`Unknown command: ${command}`);\n printHelp();\n process.exit(1);\n}\n\nconst flags = parseFlags(args.slice(1));\nconst transport = (flags.transport ?? 'stdio').toLowerCase();\nconst installOnly = Boolean(flags['install-only']);\n\ntry {\n ensureNodeVersion();\n const packageManager = detectPackageManager();\n ensurePnpmConfig();\n installDependencies(packageManager);\n ensureEnvFile();\n\n if (installOnly) {\n console.log('Dependencies installed. Skipping server launch (--install-only set).');\n process.exit(0);\n }\n\n runServer(packageManager, transport);\n} catch (error) {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n}\n\nfunction printHelp() {\n console.log(`Usage: npx @hol-org/hashnet-mcp up [options]\\n\\nOptions:\\n --transport <stdio|sse> Choose the transport to start (default: stdio)\\n --install-only Install deps and sync .env, then exit\\n -h, --help Show this help message`);\n}\n\nfunction parseFlags(values: string[]) {\n const cloned = [...values];\n return cloned.reduce<Record<string, any>>((acc, entry, index) => {\n if (entry.startsWith('--')) {\n const [key, inlineValue] = entry.split('=');\n const normalized = key.replace(/^--/, '');\n if (inlineValue !== undefined) {\n acc[normalized] = inlineValue;\n } else {\n const next = cloned[index + 1];\n if (next && !next.startsWith('--')) {\n acc[normalized] = next;\n cloned.splice(index + 1, 1);\n } else {\n acc[normalized] = true;\n }\n }\n }\n return acc;\n }, {});\n}\n\nfunction ensureNodeVersion() {\n const major = Number(process.versions.node.split('.')[0]);\n if (Number.isNaN(major) || major < 18) {\n throw new Error(`Node.js 18+ is required (detected ${process.versions.node}).`);\n }\n}\n\nfunction detectPackageManager(): 'pnpm' | 'npm' {\n if (commandExists('pnpm')) {\n return 'pnpm';\n }\n\n console.warn('pnpm not detected. Attempting to enable via corepack...');\n const enabled = spawnSync('corepack', ['enable', 'pnpm'], { stdio: 'inherit' });\n if (enabled.status === 0 && commandExists('pnpm')) {\n return 'pnpm';\n }\n\n console.warn('Falling back to npm. Install pnpm globally for faster installs.');\n return 'npm';\n}\n\nfunction commandExists(bin: string) {\n try {\n const result = spawnSync(bin, ['--version'], { stdio: 'ignore' });\n return result.status === 0;\n } catch {\n return false;\n }\n}\n\nfunction installDependencies(pm: 'pnpm' | 'npm') {\n console.log(`Installing dependencies with ${pm}...`);\n const baseEnv = {\n ...process.env,\n NODE_OPTIONS: process.env.NODE_OPTIONS ?? '--max-old-space-size=8192',\n };\n\n const npmArgs = ['install', '--legacy-peer-deps'];\n\n const installResult = spawnSync(pm, pm === 'pnpm' ? ['install'] : npmArgs, {\n cwd: projectRoot,\n stdio: 'inherit',\n env: baseEnv,\n });\n if (installResult.status !== 0) {\n throw new Error(`${pm} install failed.`);\n }\n}\n\nfunction ensurePnpmConfig() {\n const npmrcPath = path.join(projectRoot, '.npmrc');\n if (existsSync(npmrcPath)) {\n return;\n }\n\n const content = [\n 'node-linker=isolated',\n 'shamefully-hoist=false',\n 'strict-peer-dependencies=false',\n 'auto-install-peers=false',\n 'resolution-mode=lowest-direct',\n 'node-options=--max-old-space-size=8192',\n 'child-concurrency=4',\n ].join('\\n');\n\n writeFileSync(npmrcPath, content);\n}\n\nfunction ensureEnvFile() {\n const envPath = path.join(projectRoot, '.env');\n const examplePath = path.join(projectRoot, '.env.example');\n if (!existsSync(envPath) && existsSync(examplePath)) {\n copyFileSync(examplePath, envPath);\n console.log('Created .env from .env.example. Remember to fill in your credentials.');\n }\n}\n\nfunction runServer(pm: 'pnpm' | 'npm', transport: string) {\n if (!['stdio', 'sse'].includes(transport)) {\n throw new Error(`Unsupported transport \"${transport}\". Use stdio or sse.`);\n }\n const distEntry = path.join(projectRoot, 'dist', 'index.js');\n const env = { ...process.env, MCP_TRANSPORT: transport };\n\n if (!existsSync(distEntry)) {\n console.log('dist/index.js not found. Building project before start...');\n const buildResult = spawnSync(pm, ['run', 'build'], {\n cwd: projectRoot,\n stdio: 'inherit',\n env,\n });\n if (buildResult.status !== 0) {\n throw new Error(`${pm} run build exited with code ${buildResult.status}`);\n }\n }\n\n console.log(`Starting ${transport} transport via ${pm} run start...`);\n const child = spawnSync(pm, ['run', 'start'], {\n cwd: projectRoot,\n stdio: 'inherit',\n env,\n });\n if (child.status !== 0) {\n throw new Error(`${pm} run start exited with code ${child.status}`);\n }\n}\n"],"mappings":";;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc,YAAY,qBAAqB;AACxD,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,IAAM,UAAU,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC3D,IAAM,cAAc,KAAK,QAAQ,SAAS,OAAO;AAEjD,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,UAAU,KAAK,CAAC;AAEtB,IAAI,CAAC,WAAW,YAAY,YAAY,YAAY,MAAM;AACxD,YAAU;AACV,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,YAAY,MAAM;AACpB,UAAQ,MAAM,oBAAoB,OAAO,EAAE;AAC3C,YAAU;AACV,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,QAAQ,WAAW,KAAK,MAAM,CAAC,CAAC;AACtC,IAAM,aAAa,MAAM,aAAa,SAAS,YAAY;AAC3D,IAAM,cAAc,QAAQ,MAAM,cAAc,CAAC;AAEjD,IAAI;AACF,oBAAkB;AAClB,QAAM,iBAAiB,qBAAqB;AAC5C,mBAAiB;AACjB,sBAAoB,cAAc;AAClC,gBAAc;AAEd,MAAI,aAAa;AACf,YAAQ,IAAI,sEAAsE;AAClF,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,YAAU,gBAAgB,SAAS;AACrC,SAAS,OAAO;AACd,UAAQ,MAAM,iBAAiB,QAA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