firebase-tools 11.6.0 → 11.7.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/commands/crashlytics-mappingfile-generateid.js +26 -0
- package/lib/commands/crashlytics-mappingfile-upload.js +46 -0
- package/lib/commands/crashlytics-symbols-upload.js +18 -87
- package/lib/commands/functions-delete.js +2 -0
- package/lib/commands/functions-secrets-get.js +2 -0
- package/lib/commands/index.js +3 -0
- package/lib/crashlytics/buildToolsJarHelper.js +51 -0
- package/lib/deploy/functions/backend.js +4 -4
- package/lib/deploy/functions/build.js +75 -8
- package/lib/deploy/functions/checkIam.js +6 -5
- package/lib/deploy/functions/params.js +15 -15
- package/lib/deploy/functions/release/fabricator.js +22 -5
- package/lib/deploy/functions/release/index.js +2 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +1 -16
- package/lib/deploy/functions/runtimes/discovery/parsing.js +16 -0
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +59 -131
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +1 -1
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/controller.js +6 -11
- package/lib/emulator/functionsEmulatorRuntime.js +12 -23
- package/lib/emulator/storage/apis/firebase.js +13 -11
- package/lib/emulator/storage/multipart.js +2 -2
- package/lib/functions/env.js +9 -9
- package/lib/gcp/cloudscheduler.js +32 -15
- package/lib/track.js +3 -0
- package/npm-shrinkwrap.json +511 -2
- package/package.json +2 -1
package/lib/functions/env.js
CHANGED
|
@@ -161,9 +161,11 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
163
|
const { functionsSource, projectId, projectAlias, isEmulator } = envOpts;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
const envFiles = findEnvfiles(functionsSource, projectId, projectAlias, isEmulator);
|
|
165
|
+
const projectScopedFileName = `.env.${projectId}`;
|
|
166
|
+
const projectScopedFileExists = envFiles.includes(projectScopedFileName);
|
|
167
|
+
if (!projectScopedFileExists) {
|
|
168
|
+
createEnvFile(envOpts);
|
|
167
169
|
}
|
|
168
170
|
const currentEnvs = loadUserEnvs(envOpts);
|
|
169
171
|
for (const k of Object.keys(toWrite)) {
|
|
@@ -172,17 +174,15 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
172
174
|
throw new error_1.FirebaseError(`Attempted to write param-defined key ${k} to .env files, but it was already defined.`);
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
178
|
+
`Writing new parameter values to disk: ${projectScopedFileName}`);
|
|
177
179
|
for (const k of Object.keys(toWrite)) {
|
|
178
|
-
fs.appendFileSync(
|
|
180
|
+
fs.appendFileSync(path.join(functionsSource, projectScopedFileName), formatUserEnvForWrite(k, toWrite[k]));
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
exports.writeUserEnvs = writeUserEnvs;
|
|
182
184
|
function createEnvFile(envOpts) {
|
|
183
|
-
const fileToWrite = envOpts.isEmulator
|
|
184
|
-
? FUNCTIONS_EMULATOR_DOTENV
|
|
185
|
-
: `.env.${envOpts.projectAlias || envOpts.projectId}`;
|
|
185
|
+
const fileToWrite = envOpts.isEmulator ? FUNCTIONS_EMULATOR_DOTENV : `.env.${envOpts.projectId}`;
|
|
186
186
|
logger_1.logger.debug(`Creating ${fileToWrite}...`);
|
|
187
187
|
fs.writeFileSync(path.join(envOpts.functionsSource, fileToWrite), "", { flag: "wx" });
|
|
188
188
|
return fileToWrite;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jobFromEndpoint = exports.topicNameForEndpoint = exports.jobNameForEndpoint = exports.createOrReplaceJob = exports.
|
|
3
|
+
exports.jobFromEndpoint = exports.topicNameForEndpoint = exports.jobNameForEndpoint = exports.createOrReplaceJob = exports.deleteJob = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
@@ -8,15 +8,18 @@ const api_1 = require("../api");
|
|
|
8
8
|
const apiv2_1 = require("../apiv2");
|
|
9
9
|
const backend = require("../deploy/functions/backend");
|
|
10
10
|
const proto = require("./proto");
|
|
11
|
+
const checkIam_1 = require("../deploy/functions/checkIam");
|
|
11
12
|
const functional_1 = require("../functional");
|
|
12
13
|
const VERSION = "v1";
|
|
13
|
-
const
|
|
14
|
+
const DEFAULT_TIME_ZONE_V1 = "America/Los_Angeles";
|
|
15
|
+
const DEFAULT_TIME_ZONE_V2 = "UTC";
|
|
14
16
|
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.cloudschedulerOrigin, apiVersion: VERSION });
|
|
15
17
|
function createJob(job) {
|
|
16
18
|
const strippedName = job.name.substring(0, job.name.lastIndexOf("/"));
|
|
17
|
-
|
|
19
|
+
const json = job.pubsubTarget
|
|
20
|
+
? Object.assign({ timeZone: DEFAULT_TIME_ZONE_V1 }, job) : Object.assign({ timeZone: DEFAULT_TIME_ZONE_V2 }, job);
|
|
21
|
+
return apiClient.post(`/${strippedName}`, json);
|
|
18
22
|
}
|
|
19
|
-
exports.createJob = createJob;
|
|
20
23
|
function deleteJob(name) {
|
|
21
24
|
return apiClient.delete(`/${name}`);
|
|
22
25
|
}
|
|
@@ -26,16 +29,23 @@ function getJob(name) {
|
|
|
26
29
|
resolveOnHTTPError: true,
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
|
-
exports.getJob = getJob;
|
|
30
32
|
function updateJob(job) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
let fieldMasks;
|
|
34
|
+
let json;
|
|
35
|
+
if (job.pubsubTarget) {
|
|
36
|
+
fieldMasks = proto.fieldMasks(job, "pubsubTarget");
|
|
37
|
+
json = Object.assign({ timeZone: DEFAULT_TIME_ZONE_V1 }, job);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
fieldMasks = proto.fieldMasks(job, "httpTarget");
|
|
41
|
+
json = Object.assign({ timeZone: DEFAULT_TIME_ZONE_V2 }, job);
|
|
42
|
+
}
|
|
43
|
+
return apiClient.patch(`/${job.name}`, json, {
|
|
33
44
|
queryParams: {
|
|
34
45
|
updateMask: fieldMasks.join(","),
|
|
35
46
|
},
|
|
36
47
|
});
|
|
37
48
|
}
|
|
38
|
-
exports.updateJob = updateJob;
|
|
39
49
|
async function createOrReplaceJob(job) {
|
|
40
50
|
var _a, _b;
|
|
41
51
|
const jobName = job.name.split("/").pop();
|
|
@@ -56,7 +66,7 @@ async function createOrReplaceJob(job) {
|
|
|
56
66
|
return newJob;
|
|
57
67
|
}
|
|
58
68
|
if (!job.timeZone) {
|
|
59
|
-
job.timeZone =
|
|
69
|
+
job.timeZone = job.pubsubTarget ? DEFAULT_TIME_ZONE_V1 : DEFAULT_TIME_ZONE_V2;
|
|
60
70
|
}
|
|
61
71
|
if (!needUpdate(existingJob.body, job)) {
|
|
62
72
|
logger_1.logger.debug(`scheduler job ${jobName} is up to date, no changes required`);
|
|
@@ -90,9 +100,9 @@ function needUpdate(existingJob, newJob) {
|
|
|
90
100
|
}
|
|
91
101
|
return false;
|
|
92
102
|
}
|
|
93
|
-
function jobNameForEndpoint(endpoint,
|
|
103
|
+
function jobNameForEndpoint(endpoint, location) {
|
|
94
104
|
const id = backend.scheduleIdForFunction(endpoint);
|
|
95
|
-
return `projects/${endpoint.project}/locations/${
|
|
105
|
+
return `projects/${endpoint.project}/locations/${location}/jobs/${id}`;
|
|
96
106
|
}
|
|
97
107
|
exports.jobNameForEndpoint = jobNameForEndpoint;
|
|
98
108
|
function topicNameForEndpoint(endpoint) {
|
|
@@ -100,10 +110,11 @@ function topicNameForEndpoint(endpoint) {
|
|
|
100
110
|
return `projects/${endpoint.project}/topics/${id}`;
|
|
101
111
|
}
|
|
102
112
|
exports.topicNameForEndpoint = topicNameForEndpoint;
|
|
103
|
-
function jobFromEndpoint(endpoint,
|
|
113
|
+
function jobFromEndpoint(endpoint, location, projectNumber) {
|
|
104
114
|
const job = {};
|
|
115
|
+
job.name = jobNameForEndpoint(endpoint, location);
|
|
105
116
|
if (endpoint.platform === "gcfv1") {
|
|
106
|
-
job.
|
|
117
|
+
job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE_V1;
|
|
107
118
|
job.pubsubTarget = {
|
|
108
119
|
topicName: topicNameForEndpoint(endpoint),
|
|
109
120
|
attributes: {
|
|
@@ -112,7 +123,14 @@ function jobFromEndpoint(endpoint, appEngineLocation) {
|
|
|
112
123
|
};
|
|
113
124
|
}
|
|
114
125
|
else if (endpoint.platform === "gcfv2") {
|
|
115
|
-
|
|
126
|
+
job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE_V2;
|
|
127
|
+
job.httpTarget = {
|
|
128
|
+
uri: endpoint.uri,
|
|
129
|
+
httpMethod: "POST",
|
|
130
|
+
oidcToken: {
|
|
131
|
+
serviceAccountEmail: (0, checkIam_1.getDefaultComputeServiceAgent)(projectNumber),
|
|
132
|
+
},
|
|
133
|
+
};
|
|
116
134
|
}
|
|
117
135
|
else {
|
|
118
136
|
(0, functional_1.assertExhaustive)(endpoint.platform);
|
|
@@ -121,7 +139,6 @@ function jobFromEndpoint(endpoint, appEngineLocation) {
|
|
|
121
139
|
throw new error_1.FirebaseError("Cannot create a scheduler job without a schedule:" + JSON.stringify(endpoint));
|
|
122
140
|
}
|
|
123
141
|
job.schedule = endpoint.scheduleTrigger.schedule;
|
|
124
|
-
job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE;
|
|
125
142
|
if (endpoint.scheduleTrigger.retryConfig) {
|
|
126
143
|
job.retryConfig = {};
|
|
127
144
|
proto.copyIfPresent(job.retryConfig, endpoint.scheduleTrigger.retryConfig, "maxDoublings", "retryCount");
|