@lenne.tech/cli
Version:
lenne.Tech CLI: lt
81 lines (80 loc) • 4.05 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const dev_process_1 = require("../../lib/dev-process");
const dev_project_1 = require("../../lib/dev-project");
const dev_ticket_1 = require("../../lib/dev-ticket");
/**
* `lt ticket test <id> [--shard N] [-- <args>]` — run the E2E suite for a ticket
* in ITS isolated stack + DB, by delegating to `lt dev test` inside the ticket
* worktree (which is ticket-aware via the marker → test DB `<base>-<id>-test`).
*/
const TestCommand = {
alias: ['t'],
description: 'Run the E2E suite for a ticket in its isolated stack',
name: 'test',
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const { filesystem, parameters, print: { colors, error, info }, } = toolbox;
const id = String((_a = parameters.first) !== null && _a !== void 0 ? _a : '').trim();
if (!id) {
error('Usage: lt ticket test <id> [--shard N] [--keep] [-- <playwright args>]');
if (!parameters.options.fromGluegunMenu)
process.exit(1);
return 'ticket test: missing id';
}
const layout = (0, dev_project_1.resolveLayout)(filesystem.cwd(), filesystem);
let mainRepoRoot;
try {
mainRepoRoot = (0, dev_ticket_1.gitMainRepoRoot)(layout.root);
}
catch (_b) {
error('Not inside a git repository.');
if (!parameters.options.fromGluegunMenu)
process.exit(1);
return 'ticket test: not a git repo';
}
const wt = (0, dev_ticket_1.listWorktrees)(mainRepoRoot).find((w) => w.ticket === id);
if (!wt) {
error(`No ticket worktree "${id}" found. See \`lt ticket list\`.`);
if (!parameters.options.fromGluegunMenu)
process.exit(1);
return 'ticket test: not found';
}
// Reconstruct `lt dev test` args: forward the common flags + the `--` array.
const devArgs = ['dev', 'test'];
if (parameters.options.shard !== undefined) {
const s = parameters.options.shard;
devArgs.push(s === true ? '--shard' : `--shard=${s}`);
}
if (parameters.options.keep === true)
devArgs.push('--keep');
if (parameters.options.debug === true)
devArgs.push('--debug');
// Playwright args after `--` (e.g. a spec path / `--grep`): read them from
// the RAW argv. gluegun's parsed `parameters.array` does not reliably carry
// post-`--` tokens through the `ticket <id>` positional, which silently ran
// the WHOLE suite instead of the requested spec.
const dashIdx = process.argv.indexOf('--');
const forwarded = dashIdx >= 0 ? process.argv.slice(dashIdx + 1) : [];
if (forwarded.length > 0)
devArgs.push('--', ...forwarded);
info(colors.dim(`(cd ${wt.path} && lt ${devArgs.join(' ')})`));
const code = yield (0, dev_process_1.runChildInherit)(process.execPath, [process.argv[1], ...devArgs], {
cwd: wt.path,
env: process.env,
});
if (!parameters.options.fromGluegunMenu)
process.exit(code !== null && code !== void 0 ? code : 1);
return `ticket test: ${id} exit=${code}`;
}),
};
module.exports = TestCommand;