Skip to content

Commit c6fb091

Browse files
author
Orta Therox
authored
Merge pull request #1057 from microsoft/release_docs
Documents the release to TS process, and adds support for easily generating a CHANGELOG for 2 arbitrary versions
2 parents e548eed + bc2c865 commit c6fb091

File tree

4 files changed

+72
-8
lines changed

4 files changed

+72
-8
lines changed

README.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This tool is used to generate the web-based `lib.dom.d.ts` file which is include
44

55
## Why is my fancy API still not available here?
66

7-
A feature needs to be supported by more than two major browser engines to be included here, to make sure there is a good consensus among vendors: __Gecko__ (Firefox), __Blink__ (Chrome/Edge), and __WebKit__ (Safari).
7+
A feature needs to be supported by two or more major browser engines to be included here, to make sure there is a good consensus among vendors: __Gecko__ (Firefox), __Blink__ (Chrome/Edge), and __WebKit__ (Safari).
88

9-
If the condition is met but still is not available here, please [file an issue](hthttps://github.com/microsoft/TypeScript-DOM-lib-generator/issues/new).
9+
If the condition is met but still is not available here, first check the heuristics below and then please [file an issue](hthttps://github.com/microsoft/TypeScript-DOM-lib-generator/issues/new).
1010

1111
## Build Instructions
1212

@@ -28,13 +28,13 @@ To test:
2828
npm run test
2929
```
3030

31-
To deploy:
3231

33-
```sh
34-
npm run migrate
35-
```
32+
## `@types/[lib]` to TypeScript Versions
3633

37-
The script will look in for a clone of the TypeScript repo in "../TypeScript", or "./TypeScript" to move the generated files in.
34+
| `@types/[lib]` version | TypeScript Version | Minimum TypeScript Support |
35+
| ---------------------------------------------------------------------- | ----------- | -------------- |
36+
| `@types/web` [0.0.1](https://www.npmjs.com/package/@types/web/v/0.0.1) | ~4.3 | 4.4 |
37+
| `@types/web` [0.0.2](https://www.npmjs.com/package/@types/web/v/0.0.2) | ~4.4 beta | 4.4 |
3838

3939
## Contribution Guidelines
4040

@@ -116,3 +116,26 @@ To give you a sense of whether we will accept changes, you can use these heurist
116116
- `removedTypes.json`: types that are defined in the spec file but should be removed.
117117
- `comments.json`: comment strings to be embedded in the generated .js files.
118118
- `deprecatedMessage.json`: the reason why one type is deprecated. The reason why it is a separate file rather than merge in comment.json is mdn/apiDescriptions.json would also possibly be deprecated.
119+
120+
## Deployment to TypeScript
121+
122+
To migrate the *.d.ts files into TypeScript:
123+
124+
1. Run:
125+
126+
```sh
127+
npm run migrate -- [previous_types_web_version]
128+
```
129+
130+
The script will look in for a clone of the TypeScript repo in "../TypeScript", or "./TypeScript" to move the generated files in. Or migrate the files manually, you do you.
131+
132+
1. Update the README table with the mappings for versions in the `@types/[lib]`. E.g. TS 4.5 -> `@types/web` `0.0.23`.
133+
134+
1. Generate a CHANGELOG for the releases:
135+
136+
```sh
137+
# lib from to
138+
npm run ts-changelog -- @types/web 0.0.2 0.0.23
139+
```
140+
141+
1. Add the CHANGELOG to the release issue

src/migrate.ts renamed to deploy/migrate.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if (!tscWD)
1616

1717
const generatedFiles = readdirSync("generated");
1818
generatedFiles.forEach((file) => {
19+
if (file == ".DS_Store") return;
1920
const contents = readFileSync(join("generated", file), "utf8");
2021
const newFilePath = join(tscWD, "src", "lib", file);
2122
writeFileSync(newFilePath, contents);

deploy/versionChangelog.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// @ts-check
2+
3+
// npm run ts-changelog @types/web 0.0.1 0.0.3
4+
5+
import { generateChangelogFrom } from "../lib/changelog.js";
6+
import { packages } from "./createTypesPackages.mjs";
7+
import { execSync } from "child_process";
8+
import { basename } from "path";
9+
10+
const [name, before, to] = process.argv.slice(2);
11+
if (!name || !before || !to) {
12+
throw new Error(
13+
"Expected three arguments: package name, version before, version to"
14+
);
15+
}
16+
17+
const go = () => {
18+
// We'll need to map back from the filename in the npm package to the
19+
// generated file in baselines inside the git tag
20+
const thisPackageMeta = packages.find((p) => p.name === name);
21+
if (!thisPackageMeta)
22+
throw new Error(`Could not find ${name} in ${packages.map((p) => p.name)}`);
23+
24+
for (const file of thisPackageMeta.files) {
25+
const filename = `baselines/${basename(file.from)}`;
26+
const beforeFileText = gitShowFile(`${name}@${before}`, filename);
27+
const toFileText = gitShowFile(`${name}@${to}`, filename);
28+
29+
const notes = generateChangelogFrom(beforeFileText, toFileText);
30+
31+
console.log(`\n## \`${file.to}\`\n`);
32+
console.log(notes.trim() === "" ? "No changes" : notes);
33+
}
34+
};
35+
36+
const gitShowFile = (commitish, path) =>
37+
execSync(`git show "${commitish}":${path}`, { encoding: "utf-8" });
38+
39+
go();

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"lint": "eslint --max-warnings 0 src",
2121
"test": "npm run lint && npm run build && node ./lib/test.js && node ./unittests/index.js",
2222
"changelog": "tsc && node ./lib/changelog.js",
23-
"migrate": "node ./lib/migrate.js",
23+
"ts-changelog": "node ./deploy/versionChangelog.mjs",
24+
"migrate": "node ./deploy/migrate.mjs",
2425
"version": "npm i && tsc && node ./lib/version.js"
2526
},
2627
"author": {

0 commit comments

Comments
 (0)