@lakutata/cli 2.17.1 → 3.0.0-beta.0

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 (101) hide show
  1. package/README.md +455 -28
  2. package/dist/esm/CLIApp.js +6 -0
  3. package/dist/esm/Config.js +53 -0
  4. package/dist/esm/controllers/CommandLineController.js +180 -0
  5. package/dist/esm/controllers/I18nController.js +67 -0
  6. package/dist/esm/controllers/MigrationController.js +66 -0
  7. package/dist/esm/controllers/NativeController.js +41 -0
  8. package/dist/esm/controllers/PackController.js +88 -0
  9. package/dist/esm/controllers/WorkspaceController.js +91 -0
  10. package/dist/esm/dtos/AddPackageDTO.js +25 -0
  11. package/dist/esm/dtos/BundleDTO.js +29 -0
  12. package/dist/esm/dtos/CleanDTO.js +17 -0
  13. package/dist/esm/dtos/CreateProjectDTO.js +61 -0
  14. package/dist/esm/dtos/ExecutableDTO.js +37 -0
  15. package/dist/esm/dtos/I18nDTO.js +41 -0
  16. package/dist/esm/dtos/InstallerDTO.js +33 -0
  17. package/dist/{options/ListTemplatesOptions.js → esm/dtos/ListTemplatesDTO.js} +5 -14
  18. package/dist/esm/dtos/MigrationDTO.js +45 -0
  19. package/dist/esm/dtos/NativeDTO.js +41 -0
  20. package/dist/esm/dtos/RunScriptDTO.js +33 -0
  21. package/dist/esm/dtos/VersionDTO.js +29 -0
  22. package/dist/esm/lib/AddPackage.js +487 -0
  23. package/dist/esm/lib/Builder.js +21 -0
  24. package/dist/esm/lib/Clean.js +146 -0
  25. package/dist/esm/lib/Environment.js +11 -0
  26. package/dist/esm/lib/I18n.js +67 -0
  27. package/dist/esm/lib/Language.js +24 -0
  28. package/dist/esm/lib/Migration.js +94 -0
  29. package/dist/esm/lib/Output.js +40 -0
  30. package/dist/esm/lib/Processes.js +54 -0
  31. package/dist/esm/lib/ProjectCreator.js +191 -0
  32. package/dist/esm/lib/Registry.js +152 -0
  33. package/dist/esm/lib/Settings.js +25 -0
  34. package/dist/esm/lib/Tar.js +145 -0
  35. package/dist/esm/lib/TemplateCatalog.js +195 -0
  36. package/dist/esm/lib/TemplateFeatures.js +141 -0
  37. package/dist/esm/lib/Versions.js +58 -0
  38. package/dist/esm/lib/native/CMake.js +357 -0
  39. package/dist/esm/lib/native/Gyp.js +398 -0
  40. package/dist/esm/lib/native/NativeProject.js +370 -0
  41. package/dist/esm/lib/native/TextEdits.js +68 -0
  42. package/dist/esm/lib/native/Toml.js +325 -0
  43. package/dist/esm/lib/workspace/Run.js +111 -0
  44. package/dist/esm/lib/workspace/Version.js +144 -0
  45. package/dist/esm/lib/workspace/Workspace.js +231 -0
  46. package/dist/esm/locales/zh-CN.json +194 -0
  47. package/dist/esm/locales/zh-TW.json +194 -0
  48. package/dist/esm/types/ProcessResult.js +1 -0
  49. package/package.json +32 -43
  50. package/CHANGELOG.md +0 -460
  51. package/dist/CLIApp.d.ts +0 -3
  52. package/dist/CLIApp.d.ts.map +0 -1
  53. package/dist/CLIApp.js +0 -45
  54. package/dist/config/Config.d.ts +0 -3
  55. package/dist/config/Config.d.ts.map +0 -1
  56. package/dist/config/Config.js +0 -63
  57. package/dist/config/SetupCLIEntrypoint.d.ts +0 -3
  58. package/dist/config/SetupCLIEntrypoint.d.ts.map +0 -1
  59. package/dist/config/SetupCLIEntrypoint.js +0 -31
  60. package/dist/controllers/CommandLineController.d.ts +0 -25
  61. package/dist/controllers/CommandLineController.d.ts.map +0 -1
  62. package/dist/controllers/CommandLineController.js +0 -78
  63. package/dist/lib/ConvertDTO2Inquirer.d.ts +0 -3
  64. package/dist/lib/ConvertDTO2Inquirer.d.ts.map +0 -1
  65. package/dist/lib/ConvertDTO2Inquirer.js +0 -61
  66. package/dist/lib/GetDataDirectory.d.ts +0 -2
  67. package/dist/lib/GetDataDirectory.d.ts.map +0 -1
  68. package/dist/lib/GetDataDirectory.js +0 -11
  69. package/dist/lib/GetLocalDataFilename.d.ts +0 -2
  70. package/dist/lib/GetLocalDataFilename.d.ts.map +0 -1
  71. package/dist/lib/GetLocalDataFilename.js +0 -12
  72. package/dist/lib/ListTemplateNames.d.ts +0 -2
  73. package/dist/lib/ListTemplateNames.d.ts.map +0 -1
  74. package/dist/lib/ListTemplateNames.js +0 -44
  75. package/dist/lib/SpecialChar.d.ts +0 -9
  76. package/dist/lib/SpecialChar.d.ts.map +0 -1
  77. package/dist/lib/SpecialChar.js +0 -11
  78. package/dist/lib/components/DeGitPuller.d.ts +0 -19
  79. package/dist/lib/components/DeGitPuller.d.ts.map +0 -1
  80. package/dist/lib/components/DeGitPuller.js +0 -65
  81. package/dist/lib/components/Spinner.d.ts +0 -23
  82. package/dist/lib/components/Spinner.d.ts.map +0 -1
  83. package/dist/lib/components/Spinner.js +0 -61
  84. package/dist/lib/providers/Creator.d.ts +0 -46
  85. package/dist/lib/providers/Creator.d.ts.map +0 -1
  86. package/dist/lib/providers/Creator.js +0 -179
  87. package/dist/lib/providers/Information.d.ts +0 -91
  88. package/dist/lib/providers/Information.d.ts.map +0 -1
  89. package/dist/lib/providers/Information.js +0 -225
  90. package/dist/lib/providers/OnlineLatestVersion.d.ts +0 -14
  91. package/dist/lib/providers/OnlineLatestVersion.d.ts.map +0 -1
  92. package/dist/lib/providers/OnlineLatestVersion.js +0 -47
  93. package/dist/lib/providers/TemplateManager.d.ts +0 -36
  94. package/dist/lib/providers/TemplateManager.d.ts.map +0 -1
  95. package/dist/lib/providers/TemplateManager.js +0 -164
  96. package/dist/options/CreateProjectOptions.d.ts +0 -15
  97. package/dist/options/CreateProjectOptions.d.ts.map +0 -1
  98. package/dist/options/CreateProjectOptions.js +0 -94
  99. package/dist/options/ListTemplatesOptions.d.ts +0 -5
  100. package/dist/options/ListTemplatesOptions.d.ts.map +0 -1
  101. package/tsconfig.json +0 -7
@@ -1,179 +0,0 @@
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.Creator = void 0;
16
- const Information_js_1 = require("./Information.js");
17
- const DeGitPuller_js_1 = require("../components/DeGitPuller.js");
18
- const Spinner_js_1 = require("../components/Spinner.js");
19
- const CreateProjectOptions_js_1 = require("../../options/CreateProjectOptions.js");
20
- const node_path_1 = __importDefault(require("node:path"));
21
- const promises_1 = require("node:fs/promises");
22
- const SpecialChar_js_1 = require("../SpecialChar.js");
23
- const lakutata_1 = require("lakutata");
24
- const di_1 = require("lakutata/decorator/di");
25
- const logger_1 = require("lakutata/com/logger");
26
- const helper_1 = require("lakutata/helper");
27
- const dto_1 = require("lakutata/decorator/dto");
28
- const ansis_1 = __importDefault(require("ansis"));
29
- const cli_table3_1 = __importDefault(require("cli-table3"));
30
- const OnlineLatestVersion_1 = require("./OnlineLatestVersion");
31
- class Creator extends lakutata_1.Provider {
32
- /**
33
- * Check if the target path exists
34
- * @param targetDirectory
35
- * @param initOnly
36
- * @protected
37
- */
38
- async checkTargetPathExistence(targetDirectory, initOnly) {
39
- const exists = await (0, helper_1.IsExists)(targetDirectory);
40
- if (!exists && initOnly) {
41
- this.log.error(`${SpecialChar_js_1.charCross} The target path does not exist.`);
42
- return this.app.exit(1);
43
- }
44
- await (0, promises_1.mkdir)(targetDirectory, { recursive: true });
45
- this.log.info(`${SpecialChar_js_1.charCheck} The target path does not exist.`);
46
- }
47
- /**
48
- * Check target path is a valid directory
49
- * @param targetDirectory
50
- * @protected
51
- */
52
- async checkTargetPathIsDirectory(targetDirectory) {
53
- const targetInfo = await (0, promises_1.stat)(targetDirectory);
54
- if (!targetInfo.isDirectory()) {
55
- this.log.error(`${SpecialChar_js_1.charCross} The target path is not a valid directory.`);
56
- return this.app.exit(1);
57
- }
58
- this.log.info(`${SpecialChar_js_1.charCheck} The target path is a valid directory.`);
59
- }
60
- /**
61
- * Check target directory is empty, if the target directory is not empty, throw error and exit
62
- * @param targetDirectory
63
- * @param initOnly
64
- * @protected
65
- */
66
- async checkTargetDirectoryIsEmpty(targetDirectory, initOnly) {
67
- const files = await (0, promises_1.readdir)(targetDirectory);
68
- if (files.length && !initOnly) {
69
- this.log.error(`${SpecialChar_js_1.charCross} The target directory is not empty.`);
70
- return this.app.exit(1);
71
- }
72
- this.log.info(`${SpecialChar_js_1.charCheck} The target directory is empty.`);
73
- }
74
- /**
75
- * project information filling
76
- * @protected
77
- */
78
- async projectInformationFilling(targetPath, fields) {
79
- const items = await (0, helper_1.Glob)(node_path_1.default.resolve(targetPath, '**/*'));
80
- for (const item of items) {
81
- const stats = await (0, promises_1.stat)(item);
82
- if (!stats.isFile())
83
- continue;
84
- const rawContent = await (0, promises_1.readFile)(item, { encoding: 'utf-8' });
85
- const filledContent = (0, helper_1.Templating)(rawContent, fields, { ignoreMissing: true });
86
- if (rawContent !== filledContent)
87
- await (0, promises_1.writeFile)(item, filledContent, { flag: 'w' });
88
- }
89
- }
90
- /**
91
- * Exec create
92
- * @param options
93
- */
94
- async create(options) {
95
- const appName = options.name;
96
- const appId = options.id;
97
- const appDescription = options.description;
98
- const authorName = options.author;
99
- const licenseName = options.license;
100
- const appTemplate = options.template;
101
- const targetPath = options.overwrite ? node_path_1.default.resolve(options.path) : node_path_1.default.resolve(options.path, options.name);
102
- const table = new cli_table3_1.default();
103
- table.push([{ content: ansis_1.default.bold.cyan('Project Creation Information'), colSpan: 2, hAlign: 'center' }], [ansis_1.default.blue('APP ID & Project Name'), appId], [ansis_1.default.blue('APP Name'), appName], [ansis_1.default.blue('APP Description'), appDescription], [ansis_1.default.blue('Project Create Target Path'), targetPath], [ansis_1.default.blue('Project Create Mode'), options.overwrite ? ansis_1.default.yellow('Initialize project in an existing directory') : ansis_1.default.green('Create a new folder for the project')], [ansis_1.default.blue('Project Author Name'), authorName], [ansis_1.default.blue('Project License'), licenseName], [ansis_1.default.blue('Project Template Repository'), this.puller.getGitSource(appTemplate)]);
104
- console.log(table.toString());
105
- await new Promise(resolve => {
106
- let timeLeft = 10;
107
- const interval = setInterval(() => {
108
- timeLeft -= 1;
109
- if (!timeLeft) {
110
- clearInterval(interval);
111
- this.spinner.stop();
112
- return resolve();
113
- }
114
- }, 1000);
115
- this.spinner.start(() => `Please confirm the project creation information; the creation process will commence in ${timeLeft} seconds.`);
116
- });
117
- await this.checkTargetPathExistence(targetPath, options.overwrite);
118
- await this.checkTargetPathIsDirectory(targetPath);
119
- await this.checkTargetDirectoryIsEmpty(targetPath, options.overwrite);
120
- this.spinner.start('Pulling');
121
- await this.puller.pull(appTemplate, targetPath);
122
- this.spinner.stop();
123
- this.log.info(`${SpecialChar_js_1.charCheck} Template pulled.`);
124
- this.spinner.start('Filling information');
125
- await this.projectInformationFilling(targetPath, {
126
- $APP_NAME: appName,
127
- $APP_ID: appId,
128
- $APP_DESC: appDescription,
129
- $APP_AUTHOR: authorName,
130
- $APP_LICENSE: licenseName
131
- });
132
- this.spinner.stop();
133
- this.log.info(`${SpecialChar_js_1.charCheck} Project information filling completed.`);
134
- this.spinner.start('Installing');
135
- const { execa } = await import('execa');
136
- await execa('npm', ['install'], { cwd: targetPath });
137
- await execa('npm', ['install', `${this.onlineVersion.getName()}@${await this.onlineVersion.getVersion()}`], { cwd: targetPath });
138
- this.spinner.stop();
139
- this.log.info(`${SpecialChar_js_1.charCheck} Project has been successfully created.`);
140
- }
141
- }
142
- exports.Creator = Creator;
143
- __decorate([
144
- (0, di_1.Inject)(lakutata_1.Application),
145
- __metadata("design:type", lakutata_1.Application)
146
- ], Creator.prototype, "app", void 0);
147
- __decorate([
148
- (0, di_1.Inject)('log'),
149
- __metadata("design:type", logger_1.Logger)
150
- ], Creator.prototype, "log", void 0);
151
- __decorate([
152
- (0, di_1.Inject)('spinner'),
153
- __metadata("design:type", Spinner_js_1.Spinner)
154
- ], Creator.prototype, "spinner", void 0);
155
- __decorate([
156
- (0, di_1.Inject)('puller'),
157
- __metadata("design:type", DeGitPuller_js_1.DeGitPuller)
158
- ], Creator.prototype, "puller", void 0);
159
- __decorate([
160
- (0, di_1.Inject)('info'),
161
- __metadata("design:type", Information_js_1.Information)
162
- ], Creator.prototype, "frameworkInfo", void 0);
163
- __decorate([
164
- (0, di_1.Inject)('onlineVersion'),
165
- __metadata("design:type", OnlineLatestVersion_1.OnlineLatestVersion
166
- /**
167
- * Check if the target path exists
168
- * @param targetDirectory
169
- * @param initOnly
170
- * @protected
171
- */
172
- )
173
- ], Creator.prototype, "onlineVersion", void 0);
174
- __decorate([
175
- (0, dto_1.Accept)(CreateProjectOptions_js_1.CreateProjectOptions.required()),
176
- __metadata("design:type", Function),
177
- __metadata("design:paramtypes", [CreateProjectOptions_js_1.CreateProjectOptions]),
178
- __metadata("design:returntype", Promise)
179
- ], Creator.prototype, "create", null);
@@ -1,91 +0,0 @@
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
@@ -1 +0,0 @@
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;IA4BrC;;;;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;IAe/E;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAYtC"}
@@ -1,225 +0,0 @@
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 rawPackageJsonBuffer = await (0, promises_1.readFile)(packageJsonPath);
37
- const packageJson = JSON.parse(rawPackageJsonBuffer.toString());
38
- const dependenciesKeyRegExp = new RegExp('dependencies'.toUpperCase());
39
- Object.keys(packageJson).forEach((key) => {
40
- if (dependenciesKeyRegExp.test(key.toUpperCase())) {
41
- Object.keys(packageJson[key]).forEach((dependencyName) => {
42
- if (dependencyName === this.name) {
43
- this.projectRoot = projectRoot;
44
- }
45
- });
46
- }
47
- });
48
- }
49
- catch (e) {
50
- (0, helper_1.DevNull)(e);
51
- }
52
- }
53
- }
54
- /**
55
- * To find the root path of the project where the working directory is located
56
- * @param path
57
- * @private
58
- */
59
- async findProjectRoot(path) {
60
- let localRootPath = null;
61
- while (true) {
62
- const _localRootPath = await this.findLocalRoot(localRootPath ? (0, node_path_1.dirname)(localRootPath) : path);
63
- if (!_localRootPath)
64
- break;
65
- else
66
- localRootPath = _localRootPath;
67
- }
68
- return localRootPath;
69
- }
70
- /**
71
- * To locate the root path containing the package.json file
72
- * @param path
73
- * @private
74
- */
75
- async findLocalRoot(path) {
76
- try {
77
- const dir = await this.packageDirectory({ cwd: path });
78
- return dir ? dir : null;
79
- }
80
- catch (e) {
81
- return null;
82
- }
83
- }
84
- /**
85
- * Convert string first char to upper case
86
- * @param str
87
- * @private
88
- */
89
- stringFirstCharUpperCase(str) {
90
- return str.charAt(0).toUpperCase() + str.slice(1);
91
- }
92
- /**
93
- * Format framework ascii logo
94
- * @protected
95
- */
96
- formatFrameworkAsciiLogo() {
97
- const asciiLogo = '' +
98
- ' _ _ _ \n' +
99
- '| | _ | | | | \n' +
100
- '| | __ _ | | _ _ _ | |_ __ _ | |_ __ _ \n' +
101
- '| | / _` | | |/ / | | | | | __| / _` | | __| / _` | \n' +
102
- '| |____ | (_| | | < | |_| | \\ |_ | (_| | \\ |_ | (_| | \n' +
103
- '|______| \\__,_| |_|\\_\\ \\__,_| \\__| \\__,_| \\__| \\__,_| \n' +
104
- ' ';
105
- return `${ansis_1.default.yellow(asciiLogo)}`;
106
- }
107
- /**
108
- * Format framework description
109
- * @protected
110
- */
111
- formatFrameworkDescription() {
112
- return `${ansis_1.default.bold(this.stringFirstCharUpperCase(this.name))} is ${ansis_1.default.blue(this.description)}`;
113
- }
114
- /**
115
- * Format version text
116
- * @protected
117
- */
118
- formatVersionText() {
119
- return `The current version is ${ansis_1.default.bold(this.version)}`;
120
- }
121
- /**
122
- * Format framework installation path
123
- * @protected
124
- */
125
- formatInstallationPath() {
126
- return `The installation directory path is ${ansis_1.default.underline(this.getInstallPath())}`;
127
- }
128
- /**
129
- * Format current running level
130
- * @protected
131
- */
132
- formatRunningLevel() {
133
- return `Currently running at ${ansis_1.default.bold(this.getLevel())} level`;
134
- }
135
- /**
136
- * Format license
137
- * @protected
138
- */
139
- formatLicense() {
140
- return `${this.stringFirstCharUpperCase(this.name)} is ${ansis_1.default.cyan(this.license)} licensed.`;
141
- }
142
- /**
143
- * Format copyright
144
- * @protected
145
- */
146
- formatCopyright() {
147
- return `Copyright (c) ${new lakutata_1.Time().format('YYYY')} ${ansis_1.default.bold(this.stringFirstCharUpperCase(this.name))}. All rights reserved.`;
148
- }
149
- /**
150
- * To retrieve the hierarchy level of the project containing the package under the current command
151
- */
152
- getLevel() {
153
- return this.projectRoot ? 'PROJECT' : 'GLOBAL';
154
- }
155
- /**
156
- * Locate the root path of the project
157
- */
158
- getRoot() {
159
- return this.projectRoot;
160
- }
161
- /**
162
- * Locate the installation directory
163
- */
164
- getInstallPath() {
165
- return this.installPath;
166
- }
167
- /**
168
- * Retrieve the framework installation version at the project level
169
- */
170
- async getProjectLevelInstalledFrameworkVersion() {
171
- const projectRoot = this.getRoot();
172
- if (projectRoot) {
173
- try {
174
- const pkgJsonBuffer = await (0, promises_1.readFile)((0, node_path_1.resolve)(projectRoot, './node_modules', `./${this.name}/package.json`));
175
- const pkgJson = JSON.parse(pkgJsonBuffer.toString());
176
- const version = pkgJson.version;
177
- return version ? version : null;
178
- }
179
- catch (e) {
180
- return null;
181
- }
182
- }
183
- return null;
184
- }
185
- /**
186
- * Print infos
187
- */
188
- async print() {
189
- const texts = [
190
- this.formatFrameworkAsciiLogo(),
191
- this.formatFrameworkDescription(),
192
- this.formatVersionText(),
193
- this.formatInstallationPath(),
194
- this.formatRunningLevel(),
195
- this.formatLicense(),
196
- this.formatCopyright()
197
- ];
198
- console.info(texts.join('\n'));
199
- }
200
- }
201
- exports.Information = Information;
202
- __decorate([
203
- (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
204
- __metadata("design:type", String)
205
- ], Information.prototype, "name", void 0);
206
- __decorate([
207
- (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
208
- __metadata("design:type", String)
209
- ], Information.prototype, "version", void 0);
210
- __decorate([
211
- (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
212
- __metadata("design:type", String)
213
- ], Information.prototype, "description", void 0);
214
- __decorate([
215
- (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
216
- __metadata("design:type", String)
217
- ], Information.prototype, "license", void 0);
218
- __decorate([
219
- (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
220
- __metadata("design:type", String)
221
- ], Information.prototype, "currentDirectory", void 0);
222
- __decorate([
223
- (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
224
- __metadata("design:type", String)
225
- ], Information.prototype, "workingDirectory", void 0);
@@ -1,14 +0,0 @@
1
- import { Provider } from 'lakutata';
2
- export declare class OnlineLatestVersion extends Provider {
3
- protected readonly version: string;
4
- protected readonly name: string;
5
- /**
6
- * Get package name
7
- */
8
- getName(): string;
9
- /**
10
- * Get latest version
11
- */
12
- getVersion(): Promise<string>;
13
- }
14
- //# sourceMappingURL=OnlineLatestVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OnlineLatestVersion.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/OnlineLatestVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAA;AAIjC,qBAAa,mBAAoB,SAAQ,QAAQ;IAG7C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAE/B;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACU,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;CAY7C"}
@@ -1,47 +0,0 @@
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.OnlineLatestVersion = void 0;
13
- const lakutata_1 = require("lakutata");
14
- const di_1 = require("lakutata/decorator/di");
15
- const semver_1 = require("semver");
16
- class OnlineLatestVersion extends lakutata_1.Provider {
17
- /**
18
- * Get package name
19
- */
20
- getName() {
21
- return this.name;
22
- }
23
- /**
24
- * Get latest version
25
- */
26
- async getVersion() {
27
- let onlineLatestVersion;
28
- const prereleaseInfo = (0, semver_1.prerelease)(this.version);
29
- const latestVersionPackage = await import('latest-version');
30
- if (prereleaseInfo && prereleaseInfo[0]) {
31
- onlineLatestVersion = await latestVersionPackage.default(this.name, { version: prereleaseInfo[0].toString() });
32
- }
33
- else {
34
- onlineLatestVersion = await latestVersionPackage.default(this.name);
35
- }
36
- return (0, semver_1.gt)(onlineLatestVersion, this.version) ? onlineLatestVersion : this.version;
37
- }
38
- }
39
- exports.OnlineLatestVersion = OnlineLatestVersion;
40
- __decorate([
41
- (0, di_1.Configurable)(),
42
- __metadata("design:type", String)
43
- ], OnlineLatestVersion.prototype, "version", void 0);
44
- __decorate([
45
- (0, di_1.Configurable)(),
46
- __metadata("design:type", String)
47
- ], OnlineLatestVersion.prototype, "name", void 0);
@@ -1,36 +0,0 @@
1
- import { Application, Provider } from 'lakutata';
2
- import { ListTemplatesOptions } from '../../options/ListTemplatesOptions';
3
- import { Logger } from 'lakutata/com/logger';
4
- import { Spinner } from '../components/Spinner';
5
- type TemplateInfo = {
6
- name: string;
7
- description: string;
8
- repository: string;
9
- };
10
- export declare class TemplateManager extends Provider {
11
- protected readonly app: Application;
12
- protected readonly log: Logger;
13
- protected readonly spinner: Spinner;
14
- protected readonly apiHost: string;
15
- protected readonly repoPrefix: string;
16
- protected readonly localDataFilename: string;
17
- /**
18
- * Fetch template repository list from remote
19
- * @protected
20
- */
21
- protected fetchTemplateRepos(): Promise<TemplateInfo[]>;
22
- /**
23
- * List templates
24
- * @param options
25
- */
26
- list(options: ListTemplatesOptions): Promise<void>;
27
- /**
28
- * Print template information to console
29
- * @param templateInfos
30
- * @param updatedAt
31
- * @protected
32
- */
33
- protected printTemplates(templateInfos: TemplateInfo[], updatedAt: number): void;
34
- }
35
- export {};
36
- //# sourceMappingURL=TemplateManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplateManager.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/TemplateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAO,QAAQ,EAAO,MAAM,UAAU,CAAA;AACzD,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AAQvE,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAE1C,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAA;AAI7C,KAAK,YAAY,GAAG;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AAQD,qBAAa,eAAgB,SAAQ,QAAQ;IAGzC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;IAGnC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAG9B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAGnC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAErC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAyB;IAErE;;;OAGG;cACa,kBAAkB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IA0B7D;;;OAGG;IAEU,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB/D;;;;;OAKG;IACH,SAAS,CAAC,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAmBnF"}