Skip to content

Commit

Permalink
Sdtt 239 use aliases for imports in oslo uml transformer code (#38)
Browse files Browse the repository at this point in the history
* Added `@interfaces/` alias inside the project

* Replaced `@interfaces/` from both index.ts files

* Added `module-alias` so Node can recognize the aliases

* Added POC for aliases inside the project

* Added _moduleAlias to final package.json

* Add import of `module-alias` to each runner.ts file across project

* Remove aliases from packages that don't need them

* Renamed interfaces alias to enum since it does not use interfaces alias

* Updated the aliases to the root of the package, rather than directly to a subdir such as /interfaces or /enums

* Updated imports to make use of aliases for all enums

* Replaced all ./utils paths with an alias

* Replaces all ./types with an alias

* Update ./config paths to use an alias

* Replaced all ../ paths with their respective alias

* Replaced all ./ paths with their respective alias
  • Loading branch information
KristofVDB1 authored Jan 18, 2024
1 parent 3f391ab commit de0e841
Show file tree
Hide file tree
Showing 81 changed files with 389 additions and 1,859 deletions.
3 changes: 2 additions & 1 deletion packages/oslo-converter-stakeholders/bin/runner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
import { StakeholdersConversionServiceRunner } from '../lib/StakeholdersConversionServiceRunner';
import 'module-alias/register';
import { StakeholdersConversionServiceRunner } from '@oslo-converter-stakeholders/StakeholdersConversionServiceRunner';
// eslint-disable-next-line no-sync
new StakeholdersConversionServiceRunner().runCliSync(process);
8 changes: 5 additions & 3 deletions packages/oslo-converter-stakeholders/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'reflect-metadata';
export * from './lib/config/StakeholdersConversionServiceConfiguration';
export * from './lib/StakeholdersConversionService';
export * from './lib/StakeholdersConversionServiceRunner';
import 'module-alias/register';

export * from '@oslo-converter-stakeholders/config/StakeholdersConversionServiceConfiguration';
export * from '@oslo-converter-stakeholders/StakeholdersConversionService';
export * from '@oslo-converter-stakeholders/StakeholdersConversionServiceRunner';
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { fetchFileOrUrl, Logger, ServiceIdentifier } from '@oslo-flanders/core';

import { parse } from 'csv-parse';
import { inject, injectable } from 'inversify';
import { StakeholdersConversionServiceConfiguration } from './config/StakeholdersConversionServiceConfiguration';
import { ContributorType } from './enums/ContributorType';
import { context } from './utils/JsonLdContext';
import { ToJsonLdTransformer } from './utils/ToJsonLdTransformer';
import {
StakeholdersConversionServiceConfiguration,
} from '@oslo-converter-stakeholders/config/StakeholdersConversionServiceConfiguration';
import { ContributorType } from '@oslo-converter-stakeholders/enums/ContributorType';
import { context } from '@oslo-converter-stakeholders/utils/JsonLdContext';
import { ToJsonLdTransformer } from '@oslo-converter-stakeholders/utils/ToJsonLdTransformer';

@injectable()
export class StakeholdersConversionService implements IService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { CliArgv } from '@oslo-flanders/core';
import { AppRunner, LOG_LEVELS } from '@oslo-flanders/core';
import yargs from 'yargs';
import { container } from './config/DependencyInjectionConfig';
import type { StakeholdersConversionServiceConfiguration } from './config/StakeholdersConversionServiceConfiguration';
import type { StakeholdersConversionService } from './StakeholdersConversionService';
import { container } from '@oslo-converter-stakeholders/config/DependencyInjectionConfig';
import type {
StakeholdersConversionServiceConfiguration,
} from '@oslo-converter-stakeholders/config/StakeholdersConversionServiceConfiguration';
import type { StakeholdersConversionService } from '@oslo-converter-stakeholders/StakeholdersConversionService';

export class StakeholdersConversionServiceRunner extends
AppRunner<StakeholdersConversionService, StakeholdersConversionServiceConfiguration> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { IConfiguration, IService } from '@oslo-flanders/core';
import { ServiceIdentifier } from '@oslo-flanders/core';
import { Container } from 'inversify';
import { StakeholdersConversionService } from '../StakeholdersConversionService';
import { StakeholdersConversionServiceConfiguration } from './StakeholdersConversionServiceConfiguration';
import {
StakeholdersConversionServiceConfiguration,
} from '@oslo-converter-stakeholders/config/StakeholdersConversionServiceConfiguration';
import { StakeholdersConversionService } from '@oslo-converter-stakeholders/StakeholdersConversionService';

export const container = new Container();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TransformCallback } from 'stream';
import { Transform } from 'stream';
import { ContributorType } from '../enums/ContributorType';
import { ContributorType } from '@oslo-converter-stakeholders/enums/ContributorType';

export class ToJsonLdTransformer extends Transform {
private readonly columnNames = ['Voornaam', 'Naam', 'Affiliatie', 'E-mail', 'Website'];
Expand Down
8 changes: 7 additions & 1 deletion packages/oslo-converter-stakeholders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-converter-stakeholders-oslo#readme",
"license": "MIT",
"main": "index.js",
"_moduleAliases": {
"@oslo-converter-stakeholders": "./lib"
},
"bin": {
"oslo-stakeholders-converter": "./bin/runner.js"
},
Expand Down Expand Up @@ -35,5 +38,8 @@
"reflect-metadata": "^0.1.13",
"yargs": "^17.6.0"
},
"gitHead": "f749c71908781f533e0e35f0e3394ce43a8dd7c0"
"gitHead": "f749c71908781f533e0e35f0e3394ce43a8dd7c0",
"devDependencies": {
"module-alias": "^2.2.3"
}
}
3 changes: 2 additions & 1 deletion packages/oslo-converter-uml-ea/bin/runner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
import { EaUmlConversionServiceRunner } from '../lib/EaUmlConversionServiceRunner';
import 'module-alias/register';
import { EaUmlConversionServiceRunner } from '@oslo-converter-uml-ea/EaUmlConversionServiceRunner';
// eslint-disable-next-line no-sync
new EaUmlConversionServiceRunner().runCliSync(process);
38 changes: 20 additions & 18 deletions packages/oslo-converter-uml-ea/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import 'reflect-metadata';
export * from './lib/ConverterHandlerService';
export * from './lib/EaUmlConversionService';
export * from './lib/EaUmlConversionServiceRunner';
export * from './lib/UriRegistry';
export * from './lib/OutputHandlerService';
export * from './lib/converter-handlers/AttributeConverterHandler';
export * from './lib/converter-handlers/ElementConverterHandler';
export * from './lib/converter-handlers/PackageConverterHandler';
export * from './lib/converter-handlers/ConnectorConverterHandler';
export * from './lib/config/DependencyInjectionConfig';
export * from './lib/config/EaUmlConverterConfiguration';
export * from './lib/config/EaUmlConverterServiceIdentifier';
export * from './lib/enums/CasingTypes';
export * from './lib/enums/DataTypes';
export * from './lib/enums/TagNames';
export * from './lib/interfaces/ConverterHandler';
export * from './lib/utils/utils';
export * from './lib/output-handlers/JsonLdOutputHandler';
import 'module-alias/register';

export * from '@oslo-converter-uml-ea/ConverterHandlerService';
export * from '@oslo-converter-uml-ea/EaUmlConversionService';
export * from '@oslo-converter-uml-ea/EaUmlConversionServiceRunner';
export * from '@oslo-converter-uml-ea/UriRegistry';
export * from '@oslo-converter-uml-ea/OutputHandlerService';
export * from '@oslo-converter-uml-ea/converter-handlers/AttributeConverterHandler';
export * from '@oslo-converter-uml-ea/converter-handlers/ElementConverterHandler';
export * from '@oslo-converter-uml-ea/converter-handlers/PackageConverterHandler';
export * from '@oslo-converter-uml-ea/converter-handlers/ConnectorConverterHandler';
export * from '@oslo-converter-uml-ea/config/DependencyInjectionConfig';
export * from '@oslo-converter-uml-ea/config/EaUmlConverterConfiguration';
export * from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
export * from '@oslo-converter-uml-ea/enums/CasingTypes';
export * from '@oslo-converter-uml-ea/enums/DataTypes';
export * from '@oslo-converter-uml-ea/enums/TagNames';
export * from '@oslo-converter-uml-ea/interfaces/ConverterHandler';
export * from '@oslo-converter-uml-ea/utils/utils';
export * from '@oslo-converter-uml-ea/output-handlers/JsonLdOutputHandler';
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type {
} from '@oslo-flanders/ea-uml-extractor';

import { injectable } from 'inversify';
import { container } from './config/DependencyInjectionConfig';
import { EaUmlConverterServiceIdentifier } from './config/EaUmlConverterServiceIdentifier';
import type { IConnectorNormalisationCase } from './interfaces/IConnectorNormalisationCase';
import { container } from '@oslo-converter-uml-ea/config/DependencyInjectionConfig';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import type { IConnectorNormalisationCase } from '@oslo-converter-uml-ea/interfaces/IConnectorNormalisationCase';

@injectable()
export class ConnectorNormalisationService {
Expand Down
8 changes: 4 additions & 4 deletions packages/oslo-converter-uml-ea/lib/ConverterHandlerService.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Logger } from '@oslo-flanders/core';
import { QuadStore } from '@oslo-flanders/core';
import type { DataRegistry, EaObject } from '@oslo-flanders/ea-uml-extractor';
import { container } from './config/DependencyInjectionConfig';
import { EaUmlConverterServiceIdentifier } from './config/EaUmlConverterServiceIdentifier';
import type { ConverterHandler } from './interfaces/ConverterHandler';
import { UriRegistry } from './UriRegistry';
import { container } from '@oslo-converter-uml-ea/config/DependencyInjectionConfig';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import type { ConverterHandler } from '@oslo-converter-uml-ea/interfaces/ConverterHandler';
import { UriRegistry } from '@oslo-converter-uml-ea/UriRegistry';

export class ConverterHandlerService<T extends EaObject> {
public readonly logger: Logger;
Expand Down
8 changes: 4 additions & 4 deletions packages/oslo-converter-uml-ea/lib/EaUmlConversionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type { QuadStore, IService } from '@oslo-flanders/core';
import { DataRegistry } from '@oslo-flanders/ea-uml-extractor';
import { inject, injectable } from 'inversify';
import { DataFactory } from 'rdf-data-factory';
import { EaUmlConverterConfiguration } from './config/EaUmlConverterConfiguration';
import { EaUmlConverterServiceIdentifier } from './config/EaUmlConverterServiceIdentifier';
import { ConverterHandlerService } from './ConverterHandlerService';
import { OutputHandlerService } from './OutputHandlerService';
import { EaUmlConverterConfiguration } from '@oslo-converter-uml-ea/config/EaUmlConverterConfiguration';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { ConverterHandlerService } from '@oslo-converter-uml-ea/ConverterHandlerService';
import { OutputHandlerService } from '@oslo-converter-uml-ea/OutputHandlerService';

@injectable()
export class EaUmlConversionService implements IService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { CliArgv } from '@oslo-flanders/core';
import { LOG_LEVELS, AppRunner } from '@oslo-flanders/core';

import yargs from 'yargs';
import { container } from './config/DependencyInjectionConfig';
import type { EaUmlConverterConfiguration } from './config/EaUmlConverterConfiguration';
import type { EaUmlConversionService } from './EaUmlConversionService';
import { container } from '@oslo-converter-uml-ea/config/DependencyInjectionConfig';
import type { EaUmlConverterConfiguration } from '@oslo-converter-uml-ea/config/EaUmlConverterConfiguration';
import type { EaUmlConversionService } from '@oslo-converter-uml-ea/EaUmlConversionService';

export class EaUmlConversionServiceRunner extends AppRunner<EaUmlConversionService, EaUmlConverterConfiguration> {
public async runCli(argv: CliArgv): Promise<void> {
Expand Down
6 changes: 3 additions & 3 deletions packages/oslo-converter-uml-ea/lib/OutputHandlerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { createWriteStream } from 'fs';
import type { IOutputHandler, QuadStore } from '@oslo-flanders/core';
import { inject, injectable } from 'inversify';
import { EaUmlConverterConfiguration } from './config/EaUmlConverterConfiguration';
import { EaUmlConverterServiceIdentifier } from './config/EaUmlConverterServiceIdentifier';
import { JsonLdOutputHandler } from './output-handlers/JsonLdOutputHandler';
import { EaUmlConverterConfiguration } from '@oslo-converter-uml-ea/config/EaUmlConverterConfiguration';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { JsonLdOutputHandler } from '@oslo-converter-uml-ea/output-handlers/JsonLdOutputHandler';

@injectable()
export class OutputHandlerService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@ import type {
NormalizedConnector,
} from '@oslo-flanders/ea-uml-extractor';
import { Container } from 'inversify';
import { EaUmlConverterConfiguration } from '@oslo-converter-uml-ea/config/EaUmlConverterConfiguration';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { AssociationWithAssociationClassConnectorCase }
from '../connector-normalisation-cases/AssociationWithAssociationClassConnectorCase';
from '@oslo-converter-uml-ea/connector-normalisation-cases/AssociationWithAssociationClassConnectorCase';
import { AssociationWithDestinationRoleConnectorCase } from
'../connector-normalisation-cases/AssociationWithDestinationRoleConnectorCase';
import { AssociationWithNameConnectorCase } from '../connector-normalisation-cases/AssociationWithNameConnectorCase';
'@oslo-converter-uml-ea/connector-normalisation-cases/AssociationWithDestinationRoleConnectorCase';
import {
AssociationWithNameConnectorCase,
} from '@oslo-converter-uml-ea/connector-normalisation-cases/AssociationWithNameConnectorCase';
import { AssocationWithSourceRoleConnectorCase } from
'../connector-normalisation-cases/AssociationWithSourceRoleConnectorCase';
'@oslo-converter-uml-ea/connector-normalisation-cases/AssociationWithSourceRoleConnectorCase';
import { SelfAssociationWithAssociationClassConnectorCase } from
'../connector-normalisation-cases/SelfAssociationWithAssociationClassConnectorCase';
'@oslo-converter-uml-ea/connector-normalisation-cases/SelfAssociationWithAssociationClassConnectorCase';
import { SelfAssociationWithNameConnectorCase } from
'../connector-normalisation-cases/SelfAssociationWithNameConnectorCase';
import { ConnectorNormalisationService } from '../ConnectorNormalisationService';
import { AttributeConverterHandler } from '../converter-handlers/AttributeConverterHandler';
import { ConnectorConverterHandler } from '../converter-handlers/ConnectorConverterHandler';
import { ElementConverterHandler } from '../converter-handlers/ElementConverterHandler';
import { PackageConverterHandler } from '../converter-handlers/PackageConverterHandler';
import { EaUmlConversionService } from '../EaUmlConversionService';
import type { ConverterHandler } from '../interfaces/ConverterHandler';
import { OutputHandlerService } from '../OutputHandlerService';
import { EaUmlConverterConfiguration } from './EaUmlConverterConfiguration';
import { EaUmlConverterServiceIdentifier } from './EaUmlConverterServiceIdentifier';
'@oslo-converter-uml-ea/connector-normalisation-cases/SelfAssociationWithNameConnectorCase';
import { ConnectorNormalisationService } from '@oslo-converter-uml-ea/ConnectorNormalisationService';
import { AttributeConverterHandler } from '@oslo-converter-uml-ea/converter-handlers/AttributeConverterHandler';
import { ConnectorConverterHandler } from '@oslo-converter-uml-ea/converter-handlers/ConnectorConverterHandler';
import { ElementConverterHandler } from '@oslo-converter-uml-ea/converter-handlers/ElementConverterHandler';
import { PackageConverterHandler } from '@oslo-converter-uml-ea/converter-handlers/PackageConverterHandler';
import { EaUmlConversionService } from '@oslo-converter-uml-ea/EaUmlConversionService';
import type { ConverterHandler } from '@oslo-converter-uml-ea/interfaces/ConverterHandler';
import { OutputHandlerService } from '@oslo-converter-uml-ea/OutputHandlerService';

export const container = new Container();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
NormalizedConnector,
} from '@oslo-flanders/ea-uml-extractor';
import { inject, injectable } from 'inversify';
import { EaUmlConverterServiceIdentifier } from '../config/EaUmlConverterServiceIdentifier';
import { TagNames } from '../enums/TagNames';
import type { IConnectorNormalisationCase } from '../interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, toPascalCase } from '../utils/utils';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { TagNames } from '@oslo-converter-uml-ea/enums/TagNames';
import type { IConnectorNormalisationCase } from '@oslo-converter-uml-ea/interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, toPascalCase } from '@oslo-converter-uml-ea/utils/utils';

@injectable()
export class AssociationWithAssociationClassConnectorCase implements IConnectorNormalisationCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
NormalizedConnector,
} from '@oslo-flanders/ea-uml-extractor';
import { inject, injectable } from 'inversify';
import { EaUmlConverterServiceIdentifier } from '../config/EaUmlConverterServiceIdentifier';
import { TagNames } from '../enums/TagNames';
import type { IConnectorNormalisationCase } from '../interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, updateNameTag } from '../utils/utils';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { TagNames } from '@oslo-converter-uml-ea/enums/TagNames';
import type { IConnectorNormalisationCase } from '@oslo-converter-uml-ea/interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, updateNameTag } from '@oslo-converter-uml-ea/utils/utils';

@injectable()
export class AssociationWithDestinationRoleConnectorCase implements IConnectorNormalisationCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
NormalizedConnector,
} from '@oslo-flanders/ea-uml-extractor';
import { inject, injectable } from 'inversify';
import { EaUmlConverterServiceIdentifier } from '../config/EaUmlConverterServiceIdentifier';
import { TagNames } from '../enums/TagNames';
import type { IConnectorNormalisationCase } from '../interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, toPascalCase, updateNameTag } from '../utils/utils';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { TagNames } from '@oslo-converter-uml-ea/enums/TagNames';
import type { IConnectorNormalisationCase } from '@oslo-converter-uml-ea/interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, toPascalCase, updateNameTag } from '@oslo-converter-uml-ea/utils/utils';

@injectable()
export class AssociationWithNameConnectorCase implements IConnectorNormalisationCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
NormalizedConnector,
} from '@oslo-flanders/ea-uml-extractor';
import { inject, injectable } from 'inversify';
import { EaUmlConverterServiceIdentifier } from '../config/EaUmlConverterServiceIdentifier';
import { TagNames } from '../enums/TagNames';
import type { IConnectorNormalisationCase } from '../interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, updateNameTag } from '../utils/utils';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { TagNames } from '@oslo-converter-uml-ea/enums/TagNames';
import type { IConnectorNormalisationCase } from '@oslo-converter-uml-ea/interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, updateNameTag } from '@oslo-converter-uml-ea/utils/utils';

@injectable()
export class AssocationWithSourceRoleConnectorCase implements IConnectorNormalisationCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
NormalizedConnector,
} from '@oslo-flanders/ea-uml-extractor';
import { inject, injectable } from 'inversify';
import { EaUmlConverterServiceIdentifier } from '../config/EaUmlConverterServiceIdentifier';
import { TagNames } from '../enums/TagNames';
import type { IConnectorNormalisationCase } from '../interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, toPascalCase } from '../utils/utils';
import { EaUmlConverterServiceIdentifier } from '@oslo-converter-uml-ea/config/EaUmlConverterServiceIdentifier';
import { TagNames } from '@oslo-converter-uml-ea/enums/TagNames';
import type { IConnectorNormalisationCase } from '@oslo-converter-uml-ea/interfaces/IConnectorNormalisationCase';
import { getTagValue, toCamelCase, toPascalCase } from '@oslo-converter-uml-ea/utils/utils';

@injectable()
export class SelfAssociationWithAssociationClassConnectorCase implements IConnectorNormalisationCase {
Expand Down
Loading

0 comments on commit de0e841

Please sign in to comment.