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

Mark removed types as deprecated #138

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ jobs:
run: yarn lint
- name: test
run: yarn test
publish-packages-dry-run:
needs: build_and_test
uses: ./.github/workflows/publish-packages.yml
with:
dry-run: true
publish-registry-dry-run:
needs: build_and_test
uses: ./.github/workflows/publish-registry.yml
with:
dry-run: true
retag-dry-run:
needs: build_and_test
uses: ./.github/workflows/retag.yml
with:
dry-run: true
deprecate-dry-run:
needs: build_and_test
uses: ./.github/workflows/deprecate.yml
with:
dry-run: true
publish_alpha:
name: publish alpha release
runs-on: ubuntu-latest
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/deprecate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Mark removed types as deprecated
#description: Loop over npm @types packages and mark as deprecated any that no longer exist in the DT repo.
on:
schedule:
# https://crontab.guru/#0_0_*_*_0
- cron: 0 0 * * 0
workflow_call:
inputs:
dry-run:
type: boolean
workflow_dispatch:
inputs:
dry-run:
type: boolean
jobs:
deprecate:
if: github.event_name != 'schedule' || github.repository == 'microsoft/DefinitelyTyped-tools'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Parse declarations
run: yarn workspace @definitelytyped/publisher parse
- name: Mark removed types as deprecated${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
run: node --require source-map-support/register packages/deprecate/${{ (inputs || github.event.inputs).dry-run && ' --dry-run' || '' }}
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: packages/definitions-parser/data/
42 changes: 42 additions & 0 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish packages
#description: Find changed @types packages in the DT repo and publish them to npm.
on:
workflow_call:
inputs:
dry-run:
type: boolean
workflow_dispatch:
inputs:
dry-run:
type: boolean
jobs:
publish-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Parse declarations
run: yarn workspace @definitelytyped/publisher parse
- uses: actions/cache@v3
with:
path: packages/utils/cache/
key: cache-${{ github.run_id }}
restore-keys: cache-
- name: Calculate versions
run: yarn workspace @definitelytyped/publisher calculate-versions
- name: Generate packages
run: yarn workspace @definitelytyped/publisher generate
- name: Publish packages${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
run: yarn workspace @definitelytyped/publisher publish-packages${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
env:
GH_API_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: packages/definitions-parser/data/
14 changes: 12 additions & 2 deletions .github/workflows/publish-registry.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
name: Publish registry
#description: Publish the types-registry package to npm (a list of all @types packages in the DT repo).
on:
schedule:
# https://crontab.guru/#0_0_*_*_0
- cron: 0 0 * * 0
workflow_call:
inputs:
dry-run:
type: boolean
workflow_dispatch:
inputs:
dry-run:
type: boolean
jobs:
publish-registry:
if: github.event_name != 'schedule' || github.repository == 'microsoft/DefinitelyTyped-tools'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -21,11 +30,12 @@ jobs:
path: packages/utils/cache/
key: cache-${{ github.run_id }}
restore-keys: cache-
- name: Publish registry
run: yarn workspace @definitelytyped/publisher publish-registry
- name: Publish registry${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
run: yarn workspace @definitelytyped/publisher publish-registry${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
env:
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: packages/definitions-parser/data/
39 changes: 39 additions & 0 deletions .github/workflows/retag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Update npm tags
#description: Refresh tags on all DT-published packages in the @types scope.
on:
schedule:
# https://crontab.guru/#0_0_*_*_0
- cron: 0 0 * * 0
workflow_call:
inputs:
dry-run:
type: boolean
workflow_dispatch:
inputs:
dry-run:
type: boolean
jobs:
retag:
if: github.event_name != 'schedule' || github.repository == 'microsoft/DefinitelyTyped-tools'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn build
- uses: actions/cache@v3
with:
path: packages/utils/cache/
key: cache-${{ github.run_id }}
restore-keys: cache-
- name: Update npm tags${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
run: yarn retag${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
env:
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: packages/definitions-parser/data/
35 changes: 0 additions & 35 deletions .github/workflows/update-ts-version-tags.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A monorepo for formerly disparate DefinitelyTyped-related tools:

- [definitions-parser](packages/definitions-parser): the part of [microsoft/types-publisher](https://github.com/microsoft/types-publisher) that reads DefinitelyTyped repository data
- [deprecate](packages/publish-registry): Loop over npm @types packages and mark as deprecated any that no longer exist in the DT repo.
- [dtslint](packages/dtslint): [microsoft/dtslint](https://github.com/microsoft/dtslint)
- [dtslint-runner](packages/dtslint-runner): [DefinitelyTyped/dtslint-runner](https://github.com/DefinitelyTyped/dtslint-runner)
- [dts-critic](packages/dts-critic): [DefinitelyTyped/dts-critic](https://github.com/DefinitelyTyped/dts-critic)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"format": "prettier --write 'packages/**/*.ts'",
"test": "jest",
"build": "tsc -b .",
"retag": "node packages/retag/dist/retag.js"
"retag": "node --require source-map-support/register packages/retag/"
},
"devDependencies": {
"@types/jest": "^25.1.3",
Expand Down
55 changes: 55 additions & 0 deletions packages/deprecate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# deprecate

[![Mark removed types as deprecated](https://github.com/microsoft/DefinitelyTyped-tools/actions/workflows/deprecate.yml/badge.svg)](https://github.com/microsoft/DefinitelyTyped-tools/actions/workflows/deprecate.yml)

Loop over npm @types packages and mark as deprecated any that no longer exist in the DT repo.

## Use

```sh
yarn workspace @definitelytyped/publisher parse
node packages/deprecate/
```

1. [Parse declarations](../publisher/README.md#parse-the-definitions).
2. Run this package's script.

### Options

<dl><dt>

`--dry-run`

</dt><dd>

Don't actually mark anything as deprecated, just show what would be done.

</dd></dl>

### Environment variables

<dl><dt>

`GITHUB_TOKEN`

</dt><dd>

Required.
Used to talk to [GitHub's GraphQL API](https://docs.github.com/en/graphql/guides/forming-calls-with-graphql#authenticating-with-graphql), to find the commit/PR that removed the types.
That data is public and a GitHub Actions [automatic token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication) is sufficient.

</dd><dt>

[`NPM_TOKEN`](https://docs.npmjs.com/about-access-tokens)

</dt><dd>

Not required for a dry run.
Only used to actually mark @types packages as deprecated.

</dd></dl>

## Logs

GitHub Actions runs this package's script weekly.
You can [examine the logs](https://github.com/microsoft/DefinitelyTyped-tools/actions/workflows/deprecate.yml).
26 changes: 26 additions & 0 deletions packages/deprecate/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@definitelytyped/deprecate",
"version": "1.0.0",
"description": "Loop over npm @types packages and mark as deprecated any that no longer exist in the DT repo.",
"license": "MIT",
"main": "dist/index.js",
"scripts": {
"build": "tsc --build"
},
"dependencies": {
"@definitelytyped/definitions-parser": "^0.0.121",
"@definitelytyped/utils": "^0.0.121",
"@octokit/graphql": "^4.8.0",
"all-the-package-names": "^2.0.176",
"pacote": "^13.6.1",
"typescript-dom-lib-generator": "https://github.com/microsoft/TypeScript-DOM-lib-generator.git",
"yargs": "^17.5.1"
},
"devDependencies": {
"@types/all-the-package-names": "^1.3744.0",
"@types/pacote": "^11.1.5",
"@types/yargs": "^17.0.10"
},
"private": true,
"type": "module"
}
Loading