at-builder 1.2.3 → 1.2.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.
@@ -11,10 +11,8 @@ const fs = require('fs');
11
11
  * @returns {Array} - Array of actions that plop needs to perform
12
12
  */
13
13
  exports.actionHandler = (data) => {
14
- let { executionPath } = process.env;
15
14
  let actions = [];
16
15
  let fileName = '';
17
- let componentType = '';
18
16
  let folderName = '';
19
17
  let testPath = '';
20
18
  let numberOfVariations;
@@ -30,44 +28,52 @@ exports.actionHandler = (data) => {
30
28
  { 'global': true, 'path': `${testPath}/Vanalytics/analytics.js`, 'templateFile': `${TEMPLATE_DIR}/analytics.hbs`, variation },
31
29
  { 'global': false, 'path': `${folderName}/constants/index.js`, 'templateFile': `${TEMPLATE_DIR}/constants.hbs`, variation },
32
30
  { 'global': false, 'path': `${folderName}/scripts/app.js`, 'templateFile': `${TEMPLATE_DIR}/component.cb.hbs`, variation },
33
- { 'global': false, 'path': `${folderName}/css/style.scss`, 'templateFile': `${TEMPLATE_DIR}/style.hbs`, variation }
31
+ { 'global': false, 'path': `${folderName}/css/style.scss`, 'templateFile': `${TEMPLATE_DIR}/style.hbs`, variation },
32
+ { 'global': true, 'path': `${testPath}/shared/build.config.json`, 'templateFile': `${TEMPLATE_DIR}/build.config.hbs`, variation }
34
33
  ];
35
34
  }
36
35
 
37
- // Get the track path from the environment variable
38
- trackName = executionPath + "/Activities";
39
- // trackName = path.join(fs.readFileSync(path.join(process.cwd(), 'sample.txt'), { flag: 'r' }).toString(), 'Activities');
36
+ // Get the activities path from environment variables (same approach as webpack config)
37
+ const PWD = process.env.executionPath || process.cwd();
38
+ console.log(`šŸ“ Using ACTIVITIES_BASE_FOLDER directory: ${process.env.executionPath}`);
39
+ const ACTIVITIES_BASE_FOLDER = process.env.ACTIVITIES_BASE_FOLDER || 'Activities';
40
+ trackName = path.join(PWD, ACTIVITIES_BASE_FOLDER);
41
+
42
+ // Log the activities path for debugging
43
+ console.log(`šŸ“ Using activities directory: ${trackName}`);
44
+
45
+ // Ensure the activities directory exists
46
+ if (!fs.existsSync(trackName)) {
47
+ fs.mkdirSync(trackName, { recursive: true });
48
+ console.log(`šŸ“ Created activities directory: ${trackName}`);
49
+ }
40
50
 
41
51
  // Convert the name to camel case
42
52
  fileName = toCamelCase(name);
43
53
 
44
54
  // Get the number of variations from the user
45
55
  numberOfVariations = parseInt(variationName);
46
-
56
+
47
57
  let constantMappingFile = null;
48
58
 
49
59
  // If the user has provided track name and test name and variation name
50
60
  if (trackName && testName && variationName) {
51
61
  // Get the current year
52
- let year = new Date().getFullYear();
53
- // testPath = trackName + `/${year}/` + testName;
54
62
  testPath = trackName + `/${testName}`;
55
63
  // Get the constant mapping
56
64
  constantMappingFile = assignConstants();
57
65
  // Convert the name to pascal case
58
66
  fileName = toPascalCase(name);
59
- // Set the component type
60
- componentType = TEMPLATE_TYPE_SUFFIX_CLASS_BASED;
61
67
  }
62
68
 
63
69
  // Create actions for the global files
64
70
  createActionObject(true);
65
71
 
66
-
72
+
67
73
 
68
74
  // Loop through the number of variations provided by the user
69
75
  let i = 1;
70
-
76
+
71
77
  do {
72
78
  // Get the variation name
73
79
  let variation = "Variation-" + i;
@@ -111,9 +117,70 @@ exports.actionHandler = (data) => {
111
117
  });
112
118
  }
113
119
 
120
+ // Update .env file with the new activity name
121
+ updateEnvFile(testName);
114
122
 
123
+ // Show completion message
124
+ console.log(`\nšŸŽ‰ Activity "${testName}" created successfully!`);
125
+ console.log(`šŸ“ Location: ${testPath}`);
126
+ console.log(`šŸ“‹ Number of variations: ${numberOfVariations}`);
127
+ console.log(`šŸ”§ ACTIVITY_FOLDER_NAME updated in .env file`);
128
+ console.log(`\nšŸ’” Run "atb build" to build your activity`);
129
+ console.log(`šŸ’” Run "atb doctor" to check your configuration`);
115
130
 
116
131
  // Return the actions
117
132
  return actions;
118
133
  }
119
134
 
135
+ /**
136
+ * Updates the .env file with the new activity folder name
137
+ * @param {string} activityName - The name of the activity to set in ACTIVITY_FOLDER_NAME
138
+ */
139
+ function updateEnvFile(activityName) {
140
+ const PWD = process.env.executionPath || process.cwd();
141
+ const envPath = path.join(PWD, '.env');
142
+
143
+ if (!fs.existsSync(envPath)) {
144
+ console.log('āš ļø .env file not found, skipping ACTIVITY_FOLDER_NAME update');
145
+ console.log('šŸ’” Run "atb init" to create .env file');
146
+ return;
147
+ }
148
+
149
+ if (!activityName || activityName.trim() === '') {
150
+ console.log('āš ļø Activity name is empty, skipping .env update');
151
+ return;
152
+ }
153
+
154
+ try {
155
+ // Read the current .env file
156
+ let envContent = fs.readFileSync(envPath, 'utf8');
157
+
158
+ // Clean activity name (remove quotes if present)
159
+ const cleanActivityName = activityName.trim().replace(/^["']|["']$/g, '');
160
+
161
+ // Update or add ACTIVITY_FOLDER_NAME
162
+ const activityFolderRegex = /^ACTIVITY_FOLDER_NAME=.*$/m;
163
+ const newLine = `ACTIVITY_FOLDER_NAME="${cleanActivityName}"`;
164
+
165
+ if (activityFolderRegex.test(envContent)) {
166
+ // Update existing line
167
+ envContent = envContent.replace(activityFolderRegex, newLine);
168
+ console.log(`āœ… Updated ACTIVITY_FOLDER_NAME to "${cleanActivityName}" in .env file`);
169
+ } else {
170
+ // Add new line if it doesn't exist, ensure it ends with newline
171
+ if (!envContent.endsWith('\n')) {
172
+ envContent += '\n';
173
+ }
174
+ envContent += newLine;
175
+ console.log(`āœ… Added ACTIVITY_FOLDER_NAME="${cleanActivityName}" to .env file`);
176
+ }
177
+
178
+ // Write the updated content back to .env file
179
+ fs.writeFileSync(envPath, envContent, 'utf8');
180
+
181
+ } catch (error) {
182
+ console.error(`āŒ Error updating .env file: ${error.message}`);
183
+ console.log('šŸ’” You may need to manually set ACTIVITY_FOLDER_NAME in your .env file');
184
+ }
185
+ }
186
+
@@ -5,8 +5,16 @@
5
5
  * Mutation observer initialize
6
6
  */
7
7
 
8
- var observer = new MutationObserver(function (mutations) {
9
-
8
+ const observer = new MutationObserver(function (mutations) {
9
+ mutations.forEach(function (mutation) {
10
+ if (mutation.addedNodes.length) {
11
+ mutation.addedNodes.forEach(function (node) {
12
+ if (node.classList) {
13
+ // do something
14
+ }
15
+ });
16
+ }
17
+ });
10
18
  });
11
19
 
12
20
  // observing now
@@ -19,5 +27,7 @@
19
27
  window.{{windowFlagName}} = true;
20
28
  }
21
29
  }
22
- catch(err){}
30
+ catch (err){
31
+ console.log(err);
32
+ }
23
33
  }());
@@ -0,0 +1,7 @@
1
+ {
2
+ "activityInfo": {
3
+ "id": null,
4
+ "name": "",
5
+ "variations": {}
6
+ }
7
+ }
@@ -1,34 +1,79 @@
1
- {{!-- import { Observer } from '../../../../.globals/services/observer';
2
- import { logger } from '../../../../.globals/services/logger';
3
- import { GetDOMElement } from '../../../../.globals/services/domHandler'; --}}
4
- {{!-- import * as CONSTANTS from '../constants'; --}}
1
+ // import * as CONSTANTS from '../constants';
5
2
 
6
3
  export class App {
7
-
8
4
  /**
9
- * @param define constructor properties
5
+ * @param define constructor properties
10
6
  */
11
- constructor(){
12
- {{!-- this.domHandler = GetDOMElement;
13
- this.loggerService = logger; --}}
14
- };
7
+ constructor() {
8
+ this.state = {}; // For managing app state
9
+ }
15
10
 
16
11
  /**
17
- * Executes on load of the test , observer is initialised
12
+ * Initializes the application, sets up observer and logs the event
18
13
  */
19
14
  init = () => {
20
- {{!-- this.observer = new Observer();
21
- this.observer.setObserver(this.callback); --}}
15
+ this.isRunning = true;
16
+ this.onStart();
17
+ }
18
+
19
+ /**
20
+ * Starts the app or app-specific functionality
21
+ */
22
+ onStart = () => {
23
+ // Additional initialization logic (e.g., setting up listeners, data fetching)
24
+ }
25
+
26
+ /**
27
+ * Reset the app to its initial state
28
+ */
29
+ reset = () => {
30
+ this.state = {}; // Reset state
31
+ this.onStart(); // Optionally restart app functionality
22
32
  }
23
33
 
24
34
  /**
25
- * Disconnet mutation observer , clear any window variable or perform cleanup activity
35
+ * Disconnect mutation observer , clear any window variable or perform cleanup activity
26
36
  */
27
- destroy(){};
28
-
37
+ destroy = () => {
38
+ }
39
+
40
+ /**
41
+ * Handles errors that occur within the app
42
+ * @param {string} message - Error message to log
43
+ * @param {Error} error - Optional error object
44
+ */
45
+ handleError = (message, error = null) => {
46
+ // Additional error handling (e.g., sending error details to a server)
47
+ }
48
+
49
+ /**
50
+ * Logs app's current state
51
+ */
52
+ logState = () => {
53
+ }
54
+
55
+ /**
56
+ * Sets or updates a property in the app's state
57
+ * @param {string} key - The key of the state property
58
+ * @param {any} value - The value to set
59
+ */
60
+ setState = (key, value) => {
61
+ this.state[key] = value;
62
+ }
63
+
64
+ /**
65
+ * Gets a property from the app's state
66
+ * @param {string} key - The key of the state property
67
+ * @returns {any} - The value of the state property
68
+ */
69
+ getState = (key) => {
70
+ return this.state[key];
71
+ }
72
+
29
73
  /**
30
74
  * Mutation Observer Callback
31
75
  */
32
76
  callback = () => {
77
+ // Callback logic for mutation observer
33
78
  }
34
79
  }
@@ -58,4 +58,4 @@ class CustomWrapperPlugin {
58
58
  }
59
59
  }
60
60
 
61
- module.exports = CustomWrapperPlugin;
61
+ export default CustomWrapperPlugin;
package/README.md CHANGED
@@ -3,14 +3,20 @@
3
3
  [![npm version](https://badge.fury.io/js/at-builder.svg)](https://www.npmjs.com/package/at-builder)
4
4
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
5
 
6
- `at-builder` is a simple command-line tool designed to streamline Adobe Target activity creation and building processes.
6
+ A streamlined command-line tool for creating, building, and deploying Adobe Target A/B testing activities with modern web technologies.
7
7
 
8
8
  ---
9
9
 
10
- ## **Features**
10
+ ## **šŸŽÆ Features**
11
11
 
12
- - šŸ”§ **Prod Build**: Build target ready code in your local and ship to any target activity.
13
- - šŸš€ **Help Information**: Get detailed instructions on available commands and usage directly from the CLI.
12
+ - šŸ—ļø **Project Initialization**: Set up new projects with complete configuration
13
+ - šŸŽØ **Activity Templates**: Generate new activities with customizable variations
14
+ - ⚔ **Smart Building**: Development and production builds with hot reload
15
+ - šŸš€ **Adobe Target Deployment**: Direct deployment to Adobe Target activities
16
+ - 🩺 **Health Diagnostics**: Automatic configuration validation and fixing
17
+ - šŸ“ **Flexible Structure**: Configurable activities folder structure
18
+ - šŸ”§ **Environment Management**: Automatic .env file handling
19
+ - šŸ’» **Modern Toolchain**: TypeScript, Webpack, Babel, SCSS support
14
20
 
15
21
  ---
16
22
 
@@ -24,73 +30,244 @@ npm install -g at-builder
24
30
 
25
31
  ---
26
32
 
27
- ## **Usage**
33
+ ## **šŸš€ Quick Start**
28
34
 
29
- Run the command-line tool:
35
+ 1. **Initialize a new project:**
36
+ ```bash
37
+ atb init
38
+ ```
39
+
40
+ 2. **Create a new activity:**
41
+ ```bash
42
+ atb new
43
+ ```
30
44
 
45
+ 3. **Build your activity:**
31
46
  ```bash
32
- atb
47
+ atb build
33
48
  ```
34
49
 
35
- ### **Available Commands**
50
+ 4. **Deploy to Adobe Target:**
51
+ ```bash
52
+ atb deploy
53
+ ```
36
54
 
37
- - **`new`**: Creates a new activity.
38
- - **`build`**: Creates a build.
55
+ ---
56
+
57
+ ## **šŸ“‹ Commands Reference**
58
+
59
+ ### **Core Commands**
60
+
61
+ | Command | Description | Options |
62
+ |---------|-------------|---------|
63
+ | `atb init` | Initialize project with configuration files | |
64
+ | `atb new` | Create new Adobe Target activity with variations | |
65
+ | `atb build` | Build activity for development | `--prod` for production |
66
+ | `atb dev` | Start development server with file watching | `--browser` to open browser |
67
+ | `atb deploy` | Deploy activity to Adobe Target | `--dry-run` for testing |
68
+ | `atb doctor` | Diagnose and fix configuration issues | `--fix` to auto-fix |
39
69
 
40
70
  ### **Examples**
41
71
 
42
72
  ```bash
43
- # Create a new activity
44
- atb -c new
73
+ # Initialize new project
74
+ atb init
75
+
76
+ # Create new activity
77
+ atb new
78
+
79
+ # Development build with hot reload
80
+ atb build
81
+
82
+ # Production build for Adobe Target
83
+ atb build --prod
84
+
85
+ # Development server with browser
86
+ atb dev --browser
45
87
 
46
- # Build the project
47
- atb -c build
88
+ # Deploy to Adobe Target
89
+ atb deploy
48
90
 
49
- # Build the project for target activity
50
- atb -p -c build
91
+ # Check project configuration
92
+ atb doctor
93
+
94
+ # Auto-fix configuration issues
95
+ atb doctor --fix
51
96
  ```
52
97
 
53
98
  ---
54
99
 
55
- ## **API Documentation**
100
+ ## **šŸ”§ Project Structure**
101
+
102
+ After initialization, your project will have:
103
+
104
+ ```
105
+ your-project/
106
+ ā”œā”€ā”€ .env # Environment configuration
107
+ ā”œā”€ā”€ adobe.config.js # Adobe Target API settings
108
+ ā”œā”€ā”€ watch-config.json # Build configuration
109
+ ā”œā”€ā”€ package.json # NPM configuration
110
+ └── Activities/ # Your activities folder
111
+ └── your-activity/ # Activity folder (auto-created)
112
+ ā”œā”€ā”€ Variation-1/ # Test variations
113
+ │ ā”œā”€ā”€ index.js # Entry point
114
+ │ ā”œā”€ā”€ css/
115
+ │ │ └── style.scss
116
+ │ ā”œā”€ā”€ scripts/
117
+ │ │ └── app.js
118
+ │ └── constants/
119
+ │ └── index.js
120
+ ā”œā”€ā”€ Vanalytics/ # Analytics tracking
121
+ └── shared/ # Shared configuration
122
+ ```
56
123
 
57
- ### **`getVersion()`**
124
+ ---
58
125
 
59
- - **Description**: Retrieves the version number from the `package.json` file.
60
- - **Returns**: *(string)* - The version number of the package.
126
+ ## **āš™ļø Configuration**
61
127
 
62
- #### **Example**
128
+ ### **Environment Variables (.env)**
129
+
130
+ ```bash
131
+ # Project Structure
132
+ ACTIVITIES_BASE_FOLDER="Activities"
133
+ ACTIVITY_FOLDER_NAME="your-activity-name"
134
+
135
+ # Development Settings
136
+ NODE_ENV="development"
137
+ PUPPETEER_LANDING_PAGE=""
138
+ TARGET_URL=""
139
+ LOGIN_URL=""
140
+ VARIATION="Variation-1"
141
+
142
+ # Adobe Target Deployment
143
+ ADOBE_CLIENT_ID="your-client-id"
144
+ ADOBE_CLIENT_SECRET="your-client-secret"
145
+ ```
146
+
147
+ ### **Adobe Target Configuration (adobe.config.js)**
63
148
 
64
149
  ```javascript
65
- const { getVersion } = require("at-builder");
150
+ module.exports = {
151
+ BASE_URL: 'https://mc.adobe.io/target/activities/',
152
+ IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v1',
153
+ IMS_SCOPE: 'openid,target_sdk'
154
+ };
155
+ ```
156
+
157
+ ---
158
+
159
+ ## **šŸ”„ Workflow**
160
+
161
+ 1. **Setup**: Run `atb init` to create project configuration
162
+ 2. **Create**: Run `atb new` to generate activity templates
163
+ 3. **Develop**: Modify variations in `/Activities/{name}/Variation-*/`
164
+ 4. **Test**: Run `atb build` for development testing
165
+ 5. **Build**: Run `atb build --prod` for production deployment
166
+ 6. **Deploy**: Run `atb deploy` to deploy to Adobe Target
66
167
 
67
- console.log(getVersion()); // Outputs the version number of the package
168
+ ---
169
+
170
+ ## **🩺 Troubleshooting**
171
+
172
+ ### **Health Check**
173
+ ```bash
174
+ # Diagnose configuration issues
175
+ atb doctor
176
+
177
+ # Automatically fix issues
178
+ atb doctor --fix
179
+ ```
180
+
181
+ ### **Common Issues**
182
+
183
+ - **Missing .env file**: Run `atb init` or `atb doctor --fix`
184
+ - **Build errors**: Check `ACTIVITY_FOLDER_NAME` in .env
185
+ - **Deploy failures**: Verify Adobe credentials in .env
186
+ - **Missing activity folder**: Create activity with `atb new`
187
+
188
+ ## **🚨 Advanced Configuration**
189
+
190
+ ### **Custom Activities Folder**
191
+
192
+ You can customize the activities folder location:
193
+
194
+ ```bash
195
+ # Use a different activities folder
196
+ ACTIVITIES_BASE_FOLDER="MyActivities"
197
+ ```
198
+
199
+ ### **Build Scripts Integration**
200
+
201
+ Add to your project's package.json:
202
+
203
+ ```json
204
+ {
205
+ "scripts": {
206
+ "build:target": "atb build --prod",
207
+ "deploy:target": "atb deploy",
208
+ "dev:target": "atb dev --browser"
209
+ }
210
+ }
68
211
  ```
69
212
 
70
- ### **`getHelpInfo()`**
213
+ ---
71
214
 
72
- - **Description**: Provides a string containing help information for the `atb` command-line tool.
73
- - **Returns**: *(string)* - The help information string.
215
+ ## **šŸ”Œ API Integration**
74
216
 
75
- #### **Example**
217
+ For programmatic usage:
76
218
 
77
219
  ```javascript
78
- const { getHelpInfo } = require("at-builder");
220
+ const { getVersion, getHelpInfo } = require("at-builder");
221
+
222
+ // Get version
223
+ console.log(getVersion());
79
224
 
225
+ // Get help information
80
226
  console.log(getHelpInfo());
81
- // Outputs detailed help information for the CLI tool
82
227
  ```
83
228
 
84
229
  ---
85
230
 
86
- ## **License**
231
+ ## **šŸ¤ Contributing**
232
+
233
+ 1. Fork the repository
234
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
235
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
236
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
237
+ 5. Open a Pull Request
238
+
239
+ ---
240
+
241
+ ## **šŸ“ Changelog**
242
+
243
+ ### v1.2.3
244
+ - ✨ Added `deploy` command for Adobe Target deployment
245
+ - 🩺 Added `doctor` command for configuration diagnostics
246
+ - šŸ”§ Automatic .env file updates when creating activities
247
+ - šŸ“ Configurable activities folder structure
248
+ - ⚔ Improved environment variable validation
249
+ - šŸš€ Enhanced error handling and user guidance
250
+
251
+ ### Previous Versions
252
+ - v1.2.2: Build improvements and bug fixes
253
+ - v1.2.1: Enhanced CLI interface
254
+ - v1.2.0: Initial public release
255
+
256
+ ---
257
+
258
+ ## **šŸ“„ License**
87
259
 
88
260
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
89
261
 
90
262
  ---
91
263
 
92
- ## **Support**
264
+ ## **šŸ†˜ Support**
265
+
266
+ - **Repository**: [https://github.com/upesenga/at-builder](https://github.com/upesenga/at-builder)
267
+ - **Issues**: [https://github.com/upesenga/at-builder/issues](https://github.com/upesenga/at-builder/issues)
268
+ - **Author**: Upendra Sengar
269
+ - **License**: MIT
93
270
 
94
- If you encounter any issues or have questions, feel free to email.
271
+ ---
95
272
 
96
- ---
273
+ **Made with ā¤ļø for Adobe Target developers**
@@ -183,14 +183,10 @@ const createAdobeConfig = (basePath) => {
183
183
  */
184
184
 
185
185
  module.exports = {
186
- // Adobe Target API base URL
187
- BASE_URL: 'https://mc.adobe.io/target/activities/',
188
-
189
- // Adobe IMS (Identity Management Services) token endpoint
190
- IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v1',
191
-
192
- // Required scopes for Adobe Target API access
193
- IMS_SCOPE: 'openid,target_sdk'
186
+ BASE_URL_NEW: 'https://mc.adobe.io/ups/target/',
187
+ BASE_URL: 'https://mc.adobe.io/ups/target/activities/ab/',
188
+ IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v3',
189
+ IMS_SCOPE: 'openid,AdobeID,target_sdk,additional_info.projectedProductContext'
194
190
  };`;
195
191
  // Check if the adobe.config.js file already exists
196
192
  if (!fs_1.default.existsSync(adobeConfigPath)) {
package/bin/index.js CHANGED
@@ -145,7 +145,7 @@ const handleInit = async (verbose) => {
145
145
  const handleNew = async (verbose) => {
146
146
  if (verbose)
147
147
  logger_1.default.info("verbose", "Creating new activity");
148
- runCommand(["run", "new-activity"], productionEnv);
148
+ runCommand(["run", "atb:plop:new:activity"], productionEnv);
149
149
  };
150
150
  /**
151
151
  * Handles the build command
@@ -156,11 +156,11 @@ const handleBuild = async (prod, verbose) => {
156
156
  if (prod) {
157
157
  process.env['NODE_ENV'] = 'production';
158
158
  logger_1.default.info("handleBuild", "Running build with production environment");
159
- runCommand(['run', 'build-prod'], productionEnv);
159
+ runCommand(['run', 'atb:build:prod'], productionEnv);
160
160
  }
161
161
  else {
162
162
  logger_1.default.info("handleBuild", "Running build with development environment");
163
- runCommand(['run', 'dev'], productionEnv);
163
+ runCommand(['run', 'atb:build:dev'], productionEnv);
164
164
  }
165
165
  };
166
166
  /**
@@ -169,7 +169,7 @@ const handleBuild = async (prod, verbose) => {
169
169
  const handleDev = async (browser, verbose) => {
170
170
  if (verbose)
171
171
  logger_1.default.info("verbose", `Starting development server with browser=${browser}`);
172
- const commandArr = ['run', browser ? 'dev-puppeteer' : 'dev'];
172
+ const commandArr = ['run', browser ? 'atb:build:dev:puppeteer' : 'atb:build:dev'];
173
173
  logger_1.default.info("handleDev", `Running command: ${commandArr.join(', ')}`);
174
174
  runCommand(commandArr, productionEnv);
175
175
  };
@@ -180,14 +180,7 @@ const handleDeploy = async (dryRun, verbose) => {
180
180
  if (verbose)
181
181
  logger_1.default.info("verbose", `Deploying to Adobe Target with dry-run=${dryRun}`);
182
182
  logger_1.default.info("handleDeploy", "Running Adobe Target deployment");
183
- // Set environment variables for the deployment script
184
- const deployEnv = {
185
- ...productionEnv,
186
- VERBOSE: verbose.toString(),
187
- DRY_RUN: dryRun.toString()
188
- };
189
- // Run the at-deploy.js script
190
- runCommand(['run', 'deploy'], deployEnv);
183
+ runCommand(['run', 'atb:build:deploy'], productionEnv);
191
184
  };
192
185
  /**
193
186
  * Handles the doctor command
@@ -272,14 +272,10 @@ const createAdobeConfig = async (projectPath) => {
272
272
  */
273
273
 
274
274
  module.exports = {
275
- // Adobe Target API base URL
276
- BASE_URL: 'https://mc.adobe.io/target/activities/',
277
-
278
- // Adobe IMS (Identity Management Services) token endpoint
279
- IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v1',
280
-
281
- // Required scopes for Adobe Target API access
282
- IMS_SCOPE: 'openid,target_sdk'
275
+ BASE_URL_NEW: 'https://mc.adobe.io/ups/target/',
276
+ BASE_URL: 'https://mc.adobe.io/ups/target/activities/ab/',
277
+ IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v3',
278
+ IMS_SCOPE: 'openid,AdobeID,target_sdk,additional_info.projectedProductContext'
283
279
  };`;
284
280
  try {
285
281
  fs_1.default.writeFileSync(configPath, configContent, 'utf8');
package/lib/at-deploy.js CHANGED
@@ -1,3 +1,6 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable @typescript-eslint/no-require-imports */
3
+
1
4
  /*
2
5
  * Adobe Target Build Deploy Script
3
6
  * --------------------------------
@@ -29,12 +32,19 @@
29
32
 
30
33
  /* eslint-env node */
31
34
  const path = require('path');
32
- require('dotenv').config({ path: path.join(__dirname, '../.env'), quiet: true });
35
+
36
+ const dotenv = require('dotenv');
37
+
38
+ const PWD = process.env.executionPath || process.cwd();
39
+
40
+ dotenv.config({ path: path.join(PWD, ".env"), quiet: true });
41
+
33
42
  const { execSync } = require('child_process');
34
43
  const axios = require('axios');
35
44
  const qs = require('querystring');
36
45
  const fs = require('fs');
37
- const { BASE_URL, IMS_TOKEN_URL, IMS_SCOPE } = require(path.join(process.cwd(), 'adobe.config'));
46
+
47
+ const { BASE_URL, IMS_TOKEN_URL, IMS_SCOPE } = require(path.join(PWD, 'adobe.config'));
38
48
  // Fallback to ANSI codes since chalk 5.x is ESM only
39
49
  const chalk = {
40
50
  green: (s) => `\x1b[32m${s}\x1b[0m`,
@@ -52,7 +62,6 @@ if (!process.env.ACTIVITY_FOLDER_NAME || process.env.ACTIVITY_FOLDER_NAME.trim()
52
62
  }
53
63
 
54
64
  // Build root directory for variations, using same approach as webpack config
55
- const PWD = process.env.executionPath || process.cwd();
56
65
  const ACTIVITIES_BASE_FOLDER = process.env.ACTIVITIES_BASE_FOLDER || 'Activities';
57
66
  const ACTIVITY_FOLDER = process.env.ACTIVITY_FOLDER_NAME.trim();
58
67
  const BUILD_ROOT = path.join(PWD, ACTIVITIES_BASE_FOLDER, ACTIVITY_FOLDER).toString();
@@ -155,7 +164,7 @@ async function fetchAdobeToken() {
155
164
 
156
165
  // 1. Run the build (calls your build system, e.g. webpack)
157
166
  console.log('Running build...');
158
- execSync('npm run build:prod', { stdio: 'inherit' });
167
+ execSync('npm run atb:build:prod', { stdio: 'inherit' });
159
168
 
160
169
  (async () => {
161
170
  try {
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "at-builder",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "main": "bin/index.js",
5
5
  "bin": {
6
6
  "atb": "bin/index.js"
7
7
  },
8
8
  "scripts": {
9
- "build": "tsc",
10
- "build-watch": "tsc -w",
11
- "build-prod": "cross-env NODE_ENV=production webpack",
12
- "dev": "webpack -- -w",
13
- "dev-puppeteer": "webpack -- -w & npm run puppeteer",
14
- "new-activity": "plop",
15
- "puppeteer": "node puppeteer.js $b",
16
- "deploy": "node lib/at-deploy.js"
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 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
17
  },
18
18
  "author": "Upendra Sengar <upendrasengar456@gmail.com>",
19
19
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "@babel/preset-react": "^7.18.6",
28
28
  "@types/node": "^22.13.2",
29
29
  "async": "^3.2.3",
30
- "axios": "^1.6.0",
30
+ "axios": "^1.12.2",
31
31
  "babel-loader": "^9.2.1",
32
32
  "babel-plugin-transform-async-to-generator": "^6.24.1",
33
33
  "build": "^0.1.4",
@@ -45,6 +45,7 @@
45
45
  "postcss-loader": "^8.1.1",
46
46
  "postcss-preset-env": "^10.1.4",
47
47
  "puppeteer": "^24.2.0",
48
+ "querystring": "^0.2.1",
48
49
  "readline": "^1.3.0",
49
50
  "sass": "^1.53.0",
50
51
  "sass-loader": "^16.0.4",
package/plopfile.js CHANGED
@@ -1,5 +1,11 @@
1
- const components = require("./.plop/generators/components");
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
3
 
4
+ const components = require("./.plop/generators/components");
5
+ const path = require('path');
6
+ const dotenv = require('dotenv');
7
+ const PWD = process.env.executionPath || process.cwd();
8
+ dotenv.config({ path: path.join(PWD, ".env") });
3
9
 
4
10
  module.exports = function (plop) {
5
11
  plop.setGenerator('components', components );
@@ -187,14 +187,10 @@ const createAdobeConfig = (basePath) => {
187
187
  */
188
188
 
189
189
  module.exports = {
190
- // Adobe Target API base URL
191
- BASE_URL: 'https://mc.adobe.io/target/activities/',
192
-
193
- // Adobe IMS (Identity Management Services) token endpoint
194
- IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v1',
195
-
196
- // Required scopes for Adobe Target API access
197
- IMS_SCOPE: 'openid,target_sdk'
190
+ BASE_URL_NEW: 'https://mc.adobe.io/ups/target/',
191
+ BASE_URL: 'https://mc.adobe.io/ups/target/activities/ab/',
192
+ IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v3',
193
+ IMS_SCOPE: 'openid,AdobeID,target_sdk,additional_info.projectedProductContext'
198
194
  };`;
199
195
 
200
196
  // Check if the adobe.config.js file already exists
package/src/index.ts CHANGED
@@ -157,7 +157,7 @@ const handleInit = async (verbose: boolean): Promise<void> => {
157
157
  */
158
158
  const handleNew = async (verbose: boolean): Promise<void> => {
159
159
  if (verbose) logger.info("verbose", "Creating new activity");
160
- runCommand(["run", "new-activity"], productionEnv);
160
+ runCommand(["run", "atb:plop:new:activity"], productionEnv);
161
161
  };
162
162
 
163
163
  /**
@@ -169,10 +169,10 @@ const handleBuild = async (prod: boolean, verbose: boolean): Promise<void> => {
169
169
  if (prod) {
170
170
  process.env['NODE_ENV'] = 'production';
171
171
  logger.info("handleBuild", "Running build with production environment");
172
- runCommand(['run', 'build-prod'], productionEnv);
172
+ runCommand(['run', 'atb:build:prod'], productionEnv);
173
173
  } else {
174
174
  logger.info("handleBuild", "Running build with development environment");
175
- runCommand(['run', 'dev'], productionEnv);
175
+ runCommand(['run', 'atb:build:dev'], productionEnv);
176
176
  }
177
177
  };
178
178
 
@@ -182,7 +182,7 @@ const handleBuild = async (prod: boolean, verbose: boolean): Promise<void> => {
182
182
  const handleDev = async (browser: boolean, verbose: boolean): Promise<void> => {
183
183
  if (verbose) logger.info("verbose", `Starting development server with browser=${browser}`);
184
184
 
185
- const commandArr = ['run', browser ? 'dev-puppeteer' : 'dev'];
185
+ const commandArr = ['run', browser ? 'atb:build:dev:puppeteer' : 'atb:build:dev'];
186
186
  logger.info("handleDev", `Running command: ${commandArr.join(', ')}`);
187
187
 
188
188
  runCommand(commandArr, productionEnv);
@@ -196,15 +196,7 @@ const handleDeploy = async (dryRun: boolean, verbose: boolean): Promise<void> =>
196
196
 
197
197
  logger.info("handleDeploy", "Running Adobe Target deployment");
198
198
 
199
- // Set environment variables for the deployment script
200
- const deployEnv = {
201
- ...productionEnv,
202
- VERBOSE: verbose.toString(),
203
- DRY_RUN: dryRun.toString()
204
- };
205
-
206
- // Run the at-deploy.js script
207
- runCommand(['run', 'deploy'], deployEnv);
199
+ runCommand(['run', 'atb:build:deploy'], productionEnv);
208
200
  };
209
201
 
210
202
  /**
@@ -304,14 +304,10 @@ const createAdobeConfig = async (projectPath: string): Promise<boolean> => {
304
304
  */
305
305
 
306
306
  module.exports = {
307
- // Adobe Target API base URL
308
- BASE_URL: 'https://mc.adobe.io/target/activities/',
309
-
310
- // Adobe IMS (Identity Management Services) token endpoint
311
- IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v1',
312
-
313
- // Required scopes for Adobe Target API access
314
- IMS_SCOPE: 'openid,target_sdk'
307
+ BASE_URL_NEW: 'https://mc.adobe.io/ups/target/',
308
+ BASE_URL: 'https://mc.adobe.io/ups/target/activities/ab/',
309
+ IMS_TOKEN_URL: 'https://ims-na1.adobelogin.com/ims/token/v3',
310
+ IMS_SCOPE: 'openid,AdobeID,target_sdk,additional_info.projectedProductContext'
315
311
  };`;
316
312
 
317
313
  try {
package/webpack.config.js CHANGED
@@ -1,3 +1,6 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable @typescript-eslint/no-require-imports */
3
+
1
4
  const path = require('path');
2
5
  const fs = require('fs');
3
6
  const dotenv = require('dotenv');
@@ -1,196 +0,0 @@
1
- {
2
- "version": "1.1.5",
3
- "name": "at-builder",
4
- "dependencies": {
5
- "@babel/core": {
6
- "version": "7.26.8",
7
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.8.tgz",
8
- "overridden": false
9
- },
10
- "@babel/eslint-parser": {
11
- "version": "7.18.9",
12
- "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.18.9.tgz",
13
- "overridden": false
14
- },
15
- "@babel/plugin-proposal-class-properties": {
16
- "version": "7.18.6",
17
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz",
18
- "overridden": false
19
- },
20
- "@babel/plugin-syntax-dynamic-import": {
21
- "version": "7.8.3",
22
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz",
23
- "overridden": false
24
- },
25
- "@babel/plugin-transform-runtime": {
26
- "version": "7.18.9",
27
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.18.9.tgz",
28
- "overridden": false
29
- },
30
- "@babel/preset-env": {
31
- "version": "7.18.9",
32
- "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.18.9.tgz",
33
- "overridden": false
34
- },
35
- "@babel/preset-react": {
36
- "version": "7.18.6",
37
- "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.18.6.tgz",
38
- "overridden": false
39
- },
40
- "@babel/runtime": {
41
- "version": "7.18.9",
42
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz",
43
- "overridden": false
44
- },
45
- "@types/node": {
46
- "version": "22.13.4",
47
- "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.4.tgz",
48
- "overridden": false
49
- },
50
- "async": {
51
- "version": "3.2.3",
52
- "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz",
53
- "overridden": false
54
- },
55
- "babel-loader": {
56
- "version": "9.2.1",
57
- "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-9.2.1.tgz",
58
- "overridden": false
59
- },
60
- "babel-plugin-transform-async-to-generator": {
61
- "version": "6.24.1",
62
- "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz",
63
- "overridden": false
64
- },
65
- "build": {
66
- "version": "0.1.4",
67
- "resolved": "https://registry.npmjs.org/build/-/build-0.1.4.tgz",
68
- "overridden": false
69
- },
70
- "chokidar": {
71
- "version": "4.0.3",
72
- "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
73
- "overridden": false
74
- },
75
- "cli-color": {
76
- "version": "2.0.3",
77
- "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz",
78
- "overridden": false
79
- },
80
- "commander": {
81
- "version": "13.1.0",
82
- "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz",
83
- "overridden": false
84
- },
85
- "cross-env": {
86
- "version": "7.0.3",
87
- "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
88
- "overridden": false
89
- },
90
- "css-loader": {
91
- "version": "7.1.2",
92
- "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-7.1.2.tgz",
93
- "overridden": false
94
- },
95
- "dotenv": {
96
- "version": "16.0.0",
97
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz",
98
- "overridden": false
99
- },
100
- "eslint-loader": {
101
- "version": "4.0.2",
102
- "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-4.0.2.tgz",
103
- "overridden": false
104
- },
105
- "eslint-webpack-plugin": {
106
- "version": "4.2.0",
107
- "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-4.2.0.tgz",
108
- "overridden": false
109
- },
110
- "eslint": {
111
- "version": "9.20.1",
112
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.20.1.tgz",
113
- "overridden": false
114
- },
115
- "inquirer": {
116
- "version": "12.4.1",
117
- "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-12.4.1.tgz",
118
- "overridden": false
119
- },
120
- "plop": {
121
- "version": "4.0.1",
122
- "resolved": "https://registry.npmjs.org/plop/-/plop-4.0.1.tgz",
123
- "overridden": false
124
- },
125
- "postcss-loader": {
126
- "version": "8.1.1",
127
- "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-8.1.1.tgz",
128
- "overridden": false
129
- },
130
- "postcss-preset-env": {
131
- "version": "10.1.4",
132
- "resolved": "https://registry.npmjs.org/postcss-preset-env/-/postcss-preset-env-10.1.4.tgz",
133
- "overridden": false
134
- },
135
- "postcss": {
136
- "version": "8.4.12",
137
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.12.tgz",
138
- "overridden": false
139
- },
140
- "puppeteer": {
141
- "version": "24.2.0",
142
- "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.2.0.tgz",
143
- "overridden": false
144
- },
145
- "readline": {
146
- "version": "1.3.0",
147
- "resolved": "https://registry.npmjs.org/readline/-/readline-1.3.0.tgz",
148
- "overridden": false
149
- },
150
- "sass-loader": {
151
- "version": "16.0.4",
152
- "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-16.0.4.tgz",
153
- "overridden": false
154
- },
155
- "sass": {
156
- "version": "1.53.0",
157
- "resolved": "https://registry.npmjs.org/sass/-/sass-1.53.0.tgz",
158
- "overridden": false
159
- },
160
- "style-loader": {
161
- "version": "4.0.0",
162
- "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-4.0.0.tgz",
163
- "overridden": false
164
- },
165
- "terser-webpack-plugin": {
166
- "version": "5.3.3",
167
- "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.3.tgz",
168
- "overridden": false
169
- },
170
- "ts-loader": {
171
- "version": "9.3.1",
172
- "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.3.1.tgz",
173
- "overridden": false
174
- },
175
- "typescript": {
176
- "version": "5.7.3",
177
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
178
- "overridden": false
179
- },
180
- "webpack-cli": {
181
- "version": "6.0.1",
182
- "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-6.0.1.tgz",
183
- "overridden": false
184
- },
185
- "webpack": {
186
- "version": "5.72.0",
187
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.72.0.tgz",
188
- "overridden": false
189
- },
190
- "wrapper-webpack-plugin": {
191
- "version": "2.1.0",
192
- "resolved": "https://registry.npmjs.org/wrapper-webpack-plugin/-/wrapper-webpack-plugin-2.1.0.tgz",
193
- "overridden": false
194
- }
195
- }
196
- }
@@ -1,21 +0,0 @@
1
- // Test validation logic
2
- const { spawn } = require('child_process');
3
- const path = require('path');
4
-
5
- console.log('Testing build command without .env file...');
6
-
7
- // Test without .env file
8
- const testDir = path.join(__dirname, 'test-empty');
9
- require('fs').mkdirSync(testDir, { recursive: true });
10
-
11
- const webpack = spawn('node', [path.join(__dirname, 'bin/index.js'), 'build'], {
12
- cwd: testDir,
13
- env: { ...process.env, ACTIVITY_FOLDER_NAME: '' },
14
- stdio: 'inherit'
15
- });
16
-
17
- webpack.on('exit', (code) => {
18
- console.log(`Build process exited with code: ${code}`);
19
- // Clean up
20
- require('fs').rmSync(testDir, { recursive: true, force: true });
21
- });