@@ -11,11 +11,31 @@ import { execSync, spawnSync } from 'child_process';
1111import * as fs from 'fs' ;
1212import * as os from 'os' ;
1313import * as path from 'path' ;
14- import { packages } from '../lib/packages' ;
14+ import { PackageInfo , packages } from '../lib/packages' ;
1515import build from './build' ;
1616import create from './create' ;
1717
1818
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+
1939function _copy ( from : string , to : string ) {
2040 fs . readdirSync ( from )
2141 . forEach ( name => {
@@ -137,7 +157,17 @@ export default async function(opts: SnapshotsOptions, logger: logging.Logger) {
137157 _exec ( 'git' , [ 'config' , 'commit.gpgSign' , 'false' ] , { cwd : destPath } , publishLogger ) ;
138158 }
139159
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).
141171 fs . writeFileSync ( path . join ( destPath , 'uniqueId' ) , '' + new Date ( ) ) ;
142172
143173 // Commit and push.
0 commit comments