@desplega.ai/wts 0.1.2 → 0.1.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/dist/index.js +96 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1877,7 +1877,7 @@ var {
|
|
|
1877
1877
|
// package.json
|
|
1878
1878
|
var package_default = {
|
|
1879
1879
|
name: "@desplega.ai/wts",
|
|
1880
|
-
version: "0.1.
|
|
1880
|
+
version: "0.1.3",
|
|
1881
1881
|
description: "Git worktree manager with tmux integration",
|
|
1882
1882
|
type: "module",
|
|
1883
1883
|
bin: {
|
|
@@ -3408,6 +3408,100 @@ var prCommand = new Command2("pr").description("Create a pull request from a wor
|
|
|
3408
3408
|
}
|
|
3409
3409
|
});
|
|
3410
3410
|
|
|
3411
|
+
// src/commands/setup.ts
|
|
3412
|
+
import { access as access2, chmod } from "node:fs/promises";
|
|
3413
|
+
import { join as join5 } from "node:path";
|
|
3414
|
+
var SHELL_TEMPLATE = `#!/bin/bash
|
|
3415
|
+
# wts setup script - runs after worktree creation
|
|
3416
|
+
# Working directory: the new worktree
|
|
3417
|
+
# Environment: WTS_WORKTREE_PATH contains the worktree path
|
|
3418
|
+
|
|
3419
|
+
set -e
|
|
3420
|
+
|
|
3421
|
+
echo "Setting up worktree..."
|
|
3422
|
+
|
|
3423
|
+
# Install dependencies
|
|
3424
|
+
# npm install
|
|
3425
|
+
# bun install
|
|
3426
|
+
|
|
3427
|
+
# Copy environment files
|
|
3428
|
+
# cp .env.example .env
|
|
3429
|
+
|
|
3430
|
+
# Run any other setup tasks
|
|
3431
|
+
# ...
|
|
3432
|
+
|
|
3433
|
+
echo "Setup complete!"
|
|
3434
|
+
`;
|
|
3435
|
+
var TS_TEMPLATE = `#!/usr/bin/env bun
|
|
3436
|
+
// wts setup script - runs after worktree creation
|
|
3437
|
+
// Working directory: the new worktree
|
|
3438
|
+
// Environment: WTS_WORKTREE_PATH contains the worktree path
|
|
3439
|
+
|
|
3440
|
+
const worktreePath = process.env.WTS_WORKTREE_PATH;
|
|
3441
|
+
|
|
3442
|
+
console.log("Setting up worktree...");
|
|
3443
|
+
|
|
3444
|
+
// Install dependencies
|
|
3445
|
+
// await Bun.$\`npm install\`;
|
|
3446
|
+
// await Bun.$\`bun install\`;
|
|
3447
|
+
|
|
3448
|
+
// Copy environment files
|
|
3449
|
+
// await Bun.$\`cp .env.example .env\`;
|
|
3450
|
+
|
|
3451
|
+
// Run any other setup tasks
|
|
3452
|
+
// ...
|
|
3453
|
+
|
|
3454
|
+
console.log("Setup complete!");
|
|
3455
|
+
`;
|
|
3456
|
+
var setupCommand = new Command2("setup").description("Generate a setup script template for worktree initialization").option("--sh", "Generate a shell script (.wts-setup.sh)").option("--ts", "Generate a TypeScript script (.wts-setup.ts)").option("--no-config", "Don't update .wts-config.json").action(async (options) => {
|
|
3457
|
+
const gitRoot = await getGitRoot();
|
|
3458
|
+
if (!gitRoot) {
|
|
3459
|
+
console.error(source_default.red("Error: Not in a git repository"));
|
|
3460
|
+
process.exit(1);
|
|
3461
|
+
}
|
|
3462
|
+
let scriptType;
|
|
3463
|
+
if (options.sh && options.ts) {
|
|
3464
|
+
console.error(source_default.red("Error: Cannot specify both --sh and --ts"));
|
|
3465
|
+
process.exit(1);
|
|
3466
|
+
} else if (options.sh) {
|
|
3467
|
+
scriptType = "sh";
|
|
3468
|
+
} else if (options.ts) {
|
|
3469
|
+
scriptType = "ts";
|
|
3470
|
+
} else {
|
|
3471
|
+
scriptType = await select("Which type of setup script would you like?", [
|
|
3472
|
+
{ value: "sh", label: "Shell script (.wts-setup.sh)" },
|
|
3473
|
+
{ value: "ts", label: "TypeScript (.wts-setup.ts) - requires bun" }
|
|
3474
|
+
], "sh");
|
|
3475
|
+
}
|
|
3476
|
+
const filename = `.wts-setup.${scriptType}`;
|
|
3477
|
+
const filepath = join5(gitRoot, filename);
|
|
3478
|
+
try {
|
|
3479
|
+
await access2(filepath);
|
|
3480
|
+
const overwrite = await confirm(`${filename} already exists. Overwrite?`, false);
|
|
3481
|
+
if (!overwrite) {
|
|
3482
|
+
console.log(source_default.dim("Cancelled"));
|
|
3483
|
+
return;
|
|
3484
|
+
}
|
|
3485
|
+
} catch {}
|
|
3486
|
+
const template = scriptType === "sh" ? SHELL_TEMPLATE : TS_TEMPLATE;
|
|
3487
|
+
await Bun.write(filepath, template);
|
|
3488
|
+
if (scriptType === "sh") {
|
|
3489
|
+
await chmod(filepath, 493);
|
|
3490
|
+
}
|
|
3491
|
+
console.log(source_default.green(`Created ${filename}`));
|
|
3492
|
+
if (options.config !== false) {
|
|
3493
|
+
const localConfig = await loadLocalConfig(gitRoot) ?? {};
|
|
3494
|
+
localConfig.setupScript = filename;
|
|
3495
|
+
await saveLocalConfig(gitRoot, localConfig);
|
|
3496
|
+
console.log(source_default.dim(`Updated .wts-config.json with setupScript: "${filename}"`));
|
|
3497
|
+
}
|
|
3498
|
+
console.log(source_default.dim(`
|
|
3499
|
+
Next steps:`));
|
|
3500
|
+
console.log(source_default.dim(` 1. Edit ${filename} to add your setup commands`));
|
|
3501
|
+
console.log(source_default.dim(` 2. Run 'wts create <alias>' - setup script will run automatically`));
|
|
3502
|
+
console.log(source_default.dim(` 3. Use '--no-setup' flag to skip the script when needed`));
|
|
3503
|
+
});
|
|
3504
|
+
|
|
3411
3505
|
// src/commands/switch.ts
|
|
3412
3506
|
var switchCommand = new Command2("switch").description("Switch to a worktree (interactive or by alias)").argument("[alias]", "Worktree alias to switch to").option("--tmux", "Open in a new tmux window").option("--claude", "Launch Claude Code in the tmux window").action(async (alias, options) => {
|
|
3413
3507
|
const gitRoot = await getGitRoot();
|
|
@@ -3485,5 +3579,6 @@ program3.addCommand(deleteCommand);
|
|
|
3485
3579
|
program3.addCommand(cdCommand);
|
|
3486
3580
|
program3.addCommand(switchCommand);
|
|
3487
3581
|
program3.addCommand(prCommand);
|
|
3582
|
+
program3.addCommand(setupCommand);
|
|
3488
3583
|
program3.addCommand(cleanupCommand);
|
|
3489
3584
|
program3.parse();
|