@dezkareid/osddt 1.11.6 → 1.11.8
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/dist/index.js +29 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -126,7 +126,27 @@ const COMMAND_DEFINITIONS = [
|
|
|
126
126
|
{
|
|
127
127
|
name: 'osddt.continue',
|
|
128
128
|
description: 'Detect the current workflow phase and prompt the next command to run',
|
|
129
|
-
body: ({ args, npxCommand }) => `${getRepoPreamble(npxCommand)}
|
|
129
|
+
body: ({ args, npxCommand }) => `${getRepoPreamble(npxCommand)}### Resolving the Feature Name and Working Directory
|
|
130
|
+
|
|
131
|
+
Use the following logic to determine the working directory:
|
|
132
|
+
|
|
133
|
+
**If \`worktree-repository\` is present in \`.osddtrc\` (worktree mode):**
|
|
134
|
+
|
|
135
|
+
1. If arguments were provided, derive the feature name from them:
|
|
136
|
+
- If the argument looks like a branch name (no spaces, kebab-case or slash-separated), use the last segment (after the last \`/\`, or the full value if no \`/\` is present).
|
|
137
|
+
- Otherwise convert it to a feature name following the Feature Name Constraints.
|
|
138
|
+
2. Run \`${npxCommand} worktree-info\` (pass \`<feature-name>\` as argument if one was derived, otherwise run without arguments):
|
|
139
|
+
- exit code **0**: parse the JSON and use the returned \`workingDir\` as the working directory.
|
|
140
|
+
- exit code **1**: display the error output from \`worktree-info\` to the user, then **stop** and instruct them to re-run the command with the chosen feature name as an explicit argument (e.g. \`/osddt.continue <feature-name>\`).
|
|
141
|
+
|
|
142
|
+
**If \`worktree-repository\` is absent in \`.osddtrc\` (standard mode):**
|
|
143
|
+
|
|
144
|
+
1. If arguments were provided, derive the feature name (same rules as above).
|
|
145
|
+
2. If **no arguments were provided**:
|
|
146
|
+
- List all folders under \`<project-path>/working-on/\`.
|
|
147
|
+
- If there is **only one folder**, use it automatically and inform the user.
|
|
148
|
+
- If there are **multiple folders**, display the list as a numbered enumeration, then **stop** and instruct the user to re-run the command with the chosen feature name as an explicit argument (e.g. \`/osddt.continue <feature-name>\`).
|
|
149
|
+
- If there are **no folders**, inform the user that no in-progress features were found and stop.
|
|
130
150
|
|
|
131
151
|
## Instructions
|
|
132
152
|
|
|
@@ -1176,7 +1196,7 @@ function remoteBranchExists(branch, cwd) {
|
|
|
1176
1196
|
return false;
|
|
1177
1197
|
}
|
|
1178
1198
|
}
|
|
1179
|
-
async function prompt
|
|
1199
|
+
async function prompt(question) {
|
|
1180
1200
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1181
1201
|
return new Promise((resolve) => {
|
|
1182
1202
|
rl.question(question, (answer) => {
|
|
@@ -1188,7 +1208,7 @@ async function prompt$1(question) {
|
|
|
1188
1208
|
async function createWorktree(branch, worktreePath, repoRoot, mainBranch) {
|
|
1189
1209
|
if (await fs.pathExists(worktreePath)) {
|
|
1190
1210
|
console.log(`\nDirectory already exists at: ${worktreePath}`);
|
|
1191
|
-
const answer = await prompt
|
|
1211
|
+
const answer = await prompt('Resume or Abort? [R/a] ');
|
|
1192
1212
|
if (answer.toLowerCase() === 'a') {
|
|
1193
1213
|
console.log('Aborted.');
|
|
1194
1214
|
process.exit(0);
|
|
@@ -1199,7 +1219,7 @@ async function createWorktree(branch, worktreePath, repoRoot, mainBranch) {
|
|
|
1199
1219
|
const remoteExists = !localExists && remoteBranchExists(branch, repoRoot);
|
|
1200
1220
|
if (localExists || remoteExists) {
|
|
1201
1221
|
console.log(`\nBranch "${branch}" already exists ${localExists ? 'locally' : 'on remote'}.`);
|
|
1202
|
-
const answer = await prompt
|
|
1222
|
+
const answer = await prompt('Resume or Abort? [R/a] ');
|
|
1203
1223
|
if (answer.toLowerCase() === 'a') {
|
|
1204
1224
|
console.log('Aborted.');
|
|
1205
1225
|
process.exit(0);
|
|
@@ -1233,7 +1253,7 @@ async function runStartWorktree(featureName, options) {
|
|
|
1233
1253
|
if (existingPath) {
|
|
1234
1254
|
const workingDir = path.join(existingPath, 'working-on', featureName);
|
|
1235
1255
|
console.log(`\nWorktree for "${featureName}" already exists at: ${existingPath}`);
|
|
1236
|
-
const answer = await prompt
|
|
1256
|
+
const answer = await prompt('Resume or Abort? [R/a] ');
|
|
1237
1257
|
if (answer.toLowerCase() === 'a') {
|
|
1238
1258
|
console.log('Aborted.');
|
|
1239
1259
|
process.exit(0);
|
|
@@ -1252,7 +1272,7 @@ async function runStartWorktree(featureName, options) {
|
|
|
1252
1272
|
// Resolve working dir
|
|
1253
1273
|
let projectPath;
|
|
1254
1274
|
if (rc['repoType'] === 'monorepo') {
|
|
1255
|
-
const pkg = options.dir ?? await prompt
|
|
1275
|
+
const pkg = options.dir ?? await prompt('Package path (e.g. packages/my-package): ');
|
|
1256
1276
|
projectPath = path.join(worktreePath, pkg);
|
|
1257
1277
|
}
|
|
1258
1278
|
else {
|
|
@@ -1278,28 +1298,6 @@ function startWorktreeCommand() {
|
|
|
1278
1298
|
return cmd;
|
|
1279
1299
|
}
|
|
1280
1300
|
|
|
1281
|
-
async function prompt(question) {
|
|
1282
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1283
|
-
return new Promise((resolve) => {
|
|
1284
|
-
rl.question(question, (answer) => {
|
|
1285
|
-
rl.close();
|
|
1286
|
-
resolve(answer.trim());
|
|
1287
|
-
});
|
|
1288
|
-
});
|
|
1289
|
-
}
|
|
1290
|
-
async function selectWorktree(entries) {
|
|
1291
|
-
console.log('\nMultiple feature worktrees found:');
|
|
1292
|
-
entries.forEach((e, i) => {
|
|
1293
|
-
console.log(` ${i + 1}) ${e.featureName} (${e.branch})`);
|
|
1294
|
-
});
|
|
1295
|
-
const answer = await prompt(`Select a feature [1-${entries.length}]: `);
|
|
1296
|
-
const index = parseInt(answer, 10) - 1;
|
|
1297
|
-
if (index < 0 || index >= entries.length || isNaN(index)) {
|
|
1298
|
-
console.error('Invalid selection.');
|
|
1299
|
-
process.exit(1);
|
|
1300
|
-
}
|
|
1301
|
-
return entries[index];
|
|
1302
|
-
}
|
|
1303
1301
|
async function runWorktreeInfo(featureName) {
|
|
1304
1302
|
const cwd = process.cwd();
|
|
1305
1303
|
const barePath = await resolveBarePath(cwd);
|
|
@@ -1328,7 +1326,9 @@ async function runWorktreeInfo(featureName) {
|
|
|
1328
1326
|
entry = entries[0];
|
|
1329
1327
|
}
|
|
1330
1328
|
else {
|
|
1331
|
-
|
|
1329
|
+
console.error('Multiple feature worktrees found. Re-run with a feature name:');
|
|
1330
|
+
entries.forEach(e => console.error(` - ${e.featureName} (${e.branch})`));
|
|
1331
|
+
process.exit(1);
|
|
1332
1332
|
}
|
|
1333
1333
|
}
|
|
1334
1334
|
console.log(JSON.stringify({ worktreePath: entry.worktreePath, workingDir: entry.workingDir, branch: entry.branch }));
|