@xeno-js/cli 0.1.2 → 0.1.4
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/LICENSE +18 -12
- package/README.md +461 -236
- package/dist/index.js +1018 -688
- package/dist/index.js.map +1 -1
- package/package.json +91 -66
- package/.github/.copilot-instruction.md +0 -73
- package/.github/agents/git-operator.agent.md +0 -86
- package/.github/agents/unit-tester.agent.md +0 -68
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.husky/pre-push +0 -1
- package/.prettierignore +0 -7
- package/.prettierrc.json +0 -37
- package/commitlint.config.cjs +0 -39
- package/eslint.config.mjs +0 -306
- package/lint-staged.config.mjs +0 -5
- package/logo/logo.png +0 -0
- package/src/domain/contracts/icommand-cli.contracts.ts +0 -13
- package/src/domain/contracts/icommand-runner.contracts.ts +0 -3
- package/src/domain/contracts/idispatch.contracts.ts +0 -3
- package/src/domain/contracts/ifile-service.contracts.ts +0 -3
- package/src/domain/contracts/igenerator.contracts.ts +0 -5
- package/src/domain/contracts/index.ts +0 -6
- package/src/domain/contracts/iscaffold-strategy.contracts.ts +0 -7
- package/src/domain/index.ts +0 -1
- package/src/index.ts +0 -30
- package/src/infrastructure/bootstrap/bootstrapper.ts +0 -30
- package/src/infrastructure/bootstrap/index.ts +0 -1
- package/src/infrastructure/builder/builder.test.ts +0 -36
- package/src/infrastructure/builder/builder.ts +0 -15
- package/src/infrastructure/builder/index.ts +0 -1
- package/src/infrastructure/command_launcher/command.utils.ts +0 -31
- package/src/infrastructure/command_launcher/index.ts +0 -0
- package/src/infrastructure/commands/command-runner.service.ts +0 -36
- package/src/infrastructure/commands/generate.command.ts +0 -55
- package/src/infrastructure/commands/help.command.ts +0 -63
- package/src/infrastructure/commands/index.ts +0 -4
- package/src/infrastructure/commands/new-project.command.ts +0 -47
- package/src/infrastructure/dispatcher/dispatcher.ts +0 -45
- package/src/infrastructure/dispatcher/index.ts +0 -1
- package/src/infrastructure/file/file.service.ts +0 -14
- package/src/infrastructure/file/index.ts +0 -1
- package/src/infrastructure/generators/core/bootstrap.generator.ts +0 -118
- package/src/infrastructure/generators/core/command/cqrs.generator.ts +0 -63
- package/src/infrastructure/generators/core/command/generate-command.generator.ts +0 -191
- package/src/infrastructure/generators/core/command/generate-query.generator.ts +0 -150
- package/src/infrastructure/generators/core/drizzle-sql-lite.generator.ts +0 -76
- package/src/infrastructure/generators/core/drizzle.generator.ts +0 -86
- package/src/infrastructure/generators/core/env.generator.ts +0 -69
- package/src/infrastructure/generators/core/index.ts +0 -9
- package/src/infrastructure/generators/core/main.generator.ts +0 -41
- package/src/infrastructure/generators/core/packagejson.generator.ts +0 -70
- package/src/infrastructure/generators/core/readme.generator.ts +0 -427
- package/src/infrastructure/generators/core/registry.generator.ts +0 -40
- package/src/infrastructure/generators/core/tsconfig.generator.ts +0 -39
- package/src/infrastructure/generators/gitignore.generator.ts +0 -60
- package/src/infrastructure/generators/vue/app-vue.generator.ts +0 -21
- package/src/infrastructure/generators/vue/bootstrap-ts.generator.ts +0 -60
- package/src/infrastructure/generators/vue/command_query/cqrs.generator.ts +0 -36
- package/src/infrastructure/generators/vue/command_query/generate-command-vue.generator.ts +0 -153
- package/src/infrastructure/generators/vue/command_query/generate-query-vue.generator.ts +0 -161
- package/src/infrastructure/generators/vue/env.generator.ts +0 -39
- package/src/infrastructure/generators/vue/index-html.generator.ts +0 -24
- package/src/infrastructure/generators/vue/index.ts +0 -12
- package/src/infrastructure/generators/vue/main.generator.ts +0 -41
- package/src/infrastructure/generators/vue/packagejson.generator.ts +0 -50
- package/src/infrastructure/generators/vue/readme.generator.ts +0 -389
- package/src/infrastructure/generators/vue/registry-ts.generator.ts +0 -26
- package/src/infrastructure/generators/vue/router.generator.ts +0 -35
- package/src/infrastructure/generators/vue/tailwind.generator.ts +0 -17
- package/src/infrastructure/generators/vue/tsconfig.generator.ts +0 -38
- package/src/infrastructure/generators/vue/use-app.generator.ts +0 -38
- package/src/infrastructure/generators/vue/vite-config.generator.ts +0 -35
- package/src/infrastructure/index.ts +0 -5
- package/src/infrastructure/strategies/core-scaffold.strategy.ts +0 -100
- package/src/infrastructure/strategies/index.ts +0 -2
- package/src/infrastructure/strategies/vue-scaffold.strategy.ts +0 -79
- package/src/shared/constants/command.constants.ts +0 -18
- package/src/shared/constants/core.constants.ts +0 -7
- package/src/shared/constants/index.ts +0 -2
- package/src/shared/index.ts +0 -3
- package/src/shared/types/common.types.ts +0 -68
- package/src/shared/types/index.ts +0 -1
- package/src/shared/utils/guards.utils.ts +0 -334
- package/src/shared/utils/index.ts +0 -2
- package/src/shared/utils/string.utils.ts +0 -60
- package/tsconfig.json +0 -15
- package/tsup.config.ts +0 -13
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts'
|
|
2
|
-
|
|
3
|
-
import type { IFileService, IGenerator, IScaffoldStrategy } from '../../domain'
|
|
4
|
-
import type { VueOptions } from '../../shared'
|
|
5
|
-
|
|
6
|
-
export class VueScaffoldStrategy implements IScaffoldStrategy<VueOptions> {
|
|
7
|
-
constructor(private readonly _fileService: IFileService) {}
|
|
8
|
-
|
|
9
|
-
public async promptOptions(targetDir: string): Promise<VueOptions> {
|
|
10
|
-
const response = await prompts([
|
|
11
|
-
{ type: 'confirm', name: 'axios', message: 'Install Axios?', initial: true },
|
|
12
|
-
{
|
|
13
|
-
type: 'confirm',
|
|
14
|
-
name: 'cockatiel',
|
|
15
|
-
message: 'Install Cockatiel (Resilience)?',
|
|
16
|
-
initial: true,
|
|
17
|
-
},
|
|
18
|
-
{ type: 'confirm', name: 'supabase', message: 'Install Supabase Auth?', initial: true },
|
|
19
|
-
{ type: 'confirm', name: 'sentry', message: 'Install Sentry Logger?', initial: true },
|
|
20
|
-
{
|
|
21
|
-
type: 'confirm',
|
|
22
|
-
name: 'pinia',
|
|
23
|
-
message: 'Install Pinia (State Management)?',
|
|
24
|
-
initial: true,
|
|
25
|
-
},
|
|
26
|
-
{ type: 'confirm', name: 'router', message: 'Install vue-router?', initial: true },
|
|
27
|
-
{ type: 'confirm', name: 'tailwind', message: 'Install Tailwind CSS?', initial: true },
|
|
28
|
-
{ type: 'confirm', name: 'zod', message: 'Install Zod Validator?', initial: true },
|
|
29
|
-
{
|
|
30
|
-
type: 'confirm',
|
|
31
|
-
name: 'gitInit',
|
|
32
|
-
message: 'Initialize a new Git repository?',
|
|
33
|
-
initial: true,
|
|
34
|
-
},
|
|
35
|
-
])
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
targetDir,
|
|
39
|
-
projectType: 'vue',
|
|
40
|
-
...response,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public async getGenerators(_options: VueOptions): Promise<IGenerator<VueOptions>[]> {
|
|
45
|
-
const generators: IGenerator<VueOptions>[] = []
|
|
46
|
-
|
|
47
|
-
const { PackageJsonVueGenerator } = await import('../generators/vue/packagejson.generator.js')
|
|
48
|
-
const { ViteconfigGenerator } = await import('../generators/vue/vite-config.generator.js')
|
|
49
|
-
const { EnvVueGenerator } = await import('../generators/vue/env.generator.js')
|
|
50
|
-
const { TsconfigVueGenerator } = await import('../generators/vue/tsconfig.generator.js')
|
|
51
|
-
const { ReadmeVueGenerator } = await import('../generators/vue/readme.generator.js')
|
|
52
|
-
const { GitIgnoreGenerator } = await import('../generators/gitignore.generator.js')
|
|
53
|
-
const { AppVueGenerator } = await import('../generators/vue/app-vue.generator.js')
|
|
54
|
-
const { BootstrapGenerator } = await import('../generators/vue/bootstrap-ts.generator.js')
|
|
55
|
-
const { IndexVueGenerator } = await import('../generators/vue/index-html.generator.js')
|
|
56
|
-
const { MainGenerator } = await import('../generators/vue/main.generator.js')
|
|
57
|
-
const { RegistryGenerator } = await import('../generators/vue/registry-ts.generator.js')
|
|
58
|
-
const { RouterGenerator } = await import('../generators/vue/router.generator.js')
|
|
59
|
-
const { TailwindGenerator } = await import('../generators/vue/tailwind.generator.js')
|
|
60
|
-
const { UseAppVueGenerator } = await import('../generators/vue/use-app.generator.js')
|
|
61
|
-
|
|
62
|
-
generators.push(new PackageJsonVueGenerator(this._fileService))
|
|
63
|
-
generators.push(new ViteconfigGenerator(this._fileService))
|
|
64
|
-
generators.push(new EnvVueGenerator(this._fileService))
|
|
65
|
-
generators.push(new TsconfigVueGenerator(this._fileService))
|
|
66
|
-
generators.push(new AppVueGenerator(this._fileService))
|
|
67
|
-
generators.push(new BootstrapGenerator(this._fileService))
|
|
68
|
-
generators.push(new IndexVueGenerator(this._fileService))
|
|
69
|
-
generators.push(new MainGenerator(this._fileService))
|
|
70
|
-
generators.push(new RegistryGenerator(this._fileService))
|
|
71
|
-
generators.push(new RouterGenerator(this._fileService))
|
|
72
|
-
generators.push(new TailwindGenerator(this._fileService))
|
|
73
|
-
generators.push(new ReadmeVueGenerator(this._fileService))
|
|
74
|
-
generators.push(new GitIgnoreGenerator(this._fileService))
|
|
75
|
-
generators.push(new UseAppVueGenerator(this._fileService))
|
|
76
|
-
|
|
77
|
-
return generators
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const ARGS_CONSTANTS = Object.freeze({
|
|
2
|
-
HELP: '--help',
|
|
3
|
-
VUE: '--vue',
|
|
4
|
-
CORE: '--core',
|
|
5
|
-
CONSOLE: '--console',
|
|
6
|
-
} as const)
|
|
7
|
-
|
|
8
|
-
export const COMMAND_CONSTANTS = Object.freeze({
|
|
9
|
-
HELP: 'help',
|
|
10
|
-
COMMAND: 'command',
|
|
11
|
-
QUERY: 'query',
|
|
12
|
-
} as const)
|
|
13
|
-
|
|
14
|
-
export const TARGET_ENV_CONSTANTS = Object.freeze({
|
|
15
|
-
CONSOLE: 'console',
|
|
16
|
-
VERCEL: 'vercel',
|
|
17
|
-
FASTIFY: 'fastify',
|
|
18
|
-
} as const)
|
package/src/shared/index.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export type ProjectType = 'core' | 'vue'
|
|
2
|
-
|
|
3
|
-
export interface BaseOptions {
|
|
4
|
-
targetDir: string
|
|
5
|
-
projectType: ProjectType
|
|
6
|
-
gitInit: boolean
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface CoreOptions extends BaseOptions {
|
|
10
|
-
axios: boolean
|
|
11
|
-
cockatiel: boolean
|
|
12
|
-
database: 'drizzle' | 'sqlLite' | 'none'
|
|
13
|
-
supabase: boolean
|
|
14
|
-
pino: boolean
|
|
15
|
-
sentry: boolean
|
|
16
|
-
redis: boolean
|
|
17
|
-
targetEnv: 'console' | 'vercel' | 'fastify'
|
|
18
|
-
zod: boolean
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface VueOptions extends BaseOptions {
|
|
22
|
-
axios: boolean
|
|
23
|
-
cockatiel: boolean
|
|
24
|
-
router: boolean
|
|
25
|
-
pinia: boolean
|
|
26
|
-
tailwind: boolean
|
|
27
|
-
sentry: boolean
|
|
28
|
-
supabase: boolean
|
|
29
|
-
zod: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type ScaffoldingOptions = CoreOptions | VueOptions
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @description Represents a value that may be `null`.
|
|
36
|
-
* Prefer this over `T | null` in all public APIs so intent is self-documenting.
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
* @author Xeno
|
|
40
|
-
* @version 1.0.0
|
|
41
|
-
* @since 2025-09-30
|
|
42
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
43
|
-
*/
|
|
44
|
-
export type Nullable<T> = T | null
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @description Represents a value that may be either `null` or `undefined`.
|
|
48
|
-
* Use when a value is absent regardless of the reason.
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
* @author Xeno
|
|
52
|
-
* @version 1.0.0
|
|
53
|
-
* @since 2025-09-30
|
|
54
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
55
|
-
*/
|
|
56
|
-
export type Maybe<T> = T | null | undefined
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @description A plain-object dictionary with string keys and uniform value type.
|
|
60
|
-
* Prefer over `{ [key: string]: V }` for self-documenting intent.
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
* @author Xeno
|
|
64
|
-
* @version 1.0.0
|
|
65
|
-
* @since 2025-09-30
|
|
66
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
67
|
-
*/
|
|
68
|
-
export type Dictionary<V = unknown> = Record<string, V>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type * from './common.types'
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import type { Dictionary, Maybe } from '../types/common.types'
|
|
2
|
-
|
|
3
|
-
const OBJECT_TAG = '[object Object]'
|
|
4
|
-
const DATE_TAG = '[object Date]'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @description Centralized type guards and runtime predicates.
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @author Xeno
|
|
11
|
-
* @version 1.0.0
|
|
12
|
-
* @since 2025-09-30
|
|
13
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
14
|
-
*/
|
|
15
|
-
export const Guards = Object.freeze({
|
|
16
|
-
/**
|
|
17
|
-
* @description Checks value is neither null nor undefined.
|
|
18
|
-
* @param value Candidate value.
|
|
19
|
-
* @returns True when value is defined.
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @author Xeno
|
|
23
|
-
* @version 1.0.0
|
|
24
|
-
* @since 2025-09-30
|
|
25
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
26
|
-
*/
|
|
27
|
-
isDefined<TValue>(value: Maybe<TValue>): value is TValue {
|
|
28
|
-
return value !== null && value !== undefined && value !== '' && !Number.isNaN(value)
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @description Checks value is null, undefined, empty string, or false.
|
|
33
|
-
* @param value Candidate value.
|
|
34
|
-
* @returns True when value is null, undefined, empty string, or false.
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* @author Xeno
|
|
38
|
-
* @version 1.0.0
|
|
39
|
-
* @since 2025-09-30
|
|
40
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
41
|
-
*/
|
|
42
|
-
isNullOrEmpty<TValue>(value: Maybe<TValue>): value is null | undefined {
|
|
43
|
-
return (
|
|
44
|
-
!Guards.isDefined(value) ||
|
|
45
|
-
(Guards.isString(value) && value.trim() === '') ||
|
|
46
|
-
(Guards.isArray(value) && value.length === 0)
|
|
47
|
-
)
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @description Throws an error if the value is null, undefined, empty string, or false.
|
|
52
|
-
* @param value Candidate value.
|
|
53
|
-
* @param errorMessage Error message to throw if the check fails.
|
|
54
|
-
* @throws Error with the provided message if the value is null, undefined, empty string, or false.
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* @author Xeno
|
|
58
|
-
* @version 1.0.0
|
|
59
|
-
* @since 2025-09-30
|
|
60
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
61
|
-
*/
|
|
62
|
-
throwIfNullOrEmpty<TValue>(value: Maybe<TValue>, errorMessage: string): void {
|
|
63
|
-
if (Guards.isNullOrEmpty(value)) {
|
|
64
|
-
throw new Error(errorMessage)
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @description Throws an error if the value is not a positive integer.
|
|
70
|
-
* @param value Candidate value.
|
|
71
|
-
* @param errorMessage Error message to throw if the check fails.
|
|
72
|
-
* @throws Error with the provided message if the value is not a positive integer.
|
|
73
|
-
|
|
74
|
-
*
|
|
75
|
-
* @author Xeno
|
|
76
|
-
* @version 1.0.0
|
|
77
|
-
* @since 2025-09-30
|
|
78
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
79
|
-
*/
|
|
80
|
-
throwIfNegative(value: number, errorMessage: string): void {
|
|
81
|
-
if (Guards.isInteger(value) && value < 0) {
|
|
82
|
-
throw new Error(errorMessage)
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @description Throws an error if the value is not an integer.
|
|
88
|
-
* @param value Candidate value.
|
|
89
|
-
* @param errorMessage Error message to throw if the check fails.
|
|
90
|
-
* @throws Error with the provided message if the value is not an integer.
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
* @author Xeno
|
|
94
|
-
* @version 1.0.0
|
|
95
|
-
* @since 2025-09-30
|
|
96
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
97
|
-
*/
|
|
98
|
-
throwIfNotInteger(value: number, errorMessage: string): void {
|
|
99
|
-
if (!Guards.isInteger(value)) {
|
|
100
|
-
throw new Error(errorMessage)
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @description Checks if an object has a method with the given name.
|
|
106
|
-
* @param obj Object to check.
|
|
107
|
-
* @param methodName Name of the method to look for.
|
|
108
|
-
* @returns True when obj has a function property named methodName.
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
* @author Xeno
|
|
112
|
-
* @version 1.0.0
|
|
113
|
-
* @since 2025-09-30
|
|
114
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
115
|
-
*/
|
|
116
|
-
hasMethod(obj: unknown, methodName: string): boolean {
|
|
117
|
-
if (!this.isDefined(obj)) return false
|
|
118
|
-
|
|
119
|
-
// Essendo all'interno del namespace di utilità, l'uso di typeof qui è consentito
|
|
120
|
-
return Guards.isFunction((obj as Dictionary<unknown>)[methodName])
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @description Checks value is a string.
|
|
125
|
-
* @param value Candidate value.
|
|
126
|
-
* @returns True when value is string.
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
* @author Xeno
|
|
130
|
-
* @version 1.0.0
|
|
131
|
-
* @since 2025-09-30
|
|
132
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
133
|
-
*/
|
|
134
|
-
isString(value: unknown): value is string {
|
|
135
|
-
return typeof value === 'string'
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @description Checks value is a finite number.
|
|
140
|
-
* @param value Candidate value.
|
|
141
|
-
* @returns True when value is finite number.
|
|
142
|
-
|
|
143
|
-
*
|
|
144
|
-
* @author Xeno
|
|
145
|
-
* @version 1.0.0
|
|
146
|
-
* @since 2025-09-30
|
|
147
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
148
|
-
*/
|
|
149
|
-
isNumber(value: unknown): value is number {
|
|
150
|
-
return typeof value === 'number' && Number.isFinite(value)
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @description Checks value is an integer number.
|
|
155
|
-
* @param value Candidate value.
|
|
156
|
-
* @returns True when value is integer number.
|
|
157
|
-
|
|
158
|
-
*
|
|
159
|
-
* @author Xeno
|
|
160
|
-
* @version 1.0.0
|
|
161
|
-
* @since 2025-09-30
|
|
162
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
163
|
-
*/
|
|
164
|
-
isInteger(value: unknown): value is number {
|
|
165
|
-
return Guards.isNumber(value) && Number.isInteger(value)
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @description Checks value is boolean.
|
|
170
|
-
* @param value Candidate value.
|
|
171
|
-
* @returns True when value is boolean.
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
* @author Xeno
|
|
175
|
-
* @version 1.0.0
|
|
176
|
-
* @since 2025-09-30
|
|
177
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
178
|
-
*/
|
|
179
|
-
isBoolean(value: unknown): value is boolean {
|
|
180
|
-
return typeof value === 'boolean'
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @description Checks value is bigint.
|
|
185
|
-
* @param value Candidate value.
|
|
186
|
-
* @returns True when value is bigint.
|
|
187
|
-
|
|
188
|
-
*
|
|
189
|
-
* @author Xeno
|
|
190
|
-
* @version 1.0.0
|
|
191
|
-
* @since 2025-09-30
|
|
192
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
193
|
-
*/
|
|
194
|
-
isBigInt(value: unknown): value is bigint {
|
|
195
|
-
return typeof value === 'bigint'
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* @description Checks value is symbol.
|
|
200
|
-
* @param value Candidate value.
|
|
201
|
-
* @returns True when value is symbol.
|
|
202
|
-
|
|
203
|
-
*
|
|
204
|
-
* @author Xeno
|
|
205
|
-
* @version 1.0.0
|
|
206
|
-
* @since 2025-09-30
|
|
207
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
208
|
-
*/
|
|
209
|
-
isSymbol(value: unknown): value is symbol {
|
|
210
|
-
return typeof value === 'symbol'
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* @description Checks value is a function.
|
|
215
|
-
* @param value Candidate value.
|
|
216
|
-
* @returns True when value is function.
|
|
217
|
-
|
|
218
|
-
*
|
|
219
|
-
* @author Xeno
|
|
220
|
-
* @version 1.0.0
|
|
221
|
-
* @since 2025-09-30
|
|
222
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
223
|
-
*/
|
|
224
|
-
isFunction(value: unknown): value is (...args: readonly unknown[]) => unknown {
|
|
225
|
-
return typeof value === 'function'
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* @description Checks value is an array.
|
|
230
|
-
* @param value Candidate value.
|
|
231
|
-
* @returns True when value is array.
|
|
232
|
-
|
|
233
|
-
*
|
|
234
|
-
* @author Xeno
|
|
235
|
-
* @version 1.0.0
|
|
236
|
-
* @since 2025-09-30
|
|
237
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
238
|
-
*/
|
|
239
|
-
isArray<TValue>(value: unknown): value is TValue[] {
|
|
240
|
-
return Array.isArray(value)
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @description Checks value is a Date instance with valid timestamp.
|
|
245
|
-
* @param value Candidate value.
|
|
246
|
-
* @returns True when value is valid Date.
|
|
247
|
-
|
|
248
|
-
*
|
|
249
|
-
* @author Xeno
|
|
250
|
-
* @version 1.0.0
|
|
251
|
-
* @since 2025-09-30
|
|
252
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
253
|
-
*/
|
|
254
|
-
isDate(value: unknown): value is Date {
|
|
255
|
-
if (Object.prototype.toString.call(value) !== DATE_TAG) {
|
|
256
|
-
return false
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return Number.isFinite((value as Date).getTime())
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* @description Checks value is an Error instance.
|
|
264
|
-
* @param value Candidate value.
|
|
265
|
-
* @returns True when value is Error.
|
|
266
|
-
|
|
267
|
-
*
|
|
268
|
-
* @author Xeno
|
|
269
|
-
* @version 1.0.0
|
|
270
|
-
* @since 2025-09-30
|
|
271
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
272
|
-
*/
|
|
273
|
-
isError(value: unknown): value is Error {
|
|
274
|
-
return value instanceof Error
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* @description Checks value is a plain object record.
|
|
279
|
-
* @param value Candidate value.
|
|
280
|
-
* @returns True when value is object record.
|
|
281
|
-
|
|
282
|
-
*
|
|
283
|
-
* @author Xeno
|
|
284
|
-
* @version 1.0.0
|
|
285
|
-
* @since 2025-09-30
|
|
286
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
287
|
-
*/
|
|
288
|
-
isObjectRecord(value: unknown): value is Readonly<Dictionary<unknown>> {
|
|
289
|
-
if (!Guards.isDefined(value)) {
|
|
290
|
-
return false
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return Object.prototype.toString.call(value) === OBJECT_TAG
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* @description Checks value is an object (not null).
|
|
298
|
-
* @param value Candidate value.
|
|
299
|
-
* @returns True when value is object.
|
|
300
|
-
|
|
301
|
-
*
|
|
302
|
-
* @author Xeno
|
|
303
|
-
* @version 1.0.0
|
|
304
|
-
* @since 2025-09-30
|
|
305
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
306
|
-
*/
|
|
307
|
-
isObject(value: unknown): value is object {
|
|
308
|
-
return typeof value === 'object' && Guards.isDefined(value)
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* @description Checks value is PromiseLike.
|
|
313
|
-
* @param value Candidate value.
|
|
314
|
-
* @returns True when value has then function.
|
|
315
|
-
|
|
316
|
-
*
|
|
317
|
-
* @author Xeno
|
|
318
|
-
* @version 1.0.0
|
|
319
|
-
* @since 2025-09-30
|
|
320
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
321
|
-
*/
|
|
322
|
-
isPromiseLike<TValue>(value: unknown): value is PromiseLike<TValue> {
|
|
323
|
-
if (!Guards.isDefined(value)) {
|
|
324
|
-
return false
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (!Guards.isObject(value) && !Guards.isFunction(value)) {
|
|
328
|
-
return false
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const thenMember = (value as Dictionary<unknown>)['then']
|
|
332
|
-
return Guards.isFunction(thenMember)
|
|
333
|
-
},
|
|
334
|
-
} as const)
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Guards } from './guards.utils'
|
|
2
|
-
|
|
3
|
-
export const StringUtils = Object.freeze({
|
|
4
|
-
/**
|
|
5
|
-
* @description Inserisce un underscore (_) tra la fine di una parola e l'inizio della successiva in formato camelCase o PascalCase.
|
|
6
|
-
* @param input Stringa in input (es. "CreateUser").
|
|
7
|
-
* @returns Stringa separata da underscore (es. "Create_User").
|
|
8
|
-
*
|
|
9
|
-
* @author Xeno
|
|
10
|
-
* @version 1.0.0
|
|
11
|
-
* @since 2026-09-18
|
|
12
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
13
|
-
*/
|
|
14
|
-
splitCamelCaseWithUnderscore(input: string): string {
|
|
15
|
-
if (!Guards.isString(input) || Guards.isNullOrEmpty(input)) return input
|
|
16
|
-
return input.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
17
|
-
},
|
|
18
|
-
/**
|
|
19
|
-
* @description Converts a string to camelCase.
|
|
20
|
-
* @param input Input string (supports snake_case, kebab-case, or space-separated).
|
|
21
|
-
* @returns camelCase string.
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
* @author Xeno
|
|
25
|
-
* @version 1.0.0
|
|
26
|
-
* @since 2025-09-30
|
|
27
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
28
|
-
*/
|
|
29
|
-
camelCase(input: string): string {
|
|
30
|
-
const segments = input.split(/[-_\s]+/)
|
|
31
|
-
const [first, ...rest] = segments
|
|
32
|
-
const head = Guards.isDefined(first) ? first.toLowerCase() : ''
|
|
33
|
-
return head + rest.map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1)).join('')
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* @description Converts a string to PascalCase.
|
|
37
|
-
* @param input Input string (supports snake_case, kebab-case, space-separated, or camelCase).
|
|
38
|
-
* @returns PascalCase string.
|
|
39
|
-
*
|
|
40
|
-
* @author Xeno
|
|
41
|
-
* @version 1.0.0
|
|
42
|
-
* @since 2026-09-18
|
|
43
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
44
|
-
*/
|
|
45
|
-
pascalCase(input: string): string {
|
|
46
|
-
if (!Guards.isString(input) || Guards.isNullOrEmpty(input)) return ''
|
|
47
|
-
|
|
48
|
-
const segments = input.split(/[-_\s]+/)
|
|
49
|
-
|
|
50
|
-
return segments
|
|
51
|
-
.filter((seg) => seg.length > 0)
|
|
52
|
-
.map((seg) => {
|
|
53
|
-
// Se il segmento è tutto maiuscolo (es. CREATE), lo normalizziamo in minuscolo per evitare cREATE.
|
|
54
|
-
// Altrimenti, preserviamo il casing interno originale (es. UserService resta UserService).
|
|
55
|
-
const normalized = seg === seg.toUpperCase() ? seg.toLowerCase() : seg
|
|
56
|
-
return normalized.charAt(0).toUpperCase() + normalized.slice(1)
|
|
57
|
-
})
|
|
58
|
-
.join('')
|
|
59
|
-
},
|
|
60
|
-
} as const)
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"types": ["node"],
|
|
6
|
-
"moduleResolution": "NodeNext",
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true
|
|
13
|
-
},
|
|
14
|
-
"include": ["src/**/*"]
|
|
15
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ['src/index.ts'],
|
|
5
|
-
format: ['cjs'],
|
|
6
|
-
target: 'node20',
|
|
7
|
-
dts: false,
|
|
8
|
-
sourcemap: true,
|
|
9
|
-
clean: true,
|
|
10
|
-
splitting: false,
|
|
11
|
-
bundle: true,
|
|
12
|
-
outExtension: () => ({ js: '.js' }),
|
|
13
|
-
})
|