fastify-cli
Advanced tools
Comparing version 5.8.0 to 5.9.0
@@ -5,3 +5,3 @@ #!/usr/bin/env node | ||
const path = require('path') | ||
const path = require('node:path') | ||
const commist = require('commist')() | ||
@@ -8,0 +8,0 @@ const argv = require('yargs-parser')(process.argv) |
'use strict' | ||
const path = require('path') | ||
const path = require('node:path') | ||
const generify = require('generify') | ||
@@ -5,0 +5,0 @@ const argv = require('yargs-parser') |
@@ -6,5 +6,5 @@ 'use strict' | ||
writeFile | ||
} = require('fs').promises | ||
const { existsSync } = require('fs') | ||
const path = require('path') | ||
} = require('node:fs').promises | ||
const { existsSync } = require('node:fs') | ||
const path = require('node:path') | ||
const chalk = require('chalk') | ||
@@ -14,4 +14,4 @@ const generify = require('generify') | ||
const cliPkg = require('./package') | ||
const { execSync } = require('child_process') | ||
const { promisify } = require('util') | ||
const { execSync } = require('node:child_process') | ||
const { promisify } = require('node:util') | ||
const log = require('./log') | ||
@@ -18,0 +18,0 @@ |
'use strict' | ||
const { readFileSync, existsSync } = require('fs') | ||
const path = require('path') | ||
const { readFileSync, existsSync } = require('node:fs') | ||
const path = require('node:path') | ||
const generify = require('generify') | ||
const argv = require('yargs-parser') | ||
const { execSync } = require('child_process') | ||
const { execSync } = require('node:child_process') | ||
const log = require('./log') | ||
@@ -9,0 +9,0 @@ |
@@ -6,2 +6,3 @@ #! /usr/bin/env node | ||
const parseArgs = require('./args') | ||
const argv = require('yargs-parser') | ||
const log = require('./log') | ||
@@ -28,2 +29,3 @@ const { | ||
const opts = parseArgs(args) | ||
const extraOpts = argv(args) | ||
if (opts.help) { | ||
@@ -50,3 +52,7 @@ return showHelpForCommand('generate-swagger') | ||
return JSON.stringify(fastify.swagger(), undefined, 2) | ||
if (extraOpts.yaml) { | ||
return fastify.swagger({ yaml: true }) | ||
} else { | ||
return JSON.stringify(fastify.swagger(), undefined, 2) | ||
} | ||
} finally { | ||
@@ -53,0 +59,0 @@ fastify.close() |
@@ -7,4 +7,4 @@ 'use strict' | ||
existsSync | ||
} = require('fs') | ||
const path = require('path') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const chalk = require('chalk') | ||
@@ -14,3 +14,3 @@ const generify = require('generify') | ||
const cliPkg = require('./package') | ||
const { execSync } = require('child_process') | ||
const { execSync } = require('node:child_process') | ||
const log = require('./log') | ||
@@ -41,3 +41,3 @@ | ||
log('debug', `run '${chalk.bold('npm start')}' to start the application`) | ||
log('debug', `run '${chalk.bold('npm run dev')}' to start the application with pino-colada pretty logging (not suitable for production)`) | ||
log('debug', `run '${chalk.bold('npm run dev')}' to start the application with pino-pretty pretty logging (not suitable for production)`) | ||
log('debug', `run '${chalk.bold('npm test')}' to execute the unit tests`) | ||
@@ -88,3 +88,3 @@ | ||
log('debug', `run '${chalk.bold('npm build:ts')}' to compile the typescript application`) | ||
log('debug', `run '${chalk.bold('npm run dev')}' to start the application with pino-colada pretty logging (not suitable for production)`) | ||
log('debug', `run '${chalk.bold('npm run dev')}' to start the application with pino-pretty pretty logging (not suitable for production)`) | ||
log('debug', `run '${chalk.bold('npm test')}' to execute the unit tests`) | ||
@@ -91,0 +91,0 @@ } |
Usage: fastify generate-plugin [opts] <file> [--] [<plugin-options>] | ||
Generate Swagger/OpenAPI schema for a project using @fastify/cli. | ||
Generate Swagger/OpenAPI schema for a project using @fastify/swagger. | ||
OPTS | ||
--yaml=true | ||
generate in YAML format |
'use strict' | ||
const path = require('path') | ||
const cp = require('child_process') | ||
const path = require('node:path') | ||
const cp = require('node:child_process') | ||
const chalk = require('chalk') | ||
@@ -9,3 +9,3 @@ const { arrayToRegExp, logWatchVerbose } = require('./utils') | ||
const EventEmitter = require('events') | ||
const EventEmitter = require('node:events') | ||
const chokidar = require('chokidar') | ||
@@ -12,0 +12,0 @@ const forkPath = path.join(__dirname, './fork.js') |
'use strict' | ||
const chalk = require('chalk') | ||
const path = require('path') | ||
const path = require('node:path') | ||
@@ -6,0 +6,0 @@ const arrayToRegExp = (arr) => { |
{ | ||
"name": "fastify-cli", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"description": "Run a fastify route with one command!", | ||
"main": "cli.js", | ||
"type": "commonjs", | ||
"bin": { | ||
@@ -18,3 +19,3 @@ "fastify": "cli.js" | ||
"test": "c8 --clean npm run test-no-coverage", | ||
"test:typescript": "tsd templates/plugin && tsc --project templates/app-ts/tsconfig.json && del-cli templates/app-ts/dist" | ||
"test:typescript": "tsd templates/plugin -t ./../../index.d.ts && tsc --project templates/app-ts/tsconfig.json && del-cli templates/app-ts/dist" | ||
}, | ||
@@ -74,6 +75,6 @@ "keywords": [ | ||
"c8": "^7.13.0", | ||
"concurrently": "^7.0.0", | ||
"concurrently": "^8.2.2", | ||
"cross-env": "^7.0.3", | ||
"del-cli": "^3.0.1", | ||
"fastify-tsconfig": "^1.0.1", | ||
"fastify-tsconfig": "^2.0.0", | ||
"minimatch": "^5.1.0", | ||
@@ -83,3 +84,3 @@ "proxyquire": "^2.1.3", | ||
"simple-get": "^4.0.0", | ||
"sinon": "^14.0.0", | ||
"sinon": "^17.0.0", | ||
"standard": "^17.0.0", | ||
@@ -90,4 +91,4 @@ "strip-ansi": "^6.0.1", | ||
"ts-standard": "^12.0.1", | ||
"tsd": "^0.16.0", | ||
"typescript": "^4.5.4", | ||
"tsd": "^0.28.0", | ||
"typescript": "^5.2.2", | ||
"walker": "^1.0.8" | ||
@@ -94,0 +95,0 @@ }, |
@@ -127,3 +127,3 @@ #! /usr/bin/env node | ||
} else { | ||
require('inspector').open( | ||
require('node:inspector').open( | ||
opts.debugPort, | ||
@@ -130,0 +130,0 @@ opts.debugHost || isDocker() || isKubernetes() ? listenAddressDocker : undefined |
'use strict' | ||
const path = require('path') | ||
const path = require('node:path') | ||
const AutoLoad = require('@fastify/autoload') | ||
// Pass --options via CLI arguments in command to enable these options. | ||
module.exports.options = {} | ||
const options = {} | ||
@@ -29,1 +29,3 @@ module.exports = async function (fastify, opts) { | ||
} | ||
module.exports.options = options |
@@ -7,3 +7,3 @@ 'use strict' | ||
const { build: buildApplication } = require('fastify-cli/helper') | ||
const path = require('path') | ||
const path = require('node:path') | ||
const AppPath = path.join(__dirname, '..', 'app.js') | ||
@@ -10,0 +10,0 @@ |
@@ -8,3 +8,3 @@ import fastify from 'fastify' | ||
app = fastify() | ||
await app.ready() | ||
app.ready() | ||
app.register(example) | ||
@@ -11,0 +11,0 @@ expectType<() => string>(app.exampleDecorator) |
@@ -0,1 +1,3 @@ | ||
'use strict' | ||
const { test } = require('tap') | ||
@@ -2,0 +4,0 @@ |
@@ -0,1 +1,3 @@ | ||
'use strict' | ||
const t = require('tap') | ||
@@ -2,0 +4,0 @@ const test = t.test |
'use strict' | ||
const t = require('tap') | ||
const { execSync } = require('child_process') | ||
const { mkdirSync, readFileSync } = require('fs') | ||
const path = require('path') | ||
const { execSync } = require('node:child_process') | ||
const { mkdirSync, readFileSync } = require('node:fs') | ||
const path = require('node:path') | ||
const rimraf = require('rimraf') | ||
@@ -8,0 +8,0 @@ |
@@ -0,1 +1,3 @@ | ||
'use strict' | ||
module.exports = { | ||
@@ -2,0 +4,0 @@ port: 5000, |
@@ -0,1 +1,3 @@ | ||
'use strict' | ||
module.exports = { | ||
@@ -2,0 +4,0 @@ name: 'Custom Logger', |
@@ -0,1 +1,3 @@ | ||
'use strict' | ||
module.exports = {} |
@@ -12,4 +12,4 @@ 'use strict' | ||
readFile | ||
} = require('fs') | ||
const path = require('path') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const rimraf = require('rimraf') | ||
@@ -16,0 +16,0 @@ const walker = require('walker') |
@@ -8,4 +8,4 @@ 'use strict' | ||
const t = require('tap') | ||
const { mkdirSync, readFileSync, readFile } = require('fs') | ||
const path = require('path') | ||
const { mkdirSync, readFileSync, readFile } = require('node:fs') | ||
const path = require('node:path') | ||
const rimraf = require('rimraf') | ||
@@ -12,0 +12,0 @@ const walker = require('walker') |
@@ -12,4 +12,4 @@ 'use strict' | ||
readFile | ||
} = require('fs') | ||
const path = require('path') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const rimraf = require('rimraf') | ||
@@ -16,0 +16,0 @@ const walker = require('walker') |
@@ -14,5 +14,5 @@ 'use strict' | ||
unlink | ||
} = require('fs') | ||
const path = require('path') | ||
const { promisify } = require('util') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const { promisify } = require('node:util') | ||
const rimraf = require('rimraf') | ||
@@ -24,3 +24,3 @@ const walker = require('walker') | ||
const cliPkg = require('../package') | ||
const { exec, execSync } = require('child_process') | ||
const { exec, execSync } = require('node:child_process') | ||
const pExec = promisify(exec) | ||
@@ -185,3 +185,3 @@ const pUnlink = promisify(unlink) | ||
const testGlob = pkg.scripts.test.split(' ')[2].replace(/"/g, '') | ||
const testGlob = pkg.scripts.test.split(' ', 3)[2].replace(/"/g, '') | ||
t.equal(minimatch.match(['test/services/plugins/more/test/here/ok.test.js'], testGlob).length, 1) | ||
@@ -188,0 +188,0 @@ resolve() |
@@ -12,4 +12,4 @@ 'use strict' | ||
readFile | ||
} = require('fs') | ||
const path = require('path') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const rimraf = require('rimraf') | ||
@@ -21,3 +21,3 @@ const walker = require('walker') | ||
const cliPkg = require('../package') | ||
const { exec, execSync } = require('child_process') | ||
const { exec, execSync } = require('node:child_process') | ||
const minimatch = require('minimatch') | ||
@@ -144,3 +144,3 @@ const strip = require('strip-ansi') | ||
const testGlob = pkg.scripts.unit.split(' ')[1].replace(/"/g, '') | ||
const testGlob = pkg.scripts.unit.split(' ', 2)[1].replace(/"/g, '') | ||
t.equal(minimatch.match(['test/more/test/here/ok.test.js'], testGlob).length, 1) | ||
@@ -147,0 +147,0 @@ resolve() |
'use strict' | ||
const path = require('path') | ||
const fs = require('fs') | ||
const path = require('node:path') | ||
const fs = require('node:fs') | ||
const t = require('tap') | ||
@@ -6,0 +6,0 @@ const rimraf = require('rimraf') |
@@ -1,2 +0,4 @@ | ||
const path = require('path') | ||
'use strict' | ||
const path = require('node:path') | ||
const t = require('tap') | ||
@@ -19,1 +21,12 @@ const { test } = t | ||
}) | ||
test('should generate swagger in yaml format', async (t) => { | ||
t.plan(1) | ||
try { | ||
const swagger = await generateSwagger(['--yaml=true', swaggerplugin]) | ||
t.ok(swagger.startsWith('openapi: 3.0.3')) | ||
} catch (err) { | ||
t.error(err) | ||
} | ||
}) |
@@ -12,4 +12,4 @@ 'use strict' | ||
readFile | ||
} = require('fs') | ||
const path = require('path') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const rimraf = require('rimraf') | ||
@@ -21,3 +21,3 @@ const walker = require('walker') | ||
const cliPkg = require('../package') | ||
const { exec, execSync } = require('child_process') | ||
const { exec, execSync } = require('node:child_process') | ||
const minimatch = require('minimatch') | ||
@@ -148,3 +148,3 @@ const strip = require('strip-ansi') | ||
const testGlob = pkg.scripts.test.split(' ')[10].replace(/"/g, '') | ||
const testGlob = pkg.scripts.test.split(' ', 11)[10].replace(/"/g, '') | ||
@@ -151,0 +151,0 @@ t.equal(minimatch.match(['test/routes/plugins/more/test/here/ok.test.ts'], testGlob).length, 1) |
@@ -12,4 +12,4 @@ 'use strict' | ||
readFile | ||
} = require('fs') | ||
const path = require('path') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const rimraf = require('rimraf') | ||
@@ -21,3 +21,3 @@ const walker = require('walker') | ||
const cliPkg = require('../package') | ||
const { exec, execSync } = require('child_process') | ||
const { exec, execSync } = require('node:child_process') | ||
const minimatch = require('minimatch') | ||
@@ -148,3 +148,3 @@ const strip = require('strip-ansi') | ||
const testGlob = pkg.scripts.test.split(' ')[10].replace(/"/g, '') | ||
const testGlob = pkg.scripts.test.split(' ', 11)[10].replace(/"/g, '') | ||
@@ -151,0 +151,0 @@ t.equal(minimatch.match(['test/routes/plugins/more/test/here/ok.test.ts'], testGlob).length, 1) |
@@ -14,5 +14,5 @@ 'use strict' | ||
unlink | ||
} = require('fs') | ||
const path = require('path') | ||
const { promisify } = require('util') | ||
} = require('node:fs') | ||
const path = require('node:path') | ||
const { promisify } = require('node:util') | ||
const rimraf = require('rimraf') | ||
@@ -24,3 +24,3 @@ const walker = require('walker') | ||
const cliPkg = require('../package') | ||
const { exec, execSync } = require('child_process') | ||
const { exec, execSync } = require('node:child_process') | ||
const pExec = promisify(exec) | ||
@@ -175,3 +175,3 @@ const pUnlink = promisify(unlink) | ||
const testGlob = pkg.scripts.test.split(' ')[1].replace(/"/g, '') | ||
const testGlob = pkg.scripts.test.split(' ', 2)[1].replace(/"/g, '') | ||
t.equal(minimatch.match(['test/services/plugins/more/test/here/ok.test.js'], testGlob).length, 1) | ||
@@ -178,0 +178,0 @@ resolve() |
'use strict' | ||
const util = require('util') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const util = require('node:util') | ||
const fs = require('node:fs') | ||
const path = require('node:path') | ||
const { test } = require('tap') | ||
const stream = require('stream') | ||
const stream = require('node:stream') | ||
@@ -9,0 +9,0 @@ const helper = require('../helper') |
/* global GLOBAL_MODULE_1, GLOBAL_MODULE_2 */ | ||
'use strict' | ||
const util = require('util') | ||
const { once } = require('events') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const crypto = require('crypto') | ||
const util = require('node:util') | ||
const { once } = require('node:events') | ||
const fs = require('node:fs') | ||
const path = require('node:path') | ||
const crypto = require('node:crypto') | ||
const semver = require('semver') | ||
const baseFilename = path.join(__dirname, 'fixtures', `test_${crypto.randomBytes(16).toString('hex')}`) | ||
const { fork } = require('child_process') | ||
const { fork } = require('node:child_process') | ||
const moduleSupport = semver.satisfies(process.version, '>= 14 || >= 12.17.0 < 13.0.0') | ||
@@ -229,3 +229,3 @@ | ||
await new Promise((resolve, reject) => { | ||
const request = require('http').request({ | ||
const request = require('node:http').request({ | ||
method: 'GET', | ||
@@ -718,3 +718,3 @@ path: '/', | ||
const start = proxyquire('../start', { | ||
inspector: { | ||
'node:inspector': { | ||
open (p) { | ||
@@ -738,3 +738,3 @@ t.equal(p, 9320) | ||
const start = proxyquire('../start', { | ||
inspector: { | ||
'node:inspector': { | ||
open (p) { | ||
@@ -741,0 +741,0 @@ t.equal(p, Number(port)) |
@@ -6,27 +6,49 @@ 'use strict' | ||
module.exports = fp(function (fastify, opts, next) { | ||
fastify.decorate('swagger', function () { | ||
return { | ||
openapi: '3.0.3', | ||
info: { | ||
version: '8.1.0', | ||
title: '@fastify/swagger' | ||
}, | ||
components: { | ||
schemas: {} | ||
}, | ||
paths: { | ||
'/': { | ||
get: { | ||
responses: { | ||
200: { | ||
description: 'Default Response' | ||
fastify.decorate('swagger', function (opts) { | ||
if (opts && opts.yaml) { | ||
return `\ | ||
openapi: 3.0.3 | ||
info: | ||
version: 8.1.0 | ||
title: "@fastify/swagger" | ||
components: | ||
schemas: {} | ||
paths: | ||
"/": | ||
get: | ||
responses: | ||
'200': | ||
description: Default Response | ||
"/example/": | ||
get: | ||
responses: | ||
'200': | ||
description: Default Response | ||
` | ||
} else { | ||
return { | ||
openapi: '3.0.3', | ||
info: { | ||
version: '8.1.0', | ||
title: '@fastify/swagger' | ||
}, | ||
components: { | ||
schemas: {} | ||
}, | ||
paths: { | ||
'/': { | ||
get: { | ||
responses: { | ||
200: { | ||
description: 'Default Response' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
'/example/': { | ||
get: { | ||
responses: { | ||
200: { | ||
description: 'Default Response' | ||
}, | ||
'/example/': { | ||
get: { | ||
responses: { | ||
200: { | ||
description: 'Default Response' | ||
} | ||
} | ||
@@ -33,0 +55,0 @@ } |
@@ -1,4 +0,6 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const url = require('url') | ||
'use strict' | ||
const fs = require('node:fs') | ||
const path = require('node:path') | ||
const url = require('node:url') | ||
const semver = require('semver') | ||
@@ -5,0 +7,0 @@ const pkgUp = require('pkg-up') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
203496
160
5044
84
0