create-solvapay 0.7.1 → 0.7.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.
@@ -221,6 +221,27 @@ to author the resulting src/tools/*.ts files.
221
221
  Docs: https://docs.solvapay.com
222
222
  `;
223
223
 
224
+ // src/package-root.ts
225
+ import { readFileSync } from "fs";
226
+ import { dirname, join } from "path";
227
+ import { fileURLToPath } from "url";
228
+ function resolvePackageRoot(startFile) {
229
+ let dir = dirname(startFile);
230
+ while (true) {
231
+ try {
232
+ const raw = readFileSync(join(dir, "package.json"), "utf8");
233
+ const pkg = JSON.parse(raw);
234
+ if (pkg.name === "create-solvapay") return dir;
235
+ } catch {
236
+ }
237
+ const parent = dirname(dir);
238
+ if (parent === dir) break;
239
+ dir = parent;
240
+ }
241
+ throw new Error("Could not locate create-solvapay package root");
242
+ }
243
+ var PACKAGE_ROOT = resolvePackageRoot(fileURLToPath(import.meta.url));
244
+
224
245
  export {
225
246
  parseArgs,
226
247
  parseMcpArgs,
@@ -230,5 +251,6 @@ export {
230
251
  sanitizeProjectName,
231
252
  validateToolName,
232
253
  HELP_TEXT,
233
- MCP_HELP_TEXT
254
+ MCP_HELP_TEXT,
255
+ PACKAGE_ROOT
234
256
  };
@@ -1,30 +1,16 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ PACKAGE_ROOT
4
+ } from "./chunk-65Y7HJFM.js";
2
5
 
3
6
  // src/types/mcp/scaffold.ts
4
7
  import { spawn } from "child_process";
5
- import { readFileSync } from "fs";
6
8
  import { mkdir, readdir, readFile, writeFile, copyFile, stat } from "fs/promises";
7
9
  import { dirname, join, relative } from "path";
8
- import { fileURLToPath } from "url";
9
- function resolvePackageRoot(startFile) {
10
- let dir = dirname(startFile);
11
- while (true) {
12
- const parent = dirname(dir);
13
- if (parent === dir) break;
14
- try {
15
- const raw = readFileSync(join(dir, "package.json"), "utf8");
16
- const pkg = JSON.parse(raw);
17
- if (pkg.name === "create-solvapay") return dir;
18
- } catch {
19
- }
20
- dir = parent;
21
- }
22
- throw new Error("Could not locate create-solvapay package root");
23
- }
24
- var PACKAGE_ROOT = resolvePackageRoot(fileURLToPath(import.meta.url));
25
10
  var BASE_TEMPLATE_DIR = join(PACKAGE_ROOT, "templates", "mcp", "_base");
26
11
  var FROM_OPENAPI_OVERLAY_DIR = join(PACKAGE_ROOT, "templates", "mcp", "from-openapi");
27
12
  var FROM_SCRATCH_OVERLAY_DIR = join(PACKAGE_ROOT, "templates", "mcp", "from-scratch");
13
+ var NEXT_AUTH0_TEMPLATE_DIR = join(PACKAGE_ROOT, "templates", "next-auth0");
28
14
  var SCAFFOLD_SCRIPT_PATH = join(PACKAGE_ROOT, "scripts", "mcp", "scaffold.mjs");
29
15
  var PLACEHOLDERS = Object.freeze({
30
16
  WORKER_NAME: "__WORKER_NAME__",
@@ -367,6 +353,7 @@ ${errorLines.slice(-10).join("\n")}` : ""}`
367
353
  export {
368
354
  BASE_TEMPLATE_DIR,
369
355
  FROM_SCRATCH_OVERLAY_DIR,
356
+ NEXT_AUTH0_TEMPLATE_DIR,
370
357
  SCAFFOLD_SCRIPT_PATH,
371
358
  PLACEHOLDERS,
372
359
  deriveServerName,
package/dist/cli.js CHANGED
@@ -2,11 +2,12 @@
2
2
  import {
3
3
  HELP_TEXT,
4
4
  MCP_HELP_TEXT,
5
+ PACKAGE_ROOT,
5
6
  hasMcpSpecificFlags,
6
7
  parseArgs,
7
8
  parseMcpArgs,
8
9
  sanitizeProjectName
9
- } from "./chunk-4LPTJYUF.js";
10
+ } from "./chunk-65Y7HJFM.js";
10
11
 
11
12
  // src/cli.ts
12
13
  import { resolve } from "path";
@@ -15,16 +16,16 @@ import { stdin, stdout } from "process";
15
16
 
16
17
  // src/types/registry.ts
17
18
  var PROJECT_TYPES = {
18
- mcp: () => import("./mcp-EZUBUZLF.js").then((m) => m.mcpProjectType),
19
- "next-auth0": () => import("./next-auth0-WNIMA6EQ.js").then((m) => m.nextAuth0ProjectType)
19
+ mcp: () => import("./mcp-LA3IJBRV.js").then((m) => m.mcpProjectType),
20
+ "next-auth0": () => import("./next-auth0-2LGN43K2.js").then((m) => m.nextAuth0ProjectType)
20
21
  // cli: () => import('./cli/index.js').then(m => m.cliProjectType), // future
21
22
  };
22
23
  var PROJECT_TYPE_IDS = Object.keys(PROJECT_TYPES);
23
24
 
24
25
  // src/version-banner.ts
25
- import { createRequire } from "module";
26
- var require2 = createRequire(import.meta.url);
27
- var pkg = require2("../package.json");
26
+ import { readFileSync } from "fs";
27
+ import { join } from "path";
28
+ var pkg = JSON.parse(readFileSync(join(PACKAGE_ROOT, "package.json"), "utf8"));
28
29
  var PACKAGE_VERSION = pkg.version;
29
30
  var printVersionBanner = () => {
30
31
  const isTTY = process.stdout.isTTY;
@@ -15,16 +15,17 @@ import {
15
15
  printConnectionSnippets,
16
16
  resolveLatestSolvapayVersions,
17
17
  writeBootstrapEnv
18
- } from "./chunk-W4KM7GUB.js";
18
+ } from "./chunk-BNZIRZOQ.js";
19
19
  import {
20
20
  MCP_HELP_TEXT,
21
21
  inferMcpMode,
22
22
  parseMcpArgs,
23
23
  toInitOptions,
24
24
  validateToolName
25
- } from "./chunk-4LPTJYUF.js";
25
+ } from "./chunk-65Y7HJFM.js";
26
26
 
27
27
  // src/types/mcp/index.ts
28
+ import { resolve } from "path";
28
29
  import readline2 from "readline/promises";
29
30
  import { stdin as stdin2, stdout as stdout2 } from "process";
30
31
 
@@ -310,7 +311,7 @@ async function ensureScriptDepsInstalled() {
310
311
  } catch {
311
312
  }
312
313
  process.stdout.write("\u{1F4E6} Installing scaffolder helpers (one-time)\u2026\n");
313
- await new Promise((resolve, reject) => {
314
+ await new Promise((resolve2, reject) => {
314
315
  const child = spawn("npm", ["install", "--no-audit", "--no-fund", "--silent"], {
315
316
  cwd: scriptsDir,
316
317
  stdio: "inherit",
@@ -318,7 +319,7 @@ async function ensureScriptDepsInstalled() {
318
319
  });
319
320
  child.once("error", reject);
320
321
  child.once("close", (code) => {
321
- if (code === 0) resolve();
322
+ if (code === 0) resolve2();
322
323
  else reject(new Error(`npm install for scripts/ exited with code ${code}`));
323
324
  });
324
325
  });
@@ -328,7 +329,7 @@ async function runScriptCaptureJson(argv) {
328
329
  const [scriptName, ...rest] = argv;
329
330
  const scriptsDir = join(SCAFFOLD_SCRIPT_PATH, "..");
330
331
  const scriptPath = join(scriptsDir, scriptName);
331
- return new Promise((resolve, reject) => {
332
+ return new Promise((resolve2, reject) => {
332
333
  const child = spawn(process.execPath, [scriptPath, ...rest], {
333
334
  cwd: scriptsDir,
334
335
  stdio: ["ignore", "pipe", "pipe"]
@@ -349,7 +350,7 @@ async function runScriptCaptureJson(argv) {
349
350
  }
350
351
  try {
351
352
  const parsed = JSON.parse(stdoutBuf);
352
- resolve(parsed);
353
+ resolve2(parsed);
353
354
  } catch (err) {
354
355
  const message = err instanceof Error ? err.message : "unknown error";
355
356
  reject(
@@ -368,14 +369,14 @@ async function runScript(argv) {
368
369
  const [scriptName, ...rest] = argv;
369
370
  const scriptsDir = join(SCAFFOLD_SCRIPT_PATH, "..");
370
371
  const scriptPath = join(scriptsDir, scriptName);
371
- await new Promise((resolve, reject) => {
372
+ await new Promise((resolve2, reject) => {
372
373
  const child = spawn(process.execPath, [scriptPath, ...rest], {
373
374
  cwd: scriptsDir,
374
375
  stdio: ["ignore", "inherit", "inherit"]
375
376
  });
376
377
  child.once("error", reject);
377
378
  child.once("close", (code) => {
378
- if (code === 0) resolve();
379
+ if (code === 0) resolve2();
379
380
  else reject(new Error(`${scriptName} exited with code ${code}`));
380
381
  });
381
382
  });
@@ -520,7 +521,7 @@ ${MCP_HELP_TEXT}`
520
521
  });
521
522
  }
522
523
  async function resolveOpenapiSpec(value, nonInteractive) {
523
- if (value && value.trim()) return value.trim();
524
+ if (value && value.trim()) return resolveSpecLocation(value.trim());
524
525
  if (nonInteractive) {
525
526
  throw new Error("--openapi <url|path> is required in non-interactive from-openapi mode.");
526
527
  }
@@ -532,7 +533,11 @@ async function resolveOpenapiSpec(value, nonInteractive) {
532
533
  if (!trimmed) {
533
534
  throw new Error("No spec provided.");
534
535
  }
535
- return trimmed;
536
+ return resolveSpecLocation(trimmed);
537
+ }
538
+ function resolveSpecLocation(value) {
539
+ if (isAbsoluteHttpUrl(value)) return value;
540
+ return resolve(process.cwd(), value);
536
541
  }
537
542
  async function resolveToolName(value, nonInteractive) {
538
543
  if (value) {
@@ -568,5 +573,6 @@ async function askYesNo(prompt, defaultYes) {
568
573
  }
569
574
  }
570
575
  export {
571
- mcpProjectType
576
+ mcpProjectType,
577
+ resolveSpecLocation
572
578
  };
@@ -1,19 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ NEXT_AUTH0_TEMPLATE_DIR,
3
4
  assertTargetDirAbsent,
4
5
  copyDir,
5
6
  gitInit,
6
7
  installProjectDependencies
7
- } from "./chunk-W4KM7GUB.js";
8
+ } from "./chunk-BNZIRZOQ.js";
8
9
  import {
9
10
  toInitOptions
10
- } from "./chunk-4LPTJYUF.js";
11
+ } from "./chunk-65Y7HJFM.js";
11
12
 
12
13
  // src/types/next-auth0/index.ts
13
14
  import { detectPackageManager, runInitInDirectory } from "@solvapay/init";
14
- import { fileURLToPath } from "url";
15
- import { join } from "path";
16
- var NEXT_AUTH0_TEMPLATE_DIR = join(fileURLToPath(new URL("../../../templates/next-auth0", import.meta.url)));
17
15
  var parseNextAuth0Args = () => ({
18
16
  noOpenapi: false,
19
17
  help: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-solvapay",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Scaffold SolvaPay-monetized projects — MCP servers on Cloudflare Workers and more.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,10 +3,11 @@
3
3
  * Shared OpenAPI utilities for `create-solvapay/types/mcp/from-openapi`.
4
4
  *
5
5
  * Used by `describe.mjs`, `scaffold.mjs`, and `test.mjs`. Every script
6
- * re-parses the spec from disk; no cached state across modules.
6
+ * re-parses the spec from the given path or URL; no cached state across
7
+ * modules.
7
8
  *
8
9
  * Public surface:
9
- * - loadSpec(specPath) -> { spec, format }
10
+ * - loadSpec(specPath) -> { spec }
10
11
  * - listOperations(spec) -> Operation[]
11
12
  * - resolveSecuritySchemes(spec) -> ResolvedScheme[]
12
13
  * - suggestTier(operation) -> 'free' | 'paid' | 'skip'
@@ -18,7 +19,7 @@
18
19
  * pulled on demand via `npx --package @apidevtools/swagger-parser`.
19
20
  */
20
21
 
21
- import { readFile } from 'node:fs/promises'
22
+ import { access } from 'node:fs/promises'
22
23
  import { resolve } from 'node:path'
23
24
 
24
25
  const SUPPORTED_AUTH_KINDS = new Set([
@@ -31,19 +32,39 @@ const SUPPORTED_AUTH_KINDS = new Set([
31
32
  const MUTATING_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE'])
32
33
 
33
34
  /**
34
- * Load + parse an OpenAPI document from disk and run `$ref` resolution
35
- * through swagger-parser's `dereference`. Accepts JSON or YAML.
35
+ * Load + parse an OpenAPI document and run `$ref` resolution through
36
+ * swagger-parser's `dereference`. Accepts a local JSON/YAML path or an
37
+ * http(s) URL to the raw document (not a Swagger UI / docs page).
36
38
  *
37
39
  * Returns the fully-dereferenced spec so downstream callers never have
38
40
  * to think about `$ref` lookup.
39
41
  */
40
42
  export async function loadSpec(specPath) {
41
- const absolute = resolve(specPath)
42
43
  const SwaggerParser = await loadSwaggerParser()
43
- const raw = await readFile(absolute, 'utf8')
44
- const format = absolute.endsWith('.yaml') || absolute.endsWith('.yml') ? 'yaml' : 'json'
44
+ if (/^https?:\/\//i.test(specPath)) {
45
+ try {
46
+ const spec = await SwaggerParser.dereference(specPath)
47
+ return { spec }
48
+ } catch (err) {
49
+ const message = err instanceof Error ? err.message : String(err)
50
+ throw new Error(
51
+ `Could not load OpenAPI spec from ${specPath}: ${message}. ` +
52
+ 'Point at the raw JSON/YAML document (e.g. .../swagger.json or .../openapi.yaml), not a docs/Swagger UI page.',
53
+ )
54
+ }
55
+ }
56
+
57
+ const absolute = resolve(specPath)
58
+ try {
59
+ await access(absolute)
60
+ } catch (err) {
61
+ if (err && typeof err === 'object' && err.code === 'ENOENT') {
62
+ throw new Error(`Spec file not found: ${absolute}`)
63
+ }
64
+ throw err
65
+ }
45
66
  const spec = await SwaggerParser.dereference(absolute)
46
- return { spec, format, raw }
67
+ return { spec }
47
68
  }
48
69
 
49
70
  /**