@gasket/preset-nextjs 7.0.0-next.5 → 7.0.0-next.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,7 +5,7 @@ Framework for building Next.js apps using Gasket.
5
5
  ## Installation
6
6
 
7
7
  ```
8
- gasket create <app-name> --presets @gasket/preset-nextjs
8
+ npx create-gasket-app <app-name> --presets @gasket/preset-nextjs
9
9
  ```
10
10
 
11
11
  ## Plugins
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import '@gasket/plugin-express';
2
+ import '@gasket/plugin-fastify';
2
3
  import '@gasket/plugin-https';
3
4
  import '@gasket/plugin-nextjs';
4
5
  import '@gasket/plugin-redux';
5
- import '@gasket/plugin-start';
6
6
  import '@gasket/plugin-webpack';
7
7
  import '@gasket/plugin-winston';
package/lib/index.js CHANGED
@@ -1,55 +1,16 @@
1
- import pluginExpress from '@gasket/plugin-express';
2
- import pluginHttps from '@gasket/plugin-https';
3
- import pluginNext from '@gasket/plugin-nextjs';
4
- import pluginRedux from '@gasket/plugin-redux';
5
- import pluginWebpack from '@gasket/plugin-webpack';
6
- import pluginWinston from '@gasket/plugin-winston';
7
1
  import { createRequire } from 'module';
2
+ import presetPrompt from './preset-prompt.js';
3
+ import presetConfig from './preset-config.js';
8
4
  const require = createRequire(import.meta.url);
9
- const { name, dependencies } = require('../package.json');
5
+ const { name, version, description } = require('../package.json');
10
6
 
7
+ // TODO: need to create types for "preset" plugins
11
8
  export default {
12
9
  name,
10
+ version,
11
+ description,
13
12
  hooks: {
14
- async presetPrompt(gasket, context, { prompt }) {
15
- if (!('typescript' in context)) {
16
- const { typescript } = await prompt([
17
- {
18
- name: 'typescript',
19
- message: 'Do you want to use TypeScript?',
20
- type: 'confirm',
21
- default: false
22
- }
23
- ]);
24
-
25
- Object.assign(context, { typescript });
26
- }
27
- },
28
- async presetConfig(gasket, context) {
29
- let testPlugin, typescriptPlugin;
30
-
31
- if ('testPlugin' in context) {
32
- testPlugin = await import(context.testPlugin);
33
- }
34
-
35
- if (context.typescript) {
36
- typescriptPlugin = await import('@gasket/plugin-typescript');
37
- }
38
-
39
- return {
40
- plugins: [
41
- pluginWebpack,
42
- pluginExpress,
43
- pluginHttps,
44
- pluginNext,
45
- pluginRedux,
46
- pluginWinston,
47
- typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
48
- ].filter(Boolean)
49
- }
50
- },
51
- async create(gasket, { pkg }) {
52
- pkg.add('dependencies', dependencies);
53
- }
13
+ presetPrompt,
14
+ presetConfig
54
15
  }
55
- }
16
+ };
@@ -0,0 +1,50 @@
1
+ import pluginHttps from '@gasket/plugin-https';
2
+ import pluginNext from '@gasket/plugin-nextjs';
3
+ import pluginIntl from '@gasket/plugin-intl';
4
+ import pluginRedux from '@gasket/plugin-redux';
5
+ import pluginWebpack from '@gasket/plugin-webpack';
6
+ import pluginWinston from '@gasket/plugin-winston';
7
+
8
+ /**
9
+ * presetConfig hook
10
+ * @param {Gasket} gasket - Gasket API
11
+ * @param {Create} context - Create context
12
+ * @returns {Promise<CreateContext.presetConfig>} config
13
+ */
14
+ export default async function presetConfig(gasket, context) {
15
+ let typescriptPlugin;
16
+
17
+ const plugins = [
18
+ pluginHttps,
19
+ pluginNext,
20
+ pluginIntl,
21
+ pluginWebpack,
22
+ pluginRedux,
23
+ pluginWinston
24
+ ];
25
+
26
+ if ('server' in context) {
27
+ const frameworkPlugin = context.server === 'express'
28
+ ? await import('@gasket/plugin-express')
29
+ : await import('@gasket/plugin-fastify');
30
+
31
+ plugins.push(frameworkPlugin.default || frameworkPlugin);
32
+ }
33
+
34
+ if ('testPlugins' in context && context.testPlugins.length > 0) {
35
+ await Promise.all(context.testPlugins.map(async (testPlugin) => {
36
+ const plugin = await import(testPlugin);
37
+ plugins.push(plugin ? plugin.default || plugin : null);
38
+ }));
39
+ }
40
+
41
+ if (context.typescript) {
42
+ typescriptPlugin = await import('@gasket/plugin-typescript');
43
+
44
+ plugins.push(typescriptPlugin.default || typescriptPlugin);
45
+ }
46
+
47
+ return {
48
+ plugins: plugins.filter(Boolean)
49
+ };
50
+ }
@@ -0,0 +1,33 @@
1
+ import nextJsPrompts from '@gasket/plugin-nextjs/prompts';
2
+ import typescriptPrompts from '@gasket/plugin-typescript/prompts';
3
+
4
+ /**
5
+ * presetPrompt hook
6
+ * @param {Gasket} gasket - Gasket API
7
+ * @param {Create} context - Create context
8
+ * @param {Object} utils - Prompt utils
9
+ * @param {Function} utils.prompt - Inquirer prompt
10
+ */
11
+ export default async function presetPrompt(gasket, context, { prompt }) {
12
+ await typescriptPrompts.promptTypescript(context, prompt);
13
+ await nextJsPrompts.promptNextServerType(context, prompt);
14
+ await nextJsPrompts.promptNextDevProxy(context, prompt);
15
+
16
+ if (!('server' in context) && context.nextServerType === 'customServer') {
17
+ const { server } = await prompt([
18
+ {
19
+ name: 'server',
20
+ message: 'Which custom server framework would you like to use?',
21
+ type: 'list',
22
+ choices: [
23
+ { name: 'Express', value: 'express' },
24
+ { name: 'Fastify', value: 'fastify' }
25
+ ]
26
+ }
27
+ ]);
28
+
29
+ Object.assign(context, { server });
30
+ }
31
+
32
+ return context;
33
+ }
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@gasket/preset-nextjs",
3
- "version": "7.0.0-next.5",
3
+ "version": "7.0.0-next.50",
4
4
  "description": "Basic NextJS Framework",
5
+ "type": "module",
5
6
  "main": "lib/index.js",
6
7
  "types": "lib/index.d.ts",
7
8
  "files": [
8
9
  "lib"
9
10
  ],
10
- "type": "module",
11
+ "scripts": {
12
+ "lint": "eslint .",
13
+ "lint:fix": "npm run lint -- --fix",
14
+ "test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
15
+ "test:watch": "npm run test -- --watch",
16
+ "test:coverage": "jest --coverage",
17
+ "posttest": "npm run lint"
18
+ },
11
19
  "repository": {
12
20
  "type": "git",
13
21
  "url": "git+ssh://git@github.com/godaddy/gasket.git"
@@ -21,15 +29,46 @@
21
29
  "url": "https://github.com/godaddy/gasket/issues"
22
30
  },
23
31
  "dependencies": {
24
- "@gasket/core": "^7.0.0-next.5",
25
- "@gasket/engine": "^7.0.0-next.5",
26
- "@gasket/plugin-express": "^7.0.0-next.5",
27
- "@gasket/plugin-https": "^7.0.0-next.5",
28
- "@gasket/plugin-nextjs": "^7.0.0-next.5",
29
- "@gasket/plugin-redux": "^7.0.0-next.5",
30
- "@gasket/plugin-webpack": "^7.0.0-next.5",
31
- "@gasket/plugin-winston": "^7.0.0-next.5",
32
- "@gasket/utils": "^7.0.0-next.5"
33
- },
34
- "gitHead": "b3b132ef284ac43616794283b969c23c45c0a90e"
32
+ "@gasket/plugin-cypress": "^7.0.0-next.50",
33
+ "@gasket/plugin-express": "^7.0.0-next.50",
34
+ "@gasket/plugin-fastify": "^7.0.0-next.50",
35
+ "@gasket/plugin-https": "^7.0.0-next.50",
36
+ "@gasket/plugin-intl": "^7.0.0-next.50",
37
+ "@gasket/plugin-jest": "^7.0.0-next.50",
38
+ "@gasket/plugin-lint": "^7.0.0-next.50",
39
+ "@gasket/plugin-mocha": "^7.0.0-next.50",
40
+ "@gasket/plugin-nextjs": "^7.0.0-next.50",
41
+ "@gasket/plugin-redux": "^7.0.0-next.50",
42
+ "@gasket/plugin-typescript": "^7.0.0-next.50",
43
+ "@gasket/plugin-webpack": "^7.0.0-next.50",
44
+ "@gasket/plugin-winston": "^7.0.0-next.50",
45
+ "@gasket/utils": "^7.0.0-next.50"
46
+ },
47
+ "devDependencies": {
48
+ "cross-env": "^7.0.3",
49
+ "eslint": "^8.56.0",
50
+ "eslint-config-godaddy": "^7.1.1",
51
+ "eslint-plugin-jest": "^28.6.0",
52
+ "eslint-plugin-unicorn": "^55.0.0",
53
+ "jest": "^29.7.0"
54
+ },
55
+ "eslintConfig": {
56
+ "extends": [
57
+ "godaddy",
58
+ "plugin:jest/recommended"
59
+ ],
60
+ "plugins": [
61
+ "unicorn"
62
+ ],
63
+ "rules": {
64
+ "unicorn/filename-case": "error"
65
+ }
66
+ },
67
+ "eslintIgnore": [
68
+ "test/fixtures"
69
+ ],
70
+ "jest": {
71
+ "transform": {}
72
+ },
73
+ "gitHead": "e7cfec6a118cf087c6532c23dc31170f4b15d182"
35
74
  }