-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update rollup config * test: added babel test :( * test: added rollup test :( * feat: camelcase appname * docs: updage changelog
- Loading branch information
Showing
17 changed files
with
237 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import { isSkip, setup } from '../index' | ||
import { DependencyType, getDepsCollection, clearDeps } from '../../../core/dependency' | ||
import { BUILD_TOOLS } from '../../typescript/build-tools' | ||
|
||
const rootPath = path.resolve(__dirname, 'tmp') | ||
describe('As chore eslint feature', () => { | ||
beforeEach(async () => { | ||
clearDeps() | ||
await fs.ensureDir(rootPath) | ||
}) | ||
|
||
afterEach(async () => { | ||
await fs.remove(rootPath) | ||
}) | ||
|
||
it('should skip install this feature when project has exists babel config file', async () => { | ||
const eslintPath = path.resolve(rootPath, '.babelrc') | ||
await fs.ensureFile(eslintPath) | ||
const context = { rootPath, answers: {} } | ||
const skiped = await isSkip(context) | ||
expect(skiped).toBe(true) | ||
}) | ||
|
||
it('should skip this feature when given special build tool', async () => { | ||
const skiped = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.TSC } }) | ||
expect(skiped).toBe(true) | ||
|
||
const skiped1 = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.ESBUILD } }) | ||
expect(skiped1).toBe(true) | ||
|
||
const skiped2 = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.ROLLUP } }) | ||
expect(skiped2).toBe(false) | ||
|
||
const skiped3 = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.WEBPACK } }) | ||
expect(skiped3).toBe(false) | ||
}) | ||
|
||
it('should write babel config to project root when setup has been called with no react', async () => { | ||
const babelrcPath = path.resolve(rootPath, '.babelrc') | ||
const context = { rootPath, answers: {} } | ||
await setup(context) | ||
|
||
const configContent = await fs.readJSON(babelrcPath) | ||
expect(configContent).toStrictEqual({ | ||
presets: ['@babel/preset-env', '@babel/preset-typescript'], | ||
plugins: [ | ||
'@babel/plugin-transform-runtime', | ||
'@babel/proposal-class-properties', | ||
'@babel/proposal-object-rest-spread' | ||
] | ||
}) | ||
|
||
const deps = getDepsCollection() | ||
const expectedDependencies = [ | ||
'@babel/cli', | ||
'@babel/core', | ||
'@babel/preset-env', | ||
'@babel/plugin-proposal-class-properties', | ||
'@babel/plugin-proposal-object-rest-spread', | ||
'@babel/preset-typescript', | ||
'@babel/plugin-transform-runtime' | ||
].map(item => ({ name: item, type: DependencyType.DEV })) | ||
|
||
expectedDependencies.push({ name: '@babel/runtime', type: DependencyType.DEFAULT }) | ||
|
||
expect(deps).toStrictEqual(expectedDependencies) | ||
}) | ||
|
||
it('should write babel config to project root when setup has been called with react needed', async () => { | ||
const eslintPath = path.resolve(rootPath, '.babelrc') | ||
const context = { rootPath, answers: { isReactNeeded: true } } | ||
await setup(context) | ||
|
||
const configContent = await fs.readJSON(eslintPath) | ||
expect(configContent).toStrictEqual({ | ||
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react'], | ||
plugins: [ | ||
'@babel/plugin-transform-runtime', | ||
'@babel/proposal-class-properties', | ||
'@babel/proposal-object-rest-spread' | ||
] | ||
}) | ||
|
||
const deps = getDepsCollection() | ||
const expectedDependencies = [ | ||
'@babel/cli', | ||
'@babel/core', | ||
'@babel/preset-env', | ||
'@babel/plugin-proposal-class-properties', | ||
'@babel/plugin-proposal-object-rest-spread', | ||
'@babel/preset-typescript', | ||
'@babel/plugin-transform-runtime' | ||
].map(item => ({ name: item, type: DependencyType.DEV })) | ||
|
||
expectedDependencies.push({ name: '@babel/runtime', type: DependencyType.DEFAULT }) | ||
expectedDependencies.push({ name: '@babel/preset-react', type: DependencyType.DEV }) | ||
expect(deps).toStrictEqual(expectedDependencies) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import sum from '../src/index'; | ||
import sum from '../src/index' | ||
|
||
test('sum should return 2 when given 1 1', () => { | ||
expect(sum(1, 1)).toBe(2); | ||
expect(sum(1, 1)).toBe(2) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default function sum(a: number, b: number) { | ||
return a + b; | ||
} | ||
export default function sum(a: number, b: number) { | ||
return a + b | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import { isSkip, setup } from '../index' | ||
import { DependencyType, getDepsCollection, clearDeps } from '../../../core/dependency' | ||
import { BUILD_TOOLS } from '../../typescript/build-tools' | ||
|
||
const rootPath = path.resolve(__dirname, 'tmp') | ||
describe('As chore eslint feature', () => { | ||
beforeEach(async () => { | ||
clearDeps() | ||
await fs.ensureDir(rootPath) | ||
}) | ||
|
||
afterEach(async () => { | ||
await fs.remove(rootPath) | ||
}) | ||
|
||
it('should skip install this feature when project has exists rollup config file', async () => { | ||
const rollupConfigPath = path.resolve(rootPath, 'rollup.config.ts') | ||
await fs.ensureFile(rollupConfigPath) | ||
const context = { rootPath, answers: {} } | ||
const skiped = await isSkip(context) | ||
expect(skiped).toBe(true) | ||
}) | ||
|
||
it('should skip this feature when given special build tool', async () => { | ||
const skiped = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.TSC } }) | ||
expect(skiped).toBe(true) | ||
|
||
const skiped1 = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.ESBUILD } }) | ||
expect(skiped1).toBe(true) | ||
|
||
const skiped2 = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.ROLLUP } }) | ||
expect(skiped2).toBe(false) | ||
|
||
const skiped3 = await isSkip({ rootPath, answers: { buildTool: BUILD_TOOLS.WEBPACK } }) | ||
expect(skiped3).toBe(true) | ||
}) | ||
|
||
it('should write rollup config to project root when setup has been called', async () => { | ||
const context = { rootPath, answers: {} } | ||
await setup(context) | ||
|
||
const deps = getDepsCollection() | ||
const expectedDependencies = [ | ||
'rollup', | ||
'@rollup/plugin-babel', | ||
'@rollup/plugin-node-resolve', | ||
'@rollup/plugin-commonjs' | ||
].map(item => ({ name: item, type: DependencyType.DEV })) | ||
|
||
expect(deps).toStrictEqual(expectedDependencies) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.