Skip to content

Commit

Permalink
fix: package-lock missing deps (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpina1-godaddy authored Oct 2, 2024
1 parent a29b37f commit 3310699
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/gasket-plugin-docusaurus/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion packages/gasket-plugin-docusaurus/test/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe('createHook', () => {

beforeEach(() => {
mockContext = {
useDocs: true,
pkg: {
add: jest.fn()
},
Expand All @@ -31,14 +32,22 @@ 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', {
'@docusaurus/core': devDependencies['@docusaurus/core'],
'@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']
});
});

Expand Down
3 changes: 2 additions & 1 deletion packages/gasket-plugin-lint/lib/code-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'] });
}
Expand Down
3 changes: 2 additions & 1 deletion packages/gasket-plugin-lint/test/code-styles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 3310699

Please sign in to comment.