at-builder 1.4.3 → 1.4.5

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.
@@ -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.5",
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(){
@@ -1,76 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm run *)",
5
- "Bash(npm install *)",
6
- "Bash(/Users/upesenga/Documents/Projects/AT/at-builder/node_modules/.bin/tsc *)",
7
- "Bash(node /Users/upesenga/Documents/Projects/AT/at-builder/bin/index.js)",
8
- "Bash(node /Users/upesenga/Documents/Projects/AT/at-builder/bin/index.js --help)",
9
- "Bash(node /Users/upesenga/Documents/Projects/AT/at-builder/bin/index.js sync --help)",
10
- "Bash(node /Users/upesenga/Documents/Projects/AT/at-builder/bin/index.js deploy --help)",
11
- "Bash(node --check /Users/upesenga/Documents/Projects/AT/at-builder/lib/at-deploy.js)",
12
- "Bash(node --check /Users/upesenga/Documents/Projects/AT/at-builder/lib/at-sync.js)",
13
- "Bash(node --check /Users/upesenga/Documents/Projects/AT/at-builder/webpack.config.js)",
14
- "Bash(node *)",
15
- "Bash(plop --help)",
16
- "Bash(plop page *)",
17
- "Bash(git rev-list *)",
18
- "Bash(PATH=/dev/null node /Users/upesenga/Documents/Projects/AT/at-builder/bin/index.js install-extension)",
19
- "Bash(git commit -m 'chore: drop broken postinstall reference, ignore test/ sandbox *)",
20
- "Bash(git commit -m 'fix\\(plop\\): random windowFlagName per activity *)",
21
- "Bash(git commit -m 'feat: doctor build.config validation, .env consolidation, install-extension command *)",
22
- "Bash(git commit -m 'docs: document local-dev workflow \\(yarn link + npm pack\\) *)",
23
- "Bash(git fetch *)",
24
- "Bash(git check-ignore *)",
25
- "Bash(git commit -m 'docs: move local-dev guide to standalone DEVELOPMENT.md *)",
26
- "Bash(git add *)",
27
- "Bash(atb --version)",
28
- "Bash(atb --help)",
29
- "Bash(tar tzf *)",
30
- "Bash(npm ls *)",
31
- "Bash(/usr/local/bin/atb --version)",
32
- "Bash(grep -E \"\\(at-deploy|at-sync|index\\\\.js|\\\\.vsix|package\\\\.json\\)$\")",
33
- "Bash(npm pack *)",
34
- "Bash(tar xzf *)",
35
- "Bash(tar xzOf at-builder-1.3.0.tgz package/package.json)",
36
- "Bash(git commit -m '1.3.0 *)",
37
- "Read(//usr/local/lib/node_modules/at-builder/bin/**)",
38
- "Read(//Users/upesenga/.nvm/versions/node/v22.12.0/lib/node_modules/at-builder/bin/**)",
39
- "Read(//usr/local/share/.config/yarn/link/**)",
40
- "Bash(npm uninstall *)",
41
- "Bash(/Users/upesenga/.nvm/versions/node/v22.12.0/bin/atb --version)",
42
- "Bash(/Users/upesenga/.nvm/versions/node/v22.12.0/bin/atb --help)",
43
- "Bash(/Users/upesenga/.nvm/versions/node/v22.12.0/lib/node_modules/at-builder/bin/index.js --version)",
44
- "Bash(tar xzOf /Users/upesenga/Documents/Projects/AT/at-builder/at-builder-1.3.0.tgz package/package.json)",
45
- "Bash(npm config *)",
46
- "Bash(npm cache *)",
47
- "Bash(git commit -m 'docs: capture two install-time gotchas hit during 1.3.0 verification *)",
48
- "Bash(kill %1)",
49
- "Bash(git commit -m 'fix\\(eslint-plugin\\): pass overrideConfigFile: true so build doesn'\\\\''t require consumer eslint.config.js *)",
50
- "Bash(yarn global *)",
51
- "Bash(ls -la \"$\\(yarn global bin\\)/atb\")",
52
- "Bash(ls -la \"$\\(yarn global dir \\)/node_modules/at-builder\")",
53
- "Bash(git commit -m 'fix: surface ESLint error detail and clean up atb deploy build-failure exit *)",
54
- "Bash(git commit -m 'fix\\(webpack\\): emit correct `variation=` attribute on at-build.html script tag *)",
55
- "Bash(yarn install *)",
56
- "Bash(git rm *)",
57
- "Bash(git commit -m 'chore\\(deps\\): drop unused/deprecated deps + migrate qs to URLSearchParams *)",
58
- "Bash(git commit -m 'fix\\(config\\): stop printing red \"Error reading .env\" on every atb invocation *)",
59
- "Bash(yarn why *)",
60
- "Bash(git commit -m 'fix\\(plop\\): trim whitespace on all atb new text prompts *)",
61
- "Bash(atb install-extension *)",
62
- "Bash(git commit -m 'feat\\(install-extension\\): first-class support for Antigravity IDE \\(agy\\) *)",
63
- "Bash(npm whoami *)",
64
- "Bash(npm view *)",
65
- "Bash(git tag *)",
66
- "Bash(git push *)",
67
- "Bash(npm publish *)",
68
- "Bash(git commit -m 'feat\\(eslint\\): honor consumer .eslintrc.* via FlatCompat *)",
69
- "Bash(atb build *)",
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
- "Bash(grep -oE \"\\\\\\([a-z-]+\\\\\\)$\")",
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 *)"
74
- ]
75
- }
76
- }
package/.plop/index.js DELETED
@@ -1,5 +0,0 @@
1
- const components = require("./generators/components");
2
-
3
- module.exports = function (plop) {
4
- plop.setGenerator('components', components );
5
- };
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * A custom Webpack plugin to wrap bundled assets with a header and footer.
5
- */
6
- class CustomWrapperPlugin {
7
- /**
8
- * Creates an instance of CustomWrapperPlugin.
9
- * @param {object} options - The plugin options.
10
- * @param {RegExp} options.test - A regular expression to match file paths that should be wrapped.
11
- * @param {string|Function} [options.header=''] - The content to prepend to the file. Can be a string or a function that returns a string.
12
- * @param {string|Function} [options.footer=''] - The content to append to the file. Can be a string or a function that returns a string.
13
- */
14
- constructor(options) {
15
- this.options = options || {};
16
- }
17
-
18
- /**
19
- * Applies the plugin to the Webpack compiler.
20
- * @param {import('webpack').Compiler} compiler - The Webpack compiler instance.
21
- */
22
- apply(compiler) {
23
- const pluginName = this.constructor.name;
24
- const { webpack } = compiler;
25
- const { Compilation } = webpack;
26
-
27
- compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
28
- compilation.hooks.processAssets.tap(
29
- {
30
- name: pluginName,
31
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
32
- },
33
- (assets) => {
34
- for (const pathname in assets) {
35
- if (this.options.test && this.options.test.test(pathname)) {
36
- const asset = compilation.getAsset(pathname);
37
- const source = asset.source.source();
38
- const args = { hash: compilation.hash };
39
-
40
- const wrappedSource =
41
- (typeof this.options.header === 'function'
42
- ? this.options.header(source, args)
43
- : this.options.header || '') +
44
- source +
45
- (typeof this.options.footer === 'function'
46
- ? this.options.footer(source, args)
47
- : this.options.footer || '');
48
-
49
- compilation.updateAsset(
50
- pathname,
51
- new webpack.sources.RawSource(wrappedSource)
52
- );
53
- }
54
- }
55
- }
56
- );
57
- });
58
- }
59
- }
60
-
61
- export default CustomWrapperPlugin;
@@ -1,86 +0,0 @@
1
- {
2
- "name": "at-builder",
3
- "version": "1.3.0",
4
- "main": "bin/index.js",
5
- "bin": {
6
- "atb": "bin/index.js"
7
- },
8
- "scripts": {
9
- "build:atb": "tsc",
10
- "build:atb:dev": "tsc -w",
11
- "atb:build:prod": "cross-env NODE_ENV=production webpack",
12
- "atb:build:dev": "webpack -- -w",
13
- "atb:build:dev:puppeteer": "webpack -- -w & npm run atb:puppeteer",
14
- "atb:puppeteer": "node puppeteer.js $b",
15
- "atb:plop:new:activity": "plop page",
16
- "atb:build:deploy": "node lib/at-deploy.js",
17
- "atb:build:sync": "node lib/at-sync.js"
18
- },
19
- "author": "Upendra Sengar <upendrasengar456@gmail.com>",
20
- "license": "MIT",
21
- "dependencies": {
22
- "@babel/core": "^7.26.9",
23
- "@babel/eslint-parser": "^7.26.8",
24
- "@babel/plugin-proposal-class-properties": "^7.18.6",
25
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
26
- "@babel/plugin-transform-runtime": "^7.18.9",
27
- "@babel/preset-env": "^7.18.9",
28
- "@babel/preset-react": "^7.18.6",
29
- "@eslint/js": "^9.20.0",
30
- "@types/node": "^22.13.2",
31
- "async": "^3.2.3",
32
- "axios": "^1.12.2",
33
- "babel-loader": "^9.2.1",
34
- "babel-plugin-transform-async-to-generator": "^6.24.1",
35
- "build": "^0.1.4",
36
- "chokidar": "^4.0.3",
37
- "cli-color": "^2.0.3",
38
- "commander": "^13.1.0",
39
- "cross-env": "^7.0.3",
40
- "css-loader": "^7.1.2",
41
- "dotenv": "16.4.5",
42
- "eslint": "^9.20.1",
43
- "eslint-webpack-plugin": "^4.2.0",
44
- "globals": "^15.15.0",
45
- "inquirer": "^12.4.1",
46
- "kleur": "^4.1.5",
47
- "plop": "^4.0.1",
48
- "postcss": "^8.4.12",
49
- "postcss-loader": "^8.1.1",
50
- "postcss-preset-env": "^10.1.4",
51
- "puppeteer": "^24.2.0",
52
- "querystring": "^0.2.1",
53
- "readline": "^1.3.0",
54
- "sass": "^1.53.0",
55
- "sass-loader": "^16.0.4",
56
- "style-loader": "^4.0.0",
57
- "terser-webpack-plugin": "^5.3.3",
58
- "ts-loader": "^9.3.1",
59
- "typescript": "^5.7.3",
60
- "typescript-eslint": "^8.24.1",
61
- "webpack": "^5.72.0",
62
- "webpack-cli": "^6.0.1",
63
- "wrapper-webpack-plugin": "^2.1.0"
64
- },
65
- "description": "[![npm version](https://badge.fury.io/js/at-builder.svg)](https://www.npmjs.com/package/at-builder) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)",
66
- "directories": {
67
- "lib": "lib",
68
- "test": "test"
69
- },
70
- "devDependencies": {
71
- "@babel/runtime": "^7.29.2"
72
- },
73
- "repository": {
74
- "type": "git",
75
- "url": "git+https://github.com/upesenga/at-builder.git"
76
- },
77
- "keywords": [],
78
- "bugs": {
79
- "url": "https://github.com/upesenga/at-builder/issues"
80
- },
81
- "homepage": "https://github.com/upesenga/at-builder#readme",
82
- "engines": {
83
- "node": ">=16.0.0"
84
- },
85
- "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
86
- }