Skip to content

Commit

Permalink
Fastify fixes (#931)
Browse files Browse the repository at this point in the history
* fix: pack the generator dir

* fix: fastify 4 doesn't pair with next 14 well

* fix: no build script for non-TS APIs

* fix: lockfile
  • Loading branch information
agerard-godaddy authored Sep 26, 2024
1 parent d033a50 commit 44fbc51
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 68 deletions.
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' }
]
}
]);
});
});

0 comments on commit 44fbc51

Please sign in to comment.