Skip to content

Commit c688b4c

Browse files
author
Orta Therox
authored
Merge pull request #1913 from microsoft/use_twoslash_libs
Update gatsby/react and switch to the lib version of twoslash
2 parents 0787f6f + 4104110 commit c688b4c

File tree

18 files changed

+3812
-2244
lines changed

18 files changed

+3812
-2244
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ The main website for TypeScript, a Gatsby website which is statically deployed.
6565
yarn start
6666
```
6767

68-
To save your time, twoslash is not applied to code-samples in `yarn start` - to launch the server with twoslash support use: `yarn start-twoslash`.
6968
To optimize even more, the env var `NO_TRANSLATIONS` as truthy will make the website only load pages for English.
7069

7170
## Sandbox

docs/Converting Twoslash Code Samples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### A Guide to Converting to Twoslash
22

3-
To run the site with Twoslash enabled you need to use `yarn start-twoslash`.
3+
To run the site with Twoslash enabled you need to use `yarn start`.
44

55
Code samples on the TypeScript Website should run through [Twoslash](https://github.com/microsoft/TypeScript-Website/tree/v2/packages/ts-twoslasher#typescript-twoslash) which lets the compiler do more of the work.
66

docs/Setup Troubleshooting.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
Sometimes, and it's not been tracked down exactly, some dependencies of the site aren't built even though it says they are. In those cases, re-run `yarn bootstrap` and `yarn build` to re-build all the internal site deps.
66

7-
#### No syntax highlighting
8-
9-
By default the website runs without twoslash code samples being evaluated, this affects the syntax highlighting. To turn it on, use `yarn start-twoslash` instead of `yarn start`.
10-
117
#### Windows + Watchman
128

139
The Windows support for watchman is a bit meh. It's not likely to get better, given how well WSL works now. So, you _could_ use WSL to work around that.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"fb-watchman": "^2.0.1",
1717
"git-branch-is": "^3.1.0",
1818
"husky": "^4.2.3",
19-
"pleb": "^2.5.6",
19+
"pleb": "^2.6.1",
2020
"reflect-metadata": "^0.1.13"
2121
},
2222
"resolutions": {
@@ -26,7 +26,8 @@
2626
"typescript": "4.4.0-dev.20210627",
2727
"tslib": "2.1.0",
2828
"prettier": "^2.0.2",
29-
"shelljs": "0.8.4"
29+
"shelljs": "0.8.4",
30+
"sharp": "0.28.1"
3031
},
3132
"jest": {
3233
"transformIgnorePatterns": [
@@ -36,7 +37,6 @@
3637
"scripts": {
3738
"bootstrap": "yarn workspaces foreach -v -t --exclude root run bootstrap && BOOTSTRAPPING=true yarn workspaces foreach -v -t --exclude root run build",
3839
"start": "concurrently -p \"[{name}]\" -n \"BUILD,SITE\" -c \"bgBlue.bold,bgMagenta.bold\" \"node watcher.js\" \"yarn workspace typescriptlang-org start\"",
39-
"start-twoslash": "concurrently -p \"[{name}]\" -n \"BUILD,SITE\" -c \"bgBlue.bold,bgMagenta.bold\" \"node watcher.js\" \"yarn workspace typescriptlang-org start-twoslash\"",
4040
"build": "yarn workspaces foreach -v -t --exclude root --exclude typescriptlang-org run build",
4141
"build-site": "yarn workspace typescriptlang-org build",
4242
"compile": "yarn workspace typescriptlang-org tsc",
@@ -47,7 +47,7 @@
4747
"update-test-snapshots": "CI=true yarn workspaces foreach --include gatsby-remark-shiki-twoslash --include @typescript/twoslash --include shiki-twoslash --include @typescript/vfs run test -u"
4848
},
4949
"dependencies": {
50-
"@oss-docs/sync": "^1.1.1",
50+
"@oss-docs/sync": "^1.1.3",
5151
"@types/express": "^4.17.6",
5252
"gray-matter": "4.0.2",
5353
"node-polyfill-webpack-plugin": "^1.1.0",

packages/glossary/scripts/lint.js

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { readdirSync, readFileSync } = require("fs");
1212
const { join } = require("path");
1313

1414
const remark = require("remark");
15-
const remarkTwoSlash = require("gatsby-remark-shiki-twoslash");
15+
const remarkTwoSlash = require("remark-shiki-twoslash");
1616

1717
const { read } = require("gray-matter");
1818

@@ -25,62 +25,65 @@ const filterString = process.argv[2] ? process.argv[2] : "";
2525

2626
const errorReports = [];
2727

28-
languages.forEach((lang) => {
29-
console.log("\n\nLanguage: " + chalk.bold(lang) + "\n");
28+
const go = async () => {
29+
for (const lang of languages) {
30+
console.log("\n\nLanguage: " + chalk.bold(lang) + "\n");
3031

31-
const locale = join(__dirname, "..", "copy", lang);
32-
let options;
32+
const locale = join(__dirname, "..", "copy", lang);
33+
let options;
3334

34-
try {
35-
options = readdirSync(join(locale)).filter((f) => !f.startsWith("."));
36-
} catch {
37-
errorReports.push({
38-
path: join(locale, "options"),
39-
error: `Options directory ${join(locale, "options")} doesn't exist`,
40-
});
41-
return;
42-
}
35+
try {
36+
options = readdirSync(join(locale)).filter((f) => !f.startsWith("."));
37+
} catch {
38+
errorReports.push({
39+
path: join(locale, "options"),
40+
error: `Options directory ${join(locale, "options")} doesn't exist`,
41+
});
42+
return;
43+
}
4344

44-
options.forEach((option) => {
45-
if (filterString.length && !option.includes(filterString)) return;
45+
for (const option of options) {
46+
if (filterString.length && !option.includes(filterString)) return;
4647

47-
const optionPath = join(locale, option);
48+
const optionPath = join(locale, option);
4849

49-
const markdown = readFileSync(optionPath, "utf8");
50-
const markdownAST = remark().parse(markdown);
51-
let hasError = false;
50+
const markdown = readFileSync(optionPath, "utf8");
51+
const markdownAST = remark().parse(markdown);
52+
let hasError = false;
5253

53-
try {
54-
remarkTwoSlash.runTwoSlashAcrossDocument({ markdownAST }, {});
55-
} catch (error) {
56-
hasError = true;
57-
errorReports.push({ path: optionPath, error });
58-
}
54+
try {
55+
await remarkTwoSlash.default({})(markdownAST);
56+
} catch (error) {
57+
hasError = true;
58+
errorReports.push({ path: optionPath, error });
59+
}
5960

60-
const optionFile = read(optionPath);
61-
if (!optionFile.data.display) {
62-
hasError = true;
63-
// prettier-ignore
64-
errorReports.push({ path: optionPath, error: new Error("Did not have a 'display' property in the YML header") });
61+
const optionFile = read(optionPath);
62+
if (!optionFile.data.display) {
63+
hasError = true;
64+
// prettier-ignore
65+
errorReports.push({ path: optionPath, error: new Error("Did not have a 'display' property in the YML header") });
66+
}
67+
68+
const sigil = hasError ? cross : tick;
69+
const name = hasError ? chalk.red(option) : option;
70+
process.stdout.write(name + " " + sigil + ", ");
6571
}
72+
}
73+
74+
if (errorReports.length) {
75+
process.exitCode = 1;
6676

67-
const sigil = hasError ? cross : tick;
68-
const name = hasError ? chalk.red(option) : option;
69-
process.stdout.write(name + " " + sigil + ", ");
70-
});
71-
});
72-
73-
if (errorReports.length) {
74-
process.exitCode = 1;
75-
76-
errorReports.forEach((err) => {
77-
console.log(`\n> ${chalk.bold.red(err.path)}\n`);
78-
err.error.stack = undefined;
79-
console.log(err.error);
80-
});
81-
console.log("\n\n");
82-
83-
console.log(
84-
"Note: you can add an extra argument to the lint script ( yarn workspace glossary lint [opt] ) to just run one lint."
85-
);
86-
}
77+
errorReports.forEach((err) => {
78+
console.log(`\n> ${chalk.bold.red(err.path)}\n`);
79+
err.error.stack = undefined;
80+
console.log(err.error);
81+
});
82+
console.log("\n\n");
83+
84+
console.log(
85+
"Note: you can add an extra argument to the lint script ( yarn workspace glossary lint [opt] ) to just run one lint."
86+
);
87+
}
88+
};
89+
go();

packages/handbook-epub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"dependencies": {
1515
"fs-jetpack": "^2.4.0",
16-
"gatsby-remark-shiki-twoslash": "2.0.0",
16+
"gatsby-remark-shiki-twoslash": "3.0.14",
1717
"playwright": "^1.9.1",
1818
"sass": "*",
1919
"streampub": "https://github.com/orta/streampub-1.git#ibooks",

packages/typescript-vfs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
},
3838
"devDependencies": {
3939
"@types/jest": "^25.1.3",
40+
"babel-jest": "^26.0.6",
4041
"cpy-cli": "^3.1.1",
4142
"tsdx": "^0.14.1",
4243
"tslib": "^1.10.0",

packages/typescriptlang-org/gatsby-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module.exports = {
6666
resolve: `gatsby-plugin-sitemap`,
6767
options: {
6868
// Skip handbook v2 frmo appearing in search
69-
exclude: [`*/2/*`, `*/glossary`, `*/vo/*`],
69+
excludes: [`*/2/*`, `*/glossary`, `*/vo/*`],
7070
},
7171
},
7272
// Lets you edit the head from inside a react tree

packages/typescriptlang-org/lib/bootup/createPages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export const createPages: GatsbyNode["createPages"] = async args => {
2323
await createTSConfigSingleFlagPages(args.graphql, args.actions.createPage)
2424
await createRootPagesLocalized(args.graphql, args.actions.createPage)
2525

26-
return null
26+
return undefined
2727
}

packages/typescriptlang-org/package.json

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"setup-staging": "node scripts/setupStaging.mjs",
1515
"create-lighthouse-json": "node scripts/createLighthouseJSON.js",
1616
"compile-index-examples": "node scripts/runTwoslashIndexExamples.js light; node scripts/runTwoslashIndexExamples.js dark",
17-
"start": "TWOSLASH_DISABLE=true gatsby develop",
18-
"start-twoslash": "gatsby develop",
17+
"start": "gatsby develop",
1918
"serve": "gatsby serve",
2019
"test": "yarn tsc && jest"
2120
},
@@ -28,34 +27,34 @@
2827
"@typescript/sandbox": "0.1.0",
2928
"@typescript/twoslash": "2.1.0",
3029
"canvas": "^2.6.1",
31-
"gatsby": "^3.2.1",
32-
"gatsby-link": "3.2.0",
33-
"gatsby-plugin-catch-links": "^3.2.0",
30+
"gatsby": "^3.8.1",
31+
"gatsby-link": "3.10.0",
32+
"gatsby-plugin-catch-links": "^3.10.0",
3433
"gatsby-plugin-client-side-redirect": "orta/gatsby-plugin-client-side-redirect#index",
3534
"gatsby-plugin-i18n": "^1.0.1",
36-
"gatsby-plugin-manifest": "^3.2.0",
37-
"gatsby-plugin-offline": "^4.2.0",
38-
"gatsby-plugin-react-helmet": "^4.2.0",
39-
"gatsby-plugin-sass": "^4.2.0",
40-
"gatsby-plugin-sharp": "^3.2.1",
41-
"gatsby-plugin-sitemap": "^3.2.0",
42-
"gatsby-plugin-typegen": "^2.2.1",
43-
"gatsby-react-router-scroll": "4.2.0",
44-
"gatsby-remark-autolink-headers": "^3.2.0",
45-
"gatsby-remark-copy-linked-files": "^3.2.0",
35+
"gatsby-plugin-manifest": "^3.10.0",
36+
"gatsby-plugin-offline": "^4.10.0",
37+
"gatsby-plugin-react-helmet": "^4.10.0",
38+
"gatsby-plugin-sass": "^4.10.0",
39+
"gatsby-plugin-sharp": "^3.10.2",
40+
"gatsby-plugin-sitemap": "^4.6.0",
41+
"gatsby-plugin-typegen": "^2.2.4",
42+
"gatsby-react-router-scroll": "4.10.0",
43+
"gatsby-remark-autolink-headers": "^4.7.0",
44+
"gatsby-remark-copy-linked-files": "^4.7.0",
4645
"gatsby-remark-emojis": "^0.4.3",
47-
"gatsby-remark-images": "^4.2.0",
48-
"gatsby-remark-responsive-iframe": "^3.2.0",
49-
"gatsby-remark-shiki-twoslash": "^2.0.1",
50-
"gatsby-remark-smartypants": "^3.2.0",
51-
"gatsby-source-filesystem": "^3.2.0",
52-
"gatsby-transformer-remark": "^3.2.0",
46+
"gatsby-remark-images": "^5.7.0",
47+
"gatsby-remark-responsive-iframe": "^4.7.0",
48+
"gatsby-remark-shiki-twoslash": "^3.0.14",
49+
"gatsby-remark-smartypants": "^4.7.0",
50+
"gatsby-source-filesystem": "^3.8.0",
51+
"gatsby-transformer-remark": "^4.7.0",
5352
"jsdom": "^16.2.0",
54-
"preact": "^10.5.5",
55-
"react": "^16.12.0",
56-
"react-dom": "^16.12.0",
57-
"react-helmet": "^5.2.1",
58-
"react-intl": "^3.12.0",
53+
"preact": "^10.5.13",
54+
"react": "^16.14.0",
55+
"react-dom": "^16.14.0",
56+
"react-helmet": "^6.1.0",
57+
"react-intl": "^3.12.1",
5958
"rehype-shiki": "^0.0.7",
6059
"sass": "^1.26.10",
6160
"ts-debounce": "^2.2.0",
@@ -68,7 +67,7 @@
6867
"@types/react": "^16.9.20",
6968
"@types/react-dom": "^16.9.5",
7069
"concurrently": "^5.1.0",
71-
"gatsby-plugin-typescript": "^3.2.0",
70+
"gatsby-plugin-typescript": "^3.10.0",
7271
"jest": "*",
7372
"ts-jest": "^26.4.4"
7473
},

0 commit comments

Comments
 (0)