at-builder 1.4.3 → 1.4.4

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.
@@ -70,7 +70,8 @@
70
70
  "Bash(ACTIVITY_FOLDER_NAME=\"UPSDDO - 7313 - AB-26.3.1 - Left Hand Navigation With Flyout - Dashboard - EWS - FWS - Tracking - Support Portal - Billing - Pickup - Claims\" atb build --prod)",
71
71
  "Bash(grep -oE \"\\\\\\([a-z-]+\\\\\\)$\")",
72
72
  "Bash(awk '/^ERROR in/{flag=1; next} /^WARNING in/{flag=0; next} flag')",
73
- "Bash(git commit -m 'fix\\(eslint\\): honor consumer ESLint config as sole authority + 2 FlatCompat bugs *)"
73
+ "Bash(git commit -m 'fix\\(eslint\\): honor consumer ESLint config as sole authority + 2 FlatCompat bugs *)",
74
+ "Bash(git commit -m 'feat\\(wrapper\\): configurable TARGET_BUILD_PREFIX + per-asset contentHash in window flag *)"
74
75
  ]
75
76
  }
76
77
  }
@@ -119,7 +119,7 @@ var setupEnv = function (basePath) { return __awaiter(void 0, void 0, void 0, fu
119
119
  envPath = path_1.default.join(basePath, '.env');
120
120
  // Check if the .env file exists
121
121
  if (!fs_1.default.existsSync(envPath)) {
122
- envContent = "\nACTIVITIES_BASE_FOLDER=\"Activities\"\nACTIVITY_FOLDER_NAME=\"\"\nPUPPETEER_LANDING_PAGE=\"\"\nTARGET_URL=\"\"\nLOGIN_URL=\"\"\n\n# Dev-server selection (used by `atb dev --browser`).\n# Edit and save while puppeteer is running to hot-swap the previewed bundle.\n# PAGE is only meaningful for multi-page activities \u2014 leave empty otherwise.\nVARIATION=\"Variation-1\"\nPAGE=\"\"\n\nNODE_ENV=\"development\"\nVERBOSE=false\n\n# Adobe Target Deployment Configuration\n# ADOBE_TENANT is your AT tenant slug \u2014 find it in the AT URL after \"mc.adobe.io/\".\nADOBE_TENANT=\"\"\nADOBE_CLIENT_ID=\"\"\nADOBE_CLIENT_SECRET=\"\"\n ";
122
+ envContent = "\nACTIVITIES_BASE_FOLDER=\"Activities\"\nACTIVITY_FOLDER_NAME=\"\"\nPUPPETEER_LANDING_PAGE=\"\"\nTARGET_URL=\"\"\nLOGIN_URL=\"\"\n\n# Dev-server selection (used by `atb dev --browser`).\n# Edit and save while puppeteer is running to hot-swap the previewed bundle.\n# PAGE is only meaningful for multi-page activities \u2014 leave empty otherwise.\nVARIATION=\"Variation-1\"\nPAGE=\"\"\n\nNODE_ENV=\"development\"\nVERBOSE=false\n\n# Build wrapper config.\n# TARGET_BUILD_PREFIX customizes the window flag baked into each build \u2014\n# rendered as window.${TARGET_BUILD_PREFIX}_${contentHash}_${hash}. Defaults\n# to \"TargetBuild\" when empty. Useful when multiple at-builder activities\n# end up loaded on the same page and you want each project's flag namespaced.\nTARGET_BUILD_PREFIX=\"\"\n\n# Adobe Target Deployment Configuration\n# ADOBE_TENANT is your AT tenant slug \u2014 find it in the AT URL after \"mc.adobe.io/\".\nADOBE_TENANT=\"\"\nADOBE_CLIENT_ID=\"\"\nADOBE_CLIENT_SECRET=\"\"\n ";
123
123
  // Write the content to the .env file
124
124
  fs_1.default.writeFileSync(envPath, envContent.trim(), 'utf8');
125
125
  console.log('.env file created successfully!');
@@ -655,7 +655,7 @@ var createEnvFile = function (projectPath) { return __awaiter(void 0, void 0, vo
655
655
  var envPath, envContent;
656
656
  return __generator(this, function (_a) {
657
657
  envPath = path_1.default.join(projectPath, '.env');
658
- envContent = "ACTIVITIES_BASE_FOLDER=\"Activities\"\nACTIVITY_FOLDER_NAME=\"\"\nPUPPETEER_LANDING_PAGE=\"\"\nTARGET_URL=\"\"\nLOGIN_URL=\"\"\n\n# Dev-server selection (used by `atb dev --browser`).\n# Edit and save while puppeteer is running to hot-swap the previewed bundle.\n# PAGE is only meaningful for multi-page activities \u2014 leave empty otherwise.\nVARIATION=\"Variation-1\"\nPAGE=\"\"\n\nNODE_ENV=\"development\"\nVERBOSE=false\n\n# Adobe Target Deployment Configuration\n# ADOBE_TENANT is your AT tenant slug \u2014 find it in the AT URL after \"mc.adobe.io/\".\nADOBE_TENANT=\"\"\nADOBE_CLIENT_ID=\"\"\nADOBE_CLIENT_SECRET=\"\"";
658
+ envContent = "ACTIVITIES_BASE_FOLDER=\"Activities\"\nACTIVITY_FOLDER_NAME=\"\"\nPUPPETEER_LANDING_PAGE=\"\"\nTARGET_URL=\"\"\nLOGIN_URL=\"\"\n\n# Dev-server selection (used by `atb dev --browser`).\n# Edit and save while puppeteer is running to hot-swap the previewed bundle.\n# PAGE is only meaningful for multi-page activities \u2014 leave empty otherwise.\nVARIATION=\"Variation-1\"\nPAGE=\"\"\n\nNODE_ENV=\"development\"\nVERBOSE=false\n\n# Build wrapper config.\n# TARGET_BUILD_PREFIX customizes the window flag baked into each build \u2014\n# rendered as window.${TARGET_BUILD_PREFIX}_${contentHash}_${hash}. Defaults\n# to \"TargetBuild\" when empty. Useful when multiple at-builder activities\n# end up loaded on the same page and you want each project's flag namespaced.\nTARGET_BUILD_PREFIX=\"\"\n\n# Adobe Target Deployment Configuration\n# ADOBE_TENANT is your AT tenant slug \u2014 find it in the AT URL after \"mc.adobe.io/\".\nADOBE_TENANT=\"\"\nADOBE_CLIENT_ID=\"\"\nADOBE_CLIENT_SECRET=\"\"";
659
659
  try {
660
660
  fs_1.default.writeFileSync(envPath, envContent, 'utf8');
661
661
  return [2 /*return*/, true];
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const crypto = require('crypto');
4
+
3
5
  /**
4
6
  * A custom Webpack plugin to wrap bundled assets with a header and footer.
5
7
  */
@@ -35,7 +37,22 @@ class CustomWrapperPlugin {
35
37
  if (this.options.test && this.options.test.test(pathname)) {
36
38
  const asset = compilation.getAsset(pathname);
37
39
  const source = asset.source.source();
38
- const args = { hash: compilation.hash };
40
+ // contentHash is derived from the asset's source so
41
+ // it changes whenever the bundled output changes,
42
+ // independent of the compilation-wide `hash`. Both
43
+ // are exposed so consumers can reference either or
44
+ // combine them (e.g. for a window-flag id that's
45
+ // unique per-asset AND per-build).
46
+ const contentHash = crypto
47
+ .createHash('md5')
48
+ .update(typeof source === 'string' ? source : Buffer.from(source))
49
+ .digest('hex')
50
+ .slice(0, 20);
51
+ const args = {
52
+ hash: compilation.hash,
53
+ contentHash,
54
+ pathname
55
+ };
39
56
 
40
57
  const wrappedSource =
41
58
  (typeof this.options.header === 'function'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "at-builder",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "main": "bin/index.js",
5
5
  "bin": {
6
6
  "atb": "bin/index.js"
@@ -157,6 +157,13 @@ PAGE=""
157
157
  NODE_ENV="development"
158
158
  VERBOSE=false
159
159
 
160
+ # Build wrapper config.
161
+ # TARGET_BUILD_PREFIX customizes the window flag baked into each build —
162
+ # rendered as window.\${TARGET_BUILD_PREFIX}_\${contentHash}_\${hash}. Defaults
163
+ # to "TargetBuild" when empty. Useful when multiple at-builder activities
164
+ # end up loaded on the same page and you want each project's flag namespaced.
165
+ TARGET_BUILD_PREFIX=""
166
+
160
167
  # Adobe Target Deployment Configuration
161
168
  # ADOBE_TENANT is your AT tenant slug — find it in the AT URL after "mc.adobe.io/".
162
169
  ADOBE_TENANT=""
@@ -558,6 +558,13 @@ PAGE=""
558
558
  NODE_ENV="development"
559
559
  VERBOSE=false
560
560
 
561
+ # Build wrapper config.
562
+ # TARGET_BUILD_PREFIX customizes the window flag baked into each build —
563
+ # rendered as window.\${TARGET_BUILD_PREFIX}_\${contentHash}_\${hash}. Defaults
564
+ # to "TargetBuild" when empty. Useful when multiple at-builder activities
565
+ # end up loaded on the same page and you want each project's flag namespaced.
566
+ TARGET_BUILD_PREFIX=""
567
+
561
568
  # Adobe Target Deployment Configuration
562
569
  # ADOBE_TENANT is your AT tenant slug — find it in the AT URL after "mc.adobe.io/".
563
570
  ADOBE_TENANT=""
package/webpack.config.js CHANGED
@@ -222,8 +222,17 @@ const plugins = [
222
222
  new WrapperPlugin({
223
223
  test: /\.js$/,
224
224
  header: function (_, args) {
225
- //Handle target issue for reloading the styles.
226
- let _uniqueTestId = `TargetBuild_${args.hash}`;
225
+ // The window flag has to be unique per build so a fresh injection
226
+ // doesn't no-op against a stale flag from the previous version.
227
+ // Includes both contentHash (asset-content scoped) and hash
228
+ // (compilation scoped) so it changes whenever either does.
229
+ //
230
+ // Prefix is configurable per project via TARGET_BUILD_PREFIX in .env
231
+ // (defaults to "TargetBuild") — useful when multiple at-builder
232
+ // activities load on the same page and you want each one's flag
233
+ // namespaced.
234
+ const prefix = (process.env.TARGET_BUILD_PREFIX || 'TargetBuild').trim() || 'TargetBuild';
235
+ const _uniqueTestId = `${prefix}_${args.contentHash}_${args.hash}`;
227
236
  args._uniqueTestId = _uniqueTestId;
228
237
  return `
229
238
  (function(){