|
| 1 | +# Library Maintenance |
| 2 | + |
| 3 | +This document is intended for anyone who wishes to participate in developing |
| 4 | +changes or features to the client codebase. |
| 5 | + |
| 6 | +If you're looking for information on how to use the client library, see the |
| 7 | +[User Guide](./README.md). |
| 8 | + |
| 9 | +### Publish a new version |
| 10 | + |
| 11 | +To publish a new version of the library into npm, you must first configure |
| 12 | +your local npm to allow publishing new versions to |
| 13 | +[https://www.npmjs.com/package/swm-client-lib](https://www.npmjs.com/package/swm-client-lib) |
| 14 | + |
| 15 | +When ready to release a new version, please update the version number in both |
| 16 | +`package.json` and in the module itself, `swm.js`. |
| 17 | + |
| 18 | +#### `package.json` |
| 19 | + |
| 20 | +```json |
| 21 | +{ |
| 22 | + "name": "swm-client-lib", |
| 23 | + "version": "0.3.5", |
| 24 | + UPDATE THIS ^^^^^ |
| 25 | + "description": "A SMART Web Messaging Client Library", |
| 26 | + "main": "swm.js", |
| 27 | + "exports": { |
| 28 | + ".": { |
| 29 | + "browser": { |
| 30 | + "default": "./swm.js" |
| 31 | + } |
| 32 | + } |
| 33 | + }, |
| 34 | +... |
| 35 | +``` |
| 36 | + |
| 37 | +#### `swm.js` |
| 38 | + |
| 39 | +```js |
| 40 | +/** |
| 41 | + * Returns client capabilities. |
| 42 | + * |
| 43 | + * @returns A collection of client capabilities. |
| 44 | + */ |
| 45 | +export function getCapabilities() { |
| 46 | + return { |
| 47 | + version: '0.3.5', // UPDATED WITH EACH PUBLISHED RELEASE |
| 48 | + igVersion: 'STU1', |
| 49 | + supportedMessageTypes: [ |
| 50 | + 'status.handshake', |
| 51 | + 'ui.done', |
| 52 | + 'ui.launchActivity', |
| 53 | + 'scratchpad.create', |
| 54 | + 'scratchpad.read', |
| 55 | + 'scratchpad.update', |
| 56 | + 'scratchpad.delete', |
| 57 | + ], |
| 58 | + }; |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +Publish the new version by running `npm run publish` - *not* - `npm publish`. |
| 63 | +These commands do different things, and there is a *prepublish* script that |
| 64 | +runs when you publish it the expected way. |
| 65 | + |
| 66 | +Here's an example command line session showing the publication and release of `v0.3.5`. |
| 67 | + |
| 68 | +```sh |
| 69 | +can@msft-mbp ~/code/swm-dd-demo/lib (main) $ npm run publish |
| 70 | + |
| 71 | + |
| 72 | +> bash prepublish.sh |
| 73 | + |
| 74 | +Ensuring a clean build... |
| 75 | + |
| 76 | + |
| 77 | +> prettier --check swm.js |
| 78 | + |
| 79 | +Checking formatting... |
| 80 | +All matched files use Prettier code style! |
| 81 | +Ensuring a fresh build... |
| 82 | + |
| 83 | + |
| 84 | +> snowpack build |
| 85 | + |
| 86 | +[24:12:10] [snowpack] ! building files... |
| 87 | +[24:12:10] [snowpack] ✔ files built. [0.02s] |
| 88 | +[24:12:10] [snowpack] ! building dependencies... |
| 89 | +[24:12:10] [snowpack] ✔ dependencies built. [0.19s] |
| 90 | +[24:12:10] [snowpack] ! writing to disk... |
| 91 | +[24:12:10] [snowpack] ✔ write complete. [0.01s] |
| 92 | +[24:12:10] [snowpack] ▶ Build Complete! |
| 93 | +OK to publish new version: 0.3.5 |
| 94 | +Running 'npm publish' from the build directory! |
| 95 | +npm notice |
| 96 | + |
| 97 | +npm notice === Tarball Contents === |
| 98 | +npm notice 776B README.md |
| 99 | +npm notice 46B meta/pkg/import-map.json |
| 100 | +npm notice 3.1kB meta/pkg/uuid.js |
| 101 | +npm notice 6.6kB meta/pkg/uuid.js.map |
| 102 | +npm notice 851B package.json |
| 103 | +npm notice 8.1kB swm.js |
| 104 | +npm notice === Tarball Details === |
| 105 | +npm notice name: swm-client-lib |
| 106 | +npm notice version: 0.3.5 |
| 107 | +npm notice filename: swm-client-lib-0.3.5.tgz |
| 108 | +npm notice package size: 5.6 kB |
| 109 | +npm notice unpacked size: 19.5 kB |
| 110 | +npm notice shasum: e0d7c6d656bd15a317dd27fb0fbe1af87f68d053 |
| 111 | +npm notice integrity: sha512-BSDdyOua3vYwf[...]uyisTfa+m/Z5A== |
| 112 | +npm notice total files: 6 |
| 113 | +npm notice |
| 114 | +⸨░░░░░░░░░░░░░░░░░░⸩ ⠼ : notice |
| 115 | + |
| 116 | +> echo PUBLISHED |
| 117 | + |
| 118 | +PUBLISHED░░░░░░░░░░⸩ ⠼ : notice |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | +> echo PUBLISHED |
| 123 | + |
| 124 | +PUBLISHED |
| 125 | + |
| 126 | +can@msft-mbp ~/code/swm-dd-demo/lib (main) $ git add build/ |
| 127 | + |
| 128 | +can@msft-mbp ~/code/swm-dd-demo/lib (main) $ git commit -m "v0.3.5 release" |
| 129 | +[main 9ee1db9] v0.3.5 release |
| 130 | + 2 files changed, 12 insertions(+), 8 deletions(-) |
| 131 | + |
| 132 | +can@msft-mbp ~/code/swm-dd-demo/lib (main) $ git push |
| 133 | +Enumerating objects: 25, done. |
| 134 | +Counting objects: 100% (21/21), done. |
| 135 | +Delta compression using up to 12 threads |
| 136 | +Compressing objects: 100% (13/13), done. |
| 137 | +Writing objects: 100% (13/13), 1.28 KiB | 1.28 MiB/s, done. |
| 138 | +Total 13 (delta 10), reused 0 (delta 0) |
| 139 | +remote: Resolving deltas: 100% (10/10), completed with 5 local objects. |
| 140 | +``` |
0 commit comments