@gasket/preset-api 7.3.8 → 7.3.10
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/cjs/create.js +37 -0
- package/cjs/index.d.ts +5 -0
- package/cjs/index.js +31 -0
- package/cjs/package.json +1 -0
- package/cjs/preset-config.js +143 -0
- package/cjs/preset-prompt.js +86 -0
- package/package.json +38 -23
package/cjs/create.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, /** @type {import('@gasket/core').HookHandler<'create'>} */ "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return create;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _module = require("module");
|
|
13
|
+
const _url = require("url");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const require1 = (0, _module.createRequire)(require("url").pathToFileURL(__filename).toString());
|
|
20
|
+
const { devDependencies } = require1('../package.json');
|
|
21
|
+
function create(gasket, context) {
|
|
22
|
+
const { pkg, files } = context;
|
|
23
|
+
const __dirname = (0, _url.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
|
|
24
|
+
const generatorDir = _path.default.join(__dirname, '..', '..', 'generator');
|
|
25
|
+
files.add(`${generatorDir}/*.md`);
|
|
26
|
+
if (!context.typescript) {
|
|
27
|
+
files.add(`${generatorDir}/*.js`);
|
|
28
|
+
pkg.add('devDependencies', {
|
|
29
|
+
nodemon: devDependencies.nodemon
|
|
30
|
+
});
|
|
31
|
+
pkg.add('scripts', {
|
|
32
|
+
start: 'node server.js',
|
|
33
|
+
local: 'nodemon server.js',
|
|
34
|
+
preview: 'npm run start'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
package/cjs/index.d.ts
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, /** @type {import('@gasket/core').Preset} */ "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _module = require("module");
|
|
12
|
+
const _presetprompt = /*#__PURE__*/ _interop_require_default(require("./preset-prompt.js"));
|
|
13
|
+
const _presetconfig = /*#__PURE__*/ _interop_require_default(require("./preset-config.js"));
|
|
14
|
+
const _create = /*#__PURE__*/ _interop_require_default(require("./create.js"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const require1 = (0, _module.createRequire)(require("url").pathToFileURL(__filename).toString());
|
|
21
|
+
const { name, version, description } = require1('../package.json');
|
|
22
|
+
const _default = {
|
|
23
|
+
name,
|
|
24
|
+
version,
|
|
25
|
+
description,
|
|
26
|
+
hooks: {
|
|
27
|
+
presetPrompt: _presetprompt.default,
|
|
28
|
+
presetConfig: _presetconfig.default,
|
|
29
|
+
create: _create.default
|
|
30
|
+
}
|
|
31
|
+
};
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Default Plugins - included by default for all presets
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, /**
|
|
7
|
+
* presetConfig hook
|
|
8
|
+
* @param {Gasket} gasket - Gasket API
|
|
9
|
+
* @param {Create} context - Create context
|
|
10
|
+
* @returns {Promise<CreateContext.presetConfig>} config
|
|
11
|
+
*/ "default", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return presetConfig;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const _plugincommand = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-command"));
|
|
18
|
+
const _plugindocs = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-docs"));
|
|
19
|
+
const _plugindocusaurus = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-docusaurus"));
|
|
20
|
+
const _plugindynamicplugins = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-dynamic-plugins"));
|
|
21
|
+
const _plugingit = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-git"));
|
|
22
|
+
const _pluginlogger = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-logger"));
|
|
23
|
+
const _pluginhttps = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-https"));
|
|
24
|
+
const _pluginwinston = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-winston"));
|
|
25
|
+
const _pluginlint = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-lint"));
|
|
26
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
27
|
+
try {
|
|
28
|
+
var info = gen[key](arg);
|
|
29
|
+
var value = info.value;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
reject(error);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (info.done) {
|
|
35
|
+
resolve(value);
|
|
36
|
+
} else {
|
|
37
|
+
Promise.resolve(value).then(_next, _throw);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function _async_to_generator(fn) {
|
|
41
|
+
return function() {
|
|
42
|
+
var self = this, args = arguments;
|
|
43
|
+
return new Promise(function(resolve, reject) {
|
|
44
|
+
var gen = fn.apply(self, args);
|
|
45
|
+
function _next(value) {
|
|
46
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
47
|
+
}
|
|
48
|
+
function _throw(err) {
|
|
49
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
50
|
+
}
|
|
51
|
+
_next(undefined);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function _interop_require_default(obj) {
|
|
56
|
+
return obj && obj.__esModule ? obj : {
|
|
57
|
+
default: obj
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
61
|
+
if (typeof WeakMap !== "function") return null;
|
|
62
|
+
var cacheBabelInterop = new WeakMap();
|
|
63
|
+
var cacheNodeInterop = new WeakMap();
|
|
64
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
65
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
66
|
+
})(nodeInterop);
|
|
67
|
+
}
|
|
68
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
69
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
70
|
+
return obj;
|
|
71
|
+
}
|
|
72
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
73
|
+
return {
|
|
74
|
+
default: obj
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
78
|
+
if (cache && cache.has(obj)) {
|
|
79
|
+
return cache.get(obj);
|
|
80
|
+
}
|
|
81
|
+
var newObj = {
|
|
82
|
+
__proto__: null
|
|
83
|
+
};
|
|
84
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
85
|
+
for(var key in obj){
|
|
86
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
87
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
88
|
+
if (desc && (desc.get || desc.set)) {
|
|
89
|
+
Object.defineProperty(newObj, key, desc);
|
|
90
|
+
} else {
|
|
91
|
+
newObj[key] = obj[key];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
newObj.default = obj;
|
|
96
|
+
if (cache) {
|
|
97
|
+
cache.set(obj, newObj);
|
|
98
|
+
}
|
|
99
|
+
return newObj;
|
|
100
|
+
}
|
|
101
|
+
function presetConfig(gasket, context) {
|
|
102
|
+
return _presetConfig.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
function _presetConfig() {
|
|
105
|
+
_presetConfig = _async_to_generator(function*(gasket, context) {
|
|
106
|
+
const plugins = new Set([
|
|
107
|
+
_plugincommand.default,
|
|
108
|
+
_plugindocs.default,
|
|
109
|
+
_plugindocusaurus.default,
|
|
110
|
+
_plugindynamicplugins.default,
|
|
111
|
+
_plugingit.default,
|
|
112
|
+
_pluginhttps.default,
|
|
113
|
+
_pluginlint.default,
|
|
114
|
+
_pluginlogger.default,
|
|
115
|
+
_pluginwinston.default
|
|
116
|
+
]);
|
|
117
|
+
const frameworkPlugin = context.server === 'express' ? yield Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-express"))) : yield Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-fastify")));
|
|
118
|
+
plugins.add(frameworkPlugin.default || frameworkPlugin);
|
|
119
|
+
if ('testPlugins' in context && context.testPlugins.length > 0) {
|
|
120
|
+
yield Promise.all(context.testPlugins.map(/*#__PURE__*/ function() {
|
|
121
|
+
var _ref = _async_to_generator(function*(testPlugin) {
|
|
122
|
+
const plugin = yield Promise.resolve(testPlugin).then((p)=>/*#__PURE__*/ _interop_require_wildcard(require(p)));
|
|
123
|
+
plugins.add(plugin ? plugin.default || plugin : null);
|
|
124
|
+
});
|
|
125
|
+
return function(testPlugin) {
|
|
126
|
+
return _ref.apply(this, arguments);
|
|
127
|
+
};
|
|
128
|
+
}()));
|
|
129
|
+
}
|
|
130
|
+
if (context.typescript) {
|
|
131
|
+
const typescriptPlugin = yield Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-typescript")));
|
|
132
|
+
plugins.add(typescriptPlugin.default || typescriptPlugin);
|
|
133
|
+
}
|
|
134
|
+
if (context.useSwagger) {
|
|
135
|
+
const swaggerPlugin = yield Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-swagger")));
|
|
136
|
+
plugins.add(swaggerPlugin.default || swaggerPlugin);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
plugins: Array.from(plugins)
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
return _presetConfig.apply(this, arguments);
|
|
143
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, /**
|
|
6
|
+
* presetPrompt hook
|
|
7
|
+
* @param {Gasket} gasket - Gasket API
|
|
8
|
+
* @param {Create} context - Create context
|
|
9
|
+
* @param {Object} utils - Prompt utils
|
|
10
|
+
* @param {Function} utils.prompt - Inquirer prompt
|
|
11
|
+
*/ "default", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return presetPrompt;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const _prompts = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-typescript/prompts"));
|
|
18
|
+
const _prompts1 = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-swagger/prompts"));
|
|
19
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
20
|
+
try {
|
|
21
|
+
var info = gen[key](arg);
|
|
22
|
+
var value = info.value;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
reject(error);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (info.done) {
|
|
28
|
+
resolve(value);
|
|
29
|
+
} else {
|
|
30
|
+
Promise.resolve(value).then(_next, _throw);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function _async_to_generator(fn) {
|
|
34
|
+
return function() {
|
|
35
|
+
var self = this, args = arguments;
|
|
36
|
+
return new Promise(function(resolve, reject) {
|
|
37
|
+
var gen = fn.apply(self, args);
|
|
38
|
+
function _next(value) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
40
|
+
}
|
|
41
|
+
function _throw(err) {
|
|
42
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
43
|
+
}
|
|
44
|
+
_next(undefined);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function _interop_require_default(obj) {
|
|
49
|
+
return obj && obj.__esModule ? obj : {
|
|
50
|
+
default: obj
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function presetPrompt(gasket, context, _) {
|
|
54
|
+
return _presetPrompt.apply(this, arguments);
|
|
55
|
+
}
|
|
56
|
+
function _presetPrompt() {
|
|
57
|
+
_presetPrompt = _async_to_generator(function*(gasket, context, { prompt }) {
|
|
58
|
+
context.apiApp = true;
|
|
59
|
+
yield _prompts.default.promptTypescript(context, prompt);
|
|
60
|
+
yield _prompts1.default.promptSwagger(context, prompt);
|
|
61
|
+
if (!('server' in context)) {
|
|
62
|
+
const { server } = yield prompt([
|
|
63
|
+
{
|
|
64
|
+
name: 'server',
|
|
65
|
+
message: 'Which server framework would you like to use?',
|
|
66
|
+
type: 'list',
|
|
67
|
+
choices: [
|
|
68
|
+
{
|
|
69
|
+
name: 'Express',
|
|
70
|
+
value: 'express'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Fastify',
|
|
74
|
+
value: 'fastify'
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]);
|
|
79
|
+
Object.assign(context, {
|
|
80
|
+
server
|
|
81
|
+
});
|
|
82
|
+
return context;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return _presetPrompt.apply(this, arguments);
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/preset-api",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.10",
|
|
4
4
|
"description": "Create Express-based API with Gasket",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
6
|
"types": "lib/index.d.ts",
|
|
8
7
|
"files": [
|
|
9
8
|
"generator",
|
|
10
|
-
"lib"
|
|
9
|
+
"lib",
|
|
10
|
+
"cjs"
|
|
11
11
|
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./lib/index.d.ts",
|
|
15
|
+
"import": "./lib/index.js",
|
|
16
|
+
"require": "./cjs/index.js",
|
|
17
|
+
"default": "./cjs/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
12
21
|
"repository": "godaddy/gasket.git",
|
|
13
22
|
"publishConfig": {
|
|
14
23
|
"access": "public"
|
|
@@ -18,24 +27,26 @@
|
|
|
18
27
|
"bugs": "https://github.com/godaddy/gasket/issues",
|
|
19
28
|
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-preset-api",
|
|
20
29
|
"dependencies": {
|
|
21
|
-
"@gasket/plugin-command": "7.3.
|
|
22
|
-
"@gasket/plugin-cypress": "7.4.
|
|
23
|
-
"@gasket/plugin-docs": "7.3.
|
|
24
|
-
"@gasket/plugin-docusaurus": "7.4.
|
|
25
|
-
"@gasket/plugin-dynamic-plugins": "7.3.
|
|
26
|
-
"@gasket/plugin-express": "7.3.
|
|
27
|
-
"@gasket/plugin-fastify": "7.3.
|
|
28
|
-
"@gasket/plugin-git": "7.3.
|
|
29
|
-
"@gasket/plugin-https": "7.3.
|
|
30
|
-
"@gasket/plugin-jest": "7.4.
|
|
31
|
-
"@gasket/plugin-lint": "7.3.
|
|
32
|
-
"@gasket/plugin-logger": "7.3.
|
|
33
|
-
"@gasket/plugin-mocha": "7.4.
|
|
34
|
-
"@gasket/plugin-swagger": "7.3.
|
|
35
|
-
"@gasket/plugin-typescript": "7.3.
|
|
36
|
-
"@gasket/plugin-winston": "7.3.
|
|
30
|
+
"@gasket/plugin-command": "7.3.7",
|
|
31
|
+
"@gasket/plugin-cypress": "7.4.1",
|
|
32
|
+
"@gasket/plugin-docs": "7.3.7",
|
|
33
|
+
"@gasket/plugin-docusaurus": "7.4.2",
|
|
34
|
+
"@gasket/plugin-dynamic-plugins": "7.3.6",
|
|
35
|
+
"@gasket/plugin-express": "7.3.5",
|
|
36
|
+
"@gasket/plugin-fastify": "7.3.6",
|
|
37
|
+
"@gasket/plugin-git": "7.3.4",
|
|
38
|
+
"@gasket/plugin-https": "7.3.5",
|
|
39
|
+
"@gasket/plugin-jest": "7.4.2",
|
|
40
|
+
"@gasket/plugin-lint": "7.3.6",
|
|
41
|
+
"@gasket/plugin-logger": "7.3.4",
|
|
42
|
+
"@gasket/plugin-mocha": "7.4.1",
|
|
43
|
+
"@gasket/plugin-swagger": "7.3.5",
|
|
44
|
+
"@gasket/plugin-typescript": "7.3.4",
|
|
45
|
+
"@gasket/plugin-winston": "7.3.4"
|
|
37
46
|
},
|
|
38
47
|
"devDependencies": {
|
|
48
|
+
"@swc/cli": "^0.6.0",
|
|
49
|
+
"@swc/core": "^1.10.18",
|
|
39
50
|
"@types/jest": "^29.5.14",
|
|
40
51
|
"@types/node": "^20.17.19",
|
|
41
52
|
"cross-env": "^7.0.3",
|
|
@@ -46,9 +57,9 @@
|
|
|
46
57
|
"eslint-plugin-unicorn": "^55.0.0",
|
|
47
58
|
"jest": "^29.7.0",
|
|
48
59
|
"nodemon": "^3.1.9",
|
|
49
|
-
"typescript": "^5.
|
|
50
|
-
"@gasket/plugin-metadata": "7.3.
|
|
51
|
-
"create-gasket-app": "7.3.
|
|
60
|
+
"typescript": "^5.8.2",
|
|
61
|
+
"@gasket/plugin-metadata": "7.3.10",
|
|
62
|
+
"create-gasket-app": "7.3.10"
|
|
52
63
|
},
|
|
53
64
|
"eslintConfig": {
|
|
54
65
|
"extends": [
|
|
@@ -64,14 +75,18 @@
|
|
|
64
75
|
},
|
|
65
76
|
"eslintIgnore": [
|
|
66
77
|
"test/fixtures",
|
|
67
|
-
"generator"
|
|
78
|
+
"generator",
|
|
79
|
+
"cjs"
|
|
68
80
|
],
|
|
69
81
|
"jest": {
|
|
70
82
|
"transform": {}
|
|
71
83
|
},
|
|
72
84
|
"scripts": {
|
|
85
|
+
"build": "swc lib -d cjs --delete-dir-on-start --strip-leading-paths && cp lib/index.d.ts cjs/",
|
|
86
|
+
"build:watch": "pnpm run build --watch",
|
|
73
87
|
"lint": "eslint .",
|
|
74
88
|
"lint:fix": "pnpm run lint --fix",
|
|
89
|
+
"postbuild": "node -e \"require('fs').writeFileSync('cjs/package.json', '{}')\"",
|
|
75
90
|
"posttest": "pnpm run lint",
|
|
76
91
|
"test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
|
|
77
92
|
"test:coverage": "jest --coverage",
|