@desplega.ai/wts 0.1.1 → 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 +148 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1874,6 +1874,58 @@ var {
|
|
|
1874
1874
|
Option,
|
|
1875
1875
|
Help
|
|
1876
1876
|
} = import__.default;
|
|
1877
|
+
// package.json
|
|
1878
|
+
var package_default = {
|
|
1879
|
+
name: "@desplega.ai/wts",
|
|
1880
|
+
version: "0.1.3",
|
|
1881
|
+
description: "Git worktree manager with tmux integration",
|
|
1882
|
+
type: "module",
|
|
1883
|
+
bin: {
|
|
1884
|
+
wts: "./dist/index.js"
|
|
1885
|
+
},
|
|
1886
|
+
files: [
|
|
1887
|
+
"dist"
|
|
1888
|
+
],
|
|
1889
|
+
scripts: {
|
|
1890
|
+
dev: "bun src/index.ts",
|
|
1891
|
+
build: "bun build src/index.ts --outdir dist --target node --format esm",
|
|
1892
|
+
prepublishOnly: "bun run build",
|
|
1893
|
+
release: "bun run build && bun publish",
|
|
1894
|
+
lint: "biome check src",
|
|
1895
|
+
"lint:fix": "biome check --write src",
|
|
1896
|
+
format: "biome format --write src",
|
|
1897
|
+
test: "bun test",
|
|
1898
|
+
"tsc:check": "bun tsc --noEmit"
|
|
1899
|
+
},
|
|
1900
|
+
dependencies: {
|
|
1901
|
+
commander: "^12.1.0",
|
|
1902
|
+
chalk: "^5.4.1"
|
|
1903
|
+
},
|
|
1904
|
+
devDependencies: {
|
|
1905
|
+
"@biomejs/biome": "^2.3.9",
|
|
1906
|
+
"@types/bun": "latest"
|
|
1907
|
+
},
|
|
1908
|
+
peerDependencies: {
|
|
1909
|
+
typescript: "^5"
|
|
1910
|
+
},
|
|
1911
|
+
publishConfig: {
|
|
1912
|
+
access: "public"
|
|
1913
|
+
},
|
|
1914
|
+
repository: {
|
|
1915
|
+
type: "git",
|
|
1916
|
+
url: "https://github.com/anthropics/ai-toolbox.git",
|
|
1917
|
+
directory: "wts"
|
|
1918
|
+
},
|
|
1919
|
+
keywords: [
|
|
1920
|
+
"git",
|
|
1921
|
+
"worktree",
|
|
1922
|
+
"tmux",
|
|
1923
|
+
"cli",
|
|
1924
|
+
"developer-tools"
|
|
1925
|
+
],
|
|
1926
|
+
license: "MIT",
|
|
1927
|
+
author: "Desplega AI"
|
|
1928
|
+
};
|
|
1877
1929
|
|
|
1878
1930
|
// node_modules/commander/esm.mjs
|
|
1879
1931
|
var import__2 = __toESM(require_commander(), 1);
|
|
@@ -3356,6 +3408,100 @@ var prCommand = new Command2("pr").description("Create a pull request from a wor
|
|
|
3356
3408
|
}
|
|
3357
3409
|
});
|
|
3358
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
|
+
|
|
3359
3505
|
// src/commands/switch.ts
|
|
3360
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) => {
|
|
3361
3507
|
const gitRoot = await getGitRoot();
|
|
@@ -3425,7 +3571,7 @@ var switchCommand = new Command2("switch").description("Switch to a worktree (in
|
|
|
3425
3571
|
|
|
3426
3572
|
// src/index.ts
|
|
3427
3573
|
var program3 = new Command;
|
|
3428
|
-
program3.name("wts").description(
|
|
3574
|
+
program3.name("wts").description(package_default.description).version(package_default.version);
|
|
3429
3575
|
program3.addCommand(initCommand);
|
|
3430
3576
|
program3.addCommand(listCommand);
|
|
3431
3577
|
program3.addCommand(createCommand3);
|
|
@@ -3433,5 +3579,6 @@ program3.addCommand(deleteCommand);
|
|
|
3433
3579
|
program3.addCommand(cdCommand);
|
|
3434
3580
|
program3.addCommand(switchCommand);
|
|
3435
3581
|
program3.addCommand(prCommand);
|
|
3582
|
+
program3.addCommand(setupCommand);
|
|
3436
3583
|
program3.addCommand(cleanupCommand);
|
|
3437
3584
|
program3.parse();
|