diff --git a/packages/gasket-plugin-docusaurus/lib/create.js b/packages/gasket-plugin-docusaurus/lib/create.js index e92424da1..c55d53a50 100644 --- a/packages/gasket-plugin-docusaurus/lib/create.js +++ b/packages/gasket-plugin-docusaurus/lib/create.js @@ -3,7 +3,9 @@ const { name, version, devDependencies } = require('../package.json'); /** @type {import('@gasket/core').HookHandler<'create'>} */ -module.exports = function create(gasket, { pkg, gasketConfig, readme }) { +module.exports = function create(gasket, { pkg, gasketConfig, readme, useDocs }) { + if (!useDocs) return; + gasketConfig.addPlugin('pluginDocusaurus', name); pkg.add('dependencies', { @@ -15,7 +17,9 @@ module.exports = function create(gasket, { pkg, gasketConfig, readme }) { '@docusaurus/preset-classic': devDependencies['@docusaurus/preset-classic'], 'react': devDependencies.react, 'react-dom': devDependencies['react-dom'], - 'ajv': devDependencies.ajv + 'ajv': devDependencies.ajv, + 'typescript': devDependencies.typescript, + 'search-insights': devDependencies['search-insights'] }); readme diff --git a/packages/gasket-plugin-docusaurus/test/create.test.js b/packages/gasket-plugin-docusaurus/test/create.test.js index 7bdf876ef..b290a49bd 100644 --- a/packages/gasket-plugin-docusaurus/test/create.test.js +++ b/packages/gasket-plugin-docusaurus/test/create.test.js @@ -6,6 +6,7 @@ describe('createHook', () => { beforeEach(() => { mockContext = { + useDocs: true, pkg: { add: jest.fn() }, @@ -31,6 +32,12 @@ describe('createHook', () => { }); }); + it('does not add itself to the dependencies if useDocs is false', async () => { + mockContext.useDocs = false; + await create({}, mockContext); + expect(mockContext.pkg.add).not.toHaveBeenCalled(); + }); + it('adds devDependencies', async () => { await create({}, mockContext); expect(mockContext.pkg.add).toHaveBeenCalledWith('devDependencies', { @@ -38,7 +45,9 @@ describe('createHook', () => { '@docusaurus/preset-classic': devDependencies['@docusaurus/preset-classic'], 'react': devDependencies.react, 'react-dom': devDependencies['react-dom'], - 'ajv': devDependencies.ajv + 'ajv': devDependencies.ajv, + 'typescript': devDependencies.typescript, + 'search-insights': devDependencies['search-insights'] }); }); diff --git a/packages/gasket-plugin-lint/lib/code-styles.js b/packages/gasket-plugin-lint/lib/code-styles.js index c930f3311..33f93b6a7 100644 --- a/packages/gasket-plugin-lint/lib/code-styles.js +++ b/packages/gasket-plugin-lint/lib/code-styles.js @@ -56,7 +56,8 @@ const godaddy = { if (hasNext) { pkg.add('devDependencies', { - 'eslint-config-next': devDependencies['eslint-config-next'] + 'eslint-config-next': devDependencies['eslint-config-next'], + 'typescript': devDependencies.typescript }); pkg.add('eslintConfig', { extends: ['next'] }); } diff --git a/packages/gasket-plugin-lint/test/code-styles.test.js b/packages/gasket-plugin-lint/test/code-styles.test.js index 90a5ee8a3..5700339ad 100644 --- a/packages/gasket-plugin-lint/test/code-styles.test.js +++ b/packages/gasket-plugin-lint/test/code-styles.test.js @@ -102,7 +102,8 @@ describe('code styles', () => { await codeStyle.create(context, utils); expect(pkgAdd).toHaveBeenCalledWith('devDependencies', { - 'eslint-config-next': devDependencies['eslint-config-next'] + 'eslint-config-next': devDependencies['eslint-config-next'], + 'typescript': devDependencies.typescript }); expect(pkgAdd).toHaveBeenCalledWith('eslintConfig', { extends: ['next']