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

Fastify fixes #931

Merged
merged 4 commits into from
Sep 26, 2024
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
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/gasket-plugin-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"generator",
"lib"
],
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gasket-preset-api/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function create(gasket, context) {
pkg.add('scripts', {
start: 'node server.js',
local: 'nodemon server.js',
preview: 'npm run build && npm run start'
preview: 'npm run start'
});
}
}
2 changes: 1 addition & 1 deletion packages/gasket-preset-api/test/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('create', function () {
expect(mockPkgAdd).toHaveBeenCalledWith('scripts', {
start: 'node server.js',
local: 'nodemon server.js',
preview: 'npm run build && npm run start'
preview: 'npm run start'
});
});

Expand Down
1 change: 0 additions & 1 deletion packages/gasket-preset-nextjs/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@gasket/plugin-express';
import '@gasket/plugin-fastify';
import '@gasket/plugin-https';
import '@gasket/plugin-nextjs';
import '@gasket/plugin-webpack';
Expand Down
7 changes: 3 additions & 4 deletions packages/gasket-preset-nextjs/lib/preset-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ export default async function presetConfig(gasket, context) {
pluginLint
];

if ('server' in context) {
const frameworkPlugin = context.server === 'express'
? await import('@gasket/plugin-express')
: await import('@gasket/plugin-fastify');

if (context.nextServerType === 'customServer') {
const frameworkPlugin = await import('@gasket/plugin-express');

plugins.push(frameworkPlugin.default || frameworkPlugin);
}
Expand Down
16 changes: 0 additions & 16 deletions packages/gasket-preset-nextjs/lib/preset-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,5 @@ export default async function presetPrompt(gasket, context, { prompt }) {
await nextJsPrompts.promptNextServerType(context, prompt);
await nextJsPrompts.promptNextDevProxy(context, prompt);

if (!('server' in context) && context.nextServerType === 'customServer') {
const { server } = await prompt([
{
name: 'server',
message: 'Which custom server framework would you like to use?',
type: 'list',
choices: [
{ name: 'Express', value: 'express' },
{ name: 'Fastify', value: 'fastify' }
]
}
]);

Object.assign(context, { server });
}

return context;
}
1 change: 0 additions & 1 deletion packages/gasket-preset-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"dependencies": {
"@gasket/plugin-cypress": "7.0.0-next.69",
"@gasket/plugin-express": "7.0.0-next.69",
"@gasket/plugin-fastify": "7.0.0-next.69",
"@gasket/plugin-https": "7.0.0-next.69",
"@gasket/plugin-intl": "7.0.0-next.69",
"@gasket/plugin-jest": "7.0.0-next.69",
Expand Down
12 changes: 1 addition & 11 deletions packages/gasket-preset-nextjs/test/preset-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,13 @@ describe('presetConfig', () => {

describe('adds server framework plugin', () => {
it('express', async () => {
mockContext.server = 'express';
mockContext.nextServerType = 'customServer';
const config = await presetConfig({}, mockContext);
expect(config.plugins).toEqual(
expect.arrayContaining([
expect.objectContaining({ name: '@gasket/plugin-express' })
])
);
});

it('fastify', async () => {
mockContext.server = 'fastify';
const config = await presetConfig({}, mockContext);
expect(config.plugins).toEqual(
expect.arrayContaining([
expect.objectContaining({ name: '@gasket/plugin-fastify' })
])
);
});
});
});
32 changes: 0 additions & 32 deletions packages/gasket-preset-nextjs/test/preset-prompt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,4 @@ describe('presetPrompt', () => {
expect(mockNextDevProxyPrompt).toHaveBeenCalled();
expect(mockPrompt.prompt).toHaveBeenCalled();
});

it('prompts for server if nextServerType is customServer', async () => {
mockContext.nextServerType = 'customServer';
await presetPrompt({}, mockContext, mockPrompt);
expect(mockPrompt.prompt).toHaveBeenCalledWith([
{
name: 'server',
message: 'Which custom server framework would you like to use?',
type: 'list',
choices: [
{ name: 'Express', value: 'express' },
{ name: 'Fastify', value: 'fastify' }
]
}
]);
});

it('does not prompt for server if nextServerType is not customServer', async () => {
mockContext.nextServerType = 'defaultServer';
await presetPrompt({}, mockContext, mockPrompt);
expect(mockPrompt.prompt).not.toHaveBeenCalledWith([
{
name: 'server',
message: 'Which server framework would you like to use?',
type: 'list',
choices: [
{ name: 'Express', value: 'express' },
{ name: 'Fastify', value: 'fastify' }
]
}
]);
});
});
Loading