@urugus/slack-cli 0.1.4 → 0.1.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/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +7 -1
- package/tests/index.test.ts +40 -0
package/dist/index.js
CHANGED
|
@@ -7,8 +7,13 @@ const send_1 = require("./commands/send");
|
|
|
7
7
|
const channels_1 = require("./commands/channels");
|
|
8
8
|
const history_1 = require("./commands/history");
|
|
9
9
|
const unread_1 = require("./commands/unread");
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
10
12
|
const program = new commander_1.Command();
|
|
11
|
-
|
|
13
|
+
// Read version from package.json
|
|
14
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', 'package.json'), 'utf-8'));
|
|
15
|
+
const version = packageJson.version;
|
|
16
|
+
program.name('slack-cli').description('CLI tool to send messages via Slack API').version(version);
|
|
12
17
|
program.addCommand((0, config_1.setupConfigCommand)());
|
|
13
18
|
program.addCommand((0, send_1.setupSendCommand)());
|
|
14
19
|
program.addCommand((0, channels_1.setupChannelsCommand)());
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,8CAAuD;AACvD,0CAAmD;AACnD,kDAA2D;AAC3D,gDAAyD;AACzD,8CAAuD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,8CAAuD;AACvD,0CAAmD;AACnD,kDAA2D;AAC3D,gDAAyD;AACzD,8CAAuD;AACvD,2BAAkC;AAClC,+BAA4B;AAE5B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,iCAAiC;AACjC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7F,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;AAEpC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAElG,OAAO,CAAC,UAAU,CAAC,IAAA,2BAAkB,GAAE,CAAC,CAAC;AACzC,OAAO,CAAC,UAAU,CAAC,IAAA,uBAAgB,GAAE,CAAC,CAAC;AACvC,OAAO,CAAC,UAAU,CAAC,IAAA,+BAAoB,GAAE,CAAC,CAAC;AAC3C,OAAO,CAAC,UAAU,CAAC,IAAA,6BAAmB,GAAE,CAAC,CAAC;AAC1C,OAAO,CAAC,UAAU,CAAC,IAAA,2BAAkB,GAAE,CAAC,CAAC;AAEzC,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,10 +5,16 @@ import { setupSendCommand } from './commands/send';
|
|
|
5
5
|
import { setupChannelsCommand } from './commands/channels';
|
|
6
6
|
import { setupHistoryCommand } from './commands/history';
|
|
7
7
|
import { setupUnreadCommand } from './commands/unread';
|
|
8
|
+
import { readFileSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
8
10
|
|
|
9
11
|
const program = new Command();
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
// Read version from package.json
|
|
14
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
15
|
+
const version = packageJson.version;
|
|
16
|
+
|
|
17
|
+
program.name('slack-cli').description('CLI tool to send messages via Slack API').version(version);
|
|
12
18
|
|
|
13
19
|
program.addCommand(setupConfigCommand());
|
|
14
20
|
program.addCommand(setupSendCommand());
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
describe('slack-cli version', () => {
|
|
7
|
+
it('should display the correct version from package.json', () => {
|
|
8
|
+
// Read the expected version from package.json
|
|
9
|
+
const packageJson = JSON.parse(
|
|
10
|
+
readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')
|
|
11
|
+
);
|
|
12
|
+
const expectedVersion = packageJson.version;
|
|
13
|
+
|
|
14
|
+
// Execute the CLI command to get version
|
|
15
|
+
const output = execSync('node dist/index.js --version', {
|
|
16
|
+
encoding: 'utf-8',
|
|
17
|
+
cwd: join(__dirname, '..')
|
|
18
|
+
}).trim();
|
|
19
|
+
|
|
20
|
+
// The output should contain the version from package.json
|
|
21
|
+
expect(output).toBe(expectedVersion);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should display version with -V flag', () => {
|
|
25
|
+
// Read the expected version from package.json
|
|
26
|
+
const packageJson = JSON.parse(
|
|
27
|
+
readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')
|
|
28
|
+
);
|
|
29
|
+
const expectedVersion = packageJson.version;
|
|
30
|
+
|
|
31
|
+
// Execute the CLI command with -V flag
|
|
32
|
+
const output = execSync('node dist/index.js -V', {
|
|
33
|
+
encoding: 'utf-8',
|
|
34
|
+
cwd: join(__dirname, '..')
|
|
35
|
+
}).trim();
|
|
36
|
+
|
|
37
|
+
// The output should contain the version from package.json
|
|
38
|
+
expect(output).toBe(expectedVersion);
|
|
39
|
+
});
|
|
40
|
+
});
|