@lakutata/cli 1.0.37 → 2.1.0-alpha.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/CHANGELOG.md +52 -0
- package/README.md +6 -26
- package/package.json +28 -56
- package/src/CLIApp.ts +86 -0
- package/src/controllers/CommandLineController.ts +34 -0
- package/src/lib/ProjectTypeConfig.ts +20 -0
- package/src/lib/SpecialChar.ts +8 -0
- package/src/lib/components/DeGitPuller.ts +41 -0
- package/src/lib/components/Spinner.ts +48 -0
- package/src/lib/providers/Creator.ts +125 -0
- package/src/lib/providers/Information.ts +221 -0
- package/src/options/CreateProjectOptions.ts +82 -0
- package/src/options/LakutataInfoOptions.ts +4 -0
- package/tsconfig.json +3 -33
- package/.eslintrc.json +0 -47
- package/.idea/codeStyles/Project.xml +0 -18
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/dbnavigator.xml +0 -457
- package/.idea/inspectionProfiles/Project_Default.xml +0 -10
- package/.idea/lakutata-cli.iml +0 -14
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/LICENSE +0 -21
- package/assets/lakutata-banner.png +0 -0
- package/assets/lakutata_logo.jpg +0 -0
- package/build/CLI.d.ts +0 -2
- package/build/CLI.js +0 -13
- package/build/CLI.js.map +0 -1
- package/build/Deploy.d.ts +0 -1
- package/build/Deploy.js +0 -129
- package/build/Deploy.js.map +0 -1
- package/build/constants/GitIgnore.d.ts +0 -1
- package/build/constants/GitIgnore.js +0 -157
- package/build/constants/GitIgnore.js.map +0 -1
- package/build/constants/LicenseList.d.ts +0 -4
- package/build/constants/LicenseList.js +0 -68
- package/build/constants/LicenseList.js.map +0 -1
- package/build/interfaces/IApplicationInfo.d.ts +0 -4
- package/build/interfaces/IApplicationInfo.js +0 -3
- package/build/interfaces/IApplicationInfo.js.map +0 -1
- package/build/interfaces/IComponentInfo.d.ts +0 -4
- package/build/interfaces/IComponentInfo.js +0 -3
- package/build/interfaces/IComponentInfo.js.map +0 -1
- package/build/interfaces/IGenerator.d.ts +0 -3
- package/build/interfaces/IGenerator.js +0 -3
- package/build/interfaces/IGenerator.js.map +0 -1
- package/build/interfaces/IModuleInfo.d.ts +0 -4
- package/build/interfaces/IModuleInfo.js +0 -3
- package/build/interfaces/IModuleInfo.js.map +0 -1
- package/build/interfaces/IPluginInfo.d.ts +0 -4
- package/build/interfaces/IPluginInfo.js +0 -3
- package/build/interfaces/IPluginInfo.js.map +0 -1
- package/build/interfaces/IPreparePackageConfigOptions.d.ts +0 -19
- package/build/interfaces/IPreparePackageConfigOptions.js +0 -3
- package/build/interfaces/IPreparePackageConfigOptions.js.map +0 -1
- package/build/interfaces/IProjectGeneratorOptions.d.ts +0 -16
- package/build/interfaces/IProjectGeneratorOptions.js +0 -3
- package/build/interfaces/IProjectGeneratorOptions.js.map +0 -1
- package/build/interfaces/IProjectInfo.d.ts +0 -14
- package/build/interfaces/IProjectInfo.js +0 -3
- package/build/interfaces/IProjectInfo.js.map +0 -1
- package/build/lib/LatestVersion.d.ts +0 -1
- package/build/lib/LatestVersion.js +0 -13
- package/build/lib/LatestVersion.js.map +0 -1
- package/build/lib/generators/application/ApplicationGenerator.d.ts +0 -18
- package/build/lib/generators/application/ApplicationGenerator.js +0 -84
- package/build/lib/generators/application/ApplicationGenerator.js.map +0 -1
- package/build/lib/generators/application/files/AppFile.d.ts +0 -8
- package/build/lib/generators/application/files/AppFile.js +0 -36
- package/build/lib/generators/application/files/AppFile.js.map +0 -1
- package/build/lib/generators/application/files/ConfigFile.d.ts +0 -9
- package/build/lib/generators/application/files/ConfigFile.js +0 -81
- package/build/lib/generators/application/files/ConfigFile.js.map +0 -1
- package/build/lib/generators/component/ComponentGenerator.d.ts +0 -17
- package/build/lib/generators/component/ComponentGenerator.js +0 -75
- package/build/lib/generators/component/ComponentGenerator.js.map +0 -1
- package/build/lib/generators/component/files/ComponentFile.d.ts +0 -8
- package/build/lib/generators/component/files/ComponentFile.js +0 -45
- package/build/lib/generators/component/files/ComponentFile.js.map +0 -1
- package/build/lib/generators/component/files/ComponentTestFile.d.ts +0 -8
- package/build/lib/generators/component/files/ComponentTestFile.js +0 -35
- package/build/lib/generators/component/files/ComponentTestFile.js.map +0 -1
- package/build/lib/generators/module/ModuleGenerator.d.ts +0 -17
- package/build/lib/generators/module/ModuleGenerator.js +0 -85
- package/build/lib/generators/module/ModuleGenerator.js.map +0 -1
- package/build/lib/generators/module/files/ModuleFile.d.ts +0 -8
- package/build/lib/generators/module/files/ModuleFile.js +0 -116
- package/build/lib/generators/module/files/ModuleFile.js.map +0 -1
- package/build/lib/generators/module/files/ModuleTestFile.d.ts +0 -8
- package/build/lib/generators/module/files/ModuleTestFile.js +0 -35
- package/build/lib/generators/module/files/ModuleTestFile.js.map +0 -1
- package/build/lib/generators/plugin/PluginGenerator.d.ts +0 -17
- package/build/lib/generators/plugin/PluginGenerator.js +0 -75
- package/build/lib/generators/plugin/PluginGenerator.js.map +0 -1
- package/build/lib/generators/plugin/files/PluginFile.d.ts +0 -8
- package/build/lib/generators/plugin/files/PluginFile.js +0 -50
- package/build/lib/generators/plugin/files/PluginFile.js.map +0 -1
- package/build/lib/generators/plugin/files/PluginTestFile.d.ts +0 -8
- package/build/lib/generators/plugin/files/PluginTestFile.js +0 -35
- package/build/lib/generators/plugin/files/PluginTestFile.js.map +0 -1
- package/build/lib/generators/project/ProjectGenerator.d.ts +0 -27
- package/build/lib/generators/project/ProjectGenerator.js +0 -157
- package/build/lib/generators/project/ProjectGenerator.js.map +0 -1
- package/build/lib/generators/project/ProjectSourceFile.d.ts +0 -5
- package/build/lib/generators/project/ProjectSourceFile.js +0 -7
- package/build/lib/generators/project/ProjectSourceFile.js.map +0 -1
- package/build/lib/generators/project/configs/ProjectEslintrcConfig.d.ts +0 -37
- package/build/lib/generators/project/configs/ProjectEslintrcConfig.js +0 -51
- package/build/lib/generators/project/configs/ProjectEslintrcConfig.js.map +0 -1
- package/build/lib/generators/project/configs/ProjectPackageConfig.d.ts +0 -1
- package/build/lib/generators/project/configs/ProjectPackageConfig.js +0 -32
- package/build/lib/generators/project/configs/ProjectPackageConfig.js.map +0 -1
- package/build/lib/generators/project/configs/ProjectTypescriptConfig.d.ts +0 -25
- package/build/lib/generators/project/configs/ProjectTypescriptConfig.js +0 -39
- package/build/lib/generators/project/configs/ProjectTypescriptConfig.js.map +0 -1
- package/build/lib/manipulators/CreateComponentManipulator.d.ts +0 -3
- package/build/lib/manipulators/CreateComponentManipulator.js +0 -71
- package/build/lib/manipulators/CreateComponentManipulator.js.map +0 -1
- package/build/lib/manipulators/CreateDockerFileManipulator.d.ts +0 -3
- package/build/lib/manipulators/CreateDockerFileManipulator.js +0 -124
- package/build/lib/manipulators/CreateDockerFileManipulator.js.map +0 -1
- package/build/lib/manipulators/CreateModuleManipulator.d.ts +0 -3
- package/build/lib/manipulators/CreateModuleManipulator.js +0 -142
- package/build/lib/manipulators/CreateModuleManipulator.js.map +0 -1
- package/build/lib/manipulators/CreatePluginManipulator.d.ts +0 -3
- package/build/lib/manipulators/CreatePluginManipulator.js +0 -76
- package/build/lib/manipulators/CreatePluginManipulator.js.map +0 -1
- package/build/lib/manipulators/CreateProcessManipulator.d.ts +0 -3
- package/build/lib/manipulators/CreateProcessManipulator.js +0 -61
- package/build/lib/manipulators/CreateProcessManipulator.js.map +0 -1
- package/build/lib/manipulators/CreateThreadManipulator.d.ts +0 -3
- package/build/lib/manipulators/CreateThreadManipulator.js +0 -61
- package/build/lib/manipulators/CreateThreadManipulator.js.map +0 -1
- package/build/lib/manipulators/application/ApplicationIndexManipulator.d.ts +0 -1
- package/build/lib/manipulators/application/ApplicationIndexManipulator.js +0 -162
- package/build/lib/manipulators/application/ApplicationIndexManipulator.js.map +0 -1
- package/build/lib/menus/MainMenu.d.ts +0 -1
- package/build/lib/menus/MainMenu.js +0 -160
- package/build/lib/menus/MainMenu.js.map +0 -1
- package/build/lib/menus/initializeMenus/InitializeApplicationProject.d.ts +0 -1
- package/build/lib/menus/initializeMenus/InitializeApplicationProject.js +0 -93
- package/build/lib/menus/initializeMenus/InitializeApplicationProject.js.map +0 -1
- package/build/lib/menus/initializeMenus/InitializeComponentProject.d.ts +0 -1
- package/build/lib/menus/initializeMenus/InitializeComponentProject.js +0 -93
- package/build/lib/menus/initializeMenus/InitializeComponentProject.js.map +0 -1
- package/build/lib/menus/initializeMenus/InitializeModuleProject.d.ts +0 -1
- package/build/lib/menus/initializeMenus/InitializeModuleProject.js +0 -93
- package/build/lib/menus/initializeMenus/InitializeModuleProject.js.map +0 -1
- package/build/lib/menus/initializeMenus/InitializePluginProject.d.ts +0 -1
- package/build/lib/menus/initializeMenus/InitializePluginProject.js +0 -93
- package/build/lib/menus/initializeMenus/InitializePluginProject.js.map +0 -1
- package/build/lib/menus/manipulateMenus/ManipulateApplicationProject.d.ts +0 -1
- package/build/lib/menus/manipulateMenus/ManipulateApplicationProject.js +0 -60
- package/build/lib/menus/manipulateMenus/ManipulateApplicationProject.js.map +0 -1
- package/build/lib/menus/manipulateMenus/ManipulateComponentProject.d.ts +0 -1
- package/build/lib/menus/manipulateMenus/ManipulateComponentProject.js +0 -9
- package/build/lib/menus/manipulateMenus/ManipulateComponentProject.js.map +0 -1
- package/build/lib/menus/manipulateMenus/ManipulateModuleProject.d.ts +0 -1
- package/build/lib/menus/manipulateMenus/ManipulateModuleProject.js +0 -49
- package/build/lib/menus/manipulateMenus/ManipulateModuleProject.js.map +0 -1
- package/build/lib/menus/manipulateMenus/ManipulatePluginProject.d.ts +0 -1
- package/build/lib/menus/manipulateMenus/ManipulatePluginProject.js +0 -9
- package/build/lib/menus/manipulateMenus/ManipulatePluginProject.js.map +0 -1
- package/src/CLI.ts +0 -7
- package/src/Deploy.ts +0 -124
- package/src/constants/GitIgnore.ts +0 -153
- package/src/constants/LicenseList.ts +0 -64
- package/src/interfaces/IApplicationInfo.ts +0 -5
- package/src/interfaces/IComponentInfo.ts +0 -5
- package/src/interfaces/IGenerator.ts +0 -3
- package/src/interfaces/IModuleInfo.ts +0 -5
- package/src/interfaces/IPluginInfo.ts +0 -5
- package/src/interfaces/IPreparePackageConfigOptions.ts +0 -11
- package/src/interfaces/IProjectGeneratorOptions.ts +0 -15
- package/src/interfaces/IProjectInfo.ts +0 -10
- package/src/lib/LatestVersion.ts +0 -6
- package/src/lib/generators/application/ApplicationGenerator.ts +0 -97
- package/src/lib/generators/application/files/AppFile.ts +0 -35
- package/src/lib/generators/application/files/ConfigFile.ts +0 -82
- package/src/lib/generators/component/ComponentGenerator.ts +0 -87
- package/src/lib/generators/component/files/ComponentFile.ts +0 -45
- package/src/lib/generators/component/files/ComponentTestFile.ts +0 -36
- package/src/lib/generators/module/ModuleGenerator.ts +0 -97
- package/src/lib/generators/module/files/ModuleFile.ts +0 -116
- package/src/lib/generators/module/files/ModuleTestFile.ts +0 -36
- package/src/lib/generators/plugin/PluginGenerator.ts +0 -87
- package/src/lib/generators/plugin/files/PluginFile.ts +0 -50
- package/src/lib/generators/plugin/files/PluginTestFile.ts +0 -36
- package/src/lib/generators/project/ProjectGenerator.ts +0 -205
- package/src/lib/generators/project/ProjectSourceFile.ts +0 -7
- package/src/lib/generators/project/configs/ProjectEslintrcConfig.ts +0 -47
- package/src/lib/generators/project/configs/ProjectPackageConfig.ts +0 -28
- package/src/lib/generators/project/configs/ProjectTypescriptConfig.ts +0 -35
- package/src/lib/manipulators/CreateComponentManipulator.ts +0 -66
- package/src/lib/manipulators/CreateDockerFileManipulator.ts +0 -121
- package/src/lib/manipulators/CreateModuleManipulator.ts +0 -137
- package/src/lib/manipulators/CreatePluginManipulator.ts +0 -71
- package/src/lib/manipulators/CreateProcessManipulator.ts +0 -56
- package/src/lib/manipulators/CreateThreadManipulator.ts +0 -56
- package/src/lib/manipulators/application/ApplicationIndexManipulator.ts +0 -169
- package/src/lib/menus/MainMenu.ts +0 -148
- package/src/lib/menus/initializeMenus/InitializeApplicationProject.ts +0 -84
- package/src/lib/menus/initializeMenus/InitializeComponentProject.ts +0 -84
- package/src/lib/menus/initializeMenus/InitializeModuleProject.ts +0 -84
- package/src/lib/menus/initializeMenus/InitializePluginProject.ts +0 -84
- package/src/lib/menus/manipulateMenus/ManipulateApplicationProject.ts +0 -60
- package/src/lib/menus/manipulateMenus/ManipulateComponentProject.ts +0 -13
- package/src/lib/menus/manipulateMenus/ManipulateModuleProject.ts +0 -49
- package/src/lib/menus/manipulateMenus/ManipulatePluginProject.ts +0 -13
- package/src/tests/generators/GenerateApplication.spec.ts +0 -16
- package/src/tests/generators/GenerateComponent.spec.ts +0 -16
- package/src/tests/generators/GenerateModule.spec.ts +0 -16
- package/src/tests/generators/GeneratePlugin.spec.ts +0 -16
- package/typings.d.ts +0 -4
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import ansis from 'ansis'
|
|
2
|
+
import {dirname, resolve} from 'node:path'
|
|
3
|
+
import {readFile} from 'node:fs/promises'
|
|
4
|
+
import {DTO, Provider, Time} from 'lakutata'
|
|
5
|
+
import {Configurable} from 'lakutata/decorator/di'
|
|
6
|
+
import {DevNull} from 'lakutata/helper'
|
|
7
|
+
|
|
8
|
+
export class Information extends Provider {
|
|
9
|
+
|
|
10
|
+
@Configurable(DTO.String().required())
|
|
11
|
+
protected readonly name: string
|
|
12
|
+
|
|
13
|
+
@Configurable(DTO.String().required())
|
|
14
|
+
protected readonly version: string
|
|
15
|
+
|
|
16
|
+
@Configurable(DTO.String().required())
|
|
17
|
+
protected readonly description: string
|
|
18
|
+
|
|
19
|
+
@Configurable(DTO.String().required())
|
|
20
|
+
protected readonly license: string
|
|
21
|
+
|
|
22
|
+
@Configurable(DTO.String().required())
|
|
23
|
+
protected readonly currentDirectory: string
|
|
24
|
+
|
|
25
|
+
@Configurable(DTO.String().required())
|
|
26
|
+
protected readonly workingDirectory: string
|
|
27
|
+
|
|
28
|
+
protected packageDirectory: (options?: any) => Promise<string | undefined>
|
|
29
|
+
|
|
30
|
+
protected installPath: string
|
|
31
|
+
|
|
32
|
+
protected projectRoot: string | null
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Initializer
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
38
|
+
protected async init(): Promise<void> {
|
|
39
|
+
const {packageDirectory} = await import('pkg-dir')
|
|
40
|
+
this.packageDirectory = packageDirectory
|
|
41
|
+
const installPath: string | undefined = await packageDirectory({cwd: this.currentDirectory})
|
|
42
|
+
this.installPath = installPath ? installPath : 'UNKNOWN'
|
|
43
|
+
|
|
44
|
+
const projectRoot: string | null = await this.findProjectRoot(this.workingDirectory)
|
|
45
|
+
if (projectRoot) {
|
|
46
|
+
const packageJsonPath: string = resolve(projectRoot, './package.json')
|
|
47
|
+
try {
|
|
48
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, {encoding: 'utf-8'}))
|
|
49
|
+
const dependenciesKeyRegExp: RegExp = new RegExp('dependencies'.toUpperCase())
|
|
50
|
+
Object.keys(packageJson).forEach((key: string): void => {
|
|
51
|
+
if (dependenciesKeyRegExp.test(key.toUpperCase())) {
|
|
52
|
+
Object.keys(packageJson[key]).forEach((dependencyName: string) => {
|
|
53
|
+
if (dependencyName === this.name) {
|
|
54
|
+
this.projectRoot = projectRoot
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
} catch (e) {
|
|
60
|
+
DevNull(e)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* To find the root path of the project where the working directory is located
|
|
67
|
+
* @param path
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
private async findProjectRoot(path: string): Promise<string | null> {
|
|
71
|
+
let localRootPath: string | null = null
|
|
72
|
+
while (true) {
|
|
73
|
+
const _localRootPath: string | null = await this.findLocalRoot(localRootPath ? dirname(localRootPath) : path)
|
|
74
|
+
if (!_localRootPath)
|
|
75
|
+
break
|
|
76
|
+
else
|
|
77
|
+
localRootPath = _localRootPath
|
|
78
|
+
}
|
|
79
|
+
return localRootPath
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* To locate the root path containing the package.json file
|
|
84
|
+
* @param path
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private async findLocalRoot(path: string): Promise<string | null> {
|
|
88
|
+
try {
|
|
89
|
+
const dir: string | undefined = await this.packageDirectory({cwd: path})
|
|
90
|
+
return dir ? dir : null
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Convert string first char to upper case
|
|
98
|
+
* @param str
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
private stringFirstCharUpperCase(str: string): string {
|
|
102
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Format framework ascii logo
|
|
107
|
+
* @protected
|
|
108
|
+
*/
|
|
109
|
+
protected formatFrameworkAsciiLogo(): string {
|
|
110
|
+
const asciiLogo: string = '' +
|
|
111
|
+
' _ _ _ \n' +
|
|
112
|
+
'| | _ | | | | \n' +
|
|
113
|
+
'| | __ _ | | _ _ _ | |_ __ _ | |_ __ _ \n' +
|
|
114
|
+
'| | / _` | | |/ / | | | | | __| / _` | | __| / _` | \n' +
|
|
115
|
+
'| |____ | (_| | | < | |_| | \\ |_ | (_| | \\ |_ | (_| | \n' +
|
|
116
|
+
'|______| \\__,_| |_|\\_\\ \\__,_| \\__| \\__,_| \\__| \\__,_| \n' +
|
|
117
|
+
' '
|
|
118
|
+
return `${ansis.yellow(asciiLogo)}`
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Format framework description
|
|
123
|
+
* @protected
|
|
124
|
+
*/
|
|
125
|
+
protected formatFrameworkDescription(): string {
|
|
126
|
+
return `${ansis.bold(this.stringFirstCharUpperCase(this.name))} is ${ansis.blue(this.description)}`
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Format version text
|
|
131
|
+
* @protected
|
|
132
|
+
*/
|
|
133
|
+
protected formatVersionText(): string {
|
|
134
|
+
return `The current version is ${ansis.bold(this.version)}`
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Format framework installation path
|
|
139
|
+
* @protected
|
|
140
|
+
*/
|
|
141
|
+
protected formatInstallationPath(): string {
|
|
142
|
+
return `The installation directory path is ${ansis.underline(this.getInstallPath())}`
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Format current running level
|
|
147
|
+
* @protected
|
|
148
|
+
*/
|
|
149
|
+
protected formatRunningLevel(): string {
|
|
150
|
+
return `Currently running at ${ansis.bold(this.getLevel())} level`
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Format license
|
|
155
|
+
* @protected
|
|
156
|
+
*/
|
|
157
|
+
protected formatLicense(): string {
|
|
158
|
+
return `${this.stringFirstCharUpperCase(this.name)} is ${ansis.cyan(this.license)} licensed.`
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Format copyright
|
|
163
|
+
* @protected
|
|
164
|
+
*/
|
|
165
|
+
protected formatCopyright(): string {
|
|
166
|
+
return `Copyright (c) ${new Time().format('YYYY')} ${ansis.bold(this.stringFirstCharUpperCase(this.name))}. All rights reserved.`
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* To retrieve the hierarchy level of the project containing the package under the current command
|
|
171
|
+
*/
|
|
172
|
+
public getLevel(): 'PROJECT' | 'GLOBAL' {
|
|
173
|
+
return this.projectRoot ? 'PROJECT' : 'GLOBAL'
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Locate the root path of the project
|
|
178
|
+
*/
|
|
179
|
+
public getRoot(): string | null {
|
|
180
|
+
return this.projectRoot
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Locate the installation directory
|
|
185
|
+
*/
|
|
186
|
+
public getInstallPath(): string {
|
|
187
|
+
return this.installPath
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Retrieve the framework installation version at the project level
|
|
192
|
+
*/
|
|
193
|
+
public async getProjectLevelInstalledFrameworkVersion(): Promise<string | null> {
|
|
194
|
+
const projectRoot: string | null = this.getRoot()
|
|
195
|
+
if (projectRoot) {
|
|
196
|
+
try {
|
|
197
|
+
const version: string = JSON.parse(await readFile(resolve(projectRoot, './node_modules', `./${this.name}/package.json`), {encoding: 'utf-8'})).version
|
|
198
|
+
return version ? version : null
|
|
199
|
+
} catch (e) {
|
|
200
|
+
return null
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return null
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Print infos
|
|
208
|
+
*/
|
|
209
|
+
public async print(): Promise<void> {
|
|
210
|
+
const texts: string[] = [
|
|
211
|
+
this.formatFrameworkAsciiLogo(),
|
|
212
|
+
this.formatFrameworkDescription(),
|
|
213
|
+
this.formatVersionText(),
|
|
214
|
+
this.formatInstallationPath(),
|
|
215
|
+
this.formatRunningLevel(),
|
|
216
|
+
this.formatLicense(),
|
|
217
|
+
this.formatCopyright()
|
|
218
|
+
]
|
|
219
|
+
console.info(texts.join('\n'))
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {ProjectTypeConfig} from '../lib/ProjectTypeConfig'
|
|
2
|
+
import {DTO} from 'lakutata'
|
|
3
|
+
import {Expect} from 'lakutata/decorator/dto'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create project options
|
|
7
|
+
*/
|
|
8
|
+
export class CreateProjectOptions extends DTO {
|
|
9
|
+
|
|
10
|
+
@Expect(
|
|
11
|
+
DTO
|
|
12
|
+
.String()
|
|
13
|
+
.required()
|
|
14
|
+
.pattern(/^(\w+\.?)*\w+$/)
|
|
15
|
+
.description('specify the name of the project and application')
|
|
16
|
+
)
|
|
17
|
+
public name: string
|
|
18
|
+
|
|
19
|
+
@Expect(
|
|
20
|
+
DTO
|
|
21
|
+
.String()
|
|
22
|
+
.required()
|
|
23
|
+
.pattern(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/)//Match package json name regex
|
|
24
|
+
.description('specify the ID of the application')
|
|
25
|
+
)
|
|
26
|
+
public id: string
|
|
27
|
+
|
|
28
|
+
@Expect(
|
|
29
|
+
DTO
|
|
30
|
+
.String()
|
|
31
|
+
.required()
|
|
32
|
+
.valid(...Object.keys(ProjectTypeConfig))
|
|
33
|
+
.description(`select the type of the project (choices: ${Object.keys(ProjectTypeConfig).map((type: string): string => `"${type}"`).join(',')})`)
|
|
34
|
+
)
|
|
35
|
+
public type: string
|
|
36
|
+
|
|
37
|
+
@Expect(
|
|
38
|
+
DTO
|
|
39
|
+
.String()
|
|
40
|
+
.optional()
|
|
41
|
+
.default(process.cwd())
|
|
42
|
+
.description(`specify the path for creating the project (default: "${process.cwd()}")`)
|
|
43
|
+
)
|
|
44
|
+
public path: string
|
|
45
|
+
|
|
46
|
+
@Expect(
|
|
47
|
+
DTO
|
|
48
|
+
.Boolean()
|
|
49
|
+
.strict(false)
|
|
50
|
+
.optional()
|
|
51
|
+
.default(false)
|
|
52
|
+
.description('initialize project only in specified directory without creating a new folder (default: false)')
|
|
53
|
+
)
|
|
54
|
+
public initOnly: boolean
|
|
55
|
+
|
|
56
|
+
@Expect(
|
|
57
|
+
DTO
|
|
58
|
+
.String()
|
|
59
|
+
.optional()
|
|
60
|
+
.default('none')
|
|
61
|
+
.description('specify the description of the application (default: "none")')
|
|
62
|
+
)
|
|
63
|
+
public description: string
|
|
64
|
+
|
|
65
|
+
@Expect(
|
|
66
|
+
DTO
|
|
67
|
+
.String()
|
|
68
|
+
.optional()
|
|
69
|
+
.default('Anonymous')
|
|
70
|
+
.description('specify the name of the author of the application (default: "Anonymous")')
|
|
71
|
+
)
|
|
72
|
+
public author: string
|
|
73
|
+
|
|
74
|
+
@Expect(
|
|
75
|
+
DTO
|
|
76
|
+
.String()
|
|
77
|
+
.optional()
|
|
78
|
+
.default('UNLICENSED')
|
|
79
|
+
.description('specify the name of the license for the application (default: "UNLICENSED")')
|
|
80
|
+
)
|
|
81
|
+
public license: string
|
|
82
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,37 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"strict": true,
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"target": "ES2017",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"emitDecoratorMetadata": true,
|
|
9
|
-
"experimentalDecorators": true,
|
|
10
|
-
"removeComments": true,
|
|
11
|
-
"allowJs": true,
|
|
12
|
-
"pretty": true,
|
|
13
|
-
"noUnusedLocals": false,
|
|
14
|
-
"noImplicitAny": false,
|
|
15
|
-
"noUnusedParameters": false,
|
|
16
|
-
"outDir": "build",
|
|
17
4
|
"rootDir": "src",
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"resolveJsonModule": false,
|
|
21
|
-
"strictPropertyInitialization": false,
|
|
22
|
-
"types": [
|
|
23
|
-
"reflect-metadata",
|
|
24
|
-
"node"
|
|
25
|
-
],
|
|
26
|
-
"lib": [
|
|
27
|
-
"ESNext",
|
|
28
|
-
"ES2017",
|
|
29
|
-
"dom"
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
"exclude": [
|
|
33
|
-
"node_modules",
|
|
34
|
-
"build",
|
|
35
|
-
"outputs"
|
|
36
|
-
]
|
|
5
|
+
"outDir": "dist"
|
|
6
|
+
}
|
|
37
7
|
}
|
package/.eslintrc.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es6": true,
|
|
5
|
-
"node": true,
|
|
6
|
-
"mocha": true
|
|
7
|
-
},
|
|
8
|
-
"extends": [
|
|
9
|
-
"plugin:@typescript-eslint/recommended"
|
|
10
|
-
],
|
|
11
|
-
"globals": {
|
|
12
|
-
"Atomics": "readonly",
|
|
13
|
-
"SharedArrayBuffer": "readonly"
|
|
14
|
-
},
|
|
15
|
-
"parserOptions": {
|
|
16
|
-
"ecmaVersion": 2018,
|
|
17
|
-
"sourceType": "module"
|
|
18
|
-
},
|
|
19
|
-
"plugins": [
|
|
20
|
-
"typescript",
|
|
21
|
-
"@typescript-eslint"
|
|
22
|
-
],
|
|
23
|
-
"rules": {
|
|
24
|
-
"quotes": [
|
|
25
|
-
"error",
|
|
26
|
-
"single"
|
|
27
|
-
],
|
|
28
|
-
"semi": [
|
|
29
|
-
"error",
|
|
30
|
-
"never"
|
|
31
|
-
],
|
|
32
|
-
"comma-dangle": "error",
|
|
33
|
-
"prefer-spread": "off",
|
|
34
|
-
"strict": "off",
|
|
35
|
-
"prefer-rest-params": "off",
|
|
36
|
-
"no-duplicate-imports": "error",
|
|
37
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
38
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
39
|
-
"@typescript-eslint/no-namespace": "off",
|
|
40
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
41
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
42
|
-
"@typescript-eslint/no-inferrable-types": "off",
|
|
43
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
44
|
-
"@typescript-eslint/ban-types": "off",
|
|
45
|
-
"@typescript-eslint/ban-ts-ignore": "off"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
-
<code_scheme name="Project" version="173">
|
|
3
|
-
<JSCodeStyleSettings version="0">
|
|
4
|
-
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
|
5
|
-
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
6
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
7
|
-
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
8
|
-
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
9
|
-
</JSCodeStyleSettings>
|
|
10
|
-
<TypeScriptCodeStyleSettings version="0">
|
|
11
|
-
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
|
12
|
-
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
13
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
14
|
-
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
15
|
-
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
16
|
-
</TypeScriptCodeStyleSettings>
|
|
17
|
-
</code_scheme>
|
|
18
|
-
</component>
|