firebase-tools-with-isolate 15.25.1 → 15.27.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/ailogic/templates.js +124 -0
- package/lib/api.js +6 -2
- package/lib/appcheck/api.js +52 -0
- package/lib/appcheck/providers.js +240 -0
- package/lib/appcheck/services.js +135 -0
- package/lib/auth.js +33 -15
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +4 -1
- package/lib/commands/ailogic-templates-delete.js +53 -0
- package/lib/commands/ailogic-templates-get.js +33 -0
- package/lib/commands/ailogic-templates-list.js +49 -0
- package/lib/commands/ailogic-templates-lock.js +30 -0
- package/lib/commands/ailogic-templates-unlock.js +30 -0
- package/lib/commands/appcheck-apps-list.js +78 -0
- package/lib/commands/appcheck-debugtokens-create.js +2 -2
- package/lib/commands/appcheck-debugtokens-delete.js +2 -2
- package/lib/commands/appcheck-debugtokens-list.js +2 -2
- package/lib/commands/appcheck-prompts.js +55 -0
- package/lib/commands/appcheck-providers-get.js +73 -0
- package/lib/commands/appcheck-providers-list.js +67 -0
- package/lib/commands/appcheck-providers-set.js +96 -0
- package/lib/commands/appcheck-services-get.js +40 -0
- package/lib/commands/appcheck-services-list.js +52 -0
- package/lib/commands/appcheck-services-set.js +90 -0
- package/lib/commands/crashlytics-onboard-web.js +56 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/ext-export.js +75 -3
- package/lib/commands/firestore-locations.js +3 -1
- package/lib/commands/functions-kits-install.js +294 -0
- package/lib/commands/index.js +24 -0
- package/lib/commands/login.js +53 -6
- package/lib/config.js +1 -0
- package/lib/crashlytics/filters.js +12 -4
- package/lib/crashlytics/firebasetelemetry.js +36 -0
- package/lib/crashlytics/onboarding.js +41 -0
- package/lib/crashlytics/reports.js +2 -0
- package/lib/crashlytics/sourcemap.js +102 -12
- package/lib/crashlytics/types.js +8 -1
- package/lib/deploy/ailogic/index.js +19 -0
- package/lib/deploy/ailogic/prepare.js +78 -0
- package/lib/deploy/ailogic/release.js +60 -0
- package/lib/deploy/functions/backend.js +11 -1
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/params.js +5 -1
- package/lib/deploy/functions/prepare.js +26 -13
- package/lib/deploy/functions/prompts.js +1 -1
- package/lib/deploy/functions/release/lifecycle.js +11 -0
- package/lib/deploy/functions/release/planner.js +5 -2
- package/lib/deploy/index.js +9 -0
- package/lib/emulator/controller.js +1 -0
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/functionsEmulator.js +3 -1
- package/lib/experiments.js +13 -0
- package/lib/extensions/checkProjectBilling.js +3 -73
- package/lib/extensions/export.js +47 -0
- package/lib/functions/env.js +20 -7
- package/lib/functions/projectConfig.js +19 -11
- package/lib/functions/python.js +1 -1
- package/lib/gcp/ailogic.js +70 -1
- package/lib/gcp/cloudbilling.js +74 -0
- package/lib/gcp/cloudlogging.js +54 -0
- package/lib/gcp/runv2.js +1 -0
- package/lib/management/apps.js +1 -2
- package/lib/mcp/onemcp/index.js +2 -1
- package/lib/mcp/onemcp/onemcp_server.js +38 -11
- package/lib/mcp/prompts/crashlytics/connect.js +1 -1
- package/lib/mcp/resources/guides/crashlytics_issues.js +3 -3
- package/lib/mcp/resources/guides/crashlytics_reports.js +32 -11
- package/lib/mcp/tool.js +5 -0
- package/lib/mcp/tools/crashlytics/notes.js +3 -3
- package/lib/mcp/tools/crashlytics/reports.js +2 -0
- package/lib/mcp/util/crashlytics/availability.js +54 -1
- package/lib/prompt.js +10 -1
- package/lib/requirePermissions.js +1 -1
- package/lib/serve/functions.js +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/schema/firebase-config.json +42 -3
- package/templates/init/functions/typescript/index-kit-migration.ts +49 -0
- package/templates/init/functions/typescript/index-kit.ts +35 -0
- package/lib/appcheck/prompts.js +0 -41
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
exports.generateUniqueId = generateUniqueId;
|
|
5
|
+
exports.parseNpmPackageSpecifier = parseNpmPackageSpecifier;
|
|
6
|
+
exports.validateNpmPackageName = validateNpmPackageName;
|
|
7
|
+
exports.sanitizePackageNameToKitName = sanitizePackageNameToKitName;
|
|
8
|
+
exports.isThirdPartyPackage = isThirdPartyPackage;
|
|
9
|
+
exports.checkPackageHasShrinkwrap = checkPackageHasShrinkwrap;
|
|
10
|
+
const clc = require("colorette");
|
|
11
|
+
const crypto = require("crypto");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const fs = require("fs-extra");
|
|
14
|
+
const command_1 = require("../command");
|
|
15
|
+
const error_1 = require("../error");
|
|
16
|
+
const projectConfig_1 = require("../functions/projectConfig");
|
|
17
|
+
const experiments = require("../experiments");
|
|
18
|
+
const logger_1 = require("../logger");
|
|
19
|
+
const prompt_1 = require("../prompt");
|
|
20
|
+
const spawn_1 = require("../init/spawn");
|
|
21
|
+
const templates_1 = require("../templates");
|
|
22
|
+
const supported = require("../deploy/functions/runtimes/supported");
|
|
23
|
+
const self = require("./functions-kits-install");
|
|
24
|
+
const PACKAGE_NO_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/package.nolint.json");
|
|
25
|
+
const TSCONFIG_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/tsconfig.json");
|
|
26
|
+
const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/_gitignore");
|
|
27
|
+
const INDEX_KIT_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/index-kit.ts");
|
|
28
|
+
const INDEX_KIT_MIGRATION_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/index-kit-migration.ts");
|
|
29
|
+
const TEMPLATES = {
|
|
30
|
+
installation: INDEX_KIT_TEMPLATE,
|
|
31
|
+
migration: INDEX_KIT_MIGRATION_TEMPLATE,
|
|
32
|
+
};
|
|
33
|
+
const FUNCTION_KITS_DIR = "function-kits";
|
|
34
|
+
function generateUniqueId(baseId, existingIds) {
|
|
35
|
+
if (!existingIds.has(baseId)) {
|
|
36
|
+
return baseId;
|
|
37
|
+
}
|
|
38
|
+
const prefix = baseId.slice(0, 35);
|
|
39
|
+
let candidate = "";
|
|
40
|
+
do {
|
|
41
|
+
const randomSuffix = crypto.randomBytes(2).toString("hex");
|
|
42
|
+
candidate = `${prefix}-${randomSuffix}`;
|
|
43
|
+
} while (existingIds.has(candidate));
|
|
44
|
+
return candidate;
|
|
45
|
+
}
|
|
46
|
+
function parseNpmPackageSpecifier(rawPkg) {
|
|
47
|
+
const lastAt = rawPkg.lastIndexOf("@");
|
|
48
|
+
if (lastAt > 0) {
|
|
49
|
+
return {
|
|
50
|
+
packageName: rawPkg.substring(0, lastAt),
|
|
51
|
+
version: rawPkg.substring(lastAt + 1),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return { packageName: rawPkg };
|
|
55
|
+
}
|
|
56
|
+
function validateNpmPackageName(packageName) {
|
|
57
|
+
const npmPackageRegex = /^(?:@[a-z0-9_.-]+\/[a-z0-9_.-]+|[a-z0-9_.-]+)$/i;
|
|
58
|
+
if (!packageName || packageName.length > 214 || !npmPackageRegex.test(packageName)) {
|
|
59
|
+
throw new error_1.FirebaseError(`Invalid NPM package name '${packageName}'. Package names must be valid npm package specifiers (e.g. 'my-kit' or '@scope/my-kit').`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function sanitizePackageNameToKitName(packageName) {
|
|
63
|
+
const parts = packageName.split("/");
|
|
64
|
+
const nameWithoutScope = parts[parts.length - 1] || packageName;
|
|
65
|
+
const sanitized = nameWithoutScope.toLowerCase().replace(/[^a-z0-9_-]/g, "");
|
|
66
|
+
return sanitized.slice(0, 40);
|
|
67
|
+
}
|
|
68
|
+
function isThirdPartyPackage(packageName) {
|
|
69
|
+
return !packageName.startsWith("@firebase-functions-kits/");
|
|
70
|
+
}
|
|
71
|
+
async function checkPackageHasShrinkwrap(rawPkgName) {
|
|
72
|
+
try {
|
|
73
|
+
const output = await (0, spawn_1.spawnWithOutput)("npm", ["pack", rawPkgName, "--dry-run", "--json"]);
|
|
74
|
+
const parsed = JSON.parse(output);
|
|
75
|
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
76
|
+
const pkgInfo = parsed[0];
|
|
77
|
+
if (pkgInfo.hasShrinkwrap) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (Array.isArray(pkgInfo.files)) {
|
|
81
|
+
return pkgInfo.files.some((f) => f.path === "npm-shrinkwrap.json" || f.path === "npm-shrinkwrap.js");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
logger_1.logger.debug(`Failed to inspect package shrinkwrap for ${rawPkgName}: ${(0, error_1.getErrMsg)(err)}`);
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
exports.command = new command_1.Command("functions:kits:install")
|
|
91
|
+
.description("install a function kit into your project")
|
|
92
|
+
.option("--npm_package <package>", "NPM package name or specifier to install as a function kit")
|
|
93
|
+
.option("--template [installation|migration]", "template to use for the kit index file", "installation")
|
|
94
|
+
.action(async (options) => {
|
|
95
|
+
experiments.assertEnabled("kits", "install a function kit");
|
|
96
|
+
if (!options.config) {
|
|
97
|
+
throw new error_1.FirebaseError("Not in a Firebase project directory (firebase.json not found).");
|
|
98
|
+
}
|
|
99
|
+
const templateType = options.template || "installation";
|
|
100
|
+
if (!(templateType in TEMPLATES)) {
|
|
101
|
+
throw new error_1.FirebaseError(`Invalid template '${templateType}'. Template must be 'installation' or 'migration'.`);
|
|
102
|
+
}
|
|
103
|
+
const rawPkgName = options.npm_package;
|
|
104
|
+
if (!rawPkgName) {
|
|
105
|
+
throw new error_1.FirebaseError("set the --npm_package option to a valid NPM package and try again.");
|
|
106
|
+
}
|
|
107
|
+
const { packageName, version } = parseNpmPackageSpecifier(rawPkgName);
|
|
108
|
+
validateNpmPackageName(packageName);
|
|
109
|
+
const isThirdParty = isThirdPartyPackage(packageName);
|
|
110
|
+
if (isThirdParty) {
|
|
111
|
+
logger_1.logger.warn(clc.yellow(`Warning: Package ${clc.bold(packageName)} is a third-party kit (outside the @firebase-functions-kits scope).`));
|
|
112
|
+
}
|
|
113
|
+
const hasShrinkwrap = await self.checkPackageHasShrinkwrap(rawPkgName);
|
|
114
|
+
if (!hasShrinkwrap) {
|
|
115
|
+
logger_1.logger.warn(clc.yellow(`Warning: 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.`));
|
|
116
|
+
}
|
|
117
|
+
if (isThirdParty || !hasShrinkwrap) {
|
|
118
|
+
let confirmMessage;
|
|
119
|
+
if (isThirdParty && !hasShrinkwrap) {
|
|
120
|
+
confirmMessage = `Are you sure you want to install the third-party kit ${packageName} without locked dependencies?`;
|
|
121
|
+
}
|
|
122
|
+
else if (isThirdParty) {
|
|
123
|
+
confirmMessage = `Are you sure you want to install the third-party kit ${packageName}?`;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
confirmMessage = `Are you sure you want to install ${packageName} without locked dependencies?`;
|
|
127
|
+
}
|
|
128
|
+
const confirmInstallation = await (0, prompt_1.confirm)({
|
|
129
|
+
message: confirmMessage,
|
|
130
|
+
default: false,
|
|
131
|
+
nonInteractive: options.nonInteractive,
|
|
132
|
+
});
|
|
133
|
+
if (!confirmInstallation) {
|
|
134
|
+
throw new error_1.FirebaseError("Installation cancelled.");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
let existingFunctions = [];
|
|
138
|
+
const configFunctions = options.config.src.functions;
|
|
139
|
+
if (configFunctions && (!Array.isArray(configFunctions) || configFunctions.length > 0)) {
|
|
140
|
+
try {
|
|
141
|
+
existingFunctions = (0, projectConfig_1.normalizeAndValidate)(configFunctions);
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
throw new error_1.FirebaseError(`Invalid existing functions configuration: ${(0, error_1.getErrMsg)(err)}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const existingKitIds = new Set();
|
|
148
|
+
const existingCodebases = new Set();
|
|
149
|
+
const existingInstanceIds = new Set();
|
|
150
|
+
for (const c of existingFunctions) {
|
|
151
|
+
if ((0, projectConfig_1.isKitConfig)(c)) {
|
|
152
|
+
if (c.kit) {
|
|
153
|
+
existingKitIds.add(c.kit);
|
|
154
|
+
}
|
|
155
|
+
if (c.instances) {
|
|
156
|
+
for (const instId of Object.keys(c.instances)) {
|
|
157
|
+
existingInstanceIds.add(instId);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (c.codebase) {
|
|
162
|
+
existingCodebases.add(c.codebase);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const baseKitId = sanitizePackageNameToKitName(packageName);
|
|
166
|
+
const defaultKitId = generateUniqueId(baseKitId, existingKitIds);
|
|
167
|
+
const kitId = await (0, prompt_1.input)({
|
|
168
|
+
message: "What would you like to name this kit?",
|
|
169
|
+
default: defaultKitId,
|
|
170
|
+
nonInteractive: options.nonInteractive,
|
|
171
|
+
validate: (val) => {
|
|
172
|
+
try {
|
|
173
|
+
(0, projectConfig_1.validateKit)(val);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
return (0, error_1.getErrMsg)(err);
|
|
177
|
+
}
|
|
178
|
+
if (existingKitIds.has(val)) {
|
|
179
|
+
return `functions.kit must be unique but '${val}' was used more than once.`;
|
|
180
|
+
}
|
|
181
|
+
return true;
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
(0, projectConfig_1.validateKit)(kitId);
|
|
185
|
+
if (existingKitIds.has(kitId)) {
|
|
186
|
+
throw new error_1.FirebaseError(`functions.kit must be unique but '${kitId}' was used more than once.`);
|
|
187
|
+
}
|
|
188
|
+
const instanceCollisions = new Set([...existingInstanceIds, ...existingCodebases]);
|
|
189
|
+
const defaultInstanceId = generateUniqueId(kitId, instanceCollisions);
|
|
190
|
+
const instanceId = await (0, prompt_1.input)({
|
|
191
|
+
message: "What would you like to name this instance?",
|
|
192
|
+
default: defaultInstanceId,
|
|
193
|
+
nonInteractive: options.nonInteractive,
|
|
194
|
+
validate: (val) => {
|
|
195
|
+
try {
|
|
196
|
+
(0, projectConfig_1.validateKitInstanceId)(val);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
return (0, error_1.getErrMsg)(err);
|
|
200
|
+
}
|
|
201
|
+
if (existingInstanceIds.has(val)) {
|
|
202
|
+
return `functions kit instance ID must be unique across all kits, but '${val}' was used more than once.`;
|
|
203
|
+
}
|
|
204
|
+
if (existingCodebases.has(val)) {
|
|
205
|
+
return `functions codebase name and kit instance ID must be mutually exclusive, but '${val}' was used as both a codebase name and a kit instance ID.`;
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
(0, projectConfig_1.validateKitInstanceId)(instanceId);
|
|
211
|
+
if (existingInstanceIds.has(instanceId)) {
|
|
212
|
+
throw new error_1.FirebaseError(`functions kit instance ID must be unique across all kits, but '${instanceId}' was used more than once.`);
|
|
213
|
+
}
|
|
214
|
+
if (existingCodebases.has(instanceId)) {
|
|
215
|
+
throw new error_1.FirebaseError(`functions codebase name and kit instance ID must be mutually exclusive, but '${instanceId}' was used as both a codebase name and a kit instance ID.`);
|
|
216
|
+
}
|
|
217
|
+
const sourcePath = path.join(FUNCTION_KITS_DIR, kitId);
|
|
218
|
+
const configDirPath = path.join(FUNCTION_KITS_DIR, kitId, `config-${instanceId}`);
|
|
219
|
+
const absSourcePath = options.config.path(sourcePath);
|
|
220
|
+
const absConfigDirPath = options.config.path(configDirPath);
|
|
221
|
+
await fs.ensureDir(absSourcePath);
|
|
222
|
+
await fs.ensureDir(absConfigDirPath);
|
|
223
|
+
const relPackageJsonPath = path.join(sourcePath, "package.json");
|
|
224
|
+
const absPackageJsonPath = options.config.path(relPackageJsonPath);
|
|
225
|
+
let pkgJson = {};
|
|
226
|
+
if (await fs.pathExists(absPackageJsonPath)) {
|
|
227
|
+
try {
|
|
228
|
+
pkgJson = (await fs.readJson(absPackageJsonPath));
|
|
229
|
+
}
|
|
230
|
+
catch (err) {
|
|
231
|
+
logger_1.logger.debug(`Failed to read existing package.json: ${(0, error_1.getErrMsg)(err)}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const latestNodeVersion = supported.latest("nodejs").replace("nodejs", "");
|
|
236
|
+
const subbedTemplate = PACKAGE_NO_LINTING_TEMPLATE.replace("{{RUNTIME}}", latestNodeVersion);
|
|
237
|
+
try {
|
|
238
|
+
pkgJson = JSON.parse(subbedTemplate);
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
throw new error_1.FirebaseError("Failed to parse package.nolint.json template: " + (0, error_1.getErrMsg)(err));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
pkgJson.name = `${kitId}-wrapper`;
|
|
245
|
+
pkgJson.dependencies = pkgJson.dependencies || {};
|
|
246
|
+
pkgJson.dependencies[packageName] = version || "latest";
|
|
247
|
+
await options.config.askWriteProjectFile(relPackageJsonPath, pkgJson);
|
|
248
|
+
await options.config.askWriteProjectFile(path.join(sourcePath, "tsconfig.json"), TSCONFIG_TEMPLATE);
|
|
249
|
+
await options.config.askWriteProjectFile(path.join(sourcePath, ".gitignore"), GITIGNORE_TEMPLATE);
|
|
250
|
+
const relIndexTsPath = path.join(sourcePath, "src", "index.ts");
|
|
251
|
+
const absIndexTsPath = options.config.path(relIndexTsPath);
|
|
252
|
+
if (!(await fs.pathExists(absIndexTsPath))) {
|
|
253
|
+
const template = templateType === "migration" ? INDEX_KIT_MIGRATION_TEMPLATE : INDEX_KIT_TEMPLATE;
|
|
254
|
+
const indexContent = template.replace("{{PACKAGE_NAME}}", packageName);
|
|
255
|
+
await options.config.askWriteProjectFile(relIndexTsPath, indexContent);
|
|
256
|
+
}
|
|
257
|
+
const installArgs = isThirdParty ? ["install", "--ignore-scripts"] : ["install"];
|
|
258
|
+
logger_1.logger.info(clc.bold(`Running npm ${installArgs.join(" ")}...`));
|
|
259
|
+
try {
|
|
260
|
+
await (0, spawn_1.wrapSpawn)("npm", installArgs, absSourcePath);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
throw new error_1.FirebaseError(`NPM install failed: ${(0, error_1.getErrMsg)(err)}`);
|
|
264
|
+
}
|
|
265
|
+
logger_1.logger.info(clc.bold("Building TypeScript source..."));
|
|
266
|
+
try {
|
|
267
|
+
await (0, spawn_1.wrapSpawn)("npm", ["run", "build"], absSourcePath);
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
throw new error_1.FirebaseError(`TypeScript build failed: ${(0, error_1.getErrMsg)(err)}`);
|
|
271
|
+
}
|
|
272
|
+
const newKitConfig = {
|
|
273
|
+
kit: kitId,
|
|
274
|
+
sourcePackage: {
|
|
275
|
+
name: packageName,
|
|
276
|
+
},
|
|
277
|
+
source: sourcePath,
|
|
278
|
+
instances: {
|
|
279
|
+
[instanceId]: configDirPath,
|
|
280
|
+
},
|
|
281
|
+
predeploy: ['npm --prefix "$RESOURCE_DIR" run build'],
|
|
282
|
+
};
|
|
283
|
+
if (!options.config.src.functions) {
|
|
284
|
+
options.config.src.functions = [newKitConfig];
|
|
285
|
+
}
|
|
286
|
+
else if (Array.isArray(options.config.src.functions)) {
|
|
287
|
+
options.config.src.functions.push(newKitConfig);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
options.config.src.functions = [options.config.src.functions, newKitConfig];
|
|
291
|
+
}
|
|
292
|
+
options.config.writeProjectFile("firebase.json", options.config.src);
|
|
293
|
+
logger_1.logger.info(clc.green(`✔ Function kit ${clc.bold(kitId)} successfully installed.`));
|
|
294
|
+
});
|
package/lib/commands/index.js
CHANGED
|
@@ -24,6 +24,18 @@ function load(client) {
|
|
|
24
24
|
client.appcheck.debugtokens.create = loadCommand("appcheck-debugtokens-create");
|
|
25
25
|
client.appcheck.debugtokens.list = loadCommand("appcheck-debugtokens-list");
|
|
26
26
|
client.appcheck.debugtokens.delete = loadCommand("appcheck-debugtokens-delete");
|
|
27
|
+
if (experiments.isEnabled("appcheckadmin")) {
|
|
28
|
+
client.appcheck.services = {};
|
|
29
|
+
client.appcheck.services.list = loadCommand("appcheck-services-list");
|
|
30
|
+
client.appcheck.services.get = loadCommand("appcheck-services-get");
|
|
31
|
+
client.appcheck.services.set = loadCommand("appcheck-services-set");
|
|
32
|
+
client.appcheck.providers = {};
|
|
33
|
+
client.appcheck.providers.list = loadCommand("appcheck-providers-list");
|
|
34
|
+
client.appcheck.providers.get = loadCommand("appcheck-providers-get");
|
|
35
|
+
client.appcheck.providers.set = loadCommand("appcheck-providers-set");
|
|
36
|
+
client.appcheck.apps = {};
|
|
37
|
+
client.appcheck.apps.list = loadCommand("appcheck-apps-list");
|
|
38
|
+
}
|
|
27
39
|
client.appdistribution = {};
|
|
28
40
|
client.appdistribution.distribute = loadCommand("appdistribution-distribute");
|
|
29
41
|
client.appdistribution.testers = {};
|
|
@@ -57,6 +69,8 @@ function load(client) {
|
|
|
57
69
|
client.auth.export = loadCommand("auth-export");
|
|
58
70
|
client.auth.import = loadCommand("auth-import");
|
|
59
71
|
client.crashlytics = {};
|
|
72
|
+
client.crashlytics.onboard = {};
|
|
73
|
+
client.crashlytics.onboard.web = loadCommand("crashlytics-onboard-web");
|
|
60
74
|
client.crashlytics.symbols = {};
|
|
61
75
|
client.crashlytics.symbols.upload = loadCommand("crashlytics-symbols-upload");
|
|
62
76
|
client.crashlytics.mappingfile = {};
|
|
@@ -171,6 +185,10 @@ function load(client) {
|
|
|
171
185
|
client.functions.secrets.set = loadCommand("functions-secrets-set");
|
|
172
186
|
client.functions.artifacts = {};
|
|
173
187
|
client.functions.artifacts.setpolicy = loadCommand("functions-artifacts-setpolicy");
|
|
188
|
+
if (experiments.isEnabled("kits")) {
|
|
189
|
+
client.functions.kits = {};
|
|
190
|
+
client.functions.kits.install = loadCommand("functions-kits-install");
|
|
191
|
+
}
|
|
174
192
|
client.help = loadCommand("help");
|
|
175
193
|
client.hosting = {};
|
|
176
194
|
client.hosting.channel = {};
|
|
@@ -228,6 +246,12 @@ function load(client) {
|
|
|
228
246
|
client.ailogic.config = {};
|
|
229
247
|
client.ailogic.config.get = loadCommand("ailogic-config-get");
|
|
230
248
|
client.ailogic.config.set = loadCommand("ailogic-config-set");
|
|
249
|
+
client.ailogic.templates = {};
|
|
250
|
+
client.ailogic.templates.list = loadCommand("ailogic-templates-list");
|
|
251
|
+
client.ailogic.templates.get = loadCommand("ailogic-templates-get");
|
|
252
|
+
client.ailogic.templates.delete = loadCommand("ailogic-templates-delete");
|
|
253
|
+
client.ailogic.templates.lock = loadCommand("ailogic-templates-lock");
|
|
254
|
+
client.ailogic.templates.unlock = loadCommand("ailogic-templates-unlock");
|
|
231
255
|
}
|
|
232
256
|
client.login = loadCommand("login");
|
|
233
257
|
client.login.add = loadCommand("login-add");
|
package/lib/commands/login.js
CHANGED
|
@@ -10,15 +10,62 @@ const error_1 = require("../error");
|
|
|
10
10
|
const prompt_1 = require("../prompt");
|
|
11
11
|
const auth = require("../auth");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
|
-
|
|
13
|
+
const TEMP_LOGIN_STATE_KEY = "tempLoginState";
|
|
14
|
+
exports.command = new command_1.Command("login [auth_code]")
|
|
14
15
|
.description("log the CLI into Firebase")
|
|
15
16
|
.option("--no-localhost", "login from a device without an accessible localhost")
|
|
16
17
|
.option("--reauth", "force reauthentication even if already logged in")
|
|
17
|
-
.action(async (options) => {
|
|
18
|
+
.action(async (authCode, options) => {
|
|
19
|
+
if (authCode) {
|
|
20
|
+
const state = configstore_1.configstore.get(TEMP_LOGIN_STATE_KEY);
|
|
21
|
+
if (!state || !state.codeVerifier) {
|
|
22
|
+
throw new error_1.FirebaseError("No pending login session found. Run " +
|
|
23
|
+
clc.bold("firebase login") +
|
|
24
|
+
" first to generate a login URL.", { exit: 1 });
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const result = await auth.loginRemotelyComplete(authCode, state.codeVerifier);
|
|
28
|
+
auth.recordCredentials(result);
|
|
29
|
+
configstore_1.configstore.delete(TEMP_LOGIN_STATE_KEY);
|
|
30
|
+
if (typeof result.user === "object" && result.user?.email) {
|
|
31
|
+
utils.logSuccess("Success! Logged in as " + clc.bold(result.user.email));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
utils.logSuccess("Success! Logged in");
|
|
35
|
+
}
|
|
36
|
+
return auth;
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
configstore_1.configstore.delete(TEMP_LOGIN_STATE_KEY);
|
|
40
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
41
|
+
throw new error_1.FirebaseError(`Login failed: ${message}`, { exit: 1 });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
18
44
|
if (options.nonInteractive && !options.prototyperLogin) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
45
|
+
try {
|
|
46
|
+
const { sessionId, sessionIdPrefix, loginUrl, codeVerifier } = await auth.loginRemotelyStart();
|
|
47
|
+
configstore_1.configstore.set(TEMP_LOGIN_STATE_KEY, { sessionId, codeVerifier });
|
|
48
|
+
logger_1.logger.info();
|
|
49
|
+
logger_1.logger.info("To sign in to the Firebase CLI:");
|
|
50
|
+
logger_1.logger.info();
|
|
51
|
+
logger_1.logger.info("1. Take note of your session ID:");
|
|
52
|
+
logger_1.logger.info();
|
|
53
|
+
logger_1.logger.info(` ${clc.bold(sessionIdPrefix)}`);
|
|
54
|
+
logger_1.logger.info();
|
|
55
|
+
logger_1.logger.info("2. Visit the URL below on any device and follow the instructions to get your code:");
|
|
56
|
+
logger_1.logger.info();
|
|
57
|
+
logger_1.logger.info(` ${loginUrl}`);
|
|
58
|
+
logger_1.logger.info();
|
|
59
|
+
logger_1.logger.info("3. Complete the login by running:");
|
|
60
|
+
logger_1.logger.info();
|
|
61
|
+
logger_1.logger.info(` ${clc.bold(`firebase login <authorizationCode>`)}`);
|
|
62
|
+
logger_1.logger.info();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
67
|
+
throw new error_1.FirebaseError(`Failed to start login: ${message}`, { exit: 1 });
|
|
68
|
+
}
|
|
22
69
|
}
|
|
23
70
|
const user = options.user;
|
|
24
71
|
const tokens = options.tokens;
|
|
@@ -51,7 +98,7 @@ exports.command = new command_1.Command("login")
|
|
|
51
98
|
const result = await auth.loginGoogle(useLocalhost, user?.email);
|
|
52
99
|
auth.recordCredentials(result);
|
|
53
100
|
logger_1.logger.info();
|
|
54
|
-
if (typeof result.user
|
|
101
|
+
if (typeof result.user === "object" && result.user?.email) {
|
|
55
102
|
utils.logSuccess("Success! Logged in as " + clc.bold(result.user.email));
|
|
56
103
|
}
|
|
57
104
|
else {
|
package/lib/config.js
CHANGED
|
@@ -24,7 +24,10 @@ exports.EventFilterSchema = zod_1.z
|
|
|
24
24
|
.optional()
|
|
25
25
|
.describe(`Counts events originating from the given app versions. Must be obtained from the *displayName* field in an API response. `),
|
|
26
26
|
issueId: zod_1.z.string().optional().describe(`Count events for the given issue`),
|
|
27
|
-
issueVariantId: zod_1.z
|
|
27
|
+
issueVariantId: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe(`Count events for the given issue variant. Only supported for mobile apps.`),
|
|
28
31
|
issueErrorTypes: zod_1.z
|
|
29
32
|
.array(zod_1.z.enum(["FATAL", "NON_FATAL", "ANR"]))
|
|
30
33
|
.optional()
|
|
@@ -32,7 +35,7 @@ exports.EventFilterSchema = zod_1.z
|
|
|
32
35
|
issueSignals: zod_1.z
|
|
33
36
|
.array(zod_1.z.enum(["SIGNAL_EARLY", "SIGNAL_FRESH", "SIGNAL_REGRESSED", "SIGNAL_REPETITIVE"]))
|
|
34
37
|
.optional()
|
|
35
|
-
.describe(`Counts events matching the given signals
|
|
38
|
+
.describe(`Counts events matching the given signals. Only supported for mobile apps.`),
|
|
36
39
|
operatingSystemDisplayNames: zod_1.z
|
|
37
40
|
.array(zod_1.z.string())
|
|
38
41
|
.optional()
|
|
@@ -40,11 +43,15 @@ exports.EventFilterSchema = zod_1.z
|
|
|
40
43
|
deviceDisplayNames: zod_1.z
|
|
41
44
|
.array(zod_1.z.string())
|
|
42
45
|
.optional()
|
|
43
|
-
.describe(`Must be obtained from the *displayName* field in an API response.`),
|
|
46
|
+
.describe(`Must be obtained from the *displayName* field in an API response. Only supported for mobile apps.`),
|
|
44
47
|
deviceFormFactors: zod_1.z
|
|
45
48
|
.array(zod_1.z.enum(["PHONE", "TABLET", "DESKTOP", "TV", "WATCH"]))
|
|
46
49
|
.optional()
|
|
47
|
-
.describe(`Counts events originating from the given device form factors
|
|
50
|
+
.describe(`Counts events originating from the given device form factors. Only supported for mobile apps.`),
|
|
51
|
+
browserFilterDisplayNames: zod_1.z
|
|
52
|
+
.array(zod_1.z.string())
|
|
53
|
+
.optional()
|
|
54
|
+
.describe(`Counts events originating from the given browser filter display names. Only supported for web apps.`),
|
|
48
55
|
})
|
|
49
56
|
.optional()
|
|
50
57
|
.describe(`Only events matching the given filters will be counted. All filters are optional.
|
|
@@ -60,6 +67,7 @@ const toolToParamMap = {
|
|
|
60
67
|
operatingSystemDisplayNames: "filter.operating_system.display_names",
|
|
61
68
|
deviceDisplayNames: "filter.device.display_names",
|
|
62
69
|
deviceFormFactors: "filter.device.form_factors",
|
|
70
|
+
browserFilterDisplayNames: "filter.browser.display_names",
|
|
63
71
|
};
|
|
64
72
|
function filterToUrlSearchParams(filter) {
|
|
65
73
|
const params = new URLSearchParams();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOrUpdateTelemetryConfig = createOrUpdateTelemetryConfig;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const API_VERSION = "v1alpha";
|
|
8
|
+
async function createOrUpdateTelemetryConfig(projectId, appId, logBucket, samplingRate = 1) {
|
|
9
|
+
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseTelemetryAdminOrigin)(), apiVersion: API_VERSION });
|
|
10
|
+
const configId = appId.replace(/[:.]/g, "-");
|
|
11
|
+
const configName = `projects/${projectId}/locations/global/configs/${configId}`;
|
|
12
|
+
const configBody = {
|
|
13
|
+
name: configName,
|
|
14
|
+
appId,
|
|
15
|
+
logBucket,
|
|
16
|
+
samplingRate,
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
const res = await client.post(`/projects/${projectId}/locations/global/configs?configId=${configId}`, configBody);
|
|
20
|
+
return res.body;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err.status === 409) {
|
|
24
|
+
try {
|
|
25
|
+
const patchRes = await client.patch(`/projects/${projectId}/locations/global/configs/${configId}?updateMask=logBucket,samplingRate`, configBody);
|
|
26
|
+
return patchRes.body;
|
|
27
|
+
}
|
|
28
|
+
catch (patchErr) {
|
|
29
|
+
const msg = patchErr.message || JSON.stringify(patchErr.body) || patchErr;
|
|
30
|
+
throw new error_1.FirebaseError(`Failed to patch telemetry config for web app ${appId} (status ${patchErr.status}): ${msg}`, { original: patchErr });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const msg = err.message || JSON.stringify(err.body) || err;
|
|
34
|
+
throw new error_1.FirebaseError(`Failed to configure telemetry for web app ${appId} (status ${err.status}): ${msg}`, { original: err });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = exports.CRASHLYTICS_TELEMETRY_SINK_ID = exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = void 0;
|
|
4
|
+
exports.onboardCrashlyticsWeb = onboardCrashlyticsWeb;
|
|
5
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const cloudbilling_1 = require("../gcp/cloudbilling");
|
|
8
|
+
const cloudlogging_1 = require("../gcp/cloudlogging");
|
|
9
|
+
const firebasetelemetry_1 = require("./firebasetelemetry");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = "firebase-telemetry";
|
|
12
|
+
exports.CRASHLYTICS_TELEMETRY_SINK_ID = "firebase-telemetry-routing";
|
|
13
|
+
exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = "firebasetelemetry.googleapis.com/App";
|
|
14
|
+
async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
15
|
+
const billingEnabled = await (0, cloudbilling_1.checkBillingEnabled)(projectId);
|
|
16
|
+
if (!billingEnabled && options.nonInteractive) {
|
|
17
|
+
throw new error_1.FirebaseError(`Crashlytics requires the Blaze plan, but project ${projectId} is not on the Blaze plan. ` +
|
|
18
|
+
`Please visit https://console.cloud.google.com/billing/linkedaccount?project=${projectId} to upgrade your project.`);
|
|
19
|
+
}
|
|
20
|
+
else if (!billingEnabled) {
|
|
21
|
+
await (0, cloudbilling_1.enableBilling)(projectId, "Crashlytics");
|
|
22
|
+
}
|
|
23
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling required telemetry APIs...");
|
|
24
|
+
await Promise.all([
|
|
25
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "firebasetelemetry.googleapis.com", "crashlytics", false),
|
|
26
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "firebasetelemetryadmin.googleapis.com", "crashlytics", false),
|
|
27
|
+
]);
|
|
28
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Telemetry APIs enabled.");
|
|
29
|
+
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging bucket '${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}'...`);
|
|
30
|
+
const bucket = await (0, cloudlogging_1.createOrUpdateLogBucket)(projectId, exports.CRASHLYTICS_TELEMETRY_BUCKET_ID, "global", true);
|
|
31
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging bucket configured.");
|
|
32
|
+
const destination = `logging.googleapis.com/projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`;
|
|
33
|
+
const filter = `resource.type="${exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE}"`;
|
|
34
|
+
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging routing sink '${exports.CRASHLYTICS_TELEMETRY_SINK_ID}'...`);
|
|
35
|
+
const sink = await (0, cloudlogging_1.createOrUpdateLogSink)(projectId, exports.CRASHLYTICS_TELEMETRY_SINK_ID, destination, filter);
|
|
36
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging routing sink configured.");
|
|
37
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Crashlytics telemetry for web app...");
|
|
38
|
+
const config = await (0, firebasetelemetry_1.createOrUpdateTelemetryConfig)(projectId, appId, `projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`, 1);
|
|
39
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics telemetry configured successfully.");
|
|
40
|
+
return { bucket, sink, config };
|
|
41
|
+
}
|
|
@@ -18,6 +18,8 @@ var CrashlyticsReport;
|
|
|
18
18
|
CrashlyticsReport["TOP_OPERATING_SYSTEMS"] = "topOperatingSystems";
|
|
19
19
|
CrashlyticsReport["TOP_APPLE_DEVICES"] = "topAppleDevices";
|
|
20
20
|
CrashlyticsReport["TOP_ANDROID_DEVICES"] = "topAndroidDevices";
|
|
21
|
+
CrashlyticsReport["TOP_BROWSERS"] = "topBrowsers";
|
|
22
|
+
CrashlyticsReport["WEB_METRICS"] = "webMetrics";
|
|
21
23
|
})(CrashlyticsReport || (exports.CrashlyticsReport = CrashlyticsReport = {}));
|
|
22
24
|
exports.CrashlyticsReportSchema = zod_1.z.nativeEnum(CrashlyticsReport);
|
|
23
25
|
exports.ReportInputSchema = zod_1.z.object({
|