@urugus/slack-cli 0.1.7 → 0.1.8
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/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +3 -12
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/config-subcommands.d.ts +14 -0
- package/dist/commands/config-subcommands.d.ts.map +1 -0
- package/dist/commands/config-subcommands.js +65 -0
- package/dist/commands/config-subcommands.js.map +1 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +7 -55
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/history-display.d.ts +3 -0
- package/dist/commands/history-display.d.ts.map +1 -0
- package/dist/commands/history-display.js +33 -0
- package/dist/commands/history-display.js.map +1 -0
- package/dist/commands/history-validators.d.ts +5 -0
- package/dist/commands/history-validators.d.ts.map +1 -0
- package/dist/commands/history-validators.js +35 -0
- package/dist/commands/history-validators.js.map +1 -0
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +8 -51
- package/dist/commands/history.js.map +1 -1
- package/dist/utils/channel-formatter.d.ts +0 -3
- package/dist/utils/channel-formatter.d.ts.map +1 -1
- package/dist/utils/channel-formatter.js +8 -44
- package/dist/utils/channel-formatter.js.map +1 -1
- package/dist/utils/formatters/channels-list-formatters.d.ts +13 -0
- package/dist/utils/formatters/channels-list-formatters.d.ts.map +1 -0
- package/dist/utils/formatters/channels-list-formatters.js +53 -0
- package/dist/utils/formatters/channels-list-formatters.js.map +1 -0
- package/dist/utils/slack-api-client.d.ts +2 -3
- package/dist/utils/slack-api-client.d.ts.map +1 -1
- package/dist/utils/slack-api-client.js +9 -153
- package/dist/utils/slack-api-client.js.map +1 -1
- package/dist/utils/slack-operations/base-client.d.ts +10 -0
- package/dist/utils/slack-operations/base-client.d.ts.map +1 -0
- package/dist/utils/slack-operations/base-client.js +32 -0
- package/dist/utils/slack-operations/base-client.js.map +1 -0
- package/dist/utils/slack-operations/channel-operations.d.ts +15 -0
- package/dist/utils/slack-operations/channel-operations.d.ts.map +1 -0
- package/dist/utils/slack-operations/channel-operations.js +93 -0
- package/dist/utils/slack-operations/channel-operations.js.map +1 -0
- package/dist/utils/slack-operations/index.d.ts +4 -0
- package/dist/utils/slack-operations/index.d.ts.map +1 -0
- package/dist/utils/slack-operations/index.js +10 -0
- package/dist/utils/slack-operations/index.js.map +1 -0
- package/dist/utils/slack-operations/message-operations.d.ts +12 -0
- package/dist/utils/slack-operations/message-operations.d.ts.map +1 -0
- package/dist/utils/slack-operations/message-operations.js +80 -0
- package/dist/utils/slack-operations/message-operations.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/channels.ts +4 -22
- package/src/commands/config-subcommands.ts +63 -0
- package/src/commands/config.ts +15 -69
- package/src/commands/history-display.ts +36 -0
- package/src/commands/history-validators.ts +46 -0
- package/src/commands/history.ts +13 -60
- package/src/utils/channel-formatter.ts +9 -53
- package/src/utils/formatters/channels-list-formatters.ts +59 -0
- package/src/utils/slack-api-client.ts +12 -181
- package/src/utils/slack-operations/base-client.ts +30 -0
- package/src/utils/slack-operations/channel-operations.ts +112 -0
- package/src/utils/slack-operations/index.ts +3 -0
- package/src/utils/slack-operations/message-operations.ts +94 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../src/commands/channels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../src/commands/channels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,oBAAoB,IAAI,OAAO,CAsC9C"}
|
|
@@ -6,6 +6,7 @@ const command_wrapper_1 = require("../utils/command-wrapper");
|
|
|
6
6
|
const client_factory_1 = require("../utils/client-factory");
|
|
7
7
|
const constants_1 = require("../utils/constants");
|
|
8
8
|
const channel_formatter_1 = require("../utils/channel-formatter");
|
|
9
|
+
const channels_list_formatters_1 = require("../utils/formatters/channels-list-formatters");
|
|
9
10
|
function setupChannelsCommand() {
|
|
10
11
|
const channelsCommand = new commander_1.Command('channels');
|
|
11
12
|
channelsCommand
|
|
@@ -32,18 +33,8 @@ function setupChannelsCommand() {
|
|
|
32
33
|
}
|
|
33
34
|
// Format and display channels
|
|
34
35
|
const channelInfos = channels.map(channel_formatter_1.mapChannelToInfo);
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
}
|
|
36
|
+
const formatter = (0, channels_list_formatters_1.createChannelsListFormatter)(options.format);
|
|
37
|
+
formatter.format(channelInfos);
|
|
47
38
|
}));
|
|
48
39
|
return channelsCommand;
|
|
49
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/commands/channels.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/commands/channels.ts"],"names":[],"mappings":";;AAQA,oDAsCC;AA9CD,yCAAoC;AACpC,8DAAuD;AACvD,4DAA4D;AAC5D,kDAAoD;AAEpD,kEAA+E;AAC/E,2FAA2F;AAE3F,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;QACpD,MAAM,SAAS,GAAG,IAAA,sDAA2B,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9D,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC,CAAC,CACH,CAAC;IAEJ,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function handleSetToken(options: {
|
|
2
|
+
token: string;
|
|
3
|
+
profile?: string;
|
|
4
|
+
}): Promise<void>;
|
|
5
|
+
export declare function handleGetConfig(options: {
|
|
6
|
+
profile?: string;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export declare function handleListProfiles(): Promise<void>;
|
|
9
|
+
export declare function handleUseProfile(profile: string): Promise<void>;
|
|
10
|
+
export declare function handleShowCurrentProfile(): Promise<void>;
|
|
11
|
+
export declare function handleClearConfig(options: {
|
|
12
|
+
profile?: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=config-subcommands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-subcommands.d.ts","sourceRoot":"","sources":["../../src/commands/config-subcommands.ts"],"names":[],"mappings":"AAKA,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAKhG;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAalF;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBxD;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrE;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAI9D;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAKpF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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.handleSetToken = handleSetToken;
|
|
7
|
+
exports.handleGetConfig = handleGetConfig;
|
|
8
|
+
exports.handleListProfiles = handleListProfiles;
|
|
9
|
+
exports.handleUseProfile = handleUseProfile;
|
|
10
|
+
exports.handleShowCurrentProfile = handleShowCurrentProfile;
|
|
11
|
+
exports.handleClearConfig = handleClearConfig;
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const profile_config_1 = require("../utils/profile-config");
|
|
14
|
+
const command_wrapper_1 = require("../utils/command-wrapper");
|
|
15
|
+
const constants_1 = require("../utils/constants");
|
|
16
|
+
async function handleSetToken(options) {
|
|
17
|
+
const configManager = new profile_config_1.ProfileConfigManager();
|
|
18
|
+
const profileName = await (0, command_wrapper_1.getProfileName)(configManager, options.profile);
|
|
19
|
+
await configManager.setToken(options.token, options.profile);
|
|
20
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.TOKEN_SAVED(profileName)}`));
|
|
21
|
+
}
|
|
22
|
+
async function handleGetConfig(options) {
|
|
23
|
+
const configManager = new profile_config_1.ProfileConfigManager();
|
|
24
|
+
const profileName = await (0, command_wrapper_1.getProfileName)(configManager, options.profile);
|
|
25
|
+
const currentConfig = await configManager.getConfig(options.profile);
|
|
26
|
+
if (!currentConfig) {
|
|
27
|
+
console.log(chalk_1.default.yellow(constants_1.ERROR_MESSAGES.NO_CONFIG(profileName)));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
console.log(chalk_1.default.bold(`Configuration for profile "${profileName}":`));
|
|
31
|
+
console.log(` Token: ${chalk_1.default.cyan(configManager.maskToken(currentConfig.token))}`);
|
|
32
|
+
console.log(` Updated: ${chalk_1.default.gray(currentConfig.updatedAt)}`);
|
|
33
|
+
}
|
|
34
|
+
async function handleListProfiles() {
|
|
35
|
+
const configManager = new profile_config_1.ProfileConfigManager();
|
|
36
|
+
const profiles = await configManager.listProfiles();
|
|
37
|
+
const currentProfile = await configManager.getCurrentProfile();
|
|
38
|
+
if (profiles.length === 0) {
|
|
39
|
+
console.log(chalk_1.default.yellow(constants_1.ERROR_MESSAGES.NO_PROFILES_FOUND));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
console.log(chalk_1.default.bold('Available profiles:'));
|
|
43
|
+
profiles.forEach((profile) => {
|
|
44
|
+
const marker = profile.name === currentProfile ? '*' : ' ';
|
|
45
|
+
const maskedToken = configManager.maskToken(profile.config.token);
|
|
46
|
+
console.log(` ${marker} ${chalk_1.default.cyan(profile.name)} (${maskedToken})`);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function handleUseProfile(profile) {
|
|
50
|
+
const configManager = new profile_config_1.ProfileConfigManager();
|
|
51
|
+
await configManager.useProfile(profile);
|
|
52
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.PROFILE_SWITCHED(profile)}`));
|
|
53
|
+
}
|
|
54
|
+
async function handleShowCurrentProfile() {
|
|
55
|
+
const configManager = new profile_config_1.ProfileConfigManager();
|
|
56
|
+
const currentProfile = await configManager.getCurrentProfile();
|
|
57
|
+
console.log(chalk_1.default.bold(`Current profile: ${chalk_1.default.cyan(currentProfile)}`));
|
|
58
|
+
}
|
|
59
|
+
async function handleClearConfig(options) {
|
|
60
|
+
const configManager = new profile_config_1.ProfileConfigManager();
|
|
61
|
+
const profileName = await (0, command_wrapper_1.getProfileName)(configManager, options.profile);
|
|
62
|
+
await configManager.clearConfig(options.profile);
|
|
63
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.PROFILE_CLEARED(profileName)}`));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=config-subcommands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-subcommands.js","sourceRoot":"","sources":["../../src/commands/config-subcommands.ts"],"names":[],"mappings":";;;;;AAKA,wCAKC;AAED,0CAaC;AAED,gDAgBC;AAED,4CAIC;AAED,4DAIC;AAED,8CAKC;AA9DD,kDAA0B;AAC1B,4DAA+D;AAC/D,8DAA0D;AA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,CAAC,iBAAiB,EAAE,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5E,CAAC;AAEM,KAAK,UAAU,iBAAiB,CAAC,OAA6B;IACnE,MAAM,aAAa,GAAG,IAAI,qCAAoB,EAAE,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,IAAA,gCAAc,EAAC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACzE,MAAM,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,KAAK,4BAAgB,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,kBAAkB,IAAI,OAAO,CAsC5C"}
|
package/dist/commands/config.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.setupConfigCommand = setupConfigCommand;
|
|
7
4
|
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const profile_config_1 = require("../utils/profile-config");
|
|
10
5
|
const command_wrapper_1 = require("../utils/command-wrapper");
|
|
11
|
-
const
|
|
6
|
+
const config_subcommands_1 = require("./config-subcommands");
|
|
12
7
|
function setupConfigCommand() {
|
|
13
8
|
const config = new commander_1.Command('config').description('Manage Slack CLI configuration');
|
|
14
9
|
config
|
|
@@ -16,72 +11,29 @@ function setupConfigCommand() {
|
|
|
16
11
|
.description('Set API token')
|
|
17
12
|
.requiredOption('--token <token>', 'Slack API token')
|
|
18
13
|
.option('--profile <profile>', 'Profile name (default: "default")')
|
|
19
|
-
.action((0, command_wrapper_1.wrapCommand)(
|
|
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
|
-
}));
|
|
14
|
+
.action((0, command_wrapper_1.wrapCommand)(config_subcommands_1.handleSetToken));
|
|
25
15
|
config
|
|
26
16
|
.command('get')
|
|
27
17
|
.description('Show current configuration')
|
|
28
18
|
.option('--profile <profile>', 'Profile name')
|
|
29
|
-
.action((0, command_wrapper_1.wrapCommand)(
|
|
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
|
-
}));
|
|
19
|
+
.action((0, command_wrapper_1.wrapCommand)(config_subcommands_1.handleGetConfig));
|
|
41
20
|
config
|
|
42
21
|
.command('profiles')
|
|
43
22
|
.description('List all profiles')
|
|
44
|
-
.action((0, command_wrapper_1.wrapCommand)(
|
|
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
|
-
}));
|
|
23
|
+
.action((0, command_wrapper_1.wrapCommand)(config_subcommands_1.handleListProfiles));
|
|
59
24
|
config
|
|
60
25
|
.command('use <profile>')
|
|
61
26
|
.description('Switch to a different profile')
|
|
62
|
-
.action((0, command_wrapper_1.wrapCommand)(
|
|
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
|
-
}));
|
|
27
|
+
.action((0, command_wrapper_1.wrapCommand)(config_subcommands_1.handleUseProfile));
|
|
67
28
|
config
|
|
68
29
|
.command('current')
|
|
69
30
|
.description('Show current active profile')
|
|
70
|
-
.action((0, command_wrapper_1.wrapCommand)(
|
|
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
|
-
}));
|
|
31
|
+
.action((0, command_wrapper_1.wrapCommand)(config_subcommands_1.handleShowCurrentProfile));
|
|
75
32
|
config
|
|
76
33
|
.command('clear')
|
|
77
34
|
.description('Clear configuration')
|
|
78
35
|
.option('--profile <profile>', 'Profile name')
|
|
79
|
-
.action((0, command_wrapper_1.wrapCommand)(
|
|
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
|
-
}));
|
|
36
|
+
.action((0, command_wrapper_1.wrapCommand)(config_subcommands_1.handleClearConfig));
|
|
85
37
|
return config;
|
|
86
38
|
}
|
|
87
39
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";;AAWA,gDAsCC;AAjDD,yCAAoC;AACpC,8DAAuD;AACvD,6DAO8B;AAE9B,SAAgB,kBAAkB;IAChC,MAAM,MAAM,GAAG,IAAI,mBAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,gCAAgC,CAAC,CAAC;IAEnF,MAAM;SACH,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,eAAe,CAAC;SAC5B,cAAc,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;SACpD,MAAM,CAAC,qBAAqB,EAAE,mCAAmC,CAAC;SAClE,MAAM,CAAC,IAAA,6BAAW,EAAC,mCAAc,CAAC,CAAC,CAAC;IAEvC,MAAM;SACH,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,4BAA4B,CAAC;SACzC,MAAM,CAAC,qBAAqB,EAAE,cAAc,CAAC;SAC7C,MAAM,CAAC,IAAA,6BAAW,EAAC,oCAAe,CAAC,CAAC,CAAC;IAExC,MAAM;SACH,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,mBAAmB,CAAC;SAChC,MAAM,CAAC,IAAA,6BAAW,EAAC,uCAAkB,CAAC,CAAC,CAAC;IAE3C,MAAM;SACH,OAAO,CAAC,eAAe,CAAC;SACxB,WAAW,CAAC,+BAA+B,CAAC;SAC5C,MAAM,CAAC,IAAA,6BAAW,EAAC,qCAAgB,CAAC,CAAC,CAAC;IAEzC,MAAM;SACH,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,IAAA,6BAAW,EAAC,6CAAwB,CAAC,CAAC,CAAC;IAEjD,MAAM;SACH,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,qBAAqB,CAAC;SAClC,MAAM,CAAC,qBAAqB,EAAE,cAAc,CAAC;SAC7C,MAAM,CAAC,IAAA,6BAAW,EAAC,sCAAiB,CAAC,CAAC,CAAC;IAE1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-display.d.ts","sourceRoot":"","sources":["../../src/commands/history-display.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,WAAW,EAAE,MAAM,GAClB,IAAI,CA2BN"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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.displayHistoryResults = displayHistoryResults;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const date_utils_1 = require("../utils/date-utils");
|
|
9
|
+
function displayHistoryResults(messages, users, channelName) {
|
|
10
|
+
if (messages.length === 0) {
|
|
11
|
+
console.log(chalk_1.default.yellow('No messages found in the specified channel.'));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
console.log(chalk_1.default.bold(`\nMessage History for #${channelName}:\n`));
|
|
15
|
+
// Display messages in reverse order (oldest first)
|
|
16
|
+
messages.reverse().forEach((message) => {
|
|
17
|
+
const timestamp = (0, date_utils_1.formatSlackTimestamp)(message.ts);
|
|
18
|
+
let author = 'Unknown';
|
|
19
|
+
if (message.user && users.has(message.user)) {
|
|
20
|
+
author = users.get(message.user);
|
|
21
|
+
}
|
|
22
|
+
else if (message.bot_id) {
|
|
23
|
+
author = 'Bot';
|
|
24
|
+
}
|
|
25
|
+
console.log(chalk_1.default.gray(`[${timestamp}]`) + ' ' + chalk_1.default.cyan(author));
|
|
26
|
+
if (message.text) {
|
|
27
|
+
console.log(message.text);
|
|
28
|
+
}
|
|
29
|
+
console.log(''); // Empty line between messages
|
|
30
|
+
});
|
|
31
|
+
console.log(chalk_1.default.green(`✓ Displayed ${messages.length} message(s)`));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=history-display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-display.js","sourceRoot":"","sources":["../../src/commands/history-display.ts"],"names":[],"mappings":";;;;;AAIA,sDA+BC;AAnCD,kDAA0B;AAE1B,oDAA2D;AAE3D,SAAgB,qBAAqB,CACnC,QAAmB,EACnB,KAA0B,EAC1B,WAAmB;IAEnB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC,CAAC;QACzE,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,0BAA0B,WAAW,KAAK,CAAC,CAAC,CAAC;IAEpE,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,OAAgB,EAAE,EAAE;QAC9C,MAAM,SAAS,GAAG,IAAA,iCAAoB,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACnD,IAAI,MAAM,GAAG,SAAS,CAAC;QAEvB,IAAI,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5C,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC;QACpC,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,SAAS,GAAG,CAAC,GAAG,GAAG,GAAG,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACrE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,8BAA8B;IACjD,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,eAAe,QAAQ,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
export declare function validateMessageCount(value: string | undefined, command: Command): number | undefined;
|
|
3
|
+
export declare function validateDateFormat(value: string | undefined, command: Command): string | undefined;
|
|
4
|
+
export declare function prepareSinceTimestamp(since: string | undefined): string | undefined;
|
|
5
|
+
//# sourceMappingURL=history-validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-validators.d.ts","sourceRoot":"","sources":["../../src/commands/history-validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,EAAE,OAAO,GACf,MAAM,GAAG,SAAS,CAapB;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,EAAE,OAAO,GACf,MAAM,GAAG,SAAS,CAWpB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQnF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateMessageCount = validateMessageCount;
|
|
4
|
+
exports.validateDateFormat = validateDateFormat;
|
|
5
|
+
exports.prepareSinceTimestamp = prepareSinceTimestamp;
|
|
6
|
+
const constants_1 = require("../utils/constants");
|
|
7
|
+
function validateMessageCount(value, command) {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const num = parseInt(value, 10);
|
|
12
|
+
if (isNaN(num) || num < constants_1.API_LIMITS.MIN_MESSAGE_COUNT || num > constants_1.API_LIMITS.MAX_MESSAGE_COUNT) {
|
|
13
|
+
command.error(`Error: Message count must be between ${constants_1.API_LIMITS.MIN_MESSAGE_COUNT} and ${constants_1.API_LIMITS.MAX_MESSAGE_COUNT}`);
|
|
14
|
+
}
|
|
15
|
+
return num;
|
|
16
|
+
}
|
|
17
|
+
function validateDateFormat(value, command) {
|
|
18
|
+
if (!value) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const timestamp = Date.parse(value);
|
|
22
|
+
if (isNaN(timestamp)) {
|
|
23
|
+
command.error('Error: Invalid date format. Use YYYY-MM-DD HH:MM:SS');
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function prepareSinceTimestamp(since) {
|
|
28
|
+
if (!since) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
// Convert date to Unix timestamp (in seconds)
|
|
32
|
+
const timestamp = Math.floor(Date.parse(since) / 1000);
|
|
33
|
+
return timestamp.toString();
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=history-validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-validators.js","sourceRoot":"","sources":["../../src/commands/history-validators.ts"],"names":[],"mappings":";;AAGA,oDAgBC;AAED,gDAcC;AAED,sDAQC;AA5CD,kDAAgD;AAEhD,SAAgB,oBAAoB,CAClC,KAAyB,EACzB,OAAgB;IAEhB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,sBAAU,CAAC,iBAAiB,IAAI,GAAG,GAAG,sBAAU,CAAC,iBAAiB,EAAE,CAAC;QAC3F,OAAO,CAAC,KAAK,CACX,wCAAwC,sBAAU,CAAC,iBAAiB,QAAQ,sBAAU,CAAC,iBAAiB,EAAE,CAC3G,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,kBAAkB,CAChC,KAAyB,EACzB,OAAgB;IAEhB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,qBAAqB,CAAC,KAAyB;IAC7D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,8CAA8C;IAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IACvD,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,wBAAgB,mBAAmB,IAAI,OAAO,CAmC7C"}
|
package/dist/commands/history.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.setupHistoryCommand = setupHistoryCommand;
|
|
7
4
|
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
5
|
const command_wrapper_1 = require("../utils/command-wrapper");
|
|
10
6
|
const client_factory_1 = require("../utils/client-factory");
|
|
11
|
-
const date_utils_1 = require("../utils/date-utils");
|
|
12
7
|
const constants_1 = require("../utils/constants");
|
|
8
|
+
const history_validators_1 = require("./history-validators");
|
|
9
|
+
const history_display_1 = require("./history-display");
|
|
13
10
|
function setupHistoryCommand() {
|
|
14
11
|
const historyCommand = new commander_1.Command('history')
|
|
15
12
|
.description('Get message history from a Slack channel')
|
|
@@ -19,60 +16,20 @@ function setupHistoryCommand() {
|
|
|
19
16
|
.option('--profile <profile>', 'Use specific workspace profile')
|
|
20
17
|
.hook('preAction', (thisCommand) => {
|
|
21
18
|
const options = thisCommand.opts();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const num = parseInt(options.number, 10);
|
|
25
|
-
if (isNaN(num) ||
|
|
26
|
-
num < constants_1.API_LIMITS.MIN_MESSAGE_COUNT ||
|
|
27
|
-
num > constants_1.API_LIMITS.MAX_MESSAGE_COUNT) {
|
|
28
|
-
thisCommand.error(`Error: Message count must be between ${constants_1.API_LIMITS.MIN_MESSAGE_COUNT} and ${constants_1.API_LIMITS.MAX_MESSAGE_COUNT}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Validate since option
|
|
32
|
-
if (options.since) {
|
|
33
|
-
const timestamp = Date.parse(options.since);
|
|
34
|
-
if (isNaN(timestamp)) {
|
|
35
|
-
thisCommand.error('Error: Invalid date format. Use YYYY-MM-DD HH:MM:SS');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
19
|
+
(0, history_validators_1.validateMessageCount)(options.number, thisCommand);
|
|
20
|
+
(0, history_validators_1.validateDateFormat)(options.since, thisCommand);
|
|
38
21
|
})
|
|
39
22
|
.action((0, command_wrapper_1.wrapCommand)(async (options) => {
|
|
40
|
-
// Create Slack client
|
|
41
23
|
const client = await (0, client_factory_1.createSlackClient)(options.profile);
|
|
42
|
-
// Prepare API options
|
|
43
24
|
const historyOptions = {
|
|
44
25
|
limit: parseInt(options.number || constants_1.API_LIMITS.DEFAULT_MESSAGE_COUNT.toString(), 10),
|
|
45
26
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
historyOptions.oldest = timestamp.toString();
|
|
27
|
+
const oldest = (0, history_validators_1.prepareSinceTimestamp)(options.since);
|
|
28
|
+
if (oldest) {
|
|
29
|
+
historyOptions.oldest = oldest;
|
|
50
30
|
}
|
|
51
|
-
// Get message history
|
|
52
31
|
const { messages, users } = await client.getHistory(options.channel, historyOptions);
|
|
53
|
-
|
|
54
|
-
if (messages.length === 0) {
|
|
55
|
-
console.log(chalk_1.default.yellow('No messages found in the specified channel.'));
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
console.log(chalk_1.default.bold(`\nMessage History for #${options.channel}:\n`));
|
|
59
|
-
// Display messages in reverse order (oldest first)
|
|
60
|
-
messages.reverse().forEach((message) => {
|
|
61
|
-
const timestamp = (0, date_utils_1.formatSlackTimestamp)(message.ts);
|
|
62
|
-
let author = 'Unknown';
|
|
63
|
-
if (message.user && users.has(message.user)) {
|
|
64
|
-
author = users.get(message.user);
|
|
65
|
-
}
|
|
66
|
-
else if (message.bot_id) {
|
|
67
|
-
author = 'Bot';
|
|
68
|
-
}
|
|
69
|
-
console.log(chalk_1.default.gray(`[${timestamp}]`) + ' ' + chalk_1.default.cyan(author));
|
|
70
|
-
if (message.text) {
|
|
71
|
-
console.log(message.text);
|
|
72
|
-
}
|
|
73
|
-
console.log(''); // Empty line between messages
|
|
74
|
-
});
|
|
75
|
-
console.log(chalk_1.default.green(`✓ Displayed ${messages.length} message(s)`));
|
|
32
|
+
(0, history_display_1.displayHistoryResults)(messages, users, options.channel);
|
|
76
33
|
}));
|
|
77
34
|
return historyCommand;
|
|
78
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":";;AAaA,kDAmCC;AAhDD,yCAAoC;AAEpC,8DAAuD;AACvD,4DAA4D;AAE5D,kDAAgD;AAChD,6DAI8B;AA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,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC,CAAC,CACH,CAAC;IAEJ,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -8,9 +8,6 @@ export interface ChannelInfo {
|
|
|
8
8
|
purpose: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function mapChannelToInfo(channel: Channel): ChannelInfo;
|
|
11
|
-
export declare function formatChannelsAsTable(channels: ChannelInfo[]): void;
|
|
12
|
-
export declare function formatChannelsAsSimple(channels: ChannelInfo[]): void;
|
|
13
|
-
export declare function formatChannelsAsJson(channels: ChannelInfo[]): void;
|
|
14
11
|
export declare function formatChannelName(channelName?: string): string;
|
|
15
12
|
export declare function getChannelTypes(type: string): string;
|
|
16
13
|
//# sourceMappingURL=channel-formatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-formatter.d.ts","sourceRoot":"","sources":["../../src/utils/channel-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAe9D;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"channel-formatter.d.ts","sourceRoot":"","sources":["../../src/utils/channel-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAe9D;AAED,wBAAgB,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUpD"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapChannelToInfo = mapChannelToInfo;
|
|
4
|
-
exports.formatChannelsAsTable = formatChannelsAsTable;
|
|
5
|
-
exports.formatChannelsAsSimple = formatChannelsAsSimple;
|
|
6
|
-
exports.formatChannelsAsJson = formatChannelsAsJson;
|
|
7
4
|
exports.formatChannelName = formatChannelName;
|
|
8
5
|
exports.getChannelTypes = getChannelTypes;
|
|
9
6
|
const date_utils_1 = require("./date-utils");
|
|
@@ -26,52 +23,19 @@ function mapChannelToInfo(channel) {
|
|
|
26
23
|
purpose: channel.purpose?.value || '',
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
|
-
function formatChannelsAsTable(channels) {
|
|
30
|
-
// Print table header
|
|
31
|
-
console.log('Name Type Members Created Description');
|
|
32
|
-
console.log('─'.repeat(65));
|
|
33
|
-
// Print channel rows
|
|
34
|
-
channels.forEach((channel) => {
|
|
35
|
-
const name = channel.name.padEnd(17);
|
|
36
|
-
const type = channel.type.padEnd(9);
|
|
37
|
-
const members = channel.members.toString().padEnd(8);
|
|
38
|
-
const created = channel.created.padEnd(12);
|
|
39
|
-
const purpose = channel.purpose.length > 30 ? channel.purpose.substring(0, 27) + '...' : channel.purpose;
|
|
40
|
-
console.log(`${name} ${type} ${members} ${created} ${purpose}`);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function formatChannelsAsSimple(channels) {
|
|
44
|
-
channels.forEach((channel) => console.log(channel.name));
|
|
45
|
-
}
|
|
46
|
-
function formatChannelsAsJson(channels) {
|
|
47
|
-
console.log(JSON.stringify(channels.map((channel) => ({
|
|
48
|
-
id: channel.id,
|
|
49
|
-
name: channel.name,
|
|
50
|
-
type: channel.type,
|
|
51
|
-
members: channel.members,
|
|
52
|
-
created: channel.created + 'T00:00:00Z',
|
|
53
|
-
purpose: channel.purpose,
|
|
54
|
-
})), null, 2));
|
|
55
|
-
}
|
|
56
26
|
function formatChannelName(channelName) {
|
|
57
27
|
if (!channelName)
|
|
58
28
|
return '#unknown';
|
|
59
29
|
return channelName.startsWith('#') ? channelName : `#${channelName}`;
|
|
60
30
|
}
|
|
61
31
|
function getChannelTypes(type) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return 'mpim';
|
|
71
|
-
case 'all':
|
|
72
|
-
return 'public_channel,private_channel,mpim,im';
|
|
73
|
-
default:
|
|
74
|
-
return 'public_channel';
|
|
75
|
-
}
|
|
32
|
+
const channelTypeMap = {
|
|
33
|
+
public: 'public_channel',
|
|
34
|
+
private: 'private_channel',
|
|
35
|
+
im: 'im',
|
|
36
|
+
mpim: 'mpim',
|
|
37
|
+
all: 'public_channel,private_channel,mpim,im',
|
|
38
|
+
};
|
|
39
|
+
return channelTypeMap[type] || 'public_channel';
|
|
76
40
|
}
|
|
77
41
|
//# sourceMappingURL=channel-formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-formatter.js","sourceRoot":"","sources":["../../src/utils/channel-formatter.ts"],"names":[],"mappings":";;AAYA,4CAeC;AAED,
|
|
1
|
+
{"version":3,"file":"channel-formatter.js","sourceRoot":"","sources":["../../src/utils/channel-formatter.ts"],"names":[],"mappings":";;AAYA,4CAeC;AAED,8CAGC;AAED,0CAUC;AA3CD,6CAAmD;AAWnD,SAAgB,gBAAgB,CAAC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
+
import { ChannelInfo } from '../channel-formatter';
|
|
3
|
+
export declare class ChannelsTableFormatter extends BaseFormatter<ChannelInfo> {
|
|
4
|
+
format(channels: ChannelInfo[]): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class ChannelsSimpleFormatter extends BaseFormatter<ChannelInfo> {
|
|
7
|
+
format(channels: ChannelInfo[]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class ChannelsJsonFormatter extends BaseFormatter<ChannelInfo> {
|
|
10
|
+
format(channels: ChannelInfo[]): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function createChannelsListFormatter(format: string): BaseFormatter<ChannelInfo>;
|
|
13
|
+
//# sourceMappingURL=channels-list-formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels-list-formatters.d.ts","sourceRoot":"","sources":["../../../src/utils/formatters/channels-list-formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,WAAW,CAAC;IACpE,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;CAiBtC;AAED,qBAAa,uBAAwB,SAAQ,aAAa,CAAC,WAAW,CAAC;IACrE,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;CAGtC;AAED,qBAAa,qBAAsB,SAAQ,aAAa,CAAC,WAAW,CAAC;IACnE,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;CAgBtC;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAUtF"}
|