@porulle/cli 0.10.8 → 0.11.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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const channelBackfillCommand: import("citty").CommandDef<{
|
|
2
|
+
store: {
|
|
3
|
+
type: "string";
|
|
4
|
+
required: true;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
"dry-run": {
|
|
8
|
+
type: "boolean";
|
|
9
|
+
default: false;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
restart: {
|
|
13
|
+
type: "boolean";
|
|
14
|
+
default: false;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
targetUrl: {
|
|
18
|
+
type: "string";
|
|
19
|
+
default: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
authToken: {
|
|
23
|
+
type: "string";
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=channel-backfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-backfill.d.ts","sourceRoot":"","sources":["../../src/commands/channel-backfill.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;EA+CjC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import consola from "consola";
|
|
3
|
+
function baseUrl(raw) {
|
|
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
|
+
}
|
|
20
|
+
export const channelBackfillCommand = defineCommand({
|
|
21
|
+
meta: {
|
|
22
|
+
name: "channel:backfill",
|
|
23
|
+
description: "Backfill an already-imported channel catalog into the PIM.",
|
|
24
|
+
},
|
|
25
|
+
args: {
|
|
26
|
+
store: {
|
|
27
|
+
type: "string",
|
|
28
|
+
required: true,
|
|
29
|
+
description: "Connected store id",
|
|
30
|
+
},
|
|
31
|
+
"dry-run": {
|
|
32
|
+
type: "boolean",
|
|
33
|
+
default: false,
|
|
34
|
+
description: "Report changes without writing",
|
|
35
|
+
},
|
|
36
|
+
restart: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
default: false,
|
|
39
|
+
description: "Discard the persisted backfill cursor and start over",
|
|
40
|
+
},
|
|
41
|
+
targetUrl: {
|
|
42
|
+
type: "string",
|
|
43
|
+
default: "http://localhost:3000",
|
|
44
|
+
description: "UnifiedCommerce API base URL",
|
|
45
|
+
},
|
|
46
|
+
authToken: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "Bearer token for the target API",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
async run({ args }) {
|
|
52
|
+
const dryRun = args["dry-run"] === true;
|
|
53
|
+
const report = await requestBackfill(baseUrl(args.targetUrl ? String(args.targetUrl) : undefined), String(args.store), dryRun, args.restart === true, args.authToken ? String(args.authToken) : undefined);
|
|
54
|
+
if (dryRun) {
|
|
55
|
+
consola.success(`Channel catalog backfill dry run for ${String(args.store)}.`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
consola.success(`Channel catalog backfill enqueued for ${String(args.store)} (runs as a durable job).`);
|
|
59
|
+
}
|
|
60
|
+
consola.info(JSON.stringify(report, null, 2));
|
|
61
|
+
},
|
|
62
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { deployCommand } from "./commands/deploy.js";
|
|
|
8
8
|
import { importCommand } from "./commands/import.js";
|
|
9
9
|
import { apiKeyCommand } from "./commands/api-key.js";
|
|
10
10
|
import { doctorCommand } from "./commands/doctor.js";
|
|
11
|
+
import { channelBackfillCommand } from "./commands/channel-backfill.js";
|
|
11
12
|
const main = defineCommand({
|
|
12
13
|
meta: {
|
|
13
14
|
name: "@porulle/cli",
|
|
@@ -22,6 +23,7 @@ const main = defineCommand({
|
|
|
22
23
|
import: importCommand,
|
|
23
24
|
"api-key": apiKeyCommand,
|
|
24
25
|
doctor: doctorCommand,
|
|
26
|
+
"channel:backfill": channelBackfillCommand,
|
|
25
27
|
generate: defineCommand({
|
|
26
28
|
subCommands: {
|
|
27
29
|
migration: generateMigrationCommand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porulle/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"giget": "^2.0.0"
|
|
14
14
|
},
|
|
15
15
|
"optionalDependencies": {
|
|
16
|
-
"@porulle/import-
|
|
17
|
-
"@porulle/import-
|
|
18
|
-
"@porulle/import-
|
|
16
|
+
"@porulle/import-shopify": "0.11.0",
|
|
17
|
+
"@porulle/import-woocommerce": "0.11.0",
|
|
18
|
+
"@porulle/import-flat": "0.11.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@electric-sql/pglite": "0.4.5",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"eslint": "^9.39.1",
|
|
26
26
|
"typescript": "5.9.2",
|
|
27
27
|
"vitest": "^3.2.4",
|
|
28
|
-
"@porulle/
|
|
29
|
-
"@porulle/
|
|
28
|
+
"@porulle/eslint-config": "0.1.0",
|
|
29
|
+
"@porulle/typescript-config": "0.1.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|