@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.
- package/CHANGELOG.md +11 -0
- package/dist/CLIApp.d.ts +3 -0
- package/dist/CLIApp.d.ts.map +1 -0
- package/dist/CLIApp.js +75 -0
- package/dist/controllers/CommandLineController.d.ts +20 -0
- package/dist/controllers/CommandLineController.d.ts.map +1 -0
- package/dist/controllers/CommandLineController.js +61 -0
- package/dist/lib/ProjectTypeConfig.d.ts +8 -0
- package/dist/lib/ProjectTypeConfig.d.ts.map +1 -0
- package/{src/lib/ProjectTypeConfig.ts → dist/lib/ProjectTypeConfig.js} +5 -8
- package/dist/lib/SpecialChar.d.ts +9 -0
- package/dist/lib/SpecialChar.d.ts.map +1 -0
- package/dist/lib/SpecialChar.js +11 -0
- package/dist/lib/components/DeGitPuller.d.ts +19 -0
- package/dist/lib/components/DeGitPuller.d.ts.map +1 -0
- package/dist/lib/components/DeGitPuller.js +65 -0
- package/dist/lib/components/Spinner.d.ts +23 -0
- package/dist/lib/components/Spinner.d.ts.map +1 -0
- package/dist/lib/components/Spinner.js +61 -0
- package/dist/lib/providers/Creator.d.ts +38 -0
- package/dist/lib/providers/Creator.d.ts.map +1 -0
- package/dist/lib/providers/Creator.js +142 -0
- package/dist/lib/providers/Information.d.ts +91 -0
- package/dist/lib/providers/Information.d.ts.map +1 -0
- package/dist/lib/providers/Information.js +222 -0
- package/dist/options/CreateProjectOptions.d.ts +15 -0
- package/dist/options/CreateProjectOptions.d.ts.map +1 -0
- package/dist/options/CreateProjectOptions.js +86 -0
- package/dist/options/LakutataInfoOptions.d.ts +4 -0
- package/dist/options/LakutataInfoOptions.d.ts.map +1 -0
- package/dist/options/LakutataInfoOptions.js +7 -0
- package/package.json +5 -2
- package/src/CLIApp.ts +0 -86
- package/src/controllers/CommandLineController.ts +0 -34
- package/src/lib/SpecialChar.ts +0 -8
- package/src/lib/components/DeGitPuller.ts +0 -41
- package/src/lib/components/Spinner.ts +0 -48
- package/src/lib/providers/Creator.ts +0 -125
- package/src/lib/providers/Information.ts +0 -221
- package/src/options/CreateProjectOptions.ts +0 -82
- package/src/options/LakutataInfoOptions.ts +0 -4
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.1.0-alpha.5](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.1.0-alpha.4...@lakutata/cli@2.1.0-alpha.5) (2024-04-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **cli:** add clean, build, and rebuild scripts ([8d145cf](https://github.com/lakutata/lakutata-packages/commit/8d145cf70b753975c0e204b772074a2786887dbb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [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
18
|
|
|
8
19
|
**Note:** Version bump only for package @lakutata/cli
|
package/dist/CLIApp.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CLIApp.d.ts","sourceRoot":"","sources":["../src/CLIApp.ts"],"names":[],"mappings":""}
|
package/dist/CLIApp.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const CommandLineController_1 = require("./controllers/CommandLineController");
|
|
6
|
+
const Information_1 = require("./lib/providers/Information");
|
|
7
|
+
const package_json_1 = require("lakutata/package.json");
|
|
8
|
+
const Creator_1 = require("./lib/providers/Creator");
|
|
9
|
+
const DeGitPuller_1 = require("./lib/components/DeGitPuller");
|
|
10
|
+
const Spinner_1 = require("./lib/components/Spinner");
|
|
11
|
+
const cli_spinners_1 = require("cli-spinners");
|
|
12
|
+
const lakutata_1 = require("lakutata");
|
|
13
|
+
const entrypoint_1 = require("lakutata/com/entrypoint");
|
|
14
|
+
lakutata_1.Application.run(async () => ({
|
|
15
|
+
id: 'cli.lakutata.app',
|
|
16
|
+
name: 'Lakutata-CLI',
|
|
17
|
+
components: {
|
|
18
|
+
puller: {
|
|
19
|
+
class: DeGitPuller_1.DeGitPuller,
|
|
20
|
+
cache: false,
|
|
21
|
+
verbose: true,
|
|
22
|
+
force: true,
|
|
23
|
+
repo: 'lakutata/lakutata-template'
|
|
24
|
+
},
|
|
25
|
+
spinner: {
|
|
26
|
+
class: Spinner_1.Spinner,
|
|
27
|
+
style: cli_spinners_1.dots
|
|
28
|
+
},
|
|
29
|
+
entrypoint: (0, entrypoint_1.BuildEntrypoints)({
|
|
30
|
+
cli: (0, entrypoint_1.BuildCLIEntrypoint)((module, cliMap, handler, registerDestroy) => {
|
|
31
|
+
const CLIProgram = new commander_1.Command();
|
|
32
|
+
cliMap.forEach((dtoJsonSchema, command) => {
|
|
33
|
+
const cmd = new commander_1.Command(command).description(dtoJsonSchema.description);
|
|
34
|
+
for (const property in dtoJsonSchema.properties) {
|
|
35
|
+
const attr = dtoJsonSchema.properties[property];
|
|
36
|
+
const optionsArgs = [`--${property} <${attr.type}>`, attr.description];
|
|
37
|
+
if (Array.isArray(dtoJsonSchema.required) && dtoJsonSchema.required.includes(property)) {
|
|
38
|
+
optionsArgs[1] = `(required) ${optionsArgs[1]}`;
|
|
39
|
+
cmd.requiredOption(...optionsArgs);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
cmd.option(...optionsArgs);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
cmd.action(async (args) => await handler(new entrypoint_1.CLIContext({
|
|
46
|
+
command: command,
|
|
47
|
+
data: args
|
|
48
|
+
})));
|
|
49
|
+
CLIProgram.addCommand(cmd);
|
|
50
|
+
});
|
|
51
|
+
CLIProgram.parse();
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
providers: {
|
|
56
|
+
creator: {
|
|
57
|
+
class: Creator_1.Creator
|
|
58
|
+
},
|
|
59
|
+
info: {
|
|
60
|
+
class: Information_1.Information,
|
|
61
|
+
name: package_json_1.name,
|
|
62
|
+
version: package_json_1.version,
|
|
63
|
+
description: package_json_1.description,
|
|
64
|
+
license: package_json_1.license,
|
|
65
|
+
currentDirectory: __dirname,
|
|
66
|
+
workingDirectory: process.cwd()
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
controllers: [CommandLineController_1.CommandLineController],
|
|
70
|
+
bootstrap: ['entrypoint']
|
|
71
|
+
}))
|
|
72
|
+
.onUncaughtException((error) => {
|
|
73
|
+
console.error(`error: ${error.message}`);
|
|
74
|
+
return process.exit(1);
|
|
75
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export declare class CommandLineController extends Controller {
|
|
7
|
+
protected readonly projectCreator: Creator;
|
|
8
|
+
protected readonly frameworkInfo: Information;
|
|
9
|
+
/**
|
|
10
|
+
* Create project
|
|
11
|
+
* @param inp
|
|
12
|
+
*/
|
|
13
|
+
create(inp: ActionPattern<CreateProjectOptions>): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Show framework info
|
|
16
|
+
* @param inp
|
|
17
|
+
*/
|
|
18
|
+
info(inp: ActionPattern<LakutataInfoOptions>): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=CommandLineController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandLineController.d.ts","sourceRoot":"","sources":["../../src/controllers/CommandLineController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAC,KAAK,aAAa,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;AAIvD,qBAAa,qBAAsB,SAAQ,UAAU;IAGjD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAG1C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAA;IAE7C;;;OAGG;IAEU,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E;;;OAGG;IAEU,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5E"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.CommandLineController = void 0;
|
|
13
|
+
const CreateProjectOptions_1 = require("../options/CreateProjectOptions");
|
|
14
|
+
const LakutataInfoOptions_1 = require("../options/LakutataInfoOptions");
|
|
15
|
+
const Information_1 = require("../lib/providers/Information");
|
|
16
|
+
const Creator_1 = require("../lib/providers/Creator");
|
|
17
|
+
const lakutata_1 = require("lakutata");
|
|
18
|
+
const di_1 = require("lakutata/decorator/di");
|
|
19
|
+
const ctrl_1 = require("lakutata/decorator/ctrl");
|
|
20
|
+
class CommandLineController extends lakutata_1.Controller {
|
|
21
|
+
/**
|
|
22
|
+
* Create project
|
|
23
|
+
* @param inp
|
|
24
|
+
*/
|
|
25
|
+
async create(inp) {
|
|
26
|
+
await this.projectCreator.create(inp);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Show framework info
|
|
30
|
+
* @param inp
|
|
31
|
+
*/
|
|
32
|
+
async info(inp) {
|
|
33
|
+
await this.frameworkInfo.print();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.CommandLineController = CommandLineController;
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, di_1.Inject)('creator'),
|
|
39
|
+
__metadata("design:type", Creator_1.Creator)
|
|
40
|
+
], CommandLineController.prototype, "projectCreator", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, di_1.Inject)('info'),
|
|
43
|
+
__metadata("design:type", Information_1.Information
|
|
44
|
+
/**
|
|
45
|
+
* Create project
|
|
46
|
+
* @param inp
|
|
47
|
+
*/
|
|
48
|
+
)
|
|
49
|
+
], CommandLineController.prototype, "frameworkInfo", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, ctrl_1.CLIAction)('create', CreateProjectOptions_1.CreateProjectOptions.description('create a Lakutata project')),
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", [Object]),
|
|
54
|
+
__metadata("design:returntype", Promise)
|
|
55
|
+
], CommandLineController.prototype, "create", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, ctrl_1.CLIAction)('info', LakutataInfoOptions_1.LakutataInfoOptions.description('show Lakutata framework info')),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", [Object]),
|
|
60
|
+
__metadata("design:returntype", Promise)
|
|
61
|
+
], CommandLineController.prototype, "info", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectTypeConfig.d.ts","sourceRoot":"","sources":["../../src/lib/ProjectTypeConfig.ts"],"names":[],"mappings":"AAAA,UAAU,iBAAiB;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG;QACZ,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;CACJ;AAED,eAAO,MAAM,iBAAiB,EAAE,iBAa/B,CAAA"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const ProjectTypeConfig: ProjectTypeBranch = {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectTypeConfig = void 0;
|
|
4
|
+
exports.ProjectTypeConfig = {
|
|
8
5
|
plain: {
|
|
9
6
|
branch: 'main'
|
|
10
7
|
},
|
|
@@ -17,4 +14,4 @@ export const ProjectTypeConfig: ProjectTypeBranch = {
|
|
|
17
14
|
electron: {
|
|
18
15
|
branch: 'electron'
|
|
19
16
|
}
|
|
20
|
-
}
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpecialChar.d.ts","sourceRoot":"","sources":["../../src/lib/SpecialChar.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAiB,CAAA;AACzC;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAiB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component } from 'lakutata';
|
|
2
|
+
export declare class DeGitPuller extends Component {
|
|
3
|
+
protected readonly cache: boolean;
|
|
4
|
+
protected readonly verbose: boolean;
|
|
5
|
+
protected readonly force: boolean;
|
|
6
|
+
protected readonly repo: string;
|
|
7
|
+
/**
|
|
8
|
+
* get git source
|
|
9
|
+
* @param branch
|
|
10
|
+
*/
|
|
11
|
+
getGitSource(branch: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Exec pull
|
|
14
|
+
* @param branch
|
|
15
|
+
* @param localTarget
|
|
16
|
+
*/
|
|
17
|
+
pull(branch: string, localTarget: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=DeGitPuller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeGitPuller.d.ts","sourceRoot":"","sources":["../../../src/lib/components/DeGitPuller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAM,MAAM,UAAU,CAAA;AAGvC,qBACa,WAAY,SAAQ,SAAS;IAGtC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAQ;IAGzC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAO;IAG1C,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAO;IAGxC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAE/B;;;OAGG;IACI,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI3C;;;;OAIG;IACU,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOxE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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.DeGitPuller = void 0;
|
|
16
|
+
const degit_1 = __importDefault(require("degit"));
|
|
17
|
+
const di_1 = require("lakutata/decorator/di");
|
|
18
|
+
const lakutata_1 = require("lakutata");
|
|
19
|
+
let DeGitPuller = class DeGitPuller extends lakutata_1.Component {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.cache = false;
|
|
23
|
+
this.verbose = true;
|
|
24
|
+
this.force = true;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* get git source
|
|
28
|
+
* @param branch
|
|
29
|
+
*/
|
|
30
|
+
getGitSource(branch) {
|
|
31
|
+
return `${this.repo}#${branch}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Exec pull
|
|
35
|
+
* @param branch
|
|
36
|
+
* @param localTarget
|
|
37
|
+
*/
|
|
38
|
+
async pull(branch, localTarget) {
|
|
39
|
+
await (0, degit_1.default)(this.getGitSource(branch), {
|
|
40
|
+
cache: this.cache,
|
|
41
|
+
verbose: this.verbose,
|
|
42
|
+
force: this.force
|
|
43
|
+
}).clone(localTarget);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.DeGitPuller = DeGitPuller;
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, di_1.Configurable)(lakutata_1.DTO.Boolean().optional().default(false)),
|
|
49
|
+
__metadata("design:type", Boolean)
|
|
50
|
+
], DeGitPuller.prototype, "cache", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, di_1.Configurable)(lakutata_1.DTO.Boolean().optional().default(true)),
|
|
53
|
+
__metadata("design:type", Boolean)
|
|
54
|
+
], DeGitPuller.prototype, "verbose", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, di_1.Configurable)(lakutata_1.DTO.Boolean().optional().default(true)),
|
|
57
|
+
__metadata("design:type", Boolean)
|
|
58
|
+
], DeGitPuller.prototype, "force", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, di_1.Configurable)(lakutata_1.DTO.String().required()),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], DeGitPuller.prototype, "repo", void 0);
|
|
63
|
+
exports.DeGitPuller = DeGitPuller = __decorate([
|
|
64
|
+
(0, di_1.Singleton)()
|
|
65
|
+
], DeGitPuller);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { type Spinner as CliSpinner } from 'cli-spinners';
|
|
3
|
+
import { Component } from 'lakutata';
|
|
4
|
+
export declare class Spinner extends Component {
|
|
5
|
+
protected readonly style: CliSpinner;
|
|
6
|
+
protected spinnerInterval: NodeJS.Timeout | null;
|
|
7
|
+
protected logUpdate: any;
|
|
8
|
+
/**
|
|
9
|
+
* Initializer
|
|
10
|
+
* @protected
|
|
11
|
+
*/
|
|
12
|
+
protected init(): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Start spinner
|
|
15
|
+
* @param description
|
|
16
|
+
*/
|
|
17
|
+
start(description?: string | (() => string)): void;
|
|
18
|
+
/**
|
|
19
|
+
* Stop spinner
|
|
20
|
+
*/
|
|
21
|
+
stop(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=Spinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Spinner.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,OAAO,IAAI,UAAU,EAAO,MAAM,cAAc,CAAA;AAE7D,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAGlC,qBACa,OAAQ,SAAQ,SAAS;IAGlC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAO;IAE3C,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAO;IAEvD,SAAS,CAAC,SAAS,EAAE,GAAG,CAAA;IAExB;;;OAGG;cACa,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;IAUzD;;OAEG;IACI,IAAI,IAAI,IAAI;CAOtB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.Spinner = void 0;
|
|
13
|
+
const cli_spinners_1 = require("cli-spinners");
|
|
14
|
+
const di_1 = require("lakutata/decorator/di");
|
|
15
|
+
const lakutata_1 = require("lakutata");
|
|
16
|
+
const helper_1 = require("lakutata/helper");
|
|
17
|
+
let Spinner = class Spinner extends lakutata_1.Component {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.style = cli_spinners_1.dots;
|
|
21
|
+
this.spinnerInterval = null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Initializer
|
|
25
|
+
* @protected
|
|
26
|
+
*/
|
|
27
|
+
async init() {
|
|
28
|
+
this.logUpdate = (0, helper_1.As)(await import('log-update'));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Start spinner
|
|
32
|
+
* @param description
|
|
33
|
+
*/
|
|
34
|
+
start(description) {
|
|
35
|
+
this.stop();
|
|
36
|
+
let i = 0;
|
|
37
|
+
this.spinnerInterval = setInterval(() => {
|
|
38
|
+
const { frames } = this.style;
|
|
39
|
+
const text = description ? `${frames[i = ++i % frames.length]} ${typeof description === 'function' ? description() : description}` : frames[i = ++i % frames.length];
|
|
40
|
+
this.logUpdate(text);
|
|
41
|
+
}, cli_spinners_1.dots.interval);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Stop spinner
|
|
45
|
+
*/
|
|
46
|
+
stop() {
|
|
47
|
+
if (this.spinnerInterval) {
|
|
48
|
+
clearInterval(this.spinnerInterval);
|
|
49
|
+
this.spinnerInterval = null;
|
|
50
|
+
this.logUpdate.clear();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.Spinner = Spinner;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, di_1.Configurable)(),
|
|
57
|
+
__metadata("design:type", Object)
|
|
58
|
+
], Spinner.prototype, "style", void 0);
|
|
59
|
+
exports.Spinner = Spinner = __decorate([
|
|
60
|
+
(0, di_1.Singleton)()
|
|
61
|
+
], Spinner);
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { Application, Provider } from 'lakutata';
|
|
6
|
+
import { Logger } from 'lakutata/com/logger';
|
|
7
|
+
export declare class Creator extends Provider {
|
|
8
|
+
protected readonly app: Application;
|
|
9
|
+
protected readonly log: Logger;
|
|
10
|
+
protected readonly spinner: Spinner;
|
|
11
|
+
protected readonly puller: DeGitPuller;
|
|
12
|
+
protected readonly frameworkInfo: Information;
|
|
13
|
+
/**
|
|
14
|
+
* Check if the target path exists
|
|
15
|
+
* @param targetDirectory
|
|
16
|
+
* @param initOnly
|
|
17
|
+
* @protected
|
|
18
|
+
*/
|
|
19
|
+
protected checkTargetPathExistence(targetDirectory: string, initOnly: boolean): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Check target path is a valid directory
|
|
22
|
+
* @param targetDirectory
|
|
23
|
+
* @protected
|
|
24
|
+
*/
|
|
25
|
+
protected checkTargetPathIsDirectory(targetDirectory: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Check target directory is empty, if the target directory is not empty, throw error and exit
|
|
28
|
+
* @param targetDirectory
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
31
|
+
protected checkTargetDirectoryIsEmpty(targetDirectory: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Exec create
|
|
34
|
+
* @param options
|
|
35
|
+
*/
|
|
36
|
+
create(options: CreateProjectOptions): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Creator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Creator.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/Creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAM1E,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAA;AAE9C,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAM1C,qBAAa,OAAQ,SAAQ,QAAQ;IAGjC,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,MAAM,EAAE,WAAW,CAAA;IAGtC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAA;IAE7C;;;;;OAKG;cACa,wBAAwB,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnG;;;;OAIG;cACa,0BAA0B,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASlF;;;;OAIG;cACa,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASnF;;;OAGG;IAEU,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAyCpE"}
|
|
@@ -0,0 +1,142 @@
|
|
|
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 ProjectTypeConfig_js_1 = require("../ProjectTypeConfig.js");
|
|
21
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
22
|
+
const promises_1 = require("node:fs/promises");
|
|
23
|
+
const SpecialChar_js_1 = require("../SpecialChar.js");
|
|
24
|
+
const lakutata_1 = require("lakutata");
|
|
25
|
+
const di_1 = require("lakutata/decorator/di");
|
|
26
|
+
const logger_1 = require("lakutata/com/logger");
|
|
27
|
+
const helper_1 = require("lakutata/helper");
|
|
28
|
+
const dto_1 = require("lakutata/decorator/dto");
|
|
29
|
+
const ansis_1 = __importDefault(require("ansis"));
|
|
30
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
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
|
+
* @protected
|
|
64
|
+
*/
|
|
65
|
+
async checkTargetDirectoryIsEmpty(targetDirectory) {
|
|
66
|
+
const files = await (0, promises_1.readdir)(targetDirectory);
|
|
67
|
+
if (files.length) {
|
|
68
|
+
this.log.error(`${SpecialChar_js_1.charCross} The target directory is not empty.`);
|
|
69
|
+
return this.app.exit(1);
|
|
70
|
+
}
|
|
71
|
+
this.log.info(`${SpecialChar_js_1.charCheck} The target directory is empty.`);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Exec create
|
|
75
|
+
* @param options
|
|
76
|
+
*/
|
|
77
|
+
async create(options) {
|
|
78
|
+
const appName = options.name;
|
|
79
|
+
const appId = options.id;
|
|
80
|
+
const appDescription = options.description;
|
|
81
|
+
const packageName = appId;
|
|
82
|
+
const authorName = options.author;
|
|
83
|
+
const licenseName = options.license;
|
|
84
|
+
const appType = options.type;
|
|
85
|
+
const targetPath = options.initOnly ? node_path_1.default.resolve(options.path) : node_path_1.default.resolve(options.path, options.name);
|
|
86
|
+
const { branch } = ProjectTypeConfig_js_1.ProjectTypeConfig[appType];
|
|
87
|
+
const table = new cli_table3_1.default();
|
|
88
|
+
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.initOnly ? 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 Branch'), this.puller.getGitSource(branch)]);
|
|
89
|
+
console.log(table.toString());
|
|
90
|
+
await new Promise(resolve => {
|
|
91
|
+
let timeLeft = 15;
|
|
92
|
+
const interval = setInterval(() => {
|
|
93
|
+
timeLeft -= 1;
|
|
94
|
+
if (!timeLeft) {
|
|
95
|
+
clearInterval(interval);
|
|
96
|
+
this.spinner.stop();
|
|
97
|
+
return resolve();
|
|
98
|
+
}
|
|
99
|
+
}, 1000);
|
|
100
|
+
this.spinner.start(() => `Please confirm the project creation information; the creation process will commence in ${timeLeft} seconds.`);
|
|
101
|
+
});
|
|
102
|
+
await this.checkTargetPathExistence(targetPath, options.initOnly);
|
|
103
|
+
await this.checkTargetPathIsDirectory(targetPath);
|
|
104
|
+
await this.checkTargetDirectoryIsEmpty(targetPath);
|
|
105
|
+
this.log.info('Begin project creation');
|
|
106
|
+
//TODO
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.Creator = Creator;
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, di_1.Inject)(lakutata_1.Application),
|
|
112
|
+
__metadata("design:type", lakutata_1.Application)
|
|
113
|
+
], Creator.prototype, "app", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, di_1.Inject)('log'),
|
|
116
|
+
__metadata("design:type", logger_1.Logger)
|
|
117
|
+
], Creator.prototype, "log", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, di_1.Inject)('spinner'),
|
|
120
|
+
__metadata("design:type", Spinner_js_1.Spinner)
|
|
121
|
+
], Creator.prototype, "spinner", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, di_1.Inject)('puller'),
|
|
124
|
+
__metadata("design:type", DeGitPuller_js_1.DeGitPuller)
|
|
125
|
+
], Creator.prototype, "puller", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, di_1.Inject)('info'),
|
|
128
|
+
__metadata("design:type", Information_js_1.Information
|
|
129
|
+
/**
|
|
130
|
+
* Check if the target path exists
|
|
131
|
+
* @param targetDirectory
|
|
132
|
+
* @param initOnly
|
|
133
|
+
* @protected
|
|
134
|
+
*/
|
|
135
|
+
)
|
|
136
|
+
], Creator.prototype, "frameworkInfo", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
(0, dto_1.Accept)(CreateProjectOptions_js_1.CreateProjectOptions.required()),
|
|
139
|
+
__metadata("design:type", Function),
|
|
140
|
+
__metadata("design:paramtypes", [CreateProjectOptions_js_1.CreateProjectOptions]),
|
|
141
|
+
__metadata("design:returntype", Promise)
|
|
142
|
+
], Creator.prototype, "create", null);
|