@vanillaes/esmtk 0.7.2 → 0.8.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.
@@ -2,7 +2,7 @@
2
2
  "version": "0.2.0",
3
3
  "configurations": [
4
4
  {
5
- "name": "CopyFileToFile",
5
+ "name": "Lint",
6
6
  "type": "node",
7
7
  "request": "launch",
8
8
  "skipFiles": [
@@ -10,11 +10,11 @@
10
10
  ],
11
11
  "program": "${workspaceFolder}/bin/esmtk.js",
12
12
  "cwd": "${workspaceFolder}",
13
- "args": ["cp", "./test/cp/test1.txt", "./test/cp2/test1.txt"],
13
+ "args": ["lint"],
14
14
  "console": "integratedTerminal",
15
15
  },
16
16
  {
17
- "name": "CopyFileToFolder",
17
+ "name": "Types",
18
18
  "type": "node",
19
19
  "request": "launch",
20
20
  "skipFiles": [
@@ -22,11 +22,11 @@
22
22
  ],
23
23
  "program": "${workspaceFolder}/bin/esmtk.js",
24
24
  "cwd": "${workspaceFolder}",
25
- "args": ["cp", "./test/cp/test1.txt", "./test/cp2"],
25
+ "args": ["types", "./test/index.js"],
26
26
  "console": "integratedTerminal",
27
27
  },
28
28
  {
29
- "name": "CopyFolderRecursively",
29
+ "name": "CopyFileToFile",
30
30
  "type": "node",
31
31
  "request": "launch",
32
32
  "skipFiles": [
@@ -34,11 +34,11 @@
34
34
  ],
35
35
  "program": "${workspaceFolder}/bin/esmtk.js",
36
36
  "cwd": "${workspaceFolder}",
37
- "args": ["cp", "-r", "./test/cp/", "./test/cp2"],
37
+ "args": ["cp", "./test/cp/test1.txt", "./test/cp2/test1.txt"],
38
38
  "console": "integratedTerminal",
39
39
  },
40
40
  {
41
- "name": "Lint",
41
+ "name": "CopyFileToFolder",
42
42
  "type": "node",
43
43
  "request": "launch",
44
44
  "skipFiles": [
@@ -46,7 +46,19 @@
46
46
  ],
47
47
  "program": "${workspaceFolder}/bin/esmtk.js",
48
48
  "cwd": "${workspaceFolder}",
49
- "args": ["lint"],
49
+ "args": ["cp", "./test/cp/test1.txt", "./test/cp2"],
50
+ "console": "integratedTerminal",
51
+ },
52
+ {
53
+ "name": "CopyFolderRecursively",
54
+ "type": "node",
55
+ "request": "launch",
56
+ "skipFiles": [
57
+ "<node_internals>/**"
58
+ ],
59
+ "program": "${workspaceFolder}/bin/esmtk.js",
60
+ "cwd": "${workspaceFolder}",
61
+ "args": ["cp", "-r", "./test/cp/", "./test/cp2"],
50
62
  "console": "integratedTerminal",
51
63
  },
52
64
  {
package/README.md CHANGED
@@ -25,6 +25,22 @@ Lint the source code (using StandardJS)
25
25
  esmtk lint
26
26
  ```
27
27
 
28
+ ## Types
29
+
30
+ Type check the JSDoc typings (using Typescript)
31
+
32
+ ### Arguments
33
+
34
+ `esmtk types index.js`
35
+
36
+ - `[entry]` - the entry-point for the source
37
+
38
+ ### Usage
39
+
40
+ ```sh
41
+ esmtk types index.js
42
+ ```
43
+
28
44
  ## Bundle
29
45
 
30
46
  Bundle the source code to an ECMAScript module (using ESBuild)
@@ -11,14 +11,14 @@ export async function bundle (input, output) {
11
11
  if (!npmExists) {
12
12
  console.error('npm not found')
13
13
  console.error('is node installed?')
14
- return
14
+ process.exit(1)
15
15
  }
16
16
 
17
17
  const esbuildExists = await installed('esbuild')
18
18
  if (!esbuildExists) {
19
19
  console.error('esbuild not found')
20
20
  console.error('esbuild can be installed with `npm i -g esbuild`')
21
- return
21
+ process.exit(1)
22
22
  }
23
23
 
24
24
  spawn('esbuild', ['--format=esm', '--bundle', input, `--outfile=${output}`], {
@@ -11,14 +11,14 @@ export async function commonjs (input, output) {
11
11
  if (!npmExists) {
12
12
  console.error('npm not found')
13
13
  console.error('is node installed?')
14
- return
14
+ process.exit(1)
15
15
  }
16
16
 
17
17
  const esbuildExists = await installed('esbuild')
18
18
  if (!esbuildExists) {
19
19
  console.error('esbuild not found')
20
20
  console.error('esbuild can be installed with `npm i -g esbuild`')
21
- return
21
+ process.exit(1)
22
22
  }
23
23
 
24
24
  spawn('esbuild', ['--format=cjs', '--bundle', input, `--outfile=${output}`], {
@@ -4,3 +4,4 @@ export { cp } from './cp.js'
4
4
  export { lint } from './lint.js'
5
5
  export { minify } from './minify.js'
6
6
  export { rm } from './rm.js'
7
+ export { types } from './types.js'
@@ -11,14 +11,14 @@ export async function minify (input, output) {
11
11
  if (!npmExists) {
12
12
  console.error('npm not found')
13
13
  console.error('is node installed?')
14
- return
14
+ process.exit(1)
15
15
  }
16
16
 
17
17
  const esbuildExists = await installed('esbuild')
18
18
  if (!esbuildExists) {
19
19
  console.error('esbuild not found')
20
20
  console.error('esbuild can be installed with `npm i -g esbuild`')
21
- return
21
+ process.exit(1)
22
22
  }
23
23
 
24
24
  spawn('esbuild', ['--format=esm', '--minify', '--bundle', input, `--outfile=${output}`], {
@@ -0,0 +1,29 @@
1
+ import { installed, which } from '../../src/util.js'
2
+ import { spawn } from 'child_process'
3
+
4
+ /**
5
+ * Type Check the JSDOC typings
6
+ * @param {string} entry the entry point
7
+ */
8
+ export async function types (entry) {
9
+ const npmExists = await which('npm')
10
+ if (!npmExists) {
11
+ console.error('npm not found')
12
+ console.error('is node installed?')
13
+ process.exit(1)
14
+ }
15
+
16
+ const esbuildExists = await installed('typescript')
17
+ if (!esbuildExists) {
18
+ console.error('typescript not found')
19
+ console.error('typescript can be installed with `npm i -g typescript`')
20
+ process.exit(1)
21
+ }
22
+
23
+ spawn('tsc', [entry, '-t', 'esnext', '--allowJS', '--checkJS', '--skipLibCheck', '--noEmit'], {
24
+ cwd: process.cwd(),
25
+ stdio: ['pipe', process.stdout, process.stderr]
26
+ }).on('error', err => {
27
+ console.error(err)
28
+ })
29
+ }
package/bin/esmtk.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { bundle, cp, commonjs, lint, minify, rm } from './commands/index.js'
2
+ import { bundle, cp, commonjs, lint, minify, rm, types } from './commands/index.js'
3
3
  import { Command } from 'commander'
4
4
  import { createRequire } from 'module'
5
5
  const program = new Command()
@@ -16,6 +16,12 @@ program.command('lint')
16
16
  lint(flags)
17
17
  })
18
18
 
19
+ program.command('types <entry>')
20
+ .description('Type check the JSDoc typings using Typescript')
21
+ .action((entry) => {
22
+ types(entry)
23
+ })
24
+
19
25
  program.command('bundle <input> <output>')
20
26
  .description('Bundle the source using ESBuild')
21
27
  .action((input, output) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillaes/esmtk",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "ES Module Toolkit",
5
5
  "keywords": [
6
6
  "esm",
@@ -23,7 +23,8 @@
23
23
  },
24
24
  "scripts": {
25
25
  "lint": "./bin/esmtk.js lint",
26
- "preversion": "npm run lint",
26
+ "types": "./bin/esmtk.js types src/index.js",
27
+ "preversion": "npm run lint && npm run types",
27
28
  "postversion": "git push --follow-tags"
28
29
  },
29
30
  "dependencies": {
@@ -32,5 +33,8 @@
32
33
  },
33
34
  "engines": {
34
35
  "node": ">=17"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^25.3.5"
35
39
  }
36
40
  }
package/src/cp.js CHANGED
@@ -51,7 +51,7 @@ export async function copyAsync (source, target, force = false) {
51
51
  * Recursively copy a directory asynchronously
52
52
  * @param {string} source The source directory
53
53
  * @param {string} target The target directory
54
- * @param {bool} force If the file already exists, overwrite it (default false)
54
+ * @param {boolean} force If the file already exists, overwrite it (default false)
55
55
  */
56
56
  export async function copyRecursiveAsync (source, target, force = false) {
57
57
  const sExists = await fileExists(source)
package/src/rm.js CHANGED
@@ -27,7 +27,7 @@ export async function removeAsync (path, force = false) {
27
27
  /**
28
28
  * Recursively remove a file|directory asynchronously
29
29
  * @param {string} path The file|directory to remove
30
- * @param {bool} force Ignore exceptions if the file|directory doesn't exist (default false)
30
+ * @param {boolean} force Ignore exceptions if the file|directory doesn't exist (default false)
31
31
  */
32
32
  export async function removeRecursiveAsync (path, force = false) {
33
33
  const exists = await fileExists(path)