firebase-tools 11.4.2 → 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/accountImporter.js +1 -1
- package/lib/auth.js +3 -4
- package/lib/bin/firebase.js +4 -4
- package/lib/command.js +35 -10
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-create.js +1 -1
- package/lib/commands/apps-list.js +1 -1
- package/lib/commands/auth-export.js +1 -1
- package/lib/commands/auth-import.js +1 -1
- 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/database-instances-list.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +1 -1
- package/lib/commands/database-set.js +1 -1
- package/lib/commands/database-update.js +1 -1
- package/lib/commands/emulators-exec.js +4 -1
- package/lib/commands/emulators-export.js +5 -2
- package/lib/commands/emulators-start.js +24 -18
- package/lib/commands/ext-dev-deprecate.js +1 -1
- package/lib/commands/ext-dev-emulators-exec.js +1 -1
- package/lib/commands/ext-dev-emulators-start.js +1 -1
- package/lib/commands/ext-dev-extension-delete.js +1 -1
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +4 -1
- package/lib/commands/ext-dev-register.js +1 -1
- package/lib/commands/ext-dev-undeprecate.js +1 -1
- package/lib/commands/ext-dev-unpublish.js +1 -1
- package/lib/commands/ext-dev-usage.js +1 -1
- package/lib/commands/ext-info.js +1 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/ext-update.js +1 -1
- package/lib/commands/ext.js +1 -1
- package/lib/commands/firestore-delete.js +2 -2
- package/lib/commands/firestore-indexes-list.js +3 -3
- package/lib/commands/functions-config-clone.js +1 -1
- package/lib/commands/functions-config-export.js +1 -1
- package/lib/commands/functions-config-set.js +1 -1
- package/lib/commands/functions-config-unset.js +1 -1
- package/lib/commands/functions-delete.js +3 -1
- package/lib/commands/functions-secrets-get.js +2 -0
- package/lib/commands/functions-secrets-set.js +1 -1
- package/lib/commands/help.js +1 -1
- package/lib/commands/hosting-channel-create.js +5 -5
- package/lib/commands/hosting-channel-delete.js +3 -3
- package/lib/commands/hosting-channel-deploy.js +6 -6
- package/lib/commands/hosting-channel-list.js +2 -2
- package/lib/commands/hosting-channel-open.js +2 -2
- package/lib/commands/hosting-clone.js +8 -8
- package/lib/commands/hosting-disable.js +1 -1
- package/lib/commands/hosting-sites-create.js +4 -4
- package/lib/commands/hosting-sites-delete.js +4 -4
- package/lib/commands/hosting-sites-list.js +2 -2
- package/lib/commands/index.js +3 -0
- package/lib/commands/init.js +5 -5
- package/lib/commands/login-add.js +1 -1
- package/lib/commands/login-ci.js +2 -2
- package/lib/commands/login-list.js +1 -1
- package/lib/commands/login-use.js +1 -1
- package/lib/commands/login.js +3 -3
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +3 -3
- package/lib/commands/projects-list.js +2 -2
- package/lib/commands/serve.js +1 -1
- package/lib/commands/target-apply.js +1 -1
- package/lib/commands/target-clear.js +1 -1
- package/lib/commands/target-remove.js +1 -1
- package/lib/commands/target.js +1 -1
- package/lib/commands/use.js +7 -7
- package/lib/config.js +1 -1
- package/lib/crashlytics/buildToolsJarHelper.js +51 -0
- package/lib/deploy/database/prepare.js +3 -3
- package/lib/deploy/database/release.js +3 -3
- package/lib/deploy/extensions/deploymentSummary.js +1 -1
- package/lib/deploy/extensions/errors.js +1 -1
- package/lib/deploy/extensions/secrets.js +1 -1
- package/lib/deploy/extensions/tasks.js +2 -2
- package/lib/deploy/firestore/deploy.js +2 -2
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/backend.js +4 -4
- package/lib/deploy/functions/build.js +78 -8
- package/lib/deploy/functions/checkIam.js +9 -8
- package/lib/deploy/functions/containerCleaner.js +2 -2
- package/lib/deploy/functions/deploy.js +2 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/params.js +15 -15
- package/lib/deploy/functions/prepare.js +1 -1
- package/lib/deploy/functions/prepareFunctionsUpload.js +2 -2
- package/lib/deploy/functions/prompts.js +1 -1
- package/lib/deploy/functions/release/fabricator.js +24 -7
- package/lib/deploy/functions/release/index.js +3 -1
- package/lib/deploy/functions/release/reporter.js +1 -1
- 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/parseRuntimeAndValidateSDK.js +1 -1
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +2 -6
- package/lib/deploy/functions/runtimes/node/versioning.js +4 -4
- package/lib/deploy/functions/validate.js +1 -1
- package/lib/deploy/hosting/deploy.js +10 -9
- package/lib/deploy/hosting/uploader.js +2 -2
- package/lib/deploy/hosting/validate.js +2 -2
- package/lib/deploy/index.js +7 -7
- package/lib/deploy/lifecycleHooks.js +5 -2
- package/lib/deploy/storage/prepare.js +5 -3
- package/lib/deploy/storage/release.js +7 -6
- package/lib/emulator/auth/index.js +7 -2
- package/lib/emulator/auth/operations.js +10 -10
- package/lib/emulator/commandUtils.js +33 -16
- package/lib/emulator/constants.js +14 -6
- package/lib/emulator/controller.js +50 -18
- package/lib/emulator/databaseEmulator.js +1 -1
- package/lib/emulator/downloadableEmulators.js +8 -8
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/eventarcEmulator.js +148 -0
- package/lib/emulator/extensionsEmulator.js +5 -3
- package/lib/emulator/firestoreEmulator.js +1 -1
- package/lib/emulator/functionsEmulator.js +66 -14
- package/lib/emulator/functionsEmulatorRuntime.js +12 -23
- package/lib/emulator/functionsEmulatorShared.js +6 -1
- package/lib/emulator/hub.js +7 -3
- package/lib/emulator/hubClient.js +2 -2
- package/lib/emulator/hubExport.js +22 -2
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/registry.js +1 -0
- package/lib/emulator/storage/apis/firebase.js +26 -12
- package/lib/emulator/storage/apis/gcloud.js +15 -8
- package/lib/emulator/storage/files.js +21 -4
- package/lib/emulator/storage/multipart.js +6 -5
- package/lib/emulator/storage/rules/runtime.js +3 -3
- package/lib/emulator/storage/rules/utils.js +4 -2
- package/lib/emulator/storage/server.js +2 -1
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/emulator/types.js +4 -0
- package/lib/emulator/ui.js +7 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/extensions/askUserForConsent.js +1 -1
- package/lib/extensions/askUserForEventsConfig.js +1 -1
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/changelog.js +2 -2
- package/lib/extensions/checkProjectBilling.js +2 -2
- package/lib/extensions/displayExtensionInfo.js +1 -1
- package/lib/extensions/extensionsApi.js +3 -2
- package/lib/extensions/extensionsHelper.js +30 -2
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/manifest.js +1 -1
- package/lib/extensions/metricsUtils.js +1 -1
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/updateHelper.js +2 -2
- package/lib/extensions/warnings.js +2 -2
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/delete.js +1 -1
- package/lib/firestore/indexes.js +2 -2
- package/lib/firestore/validator.js +1 -1
- package/lib/functions/env.js +11 -11
- package/lib/functions/runtimeConfigExport.js +1 -1
- package/lib/functionsConfig.js +1 -1
- package/lib/functionsConfigClone.js +1 -1
- package/lib/functionsShellCommandAction.js +1 -1
- package/lib/gcp/cloudfunctions.js +3 -3
- package/lib/gcp/cloudfunctionsv2.js +5 -5
- package/lib/gcp/cloudscheduler.js +63 -22
- package/lib/gcp/cloudtasks.js +17 -1
- package/lib/gcp/serviceusage.js +2 -2
- package/lib/handlePreviewToggles.js +4 -4
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/index.js +2 -2
- package/lib/init/features/database.js +1 -1
- package/lib/init/features/emulators.js +1 -1
- package/lib/init/features/firestore/index.js +2 -2
- package/lib/init/features/firestore/indexes.js +1 -1
- package/lib/init/features/firestore/rules.js +1 -1
- package/lib/init/features/functions/golang.js +1 -1
- package/lib/init/features/functions/index.js +8 -1
- package/lib/init/features/hosting/github.js +9 -9
- package/lib/init/features/hosting/index.js +1 -1
- package/lib/init/features/project.js +1 -1
- package/lib/init/features/remoteconfig.js +1 -1
- package/lib/init/features/storage.js +1 -1
- package/lib/init/index.js +1 -1
- package/lib/logError.js +3 -3
- package/lib/management/projects.js +1 -1
- package/lib/parseBoltRules.js +1 -1
- package/lib/profileReport.js +2 -2
- package/lib/projectUtils.js +1 -1
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +1 -1
- package/lib/requireDatabaseInstance.js +2 -2
- package/lib/requirePermissions.js +2 -2
- package/lib/rulesDeploy.js +11 -12
- package/lib/serve/hosting.js +2 -1
- package/lib/serve/index.js +15 -0
- package/lib/track.js +122 -3
- package/lib/utils.js +24 -11
- package/npm-shrinkwrap.json +523 -294
- package/package.json +6 -4
- package/schema/firebase-config.json +12 -0
- package/templates/extensions/CHANGELOG.md +1 -7
- package/templates/hosting/init.js +6 -2
package/lib/firestore/indexes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FirestoreIndexes = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const utils = require("../utils");
|
|
7
7
|
const validator = require("./validator");
|
|
@@ -345,7 +345,7 @@ class FirestoreIndexes {
|
|
|
345
345
|
return result;
|
|
346
346
|
}
|
|
347
347
|
if (spec.indexes[0].collectionId) {
|
|
348
|
-
utils.logBullet(clc.bold.cyan("firestore:") +
|
|
348
|
+
utils.logBullet(clc.bold(clc.cyan("firestore:")) +
|
|
349
349
|
" your indexes indexes are specified in the v1beta1 API format. " +
|
|
350
350
|
"Please upgrade to the new index API format by running " +
|
|
351
351
|
clc.bold("firebase firestore:indexes") +
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertEnum = exports.assertHasOneOf = exports.assertHas = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
6
|
function assertHas(obj, prop) {
|
|
7
7
|
const objString = clc.cyan(JSON.stringify(obj));
|
package/lib/functions/env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadFirebaseEnvs = exports.loadUserEnvs = exports.writeUserEnvs = exports.hasUserEnvs = exports.parseStrict = exports.validateKey = exports.KeyValidationError = exports.parse = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const error_1 = require("../error");
|
|
@@ -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;
|
|
@@ -219,7 +219,7 @@ function loadUserEnvs({ functionsSource, projectId, projectAlias, isEmulator, })
|
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
(0, utils_1.logBullet)(clc.cyan.bold("functions: ") + `Loaded environment variables from ${envFiles.join(", ")}.`);
|
|
222
|
+
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) + `Loaded environment variables from ${envFiles.join(", ")}.`);
|
|
223
223
|
return envs;
|
|
224
224
|
}
|
|
225
225
|
exports.loadUserEnvs = loadUserEnvs;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateDotenvFilename = exports.toDotenvFormat = exports.hydrateEnvs = exports.configToEnv = exports.convertKey = exports.hydrateConfigs = exports.getProjectInfos = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const env = require("./env");
|
|
6
6
|
const functionsConfig = require("../functionsConfig");
|
|
7
7
|
const error_1 = require("../error");
|
package/lib/functionsConfig.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseUnsetArgs = exports.parseSetArgs = exports.materializeAll = exports.materializeConfig = exports.setVariablesRecursive = exports.getFirebaseConfig = exports.getAppEngineLocation = exports.idsToVarName = exports.varNameToIds = exports.ensureApi = exports.RESERVED_NAMESPACES = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const api_1 = require("./api");
|
|
7
7
|
const apiv2_1 = require("./apiv2");
|
|
8
8
|
const ensureApiEnabled_1 = require("./ensureApiEnabled");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.functionsConfigClone = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const error_1 = require("./error");
|
|
7
7
|
const functionsConfig = require("./functionsConfig");
|
|
8
8
|
const runtimeconfig = require("./gcp/runtimeconfig");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.actionFunction = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const repl = require("repl");
|
|
6
6
|
const _ = require("lodash");
|
|
7
7
|
const request = require("request");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.functionFromEndpoint = exports.endpointFromFunction = exports.listAllFunctions = exports.listFunctions = exports.deleteFunction = exports.updateFunction = exports.setInvokerUpdate = exports.setInvokerCreate = exports.getIamPolicy = exports.setIamPolicy = exports.createFunction = exports.generateUploadUrl = exports.BLOCKING_LABEL = exports.CODEBASE_LABEL = exports.API_VERSION = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
7
|
const backend = require("../deploy/functions/backend");
|
|
@@ -26,10 +26,10 @@ const BLOCKING_EVENT_TO_LABEL_KEY = {
|
|
|
26
26
|
function functionsOpLogReject(funcName, type, err) {
|
|
27
27
|
var _a, _b;
|
|
28
28
|
if (((_b = (_a = err === null || err === void 0 ? void 0 : err.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) === 429) {
|
|
29
|
-
utils.logWarning(`${clc.bold.yellow("functions:")} got "Quota Exceeded" error while trying to ${type} ${funcName}. Waiting to retry...`);
|
|
29
|
+
utils.logWarning(`${clc.bold(clc.yellow("functions:"))} got "Quota Exceeded" error while trying to ${type} ${funcName}. Waiting to retry...`);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
utils.logWarning(clc.bold.yellow("functions:") + " failed to " + type + " function " + funcName);
|
|
32
|
+
utils.logWarning(clc.bold(clc.yellow("functions:")) + " failed to " + type + " function " + funcName);
|
|
33
33
|
}
|
|
34
34
|
throw new error_1.FirebaseError(`Failed to ${type} function ${funcName}`, {
|
|
35
35
|
original: err,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.listFunctions = exports.getFunction = exports.createFunction = exports.generateUploadUrl = exports.mebibytes = exports.BLOCKING_LABEL = exports.CODEBASE_LABEL = exports.API_VERSION = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const api_1 = require("../api");
|
|
@@ -59,15 +59,15 @@ function mebibytes(memory) {
|
|
|
59
59
|
exports.mebibytes = mebibytes;
|
|
60
60
|
function functionsOpLogReject(funcName, type, err) {
|
|
61
61
|
var _a, _b;
|
|
62
|
-
utils.logWarning(clc.bold.yellow("functions:") + ` ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
62
|
+
utils.logWarning(clc.bold(clc.yellow("functions:")) + ` ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
63
63
|
if (((_b = (_a = err === null || err === void 0 ? void 0 : err.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) === 429) {
|
|
64
|
-
utils.logWarning(`${clc.bold.yellow("functions:")} got "Quota Exceeded" error while trying to ${type} ${funcName}. Waiting to retry...`);
|
|
64
|
+
utils.logWarning(`${clc.bold(clc.yellow("functions:"))} got "Quota Exceeded" error while trying to ${type} ${funcName}. Waiting to retry...`);
|
|
65
65
|
}
|
|
66
66
|
else if (err === null || err === void 0 ? void 0 : err.message.includes("If you recently started to use Eventarc, it may take a few minutes before all necessary permissions are propagated to the Service Agent")) {
|
|
67
|
-
utils.logWarning(`${clc.bold.yellow("functions:")} since this is your first time using functions v2, we need a little bit longer to finish setting everything up, please retry the deployment in a few minutes.`);
|
|
67
|
+
utils.logWarning(`${clc.bold(clc.yellow("functions:"))} since this is your first time using functions v2, we need a little bit longer to finish setting everything up, please retry the deployment in a few minutes.`);
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
|
-
utils.logWarning(clc.bold.yellow("functions:") + " failed to " + type + " function " + funcName);
|
|
70
|
+
utils.logWarning(clc.bold(clc.yellow("functions:")) + " failed to " + type + " function " + funcName);
|
|
71
71
|
}
|
|
72
72
|
throw new error_1.FirebaseError(`Failed to ${type} function ${funcName}`, {
|
|
73
73
|
original: err,
|
|
@@ -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
|
-
const VERSION = "
|
|
13
|
-
const
|
|
13
|
+
const VERSION = "v1";
|
|
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,11 +29,23 @@ function getJob(name) {
|
|
|
26
29
|
resolveOnHTTPError: true,
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
|
-
exports.getJob = getJob;
|
|
30
32
|
function updateJob(job) {
|
|
31
|
-
|
|
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, {
|
|
44
|
+
queryParams: {
|
|
45
|
+
updateMask: fieldMasks.join(","),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
32
48
|
}
|
|
33
|
-
exports.updateJob = updateJob;
|
|
34
49
|
async function createOrReplaceJob(job) {
|
|
35
50
|
var _a, _b;
|
|
36
51
|
const jobName = job.name.split("/").pop();
|
|
@@ -51,9 +66,9 @@ async function createOrReplaceJob(job) {
|
|
|
51
66
|
return newJob;
|
|
52
67
|
}
|
|
53
68
|
if (!job.timeZone) {
|
|
54
|
-
job.timeZone =
|
|
69
|
+
job.timeZone = job.pubsubTarget ? DEFAULT_TIME_ZONE_V1 : DEFAULT_TIME_ZONE_V2;
|
|
55
70
|
}
|
|
56
|
-
if (
|
|
71
|
+
if (!needUpdate(existingJob.body, job)) {
|
|
57
72
|
logger_1.logger.debug(`scheduler job ${jobName} is up to date, no changes required`);
|
|
58
73
|
return;
|
|
59
74
|
}
|
|
@@ -62,16 +77,32 @@ async function createOrReplaceJob(job) {
|
|
|
62
77
|
return updatedJob;
|
|
63
78
|
}
|
|
64
79
|
exports.createOrReplaceJob = createOrReplaceJob;
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
function needUpdate(existingJob, newJob) {
|
|
81
|
+
if (!existingJob) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
if (!newJob) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (existingJob.schedule !== newJob.schedule) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (existingJob.timeZone !== newJob.timeZone) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (newJob.retryConfig) {
|
|
94
|
+
if (!existingJob.retryConfig) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
if (!_.isMatch(existingJob.retryConfig, newJob.retryConfig)) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
71
102
|
}
|
|
72
|
-
function jobNameForEndpoint(endpoint,
|
|
103
|
+
function jobNameForEndpoint(endpoint, location) {
|
|
73
104
|
const id = backend.scheduleIdForFunction(endpoint);
|
|
74
|
-
return `projects/${endpoint.project}/locations/${
|
|
105
|
+
return `projects/${endpoint.project}/locations/${location}/jobs/${id}`;
|
|
75
106
|
}
|
|
76
107
|
exports.jobNameForEndpoint = jobNameForEndpoint;
|
|
77
108
|
function topicNameForEndpoint(endpoint) {
|
|
@@ -79,10 +110,11 @@ function topicNameForEndpoint(endpoint) {
|
|
|
79
110
|
return `projects/${endpoint.project}/topics/${id}`;
|
|
80
111
|
}
|
|
81
112
|
exports.topicNameForEndpoint = topicNameForEndpoint;
|
|
82
|
-
function jobFromEndpoint(endpoint,
|
|
113
|
+
function jobFromEndpoint(endpoint, location, projectNumber) {
|
|
83
114
|
const job = {};
|
|
115
|
+
job.name = jobNameForEndpoint(endpoint, location);
|
|
84
116
|
if (endpoint.platform === "gcfv1") {
|
|
85
|
-
job.
|
|
117
|
+
job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE_V1;
|
|
86
118
|
job.pubsubTarget = {
|
|
87
119
|
topicName: topicNameForEndpoint(endpoint),
|
|
88
120
|
attributes: {
|
|
@@ -91,7 +123,14 @@ function jobFromEndpoint(endpoint, appEngineLocation) {
|
|
|
91
123
|
};
|
|
92
124
|
}
|
|
93
125
|
else if (endpoint.platform === "gcfv2") {
|
|
94
|
-
|
|
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
|
+
};
|
|
95
134
|
}
|
|
96
135
|
else {
|
|
97
136
|
(0, functional_1.assertExhaustive)(endpoint.platform);
|
|
@@ -100,13 +139,15 @@ function jobFromEndpoint(endpoint, appEngineLocation) {
|
|
|
100
139
|
throw new error_1.FirebaseError("Cannot create a scheduler job without a schedule:" + JSON.stringify(endpoint));
|
|
101
140
|
}
|
|
102
141
|
job.schedule = endpoint.scheduleTrigger.schedule;
|
|
103
|
-
job.timeZone = endpoint.scheduleTrigger.timeZone || DEFAULT_TIME_ZONE;
|
|
104
142
|
if (endpoint.scheduleTrigger.retryConfig) {
|
|
105
143
|
job.retryConfig = {};
|
|
106
144
|
proto.copyIfPresent(job.retryConfig, endpoint.scheduleTrigger.retryConfig, "maxDoublings", "retryCount");
|
|
107
145
|
proto.convertIfPresent(job.retryConfig, endpoint.scheduleTrigger.retryConfig, "maxBackoffDuration", "maxBackoffSeconds", (0, functional_1.nullsafeVisitor)(proto.durationFromSeconds));
|
|
108
146
|
proto.convertIfPresent(job.retryConfig, endpoint.scheduleTrigger.retryConfig, "minBackoffDuration", "minBackoffSeconds", (0, functional_1.nullsafeVisitor)(proto.durationFromSeconds));
|
|
109
147
|
proto.convertIfPresent(job.retryConfig, endpoint.scheduleTrigger.retryConfig, "maxRetryDuration", "maxRetrySeconds", (0, functional_1.nullsafeVisitor)(proto.durationFromSeconds));
|
|
148
|
+
if (!Object.keys(job.retryConfig).length) {
|
|
149
|
+
delete job.retryConfig;
|
|
150
|
+
}
|
|
110
151
|
}
|
|
111
152
|
return job;
|
|
112
153
|
}
|
package/lib/gcp/cloudtasks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queueFromEndpoint = exports.queueNameForEndpoint = exports.setEnqueuer = exports.getIamPolicy = exports.setIamPolicy = exports.deleteQueue = exports.purgeQueue = exports.upsertQueue = exports.updateQueue = exports.getQueue = exports.createQueue = exports.DEFAULT_SETTINGS = void 0;
|
|
3
|
+
exports.triggerFromQueue = exports.queueFromEndpoint = exports.queueNameForEndpoint = exports.setEnqueuer = exports.getIamPolicy = exports.setIamPolicy = exports.deleteQueue = exports.purgeQueue = exports.upsertQueue = exports.updateQueue = exports.getQueue = exports.createQueue = exports.DEFAULT_SETTINGS = void 0;
|
|
4
4
|
const proto = require("./proto");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const api_1 = require("../api");
|
|
@@ -144,3 +144,19 @@ function queueFromEndpoint(endpoint) {
|
|
|
144
144
|
return queue;
|
|
145
145
|
}
|
|
146
146
|
exports.queueFromEndpoint = queueFromEndpoint;
|
|
147
|
+
function triggerFromQueue(queue) {
|
|
148
|
+
const taskQueueTrigger = {};
|
|
149
|
+
if (queue.rateLimits) {
|
|
150
|
+
taskQueueTrigger.rateLimits = {};
|
|
151
|
+
proto.copyIfPresent(taskQueueTrigger.rateLimits, queue.rateLimits, "maxConcurrentDispatches", "maxDispatchesPerSecond");
|
|
152
|
+
}
|
|
153
|
+
if (queue.retryConfig) {
|
|
154
|
+
taskQueueTrigger.retryConfig = {};
|
|
155
|
+
proto.copyIfPresent(taskQueueTrigger.retryConfig, queue.retryConfig, "maxAttempts", "maxDoublings");
|
|
156
|
+
proto.convertIfPresent(taskQueueTrigger.retryConfig, queue.retryConfig, "maxRetrySeconds", "maxRetryDuration", (0, functional_1.nullsafeVisitor)(proto.secondsFromDuration));
|
|
157
|
+
proto.convertIfPresent(taskQueueTrigger.retryConfig, queue.retryConfig, "maxBackoffSeconds", "maxBackoff", (0, functional_1.nullsafeVisitor)(proto.secondsFromDuration));
|
|
158
|
+
proto.convertIfPresent(taskQueueTrigger.retryConfig, queue.retryConfig, "minBackoffSeconds", "minBackoff", (0, functional_1.nullsafeVisitor)(proto.secondsFromDuration));
|
|
159
|
+
}
|
|
160
|
+
return taskQueueTrigger;
|
|
161
|
+
}
|
|
162
|
+
exports.triggerFromQueue = triggerFromQueue;
|
package/lib/gcp/serviceusage.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateServiceIdentity = void 0;
|
|
4
|
-
const
|
|
4
|
+
const colorette_1 = require("colorette");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const error_1 = require("../error");
|
|
@@ -11,7 +11,7 @@ const apiClient = new apiv2_1.Client({
|
|
|
11
11
|
apiVersion: "v1beta1",
|
|
12
12
|
});
|
|
13
13
|
async function generateServiceIdentity(projectNumber, service, prefix) {
|
|
14
|
-
utils.logLabeledBullet(prefix, `generating the service identity for ${(0,
|
|
14
|
+
utils.logLabeledBullet(prefix, `generating the service identity for ${(0, colorette_1.bold)(service)}...`);
|
|
15
15
|
try {
|
|
16
16
|
return await apiClient.post(`projects/${projectNumber}/services/${service}:generateServiceIdentity`);
|
|
17
17
|
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handlePreviewToggles = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const
|
|
5
|
+
const colorette_1 = require("colorette");
|
|
6
6
|
const configstore_1 = require("./configstore");
|
|
7
7
|
const previews_1 = require("./previews");
|
|
8
8
|
function _errorOut(name) {
|
|
9
|
-
console.log(
|
|
9
|
+
console.log((0, colorette_1.bold)((0, colorette_1.red)("Error:")), "Did not recognize preview feature", (0, colorette_1.bold)(name || ""));
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
function handlePreviewToggles(args) {
|
|
13
13
|
const isValidPreview = (0, lodash_1.has)(previews_1.previews, args[1]);
|
|
14
14
|
if (args[0] === "--open-sesame") {
|
|
15
15
|
if (isValidPreview) {
|
|
16
|
-
console.log("Enabling preview feature", (0,
|
|
16
|
+
console.log("Enabling preview feature", (0, colorette_1.bold)(args[1]) + "...");
|
|
17
17
|
previews_1.previews[args[1]] = true;
|
|
18
18
|
configstore_1.configstore.set("previews", previews_1.previews);
|
|
19
19
|
console.log("Preview feature enabled!");
|
|
@@ -23,7 +23,7 @@ function handlePreviewToggles(args) {
|
|
|
23
23
|
}
|
|
24
24
|
else if (args[0] === "--close-sesame") {
|
|
25
25
|
if (isValidPreview) {
|
|
26
|
-
console.log("Disabling preview feature", (0,
|
|
26
|
+
console.log("Disabling preview feature", (0, colorette_1.bold)(args[1]));
|
|
27
27
|
(0, lodash_1.unset)(previews_1.previews, args[1]);
|
|
28
28
|
configstore_1.configstore.set("previews", previews_1.previews);
|
|
29
29
|
return process.exit(0);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.implicitInit = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const fetchWebSetup_1 = require("../fetchWebSetup");
|
|
8
8
|
const utils = require("../utils");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizedHostingConfigs = void 0;
|
|
4
|
-
const
|
|
4
|
+
const colorette_1 = require("colorette");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
function filterOnly(configs, onlyString) {
|
|
@@ -34,7 +34,7 @@ function filterOnly(configs, onlyString) {
|
|
|
34
34
|
filteredConfigs.push(configsByTarget.get(onlyTarget));
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
throw new error_1.FirebaseError(`Hosting site or target ${(0,
|
|
37
|
+
throw new error_1.FirebaseError(`Hosting site or target ${(0, colorette_1.bold)(onlyTarget)} not detected in firebase.json`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
return filteredConfigs;
|
|
@@ -82,7 +82,7 @@ function normalizedHostingConfigs(cmdOptions, options = {}) {
|
|
|
82
82
|
if (cfg.target) {
|
|
83
83
|
const matchingTargets = cmdOptions.rc.requireTarget(cmdOptions.project, "hosting", cfg.target);
|
|
84
84
|
if (matchingTargets.length > 1) {
|
|
85
|
-
throw new error_1.FirebaseError(`Hosting target ${(0,
|
|
85
|
+
throw new error_1.FirebaseError(`Hosting target ${(0, colorette_1.bold)(cfg.target)} is linked to multiple sites, ` +
|
|
86
86
|
`but only one is permitted. ` +
|
|
87
87
|
`To clear, run:\n\n firebase target:clear hosting ${cfg.target}`);
|
|
88
88
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const program = require("commander");
|
|
3
|
-
const clc = require("
|
|
3
|
+
const clc = require("colorette");
|
|
4
4
|
const leven = require("leven");
|
|
5
5
|
const logger_1 = require("./logger");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
@@ -56,7 +56,7 @@ const RENAMED_COMMANDS = {
|
|
|
56
56
|
program.action((_, args) => {
|
|
57
57
|
(0, utils_1.setupLoggers)();
|
|
58
58
|
const cmd = args[0];
|
|
59
|
-
logger_1.logger.error(clc.bold.red("Error:"), clc.bold(cmd), "is not a Firebase command");
|
|
59
|
+
logger_1.logger.error(clc.bold(clc.red("Error:")), clc.bold(cmd), "is not a Firebase command");
|
|
60
60
|
if (RENAMED_COMMANDS[cmd]) {
|
|
61
61
|
logger_1.logger.error();
|
|
62
62
|
logger_1.logger.error(clc.bold(cmd) + " has been renamed, please run", clc.bold("firebase " + RENAMED_COMMANDS[cmd]), "instead");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const prompt_1 = require("../../prompt");
|
|
6
6
|
const logger_1 = require("../../logger");
|
|
7
7
|
const utils = require("../../utils");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const _ = require("lodash");
|
|
6
6
|
const utils = require("../../utils");
|
|
7
7
|
const prompt_1 = require("../../prompt");
|
|
@@ -9,9 +9,9 @@ const checkDatabaseType_1 = require("../../../firestore/checkDatabaseType");
|
|
|
9
9
|
const rules = require("./rules");
|
|
10
10
|
const indexes = require("./indexes");
|
|
11
11
|
const error_1 = require("../../../error");
|
|
12
|
-
const clc = require("
|
|
12
|
+
const clc = require("colorette");
|
|
13
13
|
async function checkProjectSetup(setup, config, options) {
|
|
14
|
-
const firestoreUnusedError = new error_1.FirebaseError(`It looks like you haven't used Cloud Firestore in this project before. Go to ${clc.bold.underline(`https://console.firebase.google.com/project/${setup.projectId}/firestore`)} to create your Cloud Firestore database.`, { exit: 1 });
|
|
14
|
+
const firestoreUnusedError = new error_1.FirebaseError(`It looks like you haven't used Cloud Firestore in this project before. Go to ${clc.bold(clc.underline(`https://console.firebase.google.com/project/${setup.projectId}/firestore`))} to create your Cloud Firestore database.`, { exit: 1 });
|
|
15
15
|
const isFirestoreEnabled = await apiEnabled.check(setup.projectId, "firestore.googleapis.com", "", true);
|
|
16
16
|
if (!isFirestoreEnabled) {
|
|
17
17
|
throw firestoreUnusedError;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initIndexes = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const error_1 = require("../../../error");
|
|
7
7
|
const iv2 = require("../../../firestore/indexes");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initRules = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const gcp = require("../../../gcp");
|
|
7
7
|
const fsutils = require("../../../fsutils");
|
|
@@ -4,12 +4,12 @@ const util_1 = require("util");
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const spawn = require("cross-spawn");
|
|
7
|
+
const clc = require("colorette");
|
|
7
8
|
const error_1 = require("../../../error");
|
|
8
9
|
const prompt_1 = require("../../../prompt");
|
|
9
10
|
const utils = require("../../../utils");
|
|
10
11
|
const go = require("../../../deploy/functions/runtimes/golang");
|
|
11
12
|
const logger_1 = require("../../../logger");
|
|
12
|
-
const clc = require("cli-color");
|
|
13
13
|
const RUNTIME_VERSION = "1.13";
|
|
14
14
|
const TEMPLATE_ROOT = path.resolve(__dirname, "../../../../templates/init/functions/golang");
|
|
15
15
|
const MAIN_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "functions.go"), "utf8");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const _ = require("lodash");
|
|
5
6
|
const logger_1 = require("../../../logger");
|
|
6
7
|
const prompt_1 = require("../../../prompt");
|
|
7
8
|
const requirePermissions_1 = require("../../../requirePermissions");
|
|
@@ -44,6 +45,12 @@ async function doSetup(setup, config, options) {
|
|
|
44
45
|
default: "javascript",
|
|
45
46
|
choices,
|
|
46
47
|
});
|
|
48
|
+
_.set(setup, "config.functions.ignore", [
|
|
49
|
+
"node_modules",
|
|
50
|
+
".git",
|
|
51
|
+
"firebase-debug.log",
|
|
52
|
+
"firebase-debug.*.log",
|
|
53
|
+
]);
|
|
47
54
|
return require("./" + language).setup(setup, config);
|
|
48
55
|
}
|
|
49
56
|
exports.doSetup = doSetup;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initGitHub = void 0;
|
|
4
|
-
const
|
|
4
|
+
const colorette_1 = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const yaml = require("js-yaml");
|
|
7
7
|
const js_yaml_1 = require("js-yaml");
|
|
@@ -32,7 +32,7 @@ async function initGitHub(setup) {
|
|
|
32
32
|
return (0, utils_1.reject)("Could not determine Project ID, can't set up GitHub workflow.", { exit: 1 });
|
|
33
33
|
}
|
|
34
34
|
if (!setup.config.hosting) {
|
|
35
|
-
return (0, utils_1.reject)(`Didn't find a Hosting config in firebase.json. Run ${(0,
|
|
35
|
+
return (0, utils_1.reject)(`Didn't find a Hosting config in firebase.json. Run ${(0, colorette_1.bold)("firebase init hosting")} instead.`);
|
|
36
36
|
}
|
|
37
37
|
logger_1.logger.info();
|
|
38
38
|
const gitRoot = getGitFolderPath();
|
|
@@ -46,7 +46,7 @@ async function initGitHub(setup) {
|
|
|
46
46
|
const userDetails = await getGitHubUserDetails(ghAccessToken);
|
|
47
47
|
const ghUserName = userDetails.login;
|
|
48
48
|
logger_1.logger.info();
|
|
49
|
-
(0, utils_1.logSuccess)(`Success! Logged into GitHub as ${(0,
|
|
49
|
+
(0, utils_1.logSuccess)(`Success! Logged into GitHub as ${(0, colorette_1.bold)(ghUserName)}`);
|
|
50
50
|
logger_1.logger.info();
|
|
51
51
|
const { repo, key, keyId } = await promptForRepo(setup, ghAccessToken);
|
|
52
52
|
const { default_branch: defaultBranch, id: repoId } = await getRepoDetails(repo, ghAccessToken);
|
|
@@ -56,13 +56,13 @@ async function initGitHub(setup) {
|
|
|
56
56
|
const serviceAccountName = `github-action-${repoId}`;
|
|
57
57
|
const serviceAccountJSON = await createServiceAccountAndKeyWithRetry(setup, repo, serviceAccountName);
|
|
58
58
|
logger_1.logger.info();
|
|
59
|
-
(0, utils_1.logSuccess)(`Created service account ${(0,
|
|
59
|
+
(0, utils_1.logSuccess)(`Created service account ${(0, colorette_1.bold)(serviceAccountName)} with Firebase Hosting admin permissions.`);
|
|
60
60
|
const spinnerSecrets = ora(`Uploading service account secrets to repository: ${repo}`);
|
|
61
61
|
spinnerSecrets.start();
|
|
62
62
|
const encryptedServiceAccountJSON = encryptServiceAccountJSON(serviceAccountJSON, key);
|
|
63
63
|
await uploadSecretToGitHub(repo, ghAccessToken, await encryptedServiceAccountJSON, keyId, githubSecretName);
|
|
64
64
|
spinnerSecrets.stop();
|
|
65
|
-
(0, utils_1.logSuccess)(`Uploaded service account JSON to GitHub as secret ${(0,
|
|
65
|
+
(0, utils_1.logSuccess)(`Uploaded service account JSON to GitHub as secret ${(0, colorette_1.bold)(githubSecretName)}.`);
|
|
66
66
|
(0, utils_1.logBullet)(`You can manage your secrets at https://github.com/${repo}/settings/secrets.`);
|
|
67
67
|
logger_1.logger.info();
|
|
68
68
|
if (setup.config.hosting.predeploy) {
|
|
@@ -81,7 +81,7 @@ async function initGitHub(setup) {
|
|
|
81
81
|
if (shouldWriteYMLHostingFile) {
|
|
82
82
|
writeChannelActionYMLFile(YML_FULL_PATH_PULL_REQUEST, githubSecretName, setup.projectId, script);
|
|
83
83
|
logger_1.logger.info();
|
|
84
|
-
(0, utils_1.logSuccess)(`Created workflow file ${(0,
|
|
84
|
+
(0, utils_1.logSuccess)(`Created workflow file ${(0, colorette_1.bold)(YML_FULL_PATH_PULL_REQUEST)}`);
|
|
85
85
|
}
|
|
86
86
|
const { setupDeploys, branch } = await promptToSetupDeploys(ymlDeployDoc.branch || defaultBranch);
|
|
87
87
|
if (setupDeploys) {
|
|
@@ -102,12 +102,12 @@ async function initGitHub(setup) {
|
|
|
102
102
|
if (shouldWriteYMLDeployFile) {
|
|
103
103
|
writeDeployToProdActionYMLFile(YML_FULL_PATH_MERGE, branch, githubSecretName, setup.projectId, script);
|
|
104
104
|
logger_1.logger.info();
|
|
105
|
-
(0, utils_1.logSuccess)(`Created workflow file ${(0,
|
|
105
|
+
(0, utils_1.logSuccess)(`Created workflow file ${(0, colorette_1.bold)(YML_FULL_PATH_MERGE)}`);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
logger_1.logger.info();
|
|
109
109
|
(0, utils_1.logLabeledBullet)("Action required", `Visit this URL to revoke authorization for the Firebase CLI GitHub OAuth App:`);
|
|
110
|
-
logger_1.logger.info(
|
|
110
|
+
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${api_1.githubClientId}`)));
|
|
111
111
|
(0, utils_1.logLabeledBullet)("Action required", `Push any new workflow file(s) to your repo`);
|
|
112
112
|
}
|
|
113
113
|
exports.initGitHub = initGitHub;
|
|
@@ -253,7 +253,7 @@ async function promptForRepo(options, ghAccessToken) {
|
|
|
253
253
|
(0, utils_1.logWarning)("The provided authorization cannot be used with this repository. If this repository is in an organization, did you remember to grant access?", "error");
|
|
254
254
|
logger_1.logger.info();
|
|
255
255
|
(0, utils_1.logLabeledBullet)("Action required", `Visit this URL to ensure access has been granted to the appropriate organization(s) for the Firebase CLI GitHub OAuth App:`);
|
|
256
|
-
logger_1.logger.info(
|
|
256
|
+
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${api_1.githubClientId}`)));
|
|
257
257
|
logger_1.logger.info();
|
|
258
258
|
}
|
|
259
259
|
return false;
|