@lakutata/cli 2.13.0 → 2.14.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.
- package/CHANGELOG.md +11 -0
- package/dist/CLIApp.js +23 -12
- package/dist/controllers/CommandLineController.d.ts.map +1 -1
- package/dist/controllers/CommandLineController.js +0 -25
- package/dist/lib/ConvertDTO2Inquirer.js +3 -3
- package/dist/lib/ListTemplateNames.d.ts +2 -0
- package/dist/lib/ListTemplateNames.d.ts.map +1 -0
- package/dist/lib/ListTemplateNames.js +20 -0
- package/dist/lib/providers/TemplateManager.d.ts +0 -6
- package/dist/lib/providers/TemplateManager.d.ts.map +1 -1
- package/dist/lib/providers/TemplateManager.js +1 -22
- package/dist/options/CreateProjectOptions.d.ts.map +1 -1
- package/dist/options/CreateProjectOptions.js +4 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.14.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.13.0...@lakutata/cli@2.14.0) (2025-07-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **cli:** refactor template management and DTO conversion ([7072c41](https://github.com/lakutata/lakutata-packages/commit/7072c4100419db43f00dc49cdfd9e48e0ec4cb0f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 2.13.0 (2025-07-11)
|
|
7
18
|
|
|
8
19
|
|
package/dist/CLIApp.js
CHANGED
|
@@ -27,17 +27,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const lakutata_1 = require("lakutata");
|
|
31
30
|
const console = __importStar(require("node:console"));
|
|
32
31
|
const node_path_1 = __importDefault(require("node:path"));
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
const ListTemplateNames_1 = require("./lib/ListTemplateNames");
|
|
33
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
34
|
+
const dataDir = node_path_1.default.resolve(__dirname, '../node_modules/.data');
|
|
35
|
+
const localDataFilename = node_path_1.default.resolve(dataDir, 'templates.db');
|
|
36
|
+
(0, ListTemplateNames_1.ListTemplateNames)(localDataFilename).then(async (templateNames) => {
|
|
37
|
+
node_process_1.default.env.LAKUTATA_TEMPLATE_NAMES = JSON.stringify(templateNames);
|
|
38
|
+
const { Config } = require('./config/Config');
|
|
39
|
+
const { Application } = await import('lakutata');
|
|
40
|
+
Application
|
|
41
|
+
.alias({
|
|
42
|
+
'@packageJson': node_path_1.default.resolve(__dirname, '../package.json'),
|
|
43
|
+
'@data': dataDir,
|
|
44
|
+
'@localDataFilename': localDataFilename
|
|
45
|
+
}, true)
|
|
46
|
+
.env({
|
|
47
|
+
LAKUTATA_TEMPLATE_NAMES: JSON.stringify(templateNames)
|
|
48
|
+
})
|
|
49
|
+
.run(Config)
|
|
50
|
+
.onUncaughtException((error) => {
|
|
51
|
+
console.error(`error: ${error.message}`);
|
|
52
|
+
return node_process_1.default.exit(1);
|
|
53
|
+
});
|
|
54
|
+
}).catch(() => node_process_1.default.exit(1));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineController.d.ts","sourceRoot":"","sources":["../../src/controllers/CommandLineController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAC,KAAK,aAAa,EAAM,MAAM,UAAU,CAAA;AAGhD,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"CommandLineController.d.ts","sourceRoot":"","sources":["../../src/controllers/CommandLineController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAC,KAAK,aAAa,EAAM,MAAM,UAAU,CAAA;AAGhD,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAA;AAIhE,qBAAa,qBAAsB,SAAQ,UAAU;IAGjD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAG1C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAA;IAG7C,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IAEnD;;OAEG;IAEU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;;OAGG;IAEU,SAAS,CAAC,GAAG,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/E;;OAEG;IAEU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"}
|
|
@@ -1,33 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
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;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
10
|
};
|
|
@@ -43,13 +20,11 @@ const ListTemplatesOptions_1 = require("../options/ListTemplatesOptions");
|
|
|
43
20
|
const TemplateManager_1 = require("../lib/providers/TemplateManager");
|
|
44
21
|
const CreateProjectOptions_1 = require("../options/CreateProjectOptions");
|
|
45
22
|
const ConvertDTO2Inquirer_1 = require("../lib/ConvertDTO2Inquirer");
|
|
46
|
-
const process = __importStar(require("node:process"));
|
|
47
23
|
class CommandLineController extends entrypoint_1.Controller {
|
|
48
24
|
/**
|
|
49
25
|
* Create project
|
|
50
26
|
*/
|
|
51
27
|
async create() {
|
|
52
|
-
process.env.LAKUTATA_TEMPLATE_NAMES = JSON.stringify(await this.templateManager.listNames());
|
|
53
28
|
await this.projectCreator.create(await (0, ConvertDTO2Inquirer_1.ConvertDTO2Inquirer)(CreateProjectOptions_1.CreateProjectOptions));
|
|
54
29
|
}
|
|
55
30
|
/**
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ConvertDTO2Inquirer = void 0;
|
|
7
7
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
8
|
async function ConvertDTO2Inquirer(dto) {
|
|
9
|
-
const jsonSchema = dto.
|
|
9
|
+
const jsonSchema = dto.toOpenAPIJsonSchema();
|
|
10
10
|
const prompts = [];
|
|
11
11
|
for (const propertyName in jsonSchema.properties) {
|
|
12
12
|
const propertyInfo = jsonSchema.properties[propertyName];
|
|
@@ -25,8 +25,8 @@ async function ConvertDTO2Inquirer(dto) {
|
|
|
25
25
|
break;
|
|
26
26
|
case 'string':
|
|
27
27
|
default: {
|
|
28
|
-
if (propertyInfo.
|
|
29
|
-
const enums = propertyInfo.
|
|
28
|
+
if (propertyInfo.enum) {
|
|
29
|
+
const enums = propertyInfo.enum;
|
|
30
30
|
prompts.push({
|
|
31
31
|
name: propertyName,
|
|
32
32
|
type: 'list',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListTemplateNames.d.ts","sourceRoot":"","sources":["../../src/lib/ListTemplateNames.ts"],"names":[],"mappings":"AAIA,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAWpF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListTemplateNames = void 0;
|
|
4
|
+
const helper_1 = require("lakutata/helper");
|
|
5
|
+
const lakutata_1 = require("lakutata");
|
|
6
|
+
const promises_1 = require("node:fs/promises");
|
|
7
|
+
async function ListTemplateNames(localDataFilename) {
|
|
8
|
+
const isLocalDataExists = await (0, helper_1.IsExists)(localDataFilename);
|
|
9
|
+
let cache = {
|
|
10
|
+
templates: [],
|
|
11
|
+
updatedAt: lakutata_1.Time.now()
|
|
12
|
+
};
|
|
13
|
+
if (isLocalDataExists) {
|
|
14
|
+
cache = JSON.parse(await (0, promises_1.readFile)(localDataFilename, { encoding: 'utf-8' }));
|
|
15
|
+
}
|
|
16
|
+
if (!cache)
|
|
17
|
+
return [];
|
|
18
|
+
return cache.templates.map(template => template.name);
|
|
19
|
+
}
|
|
20
|
+
exports.ListTemplateNames = ListTemplateNames;
|
|
@@ -14,11 +14,6 @@ export declare class TemplateManager extends Provider {
|
|
|
14
14
|
protected readonly apiHost: string;
|
|
15
15
|
protected readonly repoPrefix: string;
|
|
16
16
|
protected readonly localDataFilename: string;
|
|
17
|
-
/**
|
|
18
|
-
* Initializer
|
|
19
|
-
* @protected
|
|
20
|
-
*/
|
|
21
|
-
protected init(): Promise<void>;
|
|
22
17
|
/**
|
|
23
18
|
* Fetch template repository list from remote
|
|
24
19
|
* @protected
|
|
@@ -29,7 +24,6 @@ export declare class TemplateManager extends Provider {
|
|
|
29
24
|
* @param options
|
|
30
25
|
*/
|
|
31
26
|
list(options: ListTemplatesOptions): Promise<void>;
|
|
32
|
-
listNames(): Promise<string[]>;
|
|
33
27
|
/**
|
|
34
28
|
* Print template information to console
|
|
35
29
|
* @param templateInfos
|
|
@@ -1 +1 @@
|
|
|
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;AAG7C,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,
|
|
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;AAG7C,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,CAAqC;IAEjF;;;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"}
|
|
@@ -52,13 +52,7 @@ const promises_1 = require("node:fs/promises");
|
|
|
52
52
|
class TemplateManager extends lakutata_1.Provider {
|
|
53
53
|
constructor() {
|
|
54
54
|
super(...arguments);
|
|
55
|
-
this.localDataFilename = node_path_1.default.resolve('@
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Initializer
|
|
59
|
-
* @protected
|
|
60
|
-
*/
|
|
61
|
-
async init() {
|
|
55
|
+
this.localDataFilename = node_path_1.default.resolve('@localDataFilename');
|
|
62
56
|
}
|
|
63
57
|
/**
|
|
64
58
|
* Fetch template repository list from remote
|
|
@@ -117,21 +111,6 @@ class TemplateManager extends lakutata_1.Provider {
|
|
|
117
111
|
}
|
|
118
112
|
this.printTemplates(cache.templates, cache.updatedAt);
|
|
119
113
|
}
|
|
120
|
-
async listNames() {
|
|
121
|
-
const { version } = JSON.parse(await (0, promises_1.readFile)(node_path_1.default.resolve('@packageJson'), { encoding: 'utf-8' }));
|
|
122
|
-
const isLocalDataExists = await (0, helper_1.IsExists)(this.localDataFilename);
|
|
123
|
-
let cache = {
|
|
124
|
-
templates: [],
|
|
125
|
-
version: version,
|
|
126
|
-
updatedAt: lakutata_1.Time.now()
|
|
127
|
-
};
|
|
128
|
-
if (isLocalDataExists) {
|
|
129
|
-
cache = JSON.parse(await (0, promises_1.readFile)(this.localDataFilename, { encoding: 'utf-8' }));
|
|
130
|
-
}
|
|
131
|
-
if (!cache)
|
|
132
|
-
return [];
|
|
133
|
-
return cache.templates.map(template => template.name);
|
|
134
|
-
}
|
|
135
114
|
/**
|
|
136
115
|
* Print template information to console
|
|
137
116
|
* @param templateInfos
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateProjectOptions.d.ts","sourceRoot":"","sources":["../../src/options/CreateProjectOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"CreateProjectOptions.d.ts","sourceRoot":"","sources":["../../src/options/CreateProjectOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAQ5B;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,GAAG;IAQlC,IAAI,EAAE,MAAM,CAAA;IASZ,EAAE,EAAE,MAAM,CAAA;IAUV,QAAQ,EAAE,MAAM,CAAA;IAShB,IAAI,EAAE,MAAM,CAAA;IAUZ,SAAS,EAAE,OAAO,CAAA;IASlB,WAAW,EAAE,MAAM,CAAA;IASnB,MAAM,EAAE,MAAM,CAAA;IASd,OAAO,EAAE,MAAM,CAAA;CACzB"}
|
|
@@ -16,6 +16,9 @@ exports.CreateProjectOptions = void 0;
|
|
|
16
16
|
const lakutata_1 = require("lakutata");
|
|
17
17
|
const dto_1 = require("lakutata/decorator/dto");
|
|
18
18
|
const node_process_1 = __importDefault(require("node:process"));
|
|
19
|
+
function templateNames() {
|
|
20
|
+
return node_process_1.default.env.LAKUTATA_TEMPLATE_NAMES ? JSON.parse(node_process_1.default.env.LAKUTATA_TEMPLATE_NAMES) : [];
|
|
21
|
+
}
|
|
19
22
|
/**
|
|
20
23
|
* Create project options
|
|
21
24
|
*/
|
|
@@ -42,7 +45,7 @@ __decorate([
|
|
|
42
45
|
(0, dto_1.Expect)(lakutata_1.DTO
|
|
43
46
|
.String()
|
|
44
47
|
.required()
|
|
45
|
-
.allow(
|
|
48
|
+
.allow(...templateNames())
|
|
46
49
|
.only()
|
|
47
50
|
.description('Choose a template for this project')),
|
|
48
51
|
__metadata("design:type", String)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakutata/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Lakutata CLI tool",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lakutata",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/degit": "^2.8.6"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "dd63eb76227cfa240247f8f2edf368fa9f327091"
|
|
54
54
|
}
|