-
Notifications
You must be signed in to change notification settings - Fork 17
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(cts): update dependencies on cts generation for javascript #490
Conversation
✅ Deploy Preview for api-clients-automation canceled.
|
✗ The generated branch has been deleted.If the PR has been merged, you can check the generated code on the |
tests/CTS/methods/requests/templates/javascript/package.mustache
Outdated
Show resolved
Hide resolved
generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java
Outdated
Show resolved
Hide resolved
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.
Looks good !
}, | ||
"dependencies": { | ||
{{#packageVersionMap}} | ||
"@experimental-api-clients-automation/algoliasearch-lite": "{{@experimental-api-clients-automation/algoliasearch-lite}}", |
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.
you could iterate on a array of object, and have "{{packageName}}": "{{packageVersion}}
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.
I thought about it, but just left it like that, to be explicit about which dependencies we use for the package. WDTY?
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.
we can be as explicit but in the generator :)
@@ -84,6 +84,12 @@ public void processOpts() { | |||
clientName + testConfig.extension | |||
) | |||
); | |||
|
|||
if (language.equals("javascript")) { |
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.
Can you make this generic with a class that will add the correct supporting files and and data ?
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.
Can you give me an example of what the class would look like?
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.
interface VersionManager {
void addSupportingFiles(...);
void addData(...);
}
class JavascriptVersionManager implements VersionManager {
//your code
}
And instanciate the correct one in AlgoliaCtsGenerator.java
based on the language.
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.
👍 coming soon
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.
@@ -149,4 +153,15 @@ public static void generateServer( | |||
System.exit(1); | |||
} | |||
} | |||
|
|||
public static JsonNode readJsonFile(String filePath) { |
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.
Very cool ! can you replace other instance of the code where we load a json by this method ?
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.
generators/src/main/java/com/algolia/codegen/cts/CtsManagerFactory.java
Outdated
Show resolved
Hide resolved
tests/output/javascript/package.json
Outdated
@@ -5,17 +5,17 @@ | |||
"test": "jest" |
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.
We should maybe sort those deps otherwise it will be sorted locally and then unsorted when bumped etc
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.
ah or maybe just the yarn install that will come after will sort them actually
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.
Actually I was going to ask this question, but why aren't this deps sorted automatically? I thought formatting after the generation would do it, but didn't.
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.
I believe it's yarn that sorts the dependencies in the package.json
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.
I just found it:
After the cts generation, it runs this formatter: https://github.com/algolia/api-clients-automation/blob/7c434506d7d6f23f044841024b0dbc8e9af26514/scripts/formatter.ts#L16:L16
and it runs:
yarn eslint --ext=ts tests/output/javascript/src --fix --no-error-on-unmatched-pattern
that's why tests/output/javascript/package.json
is being excluded from the eslint.
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.
ahhh yes we can maybe add an extra line for the package.json if it works then
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.
What do you think?
generators/src/main/java/com/algolia/codegen/cts/CtsManagerFactory.java
Outdated
Show resolved
Hide resolved
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.
Beautiful ! The version logic has changed a little bit on main but it should make it easier here, you can add utils the same way as in js
@@ -63,31 +67,34 @@ public void processOpts() { | |||
language = (String) additionalProperties.get("language"); | |||
client = (String) additionalProperties.get("client"); | |||
packageName = (String) additionalProperties.get("packageName"); | |||
ctsManager = CtsManagerFactory.getManager(language); |
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.
fancy !
generators/src/main/java/com/algolia/codegen/cts/CtsManager.java
Outdated
Show resolved
Hide resolved
generators/src/main/java/com/algolia/codegen/cts/CtsManagerFactory.java
Outdated
Show resolved
Hide resolved
generators/src/main/java/com/algolia/codegen/cts/CtsManagerFactory.java
Outdated
Show resolved
Hide resolved
generators/src/main/java/com/algolia/codegen/cts/CtsManagerFactory.java
Outdated
Show resolved
Hide resolved
I'll mark it as ready for review once I make the CI pass. |
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.
A last few comments 😅 also can you add the package.json
of the test to generation.config.json
?
bundle.put("packageDependencies", ctsManager.getPackageDependencies()); | ||
ctsManager.addExtraToBundle(bundle); |
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.
it would be clearer to combine those into one like addSupportingData(bundle)
, and let the manager add what it wants
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.
it makes sense 0303223
if (!additionalProperties.has("packageVersion")) { | ||
continue; | ||
} | ||
String packageName = additionalProperties.get("packageName").asText(); |
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.
packageName
is a lie, it's not used for anything other than js because it doesn't change, unless we know other languages that will be split in clients, I think we can remove this notion from the CTS, and remove them from clients.config.json
(but keep them for js)
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.
And have this code that his specific to JS in the JavascriptCtsManager
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.
Bonne idée 2d04ade
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.
Looks clean!! Pierre said most of it, just one comment more :D
"@experimental-api-clients-automation/algoliasearch-lite", | ||
"@experimental-api-clients-automation/client-abtesting", | ||
"@experimental-api-clients-automation/client-analytics", | ||
"@experimental-api-clients-automation/client-common", | ||
"@experimental-api-clients-automation/client-insights", | ||
"@experimental-api-clients-automation/client-personalization", | ||
"@experimental-api-clients-automation/client-predict", | ||
"@experimental-api-clients-automation/client-query-suggestions", | ||
"@experimental-api-clients-automation/client-search", | ||
"@experimental-api-clients-automation/client-sources", | ||
"@experimental-api-clients-automation/recommend", | ||
"@experimental-api-clients-automation/requester-node-http" |
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.
Maybe this list can be guessed from the packageName
in openapitools.json?
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.
done here 2d04ade
pls |
Oh I missed that part. 70fdd86 |
🧭 What and Why
🎟 JIRA Ticket: https://algolia.atlassian.net/browse/APIC-453
Changes included:
cts generate
command now always updates the dependencies intests/output/javascript/package.json
.I will probably send a separate PR for java and php. I'd like to get this javascript validated first before moving onto other languages.