import { __deepMerge } from '@coffeekraken/sugar/object'; import { __uniqid } from '@coffeekraken/sugar/string'; let newFolderName; export default function (api) { if (api.env.platform !== 'node') return; return { /** * @name title * @namespace config.kitchenRecipeNextJs * @type String * @default NextJs 12 * * Specify the recipe name * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ title: 'NextJs 12', /** * @name description * @namespace config.kitchenRecipeNextJs * @type String * @default Default s-kitchen recipe * * Specify the recipe description * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ description: 'Create easily a next.js 12 app with coffeekraken tools support', /** * @name requirements * @namespace config.kitchenRecipeNextJs * @type String[] * @default ['[config.package.manager]'] * * Specify some requirements for this recipe like commands (npm, composer, etc...) * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ requirements: { get commands() { return [api.config.package.manager]; }, }, /** * @name defaultStack * @namespace config.kitchenRecipeNextJs * @type String * @default dev * * Specify the recipe default stack * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ defaultStack: 'dev', stacks: { new: { /** * @name description * @namespace config.kitchenRecipeNextJs.stacks.init * @type String * @default Init a new project with this recipe * * Specify the recipe init stack description * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ description: 'Init a new next.js 12 project', actions: { /** * @name createApp * @namespace config.kitchenRecipeNextJs.stacks.new.actions * @type String * * Specify the recipe init stack copy action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ get createApp() { return __deepMerge({ title: 'Create the app', description: 'Create the app using the create-next-app utility', get command() { newFolderName = __uniqid(); return `npx create-next-app ${newFolderName} --typescript`; }, after() { process.chdir( `${process.cwd()}/${newFolderName}`, ); }, params: {}, settings: { silent: true, }, }); }, /** * @name rename * @namespace config.kitchenRecipeNextJs.stacks.new.actions * @type String * * Specify the recipe init stack rename action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ get rename() { return __deepMerge(api.config.kitchen.actions.rename, { params: {}, }); }, /** * @name addSugarJson * @namespace config.kitchenRecipeNextJs.stacks.new.actions * @type String * * Specify the recipe init stack addSugarJson action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ get addSugarJson() { return __deepMerge( api.config.kitchen.actions.addSugarJson, { params: { recipe: 'nextJs12', }, }, ); }, /** * @name addSugar * @namespace config.kitchenRecipeNextJs.stacks.new.actions * @type String * * Specify the recipe init stack addSugar action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ addSugar: { extends: 'addSugar', }, /** * @name addNvmrc * @namespace config.kitchenRecipeDefault.stacks.new.actions * @type String * * Specify the recipe init stack addNvmrc action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ addNvmrc: { extends: 'addNvmrc', title: 'Add the .nvmrc file', description: 'Add the .nvmrc file', params: {}, }, /** * @name addManifestJson * @namespace config.kitchenRecipeNextJs.stacks.new.actions * @type String * * Specify the recipe init stack addManifestJson action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ get addManifestJson() { return __deepMerge( api.config.kitchen.actions.addManifestJson, { params: {}, }, ); }, /** * @name addSugarPostcss * @namespace config.kitchenRecipeNextJs.stacks.new.actions * @type String * * Specify the recipe init stack addSugarPostcss action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ get addSugarPostcss() { return __deepMerge( api.config.kitchen.actions.addSugarPostcss, { params: {}, }, ); }, /** * @name installDependencies * @namespace config.kitchenRecipeNextJs.stacks.new.actions * @type String * * Specify the recipe init stack installDependencies action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ installDependencies: __deepMerge( api.config.kitchen.actions.installDependencies, { params: {}, }, ), }, }, dev: { /** * @name description * @namespace config.kitchenRecipeNextJs.stacks.dev * @type String * @default Start the development stack * * Specify the recipe dev stack description * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ description: 'Start the development stack', runInParallel: true, actions: { /** * @name start * @namespace config.kitchenRecipeNextJs.stacks.dev.actions * @type Object * * Specify the recipe dev.start action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ start: { title: 'Start development stack', description: 'Start the development stack', command: 'npm run dev', params: {}, settings: {}, }, }, }, prod: { /** * @name description * @namespace config.kitchenRecipeNextJs.stacks.prod * @type String * @default ... * * Specify the recipe prod stack description * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ description: 'Start the production testing stack', sharedParams: { /** * @name env * @namespace config.kitchenRecipeNextJs.stacks.prod.sharedParams * @type String * @default production * * Specify the recipe prod stack env shared param * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ env: 'production', }, actions: { /** * @name start * @namespace config.kitchenRecipeNextJs.stacks.prod.actions * @type Object * * Specify the recipe dev.start action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ start: { title: 'Start production stack', description: 'Start the production stack', command: 'npm run start', params: {}, settings: {}, }, }, }, build: { /** * @name description * @namespace config.kitchenRecipeNextJs.stacks.build * @type String * @default ... * * Specify the recipe build stack description * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ description: 'Build your final production ready dist package', sharedParams: { /** * @name prod * @namespace config.kitchenRecipeNextJs.stacks.build.sharedParams * @type String * @default true * * Specify that the build is made for production * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ prod: true, }, actions: { /** * @name start * @namespace config.kitchenRecipeNextJs.stacks.build.actions * @type Object * * Specify the recipe dev.start action * * @since 2.0.0 * @author Olivier Bossel (https://coffeekraken.io) */ start: { title: 'Start the build', description: 'Start the build', command: 'npm run build', params: {}, settings: {}, }, }, }, }, }; }