Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions firebase-vscode/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,6 @@ const extensionConfig = {
to: "./schema",
},
// TODO(hlshen): Sanity check if these should be fixed or removed. AFIACT, they exist for functions and hosting deploys, which are not relevant anymore.
// Copy uncompiled JS files called at runtime by
// firebase-tools/src/parseTriggers.ts
// {
// from: "*.js",
// to: "./",
// context: "../src/deploy/functions/runtimes/node",
// },
// // Copy cross-env-shell.js used to run predeploy scripts
// // to ensure they work in Windows
// {
Expand Down
205 changes: 74 additions & 131 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
"source-map-support": "^0.5.9",
"supertest": "^6.2.3",
"swagger2openapi": "^7.0.8",
"ts-node": "^10.4.0",
"ts-node": "^10.9.2",
"typescript": "^4.5.4",
"typescript-json-schema": "^0.65.1",
"vite": "^4.2.1"
Expand Down
49 changes: 49 additions & 0 deletions src/deploy/functions/runtimes/node/discoverBuild.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { expect } from "chai";
import * as sinon from "sinon";

import * as node from ".";
import * as discovery from "../discovery";
import { FirebaseError } from "../../../../error";

const PROJECT_ID = "test-project";
const PROJECT_DIR = "/some/path";
const SOURCE_DIR = "/some/path/fns";

describe("NodeDelegate", () => {
describe("discoverBuild", () => {
let sandbox: sinon.SinonSandbox;
let delegate: node.Delegate;
let detectFromYamlStub: sinon.SinonStub;

beforeEach(() => {
sandbox = sinon.createSandbox();
delegate = new node.Delegate(PROJECT_ID, PROJECT_DIR, SOURCE_DIR, "nodejs16");
detectFromYamlStub = sandbox.stub(discovery, "detectFromYaml");
});

afterEach(() => {
sandbox.restore();
});

it("should throw error if SDK version is invalid", async () => {
sandbox.stub(delegate, "sdkVersion").get(() => "invalid");

await expect(delegate.discoverBuild({}, {})).to.be.rejectedWith(FirebaseError, /Could not parse firebase-functions version/);
});

it("should throw error if SDK version is too old", async () => {
sandbox.stub(delegate, "sdkVersion").get(() => "3.19.0");

await expect(delegate.discoverBuild({}, {})).to.be.rejectedWith(FirebaseError, /You are using an old version of firebase-functions SDK/);
});

it("should proceed if SDK version is new enough", async () => {
sandbox.stub(delegate, "sdkVersion").get(() => "3.20.0");
detectFromYamlStub.resolves({ endpoints: {}, requiredAPIs: [], params: [] });

await delegate.discoverBuild({}, {});

expect(detectFromYamlStub).to.have.been.called;
});
});
});
35 changes: 0 additions & 35 deletions src/deploy/functions/runtimes/node/extractTriggers.js

This file was deleted.

10 changes: 3 additions & 7 deletions src/deploy/functions/runtimes/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { DelegateContext } from "..";
import * as supported from "../supported";
import * as validate from "./validate";
import * as versioning from "./versioning";
import * as parseTriggers from "./parseTriggers";
import { fileExistsSync } from "../../../../fsutils";

// The versions of the Firebase Functions SDK that added support for the container contract.
Expand Down Expand Up @@ -292,18 +291,15 @@ export class Delegate {
env: backend.EnvironmentVariables,
): Promise<build.Build> {
if (!semver.valid(this.sdkVersion)) {
logger.debug(
`Could not parse firebase-functions version '${this.sdkVersion}' into semver. Falling back to parseTriggers.`,
throw new FirebaseError(
`Could not parse firebase-functions version '${this.sdkVersion}' into semver. Please make sure you are using a valid version of firebase-functions.`,
);
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
}
if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION)) {
logLabeledWarning(
"functions",
throw new FirebaseError(
`You are using an old version of firebase-functions SDK (${this.sdkVersion}). ` +
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION}`,
);
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
}
// Perform a check for the minimum SDK version that added annotation support for the `Build.extensions` property
// and log to the user explaining why they need to upgrade their version.
Expand Down
Loading
Loading