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

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 +51 -14
  2. package/package.json +15 -12
package/lib/index.js CHANGED
@@ -1,40 +1,77 @@
1
1
  import pluginExpress from '@gasket/plugin-express';
2
- import pluginTypescript from '@gasket/plugin-typescript';
3
2
  import pluginHttps from '@gasket/plugin-https';
4
- import pluginWinston from '@gasket/plugin-winston';
5
3
  import pluginDocs from '@gasket/plugin-docs';
6
4
  import pluginDocusaurus from '@gasket/plugin-docusaurus';
7
- import pluginResponeData from '@gasket/plugin-response-data';
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
+ import { createRequire } from 'module';
10
+ import { fileURLToPath } from 'url';
11
+ const require = createRequire(import.meta.url);
12
+ const { name, dependencies, devDependencies } = require('../package.json');
8
13
 
9
14
  export default {
10
- name: '@gasket/preset-api',
15
+ name,
11
16
  hooks: {
12
17
  async presetPrompt(gasket, context, { prompt }) {
13
- if (!('apiAppTest' in context)) {
14
- const { apiAppTest } = await prompt([
18
+ context.apiApp = true;
19
+ // TODOfollowup - TS prompt could possibly be global
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, 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
+
27
43
  return {
28
44
  plugins: [
29
45
  pluginExpress,
30
46
  pluginHttps,
31
- pluginWinston,
32
47
  pluginDocs,
33
48
  pluginDocusaurus,
34
- pluginResponeData,
35
- context.typescript ? pluginTypescript : null
49
+ pluginResponseData,
50
+ pluginWinston,
51
+ pluginSwagger,
52
+ pluginLint,
53
+ typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
54
+ testPlugin ? testPlugin.default || testPlugin : null
36
55
  ].filter(Boolean)
37
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
+ }
38
75
  }
39
76
  }
40
77
  };
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.5",
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,20 @@
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.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
35
  },
33
36
  "devDependencies": {
34
- "@gasket/plugin-start": "^7.0.0-next.3"
37
+ "nodemon": "^3.1.0"
35
38
  },
36
- "gitHead": "f4849afd9241977ad5b485cdb6a8fec9c44fc402"
39
+ "gitHead": "b3b132ef284ac43616794283b969c23c45c0a90e"
37
40
  }