nest-hex 0.2.0 → 0.3.2
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/README.md +155 -267
- package/dist/src/cli/bin.js +2644 -0
- package/dist/src/cli/commands/index.d.ts +23 -0
- package/dist/src/cli/commands/index.js +2609 -0
- package/dist/src/cli/config/defaults.d.ts +74 -0
- package/dist/src/cli/config/defaults.js +76 -0
- package/dist/src/cli/config/define-config.d.ts +74 -0
- package/dist/src/cli/config/define-config.js +62 -0
- package/dist/src/cli/config/loader.d.ts +74 -0
- package/dist/src/cli/config/loader.js +106 -0
- package/dist/src/cli/config/validator.d.ts +81 -0
- package/dist/src/cli/config/validator.js +108 -0
- package/dist/src/cli/generators/adapter.generator.d.ts +235 -0
- package/dist/src/cli/generators/adapter.generator.js +377 -0
- package/dist/src/cli/generators/base.generator.d.ts +190 -0
- package/dist/src/cli/generators/base.generator.js +312 -0
- package/dist/src/cli/generators/index.d.ts +264 -0
- package/dist/src/cli/generators/index.js +467 -0
- package/dist/src/cli/generators/port.generator.d.ts +211 -0
- package/dist/src/cli/generators/port.generator.js +364 -0
- package/dist/src/cli/generators/service.generator.d.ts +208 -0
- package/dist/src/cli/generators/service.generator.js +340 -0
- package/dist/src/cli/index.d.ts +74 -0
- package/dist/src/cli/index.js +69 -0
- package/dist/src/cli/types/config.types.d.ts +73 -0
- package/dist/src/cli/types/config.types.js +56 -0
- package/dist/src/cli/types/generator.types.d.ts +46 -0
- package/dist/src/cli/types/generator.types.js +56 -0
- package/dist/src/cli/types/index.d.ts +121 -0
- package/dist/src/cli/types/index.js +56 -0
- package/dist/src/cli/types/template.types.d.ts +28 -0
- package/dist/src/cli/types/template.types.js +56 -0
- package/dist/src/cli/ui/components/index.d.ts +97 -0
- package/dist/src/cli/ui/components/index.js +1507 -0
- package/dist/src/cli/utils/file-writer.d.ts +17 -0
- package/dist/src/cli/utils/file-writer.js +100 -0
- package/dist/src/cli/utils/linter-detector.d.ts +12 -0
- package/dist/src/cli/utils/linter-detector.js +128 -0
- package/dist/src/cli/utils/linter-runner.d.ts +17 -0
- package/dist/src/cli/utils/linter-runner.js +101 -0
- package/dist/src/cli/utils/name-transformer.d.ts +18 -0
- package/dist/src/cli/utils/name-transformer.js +90 -0
- package/dist/src/cli/utils/path-resolver.d.ts +5 -0
- package/dist/src/cli/utils/path-resolver.js +78 -0
- package/dist/src/cli/utils/port-scanner.d.ts +93 -0
- package/dist/src/cli/utils/port-scanner.js +104 -0
- package/dist/src/cli/utils/template-renderer.d.ts +30 -0
- package/dist/src/cli/utils/template-renderer.js +95 -0
- package/dist/{index.d.ts → src/index.d.ts} +60 -30
- package/dist/{index.js → src/index.js} +45 -13
- package/package.json +10 -10
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for nest-hex CLI
|
|
3
|
+
*/
|
|
4
|
+
interface NestHexConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Output directory configuration
|
|
7
|
+
*/
|
|
8
|
+
output?: {
|
|
9
|
+
/**
|
|
10
|
+
* Directory for generated ports
|
|
11
|
+
* @default 'src/ports'
|
|
12
|
+
*/
|
|
13
|
+
portsDir?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Directory for generated adapters
|
|
16
|
+
* @default 'src/adapters'
|
|
17
|
+
*/
|
|
18
|
+
adaptersDir?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Naming conventions
|
|
22
|
+
*/
|
|
23
|
+
naming?: {
|
|
24
|
+
/**
|
|
25
|
+
* Suffix for port tokens
|
|
26
|
+
* @default 'PORT'
|
|
27
|
+
*/
|
|
28
|
+
portSuffix?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Suffix for adapter classes
|
|
31
|
+
* @default 'Adapter'
|
|
32
|
+
*/
|
|
33
|
+
adapterSuffix?: string;
|
|
34
|
+
/**
|
|
35
|
+
* File naming case
|
|
36
|
+
* @default 'kebab'
|
|
37
|
+
*/
|
|
38
|
+
fileCase?: "kebab" | "camel" | "pascal";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Code style preferences
|
|
42
|
+
*/
|
|
43
|
+
style?: {
|
|
44
|
+
/**
|
|
45
|
+
* Indentation style
|
|
46
|
+
* @default 'tab'
|
|
47
|
+
*/
|
|
48
|
+
indent?: "tab" | 2 | 4;
|
|
49
|
+
/**
|
|
50
|
+
* Quote style
|
|
51
|
+
* @default 'single'
|
|
52
|
+
*/
|
|
53
|
+
quotes?: "single" | "double";
|
|
54
|
+
/**
|
|
55
|
+
* Use semicolons
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
semicolons?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Custom template paths
|
|
62
|
+
*/
|
|
63
|
+
templates?: {
|
|
64
|
+
portModule?: string;
|
|
65
|
+
portToken?: string;
|
|
66
|
+
portInterface?: string;
|
|
67
|
+
portService?: string;
|
|
68
|
+
adapterModule?: string;
|
|
69
|
+
adapterService?: string;
|
|
70
|
+
adapterTypes?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
declare const defaultConfig: Required<NestHexConfig>;
|
|
74
|
+
export { defaultConfig };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var import_node_module = require("node:module");
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
+
for (let key of __getOwnPropNames(mod))
|
|
12
|
+
if (!__hasOwnProp.call(to, key))
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: () => mod[key],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
20
|
+
var __toCommonJS = (from) => {
|
|
21
|
+
var entry = __moduleCache.get(from), desc;
|
|
22
|
+
if (entry)
|
|
23
|
+
return entry;
|
|
24
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
26
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
27
|
+
get: () => from[key],
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
}));
|
|
30
|
+
__moduleCache.set(from, entry);
|
|
31
|
+
return entry;
|
|
32
|
+
};
|
|
33
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, {
|
|
37
|
+
get: all[name],
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
set: (newValue) => all[name] = () => newValue
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
44
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
45
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
46
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
+
else
|
|
48
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
49
|
+
if (d = decorators[i])
|
|
50
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
51
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/cli/config/defaults.ts
|
|
55
|
+
var exports_defaults = {};
|
|
56
|
+
__export(exports_defaults, {
|
|
57
|
+
defaultConfig: () => defaultConfig
|
|
58
|
+
});
|
|
59
|
+
module.exports = __toCommonJS(exports_defaults);
|
|
60
|
+
var defaultConfig = {
|
|
61
|
+
output: {
|
|
62
|
+
portsDir: "src/ports",
|
|
63
|
+
adaptersDir: "src/adapters"
|
|
64
|
+
},
|
|
65
|
+
naming: {
|
|
66
|
+
portSuffix: "PORT",
|
|
67
|
+
adapterSuffix: "Adapter",
|
|
68
|
+
fileCase: "kebab"
|
|
69
|
+
},
|
|
70
|
+
style: {
|
|
71
|
+
indent: "tab",
|
|
72
|
+
quotes: "single",
|
|
73
|
+
semicolons: true
|
|
74
|
+
},
|
|
75
|
+
templates: {}
|
|
76
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for nest-hex CLI
|
|
3
|
+
*/
|
|
4
|
+
interface NestHexConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Output directory configuration
|
|
7
|
+
*/
|
|
8
|
+
output?: {
|
|
9
|
+
/**
|
|
10
|
+
* Directory for generated ports
|
|
11
|
+
* @default 'src/ports'
|
|
12
|
+
*/
|
|
13
|
+
portsDir?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Directory for generated adapters
|
|
16
|
+
* @default 'src/adapters'
|
|
17
|
+
*/
|
|
18
|
+
adaptersDir?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Naming conventions
|
|
22
|
+
*/
|
|
23
|
+
naming?: {
|
|
24
|
+
/**
|
|
25
|
+
* Suffix for port tokens
|
|
26
|
+
* @default 'PORT'
|
|
27
|
+
*/
|
|
28
|
+
portSuffix?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Suffix for adapter classes
|
|
31
|
+
* @default 'Adapter'
|
|
32
|
+
*/
|
|
33
|
+
adapterSuffix?: string;
|
|
34
|
+
/**
|
|
35
|
+
* File naming case
|
|
36
|
+
* @default 'kebab'
|
|
37
|
+
*/
|
|
38
|
+
fileCase?: "kebab" | "camel" | "pascal";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Code style preferences
|
|
42
|
+
*/
|
|
43
|
+
style?: {
|
|
44
|
+
/**
|
|
45
|
+
* Indentation style
|
|
46
|
+
* @default 'tab'
|
|
47
|
+
*/
|
|
48
|
+
indent?: "tab" | 2 | 4;
|
|
49
|
+
/**
|
|
50
|
+
* Quote style
|
|
51
|
+
* @default 'single'
|
|
52
|
+
*/
|
|
53
|
+
quotes?: "single" | "double";
|
|
54
|
+
/**
|
|
55
|
+
* Use semicolons
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
semicolons?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Custom template paths
|
|
62
|
+
*/
|
|
63
|
+
templates?: {
|
|
64
|
+
portModule?: string;
|
|
65
|
+
portToken?: string;
|
|
66
|
+
portInterface?: string;
|
|
67
|
+
portService?: string;
|
|
68
|
+
adapterModule?: string;
|
|
69
|
+
adapterService?: string;
|
|
70
|
+
adapterTypes?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
declare function defineConfig(config: NestHexConfig): NestHexConfig;
|
|
74
|
+
export { defineConfig };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var import_node_module = require("node:module");
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
+
for (let key of __getOwnPropNames(mod))
|
|
12
|
+
if (!__hasOwnProp.call(to, key))
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: () => mod[key],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
20
|
+
var __toCommonJS = (from) => {
|
|
21
|
+
var entry = __moduleCache.get(from), desc;
|
|
22
|
+
if (entry)
|
|
23
|
+
return entry;
|
|
24
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
26
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
27
|
+
get: () => from[key],
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
}));
|
|
30
|
+
__moduleCache.set(from, entry);
|
|
31
|
+
return entry;
|
|
32
|
+
};
|
|
33
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, {
|
|
37
|
+
get: all[name],
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
set: (newValue) => all[name] = () => newValue
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
44
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
45
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
46
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
+
else
|
|
48
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
49
|
+
if (d = decorators[i])
|
|
50
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
51
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/cli/config/define-config.ts
|
|
55
|
+
var exports_define_config = {};
|
|
56
|
+
__export(exports_define_config, {
|
|
57
|
+
defineConfig: () => defineConfig
|
|
58
|
+
});
|
|
59
|
+
module.exports = __toCommonJS(exports_define_config);
|
|
60
|
+
function defineConfig(config) {
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for nest-hex CLI
|
|
3
|
+
*/
|
|
4
|
+
interface NestHexConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Output directory configuration
|
|
7
|
+
*/
|
|
8
|
+
output?: {
|
|
9
|
+
/**
|
|
10
|
+
* Directory for generated ports
|
|
11
|
+
* @default 'src/ports'
|
|
12
|
+
*/
|
|
13
|
+
portsDir?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Directory for generated adapters
|
|
16
|
+
* @default 'src/adapters'
|
|
17
|
+
*/
|
|
18
|
+
adaptersDir?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Naming conventions
|
|
22
|
+
*/
|
|
23
|
+
naming?: {
|
|
24
|
+
/**
|
|
25
|
+
* Suffix for port tokens
|
|
26
|
+
* @default 'PORT'
|
|
27
|
+
*/
|
|
28
|
+
portSuffix?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Suffix for adapter classes
|
|
31
|
+
* @default 'Adapter'
|
|
32
|
+
*/
|
|
33
|
+
adapterSuffix?: string;
|
|
34
|
+
/**
|
|
35
|
+
* File naming case
|
|
36
|
+
* @default 'kebab'
|
|
37
|
+
*/
|
|
38
|
+
fileCase?: "kebab" | "camel" | "pascal";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Code style preferences
|
|
42
|
+
*/
|
|
43
|
+
style?: {
|
|
44
|
+
/**
|
|
45
|
+
* Indentation style
|
|
46
|
+
* @default 'tab'
|
|
47
|
+
*/
|
|
48
|
+
indent?: "tab" | 2 | 4;
|
|
49
|
+
/**
|
|
50
|
+
* Quote style
|
|
51
|
+
* @default 'single'
|
|
52
|
+
*/
|
|
53
|
+
quotes?: "single" | "double";
|
|
54
|
+
/**
|
|
55
|
+
* Use semicolons
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
semicolons?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Custom template paths
|
|
62
|
+
*/
|
|
63
|
+
templates?: {
|
|
64
|
+
portModule?: string;
|
|
65
|
+
portToken?: string;
|
|
66
|
+
portInterface?: string;
|
|
67
|
+
portService?: string;
|
|
68
|
+
adapterModule?: string;
|
|
69
|
+
adapterService?: string;
|
|
70
|
+
adapterTypes?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
declare function loadConfig(cwd?: string): Promise<NestHexConfig>;
|
|
74
|
+
export { loadConfig };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var import_node_module = require("node:module");
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
+
for (let key of __getOwnPropNames(mod))
|
|
12
|
+
if (!__hasOwnProp.call(to, key))
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: () => mod[key],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
20
|
+
var __toCommonJS = (from) => {
|
|
21
|
+
var entry = __moduleCache.get(from), desc;
|
|
22
|
+
if (entry)
|
|
23
|
+
return entry;
|
|
24
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
26
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
27
|
+
get: () => from[key],
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
}));
|
|
30
|
+
__moduleCache.set(from, entry);
|
|
31
|
+
return entry;
|
|
32
|
+
};
|
|
33
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, {
|
|
37
|
+
get: all[name],
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
set: (newValue) => all[name] = () => newValue
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
44
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
45
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
46
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
+
else
|
|
48
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
49
|
+
if (d = decorators[i])
|
|
50
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
51
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/cli/config/defaults.ts
|
|
55
|
+
var exports_defaults = {};
|
|
56
|
+
__export(exports_defaults, {
|
|
57
|
+
defaultConfig: () => defaultConfig
|
|
58
|
+
});
|
|
59
|
+
module.exports = __toCommonJS(exports_defaults);
|
|
60
|
+
var defaultConfig = {
|
|
61
|
+
output: {
|
|
62
|
+
portsDir: "src/ports",
|
|
63
|
+
adaptersDir: "src/adapters"
|
|
64
|
+
},
|
|
65
|
+
naming: {
|
|
66
|
+
portSuffix: "PORT",
|
|
67
|
+
adapterSuffix: "Adapter",
|
|
68
|
+
fileCase: "kebab"
|
|
69
|
+
},
|
|
70
|
+
style: {
|
|
71
|
+
indent: "tab",
|
|
72
|
+
quotes: "single",
|
|
73
|
+
semicolons: true
|
|
74
|
+
},
|
|
75
|
+
templates: {}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/cli/config/loader.ts
|
|
79
|
+
var exports_loader = {};
|
|
80
|
+
__export(exports_loader, {
|
|
81
|
+
loadConfig: () => loadConfig
|
|
82
|
+
});
|
|
83
|
+
module.exports = __toCommonJS(exports_loader);
|
|
84
|
+
var import_node_path = require("node:path");
|
|
85
|
+
var import_ts_deepmerge = require("ts-deepmerge");
|
|
86
|
+
async function loadConfig(cwd = process.cwd()) {
|
|
87
|
+
const configPath = import_node_path.join(cwd, "nest-hex.config.ts");
|
|
88
|
+
const configFile = Bun.file(configPath);
|
|
89
|
+
if (!await configFile.exists()) {
|
|
90
|
+
return defaultConfig;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const config = await import(configPath);
|
|
94
|
+
return import_ts_deepmerge.merge(defaultConfig, config.default ?? {});
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error(`
|
|
97
|
+
Warning: Failed to load configuration from ${configPath}`);
|
|
98
|
+
console.error(`Using default configuration instead.
|
|
99
|
+
`);
|
|
100
|
+
if (error instanceof Error) {
|
|
101
|
+
console.error(`Error: ${error.message}
|
|
102
|
+
`);
|
|
103
|
+
}
|
|
104
|
+
return defaultConfig;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for nest-hex CLI
|
|
3
|
+
*/
|
|
4
|
+
interface NestHexConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Output directory configuration
|
|
7
|
+
*/
|
|
8
|
+
output?: {
|
|
9
|
+
/**
|
|
10
|
+
* Directory for generated ports
|
|
11
|
+
* @default 'src/ports'
|
|
12
|
+
*/
|
|
13
|
+
portsDir?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Directory for generated adapters
|
|
16
|
+
* @default 'src/adapters'
|
|
17
|
+
*/
|
|
18
|
+
adaptersDir?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Naming conventions
|
|
22
|
+
*/
|
|
23
|
+
naming?: {
|
|
24
|
+
/**
|
|
25
|
+
* Suffix for port tokens
|
|
26
|
+
* @default 'PORT'
|
|
27
|
+
*/
|
|
28
|
+
portSuffix?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Suffix for adapter classes
|
|
31
|
+
* @default 'Adapter'
|
|
32
|
+
*/
|
|
33
|
+
adapterSuffix?: string;
|
|
34
|
+
/**
|
|
35
|
+
* File naming case
|
|
36
|
+
* @default 'kebab'
|
|
37
|
+
*/
|
|
38
|
+
fileCase?: "kebab" | "camel" | "pascal";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Code style preferences
|
|
42
|
+
*/
|
|
43
|
+
style?: {
|
|
44
|
+
/**
|
|
45
|
+
* Indentation style
|
|
46
|
+
* @default 'tab'
|
|
47
|
+
*/
|
|
48
|
+
indent?: "tab" | 2 | 4;
|
|
49
|
+
/**
|
|
50
|
+
* Quote style
|
|
51
|
+
* @default 'single'
|
|
52
|
+
*/
|
|
53
|
+
quotes?: "single" | "double";
|
|
54
|
+
/**
|
|
55
|
+
* Use semicolons
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
semicolons?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Custom template paths
|
|
62
|
+
*/
|
|
63
|
+
templates?: {
|
|
64
|
+
portModule?: string;
|
|
65
|
+
portToken?: string;
|
|
66
|
+
portInterface?: string;
|
|
67
|
+
portService?: string;
|
|
68
|
+
adapterModule?: string;
|
|
69
|
+
adapterService?: string;
|
|
70
|
+
adapterTypes?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
declare class ConfigValidationError extends Error {
|
|
74
|
+
constructor(message: string);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validates nest-hex configuration
|
|
78
|
+
* @throws {ConfigValidationError} If configuration is invalid
|
|
79
|
+
*/
|
|
80
|
+
declare function validateConfig(config: NestHexConfig): void;
|
|
81
|
+
export { validateConfig, ConfigValidationError };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var import_node_module = require("node:module");
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
+
for (let key of __getOwnPropNames(mod))
|
|
12
|
+
if (!__hasOwnProp.call(to, key))
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: () => mod[key],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
20
|
+
var __toCommonJS = (from) => {
|
|
21
|
+
var entry = __moduleCache.get(from), desc;
|
|
22
|
+
if (entry)
|
|
23
|
+
return entry;
|
|
24
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
26
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
27
|
+
get: () => from[key],
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
}));
|
|
30
|
+
__moduleCache.set(from, entry);
|
|
31
|
+
return entry;
|
|
32
|
+
};
|
|
33
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, {
|
|
37
|
+
get: all[name],
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
set: (newValue) => all[name] = () => newValue
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
44
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
45
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
46
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
+
else
|
|
48
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
49
|
+
if (d = decorators[i])
|
|
50
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
51
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/cli/config/validator.ts
|
|
55
|
+
var exports_validator = {};
|
|
56
|
+
__export(exports_validator, {
|
|
57
|
+
validateConfig: () => validateConfig,
|
|
58
|
+
ConfigValidationError: () => ConfigValidationError
|
|
59
|
+
});
|
|
60
|
+
module.exports = __toCommonJS(exports_validator);
|
|
61
|
+
|
|
62
|
+
class ConfigValidationError extends Error {
|
|
63
|
+
constructor(message) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.name = "ConfigValidationError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function validateConfig(config) {
|
|
69
|
+
if (config.style?.indent !== undefined) {
|
|
70
|
+
const validIndents = ["tab", 2, 4];
|
|
71
|
+
if (!validIndents.includes(config.style.indent)) {
|
|
72
|
+
throw new ConfigValidationError(`Invalid configuration: indent must be 'tab', 2, or 4. Got: ${config.style.indent}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (config.style?.quotes !== undefined) {
|
|
76
|
+
const validQuotes = ["single", "double"];
|
|
77
|
+
if (!validQuotes.includes(config.style.quotes)) {
|
|
78
|
+
throw new ConfigValidationError(`Invalid configuration: quotes must be 'single' or 'double'. Got: ${config.style.quotes}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (config.naming?.fileCase !== undefined) {
|
|
82
|
+
const validCases = ["kebab", "camel", "pascal"];
|
|
83
|
+
if (!validCases.includes(config.naming.fileCase)) {
|
|
84
|
+
throw new ConfigValidationError(`Invalid configuration: fileCase must be 'kebab', 'camel', or 'pascal'. Got: ${config.naming.fileCase}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (config.output?.portsDir !== undefined && typeof config.output.portsDir !== "string") {
|
|
88
|
+
throw new ConfigValidationError(`Invalid configuration: portsDir must be a string. Got: ${typeof config.output.portsDir}`);
|
|
89
|
+
}
|
|
90
|
+
if (config.output?.adaptersDir !== undefined && typeof config.output.adaptersDir !== "string") {
|
|
91
|
+
throw new ConfigValidationError(`Invalid configuration: adaptersDir must be a string. Got: ${typeof config.output.adaptersDir}`);
|
|
92
|
+
}
|
|
93
|
+
if (config.naming?.portSuffix !== undefined && typeof config.naming.portSuffix !== "string") {
|
|
94
|
+
throw new ConfigValidationError(`Invalid configuration: portSuffix must be a string. Got: ${typeof config.naming.portSuffix}`);
|
|
95
|
+
}
|
|
96
|
+
if (config.naming?.adapterSuffix !== undefined && typeof config.naming.adapterSuffix !== "string") {
|
|
97
|
+
throw new ConfigValidationError(`Invalid configuration: adapterSuffix must be a string. Got: ${typeof config.naming.adapterSuffix}`);
|
|
98
|
+
}
|
|
99
|
+
if (config.templates) {
|
|
100
|
+
const templateKeys = Object.keys(config.templates);
|
|
101
|
+
for (const key of templateKeys) {
|
|
102
|
+
const value = config.templates[key];
|
|
103
|
+
if (value !== undefined && typeof value !== "string") {
|
|
104
|
+
throw new ConfigValidationError(`Invalid configuration: templates.${key} must be a string. Got: ${typeof value}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|