@micromag/cli 0.4.59 → 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.
Files changed (2) hide show
  1. package/bin/export.js +54 -67
  2. 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
- let result = value.trim();
38
- result = result
39
- .replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE)
40
- .replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
41
- result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
42
- let start = 0;
43
- let end = result.length;
44
- // Trim the delimiter from around the output string.
45
- while (result.charAt(start) === "\0")
46
- start++;
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
- const words = split(value);
58
- for (let i = 0; i < words.length; i++) {
59
- const word = words[i];
60
- const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
61
- if (match) {
62
- const offset = match.index + (match[1] ?? match[2]).length;
63
- words.splice(i, 1, word.slice(0, offset), word.slice(offset));
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
- return words;
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
- const [prefix, words, suffix] = splitPrefixSuffix(input, options);
73
- const lower = lowerFactory(options?.locale);
74
- const upper = upperFactory(options?.locale);
75
- const transform = pascalCaseTransformFactory(lower, upper);
76
- return (prefix +
77
- words
78
- .map((word, index) => {
79
- if (index === 0)
80
- return lower(word);
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
- return (input) => input.toLocaleLowerCase(locale);
79
+ return input => input.toLocaleLowerCase(locale);
88
80
  }
89
81
  function upperFactory(locale) {
90
- return (input) => input.toLocaleUpperCase(locale);
82
+ return input => input.toLocaleUpperCase(locale);
91
83
  }
92
84
  function pascalCaseTransformFactory(lower, upper) {
93
- return (word, index) => {
94
- const char0 = word[0];
95
- const initial = index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0);
96
- return initial + lower(word.slice(1));
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
- const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
101
- const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
102
- const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
103
- let prefixIndex = 0;
104
- let suffixIndex = input.length;
105
- while (prefixIndex < input.length) {
106
- const char = input.charAt(prefixIndex);
107
- if (!prefixCharacters.includes(char))
108
- break;
109
- prefixIndex++;
110
- }
111
- while (suffixIndex > prefixIndex) {
112
- const index = suffixIndex - 1;
113
- const char = input.charAt(index);
114
- if (!suffixCharacters.includes(char))
115
- break;
116
- suffixIndex = index;
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.59",
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.55",
50
- "@micromag/elements": "^0.4.55",
51
- "@micromag/fields": "^0.4.56",
52
- "@micromag/screens": "^0.4.59",
53
- "@micromag/transforms": "^0.4.55",
54
- "@micromag/viewer": "^0.4.59",
55
- "@micromag/viewer-build": "^0.4.59",
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": "e4dfd331721492c90cb0f38b3a60e91237ca990f"
72
+ "gitHead": "0a6df1a5352c067c3296377d26fadb9b71244345"
73
73
  }