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

[PFX-833] Remove Default Plugins #1014

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions packages/create-gasket-app/lib/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { makeCreateContext } from '../scaffold/create-context.js';
import { dumpErrorContext } from '../scaffold/dump-error-context.js';
import { rm } from 'fs/promises';
import { makeGasket } from '@gasket/core';
import { defaultPlugins } from '../config/default-plugins.js';
import {
createHooks,
generateFiles,
Expand Down Expand Up @@ -119,7 +118,7 @@ createCommand.action = async function run(appname, options, command) {

const pluginGasket = makeGasket({
...context.presetConfig,
plugins: context.presets.concat(context.presetConfig.plugins, defaultPlugins)
plugins: context.presets.concat(context.presetConfig.plugins)
});

await promptHooks({ gasket: pluginGasket, context });
Expand Down
17 changes: 0 additions & 17 deletions packages/create-gasket-app/lib/config/default-plugins.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/create-gasket-app/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ declare module 'create-gasket-app' {

constructor(initContext?: Partial<T>);
runWith(plugin: Plugin): Proxy<CreateContext>;
typescript?: boolean;
}
}

Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions packages/gasket-plugin-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"files": [
"lib"
],
"exports": {
".": "./lib/index.js",
"./prompts": "./lib/prompt.js"
},
kbader-godaddy marked this conversation as resolved.
Show resolved Hide resolved
"scripts": {
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
Expand Down
4 changes: 4 additions & 0 deletions packages/gasket-plugin-docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"lib",
"generator"
],
"exports": {
".": "./lib/index.js",
"./prompts": "./lib/prompt.js"
},
"scripts": {
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
Expand Down
4 changes: 4 additions & 0 deletions packages/gasket-plugin-git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"generator",
"lib"
],
"exports": {
".": "./lib/index.js",
"./prompts": "./lib/prompt.js"
},
"scripts": {
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
Expand Down
4 changes: 4 additions & 0 deletions packages/gasket-plugin-lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"files": [
"lib"
],
"exports": {
".": "./lib/index.js",
"./prompts": "./lib/prompt.js"
},
"scripts": {
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
Expand Down
37 changes: 27 additions & 10 deletions packages/gasket-preset-api/lib/preset-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// Default Plugins - included by default for all presets
import pluginCommand from '@gasket/plugin-command';
import pluginDocs from '@gasket/plugin-docs';
import pluginDocusaurus from '@gasket/plugin-docusaurus';
import pluginDynamicPlugins from '@gasket/plugin-dynamic-plugins';
import pluginGit from '@gasket/plugin-git';
import pluginLogger from '@gasket/plugin-logger';
import pluginMetadata from '@gasket/plugin-metadata';

// Preset-specific Plugins
import pluginHttps from '@gasket/plugin-https';
import pluginWinston from '@gasket/plugin-winston';
import pluginLint from '@gasket/plugin-lint';
import pluginWinston from '@gasket/plugin-winston';

/**
* presetConfig hook
Expand All @@ -9,36 +19,43 @@ import pluginLint from '@gasket/plugin-lint';
* @returns {Promise<CreateContext.presetConfig>} config
*/
export default async function presetConfig(gasket, context) {
const plugins = [
const plugins = new Set([
pluginCommand,
pluginDocs,
pluginDocusaurus,
pluginDynamicPlugins,
pluginGit,
pluginHttps,
pluginWinston,
pluginLint
];
pluginLint,
pluginLogger,
pluginMetadata,
pluginWinston
]);

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

plugins.push(frameworkPlugin.default || frameworkPlugin);
plugins.add(frameworkPlugin.default || frameworkPlugin);

if ('testPlugins' in context && context.testPlugins.length > 0) {
await Promise.all(context.testPlugins.map(async (testPlugin) => {
const plugin = await import(testPlugin);
plugins.push(plugin ? plugin.default || plugin : null);
plugins.add(plugin ? plugin.default || plugin : null);
}));
}

if (context.typescript) {
const typescriptPlugin = await import('@gasket/plugin-typescript');
plugins.push(typescriptPlugin.default || typescriptPlugin);
plugins.add(typescriptPlugin.default || typescriptPlugin);
}

if (context.useSwagger) {
const swaggerPlugin = await import('@gasket/plugin-swagger');
plugins.push(swaggerPlugin.default || swaggerPlugin);
plugins.add(swaggerPlugin.default || swaggerPlugin);
}

return {
plugins: plugins.filter(Boolean)
plugins: Array.from(plugins)
};
}
11 changes: 11 additions & 0 deletions packages/gasket-preset-api/lib/preset-prompt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Default Plugins
import docsPrompts from '@gasket/plugin-docs/prompts';
import docusaurusPrompts from '@gasket/plugin-docusaurus/prompts';
import gitPrompts from '@gasket/plugin-git/prompts';

import lintPrompts from '@gasket/plugin-lint/prompts';
import typescriptPrompts from '@gasket/plugin-typescript/prompts';
import swaggerPrompts from '@gasket/plugin-swagger/prompts';

Expand All @@ -11,6 +17,11 @@ import swaggerPrompts from '@gasket/plugin-swagger/prompts';
export default async function presetPrompt(gasket, context, { prompt }) {
context.apiApp = true;

await docsPrompts(gasket, context, { prompt });
await docusaurusPrompts(gasket, context, { prompt });
await gitPrompts(gasket, context, { prompt });

await lintPrompts(gasket, context, { prompt });
kbader-godaddy marked this conversation as resolved.
Show resolved Hide resolved
await typescriptPrompts.promptTypescript(context, prompt);
await swaggerPrompts.promptSwagger(context, prompt);

Expand Down
2 changes: 2 additions & 0 deletions packages/gasket-preset-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-preset-api",
"dependencies": {
"@gasket/plugin-cypress": "^7.1.2",
"@gasket/plugin-docs": "^7.1.2",
"@gasket/plugin-dynamic-plugins": "^7.1.2",
"@gasket/plugin-express": "^7.1.3",
"@gasket/plugin-fastify": "^7.1.2",
"@gasket/plugin-https": "^7.1.2",
Expand Down
39 changes: 28 additions & 11 deletions packages/gasket-preset-nextjs/lib/preset-config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
// Default Plugins - included by default for all presets
import pluginCommand from '@gasket/plugin-command';
import pluginDocs from '@gasket/plugin-docs';
import pluginDocusaurus from '@gasket/plugin-docusaurus';
import pluginDynamicPlugins from '@gasket/plugin-dynamic-plugins';
import pluginGit from '@gasket/plugin-git';
import pluginLogger from '@gasket/plugin-logger';
import pluginMetadata from '@gasket/plugin-metadata';

// Preset-specific Plugins
import pluginHttps from '@gasket/plugin-https';
import pluginHttpsProxy from '@gasket/plugin-https-proxy';
import pluginNext from '@gasket/plugin-nextjs';
import pluginIntl from '@gasket/plugin-intl';
import pluginLint from '@gasket/plugin-lint';
import pluginNext from '@gasket/plugin-nextjs';
import pluginWebpack from '@gasket/plugin-webpack';
import pluginWinston from '@gasket/plugin-winston';
import pluginLint from '@gasket/plugin-lint';

/**
* presetConfig hook
Expand All @@ -15,41 +25,48 @@ import pluginLint from '@gasket/plugin-lint';
export default async function presetConfig(gasket, context) {
let typescriptPlugin;

const plugins = [
const plugins = new Set([
pluginCommand,
pluginDocs,
pluginDocusaurus,
pluginDynamicPlugins,
pluginGit,
pluginLogger,
pluginMetadata,
pluginNext,
pluginIntl,
pluginWebpack,
pluginWinston,
pluginLint
];
]);

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

plugins.push(pluginHttps);
plugins.push(frameworkPlugin.default || frameworkPlugin);
plugins.add(pluginHttps);
plugins.add(frameworkPlugin.default || frameworkPlugin);
} else if (context.nextDevProxy) {
plugins.push(pluginHttpsProxy);
plugins.add(pluginHttpsProxy);
}

if (context.nextDevProxy) {
plugins.push(pluginHttpsProxy);
plugins.add(pluginHttpsProxy);
}

if ('testPlugins' in context && context.testPlugins.length > 0) {
await Promise.all(context.testPlugins.map(async (testPlugin) => {
const plugin = await import(testPlugin);
plugins.push(plugin ? plugin.default || plugin : null);
plugins.add(plugin ? plugin.default || plugin : null);
}));
}

if (context.typescript) {
typescriptPlugin = await import('@gasket/plugin-typescript');

plugins.push(typescriptPlugin.default || typescriptPlugin);
plugins.add(typescriptPlugin.default || typescriptPlugin);
}

return {
plugins: plugins.filter(Boolean)
plugins: Array.from(plugins)
};
}
9 changes: 9 additions & 0 deletions packages/gasket-preset-nextjs/lib/preset-prompt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Default Plugins Prompts - included by default for all presets
import docsPrompts from '@gasket/plugin-docs/prompts';
import docusaurusPrompts from '@gasket/plugin-docusaurus/prompts';
import gitPrompts from '@gasket/plugin-git/prompts';

import nextJsPrompts from '@gasket/plugin-nextjs/prompts';
import typescriptPrompts from '@gasket/plugin-typescript/prompts';

Expand All @@ -9,6 +14,10 @@ import typescriptPrompts from '@gasket/plugin-typescript/prompts';
* @param {Function} utils.prompt - Inquirer prompt
*/
export default async function presetPrompt(gasket, context, { prompt }) {
await docsPrompts(gasket, context, { prompt });
await docusaurusPrompts(gasket, context, { prompt });
await gitPrompts(gasket, context, { prompt });

await typescriptPrompts.promptTypescript(context, prompt);
await nextJsPrompts.promptNextServerType(context, prompt);
await nextJsPrompts.promptNextDevProxy(context, prompt);
Expand Down
2 changes: 1 addition & 1 deletion packages/gasket-preset-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint:fix": "npm run lint -- --fix",
"test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
"test:watch": "npm run test -- --watch",
"test:coverage": "jest --coverage",
"test:coverage": "npm run test -- --coverage",
"posttest": "npm run lint"
},
"repository": {
Expand Down
Loading