-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Apply some refactoring debt fixes * Apply all Strict Type-Checking options from TS; * Apply all Additional Checks options from TS; * Remove all overwritten rules from tslint (except no-relative-imports); * Fix all erros; * Use namespaces for Factories; * Rely on interfaces * Add Jest for a faster test run * First Handbook test added * Add Namespaces Handbook test case
- Loading branch information
Marcos Vinícius Rubido
authored
May 22, 2019
1 parent
2d78715
commit 5cda20f
Showing
85 changed files
with
6,844 additions
and
2,139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#Compiled files | ||
dist | ||
*.js | ||
!*.spec.js | ||
|
||
#IDE | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as os from 'os'; | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for an Enum within a typescript file. | ||
*/ | ||
export class Enum implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.ENUM; | ||
public readonly name: string; | ||
public values: IComponentComposite[] = []; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
const result: string[] = []; | ||
let declaration: string = `enum ${this.name}`; | ||
if (this.values.length > 0) { | ||
declaration += ' {'; | ||
} | ||
result.push(declaration); | ||
this.values.forEach((enumValue: IComponentComposite): void => { | ||
result.push(` ${enumValue.toPUML()}`); | ||
}); | ||
if (this.values.length > 0) { | ||
result.push('}'); | ||
} | ||
|
||
return result.join(os.EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for the value or member of an enum within typescript | ||
*/ | ||
export class EnumValue implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.PROPERTY; | ||
public readonly name: string; | ||
public value: string | undefined; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
return this.name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as os from 'os'; | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for an interface within typescript | ||
*/ | ||
export class Interface implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.INTERFACE; | ||
public readonly name: string; | ||
public members: IComponentComposite[] = []; | ||
public extendsInterface: string[] = []; | ||
public typeParameters: IComponentComposite[] = []; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
const result: string[] = []; | ||
const firstLine: string[] = []; | ||
firstLine.push(`interface ${this.name}`); | ||
if (this.typeParameters.length > 0) { | ||
firstLine.push('<'); | ||
firstLine.push(this.typeParameters | ||
.map((typeParameter: IComponentComposite): string => typeParameter.toPUML()) | ||
.join(', ')); | ||
firstLine.push('>'); | ||
} | ||
if (this.extendsInterface.length > 0) { | ||
firstLine.push(` extends ${this.extendsInterface.join(', ')}`); | ||
} | ||
if (this.members.length > 0) { | ||
firstLine.push(' {'); | ||
} | ||
result.push(firstLine.join('')); | ||
this.members.forEach((member: IComponentComposite): void => { | ||
result.push(` ${member.toPUML()}`); | ||
}); | ||
if (this.members.length > 0) { | ||
result.push('}'); | ||
} | ||
|
||
return result.join(os.EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as os from 'os'; | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for a namespace within typescript | ||
*/ | ||
export class Namespace implements IComponentComposite { | ||
public readonly name: string; | ||
public readonly componentKind: ComponentKind = ComponentKind.NAMESPACE; | ||
public parts: IComponentComposite[] = []; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
const result: string[] = []; | ||
const declaration: string[] = []; | ||
declaration.push(`namespace ${this.name}`); | ||
if (this.parts.length > 0) { | ||
declaration.push(' {'); | ||
} | ||
result.push(declaration.join('')); | ||
this.parts.forEach((part: IComponentComposite): void => { | ||
result.push( | ||
part.toPUML() | ||
.replace(/^(?!\s*$)/gm, ' ') | ||
); | ||
}); | ||
if (this.parts.length > 0) { | ||
result.push('}'); | ||
} | ||
|
||
return result.join(os.EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for a parameter within typescript | ||
*/ | ||
export class Parameter implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.PARAMETER; | ||
public readonly name: string; | ||
public hasInitializer: boolean = false; | ||
public isOptional: boolean = false; | ||
public parameterType: string = 'any'; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
return `${this.name}${this.isOptional || this.hasInitializer ? '?' : ''}: ${this.parameterType}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
import { Modifier } from '../Models/Modifier'; | ||
|
||
/** | ||
* Represents the metadata for a property within typescript | ||
*/ | ||
export class Property implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.PROPERTY; | ||
public readonly name: string; | ||
public modifier: Modifier = 'public'; | ||
public returnType: string = 'any'; | ||
public isOptional: boolean = false; | ||
public isStatic: boolean = false; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
return `${{ public: '+', private: '-', protected: '#' }[this.modifier]}${(this.isStatic ? '{static} ' : '') | ||
}${this.name}${(this.isOptional ? '?' : '')}: ${this.returnType}`; | ||
} | ||
} |
Oops, something went wrong.