@gpc-cli/core 0.9.19 → 0.9.20
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/index.d.ts +14 -1
- package/dist/index.js +89 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -629,6 +629,19 @@ declare function redactAuditArgs(entry: AuditEntry): AuditEntry;
|
|
|
629
629
|
* Convenience: create an audit entry for a write command.
|
|
630
630
|
*/
|
|
631
631
|
declare function createAuditEntry(command: string, args: Record<string, unknown>, app?: string): AuditEntry;
|
|
632
|
+
declare function listAuditEvents(options?: {
|
|
633
|
+
limit?: number;
|
|
634
|
+
since?: string;
|
|
635
|
+
command?: string;
|
|
636
|
+
}): Promise<AuditEntry[]>;
|
|
637
|
+
declare function searchAuditEvents(query: string): Promise<AuditEntry[]>;
|
|
638
|
+
declare function clearAuditLog(options?: {
|
|
639
|
+
before?: string;
|
|
640
|
+
dryRun?: boolean;
|
|
641
|
+
}): Promise<{
|
|
642
|
+
deleted: number;
|
|
643
|
+
remaining: number;
|
|
644
|
+
}>;
|
|
632
645
|
|
|
633
646
|
interface WebhookPayload {
|
|
634
647
|
command: string;
|
|
@@ -663,4 +676,4 @@ declare function createPurchaseOption(client: PlayApiClient, packageName: string
|
|
|
663
676
|
declare function activatePurchaseOption(client: PlayApiClient, packageName: string, purchaseOptionId: string): Promise<PurchaseOption>;
|
|
664
677
|
declare function deactivatePurchaseOption(client: PlayApiClient, packageName: string, purchaseOptionId: string): Promise<PurchaseOption>;
|
|
665
678
|
|
|
666
|
-
export { ApiError, type AppInfo, type AuditEntry, type BatchSyncResult, type CommandContext, ConfigError, type DiscoverPluginsOptions, type DryRunPublishResult, type DryRunResult, type DryRunUploadResult, type ExportImagesOptions, type ExportImagesSummary, type FastlaneDetection, type FastlaneLane, type FileValidationResult, GOOGLE_PLAY_LANGUAGES, type GitNotesOptions, type GitReleaseNotes, GpcError, type ImageValidationResult, type InternalSharingUploadResult, type ListIapOptions, type ListSubscriptionsOptions, type ListUsersOptions, type ListVoidedOptions, type ListingDiff, type ListingsResult, type LoadedPlugin, type MigrationResult, NetworkError, type OneTimeProductDiff, PERMISSION_PROPAGATION_WARNING, type ParsedMonth, PluginManager, type PublishOptions, type PublishResult, type PushResult, type ReleaseDiff, type ReleaseNotesValidation, type ReleaseStatusResult, type ReviewExportOptions, type ReviewsFilterOptions, SENSITIVE_ARG_KEYS, SENSITIVE_KEYS, type ScaffoldOptions, type ScaffoldResult, type Spinner, type SubscriptionDiff, type SyncResult, type ThresholdResult, type UploadResult, type ValidateCheck, type ValidateOptions, type ValidateResult, type VitalsOverview, type VitalsQueryOptions, type VitalsTrendComparison, type WebhookPayload, acknowledgeProductPurchase, activateBasePlan, activateOffer, activatePurchaseOption, addRecoveryTargeting, addTesters, batchSyncInAppProducts, cancelRecoveryAction, cancelSubscriptionPurchase, checkThreshold, compareVitalsTrend, consumeProductPurchase, convertRegionPrices, createAuditEntry, createDeviceTier, createExternalTransaction, createInAppProduct, createOffer, createOneTimeOffer, createOneTimeProduct, createPurchaseOption, createRecoveryAction, createSpinner, createSubscription, createTrack, deactivateBasePlan, deactivateOffer, deactivatePurchaseOption, deferSubscriptionPurchase, deleteBasePlan, deleteImage, deleteInAppProduct, deleteListing, deleteOffer, deleteOneTimeOffer, deleteOneTimeProduct, deleteSubscription, deployRecoveryAction, detectFastlane, detectOutputFormat, diffListings, diffListingsCommand, diffOneTimeProduct, diffReleases, diffSubscription, discoverPlugins, downloadGeneratedApk, downloadReport, exportDataSafety, exportImages, exportReviews, formatCustomPayload, formatDiscordPayload, formatJunit, formatOutput, formatSlackPayload, generateMigrationPlan, generateNotesFromGit, getAppInfo, getCountryAvailability, getDataSafety, getDeviceTier, getExternalTransaction, getInAppProduct, getListings, getOffer, getOneTimeOffer, getOneTimeProduct, getProductPurchase, getPurchaseOption, getReleasesStatus, getReview, getSubscription, getSubscriptionPurchase, getUser, getVitalsAnomalies, getVitalsAnr, getVitalsBattery, getVitalsCrashes, getVitalsMemory, getVitalsOverview, getVitalsRendering, getVitalsStartup, importDataSafety, importTestersFromCsv, initAudit, inviteUser, isFinancialReportType, isStatsReportType, isValidBcp47, isValidReportType, isValidStatsDimension, listDeviceTiers, listGeneratedApks, listImages, listInAppProducts, listOffers, listOneTimeOffers, listOneTimeProducts, listPurchaseOptions, listRecoveryActions, listReports, listReviews, listSubscriptions, listTesters, listTracks, listUsers, listVoidedPurchases, migratePrices, parseAppfile, parseFastfile, parseGrantArg, parseMonth, promoteRelease, publish, pullListings, pushListings, readListingsFromDir, readReleaseNotesFromDir, redactAuditArgs, redactSensitive, refundExternalTransaction, refundOrder, removeTesters, removeUser, replyToReview, revokeSubscriptionPurchase, safePath, safePathWithin, scaffoldPlugin, searchVitalsErrors, sendWebhook, sortResults, syncInAppProducts, updateAppDetails, updateDataSafety, updateInAppProduct, updateListing, updateOffer, updateOneTimeOffer, updateOneTimeProduct, updateRollout, updateSubscription, updateTrackConfig, updateUser, uploadExternallyHosted, uploadImage, uploadInternalSharing, uploadRelease, validateImage, validateLanguageCode, validatePackageName, validatePreSubmission, validateReleaseNotes, validateSku, validateTrackName, validateUploadFile, validateVersionCode, writeAuditLog, writeListingsToDir, writeMigrationOutput };
|
|
679
|
+
export { ApiError, type AppInfo, type AuditEntry, type BatchSyncResult, type CommandContext, ConfigError, type DiscoverPluginsOptions, type DryRunPublishResult, type DryRunResult, type DryRunUploadResult, type ExportImagesOptions, type ExportImagesSummary, type FastlaneDetection, type FastlaneLane, type FileValidationResult, GOOGLE_PLAY_LANGUAGES, type GitNotesOptions, type GitReleaseNotes, GpcError, type ImageValidationResult, type InternalSharingUploadResult, type ListIapOptions, type ListSubscriptionsOptions, type ListUsersOptions, type ListVoidedOptions, type ListingDiff, type ListingsResult, type LoadedPlugin, type MigrationResult, NetworkError, type OneTimeProductDiff, PERMISSION_PROPAGATION_WARNING, type ParsedMonth, PluginManager, type PublishOptions, type PublishResult, type PushResult, type ReleaseDiff, type ReleaseNotesValidation, type ReleaseStatusResult, type ReviewExportOptions, type ReviewsFilterOptions, SENSITIVE_ARG_KEYS, SENSITIVE_KEYS, type ScaffoldOptions, type ScaffoldResult, type Spinner, type SubscriptionDiff, type SyncResult, type ThresholdResult, type UploadResult, type ValidateCheck, type ValidateOptions, type ValidateResult, type VitalsOverview, type VitalsQueryOptions, type VitalsTrendComparison, type WebhookPayload, acknowledgeProductPurchase, activateBasePlan, activateOffer, activatePurchaseOption, addRecoveryTargeting, addTesters, batchSyncInAppProducts, cancelRecoveryAction, cancelSubscriptionPurchase, checkThreshold, clearAuditLog, compareVitalsTrend, consumeProductPurchase, convertRegionPrices, createAuditEntry, createDeviceTier, createExternalTransaction, createInAppProduct, createOffer, createOneTimeOffer, createOneTimeProduct, createPurchaseOption, createRecoveryAction, createSpinner, createSubscription, createTrack, deactivateBasePlan, deactivateOffer, deactivatePurchaseOption, deferSubscriptionPurchase, deleteBasePlan, deleteImage, deleteInAppProduct, deleteListing, deleteOffer, deleteOneTimeOffer, deleteOneTimeProduct, deleteSubscription, deployRecoveryAction, detectFastlane, detectOutputFormat, diffListings, diffListingsCommand, diffOneTimeProduct, diffReleases, diffSubscription, discoverPlugins, downloadGeneratedApk, downloadReport, exportDataSafety, exportImages, exportReviews, formatCustomPayload, formatDiscordPayload, formatJunit, formatOutput, formatSlackPayload, generateMigrationPlan, generateNotesFromGit, getAppInfo, getCountryAvailability, getDataSafety, getDeviceTier, getExternalTransaction, getInAppProduct, getListings, getOffer, getOneTimeOffer, getOneTimeProduct, getProductPurchase, getPurchaseOption, getReleasesStatus, getReview, getSubscription, getSubscriptionPurchase, getUser, getVitalsAnomalies, getVitalsAnr, getVitalsBattery, getVitalsCrashes, getVitalsMemory, getVitalsOverview, getVitalsRendering, getVitalsStartup, importDataSafety, importTestersFromCsv, initAudit, inviteUser, isFinancialReportType, isStatsReportType, isValidBcp47, isValidReportType, isValidStatsDimension, listAuditEvents, listDeviceTiers, listGeneratedApks, listImages, listInAppProducts, listOffers, listOneTimeOffers, listOneTimeProducts, listPurchaseOptions, listRecoveryActions, listReports, listReviews, listSubscriptions, listTesters, listTracks, listUsers, listVoidedPurchases, migratePrices, parseAppfile, parseFastfile, parseGrantArg, parseMonth, promoteRelease, publish, pullListings, pushListings, readListingsFromDir, readReleaseNotesFromDir, redactAuditArgs, redactSensitive, refundExternalTransaction, refundOrder, removeTesters, removeUser, replyToReview, revokeSubscriptionPurchase, safePath, safePathWithin, scaffoldPlugin, searchAuditEvents, searchVitalsErrors, sendWebhook, sortResults, syncInAppProducts, updateAppDetails, updateDataSafety, updateInAppProduct, updateListing, updateOffer, updateOneTimeOffer, updateOneTimeProduct, updateRollout, updateSubscription, updateTrackConfig, updateUser, uploadExternallyHosted, uploadImage, uploadInternalSharing, uploadRelease, validateImage, validateLanguageCode, validatePackageName, validatePreSubmission, validateReleaseNotes, validateSku, validateTrackName, validateUploadFile, validateVersionCode, writeAuditLog, writeListingsToDir, writeMigrationOutput };
|
package/dist/index.js
CHANGED
|
@@ -1329,7 +1329,7 @@ var ALL_IMAGE_TYPES = [
|
|
|
1329
1329
|
"tvBanner"
|
|
1330
1330
|
];
|
|
1331
1331
|
async function exportImages(client, packageName, dir, options) {
|
|
1332
|
-
const { mkdir: mkdir5, writeFile:
|
|
1332
|
+
const { mkdir: mkdir5, writeFile: writeFile7 } = await import("fs/promises");
|
|
1333
1333
|
const { join: join7 } = await import("path");
|
|
1334
1334
|
const edit = await client.edits.insert(packageName);
|
|
1335
1335
|
try {
|
|
@@ -1366,7 +1366,7 @@ async function exportImages(client, packageName, dir, options) {
|
|
|
1366
1366
|
const response = await fetch(task.url);
|
|
1367
1367
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
1368
1368
|
const filePath = join7(dirPath, `${task.index}.png`);
|
|
1369
|
-
await
|
|
1369
|
+
await writeFile7(filePath, buffer);
|
|
1370
1370
|
return buffer.length;
|
|
1371
1371
|
})
|
|
1372
1372
|
);
|
|
@@ -1956,7 +1956,8 @@ function buildQuery(metricSet, options) {
|
|
|
1956
1956
|
const metrics = METRIC_SET_METRICS[metricSet] ?? ["errorReportCount", "distinctUsers"];
|
|
1957
1957
|
const days = options?.days ?? 30;
|
|
1958
1958
|
const end = /* @__PURE__ */ new Date();
|
|
1959
|
-
|
|
1959
|
+
end.setDate(end.getDate() - 1);
|
|
1960
|
+
const start = new Date(end);
|
|
1960
1961
|
start.setDate(start.getDate() - days);
|
|
1961
1962
|
const query = {
|
|
1962
1963
|
metrics,
|
|
@@ -2036,6 +2037,7 @@ async function searchVitalsErrors(reporting, packageName, options) {
|
|
|
2036
2037
|
}
|
|
2037
2038
|
async function compareVitalsTrend(reporting, packageName, metricSet, days = 7) {
|
|
2038
2039
|
const now = /* @__PURE__ */ new Date();
|
|
2040
|
+
now.setDate(now.getDate() - 1);
|
|
2039
2041
|
const currentEnd = new Date(now);
|
|
2040
2042
|
const currentStart = new Date(now);
|
|
2041
2043
|
currentStart.setDate(currentStart.getDate() - days);
|
|
@@ -3374,7 +3376,7 @@ describe("${pluginName}", () => {
|
|
|
3374
3376
|
}
|
|
3375
3377
|
|
|
3376
3378
|
// src/audit.ts
|
|
3377
|
-
import { appendFile, chmod, mkdir as mkdir4 } from "fs/promises";
|
|
3379
|
+
import { appendFile, chmod, mkdir as mkdir4, readFile as readFile8, writeFile as writeFile5 } from "fs/promises";
|
|
3378
3380
|
import { join as join6 } from "path";
|
|
3379
3381
|
var auditDir = null;
|
|
3380
3382
|
function initAudit(configDir) {
|
|
@@ -3437,6 +3439,84 @@ function createAuditEntry(command, args, app) {
|
|
|
3437
3439
|
args
|
|
3438
3440
|
};
|
|
3439
3441
|
}
|
|
3442
|
+
async function listAuditEvents(options) {
|
|
3443
|
+
if (!auditDir) return [];
|
|
3444
|
+
const logPath = join6(auditDir, "audit.log");
|
|
3445
|
+
let content;
|
|
3446
|
+
try {
|
|
3447
|
+
content = await readFile8(logPath, "utf-8");
|
|
3448
|
+
} catch {
|
|
3449
|
+
return [];
|
|
3450
|
+
}
|
|
3451
|
+
const lines = content.trim().split("\n").filter(Boolean);
|
|
3452
|
+
let entries = [];
|
|
3453
|
+
for (const line of lines) {
|
|
3454
|
+
try {
|
|
3455
|
+
entries.push(JSON.parse(line));
|
|
3456
|
+
} catch {
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
if (options?.since) {
|
|
3460
|
+
const sinceDate = new Date(options.since).getTime();
|
|
3461
|
+
entries = entries.filter((e) => new Date(e.timestamp).getTime() >= sinceDate);
|
|
3462
|
+
}
|
|
3463
|
+
if (options?.command) {
|
|
3464
|
+
const cmd = options.command.toLowerCase();
|
|
3465
|
+
entries = entries.filter((e) => e.command.toLowerCase().includes(cmd));
|
|
3466
|
+
}
|
|
3467
|
+
if (options?.limit) {
|
|
3468
|
+
entries = entries.slice(-options.limit);
|
|
3469
|
+
}
|
|
3470
|
+
return entries;
|
|
3471
|
+
}
|
|
3472
|
+
async function searchAuditEvents(query) {
|
|
3473
|
+
const all = await listAuditEvents();
|
|
3474
|
+
const q = query.toLowerCase();
|
|
3475
|
+
return all.filter((e) => {
|
|
3476
|
+
const text = JSON.stringify(e).toLowerCase();
|
|
3477
|
+
return text.includes(q);
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
async function clearAuditLog(options) {
|
|
3481
|
+
if (!auditDir) return { deleted: 0, remaining: 0 };
|
|
3482
|
+
const logPath = join6(auditDir, "audit.log");
|
|
3483
|
+
let content;
|
|
3484
|
+
try {
|
|
3485
|
+
content = await readFile8(logPath, "utf-8");
|
|
3486
|
+
} catch {
|
|
3487
|
+
return { deleted: 0, remaining: 0 };
|
|
3488
|
+
}
|
|
3489
|
+
const lines = content.trim().split("\n").filter(Boolean);
|
|
3490
|
+
if (!options?.before) {
|
|
3491
|
+
const count = lines.length;
|
|
3492
|
+
if (!options?.dryRun) {
|
|
3493
|
+
await writeFile5(logPath, "", { encoding: "utf-8", mode: 384 });
|
|
3494
|
+
}
|
|
3495
|
+
return { deleted: count, remaining: 0 };
|
|
3496
|
+
}
|
|
3497
|
+
const beforeDate = new Date(options.before).getTime();
|
|
3498
|
+
const keep = [];
|
|
3499
|
+
const remove = [];
|
|
3500
|
+
for (const line of lines) {
|
|
3501
|
+
try {
|
|
3502
|
+
const entry = JSON.parse(line);
|
|
3503
|
+
if (new Date(entry.timestamp).getTime() < beforeDate) {
|
|
3504
|
+
remove.push(line);
|
|
3505
|
+
} else {
|
|
3506
|
+
keep.push(line);
|
|
3507
|
+
}
|
|
3508
|
+
} catch {
|
|
3509
|
+
keep.push(line);
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
if (!options?.dryRun) {
|
|
3513
|
+
await writeFile5(logPath, keep.length > 0 ? keep.join("\n") + "\n" : "", {
|
|
3514
|
+
encoding: "utf-8",
|
|
3515
|
+
mode: 384
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3518
|
+
return { deleted: remove.length, remaining: keep.length };
|
|
3519
|
+
}
|
|
3440
3520
|
|
|
3441
3521
|
// src/utils/webhooks.ts
|
|
3442
3522
|
function formatSlackPayload(payload) {
|
|
@@ -3583,7 +3663,7 @@ function detectFileType(filePath) {
|
|
|
3583
3663
|
}
|
|
3584
3664
|
|
|
3585
3665
|
// src/commands/generated-apks.ts
|
|
3586
|
-
import { writeFile as
|
|
3666
|
+
import { writeFile as writeFile6 } from "fs/promises";
|
|
3587
3667
|
async function listGeneratedApks(client, packageName, versionCode) {
|
|
3588
3668
|
if (!Number.isInteger(versionCode) || versionCode <= 0) {
|
|
3589
3669
|
throw new GpcError(
|
|
@@ -3614,7 +3694,7 @@ async function downloadGeneratedApk(client, packageName, versionCode, apkId, out
|
|
|
3614
3694
|
}
|
|
3615
3695
|
const buffer = await client.generatedApks.download(packageName, versionCode, apkId);
|
|
3616
3696
|
const bytes = new Uint8Array(buffer);
|
|
3617
|
-
await
|
|
3697
|
+
await writeFile6(outputPath, bytes);
|
|
3618
3698
|
return { path: outputPath, sizeBytes: bytes.byteLength };
|
|
3619
3699
|
}
|
|
3620
3700
|
|
|
@@ -3699,6 +3779,7 @@ export {
|
|
|
3699
3779
|
cancelRecoveryAction,
|
|
3700
3780
|
cancelSubscriptionPurchase,
|
|
3701
3781
|
checkThreshold,
|
|
3782
|
+
clearAuditLog,
|
|
3702
3783
|
compareVitalsTrend,
|
|
3703
3784
|
consumeProductPurchase,
|
|
3704
3785
|
convertRegionPrices,
|
|
@@ -3781,6 +3862,7 @@ export {
|
|
|
3781
3862
|
isValidBcp47,
|
|
3782
3863
|
isValidReportType,
|
|
3783
3864
|
isValidStatsDimension,
|
|
3865
|
+
listAuditEvents,
|
|
3784
3866
|
listDeviceTiers,
|
|
3785
3867
|
listGeneratedApks,
|
|
3786
3868
|
listImages,
|
|
@@ -3819,6 +3901,7 @@ export {
|
|
|
3819
3901
|
safePath,
|
|
3820
3902
|
safePathWithin,
|
|
3821
3903
|
scaffoldPlugin,
|
|
3904
|
+
searchAuditEvents,
|
|
3822
3905
|
searchVitalsErrors,
|
|
3823
3906
|
sendWebhook,
|
|
3824
3907
|
sortResults,
|