-
Notifications
You must be signed in to change notification settings - Fork 21
chore: add clean models to preGen #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
9f7e31f
13d7b9c
abd3048
49472eb
059915e
eb79948
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,21 +1,66 @@ | ||||||
import path from 'path'; | ||||||
|
||||||
import { buildJSClientUtils } from './buildClients'; | ||||||
import { buildSpecs } from './buildSpecs'; | ||||||
import { buildCustomGenerators, CI, run, runIfExists } from './common'; | ||||||
import { getCustomGenerator, getLanguageFolder } from './config'; | ||||||
import { | ||||||
buildCustomGenerators, | ||||||
CI, | ||||||
run, | ||||||
runIfExists, | ||||||
toAbsolutePath, | ||||||
} from './common'; | ||||||
import { | ||||||
getCustomGenerator, | ||||||
getLanguageFolder, | ||||||
getLanguageModelFolder, | ||||||
} from './config'; | ||||||
import { formatter } from './formatter'; | ||||||
import { createSpinner } from './oraLog'; | ||||||
import { setHostsOptions } from './pre-gen/setHostsOptions'; | ||||||
import type { Generator } from './types'; | ||||||
|
||||||
async function preGen( | ||||||
{ language, client, key, output }: Generator, | ||||||
/** | ||||||
* Remove `model` folder for the current language and client. | ||||||
*/ | ||||||
async function removeExistingModel( | ||||||
{ language, client, output }: Generator, | ||||||
verbose?: boolean | ||||||
): Promise<void> { | ||||||
await runIfExists(`./scripts/pre-gen/${language}.sh`, `${output} ${key}`, { | ||||||
verbose, | ||||||
}); | ||||||
const baseModelFolder = getLanguageModelFolder(language); | ||||||
|
||||||
let clientModel = ''; | ||||||
switch (language) { | ||||||
case 'java': | ||||||
clientModel = `/${client}`; | ||||||
break; | ||||||
default: | ||||||
break; | ||||||
} | ||||||
|
||||||
await run( | ||||||
`rm -rf ${toAbsolutePath( | ||||||
path.resolve(output, `/${baseModelFolder}`, clientModel) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You have to remove the leading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL!!! Good to know (and weird behavior), but at least it's much cleaner There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks both!! |
||||||
)}`, | ||||||
{ | ||||||
verbose, | ||||||
} | ||||||
); | ||||||
} | ||||||
|
||||||
async function preGen(gen: Generator, verbose?: boolean): Promise<void> { | ||||||
// Run bash pre-gen script | ||||||
await runIfExists( | ||||||
`./scripts/pre-gen/${gen.language}.sh`, | ||||||
`${gen.output} ${gen.key}`, | ||||||
{ | ||||||
verbose, | ||||||
} | ||||||
); | ||||||
|
||||||
await removeExistingModel(gen); | ||||||
|
||||||
await setHostsOptions({ client, key }); | ||||||
// Updates `openapitools.json` file based on the spec `servers` | ||||||
await setHostsOptions({ client: gen.client, key: gen.key }); | ||||||
} | ||||||
|
||||||
async function generateClient( | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.