@vanillaes/esmtk 1.4.1 → 1.5.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/bin/commands/clean.js +1 -0
- package/bin/commands/init.js +4 -0
- package/bin/commands/preview.js +3 -17
- package/package.json +7 -7
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/util.d.ts +12 -0
- package/src/util.js +35 -1
package/bin/commands/clean.js
CHANGED
|
@@ -33,6 +33,7 @@ export async function clean (cwd, options) {
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Run one category of build artifacts
|
|
36
|
+
* @private
|
|
36
37
|
* @param {string} cwd the current working directory (default process.cwd())
|
|
37
38
|
* @param {string} glob the pattern of files to match
|
|
38
39
|
* @param {object} options 'clean' options
|
package/bin/commands/init.js
CHANGED
|
@@ -113,6 +113,7 @@ export async function init (options) {
|
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Ask a question on the command-line
|
|
116
|
+
* @private
|
|
116
117
|
* @param {object} program reference to the CLI
|
|
117
118
|
* @param {string} prompt the question to ask the User
|
|
118
119
|
* @param {string} [defaultValue] the default value for the question
|
|
@@ -126,6 +127,7 @@ async function ask (program, prompt, defaultValue) {
|
|
|
126
127
|
|
|
127
128
|
/**
|
|
128
129
|
* Fetch the user.name from .gitconfig
|
|
130
|
+
* @private
|
|
129
131
|
* @returns {Promise<string>} the user.name
|
|
130
132
|
*/
|
|
131
133
|
async function fetchGitUser () {
|
|
@@ -139,6 +141,7 @@ async function fetchGitUser () {
|
|
|
139
141
|
|
|
140
142
|
/**
|
|
141
143
|
* Fetch the user.email from .gitconfig
|
|
144
|
+
* @private
|
|
142
145
|
* @returns {Promise<string>} the user.email
|
|
143
146
|
*/
|
|
144
147
|
async function fetchGitEmail () {
|
|
@@ -152,6 +155,7 @@ async function fetchGitEmail () {
|
|
|
152
155
|
|
|
153
156
|
/**
|
|
154
157
|
* Fetch the repository name from .git/config
|
|
158
|
+
* @private
|
|
155
159
|
* @returns {Promise<string>} the repository name
|
|
156
160
|
*/
|
|
157
161
|
async function fetchGitRepository () {
|
package/bin/commands/preview.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { match } from '../../src/util.js'
|
|
1
|
+
import { match, readNPMIgnore } from '../../src/util.js'
|
|
2
2
|
import { statSync } from 'node:fs'
|
|
3
|
-
import { readFile } from 'node:fs/promises'
|
|
4
3
|
import { dirname, join } from 'node:path'
|
|
5
4
|
|
|
6
5
|
import { createRequire } from 'module'
|
|
@@ -33,23 +32,9 @@ export async function preview (options) {
|
|
|
33
32
|
console.log()
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
/**
|
|
37
|
-
* Read .npmignore
|
|
38
|
-
* @param {string} cwd the current working directory
|
|
39
|
-
* @returns {Promise<string>} a comma-deliminated list of ignore globs
|
|
40
|
-
*/
|
|
41
|
-
async function readNPMIgnore (cwd) {
|
|
42
|
-
const path = join(cwd, '.npmignore')
|
|
43
|
-
const contents = await readFile(path, 'utf8')
|
|
44
|
-
return contents
|
|
45
|
-
.split('\n')
|
|
46
|
-
.map(line => line.trim())
|
|
47
|
-
.filter(line => line && !line.startsWith('#'))
|
|
48
|
-
.join(',')
|
|
49
|
-
}
|
|
50
|
-
|
|
51
35
|
/**
|
|
52
36
|
* File list comparator
|
|
37
|
+
* @private
|
|
53
38
|
* @param {string} a file path a
|
|
54
39
|
* @param {string} b file path b
|
|
55
40
|
* @returns {number} 1 | -1
|
|
@@ -68,6 +53,7 @@ function fileCompare (a, b) {
|
|
|
68
53
|
|
|
69
54
|
/**
|
|
70
55
|
* Format a file path to include file size
|
|
56
|
+
* @private
|
|
71
57
|
* @param {string} path the file path
|
|
72
58
|
* @returns {string} file size followed by file path
|
|
73
59
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanillaes/esmtk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "ES Module Toolkit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecmascript",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"import": "./src/index.js",
|
|
29
|
+
"types": "./src/index.d.ts"
|
|
30
30
|
},
|
|
31
31
|
"./cp": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"import": "./src/cp.js",
|
|
33
|
+
"types": "./src/cp.d.ts"
|
|
34
34
|
},
|
|
35
35
|
"./rm": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"import": "./src/rm.js",
|
|
37
|
+
"types": "./src/rm.d.ts"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { copyAsync, copyMultipleAsync, copyRecursiveAsync } from "./cp.js";
|
|
2
2
|
export { removeAsync, removeMultipleAsync, removeRecursiveAsync } from "./rm.js";
|
|
3
|
-
export { expand, fileExists, installed, match, which } from "./util.js";
|
|
3
|
+
export { expand, fileExists, installed, match, readGitIgnore, readNPMIgnore, which } from "./util.js";
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { copyAsync, copyMultipleAsync, copyRecursiveAsync } from './cp.js'
|
|
2
2
|
export { removeAsync, removeMultipleAsync, removeRecursiveAsync } from './rm.js'
|
|
3
|
-
export { expand, fileExists, installed, match, which } from './util.js'
|
|
3
|
+
export { expand, fileExists, installed, match, readGitIgnore, readNPMIgnore, which } from './util.js'
|
package/src/util.d.ts
CHANGED
|
@@ -24,6 +24,18 @@ export function installed(pkg: string): Promise<boolean>;
|
|
|
24
24
|
* @returns {Promise<string[]>} an array of paths
|
|
25
25
|
*/
|
|
26
26
|
export function match(pattern: string, cwd?: string, ignore?: string): Promise<string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Read .gitignore
|
|
29
|
+
* @param {string} cwd the current working directory
|
|
30
|
+
* @returns {Promise<string[]>} a comma-deliminated list of ignore globs
|
|
31
|
+
*/
|
|
32
|
+
export function readGitIgnore(cwd: string): Promise<string[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Read .npmignore
|
|
35
|
+
* @param {string} cwd the current working directory
|
|
36
|
+
* @returns {Promise<string>} a comma-deliminated list of ignore globs
|
|
37
|
+
*/
|
|
38
|
+
export function readNPMIgnore(cwd: string): Promise<string>;
|
|
27
39
|
/**
|
|
28
40
|
* Check to see if an application is installed globally
|
|
29
41
|
* @param {string} program the name of the application
|
package/src/util.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { exec } from 'child_process'
|
|
2
|
-
import {
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import { access, constants, glob, readFile } from 'node:fs/promises'
|
|
3
4
|
import { promisify } from 'node:util'
|
|
4
5
|
|
|
5
6
|
const execAsync = promisify(exec)
|
|
@@ -74,6 +75,39 @@ export async function match (pattern, cwd = process.cwd(), ignore = null) {
|
|
|
74
75
|
return await Array.fromAsync(glob(patterns, { cwd }))
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Read .gitignore
|
|
80
|
+
* @param {string} cwd the current working directory
|
|
81
|
+
* @returns {Promise<string[]>} a comma-deliminated list of ignore globs
|
|
82
|
+
*/
|
|
83
|
+
export async function readGitIgnore (cwd) {
|
|
84
|
+
const path = join(cwd, '.gitignore')
|
|
85
|
+
const exists = await fileExists(path)
|
|
86
|
+
if (!exists) {
|
|
87
|
+
return []
|
|
88
|
+
}
|
|
89
|
+
const contents = await readFile(path, 'utf8')
|
|
90
|
+
return contents
|
|
91
|
+
.split('\n')
|
|
92
|
+
.map(line => line.trim())
|
|
93
|
+
.filter(line => line && !line.startsWith('#'))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Read .npmignore
|
|
98
|
+
* @param {string} cwd the current working directory
|
|
99
|
+
* @returns {Promise<string>} a comma-deliminated list of ignore globs
|
|
100
|
+
*/
|
|
101
|
+
export async function readNPMIgnore (cwd) {
|
|
102
|
+
const path = join(cwd, '.npmignore')
|
|
103
|
+
const contents = await readFile(path, 'utf8')
|
|
104
|
+
return contents
|
|
105
|
+
.split('\n')
|
|
106
|
+
.map(line => line.trim())
|
|
107
|
+
.filter(line => line && !line.startsWith('#'))
|
|
108
|
+
.join(',')
|
|
109
|
+
}
|
|
110
|
+
|
|
77
111
|
/**
|
|
78
112
|
* Check to see if an application is installed globally
|
|
79
113
|
* @param {string} program the name of the application
|