Skip to content

Commit

Permalink
core: handle npm package (#7)
Browse files Browse the repository at this point in the history
* v0.1.2-rc13

* core: functional build and publish

* fix: storybook

* fix: lint
  • Loading branch information
gsulloa authored Aug 4, 2020
1 parent 51aec86 commit ae3df56
Show file tree
Hide file tree
Showing 29 changed files with 336 additions and 486 deletions.
12 changes: 10 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* File Created: Thursday, 9th July 2020 8:35:11 am
* Author: Gabriel Ulloa ([email protected])
* -----
* Last Modified: Thursday, 9th July 2020 8:35:18 am
* Last Modified: Friday, 31st July 2020 3:21:00 pm
* Modified By: Gabriel Ulloa ([email protected])
* -----
* Copyright 2019 - 2020 Incrementa Ventures SpA. ALL RIGHTS RESERVED
Expand All @@ -14,5 +14,13 @@
*/

{
"presets": ["@babel/preset-env", "@babel/preset-react"]
"presets": ["@babel/preset-env", "@babel/preset-react"],
"ignore": ["**/__snapshots__", "**/*.d.ts", "**/*.test.*"],
"plugins": [
"@babel/plugin-transform-typescript",
"babel-plugin-typescript-to-proptypes",
"@babel/plugin-proposal-export-default-from",
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
}
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* File Created: Monday, 20th July 2020 2:46:10 pm
* Author: Gabriel Ulloa ([email protected])
* -----
* Last Modified: Monday, 20th July 2020 6:49:39 pm
* Last Modified: Tuesday, 4th August 2020 5:39:16 pm
* Modified By: Gabriel Ulloa ([email protected])
* -----
* Copyright 2019 - 2020 Incrementa Ventures SpA. ALL RIGHTS RESERVED
Expand Down Expand Up @@ -32,6 +32,7 @@ module.exports = {
rules: {
'react/prop-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
settings: {
react: {
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
48 changes: 7 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
@inventures/components

## Available Scripts
## Publish to NPM

In the project directory, you can run:
Build the following commands to build and publish

### `yarn start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
```bash
yarn build:lib
yarn publish:npm
```
28 changes: 25 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"name": "components-lib",
"name": "@inventures/react-lib",
"version": "0.1.0",
"private": true,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"private": false,
"publishConfig": {
"access": "public",
"tag": "prerelease"
},
"files": [
"./**/*"
],
"dependencies": {
"@material-ui/core": "^4.11.0",
"@testing-library/jest-dom": "^4.2.4",
Expand Down Expand Up @@ -29,8 +38,16 @@
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public",
"publish:gh": "yarn build-storybook && gh-pages -d storybook-static",
"prepublish:npm": "cp ./package.json ./dist && touch ./dist/.npmignore",
"publish:npm": "yarn publish dist; cp ./dist/package.json .",
"lint": "tsc --noEmit && eslint ./src/ --ext .js,.ts,.tsx",
"lint:fix": "tsc --noEmit && eslint ./src/ --ext .js,.ts,.tsx --fix"
"lint:fix": "tsc --noEmit && eslint ./src/ --ext .js,.ts,.tsx --fix",
"build:lib": "yarn clean && yarn build:babel && yarn build:types && node ./scripts/copyTS.js",
"build:babel": "yarn build:babel:cjs",
"build:babel:cjs": "BABEL_ENV=cjs babel --source-maps --extensions \".js,.ts,.tsx\" src --out-dir dist --presets=@babel/env",
"build:types": "tsc -p tsconfig.gen-dts.json",
"clean": "rimraf dist",
"develop": "yarn build:types && yarn build:babel:esm --skip-initial-build --watch --verbose"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -48,6 +65,8 @@
]
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/plugin-proposal-export-default-from": "^7.10.4",
"@material-ui/system": "^4.9.14",
"@storybook/addon-a11y": "^5.3.19",
"@storybook/addon-actions": "^5.3.19",
Expand All @@ -64,6 +83,9 @@
"@zeplin/cli": "^1.0.4",
"@zeplin/cli-connect-react-plugin": "^0.2.5",
"@zeplin/cli-connect-storybook-plugin": "^0.3.2",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-plugin-typescript-to-proptypes": "^1.4.0",
"concurrently": "^5.2.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
43 changes: 0 additions & 43 deletions public/index.html

This file was deleted.

Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

30 changes: 30 additions & 0 deletions scripts/copyTS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* File: copyTS.js
* Project: components-lib
* File Created: Friday, 31st July 2020 3:18:41 pm
* Author: Gabriel Ulloa ([email protected])
* -----
* Last Modified: Friday, 31st July 2020 3:18:53 pm
* Modified By: Gabriel Ulloa ([email protected])
* -----
* Copyright 2019 - 2020 Incrementa Ventures SpA. ALL RIGHTS RESERVED
* Terms and conditions defined in license.txt
* -----
* Inventures - www.inventures.cl
*/

/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const glob = require('glob');
const fse = require('fs-extra');
/* eslint-enable @typescript-eslint/no-var-requires */
const srcDir = path.join('./src');
const distDir = path.join('./dist');
const files = glob.sync('**/*.d.ts', {
cwd: srcDir,
});
files.forEach((file) => {
const from = path.join(srcDir, file);
const to = path.join(distDir, file);
fse.copySync(from, to);
});
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.test.tsx

This file was deleted.

89 changes: 0 additions & 89 deletions src/App.tsx

This file was deleted.

Loading

0 comments on commit ae3df56

Please sign in to comment.