workshell 0.0.3 → 0.0.5
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/README.md +19 -10
- package/dist/index.js +14 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,19 @@ $ npm i -g workshell
|
|
|
79
79
|
|
|
80
80
|
<br/>
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
This installs the `workshell` CLI. For convenience, it's also aliased to `wksh`. We'll use `wksh` throughout the quickstart.
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
$ wksh status
|
|
86
|
+
|
|
87
|
+
branch: main (root)
|
|
88
|
+
worktree: /Users/colinmcd94/Documents/projects/pf
|
|
89
|
+
status: clean
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
<br/>
|
|
93
|
+
|
|
94
|
+
Clone a repo (any repo works):
|
|
83
95
|
|
|
84
96
|
```bash
|
|
85
97
|
$ git clone git@github.com:colinhacks/zod.git
|
|
@@ -306,16 +318,13 @@ You can configure `wksh` with a `workshell.toml` file. This is useful for runnin
|
|
|
306
318
|
|
|
307
319
|
<br />
|
|
308
320
|
|
|
321
|
+
Currently only one setting is supported: `setup`.
|
|
322
|
+
|
|
309
323
|
```toml
|
|
310
324
|
# setup script executed in subshell after initialization
|
|
325
|
+
# the following variable substitutions are supported
|
|
326
|
+
# `{{ branch }}` — The name of the opened branch, e.g. `feature/auth`
|
|
327
|
+
# `{{ repo_path }}` — The absolute path to main repo, e.g. `/path/to/repo`
|
|
328
|
+
# `{{ worktree_path }}` — The absolute path to worktree, e.g. `/path/to/repo/.git/workshell/worktrees/repo@feat`
|
|
311
329
|
setup = "npm install && cp {{ repo_path }}/.env {{ worktree_path }}/.env"
|
|
312
330
|
```
|
|
313
|
-
|
|
314
|
-
The following variable substitutions are supported in `setup`.
|
|
315
|
-
|
|
316
|
-
| Variable | Description | Example |
|
|
317
|
-
|----------|-------------|---------|
|
|
318
|
-
| `{{ branch }}` | Branch name | `feature/auth` |
|
|
319
|
-
| `{{ repo_path }}` | Absolute path to main repo | `/path/to/repo` |
|
|
320
|
-
| `{{ worktree_path }}` | Absolute path to worktree | `/path/to/repo/.git/workshell/worktrees/repo@feat` |
|
|
321
|
-
|
package/dist/index.js
CHANGED
|
@@ -6722,6 +6722,12 @@ function createWorktree(name, path, baseBranch) {
|
|
|
6722
6722
|
const baseArg = baseBranch ? ` "${baseBranch}"` : "";
|
|
6723
6723
|
execSync2(`git worktree add -b "${name}" "${path}"${baseArg}`, { stdio: "ignore" });
|
|
6724
6724
|
}
|
|
6725
|
+
function initSubmodules(worktreePath) {
|
|
6726
|
+
try {
|
|
6727
|
+
execSync2("git submodule update --init --recursive", { cwd: worktreePath, stdio: "ignore" });
|
|
6728
|
+
} catch {
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6725
6731
|
function createWorktreeForExistingBranch(branch, path) {
|
|
6726
6732
|
execSync2(`git worktree add "${path}" "${branch}"`, { stdio: "ignore" });
|
|
6727
6733
|
}
|
|
@@ -6903,7 +6909,7 @@ ${setupCommand}
|
|
|
6903
6909
|
try {
|
|
6904
6910
|
writeFileSync2(join2(tmpDir, ".zshrc"), `[[ -f "$HOME/.zshrc" ]] && source "$HOME/.zshrc"
|
|
6905
6911
|
${zshScript}${setupSection}`);
|
|
6906
|
-
spawnSync(shell, [], { cwd, stdio: "inherit", env: { ...process.env, ZDOTDIR: tmpDir } });
|
|
6912
|
+
spawnSync(shell, ["-l"], { cwd, stdio: "inherit", env: { ...process.env, ZDOTDIR: tmpDir } });
|
|
6907
6913
|
} finally {
|
|
6908
6914
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
6909
6915
|
}
|
|
@@ -6914,7 +6920,7 @@ ${zshScript}${setupSection}`);
|
|
|
6914
6920
|
const rcFile = join2(tmpDir, ".bashrc");
|
|
6915
6921
|
writeFileSync2(rcFile, `[[ -f "$HOME/.bashrc" ]] && source "$HOME/.bashrc"
|
|
6916
6922
|
${bashScript}${setupSection}`);
|
|
6917
|
-
spawnSync(shell, ["--rcfile", rcFile, "-
|
|
6923
|
+
spawnSync(shell, ["--rcfile", rcFile, "-il"], { cwd, stdio: "inherit" });
|
|
6918
6924
|
} finally {
|
|
6919
6925
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
6920
6926
|
}
|
|
@@ -7029,6 +7035,7 @@ function newCommand(branchName, fromBranch) {
|
|
|
7029
7035
|
const worktreePath = join3(getWorktreesDir(), worktreeId);
|
|
7030
7036
|
mkdirSync3(dirname3(worktreePath), { recursive: true });
|
|
7031
7037
|
createWorktree(branch, worktreePath, fromBranch);
|
|
7038
|
+
initSubmodules(worktreePath);
|
|
7032
7039
|
setWorktreeMeta(store, worktreeId, {
|
|
7033
7040
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7034
7041
|
});
|
|
@@ -7098,6 +7105,7 @@ function openCommand(branch) {
|
|
|
7098
7105
|
const worktreePath = join4(getWorktreesDir(), worktreeId);
|
|
7099
7106
|
mkdirSync4(dirname4(worktreePath), { recursive: true });
|
|
7100
7107
|
createWorktreeForExistingBranch(branch, worktreePath);
|
|
7108
|
+
initSubmodules(worktreePath);
|
|
7101
7109
|
setWorktreeMeta(store, worktreeId, {
|
|
7102
7110
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7103
7111
|
});
|
|
@@ -8100,7 +8108,9 @@ function precloseCommand(force) {
|
|
|
8100
8108
|
if (force) {
|
|
8101
8109
|
try {
|
|
8102
8110
|
execSync5("git reset --hard HEAD", { stdio: "ignore" });
|
|
8103
|
-
execSync5("git clean -
|
|
8111
|
+
execSync5("git clean -ffd", { stdio: "ignore" });
|
|
8112
|
+
execSync5("git submodule foreach --recursive 'git reset --hard HEAD; git clean -ffd'", { stdio: "ignore" });
|
|
8113
|
+
execSync5("git submodule update --init --recursive --force", { stdio: "ignore" });
|
|
8104
8114
|
} catch {
|
|
8105
8115
|
}
|
|
8106
8116
|
process.exit(0);
|
|
@@ -8173,7 +8183,7 @@ function promptChoice() {
|
|
|
8173
8183
|
}
|
|
8174
8184
|
|
|
8175
8185
|
// index.ts
|
|
8176
|
-
var VERSION = "0.0.
|
|
8186
|
+
var VERSION = "0.0.5";
|
|
8177
8187
|
function printHelp() {
|
|
8178
8188
|
const dim2 = import_picocolors4.default.dim;
|
|
8179
8189
|
const cyan2 = import_picocolors4.default.cyan;
|