@@ -11,11 +11,31 @@ import { execSync, spawnSync } from 'child_process';
11
11
import * as fs from 'fs' ;
12
12
import * as os from 'os' ;
13
13
import * as path from 'path' ;
14
- import { packages } from '../lib/packages' ;
14
+ import { PackageInfo , packages } from '../lib/packages' ;
15
15
import build from './build' ;
16
16
import create from './create' ;
17
17
18
18
19
+ // Added to the README.md of the snapshot. This is markdown.
20
+ const readmeHeaderFn = ( pkg : PackageInfo ) => `
21
+ # Snapshot build of ${ pkg . name }
22
+
23
+ This repository is a snapshot of a commit on the original repository. The original code used to
24
+ generate this is located at http://github.com/angular/angular-cli.
25
+
26
+ We do not accept PRs or Issues opened on this repository. You should not use this over a tested and
27
+ released version of this package.
28
+
29
+ To test this snapshot in your own project, use
30
+
31
+ \`\`\`bash
32
+ npm install github.com/${ pkg . snapshotRepo }
33
+ \`\`\`
34
+
35
+ ----
36
+ ` ;
37
+
38
+
19
39
function _copy ( from : string , to : string ) {
20
40
fs . readdirSync ( from )
21
41
. forEach ( name => {
@@ -137,7 +157,17 @@ export default async function(opts: SnapshotsOptions, logger: logging.Logger) {
137
157
_exec ( 'git' , [ 'config' , 'commit.gpgSign' , 'false' ] , { cwd : destPath } , publishLogger ) ;
138
158
}
139
159
140
- // Make sure that every snapshots is unique.
160
+ // Add the header to the existing README.md (or create a README if it doesn't exist).
161
+ const readmePath = path . join ( destPath , 'README.md' ) ;
162
+ let readme = readmeHeaderFn ( pkg ) ;
163
+ try {
164
+ readme += fs . readFileSync ( readmePath , 'utf-8' ) ;
165
+ } catch { }
166
+
167
+ fs . writeFileSync ( readmePath , readme ) ;
168
+
169
+ // Make sure that every snapshots is unique (otherwise we would need to make sure git accepts
170
+ // empty commits).
141
171
fs . writeFileSync ( path . join ( destPath , 'uniqueId' ) , '' + new Date ( ) ) ;
142
172
143
173
// Commit and push.
0 commit comments