Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add header to snapshot build README #12482

Merged
merged 1 commit into from
Oct 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 32 additions & 2 deletions scripts/snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,31 @@ import { execSync, spawnSync } from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { packages } from '../lib/packages';
import { PackageInfo, packages } from '../lib/packages';
import build from './build';
import create from './create';


// Added to the README.md of the snapshot. This is markdown.
const readmeHeaderFn = (pkg: PackageInfo) => `
# Snapshot build of ${pkg.name}

This repository is a snapshot of a commit on the original repository. The original code used to
generate this is located at http://github.com/angular/angular-cli.

We do not accept PRs or Issues opened on this repository. You should not use this over a tested and
released version of this package.

To test this snapshot in your own project, use

\`\`\`bash
npm install github.com/${pkg.snapshotRepo}
\`\`\`

----
`;


function _copy(from: string, to: string) {
fs.readdirSync(from)
.forEach(name => {
Expand Down Expand Up @@ -137,7 +157,17 @@ export default async function(opts: SnapshotsOptions, logger: logging.Logger) {
_exec('git', ['config', 'commit.gpgSign', 'false'], { cwd: destPath }, publishLogger);
}

// Make sure that every snapshots is unique.
// Add the header to the existing README.md (or create a README if it doesn't exist).
const readmePath = path.join(destPath, 'README.md');
let readme = readmeHeaderFn(pkg);
try {
readme += fs.readFileSync(readmePath, 'utf-8');
} catch {}

fs.writeFileSync(readmePath, readme);

// Make sure that every snapshots is unique (otherwise we would need to make sure git accepts
// empty commits).
fs.writeFileSync(path.join(destPath, 'uniqueId'), '' + new Date());

// Commit and push.
Expand Down