@vanillaes/esmtk 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +12 -0
- package/README.md +68 -4
- package/bin/commands/index.js +1 -0
- package/bin/commands/test.js +22 -0
- package/bin/esmtk.js +9 -2
- package/package.json +2 -1
package/.vscode/launch.json
CHANGED
|
@@ -25,6 +25,18 @@
|
|
|
25
25
|
"args": ["init"],
|
|
26
26
|
"console": "integratedTerminal",
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Test",
|
|
30
|
+
"type": "node",
|
|
31
|
+
"request": "launch",
|
|
32
|
+
"skipFiles": [
|
|
33
|
+
"<node_internals>/**"
|
|
34
|
+
],
|
|
35
|
+
"program": "${workspaceFolder}/bin/esmtk.js",
|
|
36
|
+
"cwd": "${workspaceFolder}",
|
|
37
|
+
"args": ["test"],
|
|
38
|
+
"console": "integratedTerminal",
|
|
39
|
+
},
|
|
28
40
|
{
|
|
29
41
|
"name": "Lint",
|
|
30
42
|
"type": "node",
|
package/README.md
CHANGED
|
@@ -10,6 +10,62 @@ ESMTK, essential tools for ECMAScript module development
|
|
|
10
10
|
<a href="https://github.com/vanillaes/esmtk/actions"><img src="https://github.com/vanillaes/esmtk/workflows/Release/badge.svg" alt="Release Status"></a>
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
- [init](#init) - Create a package.json file for ECMAScript module development
|
|
16
|
+
- [test](#test) - Run tests (using Tape-ES)
|
|
17
|
+
- [lint](#lint) - Lint the source code (using StandardJS)
|
|
18
|
+
- [types](#lint) - Type check the JSDoc typings (using Typescript)
|
|
19
|
+
- [bundle](#bundle) - Bundle the source code to an ECMAScript module (using ESBuild)
|
|
20
|
+
- [minify](#minify) - Bundle and Minify the source code to an ECMAScript module (using ESBuild)
|
|
21
|
+
- [commonjs](#commonjs) - Bundle the source code to a CommonJS module (using ESBuild)
|
|
22
|
+
- [typeings](#typings) - Generate Type Declarations (.d.ts) from JSDoc (using Typescript)
|
|
23
|
+
- [clean](#clean) - Clean up build artifacts
|
|
24
|
+
- [cp](#cp) - A cross-platform clone of the `cp` command in Linux
|
|
25
|
+
- [rm](#rm) - A cross-platform clone of the `rm` command in Linux
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Init
|
|
29
|
+
|
|
30
|
+
Create a package.json file for ECMAScript module development
|
|
31
|
+
|
|
32
|
+
### Arguments
|
|
33
|
+
|
|
34
|
+
`esmtk init`
|
|
35
|
+
|
|
36
|
+
### Usage
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
# init package.json
|
|
40
|
+
npx @vanillaes/esmtk init
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Test
|
|
45
|
+
|
|
46
|
+
Run tests (using Tape-ES)
|
|
47
|
+
|
|
48
|
+
### Arguments
|
|
49
|
+
|
|
50
|
+
`esmtk test [glob]`
|
|
51
|
+
|
|
52
|
+
- `[glob]` - the glob used to locate test files (default: `**/*.spec.js`)
|
|
53
|
+
- `--watch` - watch for changes to the tests
|
|
54
|
+
|
|
55
|
+
### Usage
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
# run the tests
|
|
59
|
+
npx @vanillaes/esmtk test
|
|
60
|
+
|
|
61
|
+
# run the tests (using a different naming scheme)
|
|
62
|
+
npx @vanillaes/esmtk test **/*.test.js
|
|
63
|
+
|
|
64
|
+
# run the tests (watch for changes)
|
|
65
|
+
npx @vanillaes/esmtk test --watch
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
|
|
13
69
|
## Lint
|
|
14
70
|
|
|
15
71
|
Lint the source code (using StandardJS)
|
|
@@ -30,6 +86,7 @@ esmtk lint
|
|
|
30
86
|
esmtk --fix lint
|
|
31
87
|
```
|
|
32
88
|
|
|
89
|
+
|
|
33
90
|
## Types
|
|
34
91
|
|
|
35
92
|
Type check the JSDoc typings (using Typescript)
|
|
@@ -53,6 +110,7 @@ esmtk types --strict index.js
|
|
|
53
110
|
|
|
54
111
|
**Node: Due to Typescript limitations, inline JSDoc typings will be ignored if typings (ie `*.d.ts` files) exist.**
|
|
55
112
|
|
|
113
|
+
|
|
56
114
|
## Bundle
|
|
57
115
|
|
|
58
116
|
Bundle the source code to an ECMAScript module (using ESBuild)
|
|
@@ -75,6 +133,7 @@ esmtk bundle src/sample.js bundle.js
|
|
|
75
133
|
esmtk bundle --platform=node src/sample.js bundle.js
|
|
76
134
|
```
|
|
77
135
|
|
|
136
|
+
|
|
78
137
|
## Minify
|
|
79
138
|
|
|
80
139
|
Bundle and Minify the source code to an ECMAScript module (using ESBuild)
|
|
@@ -101,6 +160,7 @@ esmtk minify --platform=node src/sample.js bundle.min.js
|
|
|
101
160
|
esmtk minify --sourcemap src/sample.js bundle.min.js
|
|
102
161
|
```
|
|
103
162
|
|
|
163
|
+
|
|
104
164
|
## CommonJS
|
|
105
165
|
|
|
106
166
|
Bundle the source code to a CommonJS module (using ESBuild)
|
|
@@ -123,6 +183,7 @@ esmtk commonjs src/sample.js bundle.cjs
|
|
|
123
183
|
esmtk commonjs --platform=node src/sample.js bundle.cjs
|
|
124
184
|
```
|
|
125
185
|
|
|
186
|
+
|
|
126
187
|
## Typings
|
|
127
188
|
|
|
128
189
|
Generate Type Declarations (.d.ts) from JSDoc (using Typescript)
|
|
@@ -140,6 +201,7 @@ Generate Type Declarations (.d.ts) from JSDoc (using Typescript)
|
|
|
140
201
|
esmtk typings index.js
|
|
141
202
|
```
|
|
142
203
|
|
|
204
|
+
|
|
143
205
|
## Clean
|
|
144
206
|
|
|
145
207
|
Clean up build artifacts
|
|
@@ -169,9 +231,10 @@ esmtk clean --custom *.scss.css
|
|
|
169
231
|
|
|
170
232
|
**Node: The `clean` command automatically ignores the contents of `node_modules/`**
|
|
171
233
|
|
|
172
|
-
## Copy
|
|
173
234
|
|
|
174
|
-
|
|
235
|
+
## CP
|
|
236
|
+
|
|
237
|
+
A cross-platform clone of the `cp` command in Linux
|
|
175
238
|
|
|
176
239
|
### Arguments
|
|
177
240
|
|
|
@@ -200,9 +263,10 @@ esmtk cp *.txt *.js *.ts dest/
|
|
|
200
263
|
esmtk cp -r src/ dest/
|
|
201
264
|
```
|
|
202
265
|
|
|
203
|
-
## Remove
|
|
204
266
|
|
|
205
|
-
|
|
267
|
+
## RM
|
|
268
|
+
|
|
269
|
+
A cross-platform clone of the `rm` command in Linux
|
|
206
270
|
|
|
207
271
|
### Arguments
|
|
208
272
|
|
package/bin/commands/index.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { spawn } from 'child_process'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test runnner using Tape-ES
|
|
5
|
+
* @param {string} glob the glob to match test files
|
|
6
|
+
* @param {any} options bundle options
|
|
7
|
+
*/
|
|
8
|
+
export async function test (glob, options) {
|
|
9
|
+
const args = []
|
|
10
|
+
args.push('./node_modules/.bin/tape-es')
|
|
11
|
+
args.push(glob)
|
|
12
|
+
if (options?.watch) {
|
|
13
|
+
args.push('--watch')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
spawn('node', args, {
|
|
17
|
+
cwd: process.cwd(),
|
|
18
|
+
stdio: ['pipe', process.stdout, process.stderr]
|
|
19
|
+
}).on('error', err => {
|
|
20
|
+
console.error(err)
|
|
21
|
+
})
|
|
22
|
+
}
|
package/bin/esmtk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { bundle, clean, cp, commonjs, init, lint, minify, rm, types, typings } from './commands/index.js'
|
|
2
|
+
import { bundle, clean, cp, commonjs, init, lint, minify, rm, test, types, typings } from './commands/index.js'
|
|
3
3
|
import { Command } from 'commander'
|
|
4
4
|
import { createRequire } from 'module'
|
|
5
5
|
const program = new Command()
|
|
@@ -14,6 +14,14 @@ program.command('init')
|
|
|
14
14
|
init()
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
+
program.command('test')
|
|
18
|
+
.description('Run tests using Tape-ES')
|
|
19
|
+
.argument('[glob]', 'The glob pattern used to find test files', '**/*.spec.js')
|
|
20
|
+
.option('--watch', 'Watch the files for changes')
|
|
21
|
+
.action((glob, options) => {
|
|
22
|
+
test(glob, options)
|
|
23
|
+
})
|
|
24
|
+
|
|
17
25
|
program.command('lint')
|
|
18
26
|
.description('Lint the source using StandardJS')
|
|
19
27
|
.option('--fix', 'Automatically fix problems')
|
|
@@ -24,7 +32,6 @@ program.command('lint')
|
|
|
24
32
|
|
|
25
33
|
program.command('types <entry>')
|
|
26
34
|
.description('Type check the JSDoc typings using Typescript')
|
|
27
|
-
.option('--strict', 'Enable strict type checks')
|
|
28
35
|
.action((entry, options) => {
|
|
29
36
|
types(entry, options)
|
|
30
37
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanillaes/esmtk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "ES Module Toolkit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecmascript",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"node": ">=22"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@vanillaes/tape-es": "^2.0.2",
|
|
53
54
|
"commander": "^14.0.3",
|
|
54
55
|
"standard": "^17.1.2"
|
|
55
56
|
},
|