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

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.
@@ -0,0 +1,2 @@
1
+ import gasket from './gasket.js';
2
+ gasket.actions.startServer();
package/lib/create.js ADDED
@@ -0,0 +1,29 @@
1
+ import path from 'path';
2
+ import { createRequire } from 'module';
3
+ import { fileURLToPath } from 'url';
4
+ const require = createRequire(import.meta.url);
5
+ const { devDependencies } = require('../package.json');
6
+
7
+ /**
8
+ * createHook
9
+ * @param {Gasket} gasket - Gasket API
10
+ * @param {Create} context - Create context
11
+ */
12
+ export default function create(gasket, context) {
13
+ const { pkg, files } = context;
14
+ const __dirname = fileURLToPath(import.meta.url);
15
+ const generatorDir = path.join(__dirname, '..', '..', 'generator');
16
+
17
+ if (!context.typescript) {
18
+ files.add(`${generatorDir}/*`);
19
+
20
+ pkg.add('devDependencies', {
21
+ nodemon: devDependencies.nodemon
22
+ });
23
+
24
+ pkg.add('scripts', {
25
+ start: 'node server.js',
26
+ local: 'GASKET_ENV=local nodemon server.js'
27
+ });
28
+ }
29
+ }
package/lib/index.js CHANGED
@@ -1,40 +1,15 @@
1
- import pluginExpress from '@gasket/plugin-express';
2
- import pluginTypescript from '@gasket/plugin-typescript';
3
- import pluginHttps from '@gasket/plugin-https';
4
- import pluginWinston from '@gasket/plugin-winston';
5
- import pluginDocs from '@gasket/plugin-docs';
6
- import pluginDocusaurus from '@gasket/plugin-docusaurus';
7
- import pluginResponeData from '@gasket/plugin-response-data';
1
+ import { createRequire } from 'module';
2
+ import presetPrompt from './preset-prompt.js';
3
+ import presetConfig from './preset-config.js';
4
+ import create from './create.js';
5
+ const require = createRequire(import.meta.url);
6
+ const { name } = require('../package.json');
8
7
 
9
8
  export default {
10
- name: '@gasket/preset-api',
9
+ name,
11
10
  hooks: {
12
- async presetPrompt(gasket, context, { prompt }) {
13
- if (!('apiAppTest' in context)) {
14
- const { apiAppTest } = await prompt([
15
- {
16
- name: 'apiAppTest',
17
- message: 'What is your API app test?',
18
- type: 'input',
19
- default: 'A basic API'
20
- }
21
- ]);
22
-
23
- Object.assign(context, { apiAppTest, apiApp: true, typescript: true });
24
- }
25
- },
26
- async presetConfig(gasket, context) {
27
- return {
28
- plugins: [
29
- pluginExpress,
30
- pluginHttps,
31
- pluginWinston,
32
- pluginDocs,
33
- pluginDocusaurus,
34
- pluginResponeData,
35
- context.typescript ? pluginTypescript : null
36
- ].filter(Boolean)
37
- }
38
- }
11
+ presetPrompt,
12
+ presetConfig,
13
+ create
39
14
  }
40
15
  };
@@ -0,0 +1,45 @@
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
+ /**
11
+ * presetConfig hook
12
+ * @param {Gasket} gasket - Gasket API
13
+ * @param {Create} context - Create context
14
+ * @returns {Promise<CreateContext.presetConfig>} config
15
+ */
16
+ export default async function presetConfig(gasket, context) {
17
+ let typescriptPlugin;
18
+ let testPlugins = [];
19
+
20
+ if ('testPlugins' in context && context.testPlugins.length > 0) {
21
+ await Promise.all(context.testPlugins.map(async (testPlugin) => {
22
+ const plugin = await import(testPlugin);
23
+ testPlugins.push(plugin ? plugin.default || plugin : null);
24
+ }));
25
+ }
26
+
27
+ if (context.typescript) {
28
+ typescriptPlugin = await import('@gasket/plugin-typescript');
29
+ }
30
+
31
+ return {
32
+ plugins: [
33
+ pluginExpress,
34
+ pluginHttps,
35
+ pluginDocs,
36
+ pluginDocusaurus,
37
+ pluginResponseData,
38
+ pluginWinston,
39
+ pluginSwagger,
40
+ pluginLint,
41
+ typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
42
+ ...testPlugins
43
+ ].filter(Boolean)
44
+ };
45
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * presetPrompt hook
3
+ * @param {Gasket} gasket - Gasket API
4
+ * @param {Create} context - Create context
5
+ * @param {Object} utils - Prompt utils
6
+ * @param {Function} utils.prompt - Inquirer prompt
7
+ */
8
+ export default async function presetPrompt(gasket, context, { prompt }) {
9
+ context.apiApp = true;
10
+
11
+ if (!('typescript' in context)) {
12
+ const { typescript } = await prompt([
13
+ {
14
+ name: 'typescript',
15
+ message: 'Do you want to use TypeScript?',
16
+ type: 'confirm',
17
+ default: false
18
+ }
19
+ ]);
20
+
21
+ Object.assign(context, { typescript });
22
+ }
23
+ }
package/package.json CHANGED
@@ -1,13 +1,22 @@
1
1
  {
2
2
  "name": "@gasket/preset-api",
3
- "version": "7.0.0-next.3",
3
+ "version": "7.0.0-next.31",
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
+ "generator",
8
9
  "lib"
9
10
  ],
10
11
  "type": "module",
12
+ "scripts": {
13
+ "lint": "eslint .",
14
+ "lint:fix": "npm run lint -- --fix",
15
+ "test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
16
+ "test:watch": "npm run test -- --watch",
17
+ "test:coverage": "jest --coverage",
18
+ "posttest": "npm run lint"
19
+ },
11
20
  "repository": {
12
21
  "type": "git",
13
22
  "url": "git+ssh://git@github.com/godaddy/gasket.git"
@@ -21,17 +30,45 @@
21
30
  "url": "https://github.com/godaddy/gasket/issues"
22
31
  },
23
32
  "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"
33
+ "@gasket/plugin-cypress": "^7.0.0-next.31",
34
+ "@gasket/plugin-docs": "^7.0.0-next.31",
35
+ "@gasket/plugin-docusaurus": "^7.0.0-next.31",
36
+ "@gasket/plugin-express": "^7.0.0-next.31",
37
+ "@gasket/plugin-https": "^7.0.0-next.31",
38
+ "@gasket/plugin-jest": "^7.0.0-next.31",
39
+ "@gasket/plugin-lint": "^7.0.0-next.31",
40
+ "@gasket/plugin-mocha": "^7.0.0-next.31",
41
+ "@gasket/plugin-response-data": "^7.0.0-next.31",
42
+ "@gasket/plugin-swagger": "^7.0.0-next.31",
43
+ "@gasket/plugin-typescript": "^7.0.0-next.31",
44
+ "@gasket/plugin-winston": "^7.0.0-next.31"
32
45
  },
33
46
  "devDependencies": {
34
- "@gasket/plugin-start": "^7.0.0-next.3"
47
+ "cross-env": "^7.0.3",
48
+ "eslint": "^8.56.0",
49
+ "eslint-config-godaddy": "^7.0.2",
50
+ "eslint-plugin-jest": "^27.6.3",
51
+ "eslint-plugin-unicorn": "^44.0.0",
52
+ "jest": "^29.7.0",
53
+ "nodemon": "^3.1.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": {}
35
72
  },
36
- "gitHead": "f4849afd9241977ad5b485cdb6a8fec9c44fc402"
73
+ "gitHead": "36883ccf2e0ed1b3cb2e1e3b60a2f17bfa588cc6"
37
74
  }