Skip to content

Commit

Permalink
Merge pull request #475 from mocks-server/refactor/typescript-migration
Browse files Browse the repository at this point in the history
5.0.0 beta version
  • Loading branch information
javierbrea authored May 23, 2023
2 parents 7f4d556 + 0006c41 commit c067954
Show file tree
Hide file tree
Showing 397 changed files with 14,630 additions and 6,979 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/test/core-e2e/src/fixtures
/packages/core/test/functional/fixtures
/test/main-e2e/src/fixtures
/test/config-e2e/src/fixtures/ts-dist
47 changes: 46 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ module.exports = {
overrides: [
{
files: ["packages/*/test/**/*.js", "test/*/src/**/*.js"],
env: {
node: true,
es6: true,
},
parserOptions: {
sourceType: "module",
},
globals: {
jest: true,
beforeAll: true,
Expand Down Expand Up @@ -100,12 +107,50 @@ module.exports = {
{
files: ["packages/**/*.ts"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
plugins: ["prettier", "@typescript-eslint", "import"],
extends: [
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
],
rules: {
"@typescript-eslint/no-shadow": "error",
"no-shadow": "off",
"prettier/prettier": [
2,
{
printWidth: 99,
parser: "typescript",
},
],
"import/order": [
"error",
{
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
pathGroups: [
{
pattern: "./*Types",
group: "internal",
position: "before",
},
],
"newlines-between": "always",
alphabetize: {
order: "asc" /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
caseInsensitive: true /* ignore case. Options: [true, false] */,
},
},
],
},
settings: {
"import/resolver": {
typescript: true,
node: true,
},
},
},
],
};
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches:
- master
- release
- refactor/typescript-migration
pull_request:
jobs:
get-affected:
Expand Down Expand Up @@ -86,6 +87,8 @@ jobs:
run: pnpm install
- name: Generate graph
run: pnpm run graph -- --file=graph.json
- name: Build all
run: pnpm run build:all
- name: Lint
run: pnpm run lint
test-unit:
Expand Down Expand Up @@ -195,7 +198,7 @@ jobs:
path: ${{steps.get-project-path.outputs.prop}}/coverage
- name: SonarCloud Scan
if: ${{ env.SONAR_TOKEN != '' && steps.check-sonar-config.outputs.files_exists == 'true' }}
uses: sonarsource/sonarcloud-github-action@master
uses: SonarSource/sonarcloud-github-action@v1.9.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-affected.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- master
- pre-release
jobs:
check-affected:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
# Defaults to the user or organization that owns the workflow file
scope: '@mocks-server'
cache: 'pnpm'
- run: pnpm -r publish --no-git-checks
- run: pnpm -r publish --no-git-checks --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build:all
- run: pnpm -r publish --no-git-checks
- run: pnpm -r publish --no-git-checks --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ yarn-error.log*
# ides
.idea
.vs
.vscode
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
"@rollup/plugin-node-resolve": "13.3.0",
"@rollup/plugin-typescript": "8.5.0",
"@testing-library/cypress": "8.0.3",
"@types/fs-extra": "11.0.1",
"@types/json-schema": "7.0.11",
"@types/lodash": "4.14.185",
"@typescript-eslint/eslint-plugin": "5.32.0",
"@typescript-eslint/parser": "5.32.0",
"@typescript-eslint/parser": "5.48.0",
"babel-jest": "27.5.1",
"babel-loader": "8.2.5",
"babel-plugin-module-resolver": "4.1.0",
Expand All @@ -54,6 +57,8 @@
"deepmerge": "4.2.2",
"eslint": "8.24.0",
"eslint-config-prettier": "8.5.0",
"eslint-import-resolver-typescript": "3.5.3",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "26.7.0",
"eslint-plugin-no-only-tests": "2.6.0",
"eslint-plugin-prettier": "4.2.1",
Expand All @@ -78,6 +83,7 @@
"start-server-and-test": "1.14.0",
"strip-ansi": "6.0.0",
"tree-kill": "1.2.2",
"tslib": "2.5.0",
"typescript": "4.7.4",
"wait-on": "6.0.1",
"webpack": "5.74.0"
Expand Down
6 changes: 0 additions & 6 deletions packages/admin-api-client-data-provider/.vscode/settings.json

This file was deleted.

23 changes: 14 additions & 9 deletions packages/admin-api-client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module.exports = {
parser: "@babel/eslint-parser",
parserOptions: {
sourceType: "module",
allowImportExportEverywhere: true,
requireConfigFile: false,
},
globals: {
module: true,
},
overrides: [
{
files: ["*.js"],
parser: "@babel/eslint-parser",
parserOptions: {
sourceType: "module",
allowImportExportEverywhere: true,
requireConfigFile: false,
},
globals: {
module: true,
},
},
],
};
6 changes: 0 additions & 6 deletions packages/admin-api-client/.vscode/settings.json

This file was deleted.

6 changes: 6 additions & 0 deletions packages/admin-api-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
### Removed

## [unreleased]

### Changed
- refactor: Refactor and document types. Change exported types
- style: Use prettier

## [7.0.0] - 2022-09-14

### Removed
Expand Down
3 changes: 2 additions & 1 deletion packages/admin-api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mocks-server/admin-api-client",
"version": "7.0.0",
"version": "8.0.0-beta.1",
"description": "Client of @mocks-server/plugin-admin-api",
"keywords": [
"mocks-server",
Expand Down Expand Up @@ -36,6 +36,7 @@
"test:unit": "start-server-and-test mocks:ci tcp:127.0.0.1:3110 test"
},
"dependencies": {
"@mocks-server/config": "workspace:*",
"@mocks-server/admin-api-paths": "workspace:*",
"cross-fetch": "3.1.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-api-client/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.organization=mocks-server
sonar.projectKey=mocks-server_main_admin-api-client
sonar.projectName=admin-api-client
sonar.projectVersion=7.0.0
sonar.projectVersion=8.0.0-beta.1

sonar.javascript.file.suffixes=.js
sonar.sourceEncoding=UTF-8
Expand Down
13 changes: 0 additions & 13 deletions packages/admin-api-client/src/.eslintrc.json

This file was deleted.

82 changes: 82 additions & 0 deletions packages/admin-api-client/src/AdminApiClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import type { ConfigurationObject } from "@mocks-server/config";

import type { AdminApiClientInterface, AdminApiClientConstructor } from "./AdminApiClient.types";
import { AdminApiClientEntities } from "./AdminApiClientEntities";
import type {
ApiClientConfig,
ApiResponseBody,
AdminApiClientEntitiesInterface,
} from "./AdminApiClientEntities.types";
import type { EntityId } from "./Common.types";

export const AdminApiClient: AdminApiClientConstructor = class AdminApiClient
implements AdminApiClientInterface
{
private _adminApiClient: AdminApiClientEntitiesInterface;

constructor() {
this._adminApiClient = new AdminApiClientEntities();
}

public readAbout(): Promise<ApiResponseBody> {
return this._adminApiClient.about.read();
}

public readConfig(): Promise<ConfigurationObject> {
return this._adminApiClient.config.read() as Promise<ConfigurationObject>;
}

public updateConfig(newConfig: ConfigurationObject): Promise<void> {
return this._adminApiClient.config.update(newConfig) as Promise<void>;
}

public readAlerts(): Promise<ApiResponseBody> {
return this._adminApiClient.alerts.read();
}

public readAlert(id: EntityId): Promise<ApiResponseBody> {
return this._adminApiClient.alert(id).read();
}

public readCollections(): Promise<ApiResponseBody> {
return this._adminApiClient.collections.read();
}

public readCollection(id: EntityId): Promise<ApiResponseBody> {
return this._adminApiClient.collection(id).read();
}

public readRoutes(): Promise<ApiResponseBody> {
return this._adminApiClient.routes.read();
}

public readRoute(id: EntityId): Promise<ApiResponseBody> {
return this._adminApiClient.route(id).read();
}

public readVariants(): Promise<ApiResponseBody> {
return this._adminApiClient.variants.read();
}

public readVariant(id: EntityId): Promise<ApiResponseBody> {
return this._adminApiClient.variant(id).read();
}

public readCustomRouteVariants(): Promise<ApiResponseBody> {
return this._adminApiClient.customRouteVariants.read();
}

public useRouteVariant(id: EntityId): Promise<void> {
return this._adminApiClient.customRouteVariants.create({
id,
}) as Promise<void>;
}

public restoreRouteVariants(): Promise<void> {
return this._adminApiClient.customRouteVariants.delete() as Promise<void>;
}

public configClient(config: ApiClientConfig): void {
return this._adminApiClient.configClient(config);
}
};
Loading

0 comments on commit c067954

Please sign in to comment.