From 6ba09fc6a29670b7a7f4fe8294981ce7b7fc61b7 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 17 Feb 2022 05:20:15 +0530 Subject: [PATCH] fix: add more negative decriptions --- bin/cli-flags.js | 4 + lib/options.json | 15 +- .../__snapshots__/basic.test.js.snap.webpack4 | 6 +- .../__snapshots__/basic.test.js.snap.webpack5 | 6 +- types/bin/cli-flags.d.ts | 23 +- types/lib/Server.d.ts | 223 +++++++++--------- 6 files changed, 153 insertions(+), 124 deletions(-) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index d025dbaadd..1f1376ef75 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -1030,6 +1030,7 @@ module.exports = { configs: [ { description: "Request for an SSL certificate.", + negatedDescription: "Does not request for an SSL certificate.", multiple: false, path: "server.options.requestCert", type: "boolean", @@ -1067,6 +1068,8 @@ module.exports = { multiple: false, description: "Allows to configure options for serving static files from directory (by default 'public' directory).", + negatedDescription: + "Disallows to configure options for serving static files from directory.", path: "static", }, ], @@ -1206,6 +1209,7 @@ module.exports = { { description: "Deprecated: please use '--web-socket-server-type' option.", + negatedDescription: "Disallows to set web socket server and options.", multiple: false, path: "webSocketServer", type: "enum", diff --git a/lib/options.json b/lib/options.json index aba5afbfb1..32b1c84ca1 100644 --- a/lib/options.json +++ b/lib/options.json @@ -743,7 +743,10 @@ }, "requestCert": { "type": "boolean", - "description": "Request for an SSL certificate." + "description": "Request for an SSL certificate.", + "cli": { + "negatedDescription": "Does not request for an SSL certificate." + } }, "ca": { "anyOf": [ @@ -928,7 +931,10 @@ } }, { - "type": "boolean" + "type": "boolean", + "cli": { + "negatedDescription": "Disallows to configure options for serving static files from directory." + } }, { "$ref": "#/definitions/StaticString" @@ -1094,7 +1100,10 @@ "WebSocketServerEnum": { "anyOf": [ { - "enum": [false] + "enum": [false], + "cli": { + "negatedDescription": "Disallows to set web socket server and options." + } }, { "$ref": "#/definitions/WebSocketServerType" diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 38040d7dfd..6b2237bbd7 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -132,10 +132,10 @@ Options: --server-options-pfx Path to an SSL pfx file or content of an SSL pfx file. --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. --server-options-request-cert Request for an SSL certificate. - --no-server-options-request-cert Negative 'server-options-request-cert' option. + --no-server-options-request-cert Does not request for an SSL certificate. --server-type Allows to set server and options (by default 'http'). --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory). - --no-static Negative 'static' option. + --no-static Disallows to configure options for serving static files from directory. --static-directory Directory for static contents. --static-public-path The static files will be available in the browser under this public path. --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path. @@ -147,7 +147,7 @@ Options: --watch-files Allows to configure list of globs/directories/files to watch for file changes. --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes. --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). - --no-web-socket-server Negative 'web-socket-server' option. + --no-web-socket-server Disallows to set web socket server and options. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). Global options: diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index 9e0f14ceed..3649bb9ee5 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -122,7 +122,7 @@ Options: --server-type Allows to set server and options (by default 'http'). --server-options-passphrase Passphrase for a pfx file. --server-options-request-cert Request for an SSL certificate. - --no-server-options-request-cert Negative 'server-options-request-cert' option. + --no-server-options-request-cert Does not request for an SSL certificate. --server-options-ca Path to an SSL CA certificate or content of an SSL CA certificate. --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. --server-options-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the \`server.options.ca\` option. @@ -136,7 +136,7 @@ Options: --server-options-pfx Path to an SSL pfx file or content of an SSL pfx file. --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory). - --no-static Negative 'static' option. + --no-static Disallows to configure options for serving static files from directory. --static-directory Directory for static contents. --static-public-path The static files will be available in the browser under this public path. --static-serve-index Tells dev server to use serveIndex middleware when enabled. @@ -148,7 +148,7 @@ Options: --watch-files Allows to configure list of globs/directories/files to watch for file changes. --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes. --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). - --no-web-socket-server Negative 'web-socket-server' option. + --no-web-socket-server Disallows to set web socket server and options. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). Global options: diff --git a/types/bin/cli-flags.d.ts b/types/bin/cli-flags.d.ts index fb075b0be7..fa98132496 100644 --- a/types/bin/cli-flags.d.ts +++ b/types/bin/cli-flags.d.ts @@ -781,6 +781,7 @@ declare const _exports: { "server-options-request-cert": { configs: { description: string; + negatedDescription: string; multiple: boolean; path: string; type: string; @@ -802,12 +803,21 @@ declare const _exports: { simpleType: string; }; static: { - configs: { - type: string; - multiple: boolean; - description: string; - path: string; - }[]; + configs: ( + | { + type: string; + multiple: boolean; + description: string; + path: string; + } + | { + type: string; + multiple: boolean; + description: string; + negatedDescription: string; + path: string; + } + )[]; description: string; simpleType: string; multiple: boolean; @@ -906,6 +916,7 @@ declare const _exports: { configs: ( | { description: string; + negatedDescription: string; multiple: boolean; path: string; type: string; diff --git a/types/lib/Server.d.ts b/types/lib/Server.d.ts index 14eab5bc66..50294755aa 100644 --- a/types/lib/Server.d.ts +++ b/types/lib/Server.d.ts @@ -418,84 +418,6 @@ declare class Server { configs: { type: string; multiple: boolean; - /** - * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem - */ - /** - * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray - */ - /** - * @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap - */ - /** - * @typedef {Object} OpenApp - * @property {string} [name] - * @property {string[]} [arguments] - */ - /** - * @typedef {Object} Open - * @property {string | string[] | OpenApp} [app] - * @property {string | string[]} [target] - */ - /** - * @typedef {Object} NormalizedOpen - * @property {string} target - * @property {import("open").Options} options - */ - /** - * @typedef {Object} WebSocketURL - * @property {string} [hostname] - * @property {string} [password] - * @property {string} [pathname] - * @property {number | string} [port] - * @property {string} [protocol] - * @property {string} [username] - */ - /** - * @typedef {Object} ClientConfiguration - * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] - * @property {boolean} [progress] - * @property {boolean | number} [reconnect] - * @property {"ws" | "sockjs" | string} [webSocketTransport] - * @property {string | WebSocketURL} [webSocketURL] - */ - /** - * @typedef {Array<{ key: string; value: string }> | Record} Headers - */ - /** - * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware - */ - /** - * @typedef {Object} Configuration - * @property {boolean | string} [ipc] - * @property {Host} [host] - * @property {Port} [port] - * @property {boolean | "only"} [hot] - * @property {boolean} [liveReload] - * @property {DevMiddlewareOptions} [devMiddleware] - * @property {boolean} [compress] - * @property {boolean} [magicHtml] - * @property {"auto" | "all" | string | string[]} [allowedHosts] - * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] - * @property {boolean} [setupExitSignals] - * @property {boolean | BonjourOptions} [bonjour] - * @property {string | string[] | WatchFiles | Array} [watchFiles] - * @property {boolean | string | Static | Array} [static] - * @property {boolean | ServerOptions} [https] - * @property {boolean} [http2] - * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server] - * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer] - * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy] - * @property {boolean | string | Open | Array} [open] - * @property {boolean} [setupExitSignals] - * @property {boolean | ClientConfiguration} [client] - * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] - * @property {(devServer: Server) => void} [onAfterSetupMiddleware] - * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] - * @property {(devServer: Server) => void} [onListening] - * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] - */ description: string; negatedDescription: string; path: string; @@ -511,6 +433,65 @@ declare class Server { multiple: boolean; description: string; negatedDescription: string; + /** + * @typedef {Object} NormalizedOpen + * @property {string} target + * @property {import("open").Options} options + */ + /** + * @typedef {Object} WebSocketURL + * @property {string} [hostname] + * @property {string} [password] + * @property {string} [pathname] + * @property {number | string} [port] + * @property {string} [protocol] + * @property {string} [username] + */ + /** + * @typedef {Object} ClientConfiguration + * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] + * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] + * @property {boolean} [progress] + * @property {boolean | number} [reconnect] + * @property {"ws" | "sockjs" | string} [webSocketTransport] + * @property {string | WebSocketURL} [webSocketURL] + */ + /** + * @typedef {Array<{ key: string; value: string }> | Record} Headers + */ + /** + * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware + */ + /** + * @typedef {Object} Configuration + * @property {boolean | string} [ipc] + * @property {Host} [host] + * @property {Port} [port] + * @property {boolean | "only"} [hot] + * @property {boolean} [liveReload] + * @property {DevMiddlewareOptions} [devMiddleware] + * @property {boolean} [compress] + * @property {boolean} [magicHtml] + * @property {"auto" | "all" | string | string[]} [allowedHosts] + * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] + * @property {boolean} [setupExitSignals] + * @property {boolean | BonjourOptions} [bonjour] + * @property {string | string[] | WatchFiles | Array} [watchFiles] + * @property {boolean | string | Static | Array} [static] + * @property {boolean | ServerOptions} [https] + * @property {boolean} [http2] + * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server] + * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer] + * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy] + * @property {boolean | string | Open | Array} [open] + * @property {boolean} [setupExitSignals] + * @property {boolean | ClientConfiguration} [client] + * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] + * @property {(devServer: Server) => void} [onAfterSetupMiddleware] + * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] + * @property {(devServer: Server) => void} [onListening] + * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] + */ path: string; } | { @@ -606,6 +587,9 @@ declare class Server { multiple: boolean; path: string; type: string; + /** + * @type {ReturnType} + * */ values: string[]; } | { @@ -613,9 +597,6 @@ declare class Server { multiple: boolean; path: string; type: string; - /** - * @type {FSWatcher[]} - */ } )[]; description: string; @@ -712,6 +693,10 @@ declare class Server { }; https: { configs: { + /** + * @param {Port} port + * @returns {Promise} + */ type: string; multiple: boolean; description: string; @@ -727,9 +712,6 @@ declare class Server { type: string; multiple: boolean; description: string; - /** - * @returns {string} - */ path: string; }[]; description: string; @@ -765,7 +747,7 @@ declare class Server { path: string; type: string; }[]; - description: string; + /** @type {WebSocketURL} */ description: string; multiple: boolean; simpleType: string; }; @@ -778,7 +760,7 @@ declare class Server { }[]; description: string; simpleType: string; - multiple: boolean /** @type {ServerConfiguration} */; + /** @type {ServerConfiguration} */ multiple: boolean; }; "https-cert-reset": { configs: { @@ -827,7 +809,7 @@ declare class Server { "https-key-reset": { configs: { description: string; - multiple: boolean; + /** @type {string} */ multiple: boolean; path: string; type: string; }[]; @@ -891,8 +873,9 @@ declare class Server { | { type: string; values: boolean[]; + /** @type {Object} */ multiple: boolean; - /** @type {Object} */ description: string; + description: string; path: string; } )[]; @@ -1176,6 +1159,7 @@ declare class Server { "server-options-request-cert": { configs: { description: string; + negatedDescription: string; multiple: boolean; path: string; type: string; @@ -1190,22 +1174,31 @@ declare class Server { multiple: boolean; path: string; type: string; - /** @type {ServerOptions} */ values: string[]; + values: string[]; }[]; description: string; multiple: boolean; - simpleType: string; + /** @type {Array} */ simpleType: string; }; static: { - configs: { - type: string; - /** @type {Array} */ multiple: boolean; - description: string; - path: string /** @type {ServerOptions} */; - }[]; + configs: ( + | { + type: string; + multiple: boolean; + description: string; + path: string; + } + | { + type: string; + multiple: boolean; + description: string; + negatedDescription: string; + path: string; + } + )[]; description: string; simpleType: string; - multiple: boolean; + /** @type {ServerOptions} */ multiple: boolean; }; "static-directory": { configs: { @@ -1215,10 +1208,6 @@ declare class Server { path: string; }[]; description: string; - /** - * @param {string | Buffer | undefined} item - * @returns {string | Buffer | undefined} - */ simpleType: string; multiple: boolean; }; @@ -1231,9 +1220,8 @@ declare class Server { }[]; description: string; simpleType: string; - multiple: boolean /** @type {any} */; + multiple: boolean; }; - /** @type {any} */ "static-public-path-reset": { configs: { type: string; @@ -1306,6 +1294,7 @@ declare class Server { configs: ( | { description: string; + negatedDescription: string; multiple: boolean; path: string; type: string; @@ -1342,13 +1331,13 @@ declare class Server { description: string; multiple: boolean; path: string; - type: string; + type: string /** @type {ServerOptions} */; } )[]; description: string; simpleType: string; - multiple: boolean; - }; + multiple: boolean /** @type {ServerOptions} */; + } /** @type {ServerOptions} */; }; readonly processArguments: ( args: Record, @@ -2526,6 +2515,9 @@ declare class Server { requestCert: { type: string; description: string; + cli: { + negatedDescription: string; + }; }; ca: { anyOf: ( @@ -2644,6 +2636,7 @@ declare class Server { instanceof?: undefined; } | { + /** @type {NormalizedStatic} */ instanceof: string; type?: undefined; items?: undefined; @@ -2751,10 +2744,14 @@ declare class Server { $ref: string; }[]; }; + cli?: undefined /** @typedef {import("express").Request} Request */; $ref?: undefined; } | { type: string; + cli: { + negatedDescription: string; + }; items?: undefined; $ref?: undefined; } @@ -2762,6 +2759,7 @@ declare class Server { $ref: string; type?: undefined; items?: undefined; + cli?: undefined /** @typedef {import("express").Request} Request */; } )[]; description: string; @@ -2915,11 +2913,16 @@ declare class Server { anyOf: ( | { enum: boolean[]; + /** @type {ServerOptions} */ + cli: { + negatedDescription: string; + }; $ref?: undefined; } | { $ref: string; enum?: undefined; + cli?: undefined /** @typedef {import("express").Request} Request */; } )[]; cli: { @@ -2934,7 +2937,7 @@ declare class Server { properties: { type: { anyOf: { - $ref: string; + $ref: string /** @type {ServerOptions} */; }[]; }; options: { @@ -2942,7 +2945,7 @@ declare class Server { additionalProperties: boolean; cli: { exclude: boolean; - } /** @type {ServerOptions} */; + }; }; }; additionalProperties: boolean; @@ -2963,6 +2966,7 @@ declare class Server { client: { $ref: string; }; + /** @type {any} */ compress: { $ref: string; }; @@ -2973,8 +2977,9 @@ declare class Server { $ref: string; }; historyApiFallback: { - $ref: string; + $ref: string /** @type {ServerOptions} */; }; + /** @type {ServerOptions} */ host: { $ref: string; };