|
1 | 1 | # Development |
2 | 2 |
|
| 3 | +----- |
3 | 4 |
|
4 | | -**Build** |
| 5 | + |
| 6 | + |
| 7 | +### Module Format - FESM |
| 8 | + |
| 9 | +Each library comes as an tree-shakeable and AOT enabled flat ES2015 Module. |
| 10 | +See [YouTube Packaging Angular - Jason Aden - ng-conf 2017]()https://www.youtube.com/watch?v=unICbsPGFIA) for in depth explanation. |
5 | 11 |
|
6 | | -See: https://github.com/cloukit/library-build-chain |
| 12 | +----- |
7 | 13 |
|
8 | 14 | |
9 | 15 |
|
10 | | -## Howto Link Lib during Development |
| 16 | +### Metadata for each Library |
| 17 | + |
| 18 | +The library itself has `package.json` containing: |
| 19 | + |
| 20 | +```json |
| 21 | +{ |
| 22 | + "name": "@cloukit/multi-select", |
| 23 | + "moduleId": "multi-select", |
| 24 | + "version": "1.1.0", |
| 25 | + "dependencies": { |
| 26 | + |
| 27 | + }, |
| 28 | + "devDependencies": { |
| 29 | + "@cloukit/library-build-chain": "1.0.0" |
| 30 | + }, |
| 31 | + "peerDependencies": { |
| 32 | + "@angular/core": "^4.0.1", |
| 33 | + "rxjs": "^5.3.0", |
| 34 | + "zone.js": "^0.8.5" |
| 35 | + } |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +which will then be transformed into `./dist/package.json`: |
| 40 | + |
| 41 | +```json |
| 42 | +{ |
| 43 | + "name": "@cloukit/multi-select", |
| 44 | + "author": "codeclou.io", |
| 45 | + "version": "1.1.0", |
| 46 | + "license": "MIT", |
| 47 | + "module": "cloukit-multi-select.es5.js", |
| 48 | + "es2015": "cloukit-multi-select.js", |
| 49 | + "typings": "cloukit-multi-select.d.ts", |
| 50 | + "dependencies": { |
| 51 | + |
| 52 | + }, |
| 53 | + "devDependencies": { |
| 54 | + "@cloukit/library-build-chain": "1.0.0" |
| 55 | + }, |
| 56 | + "peerDependencies": { |
| 57 | + "@angular/core": "^4.0.1", |
| 58 | + "rxjs": "^5.3.0", |
| 59 | + "zone.js": "^0.8.5" |
| 60 | + } |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +----- |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +### Building a Library and Publishing to npmjs.com |
| 69 | + |
| 70 | +Goto the component dir containing `package.json` and execute: |
| 71 | + |
| 72 | +```bash |
| 73 | +yarn |
| 74 | +yarn build |
| 75 | +``` |
| 76 | + |
| 77 | +Now there will be a `./dist/` directory containing everything that can now be published to npmjs.com |
| 78 | + |
| 79 | +:bangbang: Publishing is done by `jenkins.sh` via Jenkins on TAG-Job run. |
| 80 | + |
| 81 | +Therefore tag you library like so |
| 82 | + |
| 83 | +```bash |
| 84 | +git tag -a 1.0.2 -m "1.0.2" |
| 85 | +git push origin 1.0.2 |
| 86 | +``` |
| 87 | + |
| 88 | +----- |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +### Setup for a Library |
| 93 | + |
| 94 | + * (1) Create `package.json` |
| 95 | + * (2) Copy `.gitignore` from `@cloukit/toggle` |
| 96 | + * see example: https://github.com/cloukit/toggle/blob/master/.gitignore |
| 97 | + * (3) Main file with exports is expected to be `../src/index.ts` |
| 98 | + * see example: https://github.com/cloukit/toggle |
| 99 | + * (4) place `jenkins.sh` at root |
| 100 | + * see example: https://github.com/cloukit/toggle/blob/master/jenkins.sh |
| 101 | + * (5) add Webhook to codeclou.io jenkins |
| 102 | + * (6) Create Jenkins Job for project with convention "cloukit---COMPONENTNAME" |
| 103 | + |
| 104 | +----- |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +### Howto Link Lib during Development |
11 | 110 |
|
12 | 111 | (1) Go to component project and type to build the component |
13 | 112 |
|
14 | 113 | ``` |
15 | | -git clone https://github.com/cloukit/ng-library-build.git library-build-chain |
16 | | -cd library-build-chain |
17 | | -npm install |
18 | | -npm run build |
19 | | -cd ../ |
20 | | -# symlink node_modules |
21 | | -ln -s build/node_modules |
| 114 | +cd toggle |
| 115 | +yarn |
22 | 116 | ``` |
23 | 117 |
|
24 | 118 | (2) Now `dist/` folder appeared: |
25 | 119 |
|
26 | 120 | ``` |
27 | 121 | cd dist/ |
28 | | -npm link |
| 122 | +yarn link |
29 | 123 | ``` |
30 | 124 |
|
31 | | -(3) Link into project |
| 125 | +(3) Link into project |
32 | 126 |
|
33 | | -see: https://docs.npmjs.com/cli/link |
34 | 127 |
|
35 | 128 | ``` |
36 | | -cd my-test-project |
37 | | -npm link @cloukit/foo # with foo = component name |
| 129 | +cd my-other-component |
| 130 | +yarn link @cloukit/toggle |
38 | 131 | ``` |
39 | 132 |
|
40 | 133 | (4) Now you should be able to do in your testproject |
41 | 134 |
|
42 | 135 | ```typescript |
43 | | -import { FooModule } from '@cloukit/foo'; |
| 136 | +import { FooModule } from '@cloukit/toggle'; |
44 | 137 | ``` |
45 | 138 |
|
| 139 | +----- |
| 140 | + |
46 | 141 | |
47 | 142 |
|
48 | | -## Jenkins Job Setup |
| 143 | +### Jenkins Job Setup |
49 | 144 |
|
50 | 145 | JobTrigger via Webhook and ANSI Colors plugin active: |
51 | 146 |
|
52 | 147 | ```bash |
53 | 148 | #!/bin/bash |
54 | | - |
| 149 | + |
55 | 150 | set -e |
56 | | - |
| 151 | + |
57 | 152 | # ############################################################################# # |
58 | 153 | # And: https://github.com/codeclou/jenkins-github-webhook-build-trigger-plugin # |
59 | 154 | # ############################################################################# # |
|
0 commit comments