firebase-tools-with-isolate 13.11.2 → 13.16.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 +10 -2
- 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 +57 -9
- package/lib/dataconnect/fileUtils.js +71 -7
- package/lib/dataconnect/filters.js +12 -1
- package/lib/dataconnect/load.js +9 -7
- package/lib/dataconnect/provisionCloudSql.js +5 -1
- 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/extensions/planner.js +52 -1
- package/lib/deploy/extensions/prepare.js +98 -23
- package/lib/deploy/extensions/release.js +6 -0
- package/lib/deploy/functions/build.js +15 -6
- package/lib/deploy/functions/deploy.js +12 -12
- package/lib/deploy/functions/params.js +5 -3
- package/lib/deploy/functions/prepare.js +8 -1
- package/lib/deploy/functions/release/index.js +4 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
- package/lib/emulator/adminSdkConfig.test.js +16 -0
- package/lib/emulator/constants.js +8 -0
- package/lib/emulator/controller.js +14 -10
- package/lib/emulator/dataconnectEmulator.js +122 -18
- package/lib/emulator/downloadableEmulators.js +24 -25
- package/lib/emulator/env.js +3 -0
- package/lib/emulator/eventarcEmulator.js +68 -18
- package/lib/emulator/functionsEmulator.js +119 -1
- package/lib/emulator/functionsEmulatorShared.js +20 -0
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/portUtils.js +10 -0
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/registry.js +2 -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/taskQueue.js +348 -0
- package/lib/emulator/tasksEmulator.js +237 -0
- package/lib/emulator/types.js +3 -0
- package/lib/experiments.js +8 -3
- package/lib/extensions/askUserForEventsConfig.js +18 -8
- package/lib/extensions/askUserForParam.js +3 -2
- package/lib/extensions/change-log.js +2 -4
- package/lib/extensions/displayExtensionInfo.js +5 -10
- package/lib/extensions/extensionsApi.js +1 -1
- package/lib/extensions/extensionsHelper.js +30 -10
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/refs.js +26 -11
- package/lib/extensions/runtimes/common.js +75 -0
- package/lib/extensions/types.js +56 -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/constants.js +1 -1
- package/lib/frameworks/index.js +2 -6
- package/lib/frameworks/next/constants.js +1 -1
- package/lib/frameworks/next/index.js +35 -15
- package/lib/frameworks/next/utils.js +53 -9
- 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 +104 -32
- package/lib/init/features/dataconnect/sdk.js +147 -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/prompt.js +22 -1
- 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 +12 -8
- package/templates/_gitignore +3 -0
- package/templates/init/dataconnect/connector.yaml +15 -2
- package/templates/init/dataconnect/dataconnect.yaml +5 -4
- package/templates/init/dataconnect/mutations.gql +45 -25
- package/templates/init/dataconnect/queries.gql +69 -36
- package/templates/init/dataconnect/schema.gql +38 -21
- package/lib/extensions/billingMigrationHelper.js +0 -61
|
@@ -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
|
{
|
|
@@ -69,7 +69,7 @@ async function initGitHub(setup) {
|
|
|
69
69
|
if (setup.config.hosting.predeploy) {
|
|
70
70
|
(0, utils_1.logBullet)(`You have a predeploy script configured in firebase.json.`);
|
|
71
71
|
}
|
|
72
|
-
const { script } = await promptForBuildScript();
|
|
72
|
+
const { script } = await promptForBuildScript(setup?.hosting?.useWebFrameworks);
|
|
73
73
|
const ymlDeployDoc = loadYMLDeploy();
|
|
74
74
|
let shouldWriteYMLHostingFile = true;
|
|
75
75
|
let shouldWriteYMLDeployFile = false;
|
|
@@ -80,7 +80,7 @@ async function initGitHub(setup) {
|
|
|
80
80
|
shouldWriteYMLHostingFile = overwrite;
|
|
81
81
|
}
|
|
82
82
|
if (shouldWriteYMLHostingFile) {
|
|
83
|
-
writeChannelActionYMLFile(YML_FULL_PATH_PULL_REQUEST, githubSecretName, setup.projectId, script);
|
|
83
|
+
writeChannelActionYMLFile(YML_FULL_PATH_PULL_REQUEST, githubSecretName, setup.projectId, script, setup?.hosting?.useWebFrameworks, setup?.hosting?.source);
|
|
84
84
|
logger_1.logger.info();
|
|
85
85
|
(0, utils_1.logSuccess)(`Created workflow file ${(0, colorette_1.bold)(YML_FULL_PATH_PULL_REQUEST)}`);
|
|
86
86
|
}
|
|
@@ -101,7 +101,7 @@ async function initGitHub(setup) {
|
|
|
101
101
|
shouldWriteYMLDeployFile = true;
|
|
102
102
|
}
|
|
103
103
|
if (shouldWriteYMLDeployFile) {
|
|
104
|
-
writeDeployToProdActionYMLFile(YML_FULL_PATH_MERGE, branch, githubSecretName, setup.projectId, script);
|
|
104
|
+
writeDeployToProdActionYMLFile(YML_FULL_PATH_MERGE, branch, githubSecretName, setup.projectId, script, setup?.hosting?.useWebFrameworks, setup?.hosting?.source);
|
|
105
105
|
logger_1.logger.info();
|
|
106
106
|
(0, utils_1.logSuccess)(`Created workflow file ${(0, colorette_1.bold)(YML_FULL_PATH_MERGE)}`);
|
|
107
107
|
}
|
|
@@ -155,7 +155,7 @@ function mkdirNotExists(dir) {
|
|
|
155
155
|
fs.mkdirSync(dir);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
function writeChannelActionYMLFile(ymlPath, secretName, projectId, script) {
|
|
158
|
+
function writeChannelActionYMLFile(ymlPath, secretName, projectId, script, useWebFrameworks, hostingSource) {
|
|
159
159
|
const workflowConfig = {
|
|
160
160
|
name: "Deploy to Firebase Hosting on PR",
|
|
161
161
|
on: "pull_request",
|
|
@@ -172,19 +172,31 @@ function writeChannelActionYMLFile(ymlPath, secretName, projectId, script) {
|
|
|
172
172
|
},
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
|
-
|
|
176
|
-
workflowConfig.jobs.build_and_preview.steps.push({
|
|
177
|
-
run: script,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
workflowConfig.jobs.build_and_preview.steps.push({
|
|
175
|
+
const buildAndPreviewParams = {
|
|
181
176
|
uses: HOSTING_GITHUB_ACTION_NAME,
|
|
182
177
|
with: {
|
|
183
178
|
repoToken: "${{ secrets.GITHUB_TOKEN }}",
|
|
184
179
|
firebaseServiceAccount: `\${{ secrets.${secretName} }}`,
|
|
185
180
|
projectId: projectId,
|
|
186
181
|
},
|
|
187
|
-
}
|
|
182
|
+
};
|
|
183
|
+
if (useWebFrameworks) {
|
|
184
|
+
workflowConfig.jobs.build_and_preview.steps.push({ run: "npm ci" });
|
|
185
|
+
buildAndPreviewParams.env = {
|
|
186
|
+
FIREBASE_CLI_EXPERIMENTS: "webframeworks",
|
|
187
|
+
};
|
|
188
|
+
if (hostingSource && hostingSource !== ".") {
|
|
189
|
+
workflowConfig.jobs.build_and_preview.defaults = {
|
|
190
|
+
run: { "working-directory": hostingSource },
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (script) {
|
|
195
|
+
workflowConfig.jobs.build_and_preview.steps.push({
|
|
196
|
+
run: script,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
workflowConfig.jobs.build_and_preview.steps.push(buildAndPreviewParams);
|
|
188
200
|
const ymlContents = `# This file was auto-generated by the Firebase CLI
|
|
189
201
|
# https://github.com/firebase/firebase-tools
|
|
190
202
|
|
|
@@ -193,7 +205,7 @@ ${yaml.stringify(workflowConfig)}`;
|
|
|
193
205
|
mkdirNotExists(WORKFLOW_DIR);
|
|
194
206
|
fs.writeFileSync(ymlPath, ymlContents, "utf8");
|
|
195
207
|
}
|
|
196
|
-
function writeDeployToProdActionYMLFile(ymlPath, branch, secretName, projectId, script) {
|
|
208
|
+
function writeDeployToProdActionYMLFile(ymlPath, branch, secretName, projectId, script, useWebFrameworks, hostingSource) {
|
|
197
209
|
const workflowConfig = {
|
|
198
210
|
name: "Deploy to Firebase Hosting on merge",
|
|
199
211
|
on: { push: { branches: [branch || "master"] } },
|
|
@@ -204,12 +216,7 @@ function writeDeployToProdActionYMLFile(ymlPath, branch, secretName, projectId,
|
|
|
204
216
|
},
|
|
205
217
|
},
|
|
206
218
|
};
|
|
207
|
-
|
|
208
|
-
workflowConfig.jobs.build_and_deploy.steps.push({
|
|
209
|
-
run: script,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
workflowConfig.jobs.build_and_deploy.steps.push({
|
|
219
|
+
const buildAndDeployParams = {
|
|
213
220
|
uses: HOSTING_GITHUB_ACTION_NAME,
|
|
214
221
|
with: {
|
|
215
222
|
repoToken: "${{ secrets.GITHUB_TOKEN }}",
|
|
@@ -217,7 +224,22 @@ function writeDeployToProdActionYMLFile(ymlPath, branch, secretName, projectId,
|
|
|
217
224
|
channelId: "live",
|
|
218
225
|
projectId: projectId,
|
|
219
226
|
},
|
|
220
|
-
}
|
|
227
|
+
};
|
|
228
|
+
if (useWebFrameworks) {
|
|
229
|
+
workflowConfig.jobs.build_and_deploy.steps.push({ run: "npm ci" });
|
|
230
|
+
buildAndDeployParams.env = {
|
|
231
|
+
FIREBASE_CLI_EXPERIMENTS: "webframeworks",
|
|
232
|
+
};
|
|
233
|
+
if (hostingSource && hostingSource !== ".") {
|
|
234
|
+
workflowConfig.jobs.build_and_deploy.defaults = {
|
|
235
|
+
run: { "working-directory": hostingSource },
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (script) {
|
|
240
|
+
workflowConfig.jobs.build_and_deploy.steps.push({ run: script });
|
|
241
|
+
}
|
|
242
|
+
workflowConfig.jobs.build_and_deploy.steps.push(buildAndDeployParams);
|
|
221
243
|
const ymlContents = `# This file was auto-generated by the Firebase CLI
|
|
222
244
|
# https://github.com/firebase/firebase-tools
|
|
223
245
|
|
|
@@ -270,7 +292,7 @@ async function promptForRepo(options, ghAccessToken) {
|
|
|
270
292
|
]);
|
|
271
293
|
return { repo, key, keyId };
|
|
272
294
|
}
|
|
273
|
-
async function promptForBuildScript() {
|
|
295
|
+
async function promptForBuildScript(useWebFrameworks) {
|
|
274
296
|
const { shouldSetupScript } = await (0, prompt_1.prompt)({}, [
|
|
275
297
|
{
|
|
276
298
|
type: "confirm",
|
|
@@ -286,7 +308,7 @@ async function promptForBuildScript() {
|
|
|
286
308
|
{
|
|
287
309
|
type: "input",
|
|
288
310
|
name: "script",
|
|
289
|
-
default: "npm ci && npm run build",
|
|
311
|
+
default: useWebFrameworks ? undefined : "npm ci && npm run build",
|
|
290
312
|
message: "What script should be run before every deploy?",
|
|
291
313
|
},
|
|
292
314
|
]);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const fs = require("fs");
|
|
6
5
|
const rimraf_1 = require("rimraf");
|
|
7
6
|
const path_1 = require("path");
|
|
8
7
|
const apiv2_1 = require("../../../apiv2");
|
|
@@ -15,8 +14,9 @@ const experiments = require("../../../experiments");
|
|
|
15
14
|
const getDefaultHostingSite_1 = require("../../../getDefaultHostingSite");
|
|
16
15
|
const utils_1 = require("../../../utils");
|
|
17
16
|
const interactive_1 = require("../../../hosting/interactive");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
17
|
+
const templates_1 = require("../../../templates");
|
|
18
|
+
const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/hosting/index.html");
|
|
19
|
+
const MISSING_TEMPLATE = (0, templates_1.readTemplateSync)("init/hosting/404.html");
|
|
20
20
|
const DEFAULT_IGNORES = ["firebase.json", "**/.*", "**/node_modules/**"];
|
|
21
21
|
async function doSetup(setup, config, options) {
|
|
22
22
|
setup.hosting = {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.genkit = exports.apphosting = exports.dataconnect = exports.hostingGithub = exports.remoteconfig = exports.project = exports.extensions = exports.emulators = exports.storage = exports.hosting = exports.functions = exports.firestore = exports.database = exports.account = void 0;
|
|
3
|
+
exports.genkit = exports.apphosting = exports.dataconnectSdk = exports.dataconnect = exports.hostingGithub = exports.remoteconfig = exports.project = exports.extensions = exports.emulators = exports.storage = exports.hosting = exports.functions = exports.firestore = exports.database = exports.account = void 0;
|
|
4
4
|
var account_1 = require("./account");
|
|
5
5
|
Object.defineProperty(exports, "account", { enumerable: true, get: function () { return account_1.doSetup; } });
|
|
6
6
|
var database_1 = require("./database");
|
|
@@ -25,6 +25,8 @@ var github_1 = require("./hosting/github");
|
|
|
25
25
|
Object.defineProperty(exports, "hostingGithub", { enumerable: true, get: function () { return github_1.initGitHub; } });
|
|
26
26
|
var dataconnect_1 = require("./dataconnect");
|
|
27
27
|
Object.defineProperty(exports, "dataconnect", { enumerable: true, get: function () { return dataconnect_1.doSetup; } });
|
|
28
|
+
var sdk_1 = require("./dataconnect/sdk");
|
|
29
|
+
Object.defineProperty(exports, "dataconnectSdk", { enumerable: true, get: function () { return sdk_1.doSetup; } });
|
|
28
30
|
var apphosting_1 = require("../../apphosting");
|
|
29
31
|
Object.defineProperty(exports, "apphosting", { enumerable: true, get: function () { return apphosting_1.doSetup; } });
|
|
30
32
|
var genkit_1 = require("./genkit");
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const fs = require("fs");
|
|
6
5
|
const logger_1 = require("../../logger");
|
|
7
6
|
const prompt_1 = require("../../prompt");
|
|
8
7
|
const ensureCloudResourceLocation_1 = require("../../ensureCloudResourceLocation");
|
|
9
|
-
const
|
|
8
|
+
const templates_1 = require("../../templates");
|
|
9
|
+
const RULES_TEMPLATE = (0, templates_1.readTemplateSync)("init/storage/storage.rules");
|
|
10
10
|
async function doSetup(setup, config) {
|
|
11
11
|
setup.config.storage = {};
|
|
12
12
|
(0, ensureCloudResourceLocation_1.ensureLocationSet)(setup.projectLocation, "Cloud Storage");
|
package/lib/init/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const featureFns = new Map([
|
|
|
11
11
|
["database", features.database],
|
|
12
12
|
["firestore", features.firestore],
|
|
13
13
|
["dataconnect", features.dataconnect],
|
|
14
|
+
["dataconnect:sdk", features.dataconnectSdk],
|
|
14
15
|
["functions", features.functions],
|
|
15
16
|
["hosting", features.hosting],
|
|
16
17
|
["storage", features.storage],
|
package/lib/listFiles.js
CHANGED
package/lib/management/apps.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteAppAndroidSha = exports.createAppAndroidSha = exports.listAppAndroidSha = exports.getAppConfig = exports.getAppConfigFile = exports.listFirebaseApps = exports.createWebApp = exports.createAndroidApp = exports.createIosApp = exports.getAppPlatform = exports.ShaCertificateType = exports.AppPlatform = exports.APP_LIST_PAGE_SIZE = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
4
|
const apiv2_1 = require("../apiv2");
|
|
6
5
|
const api_1 = require("../api");
|
|
7
6
|
const error_1 = require("../error");
|
|
8
7
|
const logger_1 = require("../logger");
|
|
9
8
|
const operation_poller_1 = require("../operation-poller");
|
|
9
|
+
const templates_1 = require("../templates");
|
|
10
10
|
const TIMEOUT_MILLIS = 30000;
|
|
11
11
|
exports.APP_LIST_PAGE_SIZE = 100;
|
|
12
12
|
const CREATE_APP_API_REQUEST_TIMEOUT_MILLIS = 15000;
|
|
@@ -182,7 +182,7 @@ function getAppConfigResourceString(appId, platform) {
|
|
|
182
182
|
}
|
|
183
183
|
function parseConfigFromResponse(responseBody, platform) {
|
|
184
184
|
if (platform === AppPlatform.WEB) {
|
|
185
|
-
const JS_TEMPLATE =
|
|
185
|
+
const JS_TEMPLATE = (0, templates_1.readTemplateSync)("setup/web.js");
|
|
186
186
|
return {
|
|
187
187
|
fileName: WEB_CONFIG_FILE_NAME,
|
|
188
188
|
fileContents: JS_TEMPLATE.replace("{/*--CONFIG--*/}", JSON.stringify(responseBody, null, 2)),
|
package/lib/prompt.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.confirm = exports.promptOnce = exports.prompt = void 0;
|
|
3
|
+
exports.promptForDirectory = exports.confirm = exports.promptOnce = exports.prompt = void 0;
|
|
4
4
|
const inquirer = require("inquirer");
|
|
5
|
+
const fsutils_1 = require("./fsutils");
|
|
5
6
|
const error_1 = require("./error");
|
|
7
|
+
const logger_1 = require("./logger");
|
|
6
8
|
inquirer.registerPrompt("autocomplete", require("inquirer-autocomplete-prompt"));
|
|
7
9
|
async function prompt(options, questions) {
|
|
8
10
|
const prompts = [];
|
|
@@ -47,3 +49,22 @@ async function confirm(args) {
|
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
exports.confirm = confirm;
|
|
52
|
+
async function promptForDirectory(args) {
|
|
53
|
+
let dir = "";
|
|
54
|
+
while (!dir) {
|
|
55
|
+
const target = args.config.path(await promptOnce({
|
|
56
|
+
message: "Where is your app directory?",
|
|
57
|
+
}));
|
|
58
|
+
if ((0, fsutils_1.fileExistsSync)(target)) {
|
|
59
|
+
logger_1.logger.error(`Expected a directory, but ${target} is a file. Please provide a path to a directory.`);
|
|
60
|
+
}
|
|
61
|
+
else if (!(0, fsutils_1.dirExistsSync)(target)) {
|
|
62
|
+
logger_1.logger.error(`Directory ${target} not found. Please provide a path to a directory`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
dir = target;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return dir;
|
|
69
|
+
}
|
|
70
|
+
exports.promptForDirectory = promptForDirectory;
|
package/lib/rc.js
CHANGED
package/lib/requireAuth.js
CHANGED
|
@@ -20,9 +20,6 @@ function getAuthClient(config) {
|
|
|
20
20
|
return authClient;
|
|
21
21
|
}
|
|
22
22
|
async function autoAuth(options, authScopes) {
|
|
23
|
-
if (process.env.MONOSPACE_ENV) {
|
|
24
|
-
throw new error_1.FirebaseError("autoAuth not yet implemented for IDX. Please run 'firebase login'");
|
|
25
|
-
}
|
|
26
23
|
const client = getAuthClient({ scopes: authScopes, projectId: options.project });
|
|
27
24
|
const token = await client.getAccessToken();
|
|
28
25
|
token !== null ? apiv2.setAccessToken(token) : false;
|
|
@@ -34,6 +31,14 @@ async function autoAuth(options, authScopes) {
|
|
|
34
31
|
catch (e) {
|
|
35
32
|
logger_1.logger.debug(`Error getting account credentials.`);
|
|
36
33
|
}
|
|
34
|
+
if (process.env.MONOSPACE_ENV && token && clientEmail) {
|
|
35
|
+
(0, auth_1.setActiveAccount)(options, {
|
|
36
|
+
user: { email: clientEmail },
|
|
37
|
+
tokens: { access_token: token },
|
|
38
|
+
});
|
|
39
|
+
(0, auth_1.setGlobalDefaultAccount)({ user: { email: clientEmail }, tokens: { access_token: token } });
|
|
40
|
+
options.projectId = await client.getProjectId();
|
|
41
|
+
}
|
|
37
42
|
return clientEmail;
|
|
38
43
|
}
|
|
39
44
|
async function requireAuth(options) {
|
package/lib/rulesDeploy.js
CHANGED
|
@@ -71,12 +71,13 @@ class RulesDeploy {
|
|
|
71
71
|
if (await (0, resourceManager_1.serviceAccountHasRoles)(projectNumber, saEmail, [CROSS_SERVICE_RULES_ROLE], true)) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
const addRole =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
const addRole = this.options.force ||
|
|
75
|
+
(await (0, prompt_1.promptOnce)({
|
|
76
|
+
type: "confirm",
|
|
77
|
+
name: "rulesRole",
|
|
78
|
+
message: `Cloud Storage for Firebase needs an IAM Role to use cross-service rules. Grant the new role?`,
|
|
79
|
+
default: true,
|
|
80
|
+
}, this.options));
|
|
80
81
|
if (addRole) {
|
|
81
82
|
await (0, resourceManager_1.addServiceAccountToRoles)(projectNumber, saEmail, [CROSS_SERVICE_RULES_ROLE], true);
|
|
82
83
|
utils.logLabeledBullet(RulesetType[this.type], "updated service account for cross-service rules...");
|
|
@@ -117,12 +118,13 @@ class RulesDeploy {
|
|
|
117
118
|
utils.logLabeledBullet(RulesetType[this.type], "quota exceeded error while uploading rules");
|
|
118
119
|
const history = await gcp.rules.listAllRulesets(this.options.project);
|
|
119
120
|
if (history.length > RULESET_COUNT_LIMIT) {
|
|
120
|
-
const confirm =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
const confirm = this.options.force ||
|
|
122
|
+
(await (0, prompt_1.promptOnce)({
|
|
123
|
+
type: "confirm",
|
|
124
|
+
name: "force",
|
|
125
|
+
message: `You have ${history.length} rules, do you want to delete the oldest ${RULESETS_TO_GC} to free up space?`,
|
|
126
|
+
default: false,
|
|
127
|
+
}, this.options));
|
|
126
128
|
if (confirm) {
|
|
127
129
|
const releases = await gcp.rules.listAllReleases(this.options.project);
|
|
128
130
|
const unreleased = history.filter((ruleset) => {
|
package/lib/templates.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTemplate = exports.readTemplateSync = exports.absoluteTemplateFilePath = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const TEMPLATE_ENCODING = "utf8";
|
|
9
|
+
function absoluteTemplateFilePath(relPath) {
|
|
10
|
+
if ((0, utils_1.isVSCodeExtension)()) {
|
|
11
|
+
return (0, path_1.resolve)(__dirname, "templates", relPath);
|
|
12
|
+
}
|
|
13
|
+
return (0, path_1.resolve)(__dirname, "../templates", relPath);
|
|
14
|
+
}
|
|
15
|
+
exports.absoluteTemplateFilePath = absoluteTemplateFilePath;
|
|
16
|
+
function readTemplateSync(relPath) {
|
|
17
|
+
return (0, fs_1.readFileSync)(absoluteTemplateFilePath(relPath), TEMPLATE_ENCODING);
|
|
18
|
+
}
|
|
19
|
+
exports.readTemplateSync = readTemplateSync;
|
|
20
|
+
function readTemplate(relPath) {
|
|
21
|
+
return (0, promises_1.readFile)(absoluteTemplateFilePath(relPath), TEMPLATE_ENCODING);
|
|
22
|
+
}
|
|
23
|
+
exports.readTemplate = readTemplate;
|
package/lib/utils.js
CHANGED
|
@@ -23,6 +23,7 @@ const configstore_1 = require("./configstore");
|
|
|
23
23
|
const error_1 = require("./error");
|
|
24
24
|
const logger_1 = require("./logger");
|
|
25
25
|
const prompt_1 = require("./prompt");
|
|
26
|
+
const templates_1 = require("./templates");
|
|
26
27
|
exports.IS_WINDOWS = process.platform === "win32";
|
|
27
28
|
const SUCCESS_CHAR = exports.IS_WINDOWS ? "+" : "✔";
|
|
28
29
|
const WARNING_CHAR = exports.IS_WINDOWS ? "!" : "⚠";
|
|
@@ -504,8 +505,7 @@ async function openInBrowser(url) {
|
|
|
504
505
|
}
|
|
505
506
|
exports.openInBrowser = openInBrowser;
|
|
506
507
|
async function openInBrowserPopup(url, buttonText) {
|
|
507
|
-
const popupPage =
|
|
508
|
-
.readFileSync(path.join(__dirname, "../templates/popup.html"), { encoding: "utf-8" })
|
|
508
|
+
const popupPage = (0, templates_1.readTemplateSync)("popup.html")
|
|
509
509
|
.replace("${url}", url)
|
|
510
510
|
.replace("${buttonText}", buttonText);
|
|
511
511
|
const port = await (0, portfinder_1.getPortPromise)();
|