@redocly/cli 1.20.0 → 1.21.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/CHANGELOG.md +17 -0
- package/lib/cms/commands/push.d.ts +2 -2
- package/lib/commands/build-docs/types.d.ts +2 -2
- package/lib/commands/bundle.d.ts +2 -3
- package/lib/commands/eject.d.ts +9 -0
- package/lib/commands/eject.js +18 -0
- package/lib/commands/join.d.ts +2 -4
- package/lib/commands/lint.d.ts +3 -5
- package/lib/commands/preview-docs/index.d.ts +2 -2
- package/lib/commands/preview-project/index.js +4 -4
- package/lib/commands/preview-project/types.d.ts +3 -3
- package/lib/commands/push.d.ts +2 -2
- package/lib/commands/split/index.d.ts +2 -2
- package/lib/commands/stats.d.ts +3 -3
- package/lib/commands/translations.d.ts +7 -0
- package/lib/commands/translations.js +10 -0
- package/lib/index.js +73 -3
- package/lib/types.d.ts +5 -3
- package/package.json +2 -2
- package/src/cms/commands/push.ts +2 -2
- package/src/commands/build-docs/types.ts +3 -2
- package/src/commands/bundle.ts +3 -3
- package/src/commands/eject.ts +29 -0
- package/src/commands/join.ts +3 -10
- package/src/commands/lint.ts +4 -5
- package/src/commands/preview-docs/index.ts +3 -2
- package/src/commands/preview-project/index.ts +4 -4
- package/src/commands/preview-project/types.ts +3 -3
- package/src/commands/push.ts +2 -2
- package/src/commands/split/index.ts +2 -2
- package/src/commands/stats.ts +3 -3
- package/src/commands/translations.ts +19 -0
- package/src/index.ts +96 -3
- package/src/types.ts +7 -4
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @redocly/cli
|
|
2
2
|
|
|
3
|
+
## 1.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added the `eject` and `translate` commands for use with the new Reunite-hosted product family.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated @redocly/openapi-core to v1.21.0.
|
|
12
|
+
|
|
13
|
+
## 1.20.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Get more helpful error messages when there's a problem importing a plugin.
|
|
18
|
+
- Updated @redocly/openapi-core to v1.20.1.
|
|
19
|
+
|
|
3
20
|
## 1.20.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OutputFormat } from '@redocly/openapi-core';
|
|
2
2
|
import type { CommandArgs } from '../../wrapper';
|
|
3
|
+
import type { VerifyConfigOptions } from '../../types';
|
|
3
4
|
export type PushOptions = {
|
|
4
5
|
apis?: string[];
|
|
5
6
|
organization?: string;
|
|
@@ -16,13 +17,12 @@ export type PushOptions = {
|
|
|
16
17
|
files: string[];
|
|
17
18
|
'default-branch': string;
|
|
18
19
|
domain?: string;
|
|
19
|
-
config?: string;
|
|
20
20
|
'wait-for-deployment'?: boolean;
|
|
21
21
|
'max-execution-time': number;
|
|
22
22
|
'continue-on-deploy-failures'?: boolean;
|
|
23
23
|
verbose?: boolean;
|
|
24
24
|
format?: Extract<OutputFormat, 'stylish'>;
|
|
25
|
-
};
|
|
25
|
+
} & VerifyConfigOptions;
|
|
26
26
|
export declare function handlePush({ argv, config, version, }: CommandArgs<PushOptions>): Promise<{
|
|
27
27
|
pushId: string;
|
|
28
28
|
} | void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VerifyConfigOptions } from '../../types';
|
|
1
2
|
export type BuildDocsOptions = {
|
|
2
3
|
watch?: boolean;
|
|
3
4
|
output?: string;
|
|
@@ -19,5 +20,4 @@ export type BuildDocsArgv = {
|
|
|
19
20
|
theme: {
|
|
20
21
|
openapi: string | Record<string, unknown>;
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
};
|
|
23
|
+
} & VerifyConfigOptions;
|
package/lib/commands/bundle.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { OutputExtensions, Skips } from '../types';
|
|
1
|
+
import type { OutputExtensions, Skips, VerifyConfigOptions } from '../types';
|
|
2
2
|
import type { CommandArgs } from '../wrapper';
|
|
3
3
|
export type BundleOptions = {
|
|
4
4
|
apis?: string[];
|
|
5
5
|
extends?: string[];
|
|
6
|
-
config?: string;
|
|
7
6
|
output?: string;
|
|
8
7
|
ext: OutputExtensions;
|
|
9
8
|
dereferenced?: boolean;
|
|
@@ -11,5 +10,5 @@ export type BundleOptions = {
|
|
|
11
10
|
metafile?: string;
|
|
12
11
|
'remove-unused-components'?: boolean;
|
|
13
12
|
'keep-url-references'?: boolean;
|
|
14
|
-
} & Skips;
|
|
13
|
+
} & Skips & VerifyConfigOptions;
|
|
15
14
|
export declare function handleBundle({ argv, config, version, collectSpecData, }: CommandArgs<BundleOptions>): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandArgs } from '../wrapper';
|
|
2
|
+
import type { VerifyConfigOptions } from '../types';
|
|
3
|
+
export type EjectOptions = {
|
|
4
|
+
type: 'component';
|
|
5
|
+
path: string;
|
|
6
|
+
'project-dir'?: string;
|
|
7
|
+
force: boolean;
|
|
8
|
+
} & VerifyConfigOptions;
|
|
9
|
+
export declare const handleEject: ({ argv }: CommandArgs<EjectOptions>) => Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleEject = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const handleEject = async ({ argv }) => {
|
|
6
|
+
process.stdout.write(`\nLaunching eject using NPX.\n\n`);
|
|
7
|
+
const npxExecutableName = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
8
|
+
(0, child_process_1.spawn)(npxExecutableName, [
|
|
9
|
+
'-y',
|
|
10
|
+
'@redocly/realm',
|
|
11
|
+
'eject',
|
|
12
|
+
`${argv.type}`,
|
|
13
|
+
`${argv.path}`,
|
|
14
|
+
`-d=${argv['project-dir']}`,
|
|
15
|
+
argv.force ? `--force=${argv.force}` : '',
|
|
16
|
+
], { stdio: 'inherit' });
|
|
17
|
+
};
|
|
18
|
+
exports.handleEject = handleEject;
|
package/lib/commands/join.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RuleSeverity } from '@redocly/openapi-core';
|
|
2
1
|
import type { CommandArgs } from '../wrapper';
|
|
2
|
+
import type { VerifyConfigOptions } from '../types';
|
|
3
3
|
export type JoinOptions = {
|
|
4
4
|
apis: string[];
|
|
5
5
|
'prefix-tags-with-info-prop'?: string;
|
|
@@ -7,7 +7,5 @@ export type JoinOptions = {
|
|
|
7
7
|
'prefix-components-with-info-prop'?: string;
|
|
8
8
|
'without-x-tag-groups'?: boolean;
|
|
9
9
|
output?: string;
|
|
10
|
-
|
|
11
|
-
'lint-config'?: RuleSeverity;
|
|
12
|
-
};
|
|
10
|
+
} & VerifyConfigOptions;
|
|
13
11
|
export declare function handleJoin({ argv, config, version: packageVersion, }: CommandArgs<JoinOptions>): Promise<void>;
|
package/lib/commands/lint.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import type { OutputFormat
|
|
1
|
+
import type { OutputFormat } from '@redocly/openapi-core';
|
|
2
2
|
import type { RawConfigProcessor } from '@redocly/openapi-core/lib/config';
|
|
3
|
-
import type { CommandOptions, Skips } from '../types';
|
|
3
|
+
import type { CommandOptions, Skips, VerifyConfigOptions } from '../types';
|
|
4
4
|
import type { CommandArgs } from '../wrapper';
|
|
5
5
|
export type LintOptions = {
|
|
6
6
|
apis?: string[];
|
|
7
7
|
'max-problems': number;
|
|
8
8
|
extends?: string[];
|
|
9
|
-
config?: string;
|
|
10
9
|
format: OutputFormat;
|
|
11
10
|
'generate-ignore-file'?: boolean;
|
|
12
|
-
|
|
13
|
-
} & Omit<Skips, 'skip-decorator'>;
|
|
11
|
+
} & Omit<Skips, 'skip-decorator'> & VerifyConfigOptions;
|
|
14
12
|
export declare function handleLint({ argv, config, version, collectSpecData, }: CommandArgs<LintOptions>): Promise<void>;
|
|
15
13
|
export declare function lintConfigCallback(argv: CommandOptions & Record<string, undefined>, version: string): RawConfigProcessor | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Skips } from '../../types';
|
|
1
|
+
import type { Skips, VerifyConfigOptions } from '../../types';
|
|
2
2
|
import type { CommandArgs } from '../../wrapper';
|
|
3
3
|
export type PreviewDocsOptions = {
|
|
4
4
|
port: number;
|
|
@@ -7,6 +7,6 @@ export type PreviewDocsOptions = {
|
|
|
7
7
|
config?: string;
|
|
8
8
|
api?: string;
|
|
9
9
|
force?: boolean;
|
|
10
|
-
} & Omit<Skips, 'skip-rule'
|
|
10
|
+
} & Omit<Skips, 'skip-rule'> & VerifyConfigOptions;
|
|
11
11
|
export declare function previewDocs({ argv, config: configFromFile, }: CommandArgs<PreviewDocsOptions>): Promise<void>;
|
|
12
12
|
export declare function debounce(func: Function, wait: number, immediate?: boolean): (...args: any[]) => void;
|
|
@@ -7,15 +7,15 @@ const child_process_1 = require("child_process");
|
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
8
|
const previewProject = async ({ argv }) => {
|
|
9
9
|
const { plan, port } = argv;
|
|
10
|
-
const projectDir = argv['
|
|
10
|
+
const projectDir = argv['project-dir'];
|
|
11
11
|
const product = argv.product || tryGetProductFromPackageJson(projectDir);
|
|
12
12
|
if (!isValidProduct(product)) {
|
|
13
|
-
process.stderr.write(`Invalid product ${product}
|
|
14
|
-
throw new Error(`Project preview launch failed
|
|
13
|
+
process.stderr.write(`Invalid product ${product}.`);
|
|
14
|
+
throw new Error(`Project preview launch failed.`);
|
|
15
15
|
}
|
|
16
16
|
const productName = constants_1.PRODUCT_NAMES[product];
|
|
17
17
|
const packageName = constants_1.PRODUCT_PACKAGES[product];
|
|
18
|
-
process.stdout.write(`\nLaunching preview of ${productName} ${plan} using NPX
|
|
18
|
+
process.stdout.write(`\nLaunching preview of ${productName} ${plan} using NPX.\n\n`);
|
|
19
19
|
const npxExecutableName = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
20
20
|
(0, child_process_1.spawn)(npxExecutableName, ['-y', packageName, 'develop', `--plan=${plan}`, `--port=${port || 4000}`], {
|
|
21
21
|
stdio: 'inherit',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VerifyConfigOptions } from '../../types';
|
|
1
2
|
import type { PRODUCT_PACKAGES, PRODUCT_PLANS } from './constants';
|
|
2
3
|
export type Product = keyof typeof PRODUCT_PACKAGES;
|
|
3
4
|
export type ProductPlan = typeof PRODUCT_PLANS[number];
|
|
@@ -5,6 +6,5 @@ export type PreviewProjectOptions = {
|
|
|
5
6
|
product?: Product | string;
|
|
6
7
|
plan: ProductPlan | string;
|
|
7
8
|
port?: number;
|
|
8
|
-
'
|
|
9
|
-
|
|
10
|
-
};
|
|
9
|
+
'project-dir': string;
|
|
10
|
+
} & VerifyConfigOptions;
|
package/lib/commands/push.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { handlePush as handleCMSPush } from '../cms/commands/push';
|
|
2
2
|
import type { Config, Region } from '@redocly/openapi-core';
|
|
3
3
|
import type { CommandArgs } from '../wrapper';
|
|
4
|
+
import type { VerifyConfigOptions } from '../types';
|
|
4
5
|
export declare const DESTINATION_REGEX: RegExp;
|
|
5
6
|
export type PushOptions = {
|
|
6
7
|
api?: string;
|
|
@@ -14,8 +15,7 @@ export type PushOptions = {
|
|
|
14
15
|
public?: boolean;
|
|
15
16
|
files?: string[];
|
|
16
17
|
organization?: string;
|
|
17
|
-
|
|
18
|
-
};
|
|
18
|
+
} & VerifyConfigOptions;
|
|
19
19
|
export declare function commonPushHandler({ project, 'mount-path': mountPath, }: {
|
|
20
20
|
project?: string;
|
|
21
21
|
'mount-path'?: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Oas3PathItem, Referenced } from './types';
|
|
2
2
|
import type { CommandArgs } from '../../wrapper';
|
|
3
|
+
import type { VerifyConfigOptions } from '../../types';
|
|
3
4
|
export type SplitOptions = {
|
|
4
5
|
api: string;
|
|
5
6
|
outDir: string;
|
|
6
7
|
separator: string;
|
|
7
|
-
|
|
8
|
-
};
|
|
8
|
+
} & VerifyConfigOptions;
|
|
9
9
|
export declare function handleSplit({ argv, collectSpecData }: CommandArgs<SplitOptions>): Promise<void>;
|
|
10
10
|
export declare function startsWithComponents(node: string): boolean;
|
|
11
11
|
export declare function crawl(object: unknown, visitor: (node: Record<string, unknown>) => void): void;
|
package/lib/commands/stats.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { CommandArgs } from '../wrapper';
|
|
2
1
|
import type { OutputFormat } from '@redocly/openapi-core';
|
|
2
|
+
import type { CommandArgs } from '../wrapper';
|
|
3
|
+
import type { VerifyConfigOptions } from '../types';
|
|
3
4
|
export type StatsOptions = {
|
|
4
5
|
api?: string;
|
|
5
6
|
format: OutputFormat;
|
|
6
|
-
|
|
7
|
-
};
|
|
7
|
+
} & VerifyConfigOptions;
|
|
8
8
|
export declare function handleStats({ argv, config, collectSpecData }: CommandArgs<StatsOptions>): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandArgs } from '../wrapper';
|
|
2
|
+
import type { VerifyConfigOptions } from '../types';
|
|
3
|
+
export type TranslationsOptions = {
|
|
4
|
+
locale: string;
|
|
5
|
+
'project-dir'?: string;
|
|
6
|
+
} & VerifyConfigOptions;
|
|
7
|
+
export declare const handleTranslations: ({ argv }: CommandArgs<TranslationsOptions>) => Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleTranslations = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const handleTranslations = async ({ argv }) => {
|
|
6
|
+
process.stdout.write(`\nLaunching translate using NPX.\n\n`);
|
|
7
|
+
const npxExecutableName = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
8
|
+
(0, child_process_1.spawn)(npxExecutableName, ['-y', '@redocly/realm', 'translate', argv.locale, `-d=${argv['project-dir']}`], { stdio: 'inherit' });
|
|
9
|
+
};
|
|
10
|
+
exports.handleTranslations = handleTranslations;
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,8 @@ const build_docs_1 = require("./commands/build-docs");
|
|
|
18
18
|
const update_version_notifier_1 = require("./utils/update-version-notifier");
|
|
19
19
|
const wrapper_1 = require("./wrapper");
|
|
20
20
|
const preview_project_1 = require("./commands/preview-project");
|
|
21
|
+
const translations_1 = require("./commands/translations");
|
|
22
|
+
const eject_1 = require("./commands/eject");
|
|
21
23
|
const constants_1 = require("./commands/preview-project/constants");
|
|
22
24
|
const push_1 = require("./commands/push");
|
|
23
25
|
if (!('replaceAll' in String.prototype)) {
|
|
@@ -182,6 +184,11 @@ yargs
|
|
|
182
184
|
type: 'boolean',
|
|
183
185
|
default: false,
|
|
184
186
|
},
|
|
187
|
+
'lint-config': {
|
|
188
|
+
description: 'Severity level for config file linting.',
|
|
189
|
+
choices: ['warn', 'error', 'off'],
|
|
190
|
+
default: 'warn',
|
|
191
|
+
},
|
|
185
192
|
}), (argv) => {
|
|
186
193
|
process.env.REDOCLY_CLI_COMMAND = 'push-status';
|
|
187
194
|
(0, wrapper_1.commandWrapper)(push_status_1.handlePushStatus)(argv);
|
|
@@ -545,17 +552,26 @@ yargs
|
|
|
545
552
|
default: 'enterprise',
|
|
546
553
|
},
|
|
547
554
|
port: {
|
|
555
|
+
alias: 'p',
|
|
548
556
|
type: 'number',
|
|
549
557
|
description: 'Preview port.',
|
|
550
558
|
default: 4000,
|
|
551
559
|
},
|
|
552
|
-
'
|
|
553
|
-
alias: 'd',
|
|
560
|
+
'project-dir': {
|
|
561
|
+
alias: ['d', 'source-dir'],
|
|
554
562
|
type: 'string',
|
|
555
|
-
description: '
|
|
563
|
+
description: 'Specifies the project content directory. The default value is the directory where the command is executed.',
|
|
556
564
|
default: '.',
|
|
557
565
|
},
|
|
566
|
+
'lint-config': {
|
|
567
|
+
description: 'Severity level for config file linting.',
|
|
568
|
+
choices: ['warn', 'error', 'off'],
|
|
569
|
+
default: 'warn',
|
|
570
|
+
},
|
|
558
571
|
}), (argv) => {
|
|
572
|
+
if (process.argv.some((arg) => arg.startsWith('--source-dir'))) {
|
|
573
|
+
process.stderr.write(colors.red('Option --source-dir is deprecated and will be removed soon. Use --project-dir instead.\n'));
|
|
574
|
+
}
|
|
559
575
|
(0, wrapper_1.commandWrapper)(preview_project_1.previewProject)(argv);
|
|
560
576
|
})
|
|
561
577
|
.command('preview-docs [api]', 'Preview API reference docs for an API description.', (yargs) => yargs.positional('api', { type: 'string' }).options({
|
|
@@ -649,6 +665,60 @@ yargs
|
|
|
649
665
|
}), async (argv) => {
|
|
650
666
|
process.env.REDOCLY_CLI_COMMAND = 'build-docs';
|
|
651
667
|
(0, wrapper_1.commandWrapper)(build_docs_1.handlerBuildCommand)(argv);
|
|
668
|
+
})
|
|
669
|
+
.command('translate <locale>', 'Creates or updates translations.yaml files and fills them with missing built-in translations and translations from the redocly.yaml and sidebars.yaml files.', (yargs) => yargs
|
|
670
|
+
.positional('locale', {
|
|
671
|
+
description: 'Locale code to generate translations for, or `all` for all current project locales.',
|
|
672
|
+
type: 'string',
|
|
673
|
+
demandOption: true,
|
|
674
|
+
})
|
|
675
|
+
.options({
|
|
676
|
+
'project-dir': {
|
|
677
|
+
alias: 'd',
|
|
678
|
+
type: 'string',
|
|
679
|
+
description: 'Specifies the project content directory. The default value is the directory where the command is executed.',
|
|
680
|
+
default: '.',
|
|
681
|
+
},
|
|
682
|
+
'lint-config': {
|
|
683
|
+
description: 'Severity level for config file linting.',
|
|
684
|
+
choices: ['warn', 'error', 'off'],
|
|
685
|
+
default: 'warn',
|
|
686
|
+
},
|
|
687
|
+
}), (argv) => {
|
|
688
|
+
process.env.REDOCLY_CLI_COMMAND = 'translate';
|
|
689
|
+
(0, wrapper_1.commandWrapper)(translations_1.handleTranslations)(argv);
|
|
690
|
+
})
|
|
691
|
+
.command('eject <type> <path>', 'Helper function to eject project elements for customization.', (yargs) => yargs
|
|
692
|
+
.positional('type', {
|
|
693
|
+
description: 'Specifies what type of project element to eject. Currently, it could be only `component`.',
|
|
694
|
+
demandOption: true,
|
|
695
|
+
choices: ['component'],
|
|
696
|
+
})
|
|
697
|
+
.positional('path', {
|
|
698
|
+
description: 'Filepath to a component or filepath with glob pattern.',
|
|
699
|
+
type: 'string',
|
|
700
|
+
demandOption: true,
|
|
701
|
+
})
|
|
702
|
+
.options({
|
|
703
|
+
'project-dir': {
|
|
704
|
+
alias: 'd',
|
|
705
|
+
type: 'string',
|
|
706
|
+
description: 'Specifies the project content directory. The default value is the directory where the command is executed.',
|
|
707
|
+
default: '.',
|
|
708
|
+
},
|
|
709
|
+
force: {
|
|
710
|
+
alias: 'f',
|
|
711
|
+
type: 'boolean',
|
|
712
|
+
description: 'Skips the "overwrite existing" confirmation when ejecting a component that is already ejected in the destination.',
|
|
713
|
+
},
|
|
714
|
+
'lint-config': {
|
|
715
|
+
description: 'Severity level for config file linting.',
|
|
716
|
+
choices: ['warn', 'error', 'off'],
|
|
717
|
+
default: 'warn',
|
|
718
|
+
},
|
|
719
|
+
}), (argv) => {
|
|
720
|
+
process.env.REDOCLY_CLI_COMMAND = 'eject';
|
|
721
|
+
(0, wrapper_1.commandWrapper)(eject_1.handleEject)(argv);
|
|
652
722
|
})
|
|
653
723
|
.completion('completion', 'Generate autocomplete script for `redocly` command.')
|
|
654
724
|
.demandCommand(1)
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundleOutputFormat, Region, Config } from '@redocly/openapi-core';
|
|
1
|
+
import type { BundleOutputFormat, Region, Config, RuleSeverity } from '@redocly/openapi-core';
|
|
2
2
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
3
3
|
import type { LintOptions } from './commands/lint';
|
|
4
4
|
import type { BundleOptions } from './commands/bundle';
|
|
@@ -12,6 +12,8 @@ import type { BuildDocsArgv } from './commands/build-docs/types';
|
|
|
12
12
|
import type { PushOptions as CMSPushOptions } from './cms/commands/push';
|
|
13
13
|
import type { PushStatusOptions } from './cms/commands/push-status';
|
|
14
14
|
import type { PreviewProjectOptions } from './commands/preview-project/types';
|
|
15
|
+
import type { TranslationsOptions } from './commands/translations';
|
|
16
|
+
import type { EjectOptions } from './commands/eject';
|
|
15
17
|
export type Totals = {
|
|
16
18
|
errors: number;
|
|
17
19
|
warnings: number;
|
|
@@ -24,10 +26,10 @@ export type Entrypoint = {
|
|
|
24
26
|
export declare const outputExtensions: ReadonlyArray<BundleOutputFormat>;
|
|
25
27
|
export type OutputExtensions = 'json' | 'yaml' | 'yml' | undefined;
|
|
26
28
|
export declare const regionChoices: ReadonlyArray<Region>;
|
|
27
|
-
export type CommandOptions = StatsOptions | SplitOptions | JoinOptions | PushOptions | CMSPushOptions | LintOptions | BundleOptions | LoginOptions | PreviewDocsOptions | BuildDocsArgv | PushStatusOptions |
|
|
29
|
+
export type CommandOptions = StatsOptions | SplitOptions | JoinOptions | PushOptions | CMSPushOptions | LintOptions | BundleOptions | LoginOptions | PreviewDocsOptions | BuildDocsArgv | PushStatusOptions | PreviewProjectOptions | TranslationsOptions | EjectOptions;
|
|
28
30
|
export type VerifyConfigOptions = {
|
|
29
31
|
config?: string;
|
|
30
|
-
'lint-config'?:
|
|
32
|
+
'lint-config'?: RuleSeverity;
|
|
31
33
|
};
|
|
32
34
|
export type Skips = {
|
|
33
35
|
'skip-rule'?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"Roman Hotsiy <roman@redoc.ly> (https://redoc.ly/)"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@redocly/openapi-core": "1.
|
|
39
|
+
"@redocly/openapi-core": "1.21.0",
|
|
40
40
|
"abort-controller": "^3.0.0",
|
|
41
41
|
"chokidar": "^3.5.1",
|
|
42
42
|
"colorette": "^1.2.0",
|
package/src/cms/commands/push.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { ReuniteApiClient, getDomain, getApiKeys } from '../api';
|
|
|
13
13
|
|
|
14
14
|
import type { OutputFormat } from '@redocly/openapi-core';
|
|
15
15
|
import type { CommandArgs } from '../../wrapper';
|
|
16
|
+
import type { VerifyConfigOptions } from '../../types';
|
|
16
17
|
|
|
17
18
|
export type PushOptions = {
|
|
18
19
|
apis?: string[];
|
|
@@ -33,13 +34,12 @@ export type PushOptions = {
|
|
|
33
34
|
|
|
34
35
|
'default-branch': string;
|
|
35
36
|
domain?: string;
|
|
36
|
-
config?: string;
|
|
37
37
|
'wait-for-deployment'?: boolean;
|
|
38
38
|
'max-execution-time': number;
|
|
39
39
|
'continue-on-deploy-failures'?: boolean;
|
|
40
40
|
verbose?: boolean;
|
|
41
41
|
format?: Extract<OutputFormat, 'stylish'>;
|
|
42
|
-
};
|
|
42
|
+
} & VerifyConfigOptions;
|
|
43
43
|
|
|
44
44
|
type FileToUpload = { name: string; path: string };
|
|
45
45
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { VerifyConfigOptions } from '../../types';
|
|
2
|
+
|
|
1
3
|
export type BuildDocsOptions = {
|
|
2
4
|
watch?: boolean;
|
|
3
5
|
output?: string;
|
|
@@ -20,5 +22,4 @@ export type BuildDocsArgv = {
|
|
|
20
22
|
theme: {
|
|
21
23
|
openapi: string | Record<string, unknown>;
|
|
22
24
|
};
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
+
} & VerifyConfigOptions;
|
package/src/commands/bundle.ts
CHANGED
|
@@ -14,13 +14,12 @@ import {
|
|
|
14
14
|
checkForDeprecatedOptions,
|
|
15
15
|
} from '../utils/miscellaneous';
|
|
16
16
|
|
|
17
|
-
import type { OutputExtensions, Skips, Totals } from '../types';
|
|
17
|
+
import type { OutputExtensions, Skips, Totals, VerifyConfigOptions } from '../types';
|
|
18
18
|
import type { CommandArgs } from '../wrapper';
|
|
19
19
|
|
|
20
20
|
export type BundleOptions = {
|
|
21
21
|
apis?: string[];
|
|
22
22
|
extends?: string[];
|
|
23
|
-
config?: string;
|
|
24
23
|
output?: string;
|
|
25
24
|
ext: OutputExtensions;
|
|
26
25
|
dereferenced?: boolean;
|
|
@@ -28,7 +27,8 @@ export type BundleOptions = {
|
|
|
28
27
|
metafile?: string;
|
|
29
28
|
'remove-unused-components'?: boolean;
|
|
30
29
|
'keep-url-references'?: boolean;
|
|
31
|
-
} & Skips
|
|
30
|
+
} & Skips &
|
|
31
|
+
VerifyConfigOptions;
|
|
32
32
|
|
|
33
33
|
export async function handleBundle({
|
|
34
34
|
argv,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
|
|
3
|
+
import type { CommandArgs } from '../wrapper';
|
|
4
|
+
import type { VerifyConfigOptions } from '../types';
|
|
5
|
+
|
|
6
|
+
export type EjectOptions = {
|
|
7
|
+
type: 'component';
|
|
8
|
+
path: string;
|
|
9
|
+
'project-dir'?: string;
|
|
10
|
+
force: boolean;
|
|
11
|
+
} & VerifyConfigOptions;
|
|
12
|
+
|
|
13
|
+
export const handleEject = async ({ argv }: CommandArgs<EjectOptions>) => {
|
|
14
|
+
process.stdout.write(`\nLaunching eject using NPX.\n\n`);
|
|
15
|
+
const npxExecutableName = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
16
|
+
spawn(
|
|
17
|
+
npxExecutableName,
|
|
18
|
+
[
|
|
19
|
+
'-y',
|
|
20
|
+
'@redocly/realm',
|
|
21
|
+
'eject',
|
|
22
|
+
`${argv.type}`,
|
|
23
|
+
`${argv.path}`,
|
|
24
|
+
`-d=${argv['project-dir']}`,
|
|
25
|
+
argv.force ? `--force=${argv.force}` : '',
|
|
26
|
+
],
|
|
27
|
+
{ stdio: 'inherit' }
|
|
28
|
+
);
|
|
29
|
+
};
|
package/src/commands/join.ts
CHANGED
|
@@ -23,13 +23,7 @@ import { isObject, isString, keysOf } from '../utils/js-utils';
|
|
|
23
23
|
import { COMPONENTS, OPENAPI3_METHOD } from './split/types';
|
|
24
24
|
import { crawl, startsWithComponents } from './split';
|
|
25
25
|
|
|
26
|
-
import type {
|
|
27
|
-
Oas3Definition,
|
|
28
|
-
Document,
|
|
29
|
-
Oas3Tag,
|
|
30
|
-
Referenced,
|
|
31
|
-
RuleSeverity,
|
|
32
|
-
} from '@redocly/openapi-core';
|
|
26
|
+
import type { Oas3Definition, Document, Oas3Tag, Referenced } from '@redocly/openapi-core';
|
|
33
27
|
import type { BundleResult } from '@redocly/openapi-core/lib/bundle';
|
|
34
28
|
import type {
|
|
35
29
|
Oas3Parameter,
|
|
@@ -38,6 +32,7 @@ import type {
|
|
|
38
32
|
Oas3_1Definition,
|
|
39
33
|
} from '@redocly/openapi-core/lib/typings/openapi';
|
|
40
34
|
import type { CommandArgs } from '../wrapper';
|
|
35
|
+
import type { VerifyConfigOptions } from '../types';
|
|
41
36
|
|
|
42
37
|
const Tags = 'tags';
|
|
43
38
|
const xTagGroups = 'x-tagGroups';
|
|
@@ -60,9 +55,7 @@ export type JoinOptions = {
|
|
|
60
55
|
'prefix-components-with-info-prop'?: string;
|
|
61
56
|
'without-x-tag-groups'?: boolean;
|
|
62
57
|
output?: string;
|
|
63
|
-
|
|
64
|
-
'lint-config'?: RuleSeverity;
|
|
65
|
-
};
|
|
58
|
+
} & VerifyConfigOptions;
|
|
66
59
|
|
|
67
60
|
export async function handleJoin({
|
|
68
61
|
argv,
|
package/src/commands/lint.ts
CHANGED
|
@@ -23,20 +23,19 @@ import {
|
|
|
23
23
|
import { getCommandNameFromArgs } from '../utils/getCommandNameFromArgs';
|
|
24
24
|
|
|
25
25
|
import type { Arguments } from 'yargs';
|
|
26
|
-
import type { OutputFormat, ProblemSeverity
|
|
26
|
+
import type { OutputFormat, ProblemSeverity } from '@redocly/openapi-core';
|
|
27
27
|
import type { RawConfigProcessor } from '@redocly/openapi-core/lib/config';
|
|
28
|
-
import type { CommandOptions, Skips, Totals } from '../types';
|
|
28
|
+
import type { CommandOptions, Skips, Totals, VerifyConfigOptions } from '../types';
|
|
29
29
|
import type { CommandArgs } from '../wrapper';
|
|
30
30
|
|
|
31
31
|
export type LintOptions = {
|
|
32
32
|
apis?: string[];
|
|
33
33
|
'max-problems': number;
|
|
34
34
|
extends?: string[];
|
|
35
|
-
config?: string;
|
|
36
35
|
format: OutputFormat;
|
|
37
36
|
'generate-ignore-file'?: boolean;
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
} & Omit<Skips, 'skip-decorator'> &
|
|
38
|
+
VerifyConfigOptions;
|
|
40
39
|
|
|
41
40
|
export async function handleLint({
|
|
42
41
|
argv,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../../utils/miscellaneous';
|
|
9
9
|
import startPreviewServer from './preview-server/preview-server';
|
|
10
10
|
|
|
11
|
-
import type { Skips } from '../../types';
|
|
11
|
+
import type { Skips, VerifyConfigOptions } from '../../types';
|
|
12
12
|
import type { CommandArgs } from '../../wrapper';
|
|
13
13
|
|
|
14
14
|
export type PreviewDocsOptions = {
|
|
@@ -18,7 +18,8 @@ export type PreviewDocsOptions = {
|
|
|
18
18
|
config?: string;
|
|
19
19
|
api?: string;
|
|
20
20
|
force?: boolean;
|
|
21
|
-
} & Omit<Skips, 'skip-rule'
|
|
21
|
+
} & Omit<Skips, 'skip-rule'> &
|
|
22
|
+
VerifyConfigOptions;
|
|
22
23
|
|
|
23
24
|
export async function previewDocs({
|
|
24
25
|
argv,
|
|
@@ -8,19 +8,19 @@ import type { CommandArgs } from '../../wrapper';
|
|
|
8
8
|
|
|
9
9
|
export const previewProject = async ({ argv }: CommandArgs<PreviewProjectOptions>) => {
|
|
10
10
|
const { plan, port } = argv;
|
|
11
|
-
const projectDir = argv['
|
|
11
|
+
const projectDir = argv['project-dir'];
|
|
12
12
|
|
|
13
13
|
const product = argv.product || tryGetProductFromPackageJson(projectDir);
|
|
14
14
|
|
|
15
15
|
if (!isValidProduct(product)) {
|
|
16
|
-
process.stderr.write(`Invalid product ${product}
|
|
17
|
-
throw new Error(`Project preview launch failed
|
|
16
|
+
process.stderr.write(`Invalid product ${product}.`);
|
|
17
|
+
throw new Error(`Project preview launch failed.`);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const productName = PRODUCT_NAMES[product];
|
|
21
21
|
const packageName = PRODUCT_PACKAGES[product];
|
|
22
22
|
|
|
23
|
-
process.stdout.write(`\nLaunching preview of ${productName} ${plan} using NPX
|
|
23
|
+
process.stdout.write(`\nLaunching preview of ${productName} ${plan} using NPX.\n\n`);
|
|
24
24
|
|
|
25
25
|
const npxExecutableName = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
26
26
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VerifyConfigOptions } from '../../types';
|
|
1
2
|
import type { PRODUCT_PACKAGES, PRODUCT_PLANS } from './constants';
|
|
2
3
|
|
|
3
4
|
export type Product = keyof typeof PRODUCT_PACKAGES;
|
|
@@ -7,6 +8,5 @@ export type PreviewProjectOptions = {
|
|
|
7
8
|
product?: Product | string;
|
|
8
9
|
plan: ProductPlan | string;
|
|
9
10
|
port?: number;
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
};
|
|
11
|
+
'project-dir': string;
|
|
12
|
+
} & VerifyConfigOptions;
|
package/src/commands/push.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { handlePush as handleCMSPush } from '../cms/commands/push';
|
|
|
25
25
|
|
|
26
26
|
import type { Config, BundleOutputFormat, Region } from '@redocly/openapi-core';
|
|
27
27
|
import type { CommandArgs } from '../wrapper';
|
|
28
|
+
import type { VerifyConfigOptions } from '../types';
|
|
28
29
|
|
|
29
30
|
const DEFAULT_VERSION = 'latest';
|
|
30
31
|
|
|
@@ -44,8 +45,7 @@ export type PushOptions = {
|
|
|
44
45
|
public?: boolean;
|
|
45
46
|
files?: string[];
|
|
46
47
|
organization?: string;
|
|
47
|
-
|
|
48
|
-
};
|
|
48
|
+
} & VerifyConfigOptions;
|
|
49
49
|
|
|
50
50
|
export function commonPushHandler({
|
|
51
51
|
project,
|