firebase-tools 12.4.1 → 12.4.3

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 (34) hide show
  1. package/lib/commands/ext-configure.js +0 -1
  2. package/lib/commands/ext-install.js +56 -56
  3. package/lib/commands/ext-update.js +0 -1
  4. package/lib/commands/index.js +0 -2
  5. package/lib/commands/internaltesting-frameworks-compose.js +4 -2
  6. package/lib/commands/open.js +2 -2
  7. package/lib/deploy/extensions/planner.js +8 -6
  8. package/lib/deploy/functions/ensure.js +0 -3
  9. package/lib/deploy/functions/prepare.js +12 -17
  10. package/lib/deploy/functions/release/index.js +1 -1
  11. package/lib/deploy/functions/release/reporter.js +41 -24
  12. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +0 -3
  13. package/lib/deploy/functions/runtimes/node/versioning.js +0 -2
  14. package/lib/deploy/lifecycleHooks.js +25 -6
  15. package/lib/emulator/downloadableEmulators.js +3 -3
  16. package/lib/extensions/displayExtensionInfo.js +104 -42
  17. package/lib/extensions/emulator/triggerHelper.js +1 -1
  18. package/lib/extensions/extensionsApi.js +1 -1
  19. package/lib/extensions/extensionsHelper.js +19 -30
  20. package/lib/extensions/publisherApi.js +1 -2
  21. package/lib/extensions/updateHelper.js +2 -2
  22. package/lib/frameworks/compose/discover/filesystem.js +1 -1
  23. package/lib/frameworks/compose/discover/index.js +27 -18
  24. package/lib/frameworks/compose/discover/runtime/node.js +149 -0
  25. package/lib/frameworks/compose/driver/docker.js +23 -13
  26. package/lib/frameworks/compose/driver/local.js +13 -4
  27. package/lib/frameworks/compose/index.js +9 -8
  28. package/lib/frameworks/next/index.js +13 -4
  29. package/lib/{api → gcp}/frameworks.js +7 -5
  30. package/lib/init/features/frameworks/index.js +31 -1
  31. package/lib/init/features/{composer → frameworks}/repo.js +1 -4
  32. package/package.json +1 -1
  33. package/schema/firebase-config.json +4 -0
  34. package/lib/commands/internaltesting-frameworks-init.js +0 -14
@@ -18,12 +18,21 @@ class LocalDriver {
18
18
  }
19
19
  }
20
20
  install() {
21
- const [cmd, ...args] = this.spec.installCommand.split(" ");
22
- this.execCmd(cmd, args);
21
+ if (this.spec.installCommand) {
22
+ if (this.spec.packageManagerInstallCommand) {
23
+ const [cmd, ...args] = this.spec.packageManagerInstallCommand.split(" ");
24
+ this.execCmd(cmd, args);
25
+ }
26
+ const [cmd, ...args] = this.spec.installCommand.split(" ");
27
+ this.execCmd(cmd, args);
28
+ }
23
29
  }
24
30
  build() {
25
- const [cmd, ...args] = this.spec.buildCommand.split(" ");
26
- this.execCmd(cmd, args);
31
+ var _a;
32
+ if ((_a = this.spec.detectedCommands) === null || _a === void 0 ? void 0 : _a.build) {
33
+ const [cmd, ...args] = this.spec.detectedCommands.build.cmd.split(" ");
34
+ this.execCmd(cmd, args);
35
+ }
27
36
  }
28
37
  export(bundle) {
29
38
  }
@@ -3,24 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compose = void 0;
4
4
  const driver_1 = require("./driver");
5
5
  const discover_1 = require("./discover");
6
- function compose(mode) {
6
+ async function compose(mode, fs, allFrameworkSpecs) {
7
+ var _a, _b, _c, _d;
7
8
  let bundle = { version: "v1alpha" };
8
- const spec = (0, discover_1.discover)();
9
+ const spec = await (0, discover_1.discover)(fs, allFrameworkSpecs);
9
10
  const driver = (0, driver_1.getDriver)(mode, spec);
10
- if (spec.startCommand) {
11
+ if ((_a = spec.detectedCommands) === null || _a === void 0 ? void 0 : _a.run) {
11
12
  bundle.server = {
12
13
  start: {
13
- cmd: spec.startCommand.split(" "),
14
+ cmd: spec.detectedCommands.run.cmd.split(" "),
14
15
  },
15
16
  };
16
17
  }
17
18
  driver.install();
18
- if (spec.afterInstall) {
19
- bundle = driver.execHook(bundle, spec.afterInstall);
19
+ if ((_b = spec.frameworkHooks) === null || _b === void 0 ? void 0 : _b.afterInstall) {
20
+ bundle = driver.execHook(bundle, spec.frameworkHooks.afterInstall);
20
21
  }
21
22
  driver.build();
22
- if (spec.afterBuild) {
23
- bundle = driver.execHook(bundle, spec.afterBuild);
23
+ if ((_c = spec.frameworkHooks) === null || _c === void 0 ? void 0 : _c.afterBuild) {
24
+ bundle = driver.execHook(bundle, (_d = spec.frameworkHooks) === null || _d === void 0 ? void 0 : _d.afterBuild);
24
25
  }
25
26
  if (bundle.server) {
26
27
  driver.export(bundle);
@@ -48,16 +48,25 @@ async function discover(dir) {
48
48
  exports.discover = discover;
49
49
  async function build(dir) {
50
50
  var _a, _b;
51
- const { default: nextBuild } = (0, utils_1.relativeRequire)(dir, "next/dist/build");
52
51
  await (0, utils_1.warnIfCustomBuildScript)(dir, exports.name, DEFAULT_BUILD_SCRIPT);
53
52
  const reactVersion = getReactVersion(dir);
54
53
  if (reactVersion && (0, semver_1.gte)(reactVersion, "18.0.0")) {
55
54
  process.env.__NEXT_REACT_ROOT = "true";
56
55
  }
57
- await nextBuild(dir, null, false, false, true).catch((e) => {
58
- console.error(e.message);
59
- throw e;
56
+ const cli = (0, utils_1.getNodeModuleBin)("next", dir);
57
+ const nextBuild = new Promise((resolve, reject) => {
58
+ var _a, _b;
59
+ const buildProcess = (0, cross_spawn_1.spawn)(cli, ["build"], { cwd: dir });
60
+ (_a = buildProcess.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (data) => logger_1.logger.info(data.toString()));
61
+ (_b = buildProcess.stderr) === null || _b === void 0 ? void 0 : _b.on("data", (data) => logger_1.logger.info(data.toString()));
62
+ buildProcess.on("error", (err) => {
63
+ reject(new error_1.FirebaseError(`Unable to build your Next.js app: ${err}`));
64
+ });
65
+ buildProcess.on("exit", (code) => {
66
+ resolve(code);
67
+ });
60
68
  });
69
+ await nextBuild;
61
70
  const reasonsForBackend = new Set();
62
71
  const { distDir, trailingSlash, basePath: baseUrl } = await getConfig(dir);
63
72
  if (await (0, utils_2.isUsingMiddleware)((0, path_1.join)(dir, distDir), false)) {
@@ -3,19 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createBuild = 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 = "v1";
6
+ exports.API_VERSION = "v2";
7
7
  const client = new apiv2_1.Client({
8
8
  urlPrefix: api_1.frameworksOrigin,
9
9
  auth: true,
10
10
  apiVersion: exports.API_VERSION,
11
11
  });
12
- async function createStack(projectId, location, stackId, stack) {
13
- const res = await client.post(`projects/${projectId}/locations/${location}/stacks`, stack, { queryParams: { stackId } });
12
+ async function createStack(projectId, location, stackInput) {
13
+ const stackId = stackInput.name;
14
+ const res = await client.post(`projects/${projectId}/locations/${location}/stacks`, stackInput, { queryParams: { stackId } });
14
15
  return res.body;
15
16
  }
16
17
  exports.createStack = createStack;
17
- async function createBuild(projectId, location, stackId, buildId, build) {
18
- const res = await client.post(`projects/${projectId}/locations/${location}/stacks/${stackId}/builds`, build, { queryParams: { buildId } });
18
+ async function createBuild(projectId, location, stackId, buildInput) {
19
+ const buildId = buildInput.name;
20
+ const res = await client.post(`projects/${projectId}/locations/${location}/stacks/${stackId}/builds`, buildInput, { queryParams: { buildId } });
19
21
  return res.body;
20
22
  }
21
23
  exports.createBuild = createBuild;
@@ -1,12 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.doSetup = void 0;
3
+ exports.createStack = 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");
10
+ const poller = require("../../../operation-poller");
11
+ const api_1 = require("../../../api");
12
+ const gcp = require("../../../gcp/frameworks");
13
+ const frameworks_1 = require("../../../gcp/frameworks");
14
+ const frameworksPollerOptions = {
15
+ apiOrigin: api_1.frameworksOrigin,
16
+ apiVersion: frameworks_1.API_VERSION,
17
+ masterTimeout: 25 * 60 * 1000,
18
+ maxBackoff: 10000,
19
+ };
9
20
  async function doSetup(setup) {
21
+ var _a, _b;
22
+ const projectId = (_b = (_a = setup === null || setup === void 0 ? void 0 : setup.rcfile) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b.default;
10
23
  setup.frameworks = {};
11
24
  utils.logBullet("First we need a few details to create your service.");
12
25
  await (0, prompt_1.promptOnce)({
@@ -32,5 +45,22 @@ async function doSetup(setup) {
32
45
  message: "How do you want to deploy",
33
46
  choices: constants_1.ALLOWED_DEPLOY_METHODS,
34
47
  }, 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
+ }
35
52
  }
36
53
  exports.doSetup = doSetup;
54
+ function toStack(cloudBuildConnRepo, stackId) {
55
+ return {
56
+ name: stackId,
57
+ codebase: { repository: cloudBuildConnRepo.name, rootDirectory: "/" },
58
+ labels: {},
59
+ };
60
+ }
61
+ async function createStack(projectId, location, stackInput) {
62
+ const op = await gcp.createStack(projectId, location, stackInput);
63
+ const stack = await poller.pollOperation(Object.assign(Object.assign({}, frameworksPollerOptions), { pollerName: `create-${projectId}-${location}-${stackInput.name}`, operationResourceName: op.name }));
64
+ return stack;
65
+ }
66
+ exports.createStack = createStack;
@@ -21,14 +21,11 @@ function extractRepoSlugFromURI(remoteUri) {
21
21
  }
22
22
  return match[1];
23
23
  }
24
- function generateConnectionId(stackId) {
25
- return `composer-${stackId}-conn`;
26
- }
27
24
  function generateRepositoryId() {
28
25
  return `composer-repo`;
29
26
  }
30
27
  async function linkGitHubRepository(projectId, location, stackId) {
31
- const connectionId = generateConnectionId(stackId);
28
+ const connectionId = stackId;
32
29
  await getOrCreateConnection(projectId, location, connectionId);
33
30
  let remoteUri = await promptRepositoryURI(projectId, location, connectionId);
34
31
  while (remoteUri === "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "12.4.1",
3
+ "version": "12.4.3",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -128,6 +128,10 @@
128
128
  }
129
129
  },
130
130
  "properties": {
131
+ "$schema": {
132
+ "format": "uri",
133
+ "type": "string"
134
+ },
131
135
  "database": {
132
136
  "anyOf": [
133
137
  {
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.command = void 0;
4
- const command_1 = require("../command");
5
- const repo_1 = require("../init/features/composer/repo");
6
- const projectUtils_1 = require("../projectUtils");
7
- const requireInteractive_1 = require("../requireInteractive");
8
- exports.command = new command_1.Command("internaltesting:frameworks:init")
9
- .description("connect github repo to cloud build")
10
- .before(requireInteractive_1.default)
11
- .action(async (options) => {
12
- const projectId = (0, projectUtils_1.needProjectId)(options);
13
- await (0, repo_1.linkGitHubRepository)(projectId, "us-central2", "stack0");
14
- });