@gasket/preset-api 7.0.0-next.5 → 7.0.0-next.6

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/lib/create.js ADDED
@@ -0,0 +1,23 @@
1
+ import { createRequire } from 'module';
2
+ import { fileURLToPath } from 'url';
3
+ const require = createRequire(import.meta.url);
4
+ const { dependencies, devDependencies } = require('../package.json');
5
+
6
+ export default function create(gasket, context) {
7
+ const { pkg, files } = context;
8
+ const __dirname = fileURLToPath(import.meta.url);
9
+ const generatorDir = `${__dirname}/../../generator`;
10
+
11
+ pkg.add('dependencies', dependencies);
12
+
13
+ if (!context.typescript) {
14
+ files.add(`${generatorDir}/*`);
15
+
16
+ pkg.add('devDependencies', devDependencies);
17
+
18
+ pkg.add('scripts', {
19
+ start: 'node server.js',
20
+ local: 'GASKET_ENV=local nodemon server.js'
21
+ });
22
+ }
23
+ }
package/lib/index.js CHANGED
@@ -1,77 +1,15 @@
1
- import pluginExpress from '@gasket/plugin-express';
2
- import pluginHttps from '@gasket/plugin-https';
3
- import pluginDocs from '@gasket/plugin-docs';
4
- import pluginDocusaurus from '@gasket/plugin-docusaurus';
5
- import pluginResponseData from '@gasket/plugin-response-data';
6
- import pluginWinston from '@gasket/plugin-winston';
7
- import pluginSwagger from '@gasket/plugin-swagger';
8
- import pluginLint from '@gasket/plugin-lint';
9
1
  import { createRequire } from 'module';
10
- import { fileURLToPath } from 'url';
2
+ import presetPrompt from './preset-prompt.js';
3
+ import presetConfig from './preset-config.js';
4
+ import create from './create.js';
11
5
  const require = createRequire(import.meta.url);
12
- const { name, dependencies, devDependencies } = require('../package.json');
6
+ const { name } = require('../package.json');
13
7
 
14
8
  export default {
15
9
  name,
16
10
  hooks: {
17
- async presetPrompt(gasket, context, { prompt }) {
18
- context.apiApp = true;
19
- // TODOfollowup - TS prompt could possibly be global
20
- if (!('typescript' in context)) {
21
- const { typescript } = await prompt([
22
- {
23
- name: 'typescript',
24
- message: 'Do you want to use TypeScript?',
25
- type: 'confirm',
26
- default: false
27
- }
28
- ]);
29
-
30
- Object.assign(context, { typescript });
31
- }
32
- },
33
- async presetConfig(gasket, context) {
34
- let testPlugin, typescriptPlugin;
35
- if ('testPlugin' in context) {
36
- testPlugin = await import(context.testPlugin);
37
- }
38
-
39
- if (context.typescript) {
40
- typescriptPlugin = await import('@gasket/plugin-typescript');
41
- }
42
-
43
- return {
44
- plugins: [
45
- pluginExpress,
46
- pluginHttps,
47
- pluginDocs,
48
- pluginDocusaurus,
49
- pluginResponseData,
50
- pluginWinston,
51
- pluginSwagger,
52
- pluginLint,
53
- typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
54
- testPlugin ? testPlugin.default || testPlugin : null
55
- ].filter(Boolean)
56
- }
57
- },
58
- create(gasket, context) {
59
- const { pkg, files } = context;
60
- const __dirname = fileURLToPath(import.meta.url);
61
- const generatorDir = `${__dirname}/../../generator`;
62
-
63
- pkg.add('dependencies', dependencies);
64
-
65
- if (!context.typescript) {
66
- files.add(`${generatorDir}/*`);
67
-
68
- pkg.add('devDependencies', devDependencies);
69
-
70
- pkg.add('scripts', {
71
- start: 'node server.js',
72
- local: 'GASKET_ENV=local nodemon server.js',
73
- });
74
- }
75
- }
11
+ presetPrompt,
12
+ presetConfig,
13
+ create
76
14
  }
77
15
  };
@@ -0,0 +1,34 @@
1
+ import pluginExpress from '@gasket/plugin-express';
2
+ import pluginHttps from '@gasket/plugin-https';
3
+ import pluginDocs from '@gasket/plugin-docs';
4
+ import pluginDocusaurus from '@gasket/plugin-docusaurus';
5
+ import pluginResponseData from '@gasket/plugin-response-data';
6
+ import pluginWinston from '@gasket/plugin-winston';
7
+ import pluginSwagger from '@gasket/plugin-swagger';
8
+ import pluginLint from '@gasket/plugin-lint';
9
+
10
+ export default async function presetConfig(gasket, context) {
11
+ let testPlugin, typescriptPlugin;
12
+ if ('testPlugin' in context) {
13
+ testPlugin = await import(context.testPlugin);
14
+ }
15
+
16
+ if (context.typescript) {
17
+ typescriptPlugin = await import('@gasket/plugin-typescript');
18
+ }
19
+
20
+ return {
21
+ plugins: [
22
+ pluginExpress,
23
+ pluginHttps,
24
+ pluginDocs,
25
+ pluginDocusaurus,
26
+ pluginResponseData,
27
+ pluginWinston,
28
+ pluginSwagger,
29
+ pluginLint,
30
+ typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
31
+ testPlugin ? testPlugin.default || testPlugin : null
32
+ ].filter(Boolean)
33
+ };
34
+ }
@@ -0,0 +1,16 @@
1
+ export default async function presetPrompt(gasket, context, { prompt }) {
2
+ context.apiApp = true;
3
+
4
+ if (!('typescript' in context)) {
5
+ const { typescript } = await prompt([
6
+ {
7
+ name: 'typescript',
8
+ message: 'Do you want to use TypeScript?',
9
+ type: 'confirm',
10
+ default: false
11
+ }
12
+ ]);
13
+
14
+ Object.assign(context, { typescript });
15
+ }
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gasket/preset-api",
3
- "version": "7.0.0-next.5",
3
+ "version": "7.0.0-next.6",
4
4
  "description": "Create Express-based API with Gasket",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -8,6 +8,14 @@
8
8
  "lib"
9
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": "jest --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,20 +29,44 @@
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-docs": "^7.0.0-next.5",
27
- "@gasket/plugin-docusaurus": "^7.0.0-next.5",
28
- "@gasket/plugin-express": "^7.0.0-next.5",
29
- "@gasket/plugin-https": "^7.0.0-next.5",
30
- "@gasket/plugin-lint": "^7.0.0-next.5",
31
- "@gasket/plugin-response-data": "^7.0.0-next.5",
32
- "@gasket/plugin-swagger": "^7.0.0-next.5",
33
- "@gasket/plugin-winston": "^7.0.0-next.5",
34
- "@gasket/utils": "^7.0.0-next.5"
32
+ "@gasket/core": "^7.0.0-next.6",
33
+ "@gasket/engine": "^7.0.0-next.6",
34
+ "@gasket/plugin-docs": "^7.0.0-next.6",
35
+ "@gasket/plugin-docusaurus": "^7.0.0-next.6",
36
+ "@gasket/plugin-express": "^7.0.0-next.6",
37
+ "@gasket/plugin-https": "^7.0.0-next.6",
38
+ "@gasket/plugin-lint": "^7.0.0-next.6",
39
+ "@gasket/plugin-response-data": "^7.0.0-next.6",
40
+ "@gasket/plugin-swagger": "^7.0.0-next.6",
41
+ "@gasket/plugin-winston": "^7.0.0-next.6",
42
+ "@gasket/utils": "^7.0.0-next.6"
35
43
  },
36
44
  "devDependencies": {
45
+ "cross-env": "^7.0.3",
46
+ "eslint": "^8.56.0",
47
+ "eslint-config-godaddy": "^7.0.2",
48
+ "eslint-plugin-jest": "^27.6.3",
49
+ "eslint-plugin-unicorn": "^44.0.0",
50
+ "jest": "^29.7.0",
37
51
  "nodemon": "^3.1.0"
38
52
  },
39
- "gitHead": "b3b132ef284ac43616794283b969c23c45c0a90e"
53
+ "eslintConfig": {
54
+ "extends": [
55
+ "godaddy",
56
+ "plugin:jest/recommended"
57
+ ],
58
+ "plugins": [
59
+ "unicorn"
60
+ ],
61
+ "rules": {
62
+ "unicorn/filename-case": "error"
63
+ }
64
+ },
65
+ "eslintIgnore": [
66
+ "test/fixtures"
67
+ ],
68
+ "jest": {
69
+ "transform": {}
70
+ },
71
+ "gitHead": "805a1026959d8aa783ee32be8a8ff76c06badd2f"
40
72
  }