Skip to content

Commit e8ef72d

Browse files
committed
feat: remove obsolete parseTriggers fallback
1 parent 8960b47 commit e8ef72d

File tree

10 files changed

+41
-1745
lines changed

10 files changed

+41
-1745
lines changed

firebase-vscode/webpack.common.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,8 @@ const extensionConfig = {
196196
to: "./schema",
197197
},
198198
// TODO(hlshen): Sanity check if these should be fixed or removed. AFIACT, they exist for functions and hosting deploys, which are not relevant anymore.
199-
// Copy uncompiled JS files called at runtime by
200-
// firebase-tools/src/parseTriggers.ts
201-
// {
202-
// from: "*.js",
203-
// to: "./",
204-
// context: "../src/deploy/functions/runtimes/node",
205-
// },
206-
// // Copy cross-env-shell.js used to run predeploy scripts
207-
// // to ensure they work in Windows
199+
// Copy cross-env-shell.js used to run predeploy scripts
200+
// to ensure they work in Windows
208201
// {
209202
// from: "../node_modules/cross-env/dist",
210203
// to: "./cross-env/dist",

src/deploy/functions/runtimes/node/extractTriggers.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/deploy/functions/runtimes/node/extractTriggers.spec.js

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/deploy/functions/runtimes/node/index.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,33 @@ describe("NodeDelegate", () => {
7777
expect(() => delegate.getNodeBinary()).to.throw(FirebaseError);
7878
});
7979
});
80+
81+
describe("discoverBuild", () => {
82+
let getFunctionsSDKVersionMock: sinon.SinonStub;
83+
84+
beforeEach(() => {
85+
getFunctionsSDKVersionMock = sinon.stub(versioning, "getFunctionsSDKVersion");
86+
});
87+
88+
afterEach(() => {
89+
getFunctionsSDKVersionMock.restore();
90+
});
91+
92+
it("throws error if SDK version is too old", async () => {
93+
getFunctionsSDKVersionMock.returns("3.19.0");
94+
const delegate = new node.Delegate(
95+
PROJECT_ID,
96+
PROJECT_DIR,
97+
SOURCE_DIR,
98+
"nodejs16" as Runtime,
99+
);
100+
try {
101+
await delegate.discoverBuild({}, {});
102+
throw new Error("Should have thrown");
103+
} catch (err: any) {
104+
expect(err).to.be.instanceOf(FirebaseError);
105+
expect(err.message).to.include("Please update firebase-functions SDK");
106+
}
107+
});
108+
});
80109
});

src/deploy/functions/runtimes/node/index.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { DelegateContext } from "..";
2323
import * as supported from "../supported";
2424
import * as validate from "./validate";
2525
import * as versioning from "./versioning";
26-
import * as parseTriggers from "./parseTriggers";
26+
2727
import { fileExistsSync } from "../../../../fsutils";
2828

2929
// The versions of the Firebase Functions SDK that added support for the container contract.
@@ -292,18 +292,12 @@ export class Delegate {
292292
env: backend.EnvironmentVariables,
293293
): Promise<build.Build> {
294294
if (!semver.valid(this.sdkVersion)) {
295-
logger.debug(
296-
`Could not parse firebase-functions version '${this.sdkVersion}' into semver. Falling back to parseTriggers.`,
297-
);
298-
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
299-
}
300-
if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION)) {
301-
logLabeledWarning(
302-
"functions",
295+
logger.debug(`Could not parse firebase-functions version '${this.sdkVersion}' into semver.`);
296+
} else if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION)) {
297+
throw new FirebaseError(
303298
`You are using an old version of firebase-functions SDK (${this.sdkVersion}). ` +
304299
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION}`,
305300
);
306-
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
307301
}
308302
// Perform a check for the minimum SDK version that added annotation support for the `Build.extensions` property
309303
// and log to the user explaining why they need to upgrade their version.

0 commit comments

Comments
 (0)