firebase-tools 12.4.7 → 12.4.8

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.
@@ -642,22 +642,23 @@ async function main() {
642
642
  }
643
643
  const app = express();
644
644
  app.enable("trust proxy");
645
+ const bodyParserLimit = "32mb";
645
646
  app.use(bodyParser.json({
646
- limit: "10mb",
647
+ limit: bodyParserLimit,
647
648
  verify: rawBodySaver,
648
649
  }));
649
650
  app.use(bodyParser.text({
650
- limit: "10mb",
651
+ limit: bodyParserLimit,
651
652
  verify: rawBodySaver,
652
653
  }));
653
654
  app.use(bodyParser.urlencoded({
654
655
  extended: true,
655
- limit: "10mb",
656
+ limit: bodyParserLimit,
656
657
  verify: rawBodySaver,
657
658
  }));
658
659
  app.use(bodyParser.raw({
659
660
  type: "*/*",
660
- limit: "10mb",
661
+ limit: bodyParserLimit,
661
662
  verify: rawBodySaver,
662
663
  }));
663
664
  app.get("/__/health", (req, res) => {
@@ -10,14 +10,10 @@ const utils_2 = require("./utils");
10
10
  exports.name = "Astro";
11
11
  exports.support = "experimental";
12
12
  exports.type = 2;
13
- function getAstroVersion(cwd) {
14
- var _a;
15
- return (_a = (0, utils_1.findDependency)("astro", { cwd, depth: 0, omitDev: false })) === null || _a === void 0 ? void 0 : _a.version;
16
- }
17
13
  async function discover(dir) {
18
14
  if (!(0, fs_extra_1.existsSync)((0, path_1.join)(dir, "package.json")))
19
15
  return;
20
- if (!getAstroVersion(dir))
16
+ if (!(0, utils_2.getAstroVersion)(dir))
21
17
  return;
22
18
  const { output, publicDir: publicDirectory } = await (0, utils_2.getConfig)(dir);
23
19
  return {
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConfig = exports.getBootstrapScript = void 0;
3
+ exports.getAstroVersion = exports.getConfig = exports.getBootstrapScript = void 0;
4
4
  const path_1 = require("path");
5
+ const utils_1 = require("../utils");
6
+ const semver_1 = require("semver");
5
7
  const { dynamicImport } = require(true && "../../dynamicImport");
6
8
  function getBootstrapScript() {
7
9
  return `const entry = import('./entry.mjs');\nexport const handle = async (req, res) => (await entry).handler(req, res)`;
@@ -9,9 +11,20 @@ function getBootstrapScript() {
9
11
  exports.getBootstrapScript = getBootstrapScript;
10
12
  async function getConfig(cwd) {
11
13
  const astroDirectory = (0, path_1.dirname)(require.resolve("astro/package.json", { paths: [cwd] }));
12
- const { openConfig } = await dynamicImport((0, path_1.join)(astroDirectory, "dist", "core", "config", "config.js"));
13
- const logging = undefined;
14
- const { astroConfig: config } = await openConfig({ cmd: "build", cwd, logging });
14
+ const version = getAstroVersion(cwd);
15
+ let config;
16
+ const configPath = (0, path_1.join)(astroDirectory, "dist", "core", "config", "config.js");
17
+ if ((0, semver_1.gte)(version, "2.9.7")) {
18
+ const { resolveConfig } = await dynamicImport(configPath);
19
+ const { astroConfig } = await resolveConfig({ root: cwd }, "build");
20
+ config = astroConfig;
21
+ }
22
+ else {
23
+ const { openConfig } = await dynamicImport(configPath);
24
+ const logging = undefined;
25
+ const { astroConfig } = await openConfig({ cmd: "build", cwd, logging });
26
+ config = astroConfig;
27
+ }
15
28
  return {
16
29
  outDir: (0, path_1.relative)(cwd, config.outDir.pathname),
17
30
  publicDir: (0, path_1.relative)(cwd, config.publicDir.pathname),
@@ -20,3 +33,8 @@ async function getConfig(cwd) {
20
33
  };
21
34
  }
22
35
  exports.getConfig = getConfig;
36
+ function getAstroVersion(cwd) {
37
+ var _a;
38
+ return (_a = (0, utils_1.findDependency)("astro", { cwd, depth: 0, omitDev: false })) === null || _a === void 0 ? void 0 : _a.version;
39
+ }
40
+ exports.getAstroVersion = getAstroVersion;
@@ -29,6 +29,7 @@ exports.name = "Next.js";
29
29
  exports.support = "preview";
30
30
  exports.type = 2;
31
31
  exports.docsUrl = "https://firebase.google.com/docs/hosting/frameworks/nextjs";
32
+ const BUNDLE_NEXT_CONFIG_TIMEOUT = 60000;
32
33
  const DEFAULT_NUMBER_OF_REASONS_TO_LIST = 5;
33
34
  function getReactVersion(cwd) {
34
35
  var _a;
@@ -297,7 +298,6 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
297
298
  }));
298
299
  }
299
300
  exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
300
- const BUNDLE_NEXT_CONFIG_TIMEOUT = 10000;
301
301
  async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
302
302
  const { distDir } = await getConfig(sourceDir);
303
303
  const packageJson = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, "package.json"));
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBuild = exports.createStack = exports.API_VERSION = void 0;
3
+ exports.createBuild = exports.getStack = exports.createStack = exports.API_VERSION = void 0;
4
4
  const apiv2_1 = require("../apiv2");
5
5
  const api_1 = require("../api");
6
- exports.API_VERSION = "v2";
6
+ exports.API_VERSION = "v1alpha";
7
7
  const client = new apiv2_1.Client({
8
8
  urlPrefix: api_1.frameworksOrigin,
9
9
  auth: true,
@@ -15,6 +15,12 @@ async function createStack(projectId, location, stackInput) {
15
15
  return res.body;
16
16
  }
17
17
  exports.createStack = createStack;
18
+ async function getStack(projectId, location, stackId) {
19
+ const name = `projects/${projectId}/locations/${location}/stacks/${stackId}`;
20
+ const res = await client.get(name);
21
+ return res.body;
22
+ }
23
+ exports.getStack = getStack;
18
24
  async function createBuild(projectId, location, stackId, buildInput) {
19
25
  const buildId = buildInput.name;
20
26
  const res = await client.post(`projects/${projectId}/locations/${location}/stacks/${stackId}/builds`, buildInput, { queryParams: { buildId } });
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStack = exports.doSetup = void 0;
3
+ exports.createStack = exports.getOrCreateStack = exports.doSetup = void 0;
4
4
  const clc = require("colorette");
5
5
  const utils = require("../../../utils");
6
6
  const logger_1 = require("../../../logger");
7
7
  const prompt_1 = require("../../../prompt");
8
8
  const constants_1 = require("./constants");
9
- const repo_1 = require("./repo");
9
+ const repo = require("./repo");
10
10
  const poller = require("../../../operation-poller");
11
11
  const api_1 = require("../../../api");
12
12
  const gcp = require("../../../gcp/frameworks");
13
13
  const frameworks_1 = require("../../../gcp/frameworks");
14
+ const error_1 = require("../../../error");
14
15
  const frameworksPollerOptions = {
15
16
  apiOrigin: api_1.frameworksOrigin,
16
17
  apiVersion: frameworks_1.API_VERSION,
@@ -26,7 +27,7 @@ async function doSetup(setup) {
26
27
  name: "serviceName",
27
28
  type: "input",
28
29
  default: "acme-inc-web",
29
- message: "Create a name for your service [6-32 characters]",
30
+ message: "Create a name for your service [1-30 characters]",
30
31
  }, setup.frameworks);
31
32
  await (0, prompt_1.promptOnce)({
32
33
  name: "region",
@@ -45,19 +46,62 @@ async function doSetup(setup) {
45
46
  message: "How do you want to deploy",
46
47
  choices: constants_1.ALLOWED_DEPLOY_METHODS,
47
48
  }, setup.frameworks);
48
- if (setup.frameworks.deployMethod === "github") {
49
- const cloudBuildConnRepo = await (0, repo_1.linkGitHubRepository)(projectId, setup.frameworks.region, setup.frameworks.serviceName);
50
- toStack(cloudBuildConnRepo, setup.frameworks.serviceName);
51
- }
49
+ await getOrCreateStack(projectId, setup);
52
50
  }
53
51
  exports.doSetup = doSetup;
54
52
  function toStack(cloudBuildConnRepo, stackId) {
55
53
  return {
56
54
  name: stackId,
57
- codebase: { repository: cloudBuildConnRepo.name, rootDirectory: "/" },
58
55
  labels: {},
59
56
  };
60
57
  }
58
+ async function getOrCreateStack(projectId, setup) {
59
+ const location = setup.frameworks.region;
60
+ const deployMethod = setup.frameworks.deployMethod;
61
+ try {
62
+ return await getExistingStack(projectId, setup, location);
63
+ }
64
+ catch (err) {
65
+ if (err.status === 404) {
66
+ logger_1.logger.info("Creating new stack.");
67
+ if (deployMethod === "github") {
68
+ const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location, setup.frameworks.serviceName);
69
+ const stackDetails = toStack(cloudBuildConnRepo, setup.frameworks.serviceName);
70
+ return await createStack(projectId, location, stackDetails);
71
+ }
72
+ }
73
+ else {
74
+ throw new error_1.FirebaseError(`Failed to get or create a stack using the given initialization details: ${err}`);
75
+ }
76
+ }
77
+ return undefined;
78
+ }
79
+ exports.getOrCreateStack = getOrCreateStack;
80
+ async function getExistingStack(projectId, setup, location) {
81
+ let stack = await gcp.getStack(projectId, location, setup.frameworks.serviceName);
82
+ while (stack) {
83
+ setup.frameworks.serviceName = undefined;
84
+ await (0, prompt_1.promptOnce)({
85
+ name: "existingStack",
86
+ type: "confirm",
87
+ default: true,
88
+ message: "A stack already exists for the given serviceName, do you want to use existing stack? (yes/no)",
89
+ }, setup.frameworks);
90
+ if (setup.frameworks.existingStack) {
91
+ logger_1.logger.info("Using the existing stack.");
92
+ return stack;
93
+ }
94
+ await (0, prompt_1.promptOnce)({
95
+ name: "serviceName",
96
+ type: "input",
97
+ default: "acme-inc-web",
98
+ message: "Please enter a new service name [1-30 characters]",
99
+ }, setup.frameworks);
100
+ stack = await gcp.getStack(projectId, location, setup.frameworks.serviceName);
101
+ setup.frameworks.existingStack = undefined;
102
+ }
103
+ return stack;
104
+ }
61
105
  async function createStack(projectId, location, stackInput) {
62
106
  const op = await gcp.createStack(projectId, location, stackInput);
63
107
  const stack = await poller.pollOperation(Object.assign(Object.assign({}, frameworksPollerOptions), { pollerName: `create-${projectId}-${location}-${stackInput.name}`, operationResourceName: op.name }));
@@ -32,7 +32,7 @@ async function linkGitHubRepository(projectId, location, stackId) {
32
32
  await utils.openInBrowser("https://github.com/apps/google-cloud-build/installations/new");
33
33
  await (0, prompt_1.promptOnce)({
34
34
  type: "input",
35
- message: "Press any key once you have finished configuring your installation's access settings.",
35
+ message: "Press ENTER once you have finished configuring your installation's access settings.",
36
36
  });
37
37
  remoteUri = await promptRepositoryURI(projectId, location, connectionId);
38
38
  }
package/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openInBrowser = exports.connectableHostname = exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.promiseWithSpinner = exports.setupLoggers = exports.tryParse = exports.tryStringify = exports.promiseProps = exports.withTimeout = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.getInheritedOption = exports.consoleUrl = exports.envOverrides = void 0;
3
+ exports.openInBrowser = exports.connectableHostname = exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isVSCodeExtension = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.promiseWithSpinner = exports.setupLoggers = exports.tryParse = exports.tryStringify = exports.promiseProps = exports.withTimeout = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.getInheritedOption = exports.consoleUrl = exports.envOverrides = void 0;
4
4
  const _ = require("lodash");
5
5
  const url = require("url");
6
6
  const clc = require("colorette");
@@ -367,6 +367,10 @@ function isCloudEnvironment() {
367
367
  return !!process.env.CODESPACES || !!process.env.GOOGLE_CLOUD_WORKSTATIONS;
368
368
  }
369
369
  exports.isCloudEnvironment = isCloudEnvironment;
370
+ function isVSCodeExtension() {
371
+ return !!process.env.VSCODE_CWD;
372
+ }
373
+ exports.isVSCodeExtension = isVSCodeExtension;
370
374
  function isRunningInWSL() {
371
375
  return !!process.env.WSL_DISTRO_NAME;
372
376
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "12.4.7",
3
+ "version": "12.4.8",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {