@vanillaes/esmtk 0.27.0 → 1.0.1

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  <div align="center">ESMTK, essential tools for ECMAScript module development</div>
4
4
 
5
+ <br />
6
+
5
7
  <div align="center">
6
8
  <a href="https://github.com/vanillaes/esmtk/releases"><img src="https://badgen.net/github/tag/vanillaes/esmtk?cache-control=no-cache" alt="GitHub Release"></a>
7
9
  <a href="https://www.npmjs.com/package/@vanillaes/esmtk"><img src="https://badgen.net/npm/v/@vanillaes/esmtk?icon=npm" alt="NPM Version"></a>
@@ -57,7 +59,7 @@ Run tests (using Tape-ES)
57
59
 
58
60
  - `[glob]` - the glob used to locate test files (default: `**/*.spec.js`)
59
61
  - `--ignore` - the ignore matcher pattern (default `**/node_modules/**`)
60
- - `--root` - the root path to run the tests from (default `process.cwd()`)
62
+ - `--cwd` - the current working directory (default `process.cwd()`)
61
63
  - `--watch` - watch for changes to the tests
62
64
 
63
65
  ### Usage
@@ -72,8 +74,8 @@ npx @vanillaes/esmtk test **/*.test.js
72
74
  # run the tests (ignore tests)
73
75
  npx @vanillaes/esmtk test **/*.test.js --ignore **/node_modules/**,src/rm.spec.js
74
76
 
75
- # run the tests (change the root)
76
- npx @vanillaes/esmtk test **/*.test.js --root src/
77
+ # run the tests (change the current working directory)
78
+ npx @vanillaes/esmtk test **/*.test.js --cwd src/
77
79
 
78
80
  # run the tests (watch for changes)
79
81
  npx @vanillaes/esmtk test --watch
@@ -222,9 +224,9 @@ Clean up build artifacts
222
224
 
223
225
  ### Arguments
224
226
 
225
- `esmtk clean [...options] [root]`
227
+ `esmtk clean [...options] [cwd]`
226
228
 
227
- - `[root]` - the root directory to perform the cleanup (default: `process.cwd()`)
229
+ - `[cwd]` - the current working directory (default: `process.cwd()`)
228
230
  - `--bundle` - Clean bundled build artifacts (default: `**/*.esm.js`)
229
231
  - `--minify` - Clean minified build artifacts (default: `**/*.min.js`)
230
232
  - `--typings` - Clean typing artifacts (default: `**/*.d.ts`)
@@ -254,7 +256,7 @@ Preview the package contents included during `npm publish`
254
256
 
255
257
  `esmtk preview [...options]`
256
258
 
257
- - `--root` - the root path to preview
259
+ - `--cwd` - the current working directory
258
260
 
259
261
  ### Usage
260
262
 
@@ -262,8 +264,8 @@ Preview the package contents included during `npm publish`
262
264
  # preview the package contents
263
265
  esmtk preview
264
266
 
265
- # preview the package contents (from another root directory)
266
- esmtk preview --root some/other/dir
267
+ # preview the package contents (from another directory)
268
+ esmtk preview --cwd some/other/dir
267
269
  ```
268
270
 
269
271
 
@@ -3,40 +3,40 @@ import { fileExists, match } from '../../src/util.js'
3
3
 
4
4
  /**
5
5
  * Clean build artifcats using sensible defaults
6
- * @param {string} root the root directory
6
+ * @param {string} cwd the currnt working directory
7
7
  * @param {object} options 'clean' options
8
8
  */
9
- export async function clean (root, options) {
10
- const exists = await fileExists(root)
9
+ export async function clean (cwd, options) {
10
+ const exists = await fileExists(cwd)
11
11
  if (!exists) {
12
- console.error(`clean: ${root} No such file or directory`)
12
+ console.error(`clean: ${cwd} No such file or directory`)
13
13
  process.exit(1)
14
14
  }
15
15
 
16
16
  if (options?.bundle) {
17
- await cleanOne(root, options.bundle, options)
17
+ await cleanOne(cwd, options.bundle, options)
18
18
  }
19
19
 
20
20
  if (options?.minify) {
21
- await cleanOne(root, options.minify, options)
21
+ await cleanOne(cwd, options.minify, options)
22
22
  }
23
23
 
24
24
  if (options?.typings) {
25
- await cleanOne(root, options.typings, options)
25
+ await cleanOne(cwd, options.typings, options)
26
26
  }
27
27
 
28
28
  if (options?.custom) {
29
- await cleanOne(root, options.custom, options)
29
+ await cleanOne(cwd, options.custom, options)
30
30
  }
31
31
  }
32
32
 
33
33
  /**
34
34
  * Run one category of build artifacts
35
- * @param {string} root the root directory (default process.cwd())
35
+ * @param {string} cwd the current working directory (default process.cwd())
36
36
  * @param {string} glob the pattern of files to match
37
37
  * @param {object} options 'clean' options
38
38
  */
39
- async function cleanOne (root, glob, options) {
40
- const files = await match(glob, root, 'node_modules/**')
39
+ async function cleanOne (cwd, glob, options) {
40
+ const files = await match(glob, cwd, 'node_modules/**')
41
41
  await removeMultipleAsync(files, options?.force)
42
42
  }
@@ -11,10 +11,10 @@ const require = createRequire(import.meta.url)
11
11
  * @param {object} options 'preview' options
12
12
  */
13
13
  export async function preview (options) {
14
- let ignore = await readNPMIgnore(options.root)
14
+ let ignore = await readNPMIgnore(options.cwd)
15
15
  ignore = `${ignore},node_modules/,package-lock.json`
16
16
 
17
- let files = await match('**/*', options.root, ignore)
17
+ let files = await match('**/*', options.cwd, ignore)
18
18
  if (files.length === 0) {
19
19
  console.log('preview: no files found')
20
20
  process.exit(0)
@@ -23,7 +23,7 @@ export async function preview (options) {
23
23
  .filter(path => statSync(path).isFile())
24
24
  .sort((a, b) => fileCompare(a, b))
25
25
 
26
- const pkg = require(join(options.root, 'package.json'))
26
+ const pkg = require(join(options.cwd, 'package.json'))
27
27
 
28
28
  console.log()
29
29
  console.log(`📦 ${pkg.name}@${pkg.version}`)
@@ -35,11 +35,11 @@ export async function preview (options) {
35
35
 
36
36
  /**
37
37
  * Read .npmignore
38
- * @param {string} root the root path
38
+ * @param {string} cwd the current working directory
39
39
  * @returns {Promise<string>} a comma-deliminated list of ignore globs
40
40
  */
41
- async function readNPMIgnore (root) {
42
- const path = join(root, '.npmignore')
41
+ async function readNPMIgnore (cwd) {
42
+ const path = join(cwd, '.npmignore')
43
43
  const contents = await readFile(path, 'utf8')
44
44
  return contents
45
45
  .split('\n')
@@ -13,9 +13,9 @@ export async function test (glob, options) {
13
13
  args.push('--ignore')
14
14
  args.push(options.ignore)
15
15
  }
16
- if (options?.root) {
17
- args.push('--root')
18
- args.push(options.root)
16
+ if (options?.cwd) {
17
+ args.push('--cwd')
18
+ args.push(options.cwd)
19
19
  }
20
20
  if (options?.watch) {
21
21
  args.push('--watch')
package/bin/esmtk.js CHANGED
@@ -19,7 +19,7 @@ program.command('test')
19
19
  .description('Run tests using Tape-ES')
20
20
  .argument('[glob]', 'The glob pattern used to find test files (default: `**/*.spec.js`)', '**/*.spec.js')
21
21
  .option('--ignore <ignore>', 'the ignore matcher pattern (default `**/node_modules/**`)')
22
- .option('--root <root>', 'the root path to run the tests from (default `process.cwd()`)')
22
+ .option('--cwd <cwd>', 'the current working directory (default `process.cwd()`)')
23
23
  .option('--watch', 'Watch the files for changes')
24
24
  .action((glob, options) => {
25
25
  test(glob, options)
@@ -35,6 +35,7 @@ program.command('lint')
35
35
 
36
36
  program.command('type <entry>')
37
37
  .description('Type check the JSDoc typings using Typescript')
38
+ .option('--strict', 'Enable \'strict mode\'')
38
39
  .action((entry, options) => {
39
40
  type(entry, options)
40
41
  })
@@ -69,13 +70,13 @@ program.command('minify <input> <output>')
69
70
 
70
71
  program.command('clean')
71
72
  .description('Clean build artificts')
72
- .argument('[root]', 'The root directory to perform operations from (default cwd)', process.cwd())
73
+ .argument('[cwd]', 'The current working directory (default cwd)', process.cwd())
73
74
  .option('--bundle [bundle]', 'Clean bundled build artifacts (default: **/*.esm.js)')
74
75
  .option('--minify [minify]', 'Clean minified build artifacts (default: **/*.min.js)')
75
76
  .option('--typings [typings]', 'Clean typing artifacts (default: **/*.d.ts)')
76
77
  .option('--custom <custom>', 'Clean based on a user-defined pattern')
77
78
  // .option('-f, --force', 'Do not prompt before overwriting', false)
78
- .action((root, options) => {
79
+ .action((cwd, options) => {
79
80
  // set --bundle default
80
81
  if (options?.bundle && typeof (options.bundle) === 'boolean') {
81
82
  options.bundle = '**/*.esm.js'
@@ -89,12 +90,12 @@ program.command('clean')
89
90
  options.typings = '**/*.d.ts'
90
91
  }
91
92
 
92
- clean(root, options)
93
+ clean(cwd, options)
93
94
  })
94
95
 
95
96
  program.command('preview')
96
97
  .description('Preview the package contents included during \'npm publish\'')
97
- .option('--root <root>', 'the root path to run the tests from (default `process.cwd()`)', process.cwd())
98
+ .option('--cwd <cwd>', 'the current working directory (default `process.cwd()`)', process.cwd())
98
99
  .action((options) => {
99
100
  preview(options)
100
101
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillaes/esmtk",
3
- "version": "0.27.0",
3
+ "version": "1.0.1",
4
4
  "description": "ES Module Toolkit",
5
5
  "keywords": [
6
6
  "ecmascript",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@vanillaes/lint-es": "^1.0.0",
57
- "@vanillaes/tape-es": "^3.0.3",
57
+ "@vanillaes/tape-es": "^4.0.1",
58
58
  "commander": "^14.0.3"
59
59
  },
60
60
  "devDependencies": {
package/src/util.d.ts CHANGED
@@ -19,11 +19,11 @@ export function installed(pkg: string): Promise<boolean>;
19
19
  /**
20
20
  * Description
21
21
  * @param {string} pattern glob pattern(s) to match
22
- * @param {string} root root path where the matcher runs from
22
+ * @param {string} cwd the current working directory
23
23
  * @param {string} ignore glob of pattern(s) to ignore
24
24
  * @returns {Promise<string[]>} an array of paths
25
25
  */
26
- export function match(pattern: string, root?: string, ignore?: string): Promise<string[]>;
26
+ export function match(pattern: string, cwd?: string, ignore?: string): Promise<string[]>;
27
27
  /**
28
28
  * Check to see if an application is installed globally
29
29
  * @param {string} program the name of the application
package/src/util.js CHANGED
@@ -59,16 +59,16 @@ export async function installed (pkg) {
59
59
  /**
60
60
  * Description
61
61
  * @param {string} pattern glob pattern(s) to match
62
- * @param {string} root root path where the matcher runs from
62
+ * @param {string} cwd the current working directory
63
63
  * @param {string} ignore glob of pattern(s) to ignore
64
64
  * @returns {Promise<string[]>} an array of paths
65
65
  */
66
- export async function match (pattern, root = process.cwd(), ignore = null) {
66
+ export async function match (pattern, cwd = process.cwd(), ignore = null) {
67
67
  if (ignore) {
68
68
  const ignores = ignore.includes(',') ? ignore.split(',') : [ignore]
69
- return await Array.fromAsync(glob(pattern, { cwd: root, exclude: ignores }))
69
+ return await Array.fromAsync(glob(pattern, { cwd, exclude: ignores }))
70
70
  }
71
- return await Array.fromAsync(glob(pattern, { cwd: root }))
71
+ return await Array.fromAsync(glob(pattern, { cwd }))
72
72
  }
73
73
 
74
74
  /**