@appdirect/sfb-toolkit 4.0.20 → 4.0.22
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/index.js +11 -0
- package/config/index.js +1 -1
- package/coverage/clover.xml +32 -32
- package/coverage/coverage-final.json +4 -4
- package/coverage/lcov-report/constants/customUserAttributesMock.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/pageUrls.js.html +1 -1
- package/coverage/lcov-report/constants/userMock.js.html +1 -1
- package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +1 -1
- package/coverage/lcov-report/controllers/controllers-utils/index.html +1 -1
- package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
- package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +1 -1
- package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
- package/coverage/lcov-report/controllers/index.html +1 -1
- package/coverage/lcov-report/controllers/index.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +7 -7
- package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +3 -3
- package/coverage/lcov-report/front-end-utils/src/components/base/index.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +11 -11
- package/coverage/lcov-report/front-end-utils/src/components/container.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/index.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/search.js.html +13 -13
- package/coverage/lcov-report/front-end-utils/src/constants/index.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/utils/index.html +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/middlewares/config.js.html +1 -1
- package/coverage/lcov-report/middlewares/index.html +1 -1
- package/coverage/lcov-report/tools/index.html +1 -1
- package/coverage/lcov-report/tools/proxy-fetch.js.html +1 -1
- package/coverage/lcov.info +81 -81
- package/npm-shrinkwrap.json +179 -117
- package/package.json +5 -5
- package/src/tools/.sfbconfig +1 -1
- package/src/tools/package-fonts.js +1 -1
- package/src/tools/toolkit-common-fun.js +16 -5
- package/src/tools/toolkit-common-vars.js +1 -1
- package/src/tools/toolkit-components-copy.js +358 -0
- package/src/tools/toolkit-create-extension.js +1 -1
- package/src/tools/toolkit-mock.js +1 -1
- package/src/tools/zip-theme.js +1 -1
|
@@ -26,14 +26,14 @@ const shouldBeProjectFolder = (should) => {
|
|
|
26
26
|
const errorMessagePrefix = chalk.bgRed(" ERROR ");
|
|
27
27
|
if (!should && isProjectFolder) {
|
|
28
28
|
const errorMessage =
|
|
29
|
-
"Unable to perform requested action. Please navigate away from the
|
|
29
|
+
"Unable to perform requested action. Please navigate away from the workspace folder.";
|
|
30
30
|
console.error(chalk.bold(`${errorMessagePrefix}: ${errorMessage}`));
|
|
31
31
|
process.exit(1);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (should && !isProjectFolder) {
|
|
35
35
|
const errorMessage =
|
|
36
|
-
"Unable to perform requested action. Please navigate to a
|
|
36
|
+
"Unable to perform requested action. Please navigate to a workspace folder.";
|
|
37
37
|
console.error(chalk.bold(`${errorMessagePrefix}: ${errorMessage}`));
|
|
38
38
|
process.exit(1);
|
|
39
39
|
}
|
|
@@ -158,11 +158,20 @@ const createCustomThemePacakgeJson = (themeName, themePackageName, createdBy) =>
|
|
|
158
158
|
return JSON.stringify(customThemePackageJson, null, 2);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
const getSfbThemeComponentsVersion = () => {
|
|
162
|
+
const themePackageJson = JSON.parse(fs.readFileSync(`${ACTIVE_THEME_PATH}/package.json`));
|
|
163
|
+
return themePackageJson.dependencies['@appdirect/sfb-theme-components'];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const getToolkitVersionUsedToCreateTheme = () => {
|
|
167
|
+
const themePackageJson = JSON.parse(fs.readFileSync(`${ACTIVE_THEME_PATH}/package.json`));
|
|
168
|
+
return themePackageJson.metadata.toolkitVersion;
|
|
169
|
+
}
|
|
170
|
+
|
|
161
171
|
const updateCustomComponentsMetadata = (data) => {
|
|
162
172
|
const hasPackageJson = fs.existsSync(`${ACTIVE_THEME_PATH}/package.json`);
|
|
163
173
|
if (hasPackageJson) {
|
|
164
|
-
const
|
|
165
|
-
const sfbThemeComponentsVersion = themePackageJson.dependencies['@appdirect/sfb-theme-components'];
|
|
174
|
+
const sfbThemeComponentsVersion = getSfbThemeComponentsVersion();
|
|
166
175
|
const customComponentsPath = `${ACTIVE_THEME_PATH}/customComponents`;
|
|
167
176
|
const customComponents = fs.existsSync(customComponentsPath);
|
|
168
177
|
if (customComponents && sfbThemeComponentsVersion) {
|
|
@@ -291,5 +300,7 @@ module.exports = {
|
|
|
291
300
|
updateCustomComponentsMetadata,
|
|
292
301
|
addMetadata,
|
|
293
302
|
installSass,
|
|
294
|
-
isProjectsFolder
|
|
303
|
+
isProjectsFolder,
|
|
304
|
+
getSfbThemeComponentsVersion,
|
|
305
|
+
getToolkitVersionUsedToCreateTheme
|
|
295
306
|
}
|
|
@@ -27,7 +27,7 @@ try {
|
|
|
27
27
|
} catch (e) {
|
|
28
28
|
WORKSPACE_CONFIG = {}
|
|
29
29
|
}
|
|
30
|
-
const ACTIVE_THEME = WORKSPACE_CONFIG.theme || "
|
|
30
|
+
const ACTIVE_THEME = WORKSPACE_CONFIG.theme || "plaza";
|
|
31
31
|
const ACTIVE_THEME_PATH = `${CURRENT_PATH}/themes/${ACTIVE_THEME}`;
|
|
32
32
|
const THEME_LOGS_PATH = `${CURRENT_PATH}/theme-logs`;
|
|
33
33
|
const THEME_LOGS_FILE_PATH = `${THEME_LOGS_PATH}/${ACTIVE_THEME}`;
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const { COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
|
|
3
|
+
const { customComponentsEnabled } = require("./toolkit-components-fun");
|
|
4
|
+
const { getSfbThemeComponentsVersion, getToolkitVersionUsedToCreateTheme,
|
|
5
|
+
shouldBeProjectFolder } = require("./toolkit-common-fun");
|
|
6
|
+
const chalk = require("chalk");
|
|
7
|
+
const inquirer = require("inquirer");
|
|
8
|
+
|
|
9
|
+
// check if user is in correct location
|
|
10
|
+
shouldBeProjectFolder(true);
|
|
11
|
+
|
|
12
|
+
const commandLineComponents = COMMAND_PARAM;
|
|
13
|
+
const INDEX_EXPORT_NO_CHANGE = 'nothing';
|
|
14
|
+
const INDEX_EXPORT_COMMENT_OUT = 'comment';
|
|
15
|
+
const INDEX_EXPORT_REPLACE = 'replace';
|
|
16
|
+
const FEATURE_AVAILABLE_SINCE_TOOLKIT_VERSION = '4.0.21';
|
|
17
|
+
const BLACKLISTED_COMPONENTS = ["PageOrderableContainer"];
|
|
18
|
+
const PATH_TO_CUSTOM_COMPONENTS_INDEX = `${ACTIVE_THEME_PATH}/customComponents/index.js`;
|
|
19
|
+
const BASE_PATH_TO_COMPONENTS_INDEX = `${ACTIVE_THEME_PATH}/node_modules/@appdirect/sfb-theme-components/src/components/index.js`;
|
|
20
|
+
const sfbThemeComponentsVersion = getSfbThemeComponentsVersion().replace(/\.|\^/g, '_');
|
|
21
|
+
const themeToolkitVersion = getToolkitVersionUsedToCreateTheme();
|
|
22
|
+
|
|
23
|
+
const PAGE_ORDERABLE_CONTAINER_DIR = 'page-orderable-container'
|
|
24
|
+
const PAGE_ORDERABLE_CONTAINER_BASE_PATH = `@appdirect/sfb-theme-components/src/components/${PAGE_ORDERABLE_CONTAINER_DIR}`
|
|
25
|
+
|
|
26
|
+
const formattedComponentStatus = ({ data, statusMessage, statusType, maxStringLength = 30 }) => {
|
|
27
|
+
const formattingOffset = (maxStringLength + 20) <= 50 ? 50 : maxStringLength + 20;
|
|
28
|
+
switch(statusType) {
|
|
29
|
+
case 'success':
|
|
30
|
+
console.log(chalk.green(`${data.padEnd(formattingOffset, ".")}[${statusMessage}]`));
|
|
31
|
+
break;
|
|
32
|
+
case 'skip':
|
|
33
|
+
console.log(chalk.greenBright(`${data.padEnd(formattingOffset, ".")}[${statusMessage}]`));
|
|
34
|
+
break;
|
|
35
|
+
case 'error':
|
|
36
|
+
console.log(chalk.red(`${data.padEnd(formattingOffset, ".")}[${statusMessage}]`));
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const getPathToFile = (path) => {
|
|
42
|
+
let fullPath = path;
|
|
43
|
+
const hasExtension = fullPath.match(/(.scss|.jsx?)/);
|
|
44
|
+
if(!hasExtension) {
|
|
45
|
+
const jsFile = `${fullPath}.js`;
|
|
46
|
+
const indexJsFile = `${fullPath}/index.js`;
|
|
47
|
+
const jsxFile = `${fullPath}.jsx`;
|
|
48
|
+
const scssFile = `${fullPath}.scss`;
|
|
49
|
+
|
|
50
|
+
if(fs.existsSync(jsFile)) {
|
|
51
|
+
fullPath = jsFile;
|
|
52
|
+
} else if(fs.existsSync(jsxFile)) {
|
|
53
|
+
fullPath = jsxFile;
|
|
54
|
+
} else if(fs.existsSync(scssFile)) {
|
|
55
|
+
fullPath = scssFile;
|
|
56
|
+
} else if(fs.existsSync(indexJsFile)) {
|
|
57
|
+
fullPath = indexJsFile;
|
|
58
|
+
} else {
|
|
59
|
+
const split = fullPath.split('/');
|
|
60
|
+
split[split.length - 1] = `_${split[split.length - 1]}.scss`;
|
|
61
|
+
const updatedPathToFile = split.join('/');
|
|
62
|
+
if(fs.existsSync(updatedPathToFile)) {
|
|
63
|
+
fullPath = updatedPathToFile;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return fullPath;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const constructPath = (currentPath, goToRelativePath) => {
|
|
71
|
+
const levelsToGoUp = (goToRelativePath.match(/\.\.\//g) || []).length + 1;
|
|
72
|
+
const currentPathDepthIndices = [];
|
|
73
|
+
for(let i=0; i < currentPath.length; i++) {
|
|
74
|
+
if (currentPath[i] === '/') {
|
|
75
|
+
currentPathDepthIndices.push(i);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const newCurrentPath = currentPath.slice(0, currentPathDepthIndices[currentPathDepthIndices.length - levelsToGoUp]);
|
|
79
|
+
const newGoToPath = goToRelativePath.replace(/\.+\//g, '');
|
|
80
|
+
return getPathToFile(`${newCurrentPath}/${newGoToPath}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const replacePageOrderableContainerImports = (fileData) => {
|
|
84
|
+
if (fileData.includes(PAGE_ORDERABLE_CONTAINER_DIR)) {
|
|
85
|
+
// replace all page-orderable-container paths
|
|
86
|
+
const pageOrderableRegex = new RegExp(`[\\\/.]+${PAGE_ORDERABLE_CONTAINER_DIR}`, 'g')
|
|
87
|
+
return fileData.replace(pageOrderableRegex, PAGE_ORDERABLE_CONTAINER_BASE_PATH)
|
|
88
|
+
}
|
|
89
|
+
return fileData
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const addDefaultExport = (data, indexFileData, indexExportStrategy) => {
|
|
93
|
+
if(themeToolkitVersion >= FEATURE_AVAILABLE_SINCE_TOOLKIT_VERSION) {
|
|
94
|
+
const { name, pathToCopyTo } = data;
|
|
95
|
+
const updatedPath = pathToCopyTo.split('customComponents')[1].replace(/.jsx?/g, '');
|
|
96
|
+
const template = `\nexport { default as ${name} } from '.${updatedPath}'`;
|
|
97
|
+
let componentAlreadyExported = false;
|
|
98
|
+
|
|
99
|
+
if (indexExportStrategy === INDEX_EXPORT_COMMENT_OUT) {
|
|
100
|
+
const nonCommentedOutExports = new RegExp(`(?<!\/\/\\s*)export.*\\s${name}[\\s|}].*`, 'g');
|
|
101
|
+
const matchedValues = indexFileData.matchAll(nonCommentedOutExports);
|
|
102
|
+
|
|
103
|
+
for (const match of matchedValues) {
|
|
104
|
+
if(match[0].search(updatedPath) === -1) {
|
|
105
|
+
indexFileData = indexFileData.replace(match[0], `// ${match[0]}`);
|
|
106
|
+
} else {
|
|
107
|
+
componentAlreadyExported = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} else if (indexExportStrategy === INDEX_EXPORT_REPLACE) {
|
|
111
|
+
const nonCommentedOutExports = new RegExp(`(?<!\/\/\\s*)export.*\\s${name}[\\s|}].*\\r?\\n?`, 'g');
|
|
112
|
+
const matchedValues = indexFileData.matchAll(nonCommentedOutExports);
|
|
113
|
+
|
|
114
|
+
for (const match of matchedValues) {
|
|
115
|
+
if(match[0].search(updatedPath) === -1) {
|
|
116
|
+
indexFileData = indexFileData.replace(match[0], '');
|
|
117
|
+
} else {
|
|
118
|
+
componentAlreadyExported = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!componentAlreadyExported) {
|
|
123
|
+
return indexFileData + template;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return indexFileData;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const sfbThemeComponentsDeepCopy = (
|
|
131
|
+
pathsToFileList,
|
|
132
|
+
maxComponentStringLength,
|
|
133
|
+
indexExportStrategy = INDEX_EXPORT_NO_CHANGE
|
|
134
|
+
) => {
|
|
135
|
+
const COPIED = 'COPIED';
|
|
136
|
+
const NO_MATCH = 'NO_MATCH';
|
|
137
|
+
const SUCCESS = 'success';
|
|
138
|
+
const FOUND = 'FOUND';
|
|
139
|
+
const ERROR = 'error';
|
|
140
|
+
const SKIP = 'skip';
|
|
141
|
+
|
|
142
|
+
const componentsToCopy = pathsToFileList;
|
|
143
|
+
const paths = [...Object.keys(pathsToFileList).reverse()];
|
|
144
|
+
const allPaths = [...Object.keys(pathsToFileList)];
|
|
145
|
+
|
|
146
|
+
let indexFileData = fs.readFileSync(PATH_TO_CUSTOM_COMPONENTS_INDEX, 'utf8');
|
|
147
|
+
const indexFileDataOriginalLength = indexFileData.length;
|
|
148
|
+
|
|
149
|
+
let componentBeingCopied = {};
|
|
150
|
+
|
|
151
|
+
while(paths.length > 0) {
|
|
152
|
+
const path = paths.pop();
|
|
153
|
+
let isScssFile = path.match(/.scss/);
|
|
154
|
+
let fileData;
|
|
155
|
+
|
|
156
|
+
if(fs.existsSync(path)) {
|
|
157
|
+
fileData = fs.readFileSync(path, 'utf8').replace(/^\/\/+.*\s*/g, '');
|
|
158
|
+
} else {
|
|
159
|
+
if(componentBeingCopied.name) {
|
|
160
|
+
formattedComponentStatus({
|
|
161
|
+
data: componentBeingCopied.name,
|
|
162
|
+
statusMessage: COPIED,
|
|
163
|
+
statusType: SUCCESS,
|
|
164
|
+
maxComponentStringLength
|
|
165
|
+
});
|
|
166
|
+
indexFileData = addDefaultExport(componentBeingCopied, indexFileData);
|
|
167
|
+
}
|
|
168
|
+
if(componentsToCopy[path]) {
|
|
169
|
+
formattedComponentStatus({
|
|
170
|
+
data: componentsToCopy[path],
|
|
171
|
+
statusMessage: NO_MATCH,
|
|
172
|
+
statusType: ERROR,
|
|
173
|
+
maxComponentStringLength});
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const pathToCopyTo = path.replace('node_modules/@appdirect/sfb-theme-components',
|
|
179
|
+
`customComponents/sfb_theme_components${sfbThemeComponentsVersion}`);
|
|
180
|
+
|
|
181
|
+
if(!fs.existsSync(pathToCopyTo)) {
|
|
182
|
+
const folderPath = pathToCopyTo.slice(0, pathToCopyTo.lastIndexOf('/'));
|
|
183
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
184
|
+
|
|
185
|
+
fileData = replacePageOrderableContainerImports(fileData)
|
|
186
|
+
|
|
187
|
+
fs.writeFileSync(pathToCopyTo, fileData);
|
|
188
|
+
if(componentsToCopy[path]) {
|
|
189
|
+
if(componentBeingCopied.name) {
|
|
190
|
+
formattedComponentStatus({
|
|
191
|
+
data: componentBeingCopied.name,
|
|
192
|
+
statusMessage: COPIED,
|
|
193
|
+
statusType: SUCCESS,
|
|
194
|
+
maxComponentStringLength
|
|
195
|
+
});
|
|
196
|
+
indexFileData = addDefaultExport(componentBeingCopied, indexFileData, indexExportStrategy);
|
|
197
|
+
|
|
198
|
+
};
|
|
199
|
+
componentBeingCopied = {
|
|
200
|
+
name: componentsToCopy[path],
|
|
201
|
+
pathToCopyTo
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
if(componentsToCopy[path]) {
|
|
207
|
+
if(componentBeingCopied.name) {
|
|
208
|
+
formattedComponentStatus({
|
|
209
|
+
data: componentBeingCopied.name,
|
|
210
|
+
statusMessage: COPIED,
|
|
211
|
+
statusType: SUCCESS,
|
|
212
|
+
maxComponentStringLength
|
|
213
|
+
});
|
|
214
|
+
indexFileData = addDefaultExport(componentBeingCopied, indexFileData, indexExportStrategy);
|
|
215
|
+
componentBeingCopied = {};
|
|
216
|
+
}
|
|
217
|
+
formattedComponentStatus({
|
|
218
|
+
data: componentsToCopy[path],
|
|
219
|
+
statusMessage: FOUND,
|
|
220
|
+
statusType: SKIP,
|
|
221
|
+
maxComponentStringLength
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
let imports;
|
|
227
|
+
|
|
228
|
+
if(isScssFile) {
|
|
229
|
+
imports = fileData.matchAll(/@import.*\s+['|"](.+)['|"]/g);
|
|
230
|
+
} else {
|
|
231
|
+
imports = fileData.matchAll(/import.*\s+['|"](\.+.+)['|"]|from\s+['|"](\.+.+)['|"]/g);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
for(const importPaths of imports) {
|
|
235
|
+
const usePath = importPaths[1] || importPaths[2];
|
|
236
|
+
let fullPath = constructPath(path, usePath);
|
|
237
|
+
if(!allPaths.includes(fullPath)) {
|
|
238
|
+
// skip copying page-orderable-container imports
|
|
239
|
+
// since we re-write their usages to point to library
|
|
240
|
+
if (fullPath.includes(PAGE_ORDERABLE_CONTAINER_DIR)) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
paths.push(fullPath);
|
|
245
|
+
allPaths.push(fullPath);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if(paths.length === 0 && componentBeingCopied.name) {
|
|
250
|
+
formattedComponentStatus({
|
|
251
|
+
data: componentBeingCopied.name,
|
|
252
|
+
statusMessage: COPIED,
|
|
253
|
+
statusType: SUCCESS,
|
|
254
|
+
maxComponentStringLength
|
|
255
|
+
});
|
|
256
|
+
indexFileData = addDefaultExport(componentBeingCopied, indexFileData, indexExportStrategy);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if(indexFileDataOriginalLength < indexFileData.length || indexExportStrategy === INDEX_EXPORT_REPLACE) {
|
|
260
|
+
fs.writeFileSync(PATH_TO_CUSTOM_COMPONENTS_INDEX, `${indexFileData}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
(async () => {
|
|
265
|
+
try {
|
|
266
|
+
if(customComponentsEnabled) {
|
|
267
|
+
const componentMap = {};
|
|
268
|
+
const componentsFile = fs.readFileSync(BASE_PATH_TO_COMPONENTS_INDEX, 'utf8').replace(/\/\/+.*\s*/g, '');
|
|
269
|
+
const componentMatches = [...componentsFile.matchAll(/.*as\s+(\w+)\s+.*from\s+['|"](\.+\/.+)['|"]/g)];
|
|
270
|
+
let maxComponentStringLength = 0;
|
|
271
|
+
let selectedComponentsList;
|
|
272
|
+
|
|
273
|
+
componentMatches.forEach(component => {
|
|
274
|
+
if(!BLACKLISTED_COMPONENTS.includes(component[1])) {
|
|
275
|
+
maxComponentStringLength = maxComponentStringLength < component[1].length
|
|
276
|
+
? component[1].length
|
|
277
|
+
: maxComponentStringLength;
|
|
278
|
+
componentMap[component[1].toLowerCase()] = {
|
|
279
|
+
path: component[2],
|
|
280
|
+
componentExportName: component[1]
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
if(commandLineComponents) {
|
|
286
|
+
selectedComponentsList = commandLineComponents.split(",").sort();
|
|
287
|
+
} else {
|
|
288
|
+
const selectedComponents = await inquirer.prompt([{
|
|
289
|
+
type: 'checkbox',
|
|
290
|
+
name: 'components',
|
|
291
|
+
message: 'Please select a component(s) to copy:',
|
|
292
|
+
choices: Object.values(componentMap).map(data => data.componentExportName)
|
|
293
|
+
}]);
|
|
294
|
+
selectedComponentsList = selectedComponents.components;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const selectedComponentsFilePaths = {};
|
|
298
|
+
|
|
299
|
+
selectedComponentsList.forEach(component => {
|
|
300
|
+
const hasComponent = componentMap[component.toLowerCase()];
|
|
301
|
+
if(hasComponent) {
|
|
302
|
+
const componentPathSfb = constructPath(BASE_PATH_TO_COMPONENTS_INDEX, hasComponent.path);
|
|
303
|
+
selectedComponentsFilePaths[componentPathSfb] = hasComponent.componentExportName;
|
|
304
|
+
} else {
|
|
305
|
+
// account for user passed arguments/components that do not exist
|
|
306
|
+
maxComponentStringLength = maxComponentStringLength < component.length
|
|
307
|
+
? component.length
|
|
308
|
+
: maxComponentStringLength;
|
|
309
|
+
const componentPathSfb = constructPath(BASE_PATH_TO_COMPONENTS_INDEX, component);
|
|
310
|
+
selectedComponentsFilePaths[componentPathSfb] = component;
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
let indexExportStrategy;
|
|
315
|
+
|
|
316
|
+
if(themeToolkitVersion >= FEATURE_AVAILABLE_SINCE_TOOLKIT_VERSION) {
|
|
317
|
+
while(!indexExportStrategy) {
|
|
318
|
+
indexExportStrategy = (await inquirer.prompt({
|
|
319
|
+
type: 'list',
|
|
320
|
+
name: 'strategy',
|
|
321
|
+
message: 'Please select how the copied components should be exported:',
|
|
322
|
+
choices: [{
|
|
323
|
+
name: 'Comment out existing exported components and add those selected.',
|
|
324
|
+
value: INDEX_EXPORT_COMMENT_OUT
|
|
325
|
+
}, {
|
|
326
|
+
name: 'Replace existing exported components with those selected.',
|
|
327
|
+
value: INDEX_EXPORT_REPLACE
|
|
328
|
+
}, {
|
|
329
|
+
name: 'Do nothing. (Manual index update will be required)',
|
|
330
|
+
value: INDEX_EXPORT_NO_CHANGE
|
|
331
|
+
}]
|
|
332
|
+
})).strategy;
|
|
333
|
+
|
|
334
|
+
if(indexExportStrategy === INDEX_EXPORT_REPLACE) {
|
|
335
|
+
const deepCopyChoice = (await inquirer.prompt({
|
|
336
|
+
type: 'confirm',
|
|
337
|
+
name: 'choice',
|
|
338
|
+
message: 'This action is irreversible, are you certain you wish to proceed?'
|
|
339
|
+
})).choice;
|
|
340
|
+
|
|
341
|
+
if(!deepCopyChoice) {
|
|
342
|
+
indexExportStrategy = undefined;
|
|
343
|
+
process.stdout.moveCursor(0, -2);
|
|
344
|
+
process.stdout.clearLine(0);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
sfbThemeComponentsDeepCopy(selectedComponentsFilePaths, maxComponentStringLength, indexExportStrategy);
|
|
351
|
+
|
|
352
|
+
} else {
|
|
353
|
+
console.log(chalk.red('Custom components are not enabled for this theme.'));
|
|
354
|
+
}
|
|
355
|
+
} catch (err) {
|
|
356
|
+
console.error(chalk.red(`\n ERROR: Unable to copy components due to: ${err}.\n`));
|
|
357
|
+
}
|
|
358
|
+
})();
|
|
@@ -40,7 +40,7 @@ shouldBeProjectFolder(true);
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// Remove all special characters from the extension name
|
|
43
|
-
ExtensionName = ExtensionName.replace(/[^a-zA-Z0-9 -]/g, "").replace(
|
|
43
|
+
ExtensionName = ExtensionName.replace(/[^a-zA-Z0-9 _-]/g, "").replace(
|
|
44
44
|
/[- ]/g,
|
|
45
45
|
"_"
|
|
46
46
|
);
|
|
@@ -2,7 +2,7 @@ const snapstub = require("snapstub")
|
|
|
2
2
|
|
|
3
3
|
const currentPath = process.cwd() // used to get current dev folder
|
|
4
4
|
const config = require(`${currentPath}/config`)
|
|
5
|
-
const theme = config.theme || "
|
|
5
|
+
const theme = config.theme || "plaza"
|
|
6
6
|
const themePath = `/themes/${theme}`
|
|
7
7
|
|
|
8
8
|
const ENDPOINTS = require(`${currentPath}${themePath}/__mocks__/config`)
|
package/src/tools/zip-theme.js
CHANGED
|
@@ -6,7 +6,7 @@ const chalk = require("chalk")
|
|
|
6
6
|
const currentPath = process.cwd() // used to get current dev folder
|
|
7
7
|
const config = require(`${currentPath}/config`)
|
|
8
8
|
|
|
9
|
-
const theme = config.theme || "
|
|
9
|
+
const theme = config.theme || "plaza"
|
|
10
10
|
|
|
11
11
|
const dir = `${currentPath}/theme-zips`
|
|
12
12
|
const { COMMAND_PARAM } = require("./toolkit-common-vars")
|