Skip to content
Merged
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
58 changes: 29 additions & 29 deletions src/commands/functions-kits-install.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@

describe("promptExistingInstanceForProject", () => {
it("should throw if kit has no instances configured", async () => {
const mockOptions = { project: "my-project" } as any;

Check warning on line 500 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type

Check warning on line 500 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe assignment of an `any` value
const kit = {
kit: "my-kit",
instances: {},
} as unknown as ValidatedKitSingle;

await expect(promptExistingInstanceForProject(mockOptions, kit)).to.be.rejectedWith(

Check warning on line 506 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `FunctionsKitsInstallOptions`
FirebaseError,
/Kit 'my-kit' has no instances configured\./,
);
Expand All @@ -511,7 +511,7 @@

it("should suggest deploy command directly when only one instance exists", async () => {
const selectStub = sinon.stub(prompt, "select");
const mockOptions = { project: "my-project" } as any;

Check warning on line 514 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type

Check warning on line 514 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe assignment of an `any` value
const kit = {
kit: "my-kit",
instances: {
Expand All @@ -519,7 +519,7 @@
},
} as unknown as ValidatedKitSingle;

await promptExistingInstanceForProject(mockOptions, kit);

Check warning on line 522 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `FunctionsKitsInstallOptions`

expect(selectStub).to.not.have.been.called;
expect(loggerInfoStub).to.have.been.calledWith(
Expand All @@ -530,7 +530,7 @@

it("should prompt to select instance when multiple instances exist and nonInteractive is false", async () => {
const selectStub = sinon.stub(prompt, "select").resolves("inst-2");
const mockOptions = { project: "my-project", nonInteractive: false } as any;

Check warning on line 533 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type

Check warning on line 533 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe assignment of an `any` value
const kit = {
kit: "my-kit",
instances: {
Expand All @@ -539,7 +539,7 @@
},
} as unknown as ValidatedKitSingle;

await promptExistingInstanceForProject(mockOptions, kit);

Check warning on line 542 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `FunctionsKitsInstallOptions`

expect(selectStub).to.have.been.calledOnce;
expect(selectStub).to.have.been.calledWith(
Expand All @@ -559,7 +559,7 @@

it("should suggest deploy command with instance placeholder when multiple instances exist and nonInteractive is true", async () => {
const selectStub = sinon.stub(prompt, "select");
const mockOptions = { project: "my-project", nonInteractive: true } as any;

Check warning on line 562 in src/commands/functions-kits-install.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe assignment of an `any` value
const kit = {
kit: "my-kit",
instances: {
Expand All @@ -584,7 +584,7 @@

await expect(
command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
nonInteractive: true,
}),
Expand All @@ -596,14 +596,14 @@
it("should throw an error if not in a Firebase project directory", async () => {
await expect(
command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
nonInteractive: true,
}),
).to.be.rejectedWith(FirebaseError, /firebase.json not found/);
});

it("should throw an error if --npm_package is not provided", async () => {
it("should throw an error if --package is not provided", async () => {
const mockConfig = {
projectDir: "/mock/project",
src: {
Expand All @@ -620,11 +620,11 @@
}),
).to.be.rejectedWith(
FirebaseError,
/set the --npm_package option to a valid NPM package and try again\./,
/Set the --package option to a valid NPM package and try again\./,
);
Comment thread
wandamora marked this conversation as resolved.
});

it("should throw an error if --npm_package has an invalid package name", async () => {
it("should throw an error if --package has an invalid package name", async () => {
const mockConfig = {
projectDir: "/mock/project",
src: {
Expand All @@ -635,7 +635,7 @@

await expect(
command.runner()({
npm_package: "@scope/pkg/extra@1.0.0",
package: "@scope/pkg/extra@1.0.0",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand All @@ -654,7 +654,7 @@

await expect(
command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
template: "invalid-template",
cwd: "/mock/project",
config: mockConfig,
Expand Down Expand Up @@ -685,7 +685,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
template: "migration",
cwd: "/mock/project",
config: mockConfig,
Expand Down Expand Up @@ -722,7 +722,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
template: "installation",
cwd: "/mock/project",
config: mockConfig,
Expand Down Expand Up @@ -759,7 +759,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -839,7 +839,7 @@
.resolves("my-instance");

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
cwd: "/mock/project",
config: mockConfig,
});
Expand Down Expand Up @@ -880,7 +880,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@third-party/custom-kit",
package: "@third-party/custom-kit",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -922,7 +922,7 @@

await expect(
command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
}),
Expand Down Expand Up @@ -955,7 +955,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
package: "@firebase-functions-kits/firestore-bigquery-export@1.0.0",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -994,7 +994,7 @@

await expect(
command.runner()({
npm_package: "@firebase-functions-kits/my-kit",
package: "@firebase-functions-kits/my-kit",
cwd: "/mock/project",
config: mockConfig,
}),
Expand Down Expand Up @@ -1029,7 +1029,7 @@

await expect(
command.runner()({
npm_package: "@firebase-functions-kits/my-kit",
package: "@firebase-functions-kits/my-kit",
cwd: "/mock/project",
config: mockConfig,
}),
Expand All @@ -1052,7 +1052,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@firebase-functions-kits/my-kit",
package: "@firebase-functions-kits/my-kit",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -1083,7 +1083,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@third-party/custom-kit",
package: "@third-party/custom-kit",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -1113,7 +1113,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@third-party/custom-kit",
package: "@third-party/custom-kit",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -1148,7 +1148,7 @@

await expect(
command.runner()({
npm_package: "@firebase-functions-kits/my-kit",
package: "@firebase-functions-kits/my-kit",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand All @@ -1169,7 +1169,7 @@

await expect(
command.runner()({
npm_package: "@third-party/custom-kit",
package: "@third-party/custom-kit",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand All @@ -1190,7 +1190,7 @@

await expect(
command.runner()({
npm_package: "@third-party/custom-kit",
package: "@third-party/custom-kit",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -1230,7 +1230,7 @@
} as unknown as Config;

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
nonInteractive: true,
Expand Down Expand Up @@ -1292,7 +1292,7 @@
sinon.stub(prompt, "input").resolves("custom-instance-2");

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
project: "my-target-proj",
Expand Down Expand Up @@ -1356,7 +1356,7 @@
sinon.stub(prompt, "input").resolves("inst-2");

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
project: "my-target-proj",
Expand Down Expand Up @@ -1419,7 +1419,7 @@

await expect(
command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
}),
Expand Down Expand Up @@ -1454,7 +1454,7 @@
sinon.stub(prompt, "select").resolves("addEnv");

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
project: "my-staging-project",
Expand Down Expand Up @@ -1492,7 +1492,7 @@
sinon.stub(prompt, "select").resolves("addEnv");

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
});
Expand Down Expand Up @@ -1531,7 +1531,7 @@
selectStub.onSecondCall().resolves("inst-2");

await command.runner()({
npm_package: "@firebase-functions-kits/firestore-bigquery-export",
package: "@firebase-functions-kits/firestore-bigquery-export",
cwd: "/mock/project",
config: mockConfig,
project: "prod-project",
Expand Down
8 changes: 4 additions & 4 deletions src/commands/functions-kits-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const DEFAULT_TEMPLATE: TemplateType = "installation";
export const FUNCTION_KITS_DIR = "function-kits";

export interface FunctionsKitsInstallOptions extends Options {
npm_package?: string;
package?: string;
template?: string;
}
Comment thread
wandamora marked this conversation as resolved.

Expand Down Expand Up @@ -678,7 +678,7 @@ export async function printKitFirstDeployReport(

export const command = new Command("functions:kits:install")
.description("install a function kit into your project")
.option("--npm_package <package>", "NPM package name or specifier to install as a function kit")
.option("--package <package>", "NPM package name or specifier to install as a function kit")
.option(
`--template [${Object.keys(TEMPLATES).join("|")}]`,
"template to use for the kit index file",
Expand All @@ -701,9 +701,9 @@ export const command = new Command("functions:kits:install")
);
}

const rawPkgName = options.npm_package;
const rawPkgName = options.package;
if (!rawPkgName) {
throw new FirebaseError("set the --npm_package option to a valid NPM package and try again.");
throw new FirebaseError("Set the --package option to a valid NPM package and try again.");
}
Comment thread
wandamora marked this conversation as resolved.

const { packageName, version } = parseNpmPackageSpecifier(rawPkgName);
Expand Down
Loading