Skip to content

Commit

Permalink
Remove the functions shim
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickreimer committed Jul 13, 2020
1 parent 5b1c9ea commit dbadc20
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 133 deletions.
25 changes: 0 additions & 25 deletions src/cmds/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const ora = require('ora');
const version = require('../../package.json').version;
const log = require('../log');
const messages = require('../messages');
const shim = require('../shim');
const env = require('process').env;
const { stripIndent } = require('common-tags');
const { traverse } = require('../traverse');
Expand Down Expand Up @@ -157,12 +156,6 @@ exports.builder = yargs => {
describe: 'Path to the local `statickit.json` file',
default: 'statickit.json'
});

yargs.option('shim', {
describe: 'Install the functions shim package',
type: 'boolean',
default: true
});
};

exports.handler = async args => {
Expand Down Expand Up @@ -275,24 +268,6 @@ exports.handler = async args => {
`Deployment succeeded ${chalk.gray(`(${response.data.id})`)}`
);

if (args.shim && response.data.shim) {
const shimSpinner = ora(chalk.gray('Installing functions...'));
shimSpinner.start();

try {
await shim.install(response.data.shim);
shimSpinner.stop();
log.success(
`Functions installed ${chalk.gray(`(${response.data.shim})`)}`
);
} catch (error) {
shimSpinner.stop();
log.error('Functions failed to install');
console.error(error);
process.exitCode = 1;
}
}

return;

case 401:
Expand Down
12 changes: 0 additions & 12 deletions src/shim.js

This file was deleted.

38 changes: 0 additions & 38 deletions test/cmds/__snapshots__/deploy.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -136,44 +136,6 @@ Array [
]
`;
exports[`does not install the shim if --no-shim is used 1`] = `
Array [
Array [
"✔ Deployment succeeded (xxxx-xxxx-xxxx)",
],
]
`;
exports[`does not install the shim if not present in the response 1`] = `
Array [
Array [
"✔ Deployment succeeded (xxxx-xxxx-xxxx)",
],
]
`;
exports[`installs the shim if present in the response 1`] = `
Array [
Array [
"✔ Deployment succeeded (xxxx-xxxx-xxxx)",
],
Array [
"✔ Functions installed (shim-ref)",
],
]
`;
exports[`outputs shim install errors 1`] = `
Array [
Array [
"✕ Functions failed to install",
],
Array [
[Error: error installing package],
],
]
`;
exports[`sends a deploy request with the right params 1`] = `
Array [
Array [
Expand Down
58 changes: 0 additions & 58 deletions test/cmds/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ jest.mock('process', () => ({
env: { MY_SECRET: 'pa$$w0rd', API_KEY: '12345' }
}));
jest.mock('@statickit/deploy');
jest.mock('../../src/shim');

jest.mock('ora', () => {
return () => ({
Expand All @@ -15,7 +14,6 @@ jest.mock('ora', () => {
});

const cmd = require('../../src/cmds/deploy');
const shim = require('../../src/shim');

beforeEach(() => {
jest.spyOn(console, 'log').mockImplementation();
Expand All @@ -25,7 +23,6 @@ beforeEach(() => {
afterEach(() => {
console.log.mockRestore();
console.error.mockRestore();
shim.install.mockReset();
deploy.request.mockReset();
});

Expand All @@ -42,61 +39,6 @@ it('sends a deploy request with the right params', async () => {
expect(console.log.mock.calls).toMatchSnapshot();
});

it('installs the shim if present in the response', async () => {
deploy.request.mockImplementation(() => {
return Promise.resolve({
status: 200,
data: { id: 'xxxx-xxxx-xxxx', shim: 'shim-ref' }
});
});

await cmd.handler({ config: '{}', key: 'xxx', shim: true });
expect(shim.install).toHaveBeenCalledWith('shim-ref');
expect(console.log.mock.calls).toMatchSnapshot();
});

it('does not install the shim if not present in the response', async () => {
deploy.request.mockImplementation(() => {
return Promise.resolve({
status: 200,
data: { id: 'xxxx-xxxx-xxxx', shim: null }
});
});

await cmd.handler({ config: '{}', key: 'xxx', shim: true });
expect(shim.install).not.toHaveBeenCalled();
expect(console.log.mock.calls).toMatchSnapshot();
});

it('does not install the shim if --no-shim is used', async () => {
deploy.request.mockImplementation(() => {
return Promise.resolve({
status: 200,
data: { id: 'xxxx-xxxx-xxxx', shim: 'shim-ref' }
});
});

await cmd.handler({ config: '{}', key: 'xxx', shim: false });
expect(shim.install).not.toHaveBeenCalled();
expect(console.log.mock.calls).toMatchSnapshot();
});

it('outputs shim install errors', async () => {
deploy.request.mockImplementation(() => {
return Promise.resolve({
status: 200,
data: { id: 'xxxx-xxxx-xxxx', shim: 'shim-ref' }
});
});

shim.install.mockImplementation(async () => {
throw new Error('error installing package');
});

await cmd.handler({ config: '{}', key: 'xxx', shim: true });
expect(console.error.mock.calls).toMatchSnapshot();
});

it('displays instructions for a missing mailchimp api key', async () => {
deploy.request.mockImplementation(_params => {
return Promise.resolve({
Expand Down

0 comments on commit dbadc20

Please sign in to comment.