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
|
7 | providing fingerprinting support.
|
8 |
|
9 | See the [Atomist documentation][atomist-doc] for more information on
|
10 | what SDMs are and what they can do for you using the Atomist API for
|
11 | software.
|
12 |
|
13 | [atomist-doc]: https://docs.atomist.com/ (Atomist Documentation)
|
14 |
|
15 | ## Features
|
16 |
|
17 | This 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 |
|
23 | This monitoring happens computing a set of fingerprints on every commit. The fingerprints that are computed
|
24 | depend 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 |
|
29 | When 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 |
|
36 | Make the following updates to your machine:
|
37 |
|
38 | 1. Add the imports and create a Goal to represent dependency fingerprinting
|
39 |
|
40 | ```
|
41 | import { fingerprintSupport } from "@atomist/sdm-pack-fingerprints";
|
42 | import { Fingerprint } from "@atomist/sdm";
|
43 |
|
44 | // create a goal to fingerprint all new Pushes
|
45 | export FingerprintGoal = new Fingerprint();
|
46 | ```
|
47 |
|
48 | 2. 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 |
|
61 | 3. Add the pack to your new `sdm` definition:
|
62 |
|
63 | There'll be some new imports:
|
64 |
|
65 | ```ts
|
66 | import {
|
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 |
|
79 | and 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 |
|
109 | In 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
|
110 | computed 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 |
|
119 | General support questions should be discussed in the `#support`
|
120 | channel in the [Atomist community Slack workspace][slack].
|
121 |
|
122 | If you find a problem, please create an [issue][].
|
123 |
|
124 | [issue]: https://github.com/atomist/sdm-pack-fingerprints/issues
|
125 |
|
126 | ## Development
|
127 |
|
128 | You 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 |
|
134 | Use the following package scripts to build, test, and perform other
|
135 | development tasks.
|
136 |
|
137 | Command | 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 |
|
149 | Releases are handled via the [Atomist SDM][atomist-sdm]. Just press
|
150 | the '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 |
|
156 | Created by [Atomist][atomist].
|
157 | Need 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)
|