markdown-magic 4.0.3 → 4.0.5
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/package.json +13 -9
- package/src/cli-run.js +27 -0
- package/src/utils/ansi-styles.d.ts +345 -0
- package/src/utils/ansi-styles.js +167 -0
- package/src/utils/fs.test.js +1 -0
- package/src/utils/logs.js +2 -2
- package/src/utils/remoteRequest.js +0 -20
- package/types/src/defaults.d.ts +2 -2
- package/types/src/defaults.d.ts.map +1 -1
- package/types/src/index.d.ts +15 -10
- package/types/src/index.d.ts.map +1 -1
- package/types/src/transforms/install.d.ts +3 -3
- package/types/src/utils/text.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-magic",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Automatically update markdown files with content from external sources",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"docs": "node examples/generate-readme.js",
|
|
23
23
|
"test": "uvu . '.test.([mc]js|[jt]sx?)$'",
|
|
24
24
|
"cli": "node ./cli.js --path 'README.md' --config ./markdown.config.js",
|
|
25
|
+
"bundle": "npm run bundle:all",
|
|
26
|
+
"bundle:all": "npm run bundle:mac && npm run bundle:linux && npm run bundle:windows",
|
|
27
|
+
"bundle:mac": "bun build ./cli.js --compile --minify --target=bun-darwin-arm64 --outfile dist/md-magic-darwin-arm64 && bun build ./cli.js --compile --minify --target=bun-darwin-x64 --outfile dist/md-magic-darwin-x64",
|
|
28
|
+
"bundle:linux": "bun build ./cli.js --compile --minify --target=bun-linux-x64 --outfile dist/md-magic-linux-x64 && bun build ./cli.js --compile --minify --target=bun-linux-arm64 --outfile dist/md-magic-linux-arm64",
|
|
29
|
+
"bundle:windows": "bun build ./cli.js --compile --minify --target=bun-windows-x64 --outfile dist/md-magic-windows-x64.exe",
|
|
25
30
|
"postpublish": "git push origin && git push origin --tags",
|
|
26
31
|
"release:patch": "pnpm version patch --git-tag-version && pnpm publish",
|
|
27
32
|
"release:minor": "pnpm version minor --git-tag-version && pnpm publish",
|
|
@@ -36,9 +41,10 @@
|
|
|
36
41
|
},
|
|
37
42
|
"dependencies": {
|
|
38
43
|
"@davidwells/md-utils": "0.0.53",
|
|
39
|
-
"
|
|
40
|
-
"comment-block-
|
|
41
|
-
"comment-block-
|
|
44
|
+
"color-convert": "^2.0.1",
|
|
45
|
+
"comment-block-parser": "1.1.2",
|
|
46
|
+
"comment-block-replacer": "0.1.4",
|
|
47
|
+
"comment-block-transformer": "0.2.3",
|
|
42
48
|
"globrex": "^0.1.2",
|
|
43
49
|
"gray-matter": "^4.0.3",
|
|
44
50
|
"is-glob": "^4.0.3",
|
|
@@ -48,14 +54,12 @@
|
|
|
48
54
|
"module-alias": "^2.2.3",
|
|
49
55
|
"mri": "^1.2.0",
|
|
50
56
|
"node-fetch": "^2.7.0",
|
|
51
|
-
"oparser": "^3.0.
|
|
57
|
+
"oparser": "^3.0.24",
|
|
52
58
|
"punycode": "^2.3.1",
|
|
53
59
|
"smart-glob": "^1.0.2",
|
|
54
|
-
"string-width": "^4.2.3"
|
|
55
|
-
"sync-request": "^6.1.0"
|
|
60
|
+
"string-width": "^4.2.3"
|
|
56
61
|
},
|
|
57
62
|
"devDependencies": {
|
|
58
|
-
"ansi-styles": "^4.2.1",
|
|
59
63
|
"concordance": "^5.0.1",
|
|
60
64
|
"doxxx": "^2.0.7",
|
|
61
65
|
"rimraf": "^3.0.2",
|
|
@@ -66,5 +70,5 @@
|
|
|
66
70
|
"publishConfig": {
|
|
67
71
|
"access": "public"
|
|
68
72
|
},
|
|
69
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7d81950b7a6d27d1192b1bc2d0f19d1d5ff0f321"
|
|
70
74
|
}
|
package/src/cli-run.js
CHANGED
|
@@ -21,6 +21,33 @@ function findSingleDashStrings(arr) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function runCli(options = {}, rawArgv) {
|
|
24
|
+
if (options.help || options.h) {
|
|
25
|
+
console.log(`
|
|
26
|
+
Usage: md-magic [options] [files...]
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
--files, --file Files or glob patterns to process
|
|
30
|
+
--config Path to config file (default: md.config.js)
|
|
31
|
+
--output Output directory
|
|
32
|
+
--dry Dry run - show what would be changed
|
|
33
|
+
--debug Show debug output
|
|
34
|
+
--help, -h Show this help message
|
|
35
|
+
--version, -v Show version
|
|
36
|
+
|
|
37
|
+
Examples:
|
|
38
|
+
md-magic README.md
|
|
39
|
+
md-magic --files "**/*.md"
|
|
40
|
+
md-magic --config ./my-config.js
|
|
41
|
+
`)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (options.version || options.v) {
|
|
46
|
+
const pkg = require('../package.json')
|
|
47
|
+
console.log(pkg.version)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
24
51
|
let configFile
|
|
25
52
|
let opts = {}
|
|
26
53
|
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
declare type CSSColor =
|
|
2
|
+
| 'aliceblue'
|
|
3
|
+
| 'antiquewhite'
|
|
4
|
+
| 'aqua'
|
|
5
|
+
| 'aquamarine'
|
|
6
|
+
| 'azure'
|
|
7
|
+
| 'beige'
|
|
8
|
+
| 'bisque'
|
|
9
|
+
| 'black'
|
|
10
|
+
| 'blanchedalmond'
|
|
11
|
+
| 'blue'
|
|
12
|
+
| 'blueviolet'
|
|
13
|
+
| 'brown'
|
|
14
|
+
| 'burlywood'
|
|
15
|
+
| 'cadetblue'
|
|
16
|
+
| 'chartreuse'
|
|
17
|
+
| 'chocolate'
|
|
18
|
+
| 'coral'
|
|
19
|
+
| 'cornflowerblue'
|
|
20
|
+
| 'cornsilk'
|
|
21
|
+
| 'crimson'
|
|
22
|
+
| 'cyan'
|
|
23
|
+
| 'darkblue'
|
|
24
|
+
| 'darkcyan'
|
|
25
|
+
| 'darkgoldenrod'
|
|
26
|
+
| 'darkgray'
|
|
27
|
+
| 'darkgreen'
|
|
28
|
+
| 'darkgrey'
|
|
29
|
+
| 'darkkhaki'
|
|
30
|
+
| 'darkmagenta'
|
|
31
|
+
| 'darkolivegreen'
|
|
32
|
+
| 'darkorange'
|
|
33
|
+
| 'darkorchid'
|
|
34
|
+
| 'darkred'
|
|
35
|
+
| 'darksalmon'
|
|
36
|
+
| 'darkseagreen'
|
|
37
|
+
| 'darkslateblue'
|
|
38
|
+
| 'darkslategray'
|
|
39
|
+
| 'darkslategrey'
|
|
40
|
+
| 'darkturquoise'
|
|
41
|
+
| 'darkviolet'
|
|
42
|
+
| 'deeppink'
|
|
43
|
+
| 'deepskyblue'
|
|
44
|
+
| 'dimgray'
|
|
45
|
+
| 'dimgrey'
|
|
46
|
+
| 'dodgerblue'
|
|
47
|
+
| 'firebrick'
|
|
48
|
+
| 'floralwhite'
|
|
49
|
+
| 'forestgreen'
|
|
50
|
+
| 'fuchsia'
|
|
51
|
+
| 'gainsboro'
|
|
52
|
+
| 'ghostwhite'
|
|
53
|
+
| 'gold'
|
|
54
|
+
| 'goldenrod'
|
|
55
|
+
| 'gray'
|
|
56
|
+
| 'green'
|
|
57
|
+
| 'greenyellow'
|
|
58
|
+
| 'grey'
|
|
59
|
+
| 'honeydew'
|
|
60
|
+
| 'hotpink'
|
|
61
|
+
| 'indianred'
|
|
62
|
+
| 'indigo'
|
|
63
|
+
| 'ivory'
|
|
64
|
+
| 'khaki'
|
|
65
|
+
| 'lavender'
|
|
66
|
+
| 'lavenderblush'
|
|
67
|
+
| 'lawngreen'
|
|
68
|
+
| 'lemonchiffon'
|
|
69
|
+
| 'lightblue'
|
|
70
|
+
| 'lightcoral'
|
|
71
|
+
| 'lightcyan'
|
|
72
|
+
| 'lightgoldenrodyellow'
|
|
73
|
+
| 'lightgray'
|
|
74
|
+
| 'lightgreen'
|
|
75
|
+
| 'lightgrey'
|
|
76
|
+
| 'lightpink'
|
|
77
|
+
| 'lightsalmon'
|
|
78
|
+
| 'lightseagreen'
|
|
79
|
+
| 'lightskyblue'
|
|
80
|
+
| 'lightslategray'
|
|
81
|
+
| 'lightslategrey'
|
|
82
|
+
| 'lightsteelblue'
|
|
83
|
+
| 'lightyellow'
|
|
84
|
+
| 'lime'
|
|
85
|
+
| 'limegreen'
|
|
86
|
+
| 'linen'
|
|
87
|
+
| 'magenta'
|
|
88
|
+
| 'maroon'
|
|
89
|
+
| 'mediumaquamarine'
|
|
90
|
+
| 'mediumblue'
|
|
91
|
+
| 'mediumorchid'
|
|
92
|
+
| 'mediumpurple'
|
|
93
|
+
| 'mediumseagreen'
|
|
94
|
+
| 'mediumslateblue'
|
|
95
|
+
| 'mediumspringgreen'
|
|
96
|
+
| 'mediumturquoise'
|
|
97
|
+
| 'mediumvioletred'
|
|
98
|
+
| 'midnightblue'
|
|
99
|
+
| 'mintcream'
|
|
100
|
+
| 'mistyrose'
|
|
101
|
+
| 'moccasin'
|
|
102
|
+
| 'navajowhite'
|
|
103
|
+
| 'navy'
|
|
104
|
+
| 'oldlace'
|
|
105
|
+
| 'olive'
|
|
106
|
+
| 'olivedrab'
|
|
107
|
+
| 'orange'
|
|
108
|
+
| 'orangered'
|
|
109
|
+
| 'orchid'
|
|
110
|
+
| 'palegoldenrod'
|
|
111
|
+
| 'palegreen'
|
|
112
|
+
| 'paleturquoise'
|
|
113
|
+
| 'palevioletred'
|
|
114
|
+
| 'papayawhip'
|
|
115
|
+
| 'peachpuff'
|
|
116
|
+
| 'peru'
|
|
117
|
+
| 'pink'
|
|
118
|
+
| 'plum'
|
|
119
|
+
| 'powderblue'
|
|
120
|
+
| 'purple'
|
|
121
|
+
| 'rebeccapurple'
|
|
122
|
+
| 'red'
|
|
123
|
+
| 'rosybrown'
|
|
124
|
+
| 'royalblue'
|
|
125
|
+
| 'saddlebrown'
|
|
126
|
+
| 'salmon'
|
|
127
|
+
| 'sandybrown'
|
|
128
|
+
| 'seagreen'
|
|
129
|
+
| 'seashell'
|
|
130
|
+
| 'sienna'
|
|
131
|
+
| 'silver'
|
|
132
|
+
| 'skyblue'
|
|
133
|
+
| 'slateblue'
|
|
134
|
+
| 'slategray'
|
|
135
|
+
| 'slategrey'
|
|
136
|
+
| 'snow'
|
|
137
|
+
| 'springgreen'
|
|
138
|
+
| 'steelblue'
|
|
139
|
+
| 'tan'
|
|
140
|
+
| 'teal'
|
|
141
|
+
| 'thistle'
|
|
142
|
+
| 'tomato'
|
|
143
|
+
| 'turquoise'
|
|
144
|
+
| 'violet'
|
|
145
|
+
| 'wheat'
|
|
146
|
+
| 'white'
|
|
147
|
+
| 'whitesmoke'
|
|
148
|
+
| 'yellow'
|
|
149
|
+
| 'yellowgreen';
|
|
150
|
+
|
|
151
|
+
declare namespace AnsiStylesTypes {
|
|
152
|
+
interface ColorConvert {
|
|
153
|
+
/**
|
|
154
|
+
The RGB color space.
|
|
155
|
+
|
|
156
|
+
@param red - (`0`-`255`)
|
|
157
|
+
@param green - (`0`-`255`)
|
|
158
|
+
@param blue - (`0`-`255`)
|
|
159
|
+
*/
|
|
160
|
+
rgb(red: number, green: number, blue: number): string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
The RGB HEX color space.
|
|
164
|
+
|
|
165
|
+
@param hex - A hexadecimal string containing RGB data.
|
|
166
|
+
*/
|
|
167
|
+
hex(hex: string): string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
@param keyword - A CSS color name.
|
|
171
|
+
*/
|
|
172
|
+
keyword(keyword: CSSColor): string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
The HSL color space.
|
|
176
|
+
|
|
177
|
+
@param hue - (`0`-`360`)
|
|
178
|
+
@param saturation - (`0`-`100`)
|
|
179
|
+
@param lightness - (`0`-`100`)
|
|
180
|
+
*/
|
|
181
|
+
hsl(hue: number, saturation: number, lightness: number): string;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
The HSV color space.
|
|
185
|
+
|
|
186
|
+
@param hue - (`0`-`360`)
|
|
187
|
+
@param saturation - (`0`-`100`)
|
|
188
|
+
@param value - (`0`-`100`)
|
|
189
|
+
*/
|
|
190
|
+
hsv(hue: number, saturation: number, value: number): string;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
The HSV color space.
|
|
194
|
+
|
|
195
|
+
@param hue - (`0`-`360`)
|
|
196
|
+
@param whiteness - (`0`-`100`)
|
|
197
|
+
@param blackness - (`0`-`100`)
|
|
198
|
+
*/
|
|
199
|
+
hwb(hue: number, whiteness: number, blackness: number): string;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
|
|
203
|
+
*/
|
|
204
|
+
ansi(ansi: number): string;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
|
208
|
+
*/
|
|
209
|
+
ansi256(ansi: number): string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface CSPair {
|
|
213
|
+
/**
|
|
214
|
+
The ANSI terminal control sequence for starting this style.
|
|
215
|
+
*/
|
|
216
|
+
readonly open: string;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
The ANSI terminal control sequence for ending this style.
|
|
220
|
+
*/
|
|
221
|
+
readonly close: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface ColorBase {
|
|
225
|
+
readonly ansi: ColorConvert;
|
|
226
|
+
readonly ansi256: ColorConvert;
|
|
227
|
+
readonly ansi16m: ColorConvert;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
The ANSI terminal control sequence for ending this color.
|
|
231
|
+
*/
|
|
232
|
+
readonly close: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
interface Modifier {
|
|
236
|
+
/**
|
|
237
|
+
Resets the current color chain.
|
|
238
|
+
*/
|
|
239
|
+
readonly reset: CSPair;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
Make text bold.
|
|
243
|
+
*/
|
|
244
|
+
readonly bold: CSPair;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
Emitting only a small amount of light.
|
|
248
|
+
*/
|
|
249
|
+
readonly dim: CSPair;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
Make text italic. (Not widely supported)
|
|
253
|
+
*/
|
|
254
|
+
readonly italic: CSPair;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
Make text underline. (Not widely supported)
|
|
258
|
+
*/
|
|
259
|
+
readonly underline: CSPair;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
Inverse background and foreground colors.
|
|
263
|
+
*/
|
|
264
|
+
readonly inverse: CSPair;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
Prints the text, but makes it invisible.
|
|
268
|
+
*/
|
|
269
|
+
readonly hidden: CSPair;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
Puts a horizontal line through the center of the text. (Not widely supported)
|
|
273
|
+
*/
|
|
274
|
+
readonly strikethrough: CSPair;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
interface ForegroundColor {
|
|
278
|
+
readonly black: CSPair;
|
|
279
|
+
readonly red: CSPair;
|
|
280
|
+
readonly green: CSPair;
|
|
281
|
+
readonly yellow: CSPair;
|
|
282
|
+
readonly blue: CSPair;
|
|
283
|
+
readonly cyan: CSPair;
|
|
284
|
+
readonly magenta: CSPair;
|
|
285
|
+
readonly white: CSPair;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
Alias for `blackBright`.
|
|
289
|
+
*/
|
|
290
|
+
readonly gray: CSPair;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
Alias for `blackBright`.
|
|
294
|
+
*/
|
|
295
|
+
readonly grey: CSPair;
|
|
296
|
+
|
|
297
|
+
readonly blackBright: CSPair;
|
|
298
|
+
readonly redBright: CSPair;
|
|
299
|
+
readonly greenBright: CSPair;
|
|
300
|
+
readonly yellowBright: CSPair;
|
|
301
|
+
readonly blueBright: CSPair;
|
|
302
|
+
readonly cyanBright: CSPair;
|
|
303
|
+
readonly magentaBright: CSPair;
|
|
304
|
+
readonly whiteBright: CSPair;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
interface BackgroundColor {
|
|
308
|
+
readonly bgBlack: CSPair;
|
|
309
|
+
readonly bgRed: CSPair;
|
|
310
|
+
readonly bgGreen: CSPair;
|
|
311
|
+
readonly bgYellow: CSPair;
|
|
312
|
+
readonly bgBlue: CSPair;
|
|
313
|
+
readonly bgCyan: CSPair;
|
|
314
|
+
readonly bgMagenta: CSPair;
|
|
315
|
+
readonly bgWhite: CSPair;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
Alias for `bgBlackBright`.
|
|
319
|
+
*/
|
|
320
|
+
readonly bgGray: CSPair;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
Alias for `bgBlackBright`.
|
|
324
|
+
*/
|
|
325
|
+
readonly bgGrey: CSPair;
|
|
326
|
+
|
|
327
|
+
readonly bgBlackBright: CSPair;
|
|
328
|
+
readonly bgRedBright: CSPair;
|
|
329
|
+
readonly bgGreenBright: CSPair;
|
|
330
|
+
readonly bgYellowBright: CSPair;
|
|
331
|
+
readonly bgBlueBright: CSPair;
|
|
332
|
+
readonly bgCyanBright: CSPair;
|
|
333
|
+
readonly bgMagentaBright: CSPair;
|
|
334
|
+
readonly bgWhiteBright: CSPair;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare const ansiStyles: {
|
|
339
|
+
readonly modifier: AnsiStylesTypes.Modifier;
|
|
340
|
+
readonly color: AnsiStylesTypes.ForegroundColor & AnsiStylesTypes.ColorBase;
|
|
341
|
+
readonly bgColor: AnsiStylesTypes.BackgroundColor & AnsiStylesTypes.ColorBase;
|
|
342
|
+
readonly codes: ReadonlyMap<number, number>;
|
|
343
|
+
} & AnsiStylesTypes.BackgroundColor & AnsiStylesTypes.ForegroundColor & AnsiStylesTypes.Modifier;
|
|
344
|
+
|
|
345
|
+
export = ansiStyles;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// https://github.com/chalk/ansi-styles/blob/main/index.js
|
|
5
|
+
// fix for https://github.com/DavidWells/markdown-magic/pull/111
|
|
6
|
+
|
|
7
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
8
|
+
const code = fn(...args);
|
|
9
|
+
return `\u001B[${code + offset}m`;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
13
|
+
const code = fn(...args);
|
|
14
|
+
return `\u001B[${38 + offset};5;${code}m`;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
18
|
+
const rgb = fn(...args);
|
|
19
|
+
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const ansi2ansi = n => n;
|
|
23
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
24
|
+
|
|
25
|
+
const setLazyProperty = (object, property, get) => {
|
|
26
|
+
Object.defineProperty(object, property, {
|
|
27
|
+
get: () => {
|
|
28
|
+
const value = get();
|
|
29
|
+
|
|
30
|
+
Object.defineProperty(object, property, {
|
|
31
|
+
value,
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return value;
|
|
37
|
+
},
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** @type {typeof import('color-convert')} */
|
|
44
|
+
let colorConvert;
|
|
45
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
46
|
+
if (colorConvert === undefined) {
|
|
47
|
+
colorConvert = require('color-convert');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const offset = isBackground ? 10 : 0;
|
|
51
|
+
const styles = {};
|
|
52
|
+
|
|
53
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
|
54
|
+
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
|
55
|
+
if (sourceSpace === targetSpace) {
|
|
56
|
+
styles[name] = wrap(identity, offset);
|
|
57
|
+
} else if (typeof suite === 'object') {
|
|
58
|
+
styles[name] = wrap(suite[targetSpace], offset);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return styles;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
function assembleStyles() {
|
|
66
|
+
const codes = new Map();
|
|
67
|
+
const styles = {
|
|
68
|
+
modifier: {
|
|
69
|
+
reset: [0, 0],
|
|
70
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
71
|
+
bold: [1, 22],
|
|
72
|
+
dim: [2, 22],
|
|
73
|
+
italic: [3, 23],
|
|
74
|
+
underline: [4, 24],
|
|
75
|
+
inverse: [7, 27],
|
|
76
|
+
hidden: [8, 28],
|
|
77
|
+
strikethrough: [9, 29]
|
|
78
|
+
},
|
|
79
|
+
color: {
|
|
80
|
+
black: [30, 39],
|
|
81
|
+
red: [31, 39],
|
|
82
|
+
green: [32, 39],
|
|
83
|
+
yellow: [33, 39],
|
|
84
|
+
blue: [34, 39],
|
|
85
|
+
magenta: [35, 39],
|
|
86
|
+
cyan: [36, 39],
|
|
87
|
+
white: [37, 39],
|
|
88
|
+
|
|
89
|
+
// Bright color
|
|
90
|
+
blackBright: [90, 39],
|
|
91
|
+
redBright: [91, 39],
|
|
92
|
+
greenBright: [92, 39],
|
|
93
|
+
yellowBright: [93, 39],
|
|
94
|
+
blueBright: [94, 39],
|
|
95
|
+
magentaBright: [95, 39],
|
|
96
|
+
cyanBright: [96, 39],
|
|
97
|
+
whiteBright: [97, 39]
|
|
98
|
+
},
|
|
99
|
+
bgColor: {
|
|
100
|
+
bgBlack: [40, 49],
|
|
101
|
+
bgRed: [41, 49],
|
|
102
|
+
bgGreen: [42, 49],
|
|
103
|
+
bgYellow: [43, 49],
|
|
104
|
+
bgBlue: [44, 49],
|
|
105
|
+
bgMagenta: [45, 49],
|
|
106
|
+
bgCyan: [46, 49],
|
|
107
|
+
bgWhite: [47, 49],
|
|
108
|
+
|
|
109
|
+
// Bright color
|
|
110
|
+
bgBlackBright: [100, 49],
|
|
111
|
+
bgRedBright: [101, 49],
|
|
112
|
+
bgGreenBright: [102, 49],
|
|
113
|
+
bgYellowBright: [103, 49],
|
|
114
|
+
bgBlueBright: [104, 49],
|
|
115
|
+
bgMagentaBright: [105, 49],
|
|
116
|
+
bgCyanBright: [106, 49],
|
|
117
|
+
bgWhiteBright: [107, 49]
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Alias bright black as gray (and grey)
|
|
122
|
+
styles.color.gray = styles.color.blackBright;
|
|
123
|
+
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
124
|
+
styles.color.grey = styles.color.blackBright;
|
|
125
|
+
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
126
|
+
|
|
127
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
128
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
129
|
+
styles[styleName] = {
|
|
130
|
+
open: `\u001B[${style[0]}m`,
|
|
131
|
+
close: `\u001B[${style[1]}m`
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
group[styleName] = styles[styleName];
|
|
135
|
+
|
|
136
|
+
codes.set(style[0], style[1]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
Object.defineProperty(styles, groupName, {
|
|
140
|
+
value: group,
|
|
141
|
+
enumerable: false
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Object.defineProperty(styles, 'codes', {
|
|
146
|
+
value: codes,
|
|
147
|
+
enumerable: false
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
styles.color.close = '\u001B[39m';
|
|
151
|
+
styles.bgColor.close = '\u001B[49m';
|
|
152
|
+
|
|
153
|
+
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
|
154
|
+
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
|
155
|
+
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
|
156
|
+
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
|
157
|
+
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
|
158
|
+
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
|
159
|
+
|
|
160
|
+
return styles;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Make the export immutable
|
|
164
|
+
Object.defineProperty(module, 'exports', {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: assembleStyles
|
|
167
|
+
});
|
package/src/utils/fs.test.js
CHANGED
package/src/utils/logs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const util = require('util')
|
|
2
|
-
const ansi = require('ansi-styles') // https://github.com/chalk/ansi-styles/blob/main/index.js
|
|
2
|
+
const ansi = require('./ansi-styles') // https://github.com/chalk/ansi-styles/blob/main/index.js
|
|
3
3
|
const process = require('process')
|
|
4
4
|
|
|
5
5
|
function convertHrtime(hrtime) {
|
|
@@ -91,7 +91,7 @@ const error = log.bind(null, 'error')
|
|
|
91
91
|
/*
|
|
92
92
|
// Usage:
|
|
93
93
|
console.log('Nice logs')
|
|
94
|
-
deepLog({ deep: {object }})
|
|
94
|
+
deepLog({ deep: { object: 'test' }})
|
|
95
95
|
success('Success! Yay it worked')
|
|
96
96
|
info('Info: Additional details here')
|
|
97
97
|
warning('Warning: Watch out')
|
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
const fetch = require('node-fetch')
|
|
2
|
-
const request = require('sync-request')
|
|
3
2
|
|
|
4
3
|
function formatUrl(url = '') {
|
|
5
4
|
return url.match(/^https?:\/\//) ? url : `https://${url}`
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
function remoteRequestSync(url, settings = {}, srcPath) {
|
|
9
|
-
let body
|
|
10
|
-
const finalUrl = formatUrl(url)
|
|
11
|
-
try {
|
|
12
|
-
// @ts-expect-error
|
|
13
|
-
const res = request('GET', finalUrl)
|
|
14
|
-
body = res.getBody('utf8')
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.log(`⚠️ WARNING: REMOTE URL "${finalUrl}" NOT FOUND`)
|
|
17
|
-
const msg = (e.message || '').split('\n')[0] + `\nFix "${url}" value in ${srcPath}`
|
|
18
|
-
console.log(msg)
|
|
19
|
-
if (settings.failOnMissingRemote) {
|
|
20
|
-
throw new Error(msg)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return body
|
|
24
|
-
}
|
|
25
|
-
|
|
26
7
|
async function remoteRequest(url, settings = {}, srcPath) {
|
|
27
8
|
let body
|
|
28
9
|
const finalUrl = formatUrl(url)
|
|
@@ -45,7 +26,6 @@ async function remoteRequest(url, settings = {}, srcPath) {
|
|
|
45
26
|
}
|
|
46
27
|
|
|
47
28
|
module.exports = {
|
|
48
|
-
remoteRequestSync,
|
|
49
29
|
remoteRequest
|
|
50
30
|
}
|
|
51
31
|
|
package/types/src/defaults.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.js"],"names":[],"mappings":"AACA,qBAAe,IAAI,CAAA;AACnB,wBAAkB,
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.js"],"names":[],"mappings":"AACA,qBAAe,IAAI,CAAA;AACnB,wBAAkB,MAAM,CAAA;AACxB,yBAAmB,OAAO,CAAA;AAC1B,mCAA6B,UAAU,CAAA"}
|
package/types/src/index.d.ts
CHANGED
|
@@ -22,19 +22,19 @@ export type MarkdownMagicOptions = {
|
|
|
22
22
|
*/
|
|
23
23
|
transforms?: any;
|
|
24
24
|
/**
|
|
25
|
-
* - Output configuration
|
|
25
|
+
* - Output configuration object or directory path
|
|
26
26
|
*/
|
|
27
|
-
output?: OutputConfig;
|
|
27
|
+
output?: OutputConfig | string;
|
|
28
28
|
/**
|
|
29
29
|
* - Syntax to parse
|
|
30
30
|
*/
|
|
31
31
|
syntax?: SyntaxType;
|
|
32
32
|
/**
|
|
33
|
-
* - Opening match word
|
|
33
|
+
* - Opening match word. Default is 'docs'.
|
|
34
34
|
*/
|
|
35
35
|
open?: string;
|
|
36
36
|
/**
|
|
37
|
-
* - Closing match word. If not defined will be same as opening word.
|
|
37
|
+
* - Closing match word. Default is '/docs'. If not defined will be same as opening word with closing slash added.
|
|
38
38
|
*/
|
|
39
39
|
close?: string;
|
|
40
40
|
/**
|
|
@@ -52,7 +52,7 @@ export type MarkdownMagicOptions = {
|
|
|
52
52
|
/**
|
|
53
53
|
* - See planned execution of matched blocks
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
dry?: boolean;
|
|
56
56
|
/**
|
|
57
57
|
* - See debug details
|
|
58
58
|
*/
|
|
@@ -73,6 +73,10 @@ export type MarkdownMagicOptions = {
|
|
|
73
73
|
* - Fail if remote file is missing.
|
|
74
74
|
*/
|
|
75
75
|
failOnMissingRemote?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* - Deprecated: Use `output` instead. Output directory path.
|
|
78
|
+
*/
|
|
79
|
+
outputDir?: string;
|
|
76
80
|
};
|
|
77
81
|
/**
|
|
78
82
|
* Optional output configuration
|
|
@@ -131,19 +135,20 @@ export type MarkdownMagicResult = {
|
|
|
131
135
|
* @typedef {object} MarkdownMagicOptions
|
|
132
136
|
* @property {FilePathsOrGlobs} [files] - Files to process.
|
|
133
137
|
* @property {Object} [transforms = defaultTransforms] - Custom commands to transform block contents, see transforms & custom transforms sections below.
|
|
134
|
-
* @property {OutputConfig} [output] - Output configuration
|
|
138
|
+
* @property {OutputConfig|string} [output] - Output configuration object or directory path
|
|
135
139
|
* @property {SyntaxType} [syntax = 'md'] - Syntax to parse
|
|
136
|
-
* @property {string}
|
|
137
|
-
* @property {string}
|
|
138
|
-
* @property {string}
|
|
140
|
+
* @property {string} [open = 'docs'] - Opening match word. Default is 'docs'.
|
|
141
|
+
* @property {string} [close = '/docs'] - Closing match word. Default is '/docs'. If not defined will be same as opening word with closing slash added.
|
|
142
|
+
* @property {string} [cwd = process.cwd() ] - Current working directory. Default process.cwd()
|
|
139
143
|
* @property {boolean} [outputFlatten] - Flatten files that are output
|
|
140
144
|
* @property {boolean} [useGitGlob] - Use git glob for LARGE file directories
|
|
141
|
-
* @property {boolean} [
|
|
145
|
+
* @property {boolean} [dry = false] - See planned execution of matched blocks
|
|
142
146
|
* @property {boolean} [debug = false] - See debug details
|
|
143
147
|
* @property {boolean} [silent = false] - Silence all console output
|
|
144
148
|
* @property {boolean} [applyTransformsToSource = true] - Apply transforms to source file. Default is true.
|
|
145
149
|
* @property {boolean} [failOnMissingTransforms = false] - Fail if transform functions are missing. Default skip blocks.
|
|
146
150
|
* @property {boolean} [failOnMissingRemote = true] - Fail if remote file is missing.
|
|
151
|
+
* @property {string} [outputDir] - Deprecated: Use `output` instead. Output directory path.
|
|
147
152
|
*/
|
|
148
153
|
/**
|
|
149
154
|
* Optional output configuration
|
package/types/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";;;yBAkDa,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM;;;;+BAK5B,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC;iCAIpB,OAAO,wBAAwB,EAAE,kBAAkB;;;;;;;;;;YASlD,gBAAgB;;;;;;;;aAEhB,YAAY;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";;;yBAkDa,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM;;;;+BAK5B,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC;iCAIpB,OAAO,wBAAwB,EAAE,kBAAkB;;;;;;;;;;YASlD,gBAAgB;;;;;;;;aAEhB,YAAY,GAAC,MAAM;;;;aACnB,UAAU;;;;WACV,MAAM;;;;YACN,MAAM;;;;UACN,MAAM;;;;oBACN,OAAO;;;;iBACP,OAAO;;;;UACP,OAAO;;;;YACP,OAAO;;;;aACP,OAAO;;;;8BACP,OAAO;;;;8BACP,OAAO;;;;0BACP,OAAO;;;;gBACP,MAAM;;;;;;;;;gBAMN,MAAM;;;;qBACN,OAAO;;;;;;;;8BAEP,OAAO;;;;;;;;;;;;;kBAQP,KAAK,CAAC,MAAM,CAAC;;;;;;AApD3B;;;GAGG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;GAOG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,2CARW,gBAAgB,GAAC,oBAAoB,YACrC,oBAAoB,GAClB,OAAO,CAAC,mBAAmB,CAAC,CA6lBxC"}
|
|
@@ -9,12 +9,12 @@ export = install;
|
|
|
9
9
|
*
|
|
10
10
|
* **Example:**
|
|
11
11
|
* ```md
|
|
12
|
-
* <!--
|
|
12
|
+
* <!-- docs INSTALL packageName=my-package -->
|
|
13
13
|
* Installation instructions will be generated here
|
|
14
|
-
* <!--
|
|
14
|
+
* <!-- /docs -->
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Default `matchWord` is `
|
|
17
|
+
* Default `matchWord` is `docs`
|
|
18
18
|
*
|
|
19
19
|
* ---
|
|
20
20
|
* @param {string} content The current content of the comment block
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/utils/text.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/utils/text.js"],"names":[],"mappings":"AA8ZA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAmBlB;AAlbD;;;;GAIG;AACH,+BAHW,MAAM,GACJ,MAAM,EAAE,CAIpB;AAED;;;;GAIG;AACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;AAgBD;;;;GAIG;AACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;AAoBD;;;;GAIG;AACH,uCAHW,MAAM,GACJ,MAAM,CAKlB;AA1BD;;;;GAIG;AACH,uCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,sCAHW,MAAM,GACJ,MAAM,CAIlB;AAvCD;;;;;GAKG;AACH,kDAJW,MAAM,eACN,MAAM,GACJ;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,CAQtC;AAuCD;;;;;;GAMG;AACH,0CALW,MAAM,SACN,MAAM,OACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,uCALW,MAAM,UACN,MAAM,UACN,MAAM,GACJ,MAAM,CAYlB;AAcD;;;;;;;GAOG;AACH,6CALW,MAAM,aACN,MAAM,WACN,MAAM,GACJ,MAAM,GAAC,SAAS,CAe5B;AAjCD;;;;;;;GAOG;AACH,6CANW,MAAM,SACN,MAAM,OACN,MAAM,UACN,MAAM,GACJ,MAAM,CAIlB;AA8CD;;;;;GAKG;AACH,oCAJW,MAAM,gBACN,MAAM,GACJ,MAAM,CASlB;AAaD;;;;;;;;GAQG;AACH,qCAPW,MAAM,UACN,MAAM,YAEd;IAAyB,MAAM,GAAvB,MAAM;IACY,iBAAiB,GAAnC,OAAO;CACf,GAAU,MAAM,CAclB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,GACJ,MAAM,CAOlB;AAuCD;;;;;GAKG;AACH,mCAJW,MAAM,WACN,OAAO,UAAU,EAAE,UAAU,GAC3B,MAAM,CAmBlB;AA4DD;;;QAmCC;AAvFD,yEAEC;AAND,wEAEC;AAeD,8DAqCC;AArKD;;;;GAIG;AACF,iCAHU,MAAM,GAAC,MAAM,GACX,MAAM,CAMlB;AAnCD;;;;GAIG;AACH,sCAHW,MAAM,GACJ,MAAM,CAMlB;AAnBD;;;;GAIG;AACH,iCAHW,MAAM,GACJ,OAAO,CAInB"}
|