@kubb/plugin-cypress 4.2.0 → 4.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/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-C0s4sqJf.d.ts → types-B6NVdm3Y.d.cts} +13 -57
- package/dist/{types-CpA-hLRj.d.cts → types-BmCWqgDU.d.ts} +13 -57
- package/package.json +6 -6
- package/src/plugin.ts +5 -8
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -29,7 +29,7 @@ const pluginCypress = (0, __kubb_core.createPlugin)((options) => {
|
|
|
29
29
|
pre: [__kubb_plugin_oas.pluginOasName, __kubb_plugin_ts.pluginTsName].filter(Boolean),
|
|
30
30
|
resolvePath(baseName, pathMode, options$1) {
|
|
31
31
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
32
|
-
if ((pathMode ?? __kubb_core.
|
|
32
|
+
if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
33
33
|
/**
|
|
34
34
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
35
35
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -53,7 +53,7 @@ const pluginCypress = (0, __kubb_core.createPlugin)((options) => {
|
|
|
53
53
|
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
54
54
|
const oas = await swaggerPlugin.context.getOas();
|
|
55
55
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
56
|
-
const mode = __kubb_core.
|
|
56
|
+
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
57
57
|
const files = await new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
58
58
|
oas,
|
|
59
59
|
pluginManager: this.pluginManager,
|
|
@@ -65,7 +65,7 @@ const pluginCypress = (0, __kubb_core.createPlugin)((options) => {
|
|
|
65
65
|
mode
|
|
66
66
|
}).build(...generators);
|
|
67
67
|
await this.addFile(...files);
|
|
68
|
-
const barrelFiles = await this.fileManager.
|
|
68
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fileManager.files, {
|
|
69
69
|
type: output.barrelType ?? "named",
|
|
70
70
|
root,
|
|
71
71
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","path","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = createPlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,oBAAoB;AAEjC,MAAa,+CAA6C,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,oCAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,YACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,KAAK,CAACC,iCAAeC,8BAAa,CAAC,OAAO,QAAQ;EAClD,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,qCAAoBA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUC,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,2CAAa,IAAI,MAAM,CAAC;;AAGrC,WAAOF,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASC,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAOD,kBAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,uDAAyB,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiDG,0BAAc,mBAAyC,KAAK,SAAS,CAACL,gCAAc,CAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAOE,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAarD,MAAM,QAAQ,MAXa,IAAII,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,sCAAqB,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-B6NVdm3Y.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginCypressName = "plugin-cypress";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-BmCWqgDU.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginCypressName = "plugin-cypress";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./components-CkuOZl8o.js";
|
|
2
2
|
import { t as cypressGenerator } from "./generators-v4Wf70NJ.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
6
6
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
7
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
@@ -24,7 +24,7 @@ const pluginCypress = createPlugin((options) => {
|
|
|
24
24
|
pre: [pluginOasName, pluginTsName].filter(Boolean),
|
|
25
25
|
resolvePath(baseName, pathMode, options$1) {
|
|
26
26
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
27
|
-
if ((pathMode ??
|
|
27
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
28
28
|
/**
|
|
29
29
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
30
30
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -48,7 +48,7 @@ const pluginCypress = createPlugin((options) => {
|
|
|
48
48
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
49
49
|
const oas = await swaggerPlugin.context.getOas();
|
|
50
50
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
51
|
-
const mode =
|
|
51
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
52
52
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
53
53
|
oas,
|
|
54
54
|
pluginManager: this.pluginManager,
|
|
@@ -60,7 +60,7 @@ const pluginCypress = createPlugin((options) => {
|
|
|
60
60
|
mode
|
|
61
61
|
}).build(...generators);
|
|
62
62
|
await this.addFile(...files);
|
|
63
|
-
const barrelFiles = await this.fileManager.
|
|
63
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
64
64
|
type: output.barrelType ?? "named",
|
|
65
65
|
root,
|
|
66
66
|
output,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = createPlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AASA,MAAa,oBAAoB;AAEjC,MAAa,gBAAgB,cAA6B,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAAC,iBAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,YACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,aAAa,CAAC,OAAO,QAAQ;EAClD,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;AAGrC,WAAO,KAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,eAAe,UAAU,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiD,cAAc,mBAAyC,KAAK,SAAS,CAAC,cAAc,CAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAarD,MAAM,QAAQ,MAXa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,eAAe,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
7
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
8
9
|
|
|
9
10
|
//#region ../oas/src/types.d.ts
|
|
10
11
|
type contentType = 'application/json' | (string & {});
|
|
@@ -220,8 +221,6 @@ type Logger = {
|
|
|
220
221
|
//#endregion
|
|
221
222
|
//#region ../core/src/utils/types.d.ts
|
|
222
223
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
223
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
224
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
225
224
|
//#endregion
|
|
226
225
|
//#region ../core/src/types.d.ts
|
|
227
226
|
type InputPath = {
|
|
@@ -464,6 +463,9 @@ type ResolveNameParams = {
|
|
|
464
463
|
};
|
|
465
464
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
466
465
|
config: Config;
|
|
466
|
+
/**
|
|
467
|
+
* @deprecated
|
|
468
|
+
*/
|
|
467
469
|
fileManager: FileManager;
|
|
468
470
|
pluginManager: PluginManager;
|
|
469
471
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -515,60 +517,6 @@ type Group = {
|
|
|
515
517
|
name?: (context: GroupContext) => string;
|
|
516
518
|
};
|
|
517
519
|
//#endregion
|
|
518
|
-
//#region ../core/src/FileManager.d.ts
|
|
519
|
-
type FileMetaBase = {
|
|
520
|
-
pluginKey?: Plugin['key'];
|
|
521
|
-
};
|
|
522
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
523
|
-
type AddIndexesProps = {
|
|
524
|
-
type: BarrelType | false | undefined;
|
|
525
|
-
/**
|
|
526
|
-
* Root based on root and output.path specified in the config
|
|
527
|
-
*/
|
|
528
|
-
root: string;
|
|
529
|
-
/**
|
|
530
|
-
* Output for plugin
|
|
531
|
-
*/
|
|
532
|
-
output: {
|
|
533
|
-
path: string;
|
|
534
|
-
};
|
|
535
|
-
group?: {
|
|
536
|
-
output: string;
|
|
537
|
-
exportAs: string;
|
|
538
|
-
};
|
|
539
|
-
logger?: Logger;
|
|
540
|
-
meta?: FileMetaBase;
|
|
541
|
-
};
|
|
542
|
-
type WriteFilesProps = {
|
|
543
|
-
root: Config['root'];
|
|
544
|
-
extension?: Record<Extname, Extname | ''>;
|
|
545
|
-
logger?: Logger;
|
|
546
|
-
dryRun?: boolean;
|
|
547
|
-
};
|
|
548
|
-
declare class FileManager {
|
|
549
|
-
#private;
|
|
550
|
-
constructor();
|
|
551
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
552
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
553
|
-
deleteByPath(path: Path): Promise<void>;
|
|
554
|
-
clear(): Promise<void>;
|
|
555
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
556
|
-
processFiles({
|
|
557
|
-
dryRun,
|
|
558
|
-
root,
|
|
559
|
-
extension,
|
|
560
|
-
logger
|
|
561
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
562
|
-
getBarrelFiles({
|
|
563
|
-
type,
|
|
564
|
-
meta,
|
|
565
|
-
root,
|
|
566
|
-
output,
|
|
567
|
-
logger
|
|
568
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
569
|
-
static getMode(path: string | undefined | null): Mode;
|
|
570
|
-
}
|
|
571
|
-
//#endregion
|
|
572
520
|
//#region ../core/src/PluginManager.d.ts
|
|
573
521
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
574
522
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -607,6 +555,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
607
555
|
declare class PluginManager {
|
|
608
556
|
#private;
|
|
609
557
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
558
|
+
/**
|
|
559
|
+
* @deprecated do not use from pluginManager
|
|
560
|
+
*/
|
|
610
561
|
readonly fileManager: FileManager;
|
|
611
562
|
readonly events: EventEmitter<Events>;
|
|
612
563
|
readonly config: Config;
|
|
@@ -715,6 +666,11 @@ declare class PluginManager {
|
|
|
715
666
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
716
667
|
}
|
|
717
668
|
//#endregion
|
|
669
|
+
//#region ../core/src/FileManager.d.ts
|
|
670
|
+
type FileMetaBase = {
|
|
671
|
+
pluginKey?: Plugin['key'];
|
|
672
|
+
};
|
|
673
|
+
//#endregion
|
|
718
674
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
719
675
|
type SchemaKeywordMapper = {
|
|
720
676
|
object: {
|
|
@@ -1184,4 +1140,4 @@ type ResolvedOptions = {
|
|
|
1184
1140
|
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1185
1141
|
//#endregion
|
|
1186
1142
|
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginCypress as n, HttpMethod as o, Generator as r, Options$1 as t };
|
|
1187
|
-
//# sourceMappingURL=types-
|
|
1143
|
+
//# sourceMappingURL=types-B6NVdm3Y.d.cts.map
|
|
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
7
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
8
9
|
|
|
9
10
|
//#region ../oas/src/types.d.ts
|
|
10
11
|
type contentType = 'application/json' | (string & {});
|
|
@@ -220,8 +221,6 @@ type Logger = {
|
|
|
220
221
|
//#endregion
|
|
221
222
|
//#region ../core/src/utils/types.d.ts
|
|
222
223
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
223
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
224
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
225
224
|
//#endregion
|
|
226
225
|
//#region ../core/src/types.d.ts
|
|
227
226
|
type InputPath = {
|
|
@@ -464,6 +463,9 @@ type ResolveNameParams = {
|
|
|
464
463
|
};
|
|
465
464
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
466
465
|
config: Config;
|
|
466
|
+
/**
|
|
467
|
+
* @deprecated
|
|
468
|
+
*/
|
|
467
469
|
fileManager: FileManager;
|
|
468
470
|
pluginManager: PluginManager;
|
|
469
471
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -515,60 +517,6 @@ type Group = {
|
|
|
515
517
|
name?: (context: GroupContext) => string;
|
|
516
518
|
};
|
|
517
519
|
//#endregion
|
|
518
|
-
//#region ../core/src/FileManager.d.ts
|
|
519
|
-
type FileMetaBase = {
|
|
520
|
-
pluginKey?: Plugin['key'];
|
|
521
|
-
};
|
|
522
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
523
|
-
type AddIndexesProps = {
|
|
524
|
-
type: BarrelType | false | undefined;
|
|
525
|
-
/**
|
|
526
|
-
* Root based on root and output.path specified in the config
|
|
527
|
-
*/
|
|
528
|
-
root: string;
|
|
529
|
-
/**
|
|
530
|
-
* Output for plugin
|
|
531
|
-
*/
|
|
532
|
-
output: {
|
|
533
|
-
path: string;
|
|
534
|
-
};
|
|
535
|
-
group?: {
|
|
536
|
-
output: string;
|
|
537
|
-
exportAs: string;
|
|
538
|
-
};
|
|
539
|
-
logger?: Logger;
|
|
540
|
-
meta?: FileMetaBase;
|
|
541
|
-
};
|
|
542
|
-
type WriteFilesProps = {
|
|
543
|
-
root: Config['root'];
|
|
544
|
-
extension?: Record<Extname, Extname | ''>;
|
|
545
|
-
logger?: Logger;
|
|
546
|
-
dryRun?: boolean;
|
|
547
|
-
};
|
|
548
|
-
declare class FileManager {
|
|
549
|
-
#private;
|
|
550
|
-
constructor();
|
|
551
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
552
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
553
|
-
deleteByPath(path: Path): Promise<void>;
|
|
554
|
-
clear(): Promise<void>;
|
|
555
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
556
|
-
processFiles({
|
|
557
|
-
dryRun,
|
|
558
|
-
root,
|
|
559
|
-
extension,
|
|
560
|
-
logger
|
|
561
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
562
|
-
getBarrelFiles({
|
|
563
|
-
type,
|
|
564
|
-
meta,
|
|
565
|
-
root,
|
|
566
|
-
output,
|
|
567
|
-
logger
|
|
568
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
569
|
-
static getMode(path: string | undefined | null): Mode;
|
|
570
|
-
}
|
|
571
|
-
//#endregion
|
|
572
520
|
//#region ../core/src/PluginManager.d.ts
|
|
573
521
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
574
522
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -607,6 +555,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
607
555
|
declare class PluginManager {
|
|
608
556
|
#private;
|
|
609
557
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
558
|
+
/**
|
|
559
|
+
* @deprecated do not use from pluginManager
|
|
560
|
+
*/
|
|
610
561
|
readonly fileManager: FileManager;
|
|
611
562
|
readonly events: EventEmitter<Events>;
|
|
612
563
|
readonly config: Config;
|
|
@@ -715,6 +666,11 @@ declare class PluginManager {
|
|
|
715
666
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
716
667
|
}
|
|
717
668
|
//#endregion
|
|
669
|
+
//#region ../core/src/FileManager.d.ts
|
|
670
|
+
type FileMetaBase = {
|
|
671
|
+
pluginKey?: Plugin['key'];
|
|
672
|
+
};
|
|
673
|
+
//#endregion
|
|
718
674
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
719
675
|
type SchemaKeywordMapper = {
|
|
720
676
|
object: {
|
|
@@ -1184,4 +1140,4 @@ type ResolvedOptions = {
|
|
|
1184
1140
|
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1185
1141
|
//#endregion
|
|
1186
1142
|
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginCypress as n, HttpMethod as o, Generator as r, Options$1 as t };
|
|
1187
|
-
//# sourceMappingURL=types-
|
|
1143
|
+
//# sourceMappingURL=types-BmCWqgDU.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-cypress",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cypress",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"!/**/__tests__/**"
|
|
68
68
|
],
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@kubb/core": "4.2.
|
|
71
|
-
"@kubb/oas": "4.2.
|
|
72
|
-
"@kubb/plugin-oas": "4.2.
|
|
73
|
-
"@kubb/plugin-ts": "4.2.
|
|
74
|
-
"@kubb/react": "4.2.
|
|
70
|
+
"@kubb/core": "4.2.1",
|
|
71
|
+
"@kubb/oas": "4.2.1",
|
|
72
|
+
"@kubb/plugin-oas": "4.2.1",
|
|
73
|
+
"@kubb/plugin-ts": "4.2.1",
|
|
74
|
+
"@kubb/react": "4.2.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"tsdown": "^0.15.9",
|
package/src/plugin.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'
|
|
2
|
+
import { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'
|
|
4
3
|
import { camelCase } from '@kubb/core/transformers'
|
|
4
|
+
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
5
5
|
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
|
-
|
|
8
|
-
import type { Plugin } from '@kubb/core'
|
|
9
|
-
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
10
7
|
import { cypressGenerator } from './generators'
|
|
11
8
|
import type { PluginCypress } from './types.ts'
|
|
12
9
|
|
|
@@ -37,7 +34,7 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
|
|
|
37
34
|
pre: [pluginOasName, pluginTsName].filter(Boolean),
|
|
38
35
|
resolvePath(baseName, pathMode, options) {
|
|
39
36
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
40
|
-
const mode = pathMode ??
|
|
37
|
+
const mode = pathMode ?? getMode(path.resolve(root, output.path))
|
|
41
38
|
|
|
42
39
|
if (mode === 'single') {
|
|
43
40
|
/**
|
|
@@ -85,7 +82,7 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
|
|
|
85
82
|
|
|
86
83
|
const oas = await swaggerPlugin.context.getOas()
|
|
87
84
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
88
|
-
const mode =
|
|
85
|
+
const mode = getMode(path.resolve(root, output.path))
|
|
89
86
|
|
|
90
87
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
91
88
|
oas,
|
|
@@ -101,7 +98,7 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
|
|
|
101
98
|
const files = await operationGenerator.build(...generators)
|
|
102
99
|
await this.addFile(...files)
|
|
103
100
|
|
|
104
|
-
const barrelFiles = await this.fileManager.
|
|
101
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
105
102
|
type: output.barrelType ?? 'named',
|
|
106
103
|
root,
|
|
107
104
|
output,
|