@gpc-cli/cli 0.1.1
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/LICENSE +21 -0
- package/dist/apps-BBYNHB2H.js +83 -0
- package/dist/apps-BBYNHB2H.js.map +1 -0
- package/dist/auth-T7IDSMVX.js +129 -0
- package/dist/auth-T7IDSMVX.js.map +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +36 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-4QV4WD3F.js +103 -0
- package/dist/chunk-4QV4WD3F.js.map +1 -0
- package/dist/chunk-IVVT73IP.js +245 -0
- package/dist/chunk-IVVT73IP.js.map +1 -0
- package/dist/chunk-QMKZYXDJ.js +24 -0
- package/dist/chunk-QMKZYXDJ.js.map +1 -0
- package/dist/completion-U44CGHRH.js +145 -0
- package/dist/completion-U44CGHRH.js.map +1 -0
- package/dist/config-K7UJKIXT.js +44 -0
- package/dist/config-K7UJKIXT.js.map +1 -0
- package/dist/docs-CVTWIVMS.js +20 -0
- package/dist/docs-CVTWIVMS.js.map +1 -0
- package/dist/doctor-VDDUPTIM.js +59 -0
- package/dist/doctor-VDDUPTIM.js.map +1 -0
- package/dist/iap-QIV4CXKZ.js +158 -0
- package/dist/iap-QIV4CXKZ.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/listings-PF5FDXKQ.js +261 -0
- package/dist/listings-PF5FDXKQ.js.map +1 -0
- package/dist/pricing-S4SB5FXJ.js +52 -0
- package/dist/pricing-S4SB5FXJ.js.map +1 -0
- package/dist/prompt-VP5LURRP.js +20 -0
- package/dist/prompt-VP5LURRP.js.map +1 -0
- package/dist/publish-3BAIN4NQ.js +114 -0
- package/dist/publish-3BAIN4NQ.js.map +1 -0
- package/dist/purchases-E6A2T5WQ.js +231 -0
- package/dist/purchases-E6A2T5WQ.js.map +1 -0
- package/dist/releases-464IMEEF.js +231 -0
- package/dist/releases-464IMEEF.js.map +1 -0
- package/dist/reports-3YAD4U4F.js +129 -0
- package/dist/reports-3YAD4U4F.js.map +1 -0
- package/dist/reviews-2CLM53E3.js +125 -0
- package/dist/reviews-2CLM53E3.js.map +1 -0
- package/dist/status-M7U3YNMU.js +32 -0
- package/dist/status-M7U3YNMU.js.map +1 -0
- package/dist/subscriptions-PUHH4FBB.js +376 -0
- package/dist/subscriptions-PUHH4FBB.js.map +1 -0
- package/dist/testers-WWZMLB7J.js +145 -0
- package/dist/testers-WWZMLB7J.js.map +1 -0
- package/dist/tracks-427E34S3.js +39 -0
- package/dist/tracks-427E34S3.js.map +1 -0
- package/dist/users-E5Y5HI6K.js +145 -0
- package/dist/users-E5Y5HI6K.js.map +1 -0
- package/dist/validate-TPKVSIMR.js +37 -0
- package/dist/validate-TPKVSIMR.js.map +1 -0
- package/dist/vitals-YMZMUPNA.js +166 -0
- package/dist/vitals-YMZMUPNA.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
isDryRun,
|
|
4
|
+
printDryRun
|
|
5
|
+
} from "./chunk-QMKZYXDJ.js";
|
|
6
|
+
import {
|
|
7
|
+
requireConfirm
|
|
8
|
+
} from "./chunk-4QV4WD3F.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/iap.ts
|
|
11
|
+
import { readFile } from "fs/promises";
|
|
12
|
+
import { loadConfig } from "@gpc-cli/config";
|
|
13
|
+
import { resolveAuth } from "@gpc-cli/auth";
|
|
14
|
+
import { createApiClient } from "@gpc-cli/api";
|
|
15
|
+
import {
|
|
16
|
+
listInAppProducts,
|
|
17
|
+
getInAppProduct,
|
|
18
|
+
createInAppProduct,
|
|
19
|
+
updateInAppProduct,
|
|
20
|
+
deleteInAppProduct,
|
|
21
|
+
syncInAppProducts,
|
|
22
|
+
detectOutputFormat,
|
|
23
|
+
formatOutput
|
|
24
|
+
} from "@gpc-cli/core";
|
|
25
|
+
function resolvePackageName(packageArg, config) {
|
|
26
|
+
const name = packageArg || config.app;
|
|
27
|
+
if (!name) {
|
|
28
|
+
console.error("Error: No package name. Use --app <package> or gpc config set app <package>");
|
|
29
|
+
process.exit(2);
|
|
30
|
+
}
|
|
31
|
+
return name;
|
|
32
|
+
}
|
|
33
|
+
async function getClient(config) {
|
|
34
|
+
const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });
|
|
35
|
+
return createApiClient({ auth });
|
|
36
|
+
}
|
|
37
|
+
function registerIapCommands(program) {
|
|
38
|
+
const iap = program.command("iap").description("Manage in-app products");
|
|
39
|
+
iap.command("list").description("List in-app products").option("--max <n>", "Maximum results per page", parseInt).option("--limit <n>", "Maximum total results", parseInt).option("--next-page <token>", "Resume from page token").action(async (options) => {
|
|
40
|
+
const config = await loadConfig();
|
|
41
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
42
|
+
const client = await getClient(config);
|
|
43
|
+
const format = detectOutputFormat();
|
|
44
|
+
try {
|
|
45
|
+
const result = await listInAppProducts(client, packageName, {
|
|
46
|
+
maxResults: options.max,
|
|
47
|
+
limit: options.limit,
|
|
48
|
+
nextPage: options.nextPage
|
|
49
|
+
});
|
|
50
|
+
console.log(formatOutput(result, format));
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
53
|
+
process.exit(4);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
iap.command("get <sku>").description("Get an in-app product").action(async (sku) => {
|
|
57
|
+
const config = await loadConfig();
|
|
58
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
59
|
+
const client = await getClient(config);
|
|
60
|
+
const format = detectOutputFormat();
|
|
61
|
+
try {
|
|
62
|
+
const result = await getInAppProduct(client, packageName, sku);
|
|
63
|
+
console.log(formatOutput(result, format));
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
66
|
+
process.exit(4);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
iap.command("create").description("Create an in-app product from JSON file").requiredOption("--file <path>", "JSON file with product data").action(async (options) => {
|
|
70
|
+
const config = await loadConfig();
|
|
71
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
72
|
+
const format = detectOutputFormat();
|
|
73
|
+
if (isDryRun(program)) {
|
|
74
|
+
printDryRun({
|
|
75
|
+
command: "iap create",
|
|
76
|
+
action: "create",
|
|
77
|
+
target: `in-app product from ${options.file}`
|
|
78
|
+
}, format, formatOutput);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const client = await getClient(config);
|
|
82
|
+
try {
|
|
83
|
+
const data = JSON.parse(await readFile(options.file, "utf-8"));
|
|
84
|
+
const result = await createInAppProduct(client, packageName, data);
|
|
85
|
+
console.log(formatOutput(result, format));
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
88
|
+
process.exit(4);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
iap.command("update <sku>").description("Update an in-app product from JSON file").requiredOption("--file <path>", "JSON file with product data").action(async (sku, options) => {
|
|
92
|
+
const config = await loadConfig();
|
|
93
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
94
|
+
const format = detectOutputFormat();
|
|
95
|
+
if (isDryRun(program)) {
|
|
96
|
+
printDryRun({
|
|
97
|
+
command: "iap update",
|
|
98
|
+
action: "update",
|
|
99
|
+
target: sku,
|
|
100
|
+
details: { file: options.file }
|
|
101
|
+
}, format, formatOutput);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const client = await getClient(config);
|
|
105
|
+
try {
|
|
106
|
+
const data = JSON.parse(await readFile(options.file, "utf-8"));
|
|
107
|
+
const result = await updateInAppProduct(client, packageName, sku, data);
|
|
108
|
+
console.log(formatOutput(result, format));
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
111
|
+
process.exit(4);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
iap.command("delete <sku>").description("Delete an in-app product").action(async (sku) => {
|
|
115
|
+
const config = await loadConfig();
|
|
116
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
117
|
+
await requireConfirm(`Delete in-app product "${sku}"?`, program);
|
|
118
|
+
if (isDryRun(program)) {
|
|
119
|
+
const format = detectOutputFormat();
|
|
120
|
+
printDryRun({
|
|
121
|
+
command: "iap delete",
|
|
122
|
+
action: "delete",
|
|
123
|
+
target: sku
|
|
124
|
+
}, format, formatOutput);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const client = await getClient(config);
|
|
128
|
+
try {
|
|
129
|
+
await deleteInAppProduct(client, packageName, sku);
|
|
130
|
+
console.log(`In-app product ${sku} deleted.`);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
133
|
+
process.exit(4);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
iap.command("sync").description("Sync in-app products from a directory of JSON files").requiredOption("--dir <path>", "Directory containing product JSON files").option("--dry-run", "Preview changes without applying").action(async (options) => {
|
|
137
|
+
const config = await loadConfig();
|
|
138
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
139
|
+
const client = await getClient(config);
|
|
140
|
+
const format = detectOutputFormat();
|
|
141
|
+
try {
|
|
142
|
+
const result = await syncInAppProducts(client, packageName, options.dir, {
|
|
143
|
+
dryRun: options.dryRun
|
|
144
|
+
});
|
|
145
|
+
if (options.dryRun) {
|
|
146
|
+
console.log(`[dry-run] Would create: ${result.created}, update: ${result.updated}`);
|
|
147
|
+
}
|
|
148
|
+
console.log(formatOutput(result, format));
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
151
|
+
process.exit(4);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
registerIapCommands
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=iap-QIV4CXKZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/iap.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport {\n listInAppProducts,\n getInAppProduct,\n createInAppProduct,\n updateInAppProduct,\n deleteInAppProduct,\n syncInAppProducts,\n detectOutputFormat,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\nimport { requireConfirm } from \"../prompt.js\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: any): string {\n const name = packageArg || config.app;\n if (!name) {\n console.error(\"Error: No package name. Use --app <package> or gpc config set app <package>\");\n process.exit(2);\n }\n return name;\n}\n\nasync function getClient(config: any) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport function registerIapCommands(program: Command): void {\n const iap = program\n .command(\"iap\")\n .description(\"Manage in-app products\");\n\n iap\n .command(\"list\")\n .description(\"List in-app products\")\n .option(\"--max <n>\", \"Maximum results per page\", parseInt)\n .option(\"--limit <n>\", \"Maximum total results\", parseInt)\n .option(\"--next-page <token>\", \"Resume from page token\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await listInAppProducts(client, packageName, {\n maxResults: options.max,\n limit: options.limit,\n nextPage: options.nextPage,\n });\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n iap\n .command(\"get <sku>\")\n .description(\"Get an in-app product\")\n .action(async (sku: string) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await getInAppProduct(client, packageName, sku);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n iap\n .command(\"create\")\n .description(\"Create an in-app product from JSON file\")\n .requiredOption(\"--file <path>\", \"JSON file with product data\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const format = detectOutputFormat();\n\n if (isDryRun(program)) {\n printDryRun({\n command: \"iap create\",\n action: \"create\",\n target: `in-app product from ${options.file}`,\n }, format, formatOutput);\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const data = JSON.parse(await readFile(options.file, \"utf-8\"));\n const result = await createInAppProduct(client, packageName, data);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n iap\n .command(\"update <sku>\")\n .description(\"Update an in-app product from JSON file\")\n .requiredOption(\"--file <path>\", \"JSON file with product data\")\n .action(async (sku: string, options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const format = detectOutputFormat();\n\n if (isDryRun(program)) {\n printDryRun({\n command: \"iap update\",\n action: \"update\",\n target: sku,\n details: { file: options.file },\n }, format, formatOutput);\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const data = JSON.parse(await readFile(options.file, \"utf-8\"));\n const result = await updateInAppProduct(client, packageName, sku, data);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n iap\n .command(\"delete <sku>\")\n .description(\"Delete an in-app product\")\n .action(async (sku: string) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n\n await requireConfirm(`Delete in-app product \"${sku}\"?`, program);\n\n if (isDryRun(program)) {\n const format = detectOutputFormat();\n printDryRun({\n command: \"iap delete\",\n action: \"delete\",\n target: sku,\n }, format, formatOutput);\n return;\n }\n\n const client = await getClient(config);\n\n try {\n await deleteInAppProduct(client, packageName, sku);\n console.log(`In-app product ${sku} deleted.`);\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n iap\n .command(\"sync\")\n .description(\"Sync in-app products from a directory of JSON files\")\n .requiredOption(\"--dir <path>\", \"Directory containing product JSON files\")\n .option(\"--dry-run\", \"Preview changes without applying\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await syncInAppProducts(client, packageName, options.dir, {\n dryRun: options.dryRun,\n });\n if (options.dryRun) {\n console.log(`[dry-run] Would create: ${result.created}, update: ${result.updated}`);\n }\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,gBAAgB;AAEzB,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,mBAAmB,YAAgC,QAAqB;AAC/E,QAAM,OAAO,cAAc,OAAO;AAClC,MAAI,CAAC,MAAM;AACT,YAAQ,MAAM,6EAA6E;AAC3F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAe,UAAU,QAAa;AACpC,QAAM,OAAO,MAAM,YAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,SAAO,gBAAgB,EAAE,KAAK,CAAC;AACjC;AAEO,SAAS,oBAAoB,SAAwB;AAC1D,QAAM,MAAM,QAC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,QAAQ,KAAK;AAAA,QACvE,QAAQ,QAAQ;AAAA,MAClB,CAAC;AACD,UAAI,QAAQ,QAAQ;AAClB,gBAAQ,IAAI,2BAA2B,OAAO,OAAO,aAAa,OAAO,OAAO,EAAE;AAAA,MACpF;AACA,cAAQ,IAAI,aAAa,QAAQ,MAAM,CAAC;AAAA,IAC1C,SAAS,OAAO;AACd,cAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;","names":[]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
isDryRun,
|
|
4
|
+
printDryRun
|
|
5
|
+
} from "./chunk-QMKZYXDJ.js";
|
|
6
|
+
import {
|
|
7
|
+
isInteractive,
|
|
8
|
+
requireConfirm,
|
|
9
|
+
requireOption
|
|
10
|
+
} from "./chunk-4QV4WD3F.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/listings.ts
|
|
13
|
+
import { loadConfig } from "@gpc-cli/config";
|
|
14
|
+
import { resolveAuth } from "@gpc-cli/auth";
|
|
15
|
+
import { createApiClient } from "@gpc-cli/api";
|
|
16
|
+
import {
|
|
17
|
+
getListings,
|
|
18
|
+
updateListing,
|
|
19
|
+
deleteListing,
|
|
20
|
+
pullListings,
|
|
21
|
+
pushListings,
|
|
22
|
+
listImages,
|
|
23
|
+
uploadImage,
|
|
24
|
+
deleteImage,
|
|
25
|
+
getCountryAvailability,
|
|
26
|
+
detectOutputFormat,
|
|
27
|
+
formatOutput
|
|
28
|
+
} from "@gpc-cli/core";
|
|
29
|
+
function resolvePackageName(packageArg, config) {
|
|
30
|
+
const name = packageArg || config.app;
|
|
31
|
+
if (!name) {
|
|
32
|
+
console.error("Error: No package name. Use --app <package> or gpc config set app <package>");
|
|
33
|
+
process.exit(2);
|
|
34
|
+
}
|
|
35
|
+
return name;
|
|
36
|
+
}
|
|
37
|
+
async function getClient(config) {
|
|
38
|
+
const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });
|
|
39
|
+
return createApiClient({ auth });
|
|
40
|
+
}
|
|
41
|
+
var VALID_IMAGE_TYPES = [
|
|
42
|
+
"phoneScreenshots",
|
|
43
|
+
"sevenInchScreenshots",
|
|
44
|
+
"tenInchScreenshots",
|
|
45
|
+
"tvScreenshots",
|
|
46
|
+
"wearScreenshots",
|
|
47
|
+
"icon",
|
|
48
|
+
"featureGraphic",
|
|
49
|
+
"tvBanner"
|
|
50
|
+
];
|
|
51
|
+
function validateImageType(type) {
|
|
52
|
+
if (!VALID_IMAGE_TYPES.includes(type)) {
|
|
53
|
+
console.error(`Error: Invalid image type "${type}".`);
|
|
54
|
+
console.error(`Valid types: ${VALID_IMAGE_TYPES.join(", ")}`);
|
|
55
|
+
process.exit(2);
|
|
56
|
+
}
|
|
57
|
+
return type;
|
|
58
|
+
}
|
|
59
|
+
function registerListingsCommands(program) {
|
|
60
|
+
const listings = program.command("listings").description("Manage store listings and metadata");
|
|
61
|
+
listings.command("get").description("Get store listing(s)").option("--lang <language>", "Language code (BCP 47)").action(async (options) => {
|
|
62
|
+
const config = await loadConfig();
|
|
63
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
64
|
+
const client = await getClient(config);
|
|
65
|
+
const format = detectOutputFormat();
|
|
66
|
+
try {
|
|
67
|
+
const result = await getListings(client, packageName, options.lang);
|
|
68
|
+
console.log(formatOutput(result, format));
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
71
|
+
process.exit(4);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
listings.command("update").description("Update a store listing").option("--lang <language>", "Language code (BCP 47)").option("--title <text>", "App title").option("--short <text>", "Short description").option("--full <text>", "Full description").option("--full-file <path>", "Read full description from file").option("--video <url>", "Video URL").action(async (options) => {
|
|
75
|
+
const config = await loadConfig();
|
|
76
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
77
|
+
const interactive = isInteractive(program);
|
|
78
|
+
options.lang = await requireOption("lang", options.lang, {
|
|
79
|
+
message: "Language code (BCP 47):",
|
|
80
|
+
default: "en-US"
|
|
81
|
+
}, interactive);
|
|
82
|
+
const format = detectOutputFormat();
|
|
83
|
+
try {
|
|
84
|
+
const data = {};
|
|
85
|
+
if (options.title) data.title = options.title;
|
|
86
|
+
if (options.short) data.shortDescription = options.short;
|
|
87
|
+
if (options.full) data.fullDescription = options.full;
|
|
88
|
+
if (options.fullFile) {
|
|
89
|
+
const { readFile } = await import("fs/promises");
|
|
90
|
+
data.fullDescription = (await readFile(options.fullFile, "utf-8")).trimEnd();
|
|
91
|
+
}
|
|
92
|
+
if (options.video) data.video = options.video;
|
|
93
|
+
if (Object.keys(data).length === 0) {
|
|
94
|
+
console.error("Error: Provide at least one field to update (--title, --short, --full, --full-file, --video).");
|
|
95
|
+
process.exit(2);
|
|
96
|
+
}
|
|
97
|
+
if (isDryRun(program)) {
|
|
98
|
+
printDryRun({
|
|
99
|
+
command: "listings update",
|
|
100
|
+
action: "update listing for",
|
|
101
|
+
target: options.lang,
|
|
102
|
+
details: data
|
|
103
|
+
}, format, formatOutput);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const client = await getClient(config);
|
|
107
|
+
const result = await updateListing(client, packageName, options.lang, data);
|
|
108
|
+
console.log(formatOutput(result, format));
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
111
|
+
process.exit(4);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
listings.command("delete").description("Delete a store listing for a language").option("--lang <language>", "Language code (BCP 47)").action(async (options) => {
|
|
115
|
+
const config = await loadConfig();
|
|
116
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
117
|
+
const interactive = isInteractive(program);
|
|
118
|
+
options.lang = await requireOption("lang", options.lang, {
|
|
119
|
+
message: "Language code (BCP 47):"
|
|
120
|
+
}, interactive);
|
|
121
|
+
await requireConfirm(`Delete listing for "${options.lang}"?`, program);
|
|
122
|
+
if (isDryRun(program)) {
|
|
123
|
+
const format = detectOutputFormat();
|
|
124
|
+
printDryRun({
|
|
125
|
+
command: "listings delete",
|
|
126
|
+
action: "delete listing for",
|
|
127
|
+
target: options.lang
|
|
128
|
+
}, format, formatOutput);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const client = await getClient(config);
|
|
132
|
+
try {
|
|
133
|
+
await deleteListing(client, packageName, options.lang);
|
|
134
|
+
console.log(`Listing for "${options.lang}" deleted.`);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
137
|
+
process.exit(4);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
listings.command("pull").description("Download listings to Fastlane-format directory").option("--dir <path>", "Output directory", "metadata").action(async (options) => {
|
|
141
|
+
const config = await loadConfig();
|
|
142
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
143
|
+
const client = await getClient(config);
|
|
144
|
+
const format = detectOutputFormat();
|
|
145
|
+
try {
|
|
146
|
+
const result = await pullListings(client, packageName, options.dir);
|
|
147
|
+
console.log(formatOutput({
|
|
148
|
+
directory: options.dir,
|
|
149
|
+
languages: result.listings.map((l) => l.language),
|
|
150
|
+
count: result.listings.length
|
|
151
|
+
}, format));
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
154
|
+
process.exit(4);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
listings.command("push").description("Upload listings from Fastlane-format directory").option("--dir <path>", "Source directory", "metadata").option("--dry-run", "Preview changes without applying").action(async (options) => {
|
|
158
|
+
const config = await loadConfig();
|
|
159
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
160
|
+
const client = await getClient(config);
|
|
161
|
+
const format = detectOutputFormat();
|
|
162
|
+
try {
|
|
163
|
+
const result = await pushListings(client, packageName, options.dir, {
|
|
164
|
+
dryRun: options.dryRun
|
|
165
|
+
});
|
|
166
|
+
console.log(formatOutput(result, format));
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
169
|
+
process.exit(4);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const images = listings.command("images").description("Manage listing images");
|
|
173
|
+
images.command("list").description("List images for a language and type").option("--lang <language>", "Language code (BCP 47)").option("--type <type>", "Image type").action(async (options) => {
|
|
174
|
+
const config = await loadConfig();
|
|
175
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
176
|
+
const interactive = isInteractive(program);
|
|
177
|
+
options.lang = await requireOption("lang", options.lang, {
|
|
178
|
+
message: "Language code (BCP 47):",
|
|
179
|
+
default: "en-US"
|
|
180
|
+
}, interactive);
|
|
181
|
+
options.type = await requireOption("type", options.type, {
|
|
182
|
+
message: "Image type:",
|
|
183
|
+
choices: VALID_IMAGE_TYPES
|
|
184
|
+
}, interactive);
|
|
185
|
+
const client = await getClient(config);
|
|
186
|
+
const format = detectOutputFormat();
|
|
187
|
+
const imageType = validateImageType(options.type);
|
|
188
|
+
try {
|
|
189
|
+
const result = await listImages(client, packageName, options.lang, imageType);
|
|
190
|
+
console.log(formatOutput(result, format));
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
193
|
+
process.exit(4);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
images.command("upload <file>").description("Upload an image").option("--lang <language>", "Language code (BCP 47)").option("--type <type>", "Image type").action(async (file, options) => {
|
|
197
|
+
const config = await loadConfig();
|
|
198
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
199
|
+
const interactive = isInteractive(program);
|
|
200
|
+
options.lang = await requireOption("lang", options.lang, {
|
|
201
|
+
message: "Language code (BCP 47):",
|
|
202
|
+
default: "en-US"
|
|
203
|
+
}, interactive);
|
|
204
|
+
options.type = await requireOption("type", options.type, {
|
|
205
|
+
message: "Image type:",
|
|
206
|
+
choices: VALID_IMAGE_TYPES
|
|
207
|
+
}, interactive);
|
|
208
|
+
const client = await getClient(config);
|
|
209
|
+
const format = detectOutputFormat();
|
|
210
|
+
const imageType = validateImageType(options.type);
|
|
211
|
+
try {
|
|
212
|
+
const result = await uploadImage(client, packageName, options.lang, imageType, file);
|
|
213
|
+
console.log(formatOutput(result, format));
|
|
214
|
+
} catch (error) {
|
|
215
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
216
|
+
process.exit(4);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
images.command("delete").description("Delete an image").option("--lang <language>", "Language code (BCP 47)").option("--type <type>", "Image type").option("--id <imageId>", "Image ID to delete").action(async (options) => {
|
|
220
|
+
const config = await loadConfig();
|
|
221
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
222
|
+
const interactive = isInteractive(program);
|
|
223
|
+
options.lang = await requireOption("lang", options.lang, {
|
|
224
|
+
message: "Language code (BCP 47):"
|
|
225
|
+
}, interactive);
|
|
226
|
+
options.type = await requireOption("type", options.type, {
|
|
227
|
+
message: "Image type:",
|
|
228
|
+
choices: VALID_IMAGE_TYPES
|
|
229
|
+
}, interactive);
|
|
230
|
+
options.id = await requireOption("id", options.id, {
|
|
231
|
+
message: "Image ID to delete:"
|
|
232
|
+
}, interactive);
|
|
233
|
+
await requireConfirm(`Delete image "${options.id}"?`, program);
|
|
234
|
+
const client = await getClient(config);
|
|
235
|
+
const imageType = validateImageType(options.type);
|
|
236
|
+
try {
|
|
237
|
+
await deleteImage(client, packageName, options.lang, imageType, options.id);
|
|
238
|
+
console.log(`Image "${options.id}" deleted.`);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
241
|
+
process.exit(4);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
listings.command("availability").description("Get country availability for a track").option("--track <track>", "Track name", "production").action(async (options) => {
|
|
245
|
+
const config = await loadConfig();
|
|
246
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
247
|
+
const client = await getClient(config);
|
|
248
|
+
const format = detectOutputFormat();
|
|
249
|
+
try {
|
|
250
|
+
const result = await getCountryAvailability(client, packageName, options.track);
|
|
251
|
+
console.log(formatOutput(result, format));
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
254
|
+
process.exit(4);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
export {
|
|
259
|
+
registerListingsCommands
|
|
260
|
+
};
|
|
261
|
+
//# sourceMappingURL=listings-PF5FDXKQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/listings.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport type { ImageType } from \"@gpc-cli/api\";\nimport {\n getListings,\n updateListing,\n deleteListing,\n pullListings,\n pushListings,\n listImages,\n uploadImage,\n deleteImage,\n getCountryAvailability,\n detectOutputFormat,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\nimport { isInteractive, requireOption, requireConfirm } from \"../prompt.js\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: any): string {\n const name = packageArg || config.app;\n if (!name) {\n console.error(\"Error: No package name. Use --app <package> or gpc config set app <package>\");\n process.exit(2);\n }\n return name;\n}\n\nasync function getClient(config: any) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nconst VALID_IMAGE_TYPES: ImageType[] = [\n \"phoneScreenshots\", \"sevenInchScreenshots\", \"tenInchScreenshots\",\n \"tvScreenshots\", \"wearScreenshots\", \"icon\", \"featureGraphic\", \"tvBanner\",\n];\n\nfunction validateImageType(type: string): ImageType {\n if (!VALID_IMAGE_TYPES.includes(type as ImageType)) {\n console.error(`Error: Invalid image type \"${type}\".`);\n console.error(`Valid types: ${VALID_IMAGE_TYPES.join(\", \")}`);\n process.exit(2);\n }\n return type as ImageType;\n}\n\nexport function registerListingsCommands(program: Command): void {\n const listings = program\n .command(\"listings\")\n .description(\"Manage store listings and metadata\");\n\n // Get\n listings\n .command(\"get\")\n .description(\"Get store listing(s)\")\n .option(\"--lang <language>\", \"Language code (BCP 47)\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await getListings(client, packageName, options.lang);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Update\n listings\n .command(\"update\")\n .description(\"Update a store listing\")\n .option(\"--lang <language>\", \"Language code (BCP 47)\")\n .option(\"--title <text>\", \"App title\")\n .option(\"--short <text>\", \"Short description\")\n .option(\"--full <text>\", \"Full description\")\n .option(\"--full-file <path>\", \"Read full description from file\")\n .option(\"--video <url>\", \"Video URL\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const interactive = isInteractive(program);\n\n options.lang = await requireOption(\"lang\", options.lang, {\n message: \"Language code (BCP 47):\",\n default: \"en-US\",\n }, interactive);\n const format = detectOutputFormat();\n\n try {\n const data: Record<string, string> = {};\n if (options.title) data.title = options.title;\n if (options.short) data.shortDescription = options.short;\n if (options.full) data.fullDescription = options.full;\n if (options.fullFile) {\n const { readFile } = await import(\"node:fs/promises\");\n data.fullDescription = (await readFile(options.fullFile, \"utf-8\")).trimEnd();\n }\n if (options.video) data.video = options.video;\n\n if (Object.keys(data).length === 0) {\n console.error(\"Error: Provide at least one field to update (--title, --short, --full, --full-file, --video).\");\n process.exit(2);\n }\n\n if (isDryRun(program)) {\n printDryRun({\n command: \"listings update\",\n action: \"update listing for\",\n target: options.lang,\n details: data,\n }, format, formatOutput);\n return;\n }\n\n const client = await getClient(config);\n const result = await updateListing(client, packageName, options.lang, data);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Delete\n listings\n .command(\"delete\")\n .description(\"Delete a store listing for a language\")\n .option(\"--lang <language>\", \"Language code (BCP 47)\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const interactive = isInteractive(program);\n\n options.lang = await requireOption(\"lang\", options.lang, {\n message: \"Language code (BCP 47):\",\n }, interactive);\n\n await requireConfirm(`Delete listing for \"${options.lang}\"?`, program);\n\n if (isDryRun(program)) {\n const format = detectOutputFormat();\n printDryRun({\n command: \"listings delete\",\n action: \"delete listing for\",\n target: options.lang,\n }, format, formatOutput);\n return;\n }\n\n const client = await getClient(config);\n\n try {\n await deleteListing(client, packageName, options.lang);\n console.log(`Listing for \"${options.lang}\" deleted.`);\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Pull\n listings\n .command(\"pull\")\n .description(\"Download listings to Fastlane-format directory\")\n .option(\"--dir <path>\", \"Output directory\", \"metadata\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await pullListings(client, packageName, options.dir);\n console.log(formatOutput({\n directory: options.dir,\n languages: result.listings.map((l) => l.language),\n count: result.listings.length,\n }, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Push\n listings\n .command(\"push\")\n .description(\"Upload listings from Fastlane-format directory\")\n .option(\"--dir <path>\", \"Source directory\", \"metadata\")\n .option(\"--dry-run\", \"Preview changes without applying\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await pushListings(client, packageName, options.dir, {\n dryRun: options.dryRun,\n });\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Images subcommand\n const images = listings\n .command(\"images\")\n .description(\"Manage listing images\");\n\n // Images list\n images\n .command(\"list\")\n .description(\"List images for a language and type\")\n .option(\"--lang <language>\", \"Language code (BCP 47)\")\n .option(\"--type <type>\", \"Image type\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const interactive = isInteractive(program);\n\n options.lang = await requireOption(\"lang\", options.lang, {\n message: \"Language code (BCP 47):\",\n default: \"en-US\",\n }, interactive);\n\n options.type = await requireOption(\"type\", options.type, {\n message: \"Image type:\",\n choices: VALID_IMAGE_TYPES as unknown as string[],\n }, interactive);\n\n const client = await getClient(config);\n const format = detectOutputFormat();\n const imageType = validateImageType(options.type);\n\n try {\n const result = await listImages(client, packageName, options.lang, imageType);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Images upload\n images\n .command(\"upload <file>\")\n .description(\"Upload an image\")\n .option(\"--lang <language>\", \"Language code (BCP 47)\")\n .option(\"--type <type>\", \"Image type\")\n .action(async (file: string, options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const interactive = isInteractive(program);\n\n options.lang = await requireOption(\"lang\", options.lang, {\n message: \"Language code (BCP 47):\",\n default: \"en-US\",\n }, interactive);\n\n options.type = await requireOption(\"type\", options.type, {\n message: \"Image type:\",\n choices: VALID_IMAGE_TYPES as unknown as string[],\n }, interactive);\n\n const client = await getClient(config);\n const format = detectOutputFormat();\n const imageType = validateImageType(options.type);\n\n try {\n const result = await uploadImage(client, packageName, options.lang, imageType, file);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Images delete\n images\n .command(\"delete\")\n .description(\"Delete an image\")\n .option(\"--lang <language>\", \"Language code (BCP 47)\")\n .option(\"--type <type>\", \"Image type\")\n .option(\"--id <imageId>\", \"Image ID to delete\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const interactive = isInteractive(program);\n\n options.lang = await requireOption(\"lang\", options.lang, {\n message: \"Language code (BCP 47):\",\n }, interactive);\n\n options.type = await requireOption(\"type\", options.type, {\n message: \"Image type:\",\n choices: VALID_IMAGE_TYPES as unknown as string[],\n }, interactive);\n\n options.id = await requireOption(\"id\", options.id, {\n message: \"Image ID to delete:\",\n }, interactive);\n\n await requireConfirm(`Delete image \"${options.id}\"?`, program);\n\n const client = await getClient(config);\n const imageType = validateImageType(options.type);\n\n try {\n await deleteImage(client, packageName, options.lang, imageType, options.id);\n console.log(`Image \"${options.id}\" deleted.`);\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Availability\n listings\n .command(\"availability\")\n .description(\"Get country availability for a track\")\n .option(\"--track <track>\", \"Track name\", \"production\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await getCountryAvailability(client, packageName, options.track);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,kBAAkB;AAC3B,SA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AkB,QAAQ,IAAI;AAEhD,QAAI;AACF,YAAM,YAAY,QAAQ,aAAa,QAAQ,MAAM,WAAW,QAAQ,EAAE;AAC1E,cAAQ,IAAI,UAAU,QAAQ,EAAE,YAAY;AAAA,IAC9C,SAAS,OAAO;AACd,cAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAGH,WACG,QAAQ,cAAc,EACtB,YAAY,sCAAsC,EAClD,OAAO,mBAAmB,cAAc,YAAY,EACpD,OAAO,OAAO,YAAY;AACzB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,cAAc,mBAAmB,QAAQ,KAAK,EAAE,KAAK,MAAM;AACjE,UAAM,SAAS,MAAM,UAAU,MAAM;AACrC,UAAM,SAAS,mBAAmB;AAElC,QAAI;AACF,YAAM,SAAS,MAAM,uBAAuB,QAAQ,aAAa,QAAQ,KAAK;AAC9E,cAAQ,IAAI,aAAa,QAAQ,MAAM,CAAC;AAAA,IAC1C,SAAS,OAAO;AACd,cAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/pricing.ts
|
|
4
|
+
import { loadConfig } from "@gpc-cli/config";
|
|
5
|
+
import { resolveAuth } from "@gpc-cli/auth";
|
|
6
|
+
import { createApiClient } from "@gpc-cli/api";
|
|
7
|
+
import {
|
|
8
|
+
convertRegionPrices,
|
|
9
|
+
detectOutputFormat,
|
|
10
|
+
formatOutput
|
|
11
|
+
} from "@gpc-cli/core";
|
|
12
|
+
function resolvePackageName(packageArg, config) {
|
|
13
|
+
const name = packageArg || config.app;
|
|
14
|
+
if (!name) {
|
|
15
|
+
console.error("Error: No package name. Use --app <package> or gpc config set app <package>");
|
|
16
|
+
process.exit(2);
|
|
17
|
+
}
|
|
18
|
+
return name;
|
|
19
|
+
}
|
|
20
|
+
async function getClient(config) {
|
|
21
|
+
const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });
|
|
22
|
+
return createApiClient({ auth });
|
|
23
|
+
}
|
|
24
|
+
function registerPricingCommands(program) {
|
|
25
|
+
const pricing = program.command("pricing").description("Pricing and regional price conversion");
|
|
26
|
+
pricing.command("convert").description("Convert a price to all regional prices").option("--from <currency>", "Source currency code (e.g. USD)").option("--amount <number>", "Price amount (e.g. 4.99)").action(async (options) => {
|
|
27
|
+
const config = await loadConfig();
|
|
28
|
+
const packageName = resolvePackageName(program.opts().app, config);
|
|
29
|
+
const { isInteractive, requireOption } = await import("./prompt-VP5LURRP.js");
|
|
30
|
+
const interactive = isInteractive(program);
|
|
31
|
+
options.from = await requireOption("from", options.from, {
|
|
32
|
+
message: "Source currency code (e.g. USD):",
|
|
33
|
+
default: "USD"
|
|
34
|
+
}, interactive);
|
|
35
|
+
options.amount = await requireOption("amount", options.amount, {
|
|
36
|
+
message: "Price amount (e.g. 4.99):"
|
|
37
|
+
}, interactive);
|
|
38
|
+
const client = await getClient(config);
|
|
39
|
+
const format = detectOutputFormat();
|
|
40
|
+
try {
|
|
41
|
+
const result = await convertRegionPrices(client, packageName, options.from, options.amount);
|
|
42
|
+
console.log(formatOutput(result, format));
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
45
|
+
process.exit(4);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
registerPricingCommands
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=pricing-S4SB5FXJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/pricing.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport {\n convertRegionPrices,\n detectOutputFormat,\n formatOutput,\n} from \"@gpc-cli/core\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: any): string {\n const name = packageArg || config.app;\n if (!name) {\n console.error(\"Error: No package name. Use --app <package> or gpc config set app <package>\");\n process.exit(2);\n }\n return name;\n}\n\nasync function getClient(config: any) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport function registerPricingCommands(program: Command): void {\n const pricing = program\n .command(\"pricing\")\n .description(\"Pricing and regional price conversion\");\n\n pricing\n .command(\"convert\")\n .description(\"Convert a price to all regional prices\")\n .option(\"--from <currency>\", \"Source currency code (e.g. USD)\")\n .option(\"--amount <number>\", \"Price amount (e.g. 4.99)\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts().app, config);\n const { isInteractive, requireOption } = await import(\"../prompt.js\");\n const interactive = isInteractive(program);\n\n options.from = await requireOption(\"from\", options.from, {\n message: \"Source currency code (e.g. USD):\",\n default: \"USD\",\n }, interactive);\n\n options.amount = await requireOption(\"amount\", options.amount, {\n message: \"Price amount (e.g. 4.99):\",\n }, interactive);\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await convertRegionPrices(client, packageName, options.from, options.amount);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n"],"mappings":";;;AACA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,mBAAmB,YAAgC,QAAqB;AAC/E,QAAM,OAAO,cAAc,OAAO;AAClC,MAAI,CAAC,MAAM;AACT,YAAQ,MAAM,6EA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ive,
|
|
4
|
+
promptConfirm,
|
|
5
|
+
promptInput,
|
|
6
|
+
promptSelect,
|
|
7
|
+
requireConfirm,
|
|
8
|
+
requireOption,
|
|
9
|
+
skipConfirm
|
|
10
|
+
} from "./chunk-4QV4WD3F.js";
|
|
11
|
+
export {
|
|
12
|
+
isInteractive,
|
|
13
|
+
promptConfirm,
|
|
14
|
+
promptInput,
|
|
15
|
+
promptSelect,
|
|
16
|
+
requireConfirm,
|
|
17
|
+
requireOption,
|
|
18
|
+
skipConfirm
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=prompt-VP5LURRP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|