@gpc-cli/cli 0.9.7 → 0.9.8
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/{apps-TZG5GEDW.js → apps-5YQPQ3KB.js} +20 -3
- package/dist/apps-5YQPQ3KB.js.map +1 -0
- package/dist/bin.js +1 -1
- package/dist/{chunk-LQ7FJ4QA.js → chunk-JVGSSJLY.js} +21 -8
- package/dist/chunk-JVGSSJLY.js.map +1 -0
- package/dist/device-tiers-FUZC6IHD.js +74 -0
- package/dist/device-tiers-FUZC6IHD.js.map +1 -0
- package/dist/generated-apks-SUPM3NS3.js +73 -0
- package/dist/generated-apks-SUPM3NS3.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/internal-sharing-ZQUI3SDM.js +44 -0
- package/dist/internal-sharing-ZQUI3SDM.js.map +1 -0
- package/dist/{listings-FYNMWTIE.js → listings-LTVQHMX3.js} +2 -2
- package/dist/listings-LTVQHMX3.js.map +1 -0
- package/dist/one-time-products-BHE6WPZI.js +266 -0
- package/dist/one-time-products-BHE6WPZI.js.map +1 -0
- package/dist/{recovery-ZANX3WIQ.js → recovery-DC66ZTGD.js} +77 -18
- package/dist/recovery-DC66ZTGD.js.map +1 -0
- package/dist/{reports-OJSCABN6.js → reports-T6GBAYUK.js} +2 -2
- package/dist/reports-T6GBAYUK.js.map +1 -0
- package/dist/{testers-SB77565D.js → testers-NXWT2PFS.js} +2 -2
- package/dist/testers-NXWT2PFS.js.map +1 -0
- package/dist/{tracks-HMJ3F55N.js → tracks-AJH5KP7J.js} +2 -2
- package/dist/tracks-AJH5KP7J.js.map +1 -0
- package/package.json +4 -4
- package/dist/apps-TZG5GEDW.js.map +0 -1
- package/dist/chunk-LQ7FJ4QA.js.map +0 -1
- package/dist/listings-FYNMWTIE.js.map +0 -1
- package/dist/recovery-ZANX3WIQ.js.map +0 -1
- package/dist/reports-OJSCABN6.js.map +0 -1
- package/dist/testers-SB77565D.js.map +0 -1
- package/dist/tracks-HMJ3F55N.js.map +0 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
isDryRun,
|
|
4
|
+
printDryRun
|
|
5
|
+
} from "./chunk-Y3QZDAKS.js";
|
|
6
|
+
import {
|
|
7
|
+
requireConfirm
|
|
8
|
+
} from "./chunk-NV75I5VP.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/one-time-products.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
|
+
listOneTimeProducts,
|
|
17
|
+
getOneTimeProduct,
|
|
18
|
+
createOneTimeProduct,
|
|
19
|
+
updateOneTimeProduct,
|
|
20
|
+
deleteOneTimeProduct,
|
|
21
|
+
listOneTimeOffers,
|
|
22
|
+
getOneTimeOffer,
|
|
23
|
+
createOneTimeOffer,
|
|
24
|
+
updateOneTimeOffer,
|
|
25
|
+
deleteOneTimeOffer,
|
|
26
|
+
detectOutputFormat,
|
|
27
|
+
formatOutput,
|
|
28
|
+
sortResults
|
|
29
|
+
} from "@gpc-cli/core";
|
|
30
|
+
function resolvePackageName(packageArg, config) {
|
|
31
|
+
const name = packageArg || config.app;
|
|
32
|
+
if (!name) {
|
|
33
|
+
console.error("Error: No package name. Use --app <package> or gpc config set app <package>");
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
return name;
|
|
37
|
+
}
|
|
38
|
+
async function getClient(config) {
|
|
39
|
+
const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });
|
|
40
|
+
return createApiClient({ auth });
|
|
41
|
+
}
|
|
42
|
+
function registerOneTimeProductsCommands(program) {
|
|
43
|
+
const otp = program.command("one-time-products").alias("otp").description("Manage one-time products and offers (modern OTP API)");
|
|
44
|
+
otp.command("list").description("List one-time products").option("--sort <field>", "Sort by field (prefix with - for descending)").action(async (options) => {
|
|
45
|
+
const config = await loadConfig();
|
|
46
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
47
|
+
const client = await getClient(config);
|
|
48
|
+
const format = detectOutputFormat();
|
|
49
|
+
try {
|
|
50
|
+
const result = await listOneTimeProducts(client, packageName);
|
|
51
|
+
if (options.sort) {
|
|
52
|
+
result.oneTimeProducts = sortResults(result.oneTimeProducts, options.sort);
|
|
53
|
+
}
|
|
54
|
+
console.log(formatOutput(result, format));
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
57
|
+
process.exit(4);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
otp.command("get <product-id>").description("Get a one-time product").action(async (productId) => {
|
|
61
|
+
const config = await loadConfig();
|
|
62
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
63
|
+
const client = await getClient(config);
|
|
64
|
+
const format = detectOutputFormat();
|
|
65
|
+
try {
|
|
66
|
+
const result = await getOneTimeProduct(client, packageName, productId);
|
|
67
|
+
console.log(formatOutput(result, format));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
70
|
+
process.exit(4);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
otp.command("create").description("Create a one-time product from JSON file").requiredOption("--file <path>", "JSON file with product data").action(async (options) => {
|
|
74
|
+
const config = await loadConfig();
|
|
75
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
76
|
+
const format = detectOutputFormat();
|
|
77
|
+
if (isDryRun(program)) {
|
|
78
|
+
printDryRun(
|
|
79
|
+
{
|
|
80
|
+
command: "one-time-products create",
|
|
81
|
+
action: "create",
|
|
82
|
+
target: `one-time product from ${options.file}`
|
|
83
|
+
},
|
|
84
|
+
format,
|
|
85
|
+
formatOutput
|
|
86
|
+
);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const client = await getClient(config);
|
|
90
|
+
try {
|
|
91
|
+
const data = JSON.parse(await readFile(options.file, "utf-8"));
|
|
92
|
+
const result = await createOneTimeProduct(client, packageName, data);
|
|
93
|
+
console.log(formatOutput(result, format));
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
96
|
+
process.exit(4);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
otp.command("update <product-id>").description("Update a one-time product from JSON file").requiredOption("--file <path>", "JSON file with product data").action(async (productId, options) => {
|
|
100
|
+
const config = await loadConfig();
|
|
101
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
102
|
+
const format = detectOutputFormat();
|
|
103
|
+
if (isDryRun(program)) {
|
|
104
|
+
printDryRun(
|
|
105
|
+
{
|
|
106
|
+
command: "one-time-products update",
|
|
107
|
+
action: "update",
|
|
108
|
+
target: productId,
|
|
109
|
+
details: { file: options.file }
|
|
110
|
+
},
|
|
111
|
+
format,
|
|
112
|
+
formatOutput
|
|
113
|
+
);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const client = await getClient(config);
|
|
117
|
+
try {
|
|
118
|
+
const data = JSON.parse(await readFile(options.file, "utf-8"));
|
|
119
|
+
const result = await updateOneTimeProduct(client, packageName, productId, data);
|
|
120
|
+
console.log(formatOutput(result, format));
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
123
|
+
process.exit(4);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
otp.command("delete <product-id>").description("Delete a one-time product").action(async (productId) => {
|
|
127
|
+
const config = await loadConfig();
|
|
128
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
129
|
+
await requireConfirm(`Delete one-time product "${productId}"?`, program);
|
|
130
|
+
if (isDryRun(program)) {
|
|
131
|
+
const format = detectOutputFormat();
|
|
132
|
+
printDryRun(
|
|
133
|
+
{
|
|
134
|
+
command: "one-time-products delete",
|
|
135
|
+
action: "delete",
|
|
136
|
+
target: productId
|
|
137
|
+
},
|
|
138
|
+
format,
|
|
139
|
+
formatOutput
|
|
140
|
+
);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const client = await getClient(config);
|
|
144
|
+
try {
|
|
145
|
+
await deleteOneTimeProduct(client, packageName, productId);
|
|
146
|
+
console.log(`One-time product ${productId} deleted.`);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
149
|
+
process.exit(4);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
const offers = otp.command("offers").description("Manage one-time product offers");
|
|
153
|
+
offers.command("list <product-id>").description("List offers for a one-time product").option("--sort <field>", "Sort by field (prefix with - for descending)").action(async (productId, options) => {
|
|
154
|
+
const config = await loadConfig();
|
|
155
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
156
|
+
const client = await getClient(config);
|
|
157
|
+
const format = detectOutputFormat();
|
|
158
|
+
try {
|
|
159
|
+
const result = await listOneTimeOffers(client, packageName, productId);
|
|
160
|
+
if (options.sort) {
|
|
161
|
+
result.oneTimeOffers = sortResults(result.oneTimeOffers, options.sort);
|
|
162
|
+
}
|
|
163
|
+
console.log(formatOutput(result, format));
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
166
|
+
process.exit(4);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
offers.command("get <product-id> <offer-id>").description("Get an offer for a one-time product").action(async (productId, offerId) => {
|
|
170
|
+
const config = await loadConfig();
|
|
171
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
172
|
+
const client = await getClient(config);
|
|
173
|
+
const format = detectOutputFormat();
|
|
174
|
+
try {
|
|
175
|
+
const result = await getOneTimeOffer(client, packageName, productId, offerId);
|
|
176
|
+
console.log(formatOutput(result, format));
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
179
|
+
process.exit(4);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
offers.command("create <product-id>").description("Create an offer from JSON file").requiredOption("--file <path>", "JSON file with offer data").action(async (productId, options) => {
|
|
183
|
+
const config = await loadConfig();
|
|
184
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
185
|
+
const format = detectOutputFormat();
|
|
186
|
+
if (isDryRun(program)) {
|
|
187
|
+
printDryRun(
|
|
188
|
+
{
|
|
189
|
+
command: "one-time-products offers create",
|
|
190
|
+
action: "create offer for",
|
|
191
|
+
target: productId,
|
|
192
|
+
details: { file: options.file }
|
|
193
|
+
},
|
|
194
|
+
format,
|
|
195
|
+
formatOutput
|
|
196
|
+
);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const client = await getClient(config);
|
|
200
|
+
try {
|
|
201
|
+
const data = JSON.parse(await readFile(options.file, "utf-8"));
|
|
202
|
+
const result = await createOneTimeOffer(client, packageName, productId, data);
|
|
203
|
+
console.log(formatOutput(result, format));
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
206
|
+
process.exit(4);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
offers.command("update <product-id> <offer-id>").description("Update an offer from JSON file").requiredOption("--file <path>", "JSON file with offer data").action(async (productId, offerId, options) => {
|
|
210
|
+
const config = await loadConfig();
|
|
211
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
212
|
+
const format = detectOutputFormat();
|
|
213
|
+
if (isDryRun(program)) {
|
|
214
|
+
printDryRun(
|
|
215
|
+
{
|
|
216
|
+
command: "one-time-products offers update",
|
|
217
|
+
action: "update offer",
|
|
218
|
+
target: `${productId}/${offerId}`,
|
|
219
|
+
details: { file: options.file }
|
|
220
|
+
},
|
|
221
|
+
format,
|
|
222
|
+
formatOutput
|
|
223
|
+
);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const client = await getClient(config);
|
|
227
|
+
try {
|
|
228
|
+
const data = JSON.parse(await readFile(options.file, "utf-8"));
|
|
229
|
+
const result = await updateOneTimeOffer(client, packageName, productId, offerId, data);
|
|
230
|
+
console.log(formatOutput(result, format));
|
|
231
|
+
} catch (error) {
|
|
232
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
233
|
+
process.exit(4);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
offers.command("delete <product-id> <offer-id>").description("Delete an offer").action(async (productId, offerId) => {
|
|
237
|
+
const config = await loadConfig();
|
|
238
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
239
|
+
await requireConfirm(`Delete offer "${offerId}" for product "${productId}"?`, program);
|
|
240
|
+
if (isDryRun(program)) {
|
|
241
|
+
const format = detectOutputFormat();
|
|
242
|
+
printDryRun(
|
|
243
|
+
{
|
|
244
|
+
command: "one-time-products offers delete",
|
|
245
|
+
action: "delete offer",
|
|
246
|
+
target: `${productId}/${offerId}`
|
|
247
|
+
},
|
|
248
|
+
format,
|
|
249
|
+
formatOutput
|
|
250
|
+
);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const client = await getClient(config);
|
|
254
|
+
try {
|
|
255
|
+
await deleteOneTimeOffer(client, packageName, productId, offerId);
|
|
256
|
+
console.log(`Offer ${offerId} deleted.`);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
259
|
+
process.exit(4);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
export {
|
|
264
|
+
registerOneTimeProductsCommands
|
|
265
|
+
};
|
|
266
|
+
//# sourceMappingURL=one-time-products-BHE6WPZI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/one-time-products.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\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 listOneTimeProducts,\n getOneTimeProduct,\n createOneTimeProduct,\n updateOneTimeProduct,\n deleteOneTimeProduct,\n listOneTimeOffers,\n getOneTimeOffer,\n createOneTimeOffer,\n updateOneTimeOffer,\n deleteOneTimeOffer,\n detectOutputFormat,\n formatOutput,\n sortResults,\n} from \"@gpc-cli/core\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\nimport { requireConfirm } from \"../prompt.js\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: GpcConfig): 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: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport function registerOneTimeProductsCommands(program: Command): void {\n const otp = program\n .command(\"one-time-products\")\n .alias(\"otp\")\n .description(\"Manage one-time products and offers (modern OTP API)\");\n\n otp\n .command(\"list\")\n .description(\"List one-time products\")\n .option(\"--sort <field>\", \"Sort by field (prefix with - for descending)\")\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 listOneTimeProducts(client, packageName);\n if (options.sort) {\n result.oneTimeProducts = sortResults(result.oneTimeProducts, options.sort);\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 otp\n .command(\"get <product-id>\")\n .description(\"Get a one-time product\")\n .action(async (productId: 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 getOneTimeProduct(client, packageName, productId);\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 otp\n .command(\"create\")\n .description(\"Create a one-time 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 {\n command: \"one-time-products create\",\n action: \"create\",\n target: `one-time product from ${options.file}`,\n },\n format,\n formatOutput,\n );\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 createOneTimeProduct(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 otp\n .command(\"update <product-id>\")\n .description(\"Update a one-time product from JSON file\")\n .requiredOption(\"--file <path>\", \"JSON file with product data\")\n .action(async (productId: 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 {\n command: \"one-time-products update\",\n action: \"update\",\n target: productId,\n details: { file: options.file },\n },\n format,\n formatOutput,\n );\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 updateOneTimeProduct(client, packageName, productId, 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 otp\n .command(\"delete <product-id>\")\n .description(\"Delete a one-time product\")\n .action(async (productId: string) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n\n await requireConfirm(`Delete one-time product \"${productId}\"?`, program);\n\n if (isDryRun(program)) {\n const format = detectOutputFormat();\n printDryRun(\n {\n command: \"one-time-products delete\",\n action: \"delete\",\n target: productId,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n await deleteOneTimeProduct(client, packageName, productId);\n console.log(`One-time product ${productId} deleted.`);\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // --- Offers ---\n const offers = otp.command(\"offers\").description(\"Manage one-time product offers\");\n\n offers\n .command(\"list <product-id>\")\n .description(\"List offers for a one-time product\")\n .option(\"--sort <field>\", \"Sort by field (prefix with - for descending)\")\n .action(async (productId: string, 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 listOneTimeOffers(client, packageName, productId);\n if (options.sort) {\n result.oneTimeOffers = sortResults(result.oneTimeOffers, options.sort);\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 offers\n .command(\"get <product-id> <offer-id>\")\n .description(\"Get an offer for a one-time product\")\n .action(async (productId: string, offerId: 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 getOneTimeOffer(client, packageName, productId, offerId);\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 offers\n .command(\"create <product-id>\")\n .description(\"Create an offer from JSON file\")\n .requiredOption(\"--file <path>\", \"JSON file with offer data\")\n .action(async (productId: string, options: { file: string }) => {\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 {\n command: \"one-time-products offers create\",\n action: \"create offer for\",\n target: productId,\n details: { file: options.file },\n },\n format,\n formatOutput,\n );\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 createOneTimeOffer(client, packageName, productId, 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 offers\n .command(\"update <product-id> <offer-id>\")\n .description(\"Update an offer from JSON file\")\n .requiredOption(\"--file <path>\", \"JSON file with offer data\")\n .action(async (productId: string, offerId: string, options: { file: string }) => {\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 {\n command: \"one-time-products offers update\",\n action: \"update offer\",\n target: `${productId}/${offerId}`,\n details: { file: options.file },\n },\n format,\n formatOutput,\n );\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 updateOneTimeOffer(client, packageName, productId, offerId, 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 offers\n .command(\"delete <product-id> <offer-id>\")\n .description(\"Delete an offer\")\n .action(async (productId: string, offerId: string) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n\n await requireConfirm(`Delete offer \"${offerId}\" for product \"${productId}\"?`, program);\n\n if (isDryRun(program)) {\n const format = detectOutputFormat();\n printDryRun(\n {\n command: \"one-time-products offers delete\",\n action: \"delete offer\",\n target: `${productId}/${offerId}`,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n await deleteOneTimeOffer(client, packageName, productId, offerId);\n console.log(`Offer ${offerId} deleted.`);\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;AAGzB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W;AAAA,IACzC,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":[]}
|
|
@@ -15,9 +15,12 @@ import {
|
|
|
15
15
|
listRecoveryActions,
|
|
16
16
|
cancelRecoveryAction,
|
|
17
17
|
deployRecoveryAction,
|
|
18
|
+
createRecoveryAction,
|
|
19
|
+
addRecoveryTargeting,
|
|
18
20
|
detectOutputFormat,
|
|
19
21
|
formatOutput
|
|
20
22
|
} from "@gpc-cli/core";
|
|
23
|
+
import { readFileSync } from "fs";
|
|
21
24
|
function resolvePackageName(packageArg, config) {
|
|
22
25
|
const name = packageArg || config.app;
|
|
23
26
|
if (!name) {
|
|
@@ -32,7 +35,7 @@ async function getClient(config) {
|
|
|
32
35
|
}
|
|
33
36
|
function registerRecoveryCommands(program) {
|
|
34
37
|
const recovery = program.command("recovery").description("Manage app recovery actions");
|
|
35
|
-
recovery.command("list").description("List app recovery actions").action(async () => {
|
|
38
|
+
recovery.command("list").description("List app recovery actions").option("--limit <n>", "Maximum results to return").option("--next-page <token>", "Pagination token for next page").action(async (options) => {
|
|
36
39
|
const config = await loadConfig();
|
|
37
40
|
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
38
41
|
const client = await getClient(config);
|
|
@@ -61,14 +64,7 @@ function registerRecoveryCommands(program) {
|
|
|
61
64
|
);
|
|
62
65
|
return;
|
|
63
66
|
}
|
|
64
|
-
|
|
65
|
-
`Cancel recovery action ${id}?`,
|
|
66
|
-
program.opts()["yes"]
|
|
67
|
-
);
|
|
68
|
-
if (!confirmed) {
|
|
69
|
-
console.log("Cancelled.");
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
67
|
+
await requireConfirm(`Cancel recovery action ${id}?`, program);
|
|
72
68
|
const client = await getClient(config);
|
|
73
69
|
try {
|
|
74
70
|
await cancelRecoveryAction(client, packageName, id);
|
|
@@ -94,14 +90,7 @@ function registerRecoveryCommands(program) {
|
|
|
94
90
|
);
|
|
95
91
|
return;
|
|
96
92
|
}
|
|
97
|
-
|
|
98
|
-
`Deploy recovery action ${id}?`,
|
|
99
|
-
program.opts()["yes"]
|
|
100
|
-
);
|
|
101
|
-
if (!confirmed) {
|
|
102
|
-
console.log("Cancelled.");
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
93
|
+
await requireConfirm(`Deploy recovery action ${id}?`, program);
|
|
105
94
|
const client = await getClient(config);
|
|
106
95
|
try {
|
|
107
96
|
await deployRecoveryAction(client, packageName, id);
|
|
@@ -111,8 +100,78 @@ function registerRecoveryCommands(program) {
|
|
|
111
100
|
process.exit(4);
|
|
112
101
|
}
|
|
113
102
|
});
|
|
103
|
+
recovery.command("create").description("Create a new app recovery action").requiredOption("--file <path>", "Path to JSON file with recovery action data").action(async (options) => {
|
|
104
|
+
const config = await loadConfig();
|
|
105
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
106
|
+
const format = detectOutputFormat();
|
|
107
|
+
let data;
|
|
108
|
+
try {
|
|
109
|
+
data = JSON.parse(readFileSync(options.file, "utf-8"));
|
|
110
|
+
} catch (err) {
|
|
111
|
+
console.error(
|
|
112
|
+
`Error: Could not read recovery action data from ${options.file}: ${err instanceof Error ? err.message : String(err)}`
|
|
113
|
+
);
|
|
114
|
+
process.exit(2);
|
|
115
|
+
}
|
|
116
|
+
if (isDryRun(program)) {
|
|
117
|
+
printDryRun(
|
|
118
|
+
{
|
|
119
|
+
command: "recovery create",
|
|
120
|
+
action: "create recovery action",
|
|
121
|
+
target: packageName,
|
|
122
|
+
details: data
|
|
123
|
+
},
|
|
124
|
+
format,
|
|
125
|
+
formatOutput
|
|
126
|
+
);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const client = await getClient(config);
|
|
130
|
+
try {
|
|
131
|
+
const result = await createRecoveryAction(client, packageName, data);
|
|
132
|
+
console.log(formatOutput(result, format));
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
135
|
+
process.exit(4);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
recovery.command("add-targeting <action-id>").description("Add targeting rules to an existing recovery action").requiredOption("--file <path>", "Path to JSON file with targeting data").action(async (actionId, options) => {
|
|
139
|
+
const config = await loadConfig();
|
|
140
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
141
|
+
const format = detectOutputFormat();
|
|
142
|
+
let targeting;
|
|
143
|
+
try {
|
|
144
|
+
targeting = JSON.parse(readFileSync(options.file, "utf-8"));
|
|
145
|
+
} catch (err) {
|
|
146
|
+
console.error(
|
|
147
|
+
`Error: Could not read targeting data from ${options.file}: ${err instanceof Error ? err.message : String(err)}`
|
|
148
|
+
);
|
|
149
|
+
process.exit(2);
|
|
150
|
+
}
|
|
151
|
+
if (isDryRun(program)) {
|
|
152
|
+
printDryRun(
|
|
153
|
+
{
|
|
154
|
+
command: "recovery add-targeting",
|
|
155
|
+
action: "add targeting to recovery action",
|
|
156
|
+
target: actionId,
|
|
157
|
+
details: targeting
|
|
158
|
+
},
|
|
159
|
+
format,
|
|
160
|
+
formatOutput
|
|
161
|
+
);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const client = await getClient(config);
|
|
165
|
+
try {
|
|
166
|
+
const result = await addRecoveryTargeting(client, packageName, actionId, targeting);
|
|
167
|
+
console.log(formatOutput(result, format));
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
170
|
+
process.exit(4);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
114
173
|
}
|
|
115
174
|
export {
|
|
116
175
|
registerRecoveryCommands
|
|
117
176
|
};
|
|
118
|
-
//# sourceMappingURL=recovery-
|
|
177
|
+
//# sourceMappingURL=recovery-DC66ZTGD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/recovery.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport {\n listRecoveryActions,\n cancelRecoveryAction,\n deployRecoveryAction,\n createRecoveryAction,\n addRecoveryTargeting,\n detectOutputFormat,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\nimport { requireConfirm } from \"../prompt.js\";\nimport { readFileSync } from \"node:fs\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: GpcConfig): 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: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport function registerRecoveryCommands(program: Command): void {\n const recovery = program.command(\"recovery\").description(\"Manage app recovery actions\");\n\n recovery\n .command(\"list\")\n .description(\"List app recovery actions\")\n .option(\"--limit <n>\", \"Maximum results to return\")\n .option(\"--next-page <token>\", \"Pagination token for next page\")\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 listRecoveryActions(client, packageName);\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 recovery\n .command(\"cancel <id>\")\n .description(\"Cancel a recovery action\")\n .action(async (id: string) => {\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 {\n command: \"recovery cancel\",\n action: \"cancel\",\n target: id,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n await requireConfirm(`Cancel recovery action ${id}?`, program);\n\n const client = await getClient(config);\n\n try {\n await cancelRecoveryAction(client, packageName, id);\n console.log(formatOutput({ success: true, appRecoveryId: id, action: \"cancelled\" }, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n recovery\n .command(\"deploy <id>\")\n .description(\"Deploy a recovery action\")\n .action(async (id: string) => {\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 {\n command: \"recovery deploy\",\n action: \"deploy\",\n target: id,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n await requireConfirm(`Deploy recovery action ${id}?`, program);\n\n const client = await getClient(config);\n\n try {\n await deployRecoveryAction(client, packageName, id);\n console.log(formatOutput({ success: true, appRecoveryId: id, action: \"deployed\" }, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n recovery\n .command(\"create\")\n .description(\"Create a new app recovery action\")\n .requiredOption(\"--file <path>\", \"Path to JSON file with recovery action data\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = detectOutputFormat();\n\n let data: Record<string, unknown>;\n try {\n data = JSON.parse(readFileSync(options.file, \"utf-8\"));\n } catch (err) {\n console.error(\n `Error: Could not read recovery action data from ${options.file}: ${err instanceof Error ? err.message : String(err)}`,\n );\n process.exit(2);\n }\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"recovery create\",\n action: \"create recovery action\",\n target: packageName,\n details: data,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const result = await createRecoveryAction(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 recovery\n .command(\"add-targeting <action-id>\")\n .description(\"Add targeting rules to an existing recovery action\")\n .requiredOption(\"--file <path>\", \"Path to JSON file with targeting data\")\n .action(async (actionId: string, options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = detectOutputFormat();\n\n let targeting: Record<string, unknown>;\n try {\n targeting = JSON.parse(readFileSync(options.file, \"utf-8\"));\n } catch (err) {\n console.error(\n `Error: Could not read targeting data from ${options.file}: ${err instanceof Error ? err.message : String(err)}`,\n );\n process.exit(2);\n }\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"recovery add-targeting\",\n action: \"add targeting to recovery action\",\n target: actionId,\n details: targeting,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const result = await addRecoveryTargeting(client, packageName, actionId, targeting);\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":";;;;;;;;;;AAEA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB,YAAgC,QAA2B;AACrF,QAAM,OAAO,cAAc,OAAO;AAClC,MAAI,CAAC,MAAM;AACT,YAAQ,MAAM,6EAA6E;AAC3F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAe,UAAU,QAAmB;AAC1C,QAAM,OAAO,MAAM,YAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,SAAO,gBAAgB,EAAE,KAAK,CAAC;AACjC;AAEO,SAAS,yBAAyB,SAAwB;AAC/D,QAAM,WAAW,QAAQ,QAAQ,UAAU,EAAE,YAAY,6BAA6B;AAEtF,WACG,QAAQ,MAAM,EACd,YAAY,2BAA2B,EACvC,OA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AO;AACd,cAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;","names":[]}
|
|
@@ -33,7 +33,7 @@ async function getClient(config) {
|
|
|
33
33
|
}
|
|
34
34
|
function registerReportsCommands(program) {
|
|
35
35
|
const reports = program.command("reports").description("Download financial and stats reports");
|
|
36
|
-
reports.command("list <report-type>").description("List available report buckets").option("--month <YYYY-MM>", "Report month (e.g., 2026-03)").action(async (reportType, options) => {
|
|
36
|
+
reports.command("list <report-type>").description("List available report buckets").option("--month <YYYY-MM>", "Report month (e.g., 2026-03)").option("--limit <n>", "Maximum results to return").option("--next-page <token>", "Pagination token for next page").action(async (reportType, options) => {
|
|
37
37
|
const interactive = isInteractive(program);
|
|
38
38
|
const now = /* @__PURE__ */ new Date();
|
|
39
39
|
const defaultMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}`;
|
|
@@ -180,4 +180,4 @@ function registerReportsCommands(program) {
|
|
|
180
180
|
export {
|
|
181
181
|
registerReportsCommands
|
|
182
182
|
};
|
|
183
|
-
//# sourceMappingURL=reports-
|
|
183
|
+
//# sourceMappingURL=reports-T6GBAYUK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/reports.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport {\n listReports,\n downloadReport,\n parseMonth,\n isValidReportType,\n isFinancialReportType,\n isStatsReportType,\n detectOutputFormat,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport type { ReportType } from \"@gpc-cli/api\";\nimport { writeFile } from \"node:fs/promises\";\nimport { isInteractive, requireOption } from \"../prompt.js\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: GpcConfig): 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: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport function registerReportsCommands(program: Command): void {\n const reports = program.command(\"reports\").description(\"Download financial and stats reports\");\n\n reports\n .command(\"list <report-type>\")\n .description(\"List available report buckets\")\n .option(\"--month <YYYY-MM>\", \"Report month (e.g., 2026-03)\")\n .option(\"--limit <n>\", \"Maximum results to return\")\n .option(\"--next-page <token>\", \"Pagination token for next page\")\n .action(async (reportType: string, options) => {\n const interactive = isInteractive(program);\n const now = new Date();\n const defaultMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}`;\n\n options.month = await requireOption(\n \"month\",\n options.month,\n {\n message: \"Report month (YYYY-MM):\",\n default: defaultMonth,\n },\n interactive,\n );\n\n if (!isValidReportType(reportType)) {\n console.error(\n `Error: Invalid report type \"${reportType}\". Valid types: earnings, sales, estimated_sales, installs, crashes, ratings, reviews, store_performance, subscriptions, play_balance`,\n );\n process.exit(2);\n }\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 { year, month } = parseMonth(options.month);\n const result = await listReports(\n client,\n packageName,\n reportType as ReportType,\n year,\n month,\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 const download = reports.command(\"download\").description(\"Download a report\");\n\n download\n .command(\"financial\")\n .description(\"Download a financial report\")\n .option(\"--month <YYYY-MM>\", \"Report month (e.g., 2026-03)\")\n .option(\"--type <report-type>\", \"Report type\", \"earnings\")\n .option(\"--output-file <path>\", \"Save to file instead of stdout\")\n .action(async (options) => {\n const interactive = isInteractive(program);\n const now = new Date();\n const defaultMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}`;\n\n options.month = await requireOption(\n \"month\",\n options.month,\n {\n message: \"Report month (YYYY-MM):\",\n default: defaultMonth,\n },\n interactive,\n );\n\n if (!isFinancialReportType(options.type)) {\n console.error(\n `Error: Invalid financial report type \"${options.type}\". Valid types: earnings, sales, estimated_sales, play_balance`,\n );\n process.exit(2);\n }\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const client = await getClient(config);\n\n try {\n const { year, month } = parseMonth(options.month);\n const csv = await downloadReport(\n client,\n packageName,\n options.type as ReportType,\n year,\n month,\n );\n if (options.outputFile) {\n await writeFile(options.outputFile, csv, \"utf-8\");\n console.log(`Report saved to ${options.outputFile}`);\n } else {\n console.log(csv);\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n download\n .command(\"stats\")\n .description(\"Download a stats report\")\n .option(\"--month <YYYY-MM>\", \"Report month (e.g., 2026-03)\")\n .option(\n \"--type <report-type>\",\n \"Report type (installs, crashes, ratings, reviews, store_performance, subscriptions)\",\n )\n .option(\"--output-file <path>\", \"Save to file instead of stdout\")\n .action(async (options) => {\n const interactive = isInteractive(program);\n const now = new Date();\n const defaultMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}`;\n const statsTypes = [\n \"installs\",\n \"crashes\",\n \"ratings\",\n \"reviews\",\n \"store_performance\",\n \"subscriptions\",\n ];\n\n options.month = await requireOption(\n \"month\",\n options.month,\n {\n message: \"Report month (YYYY-MM):\",\n default: defaultMonth,\n },\n interactive,\n );\n\n options.type = await requireOption(\n \"type\",\n options.type,\n {\n message: \"Stats report type:\",\n choices: statsTypes,\n },\n interactive,\n );\n\n if (!isStatsReportType(options.type)) {\n console.error(\n `Error: Invalid stats report type \"${options.type}\". Valid types: installs, crashes, ratings, reviews, store_performance, subscriptions`,\n );\n process.exit(2);\n }\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const client = await getClient(config);\n\n try {\n const { year, month } = parseMonth(options.month);\n const csv = await downloadReport(\n client,\n packageName,\n options.type as ReportType,\n year,\n month,\n );\n if (options.outputFile) {\n await writeFile(options.outputFile, csv, \"utf-8\");\n console.log(`Report saved to ${options.outputFile}`);\n } else {\n console.log(csv);\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n"],"mappings":";;;;;;;AAEA,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;AAEP,SAAS,iBAAiB;AAG1B,SAAS,mBAAmB,YAAgC,QAA2B;AACrF,QAAM,OAAO,cAAc,OAAO;AAClC,MAAI,CAAC,MAAM;AACT,YAAQ,MAAM,6EAA6E;AAC3F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAe,UAAU,QAAmB;AAC1C,QAAM,OAAO,MAAM,YAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,SAAO,gBAAgB,EAAE,KAAK,CAAC;AACjC;AAEO,SAAS,wBAAwB,SAAwB;AAC9D,QAAM,UAAU,QAAQ,QAAQ,SAAS,EAAE,YAAY,sCAAsC;AAE7F,UACG,QAAQ,oBAAoB,EAC5B,YAAY,+BAA+B,EAC3C,OAAO,qBAAqB,8BAA8B,EAC1D,OAAO,eAAe,2BAA2B,EACjD,OAAO,uBAAuB,gCAAgC,EAC9D,OAAO,OAAO,YAAoB,YAAY;AAC7C,UAAM,cAAc,cAAc,OAAO;AACzC,UAAM,MAAM,oBAAI,KAAK;AACrB,UAAM,eAAe,GAAG,IAAI,YAAY,CAAC,IAAI,OAAO,IAAI,SAAS,IAAI,CAAC,EAAE,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A,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,YAAQ,QAAQ,MAAM;AAAA,MACpB;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,QACE,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,MACA;AAAA,IACF;AAEA,YAAQ,OAAO,MAAM;AAAA,MACnB;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,QACE,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,MACA;AAAA,IACF;AAEA,QAAI,CAAC,kBAAkB,QAAQ,IAAI,GAAG;AACpC,cAAQ;AAAA,QACN,qCAAqC,QAAQ,IAAI;AAAA,MACnD;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,cAAc,mBAAmB,QAAQ,KAAK,EAAE,KAAK,GAAG,MAAM;AACpE,UAAM,SAAS,MAAM,UAAU,MAAM;AAErC,QAAI;AACF,YAAM,EAAE,MAAM,MAAM,IAAI,WAAW,QAAQ,KAAK;AAChD,YAAM,MAAM,MAAM;AAAA,QAChB;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,MACF;AACA,UAAI,QAAQ,YAAY;AACtB,cAAM,UAAU,QAAQ,YAAY,KAAK,OAAO;AAChD,gBAAQ,IAAI,mBAAmB,QAAQ,UAAU,EAAE;AAAA,MACrD,OAAO;AACL,gBAAQ,IAAI,GAAG;AAAA,MACjB;AAAA,IACF,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":[]}
|
|
@@ -35,7 +35,7 @@ async function getClient(config) {
|
|
|
35
35
|
}
|
|
36
36
|
function registerTestersCommands(program) {
|
|
37
37
|
const testers = program.command("testers").description("Manage testers and tester groups");
|
|
38
|
-
testers.command("list").description("List testers for a track").option("--track <track>", "Track name (e.g., internal, alpha, beta)").option("--sort <field>", "Sort by field (prefix with - for descending, e.g., email or -email)").action(async (options) => {
|
|
38
|
+
testers.command("list").description("List testers for a track").option("--track <track>", "Track name (e.g., internal, alpha, beta)").option("--sort <field>", "Sort by field (prefix with - for descending, e.g., email or -email)").option("--limit <n>", "Maximum results to return").option("--next-page <token>", "Pagination token for next page").action(async (options) => {
|
|
39
39
|
const config = await loadConfig();
|
|
40
40
|
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
41
41
|
const interactive = isInteractive(program);
|
|
@@ -185,4 +185,4 @@ function registerTestersCommands(program) {
|
|
|
185
185
|
export {
|
|
186
186
|
registerTestersCommands
|
|
187
187
|
};
|
|
188
|
-
//# sourceMappingURL=testers-
|
|
188
|
+
//# sourceMappingURL=testers-NXWT2PFS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/testers.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport {\n listTesters,\n addTesters,\n removeTesters,\n importTestersFromCsv,\n detectOutputFormat,\n formatOutput,\n sortResults,\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: GpcConfig): 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: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport function registerTestersCommands(program: Command): void {\n const testers = program.command(\"testers\").description(\"Manage testers and tester groups\");\n\n testers\n .command(\"list\")\n .description(\"List testers for a track\")\n .option(\"--track <track>\", \"Track name (e.g., internal, alpha, beta)\")\n .option(\"--sort <field>\", \"Sort by field (prefix with - for descending, e.g., email or -email)\")\n .option(\"--limit <n>\", \"Maximum results to return\")\n .option(\"--next-page <token>\", \"Pagination token for next page\")\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.track = await requireOption(\n \"track\",\n options.track,\n {\n message: \"Track:\",\n choices: [\"internal\", \"alpha\", \"beta\"],\n },\n interactive,\n );\n\n const client = await getClient(config);\n const format = detectOutputFormat();\n\n try {\n const result = await listTesters(client, packageName, options.track);\n if (options.sort && result.googleGroups) {\n const descending = options.sort.startsWith(\"-\");\n result.googleGroups = [...result.googleGroups].sort((a: string, b: string) =>\n descending ? b.localeCompare(a) : a.localeCompare(b),\n );\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 testers\n .command(\"add <emails...>\")\n .description(\"Add testers (Google Group emails) to a track\")\n .option(\"--track <track>\", \"Track name (e.g., internal, alpha, beta)\")\n .action(async (emails: string[], options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = detectOutputFormat();\n const interactive = isInteractive(program);\n\n options.track = await requireOption(\n \"track\",\n options.track,\n {\n message: \"Track:\",\n choices: [\"internal\", \"alpha\", \"beta\"],\n },\n interactive,\n );\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"testers add\",\n action: \"add testers to\",\n target: options.track,\n details: { emails },\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const result = await addTesters(client, packageName, options.track, emails);\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 testers\n .command(\"remove <emails...>\")\n .description(\"Remove testers (Google Group emails) from a track\")\n .option(\"--track <track>\", \"Track name (e.g., internal, alpha, beta)\")\n .action(async (emails: string[], options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = detectOutputFormat();\n const interactive = isInteractive(program);\n\n options.track = await requireOption(\n \"track\",\n options.track,\n {\n message: \"Track:\",\n choices: [\"internal\", \"alpha\", \"beta\"],\n },\n interactive,\n );\n\n await requireConfirm(`Remove ${emails.length} tester(s) from ${options.track}?`, program);\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"testers remove\",\n action: \"remove testers from\",\n target: options.track,\n details: { emails },\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const result = await removeTesters(client, packageName, options.track, emails);\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 testers\n .command(\"import\")\n .description(\"Import testers from a CSV file\")\n .option(\"--track <track>\", \"Track name (e.g., internal, alpha, beta)\")\n .option(\"--file <path>\", \"CSV file with email addresses\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = detectOutputFormat();\n const interactive = isInteractive(program);\n\n options.track = await requireOption(\n \"track\",\n options.track,\n {\n message: \"Track:\",\n choices: [\"internal\", \"alpha\", \"beta\"],\n },\n interactive,\n );\n\n options.file = await requireOption(\n \"file\",\n options.file,\n {\n message: \"CSV file path:\",\n },\n interactive,\n );\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"testers import\",\n action: \"import testers to\",\n target: options.track,\n details: { file: options.file },\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const result = await importTestersFromCsv(client, packageName, options.track, options.file);\n console.log(formatOutput({ added: result.added, testers: result.testers }, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;AAEA,SAAS,kBAA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AG,MAAM;AACpE,UAAM,SAAS,mBAAmB;AAClC,UAAM,cAAc,cAAc,OAAO;AAEzC,YAAQ,QAAQ,MAAM;AAAA,MACpB;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,QACE,SAAS;AAAA,QACT,SAAS,CAAC,YAAY,SAAS,MAAM;AAAA,MACvC;AAAA,MACA;AAAA,IACF;AAEA,YAAQ,OAAO,MAAM;AAAA,MACnB;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,QACE,SAAS;AAAA,MACX;AAAA,MACA;AAAA,IACF;AAEA,QAAI,SAAS,OAAO,GAAG;AACrB;AAAA,QACE;AAAA,UACE,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,QAAQ,QAAQ;AAAA,UAChB,SAAS,EAAE,MAAM,QAAQ,KAAK;AAAA,QAChC;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,UAAU,MAAM;AAErC,QAAI;AACF,YAAM,SAAS,MAAM,qBAAqB,QAAQ,aAAa,QAAQ,OAAO,QAAQ,IAAI;AAC1F,cAAQ,IAAI,aAAa,EAAE,OAAO,OAAO,OAAO,SAAS,OAAO,QAAQ,GAAG,MAAM,CAAC;AAAA,IACpF,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":[]}
|
|
@@ -8,7 +8,7 @@ import { listTracks } from "@gpc-cli/core";
|
|
|
8
8
|
import { detectOutputFormat, formatOutput } from "@gpc-cli/core";
|
|
9
9
|
function registerTracksCommands(program) {
|
|
10
10
|
const tracks = program.command("tracks").description("Manage tracks");
|
|
11
|
-
tracks.command("list").description("List all tracks").action(async () => {
|
|
11
|
+
tracks.command("list").description("List all tracks").option("--limit <n>", "Maximum results to return").option("--next-page <token>", "Pagination token for next page").action(async (options) => {
|
|
12
12
|
const config = await loadConfig();
|
|
13
13
|
const packageName = program.opts()["app"] || config.app;
|
|
14
14
|
if (!packageName) {
|
|
@@ -38,4 +38,4 @@ function registerTracksCommands(program) {
|
|
|
38
38
|
export {
|
|
39
39
|
registerTracksCommands
|
|
40
40
|
};
|
|
41
|
-
//# sourceMappingURL=tracks-
|
|
41
|
+
//# sourceMappingURL=tracks-AJH5KP7J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/tracks.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 { listTracks } from \"@gpc-cli/core\";\nimport { detectOutputFormat, formatOutput } from \"@gpc-cli/core\";\n\nexport function registerTracksCommands(program: Command): void {\n const tracks = program.command(\"tracks\").description(\"Manage tracks\");\n\n tracks\n .command(\"list\")\n .description(\"List all tracks\")\n .option(\"--limit <n>\", \"Maximum results to return\")\n .option(\"--next-page <token>\", \"Pagination token for next page\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = program.opts()[\"app\"] || config.app;\n if (!packageName) {\n console.error(\n \"Error: No package name. Use --app <package> or gpc config set app <package>\",\n );\n process.exit(2);\n }\n\n try {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n const client = createApiClient({ auth });\n const trackList = await listTracks(client, packageName);\n const format = detectOutputFormat();\n\n const summary = trackList.map((t) => ({\n track: t.track,\n releases: t.releases?.length || 0,\n latestStatus: t.releases?.[0]?.status || \"none\",\n latestVersion: t.releases?.[0]?.versionCodes?.[0] || \"-\",\n }));\n\n console.log(formatOutput(summary, 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,SAAS,kBAAkB;AAC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"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"commander": "^14.0.3",
|
|
22
|
-
"@gpc-cli/api": "1.0.6",
|
|
23
22
|
"@gpc-cli/auth": "^0.9.7",
|
|
23
|
+
"@gpc-cli/api": "1.0.7",
|
|
24
24
|
"@gpc-cli/config": "0.9.6",
|
|
25
|
-
"@gpc-cli/
|
|
26
|
-
"@gpc-cli/
|
|
25
|
+
"@gpc-cli/core": "0.9.8",
|
|
26
|
+
"@gpc-cli/plugin-sdk": "0.9.5"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [
|
|
29
29
|
"google-play",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/apps.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 { getAppInfo, updateAppDetails } from \"@gpc-cli/core\";\nimport { detectOutputFormat, formatOutput } from \"@gpc-cli/core\";\n\nexport function registerAppsCommands(program: Command): void {\n const apps = program.command(\"apps\").description(\"Manage applications\");\n\n apps\n .command(\"info [package]\")\n .description(\"Show app details\")\n .action(async (packageArg?: string) => {\n const config = await loadConfig();\n const packageName = packageArg || config.app;\n\n if (!packageName) {\n console.error(\"Error: No package name provided.\");\n console.error(\"Usage: gpc apps info <package>\");\n console.error(\"Or set a default: gpc config set app com.example.app\");\n process.exit(2);\n }\n\n try {\n const auth = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n });\n const client = createApiClient({ auth });\n const info = await getAppInfo(client, packageName);\n const format = detectOutputFormat();\n console.log(formatOutput(info, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n apps\n .command(\"update\")\n .description(\"Update app details\")\n .option(\"--email <email>\", \"Contact email\")\n .option(\"--phone <phone>\", \"Contact phone\")\n .option(\"--website <url>\", \"Contact website\")\n .option(\"--default-lang <lang>\", \"Default language\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = options[\"app\"] || program.opts()[\"app\"] || config.app;\n\n if (!packageName) {\n console.error(\"Error: No package name provided.\");\n console.error(\"Usage: gpc apps update --email user@example.com\");\n process.exit(2);\n }\n\n const data: Record<string, string> = {};\n if (options[\"email\"]) data[\"contactEmail\"] = options[\"email\"];\n if (options[\"phone\"]) data[\"contactPhone\"] = options[\"phone\"];\n if (options[\"website\"]) data[\"contactWebsite\"] = options[\"website\"];\n if (options[\"defaultLang\"]) data[\"defaultLanguage\"] = options[\"defaultLang\"];\n\n if (Object.keys(data).length === 0) {\n console.error(\n \"Error: Provide at least one field to update (--email, --phone, --website, --default-lang).\",\n );\n process.exit(2);\n }\n\n try {\n const auth = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n });\n const client = createApiClient({ auth });\n const result = await updateAppDetails(client, packageName, data);\n const format = detectOutputFormat();\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 apps\n .command(\"list\")\n .description(\"List configured applications\")\n .action(async () => {\n const config = await loadConfig();\n const format = detectOutputFormat();\n\n if (config.app) {\n const apps = [{ packageName: config.app, source: \"config\" }];\n console.log(formatOutput(apps, format));\n } else {\n console.log(\"No apps configured.\");\n console.log(\"\");\n console.log(\"Set a default app:\");\n console.log(\" gpc config set app com.example.myapp\");\n console.log(\"\");\n console.log(\"Or use the --app flag:\");\n console.log(\" gpc apps info --app com.example.myapp\");\n }\n });\n}\n"],"mappings":";;;AACA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,YAAY,wBAAwB;AAC7C,SAAS,oBAAoB,oBAAoB;AAE1C,SAAS,qBAAqB,SAAwB;AAC3D,QAAM,OAAO,QAAQ,QAAQ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