firebase-tools 15.22.4 → 15.24.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/apiv2.js +91 -32
- package/lib/apphosting/backend.js +11 -4
- package/lib/bin/cli.js +9 -2
- package/lib/bin/progressiveHelp.js +126 -0
- package/lib/checkValidTargetFilters.js +1 -1
- package/lib/command.js +0 -7
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/deploy.js +27 -64
- package/lib/commands/functions-delete.js +5 -3
- package/lib/commands/functions-lifecycle-list.js +94 -0
- package/lib/commands/functions-lifecycle-run.js +29 -0
- package/lib/commands/index.js +3 -0
- package/lib/database/import.js +3 -3
- package/lib/dataconnect/webhook.js +1 -2
- package/lib/deploy/apphosting/index.js +26 -1
- package/lib/deploy/auth/index.js +18 -1
- package/lib/deploy/database/index.js +16 -1
- package/lib/deploy/dataconnect/index.js +19 -1
- package/lib/deploy/extensions/index.js +9 -1
- package/lib/deploy/firestore/index.js +20 -1
- package/lib/deploy/functions/backend.js +9 -0
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/index.js +33 -1
- package/lib/deploy/functions/params.js +23 -15
- package/lib/deploy/functions/prepare.js +96 -1
- package/lib/deploy/functions/prompts.js +81 -0
- package/lib/deploy/functions/release/fabricator.js +79 -4
- package/lib/deploy/functions/release/index.js +45 -23
- package/lib/deploy/functions/release/lifecycle.js +79 -53
- package/lib/deploy/functions/release/planner.js +43 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +4 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +18 -1
- package/lib/deploy/functions/runtimes/node/index.js +1 -2
- package/lib/deploy/functions/runtimes/python/index.js +1 -2
- package/lib/deploy/hosting/index.js +30 -1
- package/lib/deploy/hosting/uploader.js +2 -3
- package/lib/deploy/index.js +68 -8
- package/lib/deploy/remoteconfig/index.js +9 -1
- package/lib/deploy/storage/index.js +16 -1
- package/lib/downloadUtils.js +3 -1
- package/lib/emulator/auth/operations.js +18 -8
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/storage/apis/gcloud.js +61 -0
- package/lib/emulator/storage/multipart.js +82 -2
- package/lib/emulator/taskQueue.js +3 -11
- package/lib/extensions/extensionsHelper.js +6 -4
- package/lib/frameworks/utils.js +50 -1
- package/lib/gcp/iam.js +68 -2
- package/lib/gcp/knownRoles.json +99 -0
- package/lib/gcp/resourceManager.js +42 -1
- package/lib/gemini/fdcExperience.js +2 -2
- package/lib/hosting/initMiddleware.js +1 -1
- package/lib/hosting/proxy.js +57 -23
- package/lib/index.js +0 -1
- package/lib/management/apps.js +4 -2
- package/lib/profiler.js +1 -2
- package/lib/streamUtils.js +24 -0
- package/lib/track.js +1 -2
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +4 -21
- package/package.json +2 -4
package/lib/apiv2.js
CHANGED
|
@@ -7,10 +7,8 @@ exports.getAccessToken = getAccessToken;
|
|
|
7
7
|
exports.noKeepAliveAgent = noKeepAliveAgent;
|
|
8
8
|
const url_1 = require("url");
|
|
9
9
|
const stream_1 = require("stream");
|
|
10
|
-
const
|
|
10
|
+
const undici_1 = require("undici");
|
|
11
11
|
const retry = require("retry");
|
|
12
|
-
const abort_controller_1 = require("abort-controller");
|
|
13
|
-
const node_fetch_1 = require("node-fetch");
|
|
14
12
|
const http = require("http");
|
|
15
13
|
const https = require("https");
|
|
16
14
|
const util_1 = require("util");
|
|
@@ -19,6 +17,7 @@ const error_1 = require("./error");
|
|
|
19
17
|
const env_1 = require("./env");
|
|
20
18
|
const logger_1 = require("./logger");
|
|
21
19
|
const responseToError_1 = require("./responseToError");
|
|
20
|
+
const streamUtils_1 = require("./streamUtils");
|
|
22
21
|
const FormData = require("form-data");
|
|
23
22
|
const pkg = require("../package.json");
|
|
24
23
|
const CLI_VERSION = pkg.version;
|
|
@@ -36,7 +35,6 @@ const standardHeaders = () => {
|
|
|
36
35
|
exports.standardHeaders = standardHeaders;
|
|
37
36
|
const GOOG_QUOTA_USER_HEADER = "x-goog-quota-user";
|
|
38
37
|
exports.GOOG_USER_PROJECT_HEADER = "x-goog-user-project";
|
|
39
|
-
const GOOGLE_CLOUD_QUOTA_PROJECT = process.env.GOOGLE_CLOUD_QUOTA_PROJECT;
|
|
40
38
|
exports.CLI_OAUTH_PROJECT_NUMBER = "563584335869";
|
|
41
39
|
let accessToken = "";
|
|
42
40
|
let refreshToken = "";
|
|
@@ -56,11 +54,15 @@ async function getAccessToken() {
|
|
|
56
54
|
return data.access_token;
|
|
57
55
|
}
|
|
58
56
|
function proxyURIFromEnv() {
|
|
59
|
-
|
|
57
|
+
const uri = process.env.HTTPS_PROXY ||
|
|
60
58
|
process.env.https_proxy ||
|
|
61
59
|
process.env.HTTP_PROXY ||
|
|
62
60
|
process.env.http_proxy ||
|
|
63
|
-
undefined
|
|
61
|
+
undefined;
|
|
62
|
+
if (uri === "undefined" || uri === "null") {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return uri;
|
|
64
66
|
}
|
|
65
67
|
const httpAgentNoKeepAlive = new http.Agent({ keepAlive: false });
|
|
66
68
|
const httpsAgentNoKeepAlive = new https.Agent({ keepAlive: false });
|
|
@@ -147,7 +149,7 @@ class Client {
|
|
|
147
149
|
throw new error_1.FirebaseError("apiv2 will not handle HTTP errors while streaming and you must set `resolveOnHTTPError` and check for res.status >= 400 on your own", { exit: 2 });
|
|
148
150
|
}
|
|
149
151
|
let internalReqOptions = Object.assign(reqOptions, {
|
|
150
|
-
headers: new
|
|
152
|
+
headers: new Headers(reqOptions.headers),
|
|
151
153
|
});
|
|
152
154
|
internalReqOptions = this.addRequestHeaders(internalReqOptions);
|
|
153
155
|
if (this.opts.auth) {
|
|
@@ -176,7 +178,7 @@ class Client {
|
|
|
176
178
|
}
|
|
177
179
|
addRequestHeaders(reqOptions) {
|
|
178
180
|
if (!reqOptions.headers) {
|
|
179
|
-
reqOptions.headers = new
|
|
181
|
+
reqOptions.headers = new Headers();
|
|
180
182
|
}
|
|
181
183
|
for (const [h, v] of Object.entries((0, exports.standardHeaders)())) {
|
|
182
184
|
if (!reqOptions.headers.has(h)) {
|
|
@@ -189,15 +191,15 @@ class Client {
|
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
if (!reqOptions.ignoreQuotaProject &&
|
|
192
|
-
GOOGLE_CLOUD_QUOTA_PROJECT &&
|
|
193
|
-
GOOGLE_CLOUD_QUOTA_PROJECT !== "") {
|
|
194
|
-
reqOptions.headers.set(exports.GOOG_USER_PROJECT_HEADER, GOOGLE_CLOUD_QUOTA_PROJECT);
|
|
194
|
+
process.env.GOOGLE_CLOUD_QUOTA_PROJECT &&
|
|
195
|
+
process.env.GOOGLE_CLOUD_QUOTA_PROJECT !== "") {
|
|
196
|
+
reqOptions.headers.set(exports.GOOG_USER_PROJECT_HEADER, process.env.GOOGLE_CLOUD_QUOTA_PROJECT);
|
|
195
197
|
}
|
|
196
198
|
return reqOptions;
|
|
197
199
|
}
|
|
198
200
|
async addAuthHeader(reqOptions) {
|
|
199
201
|
if (!reqOptions.headers) {
|
|
200
|
-
reqOptions.headers = new
|
|
202
|
+
reqOptions.headers = new Headers();
|
|
201
203
|
}
|
|
202
204
|
let token;
|
|
203
205
|
if (isLocalInsecureRequest(this.opts.urlPrefix)) {
|
|
@@ -236,31 +238,21 @@ class Client {
|
|
|
236
238
|
headers: options.headers,
|
|
237
239
|
method: options.method,
|
|
238
240
|
redirect: options.redirect,
|
|
239
|
-
compress: options.compress,
|
|
240
241
|
};
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
const proxyURI = proxyURIFromEnv();
|
|
243
|
+
if (proxyURI) {
|
|
244
|
+
fetchOptions.dispatcher = new undici_1.ProxyAgent({ uri: proxyURI });
|
|
243
245
|
}
|
|
244
246
|
if (options.signal) {
|
|
245
|
-
|
|
246
|
-
signal.reason = "";
|
|
247
|
-
signal.throwIfAborted = () => {
|
|
248
|
-
throw new error_1.FirebaseError("Aborted");
|
|
249
|
-
};
|
|
250
|
-
fetchOptions.signal = signal;
|
|
247
|
+
fetchOptions.signal = options.signal;
|
|
251
248
|
}
|
|
252
249
|
let reqTimeout;
|
|
253
250
|
if (options.timeout) {
|
|
254
|
-
const controller = new
|
|
251
|
+
const controller = new AbortController();
|
|
255
252
|
reqTimeout = setTimeout(() => {
|
|
256
253
|
controller.abort();
|
|
257
254
|
}, options.timeout);
|
|
258
|
-
|
|
259
|
-
signal.reason = "";
|
|
260
|
-
signal.throwIfAborted = () => {
|
|
261
|
-
throw new error_1.FirebaseError("Aborted");
|
|
262
|
-
};
|
|
263
|
-
fetchOptions.signal = signal;
|
|
255
|
+
fetchOptions.signal = controller.signal;
|
|
264
256
|
}
|
|
265
257
|
let bodyReplayable = true;
|
|
266
258
|
if (typeof options.body === "string" || Buffer.isBuffer(options.body)) {
|
|
@@ -271,6 +263,7 @@ class Client {
|
|
|
271
263
|
}
|
|
272
264
|
else if (isStream(options.body)) {
|
|
273
265
|
fetchOptions.body = options.body;
|
|
266
|
+
fetchOptions.duplex = "half";
|
|
274
267
|
bodyReplayable = false;
|
|
275
268
|
}
|
|
276
269
|
else if (options.body !== undefined) {
|
|
@@ -302,10 +295,39 @@ class Client {
|
|
|
302
295
|
}
|
|
303
296
|
this.logRequest(options);
|
|
304
297
|
try {
|
|
305
|
-
|
|
298
|
+
if (options.compress === false) {
|
|
299
|
+
const undiciOptions = {
|
|
300
|
+
method: fetchOptions.method,
|
|
301
|
+
headers: {},
|
|
302
|
+
decompress: false,
|
|
303
|
+
};
|
|
304
|
+
if (fetchOptions.dispatcher) {
|
|
305
|
+
undiciOptions.dispatcher = fetchOptions.dispatcher;
|
|
306
|
+
}
|
|
307
|
+
if (fetchOptions.signal) {
|
|
308
|
+
undiciOptions.signal = fetchOptions.signal;
|
|
309
|
+
}
|
|
310
|
+
if (fetchOptions.body) {
|
|
311
|
+
undiciOptions.body = fetchOptions.body;
|
|
312
|
+
}
|
|
313
|
+
if (fetchOptions.headers) {
|
|
314
|
+
for (const [key, value] of fetchOptions.headers.entries()) {
|
|
315
|
+
undiciOptions.headers[key] = value;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const undiciRes = await (0, undici_1.request)(fetchURL, undiciOptions);
|
|
319
|
+
res = new UndiciResponseCompat(undiciRes);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
res = await fetch(fetchURL, fetchOptions);
|
|
323
|
+
}
|
|
306
324
|
}
|
|
307
325
|
catch (thrown) {
|
|
308
|
-
const err = thrown
|
|
326
|
+
const err = thrown && typeof thrown === "object" && thrown.cause instanceof Error
|
|
327
|
+
? thrown.cause
|
|
328
|
+
: thrown instanceof Error
|
|
329
|
+
? thrown
|
|
330
|
+
: new Error(thrown);
|
|
309
331
|
logger_1.logger.debug(`*** [apiv2] error from fetch(${fetchURL}, ${JSON.stringify(fetchOptions)}): ${err}`);
|
|
310
332
|
const isAbortError = err.name.includes("AbortError");
|
|
311
333
|
if (isAbortError) {
|
|
@@ -339,7 +361,19 @@ class Client {
|
|
|
339
361
|
body = (await res.text());
|
|
340
362
|
}
|
|
341
363
|
else if (options.responseType === "stream") {
|
|
342
|
-
|
|
364
|
+
if (res.body) {
|
|
365
|
+
if (typeof res.body.getReader === "function") {
|
|
366
|
+
body = stream_1.Readable.fromWeb(res.body);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
body = res.body;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
const emptyStream = new stream_1.Readable();
|
|
374
|
+
emptyStream.push(null);
|
|
375
|
+
body = emptyStream;
|
|
376
|
+
}
|
|
343
377
|
}
|
|
344
378
|
else {
|
|
345
379
|
throw new error_1.FirebaseError(`Unable to interpret response. Please set responseType.`, {
|
|
@@ -354,7 +388,7 @@ class Client {
|
|
|
354
388
|
isPrematureCloseError(err)) {
|
|
355
389
|
disabledKeepAlive = true;
|
|
356
390
|
fetchOptions.agent = noKeepAliveAgent;
|
|
357
|
-
const closeHeaders = new
|
|
391
|
+
const closeHeaders = new Headers(fetchOptions.headers);
|
|
358
392
|
closeHeaders.set("Connection", "close");
|
|
359
393
|
fetchOptions.headers = closeHeaders;
|
|
360
394
|
logger_1.logger.debug(`*** [apiv2] retrying ${fetchURL} without keep-alive after a premature close error`);
|
|
@@ -435,6 +469,31 @@ function isLocalInsecureRequest(urlPrefix) {
|
|
|
435
469
|
const u = new url_1.URL(urlPrefix);
|
|
436
470
|
return u.protocol === "http:";
|
|
437
471
|
}
|
|
472
|
+
class UndiciResponseCompat {
|
|
473
|
+
constructor(undiciRes) {
|
|
474
|
+
this.undiciRes = undiciRes;
|
|
475
|
+
this.status = undiciRes.statusCode;
|
|
476
|
+
this.ok = undiciRes.statusCode >= 200 && undiciRes.statusCode < 300;
|
|
477
|
+
this.headers = new Headers();
|
|
478
|
+
for (const [key, value] of Object.entries(undiciRes.headers)) {
|
|
479
|
+
if (Array.isArray(value)) {
|
|
480
|
+
for (const v of value) {
|
|
481
|
+
this.headers.append(key, v);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
else if (value !== undefined) {
|
|
485
|
+
this.headers.set(key, String(value));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
this.body = undiciRes.body;
|
|
489
|
+
}
|
|
490
|
+
async text() {
|
|
491
|
+
if (!this.body) {
|
|
492
|
+
return "";
|
|
493
|
+
}
|
|
494
|
+
return (0, streamUtils_1.streamToString)(this.body);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
438
497
|
function bodyToString(body) {
|
|
439
498
|
if (isStream(body)) {
|
|
440
499
|
return "[stream]";
|
|
@@ -31,7 +31,6 @@ const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
|
31
31
|
const deploymentTool = require("../deploymentTool");
|
|
32
32
|
const app_1 = require("./app");
|
|
33
33
|
const ora = require("ora");
|
|
34
|
-
const node_fetch_1 = require("node-fetch");
|
|
35
34
|
const rollout_1 = require("./rollout");
|
|
36
35
|
const fuzzy = require("fuzzy");
|
|
37
36
|
const experiments_1 = require("../experiments");
|
|
@@ -45,7 +44,7 @@ const apphostingPollerOptions = {
|
|
|
45
44
|
};
|
|
46
45
|
async function tlsReady(url) {
|
|
47
46
|
try {
|
|
48
|
-
await (
|
|
47
|
+
await fetch(url);
|
|
49
48
|
return true;
|
|
50
49
|
}
|
|
51
50
|
catch (err) {
|
|
@@ -213,8 +212,16 @@ async function promptNewBackendId(projectId, location) {
|
|
|
213
212
|
while (true) {
|
|
214
213
|
const backendId = await (0, prompt_1.input)({
|
|
215
214
|
default: "my-web-app",
|
|
216
|
-
message: "Provide a name for your backend [
|
|
217
|
-
validate: (s) =>
|
|
215
|
+
message: "Provide a name for your backend [3-30 characters]",
|
|
216
|
+
validate: (s) => {
|
|
217
|
+
if (!/^[a-z](?:[a-z0-9-]*[a-z0-9])?$/.test(s)) {
|
|
218
|
+
return "Must begin with a letter, can contain only lowercase, digits, hyphens, and cannot end with hyphen";
|
|
219
|
+
}
|
|
220
|
+
else if (s.length < 3 || s.length > 30) {
|
|
221
|
+
return "Must be between 3 and 30 characters";
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
},
|
|
218
225
|
});
|
|
219
226
|
try {
|
|
220
227
|
await apphosting.getBackend(projectId, location, backendId);
|
package/lib/bin/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ const fs = require("node:fs");
|
|
|
11
11
|
const configstore_1 = require("../configstore");
|
|
12
12
|
const errorOut_1 = require("../errorOut");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
|
+
const progressiveHelp_1 = require("./progressiveHelp");
|
|
14
15
|
const experiments_1 = require("../experiments");
|
|
15
16
|
(0, experiments_1.enableExperimentsFromCliEnvVariable)();
|
|
16
17
|
const client = require("..");
|
|
@@ -50,6 +51,10 @@ function cli(pkg) {
|
|
|
50
51
|
}
|
|
51
52
|
process.env.IS_FIREBASE_CLI = "true";
|
|
52
53
|
const logFilename = (0, logger_1.useFileLogger)();
|
|
54
|
+
const hasJson = args.includes("--json") || args.includes("-j");
|
|
55
|
+
if (!hasJson) {
|
|
56
|
+
(0, logger_1.useConsoleLoggers)();
|
|
57
|
+
}
|
|
53
58
|
logger_1.logger.debug("-".repeat(70));
|
|
54
59
|
logger_1.logger.debug("Command: ", process.argv.join(" "));
|
|
55
60
|
logger_1.logger.debug("CLI Version: ", pkg.version);
|
|
@@ -113,16 +118,18 @@ function cli(pkg) {
|
|
|
113
118
|
(0, errorOut_1.errorOut)(err);
|
|
114
119
|
});
|
|
115
120
|
const commandName = args[0];
|
|
121
|
+
const hasHelpFlag = args.includes("--help") || args.includes("-h");
|
|
116
122
|
const isHelp = !args.length ||
|
|
117
123
|
commandName === "help" ||
|
|
118
124
|
(args.length === 1 && commandName === "ext") ||
|
|
119
|
-
commandName === "--help"
|
|
120
|
-
|
|
125
|
+
commandName === "--help" ||
|
|
126
|
+
hasHelpFlag;
|
|
121
127
|
if (hasHelpFlag) {
|
|
122
128
|
client.getCommand(commandName);
|
|
123
129
|
}
|
|
124
130
|
if (isHelp) {
|
|
125
131
|
loadAllCommands(client);
|
|
132
|
+
(0, progressiveHelp_1.setupProgressiveHelp)(client);
|
|
126
133
|
}
|
|
127
134
|
if (!args.length) {
|
|
128
135
|
client.cli.help();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupProgressiveHelp = setupProgressiveHelp;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const NAMESPACE_DESCRIPTIONS = {
|
|
7
|
+
appdistribution: "manage App Distribution resources",
|
|
8
|
+
apphosting: "manage App Hosting resources",
|
|
9
|
+
apps: "manage Firebase apps",
|
|
10
|
+
auth: "manage Firebase Auth",
|
|
11
|
+
crashlytics: "manage Crashlytics symbols and mappings",
|
|
12
|
+
database: "manage Realtime Database",
|
|
13
|
+
dataconnect: "manage Data Connect resources",
|
|
14
|
+
emulators: "start and manage local Firebase emulators",
|
|
15
|
+
experiments: "enable and disable CLI experiments",
|
|
16
|
+
ext: "manage Firebase Extensions",
|
|
17
|
+
firestore: "manage Cloud Firestore resources",
|
|
18
|
+
functions: "manage Cloud Functions",
|
|
19
|
+
hosting: "manage Firebase Hosting sites and channels",
|
|
20
|
+
projects: "manage Firebase projects",
|
|
21
|
+
remoteconfig: "manage Remote Config",
|
|
22
|
+
target: "manage deploy targets",
|
|
23
|
+
};
|
|
24
|
+
function patchHelpInformation(cmd, prefix, program) {
|
|
25
|
+
const originalHelpInformation = cmd.helpInformation;
|
|
26
|
+
cmd.helpInformation = function () {
|
|
27
|
+
const filteredCommands = program.commands.filter((subCmd) => {
|
|
28
|
+
const name = subCmd.name();
|
|
29
|
+
if (prefix === "") {
|
|
30
|
+
return !name.includes(":");
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (!name.startsWith(prefix + ":")) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const remainder = name.slice(prefix.length + 1);
|
|
37
|
+
return !remainder.includes(":");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const originalCommands = this.commands;
|
|
41
|
+
this.commands = filteredCommands;
|
|
42
|
+
const result = originalHelpInformation.call(this);
|
|
43
|
+
this.commands = originalCommands;
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function setupProgressiveHelp(client) {
|
|
48
|
+
const program = client.cli;
|
|
49
|
+
const existingNames = new Set(program.commands.map((cmd) => cmd.name()));
|
|
50
|
+
const allNamespaces = new Set();
|
|
51
|
+
for (const cmd of program.commands) {
|
|
52
|
+
const parts = cmd.name().split(":");
|
|
53
|
+
for (let i = 1; i < parts.length; i++) {
|
|
54
|
+
const ns = parts.slice(0, i).join(":");
|
|
55
|
+
allNamespaces.add(ns);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const ns of allNamespaces) {
|
|
59
|
+
if (!existingNames.has(ns)) {
|
|
60
|
+
const description = NAMESPACE_DESCRIPTIONS[ns] || `manage ${ns} resources`;
|
|
61
|
+
const nsCmd = program.command(ns);
|
|
62
|
+
nsCmd.description(description);
|
|
63
|
+
nsCmd.action(() => {
|
|
64
|
+
nsCmd.outputHelp();
|
|
65
|
+
});
|
|
66
|
+
nsCmd.on("--help", () => {
|
|
67
|
+
logger_1.logger.info();
|
|
68
|
+
logger_1.logger.info("To see more about a specific command, run:");
|
|
69
|
+
logger_1.logger.info(` ${clc.bold("firebase " + ns + ":<command> --help")}`);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const { TARGETS, VALID_DEPLOY_TARGETS } = require("../deploy");
|
|
75
|
+
for (const targetName of VALID_DEPLOY_TARGETS) {
|
|
76
|
+
const ns = `deploy:${targetName}`;
|
|
77
|
+
if (!existingNames.has(ns)) {
|
|
78
|
+
const target = TARGETS[targetName];
|
|
79
|
+
const description = target.help || `deploy ${targetName} resources`;
|
|
80
|
+
const nsCmd = program.command(ns);
|
|
81
|
+
nsCmd.description(description);
|
|
82
|
+
nsCmd.action(() => {
|
|
83
|
+
nsCmd.outputHelp();
|
|
84
|
+
logger_1.logger.info();
|
|
85
|
+
logger_1.logger.info(`To deploy ${targetName}, run: ${clc.bold("firebase deploy --only " + targetName)}`);
|
|
86
|
+
logger_1.logger.info();
|
|
87
|
+
});
|
|
88
|
+
nsCmd.on("--help", () => {
|
|
89
|
+
logger_1.logger.info();
|
|
90
|
+
logger_1.logger.info(clc.bold(`Detailed setup and configuration for ${targetName}:`));
|
|
91
|
+
logger_1.logger.info();
|
|
92
|
+
if (target && target.detailedHelp) {
|
|
93
|
+
logger_1.logger.info(target.detailedHelp);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
logger_1.logger.info(`Configuration for ${clc.bold(targetName)} is defined in your project's ${clc.bold("firebase.json")}.`);
|
|
97
|
+
logger_1.logger.info(`For more details, see the Firebase documentation:`);
|
|
98
|
+
logger_1.logger.info(` https://firebase.google.com/docs/cli#the_firebasejson_file`);
|
|
99
|
+
}
|
|
100
|
+
logger_1.logger.info();
|
|
101
|
+
logger_1.logger.info(clc.bold("General help for firebase deploy:"));
|
|
102
|
+
logger_1.logger.info();
|
|
103
|
+
const deployCmd = program.commands.find((c) => c.name() === "deploy");
|
|
104
|
+
if (deployCmd) {
|
|
105
|
+
deployCmd.outputHelp();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
}
|
|
113
|
+
const progTyped = program;
|
|
114
|
+
patchHelpInformation(progTyped, "", progTyped);
|
|
115
|
+
for (const cmd of program.commands) {
|
|
116
|
+
const name = cmd.name();
|
|
117
|
+
if (allNamespaces.has(name)) {
|
|
118
|
+
patchHelpInformation(cmd, name, progTyped);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
program.on("--help", () => {
|
|
122
|
+
logger_1.logger.info();
|
|
123
|
+
logger_1.logger.info("To see more about a specific namespace or command, run:");
|
|
124
|
+
logger_1.logger.info(` ${clc.bold("firebase <namespace|command> --help")}`);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkValidTargetFilters = checkValidTargetFilters;
|
|
4
|
-
const deploy_1 = require("./
|
|
4
|
+
const deploy_1 = require("./deploy");
|
|
5
5
|
const error_1 = require("./error");
|
|
6
6
|
function targetsForTypes(only, ...types) {
|
|
7
7
|
return only.filter((t) => {
|
package/lib/command.js
CHANGED
|
@@ -17,7 +17,6 @@ const auth_1 = require("./auth");
|
|
|
17
17
|
const projects_1 = require("./management/projects");
|
|
18
18
|
const studio_1 = require("./management/studio");
|
|
19
19
|
const requireAuth_1 = require("./requireAuth");
|
|
20
|
-
const logger_1 = require("./logger");
|
|
21
20
|
const env_1 = require("./env");
|
|
22
21
|
function isCommandModule(value) {
|
|
23
22
|
return typeof value === "function" && typeof value.load === "function";
|
|
@@ -90,9 +89,6 @@ class Command {
|
|
|
90
89
|
const start = process.uptime();
|
|
91
90
|
const options = (0, lodash_1.last)(args);
|
|
92
91
|
if (args.length - 1 > cmd._args.length) {
|
|
93
|
-
if (!(0, utils_1.getInheritedOption)(options, "json") && !options.isMCP) {
|
|
94
|
-
(0, logger_1.useConsoleLoggers)();
|
|
95
|
-
}
|
|
96
92
|
client.errorOut(new error_1.FirebaseError(`Too many arguments. Run ${clc.bold("firebase help " + this.name)} for usage instructions`, { exit: 1 }));
|
|
97
93
|
return;
|
|
98
94
|
}
|
|
@@ -172,9 +168,6 @@ class Command {
|
|
|
172
168
|
if ((0, utils_1.getInheritedOption)(options, "debug")) {
|
|
173
169
|
options.debug = true;
|
|
174
170
|
}
|
|
175
|
-
if (!(0, utils_1.getInheritedOption)(options, "json") && !options.isMCP) {
|
|
176
|
-
(0, logger_1.useConsoleLoggers)();
|
|
177
|
-
}
|
|
178
171
|
if ((0, utils_1.getInheritedOption)(options, "config")) {
|
|
179
172
|
options.configPath = (0, utils_1.getInheritedOption)(options, "config");
|
|
180
173
|
}
|
|
@@ -23,7 +23,7 @@ const logger_1 = require("../logger");
|
|
|
23
23
|
const responseToError_1 = require("../responseToError");
|
|
24
24
|
let stdinUsedFor = undefined;
|
|
25
25
|
exports.command = new command_1.Command("dataconnect:execute [file] [operationName]")
|
|
26
|
-
.description(
|
|
26
|
+
.description(`execute a SQL Connect query or mutation. If ${constants_1.Constants.FIREBASE_DATACONNECT_EMULATOR_HOST} is set (such as during 'firebase emulator:exec'), executes against the emulator instead.`)
|
|
27
27
|
.option("--service <serviceId>", "The service ID to execute against (optional if there's only one service)")
|
|
28
28
|
.option("--location <locationId>", "The location ID to execute against (optional if there's only one service). Ignored by the emulator.")
|
|
29
29
|
.option("--vars, --variables <vars>", "Supply variables to the operation execution, which must be a JSON object whose keys are variable names. If vars begin with the character @, the rest is interpreted as a file name to read from, or - to read from stdin.")
|
package/lib/commands/deploy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command =
|
|
3
|
+
exports.command = void 0;
|
|
4
4
|
const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
|
|
5
5
|
const requirePermissions_1 = require("../requirePermissions");
|
|
6
6
|
const checkIam_1 = require("../deploy/functions/checkIam");
|
|
@@ -17,69 +17,32 @@ const interactive_1 = require("../hosting/interactive");
|
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
18
|
const api_1 = require("../hosting/api");
|
|
19
19
|
const experiments = require("../experiments");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
firestore: [
|
|
44
|
-
"datastore.indexes.list",
|
|
45
|
-
"datastore.indexes.create",
|
|
46
|
-
"datastore.indexes.update",
|
|
47
|
-
"datastore.indexes.delete",
|
|
48
|
-
],
|
|
49
|
-
storage: [
|
|
50
|
-
"firebaserules.releases.create",
|
|
51
|
-
"firebaserules.rulesets.create",
|
|
52
|
-
"firebaserules.releases.update",
|
|
53
|
-
],
|
|
54
|
-
remoteconfig: ["cloudconfig.configs.get", "cloudconfig.configs.update"],
|
|
55
|
-
dataconnect: [
|
|
56
|
-
"cloudsql.databases.create",
|
|
57
|
-
"cloudsql.databases.update",
|
|
58
|
-
"cloudsql.instances.connect",
|
|
59
|
-
"cloudsql.instances.create",
|
|
60
|
-
"cloudsql.instances.get",
|
|
61
|
-
"cloudsql.instances.list",
|
|
62
|
-
"cloudsql.instances.update",
|
|
63
|
-
"cloudsql.users.create",
|
|
64
|
-
"firebasedataconnect.connectors.create",
|
|
65
|
-
"firebasedataconnect.connectors.delete",
|
|
66
|
-
"firebasedataconnect.connectors.list",
|
|
67
|
-
"firebasedataconnect.connectors.update",
|
|
68
|
-
"firebasedataconnect.operations.get",
|
|
69
|
-
"firebasedataconnect.services.create",
|
|
70
|
-
"firebasedataconnect.services.delete",
|
|
71
|
-
"firebasedataconnect.services.update",
|
|
72
|
-
"firebasedataconnect.services.list",
|
|
73
|
-
"firebasedataconnect.schemas.create",
|
|
74
|
-
"firebasedataconnect.schemas.delete",
|
|
75
|
-
"firebasedataconnect.schemas.list",
|
|
76
|
-
"firebasedataconnect.schemas.update",
|
|
77
|
-
],
|
|
78
|
-
apphosting: [],
|
|
79
|
-
auth: ["firebase.projects.update", "firebaseauth.configs.update"],
|
|
80
|
-
};
|
|
20
|
+
const clc = require("colorette");
|
|
21
|
+
function getDeployHelp() {
|
|
22
|
+
const boldFn = (str) => clc.bold(str);
|
|
23
|
+
let targetHelp = "Deploy targets include:\n\n";
|
|
24
|
+
for (const [targetName, target] of Object.entries(deploy_1.TARGETS)) {
|
|
25
|
+
const desc = target.help || `Deploy ${targetName} resources`;
|
|
26
|
+
const formattedDesc = desc
|
|
27
|
+
.split("\n")
|
|
28
|
+
.map((line, i) => {
|
|
29
|
+
if (i === 0)
|
|
30
|
+
return line;
|
|
31
|
+
return " " + line;
|
|
32
|
+
})
|
|
33
|
+
.join("\n");
|
|
34
|
+
targetHelp += ` ${boldFn(targetName.padEnd(14))} ${formattedDesc}\n`;
|
|
35
|
+
}
|
|
36
|
+
targetHelp +=
|
|
37
|
+
"\nTo deploy specific targets, use `--only` followed by a comma-separated list of targets.\n";
|
|
38
|
+
targetHelp += `For example, ${boldFn("firebase deploy --only hosting,firestore")}.\n`;
|
|
39
|
+
targetHelp += `\nTo see detailed setup and configuration information for a specific target, run:\n`;
|
|
40
|
+
targetHelp += ` ${boldFn("firebase deploy:<target> --help")}`;
|
|
41
|
+
return targetHelp;
|
|
42
|
+
}
|
|
81
43
|
exports.command = new command_1.Command("deploy")
|
|
82
44
|
.description("deploy code and assets to your Firebase project")
|
|
45
|
+
.help(getDeployHelp())
|
|
83
46
|
.withForce("delete Cloud Functions missing from the current working directory and bypass interactive prompts")
|
|
84
47
|
.option("-p, --public <path>", "override the Hosting public directory specified in firebase.json")
|
|
85
48
|
.option("-m, --message <message>", "an optional message describing this deploy")
|
|
@@ -100,9 +63,9 @@ if (experiments.isEnabled("apphostinglocalbuilds")) {
|
|
|
100
63
|
exports.command
|
|
101
64
|
.before(requireConfig_1.requireConfig)
|
|
102
65
|
.before((options) => {
|
|
103
|
-
options.filteredTargets = (0, filterTargets_1.filterTargets)(options,
|
|
66
|
+
options.filteredTargets = (0, filterTargets_1.filterTargets)(options, [...deploy_1.VALID_DEPLOY_TARGETS]);
|
|
104
67
|
const permissions = options.filteredTargets.reduce((perms, target) => {
|
|
105
|
-
return perms.concat(
|
|
68
|
+
return perms.concat(deploy_1.TARGET_PERMISSIONS[target]);
|
|
106
69
|
}, []);
|
|
107
70
|
return (0, requirePermissions_1.requirePermissions)(options, permissions);
|
|
108
71
|
})
|
|
@@ -40,14 +40,15 @@ exports.command = new command_1.Command("functions:delete [filters...]")
|
|
|
40
40
|
if (options.region) {
|
|
41
41
|
existingBackend.endpoints = { [options.region]: existingBackend.endpoints[options.region] };
|
|
42
42
|
}
|
|
43
|
-
const plan = planner.createDeploymentPlan({
|
|
43
|
+
const plan = await planner.createDeploymentPlan({
|
|
44
44
|
wantBackend: backend.empty(),
|
|
45
45
|
haveBackend: existingBackend,
|
|
46
46
|
codebase: "",
|
|
47
|
+
projectId: context.projectId,
|
|
47
48
|
filters: context.filters,
|
|
48
49
|
deleteAll: true,
|
|
49
50
|
});
|
|
50
|
-
const allEpToDelete = Object.values(plan)
|
|
51
|
+
const allEpToDelete = Object.values(plan.regionalChangesets)
|
|
51
52
|
.map((changes) => changes.endpointsToDelete)
|
|
52
53
|
.reduce(functional_1.reduceFlat, [])
|
|
53
54
|
.sort(backend.compareFunctions);
|
|
@@ -80,8 +81,9 @@ exports.command = new command_1.Command("functions:delete [filters...]")
|
|
|
80
81
|
executor: new executor.QueueExecutor({}),
|
|
81
82
|
sources: {},
|
|
82
83
|
projectNumber: options.projectNumber || (await (0, getProjectNumber_1.getProjectNumber)({ projectId: context.projectId })),
|
|
84
|
+
projectId: context.projectId,
|
|
83
85
|
});
|
|
84
|
-
const summary = await fab.applyPlan(plan);
|
|
86
|
+
const summary = await fab.applyPlan({ default: plan });
|
|
85
87
|
await reporter.logAndTrackDeployStats(summary);
|
|
86
88
|
reporter.printErrors(summary);
|
|
87
89
|
}
|