@lakutata/cli 2.1.0-alpha.4 → 2.1.0-alpha.5

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/CLIApp.d.ts +3 -0
  3. package/dist/CLIApp.d.ts.map +1 -0
  4. package/dist/CLIApp.js +75 -0
  5. package/dist/controllers/CommandLineController.d.ts +20 -0
  6. package/dist/controllers/CommandLineController.d.ts.map +1 -0
  7. package/dist/controllers/CommandLineController.js +61 -0
  8. package/dist/lib/ProjectTypeConfig.d.ts +8 -0
  9. package/dist/lib/ProjectTypeConfig.d.ts.map +1 -0
  10. package/{src/lib/ProjectTypeConfig.ts → dist/lib/ProjectTypeConfig.js} +5 -8
  11. package/dist/lib/SpecialChar.d.ts +9 -0
  12. package/dist/lib/SpecialChar.d.ts.map +1 -0
  13. package/dist/lib/SpecialChar.js +11 -0
  14. package/dist/lib/components/DeGitPuller.d.ts +19 -0
  15. package/dist/lib/components/DeGitPuller.d.ts.map +1 -0
  16. package/dist/lib/components/DeGitPuller.js +65 -0
  17. package/dist/lib/components/Spinner.d.ts +23 -0
  18. package/dist/lib/components/Spinner.d.ts.map +1 -0
  19. package/dist/lib/components/Spinner.js +61 -0
  20. package/dist/lib/providers/Creator.d.ts +38 -0
  21. package/dist/lib/providers/Creator.d.ts.map +1 -0
  22. package/dist/lib/providers/Creator.js +142 -0
  23. package/dist/lib/providers/Information.d.ts +91 -0
  24. package/dist/lib/providers/Information.d.ts.map +1 -0
  25. package/dist/lib/providers/Information.js +222 -0
  26. package/dist/options/CreateProjectOptions.d.ts +15 -0
  27. package/dist/options/CreateProjectOptions.d.ts.map +1 -0
  28. package/dist/options/CreateProjectOptions.js +86 -0
  29. package/dist/options/LakutataInfoOptions.d.ts +4 -0
  30. package/dist/options/LakutataInfoOptions.d.ts.map +1 -0
  31. package/dist/options/LakutataInfoOptions.js +7 -0
  32. package/package.json +5 -2
  33. package/src/CLIApp.ts +0 -86
  34. package/src/controllers/CommandLineController.ts +0 -34
  35. package/src/lib/SpecialChar.ts +0 -8
  36. package/src/lib/components/DeGitPuller.ts +0 -41
  37. package/src/lib/components/Spinner.ts +0 -48
  38. package/src/lib/providers/Creator.ts +0 -125
  39. package/src/lib/providers/Information.ts +0 -221
  40. package/src/options/CreateProjectOptions.ts +0 -82
  41. package/src/options/LakutataInfoOptions.ts +0 -4
@@ -0,0 +1,91 @@
1
+ import { Provider } from 'lakutata';
2
+ export declare class Information extends Provider {
3
+ protected readonly name: string;
4
+ protected readonly version: string;
5
+ protected readonly description: string;
6
+ protected readonly license: string;
7
+ protected readonly currentDirectory: string;
8
+ protected readonly workingDirectory: string;
9
+ protected packageDirectory: (options?: any) => Promise<string | undefined>;
10
+ protected installPath: string;
11
+ protected projectRoot: string | null;
12
+ /**
13
+ * Initializer
14
+ * @protected
15
+ */
16
+ protected init(): Promise<void>;
17
+ /**
18
+ * To find the root path of the project where the working directory is located
19
+ * @param path
20
+ * @private
21
+ */
22
+ private findProjectRoot;
23
+ /**
24
+ * To locate the root path containing the package.json file
25
+ * @param path
26
+ * @private
27
+ */
28
+ private findLocalRoot;
29
+ /**
30
+ * Convert string first char to upper case
31
+ * @param str
32
+ * @private
33
+ */
34
+ private stringFirstCharUpperCase;
35
+ /**
36
+ * Format framework ascii logo
37
+ * @protected
38
+ */
39
+ protected formatFrameworkAsciiLogo(): string;
40
+ /**
41
+ * Format framework description
42
+ * @protected
43
+ */
44
+ protected formatFrameworkDescription(): string;
45
+ /**
46
+ * Format version text
47
+ * @protected
48
+ */
49
+ protected formatVersionText(): string;
50
+ /**
51
+ * Format framework installation path
52
+ * @protected
53
+ */
54
+ protected formatInstallationPath(): string;
55
+ /**
56
+ * Format current running level
57
+ * @protected
58
+ */
59
+ protected formatRunningLevel(): string;
60
+ /**
61
+ * Format license
62
+ * @protected
63
+ */
64
+ protected formatLicense(): string;
65
+ /**
66
+ * Format copyright
67
+ * @protected
68
+ */
69
+ protected formatCopyright(): string;
70
+ /**
71
+ * To retrieve the hierarchy level of the project containing the package under the current command
72
+ */
73
+ getLevel(): 'PROJECT' | 'GLOBAL';
74
+ /**
75
+ * Locate the root path of the project
76
+ */
77
+ getRoot(): string | null;
78
+ /**
79
+ * Locate the installation directory
80
+ */
81
+ getInstallPath(): string;
82
+ /**
83
+ * Retrieve the framework installation version at the project level
84
+ */
85
+ getProjectLevelInstalledFrameworkVersion(): Promise<string | null>;
86
+ /**
87
+ * Print infos
88
+ */
89
+ print(): Promise<void>;
90
+ }
91
+ //# sourceMappingURL=Information.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Information.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/Information.ts"],"names":[],"mappings":"AAGA,OAAO,EAAM,QAAQ,EAAO,MAAM,UAAU,CAAA;AAI5C,qBAAa,WAAY,SAAQ,QAAQ;IAGrC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAG/B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAGtC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IAG3C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IAE3C,SAAS,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAE1E,SAAS,CAAC,WAAW,EAAE,MAAM,CAAA;IAE7B,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAEpC;;;OAGG;cACa,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BrC;;;;OAIG;YACW,eAAe;IAY7B;;;;OAIG;YACW,aAAa;IAS3B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAIhC;;;OAGG;IACH,SAAS,CAAC,wBAAwB,IAAI,MAAM;IAY5C;;;OAGG;IACH,SAAS,CAAC,0BAA0B,IAAI,MAAM;IAI9C;;;OAGG;IACH,SAAS,CAAC,iBAAiB,IAAI,MAAM;IAIrC;;;OAGG;IACH,SAAS,CAAC,sBAAsB,IAAI,MAAM;IAI1C;;;OAGG;IACH,SAAS,CAAC,kBAAkB,IAAI,MAAM;IAItC;;;OAGG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IAIjC;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,MAAM;IAInC;;OAEG;IACI,QAAQ,IAAI,SAAS,GAAG,QAAQ;IAIvC;;OAEG;IACI,OAAO,IAAI,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACU,wCAAwC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa/E;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAYtC"}
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Information = void 0;
16
+ const ansis_1 = __importDefault(require("ansis"));
17
+ const node_path_1 = require("node:path");
18
+ const promises_1 = require("node:fs/promises");
19
+ const lakutata_1 = require("lakutata");
20
+ const di_1 = require("lakutata/decorator/di");
21
+ const helper_1 = require("lakutata/helper");
22
+ class Information extends lakutata_1.Provider {
23
+ /**
24
+ * Initializer
25
+ * @protected
26
+ */
27
+ async init() {
28
+ const { packageDirectory } = await import('pkg-dir');
29
+ this.packageDirectory = packageDirectory;
30
+ const installPath = await packageDirectory({ cwd: this.currentDirectory });
31
+ this.installPath = installPath ? installPath : 'UNKNOWN';
32
+ const projectRoot = await this.findProjectRoot(this.workingDirectory);
33
+ if (projectRoot) {
34
+ const packageJsonPath = (0, node_path_1.resolve)(projectRoot, './package.json');
35
+ try {
36
+ const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, { encoding: 'utf-8' }));
37
+ const dependenciesKeyRegExp = new RegExp('dependencies'.toUpperCase());
38
+ Object.keys(packageJson).forEach((key) => {
39
+ if (dependenciesKeyRegExp.test(key.toUpperCase())) {
40
+ Object.keys(packageJson[key]).forEach((dependencyName) => {
41
+ if (dependencyName === this.name) {
42
+ this.projectRoot = projectRoot;
43
+ }
44
+ });
45
+ }
46
+ });
47
+ }
48
+ catch (e) {
49
+ (0, helper_1.DevNull)(e);
50
+ }
51
+ }
52
+ }
53
+ /**
54
+ * To find the root path of the project where the working directory is located
55
+ * @param path
56
+ * @private
57
+ */
58
+ async findProjectRoot(path) {
59
+ let localRootPath = null;
60
+ while (true) {
61
+ const _localRootPath = await this.findLocalRoot(localRootPath ? (0, node_path_1.dirname)(localRootPath) : path);
62
+ if (!_localRootPath)
63
+ break;
64
+ else
65
+ localRootPath = _localRootPath;
66
+ }
67
+ return localRootPath;
68
+ }
69
+ /**
70
+ * To locate the root path containing the package.json file
71
+ * @param path
72
+ * @private
73
+ */
74
+ async findLocalRoot(path) {
75
+ try {
76
+ const dir = await this.packageDirectory({ cwd: path });
77
+ return dir ? dir : null;
78
+ }
79
+ catch (e) {
80
+ return null;
81
+ }
82
+ }
83
+ /**
84
+ * Convert string first char to upper case
85
+ * @param str
86
+ * @private
87
+ */
88
+ stringFirstCharUpperCase(str) {
89
+ return str.charAt(0).toUpperCase() + str.slice(1);
90
+ }
91
+ /**
92
+ * Format framework ascii logo
93
+ * @protected
94
+ */
95
+ formatFrameworkAsciiLogo() {
96
+ const asciiLogo = '' +
97
+ ' _ _ _ \n' +
98
+ '| | _ | | | | \n' +
99
+ '| | __ _ | | _ _ _ | |_ __ _ | |_ __ _ \n' +
100
+ '| | / _` | | |/ / | | | | | __| / _` | | __| / _` | \n' +
101
+ '| |____ | (_| | | < | |_| | \\ |_ | (_| | \\ |_ | (_| | \n' +
102
+ '|______| \\__,_| |_|\\_\\ \\__,_| \\__| \\__,_| \\__| \\__,_| \n' +
103
+ ' ';
104
+ return `${ansis_1.default.yellow(asciiLogo)}`;
105
+ }
106
+ /**
107
+ * Format framework description
108
+ * @protected
109
+ */
110
+ formatFrameworkDescription() {
111
+ return `${ansis_1.default.bold(this.stringFirstCharUpperCase(this.name))} is ${ansis_1.default.blue(this.description)}`;
112
+ }
113
+ /**
114
+ * Format version text
115
+ * @protected
116
+ */
117
+ formatVersionText() {
118
+ return `The current version is ${ansis_1.default.bold(this.version)}`;
119
+ }
120
+ /**
121
+ * Format framework installation path
122
+ * @protected
123
+ */
124
+ formatInstallationPath() {
125
+ return `The installation directory path is ${ansis_1.default.underline(this.getInstallPath())}`;
126
+ }
127
+ /**
128
+ * Format current running level
129
+ * @protected
130
+ */
131
+ formatRunningLevel() {
132
+ return `Currently running at ${ansis_1.default.bold(this.getLevel())} level`;
133
+ }
134
+ /**
135
+ * Format license
136
+ * @protected
137
+ */
138
+ formatLicense() {
139
+ return `${this.stringFirstCharUpperCase(this.name)} is ${ansis_1.default.cyan(this.license)} licensed.`;
140
+ }
141
+ /**
142
+ * Format copyright
143
+ * @protected
144
+ */
145
+ formatCopyright() {
146
+ return `Copyright (c) ${new lakutata_1.Time().format('YYYY')} ${ansis_1.default.bold(this.stringFirstCharUpperCase(this.name))}. All rights reserved.`;
147
+ }
148
+ /**
149
+ * To retrieve the hierarchy level of the project containing the package under the current command
150
+ */
151
+ getLevel() {
152
+ return this.projectRoot ? 'PROJECT' : 'GLOBAL';
153
+ }
154
+ /**
155
+ * Locate the root path of the project
156
+ */
157
+ getRoot() {
158
+ return this.projectRoot;
159
+ }
160
+ /**
161
+ * Locate the installation directory
162
+ */
163
+ getInstallPath() {
164
+ return this.installPath;
165
+ }
166
+ /**
167
+ * Retrieve the framework installation version at the project level
168
+ */
169
+ async getProjectLevelInstalledFrameworkVersion() {
170
+ const projectRoot = this.getRoot();
171
+ if (projectRoot) {
172
+ try {
173
+ const version = JSON.parse(await (0, promises_1.readFile)((0, node_path_1.resolve)(projectRoot, './node_modules', `./${this.name}/package.json`), { encoding: 'utf-8' })).version;
174
+ return version ? version : null;
175
+ }
176
+ catch (e) {
177
+ return null;
178
+ }
179
+ }
180
+ return null;
181
+ }
182
+ /**
183
+ * Print infos
184
+ */
185
+ async print() {
186
+ const texts = [
187
+ this.formatFrameworkAsciiLogo(),
188
+ this.formatFrameworkDescription(),
189
+ this.formatVersionText(),
190
+ this.formatInstallationPath(),
191
+ this.formatRunningLevel(),
192
+ this.formatLicense(),
193
+ this.formatCopyright()
194
+ ];
195
+ console.info(texts.join('\n'));
196
+ }
197
+ }
198
+ exports.Information = Information;
199
+ __decorate([
200
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
201
+ __metadata("design:type", String)
202
+ ], Information.prototype, "name", void 0);
203
+ __decorate([
204
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
205
+ __metadata("design:type", String)
206
+ ], Information.prototype, "version", void 0);
207
+ __decorate([
208
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
209
+ __metadata("design:type", String)
210
+ ], Information.prototype, "description", void 0);
211
+ __decorate([
212
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
213
+ __metadata("design:type", String)
214
+ ], Information.prototype, "license", void 0);
215
+ __decorate([
216
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
217
+ __metadata("design:type", String)
218
+ ], Information.prototype, "currentDirectory", void 0);
219
+ __decorate([
220
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
221
+ __metadata("design:type", String)
222
+ ], Information.prototype, "workingDirectory", void 0);
@@ -0,0 +1,15 @@
1
+ import { DTO } from 'lakutata';
2
+ /**
3
+ * Create project options
4
+ */
5
+ export declare class CreateProjectOptions extends DTO {
6
+ name: string;
7
+ id: string;
8
+ type: string;
9
+ path: string;
10
+ initOnly: boolean;
11
+ description: string;
12
+ author: string;
13
+ license: string;
14
+ }
15
+ //# sourceMappingURL=CreateProjectOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateProjectOptions.d.ts","sourceRoot":"","sources":["../../src/options/CreateProjectOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAG5B;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,GAAG;IASlC,IAAI,EAAE,MAAM,CAAA;IASZ,EAAE,EAAE,MAAM,CAAA;IASV,IAAI,EAAE,MAAM,CAAA;IASZ,IAAI,EAAE,MAAM,CAAA;IAUZ,QAAQ,EAAE,OAAO,CAAA;IASjB,WAAW,EAAE,MAAM,CAAA;IASnB,MAAM,EAAE,MAAM,CAAA;IASd,OAAO,EAAE,MAAM,CAAA;CACzB"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CreateProjectOptions = void 0;
13
+ const ProjectTypeConfig_1 = require("../lib/ProjectTypeConfig");
14
+ const lakutata_1 = require("lakutata");
15
+ const dto_1 = require("lakutata/decorator/dto");
16
+ /**
17
+ * Create project options
18
+ */
19
+ class CreateProjectOptions extends lakutata_1.DTO {
20
+ }
21
+ exports.CreateProjectOptions = CreateProjectOptions;
22
+ __decorate([
23
+ (0, dto_1.Expect)(lakutata_1.DTO
24
+ .String()
25
+ .required()
26
+ .pattern(/^(\w+\.?)*\w+$/)
27
+ .description('specify the name of the project and application')),
28
+ __metadata("design:type", String)
29
+ ], CreateProjectOptions.prototype, "name", void 0);
30
+ __decorate([
31
+ (0, dto_1.Expect)(lakutata_1.DTO
32
+ .String()
33
+ .required()
34
+ .pattern(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/) //Match package json name regex
35
+ .description('specify the ID of the application')),
36
+ __metadata("design:type", String)
37
+ ], CreateProjectOptions.prototype, "id", void 0);
38
+ __decorate([
39
+ (0, dto_1.Expect)(lakutata_1.DTO
40
+ .String()
41
+ .required()
42
+ .valid(...Object.keys(ProjectTypeConfig_1.ProjectTypeConfig))
43
+ .description(`select the type of the project (choices: ${Object.keys(ProjectTypeConfig_1.ProjectTypeConfig).map((type) => `"${type}"`).join(',')})`)),
44
+ __metadata("design:type", String)
45
+ ], CreateProjectOptions.prototype, "type", void 0);
46
+ __decorate([
47
+ (0, dto_1.Expect)(lakutata_1.DTO
48
+ .String()
49
+ .optional()
50
+ .default(process.cwd())
51
+ .description(`specify the path for creating the project (default: "${process.cwd()}")`)),
52
+ __metadata("design:type", String)
53
+ ], CreateProjectOptions.prototype, "path", void 0);
54
+ __decorate([
55
+ (0, dto_1.Expect)(lakutata_1.DTO
56
+ .Boolean()
57
+ .strict(false)
58
+ .optional()
59
+ .default(false)
60
+ .description('initialize project only in specified directory without creating a new folder (default: false)')),
61
+ __metadata("design:type", Boolean)
62
+ ], CreateProjectOptions.prototype, "initOnly", void 0);
63
+ __decorate([
64
+ (0, dto_1.Expect)(lakutata_1.DTO
65
+ .String()
66
+ .optional()
67
+ .default('none')
68
+ .description('specify the description of the application (default: "none")')),
69
+ __metadata("design:type", String)
70
+ ], CreateProjectOptions.prototype, "description", void 0);
71
+ __decorate([
72
+ (0, dto_1.Expect)(lakutata_1.DTO
73
+ .String()
74
+ .optional()
75
+ .default('Anonymous')
76
+ .description('specify the name of the author of the application (default: "Anonymous")')),
77
+ __metadata("design:type", String)
78
+ ], CreateProjectOptions.prototype, "author", void 0);
79
+ __decorate([
80
+ (0, dto_1.Expect)(lakutata_1.DTO
81
+ .String()
82
+ .optional()
83
+ .default('UNLICENSED')
84
+ .description('specify the name of the license for the application (default: "UNLICENSED")')),
85
+ __metadata("design:type", String)
86
+ ], CreateProjectOptions.prototype, "license", void 0);
@@ -0,0 +1,4 @@
1
+ import { DTO } from 'lakutata';
2
+ export declare class LakutataInfoOptions extends DTO {
3
+ }
4
+ //# sourceMappingURL=LakutataInfoOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LakutataInfoOptions.d.ts","sourceRoot":"","sources":["../../src/options/LakutataInfoOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAE5B,qBAAa,mBAAoB,SAAQ,GAAG;CAC3C"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LakutataInfoOptions = void 0;
4
+ const lakutata_1 = require("lakutata");
5
+ class LakutataInfoOptions extends lakutata_1.DTO {
6
+ }
7
+ exports.LakutataInfoOptions = LakutataInfoOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lakutata/cli",
3
- "version": "2.1.0-alpha.4",
3
+ "version": "2.1.0-alpha.5",
4
4
  "description": "Lakutata CLI tool",
5
5
  "keywords": [
6
6
  "lakutata",
@@ -21,6 +21,9 @@
21
21
  "url": "git+https://github.com/lakutata/lakutata-packages.git"
22
22
  },
23
23
  "scripts": {
24
+ "clean": "shx rm -rf ./dist",
25
+ "build": "tsc",
26
+ "rebuild": "npm run clean && npm run build",
24
27
  "test": "node ./__tests__/@lakutata/cli.test.js"
25
28
  },
26
29
  "bugs": {
@@ -38,5 +41,5 @@
38
41
  "devDependencies": {
39
42
  "@types/degit": "^2.8.6"
40
43
  },
41
- "gitHead": "cbbd971a6d3e9d52e470da5971de114b8d9cc09f"
44
+ "gitHead": "476ec3158b204c435155afccc4bdc0487948c9a1"
42
45
  }
package/src/CLIApp.ts DELETED
@@ -1,86 +0,0 @@
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
- })
@@ -1,34 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * ✓
3
- */
4
- export const charCheck: string = '\u2713'
5
- /**
6
- * ✗
7
- */
8
- export const charCross: string = '\u2717'
@@ -1,41 +0,0 @@
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
- }