Skip to content

Commit

Permalink
refactor: files
Browse files Browse the repository at this point in the history
  • Loading branch information
collettemathieu committed Jul 17, 2024
1 parent eaad32a commit 0280431
Show file tree
Hide file tree
Showing 40 changed files with 153 additions and 103 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"oven.bun-vscode",
"biomejs.biome",
"cucumberopen.cucumber-official",
"github.vscode-github-actions"
"github.vscode-github-actions",
"tamasfe.even-better-toml"
]
}
4 changes: 1 addition & 3 deletions apps/pathway-design/server/cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module.exports = {
paths: ['apps/pathway-design/server/src/tests/**/*.feature'],
requireModule: ['ts-node/register', 'tsconfig-paths/register'],
require: ['apps/pathway-design/server/src/tests/**/*.ts'],
format: [
'json:dist/apps/pathway-design/server/tests/reports/cucumber_report.json',
],
format: ['json:dist/reports/apps/pathway-design/cucumber_report.json'],
},
};
2 changes: 0 additions & 2 deletions apps/pathway-design/server/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Controller, Get, Inject } from '@nestjs/common';

import { PathwayDesignCreationServerBusinessEntitiesPathway } from '@bewoak/pathway-design-creation-server-business-entities-pathway';
import { AppService } from './app.service';

@Controller()
Expand All @@ -9,7 +8,6 @@ export class AppController {

@Get()
getData() {
new PathwayDesignCreationServerBusinessEntitiesPathway('name');
return this.appService.getData();
}
}
4 changes: 4 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[test]
coverage = true
coverageReporter = ["text", "lcov"]
coverageDir = "dist/reports/coverage"
6 changes: 3 additions & 3 deletions docs/nx/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
### Create a Nx:Node:Library

```bash
bun run nx generate @nx/js:lib --name=init-pathway --bundler=swc --directory=libs/pathway-design/creation/server/business/usecases --importPath=@bewoak/pathway-design-creation-server-business-usescases-init-pathway --publishable --linter=none --minimal --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived -d
bun run nx generate @nx/js:lib --name=init-pathway --bundler=swc --directory=libs/pathway-design/server/business/usecases --importPath=@bewoak/pathway-design-server-business-usescases-init-pathway --publishable --linter=none --minimal --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived -d
```

### Create a Nx:Nest:Library

```bash
bun run nx generate @nx/nest:lib --name=pathway --buildable --publishable --directory=libs/pathway-design/creation/server/business/entities --importPath=@bewoak/pathway-design-creation-server-business-entities-pathway --linter=none --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived --standaloneConfig -d
bun run nx generate @nx/nest:lib --name=pathway --buildable --publishable --directory=libs/pathway-design/server/business/entities --importPath=@bewoak/pathway-design-server-business-entities-pathway --linter=none --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived --standaloneConfig -d
```

### Convert a Nx:Library to swc compiler

```bash
bun run nx g @nx/js:convert-to-swc pathway-design-creation-server-business-entities-pathway
bun run nx g @nx/js:convert-to-swc pathway-design-server-business-entities-pathway
```
File renamed without changes.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@
"type": "es6"
},
"sourceMaps": true,
"exclude": [".*\\.spec.tsx?$", ".*\\.test.tsx?$", ".*.js$"]
"exclude": [
".*\\.spec.tsx?$",
".*\\.test.tsx?$",
".*\\.step.tsx?$",
".*.js$"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pathway-design-server-business-entities-pathway

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build pathway-design-server-business-entities-pathway` to build the library.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "../../../../../../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["../../../../../../../biome.json"],
"$schema": "../../../../../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["../../../../../../biome.json"],
"linter": {
"rules": {
"nursery": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bewoak/pathway-design-creation-server-business-entities-pathway",
"name": "@bewoak/pathway-design-server-business-entities-pathway",
"version": "0.0.1",
"dependencies": {
"@swc/helpers": "~0.5.11",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pathway-design-creation-server-business-entities-pathway",
"$schema": "../../../../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/pathway-design/creation/server/business/entities/pathway/src",
"name": "pathway-design-server-business-entities-pathway",
"$schema": "../../../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/pathway-design/server/business/entities/pathway/src",
"projectType": "library",
"release": {
"version": {
Expand All @@ -17,12 +17,12 @@
"executor": "@nx/js:swc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/pathway-design/creation/server/business/entities/pathway",
"tsConfig": "libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json",
"packageJson": "libs/pathway-design/creation/server/business/entities/pathway/package.json",
"main": "libs/pathway-design/creation/server/business/entities/pathway/src/index.ts",
"outputPath": "dist/libs/pathway-design/server/business/entities/pathway",
"tsConfig": "libs/pathway-design/server/business/entities/pathway/tsconfig.lib.json",
"packageJson": "libs/pathway-design/server/business/entities/pathway/package.json",
"main": "libs/pathway-design/server/business/entities/pathway/src/index.ts",
"assets": [
"libs/pathway-design/creation/server/business/entities/pathway/*.md"
"libs/pathway-design/server/business/entities/pathway/*.md"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export {
PathwayDesignServerBusinessEntitiesPathway,
PathwayDesignServerBusinessEntitiesPathwayInitDto,
} from './lib/pathway';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export class PathwayDesignServerBusinessEntitiesPathway {
name: string | undefined;
description: string | undefined;
field: string | undefined;

init(data: PathwayDesignServerBusinessEntitiesPathwayInitDto) {
this.name = data.name;
this.description = data.description;
this.field = data.field;
}
}

export interface PathwayDesignServerBusinessEntitiesPathwayInitDto {
name: string;
description: string;
field: string;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../../../../tsconfig.base.json",
"extends": "../../../../../../tsconfig.base.json",
"compilerOptions": {
"module": "ES2022",
"forceConsistentCasingInFileNames": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../../../../dist/out-tsc",
"outDir": "../../../../../../dist/out-tsc",
"declaration": true,
"types": ["node"],
"target": "es2022",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "../../../../../../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["../../../../../../../biome.json"],
"$schema": "../../../../../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["../../../../../../biome.json"],
"linter": {
"rules": {
"nursery": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
default: {
paths: [
'libs/pathway-design/server/business/usecases/init-pathway/src/lib/**/*.feature',
],
requireModule: ['ts-node/register', 'tsconfig-paths/register'],
require: [
'libs/pathway-design/server/business/usecases/init-pathway/src/lib/**/*.ts',
],
format: [
'json:dist/reports/libs/pathway-design/init-pathway/tests/index.json',
'html:dist/reports/libs/pathway-design/init-pathway/test/index.html',
],
},
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bewoak/pathway-design-creation-server-business-usescases-init-pathway",
"name": "@bewoak/pathway-design-server-business-usescases-init-pathway",
"version": "0.0.1",
"dependencies": {
"@swc/helpers": "~0.5.11"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "pathway-design-creation-server-business-usecases-init-pathway",
"$schema": "../../../../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/pathway-design/creation/server/business/usecases/init-pathway/src",
"name": "pathway-design-server-business-usecases-init-pathway",
"$schema": "../../../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/pathway-design/server/business/usecases/init-pathway/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:swc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/pathway-design/creation/server/business/usecases/init-pathway",
"main": "libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts",
"tsConfig": "libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.lib.json",
"outputPath": "dist/libs/pathway-design/server/business/usecases/init-pathway",
"main": "libs/pathway-design/server/business/usecases/init-pathway/src/index.ts",
"tsConfig": "libs/pathway-design/server/business/usecases/init-pathway/tsconfig.lib.json",
"assets": []
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PathwayDesignServerBusinessUsecasesInitPathway } from './lib/index.usecase';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Initiate a Pathway

Scenario: I want to initiate a pathway
When I want to initiate a pathway with these data
| name | description | field |
| My Pathway | A test pathway | biology |
Then I should retrieve a pathway initiated with its data
| name | description | field |
| My Pathway | A test pathway | biology |
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type {
PathwayDesignServerBusinessEntitiesPathway,
PathwayDesignServerBusinessEntitiesPathwayInitDto,
} from '@bewoak/pathway-design-server-business-entities-pathway';
import type { DataTable } from '@cucumber/cucumber';
import { binding, then, when } from 'cucumber-tsflow';
import { strict as assert } from 'node:assert';
import { PathwayDesignServerBusinessUsecasesInitPathway } from './index.usecase';

@binding()
export default class ControllerSteps {
private initPathwayUsecase: PathwayDesignServerBusinessUsecasesInitPathway =
new PathwayDesignServerBusinessUsecasesInitPathway();
private pathway: PathwayDesignServerBusinessEntitiesPathway | undefined;

@when('I want to initiate a pathway with these data')
public whenIInitiateAPathway(dataTable: DataTable) {
const data =
dataTable.hashes()[0] as unknown as PathwayDesignServerBusinessEntitiesPathwayInitDto;
this.pathway = this.initPathwayUsecase.execute({
name: data.name,
description: data.description,
field: data.field,
});
}

@then('I should retrieve a pathway initiated with its data')
public thenIShouldSeeAPathwayInitiated(dataTable: DataTable) {
const data =
dataTable.hashes()[0] as unknown as PathwayDesignServerBusinessEntitiesPathwayInitDto;
assert.equal(this.pathway?.name, data.name);
assert.equal(this.pathway?.description, data.description);
assert.equal(this.pathway?.field, data.field);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
PathwayDesignServerBusinessEntitiesPathway,
type PathwayDesignServerBusinessEntitiesPathwayInitDto,
} from '@bewoak/pathway-design-server-business-entities-pathway';

export class PathwayDesignServerBusinessUsecasesInitPathway {
execute({
name,
description,
field,
}: PathwayDesignServerBusinessEntitiesPathwayInitDto) {
const pathway = new PathwayDesignServerBusinessEntitiesPathway();
pathway.init({
name,
description,
field,
});

return pathway;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../../../../tsconfig.base.json",
"extends": "../../../../../../tsconfig.base.json",
"compilerOptions": {
"module": "es2022",
"forceConsistentCasingInFileNames": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../../../../dist/out-tsc",
"outDir": "../../../../../../dist/out-tsc",
"types": ["node"]
},
"include": ["src/**/*.ts"],
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@bewoak/pathway-design-creation-server-business-entities-pathway": [
"libs/pathway-design/creation/server/business/entities/pathway/src/index.ts"
"@bewoak/pathway-design-server-business-entities-pathway": [
"libs/pathway-design/server/business/entities/pathway/src/index.ts"
],
"@bewoak/pathway-design-creation-server-business-usescases-init-pathway": [
"libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts"
"@bewoak/pathway-design-server-business-usescases-init-pathway": [
"libs/pathway-design/server/business/usecases/init-pathway/src/index.ts"
]
}
},
Expand Down

0 comments on commit 0280431

Please sign in to comment.