Skip to content
Prev Previous commit
quotes
  • Loading branch information
millotp committed Feb 25, 2022
commit 9fbb509de75c3bbfff68e079a2a4449c7835b98d
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ yarn docker build clients java recommend

You can add `-v` to almost every command to have a more verbose output.

### Interactive command

If you want to choose the language and client from a list you can add the `--interactive` option, or `-i`.

## Testing clients

You can test our generated clients by running:
Expand Down
2 changes: 1 addition & 1 deletion scripts/buildClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function buildAllClients(
language: string,
verbose: boolean
): Promise<void> {
const spinner = createSpinner(`building ${language}`, verbose).start();
const spinner = createSpinner(`building '${language}'`, verbose).start();
switch (language) {
case 'java':
await run(
Expand Down
18 changes: 7 additions & 11 deletions scripts/buildSpecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ async function buildSpec(
verbose: boolean,
useCache: boolean
): Promise<void> {
createSpinner(`${client} spec`, verbose).start().info();
createSpinner(`'${client}' spec`, verbose).start().info();
const cacheFile = toAbsolutePath(`specs/dist/${client}.cache`);
if (useCache) {
const spinner = createSpinner(
`checking cache for ${client}`,
`checking cache for '${client}'`,
verbose
).start();
// check if file and cache exist
Expand All @@ -33,19 +33,19 @@ async function buildSpec(
}
}

spinner.info(`cache not found for ${client} spec`);
spinner.info(`cache not found for ${client}' spec`);
}

const spinner = createSpinner(`linting ${client} spec`, verbose).start();
const spinner = createSpinner(`linting '${client}' spec`, verbose).start();
await run(`yarn specs:lint ${client}`, { verbose });

spinner.text = `building ${client} spec`;
spinner.text = `building '${client}' spec`;
await run(
`yarn openapi bundle specs/${client}/spec.yml -o specs/bundled/${client}.${outputFormat} --ext ${outputFormat}`,
{ verbose }
);

spinner.text = `validating ${client} spec`;
spinner.text = `validating '${client}' spec`;
await run(`yarn openapi lint specs/bundled/${client}.${outputFormat}`, {
verbose,
});
Expand All @@ -54,11 +54,7 @@ async function buildSpec(
const hash = (await hashElement(toAbsolutePath(`specs/${client}`))).hash;
await fsp.writeFile(cacheFile, hash);

spinner.succeed();

createSpinner(`building complete for ${client} spec`, verbose)
.start()
.succeed();
spinner.succeed(`building complete for '${client}' spec`);
}

export async function buildSpecs(
Expand Down
11 changes: 7 additions & 4 deletions scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ export const CLIENTS = [

export const CLIENTS_JS = CLIENTS.concat([]);

export function splitGeneratorKey(key: string): Generator {
const language = key.slice(0, key.indexOf('-'));
const client = key.slice(key.indexOf('-') + 1);
return { language, client, key };
/**
* Takes a generator key in the form 'language-client' and returns the Generator object.
*/
export function splitGeneratorKey(generatorKey: string): Generator {
const language = generatorKey.slice(0, generatorKey.indexOf('-'));
const client = generatorKey.slice(generatorKey.indexOf('-') + 1);
return { language, client, key: generatorKey };
}

export function createGeneratorKey({
Expand Down
7 changes: 5 additions & 2 deletions scripts/cts/runCts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { run } from '../common';
import { createSpinner } from '../oraLog';

async function runCtsOne(language: string, verbose: boolean): Promise<void> {
const spinner = createSpinner(`running cts for ${language}`, verbose).start();
const spinner = createSpinner(
`running cts for '${language}'`,
verbose
).start();
switch (language) {
case 'javascript':
await run('yarn workspace javascript-tests test', { verbose });
Expand All @@ -23,7 +26,7 @@ async function runCtsOne(language: string, verbose: boolean): Promise<void> {
break;
}*/
default:
spinner.warn(`skipping unknown language ${language} to run the CTS`);
spinner.warn(`skipping unknown language '${language}' to run the CTS`);
return;
}
spinner.succeed();
Expand Down
2 changes: 1 addition & 1 deletion scripts/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function formatter(
verbose = false
): Promise<void> {
const spinner = createSpinner(
{ text: `formatting ${language}`, indent: 4 },
{ text: `formatting '${language}'`, indent: 4 },
verbose
).start();
let cmd = '';
Expand Down