firebase-tools-with-isolate 13.6.4 → 13.9.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.
Files changed (157) hide show
  1. package/README.md +4 -6
  2. package/lib/api.js +18 -8
  3. package/lib/apiv2.js +19 -13
  4. package/lib/apphosting/app.js +69 -0
  5. package/lib/apphosting/config.js +97 -0
  6. package/lib/{init/features/apphosting → apphosting}/constants.js +2 -2
  7. package/lib/apphosting/githubConnections.js +263 -0
  8. package/lib/apphosting/index.js +319 -0
  9. package/lib/{init/features/apphosting → apphosting}/repo.js +12 -12
  10. package/lib/apphosting/secrets/dialogs.js +170 -0
  11. package/lib/apphosting/secrets/index.js +103 -0
  12. package/lib/checkValidTargetFilters.js +8 -1
  13. package/lib/commands/apphosting-backends-create.js +9 -4
  14. package/lib/commands/apphosting-backends-delete.js +27 -30
  15. package/lib/commands/apphosting-backends-get.js +8 -8
  16. package/lib/commands/apphosting-backends-list.js +6 -7
  17. package/lib/commands/apphosting-secrets-access.js +24 -0
  18. package/lib/commands/apphosting-secrets-describe.js +29 -0
  19. package/lib/commands/apphosting-secrets-grantaccess.js +49 -0
  20. package/lib/commands/apphosting-secrets-set.js +56 -0
  21. package/lib/commands/dataconnect-sdk-generate.js +37 -0
  22. package/lib/commands/dataconnect-services-list.js +80 -0
  23. package/lib/commands/dataconnect-sql-diff.js +25 -0
  24. package/lib/commands/dataconnect-sql-migrate.js +45 -0
  25. package/lib/commands/deploy.js +27 -1
  26. package/lib/commands/firestore-databases-create.js +1 -0
  27. package/lib/commands/firestore-databases-restore.js +1 -0
  28. package/lib/commands/functions-secrets-access.js +2 -2
  29. package/lib/commands/functions-secrets-describe.js +14 -0
  30. package/lib/commands/functions-secrets-destroy.js +2 -2
  31. package/lib/commands/functions-secrets-get.js +3 -17
  32. package/lib/commands/functions-secrets-prune.js +2 -1
  33. package/lib/commands/functions-secrets-set.js +3 -19
  34. package/lib/commands/index.js +25 -6
  35. package/lib/commands/init.js +10 -3
  36. package/lib/commands/setup-emulators-dataconnect.js +12 -0
  37. package/lib/config.js +1 -0
  38. package/lib/dataconnect/build.js +22 -0
  39. package/lib/dataconnect/checkIam.js +30 -0
  40. package/lib/dataconnect/client.js +112 -0
  41. package/lib/dataconnect/dataplaneClient.js +16 -0
  42. package/lib/dataconnect/ensureApis.js +12 -0
  43. package/lib/dataconnect/errors.js +29 -0
  44. package/lib/dataconnect/fileUtils.js +92 -0
  45. package/lib/dataconnect/filters.js +45 -0
  46. package/lib/dataconnect/freeTrial.js +22 -0
  47. package/lib/dataconnect/graphqlError.js +12 -0
  48. package/lib/dataconnect/load.js +40 -0
  49. package/lib/dataconnect/names.js +46 -0
  50. package/lib/dataconnect/prompts.js +20 -0
  51. package/lib/dataconnect/provisionCloudSql.js +74 -0
  52. package/lib/dataconnect/schemaMigration.js +246 -0
  53. package/lib/dataconnect/types.js +22 -0
  54. package/lib/deploy/dataconnect/deploy.js +75 -0
  55. package/lib/deploy/dataconnect/index.js +9 -0
  56. package/lib/deploy/dataconnect/prepare.js +33 -0
  57. package/lib/deploy/dataconnect/release.js +65 -0
  58. package/lib/deploy/firestore/prepare.js +4 -2
  59. package/lib/deploy/functions/checkIam.js +6 -39
  60. package/lib/deploy/functions/containerCleaner.js +1 -15
  61. package/lib/deploy/functions/deploy.js +2 -2
  62. package/lib/deploy/functions/params.js +2 -2
  63. package/lib/deploy/functions/prepare.js +13 -3
  64. package/lib/deploy/functions/pricing.js +2 -2
  65. package/lib/deploy/functions/prompts.js +39 -7
  66. package/lib/deploy/functions/release/fabricator.js +12 -7
  67. package/lib/deploy/functions/release/index.js +17 -2
  68. package/lib/deploy/functions/release/planner.js +11 -3
  69. package/lib/deploy/functions/runtimes/discovery/index.js +3 -3
  70. package/lib/deploy/functions/runtimes/index.js +6 -43
  71. package/lib/deploy/functions/runtimes/node/index.js +3 -2
  72. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +15 -34
  73. package/lib/deploy/functions/runtimes/python/index.js +10 -7
  74. package/lib/deploy/functions/runtimes/supported/index.js +80 -0
  75. package/lib/deploy/functions/runtimes/supported/types.js +74 -0
  76. package/lib/deploy/functions/services/index.js +4 -0
  77. package/lib/deploy/index.js +2 -0
  78. package/lib/downloadUtils.js +3 -2
  79. package/lib/emulator/constants.js +3 -0
  80. package/lib/emulator/controller.js +44 -13
  81. package/lib/emulator/dataconnectEmulator.js +95 -0
  82. package/lib/emulator/download.js +1 -1
  83. package/lib/emulator/downloadableEmulators.js +57 -8
  84. package/lib/emulator/functionsEmulator.js +2 -2
  85. package/lib/emulator/hub.js +5 -0
  86. package/lib/emulator/portUtils.js +3 -3
  87. package/lib/emulator/registry.js +6 -1
  88. package/lib/emulator/types.js +3 -0
  89. package/lib/experiments.js +31 -6
  90. package/lib/extensions/emulator/specHelper.js +9 -42
  91. package/lib/extensions/extensionsApi.js +2 -2
  92. package/lib/extensions/localHelper.js +3 -3
  93. package/lib/firestore/pretty-print.js +5 -0
  94. package/lib/frameworks/astro/index.js +1 -1
  95. package/lib/frameworks/flutter/index.js +2 -2
  96. package/lib/frameworks/next/constants.js +2 -1
  97. package/lib/frameworks/next/index.js +27 -15
  98. package/lib/frameworks/next/utils.js +33 -3
  99. package/lib/functional.js +2 -2
  100. package/lib/functions/events/v2.js +7 -1
  101. package/lib/functions/python.js +4 -3
  102. package/lib/functions/secrets.js +40 -22
  103. package/lib/gcp/apphosting.js +25 -3
  104. package/lib/gcp/cloudbuild.js +7 -3
  105. package/lib/gcp/cloudfunctions.js +5 -5
  106. package/lib/gcp/cloudfunctionsv2.js +3 -3
  107. package/lib/gcp/cloudscheduler.js +2 -2
  108. package/lib/gcp/cloudsql/cloudsqladmin.js +174 -0
  109. package/lib/gcp/cloudsql/connect.js +144 -0
  110. package/lib/gcp/cloudsql/fbToolsAuthClient.js +44 -0
  111. package/lib/gcp/computeEngine.js +7 -0
  112. package/lib/gcp/devConnect.js +25 -12
  113. package/lib/gcp/firedata.js +27 -0
  114. package/lib/gcp/iam.js +41 -1
  115. package/lib/gcp/secretManager.js +55 -7
  116. package/lib/gcp/serviceusage.js +24 -5
  117. package/lib/hosting/interactive.js +4 -0
  118. package/lib/init/features/dataconnect/index.js +166 -0
  119. package/lib/init/features/emulators.js +13 -1
  120. package/lib/init/features/functions/index.js +19 -3
  121. package/lib/init/features/functions/npm-dependencies.js +12 -23
  122. package/lib/init/features/functions/python.js +4 -3
  123. package/lib/init/features/genkit.js +53 -0
  124. package/lib/init/features/hosting/github.js +4 -5
  125. package/lib/init/features/index.js +6 -2
  126. package/lib/init/index.js +2 -0
  127. package/lib/init/spawn.js +23 -0
  128. package/lib/logger.js +22 -2
  129. package/lib/operation-poller.js +8 -2
  130. package/lib/rc.js +9 -1
  131. package/lib/requireAuth.js +1 -8
  132. package/lib/requireTosAcceptance.js +22 -0
  133. package/lib/utils.js +76 -8
  134. package/package.json +11 -5
  135. package/schema/connector-yaml.json +54 -0
  136. package/schema/dataconnect-yaml.json +72 -0
  137. package/schema/firebase-config.json +115 -2
  138. package/templates/extensions/javascript/package.lint.json +2 -2
  139. package/templates/extensions/javascript/package.nolint.json +2 -2
  140. package/templates/extensions/typescript/package.lint.json +2 -2
  141. package/templates/extensions/typescript/package.nolint.json +2 -2
  142. package/templates/init/dataconnect/connector.yaml +2 -0
  143. package/templates/init/dataconnect/dataconnect.yaml +10 -0
  144. package/templates/init/dataconnect/mutations.gql +30 -0
  145. package/templates/init/dataconnect/queries.gql +51 -0
  146. package/templates/init/dataconnect/schema.gql +28 -0
  147. package/templates/init/functions/javascript/_gitignore +2 -1
  148. package/templates/init/functions/javascript/package.lint.json +2 -2
  149. package/templates/init/functions/javascript/package.nolint.json +2 -2
  150. package/templates/init/functions/python/_gitignore +1 -0
  151. package/templates/init/functions/typescript/_eslintrc +1 -0
  152. package/templates/init/functions/typescript/_gitignore +1 -0
  153. package/templates/init/functions/typescript/package.lint.json +2 -2
  154. package/templates/init/functions/typescript/package.nolint.json +2 -2
  155. package/lib/init/features/apphosting/index.js +0 -229
  156. package/lib/monospace/index.js +0 -82
  157. /package/lib/{monospace/interfaces.js → gcp/cloudsql/types.js} +0 -0
@@ -0,0 +1 @@
1
+ *.local
@@ -19,6 +19,7 @@ module.exports = {
19
19
  },
20
20
  ignorePatterns: [
21
21
  "/lib/**/*", // Ignore built files.
22
+ "/generated/**/*", // Ignore generated files.
22
23
  ],
23
24
  plugins: [
24
25
  "@typescript-eslint",
@@ -7,3 +7,4 @@ typings/
7
7
 
8
8
  # Node.js dependency directory
9
9
  node_modules/
10
+ *.local
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "lib/index.js",
17
17
  "dependencies": {
18
- "firebase-admin": "^11.8.0",
19
- "firebase-functions": "^4.3.1"
18
+ "firebase-admin": "^12.1.0",
19
+ "firebase-functions": "^5.0.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@typescript-eslint/eslint-plugin": "^5.12.0",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "main": "lib/index.js",
16
16
  "dependencies": {
17
- "firebase-admin": "^11.8.0",
18
- "firebase-functions": "^4.3.1"
17
+ "firebase-admin": "^12.1.0",
18
+ "firebase-functions": "^5.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "^4.9.0",
@@ -1,229 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.orchestrateRollout = exports.setDefaultTrafficPolicy = exports.createBackend = exports.doSetup = void 0;
4
- const clc = require("colorette");
5
- const repo = require("./repo");
6
- const poller = require("../../../operation-poller");
7
- const apphosting = require("../../../gcp/apphosting");
8
- const utils_1 = require("../../../utils");
9
- const api_1 = require("../../../api");
10
- const apphosting_1 = require("../../../gcp/apphosting");
11
- const resourceManager_1 = require("../../../gcp/resourceManager");
12
- const iam_1 = require("../../../gcp/iam");
13
- const error_1 = require("../../../error");
14
- const prompt_1 = require("../../../prompt");
15
- const constants_1 = require("./constants");
16
- const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
17
- const deploymentTool = require("../../../deploymentTool");
18
- const DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME = "firebase-app-hosting-compute";
19
- const apphostingPollerOptions = {
20
- apiOrigin: (0, api_1.apphostingOrigin)(),
21
- apiVersion: apphosting_1.API_VERSION,
22
- masterTimeout: 25 * 60 * 1000,
23
- maxBackoff: 10000,
24
- };
25
- async function doSetup(projectId, location, serviceAccount) {
26
- await Promise.all([
27
- (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.cloudbuildOrigin)(), "apphosting", true),
28
- (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.secretManagerOrigin)(), "apphosting", true),
29
- (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.cloudRunApiOrigin)(), "apphosting", true),
30
- (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.artifactRegistryDomain)(), "apphosting", true),
31
- ]);
32
- const allowedLocations = (await apphosting.listLocations(projectId)).map((loc) => loc.locationId);
33
- if (location) {
34
- if (!allowedLocations.includes(location)) {
35
- throw new error_1.FirebaseError(`Invalid location ${location}. Valid choices are ${allowedLocations.join(", ")}`);
36
- }
37
- }
38
- (0, utils_1.logBullet)("First we need a few details to create your backend.");
39
- location =
40
- location ||
41
- (await (0, prompt_1.promptOnce)({
42
- name: "region",
43
- type: "list",
44
- default: constants_1.DEFAULT_REGION,
45
- message: "Please select a region " +
46
- `(${clc.yellow("info")}: Your region determines where your backend is located):\n`,
47
- choices: allowedLocations.map((loc) => ({ value: loc })),
48
- }));
49
- (0, utils_1.logSuccess)(`Region set to ${location}.\n`);
50
- const backendId = await promptNewBackendId(projectId, location, {
51
- name: "backendId",
52
- type: "input",
53
- default: "my-web-app",
54
- message: "Create a name for your backend [1-30 characters]",
55
- });
56
- const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location);
57
- const backend = await createBackend(projectId, location, backendId, cloudBuildConnRepo, serviceAccount);
58
- const branch = await (0, prompt_1.promptOnce)({
59
- name: "branch",
60
- type: "input",
61
- default: "main",
62
- message: "Pick a branch for continuous deployment",
63
- });
64
- await setDefaultTrafficPolicy(projectId, location, backendId, branch);
65
- const confirmRollout = await (0, prompt_1.promptOnce)({
66
- type: "confirm",
67
- name: "rollout",
68
- default: true,
69
- message: "Do you want to deploy now?",
70
- });
71
- if (!confirmRollout) {
72
- (0, utils_1.logSuccess)(`Successfully created backend:\n\t${backend.name}`);
73
- (0, utils_1.logSuccess)(`Your site will be deployed at:\n\thttps://${backend.uri}`);
74
- return;
75
- }
76
- await orchestrateRollout(projectId, location, backendId, {
77
- source: {
78
- codebase: {
79
- branch,
80
- },
81
- },
82
- });
83
- (0, utils_1.logSuccess)(`Successfully created backend:\n\t${backend.name}`);
84
- (0, utils_1.logSuccess)(`Your site is now deployed at:\n\thttps://${backend.uri}`);
85
- }
86
- exports.doSetup = doSetup;
87
- async function promptNewBackendId(projectId, location, prompt) {
88
- while (true) {
89
- const backendId = await (0, prompt_1.promptOnce)(prompt);
90
- try {
91
- await apphosting.getBackend(projectId, location, backendId);
92
- }
93
- catch (err) {
94
- if (err.status === 404) {
95
- return backendId;
96
- }
97
- throw new error_1.FirebaseError(`Failed to check if backend with id ${backendId} already exists in ${location}`, { original: err });
98
- }
99
- (0, utils_1.logWarning)(`Backend with id ${backendId} already exists in ${location}`);
100
- }
101
- }
102
- function defaultComputeServiceAccountEmail(projectId) {
103
- return `${DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME}@${projectId}.iam.gserviceaccount.com`;
104
- }
105
- async function createBackend(projectId, location, backendId, repository, serviceAccount) {
106
- const defaultServiceAccount = defaultComputeServiceAccountEmail(projectId);
107
- const backendReqBody = {
108
- servingLocality: "GLOBAL_ACCESS",
109
- codebase: {
110
- repository: `${repository.name}`,
111
- rootDirectory: "/",
112
- },
113
- labels: deploymentTool.labels(),
114
- computeServiceAccount: serviceAccount || defaultServiceAccount,
115
- };
116
- delete backendReqBody.computeServiceAccount;
117
- async function createBackendAndPoll() {
118
- const op = await apphosting.createBackend(projectId, location, backendReqBody, backendId);
119
- return await poller.pollOperation({
120
- ...apphostingPollerOptions,
121
- pollerName: `create-${projectId}-${location}-${backendId}`,
122
- operationResourceName: op.name,
123
- });
124
- }
125
- try {
126
- return await createBackendAndPoll();
127
- }
128
- catch (err) {
129
- if (err.status === 403) {
130
- if (err.message.includes(defaultServiceAccount)) {
131
- await provisionDefaultComputeServiceAccount(projectId);
132
- return await createBackendAndPoll();
133
- }
134
- else if (serviceAccount && err.message.includes(serviceAccount)) {
135
- throw new error_1.FirebaseError(`Failed to create backend due to missing delegation permissions for ${serviceAccount}. Make sure you have the iam.serviceAccounts.actAs permission.`, { children: [err] });
136
- }
137
- }
138
- throw err;
139
- }
140
- }
141
- exports.createBackend = createBackend;
142
- async function provisionDefaultComputeServiceAccount(projectId) {
143
- try {
144
- await (0, iam_1.createServiceAccount)(projectId, DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME, "Firebase App Hosting compute service account", "Default service account used to run builds and deploys for Firebase App Hosting");
145
- }
146
- catch (err) {
147
- if (err.status !== 409) {
148
- throw err;
149
- }
150
- }
151
- await (0, resourceManager_1.addServiceAccountToRoles)(projectId, defaultComputeServiceAccountEmail(projectId), [
152
- "roles/firebaseapphosting.viewer",
153
- "roles/artifactregistry.createOnPushWriter",
154
- "roles/logging.logWriter",
155
- "roles/storage.objectAdmin",
156
- "roles/firebase.sdkAdminServiceAgent",
157
- ], true);
158
- }
159
- async function setDefaultTrafficPolicy(projectId, location, backendId, codebaseBranch) {
160
- const traffic = {
161
- rolloutPolicy: {
162
- codebaseBranch: codebaseBranch,
163
- stages: [
164
- {
165
- progression: "IMMEDIATE",
166
- targetPercent: 100,
167
- },
168
- ],
169
- },
170
- };
171
- const op = await apphosting.updateTraffic(projectId, location, backendId, traffic);
172
- await poller.pollOperation({
173
- ...apphostingPollerOptions,
174
- pollerName: `updateTraffic-${projectId}-${location}-${backendId}`,
175
- operationResourceName: op.name,
176
- });
177
- }
178
- exports.setDefaultTrafficPolicy = setDefaultTrafficPolicy;
179
- async function orchestrateRollout(projectId, location, backendId, buildInput) {
180
- (0, utils_1.logBullet)("Starting a new rollout... this may take a few minutes.");
181
- const buildId = await apphosting.getNextRolloutId(projectId, location, backendId, 1);
182
- const buildOp = await apphosting.createBuild(projectId, location, backendId, buildId, buildInput);
183
- const rolloutBody = {
184
- build: `projects/${projectId}/locations/${location}/backends/${backendId}/builds/${buildId}`,
185
- };
186
- let tries = 0;
187
- let done = false;
188
- while (!done) {
189
- tries++;
190
- try {
191
- const validateOnly = true;
192
- await apphosting.createRollout(projectId, location, backendId, buildId, rolloutBody, validateOnly);
193
- done = true;
194
- }
195
- catch (err) {
196
- if (err instanceof error_1.FirebaseError && err.status === 400) {
197
- if (tries >= 5) {
198
- throw err;
199
- }
200
- await new Promise((resolve) => setTimeout(resolve, 1000));
201
- }
202
- else {
203
- throw err;
204
- }
205
- }
206
- }
207
- const rolloutOp = await apphosting.createRollout(projectId, location, backendId, buildId, rolloutBody);
208
- const rolloutPoll = poller.pollOperation({
209
- ...apphostingPollerOptions,
210
- pollerName: `create-${projectId}-${location}-backend-${backendId}-rollout-${buildId}`,
211
- operationResourceName: rolloutOp.name,
212
- });
213
- const buildPoll = poller.pollOperation({
214
- ...apphostingPollerOptions,
215
- pollerName: `create-${projectId}-${location}-backend-${backendId}-build-${buildId}`,
216
- operationResourceName: buildOp.name,
217
- });
218
- const [rollout, build] = await Promise.all([rolloutPoll, buildPoll]);
219
- (0, utils_1.logSuccess)("Rollout completed.");
220
- if (build.state !== "READY") {
221
- if (!build.buildLogsUri) {
222
- throw new error_1.FirebaseError("Failed to build your app, but failed to get build logs as well. " +
223
- "This is an internal error and should be reported");
224
- }
225
- throw new error_1.FirebaseError(`Failed to build your app. Please inspect the build logs at ${build.buildLogsUri}.`, { children: [build.error] });
226
- }
227
- return { rollout, build };
228
- }
229
- exports.orchestrateRollout = orchestrateRollout;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMonospaceEnv = exports.selectProjectInMonospace = void 0;
4
- const node_fetch_1 = require("node-fetch");
5
- const error_1 = require("../error");
6
- const logger_1 = require("../logger");
7
- const rc_1 = require("../rc");
8
- const POLL_USER_RESPONSE_MILLIS = 2000;
9
- async function selectProjectInMonospace({ projectRoot, project, isVSCE, }) {
10
- const initFirebaseResponse = await initFirebase(project);
11
- if (initFirebaseResponse.success === false) {
12
- throw new Error(String(initFirebaseResponse.error));
13
- }
14
- const { rid } = initFirebaseResponse;
15
- const authorizedProject = await pollAuthorizedProject(rid);
16
- if (!authorizedProject)
17
- return null;
18
- if (isVSCE)
19
- return authorizedProject;
20
- if (projectRoot)
21
- createFirebaseRc(projectRoot, authorizedProject);
22
- }
23
- exports.selectProjectInMonospace = selectProjectInMonospace;
24
- async function pollAuthorizedProject(rid) {
25
- const getInitFirebaseRes = await getInitFirebaseResponse(rid);
26
- if ("userResponse" in getInitFirebaseRes) {
27
- if (getInitFirebaseRes.userResponse.success) {
28
- return getInitFirebaseRes.userResponse.projectId;
29
- }
30
- return null;
31
- }
32
- const { error } = getInitFirebaseRes;
33
- if (error === "WAITING_FOR_RESPONSE") {
34
- await new Promise((res) => setTimeout(res, POLL_USER_RESPONSE_MILLIS));
35
- return pollAuthorizedProject(rid);
36
- }
37
- if (error === "USER_CANCELED") {
38
- throw new error_1.FirebaseError("User canceled without authorizing any project");
39
- }
40
- throw new error_1.FirebaseError(`Unhandled /get-init-firebase-response error`, {
41
- original: new Error(error),
42
- });
43
- }
44
- async function initFirebase(project) {
45
- const port = getMonospaceDaemonPort();
46
- if (!port)
47
- throw new error_1.FirebaseError("Undefined MONOSPACE_DAEMON_PORT");
48
- const initFirebaseURL = new URL(`http://localhost:${port}/init-firebase`);
49
- if (project) {
50
- initFirebaseURL.searchParams.set("known_project", project);
51
- }
52
- const initFirebaseRes = await (0, node_fetch_1.default)(initFirebaseURL.toString(), {
53
- method: "POST",
54
- headers: {
55
- "Content-Type": "application/json",
56
- },
57
- });
58
- const initFirebaseResponse = (await initFirebaseRes.json());
59
- return initFirebaseResponse;
60
- }
61
- async function getInitFirebaseResponse(rid) {
62
- const port = getMonospaceDaemonPort();
63
- if (!port)
64
- throw new error_1.FirebaseError("Undefined MONOSPACE_DAEMON_PORT");
65
- const getInitFirebaseRes = await (0, node_fetch_1.default)(`http://localhost:${port}/get-init-firebase-response?rid=${rid}`);
66
- const getInitFirebaseJson = (await getInitFirebaseRes.json());
67
- logger_1.logger.debug(`/get-init-firebase-response?rid=${rid} response:`);
68
- logger_1.logger.debug(getInitFirebaseJson);
69
- return getInitFirebaseJson;
70
- }
71
- function createFirebaseRc(projectDir, authorizedProject) {
72
- const firebaseRc = (0, rc_1.loadRC)({ cwd: projectDir });
73
- firebaseRc.addProjectAlias("default", authorizedProject);
74
- return firebaseRc.save();
75
- }
76
- function isMonospaceEnv() {
77
- return getMonospaceDaemonPort() !== undefined;
78
- }
79
- exports.isMonospaceEnv = isMonospaceEnv;
80
- function getMonospaceDaemonPort() {
81
- return process.env.MONOSPACE_DAEMON_PORT;
82
- }