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
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExtension = exports.deleteExtension = exports.unpublishExtension = exports.publishExtensionVersion = exports.undeprecateExtensionVersion = exports.deprecateExtensionVersion = exports.registerPublisherProfile = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = exports.ParamType = exports.Visibility = exports.RegistryLaunchStage = void 0;
|
|
3
|
+
exports.getExtension = exports.deleteExtension = exports.unpublishExtension = exports.publishExtensionVersion = exports.undeprecateExtensionVersion = exports.deprecateExtensionVersion = exports.registerPublisherProfile = exports.getPublisherProfile = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = exports.ParamType = exports.Visibility = exports.RegistryLaunchStage = void 0;
|
|
4
4
|
const yaml = require("js-yaml");
|
|
5
|
-
const _ = require("lodash");
|
|
6
5
|
const clc = require("cli-color");
|
|
7
|
-
const marked = require("marked");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const { marked } = require("marked");
|
|
7
|
+
const apiv2_1 = require("../apiv2");
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
const error_1 = require("../error");
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
11
|
const operationPoller = require("../operation-poller");
|
|
12
|
-
const
|
|
12
|
+
const refs = require("./refs");
|
|
13
13
|
const VERSION = "v1beta";
|
|
14
14
|
const PAGE_SIZE_MAX = 100;
|
|
15
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.extensionsOrigin, apiVersion: VERSION });
|
|
15
16
|
var RegistryLaunchStage;
|
|
16
17
|
(function (RegistryLaunchStage) {
|
|
17
18
|
RegistryLaunchStage["EXPERIMENTAL"] = "EXPERIMENTAL";
|
|
@@ -33,22 +34,19 @@ var ParamType;
|
|
|
33
34
|
ParamType["SECRET"] = "SECRET";
|
|
34
35
|
})(ParamType = exports.ParamType || (exports.ParamType = {}));
|
|
35
36
|
async function createInstanceHelper(projectId, instanceId, config, validateOnly = false) {
|
|
36
|
-
const createRes = await
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
query: {
|
|
44
|
-
validateOnly,
|
|
37
|
+
const createRes = await apiClient.post(`/projects/${projectId}/instances/`, {
|
|
38
|
+
name: `projects/${projectId}/instances/${instanceId}`,
|
|
39
|
+
config,
|
|
40
|
+
}, {
|
|
41
|
+
queryParams: {
|
|
42
|
+
validateOnly: validateOnly ? "true" : "false",
|
|
45
43
|
},
|
|
46
44
|
});
|
|
47
45
|
if (validateOnly) {
|
|
48
|
-
return createRes;
|
|
46
|
+
return createRes.body;
|
|
49
47
|
}
|
|
50
48
|
const pollRes = await operationPoller.pollOperation({
|
|
51
|
-
apiOrigin:
|
|
49
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
52
50
|
apiVersion: VERSION,
|
|
53
51
|
operationResourceName: createRes.body.name,
|
|
54
52
|
masterTimeout: 600000,
|
|
@@ -78,12 +76,9 @@ async function createInstance(args) {
|
|
|
78
76
|
}
|
|
79
77
|
exports.createInstance = createInstance;
|
|
80
78
|
async function deleteInstance(projectId, instanceId) {
|
|
81
|
-
const deleteRes = await
|
|
82
|
-
auth: true,
|
|
83
|
-
origin: api.extensionsOrigin,
|
|
84
|
-
});
|
|
79
|
+
const deleteRes = await apiClient.delete(`/projects/${projectId}/instances/${instanceId}`);
|
|
85
80
|
const pollRes = await operationPoller.pollOperation({
|
|
86
|
-
apiOrigin:
|
|
81
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
87
82
|
apiVersion: VERSION,
|
|
88
83
|
operationResourceName: deleteRes.body.name,
|
|
89
84
|
masterTimeout: 600000,
|
|
@@ -91,21 +86,16 @@ async function deleteInstance(projectId, instanceId) {
|
|
|
91
86
|
return pollRes;
|
|
92
87
|
}
|
|
93
88
|
exports.deleteInstance = deleteInstance;
|
|
94
|
-
async function getInstance(projectId, instanceId
|
|
95
|
-
const res = await
|
|
96
|
-
auth: true,
|
|
97
|
-
origin: api.extensionsOrigin,
|
|
98
|
-
}, options));
|
|
89
|
+
async function getInstance(projectId, instanceId) {
|
|
90
|
+
const res = await apiClient.get(`/projects/${projectId}/instances/${instanceId}`);
|
|
99
91
|
return res.body;
|
|
100
92
|
}
|
|
101
93
|
exports.getInstance = getInstance;
|
|
102
94
|
async function listInstances(projectId) {
|
|
103
95
|
const instances = [];
|
|
104
|
-
const getNextPage = async (pageToken) => {
|
|
105
|
-
const res = await
|
|
106
|
-
|
|
107
|
-
origin: api.extensionsOrigin,
|
|
108
|
-
query: {
|
|
96
|
+
const getNextPage = async (pageToken = "") => {
|
|
97
|
+
const res = await apiClient.get(`/projects/${projectId}/instances`, {
|
|
98
|
+
queryParams: {
|
|
109
99
|
pageSize: PAGE_SIZE_MAX,
|
|
110
100
|
pageToken,
|
|
111
101
|
},
|
|
@@ -182,20 +172,17 @@ async function updateInstanceFromRegistry(args) {
|
|
|
182
172
|
}
|
|
183
173
|
exports.updateInstanceFromRegistry = updateInstanceFromRegistry;
|
|
184
174
|
async function patchInstance(args) {
|
|
185
|
-
const updateRes = await
|
|
186
|
-
|
|
187
|
-
origin: api.extensionsOrigin,
|
|
188
|
-
query: {
|
|
175
|
+
const updateRes = await apiClient.patch(`/projects/${args.projectId}/instances/${args.instanceId}`, args.data, {
|
|
176
|
+
queryParams: {
|
|
189
177
|
updateMask: args.updateMask,
|
|
190
|
-
validateOnly: args.validateOnly,
|
|
178
|
+
validateOnly: args.validateOnly ? "true" : "false",
|
|
191
179
|
},
|
|
192
|
-
data: args.data,
|
|
193
180
|
});
|
|
194
181
|
if (args.validateOnly) {
|
|
195
182
|
return updateRes;
|
|
196
183
|
}
|
|
197
184
|
const pollRes = await operationPoller.pollOperation({
|
|
198
|
-
apiOrigin:
|
|
185
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
199
186
|
apiVersion: VERSION,
|
|
200
187
|
operationResourceName: updateRes.body.name,
|
|
201
188
|
masterTimeout: 600000,
|
|
@@ -217,16 +204,12 @@ function populateResourceProperties(spec) {
|
|
|
217
204
|
}
|
|
218
205
|
}
|
|
219
206
|
async function createSource(projectId, packageUri, extensionRoot) {
|
|
220
|
-
const createRes = await
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
data: {
|
|
224
|
-
packageUri,
|
|
225
|
-
extensionRoot,
|
|
226
|
-
},
|
|
207
|
+
const createRes = await apiClient.post(`/projects/${projectId}/sources/`, {
|
|
208
|
+
packageUri,
|
|
209
|
+
extensionRoot,
|
|
227
210
|
});
|
|
228
211
|
const pollRes = await operationPoller.pollOperation({
|
|
229
|
-
apiOrigin:
|
|
212
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
230
213
|
apiVersion: VERSION,
|
|
231
214
|
operationResourceName: createRes.body.name,
|
|
232
215
|
masterTimeout: 600000,
|
|
@@ -237,18 +220,12 @@ async function createSource(projectId, packageUri, extensionRoot) {
|
|
|
237
220
|
return pollRes;
|
|
238
221
|
}
|
|
239
222
|
exports.createSource = createSource;
|
|
240
|
-
function getSource(sourceName) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
.then((res) => {
|
|
247
|
-
if (res.body.spec) {
|
|
248
|
-
populateResourceProperties(res.body.spec);
|
|
249
|
-
}
|
|
250
|
-
return res.body;
|
|
251
|
-
});
|
|
223
|
+
async function getSource(sourceName) {
|
|
224
|
+
const res = await apiClient.get(`/${sourceName}`);
|
|
225
|
+
if (res.body.spec) {
|
|
226
|
+
populateResourceProperties(res.body.spec);
|
|
227
|
+
}
|
|
228
|
+
return res.body;
|
|
252
229
|
}
|
|
253
230
|
exports.getSource = getSource;
|
|
254
231
|
async function getExtensionVersion(extensionVersionRef) {
|
|
@@ -257,10 +234,7 @@ async function getExtensionVersion(extensionVersionRef) {
|
|
|
257
234
|
throw new error_1.FirebaseError(`ExtensionVersion ref "${extensionVersionRef}" must supply a version.`);
|
|
258
235
|
}
|
|
259
236
|
try {
|
|
260
|
-
const res = await
|
|
261
|
-
auth: true,
|
|
262
|
-
origin: api.extensionsOrigin,
|
|
263
|
-
});
|
|
237
|
+
const res = await apiClient.get(`/${refs.toExtensionVersionName(ref)}`);
|
|
264
238
|
if (res.body.spec) {
|
|
265
239
|
populateResourceProperties(res.body.spec);
|
|
266
240
|
}
|
|
@@ -279,12 +253,10 @@ async function getExtensionVersion(extensionVersionRef) {
|
|
|
279
253
|
exports.getExtensionVersion = getExtensionVersion;
|
|
280
254
|
async function listExtensions(publisherId) {
|
|
281
255
|
const extensions = [];
|
|
282
|
-
const getNextPage = async (pageToken) => {
|
|
283
|
-
const res = await
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
showUnpublished: false,
|
|
287
|
-
query: {
|
|
256
|
+
const getNextPage = async (pageToken = "") => {
|
|
257
|
+
const res = await apiClient.get(`/publishers/${publisherId}/extensions`, {
|
|
258
|
+
queryParams: {
|
|
259
|
+
showUnpublished: "false",
|
|
288
260
|
pageSize: PAGE_SIZE_MAX,
|
|
289
261
|
pageToken,
|
|
290
262
|
},
|
|
@@ -300,14 +272,12 @@ async function listExtensions(publisherId) {
|
|
|
300
272
|
return extensions;
|
|
301
273
|
}
|
|
302
274
|
exports.listExtensions = listExtensions;
|
|
303
|
-
async function listExtensionVersions(ref, filter) {
|
|
275
|
+
async function listExtensionVersions(ref, filter = "") {
|
|
304
276
|
const { publisherId, extensionId } = refs.parse(ref);
|
|
305
277
|
const extensionVersions = [];
|
|
306
|
-
const getNextPage = async (pageToken) => {
|
|
307
|
-
const res = await
|
|
308
|
-
|
|
309
|
-
origin: api.extensionsOrigin,
|
|
310
|
-
query: {
|
|
278
|
+
const getNextPage = async (pageToken = "") => {
|
|
279
|
+
const res = await apiClient.get(`/publishers/${publisherId}/extensions/${extensionId}/versions`, {
|
|
280
|
+
queryParams: {
|
|
311
281
|
filter,
|
|
312
282
|
pageSize: PAGE_SIZE_MAX,
|
|
313
283
|
pageToken,
|
|
@@ -324,11 +294,20 @@ async function listExtensionVersions(ref, filter) {
|
|
|
324
294
|
return extensionVersions;
|
|
325
295
|
}
|
|
326
296
|
exports.listExtensionVersions = listExtensionVersions;
|
|
297
|
+
async function getPublisherProfile(projectId, publisherId) {
|
|
298
|
+
const res = await apiClient.get(`/projects/${projectId}/publisherProfile`, {
|
|
299
|
+
queryParams: publisherId == undefined
|
|
300
|
+
? undefined
|
|
301
|
+
: {
|
|
302
|
+
publisherId,
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
return res.body;
|
|
306
|
+
}
|
|
307
|
+
exports.getPublisherProfile = getPublisherProfile;
|
|
327
308
|
async function registerPublisherProfile(projectId, publisherId) {
|
|
328
|
-
const res = await
|
|
329
|
-
|
|
330
|
-
origin: api.extensionsOrigin,
|
|
331
|
-
data: { publisherId },
|
|
309
|
+
const res = await apiClient.post(`/projects/${projectId}/publisherProfile:register`, {
|
|
310
|
+
publisherId,
|
|
332
311
|
});
|
|
333
312
|
return res.body;
|
|
334
313
|
}
|
|
@@ -336,10 +315,8 @@ exports.registerPublisherProfile = registerPublisherProfile;
|
|
|
336
315
|
async function deprecateExtensionVersion(extensionRef, deprecationMessage) {
|
|
337
316
|
const ref = refs.parse(extensionRef);
|
|
338
317
|
try {
|
|
339
|
-
const res = await
|
|
340
|
-
|
|
341
|
-
origin: api.extensionsOrigin,
|
|
342
|
-
data: { deprecationMessage },
|
|
318
|
+
const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:deprecate`, {
|
|
319
|
+
deprecationMessage,
|
|
343
320
|
});
|
|
344
321
|
return res.body;
|
|
345
322
|
}
|
|
@@ -362,10 +339,7 @@ exports.deprecateExtensionVersion = deprecateExtensionVersion;
|
|
|
362
339
|
async function undeprecateExtensionVersion(extensionRef) {
|
|
363
340
|
const ref = refs.parse(extensionRef);
|
|
364
341
|
try {
|
|
365
|
-
const res = await
|
|
366
|
-
auth: true,
|
|
367
|
-
origin: api.extensionsOrigin,
|
|
368
|
-
});
|
|
342
|
+
const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:undeprecate`);
|
|
369
343
|
return res.body;
|
|
370
344
|
}
|
|
371
345
|
catch (err) {
|
|
@@ -389,17 +363,13 @@ async function publishExtensionVersion(extensionVersionRef, packageUri, extensio
|
|
|
389
363
|
if (!ref.version) {
|
|
390
364
|
throw new error_1.FirebaseError(`ExtensionVersion ref "${extensionVersionRef}" must supply a version.`);
|
|
391
365
|
}
|
|
392
|
-
const publishRes = await
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
versionId: ref.version,
|
|
397
|
-
packageUri,
|
|
398
|
-
extensionRoot: extensionRoot !== null && extensionRoot !== void 0 ? extensionRoot : "/",
|
|
399
|
-
},
|
|
366
|
+
const publishRes = await apiClient.post(`/${refs.toExtensionName(ref)}/versions:publish`, {
|
|
367
|
+
versionId: ref.version,
|
|
368
|
+
packageUri,
|
|
369
|
+
extensionRoot: extensionRoot !== null && extensionRoot !== void 0 ? extensionRoot : "/",
|
|
400
370
|
});
|
|
401
371
|
const pollRes = await operationPoller.pollOperation({
|
|
402
|
-
apiOrigin:
|
|
372
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
403
373
|
apiVersion: VERSION,
|
|
404
374
|
operationResourceName: publishRes.body.name,
|
|
405
375
|
masterTimeout: 600000,
|
|
@@ -412,12 +382,8 @@ async function unpublishExtension(extensionRef) {
|
|
|
412
382
|
if (ref.version) {
|
|
413
383
|
throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
|
|
414
384
|
}
|
|
415
|
-
const url = `/${VERSION}/${refs.toExtensionName(ref)}:unpublish`;
|
|
416
385
|
try {
|
|
417
|
-
await
|
|
418
|
-
auth: true,
|
|
419
|
-
origin: api.extensionsOrigin,
|
|
420
|
-
});
|
|
386
|
+
await apiClient.post(`/${refs.toExtensionName(ref)}:unpublish`);
|
|
421
387
|
}
|
|
422
388
|
catch (err) {
|
|
423
389
|
if (err.status === 403) {
|
|
@@ -437,12 +403,8 @@ async function deleteExtension(extensionRef) {
|
|
|
437
403
|
if (ref.version) {
|
|
438
404
|
throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
|
|
439
405
|
}
|
|
440
|
-
const url = `/${VERSION}/${refs.toExtensionName(ref)}`;
|
|
441
406
|
try {
|
|
442
|
-
await
|
|
443
|
-
auth: true,
|
|
444
|
-
origin: api.extensionsOrigin,
|
|
445
|
-
});
|
|
407
|
+
await apiClient.delete(`/${refs.toExtensionName(ref)}`);
|
|
446
408
|
}
|
|
447
409
|
catch (err) {
|
|
448
410
|
if (err.status === 403) {
|
|
@@ -463,10 +425,7 @@ exports.deleteExtension = deleteExtension;
|
|
|
463
425
|
async function getExtension(extensionRef) {
|
|
464
426
|
const ref = refs.parse(extensionRef);
|
|
465
427
|
try {
|
|
466
|
-
const res = await
|
|
467
|
-
auth: true,
|
|
468
|
-
origin: api.extensionsOrigin,
|
|
469
|
-
});
|
|
428
|
+
const res = await apiClient.get(`/${refs.toExtensionName(ref)}`);
|
|
470
429
|
return res.body;
|
|
471
430
|
}
|
|
472
431
|
catch (err) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.confirm = exports.getSourceOrigin = exports.isLocalOrURLPath = exports.isLocalPath = exports.isUrlPath = exports.instanceIdExists = exports.promptForRepeatInstance = exports.promptForOfficialExtension = exports.displayReleaseNotes = exports.getExtensionSourceFromName = exports.createSourceFromLocation = exports.publishExtensionVersionFromLocalSource = exports.ensureExtensionsApiEnabled = exports.promptForValidInstanceId = exports.validateSpec = exports.validateCommandLineParams = exports.populateDefaultParams = exports.substituteParams = exports.getFirebaseProjectParams = exports.getDBInstanceFromURL = exports.resourceTypeToNiceName = exports.AUTOPOULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.URL_REGEX = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
|
|
3
|
+
exports.confirm = exports.getSourceOrigin = exports.isLocalOrURLPath = exports.isLocalPath = exports.isUrlPath = exports.instanceIdExists = exports.promptForRepeatInstance = exports.promptForOfficialExtension = exports.displayReleaseNotes = exports.getPublisherProjectFromName = exports.getExtensionSourceFromName = exports.createSourceFromLocation = exports.publishExtensionVersionFromLocalSource = exports.ensureExtensionsApiEnabled = exports.promptForValidInstanceId = exports.validateSpec = exports.validateCommandLineParams = exports.populateDefaultParams = exports.substituteParams = exports.getFirebaseProjectParams = exports.getDBInstanceFromURL = exports.resourceTypeToNiceName = exports.AUTOPOULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.URL_REGEX = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
6
|
const ora = require("ora");
|
|
7
7
|
const semver = require("semver");
|
|
8
|
-
const marked = require("marked");
|
|
8
|
+
const { marked } = require("marked");
|
|
9
9
|
const TerminalRenderer = require("marked-terminal");
|
|
10
10
|
marked.setOptions({
|
|
11
11
|
renderer: new TerminalRenderer(),
|
|
@@ -48,7 +48,7 @@ var SourceOrigin;
|
|
|
48
48
|
exports.logPrefix = "extensions";
|
|
49
49
|
const VALID_LICENSES = ["apache-2.0"];
|
|
50
50
|
exports.URL_REGEX = /^https:/;
|
|
51
|
-
exports.EXTENSIONS_BUCKET_NAME = utils_2.envOverride("FIREBASE_EXTENSIONS_UPLOAD_BUCKET", "firebase-ext-eap-uploads");
|
|
51
|
+
exports.EXTENSIONS_BUCKET_NAME = (0, utils_2.envOverride)("FIREBASE_EXTENSIONS_UPLOAD_BUCKET", "firebase-ext-eap-uploads");
|
|
52
52
|
const AUTOPOPULATED_PARAM_NAMES = [
|
|
53
53
|
"PROJECT_ID",
|
|
54
54
|
"STORAGE_BUCKET",
|
|
@@ -68,7 +68,7 @@ exports.resourceTypeToNiceName = {
|
|
|
68
68
|
};
|
|
69
69
|
function getDBInstanceFromURL(databaseUrl = "") {
|
|
70
70
|
const instanceRegex = new RegExp("(?:https://)(.*)(?:.firebaseio.com)");
|
|
71
|
-
const matches =
|
|
71
|
+
const matches = instanceRegex.exec(databaseUrl);
|
|
72
72
|
if (matches && matches.length > 1) {
|
|
73
73
|
return matches[1];
|
|
74
74
|
}
|
|
@@ -76,8 +76,8 @@ function getDBInstanceFromURL(databaseUrl = "") {
|
|
|
76
76
|
}
|
|
77
77
|
exports.getDBInstanceFromURL = getDBInstanceFromURL;
|
|
78
78
|
async function getFirebaseProjectParams(projectId) {
|
|
79
|
-
const body = await functionsConfig_1.getFirebaseConfig({ project: projectId });
|
|
80
|
-
const projectNumber = await getProjectNumber_1.getProjectNumber({ projectId });
|
|
79
|
+
const body = await (0, functionsConfig_1.getFirebaseConfig)({ project: projectId });
|
|
80
|
+
const projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId });
|
|
81
81
|
const FIREBASE_CONFIG = JSON.stringify({
|
|
82
82
|
projectId: body.projectId,
|
|
83
83
|
databaseURL: body.databaseURL,
|
|
@@ -134,7 +134,7 @@ function validateCommandLineParams(envVars, paramSpec) {
|
|
|
134
134
|
}
|
|
135
135
|
let allParamsValid = true;
|
|
136
136
|
for (const param of paramSpec) {
|
|
137
|
-
if (!askUserForParam_1.checkResponse(envVars[param.param], param)) {
|
|
137
|
+
if (!(0, askUserForParam_1.checkResponse)(envVars[param.param], param)) {
|
|
138
138
|
allParamsValid = false;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -233,7 +233,7 @@ async function promptForValidInstanceId(instanceId) {
|
|
|
233
233
|
let newInstanceId = "";
|
|
234
234
|
const instanceIdRegex = /^[a-z][a-z\d\-]*[a-z\d]$/;
|
|
235
235
|
while (!instanceIdIsValid) {
|
|
236
|
-
newInstanceId = await prompt_1.promptOnce({
|
|
236
|
+
newInstanceId = await (0, prompt_1.promptOnce)({
|
|
237
237
|
type: "input",
|
|
238
238
|
default: instanceId,
|
|
239
239
|
message: `Please enter a new name for this instance:`,
|
|
@@ -253,20 +253,20 @@ async function promptForValidInstanceId(instanceId) {
|
|
|
253
253
|
}
|
|
254
254
|
exports.promptForValidInstanceId = promptForValidInstanceId;
|
|
255
255
|
async function ensureExtensionsApiEnabled(options) {
|
|
256
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
257
|
-
return await ensureApiEnabled_1.ensure(projectId, "firebaseextensions.googleapis.com", "extensions", options.markdown);
|
|
256
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
257
|
+
return await (0, ensureApiEnabled_1.ensure)(projectId, "firebaseextensions.googleapis.com", "extensions", options.markdown);
|
|
258
258
|
}
|
|
259
259
|
exports.ensureExtensionsApiEnabled = ensureExtensionsApiEnabled;
|
|
260
260
|
async function archiveAndUploadSource(extPath, bucketName) {
|
|
261
|
-
const zippedSource = await archiveDirectory_1.archiveDirectory(extPath, {
|
|
261
|
+
const zippedSource = await (0, archiveDirectory_1.archiveDirectory)(extPath, {
|
|
262
262
|
type: "zip",
|
|
263
263
|
ignore: ["node_modules", ".git"],
|
|
264
264
|
});
|
|
265
|
-
const res = await storage_1.uploadObject(zippedSource, bucketName);
|
|
265
|
+
const res = await (0, storage_1.uploadObject)(zippedSource, bucketName);
|
|
266
266
|
return `/${res.bucket}/${res.object}`;
|
|
267
267
|
}
|
|
268
268
|
async function publishExtensionVersionFromLocalSource(args) {
|
|
269
|
-
const extensionSpec = await localHelper_1.getLocalExtensionSpec(args.rootDirectory);
|
|
269
|
+
const extensionSpec = await (0, localHelper_1.getLocalExtensionSpec)(args.rootDirectory);
|
|
270
270
|
if (extensionSpec.name != args.extensionId) {
|
|
271
271
|
throw new error_1.FirebaseError(`Extension ID '${clc.bold(args.extensionId)}' does not match the name in extension.yaml '${clc.bold(extensionSpec.name)}'.`);
|
|
272
272
|
}
|
|
@@ -275,13 +275,13 @@ async function publishExtensionVersionFromLocalSource(args) {
|
|
|
275
275
|
validateSpec(subbedSpec);
|
|
276
276
|
let extension;
|
|
277
277
|
try {
|
|
278
|
-
extension = await extensionsApi_1.getExtension(`${args.publisherId}/${args.extensionId}`);
|
|
278
|
+
extension = await (0, extensionsApi_1.getExtension)(`${args.publisherId}/${args.extensionId}`);
|
|
279
279
|
}
|
|
280
280
|
catch (err) {
|
|
281
281
|
}
|
|
282
282
|
let notes;
|
|
283
283
|
try {
|
|
284
|
-
const changes = changelog_1.getLocalChangelog(args.rootDirectory);
|
|
284
|
+
const changes = (0, changelog_1.getLocalChangelog)(args.rootDirectory);
|
|
285
285
|
notes = changes[extensionSpec.version];
|
|
286
286
|
}
|
|
287
287
|
catch (err) {
|
|
@@ -315,7 +315,7 @@ async function publishExtensionVersionFromLocalSource(args) {
|
|
|
315
315
|
const ref = `${args.publisherId}/${args.extensionId}@${extensionSpec.version}`;
|
|
316
316
|
let packageUri;
|
|
317
317
|
let objectPath = "";
|
|
318
|
-
const uploadSpinner = ora
|
|
318
|
+
const uploadSpinner = ora(" Archiving and uploading extension source code");
|
|
319
319
|
try {
|
|
320
320
|
uploadSpinner.start();
|
|
321
321
|
objectPath = await archiveAndUploadSource(args.rootDirectory, exports.EXTENSIONS_BUCKET_NAME);
|
|
@@ -326,11 +326,11 @@ async function publishExtensionVersionFromLocalSource(args) {
|
|
|
326
326
|
uploadSpinner.fail();
|
|
327
327
|
throw err;
|
|
328
328
|
}
|
|
329
|
-
const publishSpinner = ora
|
|
329
|
+
const publishSpinner = ora(`Publishing ${clc.bold(ref)}`);
|
|
330
330
|
let res;
|
|
331
331
|
try {
|
|
332
332
|
publishSpinner.start();
|
|
333
|
-
res = await extensionsApi_1.publishExtensionVersion(ref, packageUri);
|
|
333
|
+
res = await (0, extensionsApi_1.publishExtensionVersion)(ref, packageUri);
|
|
334
334
|
publishSpinner.succeed(` Successfully published ${clc.bold(ref)}`);
|
|
335
335
|
}
|
|
336
336
|
catch (err) {
|
|
@@ -348,8 +348,8 @@ async function createSourceFromLocation(projectId, sourceUri) {
|
|
|
348
348
|
let packageUri;
|
|
349
349
|
let extensionRoot;
|
|
350
350
|
let objectPath = "";
|
|
351
|
-
if (!
|
|
352
|
-
const uploadSpinner = ora
|
|
351
|
+
if (!sourceUri.startsWith("https:")) {
|
|
352
|
+
const uploadSpinner = ora(" Archiving and uploading extension source code");
|
|
353
353
|
try {
|
|
354
354
|
uploadSpinner.start();
|
|
355
355
|
objectPath = await archiveAndUploadSource(sourceUri, exports.EXTENSIONS_BUCKET_NAME);
|
|
@@ -365,7 +365,7 @@ async function createSourceFromLocation(projectId, sourceUri) {
|
|
|
365
365
|
else {
|
|
366
366
|
[packageUri, extensionRoot] = sourceUri.split("#");
|
|
367
367
|
}
|
|
368
|
-
const res = await extensionsApi_1.createSource(projectId, packageUri, extensionRoot);
|
|
368
|
+
const res = await (0, extensionsApi_1.createSource)(projectId, packageUri, extensionRoot);
|
|
369
369
|
logger_1.logger.debug("Created new Extension Source %s", res.name);
|
|
370
370
|
await deleteUploadedSource(objectPath);
|
|
371
371
|
return res;
|
|
@@ -374,7 +374,7 @@ exports.createSourceFromLocation = createSourceFromLocation;
|
|
|
374
374
|
async function deleteUploadedSource(objectPath) {
|
|
375
375
|
if (objectPath.length) {
|
|
376
376
|
try {
|
|
377
|
-
await storage_1.deleteObject(objectPath);
|
|
377
|
+
await (0, storage_1.deleteObject)(objectPath);
|
|
378
378
|
logger_1.logger.debug("Cleaned up uploaded source archive");
|
|
379
379
|
}
|
|
380
380
|
catch (err) {
|
|
@@ -387,17 +387,26 @@ async function getExtensionSourceFromName(extensionName) {
|
|
|
387
387
|
const existingSourceRegex = /projects\/.+\/sources\/.+/;
|
|
388
388
|
if (officialExtensionRegex.test(extensionName)) {
|
|
389
389
|
const [name, version] = extensionName.split("@");
|
|
390
|
-
const registryEntry = await resolveSource_1.resolveRegistryEntry(name);
|
|
391
|
-
const sourceUrl = resolveSource_1.resolveSourceUrl(registryEntry, name, version);
|
|
392
|
-
return await extensionsApi_1.getSource(sourceUrl);
|
|
390
|
+
const registryEntry = await (0, resolveSource_1.resolveRegistryEntry)(name);
|
|
391
|
+
const sourceUrl = (0, resolveSource_1.resolveSourceUrl)(registryEntry, name, version);
|
|
392
|
+
return await (0, extensionsApi_1.getSource)(sourceUrl);
|
|
393
393
|
}
|
|
394
394
|
else if (existingSourceRegex.test(extensionName)) {
|
|
395
395
|
logger_1.logger.info(`Fetching the source "${extensionName}"...`);
|
|
396
|
-
return await extensionsApi_1.getSource(extensionName);
|
|
396
|
+
return await (0, extensionsApi_1.getSource)(extensionName);
|
|
397
397
|
}
|
|
398
398
|
throw new error_1.FirebaseError(`Could not find an extension named '${extensionName}'. `);
|
|
399
399
|
}
|
|
400
400
|
exports.getExtensionSourceFromName = getExtensionSourceFromName;
|
|
401
|
+
function getPublisherProjectFromName(publisherName) {
|
|
402
|
+
const publisherNameRegex = /projects\/.+\/publisherProfile/;
|
|
403
|
+
if (publisherNameRegex.test(publisherName)) {
|
|
404
|
+
const [_, projectNumber, __] = publisherName.split("/");
|
|
405
|
+
return Number.parseInt(projectNumber);
|
|
406
|
+
}
|
|
407
|
+
throw new error_1.FirebaseError(`Could not find publisher with name '${publisherName}'.`);
|
|
408
|
+
}
|
|
409
|
+
exports.getPublisherProjectFromName = getPublisherProjectFromName;
|
|
401
410
|
function displayReleaseNotes(publisherId, extensionId, versionId, releaseNotes) {
|
|
402
411
|
const releaseNotesMessage = releaseNotes
|
|
403
412
|
? ` Release notes for this version:\n${marked(releaseNotes)}\n`
|
|
@@ -408,12 +417,12 @@ function displayReleaseNotes(publisherId, extensionId, versionId, releaseNotes)
|
|
|
408
417
|
}
|
|
409
418
|
exports.displayReleaseNotes = displayReleaseNotes;
|
|
410
419
|
async function promptForOfficialExtension(message) {
|
|
411
|
-
const officialExts = await resolveSource_1.getExtensionRegistry(true);
|
|
412
|
-
return await prompt_1.promptOnce({
|
|
420
|
+
const officialExts = await (0, resolveSource_1.getExtensionRegistry)(true);
|
|
421
|
+
return await (0, prompt_1.promptOnce)({
|
|
413
422
|
name: "input",
|
|
414
423
|
type: "list",
|
|
415
424
|
message,
|
|
416
|
-
choices: utils_1.convertOfficialExtensionsToList(officialExts),
|
|
425
|
+
choices: (0, utils_1.convertOfficialExtensionsToList)(officialExts),
|
|
417
426
|
pageSize: _.size(officialExts),
|
|
418
427
|
});
|
|
419
428
|
}
|
|
@@ -425,7 +434,7 @@ async function promptForRepeatInstance(projectName, extensionName) {
|
|
|
425
434
|
{ name: "Install a new instance with a different ID", value: "installNew" },
|
|
426
435
|
{ name: "Cancel extension installation", value: "cancel" },
|
|
427
436
|
];
|
|
428
|
-
return await prompt_1.promptOnce({
|
|
437
|
+
return await (0, prompt_1.promptOnce)({
|
|
429
438
|
type: "list",
|
|
430
439
|
message,
|
|
431
440
|
choices,
|
|
@@ -433,24 +442,28 @@ async function promptForRepeatInstance(projectName, extensionName) {
|
|
|
433
442
|
}
|
|
434
443
|
exports.promptForRepeatInstance = promptForRepeatInstance;
|
|
435
444
|
async function instanceIdExists(projectId, instanceId) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
if (
|
|
441
|
-
|
|
445
|
+
try {
|
|
446
|
+
await (0, extensionsApi_1.getInstance)(projectId, instanceId);
|
|
447
|
+
}
|
|
448
|
+
catch (err) {
|
|
449
|
+
if (err instanceof error_1.FirebaseError) {
|
|
450
|
+
if (err.status === 404) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
const msg = `Unexpected error when checking if instance ID exists: ${err}`;
|
|
454
|
+
throw new error_1.FirebaseError(msg, {
|
|
455
|
+
original: err,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
throw err;
|
|
442
460
|
}
|
|
443
|
-
const msg = "Unexpected error when checking if instance ID exists: " +
|
|
444
|
-
_.get(instanceRes, "error.message");
|
|
445
|
-
throw new error_1.FirebaseError(msg, {
|
|
446
|
-
original: instanceRes.error,
|
|
447
|
-
});
|
|
448
461
|
}
|
|
449
462
|
return true;
|
|
450
463
|
}
|
|
451
464
|
exports.instanceIdExists = instanceIdExists;
|
|
452
465
|
function isUrlPath(extInstallPath) {
|
|
453
|
-
return
|
|
466
|
+
return extInstallPath.startsWith("https:");
|
|
454
467
|
}
|
|
455
468
|
exports.isUrlPath = isUrlPath;
|
|
456
469
|
function isLocalPath(extInstallPath) {
|
|
@@ -493,7 +506,7 @@ exports.getSourceOrigin = getSourceOrigin;
|
|
|
493
506
|
async function confirm(args) {
|
|
494
507
|
if (!args.nonInteractive && !args.force) {
|
|
495
508
|
const message = `Do you wish to continue?`;
|
|
496
|
-
return await prompt_1.promptOnce({
|
|
509
|
+
return await (0, prompt_1.promptOnce)({
|
|
497
510
|
type: "confirm",
|
|
498
511
|
message,
|
|
499
512
|
default: args.default,
|
|
@@ -9,7 +9,7 @@ const extensionsHelper_1 = require("./extensionsHelper");
|
|
|
9
9
|
const utils = require("../utils");
|
|
10
10
|
const extensionsUtils = require("./utils");
|
|
11
11
|
async function listExtensions(projectId) {
|
|
12
|
-
const instances = await extensionsApi_1.listInstances(projectId);
|
|
12
|
+
const instances = await (0, extensionsApi_1.listInstances)(projectId);
|
|
13
13
|
if (instances.length < 1) {
|
|
14
14
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `there are no extensions installed on project ${clc.bold(projectId)}.`);
|
|
15
15
|
return [];
|
|
@@ -22,7 +22,7 @@ async function getLocalExtensionSpec(directory) {
|
|
|
22
22
|
}
|
|
23
23
|
exports.getLocalExtensionSpec = getLocalExtensionSpec;
|
|
24
24
|
function findExtensionYaml(directory) {
|
|
25
|
-
while (!fsutils_1.fileExistsSync(path.resolve(directory, EXTENSIONS_SPEC_FILE))) {
|
|
25
|
+
while (!(0, fsutils_1.fileExistsSync)(path.resolve(directory, EXTENSIONS_SPEC_FILE))) {
|
|
26
26
|
const parentDir = path.dirname(directory);
|
|
27
27
|
if (parentDir === directory) {
|
|
28
28
|
throw new error_1.FirebaseError("Couldn't find an extension.yaml file. Check that you are in the root directory of your extension.");
|