@gasket/preset-api 7.2.0-canary.20 → 7.2.1

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
@@ -2,18 +2,10 @@
2
2
 
3
3
  Framework for building API's using Gasket.
4
4
 
5
- ## Usage
6
-
7
- This preset requires v5 of the `@gasket/cli`:
8
-
9
- ```bash
10
- npm i -g @gasket/cli@^5.0.0
11
- ```
12
-
13
5
  ## Installation
14
6
 
15
7
  ```bash
16
- gasket create <app-name> --presets @gasket/preset-api
8
+ npx create-gasket-app <app-name> --presets @gasket/preset-api
17
9
  ```
18
10
 
19
11
  ## Docs
@@ -22,7 +14,6 @@ To see complete the list of plugins configured in your app, and what commands, l
22
14
 
23
15
  ## Plugins
24
16
 
25
- - [@gasket/plugin-data](/packages/gasket-plugin-data/README.md)
26
17
  - [@gasket/plugin-swagger](/packages/gasket-plugin-swagger/README.md)
27
18
  - [@gasket/plugin-docs](/packages/gasket-plugin-docs/README.md)
28
19
  - [@gasket/plugin-docusaurus](/packages/gasket-plugin-docusaurus/README.md)
@@ -0,0 +1,43 @@
1
+ # {{{appName}}}
2
+
3
+ {{{appDescription}}}
4
+
5
+ ## Overview
6
+
7
+ This API is built with {{{server}}}.js framework and [Gasket](https://gasket.dev/). This application utilizes [EcmaScript Modules] and requires Node.js v20 or higher.
8
+
9
+ ## Getting Started
10
+
11
+ ### Development
12
+
13
+ To start the API locally, run:
14
+
15
+ ```bash
16
+ cd {{{appName}}}
17
+ {{{installCmd}}}
18
+ {{{localCmd}}}
19
+ ```
20
+
21
+ ### Debugging
22
+
23
+ To start the API locally with debugging enabled, run:
24
+
25
+ ```bash
26
+ DEBUG=* {{{localCmd}}}
27
+ ```
28
+
29
+ Extended filtering of the debug output can be achieved by adding to the `DEBUG` environment variable:
30
+
31
+ ```bash
32
+ DEBUG=gasket:* {{{localCmd}}} // gasket operations only
33
+ DEBUG={{{server}}}:* {{{localCmd}}} // {{{server}}} operations only
34
+ ```
35
+
36
+ {{#each readme.markdown}}
37
+ {{{markdownCompile this}}}
38
+ {{/each}}
39
+ <!-- LINKS -->
40
+ [EcmaScript Modules]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
41
+ {{#each readme.links}}
42
+ {{{this}}}
43
+ {{/each}}
package/lib/create.js CHANGED
@@ -4,18 +4,15 @@ import { fileURLToPath } from 'url';
4
4
  const require = createRequire(import.meta.url);
5
5
  const { devDependencies } = require('../package.json');
6
6
 
7
- /**
8
- * createHook
9
- * @param {Gasket} gasket - Gasket API
10
- * @param {Create} context - Create context
11
- */
7
+ /** @type {import('@gasket/core').HookHandler<'create'>} */
12
8
  export default function create(gasket, context) {
13
9
  const { pkg, files } = context;
14
10
  const __dirname = fileURLToPath(import.meta.url);
15
11
  const generatorDir = path.join(__dirname, '..', '..', 'generator');
12
+ files.add(`${generatorDir}/*.md`);
16
13
 
17
14
  if (!context.typescript) {
18
- files.add(`${generatorDir}/*`);
15
+ files.add(`${generatorDir}/*.js`);
19
16
 
20
17
  pkg.add('devDependencies', {
21
18
  nodemon: devDependencies.nodemon
@@ -23,7 +20,8 @@ export default function create(gasket, context) {
23
20
 
24
21
  pkg.add('scripts', {
25
22
  start: 'node server.js',
26
- local: 'GASKET_ENV=local nodemon server.js'
23
+ local: 'nodemon server.js',
24
+ preview: 'npm run start'
27
25
  });
28
26
  }
29
27
  }
package/lib/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
- import '@gasket/plugin-data';
2
- import '@gasket/plugin-docs';
3
- import '@gasket/plugin-docusaurus';
4
1
  import '@gasket/plugin-express';
2
+ import '@gasket/plugin-fastify';
5
3
  import '@gasket/plugin-https';
6
4
  import '@gasket/plugin-lint';
7
- import '@gasket/plugin-start';
8
- import '@gasket/plugin-swagger';
9
5
  import '@gasket/plugin-winston';
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ import create from './create.js';
5
5
  const require = createRequire(import.meta.url);
6
6
  const { name, version, description } = require('../package.json');
7
7
 
8
- // TODO: need to create types for "preset" plugins
8
+ /** @type {import('@gasket/core').Preset} */
9
9
  export default {
10
10
  name,
11
11
  version,
@@ -1,10 +1,15 @@
1
- import pluginExpress from '@gasket/plugin-express';
2
- import pluginHttps from '@gasket/plugin-https';
1
+ // Default Plugins - included by default for all presets
2
+ import pluginCommand from '@gasket/plugin-command';
3
3
  import pluginDocs from '@gasket/plugin-docs';
4
4
  import pluginDocusaurus from '@gasket/plugin-docusaurus';
5
- import pluginData from '@gasket/plugin-data';
5
+ import pluginDynamicPlugins from '@gasket/plugin-dynamic-plugins';
6
+ import pluginGit from '@gasket/plugin-git';
7
+ import pluginLogger from '@gasket/plugin-logger';
8
+ import pluginMetadata from '@gasket/plugin-metadata';
9
+
10
+ // Preset-specific Plugins
11
+ import pluginHttps from '@gasket/plugin-https';
6
12
  import pluginWinston from '@gasket/plugin-winston';
7
- import pluginSwagger from '@gasket/plugin-swagger';
8
13
  import pluginLint from '@gasket/plugin-lint';
9
14
 
10
15
  /**
@@ -14,32 +19,43 @@ import pluginLint from '@gasket/plugin-lint';
14
19
  * @returns {Promise<CreateContext.presetConfig>} config
15
20
  */
16
21
  export default async function presetConfig(gasket, context) {
17
- let typescriptPlugin;
18
- let testPlugins = [];
22
+ const plugins = new Set([
23
+ pluginCommand,
24
+ pluginDocs,
25
+ pluginDocusaurus,
26
+ pluginDynamicPlugins,
27
+ pluginGit,
28
+ pluginHttps,
29
+ pluginLint,
30
+ pluginLogger,
31
+ pluginMetadata,
32
+ pluginWinston
33
+ ]);
34
+
35
+ const frameworkPlugin = context.server === 'express'
36
+ ? await import('@gasket/plugin-express')
37
+ : await import('@gasket/plugin-fastify');
38
+
39
+ plugins.add(frameworkPlugin.default || frameworkPlugin);
19
40
 
20
41
  if ('testPlugins' in context && context.testPlugins.length > 0) {
21
42
  await Promise.all(context.testPlugins.map(async (testPlugin) => {
22
43
  const plugin = await import(testPlugin);
23
- testPlugins.push(plugin ? plugin.default || plugin : null);
44
+ plugins.add(plugin ? plugin.default || plugin : null);
24
45
  }));
25
46
  }
26
47
 
27
48
  if (context.typescript) {
28
- typescriptPlugin = await import('@gasket/plugin-typescript');
49
+ const typescriptPlugin = await import('@gasket/plugin-typescript');
50
+ plugins.add(typescriptPlugin.default || typescriptPlugin);
51
+ }
52
+
53
+ if (context.useSwagger) {
54
+ const swaggerPlugin = await import('@gasket/plugin-swagger');
55
+ plugins.add(swaggerPlugin.default || swaggerPlugin);
29
56
  }
30
57
 
31
58
  return {
32
- plugins: [
33
- pluginExpress,
34
- pluginHttps,
35
- pluginDocs,
36
- pluginDocusaurus,
37
- pluginData,
38
- pluginWinston,
39
- pluginSwagger,
40
- pluginLint,
41
- typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
42
- ...testPlugins
43
- ].filter(Boolean)
59
+ plugins: Array.from(plugins)
44
60
  };
45
61
  }
@@ -1,3 +1,6 @@
1
+ import typescriptPrompts from '@gasket/plugin-typescript/prompts';
2
+ import swaggerPrompts from '@gasket/plugin-swagger/prompts';
3
+
1
4
  /**
2
5
  * presetPrompt hook
3
6
  * @param {Gasket} gasket - Gasket API
@@ -8,16 +11,24 @@
8
11
  export default async function presetPrompt(gasket, context, { prompt }) {
9
12
  context.apiApp = true;
10
13
 
11
- if (!('typescript' in context)) {
12
- const { typescript } = await prompt([
14
+ await typescriptPrompts.promptTypescript(context, prompt);
15
+ await swaggerPrompts.promptSwagger(context, prompt);
16
+
17
+ if (!('server' in context)) {
18
+ const { server } = await prompt([
13
19
  {
14
- name: 'typescript',
15
- message: 'Do you want to use TypeScript?',
16
- type: 'confirm',
17
- default: false
20
+ name: 'server',
21
+ message: 'Which server framework would you like to use?',
22
+ type: 'list',
23
+ choices: [
24
+ { name: 'Express', value: 'express' },
25
+ { name: 'Fastify', value: 'fastify' }
26
+ ]
18
27
  }
19
28
  ]);
20
29
 
21
- Object.assign(context, { typescript });
30
+ Object.assign(context, { server });
31
+
32
+ return context;
22
33
  }
23
34
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@gasket/preset-api",
3
- "version": "7.2.0-canary.20",
3
+ "version": "7.2.1",
4
4
  "description": "Create Express-based API with Gasket",
5
+ "type": "module",
5
6
  "main": "lib/index.js",
6
7
  "types": "lib/index.d.ts",
7
8
  "files": [
8
9
  "generator",
9
10
  "lib"
10
11
  ],
11
- "type": "module",
12
12
  "scripts": {
13
13
  "lint": "eslint .",
14
14
  "lint:fix": "npm run lint -- --fix",
@@ -29,24 +29,32 @@
29
29
  "bugs": {
30
30
  "url": "https://github.com/godaddy/gasket/issues"
31
31
  },
32
+ "homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-preset-api",
32
33
  "dependencies": {
33
- "@gasket/plugin-cypress": "^7.2.0-canary.20",
34
- "@gasket/plugin-data": "^7.2.0-canary.20",
35
- "@gasket/plugin-express": "^7.2.0-canary.20",
36
- "@gasket/plugin-https": "^7.2.0-canary.20",
37
- "@gasket/plugin-jest": "^7.2.0-canary.20",
38
- "@gasket/plugin-lint": "^7.2.0-canary.20",
39
- "@gasket/plugin-mocha": "^7.2.0-canary.20",
40
- "@gasket/plugin-swagger": "^7.2.0-canary.20",
41
- "@gasket/plugin-typescript": "^7.2.0-canary.20",
42
- "@gasket/plugin-winston": "^7.2.0-canary.20"
34
+ "@gasket/plugin-command": "^7.2.1",
35
+ "@gasket/plugin-cypress": "^7.2.1",
36
+ "@gasket/plugin-docs": "^7.2.1",
37
+ "@gasket/plugin-docusaurus": "^7.2.1",
38
+ "@gasket/plugin-dynamic-plugins": "^7.2.1",
39
+ "@gasket/plugin-express": "^7.2.1",
40
+ "@gasket/plugin-fastify": "^7.2.1",
41
+ "@gasket/plugin-git": "^7.2.1",
42
+ "@gasket/plugin-https": "^7.2.1",
43
+ "@gasket/plugin-jest": "^7.2.0",
44
+ "@gasket/plugin-lint": "^7.2.0",
45
+ "@gasket/plugin-logger": "^7.2.1",
46
+ "@gasket/plugin-metadata": "^7.2.1",
47
+ "@gasket/plugin-mocha": "^7.2.0",
48
+ "@gasket/plugin-swagger": "^7.2.1",
49
+ "@gasket/plugin-typescript": "^7.2.0",
50
+ "@gasket/plugin-winston": "^7.2.1"
43
51
  },
44
52
  "devDependencies": {
45
53
  "cross-env": "^7.0.3",
46
54
  "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",
55
+ "eslint-config-godaddy": "^7.1.1",
56
+ "eslint-plugin-jest": "^28.6.0",
57
+ "eslint-plugin-unicorn": "^55.0.0",
50
58
  "jest": "^29.7.0",
51
59
  "nodemon": "^3.1.0"
52
60
  },
@@ -63,10 +71,11 @@
63
71
  }
64
72
  },
65
73
  "eslintIgnore": [
66
- "test/fixtures"
74
+ "test/fixtures",
75
+ "generator"
67
76
  ],
68
77
  "jest": {
69
78
  "transform": {}
70
79
  },
71
- "gitHead": "abdb788c7ff44f4c6db7a5885e96e2dd315273fc"
80
+ "gitHead": "8af41663d838cb00344ffbdabf64fc535b78dd3d"
72
81
  }