@appdirect/sfb-toolkit 4.0.18 → 4.0.20
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 +16 -12
- 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 +2636 -689
- package/package.json +4 -4
- package/readme.md +6 -0
- package/src/tools/prompt-questions.js +0 -6
- package/src/tools/toolkit-common-fun.js +22 -19
- package/src/tools/toolkit-common-utils.js +63 -0
- package/src/tools/toolkit-common-vars.js +0 -6
- package/src/tools/toolkit-create-extension.js +71 -10
- package/src/tools/toolkit-start.js +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appdirect/sfb-toolkit",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"name": "appdirect/sfb-toolkit"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@appdirect/public-custom-app-ui": "^0.0.
|
|
59
|
-
"@appdirect/sfb-theme-classic": "
|
|
60
|
-
"@appdirect/sfb-theme-plaza": "
|
|
58
|
+
"@appdirect/public-custom-app-ui": "^0.0.21",
|
|
59
|
+
"@appdirect/sfb-theme-classic": "0.0.27",
|
|
60
|
+
"@appdirect/sfb-theme-plaza": "0.0.78",
|
|
61
61
|
"@appdirect/storefront-utils": "latest",
|
|
62
62
|
"@babel/core": "^7.19.1",
|
|
63
63
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
package/readme.md
CHANGED
|
@@ -188,12 +188,6 @@ const QUESTIONS = [
|
|
|
188
188
|
"Do you want to include the Storefront Builder layout editor settings in this package? (This will override existing settings in the editor)",
|
|
189
189
|
default: false,
|
|
190
190
|
},
|
|
191
|
-
{
|
|
192
|
-
type: "list",
|
|
193
|
-
name: "CreateExtension",
|
|
194
|
-
message: "Please select the type of extension you want to build:",
|
|
195
|
-
choices: EXTENSION_PROMPT,
|
|
196
|
-
},
|
|
197
191
|
{
|
|
198
192
|
type: "input",
|
|
199
193
|
name: "ExtensionName",
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const fs = require("fs-extra");
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const packageJson = require('package-json');
|
|
2
|
+
const chalk = require("chalk");
|
|
3
|
+
const packageJson = require("package-json");
|
|
5
4
|
const { spawnSync } = require("child_process");
|
|
6
|
-
const
|
|
5
|
+
const prompt = require("./prompt-questions");
|
|
7
6
|
|
|
8
7
|
const { CURRENT_PATH, TOOLKIT_PATH, BOOTSTRAP_FOLDERS, BOOTSTRAP_FILES, CONFIG_PATH, THEME_COMPONENT_MODULE,
|
|
9
8
|
THEME_COMPONENT_VERSION, ACTIVE_THEME_PATH, THEME_LOGS_PATH, THEME_LOGS_FILE_PATH, SASS_MODULE,
|
|
@@ -11,8 +10,6 @@ const { CURRENT_PATH, TOOLKIT_PATH, BOOTSTRAP_FOLDERS, BOOTSTRAP_FILES, CONFIG_P
|
|
|
11
10
|
|
|
12
11
|
const { getCustomComponentsInfo } = require("./toolkit-components-fun");
|
|
13
12
|
|
|
14
|
-
const { has } = require("lodash");
|
|
15
|
-
|
|
16
13
|
// function to remove project's folders (used to revert changes on error)
|
|
17
14
|
const selfDestruction = (dir) => BOOTSTRAP_FOLDERS.forEach( file => fs.removeSync(`${dir}/${file}`));
|
|
18
15
|
|
|
@@ -24,18 +21,23 @@ const isProjectsFolder = (dir) => fs.readdirSync(dir).filter( item => BOOTSTRAP_
|
|
|
24
21
|
|
|
25
22
|
// simple check if current folder is Project's folder, and give specific message
|
|
26
23
|
const shouldBeProjectFolder = (should) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const isProjectFolder = isProjectsFolder(CURRENT_PATH);
|
|
25
|
+
|
|
26
|
+
const errorMessagePrefix = chalk.bgRed(" ERROR ");
|
|
27
|
+
if (!should && isProjectFolder) {
|
|
28
|
+
const errorMessage =
|
|
29
|
+
"Unable to perform requested action. Please navigate away from the project folder.";
|
|
30
|
+
console.error(chalk.bold(`${errorMessagePrefix}: ${errorMessage}`));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (should && !isProjectFolder) {
|
|
35
|
+
const errorMessage =
|
|
36
|
+
"Unable to perform requested action. Please navigate to a project folder.";
|
|
37
|
+
console.error(chalk.bold(`${errorMessagePrefix}: ${errorMessage}`));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
39
41
|
|
|
40
42
|
// simple check if current folder is Project's folder, and give specific message
|
|
41
43
|
const licenseAgreement = () => {
|
|
@@ -288,5 +290,6 @@ module.exports = {
|
|
|
288
290
|
createCustomThemePacakgeJson,
|
|
289
291
|
updateCustomComponentsMetadata,
|
|
290
292
|
addMetadata,
|
|
291
|
-
installSass
|
|
293
|
+
installSass,
|
|
294
|
+
isProjectsFolder
|
|
292
295
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { isProjectsFolder } = require("./toolkit-common-fun");
|
|
4
|
+
|
|
5
|
+
const isInsideCreatedExtension = (currentPath) => {
|
|
6
|
+
if (!currentPath) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const [extensionsPathMatch] =
|
|
10
|
+
currentPath.match(/extensions\/[a-zA-Z-0-9]*/gm) || [];
|
|
11
|
+
|
|
12
|
+
return !!extensionsPathMatch;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const isInsideExtensionsFolder = () => {
|
|
16
|
+
const currentDir = process.cwd();
|
|
17
|
+
const previousDir = path.resolve(currentDir, "../");
|
|
18
|
+
const previousDirName = path.basename(previousDir);
|
|
19
|
+
|
|
20
|
+
const [pathMatch] = currentDir.match(/extensions\/?[a-zA-Z-0-9]*/gm) || [];
|
|
21
|
+
const isPrevDirRootFolder = isProjectsFolder(previousDir);
|
|
22
|
+
const isPrevDirExtensionsFolder = previousDirName === "extensions";
|
|
23
|
+
|
|
24
|
+
if ((isPrevDirRootFolder || isPrevDirExtensionsFolder) && !!pathMatch) {
|
|
25
|
+
return {
|
|
26
|
+
pathMatch,
|
|
27
|
+
isInsideCreatedExtensionFolder: isInsideCreatedExtension(pathMatch),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return { pathMatch: undefined, isInsideCreatedExtensionFolder: false };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const shouldNotBeInExtensionsFolder = () => {
|
|
35
|
+
const { pathMatch, isInsideCreatedExtensionFolder } =
|
|
36
|
+
isInsideExtensionsFolder();
|
|
37
|
+
|
|
38
|
+
if (pathMatch) {
|
|
39
|
+
const errorPrefixString = chalk.bgRed(" ERROR ");
|
|
40
|
+
const mainErrorMessage = `You are currently inside the "${pathMatch}" folder. The "sfb-toolkit" commands are unavailable in this folder.`;
|
|
41
|
+
|
|
42
|
+
console.error(
|
|
43
|
+
`${chalk.bold(`${errorPrefixString} ${mainErrorMessage}`)}\n`
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
if (isInsideCreatedExtensionFolder) {
|
|
47
|
+
console.error(
|
|
48
|
+
`You can try running ${chalk.bold(
|
|
49
|
+
"npm install && npm start"
|
|
50
|
+
)} to install your dependencies and get started. \n`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.error(
|
|
55
|
+
`For more information, consult the documentation on Extensions: ${chalk.underline.bold(
|
|
56
|
+
"https://developer.appdirect.com/user-guides/extensions"
|
|
57
|
+
)}\n`
|
|
58
|
+
);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
module.exports = { shouldNotBeInExtensionsFolder };
|
|
@@ -38,11 +38,6 @@ const WHO_ARE_YOU_PROMPT = [
|
|
|
38
38
|
{ "name": "external dev" }
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
-
const EXTENSION_PROMPT = [
|
|
42
|
-
{ name: "Blank Extension" },
|
|
43
|
-
{ name: "DataGrid Boilerplate" },
|
|
44
|
-
{ name: "Dashboard Boilerplate" }
|
|
45
|
-
]
|
|
46
41
|
|
|
47
42
|
module.exports = {
|
|
48
43
|
TOOLKIT_GLOBAL_CONFIG,
|
|
@@ -67,5 +62,4 @@ module.exports = {
|
|
|
67
62
|
THEME_LOGS_PATH,
|
|
68
63
|
THEME_LOGS_FILE_PATH,
|
|
69
64
|
WHO_ARE_YOU_PROMPT,
|
|
70
|
-
EXTENSION_PROMPT,
|
|
71
65
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { copy } = require("fs-extra");
|
|
2
2
|
const colors = require("colors");
|
|
3
|
+
const fs = require("fs");
|
|
3
4
|
const rimraf = require("rimraf");
|
|
4
5
|
const replace = require("replace-in-file");
|
|
5
6
|
const prompt = require("./prompt-questions");
|
|
@@ -7,22 +8,60 @@ const prompt = require("./prompt-questions");
|
|
|
7
8
|
const { CURRENT_PATH, TOOLKIT_PATH } = require("./toolkit-common-vars");
|
|
8
9
|
const { shouldBeProjectFolder } = require("./toolkit-common-fun");
|
|
9
10
|
|
|
11
|
+
function generate4DigitId() {
|
|
12
|
+
let result = "";
|
|
13
|
+
const characters =
|
|
14
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
15
|
+
const charactersLength = characters.length;
|
|
16
|
+
for (let i = 0; i < 4; i++) {
|
|
17
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
shouldBeProjectFolder(true);
|
|
11
23
|
(async () => {
|
|
12
24
|
// by default
|
|
25
|
+
let ExtensionName;
|
|
26
|
+
let AppPath;
|
|
27
|
+
let MarketplacePath;
|
|
13
28
|
|
|
29
|
+
const args = process.argv.slice(2); // Remove the first two elements
|
|
14
30
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
if (args.length >= 3) {
|
|
32
|
+
// Assign values from command line arguments ie sfb-toolkit create-extension myapp-id-123f http://marketplace.appdirect.com /app/extension-path
|
|
33
|
+
[ExtensionName, MarketplacePath, AppPath] = args;
|
|
34
|
+
} else {
|
|
35
|
+
// Prompt for values if not enough arguments are provided
|
|
36
|
+
({ ExtensionName } = await prompt.ask(["ExtensionName"]));
|
|
37
|
+
({ AppPath } = await prompt.ask(["AppPath"]));
|
|
38
|
+
({ MarketplacePath } = await prompt.ask(["MarketplacePath"]));
|
|
39
|
+
AppPath = `/app/${AppPath}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Remove all special characters from the extension name
|
|
43
|
+
ExtensionName = ExtensionName.replace(/[^a-zA-Z0-9 -]/g, "").replace(
|
|
44
|
+
/[- ]/g,
|
|
45
|
+
"_"
|
|
46
|
+
);
|
|
47
|
+
|
|
19
48
|
console.log("------------****-----------\n");
|
|
20
49
|
console.log(" ");
|
|
21
50
|
console.log("Please wait while we create your new extension\n".yellow);
|
|
22
51
|
console.log(" ");
|
|
23
52
|
console.log("------------****-----------\n");
|
|
24
53
|
|
|
25
|
-
const
|
|
54
|
+
const ExtensionsPathBase = `${CURRENT_PATH}/extensions/${ExtensionName}`;
|
|
55
|
+
let ExtensionsPath = ExtensionsPathBase;
|
|
56
|
+
let extensionMessagePath = `extensions/${ExtensionName}`;
|
|
57
|
+
|
|
58
|
+
// Check if the directory exists
|
|
59
|
+
if (fs.existsSync(ExtensionsPath)) {
|
|
60
|
+
// Generate a 4-digit UUID and append it to the path
|
|
61
|
+
const id = generate4DigitId(); // This splits the UUID and takes the first segment
|
|
62
|
+
ExtensionsPath = `${ExtensionsPathBase}-${id}`;
|
|
63
|
+
extensionMessagePath = `${extensionMessagePath}-${id}`;
|
|
64
|
+
}
|
|
26
65
|
await rimraf.sync(
|
|
27
66
|
`${TOOLKIT_PATH}/node_modules/@appdirect/public-custom-app-ui/node_modules`
|
|
28
67
|
);
|
|
@@ -55,6 +94,18 @@ shouldBeProjectFolder(true);
|
|
|
55
94
|
to: `extension_${ExtensionName}`,
|
|
56
95
|
});
|
|
57
96
|
|
|
97
|
+
const updateConfig2 = () => ({
|
|
98
|
+
files: `${ExtensionsPath}/static/app-dev-config.json`,
|
|
99
|
+
from: `http://marketplace.appdirect.com`,
|
|
100
|
+
to: `${MarketplacePath}`,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const updateConfig3 = () => ({
|
|
104
|
+
files: `${ExtensionsPath}/static/app-dev-config.json`,
|
|
105
|
+
from: `/app/extension-path`,
|
|
106
|
+
to: `${AppPath}`,
|
|
107
|
+
});
|
|
108
|
+
|
|
58
109
|
const updateWebpackConfig2 = () => ({
|
|
59
110
|
files: `${ExtensionsPath}/webpack.config.js`,
|
|
60
111
|
from: `const APPPATH = 'desiredPath';`,
|
|
@@ -67,18 +118,28 @@ shouldBeProjectFolder(true);
|
|
|
67
118
|
to: `const developmentMarketplaceDomain = "${MarketplacePath}";`,
|
|
68
119
|
});
|
|
69
120
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
121
|
+
try {
|
|
122
|
+
// old way to create extensions
|
|
123
|
+
await replace(updateWebpackConfig());
|
|
124
|
+
await replace(updateWebpackConfig2());
|
|
125
|
+
await replace(updateWebpackConfig3());
|
|
126
|
+
} catch (err) {}
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
// new way to create extensions
|
|
130
|
+
await replace(updateConfig());
|
|
131
|
+
await replace(updateConfig2());
|
|
132
|
+
await replace(updateConfig3());
|
|
133
|
+
} catch (err) {}
|
|
134
|
+
|
|
73
135
|
await replace(updatePackagejson());
|
|
74
136
|
await replace(updatePackageLockjson());
|
|
75
|
-
await replace(updateConfig());
|
|
76
137
|
|
|
77
138
|
console.log("------------****-----------\n");
|
|
78
139
|
console.log(" ");
|
|
79
140
|
console.log("Your new extension is ready to go!\n".green);
|
|
80
141
|
console.log(
|
|
81
|
-
`You can find your new extension in
|
|
142
|
+
`You can find your new extension in ${extensionMessagePath}\n`.green
|
|
82
143
|
);
|
|
83
144
|
console.log(
|
|
84
145
|
`To get started, go into that folder, run the command "npm install && npm start", You can also have a look at our document at https://developer.appdirect.com. \n`
|
|
@@ -2,8 +2,7 @@ const NODEMON_PATH = "node_modules/nodemon/bin/nodemon.js"
|
|
|
2
2
|
const { spawn } = require("child_process")
|
|
3
3
|
const { TOOLKIT_PATH, COMPILERCSS_PATH } = require("./toolkit-common-vars")
|
|
4
4
|
const { shouldBeProjectFolder, versionCheck } = require("./toolkit-common-fun")
|
|
5
|
-
const
|
|
6
|
-
const config = require(`${currentPath}/config`)
|
|
5
|
+
const config = require(`${TOOLKIT_PATH}/config`)
|
|
7
6
|
|
|
8
7
|
const shouldIgnoreMessage = (data) => {
|
|
9
8
|
if (process.env.verboseToolkitOutput) {
|