@urugus/slack-cli 0.1.0

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.
Files changed (116) hide show
  1. package/.claude/settings.local.json +53 -0
  2. package/.eslintrc.json +25 -0
  3. package/.github/dependabot.yml +18 -0
  4. package/.github/workflows/ci.yml +70 -0
  5. package/.github/workflows/pr-validation.yml +51 -0
  6. package/.prettierignore +11 -0
  7. package/.prettierrc +10 -0
  8. package/CLAUDE.md +16 -0
  9. package/README.md +161 -0
  10. package/dist/commands/channels.d.ts +3 -0
  11. package/dist/commands/channels.d.ts.map +1 -0
  12. package/dist/commands/channels.js +50 -0
  13. package/dist/commands/channels.js.map +1 -0
  14. package/dist/commands/config.d.ts +3 -0
  15. package/dist/commands/config.d.ts.map +1 -0
  16. package/dist/commands/config.js +87 -0
  17. package/dist/commands/config.js.map +1 -0
  18. package/dist/commands/history.d.ts +3 -0
  19. package/dist/commands/history.d.ts.map +1 -0
  20. package/dist/commands/history.js +79 -0
  21. package/dist/commands/history.js.map +1 -0
  22. package/dist/commands/send.d.ts +3 -0
  23. package/dist/commands/send.d.ts.map +1 -0
  24. package/dist/commands/send.js +85 -0
  25. package/dist/commands/send.js.map +1 -0
  26. package/dist/commands/unread.d.ts +3 -0
  27. package/dist/commands/unread.d.ts.map +1 -0
  28. package/dist/commands/unread.js +104 -0
  29. package/dist/commands/unread.js.map +1 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +18 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/types/commands.d.ts +40 -0
  35. package/dist/types/commands.d.ts.map +1 -0
  36. package/dist/types/commands.js +3 -0
  37. package/dist/types/commands.js.map +1 -0
  38. package/dist/types/config.d.ts +18 -0
  39. package/dist/types/config.d.ts.map +1 -0
  40. package/dist/types/config.js +3 -0
  41. package/dist/types/config.js.map +1 -0
  42. package/dist/utils/channel-formatter.d.ts +16 -0
  43. package/dist/utils/channel-formatter.d.ts.map +1 -0
  44. package/dist/utils/channel-formatter.js +77 -0
  45. package/dist/utils/channel-formatter.js.map +1 -0
  46. package/dist/utils/client-factory.d.ts +6 -0
  47. package/dist/utils/client-factory.d.ts.map +1 -0
  48. package/dist/utils/client-factory.js +13 -0
  49. package/dist/utils/client-factory.js.map +1 -0
  50. package/dist/utils/command-wrapper.d.ts +6 -0
  51. package/dist/utils/command-wrapper.d.ts.map +1 -0
  52. package/dist/utils/command-wrapper.js +27 -0
  53. package/dist/utils/command-wrapper.js.map +1 -0
  54. package/dist/utils/config-helper.d.ts +8 -0
  55. package/dist/utils/config-helper.d.ts.map +1 -0
  56. package/dist/utils/config-helper.js +19 -0
  57. package/dist/utils/config-helper.js.map +1 -0
  58. package/dist/utils/config.d.ts +10 -0
  59. package/dist/utils/config.d.ts.map +1 -0
  60. package/dist/utils/config.js +94 -0
  61. package/dist/utils/config.js.map +1 -0
  62. package/dist/utils/constants.d.ts +32 -0
  63. package/dist/utils/constants.d.ts.map +1 -0
  64. package/dist/utils/constants.js +42 -0
  65. package/dist/utils/constants.js.map +1 -0
  66. package/dist/utils/date-utils.d.ts +3 -0
  67. package/dist/utils/date-utils.d.ts.map +1 -0
  68. package/dist/utils/date-utils.js +12 -0
  69. package/dist/utils/date-utils.js.map +1 -0
  70. package/dist/utils/error-utils.d.ts +2 -0
  71. package/dist/utils/error-utils.d.ts.map +1 -0
  72. package/dist/utils/error-utils.js +10 -0
  73. package/dist/utils/error-utils.js.map +1 -0
  74. package/dist/utils/errors.d.ts +17 -0
  75. package/dist/utils/errors.d.ts.map +1 -0
  76. package/dist/utils/errors.js +40 -0
  77. package/dist/utils/errors.js.map +1 -0
  78. package/dist/utils/profile-config.d.ts +21 -0
  79. package/dist/utils/profile-config.d.ts.map +1 -0
  80. package/dist/utils/profile-config.js +173 -0
  81. package/dist/utils/profile-config.js.map +1 -0
  82. package/dist/utils/slack-api-client.d.ts +74 -0
  83. package/dist/utils/slack-api-client.d.ts.map +1 -0
  84. package/dist/utils/slack-api-client.js +132 -0
  85. package/dist/utils/slack-api-client.js.map +1 -0
  86. package/package.json +56 -0
  87. package/src/commands/channels.ts +65 -0
  88. package/src/commands/config.ts +104 -0
  89. package/src/commands/history.ts +96 -0
  90. package/src/commands/send.ts +52 -0
  91. package/src/commands/unread.ts +118 -0
  92. package/src/index.ts +19 -0
  93. package/src/types/commands.ts +46 -0
  94. package/src/types/config.ts +20 -0
  95. package/src/utils/channel-formatter.ts +89 -0
  96. package/src/utils/client-factory.ts +10 -0
  97. package/src/utils/command-wrapper.ts +27 -0
  98. package/src/utils/config-helper.ts +21 -0
  99. package/src/utils/constants.ts +47 -0
  100. package/src/utils/date-utils.ts +8 -0
  101. package/src/utils/error-utils.ts +6 -0
  102. package/src/utils/errors.ts +37 -0
  103. package/src/utils/profile-config.ts +171 -0
  104. package/src/utils/slack-api-client.ts +218 -0
  105. package/tests/commands/channels.test.ts +250 -0
  106. package/tests/commands/config.test.ts +158 -0
  107. package/tests/commands/history.test.ts +250 -0
  108. package/tests/commands/send.test.ts +156 -0
  109. package/tests/commands/unread.test.ts +248 -0
  110. package/tests/test-utils.ts +28 -0
  111. package/tests/utils/config.test.ts +400 -0
  112. package/tests/utils/date-utils.test.ts +30 -0
  113. package/tests/utils/error-utils.test.ts +34 -0
  114. package/tests/utils/slack-api-client.test.ts +170 -0
  115. package/tsconfig.json +22 -0
  116. package/vitest.config.ts +27 -0
@@ -0,0 +1,53 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(mkdir:*)",
5
+ "Bash(ls:*)",
6
+ "Bash(npm install)",
7
+ "Bash(npm run test:*)",
8
+ "Bash(find:*)",
9
+ "Bash(npm test)",
10
+ "Bash(npm run build:*)",
11
+ "Bash(npm run lint)",
12
+ "Bash(npm run format:check:*)",
13
+ "Bash(npm run format:*)",
14
+ "Bash(npm test:*)",
15
+ "Bash(node:*)",
16
+ "Bash(git add:*)",
17
+ "Bash(git commit:*)",
18
+ "Bash(grep:*)",
19
+ "Bash(true)",
20
+ "Bash(npx vitest run:*)",
21
+ "Bash(NODE_ENV=test npx vitest run --reporter=tap 2 >& 1)",
22
+ "Bash(npm ls:*)",
23
+ "Bash(/opt/homebrew/bin/slack-cli config:*)",
24
+ "Bash(npm bin:*)",
25
+ "Bash(npm root:*)",
26
+ "Bash(strace:*)",
27
+ "Bash(npx vitest list:*)",
28
+ "Bash(NODE_OPTIONS=\"--trace-warnings\" npx vitest run --no-threads 2 >& 1)",
29
+ "Bash(NODE_ENV=test npx vitest run --reporter=tap tests/commands/config.test.ts 2 >& 1)",
30
+ "Bash(echo:*)",
31
+ "Bash(git reset:*)",
32
+ "Bash(npm uninstall:*)",
33
+ "Bash(pkill:*)",
34
+ "Bash(/opt/homebrew/bin/slack:*)",
35
+ "Bash(brew list:*)",
36
+ "Bash(brew info:*)",
37
+ "Bash(npm link:*)",
38
+ "Bash(slack-cli:*)",
39
+ "Bash(git push:*)",
40
+ "Bash(gh run list:*)",
41
+ "Bash(gh run view:*)",
42
+ "Bash(gh run watch:*)",
43
+ "Bash(cat:*)",
44
+ "Bash(mv:*)",
45
+ "Bash(rm:*)",
46
+ "WebFetch(domain:api.slack.com)",
47
+ "Bash(npm run typecheck:*)",
48
+ "Bash(npm run:*)",
49
+ "Bash(npm whoami:*)"
50
+ ],
51
+ "deny": []
52
+ }
53
+ }
package/.eslintrc.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "parser": "@typescript-eslint/parser",
3
+ "extends": [
4
+ "eslint:recommended",
5
+ "plugin:@typescript-eslint/recommended",
6
+ "prettier"
7
+ ],
8
+ "plugins": ["@typescript-eslint"],
9
+ "parserOptions": {
10
+ "ecmaVersion": 2020,
11
+ "sourceType": "module",
12
+ "project": "./tsconfig.json"
13
+ },
14
+ "env": {
15
+ "node": true,
16
+ "es2020": true
17
+ },
18
+ "rules": {
19
+ "@typescript-eslint/explicit-function-return-type": "off",
20
+ "@typescript-eslint/no-explicit-any": "warn",
21
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
22
+ "no-console": "off"
23
+ },
24
+ "ignorePatterns": ["dist", "node_modules", "coverage", "vitest.config.ts"]
25
+ }
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 10
8
+ labels:
9
+ - "dependencies"
10
+ - "npm"
11
+
12
+ - package-ecosystem: "github-actions"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "weekly"
16
+ labels:
17
+ - "dependencies"
18
+ - "github-actions"
@@ -0,0 +1,70 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ main, develop ]
6
+ push:
7
+ branches: [ main, develop ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ node-version: [18.x, 20.x]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Check code formatting
30
+ run: npm run format:check
31
+
32
+ - name: Run linter
33
+ run: npm run lint
34
+
35
+ - name: Run type check
36
+ run: npm run build
37
+
38
+ - name: Run tests
39
+ run: npm test
40
+
41
+ - name: Run test coverage
42
+ run: npm run test:coverage
43
+
44
+ - name: Upload coverage reports
45
+ uses: codecov/codecov-action@v3
46
+ if: matrix.node-version == '20.x'
47
+ with:
48
+ files: ./coverage/coverage-final.json
49
+ flags: unittests
50
+ name: codecov-umbrella
51
+ fail_ci_if_error: false
52
+
53
+ build:
54
+ runs-on: ubuntu-latest
55
+ needs: test
56
+
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+
60
+ - name: Use Node.js
61
+ uses: actions/setup-node@v4
62
+ with:
63
+ node-version: '20.x'
64
+ cache: 'npm'
65
+
66
+ - name: Install dependencies
67
+ run: npm ci
68
+
69
+ - name: Build
70
+ run: npm run build
@@ -0,0 +1,51 @@
1
+ name: PR Validation
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+
7
+ jobs:
8
+ validate:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Use Node.js
15
+ uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '20.x'
18
+ cache: 'npm'
19
+
20
+ - name: Install dependencies
21
+ run: npm ci
22
+
23
+ - name: Check code formatting
24
+ run: npm run format:check
25
+
26
+ - name: Run linter
27
+ run: npm run lint
28
+
29
+ - name: Run tests with coverage
30
+ run: npm run test:coverage
31
+
32
+ - name: Comment PR with coverage
33
+ uses: ArtiomTr/jest-coverage-report-action@v2
34
+ if: github.event_name == 'pull_request'
35
+ with:
36
+ github-token: ${{ secrets.GITHUB_TOKEN }}
37
+ test-script: npm run test:coverage
38
+ skip-step: all
39
+ coverage-file: ./coverage/coverage-final.json
40
+ base-coverage-file: ./coverage/coverage-final.json
41
+
42
+ - name: Check build
43
+ run: npm run build
44
+
45
+ - name: Check for uncommitted changes
46
+ run: |
47
+ if [ -n "$(git status --porcelain)" ]; then
48
+ echo "Uncommitted changes found. Please commit all changes."
49
+ git status --porcelain
50
+ exit 1
51
+ fi
@@ -0,0 +1,11 @@
1
+ node_modules/
2
+ dist/
3
+ coverage/
4
+ .git/
5
+ *.log
6
+ .DS_Store
7
+ .env
8
+ .env.*
9
+ package-lock.json
10
+ yarn.lock
11
+ pnpm-lock.yaml
package/.prettierrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "arrowParens": "always",
9
+ "endOfLine": "lf"
10
+ }
package/CLAUDE.md ADDED
@@ -0,0 +1,16 @@
1
+ # 開発したいもの
2
+
3
+ - Slackのメッセージを送信するコマンドラインツールを作成したい
4
+ - 思考する時は英語で考え、会話する時だけ日本語で行ってください
5
+ - 実装はTDDで行う
6
+
7
+ # タスクの進め方
8
+
9
+ 以下を1つのサイクルで進めること
10
+ 1. 今回の実装対象を1つに定める
11
+ 2. その実装対象の仕様を満たすテストを実装する
12
+ 3. そのテストがパスするように実装を行う
13
+ 4. テストがパスしたら、CIに設定されている全体のテストを実行し、パスすることを確認する
14
+ 5. 今回の変更を commit & push する
15
+ 6. CI がパスするまで確認する
16
+ 7. CIがパスしたことを確認し、タスクを完了とする
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # Slack CLI
2
+
3
+ A command-line tool for sending messages to Slack using the Slack API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g slack-cli
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ You need to configure your Slack API token on first use:
14
+
15
+ ```bash
16
+ slack-cli config --token YOUR_SLACK_API_TOKEN
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Managing Multiple Workspaces (Profiles)
22
+
23
+ ```bash
24
+ # Set tokens for different workspaces
25
+ slack-cli config set --profile work --token xoxb-work-token
26
+ slack-cli config set --profile personal --token xoxb-personal-token
27
+
28
+ # Show all profiles
29
+ slack-cli config profiles
30
+
31
+ # Switch default profile
32
+ slack-cli config use work
33
+
34
+ # Show current active profile
35
+ slack-cli config current
36
+
37
+ # Show configuration for specific profile
38
+ slack-cli config get --profile personal
39
+
40
+ # Clear specific profile
41
+ slack-cli config clear --profile work
42
+ ```
43
+
44
+ ### Sending Messages
45
+
46
+ ```bash
47
+ # Basic usage (uses default profile)
48
+ slack-cli send -c channel-name -m "Your message here"
49
+
50
+ # Using specific profile
51
+ slack-cli send -c channel-name -m "Your message here" --profile personal
52
+
53
+ # Using channel ID
54
+ slack-cli send -c C1234567890 -m "Your message here"
55
+
56
+ # Multi-line message
57
+ slack-cli send -c general -m "Line 1\nLine 2\nLine 3"
58
+
59
+ # Send message from file
60
+ slack-cli send -c random -f message.txt
61
+ ```
62
+
63
+ ### List Channels
64
+
65
+ ```bash
66
+ # List all channels (uses default profile)
67
+ slack-cli channels
68
+
69
+ # List channels from specific profile
70
+ slack-cli channels --profile work
71
+
72
+ # List public channels only
73
+ slack-cli channels --public
74
+
75
+ # List private channels only
76
+ slack-cli channels --private
77
+ ```
78
+
79
+ ### View Message History
80
+
81
+ ```bash
82
+ # Get latest 10 messages
83
+ slack-cli history -c general
84
+
85
+ # Specify number of messages
86
+ slack-cli history -c general -n 20
87
+
88
+ # Get messages since specific date
89
+ slack-cli history -c general --since "2024-01-01 00:00:00"
90
+ ```
91
+
92
+ ### Get Unread Messages
93
+
94
+ ```bash
95
+ # Get all unread messages across all channels
96
+ slack-cli unread
97
+
98
+ # Get unread messages from specific channel
99
+ slack-cli unread -c general
100
+
101
+ # Get unread messages with channel names
102
+ slack-cli unread --show-channel
103
+
104
+ # Mark messages as read after fetching
105
+ slack-cli unread --mark-read
106
+
107
+ # Get unread messages from multiple channels
108
+ slack-cli unread -c general,random,development
109
+ ```
110
+
111
+ ### Other Commands
112
+
113
+ ```bash
114
+ # Show help
115
+ slack-cli --help
116
+
117
+ # Show version
118
+ slack-cli --version
119
+
120
+ # Show current configuration
121
+ slack-cli config get
122
+
123
+ # Update token for default profile
124
+ slack-cli config set --token NEW_TOKEN
125
+ ```
126
+
127
+ ## Options
128
+
129
+ | Option | Short | Description |
130
+ |--------|-------|-------------|
131
+ | --channel | -c | Target channel name or ID |
132
+ | --message | -m | Message to send |
133
+ | --file | -f | File containing message content |
134
+ | --token | -t | Slack API token (temporary override) |
135
+ | --profile | -p | Use specific workspace profile |
136
+ | --format | | Message format (text/markdown) |
137
+ | --verbose | -v | Show verbose output |
138
+ | --show-channel | | Display channel name with unread messages |
139
+ | --mark-read | | Mark messages as read after fetching |
140
+
141
+ ## Environment Variables
142
+
143
+ - `SLACK_API_TOKEN`: Default API token (used when no profile is configured)
144
+ - `SLACK_DEFAULT_CHANNEL`: Default target channel
145
+ - `SLACK_DEFAULT_PROFILE`: Default profile to use
146
+
147
+ ## Required Permissions
148
+
149
+ Your Slack API token needs the following scopes:
150
+
151
+ - `chat:write` - Send messages
152
+ - `channels:read` - List public channels
153
+ - `groups:read` - List private channels
154
+ - `channels:history` - Read channel message history
155
+ - `groups:history` - Read private channel message history
156
+ - `im:history` - Read direct message history
157
+ - `users:read` - Access user information for unread counts
158
+
159
+ ## License
160
+
161
+ MIT
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function setupChannelsCommand(): Command;
3
+ //# sourceMappingURL=channels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../src/commands/channels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,wBAAgB,oBAAoB,IAAI,OAAO,CAmD9C"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupChannelsCommand = setupChannelsCommand;
4
+ const commander_1 = require("commander");
5
+ const command_wrapper_1 = require("../utils/command-wrapper");
6
+ const client_factory_1 = require("../utils/client-factory");
7
+ const constants_1 = require("../utils/constants");
8
+ const channel_formatter_1 = require("../utils/channel-formatter");
9
+ function setupChannelsCommand() {
10
+ const channelsCommand = new commander_1.Command('channels');
11
+ channelsCommand
12
+ .description('List Slack channels')
13
+ .option('--type <type>', 'Channel type: public, private, im, mpim, all', 'public')
14
+ .option('--include-archived', 'Include archived channels', false)
15
+ .option('--format <format>', 'Output format: table, simple, json', 'table')
16
+ .option('--limit <number>', 'Maximum number of channels to list', '100')
17
+ .option('--profile <profile>', 'Use specific workspace profile')
18
+ .action((0, command_wrapper_1.wrapCommand)(async (options) => {
19
+ // Create Slack client
20
+ const client = await (0, client_factory_1.createSlackClient)(options.profile);
21
+ // Map channel type to API types
22
+ const types = (0, channel_formatter_1.getChannelTypes)(options.type);
23
+ // List channels
24
+ const channels = await client.listChannels({
25
+ types,
26
+ exclude_archived: !options.includeArchived,
27
+ limit: parseInt(options.limit, 10),
28
+ });
29
+ if (channels.length === 0) {
30
+ console.log(constants_1.ERROR_MESSAGES.NO_CHANNELS_FOUND);
31
+ return;
32
+ }
33
+ // Format and display channels
34
+ const channelInfos = channels.map(channel_formatter_1.mapChannelToInfo);
35
+ switch (options.format) {
36
+ case 'simple':
37
+ (0, channel_formatter_1.formatChannelsAsSimple)(channelInfos);
38
+ break;
39
+ case 'json':
40
+ (0, channel_formatter_1.formatChannelsAsJson)(channelInfos);
41
+ break;
42
+ case 'table':
43
+ default:
44
+ (0, channel_formatter_1.formatChannelsAsTable)(channelInfos);
45
+ break;
46
+ }
47
+ }));
48
+ return channelsCommand;
49
+ }
50
+ //# sourceMappingURL=channels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/commands/channels.ts"],"names":[],"mappings":";;AAaA,oDAmDC;AAhED,yCAAoC;AACpC,8DAAuD;AACvD,4DAA4D;AAC5D,kDAAoD;AAEpD,kEAMoC;AAEpC,SAAgB,oBAAoB;IAClC,MAAM,eAAe,GAAG,IAAI,mBAAO,CAAC,UAAU,CAAC,CAAC;IAEhD,eAAe;SACZ,WAAW,CAAC,qBAAqB,CAAC;SAClC,MAAM,CAAC,eAAe,EAAE,8CAA8C,EAAE,QAAQ,CAAC;SACjF,MAAM,CAAC,oBAAoB,EAAE,2BAA2B,EAAE,KAAK,CAAC;SAChE,MAAM,CAAC,mBAAmB,EAAE,oCAAoC,EAAE,OAAO,CAAC;SAC1E,MAAM,CAAC,kBAAkB,EAAE,oCAAoC,EAAE,KAAK,CAAC;SACvE,MAAM,CAAC,qBAAqB,EAAE,gCAAgC,CAAC;SAC/D,MAAM,CACL,IAAA,6BAAW,EAAC,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC7C,sBAAsB;QACtB,MAAM,MAAM,GAAG,MAAM,IAAA,kCAAiB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAExD,gCAAgC;QAChC,MAAM,KAAK,GAAG,IAAA,mCAAe,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE5C,gBAAgB;QAChB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;YACzC,KAAK;YACL,gBAAgB,EAAE,CAAC,OAAO,CAAC,eAAe;YAC1C,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SACnC,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,0BAAc,CAAC,iBAAiB,CAAC,CAAC;YAC9C,OAAO;QACT,CAAC;QAED,8BAA8B;QAC9B,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,oCAAgB,CAAC,CAAC;QAEpD,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACvB,KAAK,QAAQ;gBACX,IAAA,0CAAsB,EAAC,YAAY,CAAC,CAAC;gBACrC,MAAM;YAER,KAAK,MAAM;gBACT,IAAA,wCAAoB,EAAC,YAAY,CAAC,CAAC;gBACnC,MAAM;YAER,KAAK,OAAO,CAAC;YACb;gBACE,IAAA,yCAAqB,EAAC,YAAY,CAAC,CAAC;gBACpC,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEJ,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function setupConfigCommand(): Command;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,kBAAkB,IAAI,OAAO,CAiG5C"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setupConfigCommand = setupConfigCommand;
7
+ const commander_1 = require("commander");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const profile_config_1 = require("../utils/profile-config");
10
+ const command_wrapper_1 = require("../utils/command-wrapper");
11
+ const constants_1 = require("../utils/constants");
12
+ function setupConfigCommand() {
13
+ const config = new commander_1.Command('config').description('Manage Slack CLI configuration');
14
+ config
15
+ .command('set')
16
+ .description('Set API token')
17
+ .requiredOption('--token <token>', 'Slack API token')
18
+ .option('--profile <profile>', 'Profile name (default: "default")')
19
+ .action((0, command_wrapper_1.wrapCommand)(async (options) => {
20
+ const configManager = new profile_config_1.ProfileConfigManager();
21
+ const profileName = await (0, command_wrapper_1.getProfileName)(configManager, options.profile);
22
+ await configManager.setToken(options.token, options.profile);
23
+ console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.TOKEN_SAVED(profileName)}`));
24
+ }));
25
+ config
26
+ .command('get')
27
+ .description('Show current configuration')
28
+ .option('--profile <profile>', 'Profile name')
29
+ .action((0, command_wrapper_1.wrapCommand)(async (options) => {
30
+ const configManager = new profile_config_1.ProfileConfigManager();
31
+ const profileName = await (0, command_wrapper_1.getProfileName)(configManager, options.profile);
32
+ const currentConfig = await configManager.getConfig(options.profile);
33
+ if (!currentConfig) {
34
+ console.log(chalk_1.default.yellow(constants_1.ERROR_MESSAGES.NO_CONFIG(profileName)));
35
+ return;
36
+ }
37
+ console.log(chalk_1.default.bold(`Configuration for profile "${profileName}":`));
38
+ console.log(` Token: ${chalk_1.default.cyan(configManager.maskToken(currentConfig.token))}`);
39
+ console.log(` Updated: ${chalk_1.default.gray(currentConfig.updatedAt)}`);
40
+ }));
41
+ config
42
+ .command('profiles')
43
+ .description('List all profiles')
44
+ .action((0, command_wrapper_1.wrapCommand)(async () => {
45
+ const configManager = new profile_config_1.ProfileConfigManager();
46
+ const profiles = await configManager.listProfiles();
47
+ const currentProfile = await configManager.getCurrentProfile();
48
+ if (profiles.length === 0) {
49
+ console.log(chalk_1.default.yellow(constants_1.ERROR_MESSAGES.NO_PROFILES_FOUND));
50
+ return;
51
+ }
52
+ console.log(chalk_1.default.bold('Available profiles:'));
53
+ profiles.forEach((profile) => {
54
+ const marker = profile.name === currentProfile ? '*' : ' ';
55
+ const maskedToken = configManager.maskToken(profile.config.token);
56
+ console.log(` ${marker} ${chalk_1.default.cyan(profile.name)} (${maskedToken})`);
57
+ });
58
+ }));
59
+ config
60
+ .command('use <profile>')
61
+ .description('Switch to a different profile')
62
+ .action((0, command_wrapper_1.wrapCommand)(async (profile) => {
63
+ const configManager = new profile_config_1.ProfileConfigManager();
64
+ await configManager.useProfile(profile);
65
+ console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.PROFILE_SWITCHED(profile)}`));
66
+ }));
67
+ config
68
+ .command('current')
69
+ .description('Show current active profile')
70
+ .action((0, command_wrapper_1.wrapCommand)(async () => {
71
+ const configManager = new profile_config_1.ProfileConfigManager();
72
+ const currentProfile = await configManager.getCurrentProfile();
73
+ console.log(chalk_1.default.bold(`Current profile: ${chalk_1.default.cyan(currentProfile)}`));
74
+ }));
75
+ config
76
+ .command('clear')
77
+ .description('Clear configuration')
78
+ .option('--profile <profile>', 'Profile name')
79
+ .action((0, command_wrapper_1.wrapCommand)(async (options) => {
80
+ const configManager = new profile_config_1.ProfileConfigManager();
81
+ const profileName = await (0, command_wrapper_1.getProfileName)(configManager, options.profile);
82
+ await configManager.clearConfig(options.profile);
83
+ console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.PROFILE_CLEARED(profileName)}`));
84
+ }));
85
+ return config;
86
+ }
87
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","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CAAC,qBAAqB,EAAE,cAAc,CAAC;SAC7C,MAAM,CACL,IAAA,6BAAW,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5B,MAAM,aAAa,GAAG,IAAI,qCAAoB,EAAE,CAAC;QACjD,MAAM,WAAW,GAAG,MAAM,IAAA,gCAAc,EAAC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACzE,MAAM,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,KAAK,4BAAgB,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC,CAAC,CACH,CAAC;IAEJ,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function setupHistoryCommand(): Command;
3
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,mBAAmB,IAAI,OAAO,CAsF7C"}