Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): replace standard with neostandard #779

Merged
merged 5 commits into from
Jan 16, 2025
Merged
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
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 @@ -326,15 +326,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
10 changes: 10 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

module.exports = require('neostandard')({
ignores: [
...require('neostandard').resolveIgnoresFromGitignore(),
'test/data/parsing-error.js',
'test/data/undefinedVariable.js',
],
ts: true
})
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
}
13 changes: 4 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 @@ -79,14 +73,15 @@
"c8": "^10.1.2",
"concurrently": "^9.0.0",
"cross-env": "^7.0.3",
"eslint": "^9.17.0",
"fastify-tsconfig": "^3.0.0",
"glob": "^11.0.1",
"minimatch": "^9.0.5",
"neostandard": "^0.12.0",
"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
20 changes: 10 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 'node:path';
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
import { FastifyPluginAsync } from 'fastify';
import * as path from 'node:path'
import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
import { FastifyPluginAsync } from 'fastify'
import { fileURLToPath } from 'node: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 @@ -26,6 +25,7 @@ const app: FastifyPluginAsync<AppOptions> = async (
// This loads all plugins defined in plugins
// those should be support plugins that are reused
// through your application
// eslint-disable-next-line no-void
void fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
options: opts,
Expand All @@ -34,13 +34,13 @@ const app: FastifyPluginAsync<AppOptions> = async (

// This loads all plugins defined in routes
// define your routes in one of these
// eslint-disable-next-line no-void
void fastify.register(AutoLoad, {
dir: path.join(__dirname, 'routes'),
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
3 changes: 2 additions & 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 'node:url'

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

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
Expand All @@ -31,6 +31,7 @@ async function build (t: TestContext) {
const app = await helper.build(argv, config())

// Tear down our app after we are done
// eslint-disable-next-line no-void
t.after(() => void app.close())

return app
Expand Down
1 change: 1 addition & 0 deletions templates/app-ts-esm/test/plugins/support.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Support from '../../src/plugins/support.js'

test('support works standalone', async (t) => {
const fastify = Fastify()
// eslint-disable-next-line no-void
void fastify.register(Support)
await fastify.ready()

Expand Down
16 changes: 9 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 'node:path';
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify';
import { join } from 'node: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 @@ -20,18 +20,20 @@ const app: FastifyPluginAsync<AppOptions> = async (
// This loads all plugins defined in plugins
// those should be support plugins that are reused
// through your application
// eslint-disable-next-line no-void
void fastify.register(AutoLoad, {
dir: join(__dirname, 'plugins'),
options: opts
})

// This loads all plugins defined in routes
// define your routes in one of these
// eslint-disable-next-line no-void
void fastify.register(AutoLoad, {
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
5 changes: 3 additions & 2 deletions templates/app-ts/test/helper.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// This file contains code that we reuse between our tests.
const helper = require('fastify-cli/helper.js')
import * as path from 'node:path'
import * as test from 'node:test'
const helper = require('fastify-cli/helper.js')

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

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

Expand All @@ -28,6 +28,7 @@ async function build (t: TestContext) {
const app = await helper.build(argv, config())

// Tear down our app after we are done
// eslint-disable-next-line no-void
t.after(() => void app.close())

return app
Expand Down
1 change: 1 addition & 0 deletions templates/app-ts/test/plugins/support.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Support from '../../src/plugins/support'

test('support works standalone', async (t) => {
const fastify = Fastify()
// eslint-disable-next-line no-void
void fastify.register(Support)
await fastify.ready()

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'

// 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'
dotenv.config()

// 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: 2 additions & 0 deletions templates/plugin/test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { expectType } from 'tsd'
let app
try {
app = fastify()
// eslint-disable-next-line no-void
void app.ready()
// eslint-disable-next-line no-void
void app.register(example)
expectType<() => string>(app.exampleDecorator)
} catch (err) {
Expand Down
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)
Loading
Loading