Skip to content

Commit 2337e15

Browse files
committed
refactor: monorepo
BREAKING CHANGE: Images adapters must now be installed separately: - @edged/fs-adapter - @edged/http-adapter - @edged/s3-adapter
1 parent de1a46e commit 2337e15

File tree

142 files changed

+2964
-1372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+2964
-1372
lines changed

.eslintignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
!.eslintrc.js
2+
!.meta-updater
23
coverage
34
dist
4-
test/setup.ts
5+
services/**/*.mjs
56
*.js
6-
*.mjs

.eslintrc.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
root: true,
33
extends: ['@heise'],
4-
plugins: ['sort-keys-fix', 'eslint-plugin-no-only-tests'],
4+
plugins: ['sort-keys-fix'],
55
rules: {
66
'sort-keys-fix/sort-keys-fix': 'error',
77
'no-prototype-builtins': 'off',
@@ -17,6 +17,10 @@ module.exports = {
1717
es6: true,
1818
},
1919
overrides: [
20+
{
21+
files: ['jest.config.ts'],
22+
rules: {'node/no-extraneous-import': 'off'},
23+
},
2024
{
2125
files: ['*.test.ts', '*.js', '__tests__/**/*.ts'],
2226
rules: {

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
tsconfig.build.tsbuildinfo
1+
**/main
2+
*.tsbuildinfo
23
.eslintcache
34
dist
45
# Logs

.meta-updater/.releaserc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"tagFormat":"@edged/updater@v${version}"}

.meta-updater/main.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import updater from './dist/index.js'
2+
3+
export default updater

.meta-updater/package.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "@edged/updater",
3+
"version": "1.0.0",
4+
"main": "dist/index.js",
5+
"private": true,
6+
"type": "module",
7+
"scripts": {
8+
"build": "tsc --build"
9+
},
10+
"dependencies": {
11+
"@pnpm/find-workspace-packages": "^3.1.12",
12+
"@pnpm/lockfile-file": "^4.1.1",
13+
"@pnpm/logger": "^4.0.0",
14+
"@pnpm/types": "^7.4.0",
15+
"@types/normalize-path": "^3.0.0",
16+
"is-subdir": "^1.2.0",
17+
"normalize-path": "^3.0.0"
18+
},
19+
"author": "Philipp Busse"
20+
}

.meta-updater/src/index.ts

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* eslint-disable sonarjs/cognitive-complexity */
2+
3+
import { readWantedLockfile } from '@pnpm/lockfile-file'
4+
import { LockfileFile } from '@pnpm/lockfile-file/lib/write'
5+
import { ProjectManifest } from '@pnpm/types'
6+
import { existsSync } from 'fs'
7+
import normalizePath from 'normalize-path'
8+
import path from 'path'
9+
10+
type UpdateFunc = (
11+
data: Record<string, unknown>,
12+
dir: string,
13+
manifest: ProjectManifest,
14+
) => Record<string, unknown> | Promise<Record<string, unknown> | null> | null
15+
16+
export default async (
17+
workspaceDir: string,
18+
): Promise<Record<string, UpdateFunc>> => {
19+
const lockfile = await readWantedLockfile(workspaceDir, {
20+
ignoreIncompatible: false,
21+
})
22+
23+
if (lockfile == null) {
24+
throw new Error('no lockfile found')
25+
}
26+
27+
return {
28+
'.releaserc.json': (releaseRc, _dir: string, manifest) => {
29+
if (!manifest.name) {
30+
return {}
31+
}
32+
33+
return { tagFormat: `${manifest.name}@v\${version}`, ...releaseRc }
34+
},
35+
'package.json': updatePackageJson(workspaceDir, lockfile),
36+
'tsconfig.json': updateTsConfig(workspaceDir, lockfile),
37+
}
38+
}
39+
40+
function updatePackageJson(_workspaceDir: string, _lockfile: LockfileFile) {
41+
return (manifest: ProjectManifest, _dir: string) => {
42+
return {
43+
...manifest,
44+
author: 'Philipp Busse',
45+
}
46+
}
47+
}
48+
49+
function updateTsConfig(workspaceDir: string, lockfile: LockfileFile) {
50+
return (
51+
tsConfig: Record<string, unknown>,
52+
dir: string,
53+
manifest: ProjectManifest,
54+
) => {
55+
if (tsConfig == null || manifest.name?.includes('/tsconfig')) {
56+
return tsConfig
57+
}
58+
59+
const relative = normalizePath(path.relative(workspaceDir, dir))
60+
61+
const importer = lockfile.importers?.[relative]
62+
63+
if (!importer) {
64+
return tsConfig
65+
}
66+
67+
const deps = {
68+
...importer.dependencies,
69+
...importer.devDependencies,
70+
}
71+
72+
const references = Object.values(deps)
73+
.filter((dep) => dep.startsWith('link:'))
74+
.map((dep) => dep.slice('link:'.length))
75+
.filter((relativePath) =>
76+
existsSync(path.join(dir, relativePath, 'tsconfig.json')),
77+
)
78+
.map((path) => ({ path }))
79+
80+
console.log(`Updating tsconfig for ${dir}: ${JSON.stringify(references)}`)
81+
82+
return {
83+
...tsConfig,
84+
...(references && {
85+
references: references.sort((r1, r2) => r1.path.localeCompare(r2.path)),
86+
}),
87+
}
88+
}
89+
}

.meta-updater/tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "@edged/tsconfig",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"rootDir": "src",
6+
"module": "ES2020"
7+
},
8+
"include": ["src/**/*"],
9+
"references": []
10+
}

.releaserc

-18
This file was deleted.

.releaserc.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"tagFormat": "@edged/repo@v${version}",
3+
"branches": ["master", "refactor/monorepo"],
4+
"repositoryUrl": "[email protected]:pmb0/express-sharp.git",
5+
"plugins": [
6+
"@semantic-release/commit-analyzer",
7+
"@semantic-release/release-notes-generator",
8+
[
9+
"@semantic-release/changelog",
10+
{
11+
"changelogFile": "CHANGELOG.md"
12+
}
13+
],
14+
"@semantic-release/npm",
15+
[
16+
"@semantic-release/git",
17+
{
18+
"assets": ["package.json", "CHANGELOG.md"],
19+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
20+
}
21+
]
22+
],
23+
"fail": false,
24+
"success": false
25+
}

__mocks__/got.ts

-9
This file was deleted.

jest.config.js

-179
This file was deleted.

0 commit comments

Comments
 (0)