Skip to content

Commit b23ee7a

Browse files
hanslvikerman
authored andcommitted
ci: add header to snapshot build README (#12482)
Fixes #12481
1 parent f48a163 commit b23ee7a

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

scripts/snapshots.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,31 @@ import { execSync, spawnSync } from 'child_process';
1111
import * as fs from 'fs';
1212
import * as os from 'os';
1313
import * as path from 'path';
14-
import { packages } from '../lib/packages';
14+
import { PackageInfo, packages } from '../lib/packages';
1515
import build from './build';
1616
import 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+
1939
function _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

Comments
 (0)