Skip to content

Commit b1702ef

Browse files
committed
build: use templating to output the README
1 parent 5d47949 commit b1702ef

File tree

8 files changed

+274
-37
lines changed

8 files changed

+274
-37
lines changed

.monorepo.json

+77-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,91 @@
11
{
2+
"badges": [
3+
[
4+
{
5+
"image": "https://img.shields.io/circleci/project/github/angular/devkit/master.svg?label=circleci",
6+
"label": "CircleCI branch",
7+
"url": "https://circleci.com/gh/angular/devkit"
8+
},
9+
{
10+
"title": "![Dependency Status][david-badge]",
11+
"url": "[david-badge-url]"
12+
},
13+
{
14+
"title": "![devDependency Status][david-dev-badge]",
15+
"url": "[david-dev-badge-url]"
16+
}
17+
],
18+
[
19+
{
20+
"label": "License",
21+
"image": "https://img.shields.io/npm/l/@angular/devkit.svg",
22+
"url": "[npm-badge-url]"
23+
},
24+
{
25+
"label": "Downloads",
26+
"image": "https://img.shields.io/npm/dm/@angular/devkit.svg",
27+
"url": "[npm-badge-url]"
28+
}
29+
],
30+
[
31+
{
32+
"label": "GitHub forks",
33+
"image": "https://img.shields.io/github/forks/angular/devkit.svg?style=social&label=Fork",
34+
"url": "https://github.com/angular/devkit/fork"
35+
},
36+
{
37+
"label": "GitHub stars",
38+
"image": "https://img.shields.io/github/stars/angular/devkit.svg?style=social&label=Star",
39+
"url": "https://github.com/angular/devkit"
40+
}
41+
]
42+
],
43+
"links": {
44+
"Gitter": "https://gitter.im/angular/angular-cli",
45+
"Contributing": "https://github.com/angular/devkit/blob/master/CONTRIBUTING.md",
46+
"Angular CLI": "http://github.com/angular/angular-cli"
47+
},
248
"packages": {
349
"@_/benchmark": {
4-
"version": "0.0.9",
5-
"hash": "d8f46247086fb87b670c039256b02fa4"
50+
"version": "0.0.11",
51+
"hash": "37ed7e417435c92dbf301e7b26ea37ca"
652
},
753
"@angular-devkit/build-optimizer": {
8-
"version": "0.0.25",
9-
"hash": "4ad20c668e59d3dc1397dc61722e8a35"
54+
"name": "Build Optimizer",
55+
"links": [
56+
{
57+
"label": "README",
58+
"url": "https://github.com/angular/devkit/blob/master/packages/angular_devkit/build_optimizer/README.md"
59+
}
60+
],
61+
"version": "0.0.26",
62+
"hash": "e2c0761a3c38064f24e89b1dd6be6dac"
1063
},
1164
"@angular-devkit/core": {
12-
"version": "0.0.17",
13-
"hash": "22ccb2169d795924bc532fedff34b532"
65+
"name": "Core",
66+
"version": "0.0.19",
67+
"hash": "5d058b61cd6c14405f26fb664184baf9"
1468
},
1569
"@angular-devkit/schematics": {
16-
"version": "0.0.30",
17-
"hash": "7740fc3b41c4201045695b89d3f36f9f"
70+
"name": "Schematics",
71+
"links": [
72+
{
73+
"label": "README",
74+
"url": "https://github.com/angular/devkit/blob/master/packages/angular_devkit/schematics/README.md"
75+
}
76+
],
77+
"version": "0.0.32",
78+
"hash": "ba766f92c5adc83a31be8619740626b8"
1879
},
1980
"@schematics/angular": {
20-
"version": "0.0.41",
21-
"hash": "e9ded458a88d07b5f0b5f4a33ef820cb"
81+
"name": "Angular Schematics",
82+
"section": "Schematics",
83+
"version": "0.0.43",
84+
"hash": "9694dcfcaae0639c4a6d832d2241ff65"
85+
},
86+
"@schematics/schematics": {
87+
"version": "0.0.1",
88+
"hash": "ed572f54ac86841171ed00723d1173cb"
2289
}
2390
}
2491
}

README.md

+47-15
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,63 @@
1+
<!--
2+
BEFORE UPDATING THIS FILE, READ THIS.
3+
4+
This file is automatically generated during release. It is important for you to not update
5+
README directly.
6+
7+
- If you need to change the content, update `scripts/templates/readme.ejs`
8+
- If you need to add/remove a package or a link, update the .monorepo.json file instead.
9+
10+
Any changes to README.md directly will result in a failure on CI.
11+
-->
12+
113
# Angular DevKit
214
### Development tools and libraries specialized for Angular
315

4-
<!-- Insert badges here -->
516

6-
[![CircleCI branch](https://img.shields.io/circleci/project/github/angular/devkit/master.svg?label=circleci)](https://circleci.com/gh/angular/devkit)
7-
[![Dependency Status][david-badge]][david-badge-url]
8-
[![devDependency Status][david-dev-badge]][david-dev-badge-url]
17+
[![CircleCI branch](https://img.shields.io/circleci/project/github/angular/devkit/master.svg?label=circleci)](https://circleci.com/gh/angular/devkit) [![Dependency Status][david-badge]][david-badge-url] [![devDependency Status][david-dev-badge]][david-dev-badge-url]
18+
19+
[![npm](https://img.shields.io/npm/v/%40angular/cli.svg)][npm-badge-url] [![npm](https://img.shields.io/npm/v/%40angular/cli/next.svg)][npm-badge-url] [![License](https://img.shields.io/npm/l/@angular/cli.svg)][npm-badge-url] [![Downloads](https://img.shields.io/npm/dm/@angular/cli.svg)][npm-badge-url]
20+
21+
[![GitHub forks](https://img.shields.io/github/forks/angular/devkit.svg?style=social&label=Fork)](https://github.com/angular/devkit/fork) [![GitHub stars](https://img.shields.io/github/stars/angular/devkit.svg?style=social&label=Star)](https://github.com/angular/devkit)
922

10-
[![npm](https://img.shields.io/npm/v/%40angular/cli.svg)][npm-badge-url]
11-
[![npm](https://img.shields.io/npm/v/%40angular/cli/next.svg)][npm-badge-url]
12-
[![npm](https://img.shields.io/npm/l/@angular/cli.svg)][npm-badge-url]
13-
[![npm](https://img.shields.io/npm/dm/@angular/cli.svg)][npm-badge-url]
1423

15-
[![GitHub forks](https://img.shields.io/github/forks/angular/devkit.svg?style=social&label=Fork)](https://github.com/angular/devkit/fork)
16-
[![GitHub stars](https://img.shields.io/github/stars/angular/devkit.svg?style=social&label=Star)](https://github.com/angular/devkit)
1724

1825
----
1926

2027
This is the home for all the tools and libraries built to assist developers with their Angular applications.
2128

2229
### Quick Links
23-
[Gitter](https://gitter.im/angular/angular-cli) | [Contributing](https://github.com/angular/devkit/blob/master/CONTRIBUTING.md) | [Angular CLI](https://gitter.im/angular/angular-cli)
30+
[Gitter](https://gitter.im/angular/angular-cli) | [Contributing](https://github.com/angular/devkit/blob/master/CONTRIBUTING.md) | [Angular CLI](http://github.com/angular/angular-cli) |
31+
|---|---|---|
32+
33+
34+
## The Goal of DevKit
35+
36+
Our goal is to provide a large set of libraries that can be used to manage, develop, deploy and
37+
analyze your code.
38+
39+
This is the extension of the Angular CLI Project. Once this set of tools is done, the Angular CLI
40+
as it is today will become one of many interfaces available to perform those tasks. Everything
41+
will also be available to third party tools and IDEs.
2442

25-
### Packages
43+
44+
## Packages
2645
This is a monorepo which contains many packages:
2746

47+
48+
49+
50+
2851
| Project | Package | Version | Links |
29-
|---|---|---|---|---|
30-
| Build Optimizer | `@angular-devkit/build-optimizer` | [![npm](https://img.shields.io/npm/v/%40angular-devkit/build-optimizer.svg)][npm-badge-url] | [![README](https://img.shields.io/badge/README--green.svg)](https://github.com/angular/devkit/blob/master/packages/angular_devkit/build_optimizer/README.md) |
31-
| Schematics | `@angular-devkit/schematics` | [![npm](https://img.shields.io/npm/v/%40angular-devkit/schematics.svg)][npm-badge-url] | |
52+
|---|---|---|---|
53+
**Build Optimizer** | [`@angular-devkit/build-optimizer`](http://npmjs.com/packages/@angular-devkit/build-optimizer) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fbuild-optimizer/latest.svg)](http://npmjs.com/packages/@angular-devkit/build-optimizer) | [![README](https://img.shields.io/badge/README--green.svg)](https://github.com/angular/devkit/blob/master/packages/angular_devkit/build_optimizer/README.md)
54+
**Core** | [`@angular-devkit/core`](http://npmjs.com/packages/@angular-devkit/core) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fcore/latest.svg)](http://npmjs.com/packages/@angular-devkit/core) |
55+
**Schematics** | [`@angular-devkit/schematics`](http://npmjs.com/packages/@angular-devkit/schematics) | [![latest](https://img.shields.io/npm/v/%40angular-devkit%2Fschematics/latest.svg)](http://npmjs.com/packages/@angular-devkit/schematics) | [![README](https://img.shields.io/badge/README--green.svg)](https://github.com/angular/devkit/blob/master/packages/angular_devkit/schematics/README.md)
56+
57+
#### Schematics
58+
59+
| Project | Package | Version | Links |
60+
|---|---|---|---|
61+
**Angular Schematics** | [`@schematics/angular`](http://npmjs.com/packages/@schematics/angular) | [![latest](https://img.shields.io/npm/v/%40schematics%2Fangular/latest.svg)](http://npmjs.com/packages/@schematics/angular) |
62+
63+

bin/devkit-admin

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ try {
7272
try {
7373
require(scriptPath).default(args, logger);
7474
} catch (err) {
75-
logger.fatal(err.toString());
75+
logger.fatal(err.stack);
7676
}
7777

lib/packages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export const packages: PackageMap =
194194
dependencies: [],
195195
hash: '',
196196
dirty: false,
197-
version: monorepoPackages[name].version || '0.0.0',
197+
version: monorepoPackages[name] && monorepoPackages[name].version || '0.0.0',
198198
};
199199

200200
return packages;
@@ -216,7 +216,7 @@ for (const pkgName of Object.keys(packages)) {
216216
// Update the hash values of each.
217217
for (const pkgName of Object.keys(packages)) {
218218
packages[pkgName].hash = _getHashOf(packages[pkgName]);
219-
if (packages[pkgName].hash != monorepoPackages[pkgName].hash) {
219+
if (!monorepoPackages[pkgName] || packages[pkgName].hash != monorepoPackages[pkgName].hash) {
220220
packages[pkgName].dirty = true;
221221
}
222222
}

packages/angular_devkit/core/src/utils/template.ts

+22-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { Position, SourceNode } from 'source-map';
99

1010
// Matches <%= expr %>. This does not support structural JavaScript (for/if/...).
1111
const kInterpolateRe = /<%=([\s\S]+?)%>/g;
12+
// Matches <%# text %>. It's a comment and will be entirely ignored.
13+
const kCommentRe = /<%#([\s\S]+?)%>/g;
1214

1315
// Used to match template delimiters.
1416
// <%- expr %>: HTML escape the value.
@@ -83,6 +85,14 @@ export interface TemplateAstContent extends TemplateAstBase {
8385
content: string;
8486
}
8587

88+
/**
89+
* A comment node.
90+
*/
91+
export interface TemplateAstComment extends TemplateAstBase {
92+
kind: 'comment';
93+
text: string;
94+
}
95+
8696
/**
8797
* An evaluate node, which is the code between `<% ... %>`.
8898
*/
@@ -109,6 +119,7 @@ export interface TemplateAstInterpolate extends TemplateAstBase {
109119

110120
export type TemplateAstNode = TemplateAstContent
111121
| TemplateAstEvaluate
122+
| TemplateAstComment
112123
| TemplateAstEscape
113124
| TemplateAstInterpolate;
114125

@@ -119,8 +130,8 @@ export function templateParser(sourceText: string, fileName: string): TemplateAs
119130
const children = [];
120131

121132
// Compile the regexp to match each delimiter.
122-
const reDelimiters = RegExp(
123-
`${kEscapeRe.source}|${kInterpolateRe.source}|${kEvaluateRe.source}|$`, 'g');
133+
const reExpressions = [kEscapeRe, kCommentRe, kInterpolateRe, kEvaluateRe];
134+
const reDelimiters = RegExp(reExpressions.map(x => x.source).join('|') + '|$', 'g');
124135

125136
const parsed = sourceText.split(reDelimiters);
126137
let offset = 0;
@@ -129,8 +140,9 @@ export function templateParser(sourceText: string, fileName: string): TemplateAs
129140
let start = _positionFor(sourceText, offset);
130141
let end = null as Position | null;
131142

132-
for (let i = 0; i < parsed.length; i += 4) {
133-
const [content, escape, interpolate, evaluate] = parsed.slice(i, i + 4);
143+
const increment = reExpressions.length + 1;
144+
for (let i = 0; i < parsed.length; i += increment) {
145+
const [content, escape, comment, interpolate, evaluate] = parsed.slice(i, i + increment);
134146
if (content) {
135147
end = _positionFor(sourceText, offset + content.length);
136148
offset += content.length;
@@ -143,6 +155,12 @@ export function templateParser(sourceText: string, fileName: string): TemplateAs
143155
children.push({ kind: 'escape', expression: escape, start, end } as TemplateAstEscape);
144156
start = end;
145157
}
158+
if (comment) {
159+
end = _positionFor(sourceText, offset + comment.length + 5);
160+
offset += comment.length + 5;
161+
children.push({ kind: 'comment', text: comment, start, end } as TemplateAstComment);
162+
start = end;
163+
}
146164
if (interpolate) {
147165
end = _positionFor(sourceText, offset + interpolate.length + 5);
148166
offset += interpolate.length + 5;

scripts/release.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ReleaseType } from 'semver';
1313
import { packages } from '../lib/packages';
1414

1515

16-
const { packages: monorepo } = require('../.monorepo.json');
16+
const monorepo = require('../.monorepo.json');
1717

1818

1919
function _showVersions(logger: Logger) {
@@ -84,10 +84,16 @@ function _upgrade(release: string, logger: Logger) {
8484
}
8585

8686
let message = '';
87-
if (newVersion && version !== newVersion) {
87+
if (!(pkg in monorepo.packages)) {
88+
message = `${pkg} is new... setting v${newVersion}`;
89+
monorepo.packages[pkg] = {
90+
version: newVersion,
91+
hash: hash,
92+
};
93+
} else if (newVersion && version !== newVersion) {
8894
message = `${pkg} changed... updating v${version} => v${newVersion}`;
89-
monorepo[pkg].version = newVersion;
90-
monorepo[pkg].hash = hash;
95+
monorepo.packages[pkg].version = newVersion;
96+
monorepo.packages[pkg].hash = hash;
9197
} else {
9298
message = `${pkg} SAME: v${version}`;
9399
}
@@ -120,7 +126,7 @@ export default function(args: { _: string[], 'dry-run'?: boolean }, logger: Logg
120126
_upgrade(maybeRelease, logger);
121127
if (!dryRun) {
122128
fs.writeFileSync(path.join(__dirname, '../.monorepo.json'),
123-
JSON.stringify({ packages: monorepo }, null, 2) + '\n');
129+
JSON.stringify(monorepo, null, 2) + '\n');
124130
}
125131
process.exit(0);
126132
break;

scripts/templates.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import * as fs from 'fs';
9+
import * as path from 'path';
10+
import { packages } from '../lib/packages';
11+
12+
export default function(_options: {}) {
13+
const monorepo = require('../.monorepo.json');
14+
15+
const readme = require('./templates/readme').default;
16+
const content = readme({
17+
monorepo,
18+
packages,
19+
encode: (x: string) => global.encodeURIComponent(x),
20+
});
21+
fs.writeFileSync(path.join(__dirname, '../README.md'), content, 'utf-8');
22+
}

0 commit comments

Comments
 (0)