firebase-tools 15.34.2 → 15.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api.js +2 -4
- package/lib/apphosting/constants.js +1 -4
- package/lib/apphosting/utils.js +0 -26
- package/lib/commands/{crashlytics-onboard-web.js → crashlytics-setup.js} +5 -5
- package/lib/commands/crashlytics-sourcemap-upload.js +4 -0
- package/lib/commands/emulators-start.js +2 -2
- package/lib/commands/index.js +3 -2
- package/lib/commands/run-services-get.js +19 -0
- package/lib/commands/run-services-list.js +11 -0
- package/lib/crashlytics/alerts.js +1 -0
- package/lib/crashlytics/firebasetelemetry.js +5 -3
- package/lib/crashlytics/onboarding.js +8 -7
- package/lib/crashlytics/reports.js +46 -17
- package/lib/crashlytics/sourcemap.js +19 -5
- package/lib/dataconnect/dataplaneClient.js +0 -10
- package/lib/deploy/apphosting/deploy.js +20 -41
- package/lib/deploy/apphosting/localBuild.js +49 -0
- package/lib/deploy/apphosting/prepare.js +12 -25
- package/lib/deploy/apphosting/release.js +1 -1
- package/lib/deploy/apphosting/util.js +27 -4
- package/lib/deploy/functions/containerCleaner.js +1 -142
- package/lib/deploy/functions/functionsDeployHelper.js +0 -4
- package/lib/deploy/functions/validate.js +1 -1
- package/lib/deploy/run/deploy.js +26 -43
- package/lib/deploy/run/get.js +30 -0
- package/lib/deploy/run/list.js +38 -0
- package/lib/deploy/run/prereqs.js +0 -3
- package/lib/deploy/run/util.js +9 -0
- package/lib/emulator/commandUtils.js +105 -23
- package/lib/emulator/dataconnect/pgliteServer.js +1 -0
- package/lib/emulator/downloadableEmulators.js +43 -5
- package/lib/emulator/storage/rules/runtime.js +1 -0
- package/lib/extensions/extensionsApi.js +0 -8
- package/lib/extensions/extensionsHelper.js +1 -22
- package/lib/extensions/secretsUtils.js +0 -24
- package/lib/frameworks/next/utils.js +0 -11
- package/lib/fsAsync.js +34 -20
- package/lib/functions/kits/install.js +37 -337
- package/lib/functions/kits/sources/directory.js +59 -0
- package/lib/functions/kits/sources/index.js +19 -0
- package/lib/functions/kits/sources/npm.js +274 -0
- package/lib/functions/kits/sources/types.js +12 -0
- package/lib/gcp/artifactregistry.js +0 -5
- package/lib/gcp/iam.js +0 -4
- package/lib/gcp/pubsub.js +0 -14
- package/lib/gcp/storage.js +2 -1
- package/lib/init/features/run.js +3 -7
- package/lib/mcp/resources/guides/crashlytics_reports.js +33 -71
- package/lib/mcp/tools/crashlytics/reports.js +25 -30
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/lib/deploy/hosting/args.js +0 -2
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_TEMPLATE = exports.TEMPLATES = void 0;
|
|
4
|
+
exports.parseNpmPackageSpecifier = parseNpmPackageSpecifier;
|
|
5
|
+
exports.validateNpmPackageName = validateNpmPackageName;
|
|
6
|
+
exports.validateNpmPackageExists = validateNpmPackageExists;
|
|
7
|
+
exports.sanitizePackageNameToKitName = sanitizePackageNameToKitName;
|
|
8
|
+
exports.isThirdPartyPackage = isThirdPartyPackage;
|
|
9
|
+
exports.checkPackageHasShrinkwrap = checkPackageHasShrinkwrap;
|
|
10
|
+
exports.promptSecurityConfirmation = promptSecurityConfirmation;
|
|
11
|
+
exports.writeKitPackageJson = writeKitPackageJson;
|
|
12
|
+
exports.writeKitIndexTs = writeKitIndexTs;
|
|
13
|
+
exports.scaffoldKitFiles = scaffoldKitFiles;
|
|
14
|
+
exports.resolveSdkSpecifierToSave = resolveSdkSpecifierToSave;
|
|
15
|
+
exports.getKitPackagesToSave = getKitPackagesToSave;
|
|
16
|
+
exports.buildAndInstallKit = buildAndInstallKit;
|
|
17
|
+
const path = require("path");
|
|
18
|
+
const clc = require("colorette");
|
|
19
|
+
const fs = require("fs-extra");
|
|
20
|
+
const semver = require("semver");
|
|
21
|
+
const error_1 = require("../../../error");
|
|
22
|
+
const spawn_1 = require("../../../init/spawn");
|
|
23
|
+
const logger_1 = require("../../../logger");
|
|
24
|
+
const prompt_1 = require("../../../prompt");
|
|
25
|
+
const templates_1 = require("../../../templates");
|
|
26
|
+
const utils_1 = require("../../../utils");
|
|
27
|
+
const supported = require("../../../deploy/functions/runtimes/supported");
|
|
28
|
+
const types_1 = require("./types");
|
|
29
|
+
exports.TEMPLATES = {
|
|
30
|
+
installation: "init/functions/typescript/index-kit.ts",
|
|
31
|
+
migration: "init/functions/typescript/index-kit-migration.ts",
|
|
32
|
+
};
|
|
33
|
+
exports.DEFAULT_TEMPLATE = "installation";
|
|
34
|
+
function parseNpmPackageSpecifier(rawPkg) {
|
|
35
|
+
const lastAt = rawPkg.lastIndexOf("@");
|
|
36
|
+
if (lastAt > 0) {
|
|
37
|
+
const version = rawPkg.substring(lastAt + 1);
|
|
38
|
+
return {
|
|
39
|
+
packageName: rawPkg.substring(0, lastAt),
|
|
40
|
+
...(version ? { version } : {}),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return { packageName: rawPkg };
|
|
44
|
+
}
|
|
45
|
+
function validateNpmPackageName(packageNameOrSpecifier) {
|
|
46
|
+
const { packageName, version } = parseNpmPackageSpecifier(packageNameOrSpecifier);
|
|
47
|
+
const npmPackageRegex = /^(?:@[a-z0-9_.-]+\/[a-z0-9_.-]+|[a-z0-9_.-]+)$/i;
|
|
48
|
+
if (!packageName ||
|
|
49
|
+
packageName.length > 214 ||
|
|
50
|
+
!npmPackageRegex.test(packageName) ||
|
|
51
|
+
(packageNameOrSpecifier.lastIndexOf("@") > 0 && !version)) {
|
|
52
|
+
throw new error_1.FirebaseError(`Invalid NPM package name '${packageNameOrSpecifier}'. Package names must be valid npm package specifiers (e.g. 'my-kit' or '@scope/my-kit').`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function validateNpmPackageExists(rawPkgName) {
|
|
56
|
+
validateNpmPackageName(rawPkgName);
|
|
57
|
+
try {
|
|
58
|
+
const output = await (0, spawn_1.spawnWithOutput)("npm", ["view", rawPkgName, "version"]);
|
|
59
|
+
if (!output.trim()) {
|
|
60
|
+
throw new Error(`No version found for '${rawPkgName}'`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
throw new error_1.FirebaseError(`NPM package '${rawPkgName}' could not be found in the npm registry. Please verify the package name and version.`, { original: err instanceof Error ? err : undefined });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function sanitizePackageNameToKitName(packageNameOrSpecifier) {
|
|
68
|
+
const { packageName } = parseNpmPackageSpecifier(packageNameOrSpecifier);
|
|
69
|
+
const parts = packageName.split("/");
|
|
70
|
+
const nameWithoutScope = parts[parts.length - 1] || packageName;
|
|
71
|
+
return (0, types_1.sanitizeToKitId)(nameWithoutScope);
|
|
72
|
+
}
|
|
73
|
+
function isThirdPartyPackage(packageNameOrSpecifier) {
|
|
74
|
+
const { packageName } = parseNpmPackageSpecifier(packageNameOrSpecifier);
|
|
75
|
+
return !packageName.startsWith("@firebase-function-kits/");
|
|
76
|
+
}
|
|
77
|
+
async function checkPackageHasShrinkwrap(rawPkgName) {
|
|
78
|
+
try {
|
|
79
|
+
const output = await (0, spawn_1.spawnWithOutput)("npm", ["pack", rawPkgName, "--dry-run", "--json"]);
|
|
80
|
+
const parsed = JSON.parse(output);
|
|
81
|
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
82
|
+
const pkgInfo = parsed[0];
|
|
83
|
+
if (pkgInfo.hasShrinkwrap) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (Array.isArray(pkgInfo.files)) {
|
|
87
|
+
return pkgInfo.files.some((f) => f.path === "npm-shrinkwrap.json" || f.path === "npm-shrinkwrap.js");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
logger_1.logger.debug(`Failed to inspect package shrinkwrap for ${rawPkgName}: ${(0, error_1.getErrMsg)(err)}`);
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
async function promptSecurityConfirmation(options) {
|
|
97
|
+
const { rawPkgName, packageName, nonInteractive, force } = options;
|
|
98
|
+
const isThirdParty = isThirdPartyPackage(packageName);
|
|
99
|
+
if (isThirdParty) {
|
|
100
|
+
(0, utils_1.logLabeledWarning)("functions", `Package ${clc.bold(packageName)} is a third-party kit (outside the @firebase-function-kits scope).`);
|
|
101
|
+
}
|
|
102
|
+
const hasShrinkwrap = await checkPackageHasShrinkwrap(rawPkgName);
|
|
103
|
+
if (!hasShrinkwrap) {
|
|
104
|
+
(0, utils_1.logLabeledWarning)("functions", `Package ${clc.bold(packageName)} does not have an npm-shrinkwrap.json file. npm-shrinkwrap guarantees that you deploy the same version of dependencies that the publisher tested against. Since this kit does not have an npm-shrinkwrap, it is possible that deploys or updates may introduce bugs or vulnerabilities in newer dependency versions that the publisher did not test against.`);
|
|
105
|
+
}
|
|
106
|
+
if (isThirdParty || !hasShrinkwrap) {
|
|
107
|
+
let confirmMessage;
|
|
108
|
+
if (isThirdParty && !hasShrinkwrap) {
|
|
109
|
+
confirmMessage = `Are you sure you want to install the third-party kit ${packageName} without locked dependencies?`;
|
|
110
|
+
}
|
|
111
|
+
else if (isThirdParty) {
|
|
112
|
+
confirmMessage = `Are you sure you want to install the third-party kit ${packageName}?`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
confirmMessage = `Are you sure you want to install ${packageName} without locked dependencies?`;
|
|
116
|
+
}
|
|
117
|
+
const confirmInstallation = await (0, prompt_1.confirm)({
|
|
118
|
+
message: confirmMessage,
|
|
119
|
+
default: false,
|
|
120
|
+
nonInteractive,
|
|
121
|
+
force,
|
|
122
|
+
});
|
|
123
|
+
if (!confirmInstallation) {
|
|
124
|
+
throw new error_1.FirebaseError("Installation cancelled.");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return isThirdParty;
|
|
128
|
+
}
|
|
129
|
+
async function writeKitPackageJson(config, sourcePath, kitId) {
|
|
130
|
+
const relPackageJsonPath = path.join(sourcePath, "package.json");
|
|
131
|
+
const absPackageJsonPath = config.path(relPackageJsonPath);
|
|
132
|
+
let pkgJson = {};
|
|
133
|
+
if (await fs.pathExists(absPackageJsonPath)) {
|
|
134
|
+
try {
|
|
135
|
+
pkgJson = (await fs.readJson(absPackageJsonPath)) || {};
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
logger_1.logger.debug(`Failed to read existing package.json: ${(0, error_1.getErrMsg)(err)}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const latestNodeVersion = supported.latest("nodejs").replace("nodejs", "");
|
|
143
|
+
const packageKitTemplate = (0, templates_1.readTemplateSync)("init/functions/typescript/package-kit.json");
|
|
144
|
+
const subbedTemplate = packageKitTemplate.replace(/{{RUNTIME}}/g, latestNodeVersion);
|
|
145
|
+
try {
|
|
146
|
+
pkgJson = JSON.parse(subbedTemplate);
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
throw new error_1.FirebaseError("Failed to parse package-kit.json template: " + (0, error_1.getErrMsg)(err), {
|
|
150
|
+
original: err instanceof Error ? err : undefined,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
pkgJson.name = `${kitId}-wrapper`;
|
|
155
|
+
await config.askWriteProjectFile(relPackageJsonPath, pkgJson);
|
|
156
|
+
}
|
|
157
|
+
async function writeKitIndexTs(options) {
|
|
158
|
+
const { config, sourcePath, packageName, templateType } = options;
|
|
159
|
+
const relIndexTsPath = path.join(sourcePath, "src", "index.ts");
|
|
160
|
+
const absIndexTsPath = config.path(relIndexTsPath);
|
|
161
|
+
if (!(await fs.pathExists(absIndexTsPath))) {
|
|
162
|
+
const template = (0, templates_1.readTemplateSync)(exports.TEMPLATES[templateType]);
|
|
163
|
+
const indexContent = template.replace(/{{PACKAGE_NAME}}/g, packageName);
|
|
164
|
+
await config.askWriteProjectFile(relIndexTsPath, indexContent);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async function scaffoldKitFiles(config, kitId, instanceId, packageName, templateType = exports.DEFAULT_TEMPLATE) {
|
|
168
|
+
const sourcePath = path.join(types_1.FUNCTION_KITS_DIR, kitId, "source");
|
|
169
|
+
const configDirPath = path.join(types_1.FUNCTION_KITS_DIR, kitId, `config-${instanceId}`);
|
|
170
|
+
const absSourcePath = config.path(sourcePath);
|
|
171
|
+
const absConfigDirPath = config.path(configDirPath);
|
|
172
|
+
await fs.ensureDir(absSourcePath);
|
|
173
|
+
await fs.ensureDir(absConfigDirPath);
|
|
174
|
+
await writeKitPackageJson(config, sourcePath, kitId);
|
|
175
|
+
await config.askWriteProjectFile(path.join(sourcePath, "tsconfig.json"), (0, templates_1.readTemplateSync)("init/functions/typescript/tsconfig.json"));
|
|
176
|
+
await config.askWriteProjectFile(path.join(sourcePath, ".gitignore"), (0, templates_1.readTemplateSync)("init/functions/typescript/_gitignore"));
|
|
177
|
+
await writeKitIndexTs({ config, sourcePath, packageName, templateType });
|
|
178
|
+
return { sourcePath, configDirPath, absSourcePath, absConfigDirPath };
|
|
179
|
+
}
|
|
180
|
+
function resolveSdkSpecifierToSave(packageName, declaredVer, installedVer) {
|
|
181
|
+
const cleanVer = semver.clean(declaredVer);
|
|
182
|
+
if (cleanVer) {
|
|
183
|
+
return `${packageName}@=${installedVer || cleanVer}`;
|
|
184
|
+
}
|
|
185
|
+
if (declaredVer.trim().startsWith("~")) {
|
|
186
|
+
return installedVer ? `${packageName}@~${installedVer}` : `${packageName}@${declaredVer}`;
|
|
187
|
+
}
|
|
188
|
+
if (installedVer) {
|
|
189
|
+
return `${packageName}@^${installedVer}`;
|
|
190
|
+
}
|
|
191
|
+
return `${packageName}@${declaredVer}`;
|
|
192
|
+
}
|
|
193
|
+
async function getKitPackagesToSave(absSourcePath, packageName) {
|
|
194
|
+
const lockfilePath = path.join(absSourcePath, "package-lock.json");
|
|
195
|
+
let peerDeps = {};
|
|
196
|
+
let directDeps = {};
|
|
197
|
+
let installedFunctionsVer;
|
|
198
|
+
let installedAdminVer;
|
|
199
|
+
if (await fs.pathExists(lockfilePath)) {
|
|
200
|
+
try {
|
|
201
|
+
const lockfile = (await fs.readJson(lockfilePath));
|
|
202
|
+
const packages = lockfile?.packages || {};
|
|
203
|
+
const kitEntry = packages[`node_modules/${packageName}`] || {};
|
|
204
|
+
peerDeps = kitEntry.peerDependencies || {};
|
|
205
|
+
directDeps = kitEntry.dependencies || {};
|
|
206
|
+
installedFunctionsVer = packages["node_modules/firebase-functions"]?.version;
|
|
207
|
+
installedAdminVer = packages["node_modules/firebase-admin"]?.version;
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
logger_1.logger.debug(`Failed to read package-lock.json: ${(0, error_1.getErrMsg)(err)}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (Object.keys(peerDeps).length === 0 && Object.keys(directDeps).length === 0) {
|
|
214
|
+
const kitPkgJsonPath = path.join(absSourcePath, "node_modules", packageName, "package.json");
|
|
215
|
+
if (await fs.pathExists(kitPkgJsonPath)) {
|
|
216
|
+
try {
|
|
217
|
+
const kitPkgJson = (await fs.readJson(kitPkgJsonPath));
|
|
218
|
+
peerDeps = kitPkgJson?.peerDependencies || {};
|
|
219
|
+
directDeps = kitPkgJson?.dependencies || {};
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
logger_1.logger.debug(`Failed to read kit package.json: ${(0, error_1.getErrMsg)(err)}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const declaredFunctionsVer = peerDeps["firebase-functions"] || directDeps["firebase-functions"];
|
|
227
|
+
if (!declaredFunctionsVer) {
|
|
228
|
+
throw new error_1.FirebaseError(`Package '${packageName}' is not a valid Function Kit: it must declare 'firebase-functions' as a dependency or peer dependency.`);
|
|
229
|
+
}
|
|
230
|
+
const packagesToSave = [
|
|
231
|
+
resolveSdkSpecifierToSave("firebase-functions", declaredFunctionsVer, installedFunctionsVer),
|
|
232
|
+
];
|
|
233
|
+
const declaredAdminVer = peerDeps["firebase-admin"] || directDeps["firebase-admin"];
|
|
234
|
+
if (declaredAdminVer) {
|
|
235
|
+
packagesToSave.push(resolveSdkSpecifierToSave("firebase-admin", declaredAdminVer, installedAdminVer));
|
|
236
|
+
}
|
|
237
|
+
return packagesToSave;
|
|
238
|
+
}
|
|
239
|
+
async function buildAndInstallKit(absSourcePath, rawPkgName, isThirdParty) {
|
|
240
|
+
const { packageName } = parseNpmPackageSpecifier(rawPkgName);
|
|
241
|
+
const installArgs = ["install", rawPkgName, "--save-prefix=^"];
|
|
242
|
+
if (isThirdParty) {
|
|
243
|
+
installArgs.push("--ignore-scripts");
|
|
244
|
+
}
|
|
245
|
+
(0, utils_1.logLabeledBullet)("functions", `Running npm ${installArgs.join(" ")}...`);
|
|
246
|
+
try {
|
|
247
|
+
await (0, spawn_1.wrapSpawn)("npm", installArgs, absSourcePath);
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
throw new error_1.FirebaseError(`NPM install failed: ${(0, error_1.getErrMsg)(err)}`);
|
|
251
|
+
}
|
|
252
|
+
const packagesToSave = await getKitPackagesToSave(absSourcePath, packageName);
|
|
253
|
+
if (packagesToSave.length > 0) {
|
|
254
|
+
(0, utils_1.logLabeledBullet)("functions", `Saving resolved SDK dependencies: ${clc.bold(packagesToSave.join(", "))}...`);
|
|
255
|
+
const saveArgs = ["install", ...packagesToSave, "--save-prefix=^"];
|
|
256
|
+
if (isThirdParty) {
|
|
257
|
+
saveArgs.push("--ignore-scripts");
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
await (0, spawn_1.wrapSpawn)("npm", saveArgs, absSourcePath);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
throw new error_1.FirebaseError(`Failed to install required SDK dependencies (${packagesToSave.join(", ")}): ${(0, error_1.getErrMsg)(err)}. ` +
|
|
264
|
+
"Verify that the kit's dependencies are compatible with the resolved Firebase SDK versions.", { original: err instanceof Error ? err : undefined });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
(0, utils_1.logLabeledBullet)("functions", "Building TypeScript source...");
|
|
268
|
+
try {
|
|
269
|
+
await (0, spawn_1.wrapSpawn)("npm", ["run", "build"], absSourcePath);
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
throw new error_1.FirebaseError(`TypeScript build failed: ${(0, error_1.getErrMsg)(err)}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_KIT_ID_LENGTH = exports.FUNCTION_KITS_DIR = void 0;
|
|
4
|
+
exports.sanitizeToKitId = sanitizeToKitId;
|
|
5
|
+
exports.FUNCTION_KITS_DIR = "function-kits";
|
|
6
|
+
exports.MAX_KIT_ID_LENGTH = 40;
|
|
7
|
+
function sanitizeToKitId(name) {
|
|
8
|
+
return name
|
|
9
|
+
.toLowerCase()
|
|
10
|
+
.replace(/[^a-z0-9_-]/g, "")
|
|
11
|
+
.slice(0, exports.MAX_KIT_ID_LENGTH);
|
|
12
|
+
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.API_VERSION = void 0;
|
|
4
4
|
exports.ensureApiEnabled = ensureApiEnabled;
|
|
5
|
-
exports.deletePackage = deletePackage;
|
|
6
5
|
exports.getRepository = getRepository;
|
|
7
6
|
exports.updateRepository = updateRepository;
|
|
8
7
|
exports.ensureDockerRepository = ensureDockerRepository;
|
|
@@ -23,10 +22,6 @@ function ensureApiEnabled(projectId) {
|
|
|
23
22
|
return api.ensure(projectId, (0, api_1.artifactRegistryDomain)(), "artifactregistry", true);
|
|
24
23
|
}
|
|
25
24
|
(0, metaprogramming_1.assertImplements)();
|
|
26
|
-
async function deletePackage(name) {
|
|
27
|
-
const res = await client.delete(name);
|
|
28
|
-
return res.body;
|
|
29
|
-
}
|
|
30
25
|
async function getRepository(repoPath) {
|
|
31
26
|
const res = await client.get(repoPath);
|
|
32
27
|
return res.body;
|
package/lib/gcp/iam.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultCloudBuildServiceAgent = getDefaultCloudBuildServiceAgent;
|
|
4
3
|
exports.createServiceAccount = createServiceAccount;
|
|
5
4
|
exports.getServiceAccount = getServiceAccount;
|
|
6
5
|
exports.createServiceAccountKey = createServiceAccountKey;
|
|
@@ -22,9 +21,6 @@ const error_1 = require("../error");
|
|
|
22
21
|
const knownRoles = require("./knownRoles.json");
|
|
23
22
|
const crypto = require("crypto");
|
|
24
23
|
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.iamOrigin)(), apiVersion: "v1" });
|
|
25
|
-
function getDefaultCloudBuildServiceAgent(projectNumber) {
|
|
26
|
-
return `${projectNumber}@cloudbuild.gserviceaccount.com`;
|
|
27
|
-
}
|
|
28
24
|
async function createServiceAccount(projectId, accountId, description, displayName) {
|
|
29
25
|
const response = await apiClient.post(`/projects/${projectId}/serviceAccounts`, {
|
|
30
26
|
accountId,
|
package/lib/gcp/pubsub.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTopic = createTopic;
|
|
4
|
-
exports.getTopic = getTopic;
|
|
5
|
-
exports.updateTopic = updateTopic;
|
|
6
4
|
exports.deleteTopic = deleteTopic;
|
|
7
5
|
const apiv2_1 = require("../apiv2");
|
|
8
6
|
const api_1 = require("../api");
|
|
9
|
-
const proto = require("./proto");
|
|
10
7
|
const API_VERSION = "v1";
|
|
11
8
|
const client = new apiv2_1.Client({
|
|
12
9
|
urlPrefix: (0, api_1.pubsubOrigin)(),
|
|
@@ -17,17 +14,6 @@ async function createTopic(topic) {
|
|
|
17
14
|
const result = await client.put(topic.name, topic);
|
|
18
15
|
return result.body;
|
|
19
16
|
}
|
|
20
|
-
async function getTopic(name) {
|
|
21
|
-
const result = await client.get(name);
|
|
22
|
-
return result.body;
|
|
23
|
-
}
|
|
24
|
-
async function updateTopic(topic) {
|
|
25
|
-
const queryParams = {
|
|
26
|
-
updateMask: proto.fieldMasks(topic).join(","),
|
|
27
|
-
};
|
|
28
|
-
const result = await client.patch(topic.name, topic, { queryParams });
|
|
29
|
-
return result.body;
|
|
30
|
-
}
|
|
31
17
|
async function deleteTopic(name) {
|
|
32
18
|
await client.delete(name);
|
|
33
19
|
}
|
package/lib/gcp/storage.js
CHANGED
|
@@ -149,7 +149,7 @@ async function createBucket(projectId, req, projectPrivate) {
|
|
|
149
149
|
async function patchBucket(bucketName, metadata) {
|
|
150
150
|
try {
|
|
151
151
|
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
152
|
-
const mask = (0, proto_1.fieldMasks)(metadata, "labels", "acl", "defaultObjectAcl", "lifecycle", "cors");
|
|
152
|
+
const mask = (0, proto_1.fieldMasks)(metadata, "labels", "acl", "defaultObjectAcl", "lifecycle", "cors", "autoclass");
|
|
153
153
|
const result = await localAPIClient.patch(`/storage/v1/b/${bucketName}`, metadata, { queryParams: { updateMask: mask.join(",") } });
|
|
154
154
|
return result.body;
|
|
155
155
|
}
|
|
@@ -197,6 +197,7 @@ async function upsertBucket(opts) {
|
|
|
197
197
|
labels: {
|
|
198
198
|
[opts.req.purposeLabel]: "true",
|
|
199
199
|
},
|
|
200
|
+
...(opts.req.autoclass ? { autoclass: opts.req.autoclass } : {}),
|
|
200
201
|
}, true);
|
|
201
202
|
return name;
|
|
202
203
|
}
|
package/lib/init/features/run.js
CHANGED
|
@@ -40,7 +40,7 @@ async function askQuestions(setup, config, options) {
|
|
|
40
40
|
let serviceId;
|
|
41
41
|
let region;
|
|
42
42
|
if (existing) {
|
|
43
|
-
({ region, serviceId } = parseServiceName(existing.name));
|
|
43
|
+
({ region, serviceId } = (0, util_1.parseServiceName)(existing.name));
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
46
|
region = await (0, prompt_1.select)({
|
|
@@ -101,13 +101,13 @@ async function promptWebApp(projectId) {
|
|
|
101
101
|
}
|
|
102
102
|
async function promptExistingService(projectId) {
|
|
103
103
|
const allServices = await runv2.listServices(projectId, false);
|
|
104
|
-
const services = allServices.filter((s) => !
|
|
104
|
+
const services = allServices.filter((s) => !(0, util_1.isManagedByAnotherProduct)(s));
|
|
105
105
|
if (services.length === 0) {
|
|
106
106
|
(0, utils_1.logBullet)("No Cloud Run services to update. Creating a new service instead.");
|
|
107
107
|
return undefined;
|
|
108
108
|
}
|
|
109
109
|
const choices = services.map((service) => {
|
|
110
|
-
const { serviceId, region } = parseServiceName(service.name);
|
|
110
|
+
const { serviceId, region } = (0, util_1.parseServiceName)(service.name);
|
|
111
111
|
return { name: `${serviceId} (${region})`, value: service };
|
|
112
112
|
});
|
|
113
113
|
return (0, prompt_1.select)({
|
|
@@ -115,10 +115,6 @@ async function promptExistingService(projectId) {
|
|
|
115
115
|
choices,
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
function parseServiceName(name) {
|
|
119
|
-
const parts = name.split("/");
|
|
120
|
-
return { region: parts[3], serviceId: parts[5] };
|
|
121
|
-
}
|
|
122
118
|
async function promptNewServiceId(projectId, region) {
|
|
123
119
|
return (0, prompt_1.input)({
|
|
124
120
|
message: "Please enter a unique ID for your service",
|
|
@@ -5,74 +5,36 @@ const resource_1 = require("../../resource");
|
|
|
5
5
|
const RESOURCE_CONTENT = `
|
|
6
6
|
### Crashlytics Reports
|
|
7
7
|
|
|
8
|
-
Aggregate metrics for all of the events sent to Crashlytics are available as reports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Counts events, grouped by device operating systems and their versions.
|
|
27
|
-
Operating systems are sorted by event count, in descending order.
|
|
28
|
-
|
|
29
|
-
Mobile apps have the following report available:
|
|
30
|
-
|
|
31
|
-
- name: "topVariants"
|
|
32
|
-
display_name: "Top Variants"
|
|
33
|
-
usage: |
|
|
34
|
-
Counts events and distinct impacted users, grouped by issue variant.
|
|
35
|
-
Issue variant groups are sorted by event count, in descending order.
|
|
36
|
-
required: |
|
|
37
|
-
An issue filter including an issue id is required.
|
|
38
|
-
|
|
39
|
-
Mobile apps also have one of the following reports available, depending on the platform.
|
|
40
|
-
|
|
41
|
-
- name: "topAndroidDevices"
|
|
42
|
-
display_name: "Top Android Devices"
|
|
43
|
-
usage: |
|
|
44
|
-
Counts events, grouped by android device.
|
|
45
|
-
Devices are sorted by event count, in descending order.
|
|
46
|
-
|
|
47
|
-
- name: "topAppleDevices"
|
|
48
|
-
display_name: "Top Apple Devices"
|
|
49
|
-
usage:
|
|
50
|
-
Counts events, grouped by operating system and Apple device.
|
|
51
|
-
Devices are sorted by event count, in descending order.
|
|
52
|
-
|
|
53
|
-
Web apps have the following additional reports available.
|
|
54
|
-
|
|
55
|
-
- name: "topBrowsers"
|
|
56
|
-
display_name: "Top Browsers"
|
|
57
|
-
usage: |
|
|
58
|
-
Counts events, grouped by browser.
|
|
59
|
-
Browsers are sorted by event count, in descending order.
|
|
60
|
-
required: |
|
|
61
|
-
An issue filter including an issue id is required.
|
|
62
|
-
|
|
63
|
-
- name: "webMetrics"
|
|
64
|
-
display_name: "Web Metrics"
|
|
65
|
-
usage: |
|
|
66
|
-
Counts events and distinct impacted users, grouped by error type.
|
|
67
|
-
Error types are sorted by event count, in descending order.
|
|
8
|
+
Aggregate metrics for all of the events sent to Crashlytics are available as reports.
|
|
9
|
+
|
|
10
|
+
### Useful Reports
|
|
11
|
+
|
|
12
|
+
* The "appSummary" report provides overall app health metrics, including crash-free users and crash-free sessions percentages.
|
|
13
|
+
Combine it with \`granularity\` (such as \`TIME_GRANULARITY_DAY\` or \`TIME_GRANULARITY_HOUR\`) to analyze stability trends over time.
|
|
14
|
+
|
|
15
|
+
* The "releaseVersions" report groups metrics by the latest semantic release versions, making it ideal for comparing adoption and crash-free rates across recent releases.
|
|
16
|
+
|
|
17
|
+
* The "topIssues" report is comparable to the default view on the Crashlytics web dashboard.
|
|
18
|
+
Use this report to prioritize which issues are impacting the most users.
|
|
19
|
+
Apply appropriate filters for time interval based on the user's query.
|
|
20
|
+
Report responses grouped by issue will include a sample event URI.
|
|
21
|
+
Use the "crashlytics_batch_get_events" tool to fetch the complete record for any sample event.
|
|
22
|
+
When investigating an issue, use the appropriate top devices and top operating systems reports to understand what systems are impacted by the problem.
|
|
23
|
+
Pass the "issueId" in the filter to narrow any report to a specific issue.
|
|
24
|
+
|
|
25
|
+
Agents can retrieve a full list of available reports by passing an empty report name.
|
|
68
26
|
|
|
69
27
|
Report responses contain the following metrics:
|
|
70
28
|
|
|
71
29
|
- eventsCount: the number of events matching
|
|
72
|
-
-
|
|
73
|
-
-
|
|
30
|
+
- impactedUsersCount: the number of distinct end users in all the matching events
|
|
31
|
+
- impactedSessionsCount: the number of distinct sessions in all the matching events
|
|
32
|
+
- totalUsersCount: the total number of distinct active users
|
|
33
|
+
- totalSessionsCount: the total number of distinct active sessions
|
|
34
|
+
- crashFreeUsersPercentage: percentage of crash-free users (mobile only)
|
|
35
|
+
- crashFreeSessionsPercentage: percentage of crash-free sessions (mobile only)
|
|
74
36
|
|
|
75
|
-
Report responses are
|
|
37
|
+
Report responses are grouped by one of the following dimensions (or cover the entire app for \`appSummary\`):
|
|
76
38
|
|
|
77
39
|
- app version
|
|
78
40
|
- issue
|
|
@@ -82,6 +44,14 @@ Report responses are always grouped by one of the following dimensions:
|
|
|
82
44
|
- browser (web only)
|
|
83
45
|
- error type (web only)
|
|
84
46
|
|
|
47
|
+
### Time Granularity
|
|
48
|
+
|
|
49
|
+
The \`granularity\` parameter controls how metrics are bucketed over the requested time interval:
|
|
50
|
+
|
|
51
|
+
* \`TIME_GRANULARITY_NONE\`: Returns a single aggregated interval covering the entire requested time range (default when \`granularity\` is omitted).
|
|
52
|
+
* \`TIME_GRANULARITY_HOUR\`: Returns one metrics entry per hour across the requested time range.
|
|
53
|
+
* \`TIME_GRANULARITY_DAY\`: Returns one metrics entry per day across the requested time range.
|
|
54
|
+
|
|
85
55
|
### Filters
|
|
86
56
|
|
|
87
57
|
When setting report filters adhere to the following instructions.
|
|
@@ -104,14 +74,6 @@ When setting report filters adhere to the following instructions.
|
|
|
104
74
|
* Operating System: 'os (version)'
|
|
105
75
|
* App Version: 'version (build)'
|
|
106
76
|
|
|
107
|
-
### Useful Reports
|
|
108
|
-
|
|
109
|
-
* The "topIssues" report is comparable to the default view on the Crashlytics web dashboard. Use this report first to prioritize which issues are impacting the most users. Apply appropriate filters for time interval based on the user's query.
|
|
110
|
-
|
|
111
|
-
* Report responses grouped by issue will include a sample event URI. Use the "crashlytics_batch_get_events" tool to fetch the complete record for any sample event.
|
|
112
|
-
|
|
113
|
-
* When investigating an issue, use the appropriate top devices and top operating systems reports to understand what systems are impacted by the problem. Pass the "issueId" in the filter to narrow any report to a specific issue.
|
|
114
|
-
|
|
115
77
|
### How to Display Issues
|
|
116
78
|
|
|
117
79
|
When displaying a list of issues, use the following format:
|
|
@@ -7,17 +7,6 @@ const reports_1 = require("../../../crashlytics/reports");
|
|
|
7
7
|
const tool_1 = require("../../tool");
|
|
8
8
|
const app_id_1 = require("../../resources/guides/app_id");
|
|
9
9
|
const DUMP_OPTIONS = { lineWidth: 200 };
|
|
10
|
-
const REPORT_ERROR_CONTENT = `
|
|
11
|
-
Must specify the desired report:
|
|
12
|
-
* TOP_ISSUES - metrics grouped by *issue*.
|
|
13
|
-
* TOP_VARIANTS - metrics grouped by issue *variant*
|
|
14
|
-
* TOP_VERSIONS - metrics grouped by *version*
|
|
15
|
-
* TOP_OPERATING_SYSTEMS - metrics grouped by *operating system*
|
|
16
|
-
* TOP_ANDROID_DEVICES - metrics grouped by *device*
|
|
17
|
-
* TOP_APPLE_DEVICES - metrics grouped by *device*
|
|
18
|
-
* TOP_BROWSERS - metrics grouped by *browser*
|
|
19
|
-
* WEB_METRICS - metrics by *error type*
|
|
20
|
-
`.trim();
|
|
21
10
|
function toText(response, filters) {
|
|
22
11
|
const result = {
|
|
23
12
|
name: response.name || "",
|
|
@@ -44,12 +33,8 @@ exports.get_report = (0, tool_1.tool)("crashlytics", {
|
|
|
44
33
|
_meta: {
|
|
45
34
|
requiresAuth: true,
|
|
46
35
|
},
|
|
47
|
-
}, async ({ appId, report, pageSize, filter }) => {
|
|
36
|
+
}, async ({ appId, report, pageSize, filter, granularity }) => {
|
|
48
37
|
const result = { content: [] };
|
|
49
|
-
if (!report) {
|
|
50
|
-
result.isError = true;
|
|
51
|
-
result.content.push({ type: "text", text: `Error: ${REPORT_ERROR_CONTENT}` });
|
|
52
|
-
}
|
|
53
38
|
if (!appId) {
|
|
54
39
|
result.isError = true;
|
|
55
40
|
result.content.push({ type: "text", text: "Must specify 'appId' parameter" });
|
|
@@ -59,23 +44,33 @@ exports.get_report = (0, tool_1.tool)("crashlytics", {
|
|
|
59
44
|
filter = (0, filters_1.validateEventFilters)(filter || {});
|
|
60
45
|
}
|
|
61
46
|
catch (error) {
|
|
47
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
48
|
result.isError = true;
|
|
63
|
-
result.content.push({ type: "text", text: `Error: ${
|
|
49
|
+
result.content.push({ type: "text", text: `Error: ${message}` });
|
|
64
50
|
}
|
|
65
51
|
if (result.content.length > 0) {
|
|
66
52
|
return result;
|
|
67
53
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
reportResponse.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
54
|
+
try {
|
|
55
|
+
const reportResponse = (0, reports_1.simplifyReport)(await (0, reports_1.getReport)(report, appId, filter, pageSize, granularity));
|
|
56
|
+
reportResponse.usage =
|
|
57
|
+
reportResponse.groups && reportResponse.groups.length
|
|
58
|
+
? reportResponse.usage || ""
|
|
59
|
+
: "This report response contains no results.";
|
|
60
|
+
return {
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: "text",
|
|
64
|
+
text: (0, js_yaml_1.dump)(toText(reportResponse, filter), DUMP_OPTIONS),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
71
|
+
return {
|
|
72
|
+
isError: true,
|
|
73
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
81
76
|
});
|