@appdirect/sfb-toolkit 4.0.19 → 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.
Files changed (47) hide show
  1. package/bin/index.js +26 -7
  2. package/config/index.js +1 -1
  3. package/coverage/clover.xml +2 -2
  4. package/coverage/lcov-report/constants/customUserAttributesMock.js.html +1 -1
  5. package/coverage/lcov-report/constants/index.html +1 -1
  6. package/coverage/lcov-report/constants/pageUrls.js.html +1 -1
  7. package/coverage/lcov-report/constants/userMock.js.html +1 -1
  8. package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +1 -1
  9. package/coverage/lcov-report/controllers/controllers-utils/index.html +1 -1
  10. package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
  11. package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +1 -1
  12. package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
  13. package/coverage/lcov-report/controllers/index.html +1 -1
  14. package/coverage/lcov-report/controllers/index.js.html +1 -1
  15. package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +1 -1
  16. package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +1 -1
  17. package/coverage/lcov-report/front-end-utils/src/components/base/index.html +1 -1
  18. package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +1 -1
  19. package/coverage/lcov-report/front-end-utils/src/components/container.js.html +1 -1
  20. package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +1 -1
  21. package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +1 -1
  22. package/coverage/lcov-report/front-end-utils/src/components/index.html +1 -1
  23. package/coverage/lcov-report/front-end-utils/src/components/search.js.html +1 -1
  24. package/coverage/lcov-report/front-end-utils/src/constants/index.html +1 -1
  25. package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +1 -1
  26. package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +1 -1
  27. package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +1 -1
  28. package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +1 -1
  29. package/coverage/lcov-report/front-end-utils/src/utils/index.html +1 -1
  30. package/coverage/lcov-report/index.html +1 -1
  31. package/coverage/lcov-report/middlewares/config.js.html +1 -1
  32. package/coverage/lcov-report/middlewares/index.html +1 -1
  33. package/coverage/lcov-report/tools/index.html +1 -1
  34. package/coverage/lcov-report/tools/proxy-fetch.js.html +1 -1
  35. package/npm-shrinkwrap.json +329 -252
  36. package/package.json +5 -5
  37. package/readme.md +6 -0
  38. package/src/tools/.sfbconfig +1 -1
  39. package/src/tools/package-fonts.js +1 -1
  40. package/src/tools/toolkit-common-fun.js +35 -21
  41. package/src/tools/toolkit-common-utils.js +63 -0
  42. package/src/tools/toolkit-common-vars.js +1 -1
  43. package/src/tools/toolkit-components-copy.js +358 -0
  44. package/src/tools/toolkit-create-extension.js +71 -9
  45. package/src/tools/toolkit-mock.js +1 -1
  46. package/src/tools/toolkit-start.js +1 -2
  47. package/src/tools/zip-theme.js +1 -1
@@ -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,21 +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
- const { ExtensionName } = await prompt.ask(["ExtensionName"]);
16
- const { AppPath } = await prompt.ask(["AppPath"]);
17
- const { MarketplacePath } = await prompt.ask(["MarketplacePath"]);
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
+
18
48
  console.log("------------****-----------\n");
19
49
  console.log(" ");
20
50
  console.log("Please wait while we create your new extension\n".yellow);
21
51
  console.log(" ");
22
52
  console.log("------------****-----------\n");
23
53
 
24
- const ExtensionsPath = `${CURRENT_PATH}/extensions/${ExtensionName}`;
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
+ }
25
65
  await rimraf.sync(
26
66
  `${TOOLKIT_PATH}/node_modules/@appdirect/public-custom-app-ui/node_modules`
27
67
  );
@@ -54,6 +94,18 @@ shouldBeProjectFolder(true);
54
94
  to: `extension_${ExtensionName}`,
55
95
  });
56
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
+
57
109
  const updateWebpackConfig2 = () => ({
58
110
  files: `${ExtensionsPath}/webpack.config.js`,
59
111
  from: `const APPPATH = 'desiredPath';`,
@@ -66,18 +118,28 @@ shouldBeProjectFolder(true);
66
118
  to: `const developmentMarketplaceDomain = "${MarketplacePath}";`,
67
119
  });
68
120
 
69
- await replace(updateWebpackConfig());
70
- await replace(updateWebpackConfig2());
71
- await replace(updateWebpackConfig3());
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
+
72
135
  await replace(updatePackagejson());
73
136
  await replace(updatePackageLockjson());
74
- await replace(updateConfig());
75
137
 
76
138
  console.log("------------****-----------\n");
77
139
  console.log(" ");
78
140
  console.log("Your new extension is ready to go!\n".green);
79
141
  console.log(
80
- `You can find your new extension in extensions/${ExtensionName}\n`.green
142
+ `You can find your new extension in ${extensionMessagePath}\n`.green
81
143
  );
82
144
  console.log(
83
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,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 || "classic"
5
+ const theme = config.theme || "plaza"
6
6
  const themePath = `/themes/${theme}`
7
7
 
8
8
  const ENDPOINTS = require(`${currentPath}${themePath}/__mocks__/config`)
@@ -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 currentPath = process.cwd() // used to get current dev folder
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) {
@@ -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 || "classic"
9
+ const theme = config.theme || "plaza"
10
10
 
11
11
  const dir = `${currentPath}/theme-zips`
12
12
  const { COMMAND_PARAM } = require("./toolkit-common-vars")