@appdirect/sfb-toolkit 5.0.8 → 6.0.0

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 (120) hide show
  1. package/.eslintrc +35 -35
  2. package/CHANGELOG.md +32 -0
  3. package/Dockerfile +2 -1
  4. package/agent/.cursor/rules/sfb-storefront.mdc +17 -0
  5. package/agent/.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md +130 -0
  6. package/agent/.cursor/skills/sfb-custom-components/SKILL.md +43 -0
  7. package/agent/.cursor/skills/sfb-localization-settings/SKILL.md +29 -0
  8. package/agent/.cursor/skills/sfb-theme-customize/SKILL.md +25 -0
  9. package/agent/.cursor/skills/sfb-toolkit-commands/SKILL.md +35 -0
  10. package/agent/AGENTS.md +160 -0
  11. package/agent/CLAUDE.md +19 -0
  12. package/bin/index.js +82 -100
  13. package/coverage/clover.xml +1921 -335
  14. package/coverage/coverage-final.json +41 -20
  15. package/coverage/lcov-report/{controllers/controllers-utils → config}/index.html +19 -19
  16. package/coverage/lcov-report/config/index.js.html +124 -0
  17. package/coverage/lcov-report/index.html +108 -78
  18. package/coverage/lcov-report/{constants → src/constants}/customUserAttributesMock.js.html +12 -12
  19. package/coverage/lcov-report/{constants → src/constants}/index.html +10 -10
  20. package/coverage/lcov-report/{constants → src/constants}/pageUrls.js.html +14 -14
  21. package/coverage/lcov-report/{constants → src/constants}/userMock.js.html +13 -13
  22. package/coverage/lcov-report/{controllers → src/controllers}/controllers-utils/assetsUtils.js.html +20 -20
  23. package/coverage/lcov-report/src/controllers/controllers-utils/index.html +131 -0
  24. package/coverage/lcov-report/src/controllers/controllers-utils/locale.js.html +115 -0
  25. package/coverage/lcov-report/{controllers → src/controllers}/data-filters/bootstrap-data-filter.js.html +15 -15
  26. package/coverage/lcov-report/{controllers → src/controllers}/data-filters/call-to-actions-filter.js.html +22 -22
  27. package/coverage/lcov-report/{controllers → src/controllers}/data-filters/index.html +37 -22
  28. package/coverage/lcov-report/src/controllers/data-filters/media-url-filter.js.html +394 -0
  29. package/coverage/lcov-report/{controllers → src/controllers}/index.html +27 -27
  30. package/coverage/lcov-report/{controllers → src/controllers}/index.js.html +159 -126
  31. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/ResultItem.js.html +43 -43
  32. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/SearchBar.js.html +22 -22
  33. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/index.html +28 -28
  34. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/item.js.html +28 -28
  35. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/container.js.html +31 -31
  36. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/data-view.js.html +29 -29
  37. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/header-view.js.html +35 -38
  38. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/index.html +45 -45
  39. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/search.js.html +54 -54
  40. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/index.html +22 -22
  41. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/pageUrl.js.html +17 -17
  42. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/roleType.js.html +14 -14
  43. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/searchType.js.html +17 -17
  44. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/utils/debounce.js.html +15 -15
  45. package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/utils/index.html +20 -20
  46. package/coverage/lcov-report/{middlewares → src/middlewares}/config.js.html +11 -11
  47. package/coverage/lcov-report/{middlewares → src/middlewares}/index.html +10 -10
  48. package/coverage/lcov-report/{tools → src/routes}/index.html +30 -30
  49. package/coverage/lcov-report/src/routes/media-proxy.js.html +613 -0
  50. package/coverage/lcov-report/src/tools/compile-styles.js.html +1018 -0
  51. package/coverage/lcov-report/src/tools/custom-components-export-compat-loader.js.html +745 -0
  52. package/coverage/lcov-report/src/tools/index.html +371 -0
  53. package/coverage/lcov-report/src/tools/prompt-questions.js.html +1117 -0
  54. package/coverage/lcov-report/{tools → src/tools}/proxy-fetch.js.html +15 -15
  55. package/coverage/lcov-report/src/tools/resolve-components-react.js.html +457 -0
  56. package/coverage/lcov-report/src/tools/sass-legacy-compat.js.html +1192 -0
  57. package/coverage/lcov-report/src/tools/toolkit-cli-argv.js.html +226 -0
  58. package/coverage/lcov-report/src/tools/toolkit-common-fun.js.html +1192 -0
  59. package/coverage/lcov-report/src/tools/toolkit-common-vars-namespace.js.html +403 -0
  60. package/coverage/lcov-report/src/tools/toolkit-common-vars.js.html +283 -0
  61. package/coverage/lcov-report/src/tools/toolkit-components-fun.js.html +1237 -0
  62. package/coverage/lcov-report/src/tools/toolkit-components-vars.js.html +232 -0
  63. package/coverage/lcov-report/src/tools/toolkit-install-agent-guidance.js.html +439 -0
  64. package/coverage/lcov-report/src/tools/toolkit-live-reload.js.html +688 -0
  65. package/coverage/lcov-report/src/tools/toolkit-path.js.html +184 -0
  66. package/coverage/lcov-report/src/tools/toolkit-spawn.js.html +199 -0
  67. package/coverage/lcov-report/src/tools/toolkit-v6-theme-risk.js.html +1039 -0
  68. package/coverage/lcov-report/src/tools/toolkit-zip-utils.js.html +190 -0
  69. package/coverage/lcov.info +3356 -727
  70. package/index.js +40 -20
  71. package/npm-shrinkwrap.json +19445 -35435
  72. package/package.json +50 -41
  73. package/readme.md +23 -1
  74. package/rspack-components.config.cjs +81 -0
  75. package/rspack-components.config.prod.cjs +71 -0
  76. package/rspack.config.cjs +25 -0
  77. package/rspack.shared.cjs +164 -0
  78. package/src/controllers/controllers-utils/locale.js +10 -0
  79. package/src/controllers/data-filters/media-url-filter.js +103 -0
  80. package/src/controllers/index.js +15 -4
  81. package/src/front-end-utils/dist/toolbar.bundle.js +1 -2
  82. package/src/front-end-utils/src/components/header-view.js +0 -1
  83. package/src/routes/cors.js +29 -0
  84. package/src/routes/index.js +2 -0
  85. package/src/routes/media-proxy.js +176 -0
  86. package/src/tools/compile-styles.js +311 -0
  87. package/src/tools/compiler-components-prod.js +32 -21
  88. package/src/tools/compiler-css.js +7 -7
  89. package/src/tools/custom-components-export-compat-loader.js +220 -0
  90. package/src/tools/resolve-components-react.js +124 -0
  91. package/src/tools/sass-legacy-compat.js +369 -0
  92. package/src/tools/toolkit-checkout.js +3 -6
  93. package/src/tools/toolkit-cli-argv.js +47 -0
  94. package/src/tools/toolkit-common-fun.js +66 -18
  95. package/src/tools/toolkit-common-utils.js +5 -3
  96. package/src/tools/toolkit-common-vars.js +4 -3
  97. package/src/tools/toolkit-components-copy.js +6 -4
  98. package/src/tools/toolkit-components-fun.js +6 -4
  99. package/src/tools/toolkit-config-setup.js +2 -1
  100. package/src/tools/toolkit-create.js +5 -7
  101. package/src/tools/toolkit-import.js +5 -6
  102. package/src/tools/toolkit-install-agent-guidance-cli.js +24 -0
  103. package/src/tools/toolkit-install-agent-guidance.js +118 -0
  104. package/src/tools/toolkit-install.js +8 -8
  105. package/src/tools/toolkit-live-reload.js +201 -0
  106. package/src/tools/toolkit-package.js +25 -7
  107. package/src/tools/toolkit-path.js +33 -0
  108. package/src/tools/toolkit-setup-e2e.js +2 -1
  109. package/src/tools/toolkit-setup.js +5 -1
  110. package/src/tools/toolkit-spawn.js +38 -0
  111. package/src/tools/toolkit-start.js +98 -54
  112. package/src/tools/toolkit-storybook.js +38 -19
  113. package/src/tools/toolkit-update.js +5 -3
  114. package/src/tools/toolkit-v6-theme-risk.js +318 -0
  115. package/themes-param.json +1 -0
  116. package/src/front-end-utils/dist/toolbar.bundle.js.LICENSE.txt +0 -52
  117. package/src/tools/gulp-tasks.js +0 -80
  118. package/webpack-components.config.cjs +0 -123
  119. package/webpack-components.config.prod.cjs +0 -113
  120. package/webpack.config.cjs +0 -25
package/index.js CHANGED
@@ -1,16 +1,21 @@
1
1
  const express = require("express")
2
- const webpack = require("webpack")
2
+ const { rspack } = require("@rspack/core")
3
+ const { devMiddleware } = require("@rspack/dev-middleware")
3
4
  const fs = require("fs")
4
- const webpackDevMiddleware = require("webpack-dev-middleware")
5
+ const { sep } = require("path")
6
+ const { pathToFileURL } = require("url")
5
7
  const webpackHotMiddleware = require("webpack-hot-middleware")
6
8
  const bodyParser = require("body-parser")
7
9
  const cookieParser = require("cookie-parser")
8
- const { sep } = require("path")
9
- const { pathToFileURL } = require("url")
10
- const configWebpack = require("./webpack.config.cjs")
10
+ const configToolbar = require("./rspack.config.cjs")
11
11
  const routes = require("./src/routes")
12
12
  const configMiddleware = require("./src/middlewares/config")
13
- const getConfigComponentsWebpack = require("./webpack-components.config.cjs")
13
+ const getConfigComponents = require("./rspack-components.config.cjs")
14
+ const {
15
+ isLiveReloadEnabled,
16
+ createLiveReloadHub,
17
+ LIVE_RELOAD_PATH,
18
+ } = require("./src/tools/toolkit-live-reload")
14
19
 
15
20
  const {
16
21
  toolkitAssetsPath,
@@ -20,44 +25,48 @@ const {
20
25
  const currentPath = process.cwd() // used to get current dev folder
21
26
  const config = require(`${currentPath}/config`)
22
27
  const port = config.port || 3555
28
+ // Optional bind host (e.g. HOST=0.0.0.0 for Docker). Unset = Node default (same as master).
29
+ const host = process.env.HOST || config.host
30
+ configToolbar.output.publicPath = `http://localhost:${port}/utils/dist`
23
31
 
24
32
  const app = express()
25
33
  if (process.env.RUN_ENV === "dev") {
26
- const compiler = webpack(configWebpack)
34
+ const compiler = rspack(configToolbar)
27
35
  app.use(
28
- webpackDevMiddleware(compiler, {
29
- publicPath: configWebpack.output.publicPath,
36
+ devMiddleware(compiler, {
37
+ publicPath: configToolbar.output.publicPath,
30
38
  stats: { colors: true },
31
39
  })
32
40
  )
33
41
  }
34
42
 
35
43
  if (fs.existsSync(`${currentPath}/themes/${config.theme}/customComponents`)) {
36
- // This is a workaround for SASS bug:
37
- // https://github.com/dart-lang/sdk/issues/27979
38
- // which manifests itself sometimes when webpack dev middleware is used
39
- // (in dev mode), and app modules are imported in some unfortunate ways.
44
+ // Workaround for Dart Sass Uri.base/importer edge case in Node
45
+ // (https://github.com/dart-lang/sdk/issues/27979) when compiling
46
+ // custom-component styles through sass-loader + sass-embedded.
40
47
  if (!global.location) {
41
48
  global.location = {
42
49
  href: `${pathToFileURL(process.cwd()).href}${sep}`,
43
50
  }
44
51
  }
45
- const configComponentsWebpackAsset = getConfigComponentsWebpack(
52
+ const configComponentsAsset = getConfigComponents(
46
53
  currentPath,
47
54
  config,
48
55
  true
49
56
  )
50
- const compilerComponentsAsset = webpack(configComponentsWebpackAsset)
57
+ const compilerComponentsAsset = rspack(configComponentsAsset)
51
58
  app.use(
52
- webpackDevMiddleware(compilerComponentsAsset, {
53
- publicPath: configComponentsWebpackAsset.output.publicPath,
59
+ devMiddleware(compilerComponentsAsset, {
60
+ publicPath: configComponentsAsset.output.publicPath,
54
61
  writeToDisk: true,
55
62
  stats: { colors: true },
56
63
  })
57
64
  )
65
+ // webpack-hot-middleware still provides the browser HMR client + /__webpack_hmr endpoint;
66
+ // it works with the Rspack compiler without needing the webpack package.
58
67
  app.use(
59
68
  webpackHotMiddleware(compilerComponentsAsset, {
60
- log: console.log,
69
+ log: false,
61
70
  path: "/__webpack_hmr",
62
71
  heartbeat: 10 * 1000,
63
72
  })
@@ -86,12 +95,23 @@ app.use(cookieParser())
86
95
  app.use(bodyParser.json())
87
96
  // Connect all our routes to our application
88
97
  app.use(configMiddleware)
98
+
99
+ if (isLiveReloadEnabled()) {
100
+ const themePath = `${currentPath}/themes/${config.theme}`
101
+ const liveReload = createLiveReloadHub({ themePath })
102
+ app.locals.liveReload = liveReload
103
+ app.get(LIVE_RELOAD_PATH, liveReload.handle)
104
+ console.log(
105
+ `Live reload enabled (opt-in): SSE ${LIVE_RELOAD_PATH} — use for app-builder preview refresh`
106
+ )
107
+ }
108
+
89
109
  app.use("/", routes)
90
- const server = app.listen(port, () =>
110
+ const onListening = () =>
91
111
  console.log(
92
112
  `AppDirect Toolkit is running, you can view your storefront preview at: http://localhost:${port}/en-US/home`
93
113
  )
94
- )
114
+ const server = host ? app.listen(port, host, onListening) : app.listen(port, onListening)
95
115
  server.on("error", (err) => {
96
116
  switch (err.errno) {
97
117
  case "EADDRINUSE":