firebase-tools-with-isolate 13.11.2 → 13.15.0-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 +4 -2
- package/lib/apphosting/githubConnections.js +125 -37
- package/lib/apphosting/index.js +3 -8
- package/lib/auth.js +14 -15
- package/lib/bin/firebase.js +7 -5
- package/lib/commands/dataconnect-sdk-generate.js +5 -9
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/deploy.js +7 -1
- package/lib/commands/ext-configure.js +1 -6
- package/lib/commands/ext-dev-init.js +27 -30
- package/lib/commands/ext-dev-upload.js +4 -6
- package/lib/commands/ext-info.js +3 -5
- package/lib/commands/ext-install.js +0 -5
- package/lib/commands/ext-uninstall.js +0 -5
- package/lib/commands/ext-update.js +0 -5
- package/lib/commands/firestore-backups-schedules-create.js +11 -14
- package/lib/commands/firestore-backups-schedules-list.js +1 -1
- package/lib/commands/firestore-backups-schedules-update.js +4 -3
- package/lib/commands/firestore-databases-create.js +24 -7
- package/lib/commands/firestore-databases-restore.js +4 -4
- package/lib/commands/firestore-databases-update.js +5 -6
- package/lib/commands/functions-secrets-set.js +9 -6
- package/lib/commands/help.js +2 -0
- package/lib/commands/hosting-channel-create.js +1 -1
- package/lib/commands/hosting-channel-delete.js +1 -1
- package/lib/commands/hosting-channel-deploy.js +1 -1
- package/lib/commands/hosting-clone.js +1 -2
- package/lib/commands/index.js +9 -11
- package/lib/commands/init.js +16 -12
- package/lib/commands/login.js +1 -2
- package/lib/commands/setup-emulators-dataconnect.js +22 -3
- package/lib/config.js +5 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -1
- package/lib/dataconnect/client.js +55 -8
- package/lib/dataconnect/fileUtils.js +30 -7
- package/lib/dataconnect/filters.js +12 -1
- package/lib/dataconnect/load.js +9 -7
- package/lib/dataconnect/schemaMigration.js +21 -0
- package/lib/dataconnect/types.js +8 -1
- package/lib/deploy/dataconnect/prepare.js +16 -2
- package/lib/deploy/functions/build.js +10 -1
- package/lib/emulator/adminSdkConfig.test.js +16 -0
- package/lib/emulator/constants.js +1 -0
- package/lib/emulator/controller.js +3 -9
- package/lib/emulator/dataconnectEmulator.js +122 -18
- package/lib/emulator/downloadableEmulators.js +21 -22
- package/lib/emulator/eventarcEmulator.js +68 -18
- package/lib/emulator/functionsEmulator.js +89 -0
- package/lib/emulator/functionsEmulatorShared.js +4 -0
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/portUtils.js +9 -0
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/registry.js +1 -1
- package/lib/emulator/storage/apis/shared.js +2 -1
- package/lib/emulator/storage/persistence.js +5 -13
- package/lib/emulator/storage/rfc.js +9 -0
- package/lib/emulator/storage/rules/config.js +4 -2
- package/lib/experiments.js +8 -3
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/change-log.js +2 -4
- package/lib/extensions/displayExtensionInfo.js +0 -5
- package/lib/extensions/extensionsHelper.js +5 -7
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/updateHelper.js +1 -2
- package/lib/extensions/warnings.js +2 -7
- package/lib/firestore/api-sort.test.js +74 -0
- package/lib/firestore/api.js +8 -7
- package/lib/firestore/backupUtils.test.js +18 -0
- package/lib/firestore/pretty-print.js +21 -1
- package/lib/firestore/pretty-print.test.js +61 -0
- package/lib/firestore/util.test.js +42 -0
- package/lib/frameworks/angular/utils.js +13 -5
- package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
- package/lib/frameworks/index.js +2 -6
- package/lib/frameworks/next/utils.js +2 -8
- package/lib/frameworks/nuxt/index.js +3 -3
- package/lib/functions/events/v2.js +2 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
- package/lib/gcp/devConnect.js +36 -1
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/init/features/dataconnect/index.js +97 -31
- package/lib/init/features/dataconnect/sdk.js +131 -0
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/javascript.js +6 -8
- package/lib/init/features/functions/python.js +4 -6
- package/lib/init/features/functions/typescript.js +8 -10
- package/lib/init/features/hosting/github.js +43 -21
- package/lib/init/features/hosting/index.js +3 -3
- package/lib/init/features/index.js +3 -1
- package/lib/init/features/storage.js +2 -2
- package/lib/init/index.js +1 -0
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +2 -2
- package/lib/rc.js +1 -0
- package/lib/requireAuth.js +8 -3
- package/lib/rulesDeploy.js +14 -12
- package/lib/templates.js +23 -0
- package/lib/utils.js +2 -2
- package/package.json +25 -24
- package/schema/connector-yaml.json +36 -4
- package/schema/dataconnect-yaml.json +4 -0
- package/schema/firebase-config.json +0 -8
- package/templates/_gitignore +3 -0
- package/templates/init/dataconnect/connector.yaml +11 -0
- package/templates/init/dataconnect/dataconnect.yaml +2 -1
- package/templates/init/dataconnect/mutations.gql +19 -14
- package/templates/init/dataconnect/queries.gql +28 -23
- package/templates/init/dataconnect/schema.gql +1 -1
- package/lib/extensions/billingMigrationHelper.js +0 -61
|
@@ -6,7 +6,6 @@ const fs_extra_1 = require("fs-extra");
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
8
|
const glob_1 = require("glob");
|
|
9
|
-
const glob = require("glob");
|
|
10
9
|
const semver_1 = require("semver");
|
|
11
10
|
const utils_1 = require("../utils");
|
|
12
11
|
const constants_1 = require("./constants");
|
|
@@ -229,17 +228,12 @@ function getRoutesWithServerAction(serverReferenceManifest, appPathRoutesManifes
|
|
|
229
228
|
}
|
|
230
229
|
exports.getRoutesWithServerAction = getRoutesWithServerAction;
|
|
231
230
|
async function getProductionDistDirFiles(sourceDir, distDir) {
|
|
232
|
-
|
|
231
|
+
return (0, glob_1.glob)("**", {
|
|
233
232
|
ignore: [(0, path_1.join)("cache", "webpack", "*-development", "**"), (0, path_1.join)("cache", "eslint", "**")],
|
|
234
233
|
cwd: (0, path_1.join)(sourceDir, distDir),
|
|
235
234
|
nodir: true,
|
|
236
235
|
absolute: false,
|
|
237
|
-
}
|
|
238
|
-
if (err)
|
|
239
|
-
reject(err);
|
|
240
|
-
resolve(matches);
|
|
241
|
-
}));
|
|
242
|
-
return productionDistDirFiles;
|
|
236
|
+
});
|
|
243
237
|
}
|
|
244
238
|
exports.getProductionDistDirFiles = getProductionDistDirFiles;
|
|
245
239
|
async function whichNextConfigFile(dir) {
|
|
@@ -87,9 +87,9 @@ async function getDevModeHandle(cwd) {
|
|
|
87
87
|
return (0, utils_1.simpleProxy)(await host);
|
|
88
88
|
}
|
|
89
89
|
exports.getDevModeHandle = getDevModeHandle;
|
|
90
|
-
async function getConfig(
|
|
91
|
-
const { loadNuxtConfig } = await (0, utils_1.relativeRequire)(
|
|
92
|
-
return await loadNuxtConfig(
|
|
90
|
+
async function getConfig(cwd) {
|
|
91
|
+
const { loadNuxtConfig } = await (0, utils_1.relativeRequire)(cwd, "@nuxt/kit");
|
|
92
|
+
return await loadNuxtConfig({ cwd });
|
|
93
93
|
}
|
|
94
94
|
exports.getConfig = getConfig;
|
|
95
95
|
function init(setup, config) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FIRESTORE_EVENT_WITH_AUTH_CONTEXT_REGEX = exports.FIRESTORE_EVENT_REGEX = exports.FIRESTORE_EVENTS = exports.TEST_LAB_EVENT = exports.REMOTE_CONFIG_EVENT = exports.DATABASE_EVENTS = exports.FIREBASE_ALERTS_PUBLISH_EVENT = exports.STORAGE_EVENTS = exports.PUBSUB_PUBLISH_EVENT = void 0;
|
|
3
|
+
exports.FIRESTORE_EVENT_WITH_AUTH_CONTEXT_REGEX = exports.FIRESTORE_EVENT_REGEX = exports.FIREALERTS_EVENT = exports.FIRESTORE_EVENTS = exports.TEST_LAB_EVENT = exports.REMOTE_CONFIG_EVENT = exports.DATABASE_EVENTS = exports.FIREBASE_ALERTS_PUBLISH_EVENT = exports.STORAGE_EVENTS = exports.PUBSUB_PUBLISH_EVENT = void 0;
|
|
4
4
|
exports.PUBSUB_PUBLISH_EVENT = "google.cloud.pubsub.topic.v1.messagePublished";
|
|
5
5
|
exports.STORAGE_EVENTS = [
|
|
6
6
|
"google.cloud.storage.object.v1.finalized",
|
|
@@ -27,5 +27,6 @@ exports.FIRESTORE_EVENTS = [
|
|
|
27
27
|
"google.cloud.firestore.document.v1.updated.withAuthContext",
|
|
28
28
|
"google.cloud.firestore.document.v1.deleted.withAuthContext",
|
|
29
29
|
];
|
|
30
|
+
exports.FIREALERTS_EVENT = "google.firebase.firebasealerts.alerts.v1.published";
|
|
30
31
|
exports.FIRESTORE_EVENT_REGEX = /^google\.cloud\.firestore\.document\.v1\.[^\.]*$/;
|
|
31
32
|
exports.FIRESTORE_EVENT_WITH_AUTH_CONTEXT_REGEX = /^google\.cloud\.firestore\.document\.v1\..*\.withAuthContext$/;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listUsers = exports.deleteUser = exports.getUser = exports.createUser = exports.createDatabase = exports.getDatabase = exports.listDatabases = exports.updateInstanceForDataConnect = exports.createInstance = exports.instanceConsoleLink = exports.getInstance = exports.listInstances = void 0;
|
|
3
|
+
exports.listUsers = exports.deleteUser = exports.getUser = exports.createUser = exports.deleteDatabase = exports.createDatabase = exports.getDatabase = exports.listDatabases = exports.updateInstanceForDataConnect = exports.createInstance = exports.instanceConsoleLink = exports.getInstance = exports.listInstances = void 0;
|
|
4
4
|
const apiv2_1 = require("../../apiv2");
|
|
5
5
|
const api_1 = require("../../api");
|
|
6
6
|
const operationPoller = require("../../operation-poller");
|
|
@@ -124,6 +124,11 @@ async function createDatabase(projectId, instanceId, databaseId) {
|
|
|
124
124
|
return pollRes;
|
|
125
125
|
}
|
|
126
126
|
exports.createDatabase = createDatabase;
|
|
127
|
+
async function deleteDatabase(projectId, instanceId, databaseId) {
|
|
128
|
+
const res = await client.delete(`projects/${projectId}/instances/${instanceId}/databases/${databaseId}`);
|
|
129
|
+
return res.body;
|
|
130
|
+
}
|
|
131
|
+
exports.deleteDatabase = deleteDatabase;
|
|
127
132
|
async function createUser(projectId, instanceId, type, username, password) {
|
|
128
133
|
const maxRetries = 3;
|
|
129
134
|
let retries = 0;
|
package/lib/gcp/devConnect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateP4SA = exports.serviceAgentEmail = exports.getGitRepositoryLink = exports.createGitRepositoryLink = exports.listAllLinkableGitRepositories = exports.listAllConnections = exports.getConnection = exports.deleteConnection = exports.createConnection = exports.client = void 0;
|
|
3
|
+
exports.generateP4SA = exports.serviceAgentEmail = exports.sortConnectionsByCreateTime = exports.getGitRepositoryLink = exports.createGitRepositoryLink = exports.fetchGitHubInstallations = exports.listAllBranches = exports.listAllLinkableGitRepositories = exports.listAllConnections = exports.getConnection = exports.deleteConnection = exports.createConnection = exports.client = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
const serviceusage_1 = require("./serviceusage");
|
|
@@ -75,6 +75,35 @@ async function listAllLinkableGitRepositories(projectId, location, connectionId)
|
|
|
75
75
|
return repos;
|
|
76
76
|
}
|
|
77
77
|
exports.listAllLinkableGitRepositories = listAllLinkableGitRepositories;
|
|
78
|
+
async function listAllBranches(repoLinkName) {
|
|
79
|
+
const branches = new Set();
|
|
80
|
+
const getNextPage = async (pageToken = "") => {
|
|
81
|
+
const res = await exports.client.get(`${repoLinkName}:fetchGitRefs`, {
|
|
82
|
+
queryParams: {
|
|
83
|
+
refType: "BRANCH",
|
|
84
|
+
pageSize: PAGE_SIZE_MAX,
|
|
85
|
+
pageToken,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
if (Array.isArray(res.body.refNames)) {
|
|
89
|
+
res.body.refNames.forEach((branch) => {
|
|
90
|
+
branches.add(branch);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (res.body.nextPageToken) {
|
|
94
|
+
await getNextPage(res.body.nextPageToken);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
await getNextPage();
|
|
98
|
+
return branches;
|
|
99
|
+
}
|
|
100
|
+
exports.listAllBranches = listAllBranches;
|
|
101
|
+
async function fetchGitHubInstallations(projectId, location, connectionId) {
|
|
102
|
+
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE ?? location}/connections/${connectionId}:fetchGitHubInstallations`;
|
|
103
|
+
const res = await exports.client.get(name);
|
|
104
|
+
return res.body.installations;
|
|
105
|
+
}
|
|
106
|
+
exports.fetchGitHubInstallations = fetchGitHubInstallations;
|
|
78
107
|
async function createGitRepositoryLink(projectId, location, connectionId, gitRepositoryLinkId, cloneUri) {
|
|
79
108
|
const res = await exports.client.post(`projects/${projectId}/locations/${LOCATION_OVERRIDE ?? location}/connections/${connectionId}/gitRepositoryLinks`, { cloneUri }, { queryParams: { gitRepositoryLinkId } });
|
|
80
109
|
return res.body;
|
|
@@ -86,6 +115,12 @@ async function getGitRepositoryLink(projectId, location, connectionId, gitReposi
|
|
|
86
115
|
return res.body;
|
|
87
116
|
}
|
|
88
117
|
exports.getGitRepositoryLink = getGitRepositoryLink;
|
|
118
|
+
function sortConnectionsByCreateTime(connections) {
|
|
119
|
+
return connections.sort((a, b) => {
|
|
120
|
+
return Date.parse(a.createTime) - Date.parse(b.createTime);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
exports.sortConnectionsByCreateTime = sortConnectionsByCreateTime;
|
|
89
124
|
function serviceAgentEmail(projectNumber) {
|
|
90
125
|
return `service-${projectNumber}@${(0, api_1.developerConnectP4SADomain)()}`;
|
|
91
126
|
}
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.implicitInit = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("colorette");
|
|
6
|
-
const fs = require("fs");
|
|
7
6
|
const fetchWebSetup_1 = require("../fetchWebSetup");
|
|
8
7
|
const utils = require("../utils");
|
|
9
8
|
const logger_1 = require("../logger");
|
|
10
9
|
const registry_1 = require("../emulator/registry");
|
|
11
10
|
const types_1 = require("../emulator/types");
|
|
12
|
-
const
|
|
11
|
+
const templates_1 = require("../templates");
|
|
12
|
+
const INIT_TEMPLATE = (0, templates_1.readTemplateSync)("hosting/init.js");
|
|
13
13
|
async function implicitInit(options) {
|
|
14
14
|
let config;
|
|
15
15
|
try {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.doSetup = void 0;
|
|
3
|
+
exports.actuate = exports.doSetup = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
+
const clc = require("colorette");
|
|
5
6
|
const prompt_1 = require("../../../prompt");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
7
|
const provisionCloudSql_1 = require("../../../dataconnect/provisionCloudSql");
|
|
8
8
|
const freeTrial_1 = require("../../../dataconnect/freeTrial");
|
|
9
9
|
const cloudsql = require("../../../gcp/cloudsql/cloudsqladmin");
|
|
@@ -12,13 +12,34 @@ const client_1 = require("../../../dataconnect/client");
|
|
|
12
12
|
const emulators_1 = require("../emulators");
|
|
13
13
|
const names_1 = require("../../../dataconnect/names");
|
|
14
14
|
const logger_1 = require("../../../logger");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
15
|
+
const templates_1 = require("../../../templates");
|
|
16
|
+
const utils_1 = require("../../../utils");
|
|
17
|
+
const DATACONNECT_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/dataconnect.yaml");
|
|
18
|
+
const CONNECTOR_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/connector.yaml");
|
|
19
|
+
const SCHEMA_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/schema.gql");
|
|
20
|
+
const QUERIES_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/queries.gql");
|
|
21
|
+
const MUTATIONS_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/mutations.gql");
|
|
22
|
+
const defaultConnector = {
|
|
23
|
+
id: "default",
|
|
24
|
+
files: [
|
|
25
|
+
{
|
|
26
|
+
path: "queries.gql",
|
|
27
|
+
content: QUERIES_TEMPLATE,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
path: "mutations.gql",
|
|
31
|
+
content: MUTATIONS_TEMPLATE,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
21
35
|
async function doSetup(setup, config) {
|
|
36
|
+
const info = await askQuestions(setup, config);
|
|
37
|
+
await actuate(setup, config, info);
|
|
38
|
+
logger_1.logger.info("");
|
|
39
|
+
(0, utils_1.logSuccess)(`If you'd like to generate an SDK for your new connector, run ${clc.bold("firebase init dataconnect:sdk")}`);
|
|
40
|
+
}
|
|
41
|
+
exports.doSetup = doSetup;
|
|
42
|
+
async function askQuestions(setup, config) {
|
|
22
43
|
let info = {
|
|
23
44
|
serviceId: "",
|
|
24
45
|
locationId: "",
|
|
@@ -26,7 +47,9 @@ async function doSetup(setup, config) {
|
|
|
26
47
|
isNewInstance: false,
|
|
27
48
|
cloudSqlDatabase: "",
|
|
28
49
|
isNewDatabase: false,
|
|
29
|
-
|
|
50
|
+
connectors: [defaultConnector],
|
|
51
|
+
schemaGql: [],
|
|
52
|
+
shouldProvisionCSQL: false,
|
|
30
53
|
};
|
|
31
54
|
info = await promptForService(setup, info);
|
|
32
55
|
if (info.cloudSqlInstanceId === "") {
|
|
@@ -44,24 +67,17 @@ async function doSetup(setup, config) {
|
|
|
44
67
|
default: defaultConnectionString,
|
|
45
68
|
});
|
|
46
69
|
setup.rcfile.dataconnectEmulatorConfig = { postgres: { localConnectionString } };
|
|
47
|
-
|
|
48
|
-
const subbedDataconnectYaml = subValues(DATACONNECT_YAML_TEMPLATE, info);
|
|
49
|
-
const subbedConnectorYaml = subValues(CONNECTOR_YAML_TEMPLATE, info);
|
|
50
|
-
if (!config.has("dataconnect")) {
|
|
51
|
-
config.set("dataconnect.source", dir);
|
|
52
|
-
config.set("dataconnect.location", info.locationId);
|
|
53
|
-
}
|
|
54
|
-
await config.askWriteProjectFile((0, path_1.join)(dir, "dataconnect.yaml"), subbedDataconnectYaml);
|
|
55
|
-
await config.askWriteProjectFile((0, path_1.join)(dir, "schema", "schema.gql"), SCHEMA_TEMPLATE);
|
|
56
|
-
await config.askWriteProjectFile((0, path_1.join)(dir, info.connectorId, "connector.yaml"), subbedConnectorYaml);
|
|
57
|
-
await config.askWriteProjectFile((0, path_1.join)(dir, info.connectorId, "queries.gql"), QUERIES_TEMPLATE);
|
|
58
|
-
await config.askWriteProjectFile((0, path_1.join)(dir, info.connectorId, "mutations.gql"), MUTATIONS_TEMPLATE);
|
|
59
|
-
if (setup.projectId &&
|
|
70
|
+
info.shouldProvisionCSQL = !!(setup.projectId &&
|
|
60
71
|
(info.isNewInstance || info.isNewDatabase) &&
|
|
61
72
|
(await (0, prompt_1.confirm)({
|
|
62
73
|
message: "Would you like to provision your CloudSQL instance and database now? This will take a few minutes.",
|
|
63
74
|
default: true,
|
|
64
|
-
})))
|
|
75
|
+
})));
|
|
76
|
+
return info;
|
|
77
|
+
}
|
|
78
|
+
async function actuate(setup, config, info) {
|
|
79
|
+
await writeFiles(config, info);
|
|
80
|
+
if (setup.projectId && info.shouldProvisionCSQL) {
|
|
65
81
|
await (0, provisionCloudSql_1.provisionCloudSql)({
|
|
66
82
|
projectId: setup.projectId,
|
|
67
83
|
locationId: info.locationId,
|
|
@@ -72,15 +88,56 @@ async function doSetup(setup, config) {
|
|
|
72
88
|
});
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
|
-
exports.
|
|
76
|
-
function
|
|
91
|
+
exports.actuate = actuate;
|
|
92
|
+
async function writeFiles(config, info) {
|
|
93
|
+
const dir = config.get("dataconnect.source") || "dataconnect";
|
|
94
|
+
console.log(dir);
|
|
95
|
+
const subbedDataconnectYaml = subDataconnectYamlValues({
|
|
96
|
+
...info,
|
|
97
|
+
connectorIds: info.connectors.map((c) => `"./${c.id}"`).join(", "),
|
|
98
|
+
});
|
|
99
|
+
config.set("dataconnect", { source: dir });
|
|
100
|
+
await config.askWriteProjectFile((0, path_1.join)(dir, "dataconnect.yaml"), subbedDataconnectYaml);
|
|
101
|
+
if (info.schemaGql.length) {
|
|
102
|
+
(0, utils_1.logSuccess)("The service you chose already has GQL files deployed. We'll use those instead of the default templates.");
|
|
103
|
+
for (const f of info.schemaGql) {
|
|
104
|
+
await config.askWriteProjectFile((0, path_1.join)(dir, "schema", f.path), f.content);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
await config.askWriteProjectFile((0, path_1.join)(dir, "schema", "schema.gql"), SCHEMA_TEMPLATE);
|
|
109
|
+
}
|
|
110
|
+
for (const c of info.connectors) {
|
|
111
|
+
await writeConnectorFiles(config, c);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function writeConnectorFiles(config, connectorInfo) {
|
|
115
|
+
const subbedConnectorYaml = subConnectorYamlValues({ connectorId: connectorInfo.id });
|
|
116
|
+
const dir = config.get("dataconnect.source") || "dataconnect";
|
|
117
|
+
await config.askWriteProjectFile((0, path_1.join)(dir, connectorInfo.id, "connector.yaml"), subbedConnectorYaml);
|
|
118
|
+
for (const f of connectorInfo.files) {
|
|
119
|
+
await config.askWriteProjectFile((0, path_1.join)(dir, connectorInfo.id, f.path), f.content);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function subDataconnectYamlValues(replacementValues) {
|
|
77
123
|
const replacements = {
|
|
78
124
|
serviceId: "__serviceId__",
|
|
79
125
|
cloudSqlDatabase: "__cloudSqlDatabase__",
|
|
80
126
|
cloudSqlInstanceId: "__cloudSqlInstanceId__",
|
|
127
|
+
connectorIds: "__connectorIds__",
|
|
128
|
+
locationId: "__location__",
|
|
129
|
+
};
|
|
130
|
+
let replaced = DATACONNECT_YAML_TEMPLATE;
|
|
131
|
+
for (const [k, v] of Object.entries(replacementValues)) {
|
|
132
|
+
replaced = replaced.replace(replacements[k], v);
|
|
133
|
+
}
|
|
134
|
+
return replaced;
|
|
135
|
+
}
|
|
136
|
+
function subConnectorYamlValues(replacementValues) {
|
|
137
|
+
const replacements = {
|
|
81
138
|
connectorId: "__connectorId__",
|
|
82
139
|
};
|
|
83
|
-
let replaced =
|
|
140
|
+
let replaced = CONNECTOR_YAML_TEMPLATE;
|
|
84
141
|
for (const [k, v] of Object.entries(replacementValues)) {
|
|
85
142
|
replaced = replaced.replace(replacements[k], v);
|
|
86
143
|
}
|
|
@@ -96,11 +153,8 @@ async function promptForService(setup, info) {
|
|
|
96
153
|
schema: await (0, client_1.getSchema)(s.name),
|
|
97
154
|
};
|
|
98
155
|
}));
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
if (existingFreshServicesAndSchemas.length) {
|
|
103
|
-
const choices = existingFreshServicesAndSchemas.map((s) => {
|
|
156
|
+
if (existingServicesAndSchemas.length) {
|
|
157
|
+
const choices = existingServicesAndSchemas.map((s) => {
|
|
104
158
|
const serviceName = (0, names_1.parseServiceName)(s.service.name);
|
|
105
159
|
return {
|
|
106
160
|
name: `${serviceName.location}/${serviceName.serviceId}`,
|
|
@@ -122,7 +176,19 @@ async function promptForService(setup, info) {
|
|
|
122
176
|
const instanceName = (0, names_1.parseCloudSQLInstanceName)(choice.schema.primaryDatasource.postgresql?.cloudSql.instance);
|
|
123
177
|
info.cloudSqlInstanceId = instanceName.instanceId;
|
|
124
178
|
}
|
|
179
|
+
if (choice.schema.source.files) {
|
|
180
|
+
info.schemaGql = choice.schema.source.files;
|
|
181
|
+
}
|
|
125
182
|
info.cloudSqlDatabase = choice.schema.primaryDatasource.postgresql?.database ?? "";
|
|
183
|
+
const connectors = await (0, client_1.listConnectors)(choice.service.name);
|
|
184
|
+
if (connectors.length) {
|
|
185
|
+
info.connectors = connectors.map((c) => {
|
|
186
|
+
return {
|
|
187
|
+
id: c.name.split("/").pop(),
|
|
188
|
+
files: c.source.files || [],
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
}
|
|
126
192
|
}
|
|
127
193
|
}
|
|
128
194
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actuate = exports.doSetup = void 0;
|
|
4
|
+
const yaml = require("yaml");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const clc = require("colorette");
|
|
7
|
+
const prompt_1 = require("../../../prompt");
|
|
8
|
+
const fileUtils_1 = require("../../../dataconnect/fileUtils");
|
|
9
|
+
const load_1 = require("../../../dataconnect/load");
|
|
10
|
+
const logger_1 = require("../../../logger");
|
|
11
|
+
const dataconnectEmulator_1 = require("../../../emulator/dataconnectEmulator");
|
|
12
|
+
const error_1 = require("../../../error");
|
|
13
|
+
const lodash_1 = require("lodash");
|
|
14
|
+
const IOS = "ios";
|
|
15
|
+
const WEB = "web";
|
|
16
|
+
const ANDROID = "android";
|
|
17
|
+
async function doSetup(setup, config) {
|
|
18
|
+
const sdkInfo = await askQuestions(setup, config);
|
|
19
|
+
await actuate(sdkInfo, setup.projectId);
|
|
20
|
+
}
|
|
21
|
+
exports.doSetup = doSetup;
|
|
22
|
+
async function askQuestions(setup, config) {
|
|
23
|
+
const serviceCfgs = (0, fileUtils_1.readFirebaseJson)(config);
|
|
24
|
+
const serviceInfos = await Promise.all(serviceCfgs.map((c) => (0, load_1.load)(setup.projectId || "", config, c.source)));
|
|
25
|
+
const connectorChoices = serviceInfos
|
|
26
|
+
.map((si) => {
|
|
27
|
+
return si.connectorInfo.map((ci) => {
|
|
28
|
+
return {
|
|
29
|
+
name: `${si.dataConnectYaml.serviceId}/${ci.connectorYaml.connectorId}`,
|
|
30
|
+
value: ci,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
})
|
|
34
|
+
.flat();
|
|
35
|
+
if (!connectorChoices.length) {
|
|
36
|
+
throw new error_1.FirebaseError(`Your config has no connectors to set up SDKs for. Run ${clc.bold("firebase init dataconnect")} to set up a service and conenctors.`);
|
|
37
|
+
}
|
|
38
|
+
const connectorInfo = await (0, prompt_1.promptOnce)({
|
|
39
|
+
message: "Which connector do you want set up a generated SDK for?",
|
|
40
|
+
type: "list",
|
|
41
|
+
choices: connectorChoices,
|
|
42
|
+
});
|
|
43
|
+
let platforms = [];
|
|
44
|
+
while (!platforms.length) {
|
|
45
|
+
platforms = await (0, prompt_1.promptOnce)({
|
|
46
|
+
message: "Which platforms do you want to set up a generated SDK for?",
|
|
47
|
+
type: "checkbox",
|
|
48
|
+
choices: [
|
|
49
|
+
{ name: "iOS (Swift)", value: IOS },
|
|
50
|
+
{ name: "Web (JavaScript)", value: WEB },
|
|
51
|
+
{ name: "Androd (Kotlin)", value: ANDROID },
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
if (!platforms.length) {
|
|
55
|
+
logger_1.logger.info("You must pick at least one platform.");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const newConnectorYaml = JSON.parse(JSON.stringify(connectorInfo.connectorYaml));
|
|
59
|
+
if (!newConnectorYaml.generate) {
|
|
60
|
+
newConnectorYaml.generate = {};
|
|
61
|
+
}
|
|
62
|
+
if (platforms.includes(IOS)) {
|
|
63
|
+
const outputDir = await (0, prompt_1.promptOnce)({
|
|
64
|
+
message: `What directory do you want to write your Swift SDK code to? (If not absolute, path will be relative to '${connectorInfo.directory}')`,
|
|
65
|
+
type: "input",
|
|
66
|
+
default: newConnectorYaml.generate.swiftSdk?.outputDir ||
|
|
67
|
+
`./../gensdk/${newConnectorYaml.connectorId}/swift-sdk`,
|
|
68
|
+
});
|
|
69
|
+
const pkg = (0, lodash_1.camelCase)(newConnectorYaml.connectorId);
|
|
70
|
+
const swiftSdk = { outputDir, package: pkg };
|
|
71
|
+
newConnectorYaml.generate.swiftSdk = swiftSdk;
|
|
72
|
+
}
|
|
73
|
+
if (platforms.includes(WEB)) {
|
|
74
|
+
const outputDir = await (0, prompt_1.promptOnce)({
|
|
75
|
+
message: `What directory do you want to write your JavaScript SDK code to? (If not absolute, path will be relative to '${connectorInfo.directory}')`,
|
|
76
|
+
type: "input",
|
|
77
|
+
default: newConnectorYaml.generate.javascriptSdk?.outputDir ||
|
|
78
|
+
`./../gensdk/${newConnectorYaml.connectorId}/javascript-sdk`,
|
|
79
|
+
});
|
|
80
|
+
const pkg = newConnectorYaml.generate.javascriptSdk?.package ??
|
|
81
|
+
`@firebasegen/${connectorInfo.connectorYaml.connectorId}`;
|
|
82
|
+
const packageJSONDir = await (0, prompt_1.promptOnce)({
|
|
83
|
+
message: "Which directory contains the package.json that you would like to add the JavaScript SDK dependency to? (Leave blank to skip)",
|
|
84
|
+
type: "input",
|
|
85
|
+
default: newConnectorYaml.generate.javascriptSdk?.packageJSONDir,
|
|
86
|
+
});
|
|
87
|
+
const javascriptSdk = {
|
|
88
|
+
outputDir,
|
|
89
|
+
package: pkg,
|
|
90
|
+
};
|
|
91
|
+
if (packageJSONDir) {
|
|
92
|
+
javascriptSdk.packageJSONDir = packageJSONDir;
|
|
93
|
+
}
|
|
94
|
+
newConnectorYaml.generate.javascriptSdk = javascriptSdk;
|
|
95
|
+
}
|
|
96
|
+
if (platforms.includes(ANDROID)) {
|
|
97
|
+
const outputDir = await (0, prompt_1.promptOnce)({
|
|
98
|
+
message: `What directory do you want to write your Kotlin SDK code to? (If not absolute, path will be relative to '${connectorInfo.directory}')`,
|
|
99
|
+
type: "input",
|
|
100
|
+
default: newConnectorYaml.generate.kotlinSdk?.outputDir ||
|
|
101
|
+
`./../gensdk/${newConnectorYaml.connectorId}/kotlin-sdk`,
|
|
102
|
+
});
|
|
103
|
+
const pkg = newConnectorYaml.generate.kotlinSdk?.package ??
|
|
104
|
+
`connectors.${(0, lodash_1.snakeCase)(connectorInfo.connectorYaml.connectorId)}`;
|
|
105
|
+
const kotlinSdk = {
|
|
106
|
+
outputDir,
|
|
107
|
+
package: pkg,
|
|
108
|
+
};
|
|
109
|
+
newConnectorYaml.generate.kotlinSdk = kotlinSdk;
|
|
110
|
+
}
|
|
111
|
+
const shouldGenerate = !!(setup.projectId &&
|
|
112
|
+
(await (0, prompt_1.confirm)({
|
|
113
|
+
message: "Would you like to generate SDK code now?",
|
|
114
|
+
default: true,
|
|
115
|
+
})));
|
|
116
|
+
const connectorYamlContents = yaml.stringify(newConnectorYaml);
|
|
117
|
+
return { connectorYamlContents, connectorInfo, shouldGenerate };
|
|
118
|
+
}
|
|
119
|
+
async function actuate(sdkInfo, projectId) {
|
|
120
|
+
const connectorYamlPath = `${sdkInfo.connectorInfo.directory}/connector.yaml`;
|
|
121
|
+
fs.writeFileSync(connectorYamlPath, sdkInfo.connectorYamlContents, "utf8");
|
|
122
|
+
logger_1.logger.info(`Wrote new config to ${connectorYamlPath}`);
|
|
123
|
+
if (projectId && sdkInfo.shouldGenerate) {
|
|
124
|
+
await dataconnectEmulator_1.DataConnectEmulator.generate({
|
|
125
|
+
configDir: sdkInfo.connectorInfo.directory,
|
|
126
|
+
connectorId: sdkInfo.connectorInfo.connectorYaml.connectorId,
|
|
127
|
+
});
|
|
128
|
+
logger_1.logger.info(`Generated SDK code for ${sdkInfo.connectorInfo.connectorYaml.connectorId}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.actuate = actuate;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initIndexes = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const fs = require("fs");
|
|
6
5
|
const error_1 = require("../../../error");
|
|
7
6
|
const api = require("../../../firestore/api");
|
|
8
7
|
const fsutils = require("../../../fsutils");
|
|
9
8
|
const prompt_1 = require("../../../prompt");
|
|
10
9
|
const logger_1 = require("../../../logger");
|
|
10
|
+
const templates_1 = require("../../../templates");
|
|
11
11
|
const indexes = new api.FirestoreApi();
|
|
12
|
-
const INDEXES_TEMPLATE =
|
|
12
|
+
const INDEXES_TEMPLATE = (0, templates_1.readTemplateSync)("init/firestore/firestore.indexes.json");
|
|
13
13
|
function initIndexes(setup, config) {
|
|
14
14
|
logger_1.logger.info();
|
|
15
15
|
logger_1.logger.info("Firestore indexes allow you to perform complex queries while");
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initRules = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const fs = require("fs");
|
|
6
5
|
const gcp = require("../../../gcp");
|
|
7
6
|
const fsutils = require("../../../fsutils");
|
|
8
7
|
const prompt_1 = require("../../../prompt");
|
|
9
8
|
const logger_1 = require("../../../logger");
|
|
10
9
|
const utils = require("../../../utils");
|
|
10
|
+
const templates_1 = require("../../../templates");
|
|
11
11
|
const DEFAULT_RULES_FILE = "firestore.rules";
|
|
12
|
-
const RULES_TEMPLATE =
|
|
12
|
+
const RULES_TEMPLATE = (0, templates_1.readTemplateSync)("init/firestore/firestore.rules");
|
|
13
13
|
function initRules(setup, config) {
|
|
14
14
|
logger_1.logger.info();
|
|
15
15
|
logger_1.logger.info("Firestore Security Rules allow you to define how and when to allow");
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setup = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
4
|
const npm_dependencies_1 = require("./npm-dependencies");
|
|
7
5
|
const prompt_1 = require("../../../prompt");
|
|
8
6
|
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
9
|
-
const
|
|
10
|
-
const INDEX_TEMPLATE =
|
|
11
|
-
const PACKAGE_LINTING_TEMPLATE =
|
|
12
|
-
const PACKAGE_NO_LINTING_TEMPLATE =
|
|
13
|
-
const ESLINT_TEMPLATE =
|
|
14
|
-
const GITIGNORE_TEMPLATE =
|
|
7
|
+
const templates_1 = require("../../../templates");
|
|
8
|
+
const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/index.js");
|
|
9
|
+
const PACKAGE_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/package.lint.json");
|
|
10
|
+
const PACKAGE_NO_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/package.nolint.json");
|
|
11
|
+
const ESLINT_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/_eslintrc");
|
|
12
|
+
const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/_gitignore");
|
|
15
13
|
function setup(setup, config) {
|
|
16
14
|
return (0, prompt_1.prompt)(setup.functions, [
|
|
17
15
|
{
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setup = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
4
|
const spawn = require("cross-spawn");
|
|
6
|
-
const path = require("path");
|
|
7
5
|
const python_1 = require("../../../deploy/functions/runtimes/python");
|
|
8
6
|
const python_2 = require("../../../functions/python");
|
|
9
7
|
const prompt_1 = require("../../../prompt");
|
|
10
8
|
const supported_1 = require("../../../deploy/functions/runtimes/supported");
|
|
11
|
-
const
|
|
12
|
-
const MAIN_TEMPLATE =
|
|
13
|
-
const REQUIREMENTS_TEMPLATE =
|
|
14
|
-
const GITIGNORE_TEMPLATE =
|
|
9
|
+
const templates_1 = require("../../../templates");
|
|
10
|
+
const MAIN_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/python/main.py");
|
|
11
|
+
const REQUIREMENTS_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/python/requirements.txt");
|
|
12
|
+
const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/python/_gitignore");
|
|
15
13
|
async function setup(setup, config) {
|
|
16
14
|
await config.askWriteProjectFile(`${setup.functions.source}/requirements.txt`, REQUIREMENTS_TEMPLATE);
|
|
17
15
|
await config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setup = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
4
|
const npm_dependencies_1 = require("./npm-dependencies");
|
|
7
5
|
const prompt_1 = require("../../../prompt");
|
|
8
6
|
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
9
|
-
const
|
|
10
|
-
const PACKAGE_LINTING_TEMPLATE =
|
|
11
|
-
const PACKAGE_NO_LINTING_TEMPLATE =
|
|
12
|
-
const ESLINT_TEMPLATE =
|
|
13
|
-
const TSCONFIG_TEMPLATE =
|
|
14
|
-
const TSCONFIG_DEV_TEMPLATE =
|
|
15
|
-
const INDEX_TEMPLATE =
|
|
16
|
-
const GITIGNORE_TEMPLATE =
|
|
7
|
+
const templates_1 = require("../../../templates");
|
|
8
|
+
const PACKAGE_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/package.lint.json");
|
|
9
|
+
const PACKAGE_NO_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/package.nolint.json");
|
|
10
|
+
const ESLINT_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/_eslintrc");
|
|
11
|
+
const TSCONFIG_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/tsconfig.json");
|
|
12
|
+
const TSCONFIG_DEV_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/tsconfig.dev.json");
|
|
13
|
+
const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/index.ts");
|
|
14
|
+
const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/_gitignore");
|
|
17
15
|
function setup(setup, config) {
|
|
18
16
|
return (0, prompt_1.prompt)(setup.functions, [
|
|
19
17
|
{
|