diff --git a/src/cmds/deploy.js b/src/cmds/deploy.js index 68ee9a7..7cf544d 100644 --- a/src/cmds/deploy.js +++ b/src/cmds/deploy.js @@ -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'); @@ -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 => { @@ -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: diff --git a/src/shim.js b/src/shim.js deleted file mode 100644 index 2f8263f..0000000 --- a/src/shim.js +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require('fs'); -const execa = require('execa'); - -const install = async ref => { - if (fs.existsSync('yarn.lock')) { - await execa('yarn', ['add', ref]); - } else { - await execa('npm', ['install', ref]); - } -}; - -module.exports = { install }; diff --git a/test/cmds/__snapshots__/deploy.test.js.snap b/test/cmds/__snapshots__/deploy.test.js.snap index 4b6c651..c47fac4 100644 --- a/test/cmds/__snapshots__/deploy.test.js.snap +++ b/test/cmds/__snapshots__/deploy.test.js.snap @@ -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 [ diff --git a/test/cmds/deploy.test.js b/test/cmds/deploy.test.js index 0e75be7..122dfbe 100644 --- a/test/cmds/deploy.test.js +++ b/test/cmds/deploy.test.js @@ -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 () => ({ @@ -15,7 +14,6 @@ jest.mock('ora', () => { }); const cmd = require('../../src/cmds/deploy'); -const shim = require('../../src/shim'); beforeEach(() => { jest.spyOn(console, 'log').mockImplementation(); @@ -25,7 +23,6 @@ beforeEach(() => { afterEach(() => { console.log.mockRestore(); console.error.mockRestore(); - shim.install.mockReset(); deploy.request.mockReset(); }); @@ -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({