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

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
@@ -22,7 +22,7 @@ To see complete the list of plugins configured in your app, and what commands, l
22
22
 
23
23
  ## Plugins
24
24
 
25
- - [@gasket/plugin-response-data](/packages/gasket-plugin-response-data/README.md)
25
+ - [@gasket/plugin-data](/packages/gasket-plugin-data/README.md)
26
26
  - [@gasket/plugin-swagger](/packages/gasket-plugin-swagger/README.md)
27
27
  - [@gasket/plugin-docs](/packages/gasket-plugin-docs/README.md)
28
28
  - [@gasket/plugin-docusaurus](/packages/gasket-plugin-docusaurus/README.md)
@@ -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.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- import '@gasket/plugin-response-data';
2
- import '@gasket/plugin-docs';
3
- import '@gasket/plugin-docusaurus';
1
+ import '@gasket/plugin-data';
4
2
  import '@gasket/plugin-express';
5
3
  import '@gasket/plugin-https';
6
4
  import '@gasket/plugin-lint';
7
- import '@gasket/plugin-start';
8
5
  import '@gasket/plugin-swagger';
9
- import '@gasket/plugin-winston';
6
+ import '@gasket/plugin-winston';
package/lib/index.js CHANGED
@@ -1,79 +1,18 @@
1
- import pluginExpress from '@gasket/plugin-express';
2
- import pluginTypescript from '@gasket/plugin-typescript';
3
- import pluginHttps from '@gasket/plugin-https';
4
- import pluginDocs from '@gasket/plugin-docs';
5
- import pluginDocusaurus from '@gasket/plugin-docusaurus';
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
1
  import { createRequire } from 'module';
11
- import { fileURLToPath } from 'url';
2
+ import presetPrompt from './preset-prompt.js';
3
+ import presetConfig from './preset-config.js';
4
+ import create from './create.js';
12
5
  const require = createRequire(import.meta.url);
13
- const { name, dependencies, devDependencies } = require('../package.json');
6
+ const { name, version, description } = require('../package.json');
14
7
 
8
+ // TODO: need to create types for "preset" plugins
15
9
  export default {
16
10
  name,
11
+ version,
12
+ description,
17
13
  hooks: {
18
- async presetPrompt(gasket, context, { prompt }) {
19
- context.apiApp = true;
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;
35
- if ('testPlugin' in context) {
36
- testPlugin = await import(context.testPlugin);
37
- }
38
-
39
- return {
40
- plugins: [
41
- pluginExpress,
42
- pluginHttps,
43
- pluginDocs,
44
- pluginDocusaurus,
45
- pluginResponseData,
46
- pluginWinston,
47
- pluginSwagger,
48
- // pluginLint,
49
- context.typescript ? pluginTypescript : null,
50
- testPlugin ? testPlugin.default || testPlugin : null
51
- ].filter(Boolean)
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
- }
77
- }
14
+ presetPrompt,
15
+ presetConfig,
16
+ create
78
17
  }
79
18
  };
@@ -0,0 +1,41 @@
1
+ import pluginExpress from '@gasket/plugin-express';
2
+ import pluginHttps from '@gasket/plugin-https';
3
+ import pluginData from '@gasket/plugin-data';
4
+ import pluginWinston from '@gasket/plugin-winston';
5
+ import pluginSwagger from '@gasket/plugin-swagger';
6
+ import pluginLint from '@gasket/plugin-lint';
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
+ const testPlugins = [];
17
+
18
+ if ('testPlugins' in context && context.testPlugins.length > 0) {
19
+ await Promise.all(context.testPlugins.map(async (testPlugin) => {
20
+ const plugin = await import(testPlugin);
21
+ testPlugins.push(plugin ? plugin.default || plugin : null);
22
+ }));
23
+ }
24
+
25
+ if (context.typescript) {
26
+ typescriptPlugin = await import('@gasket/plugin-typescript');
27
+ }
28
+
29
+ return {
30
+ plugins: [
31
+ pluginExpress,
32
+ pluginHttps,
33
+ pluginData,
34
+ pluginWinston,
35
+ pluginSwagger,
36
+ pluginLint,
37
+ typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
38
+ ...testPlugins
39
+ ].filter(Boolean)
40
+ };
41
+ }
@@ -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.4",
3
+ "version": "7.0.0-next.40",
4
4
  "description": "Create Express-based API with Gasket",
5
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,21 +30,43 @@
21
30
  "url": "https://github.com/godaddy/gasket/issues"
22
31
  },
23
32
  "dependencies": {
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"
33
+ "@gasket/plugin-cypress": "^7.0.0-next.40",
34
+ "@gasket/plugin-data": "^7.0.0-next.40",
35
+ "@gasket/plugin-express": "^7.0.0-next.40",
36
+ "@gasket/plugin-https": "^7.0.0-next.40",
37
+ "@gasket/plugin-jest": "^7.0.0-next.40",
38
+ "@gasket/plugin-lint": "^7.0.0-next.40",
39
+ "@gasket/plugin-mocha": "^7.0.0-next.40",
40
+ "@gasket/plugin-swagger": "^7.0.0-next.40",
41
+ "@gasket/plugin-typescript": "^7.0.0-next.40",
42
+ "@gasket/plugin-winston": "^7.0.0-next.40"
35
43
  },
36
44
  "devDependencies": {
37
- "@gasket/plugin-start": "^7.0.0-next.4",
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",
38
51
  "nodemon": "^3.1.0"
39
52
  },
40
- "gitHead": "5a76c18917da4d37c2aa2f9b9a70e2514ee81398"
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": "0aa111bf03a2008753ff70d3d7207c371d9f6031"
41
72
  }