@gasket/preset-api 7.0.3-cli.0 → 7.2.0-canary.0
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 +1 -1
- package/generator/server.js +2 -0
- package/lib/create.js +29 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +13 -4
- package/lib/preset-config.js +45 -0
- package/lib/preset-prompt.js +23 -0
- package/package.json +50 -12
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-
|
|
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)
|
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,4 +1,4 @@
|
|
|
1
|
-
import '@gasket/plugin-
|
|
1
|
+
import '@gasket/plugin-data';
|
|
2
2
|
import '@gasket/plugin-docs';
|
|
3
3
|
import '@gasket/plugin-docusaurus';
|
|
4
4
|
import '@gasket/plugin-express';
|
|
@@ -6,4 +6,4 @@ import '@gasket/plugin-https';
|
|
|
6
6
|
import '@gasket/plugin-lint';
|
|
7
7
|
import '@gasket/plugin-start';
|
|
8
8
|
import '@gasket/plugin-swagger';
|
|
9
|
-
import '@gasket/plugin-winston';
|
|
9
|
+
import '@gasket/plugin-winston';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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');
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
name,
|
|
10
|
+
hooks: {
|
|
11
|
+
presetPrompt,
|
|
12
|
+
presetConfig,
|
|
13
|
+
create
|
|
5
14
|
}
|
|
6
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 pluginData from '@gasket/plugin-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
|
+
pluginData,
|
|
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,12 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/preset-api",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.0-canary.0",
|
|
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
|
],
|
|
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
|
+
},
|
|
10
20
|
"repository": {
|
|
11
21
|
"type": "git",
|
|
12
22
|
"url": "git+ssh://git@github.com/godaddy/gasket.git"
|
|
@@ -20,17 +30,45 @@
|
|
|
20
30
|
"url": "https://github.com/godaddy/gasket/issues"
|
|
21
31
|
},
|
|
22
32
|
"dependencies": {
|
|
23
|
-
"@gasket/plugin-
|
|
24
|
-
"@gasket/plugin-
|
|
25
|
-
"@gasket/plugin-
|
|
26
|
-
"@gasket/plugin-
|
|
27
|
-
"@gasket/plugin-
|
|
28
|
-
"@gasket/plugin-
|
|
29
|
-
"@gasket/plugin-
|
|
30
|
-
"@gasket/plugin-
|
|
33
|
+
"@gasket/plugin-cypress": "^7.2.0-canary.0",
|
|
34
|
+
"@gasket/plugin-data": "^7.2.0-canary.0",
|
|
35
|
+
"@gasket/plugin-docs": "^7.2.0-canary.0",
|
|
36
|
+
"@gasket/plugin-docusaurus": "^7.2.0-canary.0",
|
|
37
|
+
"@gasket/plugin-express": "^7.2.0-canary.0",
|
|
38
|
+
"@gasket/plugin-https": "^7.2.0-canary.0",
|
|
39
|
+
"@gasket/plugin-jest": "^7.2.0-canary.0",
|
|
40
|
+
"@gasket/plugin-lint": "^7.2.0-canary.0",
|
|
41
|
+
"@gasket/plugin-mocha": "^7.2.0-canary.0",
|
|
42
|
+
"@gasket/plugin-swagger": "^7.2.0-canary.0",
|
|
43
|
+
"@gasket/plugin-typescript": "^7.2.0-canary.0",
|
|
44
|
+
"@gasket/plugin-winston": "^7.2.0-canary.0"
|
|
31
45
|
},
|
|
32
46
|
"devDependencies": {
|
|
33
|
-
"
|
|
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": {}
|
|
34
72
|
},
|
|
35
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "ee8a2095eaad4cdf2b15e5fb8044076ced4acc10"
|
|
36
74
|
}
|