Skip to content

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed May 31, 2020
1 parent a2d599d commit a14f2f3
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 916 deletions.
40 changes: 11 additions & 29 deletions clean-scripts.config.js → clean-scripts.config.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
const { Service, executeScriptAsync } = require('clean-scripts')
const { watch } = require('watch-then-execute')
import { executeScriptAsync } from 'clean-scripts'
import { watch } from 'watch-then-execute'

const tsFiles = `"packages/@(core|vue|react)/@(src|demo)/**/*.@(ts|tsx)" "spec/**/*.ts" "screenshots/**/*.ts"`
const tsFiles = `"packages/@(core|vue|react)/@(src|demo)/**/*.@(ts|tsx)"`
const lessFiles = `"packages/core/src/**/*.less"`
const jsFiles = `"*.config.js" "spec/**/*.config.js"`
const excludeTsFiles = `"packages/@(core|vue|react)/@(src|demo)/**/*.d.ts"`
const jsFiles = `"*.config.js"`
const excludeTsFiles = `"packages/@(core|vue|react)/@(src|demo)/**/*.@(d|config).ts"`

const vueTemplateCommand = `file2variable-cli --config packages/vue/src/file2variable.config.js`
const vueTemplateCommand = `file2variable-cli --config packages/vue/src/file2variable.config.ts`

const tscCoreSrcCommand = `tsc -p packages/core/src`
const tscVueSrcCommand = `tsc -p packages/vue/src`
const tscReactSrcCommand = `tsc -p packages/react/src`

const tscCoreDemoCommand = `tsc -p packages/core/demo`
const tscVueDemoCommand = `tsc -p packages/vue/demo`
const tscReactDemoCommand = `tsc -p packages/react/demo`

const webpackVueCommand = `webpack --config packages/vue/demo/webpack.config.js`
const webpackReactCommand = `webpack --config packages/react/demo/webpack.config.js`
const webpackVueCommand = `webpack --config packages/vue/demo/webpack.config.ts`
const webpackReactCommand = `webpack --config packages/react/demo/webpack.config.ts`

const revStaticCommand = `rev-static`
const cssCommand = [
Expand All @@ -29,24 +25,21 @@ const cssCommand = [

const isDev = process.env.NODE_ENV === 'development'

module.exports = {
export default {
build: [
{
js: [
tscCoreSrcCommand,
tscCoreDemoCommand,
{
vue: [
vueTemplateCommand,
tscVueSrcCommand,
isDev ? undefined : `rollup --config packages/vue/src/rollup.config.js`,
tscVueDemoCommand,
webpackVueCommand
],
react: [
tscReactSrcCommand,
isDev ? undefined : `rollup --config packages/react/src/rollup.config.js`,
tscReactDemoCommand,
webpackReactCommand
]
}
Expand All @@ -64,10 +57,7 @@ module.exports = {
markdown: `markdownlint README.md`,
typeCoverage: 'lerna exec -- type-coverage -p src --strict'
},
test: [
'tsc -p spec',
'karma start spec/karma.config.js'
],
test: [],
fix: {
ts: `eslint --ext .js,.ts ${tsFiles} ${jsFiles} --fix`,
less: `stylelint --fix ${lessFiles}`
Expand All @@ -77,17 +67,9 @@ module.exports = {
tscCoreSrcCommand: `${tscCoreSrcCommand} --watch`,
tscVueSrcCommand: `${tscVueSrcCommand} --watch`,
tscReactSrcCommand: `${tscReactSrcCommand} --watch`,
tscCoreDemoCommand: `${tscCoreDemoCommand} --watch`,
tscVueDemoCommand: `${tscVueDemoCommand} --watch`,
tscReactDemoCommand: `${tscReactDemoCommand} --watch`,
webpackVueCommand: `${webpackVueCommand} --watch`,
webpackReactCommand: `${webpackReactCommand} --watch`,
less: () => watch(['src/**/*.less'], [], () => executeScriptAsync(cssCommand)),
rev: `${revStaticCommand} --watch`
},
screenshot: [
new Service(`http-server -p 8000`),
`tsc -p screenshots`,
`node screenshots/index.js`
]
}
}
15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"lint": "clean-scripts lint.ts",
"fix": "clean-scripts fix",
"test": "clean-scripts test",
"watch": "clean-scripts watch",
"screenshot": "clean-scripts screenshot"
"watch": "clean-scripts watch"
},
"repository": {
"type": "git",
Expand All @@ -30,8 +29,7 @@
"@commitlint/config-conventional": "8.3.4",
"@rollup/plugin-commonjs": "12.0.0",
"@rollup/plugin-node-resolve": "8.0.0",
"@types/jasmine": "3.5.10",
"@types/puppeteer": "3.0.0",
"@types/webpack": "4.41.16",
"@typescript-eslint/eslint-plugin": "3.0.2",
"@typescript-eslint/parser": "3.0.2",
"autoprefixer": "9.8.0",
Expand All @@ -44,24 +42,19 @@
"file2variable-cli": "1.10.1",
"github-fork-ribbon-css": "0.2.3",
"http-server": "0.12.3",
"jasmine": "3.5.0",
"karma": "5.0.9",
"karma-chrome-launcher": "3.1.0",
"karma-firefox-launcher": "1.3.0",
"karma-jasmine": "3.3.1",
"karma-webpack": "4.0.2",
"lerna": "3.22.0",
"less": "3.11.1",
"markdownlint-cli": "0.23.1",
"no-unused-export": "1.10.3",
"postcss-cli": "7.1.1",
"puppeteer": "3.2.0",
"rev-static": "3.5.1",
"rimraf": "3.0.2",
"rollup": "2.11.2",
"rollup-plugin-uglify": "6.0.4",
"stylelint": "13.5.0",
"stylelint-config-standard": "20.0.0",
"ts-loader": "7.0.5",
"ts-node": "8.10.2",
"type-coverage": "2.7.0",
"typescript": "3.9.3",
"watch-then-execute": "1.1.4",
Expand Down
8 changes: 0 additions & 8 deletions packages/react/demo/webpack.config.js

This file was deleted.

18 changes: 18 additions & 0 deletions packages/react/demo/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as webpack from 'webpack'

export default {
mode: process.env.NODE_ENV,
entry: './packages/react/demo/index',
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader' }
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
output: {
path: __dirname,
filename: 'index.bundle.js'
}
} as webpack.Configuration
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
module.exports = {
import * as webpack from 'webpack'

export default {
mode: process.env.NODE_ENV,
entry: './packages/vue/demo/index',
output: {
path: __dirname,
filename: 'index.bundle.js'
},
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader' }
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
}
}
} as webpack.Configuration
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module.exports = {
import { ConfigData } from 'file2variable-cli'

export default {
base: 'packages/vue/src/',
files: [
'packages/vue/src/*.template.html'
],
/**
* @argument {string} file
*/
handler: file => {
if (file.endsWith('select2.template.html')) {
return {
Expand All @@ -24,4 +23,4 @@ module.exports = {
return { type: 'text' }
},
out: 'packages/vue/src/variables.ts'
}
} as ConfigData
6 changes: 4 additions & 2 deletions rev-static.config.js → rev-static.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
import { ConfigData } from 'rev-static'

export default {
inputFiles: [
'packages/@(vue|react)/demo/**/index.bundle.js',
'packages/@(vue|react)/demo/**/index.ejs.html',
Expand All @@ -12,4 +14,4 @@ module.exports = {
customNewFileName: (filePath, fileString, md5String, baseName, extensionName) => baseName + '-' + md5String + extensionName,
base: 'packages',
fileSize: 'file-size.json'
}
} as ConfigData
19 changes: 0 additions & 19 deletions screenshots/index.ts

This file was deleted.

Binary file removed screenshots/react-initial.png
Binary file not shown.
6 changes: 0 additions & 6 deletions screenshots/tsconfig.json

This file was deleted.

Binary file removed screenshots/vue-initial.png
Binary file not shown.
5 changes: 0 additions & 5 deletions spec/indexSpec.ts

This file was deleted.

32 changes: 0 additions & 32 deletions spec/karma.config.js

This file was deleted.

6 changes: 0 additions & 6 deletions spec/tsconfig.json

This file was deleted.

1 change: 0 additions & 1 deletion spec/webpack.config.js

This file was deleted.

Loading

0 comments on commit a14f2f3

Please sign in to comment.