@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [2.1.0-alpha.4](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.1.0-alpha.3...@lakutata/cli@2.1.0-alpha.4) (2024-04-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @lakutata/cli
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.1.0-alpha.3](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.1.0-alpha.2...@lakutata/cli@2.1.0-alpha.3) (2024-04-15)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* Update Spinner.ts to use arrow function in setInterval ([ec3df2e](https://github.com/lakutata/lakutata-packages/commit/ec3df2e26ced10af012ed9cf6e50e108ac8205cc))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [2.1.0-alpha.2](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.1.0-alpha.1...@lakutata/cli@2.1.0-alpha.2) (2024-04-15)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* Update Spinner component ([fad870c](https://github.com/lakutata/lakutata-packages/commit/fad870cbcd912340c8eb9ae50286c805ca4079dd))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [2.1.0-alpha.1](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.1.0-alpha.0...@lakutata/cli@2.1.0-alpha.1) (2024-04-15)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* Implement log-update in Spinner component ([ceaf657](https://github.com/lakutata/lakutata-packages/commit/ceaf6570770fce60c0fda4a46957994350f3965b))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# [2.1.0-alpha.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.0.1-alpha.0...@lakutata/cli@2.1.0-alpha.0) (2024-04-15)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* **cli:** add create and info command ([670a1fc](https://github.com/lakutata/lakutata-packages/commit/670a1fcfbd38f39e6395647ffacb3867011882d7))
|
package/README.md
CHANGED
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="https://gitee.com/nnxr/lakutata-cli/raw/master/assets/lakutata-banner.png" />
|
|
3
|
-
</div>
|
|
1
|
+
# `@lakutata/cli`
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
[](https://npmjs.org/package/@lakutata/cli)
|
|
7
|
-
[](https://snyk.io/test/npm/@lakutata/cli)
|
|
8
|
-
[](https://npmjs.org/package/@lakutata/cli)
|
|
3
|
+
> TODO: description
|
|
9
4
|
|
|
10
|
-
##
|
|
5
|
+
## Usage
|
|
11
6
|
|
|
12
|
-
npm install -g @lakutata/cli
|
|
13
|
-
|
|
14
|
-
## Quickstart
|
|
15
|
-
|
|
16
|
-
Follow the commands listed below.
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
$ cd target-directory
|
|
20
|
-
$ lakutata
|
|
21
7
|
```
|
|
8
|
+
const cli = require('@lakutata/cli');
|
|
22
9
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## How to Contribute
|
|
26
|
-
|
|
27
|
-
Please let us know how can we help. Do check out [issues](https://gitee.com/nnxr/lakutata-cli/issues) for bug reports or suggestions first.
|
|
28
|
-
|
|
29
|
-
## License
|
|
30
|
-
|
|
31
|
-
[MIT](LICENSE)
|
|
10
|
+
// TODO: DEMONSTRATE API
|
|
11
|
+
```
|
package/package.json
CHANGED
|
@@ -1,70 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakutata/cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Lakutata CLI
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "2.1.0-alpha.4",
|
|
4
|
+
"description": "Lakutata CLI tool",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lakutata",
|
|
7
|
+
"cli",
|
|
8
|
+
"tool"
|
|
9
|
+
],
|
|
10
|
+
"author": "myq1991 <myq1991@gmail.com>",
|
|
11
|
+
"homepage": "https://github.com/lakutata/lakutata-packages",
|
|
12
|
+
"license": "MIT",
|
|
8
13
|
"bin": {
|
|
9
|
-
"lakutata": "./
|
|
10
|
-
"lakutata-deploy": "./build/Deploy.js"
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"clean": "shx rm -rf ./build",
|
|
14
|
-
"build": "tsc",
|
|
15
|
-
"rebuild": "npm run clean && npm run build",
|
|
16
|
-
"prepare": "npm run compile",
|
|
17
|
-
"compile": "npm run rebuild && shx rm -rf ./build/tests/*",
|
|
18
|
-
"link": "sudo npm link",
|
|
19
|
-
"unlink": "sudo npm r @lakutata/cli -g",
|
|
20
|
-
"test": "node -r ./node_modules/ts-node/register src/tests/**/*.spec.ts"
|
|
14
|
+
"lakutata": "./dist/CLIApp.js"
|
|
21
15
|
},
|
|
22
16
|
"publishConfig": {
|
|
23
|
-
"access": "public"
|
|
24
|
-
"registry": "https://registry.npmjs.org/"
|
|
17
|
+
"access": "public"
|
|
25
18
|
},
|
|
26
19
|
"repository": {
|
|
27
20
|
"type": "git",
|
|
28
|
-
"url": "https://
|
|
21
|
+
"url": "git+https://github.com/lakutata/lakutata-packages.git"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "node ./__tests__/@lakutata/cli.test.js"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/lakutata/lakutata-packages/issues"
|
|
29
28
|
},
|
|
30
|
-
"homepage": "https://lakutata.com",
|
|
31
|
-
"keywords": [
|
|
32
|
-
"lakutata",
|
|
33
|
-
"cli"
|
|
34
|
-
],
|
|
35
|
-
"author": "alex.ma",
|
|
36
|
-
"license": "MIT",
|
|
37
29
|
"dependencies": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"simple-git": "^3.9.0",
|
|
46
|
-
"ts-morph": "^13.0.2"
|
|
30
|
+
"ansis": "^3.1.0",
|
|
31
|
+
"cli-spinners": "^2.9.2",
|
|
32
|
+
"cli-table3": "^0.6.4",
|
|
33
|
+
"commander": "^12.0.0",
|
|
34
|
+
"degit": "^2.8.4",
|
|
35
|
+
"log-update": "^6.0.0",
|
|
36
|
+
"pkg-dir": "^8.0.0"
|
|
47
37
|
},
|
|
48
38
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@types/inquirer": "^8.1.3",
|
|
51
|
-
"@types/node": "^16.11.7",
|
|
52
|
-
"@types/semver": "^7.3.9",
|
|
53
|
-
"@types/shelljs": "^0.8.10",
|
|
54
|
-
"@types/update-notifier": "^5.1.0",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^4.27.0",
|
|
56
|
-
"@typescript-eslint/parser": "^4.27.0",
|
|
57
|
-
"eslint": "^7.32.0",
|
|
58
|
-
"eslint-config-standard": "^16.0.3",
|
|
59
|
-
"eslint-plugin-import": "^2.25.3",
|
|
60
|
-
"eslint-plugin-node": "^11.1.0",
|
|
61
|
-
"eslint-plugin-promise": "^5.2.0",
|
|
62
|
-
"eslint-plugin-typescript": "^0.14.0",
|
|
63
|
-
"shx": "^0.3.4",
|
|
64
|
-
"ts-node": "^10.9.1",
|
|
65
|
-
"typescript": "~4.7.4"
|
|
39
|
+
"@types/degit": "^2.8.6"
|
|
66
40
|
},
|
|
67
|
-
"
|
|
68
|
-
"node": ">=12.22.1"
|
|
69
|
-
}
|
|
41
|
+
"gitHead": "cbbd971a6d3e9d52e470da5971de114b8d9cc09f"
|
|
70
42
|
}
|
package/src/CLIApp.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {Command} from 'commander'
|
|
4
|
+
import {CommandLineController} from './controllers/CommandLineController'
|
|
5
|
+
import {Information} from './lib/providers/Information'
|
|
6
|
+
import {
|
|
7
|
+
name as packageName,
|
|
8
|
+
version as packageVersion,
|
|
9
|
+
description as packageDescription,
|
|
10
|
+
license as packageLicense
|
|
11
|
+
} from 'lakutata/package.json'
|
|
12
|
+
import {Creator} from './lib/providers/Creator'
|
|
13
|
+
import {DeGitPuller} from './lib/components/DeGitPuller'
|
|
14
|
+
import {Spinner} from './lib/components/Spinner'
|
|
15
|
+
import {dots} from 'cli-spinners'
|
|
16
|
+
import {Application, ApplicationOptions, JSONSchema, Module} from 'lakutata'
|
|
17
|
+
import {
|
|
18
|
+
BuildCLIEntrypoint,
|
|
19
|
+
BuildEntrypoints,
|
|
20
|
+
CLIContext,
|
|
21
|
+
CLIEntrypointHandler,
|
|
22
|
+
CLIMap,
|
|
23
|
+
EntrypointDestroyerRegistrar
|
|
24
|
+
} from 'lakutata/com/entrypoint'
|
|
25
|
+
|
|
26
|
+
Application.run(async (): Promise<ApplicationOptions> => ({
|
|
27
|
+
id: 'cli.lakutata.app',
|
|
28
|
+
name: 'Lakutata-CLI',
|
|
29
|
+
components: {
|
|
30
|
+
puller: {
|
|
31
|
+
class: DeGitPuller,
|
|
32
|
+
cache: false,
|
|
33
|
+
verbose: true,
|
|
34
|
+
force: true,
|
|
35
|
+
repo: 'lakutata/lakutata-template'
|
|
36
|
+
},
|
|
37
|
+
spinner: {
|
|
38
|
+
class: Spinner,
|
|
39
|
+
style: dots
|
|
40
|
+
},
|
|
41
|
+
entrypoint: BuildEntrypoints({
|
|
42
|
+
cli: BuildCLIEntrypoint((module: Module, cliMap: CLIMap, handler: CLIEntrypointHandler, registerDestroy: EntrypointDestroyerRegistrar) => {
|
|
43
|
+
const CLIProgram: Command = new Command()
|
|
44
|
+
cliMap.forEach((dtoJsonSchema: JSONSchema, command: string): void => {
|
|
45
|
+
const cmd: Command = new Command(command).description(dtoJsonSchema.description!)
|
|
46
|
+
for (const property in dtoJsonSchema.properties) {
|
|
47
|
+
const attr: JSONSchema = dtoJsonSchema.properties[property]
|
|
48
|
+
const optionsArgs: [string, string | undefined] = [`--${property} <${attr.type}>`, attr.description]
|
|
49
|
+
if (Array.isArray(dtoJsonSchema.required) && dtoJsonSchema.required.includes(property)) {
|
|
50
|
+
optionsArgs[1] = `(required) ${optionsArgs[1]}`
|
|
51
|
+
cmd.requiredOption(...optionsArgs)
|
|
52
|
+
} else {
|
|
53
|
+
cmd.option(...optionsArgs)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
cmd.action(async (args): Promise<any> => await handler(new CLIContext({
|
|
57
|
+
command: command,
|
|
58
|
+
data: args
|
|
59
|
+
})))
|
|
60
|
+
CLIProgram.addCommand(cmd)
|
|
61
|
+
})
|
|
62
|
+
CLIProgram.parse()
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
providers: {
|
|
67
|
+
creator: {
|
|
68
|
+
class: Creator
|
|
69
|
+
},
|
|
70
|
+
info: {
|
|
71
|
+
class: Information,
|
|
72
|
+
name: packageName,
|
|
73
|
+
version: packageVersion,
|
|
74
|
+
description: packageDescription,
|
|
75
|
+
license: packageLicense,
|
|
76
|
+
currentDirectory: __dirname,
|
|
77
|
+
workingDirectory: process.cwd()
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
controllers: [CommandLineController],
|
|
81
|
+
bootstrap: ['entrypoint']
|
|
82
|
+
}))
|
|
83
|
+
.onUncaughtException((error: Error) => {
|
|
84
|
+
console.error(`error: ${error.message}`)
|
|
85
|
+
return process.exit(1)
|
|
86
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {CreateProjectOptions} from '../options/CreateProjectOptions'
|
|
2
|
+
import {LakutataInfoOptions} from '../options/LakutataInfoOptions'
|
|
3
|
+
import {Information} from '../lib/providers/Information'
|
|
4
|
+
import {Creator} from '../lib/providers/Creator'
|
|
5
|
+
import {type ActionPattern, Controller} from 'lakutata'
|
|
6
|
+
import {Inject} from 'lakutata/decorator/di'
|
|
7
|
+
import {CLIAction} from 'lakutata/decorator/ctrl'
|
|
8
|
+
|
|
9
|
+
export class CommandLineController extends Controller {
|
|
10
|
+
|
|
11
|
+
@Inject('creator')
|
|
12
|
+
protected readonly projectCreator: Creator
|
|
13
|
+
|
|
14
|
+
@Inject('info')
|
|
15
|
+
protected readonly frameworkInfo: Information
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create project
|
|
19
|
+
* @param inp
|
|
20
|
+
*/
|
|
21
|
+
@CLIAction('create', CreateProjectOptions.description('create a Lakutata project'))
|
|
22
|
+
public async create(inp: ActionPattern<CreateProjectOptions>): Promise<void> {
|
|
23
|
+
await this.projectCreator.create(inp)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Show framework info
|
|
28
|
+
* @param inp
|
|
29
|
+
*/
|
|
30
|
+
@CLIAction('info', LakutataInfoOptions.description('show Lakutata framework info'))
|
|
31
|
+
public async info(inp: ActionPattern<LakutataInfoOptions>): Promise<void> {
|
|
32
|
+
await this.frameworkInfo.print()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface ProjectTypeBranch {
|
|
2
|
+
[type: string]: {
|
|
3
|
+
branch: string
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const ProjectTypeConfig: ProjectTypeBranch = {
|
|
8
|
+
plain: {
|
|
9
|
+
branch: 'main'
|
|
10
|
+
},
|
|
11
|
+
cli: {
|
|
12
|
+
branch: 'cli'
|
|
13
|
+
},
|
|
14
|
+
api: {
|
|
15
|
+
branch: 'api'
|
|
16
|
+
},
|
|
17
|
+
electron: {
|
|
18
|
+
branch: 'electron'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import degit from 'degit'
|
|
2
|
+
import {Configurable, Singleton} from 'lakutata/decorator/di'
|
|
3
|
+
import {Component, DTO} from 'lakutata'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@Singleton()
|
|
7
|
+
export class DeGitPuller extends Component {
|
|
8
|
+
|
|
9
|
+
@Configurable(DTO.Boolean().optional().default(false))
|
|
10
|
+
protected readonly cache: boolean = false
|
|
11
|
+
|
|
12
|
+
@Configurable(DTO.Boolean().optional().default(true))
|
|
13
|
+
protected readonly verbose: boolean = true
|
|
14
|
+
|
|
15
|
+
@Configurable(DTO.Boolean().optional().default(true))
|
|
16
|
+
protected readonly force: boolean = true
|
|
17
|
+
|
|
18
|
+
@Configurable(DTO.String().required())
|
|
19
|
+
protected readonly repo: string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* get git source
|
|
23
|
+
* @param branch
|
|
24
|
+
*/
|
|
25
|
+
public getGitSource(branch: string): string {
|
|
26
|
+
return `${this.repo}#${branch}`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Exec pull
|
|
31
|
+
* @param branch
|
|
32
|
+
* @param localTarget
|
|
33
|
+
*/
|
|
34
|
+
public async pull(branch: string, localTarget: string): Promise<void> {
|
|
35
|
+
await degit(this.getGitSource(branch), {
|
|
36
|
+
cache: this.cache,
|
|
37
|
+
verbose: this.verbose,
|
|
38
|
+
force: this.force
|
|
39
|
+
}).clone(localTarget)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {type Spinner as CliSpinner, dots} from 'cli-spinners'
|
|
2
|
+
import {Configurable, Singleton} from 'lakutata/decorator/di'
|
|
3
|
+
import {Component} from 'lakutata'
|
|
4
|
+
import {As} from 'lakutata/helper'
|
|
5
|
+
|
|
6
|
+
@Singleton()
|
|
7
|
+
export class Spinner extends Component {
|
|
8
|
+
|
|
9
|
+
@Configurable()
|
|
10
|
+
protected readonly style: CliSpinner = dots
|
|
11
|
+
|
|
12
|
+
protected spinnerInterval: NodeJS.Timeout | null = null
|
|
13
|
+
|
|
14
|
+
protected logUpdate: any
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initializer
|
|
18
|
+
* @protected
|
|
19
|
+
*/
|
|
20
|
+
protected async init(): Promise<void> {
|
|
21
|
+
this.logUpdate = As(await import('log-update'))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Start spinner
|
|
26
|
+
* @param description
|
|
27
|
+
*/
|
|
28
|
+
public start(description?: string | (() => string)): void {
|
|
29
|
+
this.stop()
|
|
30
|
+
let i: number = 0
|
|
31
|
+
this.spinnerInterval = setInterval((): void => {
|
|
32
|
+
const {frames} = this.style
|
|
33
|
+
const text: string = description ? `${frames[i = ++i % frames.length]} ${typeof description === 'function' ? description() : description}` : frames[i = ++i % frames.length]
|
|
34
|
+
this.logUpdate(text)
|
|
35
|
+
}, dots.interval)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stop spinner
|
|
40
|
+
*/
|
|
41
|
+
public stop(): void {
|
|
42
|
+
if (this.spinnerInterval) {
|
|
43
|
+
clearInterval(this.spinnerInterval)
|
|
44
|
+
this.spinnerInterval = null
|
|
45
|
+
this.logUpdate.clear()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {Information} from './Information.js'
|
|
2
|
+
import {DeGitPuller} from '../components/DeGitPuller.js'
|
|
3
|
+
import {Spinner} from '../components/Spinner.js'
|
|
4
|
+
import {CreateProjectOptions} from '../../options/CreateProjectOptions.js'
|
|
5
|
+
import {ProjectTypeConfig} from '../ProjectTypeConfig.js'
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
import {mkdir, readdir, stat} from 'node:fs/promises'
|
|
8
|
+
import {Stats} from 'node:fs'
|
|
9
|
+
import {charCheck, charCross} from '../SpecialChar.js'
|
|
10
|
+
import {Application, Provider} from 'lakutata'
|
|
11
|
+
import {Inject} from 'lakutata/decorator/di'
|
|
12
|
+
import {Logger} from 'lakutata/com/logger'
|
|
13
|
+
import {IsExists} from 'lakutata/helper'
|
|
14
|
+
import {Accept} from 'lakutata/decorator/dto'
|
|
15
|
+
import ansis from 'ansis'
|
|
16
|
+
import CLITable from 'cli-table3'
|
|
17
|
+
|
|
18
|
+
export class Creator extends Provider {
|
|
19
|
+
|
|
20
|
+
@Inject(Application)
|
|
21
|
+
protected readonly app: Application
|
|
22
|
+
|
|
23
|
+
@Inject('log')
|
|
24
|
+
protected readonly log: Logger
|
|
25
|
+
|
|
26
|
+
@Inject('spinner')
|
|
27
|
+
protected readonly spinner: Spinner
|
|
28
|
+
|
|
29
|
+
@Inject('puller')
|
|
30
|
+
protected readonly puller: DeGitPuller
|
|
31
|
+
|
|
32
|
+
@Inject('info')
|
|
33
|
+
protected readonly frameworkInfo: Information
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Check if the target path exists
|
|
37
|
+
* @param targetDirectory
|
|
38
|
+
* @param initOnly
|
|
39
|
+
* @protected
|
|
40
|
+
*/
|
|
41
|
+
protected async checkTargetPathExistence(targetDirectory: string, initOnly: boolean): Promise<void> {
|
|
42
|
+
const exists: boolean = await IsExists(targetDirectory)
|
|
43
|
+
if (!exists && initOnly) {
|
|
44
|
+
this.log.error(`${charCross} The target path does not exist.`)
|
|
45
|
+
return this.app.exit(1)
|
|
46
|
+
}
|
|
47
|
+
await mkdir(targetDirectory, {recursive: true})
|
|
48
|
+
this.log.info(`${charCheck} The target path does not exist.`)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Check target path is a valid directory
|
|
53
|
+
* @param targetDirectory
|
|
54
|
+
* @protected
|
|
55
|
+
*/
|
|
56
|
+
protected async checkTargetPathIsDirectory(targetDirectory: string): Promise<void> {
|
|
57
|
+
const targetInfo: Stats = await stat(targetDirectory)
|
|
58
|
+
if (!targetInfo.isDirectory()) {
|
|
59
|
+
this.log.error(`${charCross} The target path is not a valid directory.`)
|
|
60
|
+
return this.app.exit(1)
|
|
61
|
+
}
|
|
62
|
+
this.log.info(`${charCheck} The target path is a valid directory.`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Check target directory is empty, if the target directory is not empty, throw error and exit
|
|
67
|
+
* @param targetDirectory
|
|
68
|
+
* @protected
|
|
69
|
+
*/
|
|
70
|
+
protected async checkTargetDirectoryIsEmpty(targetDirectory: string): Promise<void> {
|
|
71
|
+
const files: string[] = await readdir(targetDirectory)
|
|
72
|
+
if (files.length) {
|
|
73
|
+
this.log.error(`${charCross} The target directory is not empty.`)
|
|
74
|
+
return this.app.exit(1)
|
|
75
|
+
}
|
|
76
|
+
this.log.info(`${charCheck} The target directory is empty.`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Exec create
|
|
81
|
+
* @param options
|
|
82
|
+
*/
|
|
83
|
+
@Accept(CreateProjectOptions.required())
|
|
84
|
+
public async create(options: CreateProjectOptions): Promise<void> {
|
|
85
|
+
const appName: string = options.name
|
|
86
|
+
const appId: string = options.id
|
|
87
|
+
const appDescription: string = options.description
|
|
88
|
+
const packageName: string = appId
|
|
89
|
+
const authorName: string = options.author
|
|
90
|
+
const licenseName: string = options.license
|
|
91
|
+
const appType: string = options.type
|
|
92
|
+
const targetPath: string = options.initOnly ? path.resolve(options.path) : path.resolve(options.path, options.name)
|
|
93
|
+
const {branch} = ProjectTypeConfig[appType]
|
|
94
|
+
const table: CLITable.Table = new CLITable()
|
|
95
|
+
table.push(
|
|
96
|
+
[{content: ansis.bold.cyan('Project Creation Information'), colSpan: 2, hAlign: 'center'}],
|
|
97
|
+
[ansis.blue('APP ID & Project Name'), appId],
|
|
98
|
+
[ansis.blue('APP Name'), appName],
|
|
99
|
+
[ansis.blue('APP Description'), appDescription],
|
|
100
|
+
[ansis.blue('Project Create Target Path'), targetPath],
|
|
101
|
+
[ansis.blue('Project Create Mode'), options.initOnly ? ansis.yellow('Initialize project in an existing directory') : ansis.green('Create a new folder for the project')],
|
|
102
|
+
[ansis.blue('Project Author Name'), authorName],
|
|
103
|
+
[ansis.blue('Project License'), licenseName],
|
|
104
|
+
[ansis.blue('Project Template Branch'), this.puller.getGitSource(branch)]
|
|
105
|
+
)
|
|
106
|
+
console.log(table.toString())
|
|
107
|
+
await new Promise<void>(resolve => {
|
|
108
|
+
let timeLeft: number = 15
|
|
109
|
+
const interval: NodeJS.Timeout = setInterval((): void => {
|
|
110
|
+
timeLeft -= 1
|
|
111
|
+
if (!timeLeft) {
|
|
112
|
+
clearInterval(interval)
|
|
113
|
+
this.spinner.stop()
|
|
114
|
+
return resolve()
|
|
115
|
+
}
|
|
116
|
+
}, 1000)
|
|
117
|
+
this.spinner.start((): string => `Please confirm the project creation information; the creation process will commence in ${timeLeft} seconds.`)
|
|
118
|
+
})
|
|
119
|
+
await this.checkTargetPathExistence(targetPath, options.initOnly)
|
|
120
|
+
await this.checkTargetPathIsDirectory(targetPath)
|
|
121
|
+
await this.checkTargetDirectoryIsEmpty(targetPath)
|
|
122
|
+
this.log.info('Begin project creation')
|
|
123
|
+
//TODO
|
|
124
|
+
}
|
|
125
|
+
}
|