firebase-tools-with-isolate 13.15.0-0 → 13.26.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/api.js +3 -1
- package/lib/apiv2.js +10 -3
- package/lib/appdistribution/client.js +62 -8
- package/lib/appdistribution/distribution.js +1 -1
- package/lib/apphosting/backend.js +299 -0
- package/lib/apphosting/config.js +31 -8
- package/lib/apphosting/githubConnections.js +70 -22
- package/lib/apphosting/index.js +3 -312
- package/lib/apphosting/rollout.js +138 -0
- package/lib/apphosting/secrets/index.js +70 -5
- package/lib/apphosting/utils.js +41 -0
- package/lib/apphosting/yaml.js +82 -0
- package/lib/archiveDirectory.js +1 -1
- package/lib/auth.js +31 -5
- package/lib/bin/firebase.js +2 -2
- package/lib/command.js +18 -4
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/{appdistribution-group-create.js → appdistribution-groups-create.js} +2 -1
- package/lib/commands/{appdistribution-group-delete.js → appdistribution-groups-delete.js} +3 -2
- package/lib/commands/appdistribution-groups-list.js +55 -0
- package/lib/commands/appdistribution-testers-list.js +52 -0
- package/lib/commands/appdistribution-testers-remove.js +1 -1
- package/lib/commands/apphosting-backends-create.js +4 -4
- package/lib/commands/apphosting-backends-delete.js +7 -15
- package/lib/commands/apphosting-backends-get.js +1 -1
- package/lib/commands/apphosting-config-export.js +51 -0
- package/lib/commands/apphosting-repos-create.js +23 -0
- package/lib/commands/apphosting-rollouts-create.js +14 -15
- package/lib/commands/apphosting-secrets-grantaccess.js +2 -2
- package/lib/commands/database-import.js +4 -2
- package/lib/commands/database-push.js +4 -2
- package/lib/commands/database-set.js +4 -2
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/dataconnect-sdk-generate.js +4 -1
- package/lib/commands/dataconnect-services-list.js +4 -3
- package/lib/commands/dataconnect-sql-diff.js +1 -1
- package/lib/commands/dataconnect-sql-grant.js +37 -0
- package/lib/commands/dataconnect-sql-migrate.js +1 -1
- package/lib/commands/dataconnect-sql-shell.js +115 -0
- package/lib/commands/deploy.js +5 -1
- package/lib/commands/emulators-start.js +4 -1
- package/lib/commands/ext-dev-init.js +2 -2
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-register.js +2 -2
- package/lib/commands/ext-dev-upload.js +2 -2
- package/lib/commands/ext-dev-usage.js +2 -2
- package/lib/commands/ext-info.js +3 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/ext-sdk-install.js +88 -0
- package/lib/commands/ext.js +1 -0
- package/lib/commands/firestore-databases-restore.js +39 -1
- package/lib/commands/functions-secrets-access.js +2 -4
- package/lib/commands/index.js +15 -2
- package/lib/commands/init.js +25 -15
- package/lib/commands/setup-emulators-dataconnect.js +0 -13
- package/lib/commands/use.js +1 -1
- package/lib/config.js +14 -4
- package/lib/crashlytics/buildToolsJarHelper.js +2 -2
- package/lib/dataconnect/client.js +3 -2
- package/lib/dataconnect/dataplaneClient.js +12 -9
- package/lib/dataconnect/ensureApis.js +6 -1
- package/lib/dataconnect/fileUtils.js +29 -12
- package/lib/dataconnect/freeTrial.js +45 -9
- package/lib/dataconnect/load.js +3 -1
- package/lib/dataconnect/provisionCloudSql.js +41 -24
- package/lib/dataconnect/schemaMigration.js +215 -74
- package/lib/dataconnect/types.js +4 -1
- package/lib/dataconnect/webhook.js +32 -0
- package/lib/deploy/dataconnect/deploy.js +18 -15
- package/lib/deploy/dataconnect/prepare.js +41 -0
- package/lib/deploy/dataconnect/release.js +16 -7
- package/lib/deploy/extensions/deploy.js +3 -1
- package/lib/deploy/extensions/deploymentSummary.js +7 -3
- package/lib/deploy/extensions/planner.js +95 -5
- package/lib/deploy/extensions/prepare.js +89 -42
- package/lib/deploy/extensions/release.js +17 -10
- package/lib/deploy/extensions/tasks.js +32 -21
- package/lib/deploy/firestore/prepare.js +9 -0
- package/lib/deploy/firestore/release.js +3 -6
- package/lib/deploy/functions/build.js +5 -5
- package/lib/deploy/functions/checkIam.js +7 -2
- package/lib/deploy/functions/deploy.js +12 -12
- package/lib/deploy/functions/ensure.js +11 -3
- package/lib/deploy/functions/params.js +5 -3
- package/lib/deploy/functions/prepare.js +18 -3
- package/lib/deploy/functions/release/index.js +4 -0
- package/lib/deploy/functions/release/planner.js +2 -1
- package/lib/deploy/functions/runtimes/discovery/index.js +6 -2
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
- package/lib/deploy/functions/runtimes/node/index.js +5 -0
- package/lib/deploy/functions/services/auth.js +34 -3
- package/lib/deploy/functions/services/index.js +2 -0
- package/lib/deploy/index.js +8 -5
- package/lib/deploy/lifecycleHooks.js +2 -1
- package/lib/emulator/apphosting/config.js +27 -0
- package/lib/emulator/apphosting/index.js +38 -0
- package/lib/emulator/apphosting/serve.js +50 -0
- package/lib/emulator/apphosting/utils.js +18 -0
- package/lib/emulator/auth/handlers.js +27 -0
- package/lib/emulator/auth/operations.js +41 -2
- package/lib/emulator/auth/state.js +2 -1
- package/lib/emulator/commandUtils.js +8 -3
- package/lib/emulator/constants.js +11 -1
- package/lib/emulator/controller.js +59 -6
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +11 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +58 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +22 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +124 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +34 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +270 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/trust.js +2 -0
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +75 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +79 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.js +315 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +8 -0
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +40 -0
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +53 -0
- package/lib/emulator/dataconnect/pg-gateway/index.js +27 -0
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +82 -0
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +52 -0
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +16 -0
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +35 -0
- package/lib/emulator/dataconnect/pg-gateway/utils.js +40 -0
- package/lib/emulator/dataconnect/pgliteServer.js +95 -0
- package/lib/emulator/dataconnectEmulator.js +58 -75
- package/lib/emulator/dataconnectToolkitController.js +44 -0
- package/lib/emulator/downloadableEmulators.js +30 -19
- package/lib/emulator/emulatorLogger.js +3 -0
- package/lib/emulator/env.js +3 -0
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/extensionsEmulator.js +38 -6
- package/lib/emulator/functionsEmulator.js +115 -42
- package/lib/emulator/functionsEmulatorShared.js +18 -1
- package/lib/emulator/functionsRuntimeWorker.js +2 -1
- package/lib/emulator/hub.js +13 -9
- package/lib/emulator/hubExport.js +10 -3
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/portUtils.js +11 -11
- package/lib/emulator/registry.js +2 -0
- package/lib/emulator/storage/persistence.js +2 -2
- package/lib/emulator/storage/rules/runtime.js +1 -1
- package/lib/emulator/taskQueue.js +348 -0
- package/lib/emulator/tasksEmulator.js +240 -0
- package/lib/emulator/types.js +6 -0
- package/lib/emulator/ui.js +51 -25
- package/lib/error.js +31 -1
- package/lib/experiments.js +5 -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/emulator/triggerHelper.js +1 -1
- package/lib/extensions/extensionsApi.js +15 -11
- package/lib/extensions/extensionsHelper.js +39 -8
- package/lib/extensions/localHelper.js +32 -1
- package/lib/extensions/refs.js +26 -11
- package/lib/extensions/runtimes/common.js +215 -0
- package/lib/extensions/runtimes/node.js +401 -0
- package/lib/extensions/types.js +67 -1
- package/lib/extensions/warnings.js +5 -2
- package/lib/firestore/api.js +2 -1
- package/lib/firestore/checkDatabaseType.js +10 -3
- package/lib/firestore/delete.js +11 -0
- package/lib/firestore/options.js +7 -0
- package/lib/frameworks/angular/index.js +15 -3
- package/lib/frameworks/constants.js +2 -2
- package/lib/frameworks/flutter/index.js +6 -6
- package/lib/frameworks/flutter/utils.js +34 -1
- package/lib/frameworks/next/constants.js +1 -1
- package/lib/frameworks/next/index.js +45 -17
- package/lib/frameworks/next/utils.js +57 -4
- package/lib/frameworks/vite/index.js +2 -2
- package/lib/fsutils.js +13 -1
- package/lib/functions/constants.js +4 -0
- package/lib/functions/events/v1.js +9 -2
- package/lib/gcp/apphosting.js +1 -1
- package/lib/gcp/cloudmonitoring.js +3 -3
- package/lib/gcp/cloudsql/cloudsqladmin.js +32 -20
- package/lib/gcp/cloudsql/connect.js +49 -37
- package/lib/gcp/cloudsql/interactive.js +49 -0
- package/lib/gcp/cloudsql/permissions.js +165 -0
- package/lib/gcp/devConnect.js +38 -1
- package/lib/gcp/firestore.js +5 -1
- package/lib/gcp/secretManager.js +12 -5
- package/lib/getProjectNumber.js +1 -1
- package/lib/init/features/apphosting.js +15 -0
- package/lib/init/features/dataconnect/index.js +166 -121
- package/lib/init/features/dataconnect/sdk.js +90 -81
- package/lib/init/features/emulators.js +2 -15
- package/lib/init/features/firestore/index.js +20 -1
- package/lib/init/features/firestore/indexes.js +4 -4
- package/lib/init/features/genkit/index.js +444 -0
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/init/features/index.js +1 -1
- package/lib/init/features/project.js +6 -6
- package/lib/init/features/storage.js +0 -2
- package/lib/init/index.js +1 -0
- package/lib/init/spawn.js +23 -2
- package/lib/logger.js +2 -2
- package/lib/management/projects.js +24 -4
- package/lib/projectUtils.js +1 -1
- package/lib/prompt.js +22 -1
- package/lib/rc.js +1 -8
- package/lib/requireAuth.js +19 -5
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requirePermissions.js +1 -1
- package/lib/responseToError.js +5 -2
- package/lib/rulesDeploy.js +1 -1
- package/lib/templates.js +2 -2
- package/lib/utils.js +16 -11
- package/lib/vsCodeUtils.js +8 -0
- package/package.json +8 -7
- package/schema/connector-yaml.json +57 -17
- package/schema/firebase-config.json +36 -0
- package/templates/extensions/javascript/package.lint.json +2 -2
- package/templates/extensions/javascript/package.nolint.json +2 -2
- package/templates/extensions/typescript/package.lint.json +2 -2
- package/templates/extensions/typescript/package.nolint.json +2 -2
- package/templates/genkit/firebase.0.9.0.template +57 -0
- package/templates/init/apphosting/apphosting.yaml +23 -0
- package/templates/init/dataconnect/connector.yaml +4 -3
- package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +12 -0
- package/templates/init/dataconnect/dataconnect.yaml +6 -6
- package/templates/init/dataconnect/mutations.gql +44 -29
- package/templates/init/dataconnect/queries.gql +65 -38
- package/templates/init/dataconnect/schema.gql +38 -21
- package/templates/init/functions/javascript/package.lint.json +2 -2
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +2 -2
- package/lib/ensureCloudResourceLocation.js +0 -12
- package/lib/init/features/genkit.js +0 -53
|
@@ -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) {
|
|
@@ -102,7 +102,7 @@ function obtainDefaultComputeServiceAgentBindings(projectNumber) {
|
|
|
102
102
|
return [runInvokerBinding, eventarcEventReceiverBinding];
|
|
103
103
|
}
|
|
104
104
|
exports.obtainDefaultComputeServiceAgentBindings = obtainDefaultComputeServiceAgentBindings;
|
|
105
|
-
async function ensureServiceAgentRoles(projectId, projectNumber, want, have) {
|
|
105
|
+
async function ensureServiceAgentRoles(projectId, projectNumber, want, have, dryRun) {
|
|
106
106
|
const wantServices = backend.allEndpoints(want).reduce(reduceEventsToServices, []);
|
|
107
107
|
const haveServices = backend.allEndpoints(have).reduce(reduceEventsToServices, []);
|
|
108
108
|
const newServices = wantServices.filter((wantS) => !haveServices.find((haveS) => wantS.name === haveS.name));
|
|
@@ -138,7 +138,12 @@ async function ensureServiceAgentRoles(projectId, projectNumber, want, have) {
|
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
try {
|
|
141
|
-
|
|
141
|
+
if (dryRun) {
|
|
142
|
+
logger_1.logger.info(`On your next deploy, the following required roles will be granted: ${requiredBindings.map((b) => `${b.members.join(", ")}: ${(0, colorette_1.bold)(b.role)}`)}`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
await (0, resourceManager_1.setIamPolicy)(projectNumber, policy, "bindings");
|
|
146
|
+
}
|
|
142
147
|
}
|
|
143
148
|
catch (err) {
|
|
144
149
|
iam.printManualIamConfig(requiredBindings, projectId, "functions");
|
|
@@ -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) {
|
|
@@ -15,7 +15,7 @@ const metadataCallCache = new Map();
|
|
|
15
15
|
async function defaultServiceAccount(e) {
|
|
16
16
|
let metadataCall = metadataCallCache.get(e.project);
|
|
17
17
|
if (!metadataCall) {
|
|
18
|
-
metadataCall = (0, projects_1.
|
|
18
|
+
metadataCall = (0, projects_1.getProject)(e.project);
|
|
19
19
|
metadataCallCache.set(e.project, metadataCall);
|
|
20
20
|
}
|
|
21
21
|
const metadata = await metadataCall;
|
|
@@ -78,10 +78,18 @@ async function secretsToServiceAccounts(b) {
|
|
|
78
78
|
}
|
|
79
79
|
return secretsToSa;
|
|
80
80
|
}
|
|
81
|
-
async function secretAccess(projectId, wantBackend, haveBackend) {
|
|
81
|
+
async function secretAccess(projectId, wantBackend, haveBackend, dryRun) {
|
|
82
82
|
const ensureAccess = async (secret, serviceAccounts) => {
|
|
83
83
|
(0, utils_1.logLabeledBullet)("functions", `ensuring ${clc.bold(serviceAccounts.join(", "))} access to secret ${clc.bold(secret)}.`);
|
|
84
|
-
|
|
84
|
+
if (dryRun) {
|
|
85
|
+
const check = await (0, secretManager_1.checkServiceAgentRole)({ name: secret, projectId }, serviceAccounts, "roles/secretmanager.secretAccessor");
|
|
86
|
+
if (check.length) {
|
|
87
|
+
(0, utils_1.logLabeledBullet)("functions", `On your next deploy, ${clc.bold(serviceAccounts.join(", "))} will be granted access to secret ${clc.bold(secret)}.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
await (0, secretManager_1.ensureServiceAgentRole)({ name: secret, projectId }, serviceAccounts, "roles/secretmanager.secretAccessor");
|
|
92
|
+
}
|
|
85
93
|
(0, utils_1.logLabeledSuccess)("functions", `ensured ${clc.bold(serviceAccounts.join(", "))} access to ${clc.bold(secret)}.`);
|
|
86
94
|
};
|
|
87
95
|
const wantSecrets = await secretsToServiceAccounts(wantBackend);
|
|
@@ -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(", ");
|
|
@@ -27,6 +27,7 @@ const serviceusage_1 = require("../../gcp/serviceusage");
|
|
|
27
27
|
const applyHash_1 = require("./cache/applyHash");
|
|
28
28
|
const backend_1 = require("./backend");
|
|
29
29
|
const functional_1 = require("../../functional");
|
|
30
|
+
const prepare_1 = require("../extensions/prepare");
|
|
30
31
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
31
32
|
async function prepare(context, options, payload) {
|
|
32
33
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -54,6 +55,13 @@ async function prepare(context, options, payload) {
|
|
|
54
55
|
}
|
|
55
56
|
context.codebaseDeployEvents = {};
|
|
56
57
|
const wantBuilds = await loadCodebases(context.config, options, firebaseConfig, runtimeConfig, context.filters);
|
|
58
|
+
if (Object.values(wantBuilds).some((b) => b.extensions)) {
|
|
59
|
+
const extContext = {};
|
|
60
|
+
const extPayload = {};
|
|
61
|
+
await (0, prepare_1.prepareDynamicExtensions)(extContext, options, extPayload, wantBuilds);
|
|
62
|
+
context.extensions = extContext;
|
|
63
|
+
payload.extensions = extPayload;
|
|
64
|
+
}
|
|
57
65
|
const codebaseUsesEnvs = [];
|
|
58
66
|
const wantBackends = {};
|
|
59
67
|
for (const [codebase, wantBuild] of Object.entries(wantBuilds)) {
|
|
@@ -66,7 +74,14 @@ async function prepare(context, options, payload) {
|
|
|
66
74
|
};
|
|
67
75
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
68
76
|
const envs = { ...userEnvs, ...firebaseEnvs };
|
|
69
|
-
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend(
|
|
77
|
+
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend({
|
|
78
|
+
build: wantBuild,
|
|
79
|
+
firebaseConfig,
|
|
80
|
+
userEnvOpt,
|
|
81
|
+
userEnvs,
|
|
82
|
+
nonInteractive: options.nonInteractive,
|
|
83
|
+
isEmulator: false,
|
|
84
|
+
});
|
|
70
85
|
let hasEnvsFromParams = false;
|
|
71
86
|
wantBackend.environmentVariables = envs;
|
|
72
87
|
for (const envName of Object.keys(resolvedEnvs)) {
|
|
@@ -175,9 +190,9 @@ async function prepare(context, options, payload) {
|
|
|
175
190
|
await (0, prompts_1.promptForFailurePolicies)(options, matchingBackend, haveBackend);
|
|
176
191
|
await (0, prompts_1.promptForMinInstances)(options, matchingBackend, haveBackend);
|
|
177
192
|
await backend.checkAvailability(context, matchingBackend);
|
|
178
|
-
await (0, checkIam_1.ensureServiceAgentRoles)(projectId, projectNumber, matchingBackend, haveBackend);
|
|
179
193
|
await validate.secretsAreValid(projectId, matchingBackend);
|
|
180
|
-
await
|
|
194
|
+
await (0, checkIam_1.ensureServiceAgentRoles)(projectId, projectNumber, matchingBackend, haveBackend, options.dryRun);
|
|
195
|
+
await ensure.secretAccess(projectId, matchingBackend, haveBackend, options.dryRun);
|
|
181
196
|
updateEndpointTargetedStatus(wantBackends, context.filters || []);
|
|
182
197
|
(0, applyHash_1.applyBackendHashToBackends)(wantBackends, context);
|
|
183
198
|
}
|
|
@@ -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
|
}
|
|
@@ -206,7 +206,8 @@ function checkForIllegalUpdate(want, have) {
|
|
|
206
206
|
exports.checkForIllegalUpdate = checkForIllegalUpdate;
|
|
207
207
|
function checkForV2Upgrade(want, have) {
|
|
208
208
|
if (want.platform === "gcfv2" && have.platform === "gcfv1") {
|
|
209
|
-
throw new error_1.FirebaseError(`[${(0, functionsDeployHelper_1.getFunctionLabel)(have)}] Upgrading from
|
|
209
|
+
throw new error_1.FirebaseError(`[${(0, functionsDeployHelper_1.getFunctionLabel)(have)}] Upgrading from 1st Gen to 2nd Gen is not yet supported. ` +
|
|
210
|
+
"See https://firebase.google.com/docs/functions/2nd-gen-upgrade before migrating to 2nd Gen.");
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
213
|
exports.checkForV2Upgrade = checkForV2Upgrade;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.readFileAsync = void 0;
|
|
3
|
+
exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.getFunctionDiscoveryTimeout = exports.readFileAsync = void 0;
|
|
4
4
|
const node_fetch_1 = require("node-fetch");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -12,6 +12,10 @@ const v1alpha1 = require("./v1alpha1");
|
|
|
12
12
|
const error_1 = require("../../../../error");
|
|
13
13
|
exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
|
|
14
14
|
const TIMEOUT_OVERRIDE_ENV_VAR = "FUNCTIONS_DISCOVERY_TIMEOUT";
|
|
15
|
+
function getFunctionDiscoveryTimeout() {
|
|
16
|
+
return +(process.env[TIMEOUT_OVERRIDE_ENV_VAR] || 0) * 1000;
|
|
17
|
+
}
|
|
18
|
+
exports.getFunctionDiscoveryTimeout = getFunctionDiscoveryTimeout;
|
|
15
19
|
function yamlToBuild(yaml, project, region, runtime) {
|
|
16
20
|
try {
|
|
17
21
|
if (!yaml.specVersion) {
|
|
@@ -51,7 +55,7 @@ async function detectFromPort(port, project, runtime, timeout = 10000) {
|
|
|
51
55
|
const timedOut = new Promise((resolve, reject) => {
|
|
52
56
|
setTimeout(() => {
|
|
53
57
|
reject(new error_1.FirebaseError("User code failed to load. Cannot determine backend specification"));
|
|
54
|
-
},
|
|
58
|
+
}, getFunctionDiscoveryTimeout() || timeout);
|
|
55
59
|
});
|
|
56
60
|
while (true) {
|
|
57
61
|
try {
|
|
@@ -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;
|
|
@@ -19,6 +19,7 @@ const versioning = require("./versioning");
|
|
|
19
19
|
const parseTriggers = require("./parseTriggers");
|
|
20
20
|
const fsutils_1 = require("../../../../fsutils");
|
|
21
21
|
const MIN_FUNCTIONS_SDK_VERSION = "3.20.0";
|
|
22
|
+
const MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES = "5.1.0";
|
|
22
23
|
async function tryCreateDelegate(context) {
|
|
23
24
|
const packageJsonPath = path.join(context.sourceDir, "package.json");
|
|
24
25
|
if (!(await (0, util_1.promisify)(fs.exists)(packageJsonPath))) {
|
|
@@ -163,6 +164,10 @@ class Delegate {
|
|
|
163
164
|
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION}`);
|
|
164
165
|
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
|
|
165
166
|
}
|
|
167
|
+
if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES)) {
|
|
168
|
+
(0, utils_1.logLabeledBullet)("functions", `You are using a version of firebase-functions SDK (${this.sdkVersion}) that does not have support for the newest Firebase Extensions features. ` +
|
|
169
|
+
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES} to use them correctly`);
|
|
170
|
+
}
|
|
166
171
|
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
167
172
|
if (!discovered) {
|
|
168
173
|
const basePort = 8000 + (0, utils_1.randomInt)(0, 1000);
|
|
@@ -29,7 +29,11 @@ class AuthBlockingService {
|
|
|
29
29
|
configChanged(newConfig, config) {
|
|
30
30
|
if (newConfig.triggers?.beforeCreate?.functionUri !==
|
|
31
31
|
config.triggers?.beforeCreate?.functionUri ||
|
|
32
|
-
newConfig.triggers?.beforeSignIn?.functionUri !==
|
|
32
|
+
newConfig.triggers?.beforeSignIn?.functionUri !==
|
|
33
|
+
config.triggers?.beforeSignIn?.functionUri ||
|
|
34
|
+
newConfig.triggers?.beforeSendEmail?.functionUri !==
|
|
35
|
+
config.triggers?.beforeSendEmail?.functionUri ||
|
|
36
|
+
newConfig.triggers?.beforeSendSms?.functionUri !== config.triggers?.beforeSendSms?.functionUri) {
|
|
33
37
|
return true;
|
|
34
38
|
}
|
|
35
39
|
if (!!newConfig.forwardInboundCredentials?.accessToken !==
|
|
@@ -53,7 +57,7 @@ class AuthBlockingService {
|
|
|
53
57
|
},
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
|
-
else {
|
|
60
|
+
else if (endpoint.blockingTrigger.eventType === events.v1.BEFORE_SIGN_IN_EVENT) {
|
|
57
61
|
newBlockingConfig.triggers = {
|
|
58
62
|
...newBlockingConfig.triggers,
|
|
59
63
|
beforeSignIn: {
|
|
@@ -61,6 +65,25 @@ class AuthBlockingService {
|
|
|
61
65
|
},
|
|
62
66
|
};
|
|
63
67
|
}
|
|
68
|
+
else if (endpoint.blockingTrigger.eventType === events.v1.BEFORE_SEND_EMAIL_EVENT) {
|
|
69
|
+
newBlockingConfig.triggers = {
|
|
70
|
+
...newBlockingConfig.triggers,
|
|
71
|
+
beforeSendEmail: {
|
|
72
|
+
functionUri: endpoint.uri,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
else if (endpoint.blockingTrigger.eventType === events.v1.BEFORE_SEND_SMS_EVENT) {
|
|
77
|
+
newBlockingConfig.triggers = {
|
|
78
|
+
...newBlockingConfig.triggers,
|
|
79
|
+
beforeSendSms: {
|
|
80
|
+
functionUri: endpoint.uri,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new error_1.FirebaseError(`Received invalid blocking trigger event type ${endpoint.blockingTrigger.eventType}`);
|
|
86
|
+
}
|
|
64
87
|
newBlockingConfig.forwardInboundCredentials = {
|
|
65
88
|
...oldBlockingConfig.forwardInboundCredentials,
|
|
66
89
|
...endpoint.blockingTrigger.options,
|
|
@@ -80,7 +103,9 @@ class AuthBlockingService {
|
|
|
80
103
|
async unregisterTriggerLocked(endpoint) {
|
|
81
104
|
const blockingConfig = await identityPlatform.getBlockingFunctionsConfig(endpoint.project);
|
|
82
105
|
if (endpoint.uri !== blockingConfig.triggers?.beforeCreate?.functionUri &&
|
|
83
|
-
endpoint.uri !== blockingConfig.triggers?.beforeSignIn?.functionUri
|
|
106
|
+
endpoint.uri !== blockingConfig.triggers?.beforeSignIn?.functionUri &&
|
|
107
|
+
endpoint.uri !== blockingConfig.triggers?.beforeSendEmail?.functionUri &&
|
|
108
|
+
endpoint.uri !== blockingConfig.triggers?.beforeSendSms?.functionUri) {
|
|
84
109
|
return;
|
|
85
110
|
}
|
|
86
111
|
if (endpoint.uri === blockingConfig.triggers?.beforeCreate?.functionUri) {
|
|
@@ -89,6 +114,12 @@ class AuthBlockingService {
|
|
|
89
114
|
if (endpoint.uri === blockingConfig.triggers?.beforeSignIn?.functionUri) {
|
|
90
115
|
delete blockingConfig.triggers?.beforeSignIn;
|
|
91
116
|
}
|
|
117
|
+
if (endpoint.uri === blockingConfig.triggers?.beforeSendEmail?.functionUri) {
|
|
118
|
+
delete blockingConfig.triggers?.beforeSendEmail;
|
|
119
|
+
}
|
|
120
|
+
if (endpoint.uri === blockingConfig.triggers?.beforeSendSms?.functionUri) {
|
|
121
|
+
delete blockingConfig.triggers?.beforeSendSms;
|
|
122
|
+
}
|
|
92
123
|
await identityPlatform.setBlockingFunctionsConfig(endpoint.project, blockingConfig);
|
|
93
124
|
}
|
|
94
125
|
unregisterTrigger(ep) {
|
|
@@ -94,6 +94,8 @@ const EVENT_SERVICE_MAPPING = {
|
|
|
94
94
|
"google.firebase.firebasealerts.alerts.v1.published": firebaseAlertsService,
|
|
95
95
|
"providers/cloud.auth/eventTypes/user.beforeCreate": authBlockingService,
|
|
96
96
|
"providers/cloud.auth/eventTypes/user.beforeSignIn": authBlockingService,
|
|
97
|
+
"providers/cloud.auth/eventTypes/user.beforeSendEmail": authBlockingService,
|
|
98
|
+
"providers/cloud.auth/eventTypes/user.beforeSendSms": authBlockingService,
|
|
97
99
|
"google.firebase.database.ref.v1.written": databaseService,
|
|
98
100
|
"google.firebase.database.ref.v1.created": databaseService,
|
|
99
101
|
"google.firebase.database.ref.v1.updated": databaseService,
|
package/lib/deploy/index.js
CHANGED
|
@@ -85,9 +85,11 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
85
85
|
}
|
|
86
86
|
predeploys.push((0, lifecycleHooks_1.lifecycleHooks)(targetName, "predeploy"));
|
|
87
87
|
prepares.push(target.prepare);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
if (!options.dryRun) {
|
|
89
|
+
deploys.push(target.deploy);
|
|
90
|
+
releases.push(target.release);
|
|
91
|
+
postdeploys.push((0, lifecycleHooks_1.lifecycleHooks)(targetName, "postdeploy"));
|
|
92
|
+
}
|
|
91
93
|
}
|
|
92
94
|
logger_1.logger.info();
|
|
93
95
|
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.white)("===") + " Deploying to '" + projectId + "'..."));
|
|
@@ -110,11 +112,12 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
110
112
|
analyticsParams[t] = "true";
|
|
111
113
|
}
|
|
112
114
|
await (0, track_1.trackGA4)("product_deploy", analyticsParams, duration);
|
|
115
|
+
const successMessage = options.dryRun ? "Dry run complete!" : "Deploy complete!";
|
|
113
116
|
logger_1.logger.info();
|
|
114
|
-
(0, utils_1.logSuccess)((0, colorette_1.bold)((0, colorette_1.underline)(
|
|
117
|
+
(0, utils_1.logSuccess)((0, colorette_1.bold)((0, colorette_1.underline)(successMessage)));
|
|
115
118
|
logger_1.logger.info();
|
|
116
119
|
const deployedHosting = (0, lodash_1.includes)(targetNames, "hosting");
|
|
117
|
-
logger_1.logger.info((0, colorette_1.bold)("Project Console:"), (0, utils_1.consoleUrl)(options.project, "/overview"));
|
|
120
|
+
logger_1.logger.info((0, colorette_1.bold)("Project Console:"), (0, utils_1.consoleUrl)(options.project ?? "_", "/overview"));
|
|
118
121
|
if (deployedHosting) {
|
|
119
122
|
(0, lodash_1.each)(context.hosting.deploys, (deploy) => {
|
|
120
123
|
logger_1.logger.info((0, colorette_1.bold)("Hosting URL:"), (0, utils_1.addSubdomain)((0, api_1.hostingOrigin)(), deploy.config.site));
|
|
@@ -8,9 +8,10 @@ const error_1 = require("../error");
|
|
|
8
8
|
const needProjectId = require("../projectUtils").needProjectId;
|
|
9
9
|
const logger_1 = require("../logger");
|
|
10
10
|
const path = require("path");
|
|
11
|
+
const vsCodeUtils_1 = require("../vsCodeUtils");
|
|
11
12
|
function runCommand(command, childOptions) {
|
|
12
13
|
const escapedCommand = command.replace(/\"/g, '\\"');
|
|
13
|
-
const isVSCode =
|
|
14
|
+
const isVSCode = (0, vsCodeUtils_1.isVSCodeExtension)();
|
|
14
15
|
const nodeExecutable = isVSCode ? "node" : process.execPath;
|
|
15
16
|
const crossEnvShellPath = isVSCode
|
|
16
17
|
? path.resolve(__dirname, "./cross-env/dist/bin/cross-env-shell.js")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLocalAppHostingConfiguration = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const config_1 = require("../../apphosting/config");
|
|
6
|
+
const yaml_1 = require("../../apphosting/yaml");
|
|
7
|
+
async function getLocalAppHostingConfiguration(backendDir) {
|
|
8
|
+
const appHostingConfigPaths = (0, config_1.listAppHostingFilesInPath)(backendDir);
|
|
9
|
+
const fileNameToPathMap = new Map();
|
|
10
|
+
for (const path of appHostingConfigPaths) {
|
|
11
|
+
const fileName = (0, path_1.basename)(path);
|
|
12
|
+
fileNameToPathMap.set(fileName, path);
|
|
13
|
+
}
|
|
14
|
+
const baseFilePath = fileNameToPathMap.get(config_1.APPHOSTING_BASE_YAML_FILE);
|
|
15
|
+
const localFilePath = fileNameToPathMap.get(config_1.APPHOSTING_LOCAL_YAML_FILE);
|
|
16
|
+
if (!baseFilePath && !localFilePath) {
|
|
17
|
+
return yaml_1.AppHostingYamlConfig.empty();
|
|
18
|
+
}
|
|
19
|
+
if (!baseFilePath || !localFilePath) {
|
|
20
|
+
return await yaml_1.AppHostingYamlConfig.loadFromFile((baseFilePath || localFilePath));
|
|
21
|
+
}
|
|
22
|
+
const localYamlConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(localFilePath);
|
|
23
|
+
const baseConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(baseFilePath);
|
|
24
|
+
baseConfig.merge(localYamlConfig);
|
|
25
|
+
return baseConfig;
|
|
26
|
+
}
|
|
27
|
+
exports.getLocalAppHostingConfiguration = getLocalAppHostingConfiguration;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppHostingEmulator = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const serve_1 = require("./serve");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
class AppHostingEmulator {
|
|
8
|
+
constructor(args) {
|
|
9
|
+
this.args = args;
|
|
10
|
+
}
|
|
11
|
+
async start() {
|
|
12
|
+
const { hostname, port } = await (0, serve_1.start)({
|
|
13
|
+
startCommand: this.args.startCommandOverride,
|
|
14
|
+
rootDirectory: this.args.rootDirectory,
|
|
15
|
+
});
|
|
16
|
+
this.args.options.host = hostname;
|
|
17
|
+
this.args.options.port = port;
|
|
18
|
+
}
|
|
19
|
+
connect() {
|
|
20
|
+
utils_1.logger.logLabeled("INFO", types_1.Emulators.APPHOSTING, "connecting apphosting emulator");
|
|
21
|
+
return Promise.resolve();
|
|
22
|
+
}
|
|
23
|
+
stop() {
|
|
24
|
+
utils_1.logger.logLabeled("INFO", types_1.Emulators.APPHOSTING, "stopping apphosting emulator");
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
getInfo() {
|
|
28
|
+
return {
|
|
29
|
+
name: types_1.Emulators.APPHOSTING,
|
|
30
|
+
host: this.args.options.host,
|
|
31
|
+
port: this.args.options.port,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
getName() {
|
|
35
|
+
return types_1.Emulators.APPHOSTING;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.AppHostingEmulator = AppHostingEmulator;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.start = void 0;
|
|
4
|
+
const net_1 = require("net");
|
|
5
|
+
const portUtils_1 = require("../portUtils");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const spawn_1 = require("../../init/spawn");
|
|
9
|
+
const utils_2 = require("./utils");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
const projectPath_1 = require("../../projectPath");
|
|
13
|
+
async function start(options) {
|
|
14
|
+
const hostname = constants_1.DEFAULT_HOST;
|
|
15
|
+
let port = constants_1.DEFAULT_PORTS.apphosting;
|
|
16
|
+
while (!(await availablePort(hostname, port))) {
|
|
17
|
+
port += 1;
|
|
18
|
+
}
|
|
19
|
+
serve(port, options?.startCommand, options?.rootDirectory);
|
|
20
|
+
return { hostname, port };
|
|
21
|
+
}
|
|
22
|
+
exports.start = start;
|
|
23
|
+
async function serve(port, startCommand, backendRelativeDir) {
|
|
24
|
+
backendRelativeDir = backendRelativeDir ?? "./";
|
|
25
|
+
const backendRoot = (0, projectPath_1.resolveProjectPath)({}, backendRelativeDir);
|
|
26
|
+
const apphostingLocalConfig = await (0, config_1.getLocalAppHostingConfiguration)(backendRoot);
|
|
27
|
+
const environmentVariablesAsRecord = {};
|
|
28
|
+
for (const env of apphostingLocalConfig.environmentVariables) {
|
|
29
|
+
environmentVariablesAsRecord[env.variable] = env.value;
|
|
30
|
+
}
|
|
31
|
+
const environmentVariablesToInject = {
|
|
32
|
+
...environmentVariablesAsRecord,
|
|
33
|
+
PORT: port.toString(),
|
|
34
|
+
};
|
|
35
|
+
if (startCommand) {
|
|
36
|
+
utils_2.logger.logLabeled("BULLET", types_1.Emulators.APPHOSTING, `running custom start command: '${startCommand}'`);
|
|
37
|
+
await (0, spawn_1.spawnWithCommandString)(startCommand, backendRoot, environmentVariablesToInject);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const packageManager = await (0, utils_1.discoverPackageManager)(backendRoot);
|
|
41
|
+
utils_2.logger.logLabeled("BULLET", types_1.Emulators.APPHOSTING, `starting app with: '${packageManager} run dev'`);
|
|
42
|
+
await (0, spawn_1.wrapSpawn)(packageManager, ["run", "dev"], backendRoot, environmentVariablesToInject);
|
|
43
|
+
}
|
|
44
|
+
function availablePort(host, port) {
|
|
45
|
+
return (0, portUtils_1.checkListenable)({
|
|
46
|
+
address: host,
|
|
47
|
+
port,
|
|
48
|
+
family: (0, net_1.isIPv4)(host) ? "IPv4" : "IPv6",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.discoverPackageManager = exports.logger = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const emulatorLogger_1 = require("../emulatorLogger");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
exports.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.APPHOSTING);
|
|
9
|
+
async function discoverPackageManager(rootdir) {
|
|
10
|
+
if (await (0, fs_extra_1.pathExists)((0, path_1.join)(rootdir, "pnpm-lock.yaml"))) {
|
|
11
|
+
return "pnpm";
|
|
12
|
+
}
|
|
13
|
+
if (await (0, fs_extra_1.pathExists)((0, path_1.join)(rootdir, "yarn.lock"))) {
|
|
14
|
+
return "yarn";
|
|
15
|
+
}
|
|
16
|
+
return "npm";
|
|
17
|
+
}
|
|
18
|
+
exports.discoverPackageManager = discoverPackageManager;
|
|
@@ -131,6 +131,33 @@ function registerHandlers(app, getProjectStateByApiKey) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
case "verifyAndChangeEmail": {
|
|
135
|
+
try {
|
|
136
|
+
const { newEmail } = (0, operations_1.setAccountInfoImpl)(state, { oobCode });
|
|
137
|
+
if (continueUrl) {
|
|
138
|
+
return res.redirect(303, continueUrl);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return res.status(200).json({
|
|
142
|
+
authEmulator: { success: `The email has been successfully changed.`, newEmail },
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
if (e instanceof errors_1.NotImplementedError ||
|
|
148
|
+
(e instanceof errors_1.BadRequestError && e.message === "INVALID_OOB_CODE")) {
|
|
149
|
+
return res.status(400).json({
|
|
150
|
+
authEmulator: {
|
|
151
|
+
error: `Your request to change your email has expired or the link has already been used.`,
|
|
152
|
+
instructions: `Try changing your email again.`,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
throw e;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
134
161
|
case "signIn": {
|
|
135
162
|
if (!continueUrl) {
|
|
136
163
|
return res.status(400).json({
|