fix: make constraints, lint and md-links happy
This commit is contained in:
@@ -15,7 +15,7 @@ packages/<name>/
|
|||||||
README.md # service API, events, extension points, design notes
|
README.md # service API, events, extension points, design notes
|
||||||
```
|
```
|
||||||
|
|
||||||
package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/types/index.d.ts"`, `exports["."].types: "./lib/types/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/types/**/*.d.ts`, `lib/types/**/*.d.ts.map`, and `src`; do not publish `lib/types` JS or JS-map intermediates or stale root declaration files.
|
package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/types/index.d.ts"`, `exports["."].types: "./lib/types/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/types/**/*.d.ts`, `lib/types/**/*.d.ts.map`, and `src`; do not publish `lib/types` JS or JS-map intermediates or stale root declaration files. CLI app packages with a package `bin` include `lib/bin.js` immediately after `lib/index.js` in `files`.
|
||||||
|
|
||||||
## 2. Register it in the root configs
|
## 2. Register it in the root configs
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ Do NOT write one for a mechanical or local choice (a variable name, a one-file r
|
|||||||
| [tsdown for JS bundling instead of dumble](implemented/process/2026-06-11-tsdown-over-dumble.md) | 2026-06-11 |
|
| [tsdown for JS bundling instead of dumble](implemented/process/2026-06-11-tsdown-over-dumble.md) | 2026-06-11 |
|
||||||
| [Doc-sync enforcement](implemented/process/2026-06-11-doc-sync-enforcement.md) | 2026-06-11 |
|
| [Doc-sync enforcement](implemented/process/2026-06-11-doc-sync-enforcement.md) | 2026-06-11 |
|
||||||
| [pnpm as the package manager instead of Yarn 4](implemented/process/2026-06-16-pnpm-over-yarn.md) | 2026-06-16 |
|
| [pnpm as the package manager instead of Yarn 4](implemented/process/2026-06-16-pnpm-over-yarn.md) | 2026-06-16 |
|
||||||
| [TSC-first build and one tsconfig](implemented/2026-06-17-ts-build-config.md) | 2026-06-17 |
|
| [TSC-first build and one tsconfig](implemented/process/2026-06-17-ts-build-config.md) | 2026-06-17 |
|
||||||
| [Markdown cross-link validity linting](implemented/process/2026-06-18-markdown-cross-link-lint.md) | 2026-06-18 |
|
| [Markdown cross-link validity linting](implemented/process/2026-06-18-markdown-cross-link-lint.md) | 2026-06-18 |
|
||||||
| [Core-data-structures catalog and the `ts type-equiv` drift gate](implemented/process/2026-06-20-core-data-structures-catalog.md) | 2026-06-20 |
|
| [Core-data-structures catalog and the `ts type-equiv` drift gate](implemented/process/2026-06-20-core-data-structures-catalog.md) | 2026-06-20 |
|
||||||
| [Generated cordis events + services catalog](implemented/process/2026-06-20-generated-cordis-catalog.md) | 2026-06-20 |
|
| [Generated cordis events + services catalog](implemented/process/2026-06-20-generated-cordis-catalog.md) | 2026-06-20 |
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default tseslint.config(
|
|||||||
],
|
],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: ['./packages/*/tsconfig.json', './tsconfig.json'],
|
project: ['./packages/*/*/tsconfig.json', './tsconfig.json'],
|
||||||
tsconfigRootDir: import.meta.dirname,
|
tsconfigRootDir: import.meta.dirname,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -35,12 +35,15 @@ interface PackageManifest {
|
|||||||
type?: string
|
type?: string
|
||||||
main?: string
|
main?: string
|
||||||
types?: string
|
types?: string
|
||||||
exports?: {
|
bin?: string | Record<string, string>
|
||||||
'.'?: {
|
exports?: Record<
|
||||||
|
string,
|
||||||
|
| {
|
||||||
types?: string
|
types?: string
|
||||||
default?: string
|
default?: string
|
||||||
}
|
}
|
||||||
}
|
| undefined
|
||||||
|
>
|
||||||
files?: string[]
|
files?: string[]
|
||||||
peerDependencies?: Record<string, string>
|
peerDependencies?: Record<string, string>
|
||||||
devDependencies?: Record<string, string>
|
devDependencies?: Record<string, string>
|
||||||
@@ -89,10 +92,22 @@ const dshPackageFiles = [
|
|||||||
'src',
|
'src',
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
const dshBinPackageFiles = [
|
||||||
|
'lib/index.js',
|
||||||
|
'lib/bin.js',
|
||||||
|
'lib/types/**/*.d.ts',
|
||||||
|
'lib/types/**/*.d.ts.map',
|
||||||
|
'src',
|
||||||
|
] as const
|
||||||
|
|
||||||
function sameStringList(actual: readonly string[] | undefined, expected: readonly string[]): boolean {
|
function sameStringList(actual: readonly string[] | undefined, expected: readonly string[]): boolean {
|
||||||
return !!actual && actual.length === expected.length && actual.every((value, index) => value === expected[index])
|
return !!actual && actual.length === expected.length && actual.every((value, index) => value === expected[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expectedDshPackageFiles(manifest: PackageManifest): readonly string[] {
|
||||||
|
return manifest.bin ? dshBinPackageFiles : dshPackageFiles
|
||||||
|
}
|
||||||
|
|
||||||
function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] {
|
function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] {
|
||||||
const errors: string[] = []
|
const errors: string[] = []
|
||||||
const label = manifest.name ?? dir
|
const label = manifest.name ?? dir
|
||||||
@@ -132,8 +147,9 @@ function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] {
|
|||||||
if (manifest.exports?.['.']?.default !== './lib/index.js') {
|
if (manifest.exports?.['.']?.default !== './lib/index.js') {
|
||||||
errors.push(`${label}: package.json exports["."].default must be "./lib/index.js"`)
|
errors.push(`${label}: package.json exports["."].default must be "./lib/index.js"`)
|
||||||
}
|
}
|
||||||
if (!sameStringList(manifest.files, dshPackageFiles)) {
|
const expectedFiles = expectedDshPackageFiles(manifest)
|
||||||
errors.push(`${label}: package.json files must be ${JSON.stringify(dshPackageFiles)}`)
|
if (!sameStringList(manifest.files, expectedFiles)) {
|
||||||
|
errors.push(`${label}: package.json files must be ${JSON.stringify(expectedFiles)}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user