Skip to content

Commit 9af5937

Browse files
author
Shinigami
authored
refactor: simplify build and rename bin to cli (#428)
* refactor: simplify build and rename bin to cli * chore: remove unnecessary build folder * chore: disable invalid lint rules
1 parent f92b167 commit 9af5937

22 files changed

+16
-29
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ node_modules
33
# Automatically generated directories
44
bin
55
dist
6-
build
76

87
# Website directory
98
website

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = {
3434
'template-curly-spacing': 'error',
3535
'template-tag-spacing': 'error',
3636

37+
'@typescript-eslint/adjacent-overload-signatures': 'off',
3738
'@typescript-eslint/ban-ts-comment': 'off',
3839
'@typescript-eslint/no-unsafe-assignment': 'off',
3940
'@typescript-eslint/no-unsafe-call': 'off',

.gitignore

-6
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,3 @@ test/e2e/reports
6666
/website/node_modules
6767
/website/build
6868
/website/.docusaurus
69-
70-
# Build folder
71-
build
72-
73-
# Bin folder
74-
bin

bin/htmlhint

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
4+
require('../dist/cli/htmlhint')

build-linux.sh

-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@
22
set -x
33

44
# Cleanup
5-
rm -Rf ./build
6-
rm -Rf ./bin
75
rm -Rf ./dist
86

97
# Prepare
108
npx tsc
119

12-
# Move bin
13-
mkdir ./bin
14-
cp -r ./build/bin/* ./bin/
15-
mv ./bin/htmlhint.js ./bin/htmlhint
16-
1710
# Build core
1811
npm run build:rollup

build-windows.bat

-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
@echo off
22

33
:: Cleanup
4-
IF EXIST build ( rmdir build /q /s ) ELSE ( echo build folder not present )
5-
IF EXIST bin ( rmdir bin /q /s ) ELSE ( echo bin folder not present )
64
IF EXIST dist ( rmdir dist /q /s ) ELSE ( echo dist folder not present )
75

86
:: Prepare
97
call npx tsc
108

11-
:: Move bin
12-
mkdir bin
13-
robocopy build\bin bin /s /e
14-
ren "bin\htmlhint.js" "htmlhint"
15-
169
:: Build core
1710
npm run build:rollup

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"htmlhint": "./bin/htmlhint"
2222
},
2323
"main": "dist/htmlhint.js",
24-
"module": "src/core.js",
24+
"module": "dist/core/core.js",
2525
"scripts": {
2626
"commit": "npx git-cz",
2727
"prettier": "prettier --write .",

rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import commonjs from '@rollup/plugin-commonjs'
33
import { terser } from 'rollup-plugin-terser'
44

55
const config = {
6-
input: './build/core/core.js',
6+
input: './dist/core/core.js',
77
output: {
88
file: 'dist/htmlhint.js',
99
format: 'umd',
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/bin/formatters/default.ts renamed to src/cli/formatters/default.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ const defaultFormatter: FormatterCallback = function (
55
HTMLHint,
66
options
77
) {
8-
const nocolor: boolean = !!options.nocolor
8+
const nocolor = !!options.nocolor
99

1010
formatter.on('start', () => {
1111
console.log('')
1212
})
1313

1414
formatter.on('config', (event) => {
15+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1516
const configPath = event.configPath!
1617
console.log(' Config loaded: %s', nocolor ? configPath : configPath.cyan)
1718
console.log('')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/bin/htmlhint.ts renamed to src/cli/htmlhint.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import type { HTMLHint as IHTMLHint } from '../core/core'
1313
import type { Hint, Ruleset } from '../core/types'
1414
import { Formatter } from './formatter'
1515

16-
const HTMLHint: typeof IHTMLHint = require('../dist/htmlhint.js').HTMLHint
16+
const HTMLHint: typeof IHTMLHint = require('../htmlhint.js').HTMLHint
1717
const formatter: Formatter = require('./formatter')
1818

19-
const pkg = require('../package.json')
19+
const pkg = require('../../package.json')
2020

2121
function map(val: string) {
2222
const objMap: { [name: string]: string | true } = {}
@@ -112,6 +112,7 @@ function listRules() {
112112

113113
for (const id in rules) {
114114
rule = rules[id]
115+
// eslint-disable-next-line @typescript-eslint/unbound-method
115116
console.log(' %s : %s', rule.id.bold, rule.description)
116117
}
117118
}
@@ -428,6 +429,7 @@ function walkPath(
428429
})
429430
}
430431

432+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
431433
const walk: any = glob(
432434
pattern,
433435
{
File renamed without changes.

tsconfig.core.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "./tsconfig.json",
3-
"exclude": ["src/bin"]
3+
"exclude": ["src/cli"]
44
}

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"lib": ["ES2018", "DOM"],
77
"moduleResolution": "Node",
88
"rootDir": "src",
9-
"outDir": "build",
9+
"outDir": "dist",
1010
"strict": true,
1111
"removeComments": true
1212
},

tsconfig.lint.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"removeComments": true,
1111
"noEmit": true
1212
},
13-
"exclude": ["node_modules", "bin", "build", "dist", "website"]
13+
"exclude": ["node_modules", "bin", "dist", "website"]
1414
}

0 commit comments

Comments
 (0)