code-squad-cli 2.1.2 → 2.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 CHANGED
@@ -2043,22 +2043,23 @@ csq() {
2043
2043
  fi
2044
2044
 
2045
2045
  local output
2046
- output=$(command csq "$@" 2>&1)
2046
+ output=$(command csq "$@")
2047
2047
  local exit_code=$?
2048
2048
 
2049
2049
  if [[ $exit_code -ne 0 ]]; then
2050
- echo "$output"
2051
2050
  return $exit_code
2052
2051
  fi
2053
2052
 
2054
- # \uB9C8\uC9C0\uB9C9 \uC904\uC774 \uB514\uB809\uD1A0\uB9AC\uBA74 cd
2055
- local last_line=$(echo "$output" | tail -1)
2056
- if [[ -d "$last_line" ]]; then
2057
- # \uB9C8\uC9C0\uB9C9 \uC904 \uC81C\uC678\uD55C \uB098\uBA38\uC9C0 \uCD9C\uB825
2058
- echo "$output" | sed '$d'
2059
- cd "$last_line"
2060
- else
2061
- echo "$output"
2053
+ # stdout\uC758 \uB9C8\uC9C0\uB9C9 \uC904\uC774 \uB514\uB809\uD1A0\uB9AC\uBA74 cd
2054
+ if [[ -n "$output" ]]; then
2055
+ local last_line=$(echo "$output" | tail -1)
2056
+ if [[ -d "$last_line" ]]; then
2057
+ local rest=$(echo "$output" | sed '$d')
2058
+ [[ -n "$rest" ]] && echo "$rest"
2059
+ cd "$last_line"
2060
+ else
2061
+ echo "$output"
2062
+ fi
2062
2063
  fi
2063
2064
  }
2064
2065
  `.trim();
@@ -2086,9 +2087,9 @@ async function createWorktreeCommand(workspaceRoot, args) {
2086
2087
  const worktreePath = path12.join(defaultBasePath, name);
2087
2088
  try {
2088
2089
  await gitAdapter.createWorktree(worktreePath, name, workspaceRoot);
2089
- console.log(chalk.green(`\u2713 Created worktree: ${name}`));
2090
+ console.error(chalk.green(`\u2713 Created worktree: ${name}`));
2090
2091
  await copyWorktreeFiles(workspaceRoot, worktreePath);
2091
- console.log(worktreePath);
2092
+ process.stdout.write(worktreePath + "\n");
2092
2093
  } catch (error) {
2093
2094
  console.error(chalk.red(`Failed to create worktree: ${error.message}`));
2094
2095
  process.exit(1);
@@ -2119,8 +2120,8 @@ async function quitWorktreeCommand() {
2119
2120
  try {
2120
2121
  await gitAdapter.removeWorktree(context.currentPath, context.mainRoot, true);
2121
2122
  await gitAdapter.deleteBranch(context.branch, context.mainRoot, true);
2122
- console.log(chalk.green(`\u2713 Deleted worktree and branch: ${context.branch}`));
2123
- console.log(context.mainRoot);
2123
+ console.error(chalk.green(`\u2713 Deleted worktree and branch: ${context.branch}`));
2124
+ process.stdout.write(context.mainRoot + "\n");
2124
2125
  } catch (error) {
2125
2126
  console.error(chalk.red(`Failed to quit: ${error.message}`));
2126
2127
  process.exit(1);
@@ -2134,10 +2135,10 @@ async function copyWorktreeFiles(sourceRoot, destRoot) {
2134
2135
  }
2135
2136
  const { copied, failed } = await copyFilesWithPatterns(sourceRoot, destRoot, patterns);
2136
2137
  if (copied.length > 0) {
2137
- console.log(chalk.green(`\u2713 Copied ${copied.length} file(s) to worktree`));
2138
+ console.error(chalk.green(`\u2713 Copied ${copied.length} file(s) to worktree`));
2138
2139
  }
2139
2140
  if (failed.length > 0) {
2140
- console.log(chalk.yellow(`\u26A0 Failed to copy ${failed.length} file(s)`));
2141
+ console.error(chalk.yellow(`\u26A0 Failed to copy ${failed.length} file(s)`));
2141
2142
  }
2142
2143
  }
2143
2144
  main().catch((error) => {
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "code-squad-cli",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "csq": "./dist/index.js"
7
7
  },
8
8
  "main": "./dist/index.js",
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "scripts"
11
12
  ],
12
13
  "scripts": {
13
14
  "build": "tsc && npm run bundle",
@@ -16,6 +17,7 @@
16
17
  "dev": "tsx src/index.ts",
17
18
  "type-check": "tsc --noEmit",
18
19
  "clean": "rimraf dist",
20
+ "postinstall": "node scripts/postinstall.mjs",
19
21
  "prepublishOnly": "npm run clean && npm run build"
20
22
  },
21
23
  "dependencies": {
@@ -0,0 +1,56 @@
1
+ import { existsSync, readFileSync, appendFileSync, mkdirSync } from 'fs';
2
+ import { join, dirname, basename } from 'path';
3
+ import { homedir } from 'os';
4
+
5
+ // Only run for global installs
6
+ if (process.env.npm_config_global !== 'true') {
7
+ process.exit(0);
8
+ }
9
+
10
+ const shell = basename(process.env.SHELL || '');
11
+ const home = homedir();
12
+
13
+ let rcFile;
14
+ let initLine;
15
+
16
+ switch (shell) {
17
+ case 'zsh':
18
+ rcFile = join(process.env.ZDOTDIR || home, '.zshrc');
19
+ initLine = 'eval "$(csq --init)"';
20
+ break;
21
+ case 'bash':
22
+ rcFile = existsSync(join(home, '.bashrc'))
23
+ ? join(home, '.bashrc')
24
+ : join(home, '.bash_profile');
25
+ initLine = 'eval "$(csq --init)"';
26
+ break;
27
+ case 'fish':
28
+ rcFile = join(
29
+ process.env.XDG_CONFIG_HOME || join(home, '.config'),
30
+ 'fish',
31
+ 'config.fish'
32
+ );
33
+ initLine = 'csq init | source';
34
+ break;
35
+ default:
36
+ process.exit(0);
37
+ }
38
+
39
+ // Already configured
40
+ if (existsSync(rcFile)) {
41
+ const content = readFileSync(rcFile, 'utf-8');
42
+ if (content.includes('csq --init') || content.includes('csq init')) {
43
+ process.exit(0);
44
+ }
45
+ }
46
+
47
+ try {
48
+ mkdirSync(dirname(rcFile), { recursive: true });
49
+ appendFileSync(rcFile, `\n# Code Squad CLI\n${initLine}\n`);
50
+ console.log('');
51
+ console.log(` \u2713 csq: shell integration added to ${rcFile}`);
52
+ console.log(' Restart your terminal to activate.');
53
+ console.log('');
54
+ } catch {
55
+ // Don't break install
56
+ }