@micromag/cli 0.4.60 → 0.4.63
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/export.js +54 -67
- package/package.json +9 -9
package/bin/export.js
CHANGED
|
@@ -34,92 +34,79 @@ const DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
|
34
34
|
* Split any cased input strings into an array of words.
|
|
35
35
|
*/
|
|
36
36
|
function split(value) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (start === end)
|
|
48
|
-
return [];
|
|
49
|
-
while (result.charAt(end - 1) === "\0")
|
|
50
|
-
end--;
|
|
51
|
-
return result.slice(start, end).split(/\0/g);
|
|
37
|
+
let result = value.trim();
|
|
38
|
+
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
39
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
40
|
+
let start = 0;
|
|
41
|
+
let end = result.length;
|
|
42
|
+
// Trim the delimiter from around the output string.
|
|
43
|
+
while (result.charAt(start) === "\0") start++;
|
|
44
|
+
if (start === end) return [];
|
|
45
|
+
while (result.charAt(end - 1) === "\0") end--;
|
|
46
|
+
return result.slice(start, end).split(/\0/g);
|
|
52
47
|
}
|
|
53
48
|
/**
|
|
54
49
|
* Split the input string into an array of words, separating numbers.
|
|
55
50
|
*/
|
|
56
51
|
function splitSeparateNumbers(value) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
const words = split(value);
|
|
53
|
+
for (let i = 0; i < words.length; i++) {
|
|
54
|
+
const word = words[i];
|
|
55
|
+
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
56
|
+
if (match) {
|
|
57
|
+
var _match$;
|
|
58
|
+
const offset = match.index + ((_match$ = match[1]) !== null && _match$ !== void 0 ? _match$ : match[2]).length;
|
|
59
|
+
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
65
60
|
}
|
|
66
|
-
|
|
61
|
+
}
|
|
62
|
+
return words;
|
|
67
63
|
}
|
|
68
64
|
/**
|
|
69
65
|
* Convert a string to camel case (`fooBar`).
|
|
70
66
|
*/
|
|
71
67
|
function camelCase(input, options) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return transform(word, index);
|
|
82
|
-
})
|
|
83
|
-
.join("") +
|
|
84
|
-
suffix);
|
|
68
|
+
var _options$delimiter2;
|
|
69
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
70
|
+
const lower = lowerFactory(void 0 );
|
|
71
|
+
const upper = upperFactory(void 0 );
|
|
72
|
+
const transform = pascalCaseTransformFactory(lower, upper);
|
|
73
|
+
return prefix + words.map((word, index) => {
|
|
74
|
+
if (index === 0) return lower(word);
|
|
75
|
+
return transform(word, index);
|
|
76
|
+
}).join((_options$delimiter2 = void 0 ) !== null && _options$delimiter2 !== void 0 ? _options$delimiter2 : "") + suffix;
|
|
85
77
|
}
|
|
86
78
|
function lowerFactory(locale) {
|
|
87
|
-
|
|
79
|
+
return input => input.toLocaleLowerCase(locale);
|
|
88
80
|
}
|
|
89
81
|
function upperFactory(locale) {
|
|
90
|
-
|
|
82
|
+
return input => input.toLocaleUpperCase(locale);
|
|
91
83
|
}
|
|
92
84
|
function pascalCaseTransformFactory(lower, upper) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
return (word, index) => {
|
|
86
|
+
const char0 = word[0];
|
|
87
|
+
const initial = index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0);
|
|
88
|
+
return initial + lower(word.slice(1));
|
|
89
|
+
};
|
|
98
90
|
}
|
|
99
91
|
function splitPrefixSuffix(input, options = {}) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return [
|
|
119
|
-
input.slice(0, prefixIndex),
|
|
120
|
-
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
121
|
-
input.slice(suffixIndex),
|
|
122
|
-
];
|
|
92
|
+
var _options$split, _options$prefixCharac, _options$suffixCharac;
|
|
93
|
+
const splitFn = (_options$split = options.split) !== null && _options$split !== void 0 ? _options$split : options.separateNumbers ? splitSeparateNumbers : split;
|
|
94
|
+
const prefixCharacters = (_options$prefixCharac = options.prefixCharacters) !== null && _options$prefixCharac !== void 0 ? _options$prefixCharac : DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
95
|
+
const suffixCharacters = (_options$suffixCharac = options.suffixCharacters) !== null && _options$suffixCharac !== void 0 ? _options$suffixCharac : DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
96
|
+
let prefixIndex = 0;
|
|
97
|
+
let suffixIndex = input.length;
|
|
98
|
+
while (prefixIndex < input.length) {
|
|
99
|
+
const char = input.charAt(prefixIndex);
|
|
100
|
+
if (!prefixCharacters.includes(char)) break;
|
|
101
|
+
prefixIndex++;
|
|
102
|
+
}
|
|
103
|
+
while (suffixIndex > prefixIndex) {
|
|
104
|
+
const index = suffixIndex - 1;
|
|
105
|
+
const char = input.charAt(index);
|
|
106
|
+
if (!suffixCharacters.includes(char)) break;
|
|
107
|
+
suffixIndex = index;
|
|
108
|
+
}
|
|
109
|
+
return [input.slice(0, prefixIndex), splitFn(input.slice(prefixIndex, suffixIndex)), input.slice(suffixIndex)];
|
|
123
110
|
}
|
|
124
111
|
|
|
125
112
|
const transformStory = (story, format) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.63",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/runtime": "^7.28.6",
|
|
49
|
-
"@micromag/core": "^0.4.
|
|
50
|
-
"@micromag/elements": "^0.4.
|
|
51
|
-
"@micromag/fields": "^0.4.
|
|
52
|
-
"@micromag/screens": "^0.4.
|
|
53
|
-
"@micromag/transforms": "^0.4.
|
|
54
|
-
"@micromag/viewer": "^0.4.
|
|
55
|
-
"@micromag/viewer-build": "^0.4.
|
|
49
|
+
"@micromag/core": "^0.4.63",
|
|
50
|
+
"@micromag/elements": "^0.4.63",
|
|
51
|
+
"@micromag/fields": "^0.4.63",
|
|
52
|
+
"@micromag/screens": "^0.4.63",
|
|
53
|
+
"@micromag/transforms": "^0.4.63",
|
|
54
|
+
"@micromag/viewer": "^0.4.63",
|
|
55
|
+
"@micromag/viewer-build": "^0.4.63",
|
|
56
56
|
"change-case": "^5.4.4",
|
|
57
57
|
"classnames": "^2.2.6",
|
|
58
58
|
"commander": "^12.0.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"access": "public",
|
|
70
70
|
"registry": "https://registry.npmjs.org/"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "0a6df1a5352c067c3296377d26fadb9b71244345"
|
|
73
73
|
}
|