@lakutata/cli 2.2.0 → 2.3.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 +18 -0
- package/dist/CLIApp.js +31 -1
- package/dist/controllers/CommandLineController.d.ts +2 -1
- package/dist/controllers/CommandLineController.d.ts.map +1 -1
- package/dist/controllers/CommandLineController.js +2 -2
- package/dist/lib/components/Spinner.d.ts.map +1 -1
- package/dist/lib/components/Spinner.js +1 -2
- package/dist/lib/providers/Creator.d.ts +2 -0
- package/dist/lib/providers/Creator.d.ts.map +1 -1
- package/dist/lib/providers/Creator.js +19 -5
- package/dist/lib/providers/Information.d.ts.map +1 -1
- package/dist/lib/providers/Information.js +6 -2
- package/dist/lib/providers/OnlineLatestVersion.d.ts +14 -0
- package/dist/lib/providers/OnlineLatestVersion.d.ts.map +1 -0
- package/dist/lib/providers/OnlineLatestVersion.js +46 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.3.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.2.0...@lakutata/cli@2.3.0) (2024-04-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Fix import statements in CLIApp.ts and Information.ts ([bff006b](https://github.com/lakutata/lakutata-packages/commit/bff006b9adb51fc95bc0d018950d9b88493d60ad))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **cli:** add initialization step after project creation ([5843178](https://github.com/lakutata/lakutata-packages/commit/5843178bfb91f1420921717fc1f63b7f11dfd48a))
|
|
17
|
+
* **cli:** update dependencies and improve installation process ([fd70167](https://github.com/lakutata/lakutata-packages/commit/fd70167d37b3f9af738272ac2e8599d45bc26347))
|
|
18
|
+
* Update lakutata package to version 2.0.2 ([e3c0b22](https://github.com/lakutata/lakutata-packages/commit/e3c0b22e65ae250f396e8b71137f41c61049df5b))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
# [2.2.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.1.0-alpha.5...@lakutata/cli@2.2.0) (2024-04-15)
|
|
7
25
|
|
|
8
26
|
|
package/dist/CLIApp.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
3
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
27
|
const commander_1 = require("commander");
|
|
5
28
|
const CommandLineController_1 = require("./controllers/CommandLineController");
|
|
@@ -11,6 +34,8 @@ const Spinner_1 = require("./lib/components/Spinner");
|
|
|
11
34
|
const cli_spinners_1 = require("cli-spinners");
|
|
12
35
|
const lakutata_1 = require("lakutata");
|
|
13
36
|
const entrypoint_1 = require("lakutata/com/entrypoint");
|
|
37
|
+
const console = __importStar(require("node:console"));
|
|
38
|
+
const OnlineLatestVersion_1 = require("./lib/providers/OnlineLatestVersion");
|
|
14
39
|
lakutata_1.Application.run(async () => ({
|
|
15
40
|
id: 'cli.lakutata.app',
|
|
16
41
|
name: 'Lakutata-CLI',
|
|
@@ -27,6 +52,7 @@ lakutata_1.Application.run(async () => ({
|
|
|
27
52
|
style: cli_spinners_1.dots
|
|
28
53
|
},
|
|
29
54
|
entrypoint: (0, entrypoint_1.BuildEntrypoints)({
|
|
55
|
+
controllers: [CommandLineController_1.CommandLineController],
|
|
30
56
|
cli: (0, entrypoint_1.BuildCLIEntrypoint)((module, cliMap, handler, registerDestroy) => {
|
|
31
57
|
const CLIProgram = new commander_1.Command();
|
|
32
58
|
cliMap.forEach((dtoJsonSchema, command) => {
|
|
@@ -64,9 +90,13 @@ lakutata_1.Application.run(async () => ({
|
|
|
64
90
|
license: package_json_1.license,
|
|
65
91
|
currentDirectory: __dirname,
|
|
66
92
|
workingDirectory: process.cwd()
|
|
93
|
+
},
|
|
94
|
+
onlineVersion: {
|
|
95
|
+
class: OnlineLatestVersion_1.OnlineLatestVersion,
|
|
96
|
+
name: package_json_1.name,
|
|
97
|
+
version: package_json_1.version
|
|
67
98
|
}
|
|
68
99
|
},
|
|
69
|
-
controllers: [CommandLineController_1.CommandLineController],
|
|
70
100
|
bootstrap: ['entrypoint']
|
|
71
101
|
}))
|
|
72
102
|
.onUncaughtException((error) => {
|
|
@@ -2,7 +2,8 @@ import { CreateProjectOptions } from '../options/CreateProjectOptions';
|
|
|
2
2
|
import { LakutataInfoOptions } from '../options/LakutataInfoOptions';
|
|
3
3
|
import { Information } from '../lib/providers/Information';
|
|
4
4
|
import { Creator } from '../lib/providers/Creator';
|
|
5
|
-
import { type ActionPattern
|
|
5
|
+
import { type ActionPattern } from 'lakutata';
|
|
6
|
+
import { Controller } from 'lakutata/com/entrypoint';
|
|
6
7
|
export declare class CommandLineController extends Controller {
|
|
7
8
|
protected readonly projectCreator: Creator;
|
|
8
9
|
protected readonly frameworkInfo: Information;
|
|
@@ -1 +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,
|
|
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,EAAC,MAAM,UAAU,CAAA;AAG3C,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAElD,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"}
|
|
@@ -14,10 +14,10 @@ const CreateProjectOptions_1 = require("../options/CreateProjectOptions");
|
|
|
14
14
|
const LakutataInfoOptions_1 = require("../options/LakutataInfoOptions");
|
|
15
15
|
const Information_1 = require("../lib/providers/Information");
|
|
16
16
|
const Creator_1 = require("../lib/providers/Creator");
|
|
17
|
-
const lakutata_1 = require("lakutata");
|
|
18
17
|
const di_1 = require("lakutata/decorator/di");
|
|
19
18
|
const ctrl_1 = require("lakutata/decorator/ctrl");
|
|
20
|
-
|
|
19
|
+
const entrypoint_1 = require("lakutata/com/entrypoint");
|
|
20
|
+
class CommandLineController extends entrypoint_1.Controller {
|
|
21
21
|
/**
|
|
22
22
|
* Create project
|
|
23
23
|
* @param inp
|
|
@@ -1 +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;
|
|
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;AAElC,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"}
|
|
@@ -13,7 +13,6 @@ exports.Spinner = void 0;
|
|
|
13
13
|
const cli_spinners_1 = require("cli-spinners");
|
|
14
14
|
const di_1 = require("lakutata/decorator/di");
|
|
15
15
|
const lakutata_1 = require("lakutata");
|
|
16
|
-
const helper_1 = require("lakutata/helper");
|
|
17
16
|
let Spinner = class Spinner extends lakutata_1.Component {
|
|
18
17
|
constructor() {
|
|
19
18
|
super(...arguments);
|
|
@@ -25,7 +24,7 @@ let Spinner = class Spinner extends lakutata_1.Component {
|
|
|
25
24
|
* @protected
|
|
26
25
|
*/
|
|
27
26
|
async init() {
|
|
28
|
-
this.logUpdate = (
|
|
27
|
+
this.logUpdate = require('log-update').default;
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Start spinner
|
|
@@ -4,12 +4,14 @@ import { Spinner } from '../components/Spinner.js';
|
|
|
4
4
|
import { CreateProjectOptions } from '../../options/CreateProjectOptions.js';
|
|
5
5
|
import { Application, Provider } from 'lakutata';
|
|
6
6
|
import { Logger } from 'lakutata/com/logger';
|
|
7
|
+
import { OnlineLatestVersion } from './OnlineLatestVersion';
|
|
7
8
|
export declare class Creator extends Provider {
|
|
8
9
|
protected readonly app: Application;
|
|
9
10
|
protected readonly log: Logger;
|
|
10
11
|
protected readonly spinner: Spinner;
|
|
11
12
|
protected readonly puller: DeGitPuller;
|
|
12
13
|
protected readonly frameworkInfo: Information;
|
|
14
|
+
protected readonly onlineVersion: OnlineLatestVersion;
|
|
13
15
|
/**
|
|
14
16
|
* Check if the target path exists
|
|
15
17
|
* @param targetDirectory
|
|
@@ -1 +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;
|
|
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;AAK1C,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AAEzD,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;IAG7C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAA;IAErD;;;;;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;CAkDpE"}
|
|
@@ -28,6 +28,7 @@ const helper_1 = require("lakutata/helper");
|
|
|
28
28
|
const dto_1 = require("lakutata/decorator/dto");
|
|
29
29
|
const ansis_1 = __importDefault(require("ansis"));
|
|
30
30
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
31
|
+
const OnlineLatestVersion_1 = require("./OnlineLatestVersion");
|
|
31
32
|
class Creator extends lakutata_1.Provider {
|
|
32
33
|
/**
|
|
33
34
|
* Check if the target path exists
|
|
@@ -78,7 +79,7 @@ class Creator extends lakutata_1.Provider {
|
|
|
78
79
|
const appName = options.name;
|
|
79
80
|
const appId = options.id;
|
|
80
81
|
const appDescription = options.description;
|
|
81
|
-
const packageName = appId
|
|
82
|
+
// const packageName: string = appId
|
|
82
83
|
const authorName = options.author;
|
|
83
84
|
const licenseName = options.license;
|
|
84
85
|
const appType = options.type;
|
|
@@ -102,8 +103,17 @@ class Creator extends lakutata_1.Provider {
|
|
|
102
103
|
await this.checkTargetPathExistence(targetPath, options.initOnly);
|
|
103
104
|
await this.checkTargetPathIsDirectory(targetPath);
|
|
104
105
|
await this.checkTargetDirectoryIsEmpty(targetPath);
|
|
105
|
-
this.
|
|
106
|
-
|
|
106
|
+
this.spinner.start('Pulling');
|
|
107
|
+
await this.puller.pull(branch, targetPath);
|
|
108
|
+
this.spinner.stop();
|
|
109
|
+
this.log.info(`${SpecialChar_js_1.charCheck} Template pulled.`);
|
|
110
|
+
this.spinner.start('Installing');
|
|
111
|
+
const { execa } = await import('execa');
|
|
112
|
+
await execa('npm', ['install'], { cwd: targetPath });
|
|
113
|
+
await execa('npm', ['install', `${this.onlineVersion.getName()}@${await this.onlineVersion.getVersion()}`], { cwd: targetPath });
|
|
114
|
+
this.spinner.stop();
|
|
115
|
+
//TODO 将项目内的内容进行初始化
|
|
116
|
+
this.log.info(`${SpecialChar_js_1.charCheck} Project has been successfully created.`);
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
exports.Creator = Creator;
|
|
@@ -125,7 +135,11 @@ __decorate([
|
|
|
125
135
|
], Creator.prototype, "puller", void 0);
|
|
126
136
|
__decorate([
|
|
127
137
|
(0, di_1.Inject)('info'),
|
|
128
|
-
__metadata("design:type", Information_js_1.Information
|
|
138
|
+
__metadata("design:type", Information_js_1.Information)
|
|
139
|
+
], Creator.prototype, "frameworkInfo", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
(0, di_1.Inject)('onlineVersion'),
|
|
142
|
+
__metadata("design:type", OnlineLatestVersion_1.OnlineLatestVersion
|
|
129
143
|
/**
|
|
130
144
|
* Check if the target path exists
|
|
131
145
|
* @param targetDirectory
|
|
@@ -133,7 +147,7 @@ __decorate([
|
|
|
133
147
|
* @protected
|
|
134
148
|
*/
|
|
135
149
|
)
|
|
136
|
-
], Creator.prototype, "
|
|
150
|
+
], Creator.prototype, "onlineVersion", void 0);
|
|
137
151
|
__decorate([
|
|
138
152
|
(0, dto_1.Accept)(CreateProjectOptions_js_1.CreateProjectOptions.required()),
|
|
139
153
|
__metadata("design:type", Function),
|
|
@@ -1 +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;
|
|
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;IA6BrC;;;;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"}
|
|
@@ -25,6 +25,7 @@ class Information extends lakutata_1.Provider {
|
|
|
25
25
|
* @protected
|
|
26
26
|
*/
|
|
27
27
|
async init() {
|
|
28
|
+
// const {packageDirectory} = require('pkg-dir')
|
|
28
29
|
const { packageDirectory } = await import('pkg-dir');
|
|
29
30
|
this.packageDirectory = packageDirectory;
|
|
30
31
|
const installPath = await packageDirectory({ cwd: this.currentDirectory });
|
|
@@ -33,7 +34,8 @@ class Information extends lakutata_1.Provider {
|
|
|
33
34
|
if (projectRoot) {
|
|
34
35
|
const packageJsonPath = (0, node_path_1.resolve)(projectRoot, './package.json');
|
|
35
36
|
try {
|
|
36
|
-
const
|
|
37
|
+
const rawPackageJsonBuffer = await (0, promises_1.readFile)(packageJsonPath);
|
|
38
|
+
const packageJson = JSON.parse(rawPackageJsonBuffer.toString());
|
|
37
39
|
const dependenciesKeyRegExp = new RegExp('dependencies'.toUpperCase());
|
|
38
40
|
Object.keys(packageJson).forEach((key) => {
|
|
39
41
|
if (dependenciesKeyRegExp.test(key.toUpperCase())) {
|
|
@@ -170,7 +172,9 @@ class Information extends lakutata_1.Provider {
|
|
|
170
172
|
const projectRoot = this.getRoot();
|
|
171
173
|
if (projectRoot) {
|
|
172
174
|
try {
|
|
173
|
-
const
|
|
175
|
+
const pkgJsonBuffer = await (0, promises_1.readFile)((0, node_path_1.resolve)(projectRoot, './node_modules', `./${this.name}/package.json`));
|
|
176
|
+
const pkgJson = JSON.parse(pkgJsonBuffer.toString());
|
|
177
|
+
const version = pkgJson.version;
|
|
174
178
|
return version ? version : null;
|
|
175
179
|
}
|
|
176
180
|
catch (e) {
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;CAW7C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
if (prereleaseInfo && prereleaseInfo[0]) {
|
|
30
|
+
onlineLatestVersion = await require('latest-version').default(this.name, { version: prereleaseInfo[0].toString() });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
onlineLatestVersion = await require('latest-version').default(this.name);
|
|
34
|
+
}
|
|
35
|
+
return (0, semver_1.gt)(onlineLatestVersion, this.version) ? onlineLatestVersion : this.version;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.OnlineLatestVersion = OnlineLatestVersion;
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, di_1.Configurable)(),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], OnlineLatestVersion.prototype, "version", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, di_1.Configurable)(),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], OnlineLatestVersion.prototype, "name", void 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakutata/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Lakutata CLI tool",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lakutata",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"clean": "shx rm -rf ./dist",
|
|
25
25
|
"build": "tsc",
|
|
26
26
|
"rebuild": "npm run clean && npm run build",
|
|
27
|
-
"test": "
|
|
27
|
+
"test": "tsx src/CLIApp.ts info"
|
|
28
28
|
},
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/lakutata/lakutata-packages/issues"
|
|
@@ -35,11 +35,14 @@
|
|
|
35
35
|
"cli-table3": "^0.6.4",
|
|
36
36
|
"commander": "^12.0.0",
|
|
37
37
|
"degit": "^2.8.4",
|
|
38
|
+
"execa": "^8.0.1",
|
|
39
|
+
"latest-version": "^9.0.0",
|
|
38
40
|
"log-update": "^6.0.0",
|
|
39
|
-
"pkg-dir": "^8.0.0"
|
|
41
|
+
"pkg-dir": "^8.0.0",
|
|
42
|
+
"semver": "^7.6.0"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
45
|
"@types/degit": "^2.8.6"
|
|
43
46
|
},
|
|
44
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "f58ae3dca9426997e0f624966152cecc6d5ac6b4"
|
|
45
48
|
}
|