Skip to content

Commit fbbc6ce

Browse files
authored
Merge pull request #39 from AckeeCZ/feat/monorepo
Feat/monorepo
2 parents f05ba04 + 165a947 commit fbbc6ce

36 files changed

+5728
-2522
lines changed

.eslintrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": ["@ackee/eslint-config"],
3+
"settings": {
4+
"import/resolver": {
5+
"node": {
6+
"paths": ["src"],
7+
"extensions": [".ts"]
8+
}
9+
}
10+
},
11+
"rules": {
12+
"no-unused-vars": "off",
13+
"@typescript-eslint/no-unused-vars": "warn"
14+
}
15+
}

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- 10
3+
- 12
44
install:
55
- yarn install --frozen-lockfile
66
before_script:

README.md

-118
Original file line numberDiff line numberDiff line change
@@ -33,121 +33,3 @@ export const api = create({
3333
baseURL: 'https://jsonplaceholder.typicode.com/',
3434
});
3535
```
36-
37-
## Usage Examples
38-
39-
```js
40-
import { api } from '...';
41-
42-
api.get('/todos').then(({ data, request, response }) => {
43-
// ...
44-
});
45-
46-
api.post('/todos', {
47-
title: 'Lorem ipsum',
48-
});
49-
50-
api.put(
51-
'/todos/:id',
52-
{
53-
title: 'Not lorem ipsum',
54-
},
55-
{
56-
uriParams: {
57-
id: '2',
58-
},
59-
},
60-
);
61-
62-
api.get('/todos/:id', {
63-
uriParams: {
64-
id: '2',
65-
},
66-
});
67-
68-
api.delete('/todos/:id', {
69-
uriParams: '2',
70-
});
71-
```
72-
73-
---
74-
75-
## <a name="api"></a>API
76-
77-
### `create([config])`
78-
79-
```js
80-
import * as Antonio from '@ackee/antonio';
81-
82-
const antonio = Antonio.create({
83-
baseURL: 'https://some-domain.com/api/',
84-
});
85-
```
86-
87-
### Instance methods
88-
89-
```
90-
antonio#get(url[, config])
91-
92-
antonio#delete(url[, config])
93-
94-
antonio#head(url[, config])
95-
96-
antonio#options(url[, config])
97-
98-
antonio#post(url[, data[, config]])
99-
100-
antonio#put(url[, data[, config]])
101-
102-
antonio#patch(url[, data[, config]])
103-
```
104-
105-
## Request config
106-
107-
These are the available config options for making requests. None of these is required.
108-
109-
```js
110-
{
111-
// `baseURL` will be prepended to `url` unless `url` is absolute.
112-
// It can be convenient to set `baseURL` for an instance of antonio to pass relative URLs
113-
// to methods of that instance.
114-
// Default: undefined
115-
baseUrl: 'https://jsonplaceholder.typicode.com/',
116-
117-
// Options: "json" | "blob" | "text" | "formData" | undefined
118-
// Default: "json"
119-
responseType: "json",
120-
121-
// Options: object | undefined
122-
// Default: undefined
123-
uriParams: {
124-
id: '2'
125-
},
126-
127-
// `headers` are custom headers to be sent
128-
// Must be a plain object or a Headers object
129-
// Default: new Headers()
130-
headers: new Headers({
131-
'X-Custom-Header': 1234
132-
}),
133-
134-
// `searchParams` are the URL parameters to be sent with the request
135-
// Must be a plain object or a URLSearchParams object
136-
// Default: undefined
137-
searchParams: new URLSearchParams({
138-
query: 'foo'
139-
}),
140-
141-
// Following props are pass to Request constructor,
142-
// see the official docs https://developer.mozilla.org/en-US/docs/Web/API/Request/Request
143-
mode: undefined,
144-
credentials: undefined,
145-
cache: undefined,
146-
redirect: undefined,
147-
referrer: undefined,
148-
referrerPolicy: undefined,
149-
integrity: undefined,
150-
keepalive: undefined,
151-
signal: undefined,
152-
}
153-
```

babel.config.js

+30-18
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
11
const path = require('path');
22

33
const config = {
4-
presets: ['@babel/preset-typescript'],
4+
presets: [
5+
'@babel/typescript',
6+
[
7+
'@babel/env',
8+
{
9+
useBuiltIns: 'usage',
10+
corejs: '3.11',
11+
loose: true,
12+
modules: false,
13+
bugfixes: true,
14+
browserslistEnv: 'production',
15+
},
16+
],
17+
],
518
plugins: [
6-
'@babel/proposal-class-properties',
19+
[
20+
'@babel/proposal-class-properties',
21+
{
22+
loose: true,
23+
},
24+
],
725
'@babel/proposal-object-rest-spread',
26+
'@babel/plugin-proposal-optional-chaining',
827
'@babel/plugin-proposal-nullish-coalescing-operator',
928
[
1029
'babel-plugin-custom-import-path-transform',
1130
{
1231
transformImportPath: path.resolve(__dirname, 'scripts/transformImportPath.js'),
1332
},
1433
],
34+
[
35+
'babel-plugin-transform-imports',
36+
{
37+
lodash: {
38+
transform: 'lodash/${member}',
39+
preventFullImport: true,
40+
},
41+
},
42+
],
1543
'@babel/plugin-transform-runtime',
1644
],
1745
ignore: ['**/__tests__/', '**/*.test.js'],
1846
};
1947

20-
if (process.env.BABEL_ENV === 'es') {
21-
config.presets.push([
22-
'@babel/modules',
23-
{
24-
loose: true,
25-
},
26-
]);
27-
} else {
28-
config.presets.push([
29-
'@babel/env',
30-
{
31-
loose: true,
32-
},
33-
]);
34-
}
35-
3648
module.exports = config;

lerna.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"packages": ["packages/@ackee/*"],
3+
"npmClient": "yarn",
4+
"useWorkspaces": true,
5+
"version": "4.0.0-alpha.5",
6+
"changelog": {
7+
"repo": "AckeeCZ/antonio",
8+
"labels": {
9+
"tag: new feature": ":sparkles: New Feature",
10+
"tag: breaking change": ":boom: Breaking Change",
11+
"tag: bug fix": ":bug: Bug Fix",
12+
"tag: enhancement": ":nail_care: Enhancement",
13+
"tag: documentation": ":pencil: Documentation",
14+
"tag: internal": ":house: Internal",
15+
"tag: underlying tools": ":hammer: Underlying Tools"
16+
},
17+
"cacheDir": ".changelog"
18+
}
19+
}

package.json

+58-46
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,97 @@
11
{
2-
"name": "@ackee/antonio",
3-
"version": "4.0.0-alpha.5",
4-
"description": "A HTTP client built on fetch with axios-like API.",
5-
"main": "es/index.js",
6-
"module": "es/index.js",
7-
"sideEffects": false,
2+
"private": true,
3+
"workspaces": [
4+
"packages/@ackee/*"
5+
],
86
"scripts": {
9-
"build:lib": "BABEL_ENV=lib babel src --out-dir lib --extensions \".ts\" --source-maps inline",
10-
"build:es": "BABEL_ENV=es babel src --out-dir es --extensions \".ts\" --source-maps inline",
11-
"build:js": "yarn build:es",
12-
"build:types": "tsc --project tsconfig.types.json --emitDeclarationOnly",
13-
"clean": "rm -rf lib es",
7+
"bootstrap": "lerna bootstrap --use-workspaces",
8+
"postinstall": "yarn bootstrap",
9+
"build:lib": "lerna exec --scope=@ackee/antonio-core -- babel src --out-dir lib --extensions \".ts\" --config-file=./babel.config.js --source-maps inline",
10+
"build:es": "lerna exec --scope=@ackee/antonio-core -- babel src --out-dir es --extensions \".ts\" --config-file=./babel.config.js --source-maps inline",
11+
"build:test": "babel ./packages/test/src --out-dir lib --extensions \".ts\" --config-file=./babel.config.js",
12+
"build:types": "lerna exec --scope=@ackee/antonio-core -- tsc --project ./tsconfig.types.json --emitDeclarationOnly",
13+
"build:js": "yarn build:es & yarn build:lib",
1414
"build": "yarn clean && yarn build:js && yarn build:types",
15-
"prepare": "yarn build",
16-
"lint": "tslint \"src/**/*.ts\"",
17-
"test": "BABEL_ENV=test jest",
18-
"push": "yarn build && yalc push",
15+
"clean": "lerna exec -- rm -rf lib es",
16+
"lint": "lerna exec --scope=@ackee/antonio-core -- eslint 'src/**/*.ts'",
1917
"type-check": "tsc --noEmit",
2018
"type-check:watch": "yarn type-check -- --watch",
21-
"start": "yarn build && onchange 'src/**/*.ts' -- yarn rebuild",
22-
"rebuild": "yarn clean && yarn build:es && yalc push",
19+
"test": "jest",
20+
"push": "yarn build && yalc push",
21+
"rebuild": "yarn build && yalc push",
22+
"start": "yarn build && onchange 'packages/@ackee/*/src/**/*.ts' -- yarn rebuild",
2323
"changelog": "gitmoji-changelog",
2424
"version": "yarn changelog && code --wait CHANGELOG.md && git add CHANGELOG.md",
2525
"release": "yarn version",
26-
"prettier": "prettier --config ./prettier.config.ts --write './src/**/*.ts'",
27-
"size": "package-size ./es --no-cache"
28-
},
29-
"author": "Jiří Čermák <[email protected]>",
30-
"license": "MIT",
31-
"repository": {
32-
"type": "git",
33-
"url": "https://github.com/AckeeCZ/antonio"
26+
"format": "prettier --config ./prettier.config.js --write 'packages/@ackee/*/src/**/*.ts' '*.{js,json}' --loglevel warn"
3427
},
3528
"devDependencies": {
29+
"@ackee/browserslist-config": "^1.0.1",
30+
"@ackee/eslint-config": "^3.0.0",
3631
"@babel/cli": "7.x",
3732
"@babel/core": "7.x",
38-
"@babel/plugin-proposal-class-properties": "^7.8.3",
39-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
33+
"@babel/eslint-parser": "^7.13.14",
34+
"@babel/plugin-proposal-class-properties": "7.x",
35+
"@babel/plugin-proposal-nullish-coalescing-operator": "7.x",
4036
"@babel/plugin-proposal-object-rest-spread": "7.x",
37+
"@babel/plugin-proposal-optional-chaining": "7.x",
4138
"@babel/plugin-transform-runtime": "7.x",
4239
"@babel/preset-env": "7.x",
43-
"@babel/preset-modules": "0.x",
44-
"@babel/preset-typescript": "^7.9.0",
45-
"@types/jest": "^25.2.1",
46-
"babel-eslint": "10.x",
40+
"@babel/preset-typescript": "7.x",
41+
"@types/jest": "25.x",
42+
"@types/node": "^14.14.37",
43+
"@typescript-eslint/eslint-plugin": "4.x",
44+
"@typescript-eslint/parser": "4.x",
45+
"babel-eslint": "^10.1.0",
4746
"babel-plugin-custom-import-path-transform": "1.x",
48-
"eslint": "6.x",
49-
"eslint-plugin-jest": "23.x",
47+
"babel-plugin-module-resolver": "4.x",
48+
"babel-plugin-transform-imports": "^2.0.0",
49+
"core-js": "^3.11.2",
50+
"eslint": "^7.5.0",
51+
"eslint-plugin-compat": "3.9.0",
52+
"eslint-plugin-flowtype": "^5.2.0",
53+
"eslint-plugin-import": "2.x",
54+
"eslint-plugin-jsx-a11y": "6.x",
55+
"eslint-plugin-react": "7.x",
56+
"eslint-plugin-react-hooks": "^4.0.8",
5057
"gitmoji-changelog": "2.x",
5158
"husky": "4.x",
5259
"jest": "26.x",
60+
"lerna": "4.x",
5361
"lint-staged": "^10.2.2",
54-
"onchange": "5.x",
62+
"onchange": "7.x",
5563
"package-size": "2.x",
5664
"prettier": "2.x",
5765
"prettier-config-ackee": "0.x",
5866
"redux-saga": "1.x",
5967
"reselect": "4.x",
6068
"ts-jest": "25.x",
61-
"tslint-config-ackee": "^0.3.0",
62-
"tslint-config-prettier": "1.x",
63-
"typescript": "3.x"
69+
"typescript": "4.x"
6470
},
6571
"dependencies": {
66-
"@babel/runtime": "7.x"
72+
"@babel/runtime": "7.x",
73+
"loglevel": "1.x"
6774
},
6875
"husky": {
6976
"hooks": {
70-
"pre-commit": "lint-staged",
71-
"pre-push": "yarn lint"
77+
"pre-commit": "lint-staged"
7278
}
7379
},
7480
"lint-staged": {
75-
"src/*.{ts,json,scss,less,css,md}": [
76-
"prettier --config ./prettier.config.js --write"
81+
"*.{ts,json,md}": [
82+
"yarn format"
7783
],
78-
"src/*.{ts}": [
79-
"yarn lint"
84+
"*.{ts}": [
85+
"yarn lint && yarn type-check"
8086
]
8187
},
82-
"publishConfig": {
83-
"access": "public"
88+
"browserslist": [
89+
"extends @ackee/browserslist-config"
90+
],
91+
"license": "MIT",
92+
"author": "Jiří Čermák <[email protected]>",
93+
"repository": {
94+
"type": "git",
95+
"url": "git+https://github.com/AckeeCZ/antonio.git"
8496
}
8597
}

0 commit comments

Comments
 (0)