firebase-tools-with-isolate 13.9.0 → 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 +17 -15
- package/lib/commands/dataconnect-services-list.js +2 -8
- package/lib/commands/dataconnect-sql-migrate.js +0 -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 +2 -1
- package/lib/dataconnect/build.js +1 -9
- package/lib/dataconnect/client.js +67 -28
- package/lib/dataconnect/errors.js +17 -9
- package/lib/dataconnect/fileUtils.js +30 -7
- package/lib/dataconnect/filters.js +12 -1
- package/lib/dataconnect/graphqlError.js +6 -3
- package/lib/dataconnect/load.js +9 -7
- package/lib/dataconnect/names.js +21 -1
- package/lib/dataconnect/provisionCloudSql.js +37 -20
- package/lib/dataconnect/schemaMigration.js +119 -66
- package/lib/dataconnect/types.js +8 -1
- package/lib/deploy/dataconnect/deploy.js +1 -0
- package/lib/deploy/dataconnect/prepare.js +16 -2
- package/lib/deploy/dataconnect/release.js +0 -1
- package/lib/deploy/functions/build.js +10 -1
- package/lib/deploy/functions/prepare.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -1
- package/lib/deploy/functions/runtimes/supported/types.js +6 -0
- package/lib/emulator/adminSdkConfig.test.js +16 -0
- package/lib/emulator/constants.js +1 -0
- package/lib/emulator/controller.js +4 -9
- package/lib/emulator/dataconnectEmulator.js +181 -35
- package/lib/emulator/download.js +4 -0
- package/lib/emulator/downloadableEmulators.js +54 -28
- 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 +20 -2
- 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/emulator/storage/rules/runtime.js +1 -1
- 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 +21 -8
- package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
- package/lib/frameworks/index.js +2 -6
- package/lib/frameworks/next/utils.js +2 -9
- package/lib/frameworks/nuxt/index.js +3 -3
- package/lib/functions/events/v2.js +2 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +20 -2
- package/lib/gcp/cloudsql/connect.js +6 -6
- package/lib/gcp/devConnect.js +36 -1
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/init/features/dataconnect/index.js +252 -124
- 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 +2 -3
- package/lib/requireAuth.js +8 -0
- package/lib/rulesDeploy.js +14 -12
- package/lib/templates.js +23 -0
- package/lib/track.js +29 -2
- 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 +2 -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 +18 -13
- package/templates/init/dataconnect/queries.gql +34 -29
- package/templates/init/dataconnect/schema.gql +1 -1
- package/lib/extensions/billingMigrationHelper.js +0 -61
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const API = require("./api-types");
|
|
5
|
+
const pretty_print_1 = require("./pretty-print");
|
|
6
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
7
|
+
describe("prettyIndexString", () => {
|
|
8
|
+
it("should correctly print an order type Index", () => {
|
|
9
|
+
(0, chai_1.expect)(printer.prettyIndexString({
|
|
10
|
+
name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
|
|
11
|
+
queryScope: API.QueryScope.COLLECTION,
|
|
12
|
+
fields: [
|
|
13
|
+
{ fieldPath: "foo", order: API.Order.ASCENDING },
|
|
14
|
+
{ fieldPath: "bar", order: API.Order.DESCENDING },
|
|
15
|
+
],
|
|
16
|
+
}, false)).to.contain("(foo,ASCENDING) (bar,DESCENDING) ");
|
|
17
|
+
});
|
|
18
|
+
it("should correctly print a contains type Index", () => {
|
|
19
|
+
(0, chai_1.expect)(printer.prettyIndexString({
|
|
20
|
+
name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
|
|
21
|
+
queryScope: API.QueryScope.COLLECTION,
|
|
22
|
+
fields: [
|
|
23
|
+
{ fieldPath: "foo", order: API.Order.ASCENDING },
|
|
24
|
+
{ fieldPath: "baz", arrayConfig: API.ArrayConfig.CONTAINS },
|
|
25
|
+
],
|
|
26
|
+
}, false)).to.contain("(foo,ASCENDING) (baz,CONTAINS) ");
|
|
27
|
+
});
|
|
28
|
+
it("should correctly print a vector type Index", () => {
|
|
29
|
+
(0, chai_1.expect)(printer.prettyIndexString({
|
|
30
|
+
name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
|
|
31
|
+
queryScope: API.QueryScope.COLLECTION,
|
|
32
|
+
fields: [{ fieldPath: "foo", vectorConfig: { dimension: 100, flat: {} } }],
|
|
33
|
+
}, false)).to.contain("(foo,VECTOR<100>) ");
|
|
34
|
+
});
|
|
35
|
+
it("should correctly print a vector type Index with other fields", () => {
|
|
36
|
+
(0, chai_1.expect)(printer.prettyIndexString({
|
|
37
|
+
name: "/projects/project/databases/(default)/collectionGroups/collectionB/indexes/a",
|
|
38
|
+
queryScope: API.QueryScope.COLLECTION,
|
|
39
|
+
fields: [
|
|
40
|
+
{ fieldPath: "foo", order: API.Order.ASCENDING },
|
|
41
|
+
{ fieldPath: "bar", vectorConfig: { dimension: 200, flat: {} } },
|
|
42
|
+
],
|
|
43
|
+
}, false)).to.contain("(foo,ASCENDING) (bar,VECTOR<200>) ");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe("firebaseConsoleDatabaseUrl", () => {
|
|
47
|
+
it("should provide a console link", () => {
|
|
48
|
+
(0, chai_1.expect)(printer.firebaseConsoleDatabaseUrl("example-project", "example-db")).to.equal("https://console.firebase.google.com/project/example-project/firestore/databases/example-db/data");
|
|
49
|
+
});
|
|
50
|
+
it("should convert (default) to -default-", () => {
|
|
51
|
+
(0, chai_1.expect)(printer.firebaseConsoleDatabaseUrl("example-project", "(default)")).to.equal("https://console.firebase.google.com/project/example-project/firestore/databases/-default-/data");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe("prettyStringArray", () => {
|
|
55
|
+
it("should correctly print an array of strings", () => {
|
|
56
|
+
(0, chai_1.expect)(printer.prettyStringArray(["kms-key-1", "kms-key-2"])).to.equal("kms-key-1\nkms-key-2\n");
|
|
57
|
+
});
|
|
58
|
+
it("should print nothing if the array is empty", () => {
|
|
59
|
+
(0, chai_1.expect)(printer.prettyStringArray([])).to.equal("");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const util = require("./util");
|
|
5
|
+
describe("IndexNameParsing", () => {
|
|
6
|
+
it("should parse an index name correctly", () => {
|
|
7
|
+
const name = "/projects/myproject/databases/(default)/collectionGroups/collection/indexes/abc123/";
|
|
8
|
+
(0, chai_1.expect)(util.parseIndexName(name)).to.eql({
|
|
9
|
+
projectId: "myproject",
|
|
10
|
+
databaseId: "(default)",
|
|
11
|
+
collectionGroupId: "collection",
|
|
12
|
+
indexId: "abc123",
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
it("should parse a field name correctly", () => {
|
|
16
|
+
const name = "/projects/myproject/databases/(default)/collectionGroups/collection/fields/abc123/";
|
|
17
|
+
(0, chai_1.expect)(util.parseFieldName(name)).to.eql({
|
|
18
|
+
projectId: "myproject",
|
|
19
|
+
databaseId: "(default)",
|
|
20
|
+
collectionGroupId: "collection",
|
|
21
|
+
fieldPath: "abc123",
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
it("should parse an index name from a named database correctly", () => {
|
|
25
|
+
const name = "/projects/myproject/databases/named-db/collectionGroups/collection/indexes/abc123/";
|
|
26
|
+
(0, chai_1.expect)(util.parseIndexName(name)).to.eql({
|
|
27
|
+
projectId: "myproject",
|
|
28
|
+
databaseId: "named-db",
|
|
29
|
+
collectionGroupId: "collection",
|
|
30
|
+
indexId: "abc123",
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
it("should parse a field name from a named database correctly", () => {
|
|
34
|
+
const name = "/projects/myproject/databases/named-db/collectionGroups/collection/fields/abc123/";
|
|
35
|
+
(0, chai_1.expect)(util.parseFieldName(name)).to.eql({
|
|
36
|
+
projectId: "myproject",
|
|
37
|
+
databaseId: "named-db",
|
|
38
|
+
collectionGroupId: "collection",
|
|
39
|
+
fieldPath: "abc123",
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAngularVersion = exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = exports.getAllTargets = void 0;
|
|
3
|
+
exports.tryToGetOptionsForTarget = exports.getAngularVersion = exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = exports.getAllTargets = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const error_1 = require("../../error");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -143,8 +143,9 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
143
143
|
if (apps.length === 1)
|
|
144
144
|
project = apps[0];
|
|
145
145
|
}
|
|
146
|
-
if (!project)
|
|
147
|
-
|
|
146
|
+
if (!project) {
|
|
147
|
+
throwCannotDetermineTarget();
|
|
148
|
+
}
|
|
148
149
|
const workspaceProject = workspace.projects.get(project);
|
|
149
150
|
if (!workspaceProject)
|
|
150
151
|
throw new error_1.FirebaseError(`No project ${project} found.`);
|
|
@@ -309,6 +310,8 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
309
310
|
continue;
|
|
310
311
|
if (target === buildTarget && builder === "@angular-devkit/build-angular:application")
|
|
311
312
|
continue;
|
|
313
|
+
if (target === buildTarget && builder === "@angular-devkit/build-angular:browser")
|
|
314
|
+
continue;
|
|
312
315
|
if (target === browserTarget && builder === "@angular-devkit/build-angular:browser-esbuild")
|
|
313
316
|
continue;
|
|
314
317
|
if (target === browserTarget && builder === "@angular-devkit/build-angular:browser")
|
|
@@ -332,14 +335,14 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
332
335
|
if (!buildOrBrowserTarget) {
|
|
333
336
|
throw new error_1.FirebaseError(`No build target on ${project}`);
|
|
334
337
|
}
|
|
335
|
-
const browserTargetOptions = await architectHost
|
|
338
|
+
const browserTargetOptions = await tryToGetOptionsForTarget(architectHost, buildOrBrowserTarget);
|
|
336
339
|
if (!browserTargetOptions) {
|
|
337
340
|
const targetString = targetStringFromTarget(buildOrBrowserTarget);
|
|
338
341
|
throw new error_1.FirebaseError(`Couldn't find options for ${targetString}.`);
|
|
339
342
|
}
|
|
340
343
|
const baseHref = browserTargetOptions.baseHref || "/";
|
|
341
344
|
(0, utils_2.assertIsString)(baseHref);
|
|
342
|
-
const buildTargetOptions = buildTarget && (await architectHost
|
|
345
|
+
const buildTargetOptions = buildTarget && (await tryToGetOptionsForTarget(architectHost, buildTarget));
|
|
343
346
|
const ssr = buildTarget ? !!buildTargetOptions?.ssr : !!serverTarget;
|
|
344
347
|
return {
|
|
345
348
|
architect,
|
|
@@ -363,10 +366,13 @@ async function getBrowserConfig(sourceDir, configuration) {
|
|
|
363
366
|
if (!buildOrBrowserTarget) {
|
|
364
367
|
throw new assert_1.AssertionError({ message: "expected build or browser target defined" });
|
|
365
368
|
}
|
|
366
|
-
const { locales, defaultLocale } = await
|
|
367
|
-
|
|
369
|
+
const [{ locales, defaultLocale }, targetOptions, builderName] = await Promise.all([
|
|
370
|
+
localesForTarget(sourceDir, architectHost, buildOrBrowserTarget, workspaceProject),
|
|
371
|
+
architectHost.getOptionsForTarget(buildOrBrowserTarget),
|
|
372
|
+
architectHost.getBuilderNameForTarget(buildOrBrowserTarget),
|
|
373
|
+
]);
|
|
368
374
|
(0, utils_2.assertIsString)(targetOptions?.outputPath);
|
|
369
|
-
const outputPath = (0, path_1.join)(targetOptions.outputPath, buildTarget ? "browser" : "");
|
|
375
|
+
const outputPath = (0, path_1.join)(targetOptions.outputPath, buildTarget && builderName === "@angular-devkit/build-angular:application" ? "browser" : "");
|
|
370
376
|
return { locales, baseHref, outputPath, defaultLocale };
|
|
371
377
|
}
|
|
372
378
|
exports.getBrowserConfig = getBrowserConfig;
|
|
@@ -460,3 +466,10 @@ function getAngularVersion(cwd) {
|
|
|
460
466
|
return angularVersionSemver.toString();
|
|
461
467
|
}
|
|
462
468
|
exports.getAngularVersion = getAngularVersion;
|
|
469
|
+
async function tryToGetOptionsForTarget(architectHost, target) {
|
|
470
|
+
return await architectHost.getOptionsForTarget(target).catch(throwCannotDetermineTarget);
|
|
471
|
+
}
|
|
472
|
+
exports.tryToGetOptionsForTarget = tryToGetOptionsForTarget;
|
|
473
|
+
function throwCannotDetermineTarget(error) {
|
|
474
|
+
throw new error_1.FirebaseError(`Unable to determine the application to deploy, specify a target via the FIREBASE_FRAMEWORKS_BUILD_TARGET environment variable.`, { original: error });
|
|
475
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockFileSystem = void 0;
|
|
4
|
+
class MockFileSystem {
|
|
5
|
+
constructor(fileSys) {
|
|
6
|
+
this.fileSys = fileSys;
|
|
7
|
+
this.existsCache = {};
|
|
8
|
+
this.contentCache = {};
|
|
9
|
+
}
|
|
10
|
+
exists(path) {
|
|
11
|
+
if (!(path in this.existsCache)) {
|
|
12
|
+
this.existsCache[path] = path in this.fileSys;
|
|
13
|
+
}
|
|
14
|
+
return Promise.resolve(this.existsCache[path]);
|
|
15
|
+
}
|
|
16
|
+
read(path) {
|
|
17
|
+
if (!(path in this.contentCache)) {
|
|
18
|
+
if (!(path in this.fileSys)) {
|
|
19
|
+
const err = new Error("File path not found");
|
|
20
|
+
err.cause = "ENOENT";
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.contentCache[path] = this.fileSys[path];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return Promise.resolve(this.contentCache[path]);
|
|
28
|
+
}
|
|
29
|
+
getContentCache(path) {
|
|
30
|
+
return this.contentCache[path];
|
|
31
|
+
}
|
|
32
|
+
getExistsCache(path) {
|
|
33
|
+
return this.existsCache[path];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.MockFileSystem = MockFileSystem;
|
package/lib/frameworks/index.js
CHANGED
|
@@ -7,8 +7,8 @@ const child_process_1 = require("child_process");
|
|
|
7
7
|
const cross_spawn_1 = require("cross-spawn");
|
|
8
8
|
const promises_1 = require("fs/promises");
|
|
9
9
|
const fs_extra_1 = require("fs-extra");
|
|
10
|
+
const glob_1 = require("glob");
|
|
10
11
|
const process = require("node:process");
|
|
11
|
-
const glob = require("glob");
|
|
12
12
|
const projectUtils_1 = require("../projectUtils");
|
|
13
13
|
const config_1 = require("../hosting/config");
|
|
14
14
|
const api_1 = require("../hosting/api");
|
|
@@ -365,11 +365,7 @@ async function prepareFrameworks(purpose, targetNames, context, options, emulato
|
|
|
365
365
|
await (0, promises_1.writeFile)((0, path_1.join)(functionsDist, ".env"), `${dotEnvContents}
|
|
366
366
|
__FIREBASE_FRAMEWORKS_ENTRY__=${frameworksEntry}
|
|
367
367
|
${firebaseDefaults ? `__FIREBASE_DEFAULTS__=${JSON.stringify(firebaseDefaults)}\n` : ""}`.trimStart());
|
|
368
|
-
const envs = await
|
|
369
|
-
if (err)
|
|
370
|
-
reject(err);
|
|
371
|
-
resolve(matches);
|
|
372
|
-
}));
|
|
368
|
+
const envs = await (0, glob_1.glob)(getProjectPath(".env.*"));
|
|
373
369
|
await Promise.all(envs.map((path) => (0, promises_1.copyFile)(path, (0, path_1.join)(functionsDist, (0, path_1.basename)(path)))));
|
|
374
370
|
(0, child_process_1.execSync)(`npm i --omit dev --no-audit`, {
|
|
375
371
|
cwd: functionsDist,
|
|
@@ -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,18 +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
|
-
}, (err, matches) => {
|
|
239
|
-
if (err)
|
|
240
|
-
reject(err);
|
|
241
|
-
resolve(matches);
|
|
242
|
-
}));
|
|
243
|
-
return productionDistDirFiles;
|
|
236
|
+
});
|
|
244
237
|
}
|
|
245
238
|
exports.getProductionDistDirFiles = getProductionDistDirFiles;
|
|
246
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,9 +1,10 @@
|
|
|
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.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");
|
|
7
|
+
const error_1 = require("../../error");
|
|
7
8
|
const API_VERSION = "v1";
|
|
8
9
|
const client = new apiv2_1.Client({
|
|
9
10
|
urlPrefix: (0, api_1.cloudSQLAdminOrigin)(),
|
|
@@ -17,10 +18,17 @@ async function listInstances(projectId) {
|
|
|
17
18
|
exports.listInstances = listInstances;
|
|
18
19
|
async function getInstance(projectId, instanceId) {
|
|
19
20
|
const res = await client.get(`projects/${projectId}/instances/${instanceId}`);
|
|
21
|
+
if (res.body.state === "FAILED") {
|
|
22
|
+
throw new error_1.FirebaseError(`Cloud SQL instance ${instanceId} is in a failed state.\nGo to ${instanceConsoleLink(projectId, instanceId)} to repair or delete it.`);
|
|
23
|
+
}
|
|
20
24
|
return res.body;
|
|
21
25
|
}
|
|
22
26
|
exports.getInstance = getInstance;
|
|
23
|
-
|
|
27
|
+
function instanceConsoleLink(projectId, instanceId) {
|
|
28
|
+
return `https://console.cloud.google.com/sql/instances/${instanceId}/overview?project=${projectId}`;
|
|
29
|
+
}
|
|
30
|
+
exports.instanceConsoleLink = instanceConsoleLink;
|
|
31
|
+
async function createInstance(projectId, location, instanceId, enableGoogleMlIntegration, waitForCreation) {
|
|
24
32
|
const databaseFlags = [{ name: "cloudsql.iam_authentication", value: "on" }];
|
|
25
33
|
if (enableGoogleMlIntegration) {
|
|
26
34
|
databaseFlags.push({ name: "cloudsql.enable_google_ml_integration", value: "on" });
|
|
@@ -41,9 +49,14 @@ async function createInstance(projectId, location, instanceId, enableGoogleMlInt
|
|
|
41
49
|
userLabels: { "firebase-data-connect": "ft" },
|
|
42
50
|
insightsConfig: {
|
|
43
51
|
queryInsightsEnabled: true,
|
|
52
|
+
queryPlansPerMinute: 5,
|
|
53
|
+
queryStringLength: 1024,
|
|
44
54
|
},
|
|
45
55
|
},
|
|
46
56
|
});
|
|
57
|
+
if (!waitForCreation) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
47
60
|
const opName = `projects/${projectId}/operations/${op.body.name}`;
|
|
48
61
|
const pollRes = await operationPoller.pollOperation({
|
|
49
62
|
apiOrigin: (0, api_1.cloudSQLAdminOrigin)(),
|
|
@@ -111,6 +124,11 @@ async function createDatabase(projectId, instanceId, databaseId) {
|
|
|
111
124
|
return pollRes;
|
|
112
125
|
}
|
|
113
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;
|
|
114
132
|
async function createUser(projectId, instanceId, type, username, password) {
|
|
115
133
|
const maxRetries = 3;
|
|
116
134
|
let retries = 0;
|
|
@@ -16,7 +16,7 @@ async function execute(sqlStatements, opts) {
|
|
|
16
16
|
const user = await cloudSqlAdminClient.getUser(opts.projectId, opts.instanceId, opts.username);
|
|
17
17
|
const connectionName = instance.connectionName;
|
|
18
18
|
if (!connectionName) {
|
|
19
|
-
throw new error_1.FirebaseError(`Could not get instance
|
|
19
|
+
throw new error_1.FirebaseError(`Could not get instance connection string for ${opts.instanceId}:${opts.databaseId}`);
|
|
20
20
|
}
|
|
21
21
|
let connector;
|
|
22
22
|
let pool;
|
|
@@ -34,7 +34,6 @@ async function execute(sqlStatements, opts) {
|
|
|
34
34
|
...clientOpts,
|
|
35
35
|
user: opts.username,
|
|
36
36
|
database: opts.databaseId,
|
|
37
|
-
max: 1,
|
|
38
37
|
});
|
|
39
38
|
break;
|
|
40
39
|
}
|
|
@@ -49,7 +48,6 @@ async function execute(sqlStatements, opts) {
|
|
|
49
48
|
...clientOpts,
|
|
50
49
|
user: opts.username,
|
|
51
50
|
database: opts.databaseId,
|
|
52
|
-
max: 1,
|
|
53
51
|
});
|
|
54
52
|
break;
|
|
55
53
|
}
|
|
@@ -69,20 +67,22 @@ async function execute(sqlStatements, opts) {
|
|
|
69
67
|
user: opts.username,
|
|
70
68
|
password: opts.password,
|
|
71
69
|
database: opts.databaseId,
|
|
72
|
-
max: 1,
|
|
73
70
|
});
|
|
74
71
|
break;
|
|
75
72
|
}
|
|
76
73
|
}
|
|
74
|
+
const conn = await pool.connect();
|
|
75
|
+
logFn(`Logged in as ${opts.username}`);
|
|
77
76
|
for (const s of sqlStatements) {
|
|
78
|
-
logFn(`Executing: '${s}'
|
|
77
|
+
logFn(`Executing: '${s}'`);
|
|
79
78
|
try {
|
|
80
|
-
await
|
|
79
|
+
await conn.query(s);
|
|
81
80
|
}
|
|
82
81
|
catch (err) {
|
|
83
82
|
throw new error_1.FirebaseError(`Error executing ${err}`);
|
|
84
83
|
}
|
|
85
84
|
}
|
|
85
|
+
conn.release();
|
|
86
86
|
await pool.end();
|
|
87
87
|
connector.close();
|
|
88
88
|
}
|
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 {
|