Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build system rework #2169

Merged
merged 81 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
71dab77
refactor(crypto): remove circular dependency
matthieusieben Dec 8, 2023
ee48d6d
refactor(crypto): expose compress/decompress as part of the DidKeyPlu…
matthieusieben Dec 8, 2023
ab31569
fix(crypto): remove import from private file
matthieusieben Feb 13, 2024
85ddf34
refactor: isolate tsconfig
matthieusieben Feb 12, 2024
186c34e
fix: remove unused bench file
matthieusieben Feb 12, 2024
3f34a52
chore(repo): remove unused deps
matthieusieben Feb 12, 2024
43fab6e
fix(ozone): properly list dependencies
matthieusieben Feb 12, 2024
c8fb473
fix(services): do lint js files
matthieusieben Feb 12, 2024
70b8d5f
fix(services/pds): remove unused deps
matthieusieben Feb 12, 2024
65c899f
chore(pds): remove bench
matthieusieben Feb 12, 2024
065b65d
chore(dev-env): remove unused deps
matthieusieben Feb 12, 2024
40b36b3
chore(api): remove bench
matthieusieben Feb 12, 2024
fe8f2cd
remove unused babel.config.js files
matthieusieben Feb 12, 2024
72bca36
fix: remove .ts extension from import
matthieusieben Feb 12, 2024
c0be1bb
fix(pds): remove imports of src files
matthieusieben Feb 12, 2024
50d6674
fix(tsconfig): properly list all projects
matthieusieben Feb 12, 2024
3ce21b2
fix(dev-env): remove imports of src files
matthieusieben Feb 12, 2024
bbcb359
fix(bsky): remove direct import to crypto src
matthieusieben Feb 13, 2024
937eeed
fix(api): remove imports to api internals
matthieusieben Feb 12, 2024
de60002
chore(build): prevent bundling of built output
matthieusieben Feb 12, 2024
3b37c13
chore(dev): add "dev" script to build in watch mode
matthieusieben Feb 12, 2024
ec01392
chore(deps): move ts-node dependency where it is actually used
matthieusieben Feb 13, 2024
5b0d2e1
fix(deps): add dev-env as project dependency
matthieusieben Feb 13, 2024
0da7afa
fix(xrpc-server): properly type kexicon
matthieusieben Feb 13, 2024
948044b
fix(bsky): improve typings
matthieusieben Feb 13, 2024
c106213
fix(pds): fully type formatRecordEmbedInternal return value
matthieusieben Feb 13, 2024
1fa71c2
fix(repo): remove imports from @ipld/car/api
matthieusieben Feb 13, 2024
296347e
feat(dev-env): re-export BskyIngester
matthieusieben Feb 13, 2024
878bd24
fix: properly lint & type jest config & test files
matthieusieben Feb 13, 2024
2a712c9
fix(ci): test after build
matthieusieben Feb 13, 2024
9eb438d
fix(types): use NodeJS.Timeout instead of NodeJS.Timer
matthieusieben Feb 14, 2024
fe69528
fix(bsky): make types exportable
matthieusieben Feb 14, 2024
068f90a
fix(ozone): make types exportable
matthieusieben Feb 14, 2024
05f94c6
fix(xrpc-server): make types exportable
matthieusieben Feb 14, 2024
04efc3f
fix(xprc-server): make code compliant with "node" types
matthieusieben Feb 14, 2024
aed06de
fix(xrpc-server): avoid accessing properties of unknown
matthieusieben Feb 14, 2024
a8e6db9
chore(deps): update @types/node
matthieusieben Feb 14, 2024
b75bd14
feat(tsconfig): narrow down available types depending on the package'…
matthieusieben Feb 14, 2024
6ad286a
fix(pds): remove unused prop
matthieusieben Feb 14, 2024
d20a36a
fix(bsync): Database's migrator not always initialized
matthieusieben Feb 14, 2024
b074ab1
fix(dev-env): remove unreachable code
matthieusieben Feb 14, 2024
c98106f
fix(xrpc-server): remove unused import
matthieusieben Feb 14, 2024
5276ca8
fix(xrpc-server): mark header property as abstract
matthieusieben Feb 14, 2024
d45bf7d
fix(pds): initialize LeakyTxPlugin's txOver property
matthieusieben Feb 14, 2024
35f9d21
fix(bsky): initialize LeakyTxPlugin's txOver property
matthieusieben Feb 14, 2024
6e605c0
fix(bsky): remove unused migrator from DatabaseCoordinator
matthieusieben Feb 14, 2024
96398af
fix(bsky): Properly initialize LabelService's cache property
matthieusieben Feb 14, 2024
656261a
fix(ozone): Database's migrator not initialized
matthieusieben Feb 14, 2024
6039463
fix(ozone): initialize LeakyTxPlugin's txOver property
matthieusieben Feb 14, 2024
eb687d3
fix(crypto): ignore unused variable error
matthieusieben Feb 14, 2024
941232f
feat(tsconfig): use stricter rules
matthieusieben Feb 14, 2024
28967db
feat(tsconfig): enable useDefineForClassFields
matthieusieben Feb 14, 2024
dd06571
feat(xrpc-server): add support for brotli incoming payload
matthieusieben Feb 19, 2024
035437d
fix(xrpc-server): properly parse & process content-encoding
matthieusieben Feb 19, 2024
eeb3ce1
fix(common:stream): always call cb in _transform
matthieusieben Feb 19, 2024
d221234
tidy/fix tests and service entrypoints
devinivy Feb 19, 2024
defe6c1
Revert "fix(xrpc-server): properly parse & process content-encoding"
devinivy Feb 19, 2024
f6dd19c
Revert "feat(xrpc-server): add support for brotli incoming payload"
devinivy Feb 19, 2024
535a27a
remove special node env for tests (defaults to jest val of "test")
devinivy Feb 19, 2024
00a5eda
kill mute sync handler on disconnect
devinivy Feb 20, 2024
3535a2d
work around connect-es bug w/ request aborts
devinivy Feb 20, 2024
4bb6fa6
style(crypto): rename imports from uint8arrays
matthieusieben Feb 20, 2024
0ad3fa4
fix update package-lock
matthieusieben Feb 22, 2024
4f3f01a
fix lint
matthieusieben Feb 22, 2024
5bd35f4
force hbs files to be bundled as cjs
matthieusieben Feb 22, 2024
8b991f8
fix: use concurrently instead of npm-run-all
matthieusieben Feb 23, 2024
215f4ff
remove concurrently alltogether
matthieusieben Feb 23, 2024
ba9d2a7
ignore sqlite files in services/pds
matthieusieben Feb 23, 2024
c3146a8
Merge remote-tracking branch 'origin/main' into build-rework
devinivy Feb 29, 2024
cbf395d
Merge remote-tracking branch 'origin/main' into build-rework
matthieusieben Mar 4, 2024
ac78056
fix verify
devinivy Mar 4, 2024
a2a24ed
Merge remote-tracking branch 'origin/main' into build-rework
devinivy Mar 4, 2024
851eea0
Merge remote-tracking branch 'origin/main' into build-rework
devinivy Mar 6, 2024
8fd2116
fix verify
devinivy Mar 6, 2024
fd85b4c
Merge remote-tracking branch 'origin/main' into build-rework
devinivy Mar 7, 2024
dbf64e3
Merge remote-tracking branch 'origin/main' into build-rework
matthieusieben Mar 8, 2024
1570dad
Merge remote-tracking branch 'origin/main' into build-rework
devinivy Mar 18, 2024
31d1f46
tidy, fix verify
devinivy Mar 18, 2024
57ad993
fix blob diversion test
devinivy Mar 18, 2024
452f507
Merge remote-tracking branch 'origin/main' into build-rework
devinivy Mar 18, 2024
2aee4e7
build rework changeset
devinivy Mar 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/long-planes-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@atproto/xrpc-server': minor
'@atproto/common-web': minor
'@atproto/identity': minor
'@atproto/dev-env': minor
'@atproto/lex-cli': minor
'@atproto/lexicon': minor
'@atproto/common': minor
'@atproto/crypto': minor
'@atproto/syntax': minor
'@atproto/repo': minor
'@atproto/xrpc': minor
'@atproto/api': minor
'@atproto/aws': minor
'@atproto/bsync': patch
'@atproto/ozone': patch
'@atproto/bsky': patch
'@atproto/pds': patch
---

Build system rework, stop bundling dependencies.
29 changes: 18 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@
"plugin:prettier/recommended",
"prettier"
],
"ignorePatterns": [
"dist",
"node_modules",
"jest.config.base.js",
"jest.bench.config.js",
"jest.config.js",
"babel.config.js",
"build.js",
"update-pkg.js"
],
"ignorePatterns": ["dist", "node_modules"],
"rules": {
"no-var": "error",
"prefer-const": "warn",
Expand All @@ -36,5 +27,21 @@
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off"
}
},
"overrides": [
{
"files": ["jest.config.js"],
"env": { "commonjs": true }
},
{
"files": ["jest.setup.js"],
"env": { "jest": true }
},
{
"files": "*.js",
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
1 change: 1 addition & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
node-version: 18
cache: 'pnpm'
- run: pnpm i --frozen-lockfile
- run: pnpm build
- run: pnpm verify
- name: Publish
id: changesets
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ jobs:
cache: 'pnpm'
- run: pnpm i --frozen-lockfile
- run: pnpm build
- uses: actions/upload-artifact@v4
with:
name: dist
path: packages/*/dist
retention-days: 1
test:
name: Test
needs: build
strategy:
matrix:
shard: [1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8, 8/8]
Expand All @@ -40,9 +46,14 @@ jobs:
node-version: 18
cache: 'pnpm'
- run: pnpm i --frozen-lockfile
- uses: actions/download-artifact@v4
with:
name: dist
path: packages
- run: pnpm test:withFlags --maxWorkers=1 --shard=${{ matrix.shard }} --passWithNoTests
verify:
name: Verify
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -54,4 +65,8 @@ jobs:
node-version: 18
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- uses: actions/download-artifact@v4
with:
name: dist
path: packages
- run: pnpm verify
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

20 changes: 0 additions & 20 deletions jest.config.base.js

This file was deleted.

5 changes: 1 addition & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// jest.config.js
const base = require('./jest.config.base.js')

/** @type {import('jest').Config} */
module.exports = {
...base,
projects: ['<rootDir>/packages/*/jest.config.js'],
}
File renamed without changes.
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,46 @@
},
"scripts": {
"lint:fix": "pnpm lint --fix",
"lint": "eslint . --ext .ts,.tsx",
"verify": "prettier --check . && pnpm lint",
"format": "prettier --write .",
"build": "pnpm -r --stream build",
"update-main-to-dist": "pnpm -r --stream update-main-to-dist",
"test": "LOG_ENABLED=false NODE_ENV=development ./packages/dev-infra/with-test-redis-and-db.sh pnpm --stream -r test",
"test:withFlags": "LOG_ENABLED=false NODE_ENV=development ./packages/dev-infra/with-test-redis-and-db.sh pnpm --stream -r test --",
"lint": "eslint . --ext .ts,.js",
"style:fix": "prettier --write .",
"style": "prettier --check .",
"verify": "pnpm --stream '/^verify:.+$/'",
"verify:style": "pnpm run style",
"verify:lint": "pnpm lint",
"verify:types": "tsc --build tsconfig.json",
"format": "pnpm lint:fix && pnpm style:fix",
"build": "pnpm --recursive --stream build",
"dev": "pnpm --stream '/^dev:.+$/'",
"dev:tsc": "tsc --build tsconfig.json --watch",
"dev:pkg": "pnpm --recursive --parallel --stream dev",
"test": "LOG_ENABLED=false ./packages/dev-infra/with-test-redis-and-db.sh pnpm --stream -r test",
"test:withFlags": "LOG_ENABLED=false ./packages/dev-infra/with-test-redis-and-db.sh pnpm --stream -r test --",
"changeset": "changeset",
"release": "pnpm build && changeset publish",
"version-packages": "changeset version && git add ."
},
"devDependencies": {
"@atproto/dev-env": "workspace:^",
"@babel/core": "^7.18.6",
"@babel/preset-env": "^7.18.6",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@npmcli/package-json": "^3.0.0",
"@swc/core": "^1.3.42",
"@swc/jest": "^0.2.24",
"@types/jest": "^28.1.4",
"@types/node": "^18.0.0",
"@types/node": "^18.19.24",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"babel-eslint": "^10.1.0",
"dotenv": "^16.0.3",
"esbuild": "^0.14.48",
"esbuild-node-externals": "^1.5.0",
"esbuild-plugin-handlebars": "^1.0.2",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"handlebars-jest": "^1.0.0",
"jest": "^28.1.2",
"node-gyp": "^9.3.1",
"pino-pretty": "^9.1.0",
"prettier": "^2.7.1",
"prettier-config-standard": "^5.0.0",
"ts-node": "^10.8.2",
"typescript": "^5.3.3"
},
"workspaces": {
Expand Down
3 changes: 0 additions & 3 deletions packages/api/babel.config.js

This file was deleted.

15 changes: 0 additions & 15 deletions packages/api/build.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/api/jest.bench.config.js

This file was deleted.

9 changes: 6 additions & 3 deletions packages/api/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const base = require('../../jest.config.base.js')

/** @type {import('jest').Config} */
module.exports = {
...base,
displayName: 'API',
transform: { '^.+\\.(t|j)s$': '@swc/jest' },
transformIgnorePatterns: [`<rootDir>/node_modules/(?!get-port)`],
testTimeout: 60000,
setupFiles: ['<rootDir>/../../jest.setup.ts'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
}
20 changes: 20 additions & 0 deletions packages/api/jest.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
declare namespace jest {
// eslint-disable-next-line
interface Matchers<R, T = {}> {
toBeModerationResult(
expected: ModerationTestSuiteResultFlag[] | undefined,
context?: string,
stringifiedResult?: string,
ignoreCause?: boolean,
): R
}

interface Expect {
toBeModerationResult(
expected: ModerationTestSuiteResultFlag[] | undefined,
context?: string,
stringifiedResult?: string,
ignoreCause?: boolean,
): void
}
}
97 changes: 97 additions & 0 deletions packages/api/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { ModerationUI } from './src'
import { ModerationTestSuiteResultFlag } from './tests/util/moderation-behavior'

expect.extend({
toBeModerationResult(
actual: ModerationUI,
expected: ModerationTestSuiteResultFlag[] | undefined,
context: string = '',
stringifiedResult: string | undefined = undefined,
_ignoreCause = false,
) {
const fail = (msg: string) => ({
pass: false,
message: () =>
`${msg}.${
stringifiedResult ? ` Full result: ${stringifiedResult}` : ''
}`,
})
// let cause = actual.causes?.type as string
// if (actual.cause?.type === 'label') {
// cause = `label:${actual.cause.labelDef.id}`
// } else if (actual.cause?.type === 'muted') {
// if (actual.cause.source.type === 'list') {
// cause = 'muted-by-list'
// }
// } else if (actual.cause?.type === 'blocking') {
// if (actual.cause.source.type === 'list') {
// cause = 'blocking-by-list'
// }
// }
if (!expected) {
// if (!ignoreCause && actual.cause) {
// return fail(`${context} expected to be a no-op, got ${cause}`)
// }
if (actual.inform) {
return fail(`${context} expected to be a no-op, got inform=true`)
}
if (actual.alert) {
return fail(`${context} expected to be a no-op, got alert=true`)
}
if (actual.blur) {
return fail(`${context} expected to be a no-op, got blur=true`)
}
if (actual.filter) {
return fail(`${context} expected to be a no-op, got filter=true`)
}
if (actual.noOverride) {
return fail(`${context} expected to be a no-op, got noOverride=true`)
}
} else {
// if (!ignoreCause && cause !== expected.cause) {
// return fail(`${context} expected to be ${expected.cause}, got ${cause}`)
// }
const expectedInform = expected.includes('inform')
if (!!actual.inform !== expectedInform) {
return fail(
`${context} expected to be inform=${expectedInform}, got ${
actual.inform || false
}`,
)
}
const expectedAlert = expected.includes('alert')
if (!!actual.alert !== expectedAlert) {
return fail(
`${context} expected to be alert=${expectedAlert}, got ${
actual.alert || false
}`,
)
}
const expectedBlur = expected.includes('blur')
if (!!actual.blur !== expectedBlur) {
return fail(
`${context} expected to be blur=${expectedBlur}, got ${
actual.blur || false
}`,
)
}
const expectedFilter = expected.includes('filter')
if (!!actual.filter !== expectedFilter) {
return fail(
`${context} expected to be filter=${expectedFilter}, got ${
actual.filter || false
}`,
)
}
const expectedNoOverride = expected.includes('noOverride')
if (!!actual.noOverride !== expectedNoOverride) {
return fail(
`${context} expected to be noOverride=${expectedNoOverride}, got ${
actual.noOverride || false
}`,
)
}
}
return { pass: true, message: () => '' }
},
})
19 changes: 6 additions & 13 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@
"url": "https://github.com/bluesky-social/atproto",
"directory": "packages/api"
},
"main": "src/index.ts",
"publishConfig": {
"main": "dist/index.js",
"types": "dist/index.d.ts"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"codegen": "node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/* ../../lexicons/tools/ozone/*/*",
"build": "node ./build.js",
"postbuild": "tsc --build tsconfig.build.json",
"update-main-to-dist": "node ../../update-main-to-dist.js packages/api",
"test": "jest",
"bench": "jest --config jest.bench.config.js",
"bench:profile": "node --inspect-brk ../../node_modules/.bin/jest --config jest.bench.config.js"
"build": "tsc --build tsconfig.build.json",
"test": "jest"
},
"dependencies": {
"@atproto/common-web": "workspace:^",
Expand All @@ -38,7 +31,7 @@
},
"devDependencies": {
"@atproto/lex-cli": "workspace:^",
"@atproto/dev-env": "workspace:^",
"get-port": "^6.1.2"
"get-port": "^6.1.2",
"jest": "^28.1.2"
}
}
Loading
Loading