@appdirect/sfb-toolkit 4.0.22 → 4.0.24
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 +92 -14
- 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/customComponents/index.js +10 -2
- package/npm-shrinkwrap.json +144 -20
- package/package.json +4 -4
- package/readme.md +9 -0
- package/src/boilerplates/AddComponent/AddComponent.jsx +234 -0
- package/src/boilerplates/AddComponent/styles/AddComponent.scss +47 -0
- package/src/tools/prompt-questions.js +109 -14
- package/src/tools/toolkit-common-fun.js +30 -15
- package/src/tools/toolkit-common-vars-namespace.js +106 -0
- package/src/tools/toolkit-common-vars.js +1 -1
- package/src/tools/toolkit-components-add.js +334 -0
- package/src/tools/toolkit-components-copy.js +78 -46
- package/src/tools/toolkit-components-delete.js +370 -0
- package/src/tools/toolkit-components-fun.js +126 -7
- package/src/tools/toolkit-components-info.js +6 -4
- package/src/tools/toolkit-components-vars.js +50 -0
- package/src/tools/toolkit-components.js +1 -1
- package/src/tools/toolkit-create.js +2 -3
- package/src/tools/toolkit-import.js +182 -0
- package/src/tools/toolkit-install.js +6 -5
- package/src/tools/toolkit-package.js +3 -0
- package/src/tools/toolkit-setup.js +1 -1
- package/src/tools/toolkit-start.js +4 -1
- package/src/tools/toolkit-storybook.js +136 -48
- package/src/tools/toolkit-zip-utils.js +35 -0
- package/src/tools/zip-theme.js +62 -50
- package/themes-config.json +0 -7
- package/customComponents/atoms/label/Label.jsx +0 -20
- package/customComponents/atoms/label/stories/Label.story.mdx +0 -20
- package/customComponents/atoms/label/styles/Label.scss +0 -4
- package/customComponents/components/atoms-showcase-custom/AtomsShowcaseCustom.jsx +0 -8
- package/customComponents/components/atoms-showcase-custom/stories/AtomsShowcaseCustom.story.mdx +0 -17
- package/customComponents/components/atoms-showcase-modules/AtomsShowcaseModules.jsx +0 -223
- package/customComponents/components/atoms-showcase-modules/stories/AtomsShowcaseModules.story.mdx +0 -49
- package/customComponents/components/index.js +0 -2
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const extract = require('extract-zip');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
const { shouldBeProjectFolder, getAvailableFolderWithPrompt } = require("./toolkit-common-fun");
|
|
6
|
+
const { CURRENT_PATH, PAGE_OBJECTS_SUFFIX, COMMAND_PARAM } = require("./toolkit-common-vars");
|
|
7
|
+
const chalk = require("chalk");
|
|
8
|
+
const prompt = require("./prompt-questions");
|
|
9
|
+
const { LOCAL_CONFIG } = require("./toolkit-config");
|
|
10
|
+
const { extractCustomComponentsZipToThemeRoot } = require("./toolkit-components-fun");
|
|
11
|
+
|
|
12
|
+
shouldBeProjectFolder(true);
|
|
13
|
+
|
|
14
|
+
const getPackageJsonPath = (themePath) => path.join(themePath, 'package.json');
|
|
15
|
+
|
|
16
|
+
const getPackageJsonData = (packageJsonPath) => {
|
|
17
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const packageJsonData = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
22
|
+
return JSON.parse(packageJsonData);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const getValidThemeFilePath = async (initialThemeZipPath) => {
|
|
26
|
+
let themeZipPath = initialThemeZipPath;
|
|
27
|
+
|
|
28
|
+
if (!themeZipPath || themeZipPath === "undefined" || !(fs.existsSync(themeZipPath) || fs.existsSync(themeZipPath + '.zip'))) {
|
|
29
|
+
if (themeZipPath && themeZipPath !== "undefined") {
|
|
30
|
+
console.error(chalk.red('\n ERROR: The theme file should be located in the workspace folder.\n'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const userAnswerThemeFilePath = await prompt.ask(["ThemeFilePath"]);
|
|
34
|
+
themeZipPath = userAnswerThemeFilePath.ThemeFilePath;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (path.extname(themeZipPath) !== '.zip') {
|
|
38
|
+
themeZipPath += '.zip';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return themeZipPath;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const promptForMarketplacePath = async () => {
|
|
45
|
+
const userAnswerMarketplacePath = await prompt.ask(["MarketplacePath"]);
|
|
46
|
+
return userAnswerMarketplacePath.MarketplacePath;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const getValidMarketplacePath = async (marketplacePath) => {
|
|
50
|
+
if (marketplacePath && marketplacePath !== "undefined" && await prompt.validateFun.isValidMarketplaceURL(marketplacePath)) {
|
|
51
|
+
return marketplacePath;
|
|
52
|
+
}
|
|
53
|
+
return await promptForMarketplacePath();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const getValidThemeName = async (initialThemeName) => {
|
|
57
|
+
let validatedThemeName = initialThemeName;
|
|
58
|
+
while (!prompt.validateFun.isValidFolderName(validatedThemeName)) {
|
|
59
|
+
const userAnswer = await prompt.ask(["ThemeName"]);
|
|
60
|
+
validatedThemeName = userAnswer.ThemeName;
|
|
61
|
+
}
|
|
62
|
+
return validatedThemeName;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const extractTheme = async (themeZipPath, themePath) => {
|
|
66
|
+
try {
|
|
67
|
+
await extract(themeZipPath, { dir: themePath })
|
|
68
|
+
|
|
69
|
+
await extractCustomComponentsZipToThemeRoot(themePath)
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.log(chalk.red(` ERROR: Unable to extract theme's files due to: ${err}`));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log(chalk.green(` Theme files have been extracted successfully.\n`));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const updateThemeNameInPackageJson = (themePath, newThemeName) => {
|
|
79
|
+
const packageJsonPath = getPackageJsonPath(themePath);
|
|
80
|
+
const packageJson = getPackageJsonData(packageJsonPath);
|
|
81
|
+
|
|
82
|
+
if (packageJson) {
|
|
83
|
+
packageJson.name = newThemeName;
|
|
84
|
+
|
|
85
|
+
const updatedPackageJsonData = JSON.stringify(packageJson, null, 2);
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
fs.writeFileSync(packageJsonPath, updatedPackageJsonData, 'utf-8');
|
|
89
|
+
} catch (err) {
|
|
90
|
+
console.error(chalk.red(`\n ERROR: Unable to update package.json in ${themePath}.\n`));
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const updateLocalConfig = (themeName, marketplacePath) => {
|
|
97
|
+
let newConfig = {};
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
const projectData = LOCAL_CONFIG.read();
|
|
101
|
+
const newNamespace = {
|
|
102
|
+
themeName,
|
|
103
|
+
marketplacePath,
|
|
104
|
+
pageObjectsPath: `${marketplacePath}${PAGE_OBJECTS_SUFFIX}`,
|
|
105
|
+
};
|
|
106
|
+
newConfig = {
|
|
107
|
+
...projectData,
|
|
108
|
+
namespaces: [
|
|
109
|
+
...projectData.namespaces,
|
|
110
|
+
newNamespace
|
|
111
|
+
],
|
|
112
|
+
current: themeName,
|
|
113
|
+
modified: new Date()
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
console.error(chalk.red(`\n ERROR: Unable to save updates due to: ${err}.\n`));
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
LOCAL_CONFIG.save(newConfig);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.error(chalk.red(` ERROR: Unable to save config file due to: ${err}.\n`));
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
LOCAL_CONFIG.configFileUpdate();
|
|
129
|
+
console.log(chalk.yellow(` Context switched to ${themeName}.\n`));
|
|
130
|
+
} catch (err) {
|
|
131
|
+
console.error(chalk.red(` ERROR: Unable to switch context to ${themeName} due to: ${err}.\n`));
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const areDependenciesPresentInPackageJson = (themePath) => {
|
|
137
|
+
const packageJsonPath = getPackageJsonPath(themePath);
|
|
138
|
+
const packageJson = getPackageJsonData(packageJsonPath);
|
|
139
|
+
return packageJson?.dependencies && Object.keys(packageJson.dependencies).length > 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const installDependencies = (themePath) => {
|
|
143
|
+
console.log(chalk.yellow(" Please wait while we install your dependencies. \n"));
|
|
144
|
+
spawnSync('npm',
|
|
145
|
+
['install', '--legacy-peer-deps'], {
|
|
146
|
+
cwd: themePath,
|
|
147
|
+
stdio: "inherit",
|
|
148
|
+
shell: true
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
(async () => {
|
|
153
|
+
const args = process.argv.slice(2);
|
|
154
|
+
let themeZipFilePath;
|
|
155
|
+
let marketplacePath;
|
|
156
|
+
let themeName;
|
|
157
|
+
|
|
158
|
+
[themeZipFilePath, marketplacePath, themeName] = args;
|
|
159
|
+
|
|
160
|
+
themeZipFilePath = await getValidThemeFilePath(themeZipFilePath);
|
|
161
|
+
|
|
162
|
+
marketplacePath = await getValidMarketplacePath(marketplacePath);
|
|
163
|
+
|
|
164
|
+
themeName = await getValidThemeName(themeName);
|
|
165
|
+
|
|
166
|
+
const themePath = await getAvailableFolderWithPrompt(`${CURRENT_PATH}/themes`, themeName, "ThemeName")
|
|
167
|
+
|
|
168
|
+
// Get new theme name if path for previous theme name is already taken
|
|
169
|
+
const updatedThemeName = themePath.replace(`${CURRENT_PATH}/themes/`, "");
|
|
170
|
+
|
|
171
|
+
await extractTheme(themeZipFilePath, themePath);
|
|
172
|
+
|
|
173
|
+
updateLocalConfig(updatedThemeName, marketplacePath);
|
|
174
|
+
|
|
175
|
+
if (areDependenciesPresentInPackageJson(themePath)) {
|
|
176
|
+
updateThemeNameInPackageJson(themePath, updatedThemeName);
|
|
177
|
+
installDependencies(themePath);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
console.log(chalk.green("\n Theme imported successfully."));
|
|
181
|
+
console.log(chalk.green(` All done! You can start your server by running \`sfb-toolkit start\` inside the workspace folder: ${CURRENT_PATH}\n`));
|
|
182
|
+
})();
|
|
@@ -4,6 +4,7 @@ const prompt = require("./prompt-questions");
|
|
|
4
4
|
const { shouldBeProjectFolder, createPackageJson, updateCustomComponentsMetadata } = require("./toolkit-common-fun");
|
|
5
5
|
const { spawn } = require("child_process");
|
|
6
6
|
const { COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
|
|
7
|
+
const { customComponentsEnabled } = require("./toolkit-components-fun");
|
|
7
8
|
|
|
8
9
|
const npmModule = COMMAND_PARAM;
|
|
9
10
|
|
|
@@ -28,13 +29,13 @@ const checkCommandParam = async () => {
|
|
|
28
29
|
stdio: "inherit",
|
|
29
30
|
shell: true
|
|
30
31
|
}
|
|
31
|
-
).on('exit', () => {
|
|
32
|
+
).on('exit', async () => {
|
|
32
33
|
if (npmModule.includes('@appdirect/sfb-theme-components')) {
|
|
33
34
|
const baseFilePath = `${ACTIVE_THEME_PATH}/content/layout/base.html`;
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
if (
|
|
35
|
+
|
|
36
|
+
const isCustomComponentsEnabled = await customComponentsEnabled();
|
|
37
|
+
|
|
38
|
+
if (isCustomComponentsEnabled) {
|
|
38
39
|
fs.readFile(baseFilePath, 'utf8', (err, data) => {
|
|
39
40
|
if (err) return console.error(chalk.red(` ERROR: Unable to read the base layout file. Tried: ${baseFilePath}`));
|
|
40
41
|
const updatedMetadata = updateCustomComponentsMetadata(data);
|
|
@@ -19,6 +19,7 @@ const {
|
|
|
19
19
|
ACTIVE_THEME_PATH
|
|
20
20
|
} = require("./toolkit-common-vars")
|
|
21
21
|
const { shouldBeProjectFolder, addMetadata } = require("./toolkit-common-fun")
|
|
22
|
+
const { extractCustomComponentsZipToThemeRoot } = require("./toolkit-components-fun")
|
|
22
23
|
|
|
23
24
|
shouldBeProjectFolder(true)
|
|
24
25
|
|
|
@@ -62,6 +63,8 @@ const includeSettings = async shouldIncludeSettings => {
|
|
|
62
63
|
let shouldIncludeTranslations = true
|
|
63
64
|
let shouldIncludeSettings = true
|
|
64
65
|
|
|
66
|
+
await extractCustomComponentsZipToThemeRoot()
|
|
67
|
+
|
|
65
68
|
addMetadata();
|
|
66
69
|
|
|
67
70
|
if (process.env.PACK_ALL !== "true") {
|
|
@@ -127,7 +127,7 @@ let userThemeAnswer;
|
|
|
127
127
|
|
|
128
128
|
try {
|
|
129
129
|
const toolkitPackageJson = JSON.parse(fs.readFileSync(`${TOOLKIT_PATH}/package.json`));
|
|
130
|
-
const themeVersion = toolkitPackageJson.dependencies[`${userThemeAnswer.ThemeTemplates.dependency}`];
|
|
130
|
+
const themeVersion = toolkitPackageJson.dependencies?.[`${userThemeAnswer.ThemeTemplates.dependency}`];
|
|
131
131
|
addMetadata({
|
|
132
132
|
themeTemplate: userThemeAnswer.ThemeTemplates.dependency,
|
|
133
133
|
themeVersion,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const NODEMON_PATH = "node_modules/nodemon/bin/nodemon.js"
|
|
2
2
|
const { spawn } = require("child_process")
|
|
3
|
-
const { TOOLKIT_PATH, COMPILERCSS_PATH } = require("./toolkit-common-vars")
|
|
3
|
+
const { TOOLKIT_PATH, COMPILERCSS_PATH, ACTIVE_THEME_PATH } = require("./toolkit-common-vars")
|
|
4
4
|
const { shouldBeProjectFolder, versionCheck } = require("./toolkit-common-fun")
|
|
5
|
+
const { extractCustomComponentsZipToThemeRoot } = require("./toolkit-components-fun")
|
|
5
6
|
const config = require(`${TOOLKIT_PATH}/config`)
|
|
6
7
|
|
|
7
8
|
const shouldIgnoreMessage = (data) => {
|
|
@@ -24,6 +25,8 @@ shouldBeProjectFolder(true);
|
|
|
24
25
|
(async () => {
|
|
25
26
|
await versionCheck();
|
|
26
27
|
|
|
28
|
+
await extractCustomComponentsZipToThemeRoot()
|
|
29
|
+
|
|
27
30
|
const toolkitStartProcess = spawn('node',
|
|
28
31
|
[`"${TOOLKIT_PATH}/${NODEMON_PATH}" "${TOOLKIT_PATH}/index.js" -e js,mjs,json,yml --watch themes/${config.theme}/ --ignore themes/${config.theme}/assets/js/`], {
|
|
29
32
|
shell: true
|
|
@@ -1,56 +1,144 @@
|
|
|
1
1
|
const fs = require("fs-extra");
|
|
2
2
|
const chalk = require("chalk");
|
|
3
|
-
const { shouldBeProjectFolder, installSfbThemeComponents, createPackageJson } = require("./toolkit-common-fun");
|
|
4
3
|
const { spawnSync } = require("child_process");
|
|
5
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
shouldBeProjectFolder,
|
|
6
|
+
installSfbThemeComponents,
|
|
7
|
+
createPackageJson,
|
|
8
|
+
} = require("./toolkit-common-fun");
|
|
9
|
+
const {
|
|
10
|
+
ACTIVE_THEME_PATH,
|
|
11
|
+
THEME_LOGS_FILE_PATH,
|
|
12
|
+
SASS_VERSION,
|
|
13
|
+
SASS_LOADER_VERSION,
|
|
14
|
+
} = require("./toolkit-common-vars");
|
|
15
|
+
|
|
16
|
+
const STORYBOOK_MODULE = "@storybook/react";
|
|
17
|
+
|
|
18
|
+
const isStorybookInstalledForActiveTheme = () => {
|
|
19
|
+
try {
|
|
20
|
+
// Check if Storybook is part of the theme's npm deps.
|
|
21
|
+
const packageJson = JSON.parse(
|
|
22
|
+
fs.readFileSync(`${ACTIVE_THEME_PATH}/package.json`)
|
|
23
|
+
);
|
|
24
|
+
return packageJson?.dependencies?.[STORYBOOK_MODULE] ?? false;
|
|
25
|
+
} catch (err) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getOnlineStorybookLog = () =>
|
|
31
|
+
`You can still access the online Storybook Storefront Components Library here: https://developer.appdirect.com/storefront/components/library`;
|
|
32
|
+
|
|
33
|
+
const outputWarningDeprecatedMessage = () => {
|
|
34
|
+
const getWarningMessage = (message) =>
|
|
35
|
+
`${chalk.bold(`${chalk.bgYellow(" WARNING ")} ${message}`)}`;
|
|
36
|
+
|
|
37
|
+
console.error(
|
|
38
|
+
getWarningMessage(
|
|
39
|
+
'The "storybook" command has been deprecated in the UI Toolkit.'
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
console.error(
|
|
43
|
+
getWarningMessage(
|
|
44
|
+
"The command will run for any existing theme with Storybook configured. All newly created themes will no longer support the command."
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
console.error(getWarningMessage(getOnlineStorybookLog()));
|
|
48
|
+
console.log(
|
|
49
|
+
`${chalk.bold(
|
|
50
|
+
'\nThis theme supports the deprecated "storybook" command...\n'
|
|
51
|
+
)}`
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const outputErrorDeprecatedMessage = () => {
|
|
56
|
+
const getErrorMessage = (message) =>
|
|
57
|
+
`${chalk.bold(`${chalk.bgRed(" ERROR ")} ${message}`)}`;
|
|
58
|
+
|
|
59
|
+
console.error(
|
|
60
|
+
getErrorMessage(
|
|
61
|
+
'This theme does not support the deprecated "storybook" command.'
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
console.error(
|
|
65
|
+
getErrorMessage(
|
|
66
|
+
"Only themes previously configured with Storybook are allowed to run this command."
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
console.error(getErrorMessage(getOnlineStorybookLog()));
|
|
70
|
+
};
|
|
6
71
|
|
|
7
72
|
shouldBeProjectFolder(true);
|
|
73
|
+
|
|
8
74
|
const storybookDependencies = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
].join(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
75
|
+
"@babel/core@7.19.0",
|
|
76
|
+
"@babel/plugin-proposal-class-properties@7.13.0",
|
|
77
|
+
"@babel/preset-env@7.19.0",
|
|
78
|
+
"@storybook/addon-actions@6.3.1",
|
|
79
|
+
"@storybook/addon-essentials@6.2.9",
|
|
80
|
+
"@storybook/addon-knobs@6.2.9",
|
|
81
|
+
"@storybook/addon-links@6.2.9",
|
|
82
|
+
"@storybook/addon-a11y@6.3.1",
|
|
83
|
+
"@storybook/addon-docs@6.3.1",
|
|
84
|
+
"@storybook/react@6.3.1",
|
|
85
|
+
"babel-loader@8.2.5",
|
|
86
|
+
"core-js@3.12.1",
|
|
87
|
+
"preset-react@1.0.0",
|
|
88
|
+
"react@16.14.0",
|
|
89
|
+
"react-content-loader@5.1.4",
|
|
90
|
+
"react-dom@16.14.0",
|
|
91
|
+
`sass@${SASS_VERSION}`,
|
|
92
|
+
`sass-loader@${SASS_LOADER_VERSION}`,
|
|
93
|
+
].join(" ");
|
|
94
|
+
|
|
95
|
+
(() => {
|
|
96
|
+
// Handle newly created themes without Storybook configured.
|
|
97
|
+
if (!isStorybookInstalledForActiveTheme()) {
|
|
98
|
+
outputErrorDeprecatedMessage();
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Handle previously created themes with Storybook configured.
|
|
103
|
+
outputWarningDeprecatedMessage();
|
|
104
|
+
createPackageJson();
|
|
105
|
+
installSfbThemeComponents();
|
|
106
|
+
|
|
107
|
+
// check if .storybook is part of the @appdirect/sfb-theme-components module
|
|
108
|
+
if (
|
|
109
|
+
!fs.existsSync(
|
|
110
|
+
`${ACTIVE_THEME_PATH}/node_modules/@appdirect/sfb-theme-components/.storybook`
|
|
111
|
+
)
|
|
112
|
+
) {
|
|
113
|
+
return console.log(
|
|
114
|
+
chalk.red(
|
|
115
|
+
"ERROR: missing storybook support, please update to the latest version by executing the following command:\n sfb-toolkit install @appdirect/sfb-theme-components@latest"
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// check if storybook module is installed otherwise install storybook dependencies
|
|
121
|
+
spawnSync(
|
|
122
|
+
"npm",
|
|
123
|
+
[
|
|
124
|
+
`ls ${STORYBOOK_MODULE} 2>&1 | (findstr ${STORYBOOK_MODULE} || grep ${STORYBOOK_MODULE}) > ${THEME_LOGS_FILE_PATH} 2>&1 || npm i -S ${storybookDependencies} --legacy-peer-deps --production`,
|
|
125
|
+
],
|
|
126
|
+
{
|
|
127
|
+
cwd: ACTIVE_THEME_PATH,
|
|
128
|
+
stdio: "inherit",
|
|
129
|
+
shell: true,
|
|
39
130
|
}
|
|
131
|
+
);
|
|
40
132
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
[
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
shell: true
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
})();
|
|
133
|
+
spawnSync(
|
|
134
|
+
"npx",
|
|
135
|
+
[
|
|
136
|
+
"start-storybook -p 6099 -c node_modules/@appdirect/sfb-theme-components/.storybook/ -s node_modules/@appdirect/sfb-theme-components/docs/images --loglevel silent",
|
|
137
|
+
],
|
|
138
|
+
{
|
|
139
|
+
cwd: ACTIVE_THEME_PATH,
|
|
140
|
+
stdio: "inherit",
|
|
141
|
+
shell: true,
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
})();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const fs = require("fs-extra");
|
|
2
|
+
const archiver = require("archiver");
|
|
3
|
+
const extract = require("extract-zip");
|
|
4
|
+
|
|
5
|
+
const extractZip = async (zipPath, outputPath) => {
|
|
6
|
+
try {
|
|
7
|
+
await extract(zipPath, { dir: outputPath });
|
|
8
|
+
} catch (err) {
|
|
9
|
+
throw new Error(`ERROR: Unable to extract files due to: ${err}`);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const zipFolder = async (sourceFolder, outputZipFile) => {
|
|
14
|
+
const archive = archiver("zip");
|
|
15
|
+
const fileOutputStream = fs.createWriteStream(outputZipFile);
|
|
16
|
+
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
fileOutputStream.on("close", async () => {
|
|
19
|
+
resolve();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
archive.on("error", (err) => {
|
|
23
|
+
reject(err);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
archive.pipe(fileOutputStream);
|
|
27
|
+
archive.directory(sourceFolder, false);
|
|
28
|
+
archive.finalize();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
zipFolder,
|
|
34
|
+
extractZip,
|
|
35
|
+
};
|
package/src/tools/zip-theme.js
CHANGED
|
@@ -1,64 +1,76 @@
|
|
|
1
|
-
const fs = require("fs")
|
|
2
|
-
const archiver = require("archiver")
|
|
3
|
-
const moment = require("moment")
|
|
4
|
-
const chalk = require("chalk")
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const archiver = require("archiver");
|
|
3
|
+
const moment = require("moment");
|
|
4
|
+
const chalk = require("chalk");
|
|
5
5
|
|
|
6
|
-
const currentPath = process.cwd() // used to get current dev folder
|
|
7
|
-
const config = require(`${currentPath}/config`)
|
|
6
|
+
const currentPath = process.cwd(); // used to get current dev folder
|
|
7
|
+
const config = require(`${currentPath}/config`);
|
|
8
8
|
|
|
9
|
-
const theme = config.theme || "plaza"
|
|
9
|
+
const theme = config.theme || "plaza";
|
|
10
10
|
|
|
11
|
-
const dir = `${currentPath}/theme-zips
|
|
12
|
-
const { COMMAND_PARAM } = require("./toolkit-common-vars")
|
|
11
|
+
const dir = `${currentPath}/theme-zips`;
|
|
12
|
+
const { COMMAND_PARAM } = require("./toolkit-common-vars");
|
|
13
|
+
const {
|
|
14
|
+
removeCustomComponentsInThemeAssets,
|
|
15
|
+
compressCustomComponentsToThemeAssets,
|
|
16
|
+
} = require("./toolkit-components-fun");
|
|
13
17
|
|
|
14
|
-
const SHOULD_INCLUDE_TRANSLATIONS = COMMAND_PARAM === "true" || false
|
|
15
|
-
const SHOULD_INCLUDE_SETTINGS = process.argv[3] === "true" || false
|
|
18
|
+
const SHOULD_INCLUDE_TRANSLATIONS = COMMAND_PARAM === "true" || false;
|
|
19
|
+
const SHOULD_INCLUDE_SETTINGS = process.argv[3] === "true" || false;
|
|
16
20
|
|
|
17
21
|
if (!fs.existsSync(dir)) {
|
|
18
|
-
fs.mkdirSync(dir)
|
|
22
|
+
fs.mkdirSync(dir);
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
const now = moment().format("YYYY-MM-DD_HH.mm.ss")
|
|
22
|
-
const fileName = `${currentPath}/theme-zips/${theme}__${now}.zip
|
|
23
|
-
const fileOutput = fs.createWriteStream(fileName)
|
|
24
|
-
const archive = archiver("zip")
|
|
25
|
+
const now = moment().format("YYYY-MM-DD_HH.mm.ss");
|
|
26
|
+
const fileName = `${currentPath}/theme-zips/${theme}__${now}.zip`;
|
|
27
|
+
const fileOutput = fs.createWriteStream(fileName);
|
|
28
|
+
const archive = archiver("zip");
|
|
25
29
|
|
|
26
30
|
fileOutput.on("close", () => {
|
|
27
|
-
console.log(chalk.green(`${archive.pointer()} total bytes`))
|
|
28
|
-
console.log(
|
|
29
|
-
`Archive has been finalized in /theme-zips with theme ${theme}`
|
|
30
|
-
)
|
|
31
|
-
})
|
|
31
|
+
console.log(chalk.green(`${archive.pointer()} total bytes`));
|
|
32
|
+
console.log(
|
|
33
|
+
chalk.green(`Archive has been finalized in /theme-zips with theme ${theme}`)
|
|
34
|
+
);
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
removeCustomComponentsInThemeAssets();
|
|
37
|
+
});
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
39
|
+
(async () => {
|
|
40
|
+
archive.pipe(fileOutput);
|
|
41
|
+
const root = `${currentPath}/themes/${theme}`;
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const specialIgnore = [];
|
|
44
|
+
if (!SHOULD_INCLUDE_TRANSLATIONS) {
|
|
45
|
+
specialIgnore.push("translations/**");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!SHOULD_INCLUDE_SETTINGS) {
|
|
49
|
+
specialIgnore.push("settings.json");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await compressCustomComponentsToThemeAssets();
|
|
44
53
|
|
|
45
|
-
// some glob pattern here
|
|
46
|
-
archive.glob("**", {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
// some glob pattern here
|
|
55
|
+
archive.glob("**", {
|
|
56
|
+
cwd: root,
|
|
57
|
+
ignore: [
|
|
58
|
+
".*",
|
|
59
|
+
"__*/**",
|
|
60
|
+
"**/node_modules/**",
|
|
61
|
+
"*.Jenkinsfile",
|
|
62
|
+
"package-lock.json",
|
|
63
|
+
"npm-shrinkwrap.json",
|
|
64
|
+
"README.md",
|
|
65
|
+
"convert_translation/**",
|
|
66
|
+
"customComponents/**", // exclude on root, but allow on assets
|
|
67
|
+
...specialIgnore,
|
|
68
|
+
],
|
|
69
|
+
});
|
|
70
|
+
// add as many as you like
|
|
71
|
+
archive.on("error", (err) => {
|
|
72
|
+
console.log(chalk.red(err));
|
|
73
|
+
throw err;
|
|
74
|
+
});
|
|
75
|
+
archive.finalize();
|
|
76
|
+
})();
|
package/themes-config.json
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
[
|
|
2
|
-
{
|
|
3
|
-
"name": "Classic - A theme built with simple HTML/CSS and jQuery.",
|
|
4
|
-
"value": {
|
|
5
|
-
"dependency": "@appdirect/sfb-theme-classic",
|
|
6
|
-
"name": "Classic"
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
2
|
{
|
|
10
3
|
"name": "Plaza - A modern theme built with react components that can be customized with Storefront Builder.",
|
|
11
4
|
"value": {
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import './styles/Label.scss';
|
|
4
|
-
|
|
5
|
-
const Label = ({
|
|
6
|
-
label,
|
|
7
|
-
...otherProps
|
|
8
|
-
}) => (
|
|
9
|
-
<span class="myLabel" {...otherProps}>{label}</span>
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
Label.propTypes = {
|
|
13
|
-
label: PropTypes.string
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
Label.defaultProps = {
|
|
17
|
-
label: ''
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default Label;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Story, Canvas, Meta, ArgsTable } from '@storybook/addon-docs/blocks';
|
|
2
|
-
import Label from '../Label';
|
|
3
|
-
|
|
4
|
-
<Meta title="Custom Atoms/Label" compont="Label" />
|
|
5
|
-
|
|
6
|
-
# Label
|
|
7
|
-
<br />
|
|
8
|
-
|
|
9
|
-
## `Labels` are an example of basic/reusable custom components.
|
|
10
|
-
<br />
|
|
11
|
-
|
|
12
|
-
### Default
|
|
13
|
-
<Canvas>
|
|
14
|
-
<Story name="Default">
|
|
15
|
-
<Label label="Custom Atom Label" />
|
|
16
|
-
</Story>
|
|
17
|
-
</Canvas>
|
|
18
|
-
|
|
19
|
-
## Props
|
|
20
|
-
<ArgsTable of={Label} />
|