diff --git a/jest.config.js b/jest.config.js index 3990e97..fec5010 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,10 @@ module.exports = { testEnvironment: 'node', - testPathIgnorePatterns: ['/node_modules/', '/tests/__helpers'], + testPathIgnorePatterns: [ + '/node_modules/', + '/tests/__helpers', + '/hello-world/', + ], collectCoverage: true, coverageReporters: ['lcov'], collectCoverageFrom: ['src/**/*.js'], diff --git a/src/index.js b/src/index.js index 36c2b75..a45ec20 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ import execa from 'execa'; import pkg from './pkg'; import CONFIG_FILES from './configs'; +import NPM_PACKAGES from './packages'; const PKG_DIR = __dirname; @@ -19,7 +20,9 @@ const run = async ({ packageName }) => { // npm commands await execa('npm', ['init', '-y']); - // await execa('npm', ['i', '-D', ...NPM_PACKAGES]); + const npmProc = execa('npm', ['i', '-D', ...NPM_PACKAGES]); + const { stdout: npmInstall } = await npmProc; + console.log('npm install output:', npmInstall); // copy config CONFIG_FILES.forEach((c) => { diff --git a/src/packages.js b/src/packages.js new file mode 100644 index 0000000..0734297 --- /dev/null +++ b/src/packages.js @@ -0,0 +1,21 @@ +const NPM_PACKAGES = [ + '@babel/core', + '@babel/cli', + '@babel/preset-env', + 'eslint', + 'prettier', + 'babel-eslint', + 'eslint-plugin-import', + 'eslint-plugin-prettier', + 'eslint-config-airbnb-base', + 'eslint-config-prettier', + 'husky', + 'lint-staged', + 'pretty-quick', + 'jest', + 'babel-jest', + '@babel/plugin-transform-runtime', + '@types/jest', +]; + +export default NPM_PACKAGES; diff --git a/tests/index.test.js b/tests/index.test.js index 765d3e3..59584e1 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -2,6 +2,7 @@ import fs from 'fs'; import fse from 'fs-extra'; import run from '../src'; import CONFIG_FILES from '../src/configs'; +import NPM_PACKAGES from '../src/packages'; const PKG_NAME = 'hello-world'; const ROOT_DIR = process.cwd(); @@ -17,7 +18,8 @@ describe('Create NodeJs', () => { }); it('should run', async () => { - expect.assertions(7 + CONFIG_FILES.length); + jest.setTimeout(60000); + expect.assertions(7 + CONFIG_FILES.length + NPM_PACKAGES.length); try { await run({ packageName: 'hello-world' }); expect(fs.existsSync(PKG_DIR)).toBe(true); @@ -34,6 +36,10 @@ describe('Create NodeJs', () => { expect(pkg.license).toBe('MIT'); expect(pkg.author.name).toBe('Ian Dela Cruz'); expect(pkg.author.email).toBe('iandc76@gmail.com'); + + NPM_PACKAGES.forEach((c) => { + expect(pkg.devDependencies).toHaveProperty(c); + }); } catch (error) { // console.log(error); expect(error).toBe(null);