@appdirect/sfb-toolkit 4.0.7 → 4.0.9
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/Dockerfile +1 -1
- package/bin/index.js +25 -1
- package/config/index.js +2 -3
- package/coverage/clover.xml +166 -161
- package/coverage/coverage-final.json +7 -7
- 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 +4 -4
- package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +4 -4
- package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
- package/coverage/lcov-report/controllers/index.html +21 -21
- package/coverage/lcov-report/controllers/index.js.html +164 -128
- 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 +20 -20
- package/coverage/lcov-report/middlewares/config.js.html +1 -1
- package/coverage/lcov-report/middlewares/index.html +1 -1
- package/coverage/lcov.info +341 -330
- package/index.js +11 -10
- package/npm-shrinkwrap.json +629 -277
- package/package.json +7 -7
- package/readme.md +14 -0
- package/src/api/cors.js +29 -20
- package/src/controllers/index.js +58 -46
- package/src/tools/prompt-questions.js +120 -68
- package/src/tools/proxy-fetch.js +16 -0
- package/src/tools/toolkit-common-vars.js +1 -1
- package/src/tools/toolkit-components.js +12 -4
- package/src/tools/toolkit-install.js +15 -7
- package/src/tools/toolkit-start.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appdirect/sfb-toolkit",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@appdirect/public-custom-app-ui": "^0.0.17",
|
|
59
|
-
"@appdirect/sfb-theme-classic": "0.0.
|
|
60
|
-
"@appdirect/sfb-theme-plaza": "0.0.
|
|
59
|
+
"@appdirect/sfb-theme-classic": "0.0.27",
|
|
60
|
+
"@appdirect/sfb-theme-plaza": "0.0.76",
|
|
61
61
|
"@appdirect/storefront-utils": "latest",
|
|
62
62
|
"@babel/core": "^7.19.1",
|
|
63
63
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"@fortawesome/react-fontawesome": "0.2.0",
|
|
72
72
|
"app-root-path": "^3.1.0",
|
|
73
73
|
"archiver": "^5.3.1",
|
|
74
|
-
"axios": "^0.27.2",
|
|
75
74
|
"babel-loader": "^8.2.5",
|
|
76
75
|
"babel-preset-minify": "^0.5.2",
|
|
77
76
|
"body-parser": "^1.20.0",
|
|
@@ -99,13 +98,14 @@
|
|
|
99
98
|
"mini-css-extract-plugin": "^2.6.1",
|
|
100
99
|
"minimist": "^1.2.6",
|
|
101
100
|
"moment": "^2.29.4",
|
|
102
|
-
"node-fetch": "^
|
|
101
|
+
"node-fetch": "^2.7.0",
|
|
103
102
|
"nodemon": "^2.0.20",
|
|
104
103
|
"nunjucks": "^3.2.3",
|
|
105
104
|
"nunjucks-intl": "^1.0.3",
|
|
106
105
|
"object-assign-deep": "^0.4.0",
|
|
107
106
|
"package-json": "^7.0.0",
|
|
108
107
|
"prop-types": "^15.8.1",
|
|
108
|
+
"proxy-agent": "^6.3.1",
|
|
109
109
|
"querystrings": "^0.4.0",
|
|
110
110
|
"react": "16.14.0",
|
|
111
111
|
"react-dom": "16.14.0",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"redux-thunk": "^2.4.1"
|
|
155
155
|
},
|
|
156
156
|
"engines": {
|
|
157
|
-
"node": "16",
|
|
158
|
-
"npm": "8"
|
|
157
|
+
"node": "16|18",
|
|
158
|
+
"npm": "8|9"
|
|
159
159
|
}
|
|
160
160
|
}
|
package/readme.md
CHANGED
|
@@ -9,6 +9,20 @@ It can be easily mixed with eg. HTML, CSS, JavaScript, jQuery, SASS.
|
|
|
9
9
|
* Node 16.x for versions 4.x.x
|
|
10
10
|
|
|
11
11
|
### Release Notes:
|
|
12
|
+
|
|
13
|
+
**4.0.9**
|
|
14
|
+
- Add Node 18 support
|
|
15
|
+
- Add prompts when enabling custom components and updating sfb-theme-component version
|
|
16
|
+
- Update `@appdirect/sfb-theme-plaza` to version 0.0.76 ([sfb-theme-mp2@0.0.75](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.76))
|
|
17
|
+
- Add default translations for all supported languages
|
|
18
|
+
- Update `sfb-theme-components` library to version [0.0.340](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.340)
|
|
19
|
+
- Add Node 18 support
|
|
20
|
+
|
|
21
|
+
**4.0.8**
|
|
22
|
+
- Update `@appdirect/sfb-theme-plaza` to version 0.0.64 ([sfb-theme-mp2@0.0.75](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.75))
|
|
23
|
+
- Update `@appdirect/sfb-theme-classic` to version 0.0.27 ([sfb-theme-classic@0.0.27](https://www.npmjs.com/package/@appdirect/sfb-theme-classic/v/0.0.27))
|
|
24
|
+
- Update `sfb-theme-components` library to version [0.0.338](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.338)
|
|
25
|
+
|
|
12
26
|
**4.0.4**
|
|
13
27
|
- Update `@appdirect/sfb-theme-plaza` to version 0.0.64 ([sfb-theme-mp2@0.0.64](https://www.npmjs.com/package/@appdirect/sfb-theme-plaza/v/0.0.64))
|
|
14
28
|
- Update `sfb-theme-components` library to version [0.0.321](https://www.npmjs.com/package/@appdirect/sfb-theme-components/v/0.0.321)
|
package/src/api/cors.js
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const fetch = require("../tools/proxy-fetch");
|
|
2
2
|
|
|
3
3
|
const cors = {
|
|
4
|
-
callApi(req, res, requestType = "get") {
|
|
5
|
-
const options = {
|
|
4
|
+
async callApi(req, res, requestType = "get") {
|
|
5
|
+
const options = {
|
|
6
|
+
method: requestType,
|
|
7
|
+
redirect: "follow",
|
|
8
|
+
follow: 20,
|
|
9
|
+
headers: {},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
if (["post", "put"].includes(requestType.toLowerCase())) {
|
|
13
|
+
options.body = JSON.stringify(req.body);
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
if (req.headers.authorization) {
|
|
7
|
-
options.Authorization = req.headers.authorization
|
|
17
|
+
options.headers.Authorization = req.headers.authorization;
|
|
8
18
|
} else if (req.headers.cookie) {
|
|
9
|
-
options.cookie = req.headers.cookie
|
|
19
|
+
options.headers.cookie = req.headers.cookie;
|
|
10
20
|
}
|
|
11
|
-
axios({
|
|
12
|
-
method: requestType,
|
|
13
|
-
url: `${req.config.marketplacePath}${req.originalUrl}`,
|
|
14
|
-
headers: options,
|
|
15
|
-
data: req.body
|
|
16
|
-
})
|
|
17
|
-
.then(response => {
|
|
18
|
-
res.send(response.data)
|
|
19
|
-
})
|
|
20
|
-
.catch(error => {
|
|
21
|
-
res.sendStatus(error.response.status)
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
try {
|
|
23
|
+
const response = await fetch(
|
|
24
|
+
`${req.config.marketplacePath}${req.originalUrl}`,
|
|
25
|
+
options
|
|
26
|
+
);
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
res.send(data);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.log(error);
|
|
31
|
+
res.sendStatus(500);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
module.exports = cors;
|
package/src/controllers/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
1
3
|
const yaml = require("js-yaml")
|
|
2
|
-
const axios = require("axios")
|
|
3
4
|
const fs = require("fs")
|
|
4
5
|
const objectAssignDeep = require("object-assign-deep")
|
|
5
6
|
const storefrontUtils = require("@appdirect/storefront-utils")
|
|
6
7
|
const URI = require("urijs")
|
|
8
|
+
const fetch = require("node-fetch");
|
|
7
9
|
const { merge } = require("lodash")
|
|
8
10
|
|
|
9
11
|
const { callToActionsFilter } = require("./data-filters/call-to-actions-filter")
|
|
@@ -135,7 +137,7 @@ class Pages {
|
|
|
135
137
|
this.config.marketplacePath,
|
|
136
138
|
this.envData
|
|
137
139
|
),
|
|
138
|
-
currentPage: page
|
|
140
|
+
currentPage: this.getPage(this.page),
|
|
139
141
|
}),
|
|
140
142
|
storefrontUtils.getQueryData(
|
|
141
143
|
{
|
|
@@ -152,49 +154,55 @@ class Pages {
|
|
|
152
154
|
}
|
|
153
155
|
)
|
|
154
156
|
)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
157
|
+
|
|
158
|
+
fetch(this.config.pageObjectsPath + apiURL, {
|
|
159
|
+
method: 'GET',
|
|
160
|
+
redirect: 'follow',
|
|
161
|
+
follow: 20,
|
|
162
|
+
headers: this.getDataHeaders(),
|
|
163
|
+
})
|
|
164
|
+
.then(response => response.json())
|
|
165
|
+
.then(data => {
|
|
166
|
+
data = Pages.filterData(data)
|
|
167
|
+
if (this.mockRole === "USER") {
|
|
168
|
+
data.config.user = userMock;
|
|
169
|
+
}
|
|
170
|
+
if (this.isCustomPage(page)) {
|
|
171
|
+
data.config.pageId = this.getPage(page);
|
|
172
|
+
}
|
|
173
|
+
this.defaultLocale = data.config.defaultLocale || "en-US";
|
|
174
|
+
resolve({
|
|
175
|
+
config: this.config,
|
|
176
|
+
...data,
|
|
177
|
+
i18n: Object.assign({}, data.i18n, {
|
|
178
|
+
custom: this.getLocalization()
|
|
172
179
|
})
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
console.error(
|
|
187
|
-
`Unable to fetch page data with http status ${statusCode}`
|
|
188
|
-
)
|
|
189
|
-
this.renderErrorPage(statusCode)
|
|
190
|
-
} else {
|
|
191
|
-
const errorCode = error.code
|
|
192
|
-
console.error(
|
|
193
|
-
`Unable to fetch page data with error code ${errorCode}`
|
|
194
|
-
)
|
|
195
|
-
this.renderErrorPage(errorCode)
|
|
180
|
+
});
|
|
181
|
+
})
|
|
182
|
+
.catch(error => {
|
|
183
|
+
console.log(error)
|
|
184
|
+
if (error.response) {
|
|
185
|
+
const statusCode = error.response.status;
|
|
186
|
+
if (
|
|
187
|
+
statusCode &&
|
|
188
|
+
Pages._isRecoverableBadLinkError(error.response)
|
|
189
|
+
) {
|
|
190
|
+
const uri = URI(error.response.data.link);
|
|
191
|
+
uri.addSearch(this.query);
|
|
192
|
+
this.res.redirect(uri.valueOf());
|
|
196
193
|
}
|
|
197
|
-
|
|
194
|
+
console.error(
|
|
195
|
+
`Unable to fetch page data with http status ${statusCode}`
|
|
196
|
+
);
|
|
197
|
+
this.renderErrorPage(statusCode);
|
|
198
|
+
} else {
|
|
199
|
+
const errorCode = error.code;
|
|
200
|
+
console.error(
|
|
201
|
+
`Unable to fetch page data with error code ${errorCode}`
|
|
202
|
+
);
|
|
203
|
+
this.renderErrorPage(errorCode);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
198
206
|
})
|
|
199
207
|
}
|
|
200
208
|
|
|
@@ -227,7 +235,11 @@ class Pages {
|
|
|
227
235
|
)
|
|
228
236
|
)
|
|
229
237
|
} catch (e) {
|
|
230
|
-
|
|
238
|
+
if (e instanceof yaml.YAMLException) {
|
|
239
|
+
console.log('YAML Error:', e.message);
|
|
240
|
+
} else {
|
|
241
|
+
console.log(`localization file ${locale} not found`)
|
|
242
|
+
}
|
|
231
243
|
}
|
|
232
244
|
return {}
|
|
233
245
|
}
|
|
@@ -303,9 +315,9 @@ class Pages {
|
|
|
303
315
|
).then(html => {
|
|
304
316
|
if (html) {
|
|
305
317
|
staticPage = new storefrontUtils.StaticContent(html, data)
|
|
306
|
-
.addGlobalString()
|
|
307
318
|
.addUnavDefaultContent(headerTpl)
|
|
308
319
|
.addDataStore()
|
|
320
|
+
.addGlobalString()
|
|
309
321
|
.addToolbar()
|
|
310
322
|
.addPageReload401()
|
|
311
323
|
}
|
|
@@ -400,7 +412,7 @@ class Pages {
|
|
|
400
412
|
staticPage = new storefrontUtils.StaticContent(
|
|
401
413
|
html,
|
|
402
414
|
data,
|
|
403
|
-
this.page
|
|
415
|
+
this.getPage(this.page)
|
|
404
416
|
)
|
|
405
417
|
.overrideDefaultStrings()
|
|
406
418
|
.addDataStore()
|
|
@@ -1,89 +1,139 @@
|
|
|
1
|
-
const fs = require("fs")
|
|
2
|
-
const inquirer = require("inquirer")
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const inquirer = require("inquirer");
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const fetch = require("./proxy-fetch");
|
|
5
|
+
const {
|
|
6
|
+
TOOLKIT_GLOBAL_CONFIG,
|
|
7
|
+
THEME_TEMPLATES,
|
|
8
|
+
WHO_ARE_YOU_PROMPT,
|
|
9
|
+
EXTENSION_PROMPT,
|
|
10
|
+
} = require("./toolkit-common-vars");
|
|
6
11
|
|
|
7
12
|
// small function to check if item has been defined
|
|
8
|
-
const isDefined = answer => !!answer
|
|
13
|
+
const isDefined = (answer) => !!answer;
|
|
9
14
|
|
|
10
15
|
// checks if the string provided is valid folder name
|
|
11
|
-
const isValidFolderName = toTest => {
|
|
12
|
-
const pattern = new RegExp(/^[a-z0-9_-]+$/, "i")
|
|
13
|
-
const result = pattern.test(toTest)
|
|
16
|
+
const isValidFolderName = (toTest) => {
|
|
17
|
+
const pattern = new RegExp(/^[a-z0-9_-]+$/, "i");
|
|
18
|
+
const result = pattern.test(toTest);
|
|
14
19
|
if (!result) {
|
|
15
|
-
console.error(chalk.red(`\n${toTest} does not seem as valid folder name.`))
|
|
20
|
+
console.error(chalk.red(`\n${toTest} does not seem as valid folder name.`));
|
|
16
21
|
}
|
|
17
|
-
return toTest !== "undefined" && result
|
|
18
|
-
}
|
|
22
|
+
return toTest !== "undefined" && result;
|
|
23
|
+
};
|
|
19
24
|
|
|
20
25
|
// gets only origin from the url
|
|
21
|
-
const parseToUrl = toParse => {
|
|
26
|
+
const parseToUrl = (toParse) => {
|
|
22
27
|
try {
|
|
23
|
-
const myUrl = new URL(toParse)
|
|
24
|
-
return Promise.resolve(myUrl.origin)
|
|
28
|
+
const myUrl = new URL(toParse);
|
|
29
|
+
return Promise.resolve(myUrl.origin);
|
|
25
30
|
} catch (err) {
|
|
26
|
-
return toParse
|
|
31
|
+
return toParse;
|
|
27
32
|
}
|
|
28
|
-
}
|
|
33
|
+
};
|
|
29
34
|
|
|
30
35
|
// checks if the string provided is valid URL
|
|
31
|
-
const isValidURL = toTest => {
|
|
36
|
+
const isValidURL = (toTest) => {
|
|
32
37
|
const pattern = new RegExp(
|
|
33
38
|
/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/,
|
|
34
39
|
"i"
|
|
35
|
-
)
|
|
36
|
-
const result = pattern.test(toTest)
|
|
40
|
+
);
|
|
41
|
+
const result = pattern.test(toTest);
|
|
37
42
|
if (!result) {
|
|
38
|
-
console.error(chalk.red(`\n"${toTest}" does not seem as valid URL.`))
|
|
43
|
+
console.error(chalk.red(`\n"${toTest}" does not seem as valid URL.`));
|
|
39
44
|
}
|
|
40
|
-
return result
|
|
41
|
-
}
|
|
42
|
-
const isValidMarketplaceURL = async toTest => {
|
|
43
|
-
if (!toTest || !isValidURL(toTest)) return false
|
|
44
|
-
console.log("\n\n Verifiying Marketplace URL...")
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
const isValidMarketplaceURL = async (toTest) => {
|
|
48
|
+
if (!toTest || !isValidURL(toTest)) return false;
|
|
49
|
+
console.log("\n\n Verifiying Marketplace URL...");
|
|
45
50
|
try {
|
|
46
|
-
const response = await
|
|
47
|
-
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
throw Error("This is not a marketplace")
|
|
51
|
+
const response = await fetch(`${toTest}/api/session/v1/frontend-context`);
|
|
52
|
+
const data = await response.json();
|
|
53
|
+
if (!data.bootstrap.marketPlaceName)
|
|
54
|
+
throw Error("This is not a marketplace");
|
|
51
55
|
} catch (err) {
|
|
52
56
|
switch (err.code) {
|
|
53
57
|
case "ETIMEDOUT":
|
|
54
|
-
console.log(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
console.log(
|
|
59
|
+
chalk.red(
|
|
60
|
+
` Unable to reach ${toTest}. Please make sure to provide valid marketplace URL and that if you are running a proxy, is it configured correctly with node https://jjasonclark.com/how-to-setup-node-behind-web-proxy/ \n`
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
break;
|
|
58
64
|
default:
|
|
59
|
-
console.log(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
console.log(
|
|
66
|
+
chalk.red(
|
|
67
|
+
` ${toTest} does not seem to be a valid marketplace URL.\n`
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
break;
|
|
63
71
|
}
|
|
64
|
-
return false
|
|
72
|
+
return false;
|
|
65
73
|
}
|
|
66
|
-
console.log(chalk.green(" Marketplace URL successfully verified.\n"))
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
74
|
+
console.log(chalk.green(" Marketplace URL successfully verified.\n"));
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
69
77
|
|
|
70
|
-
const licenseText = ` In order to use this software, please type 'agree' to accept the license agreement that can be found at https://help.appdirect.com/sfb-eula.pdf
|
|
78
|
+
const licenseText = ` In order to use this software, please type 'agree' to accept the license agreement that can be found at https://help.appdirect.com/sfb-eula.pdf`;
|
|
71
79
|
|
|
72
80
|
// list of default questions that could be prompt to user
|
|
73
81
|
const QUESTIONS = [
|
|
82
|
+
{
|
|
83
|
+
type: "input",
|
|
84
|
+
name: "InstallCustomComponents",
|
|
85
|
+
message: chalk.yellowBright(`${chalk.bgRed(
|
|
86
|
+
"WARNING"
|
|
87
|
+
)}: You are about to install Custom Components in your theme.\n
|
|
88
|
+
\u2022 Custom Components lets you create new UI elements using React and our components library (${chalk.cyan(
|
|
89
|
+
"@appdirect/sfb-theme-components"
|
|
90
|
+
)}).
|
|
91
|
+
\u2022 Once installed, your components library version will be locked and won't receive further updates automatically.
|
|
92
|
+
\u2022 ${chalk.bgRed("This command is irreversible.")}
|
|
93
|
+
\u2022 Please refer to our documentation for comprehensive details.
|
|
94
|
+
${chalk.cyan(
|
|
95
|
+
"https://developer.appdirect.com/storefront/how-tos/components/storefront-custom-components"
|
|
96
|
+
)}
|
|
97
|
+
\nDo you wish to proceed? (y/n)`),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "input",
|
|
101
|
+
name: "InstallSfbThemeComponents",
|
|
102
|
+
message: chalk.yellowBright(
|
|
103
|
+
`${chalk.bgRed(
|
|
104
|
+
"WARNING"
|
|
105
|
+
)}: You are about to change the installed version of ${chalk.cyan(
|
|
106
|
+
"@appdirect/sfb-theme-components"
|
|
107
|
+
)}.\n
|
|
108
|
+
\u2022 May introduce breaking changes, especially if you leverage or override the ${chalk.cyan(
|
|
109
|
+
"@appdirect/sfb-theme-components"
|
|
110
|
+
)} library.` +
|
|
111
|
+
` Please note your current ${chalk.cyan(
|
|
112
|
+
"@appdirect/sfb-theme-components"
|
|
113
|
+
)} version before going forward in the event you need to revert.
|
|
114
|
+
\u2022 ${chalk.bgRed.yellowBright(
|
|
115
|
+
"Ensure you thoroughly test your theme before deploying this new version."
|
|
116
|
+
)}
|
|
117
|
+
\u2022 Please see our documentation for more information.
|
|
118
|
+
${chalk.cyan(
|
|
119
|
+
"https://developer.appdirect.com/storefront/how-tos/components/storefront-custom-components#update-custom-components-ui-library-sfb-theme-components."
|
|
120
|
+
)}
|
|
121
|
+
\nDo you wish to proceed? (y/n)`
|
|
122
|
+
),
|
|
123
|
+
},
|
|
74
124
|
{
|
|
75
125
|
type: "input",
|
|
76
126
|
name: "ProjectName",
|
|
77
127
|
message: "Name of the project:",
|
|
78
128
|
default: TOOLKIT_GLOBAL_CONFIG.defaultValues.projectName,
|
|
79
|
-
validate: isValidFolderName
|
|
129
|
+
validate: isValidFolderName,
|
|
80
130
|
},
|
|
81
131
|
{
|
|
82
132
|
type: "input",
|
|
83
133
|
name: "ThemeName",
|
|
84
134
|
message: "Customize the theme name:",
|
|
85
135
|
default: TOOLKIT_GLOBAL_CONFIG.defaultValues.themeName,
|
|
86
|
-
validate: isValidFolderName
|
|
136
|
+
validate: isValidFolderName,
|
|
87
137
|
},
|
|
88
138
|
{
|
|
89
139
|
type: "input",
|
|
@@ -91,37 +141,39 @@ const QUESTIONS = [
|
|
|
91
141
|
message: "Path to the Marketplace:",
|
|
92
142
|
default: TOOLKIT_GLOBAL_CONFIG.defaultValues.marketplacePath,
|
|
93
143
|
validate: isValidMarketplaceURL,
|
|
94
|
-
filter: parseToUrl
|
|
144
|
+
filter: parseToUrl,
|
|
95
145
|
},
|
|
96
146
|
{
|
|
97
147
|
type: "confirm",
|
|
98
148
|
name: "PackTranslationsChoice",
|
|
99
149
|
message: "Do you want to include translations in this package?",
|
|
100
|
-
default: false
|
|
150
|
+
default: false,
|
|
101
151
|
},
|
|
102
152
|
{
|
|
103
153
|
type: "input",
|
|
104
154
|
name: "LicenseAgreement",
|
|
105
155
|
message: licenseText,
|
|
106
|
-
validate: isDefined
|
|
156
|
+
validate: isDefined,
|
|
107
157
|
},
|
|
108
158
|
{
|
|
109
159
|
type: "list",
|
|
110
160
|
name: "ThemeTemplates",
|
|
111
161
|
message: "Choose a marketplace theme as a starting point:",
|
|
112
|
-
choices: THEME_TEMPLATES
|
|
162
|
+
choices: THEME_TEMPLATES,
|
|
113
163
|
},
|
|
114
164
|
{
|
|
115
165
|
type: "list",
|
|
116
166
|
name: "WhoAreYou",
|
|
117
|
-
message:
|
|
118
|
-
|
|
167
|
+
message:
|
|
168
|
+
"Please indicate which option most closely represents who you are:",
|
|
169
|
+
choices: WHO_ARE_YOU_PROMPT,
|
|
119
170
|
},
|
|
120
171
|
{
|
|
121
172
|
type: "confirm",
|
|
122
173
|
name: "PackSettingsChoice",
|
|
123
|
-
message:
|
|
124
|
-
|
|
174
|
+
message:
|
|
175
|
+
"Do you want to include the Storefront Builder layout editor settings in this package? (This will override existing settings in the editor)",
|
|
176
|
+
default: false,
|
|
125
177
|
},
|
|
126
178
|
{
|
|
127
179
|
type: "list",
|
|
@@ -143,35 +195,35 @@ const QUESTIONS = [
|
|
|
143
195
|
"Path to the extension you want to build on the marketplace /app/:mypath (letter & dash, only) (This can be changed later):",
|
|
144
196
|
validate: isValidFolderName,
|
|
145
197
|
},
|
|
146
|
-
]
|
|
198
|
+
];
|
|
147
199
|
|
|
148
200
|
// use only selected question
|
|
149
201
|
// list: Array<String>
|
|
150
|
-
const chooseQuestions = list =>
|
|
151
|
-
QUESTIONS.filter(question => list.includes(question.name))
|
|
202
|
+
const chooseQuestions = (list) =>
|
|
203
|
+
QUESTIONS.filter((question) => list.includes(question.name));
|
|
152
204
|
|
|
153
205
|
// parse question if necessary (eg. want to update default)
|
|
154
206
|
const parseQuestions = (questions, custom) =>
|
|
155
|
-
chooseQuestions(questions).map(question => {
|
|
156
|
-
const newCustom = custom.find(q => q.name === question.name)
|
|
207
|
+
chooseQuestions(questions).map((question) => {
|
|
208
|
+
const newCustom = custom.find((q) => q.name === question.name);
|
|
157
209
|
return {
|
|
158
210
|
...question,
|
|
159
|
-
...newCustom
|
|
160
|
-
}
|
|
161
|
-
})
|
|
211
|
+
...newCustom,
|
|
212
|
+
};
|
|
213
|
+
});
|
|
162
214
|
|
|
163
215
|
// prompt to user with provided qustions
|
|
164
216
|
const ask = (questions = [], custom = []) => {
|
|
165
217
|
const toAsk =
|
|
166
218
|
custom.length > 0
|
|
167
219
|
? parseQuestions(questions, custom)
|
|
168
|
-
: chooseQuestions(questions)
|
|
169
|
-
return inquirer.prompt(toAsk)
|
|
170
|
-
}
|
|
220
|
+
: chooseQuestions(questions);
|
|
221
|
+
return inquirer.prompt(toAsk);
|
|
222
|
+
};
|
|
171
223
|
module.exports = {
|
|
172
224
|
ask,
|
|
173
225
|
validateFun: {
|
|
174
226
|
isValidFolderName,
|
|
175
|
-
isValidURL
|
|
176
|
-
}
|
|
177
|
-
}
|
|
227
|
+
isValidURL,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const fetch = require("node-fetch");
|
|
2
|
+
const ProxyAgent = require("proxy-agent");
|
|
3
|
+
|
|
4
|
+
async function fetchProxied(url, fetchOptions = {}) {
|
|
5
|
+
// Check if the URL should use a proxy
|
|
6
|
+
const useProxy = process.env.HTTPS_PROXY;
|
|
7
|
+
|
|
8
|
+
// If we should use a proxy, set the agent
|
|
9
|
+
if (useProxy) {
|
|
10
|
+
fetchOptions.agent = new ProxyAgent(process.env.HTTPS_PROXY);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return fetch(url, fetchOptions);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = fetchProxied;
|
|
@@ -15,7 +15,7 @@ const THEME_TEMPLATES_CONFIG_PATH = `${TOOLKIT_PATH}/themes-config.json`;
|
|
|
15
15
|
const THEME_TEMPLATES = JSON.parse(fs.readFileSync(THEME_TEMPLATES_CONFIG_PATH));
|
|
16
16
|
const PAGE_OBJECTS_SUFFIX = "/api/internal/storefront/v1";
|
|
17
17
|
const THEME_COMPONENT_MODULE = "@appdirect/sfb-theme-components";
|
|
18
|
-
const THEME_COMPONENT_VERSION = "0.0.
|
|
18
|
+
const THEME_COMPONENT_VERSION = "0.0.340";
|
|
19
19
|
const SASS_MODULE = "sass";
|
|
20
20
|
const SASS_VERSION = "1.57.1";
|
|
21
21
|
const SASS_LOADER_MODULE = "sass-loader";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const fs = require("fs-extra")
|
|
2
|
-
const chalk = require("chalk")
|
|
1
|
+
const fs = require("fs-extra");
|
|
2
|
+
const chalk = require("chalk");
|
|
3
|
+
const prompt = require("./prompt-questions");
|
|
3
4
|
const { shouldBeProjectFolder, installSfbThemeComponents,
|
|
4
5
|
createPackageJson, updateCustomComponentsMetadata, installSass } = require("./toolkit-common-fun");
|
|
5
6
|
const { ACTIVE_THEME_PATH, TOOLKIT_PATH } = require("./toolkit-common-vars");
|
|
@@ -17,11 +18,18 @@ const addCustomCompToBase = (baseFilePath, data) => {
|
|
|
17
18
|
|
|
18
19
|
const settingsSchemaData = `{ "useComponents": true }`;
|
|
19
20
|
|
|
20
|
-
(() => {
|
|
21
|
+
(async () => {
|
|
21
22
|
const baseFilePath = `${ACTIVE_THEME_PATH}/content/layout/base.html`;
|
|
22
23
|
const customComponentsPath = `${ACTIVE_THEME_PATH}/customComponents`
|
|
23
24
|
const customComponentsEnabled = fs.existsSync(customComponentsPath);
|
|
24
25
|
|
|
26
|
+
if(!customComponentsEnabled) {
|
|
27
|
+
const customComponents = await prompt.ask(["InstallCustomComponents"]);
|
|
28
|
+
if(customComponents.InstallCustomComponents.toLowerCase() !== "y") {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
createPackageJson();
|
|
26
34
|
|
|
27
35
|
installSfbThemeComponents();
|
|
@@ -84,4 +92,4 @@ const settingsSchemaData = `{ "useComponents": true }`;
|
|
|
84
92
|
console.log(chalk.cyan('sfb-toolkit storybook\n'))
|
|
85
93
|
}
|
|
86
94
|
})
|
|
87
|
-
})();
|
|
95
|
+
})();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require("fs-extra");
|
|
2
2
|
const chalk = require("chalk");
|
|
3
|
+
const prompt = require("./prompt-questions");
|
|
3
4
|
const { shouldBeProjectFolder, createPackageJson, updateCustomComponentsMetadata } = require("./toolkit-common-fun");
|
|
4
5
|
const { spawn } = require("child_process");
|
|
5
6
|
const { COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
|
|
@@ -7,14 +8,20 @@ const { COMMAND_PARAM, ACTIVE_THEME_PATH } = require("./toolkit-common-vars");
|
|
|
7
8
|
const npmModule = COMMAND_PARAM;
|
|
8
9
|
|
|
9
10
|
shouldBeProjectFolder(true);
|
|
10
|
-
if(npmModule === 'undefined'){
|
|
11
|
-
console.error(chalk.red(` ERROR: Please provide the npm module to install.`));
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
11
|
|
|
15
|
-
(
|
|
12
|
+
const checkCommandParam = async () => {
|
|
13
|
+
if(npmModule === 'undefined'){
|
|
14
|
+
console.error(chalk.red(` ERROR: Please provide the npm module to install.`));
|
|
15
|
+
process.exit(1);
|
|
16
|
+
} else if (npmModule.includes('@appdirect/sfb-theme-components')) {
|
|
17
|
+
const sfbThemeComponents = await prompt.ask(["InstallSfbThemeComponents"]);
|
|
18
|
+
if(sfbThemeComponents.InstallSfbThemeComponents.toLowerCase() !== "y") {
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
createPackageJson();
|
|
17
|
-
|
|
24
|
+
|
|
18
25
|
spawn('npm',
|
|
19
26
|
[`install --save ${npmModule} --production`], {
|
|
20
27
|
cwd: ACTIVE_THEME_PATH,
|
|
@@ -38,5 +45,6 @@ if(npmModule === 'undefined'){
|
|
|
38
45
|
};
|
|
39
46
|
};
|
|
40
47
|
});
|
|
48
|
+
}
|
|
41
49
|
|
|
42
|
-
|
|
50
|
+
checkCommandParam();
|