|
1 | 1 | <h1 align="center"> Components Graph </h1> |
2 | 2 | <br> |
3 | 3 | <p align="center"> |
4 | | - <img src="https://committed.software/Logo.svg" width="128px" alt="Project Logo"/> |
| 4 | + <img src="https://committed.io/Logo.svg" width="128px" alt="Project Logo"/> |
5 | 5 | </p> |
6 | 6 | <p align="center"> |
7 | 7 | Committed Software Graph Component |
8 | 8 | </p> |
9 | 9 |
|
10 | | -[](https://committed.io) |
| 10 | +[](https://committed.io) |
11 | 11 |  |
12 | 12 | [](https://sonarcloud.io/dashboard?id=commitd_components-graph) |
13 | 13 | [](https://sonarcloud.io/dashboard?id=commitd_components-graph) |
14 | 14 |  |
15 | 15 | [](https://github.com/semantic-release/semantic-release) |
16 | 16 |
|
17 | | -A graph visualisation to be used in Committed products. It supports custom decoration, different layouts and user interactions. |
| 17 | +A graph visualisation. It supports custom decoration, different layouts and user interactions. |
18 | 18 |
|
19 | 19 | ## Commands |
20 | 20 |
|
21 | | -TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`. |
| 21 | +Install dependencies with |
22 | 22 |
|
23 | | -The recommended workflow is to run TSDX in one terminal: |
| 23 | +```bash |
| 24 | +npm install |
| 25 | +``` |
| 26 | + |
| 27 | +Build the modules |
24 | 28 |
|
25 | 29 | ```bash |
26 | | -yarn start |
| 30 | +npm run build |
27 | 31 | ``` |
28 | 32 |
|
29 | | -This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`. |
| 33 | +This builds to the relevant `/dist` folders. |
30 | 34 |
|
31 | | -Then run either Storybook or the example playground: |
| 35 | +### Modules |
| 36 | + |
| 37 | +The project is published as `@committed/components-graph` but is further separated into modules so the non-ui code can be used in the backend. |
| 38 | + |
| 39 | +- `@committed/graph` - contains the graph models, types and API |
| 40 | +- `@committed/component-graph-react` - contains the react specific UI components |
32 | 41 |
|
33 | 42 | ### Storybook |
34 | 43 |
|
35 | | -Run inside another terminal: |
| 44 | +To view a storybook of the components, run: |
36 | 45 |
|
37 | 46 | ```bash |
38 | | -yarn storybook |
| 47 | +npm run storybook |
39 | 48 | ``` |
40 | 49 |
|
41 | | -This loads the stories from `./stories`. |
42 | | - |
43 | | -> NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper. |
44 | | -
|
45 | 50 | ### Example |
46 | 51 |
|
47 | | -Then run the example inside another: |
| 52 | +There is also an example project that uses the graph: |
48 | 53 |
|
49 | 54 | ```bash |
50 | 55 | cd example |
51 | | -yarn install |
52 | | -yarn start |
| 56 | +npm install |
| 57 | +npm run start |
53 | 58 | ``` |
54 | 59 |
|
55 | | -The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases). |
56 | | - |
57 | | -To do a one-off build, use `yarn build`. |
58 | | - |
59 | | -To run tests, use `yarn test`. |
| 60 | +The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases). |
60 | 61 |
|
61 | 62 | ## Configuration |
62 | 63 |
|
63 | 64 | Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly. |
64 | 65 |
|
65 | 66 | ### Jest |
66 | 67 |
|
67 | | -Jest tests are set up to run with `yarn test` and `testing-library`. |
68 | | - |
69 | | -### Bundle analysis |
70 | | - |
71 | | -Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `yarn size` and visulize it with `yarn analyze`. |
72 | | - |
73 | | -#### Setup Files |
74 | | - |
75 | | -This is the folder structure we set up for you: |
76 | | - |
77 | | -```txt |
78 | | -/example |
79 | | - index.html |
80 | | - index.tsx # test your component here in a demo app |
81 | | - package.json |
82 | | - tsconfig.json |
83 | | -/src |
84 | | - index.tsx # EDIT THIS |
85 | | - /components |
86 | | - /hooks |
87 | | -/.storybook |
88 | | - main.js |
89 | | - preview.js |
90 | | -.gitignore |
91 | | -package.json |
92 | | -README.md # EDIT THIS |
93 | | -tsconfig.json |
94 | | -``` |
95 | | - |
96 | | -### Generators |
97 | | - |
98 | | -There are generators for components and hook these can be used to create the boilerplate files with: |
99 | | - |
100 | | -```bash |
101 | | -yarn generate |
102 | | -``` |
| 68 | +Jest tests are set up to run with `npm run test` and `testing-library`. |
103 | 69 |
|
104 | 70 | #### React Testing Library |
105 | 71 |
|
106 | 72 | Import `test/setup` in your test files to use `react-testing-library`. |
107 | 73 |
|
108 | | -### Rollup |
109 | | - |
110 | | -TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details. |
111 | | - |
112 | | -### TypeScript |
113 | | - |
114 | | -`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs. |
115 | | - |
116 | | -## Continuous Integration |
117 | | - |
118 | | -### GitHub Actions |
119 | | - |
120 | | -Two actions are added by default: |
121 | | - |
122 | | -- `build` which installs deps w/ cache, lints, tests, and builds. |
123 | | -- `release` Triggered on release with (commented) options to publish and deploy storybook |
124 | | -- `size` which comments cost comparison of your library on every pull request using [size-limit](https://github.com/ai/size-limit) |
125 | | - |
126 | | -You need to configure sonarcloud separately to analyse the project. |
127 | | - |
128 | | -- Allow access on [github](https://github.com/organizations/commitd/settings/installations/) |
129 | | -- Add the project on [sonarcloud](https://sonarcloud.io/projects/create) |
130 | | -- Turn off the automated analysis in the sonorcloud settings. |
131 | | - |
132 | | -## Optimizations |
133 | | - |
134 | | -Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations: |
135 | | - |
136 | | -```js |
137 | | -// ./types/index.d.ts |
138 | | -declare var __DEV__: boolean |
139 | | - |
140 | | -// inside your code... |
141 | | -if (__DEV__) { |
142 | | - console.log('foo') |
143 | | -} |
144 | | -``` |
145 | | - |
146 | | -You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions. |
147 | | - |
148 | | -## Module Formats |
149 | | - |
150 | | -CJS, ESModules, and UMD module formats are supported. |
151 | | - |
152 | | -The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found. |
153 | | - |
154 | | -## Deploying the Example Playground |
155 | | - |
156 | | -The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`): |
157 | | - |
158 | | -```bash |
159 | | -cd example # if not already in the example folder |
160 | | -npm run build # builds to dist |
161 | | -netlify deploy # deploy the dist folder |
162 | | -``` |
163 | | - |
164 | | -Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify: |
165 | | - |
166 | | -```bash |
167 | | -netlify init |
168 | | -# build command: yarn build && cd example && yarn && yarn build |
169 | | -# directory to deploy: example/dist |
170 | | -# pick yes for netlify.toml |
171 | | -``` |
172 | | - |
173 | 74 | ## Named Exports |
174 | 75 |
|
175 | 76 | Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library. |
176 | 77 |
|
177 | | -## Including Styles |
178 | | - |
179 | | -There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like. |
180 | | - |
181 | | -For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader. |
182 | | - |
183 | 78 | ## Publishing to NPM |
184 | 79 |
|
185 | | -See `.github/workflows/release.yml`. |
| 80 | +Publish is handled by `semantic-release` use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). Use `npm run commit` for helper. |
0 commit comments