@desplega.ai/wts 0.1.2 → 0.1.4
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 +109 -5
- 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.4",
|
|
1881
1881
|
description: "Git worktree manager with tmux integration",
|
|
1882
1882
|
type: "module",
|
|
1883
1883
|
bin: {
|
|
@@ -3046,14 +3046,19 @@ async function runSetupScript(worktreePath, scriptPath, gitRoot) {
|
|
|
3046
3046
|
}
|
|
3047
3047
|
const ext = scriptPath.split(".").pop()?.toLowerCase();
|
|
3048
3048
|
try {
|
|
3049
|
+
const env2 = {
|
|
3050
|
+
...process.env,
|
|
3051
|
+
WTS_WORKTREE_PATH: worktreePath,
|
|
3052
|
+
WTS_GIT_ROOT: gitRoot
|
|
3053
|
+
};
|
|
3049
3054
|
if (ext === "ts") {
|
|
3050
|
-
await Bun.$`bun ${fullScriptPath}`.cwd(worktreePath).env(
|
|
3055
|
+
await Bun.$`bun ${fullScriptPath}`.cwd(worktreePath).env(env2);
|
|
3051
3056
|
} else if (ext === "sh") {
|
|
3052
|
-
await Bun.$`bash ${fullScriptPath}`.cwd(worktreePath).env(
|
|
3057
|
+
await Bun.$`bash ${fullScriptPath}`.cwd(worktreePath).env(env2);
|
|
3053
3058
|
} else if (ext === "js" || ext === "mjs") {
|
|
3054
|
-
await Bun.$`bun ${fullScriptPath}`.cwd(worktreePath).env(
|
|
3059
|
+
await Bun.$`bun ${fullScriptPath}`.cwd(worktreePath).env(env2);
|
|
3055
3060
|
} else {
|
|
3056
|
-
await Bun.$`${fullScriptPath}`.cwd(worktreePath).env(
|
|
3061
|
+
await Bun.$`${fullScriptPath}`.cwd(worktreePath).env(env2);
|
|
3057
3062
|
}
|
|
3058
3063
|
console.log(source_default.green("Setup script completed"));
|
|
3059
3064
|
} catch (error) {
|
|
@@ -3408,6 +3413,104 @@ var prCommand = new Command2("pr").description("Create a pull request from a wor
|
|
|
3408
3413
|
}
|
|
3409
3414
|
});
|
|
3410
3415
|
|
|
3416
|
+
// src/commands/setup.ts
|
|
3417
|
+
import { access as access2, chmod } from "node:fs/promises";
|
|
3418
|
+
import { join as join5 } from "node:path";
|
|
3419
|
+
var SHELL_TEMPLATE = `#!/bin/bash
|
|
3420
|
+
# wts setup script - runs after worktree creation
|
|
3421
|
+
#
|
|
3422
|
+
# Environment variables:
|
|
3423
|
+
# WTS_WORKTREE_PATH - path to the new worktree (also the working directory)
|
|
3424
|
+
# WTS_GIT_ROOT - path to the main repository root
|
|
3425
|
+
#
|
|
3426
|
+
# Example: copy .env from main repo to worktree
|
|
3427
|
+
# cp "$WTS_GIT_ROOT/.env" "$WTS_WORKTREE_PATH/.env"
|
|
3428
|
+
|
|
3429
|
+
set -e
|
|
3430
|
+
|
|
3431
|
+
echo "Setting up worktree..."
|
|
3432
|
+
|
|
3433
|
+
# Install dependencies
|
|
3434
|
+
# npm install
|
|
3435
|
+
# bun install
|
|
3436
|
+
|
|
3437
|
+
# Copy files from main repo
|
|
3438
|
+
# cp "$WTS_GIT_ROOT/.env" .env
|
|
3439
|
+
# cp -r "$WTS_GIT_ROOT/node_modules" .
|
|
3440
|
+
|
|
3441
|
+
echo "Setup complete!"
|
|
3442
|
+
`;
|
|
3443
|
+
var TS_TEMPLATE = `#!/usr/bin/env bun
|
|
3444
|
+
// wts setup script - runs after worktree creation
|
|
3445
|
+
//
|
|
3446
|
+
// Environment variables:
|
|
3447
|
+
// WTS_WORKTREE_PATH - path to the new worktree (also the working directory)
|
|
3448
|
+
// WTS_GIT_ROOT - path to the main repository root
|
|
3449
|
+
|
|
3450
|
+
const worktreePath = process.env.WTS_WORKTREE_PATH!;
|
|
3451
|
+
const gitRoot = process.env.WTS_GIT_ROOT!;
|
|
3452
|
+
|
|
3453
|
+
console.log("Setting up worktree...");
|
|
3454
|
+
|
|
3455
|
+
// Install dependencies
|
|
3456
|
+
// await Bun.$\`npm install\`;
|
|
3457
|
+
// await Bun.$\`bun install\`;
|
|
3458
|
+
|
|
3459
|
+
// Copy files from main repo
|
|
3460
|
+
// await Bun.$\`cp \${gitRoot}/.env .env\`;
|
|
3461
|
+
// await Bun.$\`cp -r \${gitRoot}/node_modules .\`;
|
|
3462
|
+
|
|
3463
|
+
console.log("Setup complete!");
|
|
3464
|
+
`;
|
|
3465
|
+
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) => {
|
|
3466
|
+
const gitRoot = await getGitRoot();
|
|
3467
|
+
if (!gitRoot) {
|
|
3468
|
+
console.error(source_default.red("Error: Not in a git repository"));
|
|
3469
|
+
process.exit(1);
|
|
3470
|
+
}
|
|
3471
|
+
let scriptType;
|
|
3472
|
+
if (options.sh && options.ts) {
|
|
3473
|
+
console.error(source_default.red("Error: Cannot specify both --sh and --ts"));
|
|
3474
|
+
process.exit(1);
|
|
3475
|
+
} else if (options.sh) {
|
|
3476
|
+
scriptType = "sh";
|
|
3477
|
+
} else if (options.ts) {
|
|
3478
|
+
scriptType = "ts";
|
|
3479
|
+
} else {
|
|
3480
|
+
scriptType = await select("Which type of setup script would you like?", [
|
|
3481
|
+
{ value: "sh", label: "Shell script (.wts-setup.sh)" },
|
|
3482
|
+
{ value: "ts", label: "TypeScript (.wts-setup.ts) - requires bun" }
|
|
3483
|
+
], "sh");
|
|
3484
|
+
}
|
|
3485
|
+
const filename = `.wts-setup.${scriptType}`;
|
|
3486
|
+
const filepath = join5(gitRoot, filename);
|
|
3487
|
+
try {
|
|
3488
|
+
await access2(filepath);
|
|
3489
|
+
const overwrite = await confirm(`${filename} already exists. Overwrite?`, false);
|
|
3490
|
+
if (!overwrite) {
|
|
3491
|
+
console.log(source_default.dim("Cancelled"));
|
|
3492
|
+
return;
|
|
3493
|
+
}
|
|
3494
|
+
} catch {}
|
|
3495
|
+
const template = scriptType === "sh" ? SHELL_TEMPLATE : TS_TEMPLATE;
|
|
3496
|
+
await Bun.write(filepath, template);
|
|
3497
|
+
if (scriptType === "sh") {
|
|
3498
|
+
await chmod(filepath, 493);
|
|
3499
|
+
}
|
|
3500
|
+
console.log(source_default.green(`Created ${filename}`));
|
|
3501
|
+
if (options.config !== false) {
|
|
3502
|
+
const localConfig = await loadLocalConfig(gitRoot) ?? {};
|
|
3503
|
+
localConfig.setupScript = filename;
|
|
3504
|
+
await saveLocalConfig(gitRoot, localConfig);
|
|
3505
|
+
console.log(source_default.dim(`Updated .wts-config.json with setupScript: "${filename}"`));
|
|
3506
|
+
}
|
|
3507
|
+
console.log(source_default.dim(`
|
|
3508
|
+
Next steps:`));
|
|
3509
|
+
console.log(source_default.dim(` 1. Edit ${filename} to add your setup commands`));
|
|
3510
|
+
console.log(source_default.dim(` 2. Run 'wts create <alias>' - setup script will run automatically`));
|
|
3511
|
+
console.log(source_default.dim(` 3. Use '--no-setup' flag to skip the script when needed`));
|
|
3512
|
+
});
|
|
3513
|
+
|
|
3411
3514
|
// src/commands/switch.ts
|
|
3412
3515
|
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
3516
|
const gitRoot = await getGitRoot();
|
|
@@ -3485,5 +3588,6 @@ program3.addCommand(deleteCommand);
|
|
|
3485
3588
|
program3.addCommand(cdCommand);
|
|
3486
3589
|
program3.addCommand(switchCommand);
|
|
3487
3590
|
program3.addCommand(prCommand);
|
|
3591
|
+
program3.addCommand(setupCommand);
|
|
3488
3592
|
program3.addCommand(cleanupCommand);
|
|
3489
3593
|
program3.parse();
|