@cocreate/cli 1.48.0 → 1.50.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/.github/workflows/automated.yml +0 -1
- package/CHANGELOG.md +40 -0
- package/CoCreate.config.js +499 -420
- package/docs/index.html +250 -250
- package/package.json +5 -7
- package/prettier.config.js +18 -0
- package/src/addMeta.js +74 -67
- package/src/coc.js +129 -114
- package/src/commands/acme.js +19 -22
- package/src/commands/bump.js +149 -87
- package/src/commands/clone.js +26 -22
- package/src/commands/fs/automated.js +81 -31
- package/src/commands/fs/config.js +94 -38
- package/src/commands/fs/gitignore.js +13 -22
- package/src/commands/fs/manual.js +17 -27
- package/src/commands/fs/prettier.config.js +99 -0
- package/src/commands/fs/remove.js +7 -12
- package/src/commands/fs/replace.js +23 -31
- package/src/commands/fs/webpack.js +143 -149
- package/src/commands/install.js +18 -22
- package/src/commands/link.js +73 -60
- package/src/commands/nginx.js +19 -22
- package/src/commands/symlink.js +132 -115
- package/src/execute.js +63 -50
- package/src/index.js +3 -0
- package/src/spinner.js +85 -0
package/src/spinner.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Define an object holding various spinner patterns, each pattern is an array of strings representing different frames
|
|
2
|
+
const spinnerPatterns = {
|
|
3
|
+
// Dots pattern: sequential increase in dots
|
|
4
|
+
dots: [". ", ".. ", "..."],
|
|
5
|
+
|
|
6
|
+
// Bar filling up incrementally
|
|
7
|
+
bar: ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"],
|
|
8
|
+
|
|
9
|
+
// A bouncing ball effect using Braille characters
|
|
10
|
+
bouncingBall: ["⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"],
|
|
11
|
+
|
|
12
|
+
// Wave pattern: characters form a wave-like effect
|
|
13
|
+
wave: ["⎺", "⎻", "⎼", "⎽", "⎼", "⎻"],
|
|
14
|
+
|
|
15
|
+
// Rotating arrows pattern for direction indication
|
|
16
|
+
arrows: ["←", "↖", "↑", "↗", "→", "↘", "↓", "↙"],
|
|
17
|
+
|
|
18
|
+
// Rotating dots pattern with increasing and decreasing length
|
|
19
|
+
rotatingDots: [
|
|
20
|
+
". ",
|
|
21
|
+
".. ",
|
|
22
|
+
"... ",
|
|
23
|
+
".... ",
|
|
24
|
+
".....",
|
|
25
|
+
" ....",
|
|
26
|
+
" ...",
|
|
27
|
+
" ..",
|
|
28
|
+
" ."
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
// Horizontal bounce pattern to simulate a bouncing ball effect
|
|
32
|
+
horizontalBounce: [
|
|
33
|
+
"[ ]",
|
|
34
|
+
"[= ]",
|
|
35
|
+
"[== ]",
|
|
36
|
+
"[=== ]",
|
|
37
|
+
"[ ===]",
|
|
38
|
+
"[ ==]",
|
|
39
|
+
"[ =]"
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// spinner.js
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a spinner with the specified configuration
|
|
47
|
+
* @param {Object} options - Configuration options for the spinner
|
|
48
|
+
* @param {string} options.type - The type of spinner pattern
|
|
49
|
+
* @param {number} options.milliseconds - Interval in milliseconds for frame change
|
|
50
|
+
* @param {string} options.prefix - String to prefix before the spinner frame
|
|
51
|
+
* @param {string} options.suffix - String to suffix after the spinner frame
|
|
52
|
+
* @param {Function} options.onComplete - Callback function to execute when the spinner ends
|
|
53
|
+
* @returns {Object} - An object with an `end` method to stop the spinner
|
|
54
|
+
*/
|
|
55
|
+
function createSpinner({
|
|
56
|
+
type = "dots", // Default type is 'dots'
|
|
57
|
+
milliseconds = 200, // Default interval time is 200 ms
|
|
58
|
+
prefix = "", // Default prefix is an empty string
|
|
59
|
+
suffix = "", // Default suffix is an empty string
|
|
60
|
+
onComplete = () => process.stdout.write("\r") // Default onComplete action is to clear the line
|
|
61
|
+
}) {
|
|
62
|
+
// Get the frames for the specified spinner type, fall back to 'dots' pattern if type not found
|
|
63
|
+
const frames = spinnerPatterns[type] || spinnerPatterns.dots;
|
|
64
|
+
let spinnerIndex = 0; // Track current frame index
|
|
65
|
+
|
|
66
|
+
// Set an interval to update the spinner frame
|
|
67
|
+
const interval = setInterval(() => {
|
|
68
|
+
// Write spinner frame to the process standard output along with prefix and suffix
|
|
69
|
+
process.stdout.write(`\r${prefix}${frames[spinnerIndex]}${suffix}`);
|
|
70
|
+
// Update frame index, reset to 0 if it exceeds available frames
|
|
71
|
+
spinnerIndex = (spinnerIndex + 1) % frames.length;
|
|
72
|
+
}, milliseconds);
|
|
73
|
+
|
|
74
|
+
// Return an interface to interact with spinner
|
|
75
|
+
return {
|
|
76
|
+
// Method to stop the spinner and execute the onComplete callback
|
|
77
|
+
end: () => {
|
|
78
|
+
clearInterval(interval); // Clear the frame update interval
|
|
79
|
+
onComplete(); // Execute onComplete callback (default clears the current line)
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Export createSpinner function as a module
|
|
85
|
+
module.exports = createSpinner;
|