Skip to content

Commit

Permalink
chore: remove build script and update snapshots and tsconfig (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored May 8, 2024
1 parent 123bb67 commit 1a1fd85
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion scripts/template-oss/package-json.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"scripts": {
"prepare": {{{ del }}}
"prepare": {{{ del }}},
"build": {{{ del }}},
"pretest": {{{ del }}}
},
"files": [
"types/"
Expand Down
16 changes: 8 additions & 8 deletions tap-snapshots/test/fixtures.ts.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down Expand Up @@ -123,7 +123,7 @@ export const metadata: npmTypes.Packument = {
`

exports[`test/fixtures.ts > TAP > fixtures > snapshots > [email protected] 1`] = `
export const metadata: npmTypes.PackumentVersion = {
PackumentVersion = {
"name": "not-licensed",
"version": "1.0.0",
"description": "an empty package without license metadata",
Expand Down Expand Up @@ -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"
Expand All @@ -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",
Expand Down Expand Up @@ -275,7 +275,7 @@ export const metadata: npmTypes.Packument = {
`

exports[`test/fixtures.ts > TAP > fixtures > snapshots > [email protected] 1`] = `
export const metadata: npmTypes.PackumentVersion = {
PackumentVersion = {
"name": "tiny-tarball",
"version": "1.0.0",
"description": "tiny tarball used for health checks",
Expand Down Expand Up @@ -318,7 +318,7 @@ export const metadata: npmTypes.PackumentVersion = {
`

exports[`test/fixtures.ts > TAP > fixtures > snapshots > [email protected] 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",
Expand Down Expand Up @@ -366,7 +366,7 @@ export const metadata: npmTypes.PackumentVersion = {
`

exports[`test/fixtures.ts > TAP > fixtures > snapshots > [email protected] 1`] = `
export const metadata: npmTypes.PackumentVersion = {
PackumentVersion = {
"name": "uuid",
"version": "1.4.1",
"description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.",
Expand Down
16 changes: 7 additions & 9 deletions test/fixtures.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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}`,
])),
})

Expand Down Expand Up @@ -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)}`
}
}

Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
"strict": true,
"target": "es2022",
"noEmit": true
},
"include": [
"test/fixtures.ts"
]
}
}

0 comments on commit 1a1fd85

Please sign in to comment.