Skip to content

Commit a7985ba

Browse files
committed
feat: first commit
BREAKING CHANGE: first release
0 parents  commit a7985ba

File tree

16 files changed

+8828
-0
lines changed

16 files changed

+8828
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['airbnb', 'airbnb/base', 'prettier', 'prettier/react'],
4+
parser: '@babel/eslint-parser',
5+
env: {
6+
browser: true,
7+
jest: true,
8+
},
9+
parserOptions: {
10+
ecmaVersion: 2018,
11+
sourceType: 'module',
12+
},
13+
plugins: ['react-hooks', 'emotion'],
14+
rules: {
15+
'import/order': [
16+
'error',
17+
{
18+
groups: [
19+
['builtin', 'external'],
20+
'internal',
21+
'parent',
22+
'sibling',
23+
'index',
24+
],
25+
alphabetize: {
26+
order: 'asc',
27+
caseInsensitive: false,
28+
},
29+
'newlines-between': 'never',
30+
},
31+
],
32+
33+
'react/prop-types': 'off',
34+
'react/jsx-filename-extension': ['error', { extensions: ['.js'] }],
35+
'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }],
36+
},
37+
settings: {
38+
'import/resolver': {
39+
node: {
40+
moduleDirectory: ['node_modules', 'src'],
41+
},
42+
},
43+
},
44+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.eslintcache
3+
build
4+
coverage
5+
*.log

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# From .gitignore
2+
node_modules/
3+
build/
4+
5+
# Specific to prettier
6+
package.json

LICENSE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
These packages are unlicensed, and are only usable internally at Scaleway

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# scaleway-lib
2+
3+
scaleway-lib is a set of NPM packgages used at Scaleway. These libraries are available on our [private NPM registry](https://***REMOVED***).
4+
5+
---
6+
7+
## Development
8+
9+
### Locally
10+
11+
```bash
12+
$ git clone git@***REMOVED***/scaleway-lib.git
13+
$ cd scaleway-lib
14+
$ yarn
15+
$ # ... do your changes ...
16+
$ yarn run lint
17+
$ yarn run test
18+
```
19+
20+
### Link against another project
21+
22+
```bash
23+
$ cd packages/example_package
24+
$ yarn link
25+
$ cd - && yarn run build # rebuild the package
26+
$ cd ../fo-something
27+
$ yarn link @scaleway/example_package
28+
```
29+
30+
#### Linting
31+
32+
```bash
33+
$ yarn run lint
34+
$ yarn run lint:fix
35+
```
36+
37+
#### Unit Test
38+
39+
```bash
40+
$ yarn run test # Will run all tests
41+
$ yarn run test --updateSnapshot # Will update all snapshots
42+
$ yarn run test:watch # Will watch tests and only rerun the one who are modified
43+
$ yarn run test:coverage # Will generate a coverage report
44+
```
45+
46+
## Lerna
47+
48+
This project is managed with [Lerna](https://lerna.js.org). Lerna is a tool to manage multiple NPM packages inside the same repository.
49+
50+
Lerna also allows us to use [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to manage our dependencies. This implies a few things:
51+
52+
- devDependencies should be included in top package.json
53+
- There should be no `node_modules` or `yarn.lock` in sub-packages
54+
- There is a special syntax to manage sub-packages dependencies:
55+
56+
```bash
57+
$ yarn add -W -D new_dependency # Add a new devDependency to root project
58+
$ yarn workspace @scaleway/package_name add new_dependency
59+
$ yarn workspace @scaleway/package_name remove old_dependency
60+
```
61+
62+
### Notes
63+
64+
### On build targets
65+
66+
We target by default Node@14 but you can add a browser output by adding a `browser` (you can find the spec [here](https://github.com/defunctzombie/package-browser-field-spec)) target to your `package.json`.
67+
68+
```js
69+
"browser": {
70+
"build/index.js": "build/index.browser.js",
71+
"build/module.js": "build/module.browser.js"
72+
}
73+
```
74+
75+
The browserlist we are currently using is available in the [rollup.config.js](./rollup.config.js)
76+
77+
Bear in mind that we do not currently support different entrypoint per target as we don't have the use case
78+
{: .alert .alert-warning}
79+
80+
#### On build outputs
81+
82+
We output both UMD and ESM files for each target.
83+
84+
##### On commits
85+
86+
We enforce the [conventionnal commits](https://www.conventionalcommits.org) convention in order to infer package bump versions and generate changelog.
87+
88+
##### On versioning
89+
90+
We follow the [semver](http://semver.org/) semantic.
91+
92+
### Rules
93+
94+
- Follow linter rules.
95+
- Ensure to have a tested code before merging.

babel.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@babel/preset-env"],
3+
"plugins": ["@babel/plugin-transform-runtime"]
4+
}

lerna.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"packages": [
3+
"packages/*"
4+
],
5+
"useWorkspaces": true,
6+
"npmClient": "yarn",
7+
"version": "independent",
8+
"command": {
9+
"publish": {
10+
"conventionalCommits": true
11+
},
12+
"version": {
13+
"message": "chore(release): publish [skip-ci]"
14+
}
15+
}
16+
}

package.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "root",
3+
"private": true,
4+
"workspaces": [
5+
"packages/*"
6+
],
7+
"devDependencies": {
8+
"@babel/core": "^7.12.3",
9+
"@babel/plugin-transform-runtime": "^7.12.1",
10+
"@babel/preset-env": "^7.12.1",
11+
"@commitlint/cli": "^11.0.0",
12+
"@commitlint/config-conventional": "^11.0.0",
13+
"@rollup/plugin-babel": "^5.2.1",
14+
"@rollup/plugin-commonjs": "^15.1.0",
15+
"@rollup/plugin-node-resolve": "^9.0.0",
16+
"builtin-modules": "^3.1.0",
17+
"cross-env": "^7.0.2",
18+
"husky": "^4.3.0",
19+
"jest": "^26.6.0",
20+
"lerna": "3.22.1",
21+
"lint-staged": "^10.4.2",
22+
"prettier": "^2.1.2",
23+
"read-pkg": "^5.2.0",
24+
"rollup": "^2.32.1",
25+
"rollup-plugin-analyzer": "^3.3.0"
26+
},
27+
"scripts": {
28+
"build": "lerna exec --ignore @scaleway/eslint-* -- rollup -c ../../rollup.config.js",
29+
"build:profile": "cross-env PROFILE=true yarn run build",
30+
"test": "jest",
31+
"test:watch": "jest --watch",
32+
"test:coverage": "jest --coverage"
33+
},
34+
"commitlint": {
35+
"extends": [
36+
"@commitlint/config-conventional"
37+
]
38+
},
39+
"husky": {
40+
"hooks": {
41+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
42+
"pre-commit": "lint-staged",
43+
"pre-push": "lint-staged"
44+
}
45+
},
46+
"lint-staged": {
47+
"*.js": [
48+
"prettier --write",
49+
"eslint --fix"
50+
],
51+
"*.svg": [
52+
"yarn optimize-svg"
53+
]
54+
},
55+
"config": {
56+
"commitizen": {
57+
"path": "./node_modules/cz-conventional-changelog"
58+
}
59+
},
60+
"jest": {
61+
"collectCoverageFrom": [
62+
"src/**/*.{js,jsx}"
63+
]
64+
}
65+
}

packages/example_package/.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/__tests__/**
2+
src
3+
!.npmignore

0 commit comments

Comments
 (0)