Skip to content

Commit

Permalink
feat(netlify): Disable deploy preview by default
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelastic committed Jan 21, 2021
1 parent d401f3e commit 789c908
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions modules/netlify/lib/__tests__/enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('norska-netlify > enable', () => {
beforeEach(async () => {
jest.spyOn(helper, 'hasToken').mockReturnValue();
jest.spyOn(current, 'linkRepository').mockReturnValue();
jest.spyOn(current, 'setEnvVariables').mockReturnValue();
jest.spyOn(current, 'configureSite').mockReturnValue();
});
it('should fail early if no token', async () => {
helper.hasToken.mockReturnValue(false);
Expand All @@ -32,10 +32,10 @@ describe('norska-netlify > enable', () => {
await current.run();
expect(current.linkRepository).toHaveBeenCalled();
});
it('should set the env variables', async () => {
it('should configure the website', async () => {
helper.hasToken.mockReturnValue(true);
await current.run();
expect(current.setEnvVariables).toHaveBeenCalled();
expect(current.configureSite).toHaveBeenCalled();
});
});
describe('linkRepository', () => {
Expand Down
15 changes: 9 additions & 6 deletions modules/netlify/lib/enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
return false;
}

await this.setEnvVariables();
await this.configureSite();
},
/**
* Link the current repository to a Netlify site
Expand Down Expand Up @@ -81,11 +81,13 @@ module.exports = {
return `NETLIFY_AUTH_TOKEN (${siteName})`;
},
/**
* Set the required ENV variables on Netlify
* NETLIFY_AUTH_TOKEN: Newly generated token to cancel the build
* NODE_ENV: Set to prod to not install devDependencies
* Configure the Netlify site with the following settings:
* - Disable deploy preview
* - Set the required ENV variables on Netlify
* - NETLIFY_AUTH_TOKEN: Newly generated token to cancel the build
* - NODE_ENV: Set to prod to not install devDependencies
**/
async setEnvVariables() {
async configureSite() {
const client = helper.apiClient();
const siteId = await helper.siteId();

Expand All @@ -107,10 +109,11 @@ module.exports = {
body: {
build_settings: {
env: newVars,
skip_prs: true,
},
},
});
this.__consoleSuccess('Environment variables saved to Netlify');
this.__consoleSuccess('Netlify configured');
},
__run: run,
__consoleInfo: consoleInfo,
Expand Down

0 comments on commit 789c908

Please sign in to comment.