Skip to content

Commit

Permalink
Merge branch 'main' into formatters/id-formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx committed Aug 25, 2023
2 parents a3a35c3 + 0d787e9 commit fc85bf3
Show file tree
Hide file tree
Showing 34 changed files with 495 additions and 177 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/cleanup-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
name: Cleanup caches
on:
pull_request:
types:
- closed
jobs:
cleanup:
name: Cleanup caches
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- 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 }}
2 changes: 1 addition & 1 deletion .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
core.setOutput("comment", comment);
core.setOutput("comment", comment);
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Add comment to PR
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@ jobs:

- name: Build dependencies (PR)
if: ${{ github.event_name != 'push' }}
run: yarn turbo build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}] --concurrency=3"
run: yarn turbo run build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=3

- name: Build dependencies (Push)
if: ${{ github.event_name == 'push' }}
run: yarn turbo build --filter="...[HEAD^1] --concurrency=3"
run: yarn turbo run build --filter="...[HEAD^1]" --concurrency=3

- name: ESLint (PR)
if: ${{ github.event_name != 'push' }}
run: yarn turbo lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=3 -- --format=compact
run: yarn turbo run lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=3 -- --format=compact

- name: ESLint (Push)
if: ${{ github.event_name == 'push' }}
run: yarn turbo lint --filter="...[HEAD^1]" --concurrency=3 -- --format=compact
run: yarn turbo run lint --filter="...[HEAD^1]" --concurrency=3 -- --format=compact

- name: Tests (PR)
if: ${{ github.event_name != 'push' }}
run: yarn turbo test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=3
run: yarn turbo run test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=3

- name: Tests (Push)
if: ${{ github.event_name == 'push' }}
run: yarn turbo test --filter="...[HEAD^1]" --concurrency=3
run: yarn turbo run test --filter="...[HEAD^1]" --concurrency=3

- name: Docs (PR)
if: ${{ github.event_name != 'push' }}
run: yarn turbo docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=3
run: yarn turbo run docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=3

- name: Docs (Push)
if: ${{ github.event_name == 'push' }}
run: yarn turbo docs --filter="...[HEAD^1]" --concurrency=3
run: yarn turbo run docs --filter="...[HEAD^1]" --concurrency=3

- name: Upload Coverage
if: github.repository_owner == 'discordjs'
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.useESLintClass": false,
"eslint.useESLintClass": true,
"eslint.experimental.useFlatConfig": true,
"eslint.workingDirectories": [{ "mode": "auto" }],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
Expand Down
4 changes: 2 additions & 2 deletions apps/guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
"lighthouse": "^11.0.0",
"prettier": "^3.0.2",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"unocss": "^0.55.2",
"vercel": "^32.0.1",
"vercel": "^32.0.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
"lighthouse": "^11.0.0",
"prettier": "^3.0.2",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"vercel": "^32.0.1",
"typescript": "^5.2.2",
"vercel": "^32.0.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
4 changes: 0 additions & 4 deletions apps/website/src/app/docAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { join } from 'node:path';
import { connect } from '@planetscale/database';

const sql = connect({
async fetch(input, init) {
// @ts-expect-error: Deleting cache or setting as undefined, same thing
return fetch(input, { ...init, cache: undefined, next: { revalidate: 3_600 } });
},
url: process.env.DATABASE_URL!,
});

Expand Down
12 changes: 3 additions & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import unocss from '@unocss/eslint-plugin';
import common from 'eslint-config-neon/flat/common.js';
import edge from 'eslint-config-neon/flat/edge.js';
Expand All @@ -10,9 +8,6 @@ import react from 'eslint-config-neon/flat/react.js';
import typescript from 'eslint-config-neon/flat/typescript.js';
import merge from 'lodash.merge';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const commonFiles = '{js,mjs,cjs,ts,mts,cts,jsx,tsx}';

const commonRuleset = merge(...common, { files: [`**/*${commonFiles}`] });
Expand All @@ -24,8 +19,7 @@ const typeScriptRuleset = merge(...typescript, {
languageOptions: {
parserOptions: {
allowAutomaticSingleRunInference: true,
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json', './apps/*/tsconfig.eslint.json', './packages/*/tsconfig.eslint.json'],
project: ['tsconfig.eslint.json', 'apps/*/tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
},
},
rules: {
Expand All @@ -34,7 +28,7 @@ const typeScriptRuleset = merge(...typescript, {
settings: {
'import/resolver': {
typescript: {
project: ['./tsconfig.eslint.json', './apps/*/tsconfig.eslint.json', './packages/*/tsconfig.eslint.json'],
project: ['tsconfig.eslint.json', 'apps/*/tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
},
},
},
Expand Down Expand Up @@ -100,9 +94,9 @@ export default [
'no-restricted-globals': 0,
},
},
reactRuleset,
nextRuleset,
edgeRuleset,
reactRuleset,
{
files: ['**/*{js,mjs,cjs,jsx}'],
rules: { 'tsdoc/syntax': 0 },
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"lodash.merge": "^4.6.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"unocss": "^0.55.2",
"vercel": "^32.0.1",
"vercel": "^32.0.2",
"vitest": "^0.34.2"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"prettier": "^3.0.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
1 change: 1 addition & 0 deletions packages/actions/src/yarnCache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ runs:
YARN_ENABLE_GLOBAL_CACHE: 'false'
YARN_NM_MODE: 'hardlinks-local'
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz
HUSKY: '0'
2 changes: 1 addition & 1 deletion packages/api-extractor-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"prettier": "^3.0.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},
"engines": {
"node": ">=16.11.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/brokers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"prettier": "^3.0.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"prettier": "^3.0.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/collection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"prettier": "^3.0.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"prettier": "^3.0.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/api/applications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable jsdoc/check-param-names */

import type { RequestData, REST } from '@discordjs/rest';
import { type RESTGetCurrentApplicationResult, Routes } from 'discord-api-types/v10';

export class ApplicationsAPI {
public constructor(private readonly rest: REST) {}

/**
* Fetches the application associated with the requesting bot user.
*
* @see {@link https://discord.com/developers/docs/resources/application#get-current-application}
* @param options - The options for editing the application
*/
public async getCurrent({ signal }: Pick<RequestData, 'signal'> = {}) {
return this.rest.get(Routes.currentApplication(), { signal }) as Promise<RESTGetCurrentApplicationResult>;
}
}
5 changes: 5 additions & 0 deletions packages/core/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { REST } from '@discordjs/rest';
import { ApplicationCommandsAPI } from './applicationCommands.js';
import { ApplicationsAPI } from './applications.js';
import { ChannelsAPI } from './channel.js';
import { GuildsAPI } from './guild.js';
import { InteractionsAPI } from './interactions.js';
Expand All @@ -14,6 +15,7 @@ import { VoiceAPI } from './voice.js';
import { WebhooksAPI } from './webhook.js';

export * from './applicationCommands.js';
export * from './applications.js';
export * from './channel.js';
export * from './guild.js';
export * from './interactions.js';
Expand All @@ -30,6 +32,8 @@ export * from './webhook.js';
export class API {
public readonly applicationCommands: ApplicationCommandsAPI;

public readonly applications: ApplicationsAPI;

public readonly channels: ChannelsAPI;

public readonly guilds: GuildsAPI;
Expand All @@ -56,6 +60,7 @@ export class API {

public constructor(public readonly rest: REST) {
this.applicationCommands = new ApplicationCommandsAPI(rest);
this.applications = new ApplicationsAPI(rest);
this.channels = new ChannelsAPI(rest);
this.guilds = new GuildsAPI(rest);
this.invites = new InvitesAPI(rest);
Expand Down
2 changes: 1 addition & 1 deletion packages/create-discord-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"prettier": "^3.0.2",
"terser": "^5.19.2",
"tsup": "^7.2.0",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"tsd": "0.28.1",
"tslint": "6.1.3",
"turbo": "1.10.13",
"typescript": "5.1.6"
"typescript": "5.2.2"
},
"engines": {
"node": ">=16.11.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/docgen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"prettier": "^3.0.2",
"tsup": "^7.2.0",
"turbo": "^1.10.13",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},
"engines": {
"node": ">=16.11.0"
Expand Down
40 changes: 40 additions & 0 deletions packages/formatters/__tests__/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ import {
codeBlock,
Faces,
formatEmoji,
heading,
HeadingLevel,
hideLinkEmbed,
hyperlink,
inlineCode,
italic,
messageLink,
orderedList,
quote,
roleMention,
spoiler,
strikethrough,
time,
TimestampStyles,
underscore,
unorderedList,
userMention,
} from '../src/index.js';

Expand Down Expand Up @@ -202,6 +206,42 @@ describe('Message formatters', () => {
});
});

describe('heading', () => {
test('GIVEN "discord.js" THEN returns "# discord.js"', () => {
expect<'# discord.js'>(heading('discord.js')).toEqual('# discord.js');
});

test('GIVEN "discord.js" AND a heading level 2 from number THEN returns "## discord.js"', () => {
expect<'## discord.js'>(heading('discord.js', 2)).toEqual('## discord.js');
});

test('GIVEN "discord.js" AND a heading level 3 from enum THEN returns "### discord.js"', () => {
expect<'### discord.js'>(heading('discord.js', HeadingLevel.Three)).toEqual('### discord.js');
});
});

describe('orderedList', () => {
test('GIVEN ["discord.js", "discord.js 2", ["discord.js 3"]] THEN returns "1. discord.js\n1. discord.js 2\n 1. discord.js"', () => {
expect(orderedList(['discord.js', 'discord.js 2', ['discord.js 3']])).toEqual(
'1. discord.js\n1. discord.js 2\n 1. discord.js 3',
);
});

test('GIVEN ["discord.js", "discord.js 2", ["discord.js 3"]] AND a startNumber THEN returns "${startNumber}. discord.js\n${startNumber}. discord.js 2\n ${startNumber}. discord.js"', () => {
expect(orderedList(['discord.js', 'discord.js 2', ['discord.js 3']], 50)).toEqual(
'50. discord.js\n50. discord.js 2\n 50. discord.js 3',
);
});
});

describe('unorderedList', () => {
test('GIVEN ["discord.js", "discord.js 2", ["discord.js 3"]] THEN returns "- discord.js\n- discord.js 2\n - discord.js"', () => {
expect(unorderedList(['discord.js', 'discord.js 2', ['discord.js 3']])).toEqual(
'- discord.js\n- discord.js 2\n - discord.js 3',
);
});
});

describe('time', () => {
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
vitest.useFakeTimers();
Expand Down
Loading

0 comments on commit fc85bf3

Please sign in to comment.