@slack/bolt 4.0.0-nextGen.3 → 4.0.0-nextGen.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- const { getManifestData } = require('./hook-utils/manifest');
3
+ const { getManifestData } = require('./hook-utils/get-manifest-data');
4
4
  /**
5
5
  * Implements the get-manifest script hook required by the Slack CLI
6
6
  * Returns a manifest JSON string to stdout.
@@ -1 +1 @@
1
- {"version":3,"file":"get-manifest.js","sourceRoot":"","sources":["../../src/cli/get-manifest.js"],"names":[],"mappings":";;AACA,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAE7D;;;;;;EAME;AACF,CAAC,SAAS,CAAC,CAAC,GAAG;IACb,IAAI,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAEpC,2BAA2B;IAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"get-manifest.js","sourceRoot":"","sources":["../../src/cli/get-manifest.js"],"names":[],"mappings":";;AACA,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAEtE;;;;;;EAME;AACF,CAAC,SAAS,CAAC,CAAC,GAAG;IACb,IAAI,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAEpC,2BAA2B;IAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns any manifest data, if it exists.
3
+ * Otherwise throws an error
4
+ * @param searchDir path to begin searching at
5
+ */
6
+ export function getManifestData(searchDir: any): {};
7
+ //# sourceMappingURL=get-manifest-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-manifest-data.d.ts","sourceRoot":"","sources":["../../../src/cli/hook-utils/get-manifest-data.js"],"names":[],"mappings":"AASA;;;;GAIG;AACF,oDAsBA"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ const { readManifestJSONFile, readImportedManifestFile, hasManifest, unionMerge, } = require('./manifest.js');
3
+ const merge = require('deepmerge');
4
+ /**
5
+ * Returns any manifest data, if it exists.
6
+ * Otherwise throws an error
7
+ * @param searchDir path to begin searching at
8
+ */
9
+ function getManifestData(searchDir) {
10
+ const file = 'manifest';
11
+ let manifest = {};
12
+ // look for a manifest JSON
13
+ const manifestJSON = readManifestJSONFile(searchDir, `${file}.json`);
14
+ // look for manifest.js
15
+ let manifestJS = readImportedManifestFile(searchDir, `${file}.js`);
16
+ if (!hasManifest(manifestJS, manifestJSON)) {
17
+ const msg = 'Unable to find a manifest file in this project';
18
+ throw new Error(msg);
19
+ }
20
+ // manage manifest merge
21
+ if (manifestJSON) {
22
+ manifest = merge(manifest, manifestJSON, { arrayMerge: unionMerge });
23
+ }
24
+ if (manifestJS) {
25
+ manifest = merge(manifest, manifestJS, { arrayMerge: unionMerge });
26
+ }
27
+ return manifest;
28
+ }
29
+ module.exports = { getManifestData };
30
+ //# sourceMappingURL=get-manifest-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-manifest-data.js","sourceRoot":"","sources":["../../../src/cli/hook-utils/get-manifest-data.js"],"names":[],"mappings":";AAAA,MAAM,EACJ,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,UAAU,GACX,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAGnC;;;;GAIG;AACF,SAAS,eAAe,CAAC,SAAS;IACjC,MAAM,IAAI,GAAG,UAAU,CAAC;IACxB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAElB,2BAA2B;IAC3B,MAAM,YAAY,GAAG,oBAAoB,CAAC,SAAS,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;IACrE,uBAAuB;IACvB,IAAI,UAAU,GAAG,wBAAwB,CAAC,SAAS,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC;IAEnE,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE;QAC1C,MAAM,GAAG,GAAG,gDAAgD,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;IAED,wBAAwB;IACxB,IAAI,YAAY,EAAE;QAChB,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;KACtE;IACD,IAAI,UAAU,EAAE;QACd,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;KACpE;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get-manifest-data.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-manifest-data.spec.d.ts","sourceRoot":"","sources":["../../../src/cli/hook-utils/get-manifest-data.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ require('mocha');
26
+ const sinon = require('sinon');
27
+ const { expect, assert } = require('chai');
28
+ const rewiremock = require('rewiremock/node');
29
+ const { hasManifest } = require('./manifest');
30
+ const merge = require('deepmerge');
31
+ async function importGetManifestDataMock(overrides) {
32
+ return rewiremock.module(() => Promise.resolve().then(() => __importStar(require('./get-manifest-data.js'))), overrides);
33
+ }
34
+ describe('Slack CLI Script Hooks: get-manifest-data', () => {
35
+ it('returns a manifest object, when manifest.json and .js exist', async () => {
36
+ // Override methods that return manifest file data
37
+ const { getManifestData } = await importGetManifestDataMock({
38
+ './manifest.js': {
39
+ 'readManifestJSONFile': () => ({
40
+ testJSONKey: ''
41
+ }),
42
+ 'readImportedManifestFile': () => ({
43
+ testModuleKey: ''
44
+ }),
45
+ 'hasManifest': hasManifest,
46
+ 'merge': merge
47
+ }
48
+ });
49
+ // doesnt error
50
+ const shouldNotThrow = () => getManifestData('testSearchDir', 'testFilename');
51
+ assert.doesNotThrow(shouldNotThrow);
52
+ // returns a manifest with keys
53
+ const manifestData = getManifestData('testSearchDir', 'testFilename');
54
+ assert.isNotEmpty(manifestData);
55
+ assert.containsAllKeys(manifestData, ['testJSONKey', 'testModuleKey']);
56
+ });
57
+ it('returns a manifest object, when manifest.json exists', async () => {
58
+ const { getManifestData } = await importGetManifestDataMock({
59
+ './manifest.js': {
60
+ 'readManifestJSONFile': () => ({
61
+ testJSONKey: ''
62
+ }),
63
+ 'readImportedManifestFile': () => null,
64
+ 'hasManifest': hasManifest,
65
+ 'merge': merge
66
+ }
67
+ });
68
+ // doesnt error
69
+ const shouldNotThrow = () => getManifestData('testSearchDir', 'testFilename');
70
+ assert.doesNotThrow(shouldNotThrow);
71
+ // returns a manifest
72
+ const manifestData = getManifestData('testSearchDir', 'testFilename');
73
+ assert.isNotEmpty(manifestData);
74
+ assert.containsAllKeys(manifestData, ['testJSONKey']);
75
+ assert.doesNotHaveAllKeys(manifestData, ['testModuleKey']);
76
+ });
77
+ it('returns a manifest object, when manifest.js exists', async () => {
78
+ // Override readManifestJSON to return a value
79
+ const { getManifestData } = await importGetManifestDataMock({
80
+ './manifest.js': {
81
+ 'readManifestJSONFile': () => null,
82
+ 'readImportedManifestFile': () => ({
83
+ testModuleKey: ''
84
+ }),
85
+ 'hasManifest': hasManifest,
86
+ 'merge': merge
87
+ }
88
+ });
89
+ // doesnt error
90
+ const shouldNotThrow = () => getManifestData('testSearchDir', 'testFilename');
91
+ assert.doesNotThrow(shouldNotThrow);
92
+ // returns a manifest
93
+ const manifestData = getManifestData('testSearchDir', 'testFilename');
94
+ assert.isNotEmpty(manifestData);
95
+ assert.containsAllKeys(manifestData, ['testModuleKey']);
96
+ assert.doesNotHaveAllKeys(manifestData, ['testJSONKey']);
97
+ });
98
+ it('errors when no manifest js or json exist', async () => {
99
+ // Override neither manifest json nor js found
100
+ const { getManifestData } = await importGetManifestDataMock({
101
+ './manifest.js': {
102
+ 'readManifestJSONFile': () => null,
103
+ 'readImportedManifestFile': () => null,
104
+ 'hasManifest': hasManifest,
105
+ 'merge': merge
106
+ }
107
+ });
108
+ // doesnt error
109
+ const shouldThrow = () => getManifestData('testSearchDir', 'testFilename');
110
+ assert.throws(shouldThrow, Error, 'Unable to find a manifest');
111
+ });
112
+ });
113
+ //# sourceMappingURL=get-manifest-data.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-manifest-data.spec.js","sour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BAC1B,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QAEH,eAAe;QACf,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QAC9E,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QAEpC,qBAAqB;QACrB,MAAM,YAAY,GAAG,eAAe,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QACtE,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAChC,MAAM,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;QACxD,MAAM,CAAC,kBAAkB,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,8CAA8C;QAC9C,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,yBAAyB,CAAC;YAC1D,eAAe,EAAE;gBACf,sBAAsB,EAAE,GAAG,EAAE,CAAC,IAAI;gBAClC,0BAA0B,EAAE,GAAG,EAAE,CAAC,IAAI;gBACtC,aAAa,EAAE,WAAW;gBAC1B,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QAEH,eAAe;QACf,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QAC3E,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,2BAA2B,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,7 +1,30 @@
1
- export function getManifestData(searchDir: any): {};
1
+ /**
2
+ * Union merge of arrays
3
+ */
2
4
  export function unionMerge(array1: any, array2: any): any[];
5
+ /**
6
+ * Returns a manifest.json if it exists, null otherwise
7
+ * @param searchDir typically current working directory
8
+ * @param filename file to search for
9
+ */
3
10
  export function readManifestJSONFile(searchDir: any, filename: any): any;
11
+ /**
12
+ * Returns a manifest object if it exists, null otherwise
13
+ * @param searchDir typically current working directory
14
+ * @param filename file to search for
15
+ */
4
16
  export function readImportedManifestFile(searchDir: any, filename: any): any;
17
+ /**
18
+ * @param entries
19
+ * @returns true if any non-empty manifest has been supplied
20
+ * */
5
21
  export function hasManifest(...entries: any[]): boolean;
22
+ /**
23
+ * Search for provided file path.
24
+ * Returns full path when filename is found or null if no file found.
25
+ * @param currentPath string of current path
26
+ * @param targetFilename filename to match
27
+ * @returns full file path string relative to starting path or null
28
+ * */
6
29
  export function find(currentPath: any, targetFilename: any): any;
7
30
  //# sourceMappingURL=manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.js"],"names":[],"mappings":"AAgFA,oDAwBC;AAnGD,4DAEC;AAGD,yEAWC;AAGD,6EAkBC;AAGD,wDAOC;AAOD,iEAmBC"}
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.js"],"names":[],"mappings":"AAGA;;GAEG;AACH,4DAEC;AAED;;;;GAIG;AACH,yEAWC;AAED;;;;GAIG;AACH,6EAqBC;AAED;;;KAGK;AACL,wDAOC;AAED;;;;;;KAMK;AACL,iEAuBC"}
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const merge = require('deepmerge');
5
- // helper array merge function
4
+ /**
5
+ * Union merge of arrays
6
+ */
6
7
  function unionMerge(array1, array2) {
7
8
  return [...new Set(array1.concat(array2))];
8
9
  }
9
- // look for manifest.json in the current working directory
10
+ /**
11
+ * Returns a manifest.json if it exists, null otherwise
12
+ * @param searchDir typically current working directory
13
+ * @param filename file to search for
14
+ */
10
15
  function readManifestJSONFile(searchDir, filename) {
11
16
  let jsonFilePath, manifestJSON;
12
17
  try {
@@ -16,11 +21,15 @@ function readManifestJSONFile(searchDir, filename) {
16
21
  }
17
22
  }
18
23
  catch (error) {
19
- return;
24
+ return null;
20
25
  }
21
26
  return manifestJSON;
22
27
  }
23
- // look for a manifest file in the current working directory
28
+ /**
29
+ * Returns a manifest object if it exists, null otherwise
30
+ * @param searchDir typically current working directory
31
+ * @param filename file to search for
32
+ */
24
33
  function readImportedManifestFile(searchDir, filename) {
25
34
  let importedManifestFilePath, manifestImported;
26
35
  try {
@@ -31,15 +40,21 @@ function readImportedManifestFile(searchDir, filename) {
31
40
  if (manifestImported["default"]) {
32
41
  manifestImported = manifestImported["default"];
33
42
  }
43
+ // stringify and parses the JSON in order to ensure that objects with .toJSON() functions
44
+ // resolve properly. This is a known behavior for CustomType
45
+ manifestImported = JSON.parse(JSON.stringify(manifestImported));
34
46
  }
35
47
  }
36
48
  catch (error) {
37
49
  console.log(error);
38
- return;
50
+ return null;
39
51
  }
40
52
  return manifestImported;
41
53
  }
42
- // true if any non empty manifest has been supplied
54
+ /**
55
+ * @param entries
56
+ * @returns true if any non-empty manifest has been supplied
57
+ * */
43
58
  function hasManifest(...entries) {
44
59
  for (let ent of entries) {
45
60
  if (ent && (Object.keys(ent).length > 0)) {
@@ -48,12 +63,18 @@ function hasManifest(...entries) {
48
63
  }
49
64
  return false;
50
65
  }
51
- // recursive search for provided path and return full path when filename is found
52
- // TODO: Cache searched paths and check that they haven't been explored already
53
- // This guards against rare edge case of a subdir in the file tree which is
54
- // symlinked back to root or in such a way that creates a cycle. Can also implement
55
- // max depth check.
66
+ /**
67
+ * Search for provided file path.
68
+ * Returns full path when filename is found or null if no file found.
69
+ * @param currentPath string of current path
70
+ * @param targetFilename filename to match
71
+ * @returns full file path string relative to starting path or null
72
+ * */
56
73
  function find(currentPath, targetFilename) {
74
+ // TODO Cache searched paths and check that they haven't been explored already
75
+ // This guards against rare edge case of a subdir in the file tree which is
76
+ // symlinked back to root or in such a way that creates a cycle. Can also implement
77
+ // max depth check.
57
78
  if (currentPath.endsWith(`/${targetFilename}`)) {
58
79
  return currentPath;
59
80
  }
@@ -72,29 +93,7 @@ function find(currentPath, targetFilename) {
72
93
  return null;
73
94
  }
74
95
  }
75
- function getManifestData(searchDir) {
76
- const file = 'manifest';
77
- let manifest = {};
78
- // look for a manifest JSON
79
- const manifestJSON = readManifestJSONFile(searchDir, `${file}.json`);
80
- // look for manifest.js
81
- // stringify and parses the JSON in order to ensure that objects with .toJSON() functions
82
- // resolve properly. This is a known behavior for CustomType
83
- const manifestJS = JSON.parse(JSON.stringify(readImportedManifestFile(searchDir, `${file}.js`)));
84
- if (!hasManifest(manifestJS, manifestJSON)) {
85
- throw new Error('Unable to find a manifest file in this project');
86
- }
87
- // manage manifest merge
88
- if (manifestJSON) {
89
- manifest = merge(manifest, manifestJSON, { arrayMerge: unionMerge });
90
- }
91
- if (manifestJS) {
92
- manifest = merge(manifest, manifestJS, { arrayMerge: unionMerge });
93
- }
94
- return manifest;
95
- }
96
96
  module.exports = {
97
- getManifestData,
98
97
  unionMerge,
99
98
  readManifestJSONFile,
100
99
  readImportedManifestFile,
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.js"],"names":[],"mappings":";AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEnC,8BAA8B;AAC9B,SAAS,UAAU,CAAC,MAAM,EAAE,MAAM;IAChC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,0DAA0D;AAC1D,SAAS,oBAAoB,CAAC,SAAS,EAAE,QAAQ;IAC/C,IAAI,YAAY,EAAE,YAAY,CAAC;IAC/B,IAAI;QACF,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC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AAI,KAAK,KAAK,cAAc,EAAE;gBAC5B,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;gBAC/C,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;gBAC3C,IAAI,UAAU,EAAE;oBACd,OAAO,UAAU,CAAC;iBACnB;aACF;SACF;QACD,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACf,UAAU;IACV,oBAAoB;IACpB,wBAAwB;IACxB,WAAW;IACX,IAAI;CACL,CAAA"}
@@ -6,6 +6,7 @@ const { fs } = require('memfs');
6
6
  const mockfs = require('mock-fs');
7
7
  const manifestUtils = require('./manifest');
8
8
  const { unionMerge, hasManifest, find } = manifestUtils;
9
+ const rewiremock = require('rewiremock');
9
10
  describe('Slack CLI Script Hooks: get-manifest utilities', () => {
10
11
  describe('unionMerge', () => {
11
12
  it('should return a union of two arrays', () => {
@@ -27,6 +28,9 @@ describe('Slack CLI Script Hooks: get-manifest utilities', () => {
27
28
  it('should return false if all empty objects', () => {
28
29
  expect(hasManifest({}));
29
30
  });
31
+ it('should handle an undefined or null objects', () => {
32
+ expect(hasManifest(undefined, null, { testKey: "testValue" })).to.be.true;
33
+ });
30
34
  });
31
35
  describe('find', () => {
32
36
  beforeEach(() => {
@@ -1 +1 @@
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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C5B,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slack/bolt",
3
- "version": "4.0.0-nextGen.3",
3
+ "version": "4.0.0-nextGen.4",
4
4
  "description": "A framework for building Slack apps, fast.",
5
5
  "author": "Slack Technologies, LLC",
6
6
  "license": "MIT",
@@ -93,7 +93,7 @@
93
93
  "source-map-support": "^0.5.12",
94
94
  "ts-node": "^8.1.0",
95
95
  "tsd": "^0.22.0",
96
- "typescript": "4.7.4"
96
+ "typescript": "4.8.3"
97
97
  },
98
98
  "tsd": {
99
99
  "directory": "types-tests"
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const { getManifestData } = require('./hook-utils/manifest');
2
+ const { getManifestData } = require('./hook-utils/get-manifest-data');
3
3
 
4
4
  /**
5
5
  * Implements the get-manifest script hook required by the Slack CLI
@@ -1,13 +1,18 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
- const merge = require('deepmerge');
4
3
 
5
- // helper array merge function
4
+ /**
5
+ * Union merge of arrays
6
+ */
6
7
  function unionMerge(array1, array2) {
7
8
  return [...new Set(array1.concat(array2))];
8
9
  }
9
10
 
10
- // look for manifest.json in the current working directory
11
+ /**
12
+ * Returns a manifest.json if it exists, null otherwise
13
+ * @param searchDir typically current working directory
14
+ * @param filename file to search for
15
+ */
11
16
  function readManifestJSONFile(searchDir, filename) {
12
17
  let jsonFilePath, manifestJSON;
13
18
  try {
@@ -16,12 +21,16 @@ function readManifestJSONFile(searchDir, filename) {
16
21
  manifestJSON = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8'));
17
22
  }
18
23
  } catch (error) {
19
- return;
24
+ return null;
20
25
  }
21
26
  return manifestJSON;
22
27
  }
23
28
 
24
- // look for a manifest file in the current working directory
29
+ /**
30
+ * Returns a manifest object if it exists, null otherwise
31
+ * @param searchDir typically current working directory
32
+ * @param filename file to search for
33
+ */
25
34
  function readImportedManifestFile(searchDir, filename) {
26
35
  let importedManifestFilePath, manifestImported;
27
36
 
@@ -34,15 +43,21 @@ function readImportedManifestFile(searchDir, filename) {
34
43
  if (manifestImported["default"]) {
35
44
  manifestImported = manifestImported["default"]
36
45
  }
46
+ // stringify and parses the JSON in order to ensure that objects with .toJSON() functions
47
+ // resolve properly. This is a known behavior for CustomType
48
+ manifestImported = JSON.parse(JSON.stringify(manifestImported));
37
49
  }
38
50
  } catch (error) {
39
51
  console.log(error);
40
- return;
52
+ return null;
41
53
  }
42
54
  return manifestImported;
43
55
  }
44
56
 
45
- // true if any non empty manifest has been supplied
57
+ /**
58
+ * @param entries
59
+ * @returns true if any non-empty manifest has been supplied
60
+ * */
46
61
  function hasManifest(...entries) {
47
62
  for (let ent of entries) {
48
63
  if (ent && (Object.keys(ent).length > 0)) {
@@ -52,12 +67,18 @@ function hasManifest(...entries) {
52
67
  return false;
53
68
  }
54
69
 
55
- // recursive search for provided path and return full path when filename is found
56
- // TODO: Cache searched paths and check that they haven't been explored already
57
- // This guards against rare edge case of a subdir in the file tree which is
58
- // symlinked back to root or in such a way that creates a cycle. Can also implement
59
- // max depth check.
70
+ /**
71
+ * Search for provided file path.
72
+ * Returns full path when filename is found or null if no file found.
73
+ * @param currentPath string of current path
74
+ * @param targetFilename filename to match
75
+ * @returns full file path string relative to starting path or null
76
+ * */
60
77
  function find(currentPath, targetFilename) {
78
+ // TODO Cache searched paths and check that they haven't been explored already
79
+ // This guards against rare edge case of a subdir in the file tree which is
80
+ // symlinked back to root or in such a way that creates a cycle. Can also implement
81
+ // max depth check.
61
82
  if (currentPath.endsWith(`/${targetFilename}`)) {
62
83
  return currentPath;
63
84
  }
@@ -78,34 +99,7 @@ function find(currentPath, targetFilename) {
78
99
  }
79
100
  }
80
101
 
81
- function getManifestData(searchDir) {
82
- const file = 'manifest';
83
- let manifest = {};
84
-
85
- // look for a manifest JSON
86
- const manifestJSON = readManifestJSONFile(searchDir, `${file}.json`);
87
-
88
- // look for manifest.js
89
- // stringify and parses the JSON in order to ensure that objects with .toJSON() functions
90
- // resolve properly. This is a known behavior for CustomType
91
- const manifestJS = JSON.parse(JSON.stringify(readImportedManifestFile(searchDir, `${file}.js`)));
92
-
93
- if (!hasManifest(manifestJS, manifestJSON)) {
94
- throw new Error('Unable to find a manifest file in this project');
95
- }
96
-
97
- // manage manifest merge
98
- if (manifestJSON) {
99
- manifest = merge(manifest, manifestJSON, { arrayMerge: unionMerge});
100
- }
101
- if (manifestJS) {
102
- manifest = merge(manifest, manifestJS, { arrayMerge: unionMerge });
103
- }
104
- return manifest;
105
- }
106
-
107
102
  module.exports = {
108
- getManifestData,
109
103
  unionMerge,
110
104
  readManifestJSONFile,
111
105
  readImportedManifestFile,