bajo 2.18.0 → 2.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.
Files changed (74) hide show
  1. package/.github/workflows/test.yml +37 -0
  2. package/class/_helper.js +23 -7
  3. package/class/app.js +64 -47
  4. package/class/bajo.js +182 -138
  5. package/class/base.js +3 -3
  6. package/class/cache.js +60 -0
  7. package/class/err.js +14 -11
  8. package/class/log.js +41 -40
  9. package/class/plugin.js +35 -36
  10. package/class/print.js +54 -51
  11. package/class/tools.js +3 -4
  12. package/docs/App.html +7 -7
  13. package/docs/Bajo.html +2 -2
  14. package/docs/Base.html +1 -1
  15. package/docs/Cache.html +3 -0
  16. package/docs/Err.html +2 -2
  17. package/docs/Log.html +2 -2
  18. package/docs/Plugin.html +1 -1
  19. package/docs/Print.html +1 -1
  20. package/docs/Tools.html +3 -0
  21. package/docs/class__helper.js.html +694 -0
  22. package/docs/class_app.js.html +307 -149
  23. package/docs/class_bajo.js.html +316 -464
  24. package/docs/class_base.js.html +35 -32
  25. package/docs/class_cache.js.html +150 -0
  26. package/docs/class_err.js.html +144 -0
  27. package/docs/class_log.js.html +270 -0
  28. package/docs/class_plugin.js.html +98 -71
  29. package/docs/class_print.js.html +261 -0
  30. package/docs/class_tools.js.html +44 -0
  31. package/docs/data/search.json +1 -1
  32. package/docs/global.html +1 -4
  33. package/docs/index.html +1 -1
  34. package/docs/index.js.html +21 -14
  35. package/docs/lib_find-deep.js.html +27 -0
  36. package/docs/lib_formats.js.html +19 -19
  37. package/docs/lib_freeze.js.html +19 -0
  38. package/docs/lib_import-module.js.html +16 -14
  39. package/docs/lib_index.js.html +9 -0
  40. package/docs/lib_log-levels.js.html +2 -2
  41. package/docs/module-Helper.html +3 -0
  42. package/docs/module-Lib.html +3 -8
  43. package/docs/scripts/core.js +477 -476
  44. package/docs/scripts/resize.js +36 -36
  45. package/docs/scripts/search.js +105 -105
  46. package/docs/scripts/third-party/fuse.js +1 -1
  47. package/docs/scripts/third-party/hljs-line-num-original.js +285 -282
  48. package/docs/scripts/third-party/hljs-line-num.js +1 -1
  49. package/docs/scripts/third-party/hljs-original.js +1202 -1195
  50. package/docs/scripts/third-party/hljs.js +1 -1
  51. package/docs/scripts/third-party/popper.js +1 -1
  52. package/docs/scripts/third-party/tippy.js +1 -1
  53. package/docs/scripts/third-party/tocbot.js +509 -508
  54. package/index.js +8 -11
  55. package/lib/find-deep.js +3 -3
  56. package/lib/formats.js +17 -17
  57. package/lib/freeze.js +3 -3
  58. package/lib/import-module.js +8 -8
  59. package/package.json +3 -2
  60. package/test/app.test.js +183 -0
  61. package/test/bajo.test.js +125 -0
  62. package/test/base.test.js +74 -107
  63. package/test/cache.test.js +94 -0
  64. package/test/e2e.test.js +137 -0
  65. package/test/err.test.js +73 -0
  66. package/test/helper.test.js +39 -0
  67. package/test/import-module.test.js +138 -0
  68. package/test/integration.test.js +218 -0
  69. package/test/log.test.js +119 -0
  70. package/test/plugin.test.js +116 -0
  71. package/test/print.test.js +100 -0
  72. package/test/tools.test.js +38 -0
  73. package/wiki/CHANGES.md +12 -0
  74. package/.mocharc.json +0 -4
package/class/print.js CHANGED
@@ -8,10 +8,10 @@ const { isPlainObject } = lodash
8
8
 
9
9
  /**
10
10
  * @typedef TPrintOptions
11
- * @property {boolean} [showDatetime=false] - Show actual date & time
12
- * @property {boolean} [showCounter=false] - Show as counter
13
- * @property {boolean} [silent] - Suppress any messages. Defaults to the one set in {@tutorial config}
14
- * @property {Object} [ora] - {@link https://github.com/sindresorhus/ora#api|Ora's options} object
11
+ * @property {boolean} [showDatetime=false] Show actual date & time.
12
+ * @property {boolean} [showCounter=false] Show as counter.
13
+ * @property {boolean} [silent] Suppress any messages. Defaults to the one set in {@tutorial config}.
14
+ * @property {Object} [ora] {@link https://github.com/sindresorhus/ora#api|Ora's options} object.
15
15
  * @see {@link Print}
16
16
  */
17
17
 
@@ -25,14 +25,15 @@ const { isPlainObject } = lodash
25
25
  */
26
26
  class Print extends Tools {
27
27
  /**
28
- * @param {Plugin} plugin - Plugin instance
29
- * @param {TPrintOptions} [options={}] - Options object
28
+ * @param {Plugin} plugin Plugin instance.
29
+ * @param {TPrintOptions} [options={}] Options object.
30
30
  */
31
31
  constructor (plugin, options = {}) {
32
32
  super(plugin)
33
33
 
34
34
  /**
35
- * Options object
35
+ * Options object.
36
+ *
36
37
  * @type {TPrintOptions}
37
38
  */
38
39
  this.options = options
@@ -42,7 +43,8 @@ class Print extends Tools {
42
43
  }
43
44
 
44
45
  /**
45
- * Time when instance is created
46
+ * Time when instance is created.
47
+ *
46
48
  * @type {Object}
47
49
  * @see {@link https://day.js.org|dayjs}  object
48
50
  */
@@ -50,6 +52,7 @@ class Print extends Tools {
50
52
 
51
53
  /**
52
54
  * ora instance
55
+ *
53
56
  * @see {@link https://github.com/sindresorhus/ora|ora}
54
57
  */
55
58
  this.ora = ora(this.options.ora)
@@ -57,10 +60,10 @@ class Print extends Tools {
57
60
  }
58
61
 
59
62
  /**
60
- * Setting spinner options; override the one passed at constructor
63
+ * Setting spinner options; override the one passed at constructor.
61
64
  *
62
65
  * @method
63
- * @param {any[]} [args=[]] - Array of options. If the last argument is an object, it will be used to override ora options
66
+ * @param {any[]} [args=[]] Array of options. If the last argument is an object, it will be used to override ora options.
64
67
  */
65
68
  setOpts = (args = []) => {
66
69
  const { silent } = this.app.bajo.config
@@ -71,10 +74,10 @@ class Print extends Tools {
71
74
  }
72
75
 
73
76
  /**
74
- * Translate, prefixed with counter and/or datetime etc
77
+ * Translate, prefixed with counter and/or datetime etc.
75
78
  *
76
- * @param {string} text - Text to use
77
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options
79
+ * @param {string} text Text to use.
80
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options.
78
81
  * @returns {string}
79
82
  */
80
83
  buildText = (text, ...args) => {
@@ -89,12 +92,12 @@ class Print extends Tools {
89
92
  }
90
93
 
91
94
  /**
92
- * Set spinner's text
95
+ * Set spinner's text,
93
96
  *
94
97
  * @method
95
- * @param {string} text - Text to use
96
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options
97
- * @returns {Print} Return the instance itself, usefull for method chaining
98
+ * @param {string} text Text to use.
99
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options.
100
+ * @returns {Print} Return the instance itself, usefull for method chaining.
98
101
  */
99
102
  setText = (text, ...args) => {
100
103
  text = this.buildText(text, ...args)
@@ -103,10 +106,10 @@ class Print extends Tools {
103
106
  }
104
107
 
105
108
  /**
106
- * Get elapsed time since instance is created
109
+ * Get elapsed time since instance is created.
107
110
  *
108
111
  * @method
109
- * @param {string} [unit=hms] - Unit's time. Put 'hms' (default) to get hour, minute, second format or of any format supported by {@link https://day.js.org/docs/en/display/difference|dayjs}
112
+ * @param {string} [unit=hms] Unit's time. Put 'hms' (default) to get hour, minute, second format or of any format supported by {@link https://day.js.org/docs/en/display/difference|dayjs}.
110
113
  * @returns {string} Elapsed time since start
111
114
  * @see {@link https://day.js.org/docs/en/display/difference|dayjs duration format}
112
115
  */
@@ -117,12 +120,12 @@ class Print extends Tools {
117
120
  }
118
121
 
119
122
  /**
120
- * Start the spinner
123
+ * Start the spinner,
121
124
  *
122
125
  * @method
123
- * @param {string} text - Text to use
124
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options
125
- * @returns {Print} Return the instance itself, usefull for method chaining
126
+ * @param {string} text Text to use.
127
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options.
128
+ * @returns {Print} Return the instance itself, usefull for method chaining.
126
129
  */
127
130
  start = (text, ...args) => {
128
131
  this.setOpts(args)
@@ -132,10 +135,10 @@ class Print extends Tools {
132
135
  }
133
136
 
134
137
  /**
135
- * Stop the spinner
138
+ * Stop the spinner.
136
139
  *
137
140
  * @method
138
- * @returns {Print} Return the instance itself, usefull for method chaining
141
+ * @returns {Print} Return the instance itself, usefull for method chaining.
139
142
  */
140
143
  stop = () => {
141
144
  this.ora.stop()
@@ -143,12 +146,12 @@ class Print extends Tools {
143
146
  }
144
147
 
145
148
  /**
146
- * Print success message, prefixed with a check icon
149
+ * Print success message, prefixed with a check icon.
147
150
  *
148
151
  * @method
149
- * @param {string} text - Text to use
150
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora options
151
- * @returns {Print} Return the instance itself, usefull for method chaining
152
+ * @param {string} text Text to use.
153
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora options.
154
+ * @returns {Print} Return the instance itself, usefull for method chaining.
152
155
  */
153
156
  succeed = (text, ...args) => {
154
157
  this.setText(text, ...args)
@@ -157,12 +160,12 @@ class Print extends Tools {
157
160
  }
158
161
 
159
162
  /**
160
- * Print failed message, prefixed with a cross icon
163
+ * Print failed message, prefixed with a cross icon.
161
164
  *
162
165
  * @method
163
- * @param {string} text - Text to use
164
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora options
165
- * @returns {Print} Return the instance itself, usefull for method chaining
166
+ * @param {string} text Text to use.
167
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora options.
168
+ * @returns {Print} Return the instance itself, usefull for method chaining.
166
169
  */
167
170
  fail = (text, ...args) => {
168
171
  this.setText(text, ...args)
@@ -171,12 +174,12 @@ class Print extends Tools {
171
174
  }
172
175
 
173
176
  /**
174
- * Print warning message, prefixed with a warn icon
177
+ * Print warning message, prefixed with a warn icon.
175
178
  *
176
179
  * @method
177
- * @param {string} text - Text to use
178
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora options
179
- * @returns {Print} Return the instance itself, usefull for method chaining
180
+ * @param {string} text Text to use.
181
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora options.
182
+ * @returns {Print} Return the instance itself, usefull for method chaining.
180
183
  */
181
184
  warn = (text, ...args) => {
182
185
  this.setText(text, ...args)
@@ -185,12 +188,12 @@ class Print extends Tools {
185
188
  }
186
189
 
187
190
  /**
188
- * Print information message, prefixed with an info icon
191
+ * Print information message, prefixed with an info icon.
189
192
  *
190
193
  * @method
191
- * @param {string} text - Text to use
192
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora options
193
- * @returns {Print} Return the instance itself, usefull for method chaining
194
+ * @param {string} text Text to use.
195
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora options.
196
+ * @returns {Print} Return the instance itself, usefull for method chaining.
194
197
  */
195
198
  info = (text, ...args) => {
196
199
  this.setText(text, ...args)
@@ -199,10 +202,10 @@ class Print extends Tools {
199
202
  }
200
203
 
201
204
  /**
202
- * Clear spinner text
205
+ * Clear spinner text.
203
206
  *
204
207
  * @method
205
- * @returns {Print} Return the instance itself, usefull for method chaining
208
+ * @returns {Print} Return the instance itself, usefull for method chaining.
206
209
  */
207
210
  clear = () => {
208
211
  this.ora.clear()
@@ -210,10 +213,10 @@ class Print extends Tools {
210
213
  }
211
214
 
212
215
  /**
213
- * Force render spinner
216
+ * Force render spinner.
214
217
  *
215
218
  * @method
216
- * @returns {Print} Return the instance itself, usefull for method chaining
219
+ * @returns {Print} Return the instance itself, usefull for method chaining.
217
220
  */
218
221
  render = () => {
219
222
  this.ora.render()
@@ -221,11 +224,11 @@ class Print extends Tools {
221
224
  }
222
225
 
223
226
  /**
224
- * Print failed message, prefixed with a cross icon and exit
227
+ * Print failed message, prefixed with a cross icon and exit.
225
228
  *
226
229
  * @method
227
- * @param {string} text - Text to use
228
- * @param {...any} [args] - Any variable to interpolate text. If the last argument is an object, it will be used to override ora options
230
+ * @param {string} text Text to use.
231
+ * @param {...any} [args] Any variable to interpolate text. If the last argument is an object, it will be used to override ora options.
229
232
  */
230
233
  fatal = (text, ...args) => {
231
234
  if (text instanceof Error) {
@@ -239,11 +242,11 @@ class Print extends Tools {
239
242
  }
240
243
 
241
244
  /**
242
- * Create a new print instance
245
+ * Create a new print instance.
243
246
  *
244
247
  * @method
245
- * @param {TPrintOptions} [options] - Options object. If not provided, defaults to the current options
246
- * @returns {Print} Return new print instance
248
+ * @param {TPrintOptions} [options] Options object. If not provided, defaults to the current options.
249
+ * @returns {Print} Return new print instance.
247
250
  */
248
251
  spinner = (options) => {
249
252
  const spin = new Print(this.plugin, options ?? this.options)
package/class/tools.js CHANGED
@@ -1,9 +1,8 @@
1
1
  /**
2
- * Base tools class
2
+ * Tools class.
3
3
  *
4
4
  * @class
5
5
  */
6
-
7
6
  class Tools {
8
7
  constructor (plugin) {
9
8
  /**
@@ -20,7 +19,7 @@ class Tools {
20
19
  }
21
20
 
22
21
  /**
23
- * Force bind methods to self (```this```)
22
+ * Force bind methods to self (```this```).
24
23
  *
25
24
  * @param {string[]} names - Method's names
26
25
  */
@@ -31,7 +30,7 @@ class Tools {
31
30
  }
32
31
 
33
32
  /**
34
- * Dispose internal references
33
+ * Dispose internal references.
35
34
  */
36
35
  dispose = async () => {
37
36
  this.app = null