Skip to content

Commit

Permalink
chore: Clean up formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Nov 19, 2024
1 parent 3fac192 commit e691912
Show file tree
Hide file tree
Showing 19 changed files with 777 additions and 718 deletions.
12 changes: 6 additions & 6 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
$schema: "https://docs.renovatebot.com/renovate-schema.json",
// see https://docs.renovatebot.com/presets-config/
extends: [
'config:base',
"config:base",
// automatically rebase onto main branch
':rebaseStalePrs',
":rebaseStalePrs",
// groups all ESLint-related dependency upgrades into a single PR
'group:linters'
"group:linters",
],
packageRules: [
// only send upgrade for deps (from the npm registry) after they've been
// published for 30 days
{
matchDatasources: ['npm'],
minimumReleaseAge: '30 days',
matchDatasources: ["npm"],
minimumReleaseAge: "30 days",
},
],
}
25 changes: 12 additions & 13 deletions .github/workflows/bun-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on: [push, pull_request]

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -13,15 +12,15 @@ jobs:
bun: [latest]

steps:
- uses: actions/checkout@v4
- name: Use Bun ${{ matrix.bun }}
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ matrix.bun }}
- name: bun install, build, and test
run: |
bun install
bun run build
bun run --bun test:unit
env:
CI: true
- uses: actions/checkout@v4
- name: Use Bun ${{ matrix.bun }}
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ matrix.bun }}
- name: bun install, build, and test
run: |
bun install
bun run build
bun run --bun test:unit
env:
CI: true
55 changes: 27 additions & 28 deletions .github/workflows/nodejs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on: [push, pull_request]

jobs:
test:

runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -13,34 +12,34 @@ jobs:
node: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm test
env:
CI: true
- name: JSR Publish Test
run: npm run test:jsr
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm test
env:
CI: true
- name: JSR Publish Test
run: npm run test:jsr

emfile_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: npm install and build
run: |
npm install
npm run build --if-present
env:
CI: true
- name: Run EMFILE test
run: npm run test:emfile
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: npm install and build
run: |
npm install
npm run build --if-present
env:
CI: true
- name: Run EMFILE test
run: npm run test:emfile
4 changes: 2 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}

# The logic below handles the npm publication:
- uses: actions/checkout@v4
# these if statements ensure that a publication only occurs when
Expand All @@ -27,7 +27,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}

- run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,44 @@ The API is split into two parts:

1. The `Client` class that can be used to post the same message across multiple services.
1. A number of different strategy implementations, one for each service:
* `BlueskyStrategy`
* `MastodonStrategy`
* `TwitterStrategy`
- `BlueskyStrategy`
- `MastodonStrategy`
- `TwitterStrategy`

Each strategy requires its own parameters that are specific to the service. If you only want to post to a particular service, you can just directly use the strategy for that service.

```js
import {
Client,
TwitterStrategy,
MastodonStrategy,
BlueskyStrategy
Client,
TwitterStrategy,
MastodonStrategy,
BlueskyStrategy,
} from "@humanwhocodes/crosspost";

// Note: Use an app password, not your login password!
const bluesky = new BlueskyStrategy({
identifier: "me.you.social",
password: "your-app-password",
host: "you.social"
})
identifier: "me.you.social",
password: "your-app-password",
host: "you.social",
});

// Note: Personal access token is required
const mastodon = new MastodonStrategy({
accessToken: "your-access-token",
host: "mastodon.host"
accessToken: "your-access-token",
host: "mastodon.host",
});

// Note: OAuth app is required
const twitter = new TwitterStrategy({
accessTokenKey: "access-token-key",
accessTokenSecret: "access-token-secret",
apiConsumerKey: "api-consumer-key",
apiConsumerSecret: "api-consumer-secret"
accessTokenKey: "access-token-key",
accessTokenSecret: "access-token-secret",
apiConsumerKey: "api-consumer-key",
apiConsumerSecret: "api-consumer-secret",
});

// create a client that will post to all three
const client = new Client({
strategies: [
bluesky,
mastodon,
twitter
]
strategies: [bluesky, mastodon, twitter],
});

// post to all three
Expand Down
68 changes: 28 additions & 40 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,34 @@
import js from "@eslint/js";

export default [
{
ignores: ["tests/fixtures"]
{
ignores: ["tests/fixtures"],
},
js.configs.recommended,
{
languageOptions: {
globals: {
process: false,
URL: false,
console: false,
},
},
js.configs.recommended,
{
languageOptions: {
globals: {
process: false,
URL: false,
console: false
},
},
rules: {
indent: [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
quotes: [
"error",
"double"
],
semi: [
"error",
"always"
]
}
rules: {
indent: ["error", 4],
"linebreak-style": ["error", "unix"],
quotes: ["error", "double"],
semi: ["error", "always"],
},
{
files: ["tests/**/*.js"],
languageOptions: {
globals: {
describe: false,
it: false,
beforeEach: false,
afterEach: false
}
}
}
},
{
files: ["tests/**/*.js"],
languageOptions: {
globals: {
describe: false,
it: false,
beforeEach: false,
afterEach: false,
},
},
},
];
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
},
"lint-staged": {
"*.js": [
"eslint --fix"
"eslint --fix",
"prettier --write"
],
"!(*.js)": [
"prettier --write"
]
},
"funding": {
Expand All @@ -41,6 +45,7 @@
"build:cts-types": "node -e \"fs.copyFileSync('dist/index.d.ts', 'dist/index.d.cts')\"",
"build": "rollup -c && tsc -p tsconfig.esm.json && npm run build:cts-types",
"lint": "eslint src/ tests/",
"fmt": "prettier --write .",
"pretest": "npm run build",
"test:unit": "mocha tests/**/*.*",
"test:build": "node tests/pkg.test.cjs && node tests/pkg.test.mjs",
Expand Down Expand Up @@ -71,6 +76,7 @@
"lint-staged": "15.2.1",
"mocha": "^10.3.0",
"nock": "^13.5.5",
"prettier": "^3.3.3",
"rollup": "3.29.4",
"sinon": "^19.0.2",
"typescript": "^5.6.3",
Expand Down
28 changes: 14 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export default [
{
input: "src/index.js",
output: [
{
file: "dist/cjs/index.cjs",
format: "cjs"
},
{
file: "dist/esm/index.js",
format: "esm",
banner: "// @ts-self-types=\"./index.d.ts\""
}
]
}
{
input: "src/index.js",
output: [
{
file: "dist/cjs/index.cjs",
format: "cjs",
},
{
file: "dist/esm/index.js",
format: "esm",
banner: '// @ts-self-types="./index.d.ts"',
},
],
},
];
Loading

0 comments on commit e691912

Please sign in to comment.