Skip to content

Commit

Permalink
Improvement: clean up old config, correctly name scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jvhoven committed Sep 17, 2019
1 parent 911401f commit 653791d
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 476 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ logs
results
tmp

# Build
public/css/main.css

# Coverage reports
coverage
test-results.json
Expand All @@ -29,6 +26,7 @@ node_modules/
# Editors
.idea
*.iml
.vscode

# OS metadata
.DS_Store
Expand All @@ -40,9 +38,6 @@ Thumbs.db
# Build artifacts
dist/

# Verdaccio
.versions.json

# Jekyll
*.gem
.bundle
Expand Down
16 changes: 8 additions & 8 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"dist/index.js": {
"bundled": 91853,
"minified": 44435,
"gzipped": 10893
"bundled": 91509,
"minified": 44396,
"gzipped": 10880
},
"dist/index.es.js": {
"bundled": 87463,
"minified": 40216,
"gzipped": 10589,
"bundled": 87119,
"minified": 40177,
"gzipped": 10578,
"treeshaked": {
"rollup": {
"code": 30069,
"code": 30042,
"import_statements": 1052
},
"webpack": {
"code": 33475
"code": 33448
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js: '12'
node_js: '10.16.3'
sudo: false
before_script:
- export TZ=Europe/Amsterdam
Expand Down
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

57 changes: 13 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
</p>

<p align="center">
<a href="https://lerna.js.org/">
<img alt="Lerna" src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg" />
</a>
<a href="https://travis-ci.org/42BV/ui/">
<img alt="Build status" src="https://travis-ci.org/42BV/ui.svg?branch=master" />
</a>
Expand Down Expand Up @@ -39,36 +36,18 @@ npm i @42.nl/ui --save

## Contributing

This repository makes heavy use of [`Yarn` workspaces](https://yarnpkg.com/lang/en/docs/workspaces/)
functionality, therefore it is mandatory to have `Yarn` installed. If you
do not have `Yarn` installed, consult the [installation guide](https://yarnpkg.com/en/docs/install#mac-stable).

### Setup

1. Ensure you have Node.js 10.13+ and Yarn installed.
2. Git clone the repository.
3. From the root of the repository, run `yarn` to install the dependencies required for development. This should automatically build and link the individual packages.

### Development

This project uses [lerna](https://lerna.js.org/) to manage independently
versioned packages and enable code sharing. This enables us to run commands
on repository level through `lerna run [script]` or on package level
through `yarn [script]`.

#### Scenario: new component

1. Copy an existing package (e.g. `cp -r packages/Avatar packages/Component`) or use [@lerna/create](https://github.com/lerna/lerna/tree/master/commands/create#readme).
2. Update `package.json` to reflect the new component.
3. Ensure the package works by writing a test and verify by running `yarn test`.
4. (Optional) if you're not using an [ESLint plugin](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) for your editor, run `yarn lint`.
3. From the root of the repository, run `yarn` to install the dependencies required for development.

### Testing

First follow the build instructions above. Then to run both the linters and tests, use:

```bash
yarn test
yarn test-all
```

Or to run them seperately, use:
Expand All @@ -78,39 +57,29 @@ yarn lint
```

```bash
yarn test-only
yarn test
```

### Publishing

#### Development

To prevent multiple prelease publishes for a single feature, we recommend using
[https://verdaccio.org/](Verdaccio). Verdaccio enables you to spin up
a local NPM registry. This allows us to publish multiple versions for
testing purposes without polluting the version scope.

> We recommend the Docker approach instead of locally installing
Verdaccio, if you do not want to use Docker, refer to the Verdaccio
documentation.
To prevent multiple prelease publishes for a single feature, we recommend using
[https://verdaccio.org/](Verdaccio). Verdaccio enables you to spin up
a local NPM registry which in turn allows us to publish multiple versions for testing purposes without polluting the version in NPM.

To publish to the Verdaccio registry run `yarn dev-publish` this
will spin up Verdaccio and publish all packages as a version
based on the current date. To get out the version look for a line
in the output that looks like this:
> We recommend the Docker approach instead of locally installing
> Verdaccio, if you do not want to use Docker, refer to the Verdaccio
> documentation.
`+ @42.nl/[email protected]`.

In this case the version would be `2019.7.2182427`.
To publish to the Verdaccio registry run `yarn dev:publish` this
will spin up Verdaccio and publish.

You can view Verdaccio here: `http://localhost:4873/` it should after
a successful dev publish show the packages here.

Next in the `package.json` of the project you want to test the new
version in change the `@42.nl/ui` version to the version that was
created.

Then install with the registry Verdaccio registry via:
To verify the release, install `@42.nl/ui` from the Verdaccio registry in a project of your choice
by running:

`npm install --registry http://localhost:4873`.

Expand Down
24 changes: 0 additions & 24 deletions greenkeeper.json

This file was deleted.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
],
"scripts": {
"clean": "rm -rf dist",
"start": "STORYBOOK_MODE=isolated STORYBOOK_COMPONENT=$(pwd) start-storybook -c ./storybook",
"test": "jest",
"test-all": "yarn lint && yarn test --coverage",
"start": "yarn storybook",
"test": "jest --watch",
"test-all": "yarn lint && jest --coverage",
"build": "yarn clean && rollup -c",
"lint": "eslint src --ext js,jsx,ts,tsx --max-warnings=0",
"copy:scss": "rsync -a src/*.scss lib/scss/",
"deploy-storybook": "storybook-to-ghpages",
"build-storybook": "build-storybook -c storybook -o docs/storybook",
"storybook:deploy": "storybook-to-ghpages",
"storybook:build": "build-storybook -c storybook -o docs/storybook",
"storybook": "start-storybook -c storybook",
"docs": "jekyll serve --source docs",
"dev-publish": "yarn clean && yarn build && ENV=dev ./scripts/publish.sh",
"prepublishOnly": "yarn test-all && yarn build"
"dev:publish": "./scripts/dev-publish.sh",
"prepublishOnly": "yarn clean && yarn test-all && yarn build"
},
"dependencies": {
"@42.nl/jarb-final-form": "1.0.0",
Expand Down Expand Up @@ -54,10 +53,10 @@
"@babel/core": "7.5.5",
"@babel/plugin-transform-modules-commonjs": "7.5.0",
"@storybook/addon-actions": "5.1.11",
"@storybook/addon-docs": "next",
"@storybook/addon-docs": "5.2.0",
"@storybook/preset-scss": "1.0.2",
"@storybook/preset-typescript": "1.1.0",
"@storybook/react": "next",
"@storybook/react": "5.2.0",
"@storybook/storybook-deployer": "2.8.1",
"@testing-library/react-hooks": "1.1.0",
"@types/classnames": "2.2.9",
Expand Down
52 changes: 52 additions & 0 deletions scripts/dev-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh
read -p "Have you updated the package version (y/n)? " answer
case ${answer:0:1} in
y | Y) ;;

*)
echo "Please do so according to https://semver.org/"
exit 1
;;
esac

# Check if docker exists
if [[ "$(docker -v 2>/dev/null)" == "" ]]; then
printf -- 'You dont seem to have Docker installed.\n'
printf -- 'Get it: https://www.docker.com/community-edition\n'
printf -- 'Exiting with code 127...\n'
exit 127
fi

printf -- 'Docker found.\n'

if [ "$(docker ps -q -f name=verdaccio)" ]; then
printf -- '\033[37m Verdaccio already running, pulling down... \033[0m\n'
docker stop verdaccio >/dev/null 2>&1
printf -- '\033[32m SUCCESS: Pulled down Verdaccio instance \033[0m\n'
fi

printf -- '\033[37m Starting verdaccio... \033[0m\n'
docker run -d -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio:4.2.1 >/dev/null 2>&1
docker start verdaccio 2>&1
until $(curl --output /dev/null --silent --head --fail http://localhost:4873); do
printf '.'
sleep 1
done
printf -- '\033[32m SUCCESS: Verdaccio is now running \033[0m\n'

printf -- '\033[37m Creating verdaccio user... \033[0m\n'
/usr/bin/expect <<EOD
spawn npm adduser --registry http://localhost:4873
expect {
"Username:" {send "test\r"; exp_continue}
"Password:" {send "test\r"; exp_continue}
"Email: (this IS public)" {send "test@[email protected]\r"; exp_continue}
}
EOD

printf -- '\033[32m SUCCESS: verdaccio user created \033[0m\n'

# Publish packages
printf -- '\033[37m Attempting to publish to verdaccio... \033[0m\n'
npm publish --registry http://localhost:4873
printf -- '\033[32m SUCCESS: Succesfully published packages \033[0m\n'
40 changes: 0 additions & 40 deletions scripts/prebuild.js

This file was deleted.

68 changes: 0 additions & 68 deletions scripts/publish.sh

This file was deleted.

Loading

0 comments on commit 653791d

Please sign in to comment.