Skip to content

Commit

Permalink
build(deps-dev): replace standard with neostandard
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 8, 2024
1 parent 7d1de11 commit 51767de
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 93 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/fastify/fastify-cli/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-cli/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/fastify-cli.svg?style=flat)](https://www.npmjs.com/package/fastify-cli)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)

Command line tools for [Fastify](https://github.com/fastify/fastify).
Generate, write, and run an application with one single command!
Expand Down Expand Up @@ -323,15 +323,15 @@ if your project uses `@fastify/swagger`, `fastify-cli` can generate and write ou

```diff
"devDependencies": {
+ "standard": "^11.0.1",
+ "neostandard": "^0.11.9",
}

"scripts": {
+ "pretest": "standard",
+ "pretest": "eslint",
"test": "node --test test/**/*.test.js",
"start": "fastify start -l info app.js",
"dev": "fastify start -l info -P app.js",
+ "lint": "standard --fix"
+ "lint": "eslint --fix"
},
```

Expand Down
8 changes: 4 additions & 4 deletions helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fastify from 'fastify'

declare module 'fastify-cli/helper.js' {
module helper {
export function build(args: Array<string>, additionalOptions?: Object, serverOptions?: Object): ReturnType<typeof fastify>;
}
module helper {
export function build (args: Array<string>, additionalOptions?: Object, serverOptions?: Object): ReturnType<typeof fastify>
}

export = helper;
export = helper
}
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"fastify": "cli.js"
},
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"pretest": "xcopy /e /k /i . \"..\\node_modules\\fastify-cli\" || rsync -r --exclude=node_modules ./ node_modules/fastify-cli || echo 'this is fine'",
"test": "npm run unit:suites && c8 --clean npm run test:cli-and-typescript",
"unit:cjs": "node suite-runner.js \"templates/app/test/**/*.test.js\"",
Expand Down Expand Up @@ -46,12 +46,6 @@
"url": "https://github.com/fastify/fastify-cli/issues"
},
"homepage": "https://github.com/fastify/fastify-cli#readme",
"standard": {
"ignore": [
"test/data/parsing-error.js",
"test/data/undefinedVariable.js"
]
},
"dependencies": {
"@fastify/deepmerge": "^2.0.0",
"chalk": "^4.1.2",
Expand Down Expand Up @@ -81,11 +75,11 @@
"cross-env": "^7.0.3",
"fastify-tsconfig": "^2.0.0",
"minimatch": "^9.0.5",
"neostandard": "^0.11.9",
"proxyquire": "^2.1.3",
"rimraf": "^3.0.2",
"simple-get": "^4.0.0",
"sinon": "^19.0.2",
"standard": "^17.0.0",
"strip-ansi": "^6.0.1",
"tap": "^16.1.0",
"ts-node": "^10.4.0",
Expand Down
18 changes: 8 additions & 10 deletions templates/app-ts-esm/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import * as path from 'path';
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
import { FastifyPluginAsync } from 'fastify';
import * as path from 'path'
import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
import { FastifyPluginAsync } from 'fastify'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

export type AppOptions = {
// Place your custom options for app below here.
} & Partial<AutoloadPluginOptions>;

} & Partial<AutoloadPluginOptions>

// Pass --options via CLI arguments in command to enable these options.
const options: AppOptions = {
}

const app: FastifyPluginAsync<AppOptions> = async (
fastify,
opts
fastify,
opts
): Promise<void> => {
// Place here your custom code!

Expand All @@ -39,8 +38,7 @@ const app: FastifyPluginAsync<AppOptions> = async (
options: opts,
forceESM: true
})
}

};

export default app;
export default app
export { app, options }
4 changes: 2 additions & 2 deletions templates/app-ts-esm/src/routes/example/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FastifyPluginAsync } from "fastify"
import { FastifyPluginAsync } from 'fastify'

const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
fastify.get('/', async function (request, reply) {
return 'this is an example'
})
}

export default example;
export default example
2 changes: 1 addition & 1 deletion templates/app-ts-esm/src/routes/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const root: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
})
}

export default root;
export default root
2 changes: 1 addition & 1 deletion templates/app-ts-esm/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fileURLToPath } from 'url'

export type TestContext = {
after: typeof test.after
};
}

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
Expand Down
14 changes: 7 additions & 7 deletions templates/app-ts/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path';
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify';
import { join } from 'path'
import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify'

export interface AppOptions extends FastifyServerOptions, Partial<AutoloadPluginOptions> {

Expand All @@ -10,8 +10,8 @@ const options: AppOptions = {
}

const app: FastifyPluginAsync<AppOptions> = async (
fastify,
opts
fastify,
opts
): Promise<void> => {
// Place here your custom code!

Expand All @@ -31,7 +31,7 @@ const app: FastifyPluginAsync<AppOptions> = async (
dir: join(__dirname, 'routes'),
options: opts
})
};
}

export default app;
export default app
export { app, options }
4 changes: 2 additions & 2 deletions templates/app-ts/src/routes/example/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FastifyPluginAsync } from "fastify"
import { FastifyPluginAsync } from 'fastify'

const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
fastify.get('/', async function (request, reply) {
return 'this is an example'
})
}

export default example;
export default example
2 changes: 1 addition & 1 deletion templates/app-ts/src/routes/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const root: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
})
}

export default root;
export default root
2 changes: 1 addition & 1 deletion templates/app-ts/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as test from 'node:test'

export type TestContext = {
after: typeof test.after
};
}

const AppPath = path.join(__dirname, '..', 'src', 'app.ts')

Expand Down
18 changes: 9 additions & 9 deletions templates/eject-ts/server.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Read the .env file.
import * as dotenv from "dotenv";
dotenv.config();
import * as dotenv from 'dotenv'
dotenv.config()

// Require the framework
import Fastify from "fastify";
import Fastify from 'fastify'

// Require library to exit fastify process, gracefully (if possible)
import closeWithGrace from "close-with-grace";
import closeWithGrace from 'close-with-grace'

// Instantiate Fastify with some config
const app = Fastify({
logger: true,
});
})

// Register your application as a normal plugin.
app.register(import("./app"));
app.register(import('./app'))

// delay is the number of milliseconds for the graceful close to finish
closeWithGrace({ delay: parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY) || 500 }, async function ({ signal, err, manual }) {
Expand All @@ -27,7 +27,7 @@ closeWithGrace({ delay: parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY) || 500 }
// Start listening.
app.listen({ port: parseInt(process.env.PORT) || 3000 }, (err: any) => {
if (err) {
app.log.error(err);
process.exit(1);
app.log.error(err)
process.exit(1)
}
});
})
2 changes: 1 addition & 1 deletion test/data/custom-import.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* global GLOBAL_MODULE_3 */
globalThis.GLOBAL_MODULE_3 = true // eslint-disable-line
globalThis.GLOBAL_MODULE_3 = true
console.log('this is module to be preloaded that sets GLOBAL_MODULE_3=', GLOBAL_MODULE_3)
2 changes: 1 addition & 1 deletion test/data/custom-import2.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* global GLOBAL_MODULE_4 */
globalThis.GLOBAL_MODULE_4 = true // eslint-disable-line
globalThis.GLOBAL_MODULE_4 = true
console.log('this is module to be preloaded that sets GLOBAL_MODULE_4=', GLOBAL_MODULE_4)
80 changes: 40 additions & 40 deletions test/templates/app-ts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,53 @@ import { test } from 'tap'
const sgetOriginal = require('simple-get').concat

import appDefault, { app } from '../../templates/app-ts/src/app'
import {AddressInfo} from "net";
import { AddressInfo } from 'net'

const sget = (opts: Record<string, any>): Record<string, any> => {
return new Promise((resolve, reject) => {
sgetOriginal(opts, (err: Error, response: any, body: any) => {
if (err) return reject(err)
return resolve({ response, body })
})
return new Promise((resolve, reject) => {
sgetOriginal(opts, (err: Error, response: any, body: any) => {
if (err) return reject(err)
return resolve({ response, body })
})
})
}

test('should print routes for TS app', async t => {
t.plan(4)

const fastifyApp = fastify({}, );
await app(fastifyApp, {});
await fastifyApp.ready();
await fastifyApp.listen({ port: 3000 })

const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.equal(response.statusCode, 200)
t.equal(response.headers['content-length'], '' + body.length)
t.same(JSON.parse(body), { root: true })

await fastifyApp.close();
t.pass('server closed')
t.plan(4)

const fastifyApp = fastify({})
await app(fastifyApp, {})
await fastifyApp.ready()
await fastifyApp.listen({ port: 3000 })

const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.equal(response.statusCode, 200)
t.equal(response.headers['content-length'], '' + body.length)
t.same(JSON.parse(body), { root: true })

await fastifyApp.close()
t.pass('server closed')
})

test('should print routes for default TS app', async t => {
t.plan(4)

const fastifyApp = fastify({}, );
await appDefault(fastifyApp, {});
await fastifyApp.ready();
await fastifyApp.listen({ port: 3000 })

const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.equal(response.statusCode, 200)
t.equal(response.headers['content-length'], '' + body.length)
t.same(JSON.parse(body), { root: true })

await fastifyApp.close();
t.pass('server closed')
t.plan(4)

const fastifyApp = fastify({})
await appDefault(fastifyApp, {})
await fastifyApp.ready()
await fastifyApp.listen({ port: 3000 })

const { response, body } = await sget({
method: 'GET',
url: `http://localhost:${(fastifyApp.server.address() as AddressInfo).port}`
})
t.equal(response.statusCode, 200)
t.equal(response.headers['content-length'], '' + body.length)
t.same(JSON.parse(body), { root: true })

await fastifyApp.close()
t.pass('server closed')
})

0 comments on commit 51767de

Please sign in to comment.