@vueless/storybook 0.0.71 → 0.0.72
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/index.js +39 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -21,13 +21,17 @@ if (parsedArgs.pnpm) {
|
|
|
21
21
|
await createNpmrc();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function copyStorybookPreset(source, target) {
|
|
24
|
+
function copyStorybookPreset(source, target, { consoles = true } = {}) {
|
|
25
25
|
if (fs.existsSync(target)) {
|
|
26
26
|
const timestamp = new Date().valueOf();
|
|
27
27
|
const renamedTarget = `${target}-backup-${timestamp}`;
|
|
28
28
|
|
|
29
29
|
fs.renameSync(target, renamedTarget);
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
coloredConsole(
|
|
32
|
+
"yellow",
|
|
33
|
+
`Current Storybook preset backed into : '${path.basename(renamedTarget)}' folder. Don't forget to remove it before commit.`,
|
|
34
|
+
);
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
fs.mkdirSync(target, { recursive: true });
|
|
@@ -40,9 +44,16 @@ function copyStorybookPreset(source, target) {
|
|
|
40
44
|
const stat = fs.lstatSync(srcFile);
|
|
41
45
|
|
|
42
46
|
stat.isDirectory()
|
|
43
|
-
? copyStorybookPreset(srcFile, destFile)
|
|
47
|
+
? copyStorybookPreset(srcFile, destFile, { consoles: false })
|
|
44
48
|
: fs.copyFileSync(srcFile, destFile);
|
|
45
49
|
});
|
|
50
|
+
|
|
51
|
+
if (consoles) {
|
|
52
|
+
coloredConsole(
|
|
53
|
+
"green",
|
|
54
|
+
`Storybook preset successfully saved into '${path.basename(target)}' folder.`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
async function addStorybookCommands() {
|
|
@@ -96,3 +107,28 @@ function parseArgs(args) {
|
|
|
96
107
|
|
|
97
108
|
return result;
|
|
98
109
|
}
|
|
110
|
+
|
|
111
|
+
function coloredConsole(color, message) {
|
|
112
|
+
let coloredMessage = message;
|
|
113
|
+
|
|
114
|
+
if (color === "green") {
|
|
115
|
+
coloredMessage = `\x1b[32m${message}\x1b[0m`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (color === "yellow") {
|
|
119
|
+
coloredMessage = `\x1b[33m${message}\x1b[0m`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (color === "red") {
|
|
123
|
+
coloredMessage = `\x1b[31m${message}\x1b[0m`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Remove spaces and tabs around each line. */
|
|
127
|
+
coloredMessage
|
|
128
|
+
.trim()
|
|
129
|
+
.split("\n")
|
|
130
|
+
.map((line) => line.trim())
|
|
131
|
+
.join("\n");
|
|
132
|
+
|
|
133
|
+
return console.log(coloredMessage);
|
|
134
|
+
}
|