firebase-tools 10.3.0 → 10.3.1
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/commands/ext-configure.js +11 -5
- package/lib/commands/ext-install.js +11 -6
- package/lib/commands/ext-update.js +5 -3
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +12 -5
- package/lib/emulator/functionsEmulator.js +4 -4
- package/lib/emulator/functionsEmulatorShared.js +13 -1
- package/lib/extensions/askUserForParam.js +30 -24
- package/lib/extensions/manifest.js +3 -3
- package/lib/extensions/paramHelper.js +26 -5
- package/lib/gcp/cloudfunctions.js +5 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ const logger_1 = require("../logger");
|
|
|
18
18
|
const refs = require("../extensions/refs");
|
|
19
19
|
const manifest = require("../extensions/manifest");
|
|
20
20
|
const functional_1 = require("../functional");
|
|
21
|
+
const paramHelper_1 = require("../extensions/paramHelper");
|
|
21
22
|
marked.setOptions({
|
|
22
23
|
renderer: new TerminalRenderer(),
|
|
23
24
|
});
|
|
@@ -49,7 +50,7 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
49
50
|
const [immutableParams, tbdParams] = (0, functional_1.partition)(extensionVersion.spec.params, (param) => { var _a; return (_a = param.immutable) !== null && _a !== void 0 ? _a : false; });
|
|
50
51
|
infoImmutableParams(immutableParams, oldParamValues);
|
|
51
52
|
paramHelper.setNewDefaults(tbdParams, oldParamValues);
|
|
52
|
-
const
|
|
53
|
+
const mutableParamsBindingOptions = await paramHelper.getParams({
|
|
53
54
|
projectId,
|
|
54
55
|
paramSpecs: tbdParams,
|
|
55
56
|
nonInteractive: false,
|
|
@@ -57,7 +58,7 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
57
58
|
instanceId,
|
|
58
59
|
reconfiguring: true,
|
|
59
60
|
});
|
|
60
|
-
const newParamValues = Object.assign(Object.assign({}, oldParamValues),
|
|
61
|
+
const newParamValues = Object.assign(Object.assign({}, oldParamValues), (0, paramHelper_1.getBaseParamBindings)(mutableParamsBindingOptions));
|
|
61
62
|
await manifest.writeToManifest([
|
|
62
63
|
{
|
|
63
64
|
instanceId,
|
|
@@ -87,7 +88,7 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
87
88
|
}
|
|
88
89
|
const paramSpecWithNewDefaults = paramHelper.getParamsWithCurrentValuesAsDefaults(existingInstance);
|
|
89
90
|
const immutableParams = _.remove(paramSpecWithNewDefaults, (param) => param.immutable);
|
|
90
|
-
const
|
|
91
|
+
const paramBindingOptions = await paramHelper.getParams({
|
|
91
92
|
projectId,
|
|
92
93
|
paramSpecs: paramSpecWithNewDefaults,
|
|
93
94
|
nonInteractive: options.nonInteractive,
|
|
@@ -95,13 +96,14 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
95
96
|
instanceId,
|
|
96
97
|
reconfiguring: true,
|
|
97
98
|
});
|
|
99
|
+
const paramBindings = (0, paramHelper_1.getBaseParamBindings)(paramBindingOptions);
|
|
98
100
|
if (immutableParams.length) {
|
|
99
101
|
const plural = immutableParams.length > 1;
|
|
100
102
|
logger_1.logger.info(`The following param${plural ? "s are" : " is"} immutable:`);
|
|
101
103
|
for (const { param } of immutableParams) {
|
|
102
104
|
const value = _.get(existingInstance, `config.params.${param}`);
|
|
103
105
|
logger_1.logger.info(`param: ${param}, value: ${value}`);
|
|
104
|
-
|
|
106
|
+
paramBindings[param] = value;
|
|
105
107
|
}
|
|
106
108
|
logger_1.logger.info((plural
|
|
107
109
|
? "To set different values for these params"
|
|
@@ -109,7 +111,11 @@ exports.default = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
|
109
111
|
", uninstall the extension, then install a new instance of this extension.");
|
|
110
112
|
}
|
|
111
113
|
spinner.start();
|
|
112
|
-
const res = await extensionsApi.configureInstance({
|
|
114
|
+
const res = await extensionsApi.configureInstance({
|
|
115
|
+
projectId,
|
|
116
|
+
instanceId,
|
|
117
|
+
params: paramBindings,
|
|
118
|
+
});
|
|
113
119
|
spinner.stop();
|
|
114
120
|
utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `successfully configured ${clc.bold(instanceId)}.`);
|
|
115
121
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`You can view your reconfigured instance in the Firebase console: ${utils.consoleUrl(projectId, `/extensions/instances/${instanceId}?tab=config`)}`));
|
|
@@ -28,6 +28,7 @@ const track_1 = require("../track");
|
|
|
28
28
|
const logger_1 = require("../logger");
|
|
29
29
|
const previews_1 = require("../previews");
|
|
30
30
|
const manifest = require("../extensions/manifest");
|
|
31
|
+
const paramHelper_1 = require("../extensions/paramHelper");
|
|
31
32
|
marked.setOptions({
|
|
32
33
|
renderer: new TerminalRenderer(),
|
|
33
34
|
});
|
|
@@ -175,13 +176,14 @@ async function installToManifest(options) {
|
|
|
175
176
|
while (manifest.instanceExists(instanceId, config)) {
|
|
176
177
|
instanceId = await (0, extensionsHelper_1.promptForValidInstanceId)(`${spec.name}-${(0, utils_1.getRandomString)(4)}`);
|
|
177
178
|
}
|
|
178
|
-
const
|
|
179
|
+
const paramBindingOptions = await paramHelper.getParams({
|
|
179
180
|
projectId,
|
|
180
181
|
paramSpecs: spec.params,
|
|
181
182
|
nonInteractive,
|
|
182
183
|
paramsEnvPath,
|
|
183
184
|
instanceId,
|
|
184
185
|
});
|
|
186
|
+
const params = (0, paramHelper_1.getBaseParamBindings)(paramBindingOptions);
|
|
185
187
|
const ref = refs.parse(extVersion.ref);
|
|
186
188
|
await manifest.writeToManifest([
|
|
187
189
|
{
|
|
@@ -259,17 +261,19 @@ async function installExtension(options) {
|
|
|
259
261
|
else {
|
|
260
262
|
choice = "installNew";
|
|
261
263
|
}
|
|
262
|
-
let
|
|
264
|
+
let paramBindingOptions;
|
|
265
|
+
let paramBindings;
|
|
263
266
|
switch (choice) {
|
|
264
267
|
case "installNew":
|
|
265
268
|
instanceId = await (0, extensionsHelper_1.promptForValidInstanceId)(`${instanceId}-${(0, utils_1.getRandomString)(4)}`);
|
|
266
|
-
|
|
269
|
+
paramBindingOptions = await paramHelper.getParams({
|
|
267
270
|
projectId,
|
|
268
271
|
paramSpecs: spec.params,
|
|
269
272
|
nonInteractive,
|
|
270
273
|
paramsEnvPath,
|
|
271
274
|
instanceId,
|
|
272
275
|
});
|
|
276
|
+
paramBindings = (0, paramHelper_1.getBaseParamBindings)(paramBindingOptions);
|
|
273
277
|
spinner.text = "Installing your extension instance. This usually takes 3 to 5 minutes...";
|
|
274
278
|
spinner.start();
|
|
275
279
|
await extensionsApi.createInstance({
|
|
@@ -277,20 +281,21 @@ async function installExtension(options) {
|
|
|
277
281
|
instanceId,
|
|
278
282
|
extensionSource: source,
|
|
279
283
|
extensionVersionRef: extVersion === null || extVersion === void 0 ? void 0 : extVersion.ref,
|
|
280
|
-
params,
|
|
284
|
+
params: paramBindings,
|
|
281
285
|
});
|
|
282
286
|
spinner.stop();
|
|
283
287
|
utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `Successfully installed your instance of ${clc.bold(spec.displayName || spec.name)}! ` +
|
|
284
288
|
`Its Instance ID is ${clc.bold(instanceId)}.`);
|
|
285
289
|
break;
|
|
286
290
|
case "updateExisting":
|
|
287
|
-
|
|
291
|
+
paramBindingOptions = await paramHelper.getParams({
|
|
288
292
|
projectId,
|
|
289
293
|
paramSpecs: spec.params,
|
|
290
294
|
nonInteractive,
|
|
291
295
|
paramsEnvPath,
|
|
292
296
|
instanceId,
|
|
293
297
|
});
|
|
298
|
+
paramBindings = (0, paramHelper_1.getBaseParamBindings)(paramBindingOptions);
|
|
294
299
|
spinner.text = "Updating your extension instance. This usually takes 3 to 5 minutes...";
|
|
295
300
|
spinner.start();
|
|
296
301
|
await (0, updateHelper_1.update)({
|
|
@@ -298,7 +303,7 @@ async function installExtension(options) {
|
|
|
298
303
|
instanceId,
|
|
299
304
|
source,
|
|
300
305
|
extRef: extVersion === null || extVersion === void 0 ? void 0 : extVersion.ref,
|
|
301
|
-
params,
|
|
306
|
+
params: paramBindings,
|
|
302
307
|
});
|
|
303
308
|
spinner.stop();
|
|
304
309
|
utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `Successfully updated your instance of ${clc.bold(spec.displayName || spec.name)}! ` +
|
|
@@ -70,7 +70,7 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
70
70
|
instanceId,
|
|
71
71
|
projectDir: config.projectDir,
|
|
72
72
|
});
|
|
73
|
-
const
|
|
73
|
+
const newParamBindingOptions = await paramHelper.getParamsForUpdate({
|
|
74
74
|
spec: oldExtensionVersion.spec,
|
|
75
75
|
newSpec: newExtensionVersion.spec,
|
|
76
76
|
currentParams: oldParamValues,
|
|
@@ -79,11 +79,12 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
79
79
|
nonInteractive: options.nonInteractive,
|
|
80
80
|
instanceId,
|
|
81
81
|
});
|
|
82
|
+
const newParamBindings = paramHelper.getBaseParamBindings(newParamBindingOptions);
|
|
82
83
|
await manifest.writeToManifest([
|
|
83
84
|
{
|
|
84
85
|
instanceId,
|
|
85
86
|
ref: refs.parse(newExtensionVersion.ref),
|
|
86
|
-
params:
|
|
87
|
+
params: newParamBindings,
|
|
87
88
|
},
|
|
88
89
|
], config, {
|
|
89
90
|
nonInteractive: options.nonInteractive,
|
|
@@ -195,7 +196,7 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
const oldParamValues = Object.assign({}, existingParams);
|
|
198
|
-
const
|
|
199
|
+
const newParamBindings = await paramHelper.getParamsForUpdate({
|
|
199
200
|
spec: existingSpec,
|
|
200
201
|
newSpec,
|
|
201
202
|
currentParams: existingParams,
|
|
@@ -204,6 +205,7 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
204
205
|
nonInteractive: options.nonInteractive,
|
|
205
206
|
instanceId,
|
|
206
207
|
});
|
|
208
|
+
const newParams = paramHelper.getBaseParamBindings(newParamBindings);
|
|
207
209
|
spinner.start();
|
|
208
210
|
const updateOptions = {
|
|
209
211
|
projectId,
|
|
@@ -73,6 +73,7 @@ function mergeRequiredAPIs(backend) {
|
|
|
73
73
|
}
|
|
74
74
|
exports.mergeRequiredAPIs = mergeRequiredAPIs;
|
|
75
75
|
function addResourcesToBackend(projectId, runtime, annotation, want) {
|
|
76
|
+
var _a;
|
|
76
77
|
Object.freeze(annotation);
|
|
77
78
|
for (const region of annotation.regions || [api.functionsDefaultRegion]) {
|
|
78
79
|
let triggered;
|
|
@@ -88,12 +89,18 @@ function addResourcesToBackend(projectId, runtime, annotation, want) {
|
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
else if (annotation.httpsTrigger) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if ((_a = annotation.labels) === null || _a === void 0 ? void 0 : _a["deployment-callable"]) {
|
|
93
|
+
delete annotation.labels["deployment-callable"];
|
|
94
|
+
triggered = { callableTrigger: {} };
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const trigger = {};
|
|
98
|
+
if (annotation.failurePolicy) {
|
|
99
|
+
logger_1.logger.warn(`Ignoring retry policy for HTTPS function ${annotation.name}`);
|
|
100
|
+
}
|
|
101
|
+
proto.copyIfPresent(trigger, annotation.httpsTrigger, "invoker");
|
|
102
|
+
triggered = { httpsTrigger: trigger };
|
|
94
103
|
}
|
|
95
|
-
proto.copyIfPresent(trigger, annotation.httpsTrigger, "invoker");
|
|
96
|
-
triggered = { httpsTrigger: trigger };
|
|
97
104
|
}
|
|
98
105
|
else if (annotation.schedule) {
|
|
99
106
|
want.requiredAPIs.push({
|
|
@@ -35,7 +35,6 @@ const runtimes = require("../deploy/functions/runtimes");
|
|
|
35
35
|
const backend = require("../deploy/functions/backend");
|
|
36
36
|
const functionsEnv = require("../functions/env");
|
|
37
37
|
const EVENT_INVOKE = "functions:invoke";
|
|
38
|
-
const LOCAL_SECRETS_FILE = ".secret.local";
|
|
39
38
|
const DATABASE_PATH_PATTERN = new RegExp("^projects/[^/]+/instances/([^/]+)/refs(/.*)$");
|
|
40
39
|
class FunctionsEmulator {
|
|
41
40
|
constructor(args) {
|
|
@@ -654,13 +653,14 @@ class FunctionsEmulator {
|
|
|
654
653
|
}
|
|
655
654
|
async resolveSecretEnvs(backend, trigger) {
|
|
656
655
|
let secretEnvs = {};
|
|
656
|
+
const secretPath = (0, functionsEmulatorShared_1.getSecretLocalPath)(backend, this.args.projectDir);
|
|
657
657
|
try {
|
|
658
|
-
const data = fs.readFileSync(
|
|
658
|
+
const data = fs.readFileSync(secretPath, "utf8");
|
|
659
659
|
secretEnvs = functionsEnv.parseStrict(data);
|
|
660
660
|
}
|
|
661
661
|
catch (e) {
|
|
662
662
|
if (e.code !== "ENOENT") {
|
|
663
|
-
this.logger.logLabeled("ERROR", "functions", `Failed to read local secrets file ${
|
|
663
|
+
this.logger.logLabeled("ERROR", "functions", `Failed to read local secrets file ${secretPath}: ${e.message}`);
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
666
|
if (trigger) {
|
|
@@ -687,7 +687,7 @@ class FunctionsEmulator {
|
|
|
687
687
|
if (errs.length > 0) {
|
|
688
688
|
this.logger.logLabeled("ERROR", "functions", "Unable to access secret environment variables from Google Cloud Secret Manager. " +
|
|
689
689
|
"Make sure the credential used for the Functions Emulator have access " +
|
|
690
|
-
`or provide override values in ${
|
|
690
|
+
`or provide override values in ${secretPath}:\n\t` +
|
|
691
691
|
errs.join("\n\t"));
|
|
692
692
|
}
|
|
693
693
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSignatureType = exports.formatHost = exports.findModuleRoot = exports.waitForBody = exports.getServiceFromEventType = exports.getFunctionService = exports.getTemporarySocketPath = exports.getEmulatedTriggersFromDefinitions = exports.emulatedFunctionsByRegion = exports.emulatedFunctionsFromEndpoints = exports.EmulatedTrigger = exports.HttpConstants = void 0;
|
|
3
|
+
exports.getSecretLocalPath = exports.getSignatureType = exports.formatHost = exports.findModuleRoot = exports.waitForBody = exports.getServiceFromEventType = exports.getFunctionService = exports.getTemporarySocketPath = exports.getEmulatedTriggersFromDefinitions = exports.emulatedFunctionsByRegion = exports.emulatedFunctionsFromEndpoints = exports.EmulatedTrigger = exports.HttpConstants = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const os = require("os");
|
|
6
6
|
const path = require("path");
|
|
@@ -9,6 +9,7 @@ const backend = require("../deploy/functions/backend");
|
|
|
9
9
|
const constants_1 = require("./constants");
|
|
10
10
|
const proto_1 = require("../gcp/proto");
|
|
11
11
|
const logger_1 = require("../logger");
|
|
12
|
+
const manifest_1 = require("../extensions/manifest");
|
|
12
13
|
const memoryLookup = {
|
|
13
14
|
"128MB": 128,
|
|
14
15
|
"256MB": 256,
|
|
@@ -226,3 +227,14 @@ function getSignatureType(def) {
|
|
|
226
227
|
return def.platform === "gcfv2" ? "cloudevent" : "event";
|
|
227
228
|
}
|
|
228
229
|
exports.getSignatureType = getSignatureType;
|
|
230
|
+
const LOCAL_SECRETS_FILE = ".secret.local";
|
|
231
|
+
function getSecretLocalPath(backend, projectDir) {
|
|
232
|
+
const secretsFile = backend.extensionInstanceId
|
|
233
|
+
? `${backend.extensionInstanceId}${LOCAL_SECRETS_FILE}`
|
|
234
|
+
: LOCAL_SECRETS_FILE;
|
|
235
|
+
const secretDirectory = backend.extensionInstanceId
|
|
236
|
+
? path.join(projectDir, manifest_1.ENV_DIRECTORY)
|
|
237
|
+
: backend.functionsDir;
|
|
238
|
+
return path.join(secretDirectory, secretsFile);
|
|
239
|
+
}
|
|
240
|
+
exports.getSecretLocalPath = getSecretLocalPath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getInquirerDefault = exports.promptCreateSecret = exports.askForParam = exports.ask = exports.checkResponse = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
6
|
const { marked } = require("marked");
|
|
@@ -55,7 +55,31 @@ function checkResponse(response, spec) {
|
|
|
55
55
|
return valid;
|
|
56
56
|
}
|
|
57
57
|
exports.checkResponse = checkResponse;
|
|
58
|
-
async function
|
|
58
|
+
async function ask(projectId, instanceId, paramSpecs, firebaseProjectParams, reconfiguring) {
|
|
59
|
+
if (_.isEmpty(paramSpecs)) {
|
|
60
|
+
logger_1.logger.debug("No params were specified for this extension.");
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
utils.logLabeledBullet(extensionsHelper_1.logPrefix, "answer the questions below to configure your extension:");
|
|
64
|
+
const substituted = (0, extensionsHelper_1.substituteParams)(paramSpecs, firebaseProjectParams);
|
|
65
|
+
const result = {};
|
|
66
|
+
const promises = _.map(substituted, (paramSpec) => {
|
|
67
|
+
return async () => {
|
|
68
|
+
result[paramSpec.param] = await askForParam({
|
|
69
|
+
projectId,
|
|
70
|
+
instanceId,
|
|
71
|
+
paramSpec,
|
|
72
|
+
reconfiguring,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
await promises.reduce((prev, cur) => prev.then(cur), Promise.resolve());
|
|
77
|
+
logger_1.logger.info();
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
exports.ask = ask;
|
|
81
|
+
async function askForParam(args) {
|
|
82
|
+
const paramSpec = args.paramSpec;
|
|
59
83
|
let valid = false;
|
|
60
84
|
let response = "";
|
|
61
85
|
const description = paramSpec.description || "";
|
|
@@ -99,9 +123,9 @@ async function askForParam(projectId, instanceId, paramSpec, reconfiguring) {
|
|
|
99
123
|
valid = checkResponse(response, paramSpec);
|
|
100
124
|
break;
|
|
101
125
|
case extensionsApi_1.ParamType.SECRET:
|
|
102
|
-
response = reconfiguring
|
|
103
|
-
? await promptReconfigureSecret(projectId, instanceId, paramSpec)
|
|
104
|
-
: await promptCreateSecret(projectId, instanceId, paramSpec);
|
|
126
|
+
response = args.reconfiguring
|
|
127
|
+
? await promptReconfigureSecret(args.projectId, args.instanceId, paramSpec)
|
|
128
|
+
: await promptCreateSecret(args.projectId, args.instanceId, paramSpec);
|
|
105
129
|
valid = true;
|
|
106
130
|
break;
|
|
107
131
|
default:
|
|
@@ -114,7 +138,7 @@ async function askForParam(projectId, instanceId, paramSpec, reconfiguring) {
|
|
|
114
138
|
valid = checkResponse(response, paramSpec);
|
|
115
139
|
}
|
|
116
140
|
}
|
|
117
|
-
return response;
|
|
141
|
+
return { baseValue: response };
|
|
118
142
|
}
|
|
119
143
|
exports.askForParam = askForParam;
|
|
120
144
|
async function promptReconfigureSecret(projectId, instanceId, paramSpec) {
|
|
@@ -210,21 +234,3 @@ function getInquirerDefault(options, def) {
|
|
|
210
234
|
return defaultOption ? defaultOption.label || defaultOption.value : "";
|
|
211
235
|
}
|
|
212
236
|
exports.getInquirerDefault = getInquirerDefault;
|
|
213
|
-
async function ask(projectId, instanceId, paramSpecs, firebaseProjectParams, reconfiguring) {
|
|
214
|
-
if (_.isEmpty(paramSpecs)) {
|
|
215
|
-
logger_1.logger.debug("No params were specified for this extension.");
|
|
216
|
-
return {};
|
|
217
|
-
}
|
|
218
|
-
utils.logLabeledBullet(extensionsHelper_1.logPrefix, "answer the questions below to configure your extension:");
|
|
219
|
-
const substituted = (0, extensionsHelper_1.substituteParams)(paramSpecs, firebaseProjectParams);
|
|
220
|
-
const result = {};
|
|
221
|
-
const promises = _.map(substituted, (paramSpec) => {
|
|
222
|
-
return async () => {
|
|
223
|
-
result[paramSpec.param] = await askForParam(projectId, instanceId, paramSpec, reconfiguring);
|
|
224
|
-
};
|
|
225
|
-
});
|
|
226
|
-
await promises.reduce((prev, cur) => prev.then(cur), Promise.resolve());
|
|
227
|
-
logger_1.logger.info();
|
|
228
|
-
return result;
|
|
229
|
-
}
|
|
230
|
-
exports.ask = ask;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.showPreviewWarning = exports.showDeprecationWarning = exports.readInstanceParam = exports.getInstanceRef = exports.instanceExists = exports.loadConfig = exports.removeFromManifest = exports.writeToManifest = void 0;
|
|
3
|
+
exports.showPreviewWarning = exports.showDeprecationWarning = exports.readInstanceParam = exports.getInstanceRef = exports.instanceExists = exports.loadConfig = exports.removeFromManifest = exports.writeToManifest = exports.ENV_DIRECTORY = void 0;
|
|
4
4
|
const clc = require("cli-color");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const refs = require("./refs");
|
|
@@ -11,7 +11,7 @@ const paramHelper_1 = require("./paramHelper");
|
|
|
11
11
|
const error_1 = require("../error");
|
|
12
12
|
const utils = require("../utils");
|
|
13
13
|
const extensionsHelper_1 = require("./extensionsHelper");
|
|
14
|
-
|
|
14
|
+
exports.ENV_DIRECTORY = "extensions";
|
|
15
15
|
async function writeToManifest(specs, config, options, allowOverwrite = false) {
|
|
16
16
|
if (config.has("extensions") &&
|
|
17
17
|
Object.keys(config.get("extensions")).length &&
|
|
@@ -125,7 +125,7 @@ function readInstanceParam(args) {
|
|
|
125
125
|
}
|
|
126
126
|
exports.readInstanceParam = readInstanceParam;
|
|
127
127
|
function readParamsFile(projectDir, fileName) {
|
|
128
|
-
const paramPath = path.join(projectDir, ENV_DIRECTORY, fileName);
|
|
128
|
+
const paramPath = path.join(projectDir, exports.ENV_DIRECTORY, fileName);
|
|
129
129
|
const params = (0, paramHelper_1.readEnvFile)(paramPath);
|
|
130
130
|
return params;
|
|
131
131
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readEnvFile = exports.promptForNewParams = exports.getParamsForUpdate = exports.getParams = exports.getParamsWithCurrentValuesAsDefaults = exports.setNewDefaults = void 0;
|
|
3
|
+
exports.readEnvFile = exports.promptForNewParams = exports.getParamsForUpdate = exports.getParams = exports.getParamsWithCurrentValuesAsDefaults = exports.setNewDefaults = exports.buildBindingOptionsWithBaseValue = exports.getBaseParamBindings = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const clc = require("cli-color");
|
|
@@ -11,6 +11,22 @@ const extensionsHelper_1 = require("./extensionsHelper");
|
|
|
11
11
|
const askUserForParam = require("./askUserForParam");
|
|
12
12
|
const track = require("../track");
|
|
13
13
|
const env = require("../functions/env");
|
|
14
|
+
function getBaseParamBindings(params) {
|
|
15
|
+
let ret = {};
|
|
16
|
+
for (const [k, v] of Object.entries(params)) {
|
|
17
|
+
ret = Object.assign(Object.assign({}, ret), { [k]: v.baseValue });
|
|
18
|
+
}
|
|
19
|
+
return ret;
|
|
20
|
+
}
|
|
21
|
+
exports.getBaseParamBindings = getBaseParamBindings;
|
|
22
|
+
function buildBindingOptionsWithBaseValue(baseParams) {
|
|
23
|
+
let paramOptions = {};
|
|
24
|
+
for (const [k, v] of Object.entries(baseParams)) {
|
|
25
|
+
paramOptions = Object.assign(Object.assign({}, paramOptions), { [k]: { baseValue: v } });
|
|
26
|
+
}
|
|
27
|
+
return paramOptions;
|
|
28
|
+
}
|
|
29
|
+
exports.buildBindingOptionsWithBaseValue = buildBindingOptionsWithBaseValue;
|
|
14
30
|
function setNewDefaults(params, newDefaults) {
|
|
15
31
|
params.forEach((param) => {
|
|
16
32
|
if (newDefaults[param.param.toUpperCase()]) {
|
|
@@ -107,11 +123,16 @@ async function promptForNewParams(args) {
|
|
|
107
123
|
if (paramsDiffAdditions.length) {
|
|
108
124
|
logger_1.logger.info("To update this instance, configure the following new parameters:");
|
|
109
125
|
for (const param of paramsDiffAdditions) {
|
|
110
|
-
const chosenValue = await askUserForParam.askForParam(
|
|
111
|
-
|
|
126
|
+
const chosenValue = await askUserForParam.askForParam({
|
|
127
|
+
projectId: args.projectId,
|
|
128
|
+
instanceId: args.instanceId,
|
|
129
|
+
paramSpec: param,
|
|
130
|
+
reconfiguring: false,
|
|
131
|
+
});
|
|
132
|
+
args.currentParams[param.param] = chosenValue.baseValue;
|
|
112
133
|
}
|
|
113
134
|
}
|
|
114
|
-
return args.currentParams;
|
|
135
|
+
return buildBindingOptionsWithBaseValue(args.currentParams);
|
|
115
136
|
}
|
|
116
137
|
exports.promptForNewParams = promptForNewParams;
|
|
117
138
|
function getParamsFromFile(args) {
|
|
@@ -127,7 +148,7 @@ function getParamsFromFile(args) {
|
|
|
127
148
|
const params = (0, extensionsHelper_1.populateDefaultParams)(envParams, args.paramSpecs);
|
|
128
149
|
(0, extensionsHelper_1.validateCommandLineParams)(params, args.paramSpecs);
|
|
129
150
|
logger_1.logger.info(`Using param values from ${args.paramsEnvPath}`);
|
|
130
|
-
return params;
|
|
151
|
+
return buildBindingOptionsWithBaseValue(params);
|
|
131
152
|
}
|
|
132
153
|
function readEnvFile(envPath) {
|
|
133
154
|
const buf = fs.readFileSync(path.resolve(envPath), "utf8");
|
|
@@ -202,7 +202,7 @@ async function listAllFunctions(projectId) {
|
|
|
202
202
|
}
|
|
203
203
|
exports.listAllFunctions = listAllFunctions;
|
|
204
204
|
function endpointFromFunction(gcfFunction) {
|
|
205
|
-
var _a, _b, _c, _d;
|
|
205
|
+
var _a, _b, _c, _d, _e;
|
|
206
206
|
const [, project, , region, , id] = gcfFunction.name.split("/");
|
|
207
207
|
let trigger;
|
|
208
208
|
let uri;
|
|
@@ -217,7 +217,8 @@ function endpointFromFunction(gcfFunction) {
|
|
|
217
217
|
taskQueueTrigger: {},
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
|
-
else if ((_c = gcfFunction.labels) === null || _c === void 0 ? void 0 : _c["deployment-callable"])
|
|
220
|
+
else if (((_c = gcfFunction.labels) === null || _c === void 0 ? void 0 : _c["deployment-callable"]) ||
|
|
221
|
+
((_d = gcfFunction.labels) === null || _d === void 0 ? void 0 : _d["deployment-callabled"])) {
|
|
221
222
|
trigger = {
|
|
222
223
|
callableTrigger: {},
|
|
223
224
|
};
|
|
@@ -237,7 +238,7 @@ function endpointFromFunction(gcfFunction) {
|
|
|
237
238
|
value: gcfFunction.eventTrigger.resource,
|
|
238
239
|
},
|
|
239
240
|
],
|
|
240
|
-
retry: !!((
|
|
241
|
+
retry: !!((_e = gcfFunction.eventTrigger.failurePolicy) === null || _e === void 0 ? void 0 : _e.retry),
|
|
241
242
|
},
|
|
242
243
|
};
|
|
243
244
|
}
|
|
@@ -304,7 +305,7 @@ function functionFromEndpoint(endpoint, sourceUploadUrl) {
|
|
|
304
305
|
else {
|
|
305
306
|
gcfFunction.httpsTrigger = {};
|
|
306
307
|
if (backend.isCallableTriggered(endpoint)) {
|
|
307
|
-
gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { "deployment-
|
|
308
|
+
gcfFunction.labels = Object.assign(Object.assign({}, gcfFunction.labels), { "deployment-callable": "true" });
|
|
308
309
|
}
|
|
309
310
|
if (endpoint.securityLevel) {
|
|
310
311
|
gcfFunction.httpsTrigger.securityLevel = endpoint.securityLevel;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.1",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "firebase-tools",
|
|
9
|
-
"version": "10.3.
|
|
9
|
+
"version": "10.3.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@google-cloud/pubsub": "^2.18.4",
|