firebase-tools 14.1.0 → 14.2.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/apphosting-backends-create.js +2 -0
- package/lib/commands/apphosting-backends-delete.js +2 -0
- package/lib/commands/apphosting-backends-get.js +2 -0
- package/lib/commands/apphosting-backends-list.js +2 -0
- package/lib/commands/apphosting-builds-create.js +2 -0
- package/lib/commands/apphosting-builds-get.js +2 -0
- package/lib/commands/apphosting-rollouts-create.js +2 -0
- package/lib/commands/apphosting-rollouts-list.js +2 -0
- package/lib/dataconnect/freeTrial.js +9 -3
- package/lib/dataconnect/provisionCloudSql.js +24 -25
- package/lib/deploy/dataconnect/deploy.js +1 -3
- package/lib/deploy/dataconnect/prepare.js +1 -3
- package/lib/deploy/functions/release/index.js +2 -2
- package/lib/emulator/downloadableEmulators.js +9 -9
- package/lib/emulator/extensionsEmulator.js +3 -1
- package/lib/extensions/paramHelper.js +10 -1
- package/lib/functions/artifacts.js +1 -0
- package/lib/gcp/artifactregistry.js +1 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +10 -10
- package/lib/init/features/dataconnect/index.js +8 -6
- package/package.json +1 -1
- package/templates/init/functions/python/_gitignore +6 -1
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.command = void 0;
|
|
4
4
|
const command_1 = require("../command");
|
|
5
5
|
const projectUtils_1 = require("../projectUtils");
|
|
6
|
+
const requireAuth_1 = require("../requireAuth");
|
|
6
7
|
const requireInteractive_1 = require("../requireInteractive");
|
|
7
8
|
const backend_1 = require("../apphosting/backend");
|
|
8
9
|
const apphosting_1 = require("../gcp/apphosting");
|
|
@@ -12,6 +13,7 @@ exports.command = new command_1.Command("apphosting:backends:create")
|
|
|
12
13
|
.description("create a Firebase App Hosting backend")
|
|
13
14
|
.option("-a, --app <webAppId>", "specify an existing Firebase web app's ID to associate your App Hosting backend with")
|
|
14
15
|
.option("-s, --service-account <serviceAccount>", "specify the service account used to run the server", "")
|
|
16
|
+
.before(requireAuth_1.requireAuth)
|
|
15
17
|
.before(apphosting_1.ensureApiEnabled)
|
|
16
18
|
.before(requireInteractive_1.default)
|
|
17
19
|
.before((0, requireTosAcceptance_1.requireTosAcceptance)(firedata_1.APPHOSTING_TOS_ID))
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.command = void 0;
|
|
4
4
|
const command_1 = require("../command");
|
|
5
5
|
const projectUtils_1 = require("../projectUtils");
|
|
6
|
+
const requireAuth_1 = require("../requireAuth");
|
|
6
7
|
const error_1 = require("../error");
|
|
7
8
|
const prompt_1 = require("../prompt");
|
|
8
9
|
const utils = require("../utils");
|
|
@@ -13,6 +14,7 @@ const ora = require("ora");
|
|
|
13
14
|
exports.command = new command_1.Command("apphosting:backends:delete <backend>")
|
|
14
15
|
.description("delete a Firebase App Hosting backend")
|
|
15
16
|
.withForce()
|
|
17
|
+
.before(requireAuth_1.requireAuth)
|
|
16
18
|
.before(apphosting.ensureApiEnabled)
|
|
17
19
|
.action(async (backendId, options) => {
|
|
18
20
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.command = void 0;
|
|
4
4
|
const command_1 = require("../command");
|
|
5
5
|
const projectUtils_1 = require("../projectUtils");
|
|
6
|
+
const requireAuth_1 = require("../requireAuth");
|
|
6
7
|
const error_1 = require("../error");
|
|
7
8
|
const utils_1 = require("../utils");
|
|
8
9
|
const apphosting = require("../gcp/apphosting");
|
|
9
10
|
const apphosting_backends_list_1 = require("./apphosting-backends-list");
|
|
10
11
|
exports.command = new command_1.Command("apphosting:backends:get <backend>")
|
|
11
12
|
.description("print info about a Firebase App Hosting backend")
|
|
13
|
+
.before(requireAuth_1.requireAuth)
|
|
12
14
|
.before(apphosting.ensureApiEnabled)
|
|
13
15
|
.action(async (backend, options) => {
|
|
14
16
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -6,11 +6,13 @@ const utils_1 = require("../utils");
|
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const projectUtils_1 = require("../projectUtils");
|
|
9
|
+
const requireAuth_1 = require("../requireAuth");
|
|
9
10
|
const apphosting = require("../gcp/apphosting");
|
|
10
11
|
const Table = require("cli-table3");
|
|
11
12
|
const TABLE_HEAD = ["Backend", "Repository", "URL", "Primary Region", "Updated Date"];
|
|
12
13
|
exports.command = new command_1.Command("apphosting:backends:list")
|
|
13
14
|
.description("list Firebase App Hosting backends")
|
|
15
|
+
.before(requireAuth_1.requireAuth)
|
|
14
16
|
.before(apphosting.ensureApiEnabled)
|
|
15
17
|
.action(async (options) => {
|
|
16
18
|
var _a;
|
|
@@ -5,12 +5,14 @@ const apphosting = require("../gcp/apphosting");
|
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requireAuth_1 = require("../requireAuth");
|
|
8
9
|
const utils_1 = require("../utils");
|
|
9
10
|
exports.command = new command_1.Command("apphosting:builds:create <backendId>")
|
|
10
11
|
.description("create a build for an App Hosting backend")
|
|
11
12
|
.option("-l, --location <location>", "specify the region of the backend")
|
|
12
13
|
.option("-i, --id <buildId>", "id of the build (defaults to autogenerating a random id)", "")
|
|
13
14
|
.option("-b, --branch <branch>", "repository branch to deploy (defaults to 'main')", "main")
|
|
15
|
+
.before(requireAuth_1.requireAuth)
|
|
14
16
|
.before(apphosting.ensureApiEnabled)
|
|
15
17
|
.action(async (backendId, options) => {
|
|
16
18
|
var _a, _b;
|
|
@@ -5,10 +5,12 @@ const apphosting = require("../gcp/apphosting");
|
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requireAuth_1 = require("../requireAuth");
|
|
8
9
|
const utils_1 = require("../utils");
|
|
9
10
|
exports.command = new command_1.Command("apphosting:builds:get <backendId> <buildId>")
|
|
10
11
|
.description("get a build for an App Hosting backend")
|
|
11
12
|
.option("-l, --location <location>", "specify the region of the backend")
|
|
13
|
+
.before(requireAuth_1.requireAuth)
|
|
12
14
|
.before(apphosting.ensureApiEnabled)
|
|
13
15
|
.action(async (backendId, buildId, options) => {
|
|
14
16
|
var _a;
|
|
@@ -4,6 +4,7 @@ exports.command = void 0;
|
|
|
4
4
|
const apphosting = require("../gcp/apphosting");
|
|
5
5
|
const command_1 = require("../command");
|
|
6
6
|
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const requireAuth_1 = require("../requireAuth");
|
|
7
8
|
const error_1 = require("../error");
|
|
8
9
|
const rollout_1 = require("../apphosting/rollout");
|
|
9
10
|
exports.command = new command_1.Command("apphosting:rollouts:create <backendId>")
|
|
@@ -11,6 +12,7 @@ exports.command = new command_1.Command("apphosting:rollouts:create <backendId>"
|
|
|
11
12
|
.option("-b, --git-branch <gitBranch>", "repository branch to deploy (mutually exclusive with -g)")
|
|
12
13
|
.option("-g, --git-commit <gitCommit>", "git commit to deploy (mutually exclusive with -b)")
|
|
13
14
|
.withForce("Skip confirmation before creating rollout")
|
|
15
|
+
.before(requireAuth_1.requireAuth)
|
|
14
16
|
.before(apphosting.ensureApiEnabled)
|
|
15
17
|
.action(async (backendId, options) => {
|
|
16
18
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -5,10 +5,12 @@ const apphosting = require("../gcp/apphosting");
|
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requireAuth_1 = require("../requireAuth");
|
|
8
9
|
const utils_1 = require("../utils");
|
|
9
10
|
exports.command = new command_1.Command("apphosting:rollouts:list <backendId>")
|
|
10
11
|
.description("list rollouts of an App Hosting backend")
|
|
11
12
|
.option("-l, --location <location>", "region of the rollouts (defaults to listing rollouts from all regions)")
|
|
13
|
+
.before(requireAuth_1.requireAuth)
|
|
12
14
|
.before(apphosting.ensureApiEnabled)
|
|
13
15
|
.action(async (backendId, options) => {
|
|
14
16
|
var _a;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.upgradeInstructions = exports.printFreeTrialUnavailable = exports.isFreeTrialError = exports.getFreeTrialInstanceId = exports.checkFreeTrialInstanceUsed = exports.freeTrialTermsLink = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
4
5
|
const cloudmonitoring_1 = require("../gcp/cloudmonitoring");
|
|
5
6
|
const cloudsqladmin_1 = require("../gcp/cloudsql/cloudsqladmin");
|
|
6
7
|
const utils = require("../utils");
|
|
7
|
-
const clc = require("colorette");
|
|
8
8
|
function freeTrialTermsLink() {
|
|
9
9
|
return "https://firebase.google.com/pricing";
|
|
10
10
|
}
|
|
11
11
|
exports.freeTrialTermsLink = freeTrialTermsLink;
|
|
12
12
|
const FREE_TRIAL_METRIC = "sqladmin.googleapis.com/fdc_lifetime_free_trial_per_project";
|
|
13
13
|
async function checkFreeTrialInstanceUsed(projectId) {
|
|
14
|
+
utils.logLabeledBullet("dataconnect", "Checking Cloud SQL no cost trial eligibility...");
|
|
14
15
|
const past7d = new Date();
|
|
15
16
|
past7d.setDate(past7d.getDate() - 7);
|
|
16
17
|
const query = {
|
|
@@ -20,12 +21,17 @@ async function checkFreeTrialInstanceUsed(projectId) {
|
|
|
20
21
|
};
|
|
21
22
|
try {
|
|
22
23
|
const ts = await (0, cloudmonitoring_1.queryTimeSeries)(query, projectId);
|
|
24
|
+
let used = true;
|
|
23
25
|
if (ts.length) {
|
|
24
|
-
|
|
26
|
+
used = ts[0].points.some((p) => p.value.int64Value);
|
|
27
|
+
}
|
|
28
|
+
if (used) {
|
|
29
|
+
utils.logLabeledWarning("dataconnect", "CloudSQL no cost trial has already been used on this project.");
|
|
25
30
|
}
|
|
26
|
-
return
|
|
31
|
+
return used;
|
|
27
32
|
}
|
|
28
33
|
catch (err) {
|
|
34
|
+
utils.logLabeledSuccess("dataconnect", "CloudSQL no cost trial available!");
|
|
29
35
|
return false;
|
|
30
36
|
}
|
|
31
37
|
}
|
|
@@ -8,10 +8,9 @@ const utils_1 = require("../utils");
|
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const GOOGLE_ML_INTEGRATION_ROLE = "roles/aiplatform.user";
|
|
10
10
|
const freeTrial_1 = require("./freeTrial");
|
|
11
|
-
const error_1 = require("../error");
|
|
12
11
|
async function provisionCloudSql(args) {
|
|
13
12
|
let connectionName = "";
|
|
14
|
-
const { projectId,
|
|
13
|
+
const { projectId, location, instanceId, databaseId, enableGoogleMlIntegration, waitForCreation, silent, dryRun, } = args;
|
|
15
14
|
try {
|
|
16
15
|
const existingInstance = await cloudSqlAdminClient.getInstance(projectId, instanceId);
|
|
17
16
|
silent || utils.logLabeledBullet("dataconnect", `Found existing instance ${instanceId}.`);
|
|
@@ -35,31 +34,31 @@ async function provisionCloudSql(args) {
|
|
|
35
34
|
}
|
|
36
35
|
cmekWarning();
|
|
37
36
|
const cta = dryRun ? "It will be created on your next deploy" : "Creating it now.";
|
|
37
|
+
const freeTrialUsed = await (0, freeTrial_1.checkFreeTrialInstanceUsed)(projectId);
|
|
38
38
|
silent ||
|
|
39
|
-
utils.logLabeledBullet("dataconnect", `CloudSQL instance '${instanceId}' not found.` +
|
|
40
|
-
|
|
41
|
-
`\nThis instance is provided under the terms of the Data Connect no-cost trial ${(0, freeTrial_1.freeTrialTermsLink)()}` +
|
|
42
|
-
|
|
39
|
+
utils.logLabeledBullet("dataconnect", `CloudSQL instance '${instanceId}' not found.` + cta + freeTrialUsed
|
|
40
|
+
? ""
|
|
41
|
+
: `\nThis instance is provided under the terms of the Data Connect no-cost trial ${(0, freeTrial_1.freeTrialTermsLink)()}` +
|
|
42
|
+
dryRun
|
|
43
|
+
? `\nMonitor the progress at ${cloudSqlAdminClient.instanceConsoleLink(projectId, instanceId)}`
|
|
44
|
+
: "");
|
|
43
45
|
if (!dryRun) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const newInstance = await (0, utils_1.promiseWithSpinner)(() => cloudSqlAdminClient.createInstance({
|
|
47
|
+
projectId,
|
|
48
|
+
location,
|
|
49
|
+
instanceId,
|
|
50
|
+
enableGoogleMlIntegration,
|
|
51
|
+
waitForCreation,
|
|
52
|
+
freeTrial: !freeTrialUsed,
|
|
53
|
+
}), "Creating your instance...");
|
|
54
|
+
if (newInstance) {
|
|
55
|
+
silent || utils.logLabeledBullet("dataconnect", "Instance created");
|
|
56
|
+
connectionName = (newInstance === null || newInstance === void 0 ? void 0 : newInstance.connectionName) || "";
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
throw new error_1.FirebaseError("No-cost Cloud SQL trial has already been used on this project.");
|
|
61
|
-
}
|
|
62
|
-
throw err;
|
|
58
|
+
else {
|
|
59
|
+
silent ||
|
|
60
|
+
utils.logLabeledBullet("dataconnect", "Cloud SQL instance creation started - it should be ready shortly. Database and users will be created on your next deploy.");
|
|
61
|
+
return connectionName;
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
}
|
|
@@ -114,7 +113,7 @@ function getUpdateReason(instance, requireGoogleMlIntegration) {
|
|
|
114
113
|
}
|
|
115
114
|
exports.getUpdateReason = getUpdateReason;
|
|
116
115
|
function cmekWarning() {
|
|
117
|
-
const message = "
|
|
116
|
+
const message = "Cloud SQL instances created via the Firebase CLI do not support customer managed encryption keys.\n" +
|
|
118
117
|
"If you'd like to use a CMEK to encrypt your data, first create a CMEK encrypted instance (https://cloud.google.com/sql/docs/postgres/configure-cmek#createcmekinstance).\n" +
|
|
119
118
|
"Then, edit your `dataconnect.yaml` file to use the encrypted instance and redeploy.";
|
|
120
119
|
utils.logLabeledWarning("dataconnect", message);
|
|
@@ -8,7 +8,6 @@ const provisionCloudSql_1 = require("../../dataconnect/provisionCloudSql");
|
|
|
8
8
|
const names_1 = require("../../dataconnect/names");
|
|
9
9
|
const api_1 = require("../../api");
|
|
10
10
|
const ensureApiEnabled = require("../../ensureApiEnabled");
|
|
11
|
-
const node_path_1 = require("node:path");
|
|
12
11
|
const prompt_1 = require("../../prompt");
|
|
13
12
|
async function default_1(context, options) {
|
|
14
13
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -64,10 +63,9 @@ async function default_1(context, options) {
|
|
|
64
63
|
const enableGoogleMlIntegration = (0, types_1.requiresVector)(s.deploymentMetadata);
|
|
65
64
|
return (0, provisionCloudSql_1.provisionCloudSql)({
|
|
66
65
|
projectId,
|
|
67
|
-
|
|
66
|
+
location: (0, names_1.parseServiceName)(s.serviceName).location,
|
|
68
67
|
instanceId,
|
|
69
68
|
databaseId,
|
|
70
|
-
configYamlPath: (0, node_path_1.join)(s.sourceDirectory, "dataconnect.yaml"),
|
|
71
69
|
enableGoogleMlIntegration,
|
|
72
70
|
waitForCreation: true,
|
|
73
71
|
});
|
|
@@ -17,7 +17,6 @@ const names_1 = require("../../dataconnect/names");
|
|
|
17
17
|
const error_1 = require("../../error");
|
|
18
18
|
const types_1 = require("../../dataconnect/types");
|
|
19
19
|
const schemaMigration_1 = require("../../dataconnect/schemaMigration");
|
|
20
|
-
const node_path_1 = require("node:path");
|
|
21
20
|
const freeTrial_1 = require("../../dataconnect/freeTrial");
|
|
22
21
|
async function default_1(context, options) {
|
|
23
22
|
var _a;
|
|
@@ -73,10 +72,9 @@ async function default_1(context, options) {
|
|
|
73
72
|
const enableGoogleMlIntegration = (0, types_1.requiresVector)(s.deploymentMetadata);
|
|
74
73
|
return (0, provisionCloudSql_1.provisionCloudSql)({
|
|
75
74
|
projectId,
|
|
76
|
-
|
|
75
|
+
location: (0, names_1.parseServiceName)(s.serviceName).location,
|
|
77
76
|
instanceId,
|
|
78
77
|
databaseId,
|
|
79
|
-
configYamlPath: (0, node_path_1.join)(s.sourceDirectory, "dataconnect.yaml"),
|
|
80
78
|
enableGoogleMlIntegration,
|
|
81
79
|
waitForCreation: true,
|
|
82
80
|
dryRun: options.dryRun,
|
|
@@ -123,8 +123,8 @@ async function setupArtifactCleanupPolicies(options, projectId, locations) {
|
|
|
123
123
|
`${locationsWithErrors.join(", ")}.` +
|
|
124
124
|
"This could result in a small monthly bill as container images accumulate over time.");
|
|
125
125
|
throw new error_1.FirebaseError(`Functions successfully deployed but could not set up cleanup policy in ` +
|
|
126
|
-
`${locationsWithErrors.length > 1 ? "regions" : "region"} ${locationsWithErrors.join(", ")}
|
|
127
|
-
`Pass the --force option to automatically set up a cleanup policy or` +
|
|
126
|
+
`${locationsWithErrors.length > 1 ? "regions" : "region"} ${locationsWithErrors.join(", ")}. ` +
|
|
127
|
+
`Pass the --force option to automatically set up a cleanup policy or ` +
|
|
128
128
|
"run 'firebase functions:artifacts:setpolicy' to set up a cleanup policy to automatically delete old images.");
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
48
48
|
},
|
|
49
49
|
dataconnect: process.platform === "darwin"
|
|
50
50
|
? {
|
|
51
|
-
version: "2.
|
|
52
|
-
expectedSize:
|
|
53
|
-
expectedChecksum: "
|
|
51
|
+
version: "2.2.0",
|
|
52
|
+
expectedSize: 26538752,
|
|
53
|
+
expectedChecksum: "15304de22f04e51db155b1c76229e3f3",
|
|
54
54
|
}
|
|
55
55
|
: process.platform === "win32"
|
|
56
56
|
? {
|
|
57
|
-
version: "2.
|
|
58
|
-
expectedSize:
|
|
59
|
-
expectedChecksum: "
|
|
57
|
+
version: "2.2.0",
|
|
58
|
+
expectedSize: 26982912,
|
|
59
|
+
expectedChecksum: "a7677c4dfe78275eab7320b1ff777e9e",
|
|
60
60
|
}
|
|
61
61
|
: {
|
|
62
|
-
version: "2.
|
|
63
|
-
expectedSize:
|
|
64
|
-
expectedChecksum: "
|
|
62
|
+
version: "2.2.0",
|
|
63
|
+
expectedSize: 26452120,
|
|
64
|
+
expectedChecksum: "ef332cc135bc05e43121020e5c1fef09",
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
exports.DownloadDetails = {
|
|
@@ -20,6 +20,7 @@ const validation_1 = require("./extensions/validation");
|
|
|
20
20
|
const registry_1 = require("./registry");
|
|
21
21
|
const types_1 = require("./types");
|
|
22
22
|
const common_1 = require("../extensions/runtimes/common");
|
|
23
|
+
const paramHelper_1 = require("../extensions/paramHelper");
|
|
23
24
|
class ExtensionsEmulator {
|
|
24
25
|
constructor(args) {
|
|
25
26
|
this.want = [];
|
|
@@ -170,7 +171,8 @@ class ExtensionsEmulator {
|
|
|
170
171
|
async toEmulatableBackend(instance) {
|
|
171
172
|
const extensionDir = await this.ensureSourceCode(instance);
|
|
172
173
|
const functionsDir = path.join(extensionDir, "functions");
|
|
173
|
-
const
|
|
174
|
+
const params = (0, paramHelper_1.populateDefaultParams)(instance.params, await planner.getExtensionSpec(instance));
|
|
175
|
+
const env = Object.assign(this.autoPopulatedParams(instance), params);
|
|
174
176
|
const { extensionTriggers, runtime, nonSecretEnv, secretEnvVariables } = await (0, optionsHelper_1.getExtensionFunctionInfo)(instance, env);
|
|
175
177
|
const emulatableBackend = {
|
|
176
178
|
functionsDir,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSystemParam = exports.readEnvFile = exports.promptForNewParams = exports.getParamsForUpdate = exports.getParams = exports.setNewDefaults = exports.buildBindingOptionsWithBaseValue = exports.getBaseParamBindings = void 0;
|
|
3
|
+
exports.populateDefaultParams = exports.isSystemParam = exports.readEnvFile = exports.promptForNewParams = exports.getParamsForUpdate = exports.getParams = exports.setNewDefaults = exports.buildBindingOptionsWithBaseValue = exports.getBaseParamBindings = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const clc = require("colorette");
|
|
6
6
|
const fs = require("fs-extra");
|
|
@@ -138,3 +138,12 @@ function isSystemParam(paramName) {
|
|
|
138
138
|
return regex.test(paramName);
|
|
139
139
|
}
|
|
140
140
|
exports.isSystemParam = isSystemParam;
|
|
141
|
+
function populateDefaultParams(params, spec) {
|
|
142
|
+
var _a;
|
|
143
|
+
const ret = Object.assign({}, params);
|
|
144
|
+
for (const p of spec.params) {
|
|
145
|
+
ret[p.param] = (_a = ret[p.param]) !== null && _a !== void 0 ? _a : p.default;
|
|
146
|
+
}
|
|
147
|
+
return ret;
|
|
148
|
+
}
|
|
149
|
+
exports.populateDefaultParams = populateDefaultParams;
|
|
@@ -93,6 +93,7 @@ async function setCleanupPolicy(repository, daysToKeep) {
|
|
|
93
93
|
const update = {
|
|
94
94
|
name: repository.name,
|
|
95
95
|
cleanupPolicies: Object.assign(Object.assign({}, repository.cleanupPolicies), generateCleanupPolicy(daysToKeep)),
|
|
96
|
+
cleanupPolicyDryRun: false,
|
|
96
97
|
labels,
|
|
97
98
|
};
|
|
98
99
|
await exports.updateRepository(update);
|
|
@@ -28,7 +28,7 @@ async function getRepository(repoPath) {
|
|
|
28
28
|
}
|
|
29
29
|
exports.getRepository = getRepository;
|
|
30
30
|
async function updateRepository(repo) {
|
|
31
|
-
const updateMask = proto.fieldMasks(repo, "cleanupPolicies", "labels");
|
|
31
|
+
const updateMask = proto.fieldMasks(repo, "cleanupPolicies", "cleanupPolicyDryRun", "labels");
|
|
32
32
|
if (updateMask.length === 0) {
|
|
33
33
|
const res = await client.get(repo.name);
|
|
34
34
|
return res.body;
|
|
@@ -50,16 +50,16 @@ function instanceConsoleLink(projectId, instanceId) {
|
|
|
50
50
|
return `https://console.cloud.google.com/sql/instances/${instanceId}/overview?project=${projectId}`;
|
|
51
51
|
}
|
|
52
52
|
exports.instanceConsoleLink = instanceConsoleLink;
|
|
53
|
-
async function createInstance(
|
|
53
|
+
async function createInstance(args) {
|
|
54
54
|
const databaseFlags = [{ name: "cloudsql.iam_authentication", value: "on" }];
|
|
55
|
-
if (enableGoogleMlIntegration) {
|
|
55
|
+
if (args.enableGoogleMlIntegration) {
|
|
56
56
|
databaseFlags.push({ name: "cloudsql.enable_google_ml_integration", value: "on" });
|
|
57
57
|
}
|
|
58
58
|
let op;
|
|
59
59
|
try {
|
|
60
|
-
op = await client.post(`projects/${projectId}/instances`, {
|
|
61
|
-
name: instanceId,
|
|
62
|
-
region: location,
|
|
60
|
+
op = await client.post(`projects/${args.projectId}/instances`, {
|
|
61
|
+
name: args.instanceId,
|
|
62
|
+
region: args.location,
|
|
63
63
|
databaseVersion: "POSTGRES_15",
|
|
64
64
|
settings: {
|
|
65
65
|
tier: "db-f1-micro",
|
|
@@ -67,10 +67,10 @@ async function createInstance(projectId, location, instanceId, enableGoogleMlInt
|
|
|
67
67
|
ipConfiguration: {
|
|
68
68
|
authorizedNetworks: [],
|
|
69
69
|
},
|
|
70
|
-
enableGoogleMlIntegration,
|
|
70
|
+
enableGoogleMlIntegration: args.enableGoogleMlIntegration,
|
|
71
71
|
databaseFlags,
|
|
72
72
|
storageAutoResize: false,
|
|
73
|
-
userLabels: { "firebase-data-connect": "ft" },
|
|
73
|
+
userLabels: { "firebase-data-connect": args.freeTrial ? "ft" : "nt" },
|
|
74
74
|
insightsConfig: {
|
|
75
75
|
queryInsightsEnabled: true,
|
|
76
76
|
queryPlansPerMinute: 5,
|
|
@@ -80,13 +80,13 @@ async function createInstance(projectId, location, instanceId, enableGoogleMlInt
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
catch (err) {
|
|
83
|
-
handleAllowlistError(err, location);
|
|
83
|
+
handleAllowlistError(err, args.location);
|
|
84
84
|
throw err;
|
|
85
85
|
}
|
|
86
|
-
if (!waitForCreation) {
|
|
86
|
+
if (!args.waitForCreation) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const opName = `projects/${projectId}/operations/${op.body.name}`;
|
|
89
|
+
const opName = `projects/${args.projectId}/operations/${op.body.name}`;
|
|
90
90
|
const pollRes = await operationPoller.pollOperation({
|
|
91
91
|
apiOrigin: (0, api_1.cloudSQLAdminOrigin)(),
|
|
92
92
|
apiVersion: API_VERSION,
|
|
@@ -83,12 +83,12 @@ async function askQuestions(setup, isBillingEnabled) {
|
|
|
83
83
|
info.cloudSqlInstanceId === "" ||
|
|
84
84
|
info.locationId === "" ||
|
|
85
85
|
info.cloudSqlDatabase === "";
|
|
86
|
-
const shouldConfigureBackend = isBillingEnabled &&
|
|
87
|
-
|
|
86
|
+
const shouldConfigureBackend = isBillingEnabled &&
|
|
87
|
+
requiredConfigUnset &&
|
|
88
|
+
(await (0, prompt_1.confirm)({
|
|
88
89
|
message: `Would you like to configure your backend resources now?`,
|
|
89
90
|
default: true,
|
|
90
|
-
})
|
|
91
|
-
: false;
|
|
91
|
+
}));
|
|
92
92
|
if (shouldConfigureBackend) {
|
|
93
93
|
info = await promptForService(info);
|
|
94
94
|
info = await promptForCloudSQL(setup, info);
|
|
@@ -115,10 +115,9 @@ async function actuate(setup, config, info) {
|
|
|
115
115
|
if (setup.projectId && info.shouldProvisionCSQL) {
|
|
116
116
|
await (0, provisionCloudSql_1.provisionCloudSql)({
|
|
117
117
|
projectId: setup.projectId,
|
|
118
|
-
|
|
118
|
+
location: info.locationId,
|
|
119
119
|
instanceId: info.cloudSqlInstanceId,
|
|
120
120
|
databaseId: info.cloudSqlDatabase,
|
|
121
|
-
configYamlPath: (0, path_1.join)(config.get("dataconnect.source"), "dataconnect.yaml"),
|
|
122
121
|
enableGoogleMlIntegration: false,
|
|
123
122
|
waitForCreation: false,
|
|
124
123
|
});
|
|
@@ -269,6 +268,9 @@ async function promptForCloudSQL(setup, info) {
|
|
|
269
268
|
if (!(await (0, freeTrial_1.checkFreeTrialInstanceUsed)(setup.projectId))) {
|
|
270
269
|
choices.push({ name: "Create a new free trial instance", value: "", location: "" });
|
|
271
270
|
}
|
|
271
|
+
else {
|
|
272
|
+
choices.push({ name: "Create a new CloudSQL instance", value: "", location: "" });
|
|
273
|
+
}
|
|
272
274
|
info.cloudSqlInstanceId = await (0, prompt_1.promptOnce)({
|
|
273
275
|
message: `Which CloudSQL instance would you like to use?`,
|
|
274
276
|
type: "list",
|
package/package.json
CHANGED