tshex-cli 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/main.js CHANGED
@@ -1,84 +1,84 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import fs from 'fs';
4
- import path from 'path';
5
- program
6
- .name('tshex')
7
- .version('1.0.0')
8
- .option('--lib <name>', 'creates a new library with it\'s shared directory')
9
- .option('--ctx <name>', 'creates a new context')
10
- .option('--cls <name>', 'creates a new class')
11
- .option('--rfc <name>', 'creates a new react functional component')
12
- .option('--dir <path>', 'sets the directory to create the new item')
13
- .parse(process.argv);
14
- function executeCreateLib(templatesDir, libraryDir) {
15
- try {
16
- fs.cpSync(path.join(templatesDir, 'lib'), libraryDir, {
17
- recursive: true,
18
- filter: function (src) { return (!src.endsWith('.gitkeep')); }
19
- });
20
- console.log('Library created successfully');
21
- }
22
- catch (err) {
23
- console.error(err);
24
- }
25
- }
26
- function executeCreateContext(templatesDir, contextDir) {
27
- try {
28
- fs.cpSync(path.join(templatesDir, 'ctx'), contextDir, {
29
- recursive: true,
30
- filter: function (src) { return (!src.endsWith('.gitkeep')); }
31
- });
32
- console.log('Context created successfully');
33
- }
34
- catch (err) {
35
- console.error(err);
36
- }
37
- }
38
- function executeCreateClass(templatesDir, classDir) {
39
- try {
40
- fs.cpSync(path.join(templatesDir, 'cls.example'), classDir, {});
41
- console.log('Class created successfully');
42
- }
43
- catch (err) {
44
- console.error(err);
45
- }
46
- }
47
- function executeCreateReactFunctionalComponent(templatesDir, classDir) {
48
- try {
49
- fs.cpSync(path.join(templatesDir, 'rfc.example'), classDir, {});
50
- console.log('React component created successfully');
51
- }
52
- catch (err) {
53
- console.error(err);
54
- }
55
- }
56
- (function () {
57
- var _a;
58
- var templatesDir = path.join(import.meta.dirname, '..', 'templates');
59
- var options = program.opts();
60
- var targetDir = path.resolve((_a = options.dir) !== null && _a !== void 0 ? _a : process.cwd());
61
- if (Object.keys(options).length === 0) {
62
- program.help();
63
- return;
64
- }
65
- if (!fs.existsSync(targetDir)) {
66
- fs.mkdirSync(targetDir, { recursive: true });
67
- }
68
- if (options.lib !== undefined) {
69
- targetDir = path.join(targetDir, options.lib);
70
- executeCreateLib(templatesDir, targetDir);
71
- }
72
- if (options.ctx !== undefined) {
73
- targetDir = path.join(targetDir, options.ctx);
74
- executeCreateContext(templatesDir, targetDir);
75
- }
76
- if (options.cls !== undefined) {
77
- var target = path.join(targetDir, options.cls + '.ts');
78
- executeCreateClass(templatesDir, target);
79
- }
80
- if (options.rfc !== undefined) {
81
- var target = path.join(targetDir, options.rfc + '.tsx');
82
- executeCreateReactFunctionalComponent(templatesDir, target);
83
- }
84
- })();
1
+ #!/usr/bin/env node
2
+ import { program } from 'commander';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ program
6
+ .name('tshex')
7
+ .version('1.0.0')
8
+ .option('--lib <name>', 'creates a new library with it\'s shared directory')
9
+ .option('--ctx <name>', 'creates a new context')
10
+ .option('--cls <name>', 'creates a new class')
11
+ .option('--rfc <name>', 'creates a new react functional component')
12
+ .option('--dir <path>', 'sets the directory to create the new item')
13
+ .parse(process.argv);
14
+ function executeCreateLib(templatesDir, libraryDir) {
15
+ try {
16
+ fs.cpSync(path.join(templatesDir, 'lib'), libraryDir, {
17
+ recursive: true,
18
+ filter: function (src) { return (!src.endsWith('.gitkeep')); }
19
+ });
20
+ console.log('Library created successfully');
21
+ }
22
+ catch (err) {
23
+ console.error(err);
24
+ }
25
+ }
26
+ function executeCreateContext(templatesDir, contextDir) {
27
+ try {
28
+ fs.cpSync(path.join(templatesDir, 'ctx'), contextDir, {
29
+ recursive: true,
30
+ filter: function (src) { return (!src.endsWith('.gitkeep')); }
31
+ });
32
+ console.log('Context created successfully');
33
+ }
34
+ catch (err) {
35
+ console.error(err);
36
+ }
37
+ }
38
+ function executeCreateClass(templatesDir, classDir) {
39
+ try {
40
+ fs.cpSync(path.join(templatesDir, 'cls.example'), classDir, {});
41
+ console.log('Class created successfully');
42
+ }
43
+ catch (err) {
44
+ console.error(err);
45
+ }
46
+ }
47
+ function executeCreateReactFunctionalComponent(templatesDir, classDir) {
48
+ try {
49
+ fs.cpSync(path.join(templatesDir, 'rfc.example'), classDir, {});
50
+ console.log('React component created successfully');
51
+ }
52
+ catch (err) {
53
+ console.error(err);
54
+ }
55
+ }
56
+ (function () {
57
+ var _a;
58
+ var templatesDir = path.join(import.meta.dirname, '..', 'templates');
59
+ var options = program.opts();
60
+ var targetDir = path.resolve((_a = options.dir) !== null && _a !== void 0 ? _a : process.cwd());
61
+ if (Object.keys(options).length === 0) {
62
+ program.help();
63
+ return;
64
+ }
65
+ if (!fs.existsSync(targetDir)) {
66
+ fs.mkdirSync(targetDir, { recursive: true });
67
+ }
68
+ if (options.lib !== undefined) {
69
+ targetDir = path.join(targetDir, options.lib);
70
+ executeCreateLib(templatesDir, targetDir);
71
+ }
72
+ if (options.ctx !== undefined) {
73
+ targetDir = path.join(targetDir, options.ctx);
74
+ executeCreateContext(templatesDir, targetDir);
75
+ }
76
+ if (options.cls !== undefined) {
77
+ var target = path.join(targetDir, options.cls + '.ts');
78
+ executeCreateClass(templatesDir, target);
79
+ }
80
+ if (options.rfc !== undefined) {
81
+ var target = path.join(targetDir, options.rfc + '.tsx');
82
+ executeCreateReactFunctionalComponent(templatesDir, target);
83
+ }
84
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tshex-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "author": "https://github.com/virtualitems/",
5
5
  "description": "Typescript Hexagonal Architecture CLI",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  * @description
14
14
  * function arguments are Entity
15
15
  */
16
- export default abstract class Facade
16
+ export default abstract class Service
17
17
  {
18
18
 
19
19
  [property: string]: unknown;
@@ -21,7 +21,7 @@ export default abstract class Event
21
21
 
22
22
  public readonly timestamp: number;
23
23
 
24
- public readonly details?: Record<string, unknown>;
24
+ public readonly details: Record<string, unknown>;
25
25
 
26
26
  // protected ATTRIBUTES
27
27
 
@@ -38,7 +38,7 @@ export default abstract class Event
38
38
  public constructor(timestamp: number, details?: Record<string, unknown>)
39
39
  {
40
40
  this.timestamp = timestamp;
41
- this.details = details;
41
+ this.details = details ?? {};
42
42
  }
43
43
 
44
44
  // public METHODS
@@ -10,11 +10,11 @@
10
10
 
11
11
 
12
12
  /**
13
- * @description A service is a class that contains business logic that doesn't belong to any entity.
13
+ * @description An Aggregate is a class that contains business logic that doesn't belong to any entity.
14
14
  * It is used to perform operations that don't fit into an entity or involve multiple entities.
15
15
  * Normally, method arguments are entities.
16
16
  */
17
- export default abstract class Service
17
+ export default abstract class Aggregate
18
18
  {
19
19
 
20
20
  [property: string]: unknown;