-
Notifications
You must be signed in to change notification settings - Fork 14
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
chore: check if generated CTS match committed CTS #107
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e4dcd0f
chore: check if generated CTS match commited
millotp 39c2427
harmonize output path
millotp f7b5fdf
Merge branch 'main' into chore/porcelain-cts
millotp b4be91b
refacto the templates
millotp 850aad1
config file
millotp 973c245
review
millotp 00e7a7b
Merge branch 'main' into chore/porcelain-cts
millotp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"javascript": { | ||
"extension": "test.ts", | ||
"outputFolder": "tests" | ||
}, | ||
"java": { | ||
"extension": "test.java", | ||
"outputFolder": "src/test/java/com/algolia" | ||
} | ||
} | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ import fsp from 'fs/promises'; | |||||
import path from 'path'; | ||||||
|
||||||
import openapitools from '../../openapitools.json'; | ||||||
import ctsConfig from '../CTS/config.json'; | ||||||
|
||||||
// For each generator, we map the packageName with the language and client | ||||||
export const packageNames: Record< | ||||||
|
@@ -90,19 +91,8 @@ export function removeEnumType(obj: any): any { | |||||
return obj; | ||||||
} | ||||||
|
||||||
// All those language dependents object should be defined in the CTS itself | ||||||
export const extensionForLanguage: Record<string, string> = { | ||||||
javascript: 'test.ts', | ||||||
java: 'test.java', | ||||||
}; | ||||||
|
||||||
export const sourcePathForLanguage: Record<string, string> = { | ||||||
javascript: 'tests/methods/requests', | ||||||
java: 'src/test/java/com/algolia', | ||||||
}; | ||||||
|
||||||
/* eslint-disable no-console */ | ||||||
function printUsage(commandName: string): void { | ||||||
/* eslint-disable no-console */ | ||||||
console.log(`usage: ${commandName} language client`); | ||||||
// eslint-disable-next-line no-process-exit | ||||||
process.exit(1); | ||||||
|
@@ -130,10 +120,62 @@ export function parseCLI( | |||||
// eslint-disable-next-line no-process-exit | ||||||
process.exit(1); | ||||||
} | ||||||
/* eslint-enable no-console */ | ||||||
|
||||||
return { | ||||||
lang, | ||||||
client, | ||||||
}; | ||||||
} | ||||||
/* eslint-enable no-console */ | ||||||
|
||||||
export async function createOutputDir({ | ||||||
language, | ||||||
testPath, | ||||||
}: { | ||||||
language: string; | ||||||
testPath: string; | ||||||
}): Promise<void> { | ||||||
await fsp.mkdir( | ||||||
`output/${language}/${ctsConfig[language].outputFolder}/${testPath}`, | ||||||
{ | ||||||
recursive: true, | ||||||
} | ||||||
); | ||||||
} | ||||||
|
||||||
export function outputPath({ | ||||||
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
Otherwise it feels like it's a variable name |
||||||
language, | ||||||
client, | ||||||
testPath, | ||||||
}: { | ||||||
language: string; | ||||||
client: string; | ||||||
testPath: string; | ||||||
}): string { | ||||||
return `output/${language}/${ctsConfig[language].outputFolder}/${testPath}/${client}.${ctsConfig[language].extension}`; | ||||||
} | ||||||
|
||||||
export async function loadTemplates({ | ||||||
language, | ||||||
testPath, | ||||||
}: { | ||||||
language: string; | ||||||
testPath: string; | ||||||
}): Promise<Record<string, string>> { | ||||||
const templates: Record<string, string> = {}; | ||||||
const templatePath = `./CTS/${testPath}/templates/${language}`; | ||||||
|
||||||
if (!(await exists(templatePath))) { | ||||||
return {}; | ||||||
} | ||||||
|
||||||
for await (const file of walk(templatePath)) { | ||||||
if (!file.name.endsWith('.mustache')) { | ||||||
continue; | ||||||
} | ||||||
const name = file.name.replace('.mustache', ''); | ||||||
const fileContent = (await fsp.readFile(file.path)).toString(); | ||||||
templates[name] = fileContent; | ||||||
} | ||||||
return templates; | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing formatting? It should be: