@slack/bolt 4.0.0-nextGen.8 → 4.0.0-rc.1
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/App.d.ts +17 -37
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +53 -152
- package/dist/App.js.map +1 -1
- package/dist/WorkflowFunction.d.ts +63 -0
- package/dist/WorkflowFunction.d.ts.map +1 -0
- package/dist/WorkflowFunction.js +130 -0
- package/dist/WorkflowFunction.js.map +1 -0
- package/dist/errors.d.ts +1 -13
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -25
- package/dist/errors.js.map +1 -1
- package/dist/helpers.d.ts +15 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +40 -9
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/middleware/builtin.d.ts +2 -2
- package/dist/middleware/builtin.d.ts.map +1 -1
- package/dist/middleware/builtin.js +1 -0
- package/dist/middleware/builtin.js.map +1 -1
- package/dist/middleware/process.d.ts.map +1 -1
- package/dist/middleware/process.js.map +1 -1
- package/dist/receivers/AwsLambdaReceiver.d.ts.map +1 -1
- package/dist/receivers/AwsLambdaReceiver.js +1 -1
- package/dist/receivers/AwsLambdaReceiver.js.map +1 -1
- package/dist/receivers/ExpressReceiver.d.ts.map +1 -1
- package/dist/receivers/ExpressReceiver.js +2 -2
- package/dist/receivers/ExpressReceiver.js.map +1 -1
- package/dist/receivers/HTTPModuleFunctions.d.ts +1 -1
- package/dist/receivers/HTTPModuleFunctions.d.ts.map +1 -1
- package/dist/receivers/HTTPModuleFunctions.js +13 -1
- package/dist/receivers/HTTPModuleFunctions.js.map +1 -1
- package/dist/receivers/HTTPReceiver.d.ts.map +1 -1
- package/dist/receivers/HTTPReceiver.js +11 -5
- package/dist/receivers/HTTPReceiver.js.map +1 -1
- package/dist/receivers/HTTPResponseAck.d.ts +1 -1
- package/dist/receivers/HTTPResponseAck.d.ts.map +1 -1
- package/dist/receivers/ParamsIncomingMessage.d.ts +14 -0
- package/dist/receivers/ParamsIncomingMessage.d.ts.map +1 -0
- package/dist/{types/functions/index.js → receivers/ParamsIncomingMessage.js} +1 -1
- package/dist/receivers/ParamsIncomingMessage.js.map +1 -0
- package/dist/receivers/SocketModeReceiver.d.ts +3 -2
- package/dist/receivers/SocketModeReceiver.d.ts.map +1 -1
- package/dist/receivers/SocketModeReceiver.js +13 -5
- package/dist/receivers/SocketModeReceiver.js.map +1 -1
- package/dist/receivers/custom-routes.d.ts +4 -3
- package/dist/receivers/custom-routes.d.ts.map +1 -1
- package/dist/receivers/custom-routes.js.map +1 -1
- package/dist/receivers/http-utils.d.ts.map +1 -1
- package/dist/receivers/http-utils.js.map +1 -1
- package/dist/receivers/verify-request.d.ts +1 -1
- package/dist/receivers/verify-request.d.ts.map +1 -1
- package/dist/receivers/verify-request.js +1 -1
- package/dist/receivers/verify-request.js.map +1 -1
- package/dist/types/actions/block-action.d.ts +27 -8
- package/dist/types/actions/block-action.d.ts.map +1 -1
- package/dist/types/actions/dialog-action.d.ts +0 -4
- package/dist/types/actions/dialog-action.d.ts.map +1 -1
- package/dist/types/events/base-events.d.ts +85 -33
- package/dist/types/events/base-events.d.ts.map +1 -1
- package/dist/types/events/base-events.js.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/middleware.d.ts +5 -17
- package/dist/types/middleware.d.ts.map +1 -1
- package/dist/types/middleware.js.map +1 -1
- package/dist/types/options/index.d.ts +8 -6
- package/dist/types/options/index.d.ts.map +1 -1
- package/dist/types/shortcuts/index.d.ts +1 -1
- package/dist/types/shortcuts/index.d.ts.map +1 -1
- package/dist/types/utilities.d.ts +9 -8
- package/dist/types/utilities.d.ts.map +1 -1
- package/dist/types/view/index.d.ts +134 -6
- package/dist/types/view/index.d.ts.map +1 -1
- package/package.json +14 -29
- package/dist/Manifest.d.ts +0 -5
- package/dist/Manifest.d.ts.map +0 -1
- package/dist/Manifest.js +0 -16
- package/dist/Manifest.js.map +0 -1
- package/dist/SlackFunction.d.ts +0 -182
- package/dist/SlackFunction.d.ts.map +0 -1
- package/dist/SlackFunction.js +0 -420
- package/dist/SlackFunction.js.map +0 -1
- package/dist/Subscription.d.ts +0 -61
- package/dist/Subscription.d.ts.map +0 -1
- package/dist/Subscription.js +0 -169
- package/dist/Subscription.js.map +0 -1
- package/dist/cli/check-update.d.ts +0 -3
- package/dist/cli/check-update.d.ts.map +0 -1
- package/dist/cli/check-update.js +0 -13
- package/dist/cli/check-update.js.map +0 -1
- package/dist/cli/get-hooks.d.ts +0 -2
- package/dist/cli/get-hooks.d.ts.map +0 -1
- package/dist/cli/get-hooks.js +0 -19
- package/dist/cli/get-hooks.js.map +0 -1
- package/dist/cli/get-manifest.d.ts +0 -3
- package/dist/cli/get-manifest.d.ts.map +0 -1
- package/dist/cli/get-manifest.js +0 -16
- package/dist/cli/get-manifest.js.map +0 -1
- package/dist/cli/hook-utils/get-check-update-data.d.ts +0 -49
- package/dist/cli/hook-utils/get-check-update-data.d.ts.map +0 -1
- package/dist/cli/hook-utils/get-check-update-data.js +0 -252
- package/dist/cli/hook-utils/get-check-update-data.js.map +0 -1
- package/dist/cli/hook-utils/get-check-update-data.spec.d.ts +0 -2
- package/dist/cli/hook-utils/get-check-update-data.spec.d.ts.map +0 -1
- package/dist/cli/hook-utils/get-check-update-data.spec.js +0 -266
- package/dist/cli/hook-utils/get-check-update-data.spec.js.map +0 -1
- package/dist/cli/hook-utils/get-manifest-data.d.ts +0 -7
- package/dist/cli/hook-utils/get-manifest-data.d.ts.map +0 -1
- package/dist/cli/hook-utils/get-manifest-data.js +0 -30
- package/dist/cli/hook-utils/get-manifest-data.js.map +0 -1
- package/dist/cli/hook-utils/get-manifest-data.spec.d.ts +0 -2
- package/dist/cli/hook-utils/get-manifest-data.spec.d.ts.map +0 -1
- package/dist/cli/hook-utils/get-manifest-data.spec.js +0 -113
- package/dist/cli/hook-utils/get-manifest-data.spec.js.map +0 -1
- package/dist/cli/hook-utils/manifest.d.ts +0 -30
- package/dist/cli/hook-utils/manifest.d.ts.map +0 -1
- package/dist/cli/hook-utils/manifest.js +0 -103
- package/dist/cli/hook-utils/manifest.js.map +0 -1
- package/dist/cli/hook-utils/manifest.spec.d.ts +0 -2
- package/dist/cli/hook-utils/manifest.spec.d.ts.map +0 -1
- package/dist/cli/hook-utils/manifest.spec.js +0 -79
- package/dist/cli/hook-utils/manifest.spec.js.map +0 -1
- package/dist/cli/run.d.ts +0 -2
- package/dist/cli/run.d.ts.map +0 -1
- package/dist/cli/run.js +0 -37
- package/dist/cli/run.js.map +0 -1
- package/dist/cli/start.d.ts +0 -3
- package/dist/cli/start.d.ts.map +0 -1
- package/dist/cli/start.js +0 -40
- package/dist/cli/start.js.map +0 -1
- package/dist/types/functions/index.d.ts +0 -26
- package/dist/types/functions/index.d.ts.map +0 -1
- package/dist/types/functions/index.js.map +0 -1
- package/dist/types/subscription/index.d.ts +0 -80
- package/dist/types/subscription/index.d.ts.map +0 -1
- package/dist/types/subscription/index.js +0 -3
- package/dist/types/subscription/index.js.map +0 -1
- package/src/cli/check-update.js +0 -13
- package/src/cli/get-hooks.js +0 -17
- package/src/cli/get-manifest.js +0 -16
- package/src/cli/hook-utils/get-check-update-data.js +0 -292
- package/src/cli/hook-utils/get-manifest-data.js +0 -39
- package/src/cli/hook-utils/manifest.js +0 -108
- package/src/cli/start.js +0 -43
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
require('mocha');
|
|
3
|
-
const sinon = require('sinon');
|
|
4
|
-
const { expect } = require('chai');
|
|
5
|
-
const { fs } = require('memfs');
|
|
6
|
-
const mockfs = require('mock-fs');
|
|
7
|
-
const manifestUtils = require('./manifest');
|
|
8
|
-
const { unionMerge, hasManifest, find } = manifestUtils;
|
|
9
|
-
const rewiremock = require('rewiremock');
|
|
10
|
-
describe('Slack CLI Script Hooks: get-manifest utilities', () => {
|
|
11
|
-
describe('unionMerge', () => {
|
|
12
|
-
it('should return a union of two arrays', () => {
|
|
13
|
-
expect(unionMerge(["arwen"], ["strider"])).to.eql(["arwen", "strider"]);
|
|
14
|
-
expect(unionMerge(["gandalf", "gandalf"], [])).to.eql(["gandalf"]);
|
|
15
|
-
// setup
|
|
16
|
-
const fellowship = ["frodo", "samwise", "merry", "pippin", "gandalf"];
|
|
17
|
-
const hobbits = ["frodo", "samwise", "merry", "pippin"];
|
|
18
|
-
const actualUnion = ["frodo", "samwise", "merry", "pippin", "gandalf"];
|
|
19
|
-
const testUnion = unionMerge(fellowship, hobbits);
|
|
20
|
-
// test
|
|
21
|
-
expect(testUnion).to.eql(actualUnion);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('hasManifest', () => {
|
|
25
|
-
it('should return true if at least one non-empty object', () => {
|
|
26
|
-
expect(hasManifest({}, {}, { testKey: "testValue" })).to.be.true;
|
|
27
|
-
});
|
|
28
|
-
it('should return false if all empty objects', () => {
|
|
29
|
-
expect(hasManifest({}));
|
|
30
|
-
});
|
|
31
|
-
it('should handle an undefined or null objects', () => {
|
|
32
|
-
expect(hasManifest(undefined, null, { testKey: "testValue" })).to.be.true;
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('find', () => {
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
mockfs({
|
|
38
|
-
'/middle-earth': {
|
|
39
|
-
'README.md': '1',
|
|
40
|
-
'mordor': {
|
|
41
|
-
'sauron.js': '1',
|
|
42
|
-
'orc.js': '1',
|
|
43
|
-
'nazgul.js': '1',
|
|
44
|
-
},
|
|
45
|
-
'node_modules': '1',
|
|
46
|
-
'eriador': {
|
|
47
|
-
'shire': {
|
|
48
|
-
'one-ring.js': '1',
|
|
49
|
-
'nazgul.js': '1',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
afterEach(() => {
|
|
56
|
-
mockfs.restore();
|
|
57
|
-
});
|
|
58
|
-
it('should find the required file in any part of directory', () => {
|
|
59
|
-
const cwd = '/middle-earth';
|
|
60
|
-
//test
|
|
61
|
-
// when target exists
|
|
62
|
-
const result = find(cwd, 'one-ring.js');
|
|
63
|
-
expect(result).to.equal(`${cwd}/eriador/shire/one-ring.js`);
|
|
64
|
-
// when target doesn't exist
|
|
65
|
-
const result2 = find(cwd, 'hobbitses.js');
|
|
66
|
-
expect(result2).to.equal(null);
|
|
67
|
-
// when multiple similar files exist, it is greedy
|
|
68
|
-
const result3 = find(cwd, 'nazgul.js');
|
|
69
|
-
expect(result3).to.equal(`${cwd}/eriador/shire/nazgul.js`);
|
|
70
|
-
});
|
|
71
|
-
it('should not search within node_modules', () => {
|
|
72
|
-
const cwd = '/middle-earth';
|
|
73
|
-
//test
|
|
74
|
-
const result = find(cwd, 'node_modules');
|
|
75
|
-
expect(result).to.equal(null);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
//# sourceMappingURL=manifest.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.spec.js","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.spec.js"],"names":[],"mappings":";AAAA,OAAO,CAAC,OAAO,CAAC,CAAC;AACjB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACnC,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAChC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAC5C,MAAM,EAAE,UAAU,EA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,CAAC,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAE/B,kDAAkD;YAClD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YACvC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,0BAA0B,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC/C,MAAM,GAAG,GAAG,eAAe,CAAC;YAC5B,MAAM;YACN,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YACzC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/cli/run.d.ts
DELETED
package/dist/cli/run.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":""}
|
package/dist/cli/run.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
// Run script hook verifies that requirements for running an App in
|
|
9
|
-
// in developerMode (via Socket Mode) are met
|
|
10
|
-
(function _(cwd) {
|
|
11
|
-
// TODO - Format so that its less miss-able in output
|
|
12
|
-
process.stdout.write('Preparing local run in developer mode (Socket Mode)\n');
|
|
13
|
-
// Check required local run tokens
|
|
14
|
-
validate();
|
|
15
|
-
// Kick off a subprocess to run the app in development mode
|
|
16
|
-
const app = (0, child_process_1.spawn)('node', [`${path_1.default.resolve(cwd, 'app.js')}`]);
|
|
17
|
-
app.stdout.setEncoding('utf-8');
|
|
18
|
-
// TODO - Is there a way to configure this in spawn invocation
|
|
19
|
-
app.stdout.on('data', (data) => {
|
|
20
|
-
process.stdout.write(data);
|
|
21
|
-
});
|
|
22
|
-
app.stderr.on('data', (data) => {
|
|
23
|
-
process.stderr.write(data);
|
|
24
|
-
});
|
|
25
|
-
app.on('close', (code) => {
|
|
26
|
-
process.stdout.write(`bolt-app local run exited with code ${code}`);
|
|
27
|
-
});
|
|
28
|
-
}(process.cwd()));
|
|
29
|
-
function validate() {
|
|
30
|
-
if (!process.env.SLACK_CLI_XOXB) {
|
|
31
|
-
throw new Error('Missing local run bot token. Please see slack-cli maintainers to troubleshoot.');
|
|
32
|
-
}
|
|
33
|
-
if (!process.env.SLACK_CLI_XAPP) {
|
|
34
|
-
throw new Error('Missing local run app token. Please see slack-cli maintainers to troubleshoot');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=run.js.map
|
package/dist/cli/run.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,iDAAsC;AACtC,gDAAwB;AAExB,mEAAmE;AACnE,6CAA6C;AAC7C,CAAC,SAAS,CAAC,CAAC,GAAW;IACrB,qDAAqD;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC9E,kCAAkC;IAClC,QAAQ,EAAE,CAAC;IAEX,2DAA2D;IAC3D,MAAM,GAAG,GAAG,IAAA,qBAAK,EAAC,MAAM,EAAE,CAAC,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC,8DAA8D;IAC9D,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAElB,SAAS,QAAQ;IACf,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;KACnG;IACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;KAClG;AACH,CAAC"}
|
package/dist/cli/start.d.ts
DELETED
package/dist/cli/start.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.js"],"names":[],"mappings":""}
|
package/dist/cli/start.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
const { spawn } = require('child_process');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const { main: pkgJSONMain } = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
|
|
7
|
-
// Run script hook verifies that requirements for running an App in
|
|
8
|
-
// in developerMode (via Socket Mode) are met
|
|
9
|
-
(function _(cwd, customPath) {
|
|
10
|
-
// TODO - Format so that its less miss-able in output
|
|
11
|
-
console.log('Preparing local run in developer mode (Socket Mode)');
|
|
12
|
-
// Check required local run tokens
|
|
13
|
-
validate();
|
|
14
|
-
// tries the provided path, then package.json main, then defaults to index.js in the current
|
|
15
|
-
// working directory
|
|
16
|
-
const pkgJSONDefault = 'index.js';
|
|
17
|
-
const fullPath = path.resolve(cwd, customPath ? customPath : pkgJSONMain ? pkgJSONMain : pkgJSONDefault);
|
|
18
|
-
console.log(fullPath);
|
|
19
|
-
// Kick off a subprocess to run the app in development mode
|
|
20
|
-
const app = spawn('node', [`${fullPath}`]);
|
|
21
|
-
app.stdout.setEncoding('utf-8');
|
|
22
|
-
app.stdout.on('data', (data) => {
|
|
23
|
-
process.stdout.write(data);
|
|
24
|
-
});
|
|
25
|
-
app.stderr.on('data', (data) => {
|
|
26
|
-
process.stderr.write(data);
|
|
27
|
-
});
|
|
28
|
-
app.on('close', (code) => {
|
|
29
|
-
console.log(`bolt-app local run exited with code ${code}`);
|
|
30
|
-
});
|
|
31
|
-
}(process.cwd(), process.env.SLACK_CLI_CUSTOM_FILE_PATH));
|
|
32
|
-
function validate() {
|
|
33
|
-
if (!process.env.SLACK_CLI_XOXB) {
|
|
34
|
-
throw new Error('Missing local run bot token. Please see slack-cli maintainers to troubleshoot.');
|
|
35
|
-
}
|
|
36
|
-
if (!process.env.SLACK_CLI_XAPP) {
|
|
37
|
-
throw new Error('Missing local run app token. Please see slack-cli maintainers to troubleshoot');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=start.js.map
|
package/dist/cli/start.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/cli/start.js"],"names":[],"mappings":";;AACA,M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,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,uCAAuC,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,CAAC;AAE1D,SAAS,QAAQ;IACf,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;KACnG;IACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;KAClG;AACH,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execution Context
|
|
3
|
-
*/
|
|
4
|
-
export interface FunctionExecutionContext {
|
|
5
|
-
execution_id: string;
|
|
6
|
-
inputs: Record<string, unknown>;
|
|
7
|
-
function: {
|
|
8
|
-
callback_id: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* FunctionInteractivityContext
|
|
13
|
-
*/
|
|
14
|
-
export interface FunctionInteractivityContext {
|
|
15
|
-
interactor: {
|
|
16
|
-
secret: string;
|
|
17
|
-
id: string;
|
|
18
|
-
};
|
|
19
|
-
interactivity_pointer: string;
|
|
20
|
-
}
|
|
21
|
-
export interface FunctionContext {
|
|
22
|
-
bot_access_token?: string;
|
|
23
|
-
function_data?: FunctionExecutionContext;
|
|
24
|
-
interactivity?: FunctionInteractivityContext;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/functions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAC;KACrB,CAAA;CACF;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;KACZ,CAAA;IACD,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAID,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,aAAa,CAAC,EAAE,4BAA4B,CAAC;CAC9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/functions/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { ViewsOpenResponse } from '@slack/web-api';
|
|
2
|
-
import { View } from '@slack/types';
|
|
3
|
-
import { Middleware } from '../middleware';
|
|
4
|
-
import { SayFn, AckFn } from '../utilities';
|
|
5
|
-
export interface NotificationSubscription<T extends string = string> {
|
|
6
|
-
type: T;
|
|
7
|
-
token: string;
|
|
8
|
-
action_ts: string;
|
|
9
|
-
action_id: string;
|
|
10
|
-
user: {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
};
|
|
14
|
-
team: {
|
|
15
|
-
id: string;
|
|
16
|
-
domain: string;
|
|
17
|
-
enterprise_id?: string;
|
|
18
|
-
enterprise_name?: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export interface SubscriptionCreateRequested extends NotificationSubscription<'notification_subscription_create_requested'> {
|
|
22
|
-
channel: {
|
|
23
|
-
id: string;
|
|
24
|
-
};
|
|
25
|
-
notification_subscription_action_trigger_id: string;
|
|
26
|
-
notification_subscription: {
|
|
27
|
-
resource_link: string;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export interface SubscriptionConfigureRequested extends NotificationSubscription<'notification_subscription_configure_requested'> {
|
|
31
|
-
notification_subscription_action_trigger_id: string;
|
|
32
|
-
notification_subscription: {
|
|
33
|
-
id: string;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export interface SubscriptionDeleted extends NotificationSubscription<'notification_subscription_deleted'> {
|
|
37
|
-
notification_subscription: {
|
|
38
|
-
id: string;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export declare type SubscriptionInteraction = SubscriptionCreateRequested | SubscriptionConfigureRequested | SubscriptionDeleted;
|
|
42
|
-
/**
|
|
43
|
-
* Utility mixin for middlewares to open a configuration modal view (views.open)
|
|
44
|
-
*/
|
|
45
|
-
export interface UseConfigure {
|
|
46
|
-
configure: {
|
|
47
|
-
(params: View): Promise<ViewsOpenResponse>;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Utility mixin for middlewares which can be used to send a message to the user
|
|
52
|
-
* */
|
|
53
|
-
export interface UseSay {
|
|
54
|
-
say: SayFn;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Values and utilities middlewares receive in order to process incoming notification
|
|
58
|
-
* subscription interactive payloads.
|
|
59
|
-
* */
|
|
60
|
-
export interface SubscriptionMiddlewareArgs<S extends SubscriptionInteraction = SubscriptionInteraction> {
|
|
61
|
-
payload: S;
|
|
62
|
-
body: S;
|
|
63
|
-
ack: AckFn<void>;
|
|
64
|
-
}
|
|
65
|
-
export interface SubscriptionOnCreateMiddlewareArgs extends SubscriptionMiddlewareArgs, UseConfigure, UseSay {
|
|
66
|
-
}
|
|
67
|
-
export interface SubscriptionOnConfigureMiddlewareArgs extends SubscriptionMiddlewareArgs, UseConfigure {
|
|
68
|
-
}
|
|
69
|
-
export declare type SlackSubscriptionMiddlewareArgs = SubscriptionMiddlewareArgs | SubscriptionOnCreateMiddlewareArgs | SubscriptionOnConfigureMiddlewareArgs;
|
|
70
|
-
/**
|
|
71
|
-
* Types for middleware which handle notification subscription interaction
|
|
72
|
-
* payloads defined above
|
|
73
|
-
* */
|
|
74
|
-
export declare type SubscriptionOnCreateMiddleware = Middleware<SubscriptionOnCreateMiddlewareArgs>;
|
|
75
|
-
export declare type SubscriptionOnConfigureMiddleware = Middleware<SubscriptionOnConfigureMiddlewareArgs>;
|
|
76
|
-
export declare type SubscriptionOnDeletedMiddleware = Middleware<SubscriptionMiddlewareArgs>;
|
|
77
|
-
export interface SubConfigureFn {
|
|
78
|
-
(params: View): Promise<ViewsOpenResponse>;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/subscription/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACjE,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,MAA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;;KAGK;AACL,oBAAY,8BAA8B,GAAG,UAAU,CAAC,kCAAkC,CAAC,CAAC;AAC5F,oBAAY,iCAAiC,GAAG,UAAU,CAAC,qCAAqC,CAAC,CAAC;AAClG,oBAAY,+BAA+B,GAAG,UAAU,CAAC,0BAA0B,CAAC,CAAC;AAErF,MAAM,WAAW,cAAc;IAC7B,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/subscription/index.ts"],"names":[],"mappings":""}
|
package/src/cli/check-update.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node --no-warnings
|
|
2
|
-
const { checkForSDKUpdates } = require('./hook-utils/get-check-update-data');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Implements the check-update hook and looks for available SDK updates.
|
|
6
|
-
* Returns an object detailing info on Slack dependencies to pass up to the CLI.
|
|
7
|
-
*/
|
|
8
|
-
(async function _(cwd) {
|
|
9
|
-
let updates = await checkForSDKUpdates(cwd);
|
|
10
|
-
|
|
11
|
-
// write updates to stdout
|
|
12
|
-
console.log(JSON.stringify(updates));
|
|
13
|
-
}(process.cwd()));
|
package/src/cli/get-hooks.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
console.log(JSON.stringify({
|
|
3
|
-
hooks: {
|
|
4
|
-
'get-manifest': 'npx -q --no-install -p @slack/bolt slack-cli-get-manifest',
|
|
5
|
-
'check-update': 'npx -q --no-install -p @slack/bolt slack-cli-check-update',
|
|
6
|
-
start: 'npx -q --no-install -p @slack/bolt slack-cli-start',
|
|
7
|
-
},
|
|
8
|
-
config: {
|
|
9
|
-
watch: {
|
|
10
|
-
'filter-regex': '^manifest\\.(ts|js|json)$',
|
|
11
|
-
paths: [
|
|
12
|
-
'.',
|
|
13
|
-
],
|
|
14
|
-
},
|
|
15
|
-
'sdk-managed-connection-enabled': true,
|
|
16
|
-
},
|
|
17
|
-
}));
|
package/src/cli/get-manifest.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const { getManifestData } = require('./hook-utils/get-manifest-data');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Implements the get-manifest script hook required by the Slack CLI
|
|
6
|
-
* Returns a manifest JSON string to stdout.
|
|
7
|
-
* Looks for a manifest.ts, .js and .json files. If multiple are found
|
|
8
|
-
* Then any manifest.ts (or missing that, manifest.js) defined
|
|
9
|
-
* properties will merge into any manifest.json
|
|
10
|
-
*/
|
|
11
|
-
(function _(cwd) {
|
|
12
|
-
let manifest = getManifestData(cwd);
|
|
13
|
-
|
|
14
|
-
// write manifest to stdout
|
|
15
|
-
console.log(JSON.stringify(manifest));
|
|
16
|
-
}(process.cwd()));
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const util = require('util');
|
|
4
|
-
const exec = util.promisify(require('child_process').exec);
|
|
5
|
-
|
|
6
|
-
const SLACK_BOLT_SDK = '@slack/bolt';
|
|
7
|
-
let checkUpdateExports = {};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Wraps and parses the output of the exec() function
|
|
11
|
-
* @param command the command being run by the exec() function
|
|
12
|
-
*/
|
|
13
|
-
async function execWrapper (command) {
|
|
14
|
-
const { stdout } = await exec(command);
|
|
15
|
-
return stdout.trim();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Checks for available SDK updates for specified dependencies, creates a version map,
|
|
20
|
-
* and then wraps everything up into a response to be passed to the CLI.
|
|
21
|
-
* @param cwd the current working directory
|
|
22
|
-
*/
|
|
23
|
-
async function checkForSDKUpdates(cwd) {
|
|
24
|
-
const { versionMap, inaccessibleFiles } = await createVersionMap(cwd);
|
|
25
|
-
const updateResp = createUpdateResp(versionMap, inaccessibleFiles);
|
|
26
|
-
return updateResp;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Create a version map that contains each (Slack) dependency, detailing info about
|
|
31
|
-
* current and latest versions, as well as if breaking changes are present or if there
|
|
32
|
-
* were any errors with getting version retrieval.
|
|
33
|
-
* @param cwd the current working directory of the CLI project
|
|
34
|
-
*/
|
|
35
|
-
async function createVersionMap(cwd) {
|
|
36
|
-
const { versionMap, inaccessibleFiles } = await readProjectDependencies(cwd);
|
|
37
|
-
|
|
38
|
-
if (versionMap && versionMap[SLACK_BOLT_SDK]) {
|
|
39
|
-
const current = versionMap[SLACK_BOLT_SDK].current || '';
|
|
40
|
-
let latest = '',
|
|
41
|
-
error = null;
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
latest = await fetchLatestModuleVersion(SLACK_BOLT_SDK);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
error = err;
|
|
47
|
-
}
|
|
48
|
-
const update = !!current && !!latest && current !== latest;
|
|
49
|
-
const breaking = hasBreakingChange(current, latest);
|
|
50
|
-
|
|
51
|
-
versionMap[SLACK_BOLT_SDK] = {
|
|
52
|
-
...versionMap[SLACK_BOLT_SDK],
|
|
53
|
-
latest,
|
|
54
|
-
update,
|
|
55
|
-
breaking,
|
|
56
|
-
error,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return { versionMap, inaccessibleFiles };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Reads project dependencies - cycles through project dependency files, extracts
|
|
65
|
-
* the listed dependencies, and adds it in to the version map with version info.
|
|
66
|
-
* @param cwd the current working directory of the CLI project
|
|
67
|
-
*/
|
|
68
|
-
async function readProjectDependencies(cwd) {
|
|
69
|
-
const versionMap = {};
|
|
70
|
-
const { dependencyFile, inaccessibleFiles } = await gatherDependencyFiles(
|
|
71
|
-
cwd
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const [sdk, value] =
|
|
76
|
-
await checkUpdateExports.extractDependencies(dependencyFile.body, dependencyFile.name);
|
|
77
|
-
|
|
78
|
-
if (sdk !== '' && sdk === SLACK_BOLT_SDK) {
|
|
79
|
-
versionMap[SLACK_BOLT_SDK] = {
|
|
80
|
-
name: sdk,
|
|
81
|
-
current: value.version,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
} catch (err) {
|
|
85
|
-
inaccessibleFiles.push({ name: dependencyFile.name, error: err });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return { versionMap, inaccessibleFiles };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Reads and parses JSON file - if it works, returns the file contents.
|
|
93
|
-
* If not, returns an empty object
|
|
94
|
-
* @param filePath the path of the file being read
|
|
95
|
-
*/
|
|
96
|
-
async function getJSON(filePath) {
|
|
97
|
-
let fileContents = {};
|
|
98
|
-
try {
|
|
99
|
-
if (fs.existsSync(filePath)) {
|
|
100
|
-
fileContents = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
101
|
-
} else {
|
|
102
|
-
throw new Error('Cannot find a file at path ' + filePath);
|
|
103
|
-
}
|
|
104
|
-
} catch (err) {
|
|
105
|
-
throw new Error(err);
|
|
106
|
-
}
|
|
107
|
-
return fileContents;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Gathers all related dependency files for the CLI project (package.json).
|
|
112
|
-
* @param cwd the current working directory of the CLI project
|
|
113
|
-
*/
|
|
114
|
-
async function gatherDependencyFiles(cwd) {
|
|
115
|
-
const { jsonDepFile, inaccessibleFiles } = await getJSONFiles(cwd);
|
|
116
|
-
const dependencyFile = jsonDepFile;
|
|
117
|
-
return { dependencyFile, inaccessibleFiles };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Gets the needed files that contain dependency info (package.json).
|
|
122
|
-
* @param cwd the current working directory of the CLI project
|
|
123
|
-
*/
|
|
124
|
-
async function getJSONFiles(cwd) {
|
|
125
|
-
const packageJSON = 'package.json';
|
|
126
|
-
const jsonDepFile = {};
|
|
127
|
-
const inaccessibleFiles = [];
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
const jsonFile = await getJSON(`${cwd}/${packageJSON}`);
|
|
131
|
-
const jsonIsParsable =
|
|
132
|
-
jsonFile &&
|
|
133
|
-
typeof jsonFile === 'object' &&
|
|
134
|
-
!Array.isArray(jsonFile) &&
|
|
135
|
-
jsonFile.dependencies;
|
|
136
|
-
|
|
137
|
-
if (jsonIsParsable) {
|
|
138
|
-
jsonDepFile.name = packageJSON;
|
|
139
|
-
jsonDepFile.body= jsonFile;
|
|
140
|
-
}
|
|
141
|
-
} catch (err) {
|
|
142
|
-
inaccessibleFiles.push({ name: packageJSON, error: err });
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return { jsonDepFile, inaccessibleFiles };
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Pulls dependencies from a given file and JSON structure.
|
|
150
|
-
* @param json JSON information that includes dependencies
|
|
151
|
-
* @param fileName name of the file that the dependency list is coming from
|
|
152
|
-
*/
|
|
153
|
-
checkUpdateExports.extractDependencies = async (json, fileName) => {
|
|
154
|
-
// Determine if the JSON passed is an object
|
|
155
|
-
const jsonIsParsable =
|
|
156
|
-
json !== null && typeof json === 'object' && !Array.isArray(json);
|
|
157
|
-
|
|
158
|
-
if (jsonIsParsable) {
|
|
159
|
-
let boltCurrentVersion = '';
|
|
160
|
-
if (json['dependencies']['@slack/bolt']) {
|
|
161
|
-
const boltCurrentVersionOutput = JSON.parse(
|
|
162
|
-
await checkUpdateExports.getBoltCurrentVersion()
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
if (boltCurrentVersionOutput !== '') {
|
|
166
|
-
boltCurrentVersion =
|
|
167
|
-
boltCurrentVersionOutput['dependencies']['@slack/bolt']['version'];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return [
|
|
172
|
-
'@slack/bolt',
|
|
173
|
-
{
|
|
174
|
-
version: boltCurrentVersion,
|
|
175
|
-
},
|
|
176
|
-
];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return [];
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Gets the latest module version.
|
|
184
|
-
* @param moduleName the module that the latest version is being queried for
|
|
185
|
-
*/
|
|
186
|
-
async function fetchLatestModuleVersion(moduleName) {
|
|
187
|
-
let command = '';
|
|
188
|
-
if (moduleName === '@slack/bolt') {
|
|
189
|
-
command = `npm info ${moduleName} version --tag next-gen`;
|
|
190
|
-
} else if (moduleName === '@slack/deno-slack-sdk') {
|
|
191
|
-
command = `npm info ${moduleName} version --tag latest`;
|
|
192
|
-
}
|
|
193
|
-
const stdout = await execWrapper(command);
|
|
194
|
-
|
|
195
|
-
return stdout;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Checks if a dependency's upgrade from a current to the latest version will cause a
|
|
200
|
-
* breaking change.
|
|
201
|
-
* @param current current dependency version in project
|
|
202
|
-
* @param latest most up-to-date dependency version available on NPM
|
|
203
|
-
*/
|
|
204
|
-
function hasBreakingChange(current, latest) {
|
|
205
|
-
return current !== latest;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Creates the update response - returns an object in the expected response format.
|
|
210
|
-
* @param versionMap version map of checked dependencies, current versions, and info on upgrade + breaking changes
|
|
211
|
-
* @param inaccessibleFiles array of files that could not be read or accessed
|
|
212
|
-
*/
|
|
213
|
-
function createUpdateResp(versionMap, inaccessibleFiles) {
|
|
214
|
-
const name = 'the Slack SDK';
|
|
215
|
-
const releases = [];
|
|
216
|
-
const url = 'https://api.slack.com/future/changelog';
|
|
217
|
-
const fileErrorMsg = createFileErrorMsg(inaccessibleFiles);
|
|
218
|
-
|
|
219
|
-
let error = null;
|
|
220
|
-
let errorMsg = '';
|
|
221
|
-
let message = '';
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// Output information for each dependency
|
|
225
|
-
for (const sdk of Object.values(versionMap)) {
|
|
226
|
-
// Dependency has an update OR the fetch of update failed
|
|
227
|
-
if (sdk) {
|
|
228
|
-
releases.push(sdk);
|
|
229
|
-
|
|
230
|
-
// Add the dependency that failed to be fetched to the top-level error message
|
|
231
|
-
if (sdk.error && sdk.error.message) {
|
|
232
|
-
errorMsg += errorMsg
|
|
233
|
-
? `, ${sdk}`
|
|
234
|
-
: `An error occurred fetching updates for the following packages: ${sdk.name}`;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Surface release notes for breaking changes
|
|
240
|
-
if (releases && releases[0] && releases[0].breaking) {
|
|
241
|
-
message = `Learn more about the breaking change at https://github.com/slackapi/bolt-js/releases/tag/@slack/bolt@${releases[0].latest}`
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// If there were issues accessing dependency files, append error message(s)
|
|
245
|
-
if (inaccessibleFiles.length) {
|
|
246
|
-
errorMsg += errorMsg ? `\n\n ${fileErrorMsg}` : fileErrorMsg;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (errorMsg) {
|
|
250
|
-
error = { message: errorMsg };
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return {
|
|
254
|
-
name,
|
|
255
|
-
message,
|
|
256
|
-
releases,
|
|
257
|
-
url,
|
|
258
|
-
error,
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Returns error when dependency files cannot be read.
|
|
264
|
-
* @param inaccessibleFiles array of files that could not be read or accessed
|
|
265
|
-
*/
|
|
266
|
-
function createFileErrorMsg(inaccessibleFiles) {
|
|
267
|
-
let fileErrorMsg = '';
|
|
268
|
-
|
|
269
|
-
// There were issues with reading some of the files that were found
|
|
270
|
-
for (const file of inaccessibleFiles) {
|
|
271
|
-
fileErrorMsg += fileErrorMsg
|
|
272
|
-
? `\n ${file.name}: ${file.error.message}`
|
|
273
|
-
: `An error occurred while reading the following files: \n\n ${file.name}: ${file.error.message}`;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return fileErrorMsg;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Queries for current Bolt version of the project.
|
|
281
|
-
*/
|
|
282
|
-
checkUpdateExports.getBoltCurrentVersion = async () => {
|
|
283
|
-
const stdout = await execWrapper('npm list @slack/bolt --depth=0 --json');
|
|
284
|
-
return stdout;
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
module.exports = {
|
|
288
|
-
checkForSDKUpdates,
|
|
289
|
-
getJSON,
|
|
290
|
-
getJSONFiles,
|
|
291
|
-
checkUpdateExports,
|
|
292
|
-
};
|