Skip to content

Commit

Permalink
Merge pull request #1 from microsoft/v2
Browse files Browse the repository at this point in the history
pull accross forks
  • Loading branch information
0length authored Oct 8, 2020
2 parents 0d6b05c + 1935f9e commit 55b4673
Show file tree
Hide file tree
Showing 97 changed files with 2,306 additions and 384 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ packages/tsconfig-reference/copy/id/**/*.md @jefrydco @nusendra @mazipan @mandap
packages/typescriptlang-org/src/copy/id/**/*.ts @jefrydco @nusendra @mazipan @mandaputtra [translation] [id]
packages/typescriptlang-org/src/copy/id.ts @jefrydco @nusendra @mazipan @mandaputtra [translation] [id]
packages/documentation/copy/id/**/*.md @jefrydco @nusendra @mazipan @mandaputtra [translation] [id]

# Collaborators for Ukrainian Translation of the Website
packages/playground-examples/copy/uk @AMashoshyna [translation] [uk]
packages/tsconfig-reference/copy/uk/**/*.md @AMashoshyna [translation] [uk]
packages/typescriptlang-org/src/copy/uk/**/*.ts @AMashoshyna [translation] [uk]
packages/typescriptlang-org/src/copy/uk.ts @AMashoshyna [translation] [uk]
packages/documentation/copy/uk/**/*.md @AMashoshyna [translation] [uk]
78 changes: 0 additions & 78 deletions .github/workflows/CI-post.yml

This file was deleted.

79 changes: 43 additions & 36 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ jobs:
- run: yarn bootstrap
- run: yarn workspace typescriptlang-org build

# Blocked on https://github.com/Azure/static-web-apps/issues/147
#

# PR deploys via static web apps
# - name: "Make a fake 'app' for the azure project of the static HTML"
# run: |
# mkdir fakeapp
# mv packages/typescriptlang-org/public fakeapp/public
# ls fakeapp
# ls fakeapp/public
# echo '{ "name": "fake", "scripts": { "build": "" } }' > fakeapp/package.json

# - name: Build And Deploy
# id: builddeploy
# uses: Azure/static-web-apps-deploy@v0.0.1-preview
# if: github.event.base.repo.id == github.event.head.repo.id
# with:
# azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_NICE_MEADOW_0C9756810 }}
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# action: "upload"
# app_location: "fakeapp"
# api_location: "api"
# app_artifact_location: "public"

# Verify it compiles
- run: yarn compile
# Run all the package's tests
Expand All @@ -51,40 +75,23 @@ jobs:
- name: "Validates that TypeScript plugins work"
run: npm init typescript-playground-plugin playground-my-plugin

- name: "Copy PR JSON"
run: cp $GITHUB_EVENT_PATH ${{ github.workspace }}/packages/typescriptlang-org/public/pr.json

- uses: actions/upload-artifact@v2
with:
name: built-site
path: ${{ github.workspace }}/packages/typescriptlang-org/public/**/*

windows:
runs-on: windows-latest

steps:
# Check out, and set up the node infra
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: "13.x"

# Cache yarn deps, to speed up CI
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# Get local dependencies
- run: yarn install
# danger for PR builds
- if: github.event_name == 'pull_request' && github.event.base.repo.id == github.event.head.repo.id
run: "yarn danger ci"
env:
YARN_CHECKSUM_BEHAVIOR: ignore

- run: yarn bootstrap
- run: yarn build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_DEPLOY_URL_ROOT: ${{ steps.deploy.outputs.static_web_app_url }}
#
# Blocked on https://github.com/Azure/static-web-apps/issues/147
#
# close_pull_request_job:
# if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.base.repo.id == github.event.head.repo.id
# runs-on: ubuntu-latest
# name: Close Pull Request Job
# steps:
# - name: Close Pull Request
# id: closepullrequest
# uses: Azure/static-web-apps-deploy@v0.0.1-preview
# with:
# azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_NICE_MEADOW_0C9756810 }}
# action: "close"
22 changes: 0 additions & 22 deletions .github/workflows/PR-closed-post.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/PR-closed.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/v2-merged-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
cp -r packages/typescriptlang-org/public site
env:
YARN_CHECKSUM_BEHAVIOR: ignore
TYPESCRIPT_SITE_STAGING: true

- name: Deploy + Publish to CDN
# You can find these keys here:
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ yarn start
Working on this repo is done by running `yarn start` - this starts up the website on port `8000` and creates a
builder worker for every package in the repo, so if you make a change outside of the site it will compile and lint etc.

Some useful knowledge:
Some useful knowledge you need to know:

- All packages have: `yarn build` and `yarn test`
- All packages use [debug](https://www.npmjs.com/package/debug) - which means you can do `env DEBUG="*" yarn test` to get verbose logs

You can manually via GH Actions for [production here](https://github.com/microsoft/TypeScript-Website/actions?query=workflow%3A%22Monday+Website+Push+To+Production%22) and [staging here](https://github.com/microsoft/TypeScript-Website/actions?query=workflow%3A%22Build+Website+To+Staging%22).

Having issues getting set up? [Consult the troubleshooting](./docs/Setup%20Troubleshooting.md).

## Deployment

Deployment is automatic:
Expand All @@ -39,9 +41,14 @@ Deployment is automatic:

You can find the build logs in [GitHub Actions](https://github.com/microsoft/TypeScript-Website/actions)

## Overview
## Docs

If you want to know _in-depth_ how this website works, there is an [hour long video covering the codebase, deployment and tooling on YouTube.](https://www.youtube.com/watch?v=HOvivt6B7hE). Otherwise there are some short guides:

If you want to know _in-depth_ how this website works, there is an [hour long video covering the codebase, deployment and tooling on YouTube.](https://www.youtube.com/watch?v=HOvivt6B7hE).
- [Converting Twoslash Code Samples](./docs/Converting%20Twoslash%20Code%20Samples.md)
- [How i8n Works For Site Copy](./docs/How%20i8n%20Works%20For%20Site%20Copy.md)
- [Updating the TypeScript Version](./docs/New%20TypeScript%20Version.md)
- [Something Went Wrong](./docs/Something%20Went%20Wrong.md)

# Website Packages

Expand Down Expand Up @@ -95,7 +102,7 @@ The docs for TypeScript. Originally ported over from [microsoft/TypeScript-Handb

## Playground Examples

The code samples used in the Playground split across many languages
The code samples used in the Playground split across many languages.

# Infra Packages

Expand All @@ -119,7 +126,7 @@ Generates an epub file from the handbook files. You can try downloading it at ht

## Community Meta

Generates contributions JSON metadata on who edited handbook pages
Generates contributions JSON metadata on who edited handbook pages.

# Contributing

Expand Down
81 changes: 26 additions & 55 deletions dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,39 @@
// yarn danger pr https://github.com/microsoft/TypeScript-Website/pull/115

import { danger, message, markdown } from "danger"
// import { basename } from "path"
// import spellcheck from "danger-plugin-spellcheck"
import { basename } from "path"
import spellcheck from "danger-plugin-spellcheck"

// Blocked on PR deploys, see CI.yml
// import lighthouse from "danger-plugin-lighthouse"
import { readFileSync } from "fs"

// Spell check all the things
// spellcheck({ settings: "artsy/peril-settings@spellcheck.json" })

export default () => {
// JSON reference: https://github.com/haya14busa/github-actions-playground/runs/987846369
const contextText = readFileSync("built/public/pr.json", "utf8")
console.log(contextText)
const context = JSON.parse(contextText)

const repo = { owner: context.event.repository.owner.login, repo: context.event.repository.name }
const prNumber = context.event.workflow_run.pull_requests[0].number
console.log(repo)

console.log(process.env.PR_DEPLOY_URL_ROOT)

const changedFiles = getChangedFiles(prNumber)
console.log(changedFiles)

// Print out the PR url
const deployURL = process.env.PR_DEPLOY_URL_ROOT
message(
`Deployed to [a PR branch](${deployURL}) - [playground](${deployURL}/play) [tsconfig](${deployURL}/tsconfig) [old handbook](${deployURL}/docs/handbook/integrating-with-build-tools.html)`
)
spellcheck({ settings: "artsy/peril-settings@spellcheck.json" })

// lighthouse()
const deployURL = process.env.PR_DEPLOY_URL_ROOT
if (deployURL) {
const msg = `Deployed to [a PR branch](${deployURL}) - [playground](${deployURL}/play) [tsconfig](${deployURL}/tsconfig) [old handbook](${deployURL}/docs/handbook/integrating-with-build-tools.html)`
message(msg)
}

const getChangedFiles = async (prNumber: number) => {
const repo = { owner: "microsoft", name: "TypeScript-website" }
// Look for new snapshots and show in a HTML table
const snapshots = danger.git.fileMatch("packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/*.png")
if (snapshots.modified) {
const oldSha = danger.github.pr.base.sha
const newSha = danger.github.pr.head.sha

// https://developer.github.com/v3/pulls/#list-pull-requests-files
const options = danger.github.api.pulls.listFiles.endpoint.merge({ ...repo, pull_number: prNumber })
const tables = snapshots.getKeyedPaths().modified.map(p => {
const oldURL = `https://raw.githubusercontent.com/microsoft/TypeScript-Website/${oldSha}/${p}`
const newURL = `https://raw.githubusercontent.com/microsoft/TypeScript-Website/${newSha}/${p}`

/** @type { import("@octokit/rest").PullsListFilesResponseItem[]} */
const files = await danger.github.api.paginate(options)
const fileStrings = files.map(f => `/${f.filename}`)
return fileStrings
}

// // Look for new snapshots and show in a HTML table
// const snapshots = danger.git.fileMatch("packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/*.png")
// if (snapshots.modified) {
// const oldSha = danger.github.pr.base.sha
// const newSha = danger.github.pr.head.sha

// const tables = snapshots.getKeyedPaths().modified.map(p => {
// const oldURL = `https://raw.githubusercontent.com/microsoft/TypeScript-Website/${oldSha}/${p}`
// const newURL = `https://raw.githubusercontent.com/microsoft/TypeScript-Website/${newSha}/${p}`
return `
###### \`${basename(p)}\`
// return `
// ###### \`${basename(p)}\`
Before | After
:-------------------------:|:-------------------------:
![](${oldURL}) | ![](${newURL})
`
})

// Before | After
// :-------------------------:|:-------------------------:
// ![](${oldURL}) | ![](${newURL})
// `
// })

// markdown(`## Snapshots updated\n\n ${tables.join("\n\n")}`)
// }
markdown(`## Snapshots updated\n\n ${tables.join("\n\n")}`)
}
15 changes: 15 additions & 0 deletions docs/New TypeScript Version.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ Then run `yarn install`.

That will update all of the site to use 3.9.0 for building. Run `yarn build` to see if any of the website's code broke.

##### New Handbook Docs

You might have a new reference doc to add, they live in [`packages/documentation/copy`](https://github.com/microsoft/TypeScript-website/blob/v2/packages/documentation/copy). You can ignore languages other than `en`. The folder structure is only for your reference and has no bearing on the site navigation. Each markdown document needs a header like:

```md
---
title: Basic Types
layout: docs
permalink: /docs/handbook/basic-types.html
oneline: "Step one in learning TypeScript: The basic types."
---
```

Or the site will fail the build. Once that file is ready, add it to the sidebar via the file [`packages/documentation/scripts/generateDocsNavigationPerLanguage.js`](https://github.com/microsoft/TypeScript-website/blob/v2/packages/documentation/scripts/generateDocsNavigationPerLanguage.js).

##### TSConfig Reference

Updating the version of TypeScript will force you to update the TSConfig Reference. It will fail incrementally with each missing compiler flag.
Expand Down
Loading

0 comments on commit 55b4673

Please sign in to comment.