@cimplify/sdk 0.36.0 → 0.37.0
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/dispatcher.mjs +85 -0
- package/package.json +4 -2
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// src/dispatcher.ts
|
|
3
|
+
var HELP = `cimplify \u2014 Cimplify SDK CLI
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
bunx @cimplify/sdk Boot the local mock (alias for \`mock\`)
|
|
7
|
+
bunx @cimplify/sdk mock [flags] Boot the local Cimplify API mock
|
|
8
|
+
bunx @cimplify/sdk add <component> Install a UI component from the registry
|
|
9
|
+
bunx @cimplify/sdk list List available registry components
|
|
10
|
+
bunx @cimplify/sdk --help, -h Show this help
|
|
11
|
+
bunx @cimplify/sdk --version, -v Show SDK version
|
|
12
|
+
|
|
13
|
+
Mock flags:
|
|
14
|
+
--port <num> Port (default 8787)
|
|
15
|
+
--host <host> Host (default 127.0.0.1)
|
|
16
|
+
--seed <name> default | restaurant | retail | services | grocery | reesa-storefront | empty
|
|
17
|
+
--auth-mode <mode> permissive (default) | strict
|
|
18
|
+
--otp <code> Default OTP code (default 123456)
|
|
19
|
+
--persist <file> Persist state to JSON file
|
|
20
|
+
--cors <origins> CORS origins (comma-separated, or '*')
|
|
21
|
+
--webhook-url <url> Send mock events to this URL
|
|
22
|
+
--webhook-secret <key> HMAC secret for webhook signatures
|
|
23
|
+
--frozen-at <iso> Freeze clock at given ISO timestamp
|
|
24
|
+
--quiet Suppress request logs
|
|
25
|
+
`;
|
|
26
|
+
async function main() {
|
|
27
|
+
const [, , maybeSub, ...rest] = process.argv;
|
|
28
|
+
const TOP_LEVEL_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "help", "--version", "-v", "version"]);
|
|
29
|
+
if (maybeSub && TOP_LEVEL_FLAGS.has(maybeSub)) {
|
|
30
|
+
return await runDispatcherFlag(maybeSub);
|
|
31
|
+
}
|
|
32
|
+
const isFlag = (s) => s?.startsWith("-");
|
|
33
|
+
const sub = !maybeSub || isFlag(maybeSub) ? "mock" : maybeSub;
|
|
34
|
+
const args = !maybeSub || isFlag(maybeSub) ? process.argv.slice(2) : rest;
|
|
35
|
+
switch (sub) {
|
|
36
|
+
case "mock": {
|
|
37
|
+
process.argv = [process.argv[0], process.argv[1], ...args];
|
|
38
|
+
const { fileURLToPath } = await import('url');
|
|
39
|
+
const { dirname, join } = await import('path');
|
|
40
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
41
|
+
await import(join(here, "mock", "cli.mjs"));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
case "add":
|
|
45
|
+
case "list":
|
|
46
|
+
case "init": {
|
|
47
|
+
process.argv = [process.argv[0], process.argv[1], sub, ...args];
|
|
48
|
+
const { fileURLToPath } = await import('url');
|
|
49
|
+
const { dirname, join } = await import('path');
|
|
50
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
51
|
+
await import(join(here, "cli.js"));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
default:
|
|
55
|
+
console.error(`cimplify: unknown command "${sub}"`);
|
|
56
|
+
console.error(`Run \`bunx @cimplify/sdk --help\` for usage.`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function runDispatcherFlag(flag) {
|
|
61
|
+
if (flag === "-h" || flag === "--help" || flag === "help") {
|
|
62
|
+
console.log(HELP);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const { readFileSync } = await import('fs');
|
|
66
|
+
const { fileURLToPath } = await import('url');
|
|
67
|
+
const { dirname, join, resolve } = await import('path');
|
|
68
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
69
|
+
const candidates = [join(here, "..", "package.json"), join(here, "..", "..", "package.json"), resolve(here, "package.json")];
|
|
70
|
+
for (const path of candidates) {
|
|
71
|
+
try {
|
|
72
|
+
const pkg = JSON.parse(readFileSync(path, "utf8"));
|
|
73
|
+
if (pkg.name === "@cimplify/sdk" && pkg.version) {
|
|
74
|
+
console.log(pkg.version);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
console.log("unknown");
|
|
81
|
+
}
|
|
82
|
+
main().catch((err) => {
|
|
83
|
+
console.error("cimplify:", err);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cimplify/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Cimplify Commerce SDK for storefronts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cimplify",
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"bin": {
|
|
14
|
+
"sdk": "dist/dispatcher.mjs",
|
|
15
|
+
"cimplify": "dist/dispatcher.mjs",
|
|
14
16
|
"cimplify-sdk": "dist/cli.js",
|
|
15
|
-
"cimplify-mock": "dist/mock/cli.
|
|
17
|
+
"cimplify-mock": "dist/mock/cli.mjs"
|
|
16
18
|
},
|
|
17
19
|
"files": [
|
|
18
20
|
"dist",
|