firebase-tools 10.0.0 → 10.1.2
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/accountExporter.js +9 -8
- package/lib/accountImporter.js +10 -8
- package/lib/api.js +1 -0
- package/lib/apiv2.js +2 -2
- package/lib/appdistribution/client.js +1 -1
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/auth.js +2 -2
- package/lib/bin/firebase.js +1 -1
- package/lib/command.js +26 -26
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/appdistribution-testers-add.js +2 -2
- package/lib/commands/appdistribution-testers-remove.js +2 -2
- package/lib/commands/apps-android-sha-create.js +2 -2
- package/lib/commands/apps-android-sha-delete.js +2 -2
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +9 -9
- package/lib/commands/apps-list.js +3 -3
- package/lib/commands/apps-sdkconfig.js +8 -8
- package/lib/commands/auth-export.js +26 -25
- package/lib/commands/auth-import.js +88 -78
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/database-instances-create.js +4 -4
- package/lib/commands/database-instances-list.js +4 -4
- package/lib/commands/database-profile.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +2 -2
- package/lib/commands/database-set.js +2 -2
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +2 -2
- package/lib/commands/ext-configure.js +3 -3
- package/lib/commands/ext-dev-deprecate.js +4 -4
- package/lib/commands/ext-dev-extension-delete.js +3 -3
- package/lib/commands/ext-dev-init.js +4 -4
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +4 -4
- package/lib/commands/ext-dev-register.js +6 -6
- package/lib/commands/ext-dev-undeprecate.js +4 -4
- package/lib/commands/ext-dev-unpublish.js +3 -3
- package/lib/commands/ext-dev-usage.js +145 -0
- package/lib/commands/ext-export.js +8 -8
- package/lib/commands/ext-info.js +5 -5
- package/lib/commands/ext-install.js +27 -23
- package/lib/commands/ext-list.js +2 -2
- package/lib/commands/ext-sources-create.js +2 -2
- package/lib/commands/ext-uninstall.js +4 -4
- package/lib/commands/ext-update.js +18 -18
- package/lib/commands/ext.js +3 -3
- package/lib/commands/firestore-delete.js +1 -1
- package/lib/commands/functions-config-clone.js +22 -23
- package/lib/commands/functions-config-export.js +11 -11
- package/lib/commands/functions-config-get.js +22 -22
- package/lib/commands/functions-config-set.js +24 -22
- package/lib/commands/functions-config-unset.js +20 -22
- package/lib/commands/functions-delete.js +3 -3
- package/lib/commands/functions-deletegcfartifacts.js +4 -4
- package/lib/commands/functions-list.js +1 -1
- package/lib/commands/functions-log.js +1 -1
- package/lib/commands/help.js +12 -12
- package/lib/commands/hosting-channel-create.js +13 -13
- package/lib/commands/hosting-channel-delete.js +10 -10
- package/lib/commands/hosting-channel-deploy.js +18 -18
- package/lib/commands/hosting-channel-list.js +5 -5
- package/lib/commands/hosting-channel-open.js +9 -9
- package/lib/commands/hosting-clone.js +16 -16
- package/lib/commands/hosting-disable.js +1 -1
- package/lib/commands/hosting-sites-create.js +7 -7
- package/lib/commands/hosting-sites-delete.js +7 -7
- package/lib/commands/hosting-sites-get.js +2 -2
- package/lib/commands/hosting-sites-list.js +3 -3
- package/lib/commands/index.js +1 -0
- package/lib/commands/login-ci.js +10 -10
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +1 -1
- package/lib/commands/projects-addfirebase.js +2 -2
- package/lib/commands/projects-create.js +2 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +3 -3
- package/lib/commands/remoteconfig-rollback.js +3 -3
- package/lib/commands/remoteconfig-versions-list.js +7 -2
- package/lib/commands/setup-emulators-database.js +8 -7
- package/lib/commands/setup-emulators-firestore.js +8 -7
- package/lib/commands/setup-emulators-pubsub.js +5 -4
- package/lib/commands/setup-emulators-storage.js +4 -3
- package/lib/commands/setup-emulators-ui.js +8 -7
- package/lib/commands/target-apply.js +17 -16
- package/lib/commands/target-clear.js +11 -10
- package/lib/commands/target-remove.js +10 -9
- package/lib/commands/target.js +20 -20
- package/lib/config.js +6 -6
- package/lib/database/api.js +2 -2
- package/lib/defaultCredentials.js +3 -3
- package/lib/deploy/extensions/deploy.js +4 -4
- package/lib/deploy/extensions/deploymentSummary.js +5 -4
- package/lib/deploy/extensions/index.js +1 -0
- package/lib/deploy/extensions/params.js +1 -1
- package/lib/deploy/extensions/planner.js +3 -3
- package/lib/deploy/extensions/prepare.js +9 -9
- package/lib/deploy/extensions/release.js +1 -1
- package/lib/deploy/extensions/secrets.js +7 -7
- package/lib/deploy/extensions/validate.js +2 -2
- package/lib/deploy/functions/backend.js +6 -4
- package/lib/deploy/functions/checkIam.js +7 -7
- package/lib/deploy/functions/containerCleaner.js +3 -3
- package/lib/deploy/functions/deploy.js +4 -4
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
- package/lib/deploy/functions/index.js +1 -0
- package/lib/deploy/functions/prepare.js +27 -21
- package/lib/deploy/functions/prompts.js +5 -5
- package/lib/deploy/functions/release/executor.js +4 -1
- package/lib/deploy/functions/release/fabricator.js +5 -5
- package/lib/deploy/functions/release/index.js +2 -2
- package/lib/deploy/functions/release/planner.js +6 -6
- package/lib/deploy/functions/release/reporter.js +8 -4
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
- package/lib/deploy/functions/runtimes/golang/index.js +11 -14
- package/lib/deploy/functions/runtimes/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
- package/lib/deploy/functions/runtimes/node/validate.js +2 -1
- package/lib/deploy/functions/services/storage.js +1 -1
- package/lib/deploy/functions/triggerRegionHelper.js +1 -1
- package/lib/deploy/functions/validate.js +4 -3
- package/lib/deploy/hosting/deploy.js +7 -7
- package/lib/deploy/hosting/uploader.js +1 -1
- package/lib/deploy/hosting/validate.js +3 -3
- package/lib/deploy/remoteconfig/prepare.js +3 -3
- package/lib/deploy/remoteconfig/release.js +3 -3
- package/lib/deploy/storage/deploy.js +1 -1
- package/lib/deploy/storage/release.js +2 -2
- package/lib/detectProjectRoot.js +5 -5
- package/lib/emulator/auth/apiSpec.js +13 -7
- package/lib/emulator/auth/handlers.js +3 -3
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +256 -248
- package/lib/emulator/auth/server.js +11 -8
- package/lib/emulator/auth/state.js +12 -12
- package/lib/emulator/commandUtils.js +5 -5
- package/lib/emulator/controller.js +16 -11
- package/lib/emulator/downloadableEmulators.js +10 -9
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/functionsEmulator.js +107 -74
- package/lib/emulator/functionsEmulatorRuntime.js +36 -21
- package/lib/emulator/functionsEmulatorShell.js +3 -2
- package/lib/emulator/functionsRuntimeWorker.js +1 -1
- package/lib/emulator/hubExport.js +2 -2
- package/lib/emulator/storage/apis/firebase.js +2 -2
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/cloudFunctions.js +1 -1
- package/lib/emulator/storage/files.js +14 -14
- package/lib/emulator/storage/index.js +2 -2
- package/lib/emulator/storage/metadata.js +7 -6
- package/lib/emulator/storage/rules/runtime.js +10 -9
- package/lib/emulator/storage/server.js +2 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/error.js +3 -3
- package/lib/extensions/askUserForConsent.js +3 -4
- package/lib/extensions/askUserForParam.js +11 -11
- package/lib/extensions/billingMigrationHelper.js +2 -2
- package/lib/extensions/changelog.js +4 -4
- package/lib/extensions/displayExtensionInfo.js +6 -6
- package/lib/extensions/emulator/optionsHelper.js +1 -1
- package/lib/extensions/emulator/specHelper.js +1 -1
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/export.js +6 -6
- package/lib/extensions/extensionsApi.js +69 -110
- package/lib/extensions/extensionsHelper.js +56 -43
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/metricsTypeDef.js +2 -0
- package/lib/extensions/metricsUtils.js +98 -0
- package/lib/extensions/paramHelper.js +6 -6
- package/lib/extensions/provisioningHelper.js +13 -14
- package/lib/extensions/resolveSource.js +6 -6
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/updateHelper.js +10 -10
- package/lib/extensions/utils.js +1 -1
- package/lib/extensions/warnings.js +11 -10
- package/lib/fetchWebSetup.js +2 -2
- package/lib/filterTargets.js +2 -2
- package/lib/firestore/indexes.js +2 -2
- package/lib/fsAsync.js +3 -3
- package/lib/fsutils.js +2 -2
- package/lib/functional.js +2 -1
- package/lib/functions/env.js +1 -1
- package/lib/functions/runtimeConfigExport.js +4 -4
- package/lib/functionsConfig.js +7 -8
- package/lib/functionsShellCommandAction.js +4 -3
- package/lib/gcp/cloudmonitoring.js +74 -0
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/iam.js +2 -2
- package/lib/gcp/resourceManager.js +2 -2
- package/lib/gcp/rules.js +18 -41
- package/lib/gcp/secretManager.js +3 -2
- package/lib/getDefaultDatabaseInstance.js +1 -1
- package/lib/getDefaultHostingSite.js +1 -1
- package/lib/getProjectNumber.js +2 -2
- package/lib/handlePreviewToggles.js +5 -5
- package/lib/hosting/api.js +6 -6
- package/lib/hosting/cloudRunProxy.js +6 -6
- package/lib/hosting/functionsProxy.js +3 -3
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/hosting/proxy.js +2 -2
- package/lib/init/features/account.js +7 -7
- package/lib/init/features/database.js +9 -9
- package/lib/init/features/emulators.js +8 -8
- package/lib/init/features/firestore/index.js +3 -3
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/golang.js +4 -4
- package/lib/init/features/functions/index.js +4 -4
- package/lib/init/features/hosting/github.js +31 -31
- package/lib/init/features/project.js +8 -8
- package/lib/init/features/remoteconfig.js +2 -2
- package/lib/init/features/storage.js +2 -2
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +3 -3
- package/lib/management/projects.js +6 -6
- package/lib/previews.js +2 -2
- package/lib/profiler.js +1 -1
- package/lib/projectPath.js +1 -1
- package/lib/projectUtils.js +2 -2
- package/lib/prompt.js +0 -1
- package/lib/rc.js +1 -1
- package/lib/remoteconfig/get.js +14 -8
- package/lib/remoteconfig/rollback.js +13 -6
- package/lib/remoteconfig/versionslist.js +13 -7
- package/lib/requireAuth.js +2 -2
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requireHostingSite.js +1 -1
- package/lib/requirePermissions.js +4 -4
- package/lib/rulesDeploy.js +2 -2
- package/lib/serve/functions.js +14 -7
- package/lib/serve/hosting.js +7 -7
- package/lib/utils.js +3 -2
- package/npm-shrinkwrap.json +24095 -0
- package/package.json +33 -30
- package/templates/init/hosting/index.html +1 -1
- package/CHANGELOG.md +0 -5
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Table = require("cli-table");
|
|
4
|
+
const clc = require("cli-color");
|
|
5
|
+
const utils = require("../utils");
|
|
6
|
+
const command_1 = require("../command");
|
|
7
|
+
const cloudmonitoring_1 = require("../gcp/cloudmonitoring");
|
|
8
|
+
const requireAuth_1 = require("../requireAuth");
|
|
9
|
+
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
10
|
+
const metricsUtils_1 = require("../extensions/metricsUtils");
|
|
11
|
+
const extensionsApi_1 = require("../extensions/extensionsApi");
|
|
12
|
+
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
13
|
+
const error_1 = require("../error");
|
|
14
|
+
const logger_1 = require("../logger");
|
|
15
|
+
const prompt_1 = require("../prompt");
|
|
16
|
+
const shortenUrl_1 = require("../shortenUrl");
|
|
17
|
+
module.exports = new command_1.Command("ext:dev:usage <publisherId>")
|
|
18
|
+
.description("get usage for an extension")
|
|
19
|
+
.help("use this command to get the usage of extensions you published. " +
|
|
20
|
+
"Specify the publisher ID you used to publish your extensions, " +
|
|
21
|
+
"or the extension ref of your published extension.")
|
|
22
|
+
.before(requireAuth_1.requireAuth)
|
|
23
|
+
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extDevMinVersion")
|
|
24
|
+
.action(async (input) => {
|
|
25
|
+
const extensionRefRegex = /^[\w\d-]+\/[\w\d-]+$/;
|
|
26
|
+
let extensionName;
|
|
27
|
+
let publisherId;
|
|
28
|
+
if (extensionRefRegex.test(input)) {
|
|
29
|
+
[publisherId, extensionName] = input.split("/");
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
publisherId = input;
|
|
33
|
+
let extensions;
|
|
34
|
+
try {
|
|
35
|
+
extensions = await (0, extensionsApi_1.listExtensions)(publisherId);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
throw new error_1.FirebaseError(err);
|
|
39
|
+
}
|
|
40
|
+
if (extensions.length < 1) {
|
|
41
|
+
throw new error_1.FirebaseError(`There are no published extensions associated with publisher ID ${clc.bold(publisherId)}. This could happen for two reasons:\n` +
|
|
42
|
+
" - The publisher ID doesn't exist or could be misspelled\n" +
|
|
43
|
+
" - This publisher has not published any extensions\n\n" +
|
|
44
|
+
"If you are expecting some extensions to appear, please make sure you have the correct publisher ID and try again.");
|
|
45
|
+
}
|
|
46
|
+
extensionName = await (0, prompt_1.promptOnce)({
|
|
47
|
+
type: "list",
|
|
48
|
+
name: "extension",
|
|
49
|
+
message: "Which published extension do you want to view the stats for?",
|
|
50
|
+
choices: extensions.map((e) => {
|
|
51
|
+
const [_, name] = e.ref.split("/");
|
|
52
|
+
return {
|
|
53
|
+
name,
|
|
54
|
+
value: name,
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const profile = await (0, extensionsApi_1.getPublisherProfile)("-", publisherId);
|
|
60
|
+
const projectNumber = (0, extensionsHelper_1.getPublisherProjectFromName)(profile.name);
|
|
61
|
+
const past30d = new Date();
|
|
62
|
+
past30d.setDate(past30d.getDate() - 30);
|
|
63
|
+
const query = {
|
|
64
|
+
filter: `metric.type="firebaseextensions.googleapis.com/extension/version/active_instances" ` +
|
|
65
|
+
`resource.type="firebaseextensions.googleapis.com/ExtensionVersion" ` +
|
|
66
|
+
`resource.labels.extension="${extensionName}"`,
|
|
67
|
+
"interval.endTime": new Date().toJSON(),
|
|
68
|
+
"interval.startTime": past30d.toJSON(),
|
|
69
|
+
view: cloudmonitoring_1.TimeSeriesView.FULL,
|
|
70
|
+
"aggregation.alignmentPeriod": (60 * 60 * 24).toString() + "s",
|
|
71
|
+
"aggregation.perSeriesAligner": cloudmonitoring_1.Aligner.ALIGN_MAX,
|
|
72
|
+
};
|
|
73
|
+
let response;
|
|
74
|
+
try {
|
|
75
|
+
response = await (0, cloudmonitoring_1.queryTimeSeries)(query, projectNumber);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
throw new error_1.FirebaseError(`Error occurred when fetching usage data for extension ${extensionName}`, {
|
|
79
|
+
original: err,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (!response) {
|
|
83
|
+
throw new error_1.FirebaseError(`Couldn't find any usage data for extension ${extensionName}`);
|
|
84
|
+
}
|
|
85
|
+
const metrics = (0, metricsUtils_1.parseTimeseriesResponse)(response);
|
|
86
|
+
const table = new Table({
|
|
87
|
+
head: ["Version", "Active Instances", "Changes last 7 Days", "Changes last 28 Days"],
|
|
88
|
+
style: {
|
|
89
|
+
head: ["yellow"],
|
|
90
|
+
},
|
|
91
|
+
colAligns: ["left", "right", "right", "right"],
|
|
92
|
+
});
|
|
93
|
+
metrics.forEach((m) => {
|
|
94
|
+
table.push((0, metricsUtils_1.buildMetricsTableRow)(m));
|
|
95
|
+
});
|
|
96
|
+
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `showing usage stats for ${clc.bold(extensionName)}:`);
|
|
97
|
+
logger_1.logger.info(table.toString());
|
|
98
|
+
const link = await buildCloudMonitoringLink({
|
|
99
|
+
projectNumber: projectNumber,
|
|
100
|
+
extensionName,
|
|
101
|
+
});
|
|
102
|
+
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `How to read this table:`);
|
|
103
|
+
logger_1.logger.info(`* Due to privacy considerations, numbers are reported as ranges.`);
|
|
104
|
+
logger_1.logger.info(`* In the absence of significant changes, we will render a '-' symbol.`);
|
|
105
|
+
logger_1.logger.info(`* You will need more than 10 installs over a period of more than 28 days to render sufficient data.`);
|
|
106
|
+
logger_1.logger.info(`For more detail, visit: ${link}`);
|
|
107
|
+
});
|
|
108
|
+
async function buildCloudMonitoringLink(args) {
|
|
109
|
+
const pageState = {
|
|
110
|
+
xyChart: {
|
|
111
|
+
dataSets: [
|
|
112
|
+
{
|
|
113
|
+
timeSeriesFilter: {
|
|
114
|
+
filter: `metric.type="firebaseextensions.googleapis.com/extension/version/active_instances"` +
|
|
115
|
+
` resource.type="firebaseextensions.googleapis.com/ExtensionVersion"` +
|
|
116
|
+
` resource.label.extension="${args.extensionName}"`,
|
|
117
|
+
minAlignmentPeriod: "86400s",
|
|
118
|
+
aggregations: [
|
|
119
|
+
{
|
|
120
|
+
perSeriesAligner: "ALIGN_MEAN",
|
|
121
|
+
crossSeriesReducer: "REDUCE_MAX",
|
|
122
|
+
alignmentPeriod: "86400s",
|
|
123
|
+
groupByFields: ['resource.label."extension"', 'resource.label."version"'],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
crossSeriesReducer: "REDUCE_NONE",
|
|
127
|
+
alignmentPeriod: "60s",
|
|
128
|
+
groupByFields: [],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
isAutoRefresh: true,
|
|
136
|
+
timeSelection: {
|
|
137
|
+
timeRange: "4w",
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
let uri = `https://console.cloud.google.com/monitoring/metrics-explorer?project=${args.projectNumber}` +
|
|
141
|
+
`&pageState=${JSON.stringify(pageState)}`;
|
|
142
|
+
uri = encodeURI(uri);
|
|
143
|
+
uri = await (0, shortenUrl_1.shortenUrl)(uri);
|
|
144
|
+
return uri;
|
|
145
|
+
}
|
|
@@ -18,21 +18,21 @@ module.exports = new command_1.Command("ext:export")
|
|
|
18
18
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
19
19
|
.withForce()
|
|
20
20
|
.action(async (options) => {
|
|
21
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
22
|
-
const projectNumber = await getProjectNumber_1.getProjectNumber(options);
|
|
21
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
22
|
+
const projectNumber = await (0, getProjectNumber_1.getProjectNumber)(options);
|
|
23
23
|
const have = await Promise.all((await planner.have(projectId)).map(async (i) => {
|
|
24
|
-
const subbed = await export_1.setSecretParamsToLatest(i);
|
|
25
|
-
return export_1.parameterizeProject(projectId, projectNumber, subbed);
|
|
24
|
+
const subbed = await (0, export_1.setSecretParamsToLatest)(i);
|
|
25
|
+
return (0, export_1.parameterizeProject)(projectId, projectNumber, subbed);
|
|
26
26
|
}));
|
|
27
27
|
if (have.length == 0) {
|
|
28
28
|
logger_1.logger.info(`No extension instances installed on ${projectId}, so there is nothing to export.`);
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const [withRef, withoutRef] = functional_1.partition(have, (s) => !!s.ref);
|
|
32
|
-
export_1.displayExportInfo(withRef, withoutRef);
|
|
31
|
+
const [withRef, withoutRef] = (0, functional_1.partition)(have, (s) => !!s.ref);
|
|
32
|
+
(0, export_1.displayExportInfo)(withRef, withoutRef);
|
|
33
33
|
if (!options.nonInteractive &&
|
|
34
34
|
!options.force &&
|
|
35
|
-
!(await prompt_1.promptOnce({
|
|
35
|
+
!(await (0, prompt_1.promptOnce)({
|
|
36
36
|
message: "Do you wish to add these Extension instances to firebase.json?",
|
|
37
37
|
type: "confirm",
|
|
38
38
|
default: true,
|
|
@@ -40,5 +40,5 @@ module.exports = new command_1.Command("ext:export")
|
|
|
40
40
|
logger_1.logger.info("Exiting. No changes made.");
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
await export_1.writeFiles(withRef, options);
|
|
43
|
+
await (0, export_1.writeFiles)(withRef, options);
|
|
44
44
|
});
|
package/lib/commands/ext-info.js
CHANGED
|
@@ -10,7 +10,7 @@ const localHelper_1 = require("../extensions/localHelper");
|
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
11
|
const requirePermissions_1 = require("../requirePermissions");
|
|
12
12
|
const utils = require("../utils");
|
|
13
|
-
const marked = require("marked");
|
|
13
|
+
const { marked } = require("marked");
|
|
14
14
|
const TerminalRenderer = require("marked-terminal");
|
|
15
15
|
const FUNCTION_TYPE_REGEX = /\..+\.function/;
|
|
16
16
|
exports.default = new command_1.Command("ext:info <extensionName>")
|
|
@@ -20,15 +20,15 @@ exports.default = new command_1.Command("ext:info <extensionName>")
|
|
|
20
20
|
.action(async (extensionName, options) => {
|
|
21
21
|
var _a, _b;
|
|
22
22
|
let spec;
|
|
23
|
-
if (localHelper_1.isLocalExtension(extensionName)) {
|
|
23
|
+
if ((0, localHelper_1.isLocalExtension)(extensionName)) {
|
|
24
24
|
if (!options.markdown) {
|
|
25
25
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `reading extension from directory: ${extensionName}`);
|
|
26
26
|
}
|
|
27
|
-
spec = await localHelper_1.getLocalExtensionSpec(extensionName);
|
|
27
|
+
spec = await (0, localHelper_1.getLocalExtensionSpec)(extensionName);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
await requirePermissions_1.requirePermissions(options, ["firebaseextensions.sources.get"]);
|
|
31
|
-
await extensionsHelper_1.ensureExtensionsApiEnabled(options);
|
|
30
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.sources.get"]);
|
|
31
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
32
32
|
const hasPublisherId = extensionName.split("/").length >= 2;
|
|
33
33
|
if (hasPublisherId) {
|
|
34
34
|
const nameAndVersion = extensionName.split("/")[1];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const clc = require("cli-color");
|
|
4
|
-
const marked = require("marked");
|
|
4
|
+
const { marked } = require("marked");
|
|
5
5
|
const ora = require("ora");
|
|
6
6
|
const TerminalRenderer = require("marked-terminal");
|
|
7
7
|
const askUserForConsent = require("../extensions/askUserForConsent");
|
|
@@ -24,33 +24,34 @@ const updateHelper_1 = require("../extensions/updateHelper");
|
|
|
24
24
|
const utils_1 = require("../extensions/utils");
|
|
25
25
|
const requirePermissions_1 = require("../requirePermissions");
|
|
26
26
|
const utils = require("../utils");
|
|
27
|
+
const track_1 = require("../track");
|
|
27
28
|
const logger_1 = require("../logger");
|
|
28
29
|
const previews_1 = require("../previews");
|
|
29
30
|
marked.setOptions({
|
|
30
31
|
renderer: new TerminalRenderer(),
|
|
31
32
|
});
|
|
32
33
|
async function installExtension(options) {
|
|
33
|
-
const { projectId, extensionName, source, extVersion, paramsEnvPath, nonInteractive, force
|
|
34
|
+
const { projectId, extensionName, source, extVersion, paramsEnvPath, nonInteractive, force } = options;
|
|
34
35
|
const spec = (source === null || source === void 0 ? void 0 : source.spec) || (extVersion === null || extVersion === void 0 ? void 0 : extVersion.spec);
|
|
35
36
|
if (!spec) {
|
|
36
37
|
throw new error_1.FirebaseError(`Could not find the extension.yaml for ${extensionName}. Please make sure this is a valid extension and try again.`);
|
|
37
38
|
}
|
|
38
|
-
const spinner = ora
|
|
39
|
+
const spinner = ora();
|
|
39
40
|
try {
|
|
40
41
|
await provisioningHelper.checkProductsProvisioned(projectId, spec);
|
|
41
42
|
const usesSecrets = secretsUtils.usesSecrets(spec);
|
|
42
43
|
if (spec.billingRequired || usesSecrets) {
|
|
43
|
-
const enabled = await cloudbilling_1.checkBillingEnabled(projectId);
|
|
44
|
+
const enabled = await (0, cloudbilling_1.checkBillingEnabled)(projectId);
|
|
44
45
|
if (!enabled && nonInteractive) {
|
|
45
46
|
throw new error_1.FirebaseError(`This extension requires the Blaze plan, but project ${projectId} is not on the Blaze plan. ` +
|
|
46
47
|
marked("Please visit https://console.cloud.google.com/billing/linkedaccount?project=${projectId} to upgrade your project."));
|
|
47
48
|
}
|
|
48
49
|
else if (!enabled) {
|
|
49
|
-
await billingMigrationHelper_1.displayNode10CreateBillingNotice(spec, false);
|
|
50
|
-
await checkProjectBilling_1.enableBilling(projectId);
|
|
50
|
+
await (0, billingMigrationHelper_1.displayNode10CreateBillingNotice)(spec, false);
|
|
51
|
+
await (0, checkProjectBilling_1.enableBilling)(projectId);
|
|
51
52
|
}
|
|
52
53
|
else {
|
|
53
|
-
await billingMigrationHelper_1.displayNode10CreateBillingNotice(spec, !nonInteractive);
|
|
54
|
+
await (0, billingMigrationHelper_1.displayNode10CreateBillingNotice)(spec, !nonInteractive);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
const apis = spec.apis || [];
|
|
@@ -62,7 +63,7 @@ async function installExtension(options) {
|
|
|
62
63
|
}
|
|
63
64
|
if (apis.length) {
|
|
64
65
|
askUserForConsent.displayApis(spec.displayName || spec.name, projectId, apis);
|
|
65
|
-
const consented = await extensionsHelper_1.confirm({ nonInteractive, force, default: true });
|
|
66
|
+
const consented = await (0, extensionsHelper_1.confirm)({ nonInteractive, force, default: true });
|
|
66
67
|
if (!consented) {
|
|
67
68
|
throw new error_1.FirebaseError("Without explicit consent for the APIs listed, we cannot deploy this extension.");
|
|
68
69
|
}
|
|
@@ -73,17 +74,17 @@ async function installExtension(options) {
|
|
|
73
74
|
const roles = spec.roles ? spec.roles.map((role) => role.role) : [];
|
|
74
75
|
if (roles.length) {
|
|
75
76
|
await askUserForConsent.displayRoles(spec.displayName || spec.name, projectId, roles);
|
|
76
|
-
const consented = await extensionsHelper_1.confirm({ nonInteractive, force, default: true });
|
|
77
|
+
const consented = await (0, extensionsHelper_1.confirm)({ nonInteractive, force, default: true });
|
|
77
78
|
if (!consented) {
|
|
78
79
|
throw new error_1.FirebaseError("Without explicit consent for the roles listed, we cannot deploy this extension.");
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
let instanceId = spec.name;
|
|
82
83
|
let choice;
|
|
83
|
-
const anotherInstanceExists = await extensionsHelper_1.instanceIdExists(projectId, instanceId);
|
|
84
|
+
const anotherInstanceExists = await (0, extensionsHelper_1.instanceIdExists)(projectId, instanceId);
|
|
84
85
|
if (anotherInstanceExists) {
|
|
85
86
|
if (!nonInteractive) {
|
|
86
|
-
choice = await extensionsHelper_1.promptForRepeatInstance(projectId, spec.name);
|
|
87
|
+
choice = await (0, extensionsHelper_1.promptForRepeatInstance)(projectId, spec.name);
|
|
87
88
|
}
|
|
88
89
|
else if (nonInteractive && force) {
|
|
89
90
|
choice = "updateExisting";
|
|
@@ -99,7 +100,7 @@ async function installExtension(options) {
|
|
|
99
100
|
let params;
|
|
100
101
|
switch (choice) {
|
|
101
102
|
case "installNew":
|
|
102
|
-
instanceId = await extensionsHelper_1.promptForValidInstanceId(`${instanceId}-${utils_1.getRandomString(4)}`);
|
|
103
|
+
instanceId = await (0, extensionsHelper_1.promptForValidInstanceId)(`${instanceId}-${(0, utils_1.getRandomString)(4)}`);
|
|
103
104
|
params = await paramHelper.getParams({
|
|
104
105
|
projectId,
|
|
105
106
|
paramSpecs: spec.params,
|
|
@@ -130,7 +131,7 @@ async function installExtension(options) {
|
|
|
130
131
|
});
|
|
131
132
|
spinner.text = "Updating your extension instance. This usually takes 3 to 5 minutes...";
|
|
132
133
|
spinner.start();
|
|
133
|
-
await updateHelper_1.update({
|
|
134
|
+
await (0, updateHelper_1.update)({
|
|
134
135
|
projectId,
|
|
135
136
|
instanceId,
|
|
136
137
|
source,
|
|
@@ -164,16 +165,16 @@ async function installExtension(options) {
|
|
|
164
165
|
async function infoInstallBySource(projectId, extensionName) {
|
|
165
166
|
let source;
|
|
166
167
|
try {
|
|
167
|
-
source = await extensionsHelper_1.createSourceFromLocation(projectId, extensionName);
|
|
168
|
+
source = await (0, extensionsHelper_1.createSourceFromLocation)(projectId, extensionName);
|
|
168
169
|
}
|
|
169
170
|
catch (err) {
|
|
170
171
|
throw new error_1.FirebaseError(`Unable to find published extension '${clc.bold(extensionName)}', ` +
|
|
171
172
|
`and encountered the following error when trying to create an instance of extension '${clc.bold(extensionName)}':\n ${err.message}`);
|
|
172
173
|
}
|
|
173
|
-
displayExtensionInfo_1.displayExtInfo(extensionName, "", source.spec);
|
|
174
|
+
(0, displayExtensionInfo_1.displayExtInfo)(extensionName, "", source.spec);
|
|
174
175
|
return source;
|
|
175
176
|
}
|
|
176
|
-
async function infoInstallByReference(extensionName) {
|
|
177
|
+
async function infoInstallByReference(extensionName, interactive) {
|
|
177
178
|
if (extensionName.split("/").length < 2) {
|
|
178
179
|
const [extensionID, version] = extensionName.split("@");
|
|
179
180
|
extensionName = `firebase/${extensionID}@${version || "latest"}`;
|
|
@@ -181,11 +182,12 @@ async function infoInstallByReference(extensionName) {
|
|
|
181
182
|
const ref = refs.parse(extensionName);
|
|
182
183
|
const extension = await extensionsApi.getExtension(refs.toExtensionRef(ref));
|
|
183
184
|
if (!ref.version) {
|
|
185
|
+
(0, track_1.track)("Extension Install", "Install by Extension Version Ref", interactive ? 1 : 0);
|
|
184
186
|
extensionName = `${extensionName}@latest`;
|
|
185
187
|
}
|
|
186
188
|
const extVersion = await extensionsApi.getExtensionVersion(extensionName);
|
|
187
|
-
displayExtensionInfo_1.displayExtInfo(extensionName, ref.publisherId, extVersion.spec, true);
|
|
188
|
-
await warnings_1.displayWarningPrompts(ref.publisherId, extension.registryLaunchStage, extVersion);
|
|
189
|
+
(0, displayExtensionInfo_1.displayExtInfo)(extensionName, ref.publisherId, extVersion.spec, true);
|
|
190
|
+
await (0, warnings_1.displayWarningPrompts)(ref.publisherId, extension.registryLaunchStage, extVersion);
|
|
189
191
|
return extVersion;
|
|
190
192
|
}
|
|
191
193
|
exports.default = new command_1.Command("ext:install [extensionName]")
|
|
@@ -200,13 +202,13 @@ exports.default = new command_1.Command("ext:install [extensionName]")
|
|
|
200
202
|
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
201
203
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
202
204
|
.action(async (extensionName, options) => {
|
|
203
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
205
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
204
206
|
const paramsEnvPath = options.params;
|
|
205
207
|
let learnMore = false;
|
|
206
208
|
if (!extensionName) {
|
|
207
209
|
if (options.interactive) {
|
|
208
210
|
learnMore = true;
|
|
209
|
-
extensionName = await extensionsHelper_1.promptForOfficialExtension("Which official extension do you wish to install?\n" +
|
|
211
|
+
extensionName = await (0, extensionsHelper_1.promptForOfficialExtension)("Which official extension do you wish to install?\n" +
|
|
210
212
|
" Select an extension, then press Enter to learn more.");
|
|
211
213
|
}
|
|
212
214
|
else {
|
|
@@ -216,13 +218,15 @@ exports.default = new command_1.Command("ext:install [extensionName]")
|
|
|
216
218
|
}
|
|
217
219
|
let source;
|
|
218
220
|
let extVersion;
|
|
219
|
-
if (extensionsHelper_1.isLocalOrURLPath(extensionName)) {
|
|
221
|
+
if ((0, extensionsHelper_1.isLocalOrURLPath)(extensionName)) {
|
|
222
|
+
(0, track_1.track)("Extension Install", "Install by Source", options.interactive ? 1 : 0);
|
|
220
223
|
source = await infoInstallBySource(projectId, extensionName);
|
|
221
224
|
}
|
|
222
225
|
else {
|
|
223
|
-
|
|
226
|
+
(0, track_1.track)("Extension Install", "Install by Extension Ref", options.interactive ? 1 : 0);
|
|
227
|
+
extVersion = await infoInstallByReference(extensionName, options.interactive);
|
|
224
228
|
}
|
|
225
|
-
if (!(await extensionsHelper_1.confirm({
|
|
229
|
+
if (!(await (0, extensionsHelper_1.confirm)({
|
|
226
230
|
nonInteractive: options.nonInteractive,
|
|
227
231
|
force: options.force,
|
|
228
232
|
default: true,
|
package/lib/commands/ext-list.js
CHANGED
|
@@ -12,6 +12,6 @@ module.exports = new command_1.Command("ext:list")
|
|
|
12
12
|
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
13
13
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
14
14
|
.action((options) => {
|
|
15
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
16
|
-
return listExtensions_1.listExtensions(projectId);
|
|
15
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
+
return (0, listExtensions_1.listExtensions)(projectId);
|
|
17
17
|
});
|
|
@@ -16,8 +16,8 @@ exports.default = new command_1.Command("ext:sources:create <sourceLocation>")
|
|
|
16
16
|
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
17
17
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extDevMinVersion")
|
|
18
18
|
.action(async (sourceLocation, options) => {
|
|
19
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
20
|
-
const res = await extensionsHelper_1.createSourceFromLocation(projectId, sourceLocation);
|
|
19
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
20
|
+
const res = await (0, extensionsHelper_1.createSourceFromLocation)(projectId, sourceLocation);
|
|
21
21
|
logger_1.logger.info(`Extension source creation successful for ${res.spec.name}! Your new source is ${res.name}`);
|
|
22
22
|
return res;
|
|
23
23
|
});
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const _ = require("lodash");
|
|
4
4
|
const clc = require("cli-color");
|
|
5
5
|
const ora = require("ora");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
9
9
|
const command_1 = require("../command");
|
|
@@ -34,7 +34,7 @@ exports.default = new command_1.Command("ext:uninstall <extensionInstanceId>")
|
|
|
34
34
|
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
35
35
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
36
36
|
.action(async (instanceId, options) => {
|
|
37
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
37
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
38
38
|
let instance;
|
|
39
39
|
try {
|
|
40
40
|
instance = await extensionsApi.getInstance(projectId, instanceId);
|
|
@@ -72,7 +72,7 @@ exports.default = new command_1.Command("ext:uninstall <extensionInstanceId>")
|
|
|
72
72
|
`${resourcesMessage}` +
|
|
73
73
|
`${artifactsMessage}`;
|
|
74
74
|
logger_1.logger.info(extensionDeletionMessage);
|
|
75
|
-
const confirmedExtensionDeletion = await prompt_1.promptOnce({
|
|
75
|
+
const confirmedExtensionDeletion = await (0, prompt_1.promptOnce)({
|
|
76
76
|
type: "confirm",
|
|
77
77
|
default: true,
|
|
78
78
|
message: "Are you sure that you wish to uninstall this extension?",
|
|
@@ -81,7 +81,7 @@ exports.default = new command_1.Command("ext:uninstall <extensionInstanceId>")
|
|
|
81
81
|
return utils.reject("Command aborted.", { exit: 1 });
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
const spinner = ora
|
|
84
|
+
const spinner = ora(` ${clc.green.bold(extensionsHelper_1.logPrefix)}: uninstalling ${clc.bold(instanceId)}. This usually takes 1 to 2 minutes...`);
|
|
85
85
|
spinner.start();
|
|
86
86
|
try {
|
|
87
87
|
spinner.info();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const clc = require("cli-color");
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const marked = require("marked");
|
|
5
|
+
const { marked } = require("marked");
|
|
6
6
|
const ora = require("ora");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
@@ -47,9 +47,9 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
47
47
|
.withForce()
|
|
48
48
|
.option("--params <paramsFile>", "name of params variables file with .env format.")
|
|
49
49
|
.action(async (instanceId, updateSource, options) => {
|
|
50
|
-
const spinner = ora
|
|
50
|
+
const spinner = ora(`Updating ${clc.bold(instanceId)}. This usually takes 3 to 5 minutes...`);
|
|
51
51
|
try {
|
|
52
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
52
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
53
53
|
let existingInstance;
|
|
54
54
|
try {
|
|
55
55
|
existingInstance = await extensionsApi.getInstance(projectId, instanceId);
|
|
@@ -67,11 +67,11 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
67
67
|
const existingParams = existingInstance.config.params;
|
|
68
68
|
const existingSource = existingInstance.config.source.name;
|
|
69
69
|
if (existingInstance.config.extensionRef) {
|
|
70
|
-
updateSource = updateHelper_1.inferUpdateSource(updateSource, existingInstance.config.extensionRef);
|
|
70
|
+
updateSource = (0, updateHelper_1.inferUpdateSource)(updateSource, existingInstance.config.extensionRef);
|
|
71
71
|
}
|
|
72
72
|
let newSourceName;
|
|
73
|
-
const existingSourceOrigin = await updateHelper_1.getExistingSourceOrigin(projectId, instanceId, existingSpec.name, existingSource);
|
|
74
|
-
const newSourceOrigin = extensionsHelper_1.getSourceOrigin(updateSource);
|
|
73
|
+
const existingSourceOrigin = await (0, updateHelper_1.getExistingSourceOrigin)(projectId, instanceId, existingSpec.name, existingSource);
|
|
74
|
+
const newSourceOrigin = (0, extensionsHelper_1.getSourceOrigin)(updateSource);
|
|
75
75
|
const validUpdate = isValidUpdate(existingSourceOrigin, newSourceOrigin);
|
|
76
76
|
if (!validUpdate) {
|
|
77
77
|
throw new error_1.FirebaseError(`Cannot update from a(n) ${existingSourceOrigin} to a(n) ${newSourceOrigin}. Please provide a new source that is a(n) ${existingSourceOrigin} and try again.`);
|
|
@@ -79,24 +79,24 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
79
79
|
switch (newSourceOrigin) {
|
|
80
80
|
case extensionsHelper_1.SourceOrigin.LOCAL:
|
|
81
81
|
if (previews_1.previews.extdev) {
|
|
82
|
-
newSourceName = await updateHelper_1.updateFromLocalSource(projectId, instanceId, updateSource, existingSpec);
|
|
82
|
+
newSourceName = await (0, updateHelper_1.updateFromLocalSource)(projectId, instanceId, updateSource, existingSpec);
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
case extensionsHelper_1.SourceOrigin.URL:
|
|
86
86
|
if (previews_1.previews.extdev) {
|
|
87
|
-
newSourceName = await updateHelper_1.updateFromUrlSource(projectId, instanceId, updateSource, existingSpec);
|
|
87
|
+
newSourceName = await (0, updateHelper_1.updateFromUrlSource)(projectId, instanceId, updateSource, existingSpec);
|
|
88
88
|
break;
|
|
89
89
|
}
|
|
90
90
|
case extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION_VERSION:
|
|
91
|
-
newSourceName = await updateHelper_1.updateToVersionFromPublisherSource(projectId, instanceId, updateSource, existingSpec);
|
|
91
|
+
newSourceName = await (0, updateHelper_1.updateToVersionFromPublisherSource)(projectId, instanceId, updateSource, existingSpec);
|
|
92
92
|
break;
|
|
93
93
|
case extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION:
|
|
94
|
-
newSourceName = await updateHelper_1.updateFromPublisherSource(projectId, instanceId, updateSource, existingSpec);
|
|
94
|
+
newSourceName = await (0, updateHelper_1.updateFromPublisherSource)(projectId, instanceId, updateSource, existingSpec);
|
|
95
95
|
break;
|
|
96
96
|
default:
|
|
97
97
|
throw new error_1.FirebaseError(`Unknown source '${clc.bold(updateSource)}.'`);
|
|
98
98
|
}
|
|
99
|
-
if (!(await extensionsHelper_1.confirm({
|
|
99
|
+
if (!(await (0, extensionsHelper_1.confirm)({
|
|
100
100
|
nonInteractive: options.nonInteractive,
|
|
101
101
|
force: options.force,
|
|
102
102
|
default: true,
|
|
@@ -108,7 +108,7 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
108
108
|
if (![extensionsHelper_1.SourceOrigin.LOCAL, extensionsHelper_1.SourceOrigin.URL].includes(newSourceOrigin) &&
|
|
109
109
|
existingSpec.version === newSpec.version) {
|
|
110
110
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `${clc.bold(instanceId)} is already up to date. Its version is ${clc.bold(existingSpec.version)}.`);
|
|
111
|
-
const retry = await extensionsHelper_1.confirm({
|
|
111
|
+
const retry = await (0, extensionsHelper_1.confirm)({
|
|
112
112
|
nonInteractive: options.nonInteractive,
|
|
113
113
|
force: options.force,
|
|
114
114
|
default: false,
|
|
@@ -118,7 +118,7 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
await updateHelper_1.displayChanges({
|
|
121
|
+
await (0, updateHelper_1.displayChanges)({
|
|
122
122
|
spec: existingSpec,
|
|
123
123
|
newSpec: newSpec,
|
|
124
124
|
nonInteractive: options.nonInteractive,
|
|
@@ -127,9 +127,9 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
127
127
|
await provisioningHelper.checkProductsProvisioned(projectId, newSpec);
|
|
128
128
|
const usesSecrets = secretsUtils.usesSecrets(newSpec);
|
|
129
129
|
if (newSpec.billingRequired || usesSecrets) {
|
|
130
|
-
const enabled = await cloudbilling_1.checkBillingEnabled(projectId);
|
|
131
|
-
billingMigrationHelper_1.displayNode10UpdateBillingNotice(existingSpec, newSpec);
|
|
132
|
-
if (!(await extensionsHelper_1.confirm({
|
|
130
|
+
const enabled = await (0, cloudbilling_1.checkBillingEnabled)(projectId);
|
|
131
|
+
(0, billingMigrationHelper_1.displayNode10UpdateBillingNotice)(existingSpec, newSpec);
|
|
132
|
+
if (!(await (0, extensionsHelper_1.confirm)({
|
|
133
133
|
nonInteractive: options.nonInteractive,
|
|
134
134
|
force: options.force,
|
|
135
135
|
default: true,
|
|
@@ -138,7 +138,7 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
138
138
|
}
|
|
139
139
|
if (!enabled) {
|
|
140
140
|
if (!options.nonInteractive) {
|
|
141
|
-
await checkProjectBilling_1.enableBilling(projectId);
|
|
141
|
+
await (0, checkProjectBilling_1.enableBilling)(projectId);
|
|
142
142
|
}
|
|
143
143
|
else {
|
|
144
144
|
throw new error_1.FirebaseError("The extension requires your project to be upgraded to the Blaze plan. " +
|
|
@@ -174,7 +174,7 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
|
|
|
174
174
|
if (!_.isEqual(newParams, oldParamValues)) {
|
|
175
175
|
updateOptions.params = newParams;
|
|
176
176
|
}
|
|
177
|
-
await updateHelper_1.update(updateOptions);
|
|
177
|
+
await (0, updateHelper_1.update)(updateOptions);
|
|
178
178
|
spinner.stop();
|
|
179
179
|
utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `successfully updated ${clc.bold(instanceId)}.`);
|
|
180
180
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`You can view your updated instance in the Firebase console: ${utils.consoleUrl(projectId, `/extensions/instances/${instanceId}?tab=usage`)}`));
|
package/lib/commands/ext.js
CHANGED
|
@@ -31,9 +31,9 @@ module.exports = new command_1.Command("ext")
|
|
|
31
31
|
});
|
|
32
32
|
logger_1.logger.info();
|
|
33
33
|
try {
|
|
34
|
-
await requirePermissions_1.requirePermissions(options, ["firebaseextensions.instances.list"]);
|
|
35
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
36
|
-
return listExtensions_1.listExtensions(projectId);
|
|
34
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
35
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
36
|
+
return (0, listExtensions_1.listExtensions)(projectId);
|
|
37
37
|
}
|
|
38
38
|
catch (err) {
|
|
39
39
|
return;
|
|
@@ -66,7 +66,7 @@ module.exports = new command_1.Command("firestore:delete [path]")
|
|
|
66
66
|
shallow: options.shallow,
|
|
67
67
|
allCollections: options.allCollections,
|
|
68
68
|
});
|
|
69
|
-
const confirm = await prompt_1.promptOnce({
|
|
69
|
+
const confirm = await (0, prompt_1.promptOnce)({
|
|
70
70
|
type: "confirm",
|
|
71
71
|
name: "force",
|
|
72
72
|
default: false,
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const clc = require("cli-color");
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const functionsConfig = require("../functionsConfig");
|
|
10
|
+
const functionsConfigClone = require("../functionsConfigClone");
|
|
11
|
+
const utils = require("../utils");
|
|
12
|
+
exports.default = new command_1.Command("functions:config:clone")
|
|
11
13
|
.description("clone environment config from another project")
|
|
12
14
|
.option("--from <projectId>", "the project from which to clone configuration")
|
|
13
15
|
.option("--only <keys>", "a comma-separated list of keys to clone")
|
|
14
16
|
.option("--except <keys>", "a comma-separated list of keys to not clone")
|
|
15
|
-
.before(requirePermissions, [
|
|
17
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
16
18
|
"runtimeconfig.configs.list",
|
|
17
19
|
"runtimeconfig.configs.create",
|
|
18
20
|
"runtimeconfig.configs.get",
|
|
@@ -25,29 +27,26 @@ module.exports = new Command("functions:config:clone")
|
|
|
25
27
|
"runtimeconfig.variables.delete",
|
|
26
28
|
])
|
|
27
29
|
.before(functionsConfig.ensureApi)
|
|
28
|
-
.action(
|
|
29
|
-
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
30
32
|
if (!options.from) {
|
|
31
|
-
|
|
33
|
+
throw new error_1.FirebaseError(`Must specify a source project in ${clc.bold("--from <projectId>")} option.`);
|
|
32
34
|
}
|
|
33
35
|
else if (options.from === projectId) {
|
|
34
|
-
|
|
36
|
+
throw new error_1.FirebaseError("From project and destination can't be the same project.");
|
|
35
37
|
}
|
|
36
38
|
else if (options.only && options.except) {
|
|
37
|
-
|
|
39
|
+
throw new error_1.FirebaseError("Cannot use both --only and --except at the same time.");
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
let only = [];
|
|
42
|
+
let except = [];
|
|
41
43
|
if (options.only) {
|
|
42
44
|
only = options.only.split(",");
|
|
43
45
|
}
|
|
44
46
|
else if (options.except) {
|
|
45
47
|
except = options.except.split(",");
|
|
46
48
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
clc.bold("firebase deploy --only functions") +
|
|
51
|
-
"\n");
|
|
52
|
-
});
|
|
49
|
+
await functionsConfigClone(options.from, projectId, only, except);
|
|
50
|
+
utils.logSuccess(`Cloned functions config from ${clc.bold(options.from)} into ${clc.bold(projectId)}`);
|
|
51
|
+
logger_1.logger.info(`\nPlease deploy your functions for the change to take effect by running ${clc.bold("firebase deploy --only functions")}\n`);
|
|
53
52
|
});
|