/// const S = Smithers import { scopedShell } from '../../factory/scoped-shell.js' const Shell = scopedShell('packages/effect') // Follows the packages/evm/PACKAGE.ts exemplar with one removal: this package // has no typecheck script (build:types's tsc pass is the typecheck), so the // exemplar's typecheck target is absent. const packageJson = S.file('package.json') const tsconfig = S.file('tsconfig.json') const tsupConfig = S.file('tsup.config.js') const typedocConfig = S.file('typedoc.json') const vitestConfig = S.file('vitest.config.ts') const biomeConfig = S.file('biome.json') const rootBiomeConfig = S.file('//biome.json') const srcs = S.Filegroup({ srcs: S.glob(['src/**', '!src/**/*.spec.ts', '!src/**/*.test.ts', '!src/**/__snapshots__/**']), }) const tests = S.Filegroup({ srcs: S.glob(['src/**/*.spec.ts', 'src/**/*.test.ts', 'src/**/__snapshots__/**']), }) const deps = S.Filegroup({ srcs: [packageJson] }) // build:dist. const build = Shell.Build({ bin: S.NodeModule.Bin('tsup'), data: [srcs, deps, tsupConfig, tsconfig, packageJson], outDirs: ['dist'], }) // The tsup half of build:types. const types = Shell.Build({ bin: S.NodeModule.Bin('tsup'), args: ['--dts-only'], data: [srcs, deps, tsupConfig, tsconfig, packageJson], outDirs: ['dist'], }) // The tsc half of build:types. Emits the declarations the manifest's import // types condition points at, into the tsconfig outDir. const declarations = Shell.Build({ bin: S.NodeModule.Bin('typescript', 'tsc'), args: ['--emitDeclarationOnly', '--declaration'], data: [srcs, deps, tsconfig], outDirs: ['types'], }) // test:run. const test = Shell.Test({ bin: S.NodeModule.Bin('vitest'), args: ['run'], data: [srcs, tests, deps, vitestConfig, tsconfig], }) // test:coverage. const testCoverage = Shell.Test({ bin: S.NodeModule.Bin('vitest'), args: ['run', '--coverage'], data: [srcs, tests, deps, vitestConfig, tsconfig], }) // The floors are vitest.config.ts's thresholds verbatim. The config sets // autoUpdate: true; the graph treats the config as input only, so the // ratchet's rewrite stays a local convenience. const coverageGate = S.Alias(testCoverage) // generate:docs. const docs = Shell.Build({ bin: S.NodeModule.Bin('typedoc'), data: [srcs, deps, typedocConfig, packageJson], outDirs: ['docs'], }) const pack = S.Npm.Pack({ manifest: packageJson, data: [build, types, declarations, srcs], }) // lint:package. const packageLint = Shell.Test({ command: 'pnpm exec publint --strict . && pnpm exec attw --pack .', data: [pack], }) const apiCompat = S.Api.Compat({ baseline: S.Npm.Published({ manifest: packageJson }), surface: types, manifest: packageJson, }) // lint:deps. const depsLint = Shell.Test({ bin: S.NodeModule.Bin('depcheck'), data: [srcs, tests, packageJson], }) // lint:check. const lint = Shell.Test({ bin: S.NodeModule.Bin('@biomejs/biome'), args: ['check', '.', '--verbose'], data: [srcs, tests, biomeConfig, rootBiomeConfig], }) // lint. Applies lint fixes and formatting in one pass, so it also covers the // format script. const format = Shell.Diff({ bin: S.NodeModule.Bin('@biomejs/biome'), args: ['check', '.', '--write', '--unsafe'], data: [srcs, tests, biomeConfig, rootBiomeConfig], changes: ['**'], }) // clean. node_modules is left to the workspace's install layer. const clean = S.Clean({ targets: [build, types, declarations, testCoverage, docs], paths: ['dist', 'types', 'coverage', 'docs', 'artifacts', 'cache'], }) const check = S.Suite({ tests: [lint, test, coverageGate, depsLint, packageLint], }) // Not targets: `all` is a meta script that chains the others; `build` is the // nx aggregate the build, types, and declarations targets replace; `format` // and `format:check` are the format-only half of lint and lint:check; `test` // is vitest in watch mode with coverage; `test:ui` is the vitest UI. export const Package = S.Package({ targets: { apiCompat, build, check, clean, coverageGate, declarations, depsLint, docs, format, lint, pack, packageLint, srcs, test, testCoverage, tests, types, }, })