Просмотр исходного кода

export all objects to the root module

Yuki Takei 5 лет назад
Родитель
Сommit
5e5a4114c9

+ 0 - 1
packages/slack/.gitignore

@@ -1 +0,0 @@
-/lib/

+ 5 - 0
packages/slack/package.json

@@ -2,7 +2,11 @@
   "name": "@growi/slack",
   "name": "@growi/slack",
   "version": "0.9.0-RC",
   "version": "0.9.0-RC",
   "license": "MIT",
   "license": "MIT",
+  "main": "dist/index.js",
+  "typings": "dist/index.d.ts",
   "scripts": {
   "scripts": {
+    "build": "yarn tsc",
+    "tsc": "tsc -b --verbose tsconfig.build.json && tsc-alias -p tsconfig.build.json",
     "test": "yarn test:lint && yarn test:coverage",
     "test": "yarn test:lint && yarn test:coverage",
     "test:unit": "cross-env NODE_ENV=test jest --passWithNoTests",
     "test:unit": "cross-env NODE_ENV=test jest --passWithNoTests",
     "test:coverage": "yarn test:unit",
     "test:coverage": "yarn test:unit",
@@ -24,6 +28,7 @@
     "eslint-import-resolver-typescript": "^2.4.0",
     "eslint-import-resolver-typescript": "^2.4.0",
     "eslint-plugin-jest": "^24.3.2",
     "eslint-plugin-jest": "^24.3.2",
     "ts-jest": "^26.5.4",
     "ts-jest": "^26.5.4",
+    "tsc-alias": "^1.2.9",
     "typescript": "^4.2.3"
     "typescript": "^4.2.3"
   }
   }
 }
 }

+ 4 - 0
packages/slack/src/index.ts

@@ -6,3 +6,7 @@ export const supportedGrowiCommands: string[] = [
   'search',
   'search',
   'create',
   'create',
 ];
 ];
+
+export * from './interfaces/growi-command';
+export * from './models/errors';
+export * from './utils/slash-command-parser';

+ 7 - 7
packages/slack/src/utils/slash-command-parser.test.ts

@@ -1,13 +1,13 @@
 import { SlashCommand } from '@slack/bolt';
 import { SlashCommand } from '@slack/bolt';
 import { InvalidGrowiCommandError } from '../models/errors';
 import { InvalidGrowiCommandError } from '../models/errors';
 
 
-import { parse } from './slash-command-parser';
+import { parseSlashCommand } from './slash-command-parser';
 
 
 const SlashCommandMock = jest.fn<SlashCommand, [string]>().mockImplementation((text) => {
 const SlashCommandMock = jest.fn<SlashCommand, [string]>().mockImplementation((text) => {
   return { text } as SlashCommand;
   return { text } as SlashCommand;
 });
 });
 
 
-describe('parse SlashCommand', () => {
+describe('parseSlashCommand', () => {
 
 
   describe('without growiCommandType', () => {
   describe('without growiCommandType', () => {
     test('throws InvalidGrowiCommandError', () => {
     test('throws InvalidGrowiCommandError', () => {
@@ -17,7 +17,7 @@ describe('parse SlashCommand', () => {
 
 
       // when/then
       // when/then
       expect(() => {
       expect(() => {
-        parse(slashCommand);
+        parseSlashCommand(slashCommand);
       }).toThrowError(InvalidGrowiCommandError);
       }).toThrowError(InvalidGrowiCommandError);
     });
     });
   });
   });
@@ -28,7 +28,7 @@ describe('parse SlashCommand', () => {
     const slashCommand = new SlashCommandMock(slashCommandText);
     const slashCommand = new SlashCommandMock(slashCommandText);
 
 
     // when
     // when
-    const result = parse(slashCommand);
+    const result = parseSlashCommand(slashCommand);
 
 
     // then
     // then
     expect(result.text).toBe(slashCommandText);
     expect(result.text).toBe(slashCommandText);
@@ -42,7 +42,7 @@ describe('parse SlashCommand', () => {
     const slashCommand = new SlashCommandMock(slashCommandText);
     const slashCommand = new SlashCommandMock(slashCommandText);
 
 
     // when
     // when
-    const result = parse(slashCommand);
+    const result = parseSlashCommand(slashCommand);
 
 
     // then
     // then
     expect(result.text).toBe(slashCommandText);
     expect(result.text).toBe(slashCommandText);
@@ -56,7 +56,7 @@ describe('parse SlashCommand', () => {
     const slashCommand = new SlashCommandMock(slashCommandText);
     const slashCommand = new SlashCommandMock(slashCommandText);
 
 
     // when
     // when
-    const result = parse(slashCommand);
+    const result = parseSlashCommand(slashCommand);
 
 
     // then
     // then
     expect(result.text).toBe(slashCommandText);
     expect(result.text).toBe(slashCommandText);
@@ -70,7 +70,7 @@ describe('parse SlashCommand', () => {
     const slashCommand = new SlashCommandMock(slashCommandText);
     const slashCommand = new SlashCommandMock(slashCommandText);
 
 
     // when
     // when
-    const result = parse(slashCommand);
+    const result = parseSlashCommand(slashCommand);
 
 
     // then
     // then
     expect(result.text).toBe(slashCommandText);
     expect(result.text).toBe(slashCommandText);

+ 1 - 1
packages/slack/src/utils/slash-command-parser.ts

@@ -1,7 +1,7 @@
 import { GrowiCommand } from '../interfaces/growi-command';
 import { GrowiCommand } from '../interfaces/growi-command';
 import { InvalidGrowiCommandError } from '../models/errors';
 import { InvalidGrowiCommandError } from '../models/errors';
 
 
-export const parse = (slashCommand:{[key:string]:string}): GrowiCommand => {
+export const parseSlashCommand = (slashCommand:{[key:string]:string}): GrowiCommand => {
   const trimmedText = slashCommand.text.trim();
   const trimmedText = slashCommand.text.trim();
   const splitted = trimmedText.split(' ');
   const splitted = trimmedText.split(' ');
 
 

+ 1 - 2
packages/slack/tsconfig.build.json

@@ -2,8 +2,7 @@
   "extends": "./tsconfig.json",
   "extends": "./tsconfig.json",
   "compilerOptions": {
   "compilerOptions": {
     "rootDir": "./src",
     "rootDir": "./src",
-    "outDir": "../../dist/slack",
-    "composite": true,
+    "outDir": "dist",
     "declaration": true,
     "declaration": true,
     "noResolve": false,
     "noResolve": false,
     "preserveConstEnums": true,
     "preserveConstEnums": true,

+ 1 - 0
packages/slack/tsconfig.json

@@ -7,6 +7,7 @@
   },
   },
   "exclude": [
   "exclude": [
     "node_modules",
     "node_modules",
+    "dist",
     "**/*.test.ts"
     "**/*.test.ts"
   ]
   ]
 }
 }