@gasket/preset-api 7.0.0-next.3 → 7.0.0-next.4

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.
Files changed (2) hide show
  1. package/lib/index.js +52 -13
  2. package/package.json +16 -12
package/lib/index.js CHANGED
@@ -1,40 +1,79 @@
1
1
  import pluginExpress from '@gasket/plugin-express';
2
2
  import pluginTypescript from '@gasket/plugin-typescript';
3
3
  import pluginHttps from '@gasket/plugin-https';
4
- import pluginWinston from '@gasket/plugin-winston';
5
4
  import pluginDocs from '@gasket/plugin-docs';
6
5
  import pluginDocusaurus from '@gasket/plugin-docusaurus';
7
- import pluginResponeData from '@gasket/plugin-response-data';
6
+ import pluginResponseData from '@gasket/plugin-response-data';
7
+ import pluginWinston from '@gasket/plugin-winston';
8
+ import pluginSwagger from '@gasket/plugin-swagger';
9
+ // import pluginLint from '@gasket/plugin-lint';
10
+ import { createRequire } from 'module';
11
+ import { fileURLToPath } from 'url';
12
+ const require = createRequire(import.meta.url);
13
+ const { name, dependencies, devDependencies } = require('../package.json');
8
14
 
9
15
  export default {
10
- name: '@gasket/preset-api',
16
+ name,
11
17
  hooks: {
12
18
  async presetPrompt(gasket, context, { prompt }) {
13
- if (!('apiAppTest' in context)) {
14
- const { apiAppTest } = await prompt([
19
+ context.apiApp = true;
20
+ if (!('typescript' in context)) {
21
+ const { typescript } = await prompt([
15
22
  {
16
- name: 'apiAppTest',
17
- message: 'What is your API app test?',
18
- type: 'input',
19
- default: 'A basic API'
23
+ name: 'typescript',
24
+ message: 'Do you want to use TypeScript?',
25
+ type: 'confirm',
26
+ default: false
20
27
  }
21
28
  ]);
22
29
 
23
- Object.assign(context, { apiAppTest, apiApp: true, typescript: true });
30
+ Object.assign(context, { typescript });
24
31
  }
25
32
  },
26
33
  async presetConfig(gasket, context) {
34
+ let testPlugin;
35
+ if ('testPlugin' in context) {
36
+ testPlugin = await import(context.testPlugin);
37
+ }
38
+
27
39
  return {
28
40
  plugins: [
29
41
  pluginExpress,
30
42
  pluginHttps,
31
- pluginWinston,
32
43
  pluginDocs,
33
44
  pluginDocusaurus,
34
- pluginResponeData,
35
- context.typescript ? pluginTypescript : null
45
+ pluginResponseData,
46
+ pluginWinston,
47
+ pluginSwagger,
48
+ // pluginLint,
49
+ context.typescript ? pluginTypescript : null,
50
+ testPlugin ? testPlugin.default || testPlugin : null
36
51
  ].filter(Boolean)
37
52
  }
53
+ },
54
+ create(gasket, context) {
55
+ const { pkg, files } = context;
56
+ const __dirname = fileURLToPath(import.meta.url);
57
+ const generatorDir = `${__dirname}/../../generator`;
58
+
59
+ pkg.add('dependencies', {
60
+ '@gasket/engine': dependencies['@gasket/engine'],
61
+ '@gasket/core': dependencies['@gasket/core'],
62
+ '@gasket/utils': dependencies['@gasket/utils']
63
+ });
64
+
65
+ if (!context.typescript) {
66
+ files.add(`${generatorDir}/*`);
67
+
68
+ pkg.add('devDependencies', {
69
+ nodemon: devDependencies.nodemon
70
+ });
71
+
72
+ pkg.add('scripts', {
73
+ start: 'node server.js',
74
+ local: 'GASKET_ENV=local nodemon server.js',
75
+ });
76
+ }
38
77
  }
39
78
  }
40
79
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@gasket/preset-api",
3
- "version": "7.0.0-next.3",
3
+ "version": "7.0.0-next.4",
4
4
  "description": "Create Express-based API with Gasket",
5
- "main": "lib",
5
+ "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "files": [
8
8
  "lib"
@@ -21,17 +21,21 @@
21
21
  "url": "https://github.com/godaddy/gasket/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@gasket/plugin-docs": "^7.0.0-next.3",
25
- "@gasket/plugin-docusaurus": "^7.0.0-next.3",
26
- "@gasket/plugin-express": "^7.0.0-next.3",
27
- "@gasket/plugin-https": "^7.0.0-next.3",
28
- "@gasket/plugin-lint": "^7.0.0-next.3",
29
- "@gasket/plugin-response-data": "^7.0.0-next.3",
30
- "@gasket/plugin-swagger": "^7.0.0-next.3",
31
- "@gasket/plugin-winston": "^7.0.0-next.3"
24
+ "@gasket/core": "^7.0.0-next.4",
25
+ "@gasket/engine": "^7.0.0-next.4",
26
+ "@gasket/plugin-docs": "^7.0.0-next.4",
27
+ "@gasket/plugin-docusaurus": "^7.0.0-next.4",
28
+ "@gasket/plugin-express": "^7.0.0-next.4",
29
+ "@gasket/plugin-https": "^7.0.0-next.4",
30
+ "@gasket/plugin-lint": "^7.0.0-next.4",
31
+ "@gasket/plugin-response-data": "^7.0.0-next.4",
32
+ "@gasket/plugin-swagger": "^7.0.0-next.4",
33
+ "@gasket/plugin-winston": "^7.0.0-next.4",
34
+ "@gasket/utils": "^7.0.0-next.4"
32
35
  },
33
36
  "devDependencies": {
34
- "@gasket/plugin-start": "^7.0.0-next.3"
37
+ "@gasket/plugin-start": "^7.0.0-next.4",
38
+ "nodemon": "^3.1.0"
35
39
  },
36
- "gitHead": "f4849afd9241977ad5b485cdb6a8fec9c44fc402"
40
+ "gitHead": "5a76c18917da4d37c2aa2f9b9a70e2514ee81398"
37
41
  }