at-builder 1.2.9 ā 1.3.3
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.
- package/.claude/settings.local.json +53 -11
- package/.plop/constants/index.js +0 -7
- package/.plop/generators/actions.js +217 -126
- package/.plop/generators/prompts.js +50 -18
- package/.plop/utils/index.js +19 -5
- package/.vscode/settings.json +6 -0
- package/DEVELOPMENT.md +164 -0
- package/README.md +16 -1
- package/at-builder-0.0.2.vsix +0 -0
- package/bin/constants/config.js +169 -167
- package/bin/index.js +494 -182
- package/bin/services/doctor.js +752 -290
- package/bin/services/logger.js +40 -20
- package/lib/at-deploy.js +379 -145
- package/lib/at-sync.js +455 -0
- package/lib/eslint-flat-config-plugin.js +34 -33
- package/lib/install-checks.js +236 -0
- package/lib/postinstall.js +90 -0
- package/package/package.json +86 -0
- package/package.json +18 -11
- package/puppeteer.js +128 -32
- package/src/constants/config.ts +84 -9
- package/src/index.ts +131 -11
- package/src/services/doctor.ts +377 -39
- package/webpack.config.js +228 -39
- package/.plop/templates/build-template.hbs +0 -7
- package/.plop/templates/build.config.hbs +0 -7
- package/.plop/templates/observer.hbs +0 -18
package/bin/index.js
CHANGED
|
@@ -1,22 +1,78 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
25
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
30
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
51
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
52
|
+
if (ar || !(i in from)) {
|
|
53
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
54
|
+
ar[i] = from[i];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
58
|
+
};
|
|
3
59
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
60
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
61
|
};
|
|
6
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
63
|
+
var child_process_1 = require("child_process");
|
|
64
|
+
var path_1 = __importDefault(require("path"));
|
|
65
|
+
var fs_1 = __importDefault(require("fs"));
|
|
66
|
+
var commander_1 = require("commander");
|
|
67
|
+
var config_1 = require("./constants/config");
|
|
68
|
+
var doctor_1 = require("./services/doctor");
|
|
69
|
+
var logger_1 = __importDefault(require("./services/logger"));
|
|
14
70
|
/**
|
|
15
71
|
* Checks if the .env file exists at the current working directory
|
|
16
72
|
*
|
|
17
73
|
* @throws {Error} If the .env file is not found
|
|
18
74
|
*/
|
|
19
|
-
|
|
75
|
+
var checkEnvFile = function () {
|
|
20
76
|
logger_1.default.info("checkEnvFile", "Checking if .env file exists at current working directory");
|
|
21
77
|
try {
|
|
22
78
|
// Check if the file exists and is readable
|
|
@@ -25,94 +81,197 @@ const checkEnvFile = () => {
|
|
|
25
81
|
}
|
|
26
82
|
catch (error) {
|
|
27
83
|
// If the file does not exist, provide helpful guidance
|
|
28
|
-
console.error('\x1b[31m%s\x1b[0m',
|
|
84
|
+
console.error('\x1b[31m%s\x1b[0m', "\u274C Error: .env file not found at ".concat(process.cwd()));
|
|
29
85
|
console.error('\x1b[33m%s\x1b[0m', 'š” Run "atb init" to create .env file or "atb doctor --fix" to diagnose and fix configuration issues.');
|
|
30
|
-
logger_1.default.error("checkEnvFile",
|
|
86
|
+
logger_1.default.error("checkEnvFile", "Error: Couldn't find .env file at location ".concat(process.cwd()));
|
|
31
87
|
throw error;
|
|
32
88
|
}
|
|
33
89
|
};
|
|
34
90
|
// Prepare environment for spawning processes
|
|
35
|
-
|
|
36
|
-
...process.env,
|
|
37
|
-
executionPath: process.cwd()
|
|
38
|
-
};
|
|
91
|
+
var productionEnv = __assign(__assign({}, process.env), { executionPath: process.cwd() });
|
|
39
92
|
// Commander setup with proper subcommands
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
var setupCommander = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
+
var version, program;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
logger_1.default.info("setupCommander", "Setting up commander");
|
|
99
|
+
return [4 /*yield*/, (0, config_1.getVersion)()];
|
|
100
|
+
case 1:
|
|
101
|
+
version = _a.sent();
|
|
102
|
+
program = new commander_1.Command();
|
|
103
|
+
program
|
|
104
|
+
.name('atb')
|
|
105
|
+
.description('Adobe Target Activity Development CLI')
|
|
106
|
+
.version(version, "-V, --version")
|
|
107
|
+
.option("-v, --verbose", "Enable verbose logging");
|
|
108
|
+
// Add subcommands with proper actions
|
|
109
|
+
program
|
|
110
|
+
.command('init')
|
|
111
|
+
.description('Initialize project with .env configuration and templates')
|
|
112
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
+
var globalOpts;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
globalOpts = command.parent.opts();
|
|
118
|
+
return [4 /*yield*/, handleInit(globalOpts.verbose)];
|
|
119
|
+
case 1:
|
|
120
|
+
_a.sent();
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); });
|
|
125
|
+
program
|
|
126
|
+
.command('new')
|
|
127
|
+
.description('Create a new Adobe Target activity with variations')
|
|
128
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
|
+
var globalOpts;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
globalOpts = command.parent.opts();
|
|
134
|
+
return [4 /*yield*/, handleNew(globalOpts.verbose)];
|
|
135
|
+
case 1:
|
|
136
|
+
_a.sent();
|
|
137
|
+
return [2 /*return*/];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}); });
|
|
141
|
+
program
|
|
142
|
+
.command('build')
|
|
143
|
+
.description('Build activity for development or production')
|
|
144
|
+
.option('--prod', 'Build for production deployment')
|
|
145
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var globalOpts;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
globalOpts = command.parent.opts();
|
|
151
|
+
checkEnvFile();
|
|
152
|
+
return [4 /*yield*/, handleBuild(options.prod, globalOpts.verbose)];
|
|
153
|
+
case 1:
|
|
154
|
+
_a.sent();
|
|
155
|
+
return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}); });
|
|
159
|
+
program
|
|
160
|
+
.command('dev')
|
|
161
|
+
.description('Start development server with file watching')
|
|
162
|
+
.option('--browser', 'Open in browser automatically')
|
|
163
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
+
var globalOpts;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
globalOpts = command.parent.opts();
|
|
169
|
+
checkEnvFile();
|
|
170
|
+
return [4 /*yield*/, handleDev(options.browser, globalOpts.verbose)];
|
|
171
|
+
case 1:
|
|
172
|
+
_a.sent();
|
|
173
|
+
return [2 /*return*/];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}); });
|
|
177
|
+
program
|
|
178
|
+
.command('deploy')
|
|
179
|
+
.description('Deploy activity to Adobe Target using at-deploy.js')
|
|
180
|
+
.option('--dry-run', 'Run deployment in dry-run mode without actual deployment')
|
|
181
|
+
.option('--force', 'Override the 60s post-deploy cooldown lock')
|
|
182
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
183
|
+
var globalOpts;
|
|
184
|
+
return __generator(this, function (_a) {
|
|
185
|
+
switch (_a.label) {
|
|
186
|
+
case 0:
|
|
187
|
+
globalOpts = command.parent.opts();
|
|
188
|
+
checkEnvFile();
|
|
189
|
+
return [4 /*yield*/, handleDeploy(options.dryRun, options.force, globalOpts.verbose)];
|
|
190
|
+
case 1:
|
|
191
|
+
_a.sent();
|
|
192
|
+
return [2 /*return*/];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}); });
|
|
196
|
+
program
|
|
197
|
+
.command('sync')
|
|
198
|
+
.description('Sync build.config.json with the Adobe Target activity definition')
|
|
199
|
+
.option('--scaffold', 'Auto-create missing variation folders with boilerplate')
|
|
200
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
201
|
+
var globalOpts;
|
|
202
|
+
return __generator(this, function (_a) {
|
|
203
|
+
switch (_a.label) {
|
|
204
|
+
case 0:
|
|
205
|
+
globalOpts = command.parent.opts();
|
|
206
|
+
checkEnvFile();
|
|
207
|
+
return [4 /*yield*/, handleSync(options.scaffold, globalOpts.verbose)];
|
|
208
|
+
case 1:
|
|
209
|
+
_a.sent();
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}); });
|
|
214
|
+
program
|
|
215
|
+
.command('doctor')
|
|
216
|
+
.description('Diagnose and fix project configuration issues')
|
|
217
|
+
.option('--fix', 'Automatically fix detected issues')
|
|
218
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
219
|
+
var globalOpts;
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
switch (_a.label) {
|
|
222
|
+
case 0:
|
|
223
|
+
globalOpts = command.parent.opts();
|
|
224
|
+
return [4 /*yield*/, handleDoctor(options.fix, globalOpts.verbose)];
|
|
225
|
+
case 1:
|
|
226
|
+
_a.sent();
|
|
227
|
+
return [2 /*return*/];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}); });
|
|
231
|
+
program
|
|
232
|
+
.command('install-extension')
|
|
233
|
+
.description('Install the bundled at-builder VSCode extension (.vsix)')
|
|
234
|
+
.option('--editor <bin>', 'Editor CLI to use (e.g. code, cursor, codium)', 'code')
|
|
235
|
+
.action(function (options, command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
236
|
+
var globalOpts;
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0:
|
|
240
|
+
globalOpts = command.parent.opts();
|
|
241
|
+
return [4 /*yield*/, handleInstallExtension(options.editor, globalOpts.verbose)];
|
|
242
|
+
case 1:
|
|
243
|
+
_a.sent();
|
|
244
|
+
return [2 /*return*/];
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}); });
|
|
248
|
+
return [4 /*yield*/, program.parseAsync(process.argv)];
|
|
249
|
+
case 2:
|
|
250
|
+
_a.sent();
|
|
251
|
+
logger_1.default.info("setupCommander", "Commander setup complete");
|
|
252
|
+
return [2 /*return*/];
|
|
253
|
+
}
|
|
98
254
|
});
|
|
99
|
-
|
|
100
|
-
logger_1.default.info("setupCommander", "Commander setup complete");
|
|
101
|
-
};
|
|
255
|
+
}); };
|
|
102
256
|
/**
|
|
103
257
|
* Spawn a command using `npm` with the given command array and environment object.
|
|
104
258
|
*
|
|
259
|
+
* Any entries in `scriptArgs` are forwarded to the underlying script via npm's
|
|
260
|
+
* `--` passthrough (e.g. `npm run foo -- --dry-run`).
|
|
261
|
+
*
|
|
105
262
|
* @param commandArr - The array of command strings to pass to `npm`.
|
|
106
263
|
* @param env - The environment object to pass to the spawned process.
|
|
264
|
+
* @param scriptArgs - Optional flags/args to forward to the npm script itself.
|
|
107
265
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
266
|
+
var runCommand = function (commandArr, env, scriptArgs) {
|
|
267
|
+
if (scriptArgs === void 0) { scriptArgs = []; }
|
|
268
|
+
var fullArgs = scriptArgs.length > 0
|
|
269
|
+
? __spreadArray(__spreadArray(__spreadArray([], commandArr, true), ["--"], false), scriptArgs, true) : commandArr;
|
|
270
|
+
logger_1.default.info("runCommand", "Running npm command [".concat(fullArgs.join(", "), "]"));
|
|
271
|
+
logger_1.default.info("runCommand", "Current working directory: ".concat(process.cwd()));
|
|
272
|
+
(0, child_process_1.spawn)("npm", fullArgs, {
|
|
114
273
|
cwd: path_1.default.join(__dirname, "../"),
|
|
115
|
-
env,
|
|
274
|
+
env: env,
|
|
116
275
|
shell: true,
|
|
117
276
|
stdio: "inherit",
|
|
118
277
|
});
|
|
@@ -120,134 +279,287 @@ const runCommand = (commandArr, env) => {
|
|
|
120
279
|
/**
|
|
121
280
|
* Handles the init command
|
|
122
281
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
282
|
+
var handleInit = function (verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
283
|
+
return __generator(this, function (_a) {
|
|
284
|
+
if (verbose)
|
|
285
|
+
logger_1.default.info("verbose", "Initializing new .env file");
|
|
286
|
+
// Run npm init in the current working directory (where user ran atb init)
|
|
287
|
+
(0, child_process_1.spawn)("npm", ["init", "-y"], {
|
|
288
|
+
cwd: process.cwd(),
|
|
289
|
+
env: process.env,
|
|
290
|
+
shell: true,
|
|
291
|
+
stdio: "inherit",
|
|
292
|
+
});
|
|
293
|
+
// Install @babel/runtime as dev dependency in the current directory
|
|
294
|
+
(0, child_process_1.spawn)("npm", ["install", "@babel/runtime", "-D"], {
|
|
295
|
+
cwd: process.cwd(),
|
|
296
|
+
env: process.env,
|
|
297
|
+
shell: true,
|
|
298
|
+
stdio: "inherit",
|
|
299
|
+
});
|
|
300
|
+
(0, config_1.setupEnv)(process.cwd());
|
|
301
|
+
return [2 /*return*/];
|
|
139
302
|
});
|
|
140
|
-
|
|
141
|
-
};
|
|
303
|
+
}); };
|
|
142
304
|
/**
|
|
143
305
|
* Handles the new command
|
|
144
306
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
307
|
+
var handleNew = function (verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
308
|
+
return __generator(this, function (_a) {
|
|
309
|
+
if (verbose)
|
|
310
|
+
logger_1.default.info("verbose", "Creating new activity");
|
|
311
|
+
runCommand(["run", "atb:plop:new:activity"], productionEnv);
|
|
312
|
+
return [2 /*return*/];
|
|
313
|
+
});
|
|
314
|
+
}); };
|
|
150
315
|
/**
|
|
151
316
|
* Handles the build command
|
|
152
317
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
318
|
+
var handleBuild = function (prod, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
319
|
+
return __generator(this, function (_a) {
|
|
320
|
+
if (verbose)
|
|
321
|
+
logger_1.default.info("verbose", "Building in ".concat(prod ? 'production' : 'development', " mode"));
|
|
322
|
+
if (prod) {
|
|
323
|
+
process.env['NODE_ENV'] = 'production';
|
|
324
|
+
logger_1.default.info("handleBuild", "Running build with production environment");
|
|
325
|
+
runCommand(['run', 'atb:build:prod'], productionEnv);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
logger_1.default.info("handleBuild", "Running build with development environment");
|
|
329
|
+
runCommand(['run', 'atb:build:dev'], productionEnv);
|
|
330
|
+
}
|
|
331
|
+
return [2 /*return*/];
|
|
332
|
+
});
|
|
333
|
+
}); };
|
|
166
334
|
/**
|
|
167
335
|
* Handles the dev command
|
|
168
336
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
337
|
+
var handleDev = function (browser, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
338
|
+
var commandArr;
|
|
339
|
+
return __generator(this, function (_a) {
|
|
340
|
+
if (verbose)
|
|
341
|
+
logger_1.default.info("verbose", "Starting development server with browser=".concat(browser));
|
|
342
|
+
commandArr = ['run', browser ? 'atb:build:dev:puppeteer' : 'atb:build:dev'];
|
|
343
|
+
logger_1.default.info("handleDev", "Running command: ".concat(commandArr.join(', ')));
|
|
344
|
+
runCommand(commandArr, productionEnv);
|
|
345
|
+
return [2 /*return*/];
|
|
346
|
+
});
|
|
347
|
+
}); };
|
|
176
348
|
/**
|
|
177
349
|
* Handles the deploy command
|
|
178
350
|
*/
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
351
|
+
var handleDeploy = function (dryRun, force, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
352
|
+
var scriptArgs;
|
|
353
|
+
return __generator(this, function (_a) {
|
|
354
|
+
if (verbose)
|
|
355
|
+
logger_1.default.info("verbose", "Deploying to Adobe Target with dry-run=".concat(dryRun, " force=").concat(force));
|
|
356
|
+
logger_1.default.info("handleDeploy", "Running Adobe Target deployment");
|
|
357
|
+
scriptArgs = [];
|
|
358
|
+
if (dryRun)
|
|
359
|
+
scriptArgs.push('--dry-run');
|
|
360
|
+
if (force)
|
|
361
|
+
scriptArgs.push('--force');
|
|
362
|
+
runCommand(['run', 'atb:build:deploy'], productionEnv, scriptArgs);
|
|
363
|
+
return [2 /*return*/];
|
|
364
|
+
});
|
|
365
|
+
}); };
|
|
185
366
|
/**
|
|
186
|
-
* Handles the
|
|
367
|
+
* Handles the sync command
|
|
187
368
|
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
369
|
+
var handleSync = function (scaffold, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
370
|
+
var scriptArgs;
|
|
371
|
+
return __generator(this, function (_a) {
|
|
372
|
+
if (verbose)
|
|
373
|
+
logger_1.default.info("verbose", "Syncing build.config.json with scaffold=".concat(scaffold));
|
|
374
|
+
logger_1.default.info("handleSync", "Running Adobe Target sync");
|
|
375
|
+
scriptArgs = [];
|
|
376
|
+
if (scaffold)
|
|
377
|
+
scriptArgs.push('--scaffold');
|
|
378
|
+
runCommand(['run', 'atb:build:sync'], productionEnv, scriptArgs);
|
|
379
|
+
return [2 /*return*/];
|
|
380
|
+
});
|
|
381
|
+
}); };
|
|
382
|
+
/**
|
|
383
|
+
* Handles the install-extension command.
|
|
384
|
+
*
|
|
385
|
+
* Locates the bundled at-builder-*.vsix in at-builder's install directory
|
|
386
|
+
* (one level up from this compiled file) and installs it via the editor's
|
|
387
|
+
* CLI. Defaults to `code`; users on Cursor/VSCodium can pass --editor.
|
|
388
|
+
*
|
|
389
|
+
* The .vsix lives inside the at-builder package itself, NOT the consumer's
|
|
390
|
+
* project ā so it resolves via __dirname, not PWD.
|
|
391
|
+
*/
|
|
392
|
+
var handleInstallExtension = function (editor, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
393
|
+
var installRoot, candidates, vsixPath, result;
|
|
394
|
+
return __generator(this, function (_a) {
|
|
395
|
+
if (verbose)
|
|
396
|
+
logger_1.default.info("verbose", "Installing VSCode extension via ".concat(editor));
|
|
397
|
+
installRoot = path_1.default.join(__dirname, "..");
|
|
398
|
+
try {
|
|
399
|
+
candidates = fs_1.default.readdirSync(installRoot)
|
|
400
|
+
.filter(function (f) { return /^at-builder-.+\.vsix$/.test(f); })
|
|
401
|
+
.sort()
|
|
402
|
+
.reverse(); // latest version first by lexicographic sort
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
console.error("\u274C Failed to scan at-builder directory: ".concat(error.message));
|
|
406
|
+
process.exit(1);
|
|
407
|
+
}
|
|
408
|
+
if (candidates.length === 0) {
|
|
409
|
+
console.error("ā No at-builder VSCode extension (.vsix) found bundled with this install.");
|
|
410
|
+
console.error("\uD83D\uDCA1 Expected at: ".concat(installRoot, "/at-builder-*.vsix"));
|
|
411
|
+
process.exit(1);
|
|
198
412
|
}
|
|
199
|
-
|
|
200
|
-
console.log(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
413
|
+
vsixPath = path_1.default.join(installRoot, candidates[0]);
|
|
414
|
+
console.log("\uD83D\uDCE6 Installing ".concat(candidates[0], " via \"").concat(editor, "\"..."));
|
|
415
|
+
result = (0, child_process_1.spawn)(editor, ["--install-extension", vsixPath], {
|
|
416
|
+
stdio: "inherit",
|
|
417
|
+
shell: true
|
|
418
|
+
});
|
|
419
|
+
result.on("error", function (err) {
|
|
420
|
+
// ENOENT here means the editor binary isn't on PATH.
|
|
421
|
+
if (err.code === "ENOENT") {
|
|
422
|
+
console.error("\u274C \"".concat(editor, "\" CLI not found in PATH."));
|
|
423
|
+
if (editor === "code") {
|
|
424
|
+
console.error("š” Open VSCode and run Command Palette ā \"Shell Command: Install 'code' command in PATH\".");
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
console.error("\uD83D\uDCA1 Make sure the \"".concat(editor, "\" CLI is installed and on your PATH, or pass a different --editor."));
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
console.error("\u274C Failed to launch \"".concat(editor, "\": ").concat(err.message));
|
|
205
432
|
}
|
|
433
|
+
process.exit(1);
|
|
206
434
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (fixed < issues.length) {
|
|
212
|
-
console.log(`ā ļø ${issues.length - fixed} issue(s) require manual attention.`);
|
|
435
|
+
result.on("exit", function (code) {
|
|
436
|
+
if (code === 0) {
|
|
437
|
+
console.log("ā
Extension installed. Reload your editor window to activate.");
|
|
438
|
+
return;
|
|
213
439
|
}
|
|
440
|
+
// 127 = shell's "command not found". With shell:true the spawn 'error'
|
|
441
|
+
// event never fires for missing CLIs, so we surface the same hint here.
|
|
442
|
+
if (code === 127) {
|
|
443
|
+
console.error("\u274C \"".concat(editor, "\" CLI not found in PATH."));
|
|
444
|
+
if (editor === "code") {
|
|
445
|
+
console.error("š” Open VSCode and run Command Palette ā \"Shell Command: Install 'code' command in PATH\".");
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
console.error("\uD83D\uDCA1 Make sure the \"".concat(editor, "\" CLI is installed and on your PATH, or pass a different --editor."));
|
|
449
|
+
}
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
console.error("\u274C \"".concat(editor, " --install-extension\" exited with code ").concat(code, "."));
|
|
453
|
+
process.exit(code !== null && code !== void 0 ? code : 1);
|
|
454
|
+
});
|
|
455
|
+
return [2 /*return*/];
|
|
456
|
+
});
|
|
457
|
+
}); };
|
|
458
|
+
/**
|
|
459
|
+
* Handles the doctor command
|
|
460
|
+
*/
|
|
461
|
+
var handleDoctor = function (autoFix, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
462
|
+
var issues, fixed, error_1;
|
|
463
|
+
return __generator(this, function (_a) {
|
|
464
|
+
switch (_a.label) {
|
|
465
|
+
case 0:
|
|
466
|
+
if (verbose)
|
|
467
|
+
logger_1.default.info("verbose", "Running diagnostics with auto-fix=".concat(autoFix));
|
|
468
|
+
logger_1.default.info("handleDoctor", "Diagnosing project configuration");
|
|
469
|
+
_a.label = 1;
|
|
470
|
+
case 1:
|
|
471
|
+
_a.trys.push([1, 6, , 7]);
|
|
472
|
+
return [4 /*yield*/, (0, doctor_1.runDiagnostics)(process.cwd(), verbose)];
|
|
473
|
+
case 2:
|
|
474
|
+
issues = _a.sent();
|
|
475
|
+
if (issues.length === 0) {
|
|
476
|
+
console.log("ā
No issues found. Your project configuration is healthy!");
|
|
477
|
+
return [2 /*return*/];
|
|
478
|
+
}
|
|
479
|
+
// Display issues
|
|
480
|
+
console.log("\n\uD83D\uDD0D Found ".concat(issues.length, " issue(s):\n"));
|
|
481
|
+
issues.forEach(function (issue, index) {
|
|
482
|
+
console.log("".concat(index + 1, ". ").concat(issue.severity === 'error' ? 'ā' : 'ā ļø', " ").concat(issue.message));
|
|
483
|
+
if (issue.suggestion) {
|
|
484
|
+
console.log(" \uD83D\uDCA1 ".concat(issue.suggestion));
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
if (!autoFix) return [3 /*break*/, 4];
|
|
488
|
+
console.log('\nš§ Attempting to fix issues...\n');
|
|
489
|
+
return [4 /*yield*/, (0, doctor_1.fixIssues)(issues, process.cwd(), verbose)];
|
|
490
|
+
case 3:
|
|
491
|
+
fixed = _a.sent();
|
|
492
|
+
console.log("\n\u2705 Fixed ".concat(fixed, " issue(s)."));
|
|
493
|
+
if (fixed < issues.length) {
|
|
494
|
+
console.log("\u26A0\uFE0F ".concat(issues.length - fixed, " issue(s) require manual attention."));
|
|
495
|
+
}
|
|
496
|
+
return [3 /*break*/, 5];
|
|
497
|
+
case 4:
|
|
498
|
+
console.log('\nš” Run `atb doctor --fix` to automatically fix resolvable issues.');
|
|
499
|
+
_a.label = 5;
|
|
500
|
+
case 5: return [3 /*break*/, 7];
|
|
501
|
+
case 6:
|
|
502
|
+
error_1 = _a.sent();
|
|
503
|
+
logger_1.default.error("handleDoctor", "Doctor command failed: ".concat(error_1.message));
|
|
504
|
+
process.exit(1);
|
|
505
|
+
return [3 /*break*/, 7];
|
|
506
|
+
case 7: return [2 /*return*/];
|
|
214
507
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
logger_1.default.error("handleDoctor", `Doctor command failed: ${error.message}`);
|
|
221
|
-
process.exit(1);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
508
|
+
});
|
|
509
|
+
}); };
|
|
224
510
|
// Command execution logic
|
|
225
511
|
/**
|
|
226
512
|
* Main command execution entry point
|
|
227
513
|
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
514
|
+
var executeCommand = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
515
|
+
return __generator(this, function (_a) {
|
|
516
|
+
switch (_a.label) {
|
|
517
|
+
case 0:
|
|
518
|
+
logger_1.default.info("executeCommand", "Entering executeCommand");
|
|
519
|
+
return [4 /*yield*/, setupCommander()];
|
|
520
|
+
case 1:
|
|
521
|
+
_a.sent();
|
|
522
|
+
logger_1.default.info("executeCommand", "Exiting executeCommand");
|
|
523
|
+
return [2 /*return*/];
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}); };
|
|
233
527
|
// Print command help
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
528
|
+
var printCommandHelp = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
529
|
+
var help;
|
|
530
|
+
return __generator(this, function (_a) {
|
|
531
|
+
switch (_a.label) {
|
|
532
|
+
case 0: return [4 /*yield*/, (0, config_1.getHelpInfo)()];
|
|
533
|
+
case 1:
|
|
534
|
+
help = _a.sent();
|
|
535
|
+
console.log(help);
|
|
536
|
+
process.exit(0);
|
|
537
|
+
return [2 /*return*/];
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
}); };
|
|
239
541
|
/**
|
|
240
542
|
* Main program flow
|
|
241
543
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
544
|
+
var main = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
545
|
+
var error_2;
|
|
546
|
+
return __generator(this, function (_a) {
|
|
547
|
+
switch (_a.label) {
|
|
548
|
+
case 0:
|
|
549
|
+
_a.trys.push([0, 2, , 3]);
|
|
550
|
+
return [4 /*yield*/, executeCommand()];
|
|
551
|
+
case 1:
|
|
552
|
+
_a.sent();
|
|
553
|
+
return [3 /*break*/, 3];
|
|
554
|
+
case 2:
|
|
555
|
+
error_2 = _a.sent();
|
|
556
|
+
logger_1.default.error("main", error_2.message);
|
|
557
|
+
process.exit(1);
|
|
558
|
+
return [3 /*break*/, 3];
|
|
559
|
+
case 3: return [2 /*return*/];
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}); };
|
|
251
563
|
// Print custom help if no arguments, otherwise let Commander.js handle everything
|
|
252
564
|
if (process.argv.length <= 2) {
|
|
253
565
|
printCommandHelp();
|