Skip to content
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(all): factor the version into clients.config.json #496

Merged
merged 6 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/** Exception thrown in case of API failure such as 4XX, 5XX error. */
public class AlgoliaApiException extends AlgoliaRuntimeException {

public static final long serialVersionUID = -1L;
public static final long serialVersionUID = 1L;

public int getHttpErrorCode() {
return httpErrorCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
public class AlgoliaRetryException extends AlgoliaRuntimeException {

public static final long serialVersionUID = -1L;
public static final long serialVersionUID = 1L;

public AlgoliaRetryException(String message, Throwable cause) {
super(message, cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/** Exception thrown when an error occurs during the Serialization/Deserialization process */
public class AlgoliaRuntimeException extends RuntimeException {

public static final long serialVersionUID = -1L;
public static final long serialVersionUID = 1L;

public AlgoliaRuntimeException(String message, Throwable cause) {
super(message, cause);
Expand Down
5 changes: 2 additions & 3 deletions config/clients.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"java": {
"folder": "clients/algoliasearch-client-java-2",
"mainPackage": "java-search",
eunjae-lee marked this conversation as resolved.
Show resolved Hide resolved
"packageVersion": "0.0.1",
"modelFolder": "algoliasearch-core/src/main/java/com/algolia/model",
"apiFolder": "algoliasearch-core/src/main/java/com/algolia/api",
"customGenerator": "algolia-java",
Expand All @@ -12,7 +12,6 @@
},
"javascript": {
"folder": "clients/algoliasearch-client-javascript",
"mainPackage": "javascript-search",
"modelFolder": "model",
"apiFolder": "src",
"customGenerator": "algolia-javascript",
Expand All @@ -23,7 +22,7 @@
},
"php": {
"folder": "clients/algoliasearch-client-php",
"mainPackage": "php-search",
"packageVersion": "0.0.1",
"modelFolder": "lib/Model",
"customGenerator": "algolia-php",
"apiFolder": "lib/Api",
Expand Down
27 changes: 6 additions & 21 deletions config/openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
"library": "okhttp-gson",
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1"
"packageName": "algoliasearch-client-java-2"
}
},
"java-recommend": {
Expand All @@ -157,8 +156,7 @@
"library": "okhttp-gson",
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1"
"packageName": "algoliasearch-client-java-2"
}
},
"java-personalization": {
Expand All @@ -172,7 +170,6 @@
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -187,7 +184,6 @@
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -202,7 +198,6 @@
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -217,7 +212,6 @@
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -232,7 +226,6 @@
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -246,8 +239,7 @@
"library": "okhttp-gson",
"gitRepoId": "algoliasearch-client-java-2",
"additionalProperties": {
"packageName": "algoliasearch-client-java-2",
"packageVersion": "0.0.1"
"packageName": "algoliasearch-client-java-2"
}
},
"php-search": {
Expand All @@ -256,8 +248,7 @@
"invokerPackage": "Algolia\\AlgoliaSearch",
"modelPackage": "Model\\Search",
"additionalProperties": {
"packageName": "algoliasearch-client-php",
"packageVersion": "0.0.1"
"packageName": "algoliasearch-client-php"
}
},
"php-recommend": {
Expand All @@ -266,8 +257,7 @@
"invokerPackage": "Algolia\\AlgoliaSearch",
"modelPackage": "Model\\Recommend",
"additionalProperties": {
"packageName": "algoliasearch-client-php",
"packageVersion": "0.0.1"
"packageName": "algoliasearch-client-php"
}
},
"php-personalization": {
Expand All @@ -277,7 +267,6 @@
"modelPackage": "Model\\Personalization",
"additionalProperties": {
"packageName": "algoliasearch-client-php",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -288,7 +277,6 @@
"modelPackage": "Model\\Analytics",
"additionalProperties": {
"packageName": "algoliasearch-client-php",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -299,7 +287,6 @@
"modelPackage": "Model\\Insights",
"additionalProperties": {
"packageName": "algoliasearch-client-php",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -310,7 +297,6 @@
"modelPackage": "Model\\Abtesting",
"additionalProperties": {
"packageName": "algoliasearch-client-php",
"packageVersion": "0.0.1",
"hasRegionalHost": true
}
},
Expand All @@ -326,8 +312,7 @@
"invokerPackage": "Algolia\\AlgoliaSearch",
"modelPackage": "Model\\QuerySuggestions",
"additionalProperties": {
"packageName": "algoliasearch-client-php",
"packageVersion": "0.0.1"
"packageName": "algoliasearch-client-php"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@algolia/api-client-automation",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"workspaces": [
"clients/algoliasearch-client-javascript/",
Expand Down
11 changes: 2 additions & 9 deletions scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import execa from 'execa'; // https://github.com/sindresorhus/execa/tree/v5.1.1
import { hashElement } from 'folder-hash';
import { remove } from 'fs-extra';

import clientsConfig from '../config/clients.config.json';
import openapiConfig from '../config/openapitools.json';
import releaseConfig from '../config/release.config.json';

import { getPackageVersionDefault } from './config';
import { createSpinner } from './oraLog';
import type {
CheckForCache,
Expand Down Expand Up @@ -41,10 +41,7 @@ export const GENERATORS: Record<string, Generator> = {
additionalProperties: {
buildFile: 'algoliasearch',
packageName: '@experimental-api-clients-automation/algoliasearch',
packageVersion:
openapiConfig['generator-cli'].generators[
clientsConfig.javascript.mainPackage
].additionalProperties.packageVersion,
packageVersion: getPackageVersionDefault('javascript'),
},
},
};
Expand All @@ -60,10 +57,6 @@ Object.entries(openapiConfig['generator-cli'].generators).forEach(
}
);

export function getPackageVersion(generator: string): string {
return GENERATORS[generator].additionalProperties.packageVersion;
}

export const LANGUAGES = [
...new Set(Object.values(GENERATORS).map((gen) => gen.language)),
];
Expand Down
9 changes: 9 additions & 0 deletions scripts/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import clientsConfig from '../config/clients.config.json';
import openapiConfig from '../config/openapitools.json';

import type { Language } from './types';

Expand All @@ -25,3 +26,11 @@ export function getTestOutputFolder(language: Language): string {
export function getCustomGenerator(language: Language): string {
return clientsConfig[language].customGenerator;
}

export function getPackageVersionDefault(language: Language): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a description with the case for js pls?

if (language === 'javascript') {
return openapiConfig['generator-cli'].generators['javascript-search']
.additionalProperties.packageVersion;
}
return clientsConfig[language].packageVersion;
}
10 changes: 0 additions & 10 deletions scripts/release/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ import path from 'path';

import { Octokit } from '@octokit/rest';

import clientsConfig from '../../config/clients.config.json';
import config from '../../config/release.config.json';
import { getGitHubUrl, run } from '../common';

export const RELEASED_TAG = config.releasedTag;
export const TEAM_SLUG = config.teamSlug;
export const MAIN_PACKAGE = Object.keys(clientsConfig).reduce(
(mainPackage: { [lang: string]: string }, lang: string) => {
return {
...mainPackage,
[lang]: clientsConfig[lang].mainPackage,
};
},
{}
);

export function getOctokit(githubToken: string): Octokit {
return new Octokit({
Expand Down
15 changes: 5 additions & 10 deletions scripts/release/create-release-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
LANGUAGES,
ROOT_ENV_PATH,
run,
getPackageVersion,
MAIN_BRANCH,
OWNER,
REPO,
} from '../common';
import { getPackageVersionDefault } from '../config';
import type { Language } from '../types';

import { RELEASED_TAG, MAIN_PACKAGE, getOctokit } from './common';
import { RELEASED_TAG, getOctokit } from './common';
import TEXT from './text';
import type {
Versions,
Expand All @@ -26,14 +26,9 @@ import type {
dotenv.config({ path: ROOT_ENV_PATH });

export function readVersions(): VersionsWithoutReleaseType {
return Object.keys(MAIN_PACKAGE).reduce((acc, lang) => {
return {
...acc,
[lang]: {
current: getPackageVersion(MAIN_PACKAGE[lang]),
},
};
}, {});
return Object.fromEntries(
LANGUAGES.map((lang) => [lang, { current: getPackageVersionDefault(lang) }])
);
}

export function getVersionChangesText(versions: Versions): string {
Expand Down
Loading