File tree Expand file tree Collapse file tree 6 files changed +39
-2
lines changed
Expand file tree Collapse file tree 6 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @redocly/cli " : patch
3+ ---
4+
5+ Fixed an issue where the ` mount-path ` option was not validated, leading to errors when used with an empty path or a path identical to the project path.
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ REDOCLY_AUTHORIZATION=<api-key> redocly push <files> --organization <organizatio
3737| files | [ string] | ** REQUIRED.** List of folders and/or files to upload. |
3838| --organization, -o | string | ** REQUIRED.** Organization slug. |
3939| --project, -p | string | ** REQUIRED.** Project slug. |
40- | --mount-path, -mp | string | ** REQUIRED.** The path where the files are mounted in the project. |
40+ | --mount-path, -mp | string | ** REQUIRED.** The path where the files are mounted in the project. Cannot be empty or identical to the project path. |
4141| --branch, -b | string | ** REQUIRED.** The branch files are pushed from. |
4242| --author, -a | string | ** REQUIRED.** The author of the push in the format: ` 'Author Name <author-email@example.com>' ` . |
4343| --message, -m | string | ** REQUIRED.** The commit message for the push. |
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ REDOCLY_AUTHORIZATION=<api-key> redocly push <files> --organization <organizatio
3333| files | [ string] | ** REQUIRED.** List of folders and/or files to upload. |
3434| --organization, -o | string | ** REQUIRED.** Organization slug. |
3535| --project, -p | string | ** REQUIRED.** Project slug. |
36- | --mount-path, -mp | string | ** REQUIRED.** The path where the files are mounted in the project. |
36+ | --mount-path, -mp | string | ** REQUIRED.** The path where the files are mounted in the project. Cannot be empty or identical to the project path. |
3737| --branch, -b | string | ** REQUIRED.** The branch files are pushed from. |
3838| --author, -a | string | ** REQUIRED.** The author of the push in the format: ` 'Author Name <author-email@example.com>' ` . |
3939| --message, -m | string | ** REQUIRED.** The commit message for the push. |
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import {
2828import { handleRespect , type RespectArgv } from './commands/respect/index.js' ;
2929import { version } from './utils/package.js' ;
3030import { validatePositiveNumber } from './utils/validate-positive-number.js' ;
31+ import { validateMountPath } from './utils/validate-mount-path.js' ;
3132import { validateMtlsCommandOption } from './commands/respect/mtls/validate-mtls-command-option.js' ;
3233
3334import type { Arguments } from 'yargs' ;
@@ -247,6 +248,7 @@ yargs(hideBin(process.argv))
247248 type : 'string' ,
248249 alias : 'mp' ,
249250 required : true ,
251+ coerce : validateMountPath ,
250252 } ,
251253 author : {
252254 description : 'Author of the commit.' ,
Original file line number Diff line number Diff line change 1+ import { describe , it , expect } from 'vitest' ;
2+ import { validateMountPath } from '../validate-mount-path.js' ;
3+
4+ describe ( 'validateMountPath' , ( ) => {
5+ it ( 'should accept valid mount path' , ( ) => {
6+ expect ( validateMountPath ( '/docs' ) ) . toBe ( '/docs' ) ;
7+ expect ( validateMountPath ( '/api/v1' ) ) . toBe ( '/api/v1' ) ;
8+ expect ( validateMountPath ( '/my-path' ) ) . toBe ( '/my-path' ) ;
9+ } ) ;
10+
11+ it ( 'should reject empty mount path' , ( ) => {
12+ expect ( ( ) => validateMountPath ( '' ) ) . toThrow (
13+ 'Mount path cannot be empty or root path. Please use --mount-path option with a valid path.'
14+ ) ;
15+ } ) ;
16+
17+ it ( 'should reject root path "/"' , ( ) => {
18+ expect ( ( ) => validateMountPath ( '/' ) ) . toThrow (
19+ 'Mount path cannot be empty or root path. Please use --mount-path option with a valid path.'
20+ ) ;
21+ } ) ;
22+ } ) ;
Original file line number Diff line number Diff line change 1+ export function validateMountPath ( value : string ) {
2+ if ( ! value || value === '/' ) {
3+ throw new Error (
4+ 'Mount path cannot be empty or root path. Please use --mount-path option with a valid path.'
5+ ) ;
6+ }
7+ return value ;
8+ }
You can’t perform that action at this time.
0 commit comments