Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions generate-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const pluginTemplate = {
lint: 'standard && npm run lint:typescript',
'lint:typescript': 'ts-standard',
test: 'npm run lint && npm run unit && npm run test:typescript',
'test:typescript': 'tsd',
'test:typescript': 'tstyche',
unit: 'node --test'
},
dependencies: {
Expand All @@ -34,16 +34,16 @@ const pluginTemplate = {
'fastify-tsconfig': cliPkg.devDependencies['fastify-tsconfig'],
standard: cliPkg.devDependencies.standard,
'ts-standard': cliPkg.devDependencies['ts-standard'],
tsd: cliPkg.devDependencies.tsd,
tstyche: cliPkg.devDependencies.tstyche,
typescript: cliPkg.devDependencies.typescript
},
tsd: {
directory: 'test'
},
logInstructions: function (pkg) {
log('debug', 'saved package.json')
log('info', `project ${pkg.name} generated successfully`)
log('debug', `run '${chalk.bold('npm install')}' to install the dependencies`)
log(
'debug',
`run '${chalk.bold('npm install')}' to install the dependencies`
)
log('debug', `run '${chalk.bold('npm test')}' to execute the tests`)
}
}
Expand All @@ -69,7 +69,7 @@ async function generate (dir, template) {
pkg.scripts = Object.assign(pkg.scripts || {}, template.scripts)
pkg.dependencies = Object.assign(pkg.dependencies || {}, template.dependencies)
pkg.devDependencies = Object.assign(pkg.devDependencies || {}, template.devDependencies)
pkg.tsd = Object.assign(pkg.tsd || {}, template.tsd)
pkg.tstyche = Object.assign(pkg.tstyche || {}, template.tstyche)

log('debug', 'edited package.json, saving')

Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"unit:cli-ts": "cross-env TS_NODE_PROJECT=./test/configs/ts-cjs.tsconfig.json node -r ts-node/register suite-runner.js \"test/**/*.test.ts\"",
"unit:cli": "npm run unit:cli-js && npm run unit:cli-ts && npm run unit:cli-js-esm",
"test:cli-and-typescript": "npm run unit:cli && npm run test:typescript",
"test:typescript": "tsd templates/plugin -t ./../../index.d.ts && tsc --project templates/app-ts/tsconfig.json --noEmit && tsc --project templates/app-ts-esm/tsconfig.json --noEmit"
"test:typescript": "tstyche"
},
"keywords": [
"fastify",
Expand Down Expand Up @@ -80,11 +80,8 @@
"strip-ansi": "^6.0.1",
"ts-node": "^10.4.0",
"ts-standard": "^12.0.1",
"tsd": "^0.33.0",
"tstyche": "^7.0.0",
"typescript": "~6.0.2",
"walker": "^1.0.8"
},
"tsd": {
"directory": "test"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fastify from 'fastify'
import example from '..'
import { expectType } from 'tsd'
import { expect } from 'tstyche'

let app
try {
Expand All @@ -9,7 +9,7 @@ try {
void app.ready()
// eslint-disable-next-line no-void
void app.register(example)
expectType<() => string>(app.exampleDecorator)
expect(app.exampleDecorator).type.toBe<() => string>()
} catch (err) {
console.error(err)
}
6 changes: 3 additions & 3 deletions test/generate-plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ function define (t) {
t.assert.strictEqual(pkg.scripts.lint, 'standard && npm run lint:typescript')
t.assert.strictEqual(pkg.scripts['lint:typescript'], 'ts-standard')
t.assert.strictEqual(pkg.scripts.test, 'npm run lint && npm run unit && npm run test:typescript')
t.assert.strictEqual(pkg.scripts['test:typescript'], 'tsd')
t.assert.strictEqual(pkg.scripts['test:typescript'], 'tstyche')
t.assert.strictEqual(pkg.scripts.unit, 'node --test')
t.assert.strictEqual(pkg.dependencies['fastify-plugin'], cliPkg.dependencies['fastify-plugin'])
t.assert.strictEqual(pkg.devDependencies['@types/node'], cliPkg.devDependencies['@types/node'])
t.assert.strictEqual(pkg.devDependencies.fastify, cliPkg.devDependencies.fastify)
t.assert.strictEqual(pkg.devDependencies.standard, cliPkg.devDependencies.standard)
t.assert.strictEqual(pkg.devDependencies.tsd, cliPkg.devDependencies.tsd)
t.assert.strictEqual(pkg.devDependencies.tstyche, cliPkg.devDependencies.tstyche)
t.assert.strictEqual(pkg.devDependencies.typescript, cliPkg.devDependencies.typescript)
t.assert.deepStrictEqual(pkg.tsd, pluginTemplate.tsd)
t.assert.deepStrictEqual(pkg.tstyche, pluginTemplate.tstyche)

resolve()
})
Expand Down
Loading