Skip to content

Commit c789ed8

Browse files
committed
Complete rewrite in TypeScript, adding unit tests
1 parent 5c71adf commit c789ed8

File tree

126 files changed

+2596
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2596
-474
lines changed

.editorconfig

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
# editorconfig.org
12
root = true
23

34
[*]
4-
insert_final_newline = true
5+
charset = utf-8
56
indent_size = 2
67
indent_style = tab
78
tab_width = 2
89
trim_trailing_whitespace = true
10+
end_of_line = lf
11+
insert_final_newline = true
912

1013
[*.md]
11-
indent_style = space
14+
indent_style = space

.github/FUNDING.yml

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
# These are supported funding model platforms
22

33
github: [roydukkey]
4-
patreon: # Replace with a single Patreon username
5-
open_collective: # Replace with a single Open Collective username
6-
ko_fi: # Replace with a single Ko-fi username
7-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9-
liberapay: # Replace with a single Liberapay username
10-
issuehunt: # Replace with a single IssueHunt username
11-
otechie: # Replace with a single Otechie username
12-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ npm-debug.log
1414
*.lock
1515
*.backup
1616
*.cache
17+
*.jest
1718
*.tgz
19+
dist
20+
21+
# Test Artifacts
22+
*.clean

.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.env
55
*.user
66
*.vs
7+
*.github
78

89
# Package Managers
910
node_modules
@@ -15,3 +16,8 @@ npm-debug.log
1516
*.backup
1617
*.cache
1718
*.tgz
19+
.jest
20+
21+
# Source Code
22+
tsconfig.json
23+
src

.vscode/cSpell.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"version": "0.2",
3+
"ignorePaths": [
4+
"node_modules",
5+
".git",
6+
".jest",
7+
"**/.DS_Store",
8+
"*.lock.json",
9+
"*-lock.json",
10+
"*.lock",
11+
"*.tgz"
12+
],
13+
// Before adding a word, see if there is already a dictionary in which it is contained.
14+
// http://github.com/streetsidesoftware/cspell-dicts
15+
"words": [
16+
"browserslist",
17+
"editorconfig",
18+
"postpack",
19+
"roydukkey",
20+
"streetsidesoftware",
21+
"toplevel",
22+
"tsdoc",
23+
"yarpm"
24+
]
25+
}

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"editorconfig.editorconfig",
6+
"streetsidesoftware.code-spell-checker"
7+
]
8+
}

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files.exclude": {
3+
"**/node_modules": true,
4+
".jest": true,
5+
"package-lock.json": true,
6+
"yarn.lock": true
7+
}
8+
}

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@ where <option> is one of:
120120
121121
-c, --config <path> Specify the path to a configuration file.
122122
123+
-e, --extends <name>... Specify the name to a shareable configuration. (e.g. 'clean-package/common')
124+
123125
-i, --indent <value> Specify the indentation, overriding configuration from file.
124126
125127
-rm, --remove <key>... Specify the keys to remove, overriding configuration from file.
126128
127-
--removeAdd <key>... Same as --remove without overriding configuration from file.
129+
--remove-add <key>... Same as --remove without overriding configuration from file.
128130
129131
-r, --replace <key>=<value>... Specify the keys to replace, overriding configuration from file.
130132
131-
--replaceAdd <key>=<value>... Same as --replace without overriding configuration from file.
132-
133-
--extends <name>... Specify the name to a shareable configuration. (e.g. 'clean-package/common')
133+
--replace-add <key>=<value>... Same as --replace without overriding configuration from file.
134134
135135
--print-config Print the combined configuration without executing command.
136136
@@ -146,7 +146,7 @@ where <option> is one of:
146146
147147
-c, --config <path> Specify the path to a configuration file.
148148
149-
--extends <name>... Specify the name to a shareable configuration. (e.g. 'clean-package/common')
149+
-e, --extends <name>... Specify the name to a shareable configuration. (e.g. 'clean-package/common')
150150
151151
--print-config Print the combined configuration without executing command.
152152
```

bin/clean-package.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/usr/bin/env node
2-
32
'use strict';
4-
5-
require('../src');
3+
require('../dist/cli.js');

package.json

+93-83
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
"name": "clean-package",
33
"description": "Removing configuration keys in 'package.json' before creating an NPM package.",
44
"version": "1.0.1",
5-
"author": "roydukkey",
5+
"author": {
6+
"name": "roydukkey",
7+
"email": "contact@changelog.me",
8+
"url": "http://changelog.me"
9+
},
610
"license": "MIT",
711
"repository": {
812
"type": "git",
9-
"url": "git+https://roydukkey@github.com/roydukkey/clean-package.git"
13+
"url": "https://roydukkey@github.com/roydukkey/clean-package.git"
1014
},
1115
"homepage": "https://github.com/roydukkey/clean-package#readme",
1216
"bugs": {
@@ -20,107 +24,113 @@
2024
"publish",
2125
"clean"
2226
],
23-
"bin": {
24-
"clean-package": "./bin/clean-package.js"
27+
"bin": "./bin/clean-package.js",
28+
"main": "./dist/clean-package.js",
29+
"types": "./dist/clean-package.d.ts",
30+
"config": {
31+
"main": "./src/index.ts",
32+
"cli": [
33+
"./src/bin.ts",
34+
"./dist/cli.js"
35+
]
2536
},
2637
"dependencies": {
2738
"dot-object": "^2.1.3"
2839
},
2940
"devDependencies": {
30-
"@types/node": "^14.6.1",
31-
"eslint": "^7.7.0"
41+
"@babel/core": "^7.15.0",
42+
"@babel/preset-env": "^7.15.0",
43+
"@babel/preset-typescript": "^7.15.0",
44+
"@rollup/plugin-json": "^4.1.0",
45+
"@rollup/plugin-node-resolve": "^13.0.4",
46+
"@rollup/plugin-replace": "^3.0.0",
47+
"@roydukkey/eslint-config": "^1.0.10",
48+
"@types/dot-object": "^2.1.2",
49+
"@types/jest": "^27.0.1",
50+
"@types/node": "^16.7.9",
51+
"@typescript-eslint/eslint-plugin": "^4.30.0",
52+
"@typescript-eslint/parser": "^4.30.0",
53+
"babel-jest": "^27.1.0",
54+
"cspell": "^5.9.0",
55+
"eslint": "^7.32.0",
56+
"eslint-plugin-tsdoc": "^0.2.14",
57+
"jest": "^27.1.0",
58+
"rollup": "^2.56.3",
59+
"rollup-plugin-license": "^2.5.0",
60+
"rollup-plugin-ts": "^1.4.1",
61+
"terser": "^5.7.2",
62+
"typescript": "^4.4.2",
63+
"yarpm": "^1.1.1"
3264
},
3365
"scripts": {
34-
"test": "./bin/clean-package.js",
35-
"prepack": "npm test",
36-
"new:pack": "npm pack && ./bin/clean-package.js restore",
37-
"new:publish": "npm publish && ./bin/clean-package.js restore"
66+
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true })\"",
67+
"lint": "yarpm run lint:spelling && yarpm run lint:es",
68+
"lint:es": "eslint --ext js,ts ./",
69+
"lint:spelling": "cspell --config './.vscode/cSpell.json' --no-progress '**/{.*/**/,.*/**/.,,.}*'",
70+
"build": "yarpm run clean && rollup --config",
71+
"minify": "terser $npm_package_main --compress toplevel --mangle toplevel -o $npm_package_main & terser $npm_package_config_cli_1 --compress toplevel --mangle toplevel -o $npm_package_config_cli_1",
72+
"test": "jest",
73+
"test:build": "yarpm run test -- --setupTestFrameworkScriptFile=./test/setup/prepack.ts",
74+
"test:bin": "./bin/clean-package.js",
75+
"prepack": "yarpm run lint && yarpm run build && yarpm run minify && yarpm run test:build -- --coverage=false --verbose=false && clean-package",
76+
"new:pack": "yarpm pack && $npm_package_bin restore",
77+
"new:publish": "yarpm publish && $npm_package_bin restore"
3878
},
3979
"clean-package": {
4080
"indent": "\t",
4181
"remove": [
82+
"babel",
4283
"clean-package",
4384
"eslintConfig",
85+
"jest",
4486
"scripts"
4587
]
4688
},
47-
"eslintConfig": {
48-
"env": {
49-
"node": true,
50-
"es6": true
51-
},
52-
"parserOptions": {
53-
"ecmaVersion": 2018
54-
},
55-
"rules": {
56-
"arrow-parens": [
57-
"error",
58-
"always"
59-
],
60-
"arrow-spacing": [
61-
"error",
62-
{
63-
"before": true,
64-
"after": true
65-
}
66-
],
67-
"brace-style": [
68-
"error",
69-
"stroustrup",
70-
{
71-
"allowSingleLine": false
72-
}
73-
],
74-
"comma-spacing": [
75-
"error",
76-
{
77-
"before": false,
78-
"after": true
79-
}
80-
],
81-
"curly": [
82-
"error"
83-
],
84-
"comma-dangle": [
85-
"error",
86-
"never"
87-
],
88-
"key-spacing": [
89-
"error"
90-
],
91-
"object-curly-spacing": [
92-
"error",
93-
"always"
94-
],
95-
"quotes": [
96-
"error",
97-
"single"
98-
],
99-
"semi": [
100-
"error"
101-
],
102-
"sort-imports": [
103-
"error",
89+
"jest": {
90+
"testEnvironment": "node",
91+
"verbose": true,
92+
"collectCoverage": true,
93+
"coverageDirectory": ".jest/coverage",
94+
"cacheDirectory": ".jest/cache",
95+
"coveragePathIgnorePatterns": [
96+
"./test/data",
97+
"./test/setup"
98+
],
99+
"setupFiles": [
100+
"./test/setup/default.ts"
101+
]
102+
},
103+
"babel": {
104+
"presets": [
105+
[
106+
"@babel/preset-env",
104107
{
105-
"ignoreCase": false,
106-
"ignoreDeclarationSort": false,
107-
"ignoreMemberSort": false,
108-
"memberSyntaxSortOrder": [
109-
"single",
110-
"multiple",
111-
"all",
112-
"none"
113-
]
108+
"targets": {
109+
"node": "current"
110+
}
114111
}
115112
],
116-
"space-before-blocks": [
117-
"error",
118-
"always"
119-
],
120-
"space-before-function-paren": [
121-
"error",
122-
"always"
113+
[
114+
"@babel/preset-typescript"
123115
]
116+
],
117+
"comments": false
118+
},
119+
"eslintConfig": {
120+
"env": {
121+
"node": true
122+
},
123+
"ignorePatterns": [
124+
"dist/*"
125+
],
126+
"extends": [
127+
"@roydukkey/eslint-config"
128+
],
129+
"rules": {
130+
"@typescript-eslint/no-require-imports": "off",
131+
"@typescript-eslint/no-type-alias": "off",
132+
"@typescript-eslint/no-var-requires": "off",
133+
"@typescript-eslint/prefer-enum-initializers": "off"
124134
}
125135
}
126136
}

0 commit comments

Comments
 (0)