@porulle/cli 0.63.0 → 0.65.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/README.md +0 -3
- package/dist/commands/channel-backfill.d.ts.map +1 -1
- package/dist/commands/channel-backfill.js +3 -18
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +9 -25
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/commands/import.js +3 -29
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -5
- package/dist/index.js +3 -11
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +54 -0
- package/package.json +4 -4
- package/dist/commands/deploy.d.ts +0 -13
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js +0 -45
- package/dist/commands/generate-migration.d.ts +0 -2
- package/dist/commands/generate-migration.d.ts.map +0 -1
- package/dist/commands/generate-migration.js +0 -20
- package/dist/commands/migrate.d.ts +0 -2
- package/dist/commands/migrate.d.ts.map +0 -1
- package/dist/commands/migrate.js +0 -20
package/README.md
CHANGED
|
@@ -8,9 +8,6 @@ The command-line tool. Scaffolds new stores, runs migrations, mints API keys, do
|
|
|
8
8
|
|---|---|
|
|
9
9
|
| `porulle init <name>` | scaffold a new store from `templates/starter/` — `commerce.config.ts`, `drizzle.config.ts`, server entry, package.json wired to `@porulle/*` workspace deps |
|
|
10
10
|
| `porulle dev` | start the example server with reload (delegates to the app's own `dev` script when present) |
|
|
11
|
-
| `porulle migrate` | apply pending Drizzle migrations against `DATABASE_URL` |
|
|
12
|
-
| `porulle generate migration` | drizzle-kit generate — produce a new SQL migration from schema diffs |
|
|
13
|
-
| `porulle deploy` | thin wrapper around the app's deploy script |
|
|
14
11
|
| `porulle import <file>` | run an import adapter (Shopify CSV, WooCommerce XML, flat JSON) |
|
|
15
12
|
| `porulle api-key create --scope <scope>` | mint an API key with the given permission scope (replaces the deprecated `auth.devKey`) |
|
|
16
13
|
| `porulle doctor` | environment + config sanity check |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-backfill.d.ts","sourceRoot":"","sources":["../../src/commands/channel-backfill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channel-backfill.d.ts","sourceRoot":"","sources":["../../src/commands/channel-backfill.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;EAgDjC,CAAC"}
|
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
2
|
import consola from "consola";
|
|
3
|
-
|
|
4
|
-
return (raw ?? "http://localhost:3000").replace(/\/$/, "");
|
|
5
|
-
}
|
|
6
|
-
async function requestBackfill(url, storeId, dryRun, restart, token) {
|
|
7
|
-
const response = await fetch(`${url}/api/channels/stores/${encodeURIComponent(storeId)}/backfill`, {
|
|
8
|
-
method: "POST",
|
|
9
|
-
headers: {
|
|
10
|
-
"content-type": "application/json",
|
|
11
|
-
...(token ? { authorization: `Bearer ${token}` } : {}),
|
|
12
|
-
},
|
|
13
|
-
body: JSON.stringify({ dryRun, ...(restart ? { restart: true } : {}) }),
|
|
14
|
-
});
|
|
15
|
-
const payload = (await response.json().catch(() => ({})));
|
|
16
|
-
if (!response.ok || !payload.data)
|
|
17
|
-
throw new Error(payload.error?.message ?? `Backfill request failed (${response.status}).`);
|
|
18
|
-
return payload.data;
|
|
19
|
-
}
|
|
3
|
+
import { apiBaseUrl, requestJson } from "../utils.js";
|
|
20
4
|
export const channelBackfillCommand = defineCommand({
|
|
21
5
|
meta: {
|
|
22
6
|
name: "channel:backfill",
|
|
@@ -50,7 +34,8 @@ export const channelBackfillCommand = defineCommand({
|
|
|
50
34
|
},
|
|
51
35
|
async run({ args }) {
|
|
52
36
|
const dryRun = args["dry-run"] === true;
|
|
53
|
-
const
|
|
37
|
+
const url = apiBaseUrl(args.targetUrl ? String(args.targetUrl) : undefined);
|
|
38
|
+
const report = await requestJson(url, `/api/channels/stores/${encodeURIComponent(String(args.store))}/backfill`, "POST", { dryRun, ...(args.restart === true ? { restart: true } : {}) }, args.authToken ? String(args.authToken) : undefined);
|
|
54
39
|
if (dryRun) {
|
|
55
40
|
consola.success(`Channel catalog backfill dry run for ${String(args.store)}.`);
|
|
56
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAgBA,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAuB1D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM/D;AA4BD,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAgBA,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAuB1D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM/D;AA4BD,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChB;AAED,eAAO,MAAM,UAAU;;;;;EAuCrB,CAAC"}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
2
|
import { dirname, join } from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import { defineCommand } from "citty";
|
|
6
5
|
import consola from "consola";
|
|
7
6
|
import postgres from "postgres";
|
|
7
|
+
import { npxCommand, runProcess } from "../utils.js";
|
|
8
8
|
const DRIZZLE_CONFIG_CANDIDATES = [
|
|
9
9
|
"drizzle.config.ts",
|
|
10
10
|
"drizzle.config.mjs",
|
|
@@ -82,17 +82,7 @@ export async function runDrizzleKitPush(cwd, env) {
|
|
|
82
82
|
}
|
|
83
83
|
const configPath = join(cwd, configName);
|
|
84
84
|
const spawnCwd = spawnCwdForDrizzleKit(cwd);
|
|
85
|
-
await
|
|
86
|
-
const proc = spawn(process.platform === "win32" ? "npx.cmd" : "npx", ["drizzle-kit", "push", "--force", "--config", configPath], { cwd: spawnCwd, stdio: "inherit", shell: false, env });
|
|
87
|
-
proc.on("exit", (code) => {
|
|
88
|
-
if (code === 0)
|
|
89
|
-
resolvePromise();
|
|
90
|
-
else {
|
|
91
|
-
rejectPromise(new Error(`drizzle-kit push exited with code ${code ?? "unknown"}`));
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
proc.on("error", rejectPromise);
|
|
95
|
-
});
|
|
85
|
+
await runProcess(npxCommand(), ["drizzle-kit", "push", "--force", "--config", configPath], { cwd: spawnCwd, env });
|
|
96
86
|
}
|
|
97
87
|
export async function maybeBootstrapDevDatabase(options) {
|
|
98
88
|
if (options.nodeEnv === "production")
|
|
@@ -156,18 +146,12 @@ export const devCommand = defineCommand({
|
|
|
156
146
|
consola.error("Try `bun run db:push` manually or check your DATABASE_URL.");
|
|
157
147
|
process.exit(1);
|
|
158
148
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
resolvePromise();
|
|
167
|
-
else
|
|
168
|
-
rejectPromise(new Error(`dev exited with code ${code}`));
|
|
169
|
-
});
|
|
170
|
-
proc.on("error", rejectPromise);
|
|
171
|
-
});
|
|
149
|
+
await runProcess(npxCommand(), [
|
|
150
|
+
"tsx",
|
|
151
|
+
"watch",
|
|
152
|
+
"src/dev-server.ts",
|
|
153
|
+
"--port",
|
|
154
|
+
port,
|
|
155
|
+
]);
|
|
172
156
|
},
|
|
173
157
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAoIA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuLxB,CAAC"}
|
package/dist/commands/import.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { extname, resolve } from "node:path";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
import consola from "consola";
|
|
5
|
+
import { apiBaseUrl, bearerHeaders, requestJson } from "../utils.js";
|
|
5
6
|
/**
|
|
6
7
|
* The import adapters (`@porulle/import-flat`, `@porulle/import-shopify`,
|
|
7
8
|
* `@porulle/import-woocommerce`) are optional dependencies, loaded on demand
|
|
@@ -23,33 +24,6 @@ async function loadImporter(pkg, named) {
|
|
|
23
24
|
}
|
|
24
25
|
return fn;
|
|
25
26
|
}
|
|
26
|
-
function toBaseUrl(raw) {
|
|
27
|
-
return (raw ?? "http://localhost:3000").replace(/\/$/, "");
|
|
28
|
-
}
|
|
29
|
-
function toHeaders(token) {
|
|
30
|
-
if (!token)
|
|
31
|
-
return {};
|
|
32
|
-
return { authorization: `Bearer ${token}` };
|
|
33
|
-
}
|
|
34
|
-
async function requestJson(baseUrl, path, method, body, token) {
|
|
35
|
-
const response = await fetch(`${baseUrl}${path}`, {
|
|
36
|
-
method,
|
|
37
|
-
headers: {
|
|
38
|
-
"content-type": "application/json",
|
|
39
|
-
...toHeaders(token),
|
|
40
|
-
},
|
|
41
|
-
body: JSON.stringify(body),
|
|
42
|
-
});
|
|
43
|
-
const payload = (await response.json().catch(() => ({})));
|
|
44
|
-
if (!response.ok) {
|
|
45
|
-
const message = payload.error?.message ?? `HTTP ${response.status}`;
|
|
46
|
-
throw new Error(`Request failed for ${method} ${path}: ${message}`);
|
|
47
|
-
}
|
|
48
|
-
if (payload.data === undefined) {
|
|
49
|
-
throw new Error(`Expected data payload for ${method} ${path}.`);
|
|
50
|
-
}
|
|
51
|
-
return payload.data;
|
|
52
|
-
}
|
|
53
27
|
function createRestImportTarget(baseUrl, token) {
|
|
54
28
|
return {
|
|
55
29
|
async createEntity(input) {
|
|
@@ -74,7 +48,7 @@ function createRestImportTarget(baseUrl, token) {
|
|
|
74
48
|
const response = await fetch(`${baseUrl}/api/media/upload`, {
|
|
75
49
|
method: "POST",
|
|
76
50
|
headers: {
|
|
77
|
-
...
|
|
51
|
+
...bearerHeaders(token),
|
|
78
52
|
},
|
|
79
53
|
body: form,
|
|
80
54
|
});
|
|
@@ -145,7 +119,7 @@ export const importCommand = defineCommand({
|
|
|
145
119
|
},
|
|
146
120
|
async run({ args }) {
|
|
147
121
|
const source = String(args.source).toLowerCase();
|
|
148
|
-
const baseUrl =
|
|
122
|
+
const baseUrl = apiBaseUrl(args.targetUrl ? String(args.targetUrl) : undefined);
|
|
149
123
|
const token = args.authToken ? String(args.authToken) : undefined;
|
|
150
124
|
const target = createRestImportTarget(baseUrl, token);
|
|
151
125
|
if (source === "shopify") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAUA,UAAU,gBAAgB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAaD,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,MAAM,GACd,IAAI,CAWN;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAUA,UAAU,gBAAgB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAaD,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,MAAM,GACd,IAAI,CAWN;AAED,eAAO,MAAM,WAAW;;;;;;;;;;EAmDtB,CAAC"}
|
package/dist/commands/init.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { downloadTemplate } from "giget";
|
|
7
|
-
import { copyDir, readJson, writeJson } from "../utils.js";
|
|
7
|
+
import { copyDir, readCliVersion, readJson, writeJson } from "../utils.js";
|
|
8
8
|
const currentDir = fileURLToPath(new URL(".", import.meta.url));
|
|
9
9
|
const DEP_SECTIONS = [
|
|
10
10
|
"dependencies",
|
|
@@ -29,10 +29,6 @@ export function pinPorulleDependencies(pkg, version) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async function readCliVersion() {
|
|
33
|
-
const pkg = await readJson(resolve(currentDir, "../../package.json"));
|
|
34
|
-
return pkg.version;
|
|
35
|
-
}
|
|
36
32
|
export const initCommand = defineCommand({
|
|
37
33
|
meta: {
|
|
38
34
|
name: "init",
|
package/dist/index.js
CHANGED
|
@@ -2,33 +2,25 @@
|
|
|
2
2
|
import { defineCommand, runMain } from "citty";
|
|
3
3
|
import { initCommand } from "./commands/init.js";
|
|
4
4
|
import { devCommand } from "./commands/dev.js";
|
|
5
|
-
import { generateMigrationCommand } from "./commands/generate-migration.js";
|
|
6
|
-
import { migrateCommand } from "./commands/migrate.js";
|
|
7
|
-
import { deployCommand } from "./commands/deploy.js";
|
|
8
5
|
import { importCommand } from "./commands/import.js";
|
|
9
6
|
import { apiKeyCommand } from "./commands/api-key.js";
|
|
10
7
|
import { doctorCommand } from "./commands/doctor.js";
|
|
11
8
|
import { channelBackfillCommand } from "./commands/channel-backfill.js";
|
|
9
|
+
import { readCliVersion } from "./utils.js";
|
|
10
|
+
const cliVersion = await readCliVersion();
|
|
12
11
|
const main = defineCommand({
|
|
13
12
|
meta: {
|
|
14
13
|
name: "@porulle/cli",
|
|
15
|
-
version: "0.
|
|
14
|
+
version: cliVersion ?? "0.0.0",
|
|
16
15
|
description: "UnifiedCommerce Engine CLI",
|
|
17
16
|
},
|
|
18
17
|
subCommands: {
|
|
19
18
|
init: initCommand,
|
|
20
19
|
dev: devCommand,
|
|
21
|
-
migrate: migrateCommand,
|
|
22
|
-
deploy: deployCommand,
|
|
23
20
|
import: importCommand,
|
|
24
21
|
"api-key": apiKeyCommand,
|
|
25
22
|
doctor: doctorCommand,
|
|
26
23
|
"channel:backfill": channelBackfillCommand,
|
|
27
|
-
generate: defineCommand({
|
|
28
|
-
subCommands: {
|
|
29
|
-
migration: generateMigrationCommand,
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
24
|
},
|
|
33
25
|
});
|
|
34
26
|
await runMain(main);
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,4 +2,13 @@ export declare function copyDir(src: string, dest: string): Promise<void>;
|
|
|
2
2
|
export declare function writeJson(path: string, value: unknown): Promise<void>;
|
|
3
3
|
export declare function readJson<T>(path: string): Promise<T>;
|
|
4
4
|
export declare function resolveFromCwd(path: string): string;
|
|
5
|
+
export declare function readCliVersion(): Promise<string | undefined>;
|
|
6
|
+
export declare function npxCommand(): string;
|
|
7
|
+
export declare function runProcess(command: string, args: string[], options?: {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
export declare function apiBaseUrl(raw: string | undefined): string;
|
|
12
|
+
export declare function bearerHeaders(token?: string): Record<string, string>;
|
|
13
|
+
export declare function requestJson<T>(baseUrl: string, path: string, method: "GET" | "POST" | "PATCH" | "DELETE", body: unknown, token?: string): Promise<T>;
|
|
5
14
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAOA,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtE;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAG3E;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAG1D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAOD,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAGlE;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,GAClD,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE1D;AAED,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGpE;AAED,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAC3C,IAAI,EAAE,OAAO,EACb,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
1
2
|
import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
3
|
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
const cliPackageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
3
6
|
export async function copyDir(src, dest) {
|
|
4
7
|
await mkdir(dest, { recursive: true });
|
|
5
8
|
await cp(src, dest, { recursive: true, force: true });
|
|
@@ -15,3 +18,54 @@ export async function readJson(path) {
|
|
|
15
18
|
export function resolveFromCwd(path) {
|
|
16
19
|
return resolve(process.cwd(), path);
|
|
17
20
|
}
|
|
21
|
+
export async function readCliVersion() {
|
|
22
|
+
const pkg = await readJson(resolve(cliPackageRoot, "package.json"));
|
|
23
|
+
return pkg.version;
|
|
24
|
+
}
|
|
25
|
+
export function npxCommand() {
|
|
26
|
+
return process.platform === "win32" ? "npx.cmd" : "npx";
|
|
27
|
+
}
|
|
28
|
+
export function runProcess(command, args, options) {
|
|
29
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
30
|
+
const proc = spawn(command, args, {
|
|
31
|
+
stdio: "inherit",
|
|
32
|
+
shell: false,
|
|
33
|
+
...options,
|
|
34
|
+
});
|
|
35
|
+
proc.on("exit", (code) => {
|
|
36
|
+
if (code === 0)
|
|
37
|
+
resolvePromise();
|
|
38
|
+
else {
|
|
39
|
+
rejectPromise(new Error(`${command} ${args.join(" ")} exited with code ${code ?? "unknown"}`));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
proc.on("error", rejectPromise);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export function apiBaseUrl(raw) {
|
|
46
|
+
return (raw ?? "http://localhost:3000").replace(/\/$/, "");
|
|
47
|
+
}
|
|
48
|
+
export function bearerHeaders(token) {
|
|
49
|
+
if (!token)
|
|
50
|
+
return {};
|
|
51
|
+
return { authorization: `Bearer ${token}` };
|
|
52
|
+
}
|
|
53
|
+
export async function requestJson(baseUrl, path, method, body, token) {
|
|
54
|
+
const response = await fetch(`${baseUrl}${path}`, {
|
|
55
|
+
method,
|
|
56
|
+
headers: {
|
|
57
|
+
"content-type": "application/json",
|
|
58
|
+
...bearerHeaders(token),
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify(body),
|
|
61
|
+
});
|
|
62
|
+
const payload = (await response.json().catch(() => ({})));
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
const message = payload.error?.message ?? `HTTP ${response.status}`;
|
|
65
|
+
throw new Error(`Request failed for ${method} ${path}: ${message}`);
|
|
66
|
+
}
|
|
67
|
+
if (payload.data === undefined) {
|
|
68
|
+
throw new Error(`Expected data payload for ${method} ${path}.`);
|
|
69
|
+
}
|
|
70
|
+
return payload.data;
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porulle/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"giget": "^2.0.0"
|
|
15
15
|
},
|
|
16
16
|
"optionalDependencies": {
|
|
17
|
-
"@porulle/import-
|
|
18
|
-
"@porulle/import-
|
|
19
|
-
"@porulle/import-
|
|
17
|
+
"@porulle/import-flat": "0.65.0",
|
|
18
|
+
"@porulle/import-shopify": "0.65.0",
|
|
19
|
+
"@porulle/import-woocommerce": "0.65.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@electric-sql/pglite": "0.4.5",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const deployCommand: import("citty").CommandDef<{
|
|
2
|
-
target: {
|
|
3
|
-
type: "string";
|
|
4
|
-
required: true;
|
|
5
|
-
description: string;
|
|
6
|
-
};
|
|
7
|
-
prod: {
|
|
8
|
-
type: "boolean";
|
|
9
|
-
default: false;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
13
|
-
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;;;;;;;;;;;EA4CxB,CAAC"}
|
package/dist/commands/deploy.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { defineCommand } from "citty";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
export const deployCommand = defineCommand({
|
|
5
|
-
meta: {
|
|
6
|
-
name: "deploy",
|
|
7
|
-
description: "Deploy UnifiedCommerce app to a target environment.",
|
|
8
|
-
},
|
|
9
|
-
args: {
|
|
10
|
-
target: {
|
|
11
|
-
type: "string",
|
|
12
|
-
required: true,
|
|
13
|
-
description: "Deployment target. Supported: vercel",
|
|
14
|
-
},
|
|
15
|
-
prod: {
|
|
16
|
-
type: "boolean",
|
|
17
|
-
default: false,
|
|
18
|
-
description: "Deploy production build",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
async run({ args }) {
|
|
22
|
-
const target = String(args.target).toLowerCase();
|
|
23
|
-
if (target !== "vercel") {
|
|
24
|
-
throw new Error(`Unsupported deploy target: ${target}. Currently supported: vercel.`);
|
|
25
|
-
}
|
|
26
|
-
const command = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
27
|
-
const deployArgs = ["vercel", "deploy"];
|
|
28
|
-
if (args.prod)
|
|
29
|
-
deployArgs.push("--prod");
|
|
30
|
-
consola.info(`Running deploy for target=${target} (${deployArgs.join(" ")})`);
|
|
31
|
-
await new Promise((resolvePromise, rejectPromise) => {
|
|
32
|
-
const proc = spawn(command, deployArgs, {
|
|
33
|
-
stdio: "inherit",
|
|
34
|
-
shell: false,
|
|
35
|
-
});
|
|
36
|
-
proc.on("exit", (code) => {
|
|
37
|
-
if (code === 0)
|
|
38
|
-
resolvePromise();
|
|
39
|
-
else
|
|
40
|
-
rejectPromise(new Error(`Deploy command failed with code ${code}`));
|
|
41
|
-
});
|
|
42
|
-
proc.on("error", rejectPromise);
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-migration.d.ts","sourceRoot":"","sources":["../../src/commands/generate-migration.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,qDAmBnC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { defineCommand } from "citty";
|
|
3
|
-
export const generateMigrationCommand = defineCommand({
|
|
4
|
-
meta: {
|
|
5
|
-
name: "generate migration",
|
|
6
|
-
description: "Generate Drizzle migration",
|
|
7
|
-
},
|
|
8
|
-
async run() {
|
|
9
|
-
await new Promise((resolvePromise, rejectPromise) => {
|
|
10
|
-
const proc = spawn(process.platform === "win32" ? "npx.cmd" : "npx", ["drizzle-kit", "generate"], { stdio: "inherit" });
|
|
11
|
-
proc.on("exit", (code) => {
|
|
12
|
-
if (code === 0)
|
|
13
|
-
resolvePromise();
|
|
14
|
-
else
|
|
15
|
-
rejectPromise(new Error(`drizzle-kit generate failed with code ${code}`));
|
|
16
|
-
});
|
|
17
|
-
proc.on("error", rejectPromise);
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,qDAmBzB,CAAC"}
|
package/dist/commands/migrate.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { defineCommand } from "citty";
|
|
3
|
-
export const migrateCommand = defineCommand({
|
|
4
|
-
meta: {
|
|
5
|
-
name: "migrate",
|
|
6
|
-
description: "Apply Drizzle migrations",
|
|
7
|
-
},
|
|
8
|
-
async run() {
|
|
9
|
-
await new Promise((resolvePromise, rejectPromise) => {
|
|
10
|
-
const proc = spawn(process.platform === "win32" ? "npx.cmd" : "npx", ["drizzle-kit", "migrate"], { stdio: "inherit" });
|
|
11
|
-
proc.on("exit", (code) => {
|
|
12
|
-
if (code === 0)
|
|
13
|
-
resolvePromise();
|
|
14
|
-
else
|
|
15
|
-
rejectPromise(new Error(`drizzle-kit migrate failed with code ${code}`));
|
|
16
|
-
});
|
|
17
|
-
proc.on("error", rejectPromise);
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
});
|