mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-23 12:00:09 +00:00
Compare commits
1 Commits
@discordjs
...
@discordjs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
444d7c98dd |
@@ -1,13 +1,11 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/commitlintrc.json",
|
||||
"extends": ["@commitlint/config-angular"],
|
||||
"rules": {
|
||||
"type-enum": [
|
||||
2,
|
||||
"always",
|
||||
["chore", "build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test", "types"]
|
||||
["chore", "build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test", "types", "typings"]
|
||||
],
|
||||
"scope-case": [0],
|
||||
"subject-exclamation-mark": [0]
|
||||
"scope-case": [0]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +1,38 @@
|
||||
# Packages
|
||||
**/node_modules
|
||||
node_modules/
|
||||
|
||||
# Log files
|
||||
**/logs
|
||||
**/*.log
|
||||
**/npm-debug.log*
|
||||
logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Runtime data
|
||||
**/pids
|
||||
**/*.pid
|
||||
**/*.seed
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Env
|
||||
**/.env
|
||||
.env
|
||||
|
||||
# Dist
|
||||
**/dist/
|
||||
**/dist-docs/
|
||||
dist/
|
||||
|
||||
# Miscellaneous
|
||||
**/.tmp
|
||||
**/.vscode
|
||||
**/.idea
|
||||
**/.DS_Store
|
||||
**/.turbo
|
||||
**/tsconfig.tsbuildinfo
|
||||
**/coverage
|
||||
**/__tests__
|
||||
**/out
|
||||
.tmp/
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
!.vscode/settings.json
|
||||
.idea/
|
||||
.DS_Store
|
||||
.turbo
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
# yarn
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/cache
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# Cache
|
||||
**/.prettiercache
|
||||
**/.eslintcache
|
||||
**/.vercel
|
||||
|
||||
# Docker specific
|
||||
**/.cliff-jumperrc.json
|
||||
**/api-extractor.json
|
||||
**/api-extractor-docs.json
|
||||
**/.eslintignore
|
||||
**/.eslintrc.json
|
||||
**/.lintstagedrc.js
|
||||
**/.lintstagedrc.cjs
|
||||
**/.lintstagedrc.json
|
||||
**/.prettierignore
|
||||
**/.prettierrc.js
|
||||
**/.prettierrc.cjs
|
||||
**/.prettierrc.json
|
||||
**/cliff.toml
|
||||
**/CHANGELOG.md
|
||||
**/README.md
|
||||
**/LICENSE
|
||||
**/tsconfig.eslint.json
|
||||
**/tsconfig.docs.json
|
||||
**/docs/
|
||||
**/vitest.config.ts
|
||||
|
||||
|
||||
11
.eslintrc.json
Normal file
11
.eslintrc.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "marine/prettier/node",
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.eslint.json"
|
||||
},
|
||||
"ignorePatterns": ["**/dist/*"],
|
||||
"env": {
|
||||
"jest": true
|
||||
}
|
||||
}
|
||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,2 +1 @@
|
||||
* text=auto eol=lf
|
||||
pnpm-lock.yaml linguist-generated=true text=auto eol=lf
|
||||
|
||||
11
.github/.kodiak.toml
vendored
11
.github/.kodiak.toml
vendored
@@ -1,11 +0,0 @@
|
||||
version = 1
|
||||
|
||||
[merge]
|
||||
require_automerge_label = false
|
||||
blocking_labels = ['blocked', 'in review']
|
||||
method = 'squash'
|
||||
|
||||
[merge.message]
|
||||
title = 'pull_request_title'
|
||||
strip_html_comments = true
|
||||
include_coauthors = true
|
||||
24
.github/CODEOWNERS
vendored
24
.github/CODEOWNERS
vendored
@@ -1,24 +0,0 @@
|
||||
# Learn how to add code owners here:
|
||||
# https://help.github.com/articles/about-code-owners
|
||||
|
||||
* @iCrawl
|
||||
|
||||
/packages/actions/ @discordjs/actions
|
||||
/packages/api-extractor-utils/ @discordjs/api-extractor-utils
|
||||
/packages/brokers/ @discordjs/brokers
|
||||
/packages/builders/ @discordjs/builders
|
||||
/packages/collection/ @discordjs/collection
|
||||
/packages/core/ @discordjs/core
|
||||
/packages/create-discord-bot/ @discordjs/guide
|
||||
/packages/discord.js/ @discordjs/core
|
||||
/packages/docgen/ @iCrawl
|
||||
/packages/formatters/ @discordjs/formatters
|
||||
/packages/next/ @discordjs/core
|
||||
/packages/proxy/ @discordjs/proxy
|
||||
/packages/proxy-container/ @discordjs/proxy
|
||||
/packages/rest/ @discordjs/rest
|
||||
/packages/scripts/ @discordjs/scripts
|
||||
/packages/ui/ @discordjs/ui
|
||||
/packages/util/ @discordjs/util
|
||||
/packages/voice/ @discordjs/core
|
||||
/packages/ws/ @discordjs/ws
|
||||
3
.github/COMMIT_CONVENTION.md
vendored
3
.github/COMMIT_CONVENTION.md
vendored
@@ -7,7 +7,7 @@
|
||||
Messages must be matched by the following regex:
|
||||
|
||||
```js
|
||||
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore|types)(\(.+\))?!?: .{1,72}/;
|
||||
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,72}/;
|
||||
```
|
||||
|
||||
#### Examples
|
||||
@@ -55,7 +55,6 @@ A commit message consists of a **header**, **body** and **footer**. The header h
|
||||
```
|
||||
|
||||
The **header** is mandatory and the **scope** of the header is optional.
|
||||
If the commit contains **Breaking Changes**, a `!` can be added before the `:` as an indicator.
|
||||
|
||||
### Revert
|
||||
|
||||
|
||||
37
.github/CONTRIBUTING.md
vendored
37
.github/CONTRIBUTING.md
vendored
@@ -11,39 +11,8 @@ is a great boon to your development process.
|
||||
To get ready to work on the codebase, please do the following:
|
||||
|
||||
1. Fork & clone the repository, and make sure you're on the **main** branch
|
||||
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
|
||||
3. Run `pnpm run build` to build local packages
|
||||
2. Run `yarn --immutable` ([install](https://yarnpkg.com/getting-started/install))
|
||||
3. Run `yarn build` to build local packages
|
||||
4. Code your heart out!
|
||||
5. Run `pnpm run test` to run ESLint and ensure any JSDoc changes are valid
|
||||
5. Run `yarn test` to run ESLint and ensure any JSDoc changes are valid
|
||||
6. [Submit a pull request](https://github.com/discordjs/discord.js/compare) (Make sure you follow the [conventional commit format](https://github.com/discordjs/discord.js/blob/main/.github/COMMIT_CONVENTION.md))
|
||||
|
||||
## Testing changes locally
|
||||
|
||||
If you want to test changes you've made locally, you can do so by using `pnpm link <package-you-want-to-link-to-your-current-package>`. This will create a symlink to your local copy of the discord.js libraries.
|
||||
|
||||
1. Create a new directory `mkdir discordjs-test` and move into it `cd discordjs-test`
|
||||
2. Initialize a new pnpm project `pnpm init`
|
||||
3. Now link the discord.js package from the directory you cloned earlier `pnpm link {PATH_TO_DISCORDJS_REPO}/packages/<package>`. (e.g. `pnpm link ~/discord.js/packages/rest`)
|
||||
4. Import the package in your source code and test them out!
|
||||
|
||||
### Working with TypeScript packages
|
||||
|
||||
When testing local changes, you may notice you need to manually recompile TypeScript projects on every change in order to get the latest code changes to test locally.
|
||||
|
||||
To avoid this you can use the `--watch` parameter in the package build script to automatically recompile the project when changes are detected.
|
||||
|
||||
For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `pnpm turbo run build --filter='@discordjs/rest' -- --watch` in the root folder of where you cloned the discord.js repo.
|
||||
|
||||
## Adding new packages
|
||||
|
||||
If you'd like to create another package under the `@discordjs` organization run the following command:
|
||||
|
||||
```sh
|
||||
pnpm run create-package <package-name> [package-description]
|
||||
```
|
||||
|
||||
This will create new package directory under `packages/` with the required configuration files. You may begin
|
||||
to make changes within the `src/` directory. You may also need to:
|
||||
|
||||
- Update workflows that utilize packages
|
||||
- Update the CODEOWNERS file
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
name: Websites bug report
|
||||
description: Report an issue with the documentation or guide websites.
|
||||
labels: [bug, need repro]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for filing an issue! If you are here to ask a question, use Discord instead: https://discord.gg/djs
|
||||
|
||||
This issue form is for our documentation and guide websites.
|
||||
- type: dropdown
|
||||
id: application
|
||||
attributes:
|
||||
label: Which application is this bug report for?
|
||||
options:
|
||||
- Documentation
|
||||
- Guide
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Issue description
|
||||
description: Describe the issue in as much detail as possible.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps_to_reproduce
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
description: What steps must be taken to reproduce this issue?
|
||||
placeholder: |
|
||||
1. Visit a page
|
||||
2. Click a link
|
||||
3. ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: versions
|
||||
attributes:
|
||||
label: Versions
|
||||
description: List necessary versions here. This includes your browser, operating system etc.
|
||||
placeholder: |
|
||||
- Safari 16.4 (18615.1.26.11.23)
|
||||
- macOS Ventura 13.3.1
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: priority
|
||||
attributes:
|
||||
label: Issue priority
|
||||
description: Please be realistic. If you need to elaborate on your reasoning, please use the issue description field above.
|
||||
options:
|
||||
- Low (slightly annoying)
|
||||
- Medium (should be fixed soon)
|
||||
- High (immediate attention needed)
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,31 +1,22 @@
|
||||
name: Bug report
|
||||
description: Report an issue with discord.js or another package.
|
||||
description: Report incorrect or unexpected behavior of a package
|
||||
labels: [bug, need repro]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for filing an issue! If you are here to ask a question, use Discord instead: https://discord.gg/djs
|
||||
|
||||
This issue form is for discord.js, including other packages.
|
||||
Use Discord for questions: https://discord.gg/djs
|
||||
- type: dropdown
|
||||
id: package
|
||||
attributes:
|
||||
label: Which package is this bug report for?
|
||||
options:
|
||||
- discord.js
|
||||
- brokers
|
||||
- builders
|
||||
- collection
|
||||
- core
|
||||
- create-discord-bot
|
||||
- formatters
|
||||
- next
|
||||
- rest
|
||||
- proxy
|
||||
- proxy-container
|
||||
- rest
|
||||
- ui
|
||||
- util
|
||||
- voice
|
||||
- ws
|
||||
validations:
|
||||
@@ -34,44 +25,57 @@ body:
|
||||
id: description
|
||||
attributes:
|
||||
label: Issue description
|
||||
description: Describe the issue in as much detail as possible.
|
||||
description: |
|
||||
Describe the issue in as much detail as possible.
|
||||
|
||||
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files into it.
|
||||
placeholder: |
|
||||
Steps to reproduce with below code sample:
|
||||
1. Do thing
|
||||
2. Do thing in Discord client
|
||||
3. Observe behavior
|
||||
4. See error logs below
|
||||
1. do thing
|
||||
2. do thing in Discord client
|
||||
3. observe behavior
|
||||
4. see error logs below
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: code_sample
|
||||
id: codesample
|
||||
attributes:
|
||||
label: Code sample
|
||||
description: |
|
||||
Your code sample should be:
|
||||
1. Minimal - Use as little code as possible that still produces the same problem (and is understandable)
|
||||
2. Complete - Provide all parts someone else needs to reproduce your problem
|
||||
3. Reproducible - Test the code you're about to provide to make sure it reproduces the problem
|
||||
|
||||
This will be automatically formatted into code, so no need for backticks.
|
||||
description: Include a reproducible, minimal code sample. This will be automatically formatted into code, so no need for backticks.
|
||||
render: typescript
|
||||
- type: textarea
|
||||
id: versions
|
||||
attributes:
|
||||
label: Versions
|
||||
description: List necessary versions here. This includes your package version, runtime version, operating system etc.
|
||||
placeholder: |
|
||||
- discord.js 14.12.1 (`npm ls discord.js` or another package)
|
||||
- Node.js 16.11.0 (`node --version`)
|
||||
- TypeScript 5.1.6 (`npm ls typescript` if you use it)
|
||||
- macOS Ventura 13.3.1
|
||||
Your code sample should be...
|
||||
... Minimal - Use as little code as possible that still produces the same problem (and is understandable)
|
||||
... Complete - Provide all parts someone else needs to reproduce your problem
|
||||
... Reproducible - Test the code you're about to provide to make sure it reproduces the problem
|
||||
- type: input
|
||||
id: djs-version
|
||||
attributes:
|
||||
label: Package version
|
||||
description: Which version of are you using? Run `npm list <package>` in your project directory and paste the output.
|
||||
placeholder: We no longer support version 12 or earlier of discord.js
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: node-version
|
||||
attributes:
|
||||
label: Node.js version
|
||||
description: |
|
||||
Which version of Node.js are you using? Run `node --version` in your project directory and paste the output.
|
||||
If you are using TypeScript, please include its version (`npm list typescript`) as well.
|
||||
placeholder: Node.js version 16.9+ is required for version 14.0.0+
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: Operating system
|
||||
description: Which OS does your application run on?
|
||||
- type: dropdown
|
||||
id: priority
|
||||
attributes:
|
||||
label: Issue priority
|
||||
description: Please be realistic. If you need to elaborate on your reasoning, please use the issue description field above.
|
||||
label: Priority this issue should have
|
||||
description: Please be realistic. If you need to elaborate on your reasoning, please use the Issue description field above.
|
||||
options:
|
||||
- Low (slightly annoying)
|
||||
- Medium (should be fixed soon)
|
||||
@@ -82,9 +86,12 @@ body:
|
||||
id: partials
|
||||
attributes:
|
||||
label: Which partials do you have configured?
|
||||
description: Check your `Client` constructor for the `partials` key.
|
||||
description: |
|
||||
Check your Client constructor for the `partials` key.
|
||||
|
||||
Tip: you can select multiple items
|
||||
options:
|
||||
- Not applicable
|
||||
- Not applicable (subpackage bug)
|
||||
- No Partials
|
||||
- User
|
||||
- Channel
|
||||
@@ -100,13 +107,16 @@ body:
|
||||
id: intents
|
||||
attributes:
|
||||
label: Which gateway intents are you subscribing to?
|
||||
description: Check your `Client` constructor for the `intents` key.
|
||||
description: |
|
||||
Check your Client constructor options for the `intents` key.
|
||||
|
||||
Tip: you can select multiple items
|
||||
options:
|
||||
- Not applicable
|
||||
- Not applicable (subpackage bug)
|
||||
- No Intents
|
||||
- Guilds
|
||||
- GuildMembers
|
||||
- GuildModeration
|
||||
- GuildBans
|
||||
- GuildEmojisAndStickers
|
||||
- GuildIntegrations
|
||||
- GuildWebhooks
|
||||
@@ -121,15 +131,11 @@ body:
|
||||
- DirectMessageTyping
|
||||
- MessageContent
|
||||
- GuildScheduledEvents
|
||||
- AutoModerationConfiguration
|
||||
- AutoModerationExecution
|
||||
- GuildMessagePolls
|
||||
- DirectMessagePolls
|
||||
multiple: true
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: dev_release
|
||||
id: dev-release
|
||||
attributes:
|
||||
label: I have tested this issue on a development release
|
||||
placeholder: d23280c (commit hash)
|
||||
@@ -5,29 +5,20 @@ body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
We can only implement features that Discord publishes, documents, and merges into the Discord API documentation.
|
||||
We can only implement features that Discord publishes, documents and merges into the Discord API documentation.
|
||||
We do not implement unreleased features.
|
||||
Use Discord for questions: https://discord.gg/djs
|
||||
- type: dropdown
|
||||
id: application_or_package
|
||||
id: package
|
||||
attributes:
|
||||
label: Which application or package is this feature request for?
|
||||
label: Which package is the feature request for?
|
||||
options:
|
||||
- discord.js
|
||||
- Documentation
|
||||
- Guide
|
||||
- brokers
|
||||
- builders
|
||||
- collection
|
||||
- core
|
||||
- create-discord-bot
|
||||
- formatters
|
||||
- next
|
||||
- rest
|
||||
- proxy
|
||||
- proxy-container
|
||||
- rest
|
||||
- ui
|
||||
- util
|
||||
- voice
|
||||
- ws
|
||||
validations:
|
||||
@@ -53,7 +44,7 @@ body:
|
||||
label: Alternative solutions or implementations
|
||||
description: A clear and concise description of any alternative solutions or features you have considered.
|
||||
- type: textarea
|
||||
id: additional_context
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: Other context
|
||||
description: Any other context, screenshots, or file uploads that help us understand your feature request.
|
||||
8
.github/auto_assign.yml
vendored
Normal file
8
.github/auto_assign.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
addReviewers: true
|
||||
reviewers:
|
||||
- iCrawl
|
||||
- SpaceEEC
|
||||
- kyranet
|
||||
- vladfrangu
|
||||
numberOfReviewers: 0
|
||||
runOnDraft: true
|
||||
13
.github/check_deploy_branch.sh
vendored
Executable file
13
.github/check_deploy_branch.sh
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
git diff HEAD^ HEAD --quiet .
|
||||
|
||||
if [[ "$VERCEL_GIT_COMMIT_REF" == "main" || $? -eq 1 ]]; then
|
||||
# Proceed with the build
|
||||
echo "✅ - Proceed"
|
||||
exit 1;
|
||||
else
|
||||
# Don't build
|
||||
echo "🛑 - Build cancelled"
|
||||
exit 0;
|
||||
fi
|
||||
51
.github/issue-labeler.yml
vendored
51
.github/issue-labeler.yml
vendored
@@ -1,51 +0,0 @@
|
||||
apps:guide:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nGuide\\n"
|
||||
apps:website:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nDocumentation\\n"
|
||||
packages:brokers:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nbrokers\\n"
|
||||
packages:builders:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nbuilders\\n"
|
||||
packages:collection:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ncollection\\n"
|
||||
packages:core:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ncore\\n"
|
||||
packages:create-discord-bot:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ncreate-discord-bot\\n"
|
||||
packages:discord.js:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ndiscord.js\\n"
|
||||
packages:formatters:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nformatters\\n"
|
||||
packages:next:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nnext\\n"
|
||||
packages:proxy:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nproxy\\n"
|
||||
packages:proxy-container:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nproxy-container\\n"
|
||||
packages:rest:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nrest\\n"
|
||||
packages:ui:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\ui\\n"
|
||||
packages:util:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\util\\n"
|
||||
packages:voice:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nvoice\\n"
|
||||
packages:ws:
|
||||
- "### Which (application|package|application or package) is this (bug
|
||||
report|feature request) for\\?\\n\\nws\\n"
|
||||
143
.github/labeler.yml
vendored
143
.github/labeler.yml
vendored
@@ -1,100 +1,43 @@
|
||||
apps:guide:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- apps/guide/*
|
||||
- apps/guide/**/*
|
||||
apps:website:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- apps/website/*
|
||||
- apps/website/**/*
|
||||
packages:api-extractor:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/api-extractor/*
|
||||
- packages/api-extractor/**/*
|
||||
packages:api-extractor-model:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/api-extractor-model/*
|
||||
- packages/api-extractor-model/**/*
|
||||
packages:brokers:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/brokers/*
|
||||
- packages/brokers/**/*
|
||||
packages:builders:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/builders/*
|
||||
- packages/builders/**/*
|
||||
packages:collection:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/collection/*
|
||||
- packages/collection/**/*
|
||||
packages:core:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/core/*
|
||||
- packages/core/**/*
|
||||
packages:create-discord-bot:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/create-discord-bot/*
|
||||
- packages/create-discord-bot/**/*
|
||||
packages:discord.js:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/discord.js/*
|
||||
- packages/discord.js/**/*
|
||||
packages:docgen:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/docgen/*
|
||||
- packages/docgen/**/*
|
||||
packages:formatters:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/formatters/*
|
||||
- packages/formatters/**/*
|
||||
packages:next:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/next/*
|
||||
- packages/next/**/*
|
||||
packages:proxy:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/proxy/*
|
||||
- packages/proxy/**/*
|
||||
packages:proxy-container:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/proxy-container/*
|
||||
- packages/proxy-container/**/*
|
||||
packages:rest:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/rest/*
|
||||
- packages/rest/**/*
|
||||
packages:ui:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/ui/*
|
||||
- packages/ui/**/*
|
||||
packages:util:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/util/*
|
||||
- packages/util/**/*
|
||||
packages:voice:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/voice/*
|
||||
- packages/voice/**/*
|
||||
packages:ws:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- packages/ws/*
|
||||
- packages/ws/**/*
|
||||
chore:
|
||||
- any: ['*']
|
||||
all: ['!packages/*', '!packages/**/*']
|
||||
|
||||
'packages:builders':
|
||||
- packages/builders/*
|
||||
- packages/builders/**/*
|
||||
|
||||
'packages:collection':
|
||||
- packages/collection/*
|
||||
- packages/collection/**/*
|
||||
|
||||
'packages:discord.js':
|
||||
- packages/discord.js/*
|
||||
- packages/discord.js/**/*
|
||||
|
||||
'packages:docgen':
|
||||
- packages/docgen/*
|
||||
- packages/docgen/**/*
|
||||
|
||||
'packages:proxy':
|
||||
- packages/proxy/*
|
||||
- packages/proxy/**/*
|
||||
|
||||
'packages:proxy-container':
|
||||
- packages/proxy-container/*
|
||||
- packages/proxy-container/**/*
|
||||
|
||||
'packages:rest':
|
||||
- packages/rest/*
|
||||
- packages/rest/**/*
|
||||
|
||||
'packages:voice':
|
||||
- packages/voice/*
|
||||
- packages/voice/**/*
|
||||
|
||||
'packages:website':
|
||||
- packages/website/*
|
||||
- packages/website/**/*
|
||||
|
||||
'packages:ws':
|
||||
- packages/ws/*
|
||||
- packages/ws/**/*
|
||||
|
||||
218
.github/labels.yml
vendored
218
.github/labels.yml
vendored
@@ -1,124 +1,102 @@
|
||||
- name: api changes
|
||||
- name: 'api changes'
|
||||
color: '5663e9'
|
||||
- name: api support
|
||||
- name: 'api support'
|
||||
color: '5663e9'
|
||||
- name: apps:guide
|
||||
color: fbca04
|
||||
- name: apps:website
|
||||
color: fbca04
|
||||
- name: backlog
|
||||
color: 7ef7ef
|
||||
- name: backport
|
||||
color: 88aabb
|
||||
- name: blocked
|
||||
color: fc1423
|
||||
- name: bug
|
||||
color: d73a4a
|
||||
- name: caching
|
||||
color: 80c042
|
||||
- name: chore
|
||||
color: ffffff
|
||||
- name: ci
|
||||
color: 0075ca
|
||||
- name: dependencies
|
||||
color: 276bd1
|
||||
- name: discord
|
||||
- name: 'backlog'
|
||||
color: '7ef7ef'
|
||||
- name: 'blocked'
|
||||
color: 'fc1423'
|
||||
- name: 'bug'
|
||||
color: 'd73a4a'
|
||||
- name: 'caching'
|
||||
color: '80c042'
|
||||
- name: 'chore'
|
||||
color: 'ffffff'
|
||||
- name: 'ci'
|
||||
color: '0075ca'
|
||||
- name: 'dependencies'
|
||||
color: '276bd1'
|
||||
- name: 'discussion'
|
||||
color: 'b6b1f9'
|
||||
- name: 'discord'
|
||||
color: '5663e9'
|
||||
- name: discussion
|
||||
color: b6b1f9
|
||||
- name: documentation
|
||||
color: 0075ca
|
||||
- name: duplicate
|
||||
color: cfd3d7
|
||||
- name: error handling
|
||||
color: 80c042
|
||||
- name: feature request
|
||||
color: fcf95a
|
||||
- name: gateway
|
||||
color: 80c042
|
||||
- name: good first issue
|
||||
color: 7057ff
|
||||
- name: has PR
|
||||
color: 4b1f8e
|
||||
- name: help wanted
|
||||
- name: 'documentation'
|
||||
color: '0075ca'
|
||||
- name: 'duplicate'
|
||||
color: 'cfd3d7'
|
||||
- name: 'error handling'
|
||||
color: '80c042'
|
||||
- name: 'feature request'
|
||||
color: 'fcf95a'
|
||||
- name: 'gateway'
|
||||
color: '80c042'
|
||||
- name: 'good first issue'
|
||||
color: '7057ff'
|
||||
- name: 'has PR'
|
||||
color: '4b1f8e'
|
||||
- name: 'help wanted'
|
||||
color: '008672'
|
||||
- name: in progress
|
||||
color: ffccd7
|
||||
- name: in review
|
||||
color: aed5fc
|
||||
- name: interactions
|
||||
color: 80c042
|
||||
- name: invalid
|
||||
color: e4e669
|
||||
- name: need repro
|
||||
color: c66037
|
||||
- name: packages:api-extractor
|
||||
color: fbca04
|
||||
- name: packages:api-extractor-model
|
||||
color: fbca04
|
||||
- name: packages:brokers
|
||||
color: fbca04
|
||||
- name: packages:builders
|
||||
color: fbca04
|
||||
- name: packages:collection
|
||||
color: fbca04
|
||||
- name: packages:core
|
||||
color: fbca04
|
||||
- name: packages:create-discord-bot
|
||||
color: fbca04
|
||||
- name: packages:discord.js
|
||||
color: fbca04
|
||||
- name: packages:docgen
|
||||
color: fbca04
|
||||
- name: packages:formatters
|
||||
color: fbca04
|
||||
- name: packages:next
|
||||
color: fbca04
|
||||
- name: packages:proxy
|
||||
color: fbca04
|
||||
- name: packages:proxy-container
|
||||
color: fbca04
|
||||
- name: packages:rest
|
||||
color: fbca04
|
||||
- name: packages:ui
|
||||
color: fbca04
|
||||
- name: packages:util
|
||||
color: fbca04
|
||||
- name: packages:voice
|
||||
color: fbca04
|
||||
- name: packages:ws
|
||||
color: fbca04
|
||||
- name: performance
|
||||
color: 80c042
|
||||
- name: permissions
|
||||
color: 80c042
|
||||
- name: priority:high
|
||||
color: fc1423
|
||||
- name: question (please use Discord instead)
|
||||
color: d876e3
|
||||
- name: ratelimits
|
||||
color: 80c042
|
||||
- name: refactor
|
||||
color: 1d637f
|
||||
- name: regression
|
||||
color: ea8785
|
||||
- name: REST
|
||||
color: 80c042
|
||||
- name: semver:major
|
||||
color: c10f47
|
||||
- name: semver:minor
|
||||
color: e4f486
|
||||
- name: semver:patch
|
||||
color: e8be8b
|
||||
- name: sharding
|
||||
color: 80c042
|
||||
- name: tests
|
||||
color: f06dff
|
||||
- name: threads
|
||||
color: 80c042
|
||||
- name: typings
|
||||
color: 80c042
|
||||
- name: utility
|
||||
color: 80c042
|
||||
- name: wontfix
|
||||
color: ffffff
|
||||
- name: 'interactions'
|
||||
color: '80c042'
|
||||
- name: 'in progress'
|
||||
color: 'ffccd7'
|
||||
- name: 'in review'
|
||||
color: 'aed5fc'
|
||||
- name: 'invalid'
|
||||
color: 'e4e669'
|
||||
- name: 'need repro'
|
||||
color: 'c66037'
|
||||
- name: 'packages:builders'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:collection'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:discord.js'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:docgen'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:proxy'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:proxy-container'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:rest'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:voice'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:website'
|
||||
color: 'fbca04'
|
||||
- name: 'packages:ws'
|
||||
color: 'fbca04'
|
||||
- name: 'performance'
|
||||
color: '80c042'
|
||||
- name: 'permissions'
|
||||
color: '80c042'
|
||||
- name: 'priority:high'
|
||||
color: 'fc1423'
|
||||
- name: 'question (please use Discord instead)'
|
||||
color: 'd876e3'
|
||||
- name: 'ratelimits'
|
||||
color: '80c042'
|
||||
- name: 'refactor'
|
||||
color: '1d637f'
|
||||
- name: 'regression'
|
||||
color: 'ea8785'
|
||||
- name: 'REST'
|
||||
color: '80c042'
|
||||
- name: 'semver:major'
|
||||
color: 'c10f47'
|
||||
- name: 'semver:minor'
|
||||
color: 'e4f486'
|
||||
- name: 'semver:patch'
|
||||
color: 'e8be8b'
|
||||
- name: 'sharding'
|
||||
color: '80c042'
|
||||
- name: 'tests'
|
||||
color: 'f06dff'
|
||||
- name: 'threads'
|
||||
color: '80c042'
|
||||
- name: 'typings'
|
||||
color: '80c042'
|
||||
- name: 'utility'
|
||||
color: '80c042'
|
||||
- name: 'wontfix'
|
||||
color: 'ffffff'
|
||||
|
||||
BIN
.github/powered-by-workers.png
vendored
BIN
.github/powered-by-workers.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
35
.github/workflows/cleanup-cache.yml
vendored
35
.github/workflows/cleanup-cache.yml
vendored
@@ -1,35 +0,0 @@
|
||||
# https://docs.github.com/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
|
||||
name: Cleanup caches
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
cleanup:
|
||||
name: Cleanup caches
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cleanup caches
|
||||
run: |
|
||||
gh extension install actions/gh-actions-cache
|
||||
|
||||
REPO=${{ github.repository }}
|
||||
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
|
||||
|
||||
echo "Fetching list of cache key"
|
||||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
|
||||
|
||||
## Setting this to not fail the workflow while deleting cache keys.
|
||||
set +e
|
||||
echo "Deleting caches..."
|
||||
for cacheKey in $cacheKeysForPR
|
||||
do
|
||||
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
|
||||
done
|
||||
echo "Done"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
50
.github/workflows/deprecate-version.yml
vendored
50
.github/workflows/deprecate-version.yml
vendored
@@ -1,50 +0,0 @@
|
||||
name: Deprecate version
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
package:
|
||||
description: Package
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- '@discordjs/brokers'
|
||||
- '@discordjs/builders'
|
||||
- '@discordjs/collection'
|
||||
- '@discordjs/core'
|
||||
- 'create-discord-bot'
|
||||
- '@discordjs/formatters'
|
||||
- 'discord.js'
|
||||
- '@discordjs/next'
|
||||
- '@discordjs/proxy'
|
||||
- '@discordjs/rest'
|
||||
- '@discordjs/util'
|
||||
- '@discordjs/voice'
|
||||
- '@discordjs/ws'
|
||||
version:
|
||||
description: Version(s)
|
||||
required: true
|
||||
type: string
|
||||
message:
|
||||
description: Deprecation message
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
deprecate:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
|
||||
- name: Deprecate
|
||||
run: pnpm exec npm-deprecate --name "${{inputs.version}}" --message "${{inputs.message || 'This version is deprecated. Please use a newer version.'}}" --package ${{inputs.package}}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||
323
.github/workflows/documentation.yml
vendored
323
.github/workflows/documentation.yml
vendored
@@ -3,11 +3,8 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
paths:
|
||||
- 'packages/*/src/**'
|
||||
- '!packages/create-discord-bot/**'
|
||||
- '!packages/proxy-container/**'
|
||||
- '!packages/ui/**'
|
||||
- 'stable'
|
||||
- '!docs'
|
||||
tags:
|
||||
- '**'
|
||||
workflow_dispatch:
|
||||
@@ -15,230 +12,134 @@ on:
|
||||
ref:
|
||||
description: 'The branch, tag or SHA to checkout'
|
||||
required: true
|
||||
ref_type:
|
||||
type: choice
|
||||
description: 'Branch or tag'
|
||||
options:
|
||||
- branch
|
||||
- tag
|
||||
required: true
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
build-docs:
|
||||
name: Build & upload documentation
|
||||
build:
|
||||
name: Build documentation
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
REF_TYPE: ${{ inputs.ref_type || github.ref_type }}
|
||||
if: github.repository_owner == 'discordjs'
|
||||
outputs:
|
||||
BRANCH_NAME: ${{ steps.env.outputs.BRANCH_NAME }}
|
||||
BRANCH_OR_TAG: ${{ steps.env.outputs.BRANCH_OR_TAG }}
|
||||
SHA: ${{ steps.env.outputs.SHA }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.ref || '' }}
|
||||
ref: ${{ github.event.inputs.ref || '' }}
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
- name: Install node.js v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
run: yarn --immutable
|
||||
|
||||
- name: Build dependencies
|
||||
run: pnpm run build
|
||||
|
||||
- name: Checkout main repository
|
||||
if: ${{ inputs.ref && inputs.ref != 'main' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: 'main'
|
||||
|
||||
- name: Build main
|
||||
if: ${{ inputs.ref && inputs.ref != 'main' }}
|
||||
shell: bash
|
||||
run: |
|
||||
cd main
|
||||
pnpm install --frozen-lockfile --prefer-offline --loglevel error
|
||||
pnpm run build
|
||||
cd ..
|
||||
|
||||
- name: Extract package and semver from tag
|
||||
if: ${{ env.REF_TYPE == 'tag' }}
|
||||
id: extract-tag
|
||||
uses: ./packages/actions/src/formatTag
|
||||
with:
|
||||
tag: ${{ inputs.ref || github.ref_name }}
|
||||
|
||||
- name: Apply tag to api-extractor config
|
||||
if: ${{ env.REF_TYPE == 'tag' && !inputs.ref }}
|
||||
run: sed -i 's!https://github.com/discordjs/discord.js/tree/main!https://github.com/discordjs/discord.js/tree/${{ github.ref_name }}!' "packages/${{ steps.extract-tag.outputs.package}}/api-extractor.json"
|
||||
run: yarn build
|
||||
|
||||
- name: Build docs
|
||||
run: pnpm run docs
|
||||
run: yarn docs
|
||||
|
||||
- name: Build docs with main api-extractor
|
||||
if: ${{ inputs.ref && inputs.ref != 'main' }}
|
||||
- name: Upload docgen artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: docgen
|
||||
path: packages/*/docs/docs.json
|
||||
|
||||
- name: Upload api-extractor artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: api-extractor
|
||||
path: packages/*/docs/docs.api.json
|
||||
|
||||
- name: Set outputs for upload job
|
||||
id: env
|
||||
run: |
|
||||
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "formatters" "next" "proxy" "rest" "util" "voice" "ws")
|
||||
for PACKAGE in "${PACKAGES[@]}"; do
|
||||
cd "packages/${PACKAGE}"
|
||||
sed -i 's!https://github.com/discordjs/discord.js/tree/main!https://github.com/discordjs/discord.js/tree/${{ inputs.ref }}!' api-extractor.json
|
||||
../../main/packages/api-extractor/bin/api-extractor run --local --minify
|
||||
../../main/packages/scripts/bin/generateSplitDocumentation.js
|
||||
cd ../..
|
||||
done
|
||||
echo "::set-output name=BRANCH_NAME::${GITHUB_REF_NAME}"
|
||||
echo "::set-output name=BRANCH_OR_TAG::${GITHUB_REF_TYPE}"
|
||||
echo "::set-output name=SHA::${GITHUB_SHA}"
|
||||
|
||||
upload:
|
||||
name: Upload Documentation
|
||||
needs: build
|
||||
strategy:
|
||||
max-parallel: 1
|
||||
fail-fast: false
|
||||
matrix:
|
||||
package: ['builders', 'collection', 'discord.js', 'proxy', 'rest', 'voice', 'ws']
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BRANCH_NAME: ${{ github.event.inputs.ref || needs.build.outputs.BRANCH_NAME }}
|
||||
BRANCH_OR_TAG: ${{ needs.build.outputs.BRANCH_OR_TAG }}
|
||||
SHA: ${{ needs.build.outputs.SHA }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install node.js v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn --immutable
|
||||
|
||||
- name: Build actions
|
||||
run: yarn build
|
||||
|
||||
- name: Download docgen artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: docgen
|
||||
path: docs
|
||||
|
||||
- name: Download api-extractor artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: api-extractor
|
||||
path: docs
|
||||
|
||||
- name: Checkout docs repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: 'discordjs/docs'
|
||||
token: ${{ secrets.DJS_DOCS }}
|
||||
path: 'out'
|
||||
|
||||
- name: Upload documentation to database
|
||||
if: ${{ env.REF_TYPE == 'tag' && (!inputs.ref || inputs.ref == 'main') }}
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
CF_D1_DOCS_API_KEY: ${{ secrets.CF_D1_DOCS_API_KEY }}
|
||||
CF_D1_DOCS_ID: ${{ secrets.CF_D1_DOCS_ID }}
|
||||
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
CF_R2_DOCS_BUCKET_URL: ${{ secrets.CF_R2_DOCS_BUCKET_URL }}
|
||||
uses: ./packages/actions/src/uploadDocumentation
|
||||
- name: Extract package and semver from tag
|
||||
if: ${{ github.event.inputs.ref || env.BRANCH_OR_TAG == 'tag' }}
|
||||
id: extract-tag
|
||||
uses: ./packages/actions/src/formatTag
|
||||
with:
|
||||
package: ${{ steps.extract-tag.outputs.package }}
|
||||
version: ${{ steps.extract-tag.outputs.semver }}
|
||||
|
||||
- name: Upload documentation to database
|
||||
if: ${{ env.REF_TYPE == 'tag' && inputs.ref && inputs.ref != 'main' }}
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
CF_D1_DOCS_API_KEY: ${{ secrets.CF_D1_DOCS_API_KEY }}
|
||||
CF_D1_DOCS_ID: ${{ secrets.CF_D1_DOCS_ID }}
|
||||
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
CF_R2_DOCS_BUCKET_URL: ${{ secrets.CF_R2_DOCS_BUCKET_URL }}
|
||||
uses: ./main/packages/actions/src/uploadDocumentation
|
||||
with:
|
||||
package: ${{ steps.extract-tag.outputs.package }}
|
||||
version: ${{ steps.extract-tag.outputs.semver }}
|
||||
|
||||
- name: Upload split documentation to blob storage
|
||||
if: ${{ env.REF_TYPE == 'tag' && (!inputs.ref || inputs.ref == 'main') }}
|
||||
env:
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
uses: ./packages/actions/src/uploadSplitDocumentation
|
||||
with:
|
||||
package: ${{ steps.extract-tag.outputs.package }}
|
||||
version: ${{ steps.extract-tag.outputs.semver }}
|
||||
|
||||
- name: Upload split documentation to blob storage
|
||||
if: ${{ env.REF_TYPE == 'tag' && inputs.ref && inputs.ref != 'main' }}
|
||||
env:
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
uses: ./main/packages/actions/src/uploadSplitDocumentation
|
||||
with:
|
||||
package: ${{ steps.extract-tag.outputs.package }}
|
||||
version: ${{ steps.extract-tag.outputs.semver }}
|
||||
tag: ${{ env.BRANCH_NAME }}
|
||||
|
||||
- name: Move docs to correct directory
|
||||
if: ${{ env.REF_TYPE == 'tag' }}
|
||||
if: ${{ (github.event.inputs.ref || env.BRANCH_OR_TAG == 'tag') && matrix.package == steps.extract-tag.outputs.package }}
|
||||
env:
|
||||
PACKAGE: ${{ steps.extract-tag.outputs.package }}
|
||||
SEMVER: ${{ steps.extract-tag.outputs.semver }}
|
||||
run: |
|
||||
mkdir -p "out/${PACKAGE}"
|
||||
if [[ "${PACKAGE}" == "discord.js" ]]; then
|
||||
mv "packages/${PACKAGE}/docs/docs.json" "out/${PACKAGE}/${SEMVER}.json"
|
||||
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${SEMVER}.api.json"
|
||||
else
|
||||
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${SEMVER}.api.json"
|
||||
mkdir -p out/${PACKAGE}
|
||||
mv docs/${PACKAGE}/docs/docs.json out/${PACKAGE}/${SEMVER}.json
|
||||
if [[ $PACKAGE != "discord.js" ]]; then
|
||||
mv docs/${PACKAGE}/docs/docs.api.json out/${PACKAGE}/${SEMVER}.api.json
|
||||
fi
|
||||
|
||||
- name: Upload documentation to database
|
||||
if: ${{ env.REF_TYPE == 'branch' && (!inputs.ref || inputs.ref == 'main') }}
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
CF_D1_DOCS_API_KEY: ${{ secrets.CF_D1_DOCS_API_KEY }}
|
||||
CF_D1_DOCS_ID: ${{ secrets.CF_D1_DOCS_ID }}
|
||||
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
CF_R2_DOCS_BUCKET_URL: ${{ secrets.CF_R2_DOCS_BUCKET_URL }}
|
||||
uses: ./packages/actions/src/uploadDocumentation
|
||||
|
||||
- name: Upload documentation to database
|
||||
if: ${{ env.REF_TYPE == 'branch' && inputs.ref && inputs.ref != 'main' }}
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
CF_D1_DOCS_API_KEY: ${{ secrets.CF_D1_DOCS_API_KEY }}
|
||||
CF_D1_DOCS_ID: ${{ secrets.CF_D1_DOCS_ID }}
|
||||
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
CF_R2_DOCS_BUCKET_URL: ${{ secrets.CF_R2_DOCS_BUCKET_URL }}
|
||||
uses: ./main/packages/actions/src/uploadDocumentation
|
||||
|
||||
- name: Upload split documentation to blob storage
|
||||
if: ${{ env.REF_TYPE == 'branch' && (!inputs.ref || inputs.ref == 'main') }}
|
||||
env:
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
uses: ./packages/actions/src/uploadSplitDocumentation
|
||||
|
||||
- name: Upload split documentation to blob storage
|
||||
if: ${{ env.REF_TYPE == 'branch' && inputs.ref && inputs.ref != 'main' }}
|
||||
env:
|
||||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
|
||||
CF_R2_DOCS_URL: ${{ secrets.CF_R2_DOCS_URL }}
|
||||
CF_R2_DOCS_ACCESS_KEY_ID: ${{ secrets.CF_R2_DOCS_ACCESS_KEY_ID }}
|
||||
CF_R2_DOCS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_DOCS_SECRET_ACCESS_KEY }}
|
||||
CF_R2_DOCS_BUCKET: ${{ secrets.CF_R2_DOCS_BUCKET }}
|
||||
uses: ./main/packages/actions/src/uploadSplitDocumentation
|
||||
|
||||
- name: Move docs to correct directory
|
||||
if: ${{ env.REF_TYPE == 'branch' }}
|
||||
if: ${{ !github.event.inputs.ref && env.BRANCH_OR_TAG == 'branch' }}
|
||||
env:
|
||||
PACKAGE: ${{ matrix.package }}
|
||||
run: |
|
||||
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "formatters" "next" "proxy" "rest" "util" "voice" "ws")
|
||||
for PACKAGE in "${PACKAGES[@]}"; do
|
||||
if [[ "${PACKAGE}" == "discord.js" ]]; then
|
||||
mkdir -p "out/${PACKAGE}"
|
||||
mv "packages/${PACKAGE}/docs/docs.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.json"
|
||||
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.api.json"
|
||||
else
|
||||
mkdir -p "out/${PACKAGE}"
|
||||
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.api.json"
|
||||
fi
|
||||
done
|
||||
mkdir -p out/${PACKAGE}
|
||||
mv docs/${PACKAGE}/docs/docs.json out/${PACKAGE}/${BRANCH_NAME}.json
|
||||
if [[ $PACKAGE != "discord.js" ]]; then
|
||||
mv docs/${PACKAGE}/docs/docs.api.json out/${PACKAGE}/${BRANCH_NAME}.api.json
|
||||
fi
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
@@ -246,35 +147,5 @@ jobs:
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||
git add .
|
||||
git commit -m "Docs build for ${GITHUB_REF_TYPE} ${GITHUB_REF_NAME}: ${GITHUB_SHA}" || true
|
||||
git commit -m "Docs build for ${BRANCH_OR_TAG} ${BRANCH_NAME}: ${SHA}" || true
|
||||
git push
|
||||
|
||||
build-indices:
|
||||
needs: build-docs
|
||||
name: Build & upload search indices
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
|
||||
- name: Build dependencies
|
||||
run: pnpm run build
|
||||
|
||||
- name: Upload search indices to meilisearch
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }}
|
||||
SEARCH_API_KEY: ${{ secrets.SEARCH_API_KEY }}
|
||||
uses: ./packages/actions/src/uploadSearchIndices
|
||||
|
||||
14
.github/workflows/issue-triage.yml
vendored
14
.github/workflows/issue-triage.yml
vendored
@@ -1,14 +0,0 @@
|
||||
name: 'Issue Labeler'
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
jobs:
|
||||
issue-triage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: github/issue-labeler@v3.4
|
||||
with:
|
||||
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||
configuration-path: .github/issue-labeler.yml
|
||||
not-before: 2023-01-13T10:25:03.847Z
|
||||
enable-versioned-regex: 0
|
||||
4
.github/workflows/label-sync.yml
vendored
4
.github/workflows/label-sync.yml
vendored
@@ -15,9 +15,9 @@ jobs:
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Label sync
|
||||
uses: crazy-max/ghaction-github-labeler@v5
|
||||
uses: crazy-max/ghaction-github-labeler@v4
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
19
.github/workflows/lock.yml
vendored
19
.github/workflows/lock.yml
vendored
@@ -1,19 +0,0 @@
|
||||
name: Lock Ancient Issues
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 16 * * *'
|
||||
workflow_dispatch:
|
||||
concurrency:
|
||||
group: lock
|
||||
jobs:
|
||||
action:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-inactive-days: 365
|
||||
issue-lock-reason: resolved
|
||||
process-only: issues
|
||||
28
.github/workflows/npm-auto-deprecate.yml
vendored
Normal file
28
.github/workflows/npm-auto-deprecate.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: npm auto deprecate
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 1 * * *'
|
||||
jobs:
|
||||
npm-auto-deprecate:
|
||||
name: npm auto deprecate
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install node.js v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn --immutable
|
||||
|
||||
- name: Deprecate versions
|
||||
run: 'yarn npm-deprecate --name "*dev*" --package @discordjs/builders @discordjs/collection discord.js @discordjs/proxy @discordjs/rest @discordjs/voice'
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||
32
.github/workflows/pr-triage.yml
vendored
32
.github/workflows/pr-triage.yml
vendored
@@ -1,35 +1,17 @@
|
||||
name: 'PR Triage'
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
- reopened
|
||||
- synchronize
|
||||
jobs:
|
||||
label:
|
||||
name: Label
|
||||
if: github.event.action != 'edited'
|
||||
pr-triage:
|
||||
name: PR Triage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Label pull request
|
||||
uses: actions/labeler@v5
|
||||
- name: Automatically label PR
|
||||
uses: actions/labeler@v4
|
||||
with:
|
||||
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||
sync-labels: true
|
||||
validate-title:
|
||||
name: Validate title
|
||||
if: github.event.action != 'synchronize'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Validate pull request title
|
||||
env:
|
||||
TITLE: ${{ github.event.pull_request.title }}
|
||||
run: |
|
||||
REGEX="^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore|types)(\\(.+\\))?!?: .{1,72}$"
|
||||
|
||||
echo "Title: \"$TITLE\""
|
||||
|
||||
if [[ ! "$TITLE" =~ $REGEX ]]; then
|
||||
exit 1
|
||||
fi
|
||||
- name: Automatically assign reviewers
|
||||
if: github.event.action == 'opened'
|
||||
uses: kentaro-m/auto-assign-action@v1.2.1
|
||||
|
||||
21
.github/workflows/publish-dev-docker.yml
vendored
21
.github/workflows/publish-dev-docker.yml
vendored
@@ -1,8 +1,8 @@
|
||||
name: Publish dev docker images
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 */12 * * *'
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
docker-publish:
|
||||
name: Docker publish
|
||||
@@ -10,21 +10,16 @@ jobs:
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||
|
||||
- name: Build & push docker image
|
||||
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:latest --push .
|
||||
- name: Build the image
|
||||
run: docker build -t discordjs/proxy:latest -f packages/proxy-container/Dockerfile .
|
||||
|
||||
- name: Push image to DockerHub
|
||||
run: docker push discordjs/proxy:latest
|
||||
|
||||
56
.github/workflows/publish-dev.yml
vendored
56
.github/workflows/publish-dev.yml
vendored
@@ -1,8 +1,8 @@
|
||||
name: Publish dev
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 */12 * * *'
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
npm-publish:
|
||||
name: npm publish
|
||||
@@ -10,75 +10,43 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- package: '@discordjs/brokers'
|
||||
folder: 'brokers'
|
||||
- package: '@discordjs/builders'
|
||||
folder: 'builders'
|
||||
- package: '@discordjs/collection'
|
||||
folder: 'collection'
|
||||
- package: '@discordjs/core'
|
||||
folder: 'core'
|
||||
- package: '@discordjs/formatters'
|
||||
folder: 'formatters'
|
||||
- package: 'discord.js'
|
||||
folder: 'discord.js'
|
||||
- package: '@discordjs/next'
|
||||
folder: 'next'
|
||||
- package: '@discordjs/proxy'
|
||||
folder: 'proxy'
|
||||
- package: '@discordjs/rest'
|
||||
folder: 'rest'
|
||||
- package: '@discordjs/util'
|
||||
folder: 'util'
|
||||
- package: '@discordjs/voice'
|
||||
folder: 'voice'
|
||||
- package: '@discordjs/ws'
|
||||
folder: 'ws'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
- name: Install node.js v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 16
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- name: Check the current development version
|
||||
id: release-check
|
||||
run: |
|
||||
if [[ $(npm view ${{ matrix.package }}@dev version | grep -e "$(git rev-parse --short HEAD)") ]]; \
|
||||
then echo "RELEASE=0" >> "$GITHUB_OUTPUT"; \
|
||||
else echo "RELEASE=1" >> "$GITHUB_OUTPUT"; \
|
||||
fi
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.release-check.outputs.release == '1'
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
run: yarn --immutable
|
||||
|
||||
- name: Build dependencies
|
||||
if: steps.release-check.outputs.release == '1'
|
||||
run: pnpm run build
|
||||
run: yarn build
|
||||
|
||||
- name: Publish package
|
||||
if: steps.release-check.outputs.release == '1'
|
||||
run: |
|
||||
pnpm --filter=${{ matrix.package }} run release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)" --skip-changelog
|
||||
pnpm --filter=${{ matrix.package }} publish --provenance --no-git-checks --tag dev || true
|
||||
yarn workspace ${{ matrix.package }} release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)"
|
||||
yarn workspace ${{ matrix.package }} npm publish --tag dev || true
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||
|
||||
- name: Deprecate prior development releases
|
||||
if: steps.release-check.outputs.release == '1'
|
||||
run: pnpm exec npm-deprecate --name "*dev*" --message "This version is deprecated. Please use a newer version." --package ${{ matrix.package }}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||
|
||||
22
.github/workflows/publish-docker.yml
vendored
22
.github/workflows/publish-docker.yml
vendored
@@ -7,21 +7,19 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||
|
||||
- name: Build & push docker image
|
||||
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push .
|
||||
- name: Build docker image
|
||||
run: docker build -t discordjs/proxy:latest -f packages/proxy-container/Dockerfile .
|
||||
|
||||
- name: Tag image with major
|
||||
run: docker tag discordjs/proxy discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json))
|
||||
|
||||
- name: Push image to DockerHub
|
||||
run: docker push --all-tags discordjs/proxy
|
||||
|
||||
41
.github/workflows/publish-release.yml
vendored
41
.github/workflows/publish-release.yml
vendored
@@ -1,41 +0,0 @@
|
||||
name: Publish Release
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
jobs:
|
||||
npm-publish:
|
||||
name: npm publish
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
|
||||
- name: Build dependencies
|
||||
run: pnpm run build
|
||||
|
||||
- name: Extract package and semver from tag
|
||||
id: extract-tag
|
||||
uses: ./packages/actions/src/formatTag
|
||||
with:
|
||||
tag: ${{ github.ref_name }}
|
||||
|
||||
- name: Publish package
|
||||
run: |
|
||||
pnpm --filter=${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} publish --provenance --no-git-checks
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||
64
.github/workflows/tests.yml
vendored
64
.github/workflows/tests.yml
vendored
@@ -1,66 +1,32 @@
|
||||
name: Tests
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
concurrency:
|
||||
# Group based on workflow name and PR if it exists, if no PR, let it run so carryforward flags work
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
tests:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node.js v20
|
||||
uses: actions/setup-node@v4
|
||||
- name: Install node.js v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
run: yarn --immutable
|
||||
|
||||
- name: Build dependencies (PR)
|
||||
if: ${{ github.event_name != 'push' }}
|
||||
run: pnpm exec turbo run build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
|
||||
- name: Build dependencies
|
||||
run: yarn build
|
||||
|
||||
- name: Build dependencies (Push)
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
run: pnpm exec turbo run build --filter="...[HEAD^1]" --concurrency=4
|
||||
- name: ESLint
|
||||
run: yarn lint
|
||||
|
||||
- name: Tests (PR)
|
||||
if: ${{ github.event_name != 'push' }}
|
||||
run: pnpm exec turbo run test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
|
||||
|
||||
- name: Tests (Push)
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
run: pnpm exec turbo run test --filter="...[HEAD^1]" --concurrency=4
|
||||
|
||||
- name: ESLint (PR)
|
||||
if: ${{ github.event_name != 'push' }}
|
||||
run: pnpm exec turbo run lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4 -- --format=compact
|
||||
|
||||
- name: ESLint (Push)
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
run: pnpm exec turbo run lint --filter="...[HEAD^1]" --concurrency=4 -- --format=compact
|
||||
|
||||
- name: Docs (PR)
|
||||
if: ${{ github.event_name != 'push' }}
|
||||
run: pnpm exec turbo run docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
|
||||
|
||||
- name: Docs (Push)
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
run: pnpm exec turbo run docs --filter="...[HEAD^1]" --concurrency=4
|
||||
- name: Tests
|
||||
run: yarn test
|
||||
|
||||
- name: Upload Coverage
|
||||
if: github.repository_owner == 'discordjs'
|
||||
uses: ./packages/actions/src/uploadCoverage
|
||||
with:
|
||||
codecov_token: ${{ secrets.CODECOV_TOKEN }}
|
||||
if: github.repository_owner == 'discordjs'
|
||||
|
||||
26
.gitignore
vendored
26
.gitignore
vendored
@@ -1,8 +1,8 @@
|
||||
# Packages
|
||||
node_modules
|
||||
node_modules/
|
||||
|
||||
# Log files
|
||||
logs
|
||||
logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
@@ -15,29 +15,18 @@ pids
|
||||
.env
|
||||
|
||||
# Dist
|
||||
dist
|
||||
dist-docs
|
||||
dist/
|
||||
|
||||
# Miscellaneous
|
||||
.tmp
|
||||
.tmp/
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
!.vscode/settings.json
|
||||
.idea
|
||||
.idea/
|
||||
.DS_Store
|
||||
.turbo
|
||||
tsconfig.tsbuildinfo
|
||||
coverage
|
||||
out
|
||||
package.tgz
|
||||
tsup.config.bundled*
|
||||
vitest.config.ts.timestamp*
|
||||
|
||||
# Deno
|
||||
deno.lock
|
||||
|
||||
# Bun
|
||||
bun.lockb
|
||||
coverage/
|
||||
|
||||
# yarn
|
||||
.pnp.*
|
||||
@@ -50,5 +39,4 @@ bun.lockb
|
||||
|
||||
# Cache
|
||||
.prettiercache
|
||||
.eslintcache
|
||||
.vercel
|
||||
.eslintcache
|
||||
@@ -1 +1,4 @@
|
||||
pnpm exec commitlint --edit $1
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn commitlint --edit $1
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
pnpm run build:affected && pnpm exec lint-staged
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn build && yarn lint-staged
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/lintstagedrc.schema.json",
|
||||
"*": "prettier --ignore-unknown --write",
|
||||
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --fix",
|
||||
"src/**.ts": "vitest related --run --config ../../vitest.config.ts"
|
||||
"{src/**,__tests__/**}.{mjs,js,ts}": "eslint --ext mjs,js,ts --fix",
|
||||
"src/**.ts": "vitest related"
|
||||
}
|
||||
|
||||
6
.npmrc
6
.npmrc
@@ -1,6 +0,0 @@
|
||||
auto-install-peers=false
|
||||
resolution-mode=highest
|
||||
public-hoist-pattern[]=*eslint*
|
||||
public-hoist-pattern[]=*prettier*
|
||||
public-hoist-pattern[]=*@rushstack/node-core-library*
|
||||
public-hoist-pattern[]=*jju*
|
||||
@@ -1,5 +0,0 @@
|
||||
CODEOWNERS
|
||||
CHANGELOG.md
|
||||
tsup.config.bundled*
|
||||
vitest.config.ts.timestamp*
|
||||
pnpm-lock.yaml
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/prettierrc.json",
|
||||
"printWidth": 120,
|
||||
"useTabs": true,
|
||||
"singleQuote": true,
|
||||
|
||||
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
@@ -8,6 +8,6 @@
|
||||
"eamodio.gitlens",
|
||||
"christian-kohler.npm-intellisense",
|
||||
"christian-kohler.path-intellisense",
|
||||
"unifiedjs.vscode-mdx"
|
||||
"antfu.unocss"
|
||||
]
|
||||
}
|
||||
|
||||
30
.vscode/settings.json
vendored
30
.vscode/settings.json
vendored
@@ -1,31 +1,11 @@
|
||||
{
|
||||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
|
||||
"eslint.useFlatConfig": true,
|
||||
"eslint.workingDirectories": [{ "directory": "${workspaceFolder}" }, { "pattern": "./packages/*/" }],
|
||||
"eslint.workingDirectories": [{ "pattern": "./packages/*" }],
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": "never",
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.fixAll": "explicit"
|
||||
"source.fixAll": true,
|
||||
"source.organizeImports": false
|
||||
},
|
||||
"editor.trimAutoWhitespace": false,
|
||||
"files.associations": {
|
||||
"api-extractor.json": "jsonc",
|
||||
"api-extractor-docs.json": "jsonc",
|
||||
"tsconfig.json": "jsonc",
|
||||
"tsconfig.eslint.json": "jsonc",
|
||||
"tsconfig.docs.json": "jsonc"
|
||||
},
|
||||
"files.insertFinalNewline": true,
|
||||
"files.eol": "\n",
|
||||
"npm.packageManager": "pnpm",
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"unocss.disable": true,
|
||||
"deno.enable": false,
|
||||
"deno.enablePaths": ["./packages/create-discord-bot/template/Deno"],
|
||||
"deno.lint": false,
|
||||
"deno.unstable": [],
|
||||
"deno.config": "./packages/create-discord-bot/template/Deno/deno.jsonc"
|
||||
"unocss.root": "./packages/website",
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/lib/TSDocConfigFile.js b/lib/TSDocConfigFile.js
|
||||
index caf3515d60fd386c5909db5a0aa8b4180b10d602..6fa4f1984b6ba6b3a7aecd05e54477ebf141af94 100644
|
||||
--- a/lib/TSDocConfigFile.js
|
||||
+++ b/lib/TSDocConfigFile.js
|
||||
@@ -31,8 +31,7 @@ const ajv_1 = __importDefault(require("ajv"));
|
||||
const jju = __importStar(require("jju"));
|
||||
const ajv = new ajv_1.default({ verbose: true });
|
||||
function initializeSchemaValidator() {
|
||||
- const jsonSchemaPath = resolve.sync('@microsoft/tsdoc/schemas/tsdoc.schema.json', { basedir: __dirname });
|
||||
- const jsonSchemaContent = fs.readFileSync(jsonSchemaPath).toString();
|
||||
+ const jsonSchemaContent = "{\"title\":\"TSDoc Configuration\",\"description\":\"Describes the TSDoc configuration for a TypeScript project\",\"type\":\"object\",\"properties\":{\"$schema\":{\"description\":\"Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.\",\"type\":\"string\"},\"extends\":{\"description\":\"Optionally specifies one or more JSON config files that will be combined with this file. This provides a way for standard settings to be shared across multiple projects. Important: The \\\"extends\\\" paths are resolved using NodeJS module resolution, so a path to a local file MUST be prefixed with \\\"./\\\".\",\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"noStandardTags\":{\"description\":\"By default, the config file loader will predefine all of the standardized TSDoc tags. To disable this and start with a completely empty configuration, set \\\"noStandardTags\\\"=true.\",\"type\":\"boolean\"},\"tagDefinitions\":{\"description\":\"Additional tags to support when parsing documentation comments with TSDoc.\",\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/tsdocTagDefinition\"}},\"supportedHtmlElements\":{\"description\":\"The HTML element names that are supported in this configuration. Used in conjunction with the \\\"reportUnsupportedHtmlElements\\\" setting.\",\"type\":\"array\",\"items\":{\"type\":\"string\",\"pattern\":\"^[a-zA-Z0-9-]+$\"}},\"reportUnsupportedHtmlElements\":{\"description\":\"Whether an error should be reported when an unsupported HTML element is encountered in a doc comment. Defaults to \\\"true\\\" if the \\\"supportedHtmlElements\\\" field is present in this file, \\\"false\\\" if not.\",\"type\":\"boolean\"},\"supportForTags\":{\"description\":\"A collection of key/value pairs. The key is a TSDoc tag name (e.g. \\\"@myTag\\\") that must be defined in this configuration. The value is a boolean indicating whether the tag is supported. The TSDoc parser may report warnings when unsupported tags are encountered. If \\\"supportForTags\\\" is specified for at least one tag, then the \\\"reportUnsupportedTags\\\" validation check is enabled by default.\",\"type\":\"object\",\"patternProperties\":{\"@[a-zA-Z][a-zA-Z0-9]*$\":{\"type\":\"boolean\"}},\"additionalItems\":false}},\"required\":[\"$schema\"],\"additionalProperties\":false,\"definitions\":{\"tsdocTagDefinition\":{\"description\":\"Configuration for a custom supported TSDoc tag.\",\"type\":\"object\",\"properties\":{\"tagName\":{\"description\":\"Name of the custom tag. TSDoc tag names start with an at-sign (@) followed by ASCII letters using camelCase capitalization.\",\"type\":\"string\"},\"syntaxKind\":{\"description\":\"Syntax kind of the custom tag. \\\"inline\\\" means that this tag can appear inside other documentation sections (example: {@link}). \\\"block\\\" means that this tag starts a new documentation section (example: @remarks). \\\"modifier\\\" means that this tag's presence indicates an aspect of the associated API item (example: @internal).\",\"type\":\"string\",\"enum\":[\"inline\",\"block\",\"modifier\"]},\"allowMultiple\":{\"description\":\"If true, then this tag may appear multiple times in a doc comment. By default, a tag may only appear once.\",\"type\":\"boolean\"}},\"required\":[\"tagName\",\"syntaxKind\"],\"additionalProperties\":false}}}";
|
||||
const jsonSchema = jju.parse(jsonSchemaContent, { mode: 'cjson' });
|
||||
return ajv.compile(jsonSchema);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
diff --git a/dist/rollup-plugin-typescript2.cjs.js b/dist/rollup-plugin-typescript2.cjs.js
|
||||
index 9ab972b041cc76f8f786d6a20f3efb53c364cad6..13e056a3c0971eb18b307d91fad096a9f3b9de79 100644
|
||||
--- a/dist/rollup-plugin-typescript2.cjs.js
|
||||
+++ b/dist/rollup-plugin-typescript2.cjs.js
|
||||
@@ -29799,6 +29799,13 @@ const typescript = (options) => {
|
||||
declarations[key] = { type: result.dts, map: result.dtsmap };
|
||||
context.debug(() => `${safe.exports.blue("generated declarations")} for '${key}'`);
|
||||
}
|
||||
+ // if a user sets this compilerOption, they probably want another plugin (e.g. Babel, ESBuild) to transform their TS instead, while rpt2 just type-checks and/or outputs declarations
|
||||
+ // note that result.code is non-existent if emitDeclarationOnly per https://github.com/ezolenko/rollup-plugin-typescript2/issues/268
|
||||
+ if (parsedConfig.options.emitDeclarationOnly)
|
||||
+ {
|
||||
+ context.debug(() => `${blue("emitDeclarationOnly")} enabled, not transforming TS'`);
|
||||
+ return undefined;
|
||||
+ }
|
||||
const transformResult = { code: result.code, map: { mappings: "" } };
|
||||
if (result.map) {
|
||||
if (pluginOptions.sourceMapCallback)
|
||||
diff --git a/dist/rollup-plugin-typescript2.es.js b/dist/rollup-plugin-typescript2.es.js
|
||||
index e43bf8f03bc6792b61d8352e04bb6466712426c2..420e8f0d0d109076bc72e9d60240077235a9ba11 100644
|
||||
--- a/dist/rollup-plugin-typescript2.es.js
|
||||
+++ b/dist/rollup-plugin-typescript2.es.js
|
||||
@@ -29770,6 +29770,13 @@ const typescript = (options) => {
|
||||
declarations[key] = { type: result.dts, map: result.dtsmap };
|
||||
context.debug(() => `${safe.exports.blue("generated declarations")} for '${key}'`);
|
||||
}
|
||||
+ // if a user sets this compilerOption, they probably want another plugin (e.g. Babel, ESBuild) to transform their TS instead, while rpt2 just type-checks and/or outputs declarations
|
||||
+ // note that result.code is non-existent if emitDeclarationOnly per https://github.com/ezolenko/rollup-plugin-typescript2/issues/268
|
||||
+ if (parsedConfig.options.emitDeclarationOnly)
|
||||
+ {
|
||||
+ context.debug(() => `${blue("emitDeclarationOnly")} enabled, not transforming TS'`);
|
||||
+ return undefined;
|
||||
+ }
|
||||
const transformResult = { code: result.code, map: { mappings: "" } };
|
||||
if (result.map) {
|
||||
if (pluginOptions.sourceMapCallback)
|
||||
363
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
363
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
550
.yarn/plugins/@yarnpkg/plugin-version.cjs
vendored
Normal file
550
.yarn/plugins/@yarnpkg/plugin-version.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
28
.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
vendored
Normal file
28
.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
786
.yarn/releases/yarn-3.2.1.cjs
vendored
Executable file
786
.yarn/releases/yarn-3.2.1.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
11
.yarnrc.yml
Normal file
11
.yarnrc.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||
spec: "@yarnpkg/plugin-workspace-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-3.2.1.cjs
|
||||
154
README.md
154
README.md
@@ -9,81 +9,123 @@
|
||||
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/commits/main"><img src="https://img.shields.io/github/last-commit/discordjs/discord.js.svg?logo=github&logoColor=ffffff" alt="Last commit." /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/graphs/contributors"><img src="https://img.shields.io/github/contributors/discordjs/discord.js.svg?maxAge=3600&logo=github&logoColor=fff&color=00c7be" alt="contributors" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
This repository contains multiple packages with separate [releases][github-releases]. You can find the assembled Discord API wrapper at [`discord.js`][source]. It is a powerful [Node.js](https://nodejs.org/en) module that allows you to easily interact with the [Discord API](https://discord.com/developers/docs/intro).
|
||||
discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to easily interact with the
|
||||
[Discord API](https://discord.com/developers/docs/intro).
|
||||
|
||||
## Packages
|
||||
- Object-oriented
|
||||
- Predictable abstractions
|
||||
- Performant
|
||||
- 100% coverage of the Discord API
|
||||
|
||||
- `discord.js` ([source][source]) - A powerful Node.js module for interacting with the Discord API
|
||||
- `@discordjs/brokers` ([source][brokers-source]) - A collection of brokers for use with discord.js
|
||||
- `@discordjs/builders` ([source][builders-source]) - A utility package for easily building Discord API payloads
|
||||
- `@discordjs/collection` ([source][collection-source]) - A powerful utility data structure
|
||||
- `@discordjs/core` ([source][core-source]) - A thinly abstracted wrapper around the core components of the Discord API
|
||||
- `@discordjs/formatters` ([source][formatters-source]) - A collection of functions for formatting strings
|
||||
- `@discordjs/proxy` ([source][proxy-source]) - A wrapper around `@discordjs/rest` for running an HTTP proxy
|
||||
- `@discordjs/rest` ([source][rest-source]) - A module for interacting with the Discord REST API
|
||||
- `@discordjs/voice` ([source][voice-source]) - A module for interacting with the Discord Voice API
|
||||
- `@discordjs/util` ([source][util-source]) - A collection of utility functions
|
||||
- `@discordjs/ws` ([source][ws-source]) - A wrapper around Discord's gateway
|
||||
## Installation
|
||||
|
||||
**Node.js 16.9.0 or newer is required.**
|
||||
|
||||
```sh-session
|
||||
npm install discord.js
|
||||
yarn add discord.js
|
||||
pnpm add discord.js
|
||||
```
|
||||
|
||||
### Optional packages
|
||||
|
||||
- [zlib-sync](https://www.npmjs.com/package/zlib-sync) for WebSocket data compression and inflation (`npm install zlib-sync`)
|
||||
- [erlpack](https://github.com/discord/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install discord/erlpack`)
|
||||
- [bufferutil](https://www.npmjs.com/package/bufferutil) for a much faster WebSocket connection (`npm install bufferutil`)
|
||||
- [utf-8-validate](https://www.npmjs.com/package/utf-8-validate) in combination with `bufferutil` for much faster WebSocket processing (`npm install utf-8-validate`)
|
||||
- [@discordjs/voice](https://www.npmjs.com/package/@discordjs/voice) for interacting with the Discord Voice API (`npm install @discordjs/voice`)
|
||||
|
||||
## Example usage
|
||||
|
||||
Install all required dependencies:
|
||||
|
||||
```sh-session
|
||||
npm install discord.js @discordjs/rest
|
||||
yarn add discord.js @discordjs/rest
|
||||
pnpm add discord.js @discordjs/rest
|
||||
```
|
||||
|
||||
Register a slash command against the Discord API:
|
||||
|
||||
```js
|
||||
const { REST } = require('@discordjs/rest');
|
||||
const { Routes } = require('discord.js');
|
||||
|
||||
const commands = [
|
||||
{
|
||||
name: 'ping',
|
||||
description: 'Replies with Pong!',
|
||||
},
|
||||
];
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken('token');
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
|
||||
await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands });
|
||||
|
||||
console.log('Successfully reloaded application (/) commands.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
Afterwards we can create a quite simple example bot:
|
||||
|
||||
```js
|
||||
const { Client, GatewayIntentBits } = require('discord.js');
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log(`Logged in as ${client.user.tag}!`);
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
if (interaction.commandName === 'ping') {
|
||||
await interaction.reply('Pong!');
|
||||
}
|
||||
});
|
||||
|
||||
client.login('token');
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Documentation][documentation]
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [npm][npm]
|
||||
- [Related libraries][related-libs]
|
||||
- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/discord.js/tree/main/packages/website))
|
||||
- [Documentation](https://discord.js.org/#/docs)
|
||||
- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
|
||||
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v14.html), including updated and removed items in the library.
|
||||
- [discord.js Discord server](https://discord.gg/djs)
|
||||
- [Discord API Discord server](https://discord.gg/discord-api)
|
||||
- [GitHub](https://github.com/discordjs/discord.js)
|
||||
- [npm](https://www.npmjs.com/package/discord.js)
|
||||
- [Related libraries](https://discord.com/developers/docs/topics/community-resources#libraries)
|
||||
|
||||
### Extensions
|
||||
|
||||
- [RPC][rpc] ([source][rpc-source])
|
||||
- [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC))
|
||||
|
||||
## Contributing
|
||||
|
||||
Please read through our [contribution guidelines][contributing] before starting a pull request. We welcome contributions of all kinds, not just code! If you're stuck for ideas, look for the [good first issue][good-first-issue] label on issues in the repository. If you have any questions about the project, feel free to ask them on [Discord][discord]. Before creating your own issue or pull request, always check to see if one already exists! Don't rush contributions, take your time and ensure you're doing it correctly.
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||
[documentation](https://discord.js.org/#/docs).
|
||||
See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please join our [Discord server][discord].
|
||||
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[documentation]: https://discord.js.org/docs
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/discord.js
|
||||
[npm]: https://www.npmjs.com/package/discord.js
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[rpc]: https://www.npmjs.com/package/discord-rpc
|
||||
[rpc-source]: https://github.com/discordjs/RPC
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
||||
[github-releases]: https://github.com/discordjs/discord.js/releases
|
||||
[brokers-source]: https://github.com/discordjs/discord.js/tree/main/packages/brokers
|
||||
[builders-source]: https://github.com/discordjs/discord.js/tree/main/packages/builders
|
||||
[collection-source]: https://github.com/discordjs/discord.js/tree/main/packages/collection
|
||||
[core-source]: https://github.com/discordjs/discord.js/tree/main/packages/core
|
||||
[formatters-source]: https://github.com/discordjs/discord.js/tree/main/packages/formatters
|
||||
[proxy-source]: https://github.com/discordjs/discord.js/tree/main/packages/proxy
|
||||
[rest-source]: https://github.com/discordjs/discord.js/tree/main/packages/rest
|
||||
[voice-source]: https://github.com/discordjs/discord.js/tree/main/packages/voice
|
||||
[util-source]: https://github.com/discordjs/discord.js/tree/main/packages/util
|
||||
[ws-source]: https://github.com/discordjs/discord.js/tree/main/packages/ws
|
||||
[good-first-issue]: https://github.com/discordjs/discord.js/contribute
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
|
||||
nudge in the right direction, please don't hesitate to join our official [discord.js Server](https://discord.gg/djs).
|
||||
|
||||
@@ -1,425 +0,0 @@
|
||||
/**
|
||||
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
|
||||
*/
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
|
||||
/**
|
||||
* Optionally specifies another JSON config file that this file extends from. This provides a way for
|
||||
* standard settings to be shared across multiple projects.
|
||||
*
|
||||
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
|
||||
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
|
||||
* resolved using NodeJS require().
|
||||
*
|
||||
* SUPPORTED TOKENS: none
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
// "extends": "./shared/api-extractor-base.json"
|
||||
// "extends": "my-package/include/api-extractor-base.json"
|
||||
|
||||
/**
|
||||
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
|
||||
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting.
|
||||
*
|
||||
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
|
||||
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
|
||||
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
|
||||
* will be reported.
|
||||
*
|
||||
* SUPPORTED TOKENS: <lookup>
|
||||
* DEFAULT VALUE: "<lookup>"
|
||||
*/
|
||||
// "projectFolder": "..",
|
||||
|
||||
/**
|
||||
* (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
|
||||
* analyzes the symbols exported by this module.
|
||||
*
|
||||
* The file extension must be ".d.ts" and not ".ts".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
*/
|
||||
"mainEntryPointFilePath": "<projectFolder>/dist-docs/index.d.ts",
|
||||
|
||||
/**
|
||||
* A list of NPM package names whose exports should be treated as part of this package.
|
||||
*
|
||||
* For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
|
||||
* and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
|
||||
* of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
|
||||
* imports library2. To avoid this, we can specify:
|
||||
*
|
||||
* "bundledPackages": [ "library2" ],
|
||||
*
|
||||
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
|
||||
* local files for library1.
|
||||
*/
|
||||
"bundledPackages": [],
|
||||
|
||||
/**
|
||||
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
|
||||
*/
|
||||
"compiler": {
|
||||
/**
|
||||
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* Note: This setting will be ignored if "overrideTsconfig" is used.
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
|
||||
*/
|
||||
// "tsconfigFilePath": "<projectFolder>/tsconfig.json",
|
||||
/**
|
||||
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
|
||||
* The object must conform to the TypeScript tsconfig schema:
|
||||
*
|
||||
* http://json.schemastore.org/tsconfig
|
||||
*
|
||||
* If omitted, then the tsconfig.json file will be read from the "projectFolder".
|
||||
*
|
||||
* DEFAULT VALUE: no overrideTsconfig section
|
||||
*/
|
||||
"overrideTsconfig": {
|
||||
"compilerOptions": {
|
||||
// Type Checking
|
||||
"allowUnreachableCode": false,
|
||||
"allowUnusedLabels": false,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"strict": true,
|
||||
|
||||
// Modules
|
||||
"allowArbitraryExtensions": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "nodenext",
|
||||
"resolveJsonModule": true,
|
||||
"resolvePackageJsonExports": false,
|
||||
"resolvePackageJsonImports": false,
|
||||
|
||||
// Emit
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"importHelpers": false,
|
||||
"newLine": "lf",
|
||||
"noEmitHelpers": true,
|
||||
"outDir": "dist",
|
||||
"removeComments": false,
|
||||
"sourceMap": true,
|
||||
|
||||
// Interop Constraints
|
||||
"esModuleInterop": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
|
||||
// Language and Environment
|
||||
"experimentalDecorators": true,
|
||||
"lib": ["ESNext"],
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
|
||||
* and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
|
||||
* dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
|
||||
* for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
|
||||
*
|
||||
* DEFAULT VALUE: false
|
||||
*/
|
||||
// "skipLibCheck": true,
|
||||
},
|
||||
|
||||
/**
|
||||
* Configures how the API report file (*.api.md) will be generated.
|
||||
*/
|
||||
"apiReport": {
|
||||
/**
|
||||
* (REQUIRED) Whether to generate an API report.
|
||||
*/
|
||||
"enabled": false
|
||||
|
||||
/**
|
||||
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
|
||||
* a full file path.
|
||||
*
|
||||
* The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
|
||||
*
|
||||
* SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<unscopedPackageName>.api.md"
|
||||
*/
|
||||
// "reportFileName": "<unscopedPackageName>.api.md",
|
||||
|
||||
/**
|
||||
* Specifies the folder where the API report file is written. The file name portion is determined by
|
||||
* the "reportFileName" setting.
|
||||
*
|
||||
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
|
||||
* e.g. for an API review.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/temp/"
|
||||
*/
|
||||
// "reportFolder": "<projectFolder>/temp/",
|
||||
|
||||
/**
|
||||
* Specifies the folder where the temporary report file is written. The file name portion is determined by
|
||||
* the "reportFileName" setting.
|
||||
*
|
||||
* After the temporary file is written to disk, it is compared with the file in the "reportFolder".
|
||||
* If they are different, a production build will fail.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/temp/"
|
||||
*/
|
||||
// "reportTempFolder": "<projectFolder>/temp/"
|
||||
},
|
||||
|
||||
/**
|
||||
* Configures how the doc model file (*.api.json) will be generated.
|
||||
*/
|
||||
"docModel": {
|
||||
/**
|
||||
* (REQUIRED) Whether to generate a doc model file.
|
||||
*/
|
||||
"enabled": true,
|
||||
|
||||
/**
|
||||
* The output path for the doc model file. The file extension should be ".api.json".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
|
||||
*/
|
||||
"apiJsonFilePath": "<projectFolder>/docs/docs.api.json"
|
||||
},
|
||||
|
||||
/**
|
||||
* Configures how the .d.ts rollup file will be generated.
|
||||
*/
|
||||
"dtsRollup": {
|
||||
/**
|
||||
* (REQUIRED) Whether to generate the .d.ts rollup file.
|
||||
*/
|
||||
"enabled": false,
|
||||
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
|
||||
* This file will include all declarations that are exported by the main entry point.
|
||||
*
|
||||
* If the path is an empty string, then this file will not be written.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
|
||||
*/
|
||||
"untrimmedFilePath": "<projectFolder>/dist-docs/index.d.ts"
|
||||
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
|
||||
* This file will include only declarations that are marked as "@public", "@beta", or "@alpha".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
// "alphaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-alpha.d.ts",
|
||||
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
|
||||
* This file will include only declarations that are marked as "@public" or "@beta".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
|
||||
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
|
||||
* This file will include only declarations that are marked as "@public".
|
||||
*
|
||||
* If the path is an empty string, then this file will not be written.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
// "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
|
||||
|
||||
/**
|
||||
* When a declaration is trimmed, by default it will be replaced by a code comment such as
|
||||
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
|
||||
* declaration completely.
|
||||
*
|
||||
* DEFAULT VALUE: false
|
||||
*/
|
||||
// "omitTrimmingComments": true
|
||||
},
|
||||
|
||||
/**
|
||||
* Configures how the tsdoc-metadata.json file will be generated.
|
||||
*/
|
||||
"tsdocMetadata": {
|
||||
/**
|
||||
* Whether to generate the tsdoc-metadata.json file.
|
||||
*
|
||||
* DEFAULT VALUE: true
|
||||
*/
|
||||
// "enabled": true,
|
||||
/**
|
||||
* Specifies where the TSDoc metadata file should be written.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
|
||||
* "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
|
||||
* falls back to "tsdoc-metadata.json" in the package folder.
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<lookup>"
|
||||
*/
|
||||
// "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
|
||||
},
|
||||
|
||||
/**
|
||||
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
|
||||
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
|
||||
* To use the OS's default newline kind, specify "os".
|
||||
*
|
||||
* DEFAULT VALUE: "crlf"
|
||||
*/
|
||||
"newlineKind": "lf",
|
||||
|
||||
/**
|
||||
* Configures how API Extractor reports error and warning messages produced during analysis.
|
||||
*
|
||||
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
|
||||
*/
|
||||
"messages": {
|
||||
/**
|
||||
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
|
||||
* the input .d.ts files.
|
||||
*
|
||||
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
|
||||
*
|
||||
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
||||
*/
|
||||
"compilerMessageReporting": {
|
||||
/**
|
||||
* Configures the default routing for messages that don't match an explicit rule in this table.
|
||||
*/
|
||||
"default": {
|
||||
/**
|
||||
* Specifies whether the message should be written to the the tool's output log. Note that
|
||||
* the "addToApiReportFile" property may supersede this option.
|
||||
*
|
||||
* Possible values: "error", "warning", "none"
|
||||
*
|
||||
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
|
||||
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
|
||||
* the "--local" option), the warning is displayed but the build will not fail.
|
||||
*
|
||||
* DEFAULT VALUE: "warning"
|
||||
*/
|
||||
"logLevel": "warning"
|
||||
|
||||
/**
|
||||
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
|
||||
* then the message will be written inside that file; otherwise, the message is instead logged according to
|
||||
* the "logLevel" option.
|
||||
*
|
||||
* DEFAULT VALUE: false
|
||||
*/
|
||||
// "addToApiReportFile": false
|
||||
}
|
||||
|
||||
// "TS2551": {
|
||||
// "logLevel": "warning",
|
||||
// "addToApiReportFile": true
|
||||
// },
|
||||
//
|
||||
// . . .
|
||||
},
|
||||
|
||||
/**
|
||||
* Configures handling of messages reported by API Extractor during its analysis.
|
||||
*
|
||||
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
|
||||
*
|
||||
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
|
||||
*/
|
||||
"extractorMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
// "addToApiReportFile": false
|
||||
},
|
||||
|
||||
// Disable the following warning:
|
||||
// (ae-missing-release-tag) "x" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
"ae-missing-release-tag": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
|
||||
// "ae-extra-release-tag": {
|
||||
// "logLevel": "warning",
|
||||
// "addToApiReportFile": true
|
||||
// },
|
||||
//
|
||||
// . . .
|
||||
},
|
||||
|
||||
/**
|
||||
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
|
||||
*
|
||||
* TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
|
||||
*
|
||||
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
||||
*/
|
||||
"tsdocMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
// "addToApiReportFile": false
|
||||
}
|
||||
|
||||
// "tsdoc-link-tag-unescaped-text": {
|
||||
// "logLevel": "warning",
|
||||
// "addToApiReportFile": true
|
||||
// },
|
||||
//
|
||||
// . . .
|
||||
}
|
||||
}
|
||||
}
|
||||
36
biome.json
36
biome.json
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"formatWithErrors": false,
|
||||
"indentStyle": "tab",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 120,
|
||||
"lineEnding": "lf",
|
||||
"ignore": [
|
||||
".turbo",
|
||||
".vercel",
|
||||
".contentlayer",
|
||||
".next",
|
||||
"coverage",
|
||||
"dist",
|
||||
"dist-docs",
|
||||
"docs",
|
||||
"CHANGELOG.md",
|
||||
"tsup.config.bundled*"
|
||||
]
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"quoteStyle": "single",
|
||||
"quoteProperties": "asNeeded",
|
||||
"trailingComma": "all",
|
||||
"semicolons": "always"
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": true,
|
||||
"maxSize": 1000000
|
||||
}
|
||||
}
|
||||
93
build.config.ts
Normal file
93
build.config.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import { relative, resolve } from 'node:path';
|
||||
import glob from 'fast-glob';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
import { defineBuildConfig, BuildEntry } from 'unbuild';
|
||||
|
||||
interface ConfigOptions {
|
||||
entries: (BuildEntry | string)[];
|
||||
minify: boolean;
|
||||
emitCJS: boolean;
|
||||
externals: string[];
|
||||
cjsBridge: boolean;
|
||||
sourcemap: boolean;
|
||||
preserveModules: boolean;
|
||||
preserveModulesRoot: string;
|
||||
declaration: boolean;
|
||||
typeCheck: boolean;
|
||||
}
|
||||
|
||||
export function createUnbuildConfig({
|
||||
entries = [{ builder: 'rollup', input: 'src/index' }],
|
||||
minify = false,
|
||||
emitCJS = true,
|
||||
cjsBridge = true,
|
||||
externals = [],
|
||||
sourcemap = true,
|
||||
preserveModules = true,
|
||||
preserveModulesRoot = 'src',
|
||||
declaration = true,
|
||||
typeCheck = false,
|
||||
}: Partial<ConfigOptions> = {}) {
|
||||
const files = glob
|
||||
.sync('**', { cwd: 'src' })
|
||||
.map((file) => [`${file.slice(0, -2)}cjs`, `${file.slice(0, -2)}mjs`])
|
||||
.flat();
|
||||
|
||||
return defineBuildConfig({
|
||||
entries,
|
||||
clean: true,
|
||||
rollup: {
|
||||
esbuild: {
|
||||
minify,
|
||||
minifyIdentifiers: false,
|
||||
},
|
||||
emitCJS,
|
||||
cjsBridge,
|
||||
json: {
|
||||
namedExports: false,
|
||||
},
|
||||
},
|
||||
|
||||
externals: [...files, ...externals],
|
||||
|
||||
hooks: {
|
||||
'rollup:options': (_, options) => {
|
||||
// @ts-expect-error: This will always be an array
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
options.output![0] = {
|
||||
// @ts-expect-error: This will always be an array
|
||||
...options.output![0],
|
||||
sourcemap,
|
||||
preserveModules,
|
||||
preserveModulesRoot,
|
||||
};
|
||||
|
||||
if (emitCJS) {
|
||||
// @ts-expect-error: This will always be an array
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
options.output![1] = {
|
||||
// @ts-expect-error: This will always be an array
|
||||
...options.output![1],
|
||||
sourcemap,
|
||||
preserveModules,
|
||||
preserveModulesRoot,
|
||||
};
|
||||
}
|
||||
|
||||
if (declaration) {
|
||||
options.plugins?.unshift(
|
||||
typescript({
|
||||
check: typeCheck,
|
||||
tsconfig: relative(__dirname, resolve(process.cwd(), 'tsconfig.json')),
|
||||
tsconfigOverride: {
|
||||
compilerOptions: {
|
||||
emitDeclarationOnly: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -15,7 +15,6 @@ coverage:
|
||||
|
||||
flag_management:
|
||||
default_rules:
|
||||
carryforward: true
|
||||
statuses:
|
||||
- type: project
|
||||
target: auto
|
||||
|
||||
139
eslint.config.js
139
eslint.config.js
@@ -1,139 +0,0 @@
|
||||
import unocss from '@unocss/eslint-plugin';
|
||||
import common from 'eslint-config-neon/flat/common.js';
|
||||
import edge from 'eslint-config-neon/flat/edge.js';
|
||||
import next from 'eslint-config-neon/flat/next.js';
|
||||
import node from 'eslint-config-neon/flat/node.js';
|
||||
import prettier from 'eslint-config-neon/flat/prettier.js';
|
||||
import react from 'eslint-config-neon/flat/react.js';
|
||||
import typescript from 'eslint-config-neon/flat/typescript.js';
|
||||
// import oxlint from 'eslint-plugin-oxlint';
|
||||
import merge from 'lodash.merge';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
const commonFiles = '{js,mjs,cjs,ts,mts,cts,jsx,tsx}';
|
||||
|
||||
const commonRuleset = merge(...common, { files: [`**/*${commonFiles}`] });
|
||||
|
||||
const nodeRuleset = merge(...node, { files: [`**/*${commonFiles}`] });
|
||||
|
||||
const typeScriptRuleset = merge(...typescript, {
|
||||
files: [`**/*${commonFiles}`],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
allowAutomaticSingleRunInference: true,
|
||||
project: ['tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/consistent-type-definitions': [2, 'interface'],
|
||||
'@typescript-eslint/naming-convention': [
|
||||
2,
|
||||
{
|
||||
selector: 'typeParameter',
|
||||
format: ['PascalCase'],
|
||||
custom: {
|
||||
regex: '^\\w{3,}',
|
||||
match: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
project: ['tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const reactRuleset = merge(...react, {
|
||||
files: [`packages/ui/**/*${commonFiles}`],
|
||||
rules: {
|
||||
'@next/next/no-html-link-for-pages': 0,
|
||||
'react/react-in-jsx-scope': 0,
|
||||
'react/jsx-filename-extension': [1, { extensions: ['.tsx'] }],
|
||||
},
|
||||
});
|
||||
|
||||
const prettierRuleset = merge(...prettier, { files: [`**/*${commonFiles}`] });
|
||||
|
||||
// const oxlintRuleset = merge({ rules: oxlint.rules }, { files: [`**/*${commonFiles}`] });
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: [
|
||||
'**/node_modules/',
|
||||
'.git/',
|
||||
'**/dist/',
|
||||
'**/template/',
|
||||
'**/coverage/',
|
||||
'**/storybook-static/',
|
||||
'**/.next/',
|
||||
'packages/discord.js/',
|
||||
],
|
||||
},
|
||||
commonRuleset,
|
||||
nodeRuleset,
|
||||
typeScriptRuleset,
|
||||
{
|
||||
files: ['**/*{ts,mts,cts,tsx}'],
|
||||
rules: { 'jsdoc/no-undefined-types': 0 },
|
||||
},
|
||||
{
|
||||
files: [`packages/{api-extractor,brokers,create-discord-bot,docgen,ws}/**/*${commonFiles}`],
|
||||
rules: { 'n/no-sync': 0 },
|
||||
},
|
||||
{
|
||||
files: [`packages/rest/**/*${commonFiles}`],
|
||||
rules: {
|
||||
'n/prefer-global/url': 0,
|
||||
'n/prefer-global/url-search-params': 0,
|
||||
'n/prefer-global/buffer': 0,
|
||||
'n/prefer-global/process': 0,
|
||||
'no-restricted-globals': 0,
|
||||
'unicorn/prefer-node-protocol': 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [`packages/voice/**/*${commonFiles}`],
|
||||
rules: { 'no-restricted-globals': 0 },
|
||||
},
|
||||
{
|
||||
files: [`packages/api-extractor-model/**/*${commonFiles}`],
|
||||
rules: {
|
||||
'@typescript-eslint/no-namespace': 0,
|
||||
'no-prototype-builtins': 0,
|
||||
'consistent-this': 0,
|
||||
'unicorn/no-this-assignment': 0,
|
||||
'@typescript-eslint/no-this-alias': 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [`packages/api-extractor/**/*${commonFiles}`],
|
||||
rules: {
|
||||
'consistent-this': 0,
|
||||
'unicorn/no-this-assignment': 0,
|
||||
'@typescript-eslint/no-this-alias': 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [`packages/{api-extractor,api-extractor-model,api-extractor-utils}/**/*${commonFiles}`],
|
||||
rules: { '@typescript-eslint/naming-convention': 0 },
|
||||
},
|
||||
reactRuleset,
|
||||
{
|
||||
files: [`packages/ui/**/*${commonFiles}`],
|
||||
plugins: { '@unocss': unocss },
|
||||
rules: {
|
||||
'@unocss/order': 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*{js,mjs,cjs,jsx}'],
|
||||
rules: { 'tsdoc/syntax': 0 },
|
||||
},
|
||||
prettierRuleset,
|
||||
// oxlintRuleset,
|
||||
);
|
||||
99
package.json
99
package.json
@@ -1,34 +1,24 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/discord.js",
|
||||
"version": "0.0.0",
|
||||
"description": "A powerful library for interacting with the Discord API",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "turbo run build --concurrency=4",
|
||||
"build:affected": "turbo run build --filter=...[origin/v14] --concurrency=4",
|
||||
"test": "turbo run test --concurrency=4",
|
||||
"test:affected": "turbo run test --filter=...[origin/v14] --concurrency=4",
|
||||
"lint": "turbo run lint --concurrency=4",
|
||||
"lint:affected": "turbo run lint --filter=...[origin/v14] --concurrency=4",
|
||||
"format": "turbo run format --concurrency=4",
|
||||
"format:affected": "turbo run format --filter=...[origin/v14] --concurrency=4",
|
||||
"fmt": "turbo run format --concurrency=4",
|
||||
"fmt:affected": "turbo run format --filter=...[origin/v14] --concurrency=4",
|
||||
"docs": "turbo run docs --concurrency=4",
|
||||
"docs:affected": "turbo run docs --filter=...[origin/v14] --concurrency=4",
|
||||
"prepare": "is-ci || husky",
|
||||
"update": "pnpm --recursive update --interactive",
|
||||
"update:latest": "pnpm --recursive update --interactive --latest",
|
||||
"create-package": "turbo gen create-package --args"
|
||||
"build": "yarn workspaces foreach --parallel --topological run build",
|
||||
"test": "yarn workspaces foreach --parallel --topological run test",
|
||||
"lint": "yarn workspaces foreach --parallel --topological run lint",
|
||||
"format": "yarn workspaces foreach --parallel --topological run format",
|
||||
"fmt": "yarn format",
|
||||
"postinstall": "is-ci || husky install",
|
||||
"docs": "yarn workspaces foreach --parallel --topological run docs",
|
||||
"update": "yarn upgrade-interactive"
|
||||
},
|
||||
"type": "module",
|
||||
"contributors": [
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"Amish Shah <amishshah.2k@gmail.com>",
|
||||
"Vlad Frangu <me@vladfrangu.dev>",
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Aura Román <kyradiscord@gmail.com>"
|
||||
"Antonio Roman <kyradiscord@gmail.com>"
|
||||
],
|
||||
"keywords": [
|
||||
"discord",
|
||||
@@ -46,54 +36,35 @@
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.4.0",
|
||||
"@commitlint/config-angular": "^19.3.0",
|
||||
"@favware/cliff-jumper": "^4.1.0",
|
||||
"@favware/npm-deprecate": "^1.0.7",
|
||||
"@types/lodash.merge": "^4.6.9",
|
||||
"@unocss/eslint-plugin": "^0.59.4",
|
||||
"@vitest/coverage-v8": "^2.0.5",
|
||||
"conventional-changelog-cli": "^4.1.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-neon": "^0.1.62",
|
||||
"husky": "^9.1.5",
|
||||
"@commitlint/cli": "^17.0.3",
|
||||
"@commitlint/config-angular": "^17.0.3",
|
||||
"@favware/cliff-jumper": "^1.8.5",
|
||||
"@favware/npm-deprecate": "^1.0.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||
"@typescript-eslint/parser": "^5.31.0",
|
||||
"conventional-changelog-cli": "^2.2.2",
|
||||
"eslint": "^8.20.0",
|
||||
"eslint-config-marine": "^9.4.1",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-import-resolver-typescript": "^3.3.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"fast-glob": "^3.2.11",
|
||||
"husky": "^8.0.1",
|
||||
"is-ci": "^3.0.1",
|
||||
"lint-staged": "^15.2.9",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"prettier": "^3.3.3",
|
||||
"tsup": "^8.2.4",
|
||||
"turbo": "^2.0.14",
|
||||
"typescript": "~5.5.4",
|
||||
"typescript-eslint": "^8.2.0",
|
||||
"unocss": "^0.60.4",
|
||||
"vercel": "^37.0.0",
|
||||
"vitest": "^2.0.5"
|
||||
"lint-staged": "^13.0.3",
|
||||
"prettier": "^2.7.1",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"pnpm": {
|
||||
"peerDependencyRules": {
|
||||
"ignoreMissing": [
|
||||
"*"
|
||||
],
|
||||
"allowedAny": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
"overrides": {
|
||||
"@contentlayer/utils>@opentelemetry/core": "^1.15.1",
|
||||
"@contentlayer/utils>@opentelemetry/exporter-trace-otlp-grpc": "^0.41.1",
|
||||
"@contentlayer/utils>@opentelemetry/resources": "^1.15.1",
|
||||
"@contentlayer/utils>@opentelemetry/sdk-trace-base": "^1.15.1",
|
||||
"@contentlayer/utils>@opentelemetry/sdk-trace-node": "^1.15.1",
|
||||
"@contentlayer/utils>@opentelemetry/semantic-conventions": "^1.15.1"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"@microsoft/tsdoc-config@0.16.2": "patches/@microsoft__tsdoc-config@0.16.2.patch"
|
||||
}
|
||||
"resolutions": {
|
||||
"rollup-plugin-typescript2@0.32.1": "patch:rollup-plugin-typescript2@npm:0.32.1#.yarn/patches/rollup-plugin-typescript2-npm-0.32.1-b5887420f2.patch",
|
||||
"@microsoft/tsdoc-config": "patch:@microsoft/tsdoc-config@npm:0.16.1#.yarn/patches/@microsoft-tsdoc-config-npm-0.16.1-81031b1bbf.patch"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=16.9.0"
|
||||
},
|
||||
"packageManager": "pnpm@9.8.0"
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"packageManager": "yarn@3.2.1"
|
||||
}
|
||||
|
||||
3
packages/actions/.eslintrc.json
Normal file
3
packages/actions/.eslintrc.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../../.eslintrc.json"
|
||||
}
|
||||
18
packages/actions/.gitignore
vendored
18
packages/actions/.gitignore
vendored
@@ -1,8 +1,8 @@
|
||||
# Packages
|
||||
node_modules
|
||||
node_modules/
|
||||
|
||||
# Log files
|
||||
logs
|
||||
logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
@@ -15,9 +15,15 @@ pids
|
||||
.env
|
||||
|
||||
# Dist
|
||||
dist
|
||||
dist/
|
||||
typings/
|
||||
|
||||
docs/**/*
|
||||
!docs/index.yml
|
||||
!docs/README.md
|
||||
!docs/examples/
|
||||
!docs/examples/*.md
|
||||
|
||||
# Miscellaneous
|
||||
.turbo
|
||||
.tmp
|
||||
coverage
|
||||
.tmp/
|
||||
coverage/
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
/** @type {import('lint-staged').Config} */
|
||||
module.exports = require('../../.lintstagedrc.json');
|
||||
@@ -1,2 +1 @@
|
||||
/** @type {import('lint-staged').Config} */
|
||||
module.exports = require('../../.lintstagedrc.json');
|
||||
@@ -1,4 +1,9 @@
|
||||
# Autogenerated
|
||||
CHANGELOG.md
|
||||
.turbo
|
||||
coverage
|
||||
dist
|
||||
tsup.config.bundled*
|
||||
dist/
|
||||
docs/**/*
|
||||
!docs/index.yml
|
||||
!docs/README.md
|
||||
coverage/
|
||||
tsup.config.*.mjs
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
/** @type {import('prettier').Config} */
|
||||
module.exports = require('../../.prettierrc.json');
|
||||
@@ -1,2 +1 @@
|
||||
/** @type {import('prettier').Config} */
|
||||
module.exports = require('../../.prettierrc.json');
|
||||
@@ -10,36 +10,25 @@
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [Related libraries][related-libs]
|
||||
- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/discord.js/tree/main/packages/website))
|
||||
- [Documentation](https://discord.js.org/#/docs)
|
||||
- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
|
||||
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v14.html), including updated and removed items in the library.
|
||||
- [discord.js Discord server](https://discord.gg/djs)
|
||||
- [Discord API Discord server](https://discord.gg/discord-api)
|
||||
- [GitHub](https://github.com/discordjs/discord.js/tree/main/packages/scripts)
|
||||
- [Related libraries](https://discord.com/developers/docs/topics/community-resources#libraries)
|
||||
|
||||
## Contributing
|
||||
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested.
|
||||
See [the contribution guide][contributing] if you'd like to submit a PR.
|
||||
See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
||||
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/actions
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
|
||||
nudge in the right direction, please don't hesitate to join our official [discord.js Server](https://discord.gg/djs).
|
||||
|
||||
@@ -1,51 +1,18 @@
|
||||
import { describe, test, expect } from 'vitest';
|
||||
import { formatTag } from '../src/index.js';
|
||||
import { formatTag } from '../src';
|
||||
|
||||
describe('Format Tag', () => {
|
||||
test('GIVEN tag with a prefix THEN format tag to not contain the prefix', () => {
|
||||
expect(formatTag('@discordjs/rest@0.4.0')).toEqual({
|
||||
isSubpackage: true,
|
||||
package: 'rest',
|
||||
semver: '0.4.0',
|
||||
});
|
||||
expect(formatTag('@discordjs/collection@0.6.0')).toEqual({
|
||||
isSubpackage: true,
|
||||
package: 'collection',
|
||||
semver: '0.6.0',
|
||||
});
|
||||
expect(formatTag('@discordjs/proxy@0.1.0')).toEqual({
|
||||
isSubpackage: true,
|
||||
package: 'proxy',
|
||||
semver: '0.1.0',
|
||||
});
|
||||
expect(formatTag('@discordjs/builders@0.13.0')).toEqual({
|
||||
isSubpackage: true,
|
||||
package: 'builders',
|
||||
semver: '0.13.0',
|
||||
});
|
||||
expect(formatTag('@discordjs/voice@0.9.0')).toEqual({
|
||||
isSubpackage: true,
|
||||
package: 'voice',
|
||||
semver: '0.9.0',
|
||||
});
|
||||
expect(formatTag('@discordjs/rest@0.4.0')).toEqual({ package: 'rest', semver: '0.4.0' });
|
||||
expect(formatTag('@discordjs/collection@0.6.0')).toEqual({ package: 'collection', semver: '0.6.0' });
|
||||
expect(formatTag('@discordjs/proxy@0.1.0')).toEqual({ package: 'proxy', semver: '0.1.0' });
|
||||
expect(formatTag('@discordjs/builders@0.13.0')).toEqual({ package: 'builders', semver: '0.13.0' });
|
||||
expect(formatTag('@discordjs/voice@0.9.0')).toEqual({ package: 'voice', semver: '0.9.0' });
|
||||
});
|
||||
|
||||
test('GIVEN tag with no prefix THEN return tag', () => {
|
||||
expect(formatTag('13.5.1')).toEqual({
|
||||
isSubpackage: false,
|
||||
package: 'discord.js',
|
||||
semver: '13.5.1',
|
||||
});
|
||||
expect(formatTag('13.7.0')).toEqual({
|
||||
isSubpackage: false,
|
||||
package: 'discord.js',
|
||||
semver: '13.7.0',
|
||||
});
|
||||
expect(formatTag('create-discord-bot@1.0.0')).toEqual({
|
||||
isSubpackage: false,
|
||||
package: 'create-discord-bot',
|
||||
semver: '1.0.0',
|
||||
});
|
||||
expect(formatTag('13.5.1')).toEqual({ package: 'discord.js', semver: '13.5.1' });
|
||||
expect(formatTag('13.7.0')).toEqual({ package: 'discord.js', semver: '13.7.0' });
|
||||
});
|
||||
|
||||
test('GIVEN no or invalid tag THEN return null', () => {
|
||||
|
||||
3
packages/actions/build.config.ts
Normal file
3
packages/actions/build.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { createUnbuildConfig } from '../../build.config';
|
||||
|
||||
export default createUnbuildConfig({ minify: true });
|
||||
@@ -1,17 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/actions",
|
||||
"version": "0.1.0",
|
||||
"description": "A set of actions that we use for our workflows",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"build": "tsc --noEmit --lib ESNext,DOM && tsup",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||
"fmt": "pnpm run format"
|
||||
"build": "unbuild",
|
||||
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
||||
"fmt": "yarn format"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"type": "module",
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"test": "__tests__"
|
||||
@@ -32,43 +38,28 @@
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/actions"
|
||||
"url": "https://github.com/discordjs/discord.js.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/glob": "^0.5.0",
|
||||
"@aws-sdk/client-s3": "^3.787.0",
|
||||
"@discordjs/scripts": "workspace:^",
|
||||
"@vercel/blob": "^0.27.3",
|
||||
"@vercel/postgres": "^0.9.0",
|
||||
"cloudflare": "^4.2.0",
|
||||
"meilisearch": "^0.38.0",
|
||||
"p-limit": "^6.2.0",
|
||||
"p-queue": "^8.1.0",
|
||||
"tslib": "^2.8.1",
|
||||
"undici": "7.8.0"
|
||||
"@actions/core": "^1.9.0",
|
||||
"tslib": "^2.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.14.0",
|
||||
"@vitest/coverage-v8": "^3.1.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-neon": "^0.1.62",
|
||||
"eslint-formatter-pretty": "^6.0.1",
|
||||
"prettier": "^3.5.3",
|
||||
"terser": "^5.37.0",
|
||||
"tsup": "^8.4.0",
|
||||
"turbo": "^2.5.0",
|
||||
"typescript": "~5.8.3",
|
||||
"vitest": "^3.1.1"
|
||||
"@types/node": "^16.11.45",
|
||||
"c8": "^7.12.0",
|
||||
"eslint": "^8.20.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rollup-plugin-typescript2": "0.32.1",
|
||||
"tsup": "^6.2.0",
|
||||
"typescript": "^4.7.4",
|
||||
"unbuild": "^0.7.6",
|
||||
"vitest": "^0.19.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,10 @@ inputs:
|
||||
description: 'The input tag'
|
||||
required: true
|
||||
outputs:
|
||||
subpackage:
|
||||
description: 'Whether this tag is a subpackage tag'
|
||||
package:
|
||||
description: 'The package string that was extracted from this tag'
|
||||
semver:
|
||||
description: 'The semver string that was extracted from this tag'
|
||||
runs:
|
||||
using: node20
|
||||
using: node16
|
||||
main: ../../dist/formatTag/index.js
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
export function formatTag(tag: string) {
|
||||
const parsed = /(?:^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
|
||||
const parsedPackage = /(?<package>.*)@v?-?.*/.exec(tag);
|
||||
const parsed = /(^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
|
||||
|
||||
if (parsed?.groups) {
|
||||
const isSubpackage = typeof parsed.groups.package === 'string';
|
||||
const pkg = isSubpackage ? parsed.groups.package : (parsedPackage?.groups?.package ?? 'discord.js');
|
||||
const semver = parsed.groups.semver;
|
||||
|
||||
return {
|
||||
isSubpackage,
|
||||
package: pkg,
|
||||
semver,
|
||||
package: parsed.groups.package ?? 'discord.js',
|
||||
semver: parsed.groups.semver,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { getInput, setOutput } from '@actions/core';
|
||||
import { formatTag } from './formatTag.js';
|
||||
import { formatTag } from './formatTag';
|
||||
|
||||
const tag = getInput('tag', { required: true });
|
||||
const parsed = formatTag(tag);
|
||||
|
||||
if (parsed) {
|
||||
setOutput('subpackage', parsed.isSubpackage);
|
||||
setOutput('package', parsed.package);
|
||||
setOutput('semver', parsed.semver);
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './formatTag/formatTag.js';
|
||||
export * from './formatTag/formatTag';
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
name: 'pnpm install'
|
||||
description: 'Run pnpm install with cache enabled'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Set up swap space
|
||||
if: runner.os == 'Linux'
|
||||
uses: pierotofy/set-swap-space@v1.0
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
|
||||
- uses: pnpm/action-setup@v4.1.0
|
||||
name: Install pnpm
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- name: Expose pnpm config(s) through "$GITHUB_OUTPUT"
|
||||
id: pnpm-config
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache rotation keys
|
||||
id: cache-rotation
|
||||
shell: bash
|
||||
run: |
|
||||
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v4
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
pnpm install --frozen-lockfile --prefer-offline --loglevel error
|
||||
env:
|
||||
HUSKY: '0'
|
||||
@@ -1,116 +1,58 @@
|
||||
name: 'Upload Coverage'
|
||||
description: 'Uploads code coverage reports to codecov with separate flags for separate packages'
|
||||
inputs:
|
||||
codecov_token:
|
||||
description: 'Codecov token.'
|
||||
required: true
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Upload Brokers Coverage
|
||||
if: ${{ hashFiles('packages/brokers/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
files: ./packages/brokers/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: brokers
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Builders Coverage
|
||||
if: ${{ hashFiles('packages/builders/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/builders/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: builders
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Collection Coverage
|
||||
if: ${{ hashFiles('packages/collection/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/collection/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: collection
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Discord.js Coverage
|
||||
if: ${{ hashFiles('packages/discord.js/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/discord.js/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: discord.js
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Formatters Coverage
|
||||
if: ${{ hashFiles('packages/formatters/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
files: ./packages/formatters/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: formatters
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Next Coverage
|
||||
if: ${{ hashFiles('packages/next/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
files: ./packages/next/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: next
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Proxy Coverage
|
||||
if: ${{ hashFiles('packages/proxy/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/proxy/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: proxy
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Rest Coverage
|
||||
if: ${{ hashFiles('packages/rest/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/rest/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: rest
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Voice Coverage
|
||||
if: ${{ hashFiles('packages/voice/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/voice/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: voice
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Website Coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/website/coverage/cobertura-coverage.xml
|
||||
flags: website
|
||||
|
||||
- name: Upload WS Coverage
|
||||
if: ${{ hashFiles('packages/ws/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/ws/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: ws
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Util Coverage
|
||||
if: ${{ hashFiles('packages/util/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
files: ./packages/util/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: util
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
- name: Upload Utilities Coverage
|
||||
if: ${{ hashFiles('packages/actions/coverage/cobertura-coverage.xml') != '' || hashFiles('packages/scripts/coverage/cobertura-coverage.xml') != '' }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
files: ./packages/actions/coverage/cobertura-coverage.xml, ./packages/scripts/coverage/cobertura-coverage.xml
|
||||
disable_search: true
|
||||
flags: utilities
|
||||
token: ${{ inputs.CODECOV_TOKEN }}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
name: 'Upload documentation'
|
||||
description: 'Uploads the docs.api.json file to a neon postgresql database'
|
||||
inputs:
|
||||
package:
|
||||
description: 'The package string'
|
||||
version:
|
||||
description: 'The semver string'
|
||||
runs:
|
||||
using: node20
|
||||
main: ../../dist/uploadDocumentation/index.js
|
||||
@@ -1,96 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-loop-func */
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import process from 'node:process';
|
||||
import { getInput, setFailed } from '@actions/core';
|
||||
import { create } from '@actions/glob';
|
||||
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
||||
import { put } from '@vercel/blob';
|
||||
import { createPool } from '@vercel/postgres';
|
||||
import Cloudflare from 'cloudflare';
|
||||
import pLimit from 'p-limit';
|
||||
|
||||
if (
|
||||
!process.env.DATABASE_URL ||
|
||||
!process.env.CF_R2_DOCS_URL ||
|
||||
!process.env.CF_R2_DOCS_ACCESS_KEY_ID ||
|
||||
!process.env.CF_R2_DOCS_SECRET_ACCESS_KEY ||
|
||||
!process.env.CF_R2_DOCS_BUCKET ||
|
||||
!process.env.CF_R2_DOCS_BUCKET_URL ||
|
||||
!process.env.CF_D1_DOCS_API_KEY ||
|
||||
!process.env.CF_D1_DOCS_ID ||
|
||||
!process.env.CF_ACCOUNT_ID
|
||||
) {
|
||||
setFailed('Missing environment variables');
|
||||
}
|
||||
|
||||
const pkg = getInput('package') || '*';
|
||||
const version = getInput('version') || 'main';
|
||||
|
||||
const pool = createPool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
});
|
||||
|
||||
const S3 = new S3Client({
|
||||
region: 'auto',
|
||||
endpoint: process.env.CF_R2_DOCS_URL!,
|
||||
credentials: {
|
||||
accessKeyId: process.env.CF_R2_DOCS_ACCESS_KEY_ID!,
|
||||
secretAccessKey: process.env.CF_R2_DOCS_SECRET_ACCESS_KEY!,
|
||||
},
|
||||
requestChecksumCalculation: 'WHEN_REQUIRED',
|
||||
responseChecksumValidation: 'WHEN_REQUIRED',
|
||||
});
|
||||
|
||||
const client = new Cloudflare({
|
||||
apiToken: process.env.CF_D1_DOCS_API_KEY,
|
||||
});
|
||||
|
||||
const limit = pLimit(10);
|
||||
const promises = [];
|
||||
|
||||
const globber = await create(`packages/${pkg}/docs/docs.api.json`);
|
||||
console.log('Glob: ', await globber.glob());
|
||||
for await (const file of globber.globGenerator()) {
|
||||
const data = await readFile(file, 'utf8');
|
||||
try {
|
||||
promises.push(
|
||||
limit(async () => {
|
||||
console.log(`Uploading ${file} with ${version}...`);
|
||||
const json = JSON.parse(data);
|
||||
const name = json.name ?? json.n;
|
||||
|
||||
const key = `${name.replace('@discordjs/', '')}/${version}.json`;
|
||||
|
||||
const { url } = await put(key, data, {
|
||||
access: 'public',
|
||||
addRandomSuffix: false,
|
||||
});
|
||||
await pool.sql`insert into documentation (name, version, url) values (${name.replace(
|
||||
'@discordjs/',
|
||||
'',
|
||||
)}, ${version}, ${url}) on conflict (name, version) do update set url = EXCLUDED.url`;
|
||||
|
||||
await S3.send(
|
||||
new PutObjectCommand({
|
||||
Bucket: process.env.CF_R2_DOCS_BUCKET,
|
||||
Key: key,
|
||||
Body: data,
|
||||
}),
|
||||
);
|
||||
await client.d1.database.raw(process.env.CF_D1_DOCS_ID!, {
|
||||
account_id: process.env.CF_ACCOUNT_ID!,
|
||||
sql: `insert into documentation (name, version, url) values (?, ?, ?) on conflict (name, version) do update set url = excluded.url;`,
|
||||
params: [name.replace('@discordjs/', ''), version, process.env.CF_R2_DOCS_BUCKET_URL + '/' + key],
|
||||
});
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
name: 'Upload search indices'
|
||||
description: 'Uploads the search indices to a meilisearch database'
|
||||
runs:
|
||||
using: node20
|
||||
main: ../../dist/uploadSearchIndices/index.js
|
||||
@@ -1,86 +0,0 @@
|
||||
import process from 'node:process';
|
||||
import { setFailed } from '@actions/core';
|
||||
import { generateAllIndices } from '@discordjs/scripts';
|
||||
import { createPool } from '@vercel/postgres';
|
||||
import { MeiliSearch } from 'meilisearch';
|
||||
import pLimit from 'p-limit';
|
||||
import { fetch } from 'undici';
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
setFailed('DATABASE_URL is not set');
|
||||
}
|
||||
|
||||
if (!process.env.SEARCH_API_URL) {
|
||||
setFailed('SEARCH_API_URL is not set');
|
||||
}
|
||||
|
||||
if (!process.env.SEARCH_API_KEY) {
|
||||
setFailed('SEARCH_API_KEY is not set');
|
||||
}
|
||||
|
||||
const pool = createPool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
});
|
||||
|
||||
const client = new MeiliSearch({
|
||||
host: process.env.SEARCH_API_URL!,
|
||||
apiKey: process.env.SEARCH_API_KEY!,
|
||||
});
|
||||
|
||||
const limit = pLimit(10);
|
||||
let promises: Promise<any>[] = [];
|
||||
|
||||
try {
|
||||
console.log('Generating all indices...');
|
||||
const indices = await generateAllIndices({
|
||||
fetchPackageVersions: async (pkg) => {
|
||||
console.log(`Fetching versions for ${pkg}...`);
|
||||
const { rows } = await pool.sql`select version from documentation where name = ${pkg}`;
|
||||
|
||||
return rows.map((row) => row.version);
|
||||
},
|
||||
fetchPackageVersionDocs: async (pkg, version) => {
|
||||
console.log(`Fetching data for ${pkg} ${version}...`);
|
||||
const { rows } = await pool.sql`select url from documentation where name = ${pkg} and version = ${version}`;
|
||||
const res = await fetch(rows[0]?.url ?? '');
|
||||
|
||||
return res.json();
|
||||
},
|
||||
writeToFile: false,
|
||||
});
|
||||
console.log('Generated all indices.');
|
||||
|
||||
console.log('Uploading indices...');
|
||||
|
||||
try {
|
||||
promises = indices.map(async (index) =>
|
||||
limit(async () => {
|
||||
console.log(`Uploading ${index.index}...`);
|
||||
let task;
|
||||
try {
|
||||
task = await client.createIndex(index.index);
|
||||
} catch {}
|
||||
|
||||
if (task) {
|
||||
await client.waitForTask(task.taskUid);
|
||||
}
|
||||
|
||||
const searchIndex = client.index(index.index);
|
||||
await searchIndex.updateSettings({ sortableAttributes: ['type'] });
|
||||
|
||||
await searchIndex.addDocuments(index.data);
|
||||
}),
|
||||
);
|
||||
} catch {}
|
||||
|
||||
console.log('Uploaded all indices.');
|
||||
} catch (error) {
|
||||
const err = error as Error;
|
||||
setFailed(err.message);
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
name: 'Upload split documentation'
|
||||
description: 'Splits and uploads the docs.api.json file into more fine-grained [item].api.json files'
|
||||
inputs:
|
||||
package:
|
||||
description: 'The package string'
|
||||
version:
|
||||
description: 'The semver string'
|
||||
runs:
|
||||
using: node20
|
||||
main: ../../dist/uploadSplitDocumentation/index.js
|
||||
@@ -1,94 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-loop-func */
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { basename, dirname, relative, sep } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { setTimeout as sleep } from 'node:timers/promises';
|
||||
import { setFailed, getInput } from '@actions/core';
|
||||
import { create } from '@actions/glob';
|
||||
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
|
||||
import { put } from '@vercel/blob';
|
||||
import PQueue from 'p-queue';
|
||||
|
||||
if (
|
||||
!process.env.CF_R2_DOCS_URL ||
|
||||
!process.env.CF_R2_DOCS_ACCESS_KEY_ID ||
|
||||
!process.env.CF_R2_DOCS_SECRET_ACCESS_KEY ||
|
||||
!process.env.CF_R2_DOCS_BUCKET
|
||||
) {
|
||||
setFailed('Missing environment variables');
|
||||
}
|
||||
|
||||
const pkg = getInput('package') || '*';
|
||||
const version = getInput('version') || 'main';
|
||||
|
||||
const queue = new PQueue({ concurrency: 10, interval: 60_000, intervalCap: 1_000 });
|
||||
const promises = [];
|
||||
const failedUploads: string[] = [];
|
||||
|
||||
const S3 = new S3Client({
|
||||
region: 'auto',
|
||||
endpoint: process.env.CF_R2_DOCS_URL!,
|
||||
credentials: {
|
||||
accessKeyId: process.env.CF_R2_DOCS_ACCESS_KEY_ID!,
|
||||
secretAccessKey: process.env.CF_R2_DOCS_SECRET_ACCESS_KEY!,
|
||||
},
|
||||
requestChecksumCalculation: 'WHEN_REQUIRED',
|
||||
responseChecksumValidation: 'WHEN_REQUIRED',
|
||||
});
|
||||
|
||||
const globber = await create(`packages/${pkg}/docs/${pkg}/split/*.api.json`);
|
||||
console.log('Glob: ', await globber.glob());
|
||||
for await (const file of globber.globGenerator()) {
|
||||
const data = await readFile(file, 'utf8');
|
||||
const pkgName = dirname(relative(process.cwd(), file)).split(sep)[1];
|
||||
try {
|
||||
promises.push(
|
||||
queue.add(async () => {
|
||||
console.log(`Uploading ${file} with ${version} from ${pkgName}...`);
|
||||
const name = basename(file).replace('main.', '');
|
||||
async function upload(retries = 0) {
|
||||
try {
|
||||
await put(`rewrite/${pkgName}/${version}.${name}`, data, {
|
||||
access: 'public',
|
||||
addRandomSuffix: false,
|
||||
});
|
||||
await S3.send(
|
||||
new PutObjectCommand({
|
||||
Bucket: process.env.CF_R2_DOCS_BUCKET,
|
||||
Key: `${pkgName}/${version}.${name}`,
|
||||
Body: data,
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
if (retries > 3) {
|
||||
console.error(`Could not upload ${file} after 3 retries`, error);
|
||||
failedUploads.push(name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof error === 'object' && error && 'retryAfter' in error && typeof error.retryAfter === 'number') {
|
||||
await sleep(error.retryAfter * 1_000);
|
||||
return upload(retries + 1);
|
||||
} else {
|
||||
console.error(`Could not upload ${file}`, error);
|
||||
failedUploads.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await upload();
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
if (failedUploads.length) {
|
||||
setFailed(`Failed to upload ${failedUploads.length} files: ${failedUploads.join(', ')}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
name: 'yarn install'
|
||||
description: 'Run yarn install with node_modules linker and cache enabled'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Set up swap space
|
||||
if: runner.os == 'Linux'
|
||||
uses: pierotofy/set-swap-space@v1.0
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
|
||||
- name: Expose yarn config as "$GITHUB_OUTPUT"
|
||||
id: yarn-config
|
||||
shell: bash
|
||||
env:
|
||||
YARN_ENABLE_GLOBAL_CACHE: 'false'
|
||||
run: |
|
||||
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT
|
||||
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT
|
||||
echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Restore yarn cache
|
||||
uses: actions/cache@v4
|
||||
id: yarn-download-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
|
||||
key: yarn-download-cache-default-${{ hashFiles(yarn.lock, .yarnrc.yml) }}
|
||||
restore-keys: |
|
||||
yarn-download-cache-default-
|
||||
|
||||
- name: Restore global npm cache folder
|
||||
id: npm-global-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}
|
||||
key: npm-global-cache-default-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(yarn.lock, .yarnrc.yml) }}
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
yarn install --immutable --inline-builds
|
||||
env:
|
||||
YARN_ENABLE_GLOBAL_CACHE: 'false'
|
||||
YARN_ENABLE_MIRROR: 'false'
|
||||
YARN_NM_MODE: 'hardlinks-local'
|
||||
YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz'
|
||||
HUSKY: '0'
|
||||
@@ -1,22 +1,20 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig.json",
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true
|
||||
},
|
||||
"include": [
|
||||
"*.ts",
|
||||
"*.js",
|
||||
"*.cjs",
|
||||
"*.mjs",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.js",
|
||||
"src/**/*.cjs",
|
||||
"src/**/*.mjs",
|
||||
"bin",
|
||||
"scripts",
|
||||
"__tests__",
|
||||
"__mocks__"
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"**/*.js",
|
||||
"**/*.mjs",
|
||||
"**/*.jsx",
|
||||
"**/*.test.ts",
|
||||
"**/*.test.js",
|
||||
"**/*.test.mjs",
|
||||
"**/*.spec.ts",
|
||||
"**/*.spec.js",
|
||||
"**/*.spec.mjs"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": []
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig.json",
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "bin"],
|
||||
"exclude": ["node_modules"]
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig.json",
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["__tests__/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
import { createTsupConfig } from '../../tsup.config.js';
|
||||
import { createTsupConfig } from '../../tsup.config';
|
||||
|
||||
export default createTsupConfig({
|
||||
entry: [
|
||||
'src/index.ts',
|
||||
'src/formatTag/index.ts',
|
||||
'src/uploadDocumentation/index.ts',
|
||||
'src/uploadSearchIndices/index.ts',
|
||||
'src/uploadSplitDocumentation/index.ts',
|
||||
],
|
||||
dts: false,
|
||||
format: 'esm',
|
||||
minify: 'terser',
|
||||
entry: ['src/index.ts', 'src/formatTag/index.ts'],
|
||||
format: ['cjs'],
|
||||
skipNodeModulesBundle: false,
|
||||
noExternal: ['@actions/core'],
|
||||
minify: true,
|
||||
});
|
||||
|
||||
23
packages/api-extractor-model/.gitignore
vendored
23
packages/api-extractor-model/.gitignore
vendored
@@ -1,23 +0,0 @@
|
||||
# Packages
|
||||
node_modules
|
||||
|
||||
# Log files
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Env
|
||||
.env
|
||||
|
||||
# Dist
|
||||
dist
|
||||
|
||||
# Miscellaneous
|
||||
.turbo
|
||||
.tmp
|
||||
coverage
|
||||
@@ -1,30 +0,0 @@
|
||||
# THIS IS A STANDARD TEMPLATE FOR .npmignore FILES IN THIS REPO.
|
||||
|
||||
# Ignore all files by default, to avoid accidentally publishing unintended files.
|
||||
*
|
||||
|
||||
# Use negative patterns to bring back the specific things we want to publish.
|
||||
!/bin/**
|
||||
!/lib/**
|
||||
!/lib-*/**
|
||||
!/dist/**
|
||||
!ThirdPartyNotice.txt
|
||||
|
||||
# Ignore certain patterns that should not get published.
|
||||
/dist/*.stats.*
|
||||
/lib/**/test/
|
||||
/lib-*/**/test/
|
||||
*.test.js
|
||||
|
||||
# NOTE: These don't need to be specified, because NPM includes them automatically.
|
||||
#
|
||||
# package.json
|
||||
# README (and its variants)
|
||||
# CHANGELOG (and its variants)
|
||||
# LICENSE / LICENCE
|
||||
|
||||
#--------------------------------------------
|
||||
# DO NOT MODIFY THE TEMPLATE ABOVE THIS LINE
|
||||
#--------------------------------------------
|
||||
|
||||
# (Add your project-specific overrides here)
|
||||
@@ -1,5 +0,0 @@
|
||||
.turbo
|
||||
coverage
|
||||
dist
|
||||
CHANGELOG.md
|
||||
tsup.config.bundled*
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,965 +0,0 @@
|
||||
# Change Log - @microsoft/api-extractor-model
|
||||
|
||||
This log was last generated on Thu, 28 Sep 2023 20:53:16 GMT and should not be manually modified.
|
||||
|
||||
## 7.28.2
|
||||
Thu, 28 Sep 2023 20:53:16 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.28.1
|
||||
Tue, 26 Sep 2023 09:30:33 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update type-only imports to include the type modifier.
|
||||
|
||||
## 7.28.0
|
||||
Fri, 15 Sep 2023 00:36:58 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Update @types/node from 14 to 18
|
||||
|
||||
## 7.27.6
|
||||
Tue, 08 Aug 2023 07:10:40 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.27.5
|
||||
Wed, 19 Jul 2023 00:20:32 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.27.4
|
||||
Thu, 06 Jul 2023 00:16:20 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.27.3
|
||||
Thu, 15 Jun 2023 00:21:01 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.27.2
|
||||
Wed, 07 Jun 2023 22:45:16 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.27.1
|
||||
Mon, 29 May 2023 15:21:15 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.27.0
|
||||
Mon, 22 May 2023 06:34:32 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Upgrade the TypeScript dependency to ~5.0.4
|
||||
|
||||
## 7.26.9
|
||||
Fri, 12 May 2023 00:23:05 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.8
|
||||
Thu, 04 May 2023 00:20:28 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Fix a mistake in the documentation for ApiParameterListMixin.overloadIndex
|
||||
|
||||
## 7.26.7
|
||||
Mon, 01 May 2023 15:23:20 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.6
|
||||
Sat, 29 Apr 2023 00:23:03 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.5
|
||||
Thu, 27 Apr 2023 17:18:43 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.4
|
||||
Fri, 10 Feb 2023 01:18:51 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.3
|
||||
Sun, 05 Feb 2023 03:02:02 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.2
|
||||
Wed, 01 Feb 2023 02:16:34 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.1
|
||||
Mon, 30 Jan 2023 16:22:30 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.26.0
|
||||
Wed, 25 Jan 2023 07:26:55 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add new .api.json field `isAbstract` to track `abstract` modifier in ApiClass, ApiMethod, and ApiProperty via ApiAbstractMixin (GitHub #3661)
|
||||
|
||||
## 7.25.3
|
||||
Fri, 09 Dec 2022 16:18:28 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.25.2
|
||||
Wed, 26 Oct 2022 00:16:16 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update the @microsoft/tsdoc dependency version to 0.14.2.
|
||||
|
||||
## 7.25.1
|
||||
Thu, 13 Oct 2022 00:20:15 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.25.0
|
||||
Tue, 11 Oct 2022 23:49:12 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add a new fileUrlPath property to relevant API items and serialize this to the .api.json. Additionally, add a SourceFile helper class for constructing file URLs from these paths and the projectFolderUrl.
|
||||
|
||||
## 7.24.4
|
||||
Mon, 10 Oct 2022 15:23:44 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.24.3
|
||||
Thu, 29 Sep 2022 07:13:06 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.24.2
|
||||
Wed, 21 Sep 2022 20:21:10 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.24.1
|
||||
Thu, 15 Sep 2022 00:18:52 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.24.0
|
||||
Fri, 02 Sep 2022 17:48:42 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add new ApiExportedMixin mixin class for determining whether an API item is exported or not
|
||||
|
||||
## 7.23.3
|
||||
Wed, 24 Aug 2022 03:01:22 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.23.2
|
||||
Wed, 24 Aug 2022 00:14:38 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Remove use of LegacyAdapters.sortStable
|
||||
|
||||
## 7.23.1
|
||||
Fri, 19 Aug 2022 00:17:19 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.23.0
|
||||
Wed, 03 Aug 2022 18:40:35 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Upgrade TypeScript dependency to 4.7
|
||||
|
||||
## 7.22.2
|
||||
Mon, 01 Aug 2022 02:45:32 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.22.1
|
||||
Thu, 21 Jul 2022 23:30:27 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Improve IFindApiItemMessage and fix two small bugs with ApiItemContainerMixin.findMembersWithInheritance()
|
||||
|
||||
## 7.22.0
|
||||
Thu, 21 Jul 2022 00:16:14 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add a new ApiItemContainerMixin.findMembersWithInheritance() method for finding an item's inherited members
|
||||
|
||||
## 7.21.0
|
||||
Thu, 30 Jun 2022 04:48:53 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Update model to reflect that index signatures can also be readonly
|
||||
|
||||
## 7.20.3
|
||||
Tue, 28 Jun 2022 22:47:13 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.20.2
|
||||
Tue, 28 Jun 2022 00:23:32 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.20.1
|
||||
Mon, 27 Jun 2022 18:43:09 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.20.0
|
||||
Sat, 25 Jun 2022 21:00:40 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add a new initializerTokenRange field to ApiProperty and ApiVariable items.
|
||||
|
||||
## 7.19.1
|
||||
Sat, 25 Jun 2022 01:54:29 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.19.0
|
||||
Fri, 24 Jun 2022 07:16:47 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Added new configuration for ItemContainerMixin member ordering
|
||||
|
||||
## 7.18.2
|
||||
Fri, 17 Jun 2022 09:17:54 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.18.1
|
||||
Fri, 17 Jun 2022 00:16:18 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.18.0
|
||||
Tue, 07 Jun 2022 09:37:04 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add an "isReadonly" field to ApiProperty, ApiPropertySignature, and ApiVariable
|
||||
- Add an "isProtected" field to ApiConstructor, ApiMethod, and ApiProperty
|
||||
|
||||
## 7.17.3
|
||||
Tue, 10 May 2022 01:20:43 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.17.2
|
||||
Sat, 23 Apr 2022 02:13:07 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.17.1
|
||||
Fri, 15 Apr 2022 00:12:36 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.17.0
|
||||
Wed, 13 Apr 2022 15:12:40 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add a new isOptional property to TypeParameters deserialized from the .api.json file with api-extractor-model.
|
||||
|
||||
## 7.16.2
|
||||
Tue, 12 Apr 2022 02:58:32 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update TSDoc dependencies.
|
||||
|
||||
## 7.16.1
|
||||
Sat, 09 Apr 2022 02:24:26 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Rename the "master" branch to "main".
|
||||
- Update a path in the README.
|
||||
|
||||
## 7.16.0
|
||||
Thu, 31 Mar 2022 02:06:05 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Updated api-extractor-model to store whether a parameter is optional.
|
||||
|
||||
## 7.15.4
|
||||
Tue, 15 Mar 2022 19:15:53 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.15.3
|
||||
Wed, 05 Jan 2022 16:07:47 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.15.2
|
||||
Mon, 27 Dec 2021 16:10:40 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.15.1
|
||||
Thu, 09 Dec 2021 20:34:41 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.15.0
|
||||
Thu, 09 Dec 2021 00:21:54 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Replace const enums with conventional enums to allow for compatibility with JavaScript consumers.
|
||||
|
||||
## 7.14.0
|
||||
Wed, 08 Dec 2021 16:14:05 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Update to TypeScript 4.5
|
||||
|
||||
## 7.13.18
|
||||
Mon, 06 Dec 2021 16:08:33 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.17
|
||||
Fri, 03 Dec 2021 03:05:22 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.16
|
||||
Sat, 06 Nov 2021 00:09:13 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.15
|
||||
Fri, 05 Nov 2021 15:09:18 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.14
|
||||
Wed, 27 Oct 2021 00:08:15 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update the package.json repository field to include the directory property.
|
||||
|
||||
## 7.13.13
|
||||
Wed, 13 Oct 2021 15:09:54 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.12
|
||||
Fri, 08 Oct 2021 08:08:34 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.11
|
||||
Thu, 07 Oct 2021 07:13:35 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.10
|
||||
Tue, 05 Oct 2021 15:08:38 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.9
|
||||
Fri, 24 Sep 2021 00:09:29 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.8
|
||||
Thu, 23 Sep 2021 00:10:40 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Upgrade the `@types/node` dependency to version to version 12.
|
||||
|
||||
## 7.13.7
|
||||
Tue, 14 Sep 2021 01:17:04 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.6
|
||||
Mon, 13 Sep 2021 15:07:06 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.5
|
||||
Wed, 11 Aug 2021 00:07:21 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.4
|
||||
Mon, 12 Jul 2021 23:08:26 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.3
|
||||
Fri, 04 Jun 2021 19:59:53 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.2
|
||||
Wed, 19 May 2021 00:11:39 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.1
|
||||
Mon, 03 May 2021 15:10:29 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.13.0
|
||||
Tue, 20 Apr 2021 04:59:51 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- The .api.json file format now stores the TSDoc configuration used for parsing doc comments
|
||||
|
||||
## 7.12.5
|
||||
Mon, 12 Apr 2021 15:10:28 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.12.4
|
||||
Thu, 08 Apr 2021 06:05:31 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Fix minor typo in README.md
|
||||
|
||||
## 7.12.3
|
||||
Tue, 06 Apr 2021 15:14:22 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.12.2
|
||||
Fri, 05 Feb 2021 16:10:42 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.12.1
|
||||
Thu, 10 Dec 2020 23:25:49 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Enable support for @decorator
|
||||
|
||||
## 7.12.0
|
||||
Wed, 18 Nov 2020 08:19:54 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Introduce an ApiOptionalMixin base class for representing optional properties and methods
|
||||
|
||||
## 7.11.0
|
||||
Wed, 18 Nov 2020 06:21:57 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Update .api.json file format to store a new field "isOptional" for documenting optional properties
|
||||
|
||||
## 7.10.10
|
||||
Wed, 11 Nov 2020 01:08:59 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.9
|
||||
Tue, 10 Nov 2020 23:13:12 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.8
|
||||
Fri, 30 Oct 2020 06:38:39 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.7
|
||||
Fri, 30 Oct 2020 00:10:14 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.6
|
||||
Thu, 29 Oct 2020 06:14:19 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Fix .d.ts error when the library is imported by a project using TypeScript 4.0
|
||||
|
||||
## 7.10.5
|
||||
Wed, 28 Oct 2020 01:18:03 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.4
|
||||
Tue, 27 Oct 2020 15:10:14 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.3
|
||||
Tue, 06 Oct 2020 00:24:06 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.2
|
||||
Mon, 05 Oct 2020 22:36:57 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.10.1
|
||||
Wed, 30 Sep 2020 18:39:17 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update to build with @rushstack/heft-node-rig
|
||||
|
||||
## 7.10.0
|
||||
Wed, 30 Sep 2020 06:53:53 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Upgrade compiler; the API now requires TypeScript 3.9 or newer
|
||||
|
||||
### Patches
|
||||
|
||||
- Update README.md
|
||||
|
||||
## 7.9.7
|
||||
Tue, 22 Sep 2020 05:45:57 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.9.6
|
||||
Tue, 22 Sep 2020 01:45:31 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.9.5
|
||||
Tue, 22 Sep 2020 00:08:53 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.9.4
|
||||
Sat, 19 Sep 2020 04:37:27 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.9.3
|
||||
Sat, 19 Sep 2020 03:33:07 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.9.2
|
||||
Fri, 18 Sep 2020 22:57:24 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.9.1
|
||||
Fri, 18 Sep 2020 21:49:54 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.9.0
|
||||
Sun, 13 Sep 2020 01:53:20 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add support for system selectors in declaration references
|
||||
|
||||
## 7.8.22
|
||||
Fri, 11 Sep 2020 02:13:35 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.21
|
||||
Mon, 07 Sep 2020 07:37:37 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.20
|
||||
Sat, 05 Sep 2020 18:56:34 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Fix "Converting circular structure to JSON" error (GitHub #2152)
|
||||
|
||||
## 7.8.19
|
||||
Thu, 27 Aug 2020 11:27:06 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.18
|
||||
Mon, 24 Aug 2020 07:35:20 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.17
|
||||
Sat, 22 Aug 2020 05:55:43 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.16
|
||||
Tue, 18 Aug 2020 23:59:42 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.15
|
||||
Mon, 17 Aug 2020 04:53:23 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.14
|
||||
Wed, 12 Aug 2020 00:10:05 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Updated project to build with Heft
|
||||
|
||||
## 7.8.13
|
||||
Wed, 05 Aug 2020 18:27:33 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.12
|
||||
Fri, 03 Jul 2020 15:09:04 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.11
|
||||
Thu, 25 Jun 2020 06:43:35 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.10
|
||||
Wed, 24 Jun 2020 09:50:48 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.9
|
||||
Wed, 24 Jun 2020 09:04:28 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.8
|
||||
Wed, 10 Jun 2020 20:48:30 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.7
|
||||
Sat, 30 May 2020 02:59:54 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.6
|
||||
Thu, 28 May 2020 05:59:02 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.5
|
||||
Wed, 27 May 2020 05:15:11 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.4
|
||||
Tue, 26 May 2020 23:00:25 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.3
|
||||
Fri, 22 May 2020 15:08:43 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.2
|
||||
Thu, 21 May 2020 23:09:44 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.1
|
||||
Thu, 21 May 2020 15:42:00 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.8.0
|
||||
Wed, 06 May 2020 08:23:45 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Enable canonicalReference to ApiItem lookup
|
||||
|
||||
## 7.7.11
|
||||
Wed, 08 Apr 2020 04:07:33 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.7.10
|
||||
Sat, 28 Mar 2020 00:37:16 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Upgrade to TSdoc 0.12.19
|
||||
|
||||
## 7.7.9
|
||||
Wed, 18 Mar 2020 15:07:47 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Upgrade cyclic dependencies
|
||||
|
||||
## 7.7.8
|
||||
Tue, 17 Mar 2020 23:55:58 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Replace dependencies whose NPM scope was renamed from `@microsoft` to `@rushstack`
|
||||
|
||||
## 7.7.7
|
||||
Tue, 28 Jan 2020 02:23:44 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.7.6
|
||||
Thu, 23 Jan 2020 01:07:56 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.7.5
|
||||
Tue, 21 Jan 2020 21:56:14 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.7.4
|
||||
Sun, 19 Jan 2020 02:26:52 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Upgrade Node typings to Node 10
|
||||
|
||||
## 7.7.3
|
||||
Fri, 17 Jan 2020 01:08:23 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.7.2
|
||||
Thu, 09 Jan 2020 06:44:13 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.7.1
|
||||
Wed, 08 Jan 2020 00:11:31 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.7.0
|
||||
Tue, 03 Dec 2019 03:17:43 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Improve declaration reference syntax to allow linking to overloaded functions/methods
|
||||
|
||||
## 7.6.0
|
||||
Sun, 24 Nov 2019 00:54:04 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Added support for `@throws`
|
||||
|
||||
## 7.5.6
|
||||
Fri, 15 Nov 2019 04:50:50 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.5.5
|
||||
Mon, 11 Nov 2019 16:07:56 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.5.4
|
||||
Tue, 05 Nov 2019 06:49:28 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Fix an issue where API reports sometimes were ordered differently depending on the version of NodeJS (GitHub #1552)
|
||||
|
||||
## 7.5.3
|
||||
Tue, 05 Nov 2019 01:08:39 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Clarified an error message
|
||||
|
||||
## 7.5.2
|
||||
Tue, 22 Oct 2019 06:24:44 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Refactor some code as part of migration from TSLint to ESLint
|
||||
|
||||
## 7.5.1
|
||||
Sun, 29 Sep 2019 23:56:29 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update repository URL
|
||||
|
||||
## 7.5.0
|
||||
Wed, 25 Sep 2019 15:15:31 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add ApiItem.getMergedSiblings() API
|
||||
|
||||
## 7.4.2
|
||||
Mon, 23 Sep 2019 15:14:55 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Remove unnecessary dependency on @types/node
|
||||
|
||||
## 7.4.1
|
||||
Tue, 10 Sep 2019 22:32:23 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update documentation
|
||||
|
||||
## 7.4.0
|
||||
Tue, 10 Sep 2019 20:38:33 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add 'canonicalReference' to ExcerptToken
|
||||
|
||||
## 7.3.4
|
||||
Wed, 04 Sep 2019 18:28:06 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.3.3
|
||||
Wed, 04 Sep 2019 15:15:37 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Update TSDoc dependency to 0.12.14
|
||||
|
||||
## 7.3.2
|
||||
Thu, 08 Aug 2019 15:14:17 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.3.1
|
||||
Thu, 08 Aug 2019 00:49:05 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- (Experimental) Add ApiExtractor.canonicalReference which is a beta implementation of the revised TSDoc declaration reference notation
|
||||
|
||||
## 7.3.0
|
||||
Mon, 22 Jul 2019 19:13:10 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Rename `ApiItem.canonicalReference` to `.containerKey`; rename `ApiItemContainerMixin.tryGetMember()` to `.tryGetMemberByKey()`; rename `Api___.getCanonicalReference()` to `.getContainerKey()`
|
||||
|
||||
## 7.2.0
|
||||
Tue, 11 Jun 2019 00:48:06 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Add API support for type parameters and type alias types
|
||||
|
||||
### Patches
|
||||
|
||||
- Improve the .api.json deserializer to validate the schema version and support backwards compatibility
|
||||
|
||||
## 7.1.3
|
||||
Wed, 05 Jun 2019 19:12:34 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Fix an issue where TSDoc index selectors (ApiParameterListMixin.overloadIndex) started from 0, whereas TSDoc requires a nonzero number
|
||||
|
||||
## 7.1.2
|
||||
Tue, 04 Jun 2019 05:51:53 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Fix an issue where ApiConstructor inherited from ApiStaticMixin, but TypeScript constructors cannot be static
|
||||
|
||||
## 7.1.1
|
||||
Mon, 27 May 2019 04:13:44 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Make the strings returned by ApiItem.displayName less verbose
|
||||
- Improve formatting of the strings returned by ApiItem.getScopedNameWithinPackage()
|
||||
|
||||
## 7.1.0
|
||||
Tue, 16 Apr 2019 11:01:37 GMT
|
||||
|
||||
### Minor changes
|
||||
|
||||
- Initial stable release of API Extractor 7
|
||||
|
||||
## 7.0.28
|
||||
Wed, 20 Mar 2019 19:14:49 GMT
|
||||
|
||||
_Version update only_
|
||||
|
||||
## 7.0.27
|
||||
Mon, 18 Mar 2019 04:28:43 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Add helper functions for ReleaseTag
|
||||
- Export IApiItemConstructor to eliminate the ae-forgotten-export warning
|
||||
|
||||
## 7.0.26
|
||||
Wed, 13 Mar 2019 19:13:14 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Refactor code to move the IndentedWriter API from api-extractor-model to api-documenter
|
||||
|
||||
## 7.0.25
|
||||
Wed, 13 Mar 2019 01:14:05 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Upgrade TSDoc
|
||||
|
||||
## 7.0.24
|
||||
Mon, 11 Mar 2019 16:13:36 GMT
|
||||
|
||||
### Patches
|
||||
|
||||
- Initial setup of new package @microsoft/api-extractor-model
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
@microsoft/api-extractor
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,67 +0,0 @@
|
||||
# @discordjs/api-extractor-model
|
||||
|
||||
Use this library to read and write \*.api.json files as defined by the [API Extractor](https://api-extractor.com/) tool.
|
||||
These files are used to generate a documentation website for your TypeScript package. The files store the
|
||||
API signatures and doc comments that were extracted from your package.
|
||||
|
||||
API documentation for this package: https://rushstack.io/pages/api/api-extractor-model/
|
||||
|
||||
## Example Usage
|
||||
|
||||
The following code sample shows how to load `example.api.json`, which would be generated by API Extractor
|
||||
when it analyzes a hypothetical NPM package called `example`:
|
||||
|
||||
```ts
|
||||
import { ApiModel, ApiPackage } from '@discordjs/api-extractor-model';
|
||||
|
||||
const apiModel: ApiModel = new ApiModel();
|
||||
const apiPackage: ApiPackage = apiModel.loadPackage('example.api.json');
|
||||
|
||||
for (const member of apiPackage.members) {
|
||||
console.log(member.displayName);
|
||||
}
|
||||
```
|
||||
|
||||
The `ApiModel` is acts as a container for various packages that are loaded and operated on as a group.
|
||||
For example, a documentation tool may need to resolve `@link` references across different packages.
|
||||
In this case we would load the various packages into the `ApiModel`, and then use
|
||||
the `ApiModel.resolveDeclarationReference()` to resolve the `@link` targets.
|
||||
|
||||
The data structure forms a tree of various classes that start with the `Api` prefix. The nesting hierarchy
|
||||
might look like this:
|
||||
|
||||
```
|
||||
- ApiModel
|
||||
- ApiPackage
|
||||
- ApiEntryPoint
|
||||
- ApiClass
|
||||
- ApiMethod
|
||||
- ApiProperty
|
||||
- ApiEnum
|
||||
- ApiEnumMember
|
||||
- ApiInterface
|
||||
- ApiMethodSignature
|
||||
- ApiPropertySignature
|
||||
- ApiNamespace
|
||||
- (ApiClass, ApiEnum, ApiInterface, ...)
|
||||
```
|
||||
|
||||
You can use the `ApiItem.members` property to traverse this tree.
|
||||
|
||||
Note that the non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
|
||||
TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
|
||||
features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
|
||||
to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
|
||||
the function that generates a subclass, an interface that describes the members of the subclass, and
|
||||
a namespace containing static members of the class.
|
||||
|
||||
> For a complete project that uses these APIs to generate an API reference web site,
|
||||
> see the [@microsoft/api-documenter](https://www.npmjs.com/package/@microsoft/api-documenter) source code.
|
||||
|
||||
## Links
|
||||
|
||||
- [CHANGELOG.md](https://github.com/discordjs/discord.js/blob/main/packages/api-extractor-model/CHANGELOG.md) - Find
|
||||
out what's new in the latest version
|
||||
- [API Reference](https://rushstack.io/pages/api/api-extractor-model/)
|
||||
|
||||
API Extractor is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
|
||||
|
||||
"apiReport": {
|
||||
"enabled": true,
|
||||
"reportFolder": "../../../common/reviews/api"
|
||||
},
|
||||
|
||||
"docModel": {
|
||||
"enabled": true,
|
||||
"apiJsonFilePath": "../../../common/temp/api/<unscopedPackageName>.api.json"
|
||||
},
|
||||
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"untrimmedFilePath": "<projectFolder>/dist/rollup.d.ts"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"extends": "@rushstack/heft-node-rig/profiles/default/config/jest.config.json",
|
||||
|
||||
// Enable code coverage for Jest
|
||||
"collectCoverage": true,
|
||||
"coverageDirectory": "<rootDir>/coverage",
|
||||
"coverageReporters": ["cobertura", "html"],
|
||||
|
||||
// Use v8 coverage provider to avoid Babel
|
||||
"coverageProvider": "v8"
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
{
|
||||
"name": "@discordjs/api-extractor-model",
|
||||
"version": "7.28.2",
|
||||
"description": "A helper library for loading and saving the .api.json files created by API Extractor",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/api-extractor-model"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc --noEmit && tsup",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/tsdoc": "0.14.2",
|
||||
"@microsoft/tsdoc-config": "0.16.2",
|
||||
"@rushstack/node-core-library": "4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^18.19.45",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-neon": "^0.1.62",
|
||||
"eslint-formatter-pretty": "^6.0.1",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.3.3",
|
||||
"tsup": "^8.2.4",
|
||||
"turbo": "^2.0.14",
|
||||
"typescript": "~5.5.4"
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind, StandardTags } from '@microsoft/tsdoc';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated - tsdoc configuration is now constructed from tsdoc.json files associated with each package.
|
||||
*/
|
||||
export class AedocDefinitions {
|
||||
public static readonly betaDocumentation: TSDocTagDefinition = new TSDocTagDefinition({
|
||||
tagName: '@betaDocumentation',
|
||||
syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
||||
});
|
||||
|
||||
public static readonly internalRemarks: TSDocTagDefinition = new TSDocTagDefinition({
|
||||
tagName: '@internalRemarks',
|
||||
syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
||||
});
|
||||
|
||||
public static readonly preapprovedTag: TSDocTagDefinition = new TSDocTagDefinition({
|
||||
tagName: '@preapproved',
|
||||
syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
||||
});
|
||||
|
||||
public static get tsdocConfiguration(): TSDocConfiguration {
|
||||
if (!AedocDefinitions._tsdocConfiguration) {
|
||||
const configuration: TSDocConfiguration = new TSDocConfiguration();
|
||||
configuration.addTagDefinitions(
|
||||
[AedocDefinitions.betaDocumentation, AedocDefinitions.internalRemarks, AedocDefinitions.preapprovedTag],
|
||||
true,
|
||||
);
|
||||
|
||||
configuration.setSupportForTags(
|
||||
[
|
||||
StandardTags.alpha,
|
||||
StandardTags.beta,
|
||||
StandardTags.decorator,
|
||||
StandardTags.defaultValue,
|
||||
StandardTags.deprecated,
|
||||
StandardTags.eventProperty,
|
||||
StandardTags.example,
|
||||
StandardTags.inheritDoc,
|
||||
StandardTags.internal,
|
||||
StandardTags.link,
|
||||
StandardTags.override,
|
||||
StandardTags.packageDocumentation,
|
||||
StandardTags.param,
|
||||
StandardTags.privateRemarks,
|
||||
StandardTags.public,
|
||||
StandardTags.readonly,
|
||||
StandardTags.remarks,
|
||||
StandardTags.returns,
|
||||
StandardTags.sealed,
|
||||
StandardTags.throws,
|
||||
StandardTags.virtual,
|
||||
],
|
||||
true,
|
||||
);
|
||||
|
||||
AedocDefinitions._tsdocConfiguration = configuration;
|
||||
}
|
||||
|
||||
return AedocDefinitions._tsdocConfiguration;
|
||||
}
|
||||
|
||||
private static _tsdocConfiguration: TSDocConfiguration | undefined;
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
/**
|
||||
* A "release tag" is a custom TSDoc tag that is applied to an API to communicate the level of support
|
||||
* provided for third-party developers.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* The four release tags are: `@internal`, `@alpha`, `@beta`, and `@public`. They are applied to API items such
|
||||
* as classes, member functions, enums, etc. The release tag applies recursively to members of a container
|
||||
* (e.g. class or interface). For example, if a class is marked as `@beta`, then all of its members automatically
|
||||
* have this status; you DON'T need add the `@beta` tag to each member function. However, you could add
|
||||
* `@internal` to a member function to give it a different release status.
|
||||
* @public
|
||||
*/
|
||||
export enum ReleaseTag {
|
||||
/**
|
||||
* No release tag was specified in the AEDoc summary.
|
||||
*/
|
||||
None = 0,
|
||||
/**
|
||||
* Indicates that an API item is meant only for usage by other NPM packages from the same
|
||||
* maintainer. Third parties should never use "internal" APIs. (To emphasize this, their
|
||||
* names are prefixed by underscores.)
|
||||
*/
|
||||
Internal = 1,
|
||||
/**
|
||||
* Indicates that an API item is eventually intended to be public, but currently is in an
|
||||
* early stage of development. Third parties should not use "alpha" APIs.
|
||||
*/
|
||||
Alpha = 2,
|
||||
/**
|
||||
* Indicates that an API item has been released in an experimental state. Third parties are
|
||||
* encouraged to try it and provide feedback. However, a "beta" API should NOT be used
|
||||
* in production.
|
||||
*/
|
||||
Beta = 3,
|
||||
/**
|
||||
* Indicates that an API item has been officially released. It is part of the supported
|
||||
* contract (e.g. SemVer) for a package.
|
||||
*/
|
||||
Public = 4,
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions for working with the `ReleaseTag` enum.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
// export namespace ReleaseTag {
|
||||
/**
|
||||
* Returns the TSDoc tag name for a `ReleaseTag` value.
|
||||
*
|
||||
* @remarks
|
||||
* For example, `getTagName(ReleaseTag.Internal)` would return the string `@internal`.
|
||||
*/
|
||||
export function getTagName(releaseTag: ReleaseTag): string {
|
||||
switch (releaseTag) {
|
||||
case ReleaseTag.None:
|
||||
return '(none)';
|
||||
case ReleaseTag.Internal:
|
||||
return '@internal';
|
||||
case ReleaseTag.Alpha:
|
||||
return '@alpha';
|
||||
case ReleaseTag.Beta:
|
||||
return '@beta';
|
||||
case ReleaseTag.Public:
|
||||
return '@public';
|
||||
default:
|
||||
throw new Error('Unsupported release tag');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two `ReleaseTag` values. Their values must not be `ReleaseTag.None`.
|
||||
*
|
||||
* @returns 0 if `a` and `b` are equal, a positive number if `a` is more public than `b`,
|
||||
* and a negative number if `a` is less public than `b`.
|
||||
* @remarks
|
||||
* For example, `compareReleaseTag(ReleaseTag.Beta, ReleaseTag.Alpha)` will return a positive
|
||||
* number because beta is more public than alpha.
|
||||
*/
|
||||
export function compare(a: ReleaseTag, b: ReleaseTag): number {
|
||||
return a - b;
|
||||
}
|
||||
// }
|
||||
@@ -1,85 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
/**
|
||||
* Use this library to read and write *.api.json files as defined by the
|
||||
* {@link https://api-extractor.com/ | API Extractor} tool. These files are used to generate a documentation
|
||||
* website for your TypeScript package. The files store the API signatures and doc comments that were extracted
|
||||
* from your package.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export { AedocDefinitions } from './aedoc/AedocDefinitions.js';
|
||||
export { ReleaseTag, compare as releaseTagCompare, getTagName as releaseTagGetTagName } from './aedoc/ReleaseTag.js';
|
||||
|
||||
// items
|
||||
export { type IApiDeclaredItemOptions, ApiDeclaredItem } from './items/ApiDeclaredItem.js';
|
||||
export { type IApiDocumentedItemOptions, ApiDocumentedItem } from './items/ApiDocumentedItem.js';
|
||||
export { ApiItemKind, type IApiItemOptions, ApiItem, type IApiItemConstructor } from './items/ApiItem.js';
|
||||
export { type IApiPropertyItemOptions, ApiPropertyItem } from './items/ApiPropertyItem.js';
|
||||
|
||||
// mixins
|
||||
export {
|
||||
type IApiParameterListMixinOptions,
|
||||
type IApiParameterOptions,
|
||||
ApiParameterListMixin,
|
||||
} from './mixins/ApiParameterListMixin.js';
|
||||
export {
|
||||
type IApiTypeParameterOptions,
|
||||
type IApiTypeParameterListMixinOptions,
|
||||
ApiTypeParameterListMixin,
|
||||
} from './mixins/ApiTypeParameterListMixin.js';
|
||||
export { type IApiAbstractMixinOptions, ApiAbstractMixin } from './mixins/ApiAbstractMixin.js';
|
||||
export { type IApiItemContainerMixinOptions, ApiItemContainerMixin } from './mixins/ApiItemContainerMixin.js';
|
||||
export { type IApiProtectedMixinOptions, ApiProtectedMixin } from './mixins/ApiProtectedMixin.js';
|
||||
export { type IApiReleaseTagMixinOptions, ApiReleaseTagMixin } from './mixins/ApiReleaseTagMixin.js';
|
||||
export { type IApiReturnTypeMixinOptions, ApiReturnTypeMixin } from './mixins/ApiReturnTypeMixin.js';
|
||||
export { type IApiStaticMixinOptions, ApiStaticMixin } from './mixins/ApiStaticMixin.js';
|
||||
export { type IApiNameMixinOptions, ApiNameMixin } from './mixins/ApiNameMixin.js';
|
||||
export { type IApiOptionalMixinOptions, ApiOptionalMixin } from './mixins/ApiOptionalMixin.js';
|
||||
export { type IApiReadonlyMixinOptions, ApiReadonlyMixin } from './mixins/ApiReadonlyMixin.js';
|
||||
export { type IApiInitializerMixinOptions, ApiInitializerMixin } from './mixins/ApiInitializerMixin.js';
|
||||
export { type IApiExportedMixinOptions, ApiExportedMixin } from './mixins/ApiExportedMixin.js';
|
||||
export {
|
||||
type IFindApiItemsResult,
|
||||
type IFindApiItemsMessage,
|
||||
FindApiItemsMessageId,
|
||||
} from './mixins/IFindApiItemsResult.js';
|
||||
|
||||
export {
|
||||
ExcerptTokenKind,
|
||||
type IExcerptTokenRange,
|
||||
type IExcerptToken,
|
||||
ExcerptToken,
|
||||
Excerpt,
|
||||
} from './mixins/Excerpt.js';
|
||||
export type { Constructor, PropertiesOf } from './mixins/Mixin.js';
|
||||
|
||||
// model
|
||||
export { type IApiCallSignatureOptions, ApiCallSignature } from './model/ApiCallSignature.js';
|
||||
export { type IApiClassOptions, ApiClass, type IExcerptTokenRangeWithTypeParameters } from './model/ApiClass.js';
|
||||
export { type IApiConstructorOptions, ApiConstructor } from './model/ApiConstructor.js';
|
||||
export { type IApiConstructSignatureOptions, ApiConstructSignature } from './model/ApiConstructSignature.js';
|
||||
export { type IApiEntryPointOptions, ApiEntryPoint } from './model/ApiEntryPoint.js';
|
||||
export { type IApiEnumOptions, ApiEnum } from './model/ApiEnum.js';
|
||||
export { type IApiEnumMemberOptions, ApiEnumMember, EnumMemberOrder } from './model/ApiEnumMember.js';
|
||||
export { type IApiEventOptions, ApiEvent } from './model/ApiEvent.js';
|
||||
export { type IApiFunctionOptions, ApiFunction } from './model/ApiFunction.js';
|
||||
export { type IApiIndexSignatureOptions, ApiIndexSignature } from './model/ApiIndexSignature.js';
|
||||
export { type IApiInterfaceOptions, ApiInterface } from './model/ApiInterface.js';
|
||||
export { type IApiMethodOptions, ApiMethod } from './model/ApiMethod.js';
|
||||
export { type IApiMethodSignatureOptions, ApiMethodSignature } from './model/ApiMethodSignature.js';
|
||||
export { ApiModel } from './model/ApiModel.js';
|
||||
export { type IApiNamespaceOptions, ApiNamespace } from './model/ApiNamespace.js';
|
||||
export { type IApiPackageOptions, ApiPackage, type IApiPackageSaveOptions } from './model/ApiPackage.js';
|
||||
export { type IParameterOptions, Parameter } from './model/Parameter.js';
|
||||
export { type IApiPropertyOptions, ApiProperty } from './model/ApiProperty.js';
|
||||
export { type IApiPropertySignatureOptions, ApiPropertySignature } from './model/ApiPropertySignature.js';
|
||||
export { type IApiTypeAliasOptions, ApiTypeAlias } from './model/ApiTypeAlias.js';
|
||||
export { type ITypeParameterOptions, TypeParameter } from './model/TypeParameter.js';
|
||||
export { type IApiVariableOptions, ApiVariable } from './model/ApiVariable.js';
|
||||
export type { IResolveDeclarationReferenceResult } from './model/ModelReferenceResolver.js';
|
||||
export { HeritageType } from './model/HeritageType.js';
|
||||
export { type ISourceLocationOptions, SourceLocation } from './model/SourceLocation.js';
|
||||
export { Navigation, Meaning } from './items/ApiItem.js';
|
||||
@@ -1,225 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
|
||||
import { Excerpt, ExcerptToken, type IExcerptTokenRange, type IExcerptToken } from '../mixins/Excerpt.js';
|
||||
import type { DeserializerContext } from '../model/DeserializerContext.js';
|
||||
import { SourceLocation } from '../model/SourceLocation.js';
|
||||
import { ApiDocumentedItem, type IApiDocumentedItemJson, type IApiDocumentedItemOptions } from './ApiDocumentedItem.js';
|
||||
import type { ApiItem } from './ApiItem.js';
|
||||
|
||||
/**
|
||||
* Constructor options for {@link ApiDeclaredItem}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {
|
||||
excerptTokens: IExcerptToken[];
|
||||
fileColumn?: number | undefined;
|
||||
fileLine?: number | undefined;
|
||||
fileUrlPath?: string | undefined;
|
||||
}
|
||||
|
||||
export interface IApiDeclaredItemJson extends IApiDocumentedItemJson {
|
||||
excerptTokens: IExcerptToken[];
|
||||
fileColumn?: number;
|
||||
fileLine?: number;
|
||||
fileUrlPath?: string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base class for API items that have an associated source code excerpt containing a TypeScript declaration.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
|
||||
* API declarations.
|
||||
*
|
||||
* Most `ApiItem` subclasses have declarations and thus extend `ApiDeclaredItem`. Counterexamples include
|
||||
* `ApiModel` and `ApiPackage`, which do not have any corresponding TypeScript source code.
|
||||
* @public
|
||||
*/
|
||||
|
||||
export class ApiDeclaredItem extends ApiDocumentedItem {
|
||||
private readonly _excerptTokens: ExcerptToken[];
|
||||
|
||||
private readonly _excerpt: Excerpt;
|
||||
|
||||
private readonly _fileUrlPath?: string | undefined;
|
||||
|
||||
private readonly _fileLine?: number | undefined;
|
||||
|
||||
private readonly _fileColumn?: number | undefined;
|
||||
|
||||
private _sourceLocation?: SourceLocation;
|
||||
|
||||
public constructor(options: IApiDeclaredItemOptions) {
|
||||
super(options);
|
||||
|
||||
this._excerptTokens = options.excerptTokens.map((token) => {
|
||||
const canonicalReference: DeclarationReference | undefined =
|
||||
token.canonicalReference === undefined ? undefined : DeclarationReference.parse(token.canonicalReference);
|
||||
return new ExcerptToken(token.kind, token.text, canonicalReference);
|
||||
});
|
||||
this._excerpt = new Excerpt(this.excerptTokens, { startIndex: 0, endIndex: this.excerptTokens.length });
|
||||
this._fileUrlPath = options.fileUrlPath;
|
||||
this._fileLine = options.fileLine;
|
||||
this._fileColumn = options.fileColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public static override onDeserializeInto(
|
||||
options: Partial<IApiDeclaredItemOptions>,
|
||||
context: DeserializerContext,
|
||||
jsonObject: IApiDeclaredItemJson,
|
||||
): void {
|
||||
super.onDeserializeInto(options, context, jsonObject);
|
||||
|
||||
options.excerptTokens = jsonObject.excerptTokens;
|
||||
options.fileUrlPath = jsonObject.fileUrlPath;
|
||||
options.fileLine = jsonObject.fileLine;
|
||||
options.fileColumn = jsonObject.fileColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* The source code excerpt where the API item is declared.
|
||||
*/
|
||||
public get excerpt(): Excerpt {
|
||||
return this._excerpt;
|
||||
}
|
||||
|
||||
/**
|
||||
* The individual source code tokens that comprise the main excerpt.
|
||||
*/
|
||||
public get excerptTokens(): readonly ExcerptToken[] {
|
||||
return this._excerptTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* The file URL path relative to the `projectFolder` and `projectFolderURL` fields
|
||||
* as defined in the `api-extractor.json` config. Is `undefined` if the path is
|
||||
* the same as the parent API item's.
|
||||
*/
|
||||
public get fileUrlPath(): string | undefined {
|
||||
return this._fileUrlPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* The line in the `fileUrlPath` where the API item is declared.
|
||||
*/
|
||||
public get fileLine(): number | undefined {
|
||||
return this._fileLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column in the `fileUrlPath` where the API item is declared.
|
||||
*/
|
||||
public get fileColumn(): number | undefined {
|
||||
return this._fileColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source location where the API item is declared.
|
||||
*/
|
||||
public get sourceLocation(): SourceLocation {
|
||||
if (!this._sourceLocation) {
|
||||
this._sourceLocation = this._buildSourceLocation();
|
||||
}
|
||||
|
||||
return this._sourceLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the API item has certain important modifier tags such as `@sealed`, `@virtual`, or `@override`,
|
||||
* this prepends them as a doc comment above the excerpt.
|
||||
*/
|
||||
public getExcerptWithModifiers(): string {
|
||||
const excerpt: string = this.excerpt.text;
|
||||
const modifierTags: string[] = [];
|
||||
|
||||
if (excerpt.length > 0 && this instanceof ApiDocumentedItem) {
|
||||
if (this.tsdocComment) {
|
||||
if (this.tsdocComment.modifierTagSet.isSealed()) {
|
||||
modifierTags.push('@sealed');
|
||||
}
|
||||
|
||||
if (this.tsdocComment.modifierTagSet.isVirtual()) {
|
||||
modifierTags.push('@virtual');
|
||||
}
|
||||
|
||||
if (this.tsdocComment.modifierTagSet.isOverride()) {
|
||||
modifierTags.push('@override');
|
||||
}
|
||||
}
|
||||
|
||||
if (modifierTags.length > 0) {
|
||||
return '/** ' + modifierTags.join(' ') + ' */\n' + excerpt;
|
||||
}
|
||||
}
|
||||
|
||||
return excerpt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public override serializeInto(jsonObject: Partial<IApiDeclaredItemJson>): void {
|
||||
super.serializeInto(jsonObject);
|
||||
jsonObject.excerptTokens = this.excerptTokens.map((x) => {
|
||||
const excerptToken: IExcerptToken = { kind: x.kind, text: x.text };
|
||||
if (x.canonicalReference !== undefined) {
|
||||
excerptToken.canonicalReference = x.canonicalReference.toString();
|
||||
}
|
||||
|
||||
return excerptToken;
|
||||
});
|
||||
|
||||
// Only serialize this API item's file URL path if it exists and it's different from its parent's
|
||||
// (a little optimization to keep the doc model succinct).
|
||||
if (
|
||||
this.fileUrlPath &&
|
||||
(!(this.parent instanceof ApiDeclaredItem) || this.fileUrlPath !== this.parent.fileUrlPath)
|
||||
) {
|
||||
jsonObject.fileUrlPath = this.fileUrlPath;
|
||||
}
|
||||
|
||||
if (this.fileLine) {
|
||||
jsonObject.fileLine = this.fileLine;
|
||||
}
|
||||
|
||||
if (this.fileColumn) {
|
||||
jsonObject.fileColumn = this.fileColumn;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Excerpt} corresponding to the provided token range.
|
||||
*/
|
||||
public buildExcerpt(tokenRange: IExcerptTokenRange): Excerpt {
|
||||
return new Excerpt(this.excerptTokens, tokenRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the cached object used by the `sourceLocation` property.
|
||||
*/
|
||||
private _buildSourceLocation(): SourceLocation {
|
||||
const projectFolderUrl: string | undefined = this.getAssociatedPackage()?.projectFolderUrl;
|
||||
|
||||
let fileUrlPath: string | undefined;
|
||||
for (let current: ApiItem | undefined = this; current !== undefined; current = current.parent) {
|
||||
if (current instanceof ApiDeclaredItem && current.fileUrlPath) {
|
||||
fileUrlPath = current.fileUrlPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new SourceLocation({
|
||||
projectFolderUrl,
|
||||
fileUrlPath,
|
||||
sourceFileColumn: this.fileColumn,
|
||||
sourceFileLine: this.fileLine,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import * as tsdoc from '@microsoft/tsdoc';
|
||||
import type { DeserializerContext } from '../model/DeserializerContext.js';
|
||||
import { ApiItem, type IApiItemOptions, type IApiItemJson } from './ApiItem.js';
|
||||
|
||||
/**
|
||||
* Constructor options for {@link ApiDocumentedItem}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IApiDocumentedItemOptions extends IApiItemOptions {
|
||||
docComment: tsdoc.DocComment | undefined;
|
||||
}
|
||||
|
||||
export interface IApiDocumentedItemJson extends IApiItemJson {
|
||||
docComment: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An abstract base class for API declarations that can have an associated TSDoc comment.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
|
||||
* API declarations.
|
||||
* @public
|
||||
*/
|
||||
export class ApiDocumentedItem extends ApiItem {
|
||||
private readonly _tsdocComment: tsdoc.DocComment | undefined;
|
||||
|
||||
public constructor(options: IApiDocumentedItemOptions) {
|
||||
super(options);
|
||||
this._tsdocComment = options.docComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public static override onDeserializeInto(
|
||||
options: Partial<IApiDocumentedItemOptions>,
|
||||
context: DeserializerContext,
|
||||
jsonObject: IApiItemJson,
|
||||
): void {
|
||||
super.onDeserializeInto(options, context, jsonObject);
|
||||
|
||||
const documentedJson: IApiDocumentedItemJson = jsonObject as IApiDocumentedItemJson;
|
||||
|
||||
if (documentedJson.docComment) {
|
||||
const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(context.tsdocConfiguration);
|
||||
|
||||
// NOTE: For now, we ignore TSDoc errors found in a serialized .api.json file.
|
||||
// Normally these errors would have already been reported by API Extractor during analysis.
|
||||
// However, they could also arise if the JSON file was edited manually, or if the file was saved
|
||||
// using a different release of the software that used an incompatible syntax.
|
||||
const parserContext: tsdoc.ParserContext = tsdocParser.parseString(documentedJson.docComment);
|
||||
|
||||
options.docComment = parserContext.docComment;
|
||||
}
|
||||
}
|
||||
|
||||
public get tsdocComment(): tsdoc.DocComment | undefined {
|
||||
return this._tsdocComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public override serializeInto(jsonObject: Partial<IApiDocumentedItemJson>): void {
|
||||
super.serializeInto(jsonObject);
|
||||
if (this.tsdocComment === undefined) {
|
||||
jsonObject.docComment = '';
|
||||
} else {
|
||||
jsonObject.docComment = this.tsdocComment.emitAsTsdoc();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,375 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
|
||||
import { InternalError } from '@rushstack/node-core-library';
|
||||
import { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin.js';
|
||||
import { ApiParameterListMixin } from '../mixins/ApiParameterListMixin.js';
|
||||
import type { Constructor, PropertiesOf } from '../mixins/Mixin.js';
|
||||
import type { ApiModel } from '../model/ApiModel.js';
|
||||
import type { ApiPackage } from '../model/ApiPackage.js';
|
||||
import type { DocgenJson } from '../model/Deserializer';
|
||||
import type { DeserializerContext } from '../model/DeserializerContext.js';
|
||||
|
||||
/**
|
||||
* The type returned by the {@link ApiItem.kind} property, which can be used to easily distinguish subclasses of
|
||||
* {@link ApiItem}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export enum ApiItemKind {
|
||||
CallSignature = 'CallSignature',
|
||||
Class = 'Class',
|
||||
ConstructSignature = 'ConstructSignature',
|
||||
Constructor = 'Constructor',
|
||||
EntryPoint = 'EntryPoint',
|
||||
Enum = 'Enum',
|
||||
EnumMember = 'EnumMember',
|
||||
Event = 'Event',
|
||||
Function = 'Function',
|
||||
IndexSignature = 'IndexSignature',
|
||||
Interface = 'Interface',
|
||||
Method = 'Method',
|
||||
MethodSignature = 'MethodSignature',
|
||||
Model = 'Model',
|
||||
Namespace = 'Namespace',
|
||||
None = 'None',
|
||||
Package = 'Package',
|
||||
Property = 'Property',
|
||||
PropertySignature = 'PropertySignature',
|
||||
TypeAlias = 'TypeAlias',
|
||||
Variable = 'Variable',
|
||||
}
|
||||
/**
|
||||
* Indicates the symbol table from which to resolve the next symbol component.
|
||||
*
|
||||
* @beta
|
||||
*/
|
||||
export enum Navigation {
|
||||
Exports = '.',
|
||||
Locals = '~',
|
||||
Members = '#',
|
||||
}
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export enum Meaning {
|
||||
CallSignature = 'call',
|
||||
Class = 'class',
|
||||
ComplexType = 'complex',
|
||||
ConstructSignature = 'new',
|
||||
Constructor = 'constructor',
|
||||
Enum = 'enum',
|
||||
Event = 'event',
|
||||
Function = 'function',
|
||||
IndexSignature = 'index',
|
||||
Interface = 'interface',
|
||||
Member = 'member',
|
||||
Namespace = 'namespace',
|
||||
TypeAlias = 'type',
|
||||
Variable = 'var',
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor options for {@link ApiItem}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface IApiItemOptions {}
|
||||
|
||||
export interface IApiItemJson {
|
||||
canonicalReference: string;
|
||||
kind: ApiItemKind;
|
||||
}
|
||||
|
||||
// PRIVATE - Allows ApiItemContainerMixin to assign the parent.
|
||||
//
|
||||
export const apiItem_onParentChanged: unique symbol = Symbol('ApiItem._onAddToContainer');
|
||||
|
||||
/**
|
||||
* The abstract base class for all members of an `ApiModel` object.
|
||||
*
|
||||
* @remarks
|
||||
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
|
||||
* API declarations.
|
||||
* @public
|
||||
*/
|
||||
export class ApiItem {
|
||||
private _canonicalReference: DeclarationReference | undefined;
|
||||
|
||||
private _parent: ApiItem | undefined;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
||||
public constructor(_options: IApiItemOptions) {
|
||||
// ("options" is not used here, but part of the inheritance pattern)
|
||||
}
|
||||
|
||||
public static deserialize(jsonObject: IApiItemJson, context: DeserializerContext): ApiItem {
|
||||
// The Deserializer class is coupled with a ton of other classes, so we delay loading it
|
||||
// to avoid ES5 circular imports.
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||
const deserializerModule: typeof import('../model/Deserializer') = require('../model/Deserializer');
|
||||
return deserializerModule.Deserializer.deserialize(context, jsonObject);
|
||||
}
|
||||
|
||||
public static deserializeDocgen(jsonObject: DocgenJson, _package: string): ApiItem {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||
const deserializerModule: typeof import('../model/Deserializer') = require('../model/Deserializer');
|
||||
return deserializerModule.Deserializer.deserializeDocgen(jsonObject, _package);
|
||||
}
|
||||
|
||||
/**
|
||||
* @virtual
|
||||
*/
|
||||
public static onDeserializeInto(
|
||||
_options: Partial<IApiItemOptions>,
|
||||
_context: DeserializerContext,
|
||||
_jsonObject: IApiItemJson,
|
||||
): void {
|
||||
// (implemented by subclasses)
|
||||
}
|
||||
|
||||
/**
|
||||
* @virtual
|
||||
*/
|
||||
public serializeInto(jsonObject: Partial<IApiItemJson>): void {
|
||||
jsonObject.kind = this.kind;
|
||||
jsonObject.canonicalReference = this.canonicalReference.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies the subclass of the `ApiItem` base class.
|
||||
*
|
||||
* @virtual
|
||||
*/
|
||||
public get kind(): ApiItemKind {
|
||||
throw new Error('ApiItem.kind was not implemented by the child class');
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning: This API is used internally by API extractor but is not yet ready for general usage.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Returns a `DeclarationReference` object using the experimental new declaration reference notation.
|
||||
* @beta
|
||||
*/
|
||||
public get canonicalReference(): DeclarationReference {
|
||||
if (!this._canonicalReference) {
|
||||
try {
|
||||
this._canonicalReference = this.buildCanonicalReference();
|
||||
} catch (error) {
|
||||
const name: string = this.getScopedNameWithinPackage() || this.displayName;
|
||||
throw new InternalError(`Error building canonical reference for ${name}:\n` + (error as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
return this._canonicalReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string key that can be used to efficiently retrieve an `ApiItem` from an `ApiItemContainerMixin`.
|
||||
* The key is unique within the container. Its format is undocumented and may change at any time.
|
||||
*
|
||||
* @remarks
|
||||
* Use the `getContainerKey()` static member to construct the key. Each subclass has a different implementation
|
||||
* of this function, according to the aspects that are important for identifying it.
|
||||
* @virtual
|
||||
*/
|
||||
public get containerKey(): string {
|
||||
throw new InternalError('ApiItem.containerKey was not implemented by the child class');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a name for this object that can be used in diagnostic messages, for example.
|
||||
*
|
||||
* @remarks
|
||||
* For an object that inherits ApiNameMixin, this will return the declared name (e.g. the name of a TypeScript
|
||||
* function). Otherwise, it will return a string such as "(call signature)" or "(model)".
|
||||
* @virtual
|
||||
*/
|
||||
public get displayName(): string {
|
||||
switch (this.kind) {
|
||||
case ApiItemKind.CallSignature:
|
||||
return '(call)';
|
||||
case ApiItemKind.Constructor:
|
||||
return '(constructor)';
|
||||
case ApiItemKind.ConstructSignature:
|
||||
return '(new)';
|
||||
case ApiItemKind.IndexSignature:
|
||||
return '(indexer)';
|
||||
case ApiItemKind.Model:
|
||||
return '(model)';
|
||||
default:
|
||||
return '(???)'; // All other types should inherit ApiNameMixin which will override this property
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If this item was added to a ApiItemContainerMixin item, then this returns the container item.
|
||||
* If this is an Parameter that was added to a method or function, then this returns the function item.
|
||||
* Otherwise, it returns undefined.
|
||||
*
|
||||
* @virtual
|
||||
*/
|
||||
public get parent(): ApiItem | undefined {
|
||||
return this._parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This property supports a visitor pattern for walking the tree.
|
||||
* For items with ApiItemContainerMixin, it returns the contained items, sorted alphabetically.
|
||||
* Otherwise it returns an empty array.
|
||||
*
|
||||
* @virtual
|
||||
*/
|
||||
public get members(): readonly ApiItem[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* If this item has a name (i.e. extends `ApiNameMixin`), then return all items that have the same parent
|
||||
* and the same name. Otherwise, return all items that have the same parent and the same `ApiItemKind`.
|
||||
*
|
||||
* @remarks
|
||||
* Examples: For a function, this would return all overloads for the function. For a constructor, this would
|
||||
* return all overloads for the constructor. For a merged declaration (e.g. a `namespace` and `enum` with the
|
||||
* same name), this would return both declarations. If this item does not have a parent, or if it is the only
|
||||
* item of its name/kind, then the result is an array containing only this item.
|
||||
*/
|
||||
public getMergedSiblings(): readonly ApiItem[] {
|
||||
const parent: ApiItem | undefined = this._parent;
|
||||
if (parent && ApiItemContainerMixin.isBaseClassOf(parent)) {
|
||||
return parent._getMergedSiblingsForMember(this);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chain of ancestors, starting from the root of the tree, and ending with the this item.
|
||||
*/
|
||||
public getHierarchy(): readonly ApiItem[] {
|
||||
const hierarchy: ApiItem[] = [];
|
||||
for (let current: ApiItem | undefined = this; current !== undefined; current = current.parent) {
|
||||
hierarchy.push(current);
|
||||
}
|
||||
|
||||
hierarchy.reverse();
|
||||
return hierarchy;
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns a scoped name such as `"Namespace1.Namespace2.MyClass.myMember()"`. It does not include the
|
||||
* package name or entry point.
|
||||
*
|
||||
* @remarks
|
||||
* If called on an ApiEntrypoint, ApiPackage, or ApiModel item, the result is an empty string.
|
||||
*/
|
||||
public getScopedNameWithinPackage(): string {
|
||||
const reversedParts: string[] = [];
|
||||
|
||||
for (let current: ApiItem | undefined = this; current !== undefined; current = current.parent) {
|
||||
if (
|
||||
current.kind === ApiItemKind.Model ||
|
||||
current.kind === ApiItemKind.Package ||
|
||||
current.kind === ApiItemKind.EntryPoint
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (reversedParts.length === 0) {
|
||||
switch (current.kind) {
|
||||
case ApiItemKind.CallSignature:
|
||||
case ApiItemKind.ConstructSignature:
|
||||
case ApiItemKind.Constructor:
|
||||
case ApiItemKind.IndexSignature:
|
||||
// These functional forms don't have a proper name, so we don't append the "()" suffix
|
||||
break;
|
||||
default:
|
||||
if (ApiParameterListMixin.isBaseClassOf(current)) {
|
||||
reversedParts.push('()');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reversedParts.push('.');
|
||||
}
|
||||
|
||||
reversedParts.push(current.displayName);
|
||||
}
|
||||
|
||||
return reversedParts.reverse().join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* If this item is an ApiPackage or has an ApiPackage as one of its parents, then that object is returned.
|
||||
* Otherwise undefined is returned.
|
||||
*/
|
||||
public getAssociatedPackage(): ApiPackage | undefined {
|
||||
for (let current: ApiItem | undefined = this; current !== undefined; current = current.parent) {
|
||||
if (current.kind === ApiItemKind.Package) {
|
||||
return current as ApiPackage;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this item is an ApiModel or has an ApiModel as one of its parents, then that object is returned.
|
||||
* Otherwise undefined is returned.
|
||||
*/
|
||||
public getAssociatedModel(): ApiModel | undefined {
|
||||
for (let current: ApiItem | undefined = this; current !== undefined; current = current.parent) {
|
||||
if (current.kind === ApiItemKind.Model) {
|
||||
return current as ApiModel;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* A text string whose value determines the sort order that is automatically applied by the
|
||||
* {@link (ApiItemContainerMixin:interface)} class.
|
||||
*
|
||||
* @remarks
|
||||
* The value of this string is undocumented and may change at any time.
|
||||
* If {@link (ApiItemContainerMixin:interface).preserveMemberOrder} is enabled for the `ApiItem`'s parent,
|
||||
* then no sorting is performed, and this key is not used.
|
||||
* @virtual
|
||||
*/
|
||||
public getSortKey(): string {
|
||||
return this.containerKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* PRIVATE
|
||||
*
|
||||
* @privateRemarks
|
||||
* Allows ApiItemContainerMixin to assign the parent when the item is added to a container.
|
||||
* @internal
|
||||
*/
|
||||
public [apiItem_onParentChanged](parent: ApiItem | undefined): void {
|
||||
this._parent = parent;
|
||||
this._canonicalReference = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the cached object used by the `canonicalReference` property.
|
||||
*
|
||||
* @virtual
|
||||
*/
|
||||
protected buildCanonicalReference(): DeclarationReference {
|
||||
throw new InternalError('ApiItem.canonicalReference was not implemented by the child class');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This abstraction is used by the mixin pattern.
|
||||
* It describes a class type that inherits from {@link ApiItem}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IApiItemConstructor extends Constructor<ApiItem>, PropertiesOf<typeof ApiItem> {}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import { type IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin.js';
|
||||
import { ApiOptionalMixin, type IApiOptionalMixinOptions } from '../mixins/ApiOptionalMixin.js';
|
||||
import { ApiReadonlyMixin, type IApiReadonlyMixinOptions } from '../mixins/ApiReadonlyMixin.js';
|
||||
import { ApiReleaseTagMixin, type IApiReleaseTagMixinOptions } from '../mixins/ApiReleaseTagMixin.js';
|
||||
import type { Excerpt, IExcerptTokenRange } from '../mixins/Excerpt.js';
|
||||
import type { DeserializerContext } from '../model/DeserializerContext.js';
|
||||
import { type IApiDeclaredItemOptions, ApiDeclaredItem, type IApiDeclaredItemJson } from './ApiDeclaredItem.js';
|
||||
|
||||
/**
|
||||
* Constructor options for {@link ApiPropertyItem}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IApiPropertyItemOptions
|
||||
extends IApiNameMixinOptions,
|
||||
IApiReleaseTagMixinOptions,
|
||||
IApiOptionalMixinOptions,
|
||||
IApiReadonlyMixinOptions,
|
||||
IApiDeclaredItemOptions {
|
||||
propertyTypeTokenRange: IExcerptTokenRange;
|
||||
}
|
||||
|
||||
export interface IApiPropertyItemJson extends IApiDeclaredItemJson {
|
||||
propertyTypeTokenRange: IExcerptTokenRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* The abstract base class for {@link ApiProperty} and {@link ApiPropertySignature}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class ApiPropertyItem extends ApiNameMixin(
|
||||
ApiReleaseTagMixin(ApiOptionalMixin(ApiReadonlyMixin(ApiDeclaredItem))),
|
||||
) {
|
||||
/**
|
||||
* An {@link Excerpt} that describes the type of the property.
|
||||
*/
|
||||
public readonly propertyTypeExcerpt: Excerpt;
|
||||
|
||||
public constructor(options: IApiPropertyItemOptions) {
|
||||
super(options);
|
||||
|
||||
this.propertyTypeExcerpt = this.buildExcerpt(options.propertyTypeTokenRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public static override onDeserializeInto(
|
||||
options: Partial<IApiPropertyItemOptions>,
|
||||
context: DeserializerContext,
|
||||
jsonObject: IApiPropertyItemJson,
|
||||
): void {
|
||||
super.onDeserializeInto(options, context, jsonObject);
|
||||
|
||||
options.propertyTypeTokenRange = jsonObject.propertyTypeTokenRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this property should be documented as an event.
|
||||
*
|
||||
* @remarks
|
||||
* The `@eventProperty` TSDoc modifier can be added to readonly properties to indicate that they return an
|
||||
* event object that event handlers can be attached to. The event-handling API is implementation-defined, but
|
||||
* typically the return type would be a class with members such as `addHandler()` and `removeHandler()`.
|
||||
* The documentation should display such properties under an "Events" heading instead of the
|
||||
* usual "Properties" heading.
|
||||
*/
|
||||
public get isEventProperty(): boolean {
|
||||
if (this.tsdocComment) {
|
||||
return this.tsdocComment.modifierTagSet.isEventProperty();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public override serializeInto(jsonObject: Partial<IApiPropertyItemJson>): void {
|
||||
super.serializeInto(jsonObject);
|
||||
|
||||
jsonObject.propertyTypeTokenRange = this.propertyTypeExcerpt.tokenRange;
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem.js';
|
||||
import type { DeserializerContext } from '../model/DeserializerContext.js';
|
||||
|
||||
/**
|
||||
* Constructor options for {@link (ApiAbstractMixin:interface)}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IApiAbstractMixinOptions extends IApiItemOptions {
|
||||
isAbstract: boolean;
|
||||
}
|
||||
|
||||
export interface IApiAbstractMixinJson extends IApiItemJson {
|
||||
isAbstract: boolean;
|
||||
}
|
||||
|
||||
const _isAbstract: unique symbol = Symbol('ApiAbstractMixin._isAbstract');
|
||||
|
||||
/**
|
||||
* The mixin base class for API items that have an abstract modifier.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
|
||||
* API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
|
||||
* TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
|
||||
* features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
|
||||
* to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
|
||||
* the function that generates a subclass, an interface that describes the members of the subclass, and
|
||||
* a namespace containing static members of the class.
|
||||
* @public
|
||||
*/
|
||||
|
||||
export interface ApiAbstractMixin extends ApiItem {
|
||||
/**
|
||||
* Indicates that the API item's value has an 'abstract' modifier.
|
||||
*/
|
||||
readonly isAbstract: boolean;
|
||||
|
||||
serializeInto(jsonObject: Partial<IApiItemJson>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixin function for {@link (ApiAbstractMixin:interface)}.
|
||||
*
|
||||
* @param baseClass - The base class to be extended
|
||||
* @returns A child class that extends baseClass, adding the {@link (ApiAbstractMixin:interface)}
|
||||
* functionality.
|
||||
* @public
|
||||
*/
|
||||
export function ApiAbstractMixin<TBaseClass extends IApiItemConstructor>(
|
||||
baseClass: TBaseClass,
|
||||
): TBaseClass & (new (...args: any[]) => ApiAbstractMixin) {
|
||||
class MixedClass extends baseClass implements ApiAbstractMixin {
|
||||
public [_isAbstract]: boolean;
|
||||
|
||||
public constructor(...args: any[]) {
|
||||
super(...args);
|
||||
|
||||
const options: IApiAbstractMixinOptions = args[0];
|
||||
this[_isAbstract] = options.isAbstract;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public static override onDeserializeInto(
|
||||
options: Partial<IApiAbstractMixinOptions>,
|
||||
context: DeserializerContext,
|
||||
jsonObject: IApiAbstractMixinJson,
|
||||
): void {
|
||||
baseClass.onDeserializeInto(options, context, jsonObject);
|
||||
|
||||
options.isAbstract = jsonObject.isAbstract || false;
|
||||
}
|
||||
|
||||
public get isAbstract(): boolean {
|
||||
return this[_isAbstract];
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public override serializeInto(jsonObject: Partial<IApiAbstractMixinJson>): void {
|
||||
super.serializeInto(jsonObject);
|
||||
|
||||
jsonObject.isAbstract = this.isAbstract;
|
||||
}
|
||||
}
|
||||
|
||||
return MixedClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static members for {@link (ApiAbstractMixin:interface)}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export namespace ApiAbstractMixin {
|
||||
/**
|
||||
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiAbstractMixin` mixin.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
|
||||
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
|
||||
* the TypeScript type system cannot invoke a runtime test.)
|
||||
*/
|
||||
export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiAbstractMixin {
|
||||
return apiItem.hasOwnProperty(_isAbstract);
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
|
||||
import type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem.js';
|
||||
import { Navigation } from '../items/ApiItem.js';
|
||||
import type { DeserializerContext } from '../model/DeserializerContext.js';
|
||||
|
||||
/**
|
||||
* Constructor options for {@link (IApiExportedMixinOptions:interface)}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IApiExportedMixinOptions extends IApiItemOptions {
|
||||
isExported: boolean;
|
||||
}
|
||||
|
||||
export interface IApiExportedMixinJson extends IApiItemJson {
|
||||
isExported: boolean;
|
||||
}
|
||||
|
||||
const _isExported: unique symbol = Symbol('ApiExportedMixin._isExported');
|
||||
|
||||
/**
|
||||
* The mixin base class for API items that can be exported.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
|
||||
* API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
|
||||
* TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
|
||||
* features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
|
||||
* to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
|
||||
* the function that generates a subclass, an interface that describes the members of the subclass, and
|
||||
* a namespace containing static members of the class.
|
||||
* @public
|
||||
*/
|
||||
|
||||
export interface ApiExportedMixin extends ApiItem {
|
||||
/**
|
||||
* Whether the declaration is exported from its parent item container (i.e. either an `ApiEntryPoint` or an
|
||||
* `ApiNamespace`).
|
||||
*
|
||||
* @remarks
|
||||
* Suppose `index.ts` is your entry point:
|
||||
*
|
||||
* ```ts
|
||||
* // index.ts
|
||||
*
|
||||
* export class A {}
|
||||
* class B {}
|
||||
*
|
||||
* namespace n {
|
||||
* export class C {}
|
||||
* class D {}
|
||||
* }
|
||||
*
|
||||
* // file.ts
|
||||
* export class E {}
|
||||
* ```
|
||||
*
|
||||
* Classes `A` and `C` are both exported, while classes `B`, `D`, and `E` are not. `E` is exported from its
|
||||
* local file, but not from its parent item container (i.e. the entry point).
|
||||
*/
|
||||
readonly isExported: boolean;
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
serializeInto(jsonObject: Partial<IApiItemJson>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixin function for {@link (ApiExportedMixin:interface)}.
|
||||
*
|
||||
* @param baseClass - The base class to be extended
|
||||
* @returns A child class that extends baseClass, adding the {@link (ApiExportedMixin:interface)} functionality.
|
||||
* @public
|
||||
*/
|
||||
export function ApiExportedMixin<TBaseClass extends IApiItemConstructor>(
|
||||
baseClass: TBaseClass,
|
||||
): TBaseClass & (new (...args: any[]) => ApiExportedMixin) {
|
||||
class MixedClass extends baseClass implements ApiExportedMixin {
|
||||
public [_isExported]: boolean;
|
||||
|
||||
public constructor(...args: any[]) {
|
||||
super(...args);
|
||||
|
||||
const options: IApiExportedMixinOptions = args[0];
|
||||
this[_isExported] = options.isExported;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public static override onDeserializeInto(
|
||||
options: Partial<IApiExportedMixinOptions>,
|
||||
context: DeserializerContext,
|
||||
jsonObject: IApiExportedMixinJson,
|
||||
): void {
|
||||
baseClass.onDeserializeInto(options, context, jsonObject);
|
||||
|
||||
const declarationReference: DeclarationReference = DeclarationReference.parse(jsonObject.canonicalReference);
|
||||
options.isExported = declarationReference.navigation === (Navigation.Exports as any); // ambient const enums suck...
|
||||
}
|
||||
|
||||
public get isExported(): boolean {
|
||||
return this[_isExported];
|
||||
}
|
||||
|
||||
/**
|
||||
* The `isExported` property is intentionally not serialized because the information is already present
|
||||
* in the item's `canonicalReference`.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
public override serializeInto(jsonObject: Partial<IApiExportedMixinJson>): void {
|
||||
super.serializeInto(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
return MixedClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static members for {@link (ApiExportedMixin:interface)}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export namespace ApiExportedMixin {
|
||||
/**
|
||||
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiExportedMixin` mixin.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
|
||||
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
|
||||
* the TypeScript type system cannot invoke a runtime test.)
|
||||
*/
|
||||
export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiExportedMixin {
|
||||
return apiItem.hasOwnProperty(_isExported);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user