Commit ad9a13e3 authored by Harrison Healey's avatar Harrison Healey

Merge branch 'master' into mark-as-unread

parents fcdcfe0a 47334e5f
......@@ -5,6 +5,16 @@ executors:
docker:
- image: circleci/node:11.3.0
aliases:
- &restore_cache
restore_cache:
key: dependencies-{{ checksum "package-lock.json" }}
- &save_cache
save_cache:
key: dependencies-{{ checksum "package-lock.json" }}
paths:
- node_modules
jobs:
install:
executor:
......@@ -12,38 +22,26 @@ jobs:
steps:
- checkout
- run: ls -la
- restore_cache:
keys:
- test-dependencies-{{ checksum "package.json" }}
- run: npm install --ignore-scripts
- run: npm run flow-typed install
- *restore_cache
- run: npm install
- run: ls -la
- save_cache:
paths:
- node_modules
- flow-typed
key: test-dependencies-{{ checksum "package.json" }}
- *save_cache
lint:
executor:
name: default
steps:
- checkout
- restore_cache:
keys:
- test-dependencies-{{ checksum "package.json" }}
- *restore_cache
- run: npm run check
- run: npm run flow
- run: npm run tsc
test:
executor:
name: default
steps:
- checkout
- restore_cache:
keys:
- test-dependencies-{{ checksum "package.json" }}
- *restore_cache
- run: npm test
- store_test_results:
path: build/
......
{
"extends": [
"./node_modules/eslint-config-mattermost/.eslintrc.json",
"plugin:flowtype/recommended"
],
"env": {
"jest": true
},
"plugins": [
"flowtype"
],
"overrides": [
{
"files": ["*.test.js"],
"env": {
"extends": [
"./node_modules/eslint-config-mattermost/.eslintrc.json",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"env": {
"jest": true
}
}
]
},
"rules": {
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/no-undefined": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"no-prototype-builtins": 0,
"no-mixed-operators": 0,
"no-undefined": 0,
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "function",
"next": "function"
}
],
"no-nested-ternary": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-use-before-define": 0,
"max-lines": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-function-return-type": 0
},
"overrides": [
{
"files": [
"*.test.js"
],
"env": {
"jest": true
}
}
]
}
[ignore]
<PROJECT_ROOT>/node_modules/.*
<PROJECT_ROOT>/action_types/.*
<PROJECT_ROOT>/actions/.*
<PROJECT_ROOT>/client/.*
<PROJECT_ROOT>/constants/.*
<PROJECT_ROOT>/reducers/.*
<PROJECT_ROOT>/selectors/.*
<PROJECT_ROOT>/store/.*
<PROJECT_ROOT>/utils/.*
<PROJECT_ROOT>/types/.*
[include]
[libs]
[lints]
[options]
module.system.node.resolve_dirname=node_modules
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
module.name_mapper='^action_types\(.*\)$' -> '<PROJECT_ROOT>/src/action_types/\1'
module.name_mapper='^actions\(.*\)$' -> '<PROJECT_ROOT>/src/actions/\1'
module.name_mapper='^client\(.*\)$' -> '<PROJECT_ROOT>/src/client/\1'
module.name_mapper='^constants\(.*\)$' -> '<PROJECT_ROOT>/src/constants/\1'
module.name_mapper='^reducers\(.*\)$' -> '<PROJECT_ROOT>/src/reducers/\1'
module.name_mapper='^selectors\(.*\)$' -> '<PROJECT_ROOT>/src/selectors/\1'
module.name_mapper='^store\(.*\)$' -> '<PROJECT_ROOT>/src/store/\1'
module.name_mapper='^utils\(.*\)$' -> '<PROJECT_ROOT>/src/utils/\1'
module.name_mapper='^types\(.*\)$' -> '<PROJECT_ROOT>/src/types/\1'
[version]
0.95.1
......@@ -47,3 +47,16 @@ mattermost-redux-*.tgz
# test coverage
coverage
/.rts2_cache_cjs/
/.rts2_cache_esm/
/dist/
/build/
/tsconfig.tsbuildinfo
junit.xml
index.d.ts
index.js
index.js.map
mattermost.client4.js
mattermost.client4.js.map
mattermost.websocket_client.js
mattermost.websocket_client.js.map
......@@ -10,3 +10,13 @@ PULL_REQUEST_TEMPLATE.md
.npmignore
.npminstall
.tmp
src
.circleci
jest.config.js
babel.config.js
rollup.config.js
tsconfig.json
.editorconfig
.eslintignore
mattermost-redux.iml
.eslintrc.json
\ No newline at end of file
.PHONY: check-style clean pre-run test install flow
.PHONY: check-style clean pre-run test install
node_modules: package.json
@if ! [ $(shell which npm) ]; then \
......@@ -15,41 +15,21 @@ check-style: | pre-run node_modules
npm run check
clean:
clean: pre-run
@echo Cleaning app
rm -rf node_modules
rm -rf node_modules
pre-run:
@echo Make sure no previous build are in the folder
@rm -rf actions
@rm -rf action_types
@rm -rf client
@rm -rf constants
@rm -rf reducers
@rm -rf selectors
@rm -rf store
@rm -rf utils
@rm -rf lib
test: check-style flow
npm test
flow: .flowinstall
@echo Checking types
npm run flow
@rm -rf build/* actions client constants reducers selectors store utils types mattermost.client4* index.* mattermost.websocket_client*
.flowinstall: node_modules
@echo Getting flow-typed packages
npm run flow-typed install
test: check-style
npm test
touch $@
install: node_modules
bundle:
bundle: | pre-run node_modules
npm run build
npm run webpack
......@@ -15,13 +15,16 @@ const config = {
useBuiltIns: 'usage',
shippedProposals: true,
}],
'@babel/typescript',
],
plugins: [
'@babel/transform-flow-comments',
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
'@babel/plugin-proposal-optional-chaining',
['module-resolver', {
root: ['./src', '.'],
root: ['./src', './test'],
}],
],
};
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
module.exports = {
globals: {
'ts-jest': {
tsConfig: 'tsconfig.json',
diagnostics: true,
},
NODE_ENV: 'test',
},
preset: 'ts-jest/presets/js-with-babel',
rootDir: '.',
moduleDirectories: ['node_modules', 'src'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
transformIgnorePatterns: ['<rootDir>/node_modules/'],
testMatch: [
'<rootDir>/src/**/?(*.)(spec|test).(ts|js)?(x)',
],
setupFilesAfterEnv: [
'<rootDir>/test/setup.js',
],
clearMocks: true,
collectCoverageFrom: [
'src/**/*.{js}',
'src/**/*.{ts}',
],
coverageReporters: [
'lcov',
'text-summary',
],
reporters: [
'default',
'jest-junit',
],
verbose: true,
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1',
'^test/(.*)$': '<rootDir>/test/$1',
'^utils/(.*)$': '<rootDir>/src/utils/$1',
'^actions/(.*)$': '<rootDir>/src/actions/$1',
'^action_types$': '<rootDir>/src/action_types',
'^constants$': '<rootDir>/src/constants',
'^action_types/(.*)$': '<rootDir>/src/action_types/$1',
},
};
This diff is collapsed.
......@@ -8,99 +8,86 @@
"bugs": {
"url": "https://github.com/mattermost/mattermost-redux/issues"
},
"scripts": {
"start": "ttsc --watch",
"build": "cross-env NODE_ENV=production ttsc && cross-env NODE_ENV=production rollup -c",
"check": "eslint --ignore-path .gitignore --ignore-pattern node_modules --quiet 'src/**/*.ts'",
"fix": "eslint --ignore-path .gitignore --ignore-pattern node_modules --quiet 'src/**/*.ts' --fix",
"tsc": "ttsc --noEmit",
"tsc:watch": "ttsc --noEmit --watch",
"test": "jest --forceExit --detectOpenHandles --maxWorkers=2",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"prepare": "npm run build",
"dev": "ttsc --outDir ${WEBAPP_DIR:-../mattermost-webapp}/node_modules/mattermost-redux",
"dev-mobile": "ttsc --outDir ${MOBILE_DIR:-../mattermost-mobile}/node_modules/mattermost-redux",
"dev:watch": "ttsc --watch --outDir ${WEBAPP_DIR:-../mattermost-webapp}/node_modules/mattermost-redux",
"dev-mobile:watch": "ttsc --watch --outDir ${MOBILE_DIR:-../mattermost-mobile}/node_modules/mattermost-redux"
},
"dependencies": {
"deep-equal": "1.0.1",
"eslint-plugin-header": "3.0.0",
"form-data": "2.5.0",
"gfycat-sdk": "1.4.18",
"harmony-reflect": "1.6.1",
"isomorphic-fetch": "2.2.1",
"mime-db": "1.40.0",
"moment-timezone": "0.5.26",
"isomorphic-fetch": "2.2.1",
"redux": "4.0.4",
"redux-action-buffer": "1.2.0",
"redux-batched-actions": "0.4.1",
"redux-offline": "git+https://github.com/enahum/redux-offline.git#885024de96b6ec73650c340c8928066585c413df",
"redux-persist": "4.9.1",
"redux-persist-node-storage": "2.0.0",
"redux-thunk": "2.3.0",
"remote-redux-devtools": "0.5.16",
"reselect": "4.0.0",
"serialize-error": "2.1.0",
"shallow-equals": "1.0.0"
},
"husky": {
"hooks": {
"pre-commit": "npm run check && npm run tsc"
}
},
"jest-junit": {
"output": "build/test-results.xml"
},
"devDependencies": {
"@babel/cli": "7.5.5",
"@babel/core": "7.5.5",
"@babel/core": "7.6.0",
"@babel/plugin-proposal-class-properties": "7.5.5",
"@babel/plugin-proposal-object-rest-spread": "7.6.2",
"@babel/plugin-proposal-optional-chaining": "7.2.0",
"@babel/plugin-transform-flow-comments": "7.5.5",
"@babel/polyfill": "7.4.4",
"@babel/preset-env": "7.5.5",
"@babel/register": "7.5.5",
"babel-eslint": "10.0.2",
"babel-jest": "24.8.0",
"babel-loader": "8.0.6",
"@babel/plugin-transform-runtime": "7.6.0",
"@babel/preset-env": "7.6.0",
"@babel/preset-typescript": "7.6.0",
"@babel/runtime": "7.6.0",
"@typescript-eslint/eslint-plugin": "2.3.1",
"@typescript-eslint/parser": "2.3.1",
"@types/jest": "24.0.18",
"@types/moment-timezone": "0.5.12",
"@types/node": "12.7.11",
"@zerollup/ts-transform-paths": "1.7.3",
"babel-eslint": "10.0.3",
"babel-plugin-module-resolver": "3.2.0",
"core-js": "3.1.4",
"chai": "4.2.0",
"deep-freeze": "0.0.1",
"cross-env": "6.0.3",
"eslint": "6.0.1",
"eslint-config-mattermost": "github:mattermost/eslint-config-mattermost#6fe27a2bd1f9df4d4eb96fac6fcdcc0fee0ecbd7",
"eslint-plugin-flowtype": "3.12.1",
"eslint-plugin-jest": "22.11.1",
"expect": "24.8.0",
"fetch-mock": "7.3.7",
"flow-bin": "0.95.1",
"flow-typed": "2.5.1",
"eslint-plugin-cypress": "2.7.0",
"eslint-plugin-header": "3.0.0",
"eslint-plugin-import": "2.18.2",
"form-data": "2.5.1",
"husky": "3.0.5",
"jest": "24.8.0",
"jest-cli": "24.8.0",
"jest-junit": "6.4.0",
"mock-socket": "8.0.5",
"nock": "10.0.6",
"react": "16.8.6",
"nock": "^11.3.5",
"redux-mock-store": "1.5.3",
"redux-persist-node-storage": "2.0.0",
"remote-redux-devtools": "0.5.16",
"uglifyjs-webpack-plugin": "2.1.3",
"webpack": "4.36.1",
"ws": "7.1.1"
},
"scripts": {
"build": "babel src --out-dir . --ignore '**/*.test.js'",
"webpack": "webpack",
"dev": "babel src --out-dir ${WEBAPP_DIR:-../mattermost-webapp}/node_modules/mattermost-redux --source-maps",
"dev-mobile": "babel src --out-dir ${MOBILE_DIR:-../mattermost-mobile}/node_modules/mattermost-redux --source-maps",
"dev:watch": "babel --watch src --out-dir ${WEBAPP_DIR:-../mattermost-webapp}/node_modules/mattermost-redux --source-maps",
"dev-mobile:watch": "babel --watch src --out-dir ${MOBILE_DIR:-../mattermost-mobile}/node_modules/mattermost-redux --source-maps",
"check": "eslint --ignore-path .gitignore --ignore-pattern node_modules --quiet .",
"fix": "eslint --ignore-path .gitignore --ignore-pattern node_modules --quiet . --fix",
"flow": "flow",
"flow-typed": "flow-typed",
"test": "jest --forceExit --detectOpenHandles --maxWorkers=2",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"prepare": "npm run build"
},
"jest": {
"clearMocks": true,
"collectCoverageFrom": [
"src/**/*.{js}"
],
"coverageReporters": [
"lcov",
"text-summary"
],
"reporters": [
"default",
"jest-junit"
],
"setupFilesAfterEnv": [
"<rootDir>/test/setup.js"
],
"testPathIgnorePatterns": [
"/node_modules/"
]
},
"jest-junit": {
"output": "build/test-results.xml"
"rollup": "1.22.0",
"rollup-plugin-babel": "4.3.3",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-terser": "5.1.2",
"rollup-plugin-typescript2": "0.24.3",
"ts-jest": "24.1.0",
"tslib": "1.10.0",
"ttypescript": "1.5.7",
"source-map-support": "0.5.12",
"typescript": "3.6.3"
}
}
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import resolve from 'rollup-plugin-node-resolve';
import {terser} from 'rollup-plugin-terser';
import commonjs from 'rollup-plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
// eslint-disable-next-line no-process-env
const production = process.env.NODE_ENV === 'production';
const inputs = ['client4', 'websocket_client'];
// eslint-disable-next-line no-process-env
const buildFolder = process.env.OUTPUT_FOLDER || '.';
module.exports = inputs.map((input) => ({
input: `./src/client/${input}.ts`,
treeshake: Boolean(production),
output: [
{
format: 'cjs',
file: `${buildFolder}/mattermost.${input}.js`,
sourcemap: true,
exports: 'named',
}],
plugins: [
resolve(),
commonjs({
include: ['node_modules/**'],
}),
typescript({
tsconfigOverride: {
compilerOptions: {module: 'esnext'},
},
// eslint-disable-next-line global-require
typescript: require('ttypescript'),
rollupCommonJSResolveHack: true,
exclude: '**/__tests__/**',
clean: true,
}),
// only minify if in production
production && terser(),
],
}));
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// @flow
import keyMirror from 'utils/key_mirror';
export default keyMirror({
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// @flow
import keyMirror from 'utils/key_mirror';
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// @flow
import keyMirror from 'utils/key_mirror';
<