firebase-tools-with-isolate 13.15.0-0 → 13.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/deploy.js +3 -1
- package/lib/dataconnect/client.js +2 -1
- package/lib/dataconnect/fileUtils.js +52 -11
- package/lib/dataconnect/provisionCloudSql.js +5 -1
- package/lib/deploy/extensions/planner.js +52 -1
- package/lib/deploy/extensions/prepare.js +98 -23
- package/lib/deploy/extensions/release.js +6 -0
- package/lib/deploy/functions/build.js +5 -5
- package/lib/deploy/functions/deploy.js +12 -12
- package/lib/deploy/functions/params.js +5 -3
- package/lib/deploy/functions/prepare.js +8 -1
- package/lib/deploy/functions/release/index.js +4 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
- package/lib/emulator/constants.js +7 -0
- package/lib/emulator/controller.js +11 -1
- package/lib/emulator/downloadableEmulators.js +12 -12
- package/lib/emulator/env.js +3 -0
- package/lib/emulator/functionsEmulator.js +30 -1
- package/lib/emulator/functionsEmulatorShared.js +16 -0
- package/lib/emulator/portUtils.js +1 -0
- package/lib/emulator/registry.js +1 -0
- package/lib/emulator/taskQueue.js +348 -0
- package/lib/emulator/tasksEmulator.js +237 -0
- package/lib/emulator/types.js +3 -0
- package/lib/extensions/askUserForEventsConfig.js +18 -8
- package/lib/extensions/askUserForParam.js +2 -1
- package/lib/extensions/displayExtensionInfo.js +5 -5
- package/lib/extensions/extensionsApi.js +1 -1
- package/lib/extensions/extensionsHelper.js +25 -3
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/refs.js +26 -11
- package/lib/extensions/runtimes/common.js +75 -0
- package/lib/extensions/types.js +56 -1
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/next/constants.js +1 -1
- package/lib/frameworks/next/index.js +35 -15
- package/lib/frameworks/next/utils.js +51 -1
- package/lib/init/features/dataconnect/index.js +14 -8
- package/lib/init/features/dataconnect/sdk.js +64 -48
- package/lib/prompt.js +22 -1
- package/package.json +3 -3
- package/schema/firebase-config.json +12 -0
- package/templates/init/dataconnect/connector.yaml +5 -3
- package/templates/init/dataconnect/dataconnect.yaml +5 -5
- package/templates/init/dataconnect/mutations.gql +44 -29
- package/templates/init/dataconnect/queries.gql +66 -38
- package/templates/init/dataconnect/schema.gql +38 -21
package/lib/commands/deploy.js
CHANGED
|
@@ -80,7 +80,9 @@ exports.command = new command_1.Command("deploy")
|
|
|
80
80
|
.option("--only <targets>", 'only deploy to specified, comma-separated targets (e.g. "hosting,storage"). For functions, ' +
|
|
81
81
|
'can specify filters with colons to scope function deploys to only those functions (e.g. "--only functions:func1,functions:func2"). ' +
|
|
82
82
|
"When filtering based on export groups (the exported module object keys), use dots to specify group names " +
|
|
83
|
-
'(e.g. "--only functions:group1.subgroup1,functions:group2)
|
|
83
|
+
'(e.g. "--only functions:group1.subgroup1,functions:group2"). ' +
|
|
84
|
+
"When filtering based on codebases, use colons to specify codebase names " +
|
|
85
|
+
'(e.g. "--only functions:codebase1:func1,functions:codebase2:group1.subgroup1"). ' +
|
|
84
86
|
"For data connect, can specify filters with colons to deploy only a service, connector, or schema" +
|
|
85
87
|
'(e.g. "--only dataconnect:serviceId,dataconnect:serviceId:connectorId,dataconnect:serviceId:schema"). ')
|
|
86
88
|
.option("--except <targets>", 'deploy to all targets except specified (e.g. "database")')
|
|
@@ -121,13 +121,14 @@ async function deleteConnector(name) {
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
exports.deleteConnector = deleteConnector;
|
|
124
|
-
async function listConnectors(serviceName) {
|
|
124
|
+
async function listConnectors(serviceName, fields = []) {
|
|
125
125
|
const connectors = [];
|
|
126
126
|
const getNextPage = async (pageToken = "") => {
|
|
127
127
|
const res = await dataconnectClient().get(`${serviceName}/connectors`, {
|
|
128
128
|
queryParams: {
|
|
129
129
|
pageSize: PAGE_SIZE_MAX,
|
|
130
130
|
pageToken,
|
|
131
|
+
fields: fields.join(","),
|
|
131
132
|
},
|
|
132
133
|
});
|
|
133
134
|
connectors.push(...(res.body.connectors || []));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPlatformFromFolder = exports.pickService = exports.readGQLFiles = exports.readConnectorYaml = exports.readDataConnectYaml = exports.readFirebaseJson = void 0;
|
|
3
|
+
exports.generateSdkYaml = exports.directoryHasPackageJson = exports.getPlatformFromFolder = exports.pickService = exports.readGQLFiles = exports.readConnectorYaml = exports.readDataConnectYaml = exports.readFirebaseJson = void 0;
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const error_1 = require("../error");
|
|
@@ -95,21 +95,62 @@ async function pickService(projectId, config, serviceId) {
|
|
|
95
95
|
exports.pickService = pickService;
|
|
96
96
|
const WEB_INDICATORS = ["package.json", "package-lock.json", "node_modules"];
|
|
97
97
|
const IOS_INDICATORS = ["info.plist", "podfile", "package.swift"];
|
|
98
|
-
const ANDROID_INDICATORS = ["androidmanifest.xml", "build.gradle"];
|
|
99
|
-
const
|
|
98
|
+
const ANDROID_INDICATORS = ["androidmanifest.xml", "build.gradle", "build.gradle.kts"];
|
|
99
|
+
const IOS_POSTFIX_INDICATORS = [".xcworkspace", ".xcodeproj"];
|
|
100
100
|
async function getPlatformFromFolder(dirPath) {
|
|
101
101
|
const fileNames = await fs.readdir(dirPath);
|
|
102
|
+
let hasWeb = false;
|
|
103
|
+
let hasAndroid = false;
|
|
104
|
+
let hasIOS = false;
|
|
102
105
|
for (const fileName of fileNames) {
|
|
103
106
|
const cleanedFileName = fileName.toLowerCase();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
hasWeb || (hasWeb = WEB_INDICATORS.some((indicator) => indicator === cleanedFileName));
|
|
108
|
+
hasAndroid || (hasAndroid = ANDROID_INDICATORS.some((indicator) => indicator === cleanedFileName));
|
|
109
|
+
hasIOS || (hasIOS = IOS_INDICATORS.some((indicator) => indicator === cleanedFileName) ||
|
|
110
|
+
IOS_POSTFIX_INDICATORS.some((indicator) => cleanedFileName.endsWith(indicator)));
|
|
111
|
+
}
|
|
112
|
+
if (hasWeb && !hasAndroid && !hasIOS) {
|
|
113
|
+
return types_1.Platform.WEB;
|
|
114
|
+
}
|
|
115
|
+
else if (hasAndroid && !hasWeb && !hasIOS) {
|
|
116
|
+
return types_1.Platform.ANDROID;
|
|
117
|
+
}
|
|
118
|
+
else if (hasIOS && !hasWeb && !hasAndroid) {
|
|
119
|
+
return types_1.Platform.IOS;
|
|
112
120
|
}
|
|
113
121
|
return types_1.Platform.UNDETERMINED;
|
|
114
122
|
}
|
|
115
123
|
exports.getPlatformFromFolder = getPlatformFromFolder;
|
|
124
|
+
async function directoryHasPackageJson(dirPath) {
|
|
125
|
+
const fileNames = await fs.readdir(dirPath);
|
|
126
|
+
return fileNames.some((f) => f.toLowerCase() === "package.json");
|
|
127
|
+
}
|
|
128
|
+
exports.directoryHasPackageJson = directoryHasPackageJson;
|
|
129
|
+
function generateSdkYaml(platform, connectorYaml, connectorYamlFolder, appFolder) {
|
|
130
|
+
const relPath = path.relative(connectorYamlFolder, appFolder);
|
|
131
|
+
const outputDir = path.join(relPath, "dataconnect-generated");
|
|
132
|
+
if (!connectorYaml.generate) {
|
|
133
|
+
connectorYaml.generate = {};
|
|
134
|
+
}
|
|
135
|
+
if (platform === types_1.Platform.WEB) {
|
|
136
|
+
connectorYaml.generate.javascriptSdk = {
|
|
137
|
+
outputDir,
|
|
138
|
+
package: `@firebasegen/${connectorYaml.connectorId}`,
|
|
139
|
+
packageJsonDir: appFolder,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (platform === types_1.Platform.IOS) {
|
|
143
|
+
connectorYaml.generate.swiftSdk = {
|
|
144
|
+
outputDir,
|
|
145
|
+
package: connectorYaml.connectorId,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (platform === types_1.Platform.ANDROID) {
|
|
149
|
+
connectorYaml.generate.kotlinSdk = {
|
|
150
|
+
outputDir,
|
|
151
|
+
package: `connectors.${connectorYaml.connectorId}`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return connectorYaml;
|
|
155
|
+
}
|
|
156
|
+
exports.generateSdkYaml = generateSdkYaml;
|
|
@@ -5,6 +5,7 @@ const cloudSqlAdminClient = require("../gcp/cloudsql/cloudsqladmin");
|
|
|
5
5
|
const utils = require("../utils");
|
|
6
6
|
const checkIam_1 = require("./checkIam");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
8
9
|
const GOOGLE_ML_INTEGRATION_ROLE = "roles/aiplatform.user";
|
|
9
10
|
const freeTrial_1 = require("./freeTrial");
|
|
10
11
|
const error_1 = require("../error");
|
|
@@ -44,7 +45,9 @@ async function provisionCloudSql(args) {
|
|
|
44
45
|
connectionName = newInstance?.connectionName || "";
|
|
45
46
|
}
|
|
46
47
|
else {
|
|
47
|
-
silent ||
|
|
48
|
+
silent ||
|
|
49
|
+
utils.logLabeledBullet("dataconnect", "Cloud SQL instance creation started - it should be ready shortly. Database and users will be created on your next deploy.");
|
|
50
|
+
return connectionName;
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
try {
|
|
@@ -59,6 +62,7 @@ async function provisionCloudSql(args) {
|
|
|
59
62
|
silent || utils.logLabeledBullet("dataconnect", `Database ${databaseId} created.`);
|
|
60
63
|
}
|
|
61
64
|
else {
|
|
65
|
+
logger_1.logger.debug(`Unexpected error from CloudSQL: ${err}`);
|
|
62
66
|
silent || utils.logLabeledWarning("dataconnect", `Database ${databaseId} is not accessible.`);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveVersion = exports.want = exports.have = exports.getExtensionSpec = exports.getExtension = exports.getExtensionVersion = void 0;
|
|
3
|
+
exports.resolveVersion = exports.want = exports.wantDynamic = exports.have = exports.getExtensionSpec = exports.getExtension = exports.getExtensionVersion = void 0;
|
|
4
4
|
const semver = require("semver");
|
|
5
5
|
const extensionsApi = require("../../extensions/extensionsApi");
|
|
6
6
|
const refs = require("../../extensions/refs");
|
|
@@ -11,6 +11,7 @@ const manifest_1 = require("../../extensions/manifest");
|
|
|
11
11
|
const paramHelper_1 = require("../../extensions/paramHelper");
|
|
12
12
|
const specHelper_1 = require("../../extensions/emulator/specHelper");
|
|
13
13
|
const functional_1 = require("../../functional");
|
|
14
|
+
const askUserForEventsConfig_1 = require("../../extensions/askUserForEventsConfig");
|
|
14
15
|
async function getExtensionVersion(i) {
|
|
15
16
|
if (!i.extensionVersion) {
|
|
16
17
|
if (!i.ref) {
|
|
@@ -68,9 +69,59 @@ async function have(projectId) {
|
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
exports.have = have;
|
|
72
|
+
async function wantDynamic(args) {
|
|
73
|
+
const instanceSpecs = [];
|
|
74
|
+
const errors = [];
|
|
75
|
+
if (!args.extensions) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
for (const [instanceId, ext] of Object.entries(args.extensions)) {
|
|
79
|
+
const autoPopulatedParams = await (0, extensionsHelper_1.getFirebaseProjectParams)(args.projectId, args.emulatorMode);
|
|
80
|
+
const subbedParams = (0, extensionsHelper_1.substituteParams)(ext.params, autoPopulatedParams);
|
|
81
|
+
const eventarcChannel = ext.params["_EVENT_ARC_REGION"]
|
|
82
|
+
? (0, askUserForEventsConfig_1.getEventArcChannel)(args.projectId, ext.params["_EVENT_ARC_REGION"])
|
|
83
|
+
: undefined;
|
|
84
|
+
delete subbedParams["_EVENT_ARC_REGION"];
|
|
85
|
+
const subbedSecretParams = await (0, extensionsHelper_1.substituteSecretParams)(args.projectNumber, subbedParams);
|
|
86
|
+
const [systemParams, params] = (0, functional_1.partitionRecord)(subbedSecretParams, paramHelper_1.isSystemParam);
|
|
87
|
+
const allowedEventTypes = ext.events.length ? ext.events : undefined;
|
|
88
|
+
if (allowedEventTypes && !eventarcChannel) {
|
|
89
|
+
errors.push(new error_1.FirebaseError("EventArcRegion must be specified if event handlers are defined"));
|
|
90
|
+
}
|
|
91
|
+
if (ext.localPath) {
|
|
92
|
+
instanceSpecs.push({
|
|
93
|
+
instanceId,
|
|
94
|
+
localPath: ext.localPath,
|
|
95
|
+
params,
|
|
96
|
+
systemParams,
|
|
97
|
+
allowedEventTypes,
|
|
98
|
+
eventarcChannel,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else if (ext.ref) {
|
|
102
|
+
instanceSpecs.push({
|
|
103
|
+
instanceId,
|
|
104
|
+
ref: refs.parse(ext.ref),
|
|
105
|
+
params,
|
|
106
|
+
systemParams,
|
|
107
|
+
allowedEventTypes,
|
|
108
|
+
eventarcChannel,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (errors.length) {
|
|
113
|
+
const messages = errors.map((err) => `- ${err.message}`).join("\n");
|
|
114
|
+
throw new error_1.FirebaseError(`Errors while reading 'extensions' in app code\n${messages}`);
|
|
115
|
+
}
|
|
116
|
+
return instanceSpecs;
|
|
117
|
+
}
|
|
118
|
+
exports.wantDynamic = wantDynamic;
|
|
71
119
|
async function want(args) {
|
|
72
120
|
const instanceSpecs = [];
|
|
73
121
|
const errors = [];
|
|
122
|
+
if (!args.extensions) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
74
125
|
for (const e of Object.entries(args.extensions)) {
|
|
75
126
|
try {
|
|
76
127
|
const instanceId = e[0];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepare = void 0;
|
|
3
|
+
exports.prepare = exports.prepareDynamicExtensions = void 0;
|
|
4
4
|
const planner = require("./planner");
|
|
5
5
|
const deploymentSummary = require("./deploymentSummary");
|
|
6
6
|
const prompt = require("../../prompt");
|
|
@@ -16,31 +16,28 @@ const warnings_1 = require("../../extensions/warnings");
|
|
|
16
16
|
const etags_1 = require("../../extensions/etags");
|
|
17
17
|
const v2FunctionHelper_1 = require("./v2FunctionHelper");
|
|
18
18
|
const tos_1 = require("../../extensions/tos");
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const common_1 = require("../../extensions/runtimes/common");
|
|
20
|
+
const projectConfig_1 = require("../../functions/projectConfig");
|
|
21
|
+
const functionsDeployHelper_1 = require("../functions/functionsDeployHelper");
|
|
22
|
+
async function prepareHelper(context, options, payload, wantExtensions, noDeleteExtensions, isPrimaryCall) {
|
|
21
23
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
22
|
-
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
23
|
-
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
24
|
-
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
25
|
-
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
26
24
|
context.have = await planner.have(projectId);
|
|
27
|
-
context.want =
|
|
28
|
-
projectId,
|
|
29
|
-
projectNumber,
|
|
30
|
-
aliases,
|
|
31
|
-
projectDir: options.config.projectDir,
|
|
32
|
-
extensions: options.config.get("extensions"),
|
|
33
|
-
});
|
|
25
|
+
context.want = wantExtensions;
|
|
34
26
|
const etagsChanged = (0, etags_1.detectEtagChanges)(options.rc, projectId, context.have);
|
|
35
27
|
if (etagsChanged.length) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
const wantChangedIds = wantExtensions
|
|
29
|
+
.map((e) => e.instanceId)
|
|
30
|
+
.filter((id) => etagsChanged.includes(id));
|
|
31
|
+
if (wantChangedIds.length) {
|
|
32
|
+
(0, warnings_1.outOfBandChangesWarning)(wantChangedIds);
|
|
33
|
+
if (!(await prompt.confirm({
|
|
34
|
+
message: `Do you wish to continue deploying these extension instances?`,
|
|
35
|
+
default: false,
|
|
36
|
+
nonInteractive: options.nonInteractive,
|
|
37
|
+
force: options.force,
|
|
38
|
+
}))) {
|
|
39
|
+
throw new error_1.FirebaseError("Deployment cancelled");
|
|
40
|
+
}
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
const usingSecrets = await Promise.all(context.want?.map(secrets_1.checkSpecForSecrets));
|
|
@@ -54,7 +51,7 @@ async function prepare(context, options, payload) {
|
|
|
54
51
|
payload.instancesToCreate = context.want.filter((i) => !context.have?.some(matchesInstanceId(i)));
|
|
55
52
|
payload.instancesToConfigure = context.want.filter((i) => context.have?.some(isConfigure(i)));
|
|
56
53
|
payload.instancesToUpdate = context.want.filter((i) => context.have?.some(isUpdate(i)));
|
|
57
|
-
payload.instancesToDelete = context.have.filter((i) => !context.want?.some(matchesInstanceId(i)));
|
|
54
|
+
payload.instancesToDelete = context.have.filter((i) => !context.want?.some(matchesInstanceId(i)) && !noDeleteExtensions?.some(matchesInstanceId(i)));
|
|
58
55
|
if (await (0, warnings_1.displayWarningsForDeploy)(payload.instancesToCreate)) {
|
|
59
56
|
if (!(await prompt.confirm({
|
|
60
57
|
message: `Do you wish to continue deploying these extension instances?`,
|
|
@@ -66,6 +63,9 @@ async function prepare(context, options, payload) {
|
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
const permissionsNeeded = [];
|
|
66
|
+
if (!isPrimaryCall) {
|
|
67
|
+
payload.instancesToDelete = [];
|
|
68
|
+
}
|
|
69
69
|
if (payload.instancesToCreate.length) {
|
|
70
70
|
permissionsNeeded.push("firebaseextensions.instances.create");
|
|
71
71
|
logger_1.logger.info(deploymentSummary.createsSummary(payload.instancesToCreate));
|
|
@@ -97,6 +97,81 @@ async function prepare(context, options, payload) {
|
|
|
97
97
|
await (0, requirePermissions_1.requirePermissions)(options, permissionsNeeded);
|
|
98
98
|
await (0, tos_1.acceptLatestAppDeveloperTOS)(options, projectId, context.want.map((i) => i.instanceId));
|
|
99
99
|
}
|
|
100
|
+
async function prepareDynamicExtensions(context, options, payload, builds) {
|
|
101
|
+
const filters = (0, functionsDeployHelper_1.getEndpointFilters)(options);
|
|
102
|
+
const extensions = (0, common_1.extractExtensionsFromBuilds)(builds, filters);
|
|
103
|
+
const isApiEnabled = await (0, extensionsHelper_1.checkExtensionsApiEnabled)(options);
|
|
104
|
+
if (Object.keys(extensions).length === 0 && !isApiEnabled) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
108
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
109
|
+
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
110
|
+
const projectDir = options.config.projectDir;
|
|
111
|
+
const isPrimaryCall = !!options.only && !options.only.split(",").includes("extensions");
|
|
112
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
113
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
114
|
+
const dynamicWant = await planner.wantDynamic({
|
|
115
|
+
projectId,
|
|
116
|
+
projectNumber,
|
|
117
|
+
extensions,
|
|
118
|
+
});
|
|
119
|
+
let noDeleteExtensions = [];
|
|
120
|
+
if (isPrimaryCall) {
|
|
121
|
+
const firebaseJsonWant = await planner.want({
|
|
122
|
+
projectId,
|
|
123
|
+
projectNumber,
|
|
124
|
+
aliases,
|
|
125
|
+
projectDir,
|
|
126
|
+
extensions: options.config.get("extensions", {}),
|
|
127
|
+
});
|
|
128
|
+
noDeleteExtensions = noDeleteExtensions.concat(firebaseJsonWant);
|
|
129
|
+
if (hasNonDeployingCodebases(options)) {
|
|
130
|
+
const dynamicAll = await planner.wantDynamic({
|
|
131
|
+
projectId,
|
|
132
|
+
projectNumber,
|
|
133
|
+
extensions: await (0, common_1.extractAllDynamicExtensions)(options),
|
|
134
|
+
});
|
|
135
|
+
noDeleteExtensions = noDeleteExtensions.concat(dynamicAll);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return prepareHelper(context, options, payload, dynamicWant, noDeleteExtensions, isPrimaryCall);
|
|
139
|
+
}
|
|
140
|
+
exports.prepareDynamicExtensions = prepareDynamicExtensions;
|
|
141
|
+
function hasNonDeployingCodebases(options) {
|
|
142
|
+
const functionFilters = (0, functionsDeployHelper_1.getEndpointFilters)(options);
|
|
143
|
+
if (functionFilters?.length) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
const functionsConfig = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
|
|
147
|
+
const allCodebases = (0, functionsDeployHelper_1.targetCodebases)(functionsConfig);
|
|
148
|
+
const deployingCodebases = (0, functionsDeployHelper_1.targetCodebases)(functionsConfig, functionFilters);
|
|
149
|
+
if (allCodebases.length > deployingCodebases.length) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function prepare(context, options, payload) {
|
|
154
|
+
context.extensionsStartTime = Date.now();
|
|
155
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
156
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
157
|
+
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
158
|
+
const projectDir = options.config.projectDir;
|
|
159
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
160
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
161
|
+
const firebaseJsonWant = await planner.want({
|
|
162
|
+
projectId,
|
|
163
|
+
projectNumber,
|
|
164
|
+
aliases,
|
|
165
|
+
projectDir,
|
|
166
|
+
extensions: options.config.get("extensions", {}),
|
|
167
|
+
});
|
|
168
|
+
const dynamicWant = await planner.wantDynamic({
|
|
169
|
+
projectId,
|
|
170
|
+
projectNumber,
|
|
171
|
+
extensions: await (0, common_1.extractAllDynamicExtensions)(options),
|
|
172
|
+
});
|
|
173
|
+
return prepareHelper(context, options, payload, firebaseJsonWant, dynamicWant, true);
|
|
174
|
+
}
|
|
100
175
|
exports.prepare = prepare;
|
|
101
176
|
const matchesInstanceId = (dep) => (test) => {
|
|
102
177
|
return dep.instanceId === test.instanceId;
|
|
@@ -10,6 +10,12 @@ const projectUtils_1 = require("../../projectUtils");
|
|
|
10
10
|
const etags_1 = require("../../extensions/etags");
|
|
11
11
|
const track_1 = require("../../track");
|
|
12
12
|
async function release(context, options, payload) {
|
|
13
|
+
if (!payload.instancesToCreate &&
|
|
14
|
+
!payload.instancesToUpdate &&
|
|
15
|
+
!payload.instancesToConfigure &&
|
|
16
|
+
!payload.instancesToDelete) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
13
19
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
20
|
const errorHandler = new errors_1.ErrorHandler();
|
|
15
21
|
const deploymentQueue = new queue_1.default({
|
|
@@ -55,19 +55,19 @@ exports.AllIngressSettings = [
|
|
|
55
55
|
"ALLOW_INTERNAL_ONLY",
|
|
56
56
|
"ALLOW_INTERNAL_AND_GCLB",
|
|
57
57
|
];
|
|
58
|
-
async function resolveBackend(
|
|
58
|
+
async function resolveBackend(opts) {
|
|
59
59
|
let paramValues = {};
|
|
60
|
-
paramValues = await params.resolveParams(build.params, firebaseConfig, envWithTypes(build.params, userEnvs), nonInteractive);
|
|
60
|
+
paramValues = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.nonInteractive, opts.isEmulator);
|
|
61
61
|
const toWrite = {};
|
|
62
62
|
for (const paramName of Object.keys(paramValues)) {
|
|
63
63
|
const paramValue = paramValues[paramName];
|
|
64
|
-
if (Object.prototype.hasOwnProperty.call(userEnvs, paramName) || paramValue.internal) {
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(opts.userEnvs, paramName) || paramValue.internal) {
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
67
|
toWrite[paramName] = paramValue.toString();
|
|
68
68
|
}
|
|
69
|
-
(0, env_1.writeUserEnvs)(toWrite, userEnvOpt);
|
|
70
|
-
return { backend: toBackend(build, paramValues), envs: paramValues };
|
|
69
|
+
(0, env_1.writeUserEnvs)(toWrite, opts.userEnvOpt);
|
|
70
|
+
return { backend: toBackend(opts.build, paramValues), envs: paramValues };
|
|
71
71
|
}
|
|
72
72
|
exports.resolveBackend = resolveBackend;
|
|
73
73
|
function envWithTypes(definedParams, rawEnvs) {
|
|
@@ -12,6 +12,7 @@ const gcf = require("../../gcp/cloudfunctions");
|
|
|
12
12
|
const gcfv2 = require("../../gcp/cloudfunctionsv2");
|
|
13
13
|
const backend = require("./backend");
|
|
14
14
|
const backend_1 = require("./backend");
|
|
15
|
+
const extensions_1 = require("../extensions");
|
|
15
16
|
(0, tmp_1.setGracefulCleanup)();
|
|
16
17
|
async function uploadSourceV1(projectId, source, wantBackend) {
|
|
17
18
|
const v1Endpoints = backend.allEndpoints(wantBackend).filter((e) => e.platform === "gcfv1");
|
|
@@ -76,21 +77,20 @@ async function uploadCodebase(context, codebase, wantBackend) {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
async function deploy(context, options, payload) {
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (!payload.functions) {
|
|
83
|
-
return;
|
|
80
|
+
if (payload.extensions && context.extensions) {
|
|
81
|
+
await (0, extensions_1.deploy)(context.extensions, options, payload.extensions);
|
|
84
82
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
if (payload.functions && context.config) {
|
|
84
|
+
await (0, checkIam_1.checkHttpIam)(context, options, payload);
|
|
85
|
+
const uploads = [];
|
|
86
|
+
for (const [codebase, { wantBackend, haveBackend }] of Object.entries(payload.functions)) {
|
|
87
|
+
if (shouldUploadBeSkipped(context, wantBackend, haveBackend)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
uploads.push(uploadCodebase(context, codebase, wantBackend));
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
await Promise.all(uploads);
|
|
92
93
|
}
|
|
93
|
-
await Promise.all(uploads);
|
|
94
94
|
}
|
|
95
95
|
exports.deploy = deploy;
|
|
96
96
|
function shouldUploadBeSkipped(context, wantBackend, haveBackend) {
|
|
@@ -154,7 +154,7 @@ function canSatisfyParam(param, value) {
|
|
|
154
154
|
}
|
|
155
155
|
(0, functional_1.assertExhaustive)(param);
|
|
156
156
|
}
|
|
157
|
-
async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive) {
|
|
157
|
+
async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, isEmulator = false) {
|
|
158
158
|
const paramValues = populateDefaultParams(firebaseConfig);
|
|
159
159
|
const [resolved, outstanding] = (0, functional_1.partition)(params, (param) => {
|
|
160
160
|
return {}.hasOwnProperty.call(userEnvs, param.name);
|
|
@@ -163,8 +163,10 @@ async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive) {
|
|
|
163
163
|
paramValues[param.name] = userEnvs[param.name];
|
|
164
164
|
}
|
|
165
165
|
const [needSecret, needPrompt] = (0, functional_1.partition)(outstanding, (param) => param.type === "secret");
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
if (!isEmulator) {
|
|
167
|
+
for (const param of needSecret) {
|
|
168
|
+
await handleSecret(param, firebaseConfig.projectId);
|
|
169
|
+
}
|
|
168
170
|
}
|
|
169
171
|
if (nonInteractive && needPrompt.length > 0) {
|
|
170
172
|
const envNames = outstanding.map((p) => p.name).join(", ");
|
|
@@ -66,7 +66,14 @@ async function prepare(context, options, payload) {
|
|
|
66
66
|
};
|
|
67
67
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
68
68
|
const envs = { ...userEnvs, ...firebaseEnvs };
|
|
69
|
-
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend(
|
|
69
|
+
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend({
|
|
70
|
+
build: wantBuild,
|
|
71
|
+
firebaseConfig,
|
|
72
|
+
userEnvOpt,
|
|
73
|
+
userEnvs,
|
|
74
|
+
nonInteractive: options.nonInteractive,
|
|
75
|
+
isEmulator: false,
|
|
76
|
+
});
|
|
70
77
|
let hasEnvsFromParams = false;
|
|
71
78
|
wantBackend.environmentVariables = envs;
|
|
72
79
|
for (const envName of Object.keys(resolvedEnvs)) {
|
|
@@ -16,7 +16,11 @@ const functionsConfig_1 = require("../../../functionsConfig");
|
|
|
16
16
|
const functionsDeployHelper_1 = require("../functionsDeployHelper");
|
|
17
17
|
const error_1 = require("../../../error");
|
|
18
18
|
const getProjectNumber_1 = require("../../../getProjectNumber");
|
|
19
|
+
const extensions_1 = require("../../extensions");
|
|
19
20
|
async function release(context, options, payload) {
|
|
21
|
+
if (context.extensions && payload.extensions) {
|
|
22
|
+
await (0, extensions_1.release)(context.extensions, options, payload.extensions);
|
|
23
|
+
}
|
|
20
24
|
if (!context.config) {
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
@@ -21,7 +21,7 @@ function assertKeyTypes(prefix, yaml, schema) {
|
|
|
21
21
|
const key = keyAsString;
|
|
22
22
|
const fullKey = prefix ? `${prefix}.${keyAsString}` : keyAsString;
|
|
23
23
|
if (!schema[key] || schema[key] === "omit") {
|
|
24
|
-
throw new error_1.FirebaseError(`Unexpected key ${fullKey}. You may need to install a newer version of the Firebase CLI.`);
|
|
24
|
+
throw new error_1.FirebaseError(`Unexpected key '${fullKey}'. You may need to install a newer version of the Firebase CLI.`);
|
|
25
25
|
}
|
|
26
26
|
let schemaType = schema[key];
|
|
27
27
|
if (typeof schemaType === "function") {
|
|
@@ -21,6 +21,7 @@ function buildFromV1Alpha1(yaml, project, region, runtime) {
|
|
|
21
21
|
params: "array",
|
|
22
22
|
requiredAPIs: "array",
|
|
23
23
|
endpoints: "object",
|
|
24
|
+
extensions: "object",
|
|
24
25
|
});
|
|
25
26
|
const bd = build.empty();
|
|
26
27
|
bd.params = manifest.params || [];
|
|
@@ -31,6 +32,15 @@ function buildFromV1Alpha1(yaml, project, region, runtime) {
|
|
|
31
32
|
const be = parseEndpointForBuild(id, me, project, region, runtime);
|
|
32
33
|
bd.endpoints[id] = be;
|
|
33
34
|
}
|
|
35
|
+
if (manifest.extensions) {
|
|
36
|
+
bd.extensions = {};
|
|
37
|
+
for (const id of Object.keys(manifest.extensions)) {
|
|
38
|
+
const me = manifest.extensions[id];
|
|
39
|
+
assertBuildExtension(me, id);
|
|
40
|
+
const be = parseExtensionForBuild(me);
|
|
41
|
+
bd.extensions[id] = be;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
34
44
|
return bd;
|
|
35
45
|
}
|
|
36
46
|
exports.buildFromV1Alpha1 = buildFromV1Alpha1;
|
|
@@ -277,6 +287,42 @@ function parseEndpointForBuild(id, ep, project, defaultRegion, runtime) {
|
|
|
277
287
|
});
|
|
278
288
|
return parsed;
|
|
279
289
|
}
|
|
290
|
+
function assertBuildExtension(ex, id) {
|
|
291
|
+
const prefix = `extensions[${id}]`;
|
|
292
|
+
(0, parsing_1.assertKeyTypes)(prefix, ex, {
|
|
293
|
+
params: "object",
|
|
294
|
+
ref: "string?",
|
|
295
|
+
localPath: "string?",
|
|
296
|
+
events: "array",
|
|
297
|
+
});
|
|
298
|
+
let refOrPath = 0;
|
|
299
|
+
if (ex.ref) {
|
|
300
|
+
refOrPath++;
|
|
301
|
+
}
|
|
302
|
+
if (ex.localPath) {
|
|
303
|
+
refOrPath++;
|
|
304
|
+
}
|
|
305
|
+
if (refOrPath === 0) {
|
|
306
|
+
throw new error_1.FirebaseError(`Expected either extension reference or local path in extension: ${id}`);
|
|
307
|
+
}
|
|
308
|
+
if (refOrPath > 1) {
|
|
309
|
+
throw new error_1.FirebaseError(`Multiple definitions for extension ${id}. Do not specify both reference and local path.`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function parseExtensionForBuild(ex) {
|
|
313
|
+
const parsed = {
|
|
314
|
+
params: {},
|
|
315
|
+
events: [],
|
|
316
|
+
};
|
|
317
|
+
if (ex.localPath) {
|
|
318
|
+
parsed.localPath = ex.localPath;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
parsed.ref = ex.ref;
|
|
322
|
+
}
|
|
323
|
+
(0, proto_1.copyIfPresent)(parsed, ex, "params", "events");
|
|
324
|
+
return parsed;
|
|
325
|
+
}
|
|
280
326
|
function resolveChannelName(projectId, channel, defaultRegion) {
|
|
281
327
|
if (!channel.includes("/")) {
|
|
282
328
|
const location = defaultRegion;
|
|
@@ -15,6 +15,7 @@ exports.DEFAULT_PORTS = {
|
|
|
15
15
|
storage: 9199,
|
|
16
16
|
eventarc: 9299,
|
|
17
17
|
dataconnect: 9399,
|
|
18
|
+
tasks: 9499,
|
|
18
19
|
};
|
|
19
20
|
exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
20
21
|
ui: true,
|
|
@@ -30,6 +31,7 @@ exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
|
30
31
|
extensions: false,
|
|
31
32
|
eventarc: true,
|
|
32
33
|
dataconnect: true,
|
|
34
|
+
tasks: true,
|
|
33
35
|
};
|
|
34
36
|
exports.EMULATOR_DESCRIPTION = {
|
|
35
37
|
ui: "Emulator UI",
|
|
@@ -45,6 +47,7 @@ exports.EMULATOR_DESCRIPTION = {
|
|
|
45
47
|
extensions: "Extensions Emulator",
|
|
46
48
|
eventarc: "Eventarc Emulator",
|
|
47
49
|
dataconnect: "Data Connect Emulator",
|
|
50
|
+
tasks: "Cloud Tasks Emulator",
|
|
48
51
|
};
|
|
49
52
|
exports.DEFAULT_HOST = "localhost";
|
|
50
53
|
class Constants {
|
|
@@ -70,6 +73,8 @@ class Constants {
|
|
|
70
73
|
return "test lab";
|
|
71
74
|
case this.SERVICE_EVENTARC:
|
|
72
75
|
return "eventarc";
|
|
76
|
+
case this.SERVICE_CLOUD_TASKS:
|
|
77
|
+
return "tasks";
|
|
73
78
|
default:
|
|
74
79
|
return service;
|
|
75
80
|
}
|
|
@@ -100,12 +105,14 @@ Constants.FIREBASE_STORAGE_EMULATOR_HOST = "FIREBASE_STORAGE_EMULATOR_HOST";
|
|
|
100
105
|
Constants.CLOUD_STORAGE_EMULATOR_HOST = "STORAGE_EMULATOR_HOST";
|
|
101
106
|
Constants.PUBSUB_EMULATOR_HOST = "PUBSUB_EMULATOR_HOST";
|
|
102
107
|
Constants.CLOUD_EVENTARC_EMULATOR_HOST = "CLOUD_EVENTARC_EMULATOR_HOST";
|
|
108
|
+
Constants.CLOUD_TASKS_EMULATOR_HOST = "CLOUD_TASKS_EMULATOR_HOST";
|
|
103
109
|
Constants.FIREBASE_EMULATOR_HUB = "FIREBASE_EMULATOR_HUB";
|
|
104
110
|
Constants.FIREBASE_GA_SESSION = "FIREBASE_GA_SESSION";
|
|
105
111
|
Constants.SERVICE_FIRESTORE = "firestore.googleapis.com";
|
|
106
112
|
Constants.SERVICE_REALTIME_DATABASE = "firebaseio.com";
|
|
107
113
|
Constants.SERVICE_PUBSUB = "pubsub.googleapis.com";
|
|
108
114
|
Constants.SERVICE_EVENTARC = "eventarc.googleapis.com";
|
|
115
|
+
Constants.SERVICE_CLOUD_TASKS = "cloudtasks.googleapis.com";
|
|
109
116
|
Constants.SERVICE_FIREALERTS = "firebasealerts.googleapis.com";
|
|
110
117
|
Constants.SERVICE_ANALYTICS = "app-measurement.com";
|
|
111
118
|
Constants.SERVICE_AUTH = "firebaseauth.googleapis.com";
|