@lenne.tech/cli 1.27.0 → 1.29.0
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/build/cli.js +7 -1
- package/build/commands/dev/doctor.js +27 -1
- package/build/commands/dev/down.js +22 -10
- package/build/commands/dev/status.js +4 -3
- package/build/commands/dev/test.js +12 -4
- package/build/commands/dev/up.js +90 -50
- package/build/commands/frontend/angular.js +48 -46
- package/build/commands/frontend/convert-mode.js +41 -39
- package/build/commands/frontend/nuxt.js +49 -47
- package/build/commands/fullstack/add-api.js +34 -32
- package/build/commands/fullstack/add-app.js +25 -23
- package/build/commands/fullstack/convert-mode.js +85 -65
- package/build/commands/fullstack/init.js +12 -0
- package/build/commands/fullstack/update.js +24 -0
- package/build/commands/server/add-property.js +42 -40
- package/build/commands/server/convert-mode.js +41 -39
- package/build/commands/server/create.js +65 -63
- package/build/commands/server/module.js +56 -54
- package/build/commands/server/object.js +42 -40
- package/build/commands/server/permissions.js +60 -58
- package/build/commands/ticket/list.js +78 -0
- package/build/commands/ticket/start.js +141 -0
- package/build/commands/ticket/stop.js +166 -0
- package/build/commands/ticket/switch.js +70 -0
- package/build/commands/ticket/test.js +80 -0
- package/build/commands/ticket/ticket.js +36 -0
- package/build/commands/tools/crawl.js +92 -90
- package/build/extensions/frontend-helper.js +8 -37
- package/build/extensions/server.js +8 -38
- package/build/lib/command-help.js +161 -0
- package/build/lib/dev-identity.js +18 -0
- package/build/lib/dev-patches.js +1 -1
- package/build/lib/dev-project.js +14 -0
- package/build/lib/dev-state.js +96 -0
- package/build/lib/dev-test-session.js +55 -35
- package/build/lib/dev-ticket.js +343 -0
- package/build/lib/vendor-claude-md.js +227 -0
- package/docs/lt-dev-ticket-workflow.html +603 -0
- package/docs/lt-dev-ticket-workflow.pdf +0 -0
- package/package.json +32 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const dev_identity_1 = require("../../lib/dev-identity");
|
|
13
|
+
const dev_project_1 = require("../../lib/dev-project");
|
|
14
|
+
const dev_state_1 = require("../../lib/dev-state");
|
|
15
|
+
const dev_ticket_1 = require("../../lib/dev-ticket");
|
|
16
|
+
/**
|
|
17
|
+
* `lt ticket list` — the dashboard of all active ticket worktrees: id, folder,
|
|
18
|
+
* branch, URLs, DB and running state. The one place to re-view every ticket's
|
|
19
|
+
* URLs at any time.
|
|
20
|
+
*/
|
|
21
|
+
const ListCommand = {
|
|
22
|
+
alias: ['ls'],
|
|
23
|
+
description: 'List all ticket worktrees with their URLs + status',
|
|
24
|
+
name: 'list',
|
|
25
|
+
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
const { filesystem, parameters, print: { colors, info, warning }, } = toolbox;
|
|
28
|
+
const layout = (0, dev_project_1.resolveLayout)(filesystem.cwd(), filesystem);
|
|
29
|
+
let mainRepoRoot;
|
|
30
|
+
try {
|
|
31
|
+
mainRepoRoot = (0, dev_ticket_1.gitMainRepoRoot)(layout.root);
|
|
32
|
+
}
|
|
33
|
+
catch (_b) {
|
|
34
|
+
warning('Not inside a git repository.');
|
|
35
|
+
if (!parameters.options.fromGluegunMenu)
|
|
36
|
+
process.exit(1);
|
|
37
|
+
return 'ticket list: not a git repo';
|
|
38
|
+
}
|
|
39
|
+
const base = (0, dev_identity_1.buildIdentity)(mainRepoRoot);
|
|
40
|
+
const tickets = (0, dev_ticket_1.listWorktrees)(mainRepoRoot).filter((w) => w.ticket);
|
|
41
|
+
const reg = (0, dev_state_1.loadRegistry)();
|
|
42
|
+
info('');
|
|
43
|
+
info(colors.bold('Ticket environments'));
|
|
44
|
+
info(colors.dim('─'.repeat(64)));
|
|
45
|
+
if (tickets.length === 0) {
|
|
46
|
+
info(colors.dim(' none — start one with `lt ticket start <ticket-or-name>`'));
|
|
47
|
+
info('');
|
|
48
|
+
if (!parameters.options.fromGluegunMenu)
|
|
49
|
+
process.exit();
|
|
50
|
+
return 'ticket list: empty';
|
|
51
|
+
}
|
|
52
|
+
for (const wt of tickets) {
|
|
53
|
+
const session = (0, dev_state_1.loadSession)(wt.path);
|
|
54
|
+
const apiAlive = (session === null || session === void 0 ? void 0 : session.pids.api) ? (0, dev_state_1.isPidAlive)(session.pids.api) : false;
|
|
55
|
+
const appAlive = (session === null || session === void 0 ? void 0 : session.pids.app) ? (0, dev_state_1.isPidAlive)(session.pids.app) : false;
|
|
56
|
+
const running = apiAlive || appAlive;
|
|
57
|
+
const dot = running ? colors.green('●') : colors.dim('○');
|
|
58
|
+
// The dev stack for this ticket is registered under `<base>-<id>`.
|
|
59
|
+
const entry = reg.projects[`${base.slug}-${wt.ticket}`];
|
|
60
|
+
info(` ${dot} ${colors.bold(String(wt.ticket).padEnd(16))} ${colors.dim(`branch ${(_a = wt.branch) !== null && _a !== void 0 ? _a : '-'}`)}`);
|
|
61
|
+
if (entry) {
|
|
62
|
+
for (const [sub, host] of Object.entries(entry.subdomains))
|
|
63
|
+
info(` ${sub.padEnd(4)} https://${host}`);
|
|
64
|
+
if (entry.dbName)
|
|
65
|
+
info(` db mongodb://127.0.0.1/${entry.dbName}`);
|
|
66
|
+
}
|
|
67
|
+
info(colors.dim(` dir ${wt.path}`));
|
|
68
|
+
info(colors.dim(` ${running ? 'running' : 'stopped'}${entry ? '' : ' (not brought up yet)'}`));
|
|
69
|
+
}
|
|
70
|
+
info('');
|
|
71
|
+
info(colors.dim('Open: `code <dir>` / `lt ticket switch <id>` · Test: `lt ticket test <id>` · Stop: `lt ticket stop <id>`'));
|
|
72
|
+
info('');
|
|
73
|
+
if (!parameters.options.fromGluegunMenu)
|
|
74
|
+
process.exit();
|
|
75
|
+
return `ticket list: ${tickets.length}`;
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
module.exports = ListCommand;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const dev_identity_1 = require("../../lib/dev-identity");
|
|
14
|
+
const dev_process_1 = require("../../lib/dev-process");
|
|
15
|
+
const dev_project_1 = require("../../lib/dev-project");
|
|
16
|
+
const dev_state_1 = require("../../lib/dev-state");
|
|
17
|
+
const dev_ticket_1 = require("../../lib/dev-ticket");
|
|
18
|
+
/**
|
|
19
|
+
* `lt ticket start <name>` — spin up a fully-isolated parallel dev environment
|
|
20
|
+
* for a ticket or feature, in seconds:
|
|
21
|
+
*
|
|
22
|
+
* 1. `git fetch` + create a git WORKTREE on a fresh branch from `origin/dev`
|
|
23
|
+
* (so every ticket starts independent from the latest dev) at a sibling
|
|
24
|
+
* folder `<parent>/<slug>-<id>`,
|
|
25
|
+
* 2. tag it with a `.lt-dev/ticket` marker (makes every `lt dev *` in it
|
|
26
|
+
* ticket-aware),
|
|
27
|
+
* 3. `pnpm install` (hard-links from the shared store → fast),
|
|
28
|
+
* 4. `lt dev up` → own URLs (`<slug>-<id>.localhost` / `api.<slug>-<id>…`),
|
|
29
|
+
* own ports, own Caddy block, own EMPTY DB (`<base>-<id>`).
|
|
30
|
+
*
|
|
31
|
+
* lt ticket start DEV-2200 → svl-2200.localhost (branch feat/DEV-2200)
|
|
32
|
+
* lt ticket start checkout-refactor → svl-checkout-refactor.localhost
|
|
33
|
+
* lt ticket start DEV-2200 --as cof → svl-cof.localhost
|
|
34
|
+
*/
|
|
35
|
+
const StartCommand = {
|
|
36
|
+
description: 'Start an isolated parallel dev env for a ticket/feature (worktree + lt dev up)',
|
|
37
|
+
name: 'start',
|
|
38
|
+
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
var _a;
|
|
40
|
+
const { filesystem, parameters, print: { colors, error, info, success, warning }, } = toolbox;
|
|
41
|
+
// `String(...)` — a purely-numeric arg (e.g. a ticket "9991") is parsed as a
|
|
42
|
+
// JS number by the option parser, on which `.trim()` would throw.
|
|
43
|
+
const name = String((_a = parameters.first) !== null && _a !== void 0 ? _a : '').trim();
|
|
44
|
+
if (!name) {
|
|
45
|
+
error('Usage: lt ticket start <ticket-or-name> [--as <id>] [--branch <branch>] [--base <ref>]');
|
|
46
|
+
info(colors.dim(' e.g. lt ticket start DEV-2200 | lt ticket start checkout-refactor'));
|
|
47
|
+
if (!parameters.options.fromGluegunMenu)
|
|
48
|
+
process.exit(1);
|
|
49
|
+
return 'ticket start: missing name';
|
|
50
|
+
}
|
|
51
|
+
// Anchor to the MAIN repo (works even when invoked from inside a worktree).
|
|
52
|
+
const layout = (0, dev_project_1.resolveLayout)(filesystem.cwd(), filesystem);
|
|
53
|
+
let mainRepoRoot;
|
|
54
|
+
try {
|
|
55
|
+
mainRepoRoot = (0, dev_ticket_1.gitMainRepoRoot)(layout.root);
|
|
56
|
+
}
|
|
57
|
+
catch (_b) {
|
|
58
|
+
error('Not inside a git repository — `lt ticket` needs a git project.');
|
|
59
|
+
if (!parameters.options.fromGluegunMenu)
|
|
60
|
+
process.exit(1);
|
|
61
|
+
return 'ticket start: not a git repo';
|
|
62
|
+
}
|
|
63
|
+
const base = (0, dev_identity_1.buildIdentity)(mainRepoRoot);
|
|
64
|
+
const id = (0, dev_ticket_1.deriveTicketId)(name, parameters.options.as != null ? String(parameters.options.as) : undefined);
|
|
65
|
+
const branch = typeof parameters.options.branch === 'string' ? parameters.options.branch : (0, dev_ticket_1.defaultTicketBranch)(name);
|
|
66
|
+
const baseRef = typeof parameters.options.base === 'string' ? parameters.options.base : 'origin/dev';
|
|
67
|
+
const ticketIdentity = (0, dev_identity_1.buildTicketIdentity)(base, id);
|
|
68
|
+
const dbName = (0, dev_project_1.deriveTicketDbName)((0, dev_project_1.deriveDbName)(layout.apiDir, base.slug), id);
|
|
69
|
+
const worktreePath = (0, dev_ticket_1.worktreePathFor)(mainRepoRoot, base.slug, id);
|
|
70
|
+
// Pre-flight: nothing already there + slug free.
|
|
71
|
+
if ((0, fs_1.existsSync)(worktreePath)) {
|
|
72
|
+
error(`Target folder already exists: ${worktreePath}`);
|
|
73
|
+
info(colors.dim(' Use a different id (`--as <id>`) or remove it with `lt ticket stop`.'));
|
|
74
|
+
if (!parameters.options.fromGluegunMenu)
|
|
75
|
+
process.exit(1);
|
|
76
|
+
return 'ticket start: path exists';
|
|
77
|
+
}
|
|
78
|
+
if ((0, dev_state_1.loadRegistry)().projects[ticketIdentity.slug]) {
|
|
79
|
+
warning(`An env named "${ticketIdentity.slug}" is already registered — choose another id with --as.`);
|
|
80
|
+
}
|
|
81
|
+
info('');
|
|
82
|
+
info(colors.bold(`Starting ticket "${id}" → ${ticketIdentity.slug}`));
|
|
83
|
+
info(colors.dim(` branch: ${branch} (from ${baseRef})`));
|
|
84
|
+
info(colors.dim(` worktree: ${worktreePath}`));
|
|
85
|
+
info('');
|
|
86
|
+
// 1. fetch + worktree (fresh branch from origin/dev → independent).
|
|
87
|
+
try {
|
|
88
|
+
info(colors.dim(`Fetching + creating worktree from ${baseRef} …`));
|
|
89
|
+
(0, dev_ticket_1.gitFetch)(mainRepoRoot);
|
|
90
|
+
(0, dev_ticket_1.worktreeAdd)(mainRepoRoot, worktreePath, branch, baseRef);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
error(`git worktree setup failed: ${e.message}`);
|
|
94
|
+
if (!parameters.options.fromGluegunMenu)
|
|
95
|
+
process.exit(1);
|
|
96
|
+
return 'ticket start: worktree failed';
|
|
97
|
+
}
|
|
98
|
+
// 2. tag the worktree with its ticket id (makes lt dev * ticket-aware).
|
|
99
|
+
(0, dev_ticket_1.writeTicketMarker)(worktreePath, id);
|
|
100
|
+
// 3. install deps (pnpm hard-links from the shared store → fast).
|
|
101
|
+
if (parameters.options.install !== false) {
|
|
102
|
+
info(colors.dim('Installing dependencies (pnpm) …'));
|
|
103
|
+
try {
|
|
104
|
+
(0, dev_ticket_1.pnpmInstall)(worktreePath);
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
warning(`pnpm install failed (${e.message}) — continuing; run it manually in the worktree.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// 4. bring the isolated stack up (re-invokes THIS lt build so the marker is
|
|
111
|
+
// honoured even before a global recompile). `--no-up` just scaffolds.
|
|
112
|
+
if (parameters.options.up !== false) {
|
|
113
|
+
info('');
|
|
114
|
+
info(colors.dim('Bringing up the isolated stack (lt dev up) …'));
|
|
115
|
+
const code = yield (0, dev_process_1.runChildInherit)(process.execPath, [process.argv[1], 'dev', 'up'], {
|
|
116
|
+
cwd: worktreePath,
|
|
117
|
+
env: process.env,
|
|
118
|
+
});
|
|
119
|
+
if (code !== 0)
|
|
120
|
+
warning(`lt dev up exited ${code} — inspect with \`cd ${worktreePath} && lt dev status\`.`);
|
|
121
|
+
}
|
|
122
|
+
// Summary — the URLs the user works with (always re-viewable via `lt ticket list`).
|
|
123
|
+
info('');
|
|
124
|
+
success(`Ticket "${id}" ready.`);
|
|
125
|
+
if (ticketIdentity.subdomains.app)
|
|
126
|
+
info(` app: https://${ticketIdentity.subdomains.app.hostname}`);
|
|
127
|
+
if (ticketIdentity.subdomains.api)
|
|
128
|
+
info(` api: https://${ticketIdentity.subdomains.api.hostname}`);
|
|
129
|
+
info(` db: mongodb://127.0.0.1/${dbName} (empty)`);
|
|
130
|
+
info(` dir: ${worktreePath}`);
|
|
131
|
+
info('');
|
|
132
|
+
info(colors.dim(`Open it: code ${worktreePath} (or: lt ticket switch ${id})`));
|
|
133
|
+
info(colors.dim(`Test it: cd ${worktreePath} && lt dev test (or: lt ticket test ${id})`));
|
|
134
|
+
info(colors.dim('All envs: lt ticket list'));
|
|
135
|
+
info(colors.dim(`Stop it: lt ticket stop ${id}`));
|
|
136
|
+
if (!parameters.options.fromGluegunMenu)
|
|
137
|
+
process.exit();
|
|
138
|
+
return `ticket start: ${id}`;
|
|
139
|
+
}),
|
|
140
|
+
};
|
|
141
|
+
module.exports = StartCommand;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const dev_identity_1 = require("../../lib/dev-identity");
|
|
14
|
+
const dev_process_1 = require("../../lib/dev-process");
|
|
15
|
+
const dev_project_1 = require("../../lib/dev-project");
|
|
16
|
+
const dev_state_1 = require("../../lib/dev-state");
|
|
17
|
+
const dev_ticket_1 = require("../../lib/dev-ticket");
|
|
18
|
+
/**
|
|
19
|
+
* `lt ticket stop [<id>]` — tear a ticket env down + remove its worktree.
|
|
20
|
+
*
|
|
21
|
+
* 1. `lt dev down` inside the worktree (stops the ticket stack + any test
|
|
22
|
+
* stacks, removes the Caddy block — residue-free),
|
|
23
|
+
* 2. `git worktree remove` (the BRANCH is kept, so nothing is lost),
|
|
24
|
+
* 3. `--drop-db` also drops the ticket's empty dev + test databases.
|
|
25
|
+
*
|
|
26
|
+
* Run with NO id from INSIDE a ticket worktree to clean up THIS environment
|
|
27
|
+
* (the current folder is removed; the process steps out to the main repo first).
|
|
28
|
+
*/
|
|
29
|
+
const StopCommand = {
|
|
30
|
+
alias: ['rm'],
|
|
31
|
+
description: 'Stop a ticket env + remove its worktree (branch kept); no id = the current worktree',
|
|
32
|
+
name: 'stop',
|
|
33
|
+
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
var _a, _b, _c, _d, _e;
|
|
35
|
+
const { filesystem, parameters, print: { colors, error, info, success, warning }, } = toolbox;
|
|
36
|
+
const layout = (0, dev_project_1.resolveLayout)(filesystem.cwd(), filesystem);
|
|
37
|
+
let mainRepoRoot;
|
|
38
|
+
try {
|
|
39
|
+
mainRepoRoot = (0, dev_ticket_1.gitMainRepoRoot)(layout.root);
|
|
40
|
+
}
|
|
41
|
+
catch (_f) {
|
|
42
|
+
error('Not inside a git repository.');
|
|
43
|
+
if (!parameters.options.fromGluegunMenu)
|
|
44
|
+
process.exit(1);
|
|
45
|
+
return 'ticket stop: not a git repo';
|
|
46
|
+
}
|
|
47
|
+
// Id from the argument — or, when invoked with NO id from INSIDE a ticket
|
|
48
|
+
// worktree, the current worktree's own ticket (so a bare `lt ticket stop`
|
|
49
|
+
// cleans up "this" environment and removes this very folder).
|
|
50
|
+
const fromMarker = parameters.first == null ? (0, dev_ticket_1.readTicketMarker)(layout.root) : null;
|
|
51
|
+
const id = String((_b = (_a = parameters.first) !== null && _a !== void 0 ? _a : fromMarker) !== null && _b !== void 0 ? _b : '').trim();
|
|
52
|
+
if (!id) {
|
|
53
|
+
error('Usage: lt ticket stop <id> [--drop-db] [--force] — or run with no id from INSIDE a ticket worktree.');
|
|
54
|
+
if (!parameters.options.fromGluegunMenu)
|
|
55
|
+
process.exit(1);
|
|
56
|
+
return 'ticket stop: missing id';
|
|
57
|
+
}
|
|
58
|
+
const wt = (0, dev_ticket_1.listWorktrees)(mainRepoRoot).find((w) => w.ticket === id);
|
|
59
|
+
if (!wt) {
|
|
60
|
+
error(`No ticket worktree "${id}" found. See \`lt ticket list\`.`);
|
|
61
|
+
if (!parameters.options.fromGluegunMenu)
|
|
62
|
+
process.exit(1);
|
|
63
|
+
return 'ticket stop: not found';
|
|
64
|
+
}
|
|
65
|
+
// SAFETY: never silently delete unsaved work. Warn + REFUSE (unless --force)
|
|
66
|
+
// when the worktree has uncommitted changes OR unpushed commits, so the user
|
|
67
|
+
// commits + pushes first. (`--force` removes anyway; the branch is kept, so
|
|
68
|
+
// committed history survives regardless.)
|
|
69
|
+
const safety = (0, dev_ticket_1.worktreeSafetyReport)(wt.path);
|
|
70
|
+
if ((safety.dirtySource.length > 0 || safety.unpushed > 0) && parameters.options.force !== true) {
|
|
71
|
+
warning('');
|
|
72
|
+
warning(`Refusing to remove ticket "${id}" — work is not fully committed + pushed:`);
|
|
73
|
+
if (safety.dirtySource.length > 0) {
|
|
74
|
+
warning(` • ${safety.dirtySource.length} uncommitted change(s) — would be LOST on removal:`);
|
|
75
|
+
safety.dirtySource.slice(0, 12).forEach((l) => info(colors.dim(` ${l}`)));
|
|
76
|
+
if (safety.dirtySource.length > 12)
|
|
77
|
+
info(colors.dim(` … and ${safety.dirtySource.length - 12} more`));
|
|
78
|
+
}
|
|
79
|
+
if (safety.unpushed > 0) {
|
|
80
|
+
warning(` • ${safety.unpushed} commit(s) on "${(_c = wt.branch) !== null && _c !== void 0 ? _c : '-'}" not pushed to any remote`);
|
|
81
|
+
}
|
|
82
|
+
info('');
|
|
83
|
+
info(colors.dim(' Commit + push first (the branch is kept), or re-run with --force to remove anyway.'));
|
|
84
|
+
if (!parameters.options.fromGluegunMenu)
|
|
85
|
+
process.exit(1);
|
|
86
|
+
return 'ticket stop: unsaved work (use --force)';
|
|
87
|
+
}
|
|
88
|
+
// If we are removing the worktree we are standing in, step the process out
|
|
89
|
+
// to the main repo first so git can remove the folder cleanly.
|
|
90
|
+
const removingCwd = fromMarker !== null || samePath(wt.path, layout.root);
|
|
91
|
+
if (removingCwd) {
|
|
92
|
+
try {
|
|
93
|
+
process.chdir(mainRepoRoot);
|
|
94
|
+
}
|
|
95
|
+
catch (_g) {
|
|
96
|
+
/* best-effort */
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
info('');
|
|
100
|
+
info(colors.bold(`Stopping ticket "${id}"`));
|
|
101
|
+
// 1. Tear the isolated stack down from inside the worktree (marker-aware).
|
|
102
|
+
info(colors.dim(' lt dev down …'));
|
|
103
|
+
yield (0, dev_process_1.runChildInherit)(process.execPath, [process.argv[1], 'dev', 'down'], { cwd: wt.path, env: process.env });
|
|
104
|
+
// 2. Optionally drop the ticket databases (they are otherwise just left empty).
|
|
105
|
+
if (parameters.options.dropDb === true || parameters.options['drop-db'] === true) {
|
|
106
|
+
const base = (0, dev_identity_1.buildIdentity)(mainRepoRoot);
|
|
107
|
+
const entry = (0, dev_state_1.loadRegistry)().projects[`${base.slug}-${id}`];
|
|
108
|
+
const mainLayout = (0, dev_project_1.resolveLayout)(mainRepoRoot, filesystem);
|
|
109
|
+
const devDb = (_d = entry === null || entry === void 0 ? void 0 : entry.dbName) !== null && _d !== void 0 ? _d : (0, dev_project_1.deriveTicketDbName)((0, dev_project_1.deriveDbName)(mainLayout.apiDir, base.slug), id);
|
|
110
|
+
const testDb = (0, dev_project_1.deriveTestDbName)(devDb);
|
|
111
|
+
for (const db of [devDb, testDb]) {
|
|
112
|
+
if ((0, dev_ticket_1.dropDatabase)(db))
|
|
113
|
+
info(colors.dim(` dropped db ${db}`));
|
|
114
|
+
else
|
|
115
|
+
warning(` could not drop db ${db} (mongosh missing or DB not reachable) — drop it manually if needed.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// 3. Remove the worktree (branch is kept). Auto-force when the ONLY dirty
|
|
119
|
+
// files are framework-generated (e.g. `nuxt dev` rewrites the tracked
|
|
120
|
+
// `.nuxtrc` on boot), which would otherwise block the remove — but NEVER
|
|
121
|
+
// discard real source edits (those keep the non-forced remove, which
|
|
122
|
+
// errors with a hint so unsaved work is never lost).
|
|
123
|
+
const force = parameters.options.force === true || (0, dev_ticket_1.worktreeDirtyOnlyGenerated)(wt.path);
|
|
124
|
+
if (force && parameters.options.force !== true) {
|
|
125
|
+
info(colors.dim(' (worktree had only generated files dirty, e.g. .nuxtrc — removing)'));
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
(0, dev_ticket_1.worktreeRemove)(mainRepoRoot, wt.path, force);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
error(`git worktree remove failed: ${e.message}`);
|
|
132
|
+
info(colors.dim(' The worktree has uncommitted SOURCE changes — commit/stash them, or pass --force to discard.'));
|
|
133
|
+
if (!parameters.options.fromGluegunMenu)
|
|
134
|
+
process.exit(1);
|
|
135
|
+
return 'ticket stop: worktree remove failed';
|
|
136
|
+
}
|
|
137
|
+
// The whole env is gone now — drop the ticket's registry entry so its slug +
|
|
138
|
+
// reserved ports are reclaimed (`lt dev down` only ends the session, keeping
|
|
139
|
+
// the entry for a restart; `lt ticket stop` removes the env entirely).
|
|
140
|
+
{
|
|
141
|
+
const reg = (0, dev_state_1.loadRegistry)();
|
|
142
|
+
const ticketSlug = `${(0, dev_identity_1.buildIdentity)(mainRepoRoot).slug}-${id}`;
|
|
143
|
+
if (reg.projects[ticketSlug]) {
|
|
144
|
+
delete reg.projects[ticketSlug];
|
|
145
|
+
(0, dev_state_1.saveRegistry)(reg);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
info('');
|
|
149
|
+
success(`Ticket "${id}" stopped — worktree removed, branch "${(_e = wt.branch) !== null && _e !== void 0 ? _e : '-'}" kept.`);
|
|
150
|
+
if (removingCwd)
|
|
151
|
+
info(colors.dim(` This folder is gone — your shell is still in it. Run: cd ${mainRepoRoot}`));
|
|
152
|
+
if (!parameters.options.fromGluegunMenu)
|
|
153
|
+
process.exit();
|
|
154
|
+
return `ticket stop: ${id}`;
|
|
155
|
+
}),
|
|
156
|
+
};
|
|
157
|
+
/** True if two paths point at the same location (resolving symlinks, e.g. /tmp → /private/tmp). */
|
|
158
|
+
function samePath(a, b) {
|
|
159
|
+
try {
|
|
160
|
+
return (0, fs_1.realpathSync)(a) === (0, fs_1.realpathSync)(b);
|
|
161
|
+
}
|
|
162
|
+
catch (_a) {
|
|
163
|
+
return a === b;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
module.exports = StopCommand;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const dev_project_1 = require("../../lib/dev-project");
|
|
14
|
+
const dev_ticket_1 = require("../../lib/dev-ticket");
|
|
15
|
+
/**
|
|
16
|
+
* `lt ticket switch <id>` — show a ticket worktree's path and open it in your
|
|
17
|
+
* editor (best-effort). A CLI cannot change the parent shell's directory, so it
|
|
18
|
+
* also prints the `cd` line to copy. `--no-open` only prints.
|
|
19
|
+
*/
|
|
20
|
+
const SwitchCommand = {
|
|
21
|
+
alias: ['sw', 'open'],
|
|
22
|
+
description: 'Show a ticket worktree path + open it in your editor',
|
|
23
|
+
name: 'switch',
|
|
24
|
+
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
var _a;
|
|
26
|
+
const { filesystem, parameters, print: { colors, error, info, success }, } = toolbox;
|
|
27
|
+
const id = String((_a = parameters.first) !== null && _a !== void 0 ? _a : '').trim();
|
|
28
|
+
if (!id) {
|
|
29
|
+
error('Usage: lt ticket switch <id>');
|
|
30
|
+
if (!parameters.options.fromGluegunMenu)
|
|
31
|
+
process.exit(1);
|
|
32
|
+
return 'ticket switch: missing id';
|
|
33
|
+
}
|
|
34
|
+
const layout = (0, dev_project_1.resolveLayout)(filesystem.cwd(), filesystem);
|
|
35
|
+
let mainRepoRoot;
|
|
36
|
+
try {
|
|
37
|
+
mainRepoRoot = (0, dev_ticket_1.gitMainRepoRoot)(layout.root);
|
|
38
|
+
}
|
|
39
|
+
catch (_b) {
|
|
40
|
+
error('Not inside a git repository.');
|
|
41
|
+
if (!parameters.options.fromGluegunMenu)
|
|
42
|
+
process.exit(1);
|
|
43
|
+
return 'ticket switch: not a git repo';
|
|
44
|
+
}
|
|
45
|
+
const wt = (0, dev_ticket_1.listWorktrees)(mainRepoRoot).find((w) => w.ticket === id);
|
|
46
|
+
if (!wt) {
|
|
47
|
+
error(`No ticket worktree "${id}" found. See \`lt ticket list\`.`);
|
|
48
|
+
if (!parameters.options.fromGluegunMenu)
|
|
49
|
+
process.exit(1);
|
|
50
|
+
return 'ticket switch: not found';
|
|
51
|
+
}
|
|
52
|
+
info('');
|
|
53
|
+
info(`Ticket "${id}" → ${wt.path}`);
|
|
54
|
+
info(colors.dim(` cd ${wt.path}`));
|
|
55
|
+
if (parameters.options.open !== false) {
|
|
56
|
+
const editor = process.env.LT_EDITOR || 'code';
|
|
57
|
+
try {
|
|
58
|
+
(0, child_process_1.execFileSync)(editor, [wt.path], { stdio: 'ignore' });
|
|
59
|
+
success(`Opened in ${editor}.`);
|
|
60
|
+
}
|
|
61
|
+
catch (_c) {
|
|
62
|
+
info(colors.dim(` (could not run \`${editor}\` — open the folder manually, or set LT_EDITOR)`));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!parameters.options.fromGluegunMenu)
|
|
66
|
+
process.exit();
|
|
67
|
+
return `ticket switch: ${id}`;
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
module.exports = SwitchCommand;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const dev_process_1 = require("../../lib/dev-process");
|
|
13
|
+
const dev_project_1 = require("../../lib/dev-project");
|
|
14
|
+
const dev_ticket_1 = require("../../lib/dev-ticket");
|
|
15
|
+
/**
|
|
16
|
+
* `lt ticket test <id> [--shard N] [-- <args>]` — run the E2E suite for a ticket
|
|
17
|
+
* in ITS isolated stack + DB, by delegating to `lt dev test` inside the ticket
|
|
18
|
+
* worktree (which is ticket-aware via the marker → test DB `<base>-<id>-test`).
|
|
19
|
+
*/
|
|
20
|
+
const TestCommand = {
|
|
21
|
+
alias: ['t'],
|
|
22
|
+
description: 'Run the E2E suite for a ticket in its isolated stack',
|
|
23
|
+
name: 'test',
|
|
24
|
+
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
var _a;
|
|
26
|
+
const { filesystem, parameters, print: { colors, error, info }, } = toolbox;
|
|
27
|
+
const id = String((_a = parameters.first) !== null && _a !== void 0 ? _a : '').trim();
|
|
28
|
+
if (!id) {
|
|
29
|
+
error('Usage: lt ticket test <id> [--shard N] [--keep] [-- <playwright args>]');
|
|
30
|
+
if (!parameters.options.fromGluegunMenu)
|
|
31
|
+
process.exit(1);
|
|
32
|
+
return 'ticket test: missing id';
|
|
33
|
+
}
|
|
34
|
+
const layout = (0, dev_project_1.resolveLayout)(filesystem.cwd(), filesystem);
|
|
35
|
+
let mainRepoRoot;
|
|
36
|
+
try {
|
|
37
|
+
mainRepoRoot = (0, dev_ticket_1.gitMainRepoRoot)(layout.root);
|
|
38
|
+
}
|
|
39
|
+
catch (_b) {
|
|
40
|
+
error('Not inside a git repository.');
|
|
41
|
+
if (!parameters.options.fromGluegunMenu)
|
|
42
|
+
process.exit(1);
|
|
43
|
+
return 'ticket test: not a git repo';
|
|
44
|
+
}
|
|
45
|
+
const wt = (0, dev_ticket_1.listWorktrees)(mainRepoRoot).find((w) => w.ticket === id);
|
|
46
|
+
if (!wt) {
|
|
47
|
+
error(`No ticket worktree "${id}" found. See \`lt ticket list\`.`);
|
|
48
|
+
if (!parameters.options.fromGluegunMenu)
|
|
49
|
+
process.exit(1);
|
|
50
|
+
return 'ticket test: not found';
|
|
51
|
+
}
|
|
52
|
+
// Reconstruct `lt dev test` args: forward the common flags + the `--` array.
|
|
53
|
+
const devArgs = ['dev', 'test'];
|
|
54
|
+
if (parameters.options.shard !== undefined) {
|
|
55
|
+
const s = parameters.options.shard;
|
|
56
|
+
devArgs.push(s === true ? '--shard' : `--shard=${s}`);
|
|
57
|
+
}
|
|
58
|
+
if (parameters.options.keep === true)
|
|
59
|
+
devArgs.push('--keep');
|
|
60
|
+
if (parameters.options.debug === true)
|
|
61
|
+
devArgs.push('--debug');
|
|
62
|
+
// Playwright args after `--` (e.g. a spec path / `--grep`): read them from
|
|
63
|
+
// the RAW argv. gluegun's parsed `parameters.array` does not reliably carry
|
|
64
|
+
// post-`--` tokens through the `ticket <id>` positional, which silently ran
|
|
65
|
+
// the WHOLE suite instead of the requested spec.
|
|
66
|
+
const dashIdx = process.argv.indexOf('--');
|
|
67
|
+
const forwarded = dashIdx >= 0 ? process.argv.slice(dashIdx + 1) : [];
|
|
68
|
+
if (forwarded.length > 0)
|
|
69
|
+
devArgs.push('--', ...forwarded);
|
|
70
|
+
info(colors.dim(`(cd ${wt.path} && lt ${devArgs.join(' ')})`));
|
|
71
|
+
const code = yield (0, dev_process_1.runChildInherit)(process.execPath, [process.argv[1], ...devArgs], {
|
|
72
|
+
cwd: wt.path,
|
|
73
|
+
env: process.env,
|
|
74
|
+
});
|
|
75
|
+
if (!parameters.options.fromGluegunMenu)
|
|
76
|
+
process.exit(code !== null && code !== void 0 ? code : 1);
|
|
77
|
+
return `ticket test: ${id} exit=${code}`;
|
|
78
|
+
}),
|
|
79
|
+
};
|
|
80
|
+
module.exports = TestCommand;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/**
|
|
13
|
+
* Parallel ticket dev environments (`lt ticket <subcommand>`).
|
|
14
|
+
*
|
|
15
|
+
* Each ticket runs in its OWN git worktree (a fresh branch from `origin/dev`)
|
|
16
|
+
* with its OWN isolated `lt dev` stack — own URLs, ports, Caddy block and empty
|
|
17
|
+
* database — so several tickets can be developed, browser-tested and E2E-tested
|
|
18
|
+
* fully in parallel without ever influencing each other.
|
|
19
|
+
*
|
|
20
|
+
* Subcommands:
|
|
21
|
+
* - `start <name>` — create the worktree + bring the isolated stack up
|
|
22
|
+
* - `list` — dashboard of all ticket envs (URLs, branch, status, DB)
|
|
23
|
+
* - `switch <id>` — show + open a ticket worktree in your editor
|
|
24
|
+
* - `test <id>` — run the E2E suite in the ticket's isolated stack
|
|
25
|
+
* - `stop <id>` — tear the env down + remove the worktree (branch kept)
|
|
26
|
+
*/
|
|
27
|
+
module.exports = {
|
|
28
|
+
alias: ['tk'],
|
|
29
|
+
description: 'Parallel ticket dev environments (worktree + isolated lt dev stack)',
|
|
30
|
+
hidden: false,
|
|
31
|
+
name: 'ticket',
|
|
32
|
+
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
yield toolbox.helper.showMenu('ticket');
|
|
34
|
+
return 'ticket';
|
|
35
|
+
}),
|
|
36
|
+
};
|