diff --git a/package.json b/package.json index e11dae2..d3badee 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,10 @@ "./package.json": "./package.json" }, "scripts": { - "build": "tsc", "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"", "lintfix": "npm run lint -- --fix", "postlint": "template-oss-check", "posttest": "npm run lint", - "pretest": "npm run build", "template-oss-apply": "template-oss-apply --force", "test": "tap", "snap": "tap" diff --git a/scripts/template-oss/package-json.hbs b/scripts/template-oss/package-json.hbs index bfc1ae2..1059cb9 100644 --- a/scripts/template-oss/package-json.hbs +++ b/scripts/template-oss/package-json.hbs @@ -1,6 +1,8 @@ { "scripts": { - "prepare": {{{ del }}} + "prepare": {{{ del }}}, + "build": {{{ del }}}, + "pretest": {{{ del }}} }, "files": [ "types/" diff --git a/tap-snapshots/test/fixtures.ts.test.cjs b/tap-snapshots/test/fixtures.ts.test.cjs index 1cab282..1ea6608 100644 --- a/tap-snapshots/test/fixtures.ts.test.cjs +++ b/tap-snapshots/test/fixtures.ts.test.cjs @@ -6,7 +6,7 @@ */ 'use strict' exports[`test/fixtures.ts > TAP > fixtures > snapshots > not-licensed.manifest.ts 1`] = ` -export const metadata: npmTypes.Manifest = { +Manifest = { "name": "not-licensed", "dist-tags": { "latest": "1.0.0" @@ -33,7 +33,7 @@ export const metadata: npmTypes.Manifest = { ` exports[`test/fixtures.ts > TAP > fixtures > snapshots > not-licensed.ts 1`] = ` -export const metadata: npmTypes.Packument = { +Packument = { "_id": "not-licensed", "_rev": "3-5e8502a05053da7c2cb1b51f8a08a0ec", "name": "not-licensed", @@ -123,7 +123,7 @@ export const metadata: npmTypes.Packument = { ` exports[`test/fixtures.ts > TAP > fixtures > snapshots > not-licensed@1.0.0.ts 1`] = ` -export const metadata: npmTypes.PackumentVersion = { +PackumentVersion = { "name": "not-licensed", "version": "1.0.0", "description": "an empty package without license metadata", @@ -176,7 +176,7 @@ export const metadata: npmTypes.PackumentVersion = { ` exports[`test/fixtures.ts > TAP > fixtures > snapshots > tiny-tarball.manifest.ts 1`] = ` -export const metadata: npmTypes.Manifest = { +Manifest = { "name": "tiny-tarball", "dist-tags": { "latest": "1.0.0" @@ -203,7 +203,7 @@ export const metadata: npmTypes.Manifest = { ` exports[`test/fixtures.ts > TAP > fixtures > snapshots > tiny-tarball.ts 1`] = ` -export const metadata: npmTypes.Packument = { +Packument = { "_id": "tiny-tarball", "_rev": "5-6e3e9084c69f16db2d53a953e67d0f9e", "name": "tiny-tarball", @@ -275,7 +275,7 @@ export const metadata: npmTypes.Packument = { ` exports[`test/fixtures.ts > TAP > fixtures > snapshots > tiny-tarball@1.0.0.ts 1`] = ` -export const metadata: npmTypes.PackumentVersion = { +PackumentVersion = { "name": "tiny-tarball", "version": "1.0.0", "description": "tiny tarball used for health checks", @@ -318,7 +318,7 @@ export const metadata: npmTypes.PackumentVersion = { ` exports[`test/fixtures.ts > TAP > fixtures > snapshots > uuid@0.0.2.ts 1`] = ` -export const metadata: npmTypes.PackumentVersion = { +PackumentVersion = { "name": "uuid", "description": "Simple libuuid bindings to allow UUIDs to be generated from JS.", "version": "0.0.2", @@ -366,7 +366,7 @@ export const metadata: npmTypes.PackumentVersion = { ` exports[`test/fixtures.ts > TAP > fixtures > snapshots > uuid@1.4.1.ts 1`] = ` -export const metadata: npmTypes.PackumentVersion = { +PackumentVersion = { "name": "uuid", "version": "1.4.1", "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", diff --git a/test/fixtures.ts b/test/fixtures.ts index 0b28f21..8ec7ed9 100644 --- a/test/fixtures.ts +++ b/test/fixtures.ts @@ -1,5 +1,6 @@ import { spawn } from 'node:child_process' -import { resolve } from 'node:path' +import { readFile } from 'node:fs/promises' +import { resolve, join } from 'node:path' import t from 'tap' const REGISTRY = 'https://registry.npmjs.org' @@ -29,23 +30,21 @@ const FIXTURES: FixtureEntry[] = [ */ t.test('fixtures', async (t) => { const root = process.cwd() + const tsConfig = await readFile(join(root, 'tsconfig.json'), 'utf-8') const fixtures = await getFixtures() const dir = t.testdir({ 'tsconfig-test.json': JSON.stringify({ compilerOptions: { - module: 'NodeNext', - moduleResolution: 'nodenext', - strict: true, - target: 'es2022', - noEmit: true, + ...JSON.parse(tsConfig).compilerOptions, rootDir: 'fixtures', }, include: ['fixtures'], }, null, 2), fixtures: Object.fromEntries(Object.entries(fixtures).map(([k, v]) => [ k, - `import type * as npmTypes from '../../../../types/index.d.ts'\n${v}`, + `import type * as npmTypes from '../../../../types/index.d.ts'\n` + + `export const metadata: npmTypes.${v}`, ])), }) @@ -98,8 +97,7 @@ async function getFixtures () { manifestFormat, }) - fixtures[fixturePath] = - `export const metadata: npmTypes.${tsType} = ${JSON.stringify(pkg, null, 2)}` + fixtures[fixturePath] = `${tsType} = ${JSON.stringify(pkg, null, 2)}` } } diff --git a/tsconfig.json b/tsconfig.json index 57c7357..c7998a4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,8 +9,5 @@ "strict": true, "target": "es2022", "noEmit": true - }, - "include": [ - "test/fixtures.ts" - ] + } }