UNPKG

5.76 kBMarkdownView Raw
1# @atomist/sdm-pack-fingerprints
2
3[![atomist sdm goals](http://badge.atomist.com/T29E48P34/atomist/sdm-pack-fingerprints/04e080df-3333-4783-82d3-a4c76637827b)](https://app.atomist.com/workspace/T29E48P34)
4[![npm version](https://img.shields.io/npm/v/@atomist/sdm-pack-fingerprints.svg)](https://www.npmjs.com/package/@atomist/sdm-pack-fingerprints)
5
6[Atomist][atomist] software delivery machine (SDM) extension pack
7providing fingerprinting support.
8
9See the [Atomist documentation][atomist-doc] for more information on
10what SDMs are and what they can do for you using the Atomist API for
11software.
12
13[atomist-doc]: https://docs.atomist.com/ (Atomist Documentation)
14
15## Features
16
17This pack sets a goal to monitor all git pushes and trackes the following features:
18
19* leiningen `project.clj` files are monitored for updates to library dependencies and project version.
20* maven `pom.xml` files are monitored for updates to maven library dependencies and version coordinates.
21* npm `package.json` files are monitored for updates to module dependencies and package version changes.
22
23This monitoring happens computing a set of fingerprints on every commit. The fingerprints that are computed
24depend on the type of project. We currently compute fingerprints for maven, clojure, and npm projects.
25
26* npm-project-deps, clojure-project-deps, and maven-project-deps
27* npm-project-coordinates, clojure-project-coordinates, maven-project-coordinates
28
29When a new fingerprint is computed, we can drive interesting behaviors such as:
30
31* check whether a library is up to date with a set of team-wide goals and offer to push a PR if not
32* check whether a new version of a library is available and check whether consumers need to update to this new version
33
34## Usage
35
36Make the following updates to your machine:
37
381. Add the imports and create a Goal to represent dependency fingerprinting
39
40```
41import { fingerprintSupport } from "@atomist/sdm-pack-fingerprints";
42import { Fingerprint } from "@atomist/sdm";
43
44// create a goal to fingerprint all new Pushes
45export FingerprintGoal = new Fingerprint();
46```
47
482. Enable the `FingerprintGoal` for some push rules. Normally, this is done as part of creating your machine:
49
50```ts
51 // there will usually be more than one Push rule here
52 const sdm = createSoftwareDeliveryMachine({
53 ...config
54 },
55 whenPushSatisfies(IsLein)
56 .itMeans("fingerprint a clojure project")
57 .setGoals(FingerprintGoal));
58
59```
60
613. Add the pack to your new `sdm` definition:
62
63There'll be some new imports:
64
65```ts
66import {
67 fingerprintSupport,
68 forFingerprints,
69 renderDiffSnippet,
70 depsFingerprints,
71 logbackFingerprints,
72 renderData,
73 applyFingerprint,
74 FP,
75} from "@atomist/sdm-pack-fingerprints";
76
77```
78
79and then you'll have to add the extension pack to your machine definition:
80
81```ts
82 // add this pack to your SDM
83 sdm.addExtensionPacks(
84 fingerprintSupport(
85 FingerprintGoal,
86 async (p: GitProject) => {
87 // COMPUTE fingerprints: called on every Push
88 return depsFingerprints(p.baseDir);
89 },
90 async (p: GitProject, fp: FP) => {
91 // APPLY fingerprint to Project (currently only through user actions in chat)
92 return applyFingerprint(p.baseDir, fp);
93 },
94 {
95 selector: forFingerprints("backpack-react-scripts"),
96 handler: async (ctx, diff) => {
97 // HANDLE new fingerprint (even if it hasn't changed in this push)
98 return checkFingerprintTargets(ctx, diff);
99 },
100 diffHandler: async (ctx, diff) => {
101 // HANDLE new fingerprint (only when the fingerprint sha is updated)
102 return renderDiffSnippet(ctx, diff);
103 },
104 },
105 ),
106 )
107```
108
109In the example above, we have a module which computes a set of fingerprints on every `Push` (one of them is named `backpack-react-scripts`). The pack also notices if a newly
110computed fingerprint has either changed, or is different from a `goal` state. It will then present the user with options to do things like:
111
112* set new targets
113* update a project to be in sync with a target fingerprint
114* apply a fingerprint to a project for the first time
115* broadcast a message to all projects out of sync with the fingerprint
116
117## Support
118
119General support questions should be discussed in the `#support`
120channel in the [Atomist community Slack workspace][slack].
121
122If you find a problem, please create an [issue][].
123
124[issue]: https://github.com/atomist/sdm-pack-fingerprints/issues
125
126## Development
127
128You will need to install [node][] to build and test this project.
129
130[node]: https://nodejs.org/ (Node.js)
131
132### Build and test
133
134Use the following package scripts to build, test, and perform other
135development tasks.
136
137Command | Reason
138------- | ------
139`npm install` | install project dependencies
140`npm run build` | compile, test, lint, and generate docs
141`npm run lint` | run TSLint against the TypeScript
142`npm run compile` | generate types from GraphQL and compile TypeScript
143`npm test` | run tests
144`npm run autotest` | run tests every time a file changes
145`npm run clean` | remove files generated during build
146
147### Release
148
149Releases are handled via the [Atomist SDM][atomist-sdm]. Just press
150the 'Approve' button in the Atomist dashboard or Slack.
151
152[atomist-sdm]: https://github.com/atomist/atomist-sdm (Atomist Software Delivery Machine)
153
154---
155
156Created by [Atomist][atomist].
157Need Help? [Join our Slack workspace][slack].
158
159[atomist]: https://atomist.com/ (Atomist - How Teams Deliver Software)
160[slack]: https://join.atomist.com/ (Atomist Community Slack)