@tsed/cli-core 3.20.10 → 3.20.13
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/lib/index.js +96 -44
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +97 -45
- package/lib/index.modern.js.map +1 -1
- package/lib/services/Renderer.d.ts +2 -6
- package/package.json +6 -6
package/lib/index.modern.js
CHANGED
|
@@ -8,7 +8,7 @@ import { GlobalProviders, Provider, Injectable, DIConfiguration, Inject, Configu
|
|
|
8
8
|
export { Configuration, Constant, Container, DITest, Inject, Injectable, InjectorService, LocalsContainer, Module, Opts, OverrideProvider, UseOpts, Value, registerProvider } from '@tsed/di';
|
|
9
9
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
10
10
|
import { Command as Command$1, Argument } from 'commander';
|
|
11
|
-
import { Listr, Logger as Logger$1 } from 'listr2';
|
|
11
|
+
import { Listr, Logger as Logger$1, figures } from 'listr2';
|
|
12
12
|
import { join, dirname, relative, resolve } from 'path';
|
|
13
13
|
import { EMPTY, throwError, Observable } from 'rxjs';
|
|
14
14
|
import { merge, filter, catchError } from 'rxjs/operators';
|
|
@@ -141,14 +141,13 @@ let CliExeca = class CliExeca {
|
|
|
141
141
|
constructor() {
|
|
142
142
|
this.raw = execa;
|
|
143
143
|
}
|
|
144
|
+
|
|
144
145
|
/**
|
|
145
146
|
*
|
|
146
147
|
* @param cmd
|
|
147
148
|
* @param args
|
|
148
149
|
* @param opts
|
|
149
150
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
151
|
run(cmd, args, opts) {
|
|
153
152
|
const cp = this.raw(cmd, args, opts);
|
|
154
153
|
const stdout = streamToObservable(cp.stdout.pipe(split()), {
|
|
@@ -335,9 +334,14 @@ function defaultPreferences(pkg) {
|
|
|
335
334
|
|
|
336
335
|
let ProjectPackageJson = class ProjectPackageJson {
|
|
337
336
|
constructor(configuration) {
|
|
338
|
-
this.configuration =
|
|
337
|
+
this.configuration = void 0;
|
|
339
338
|
this.rewrite = false;
|
|
340
339
|
this.reinstall = false;
|
|
340
|
+
this.cliExeca = void 0;
|
|
341
|
+
this.fs = void 0;
|
|
342
|
+
this.GH_TOKEN = void 0;
|
|
343
|
+
this.raw = void 0;
|
|
344
|
+
this.configuration = configuration;
|
|
341
345
|
this.setRaw({
|
|
342
346
|
name: "",
|
|
343
347
|
version: "1.0.0",
|
|
@@ -939,6 +943,10 @@ function parseOption(value, options) {
|
|
|
939
943
|
}
|
|
940
944
|
|
|
941
945
|
let CliHooks = class CliHooks {
|
|
946
|
+
constructor() {
|
|
947
|
+
this.injector = void 0;
|
|
948
|
+
}
|
|
949
|
+
|
|
942
950
|
async emit(hookName, cmd, ...args) {
|
|
943
951
|
const providers = this.injector.getProviders();
|
|
944
952
|
let results = [];
|
|
@@ -974,6 +982,10 @@ let CliService = class CliService {
|
|
|
974
982
|
constructor() {
|
|
975
983
|
this.program = new Command$1();
|
|
976
984
|
this.reinstallAfterRun = false;
|
|
985
|
+
this.pkg = void 0;
|
|
986
|
+
this.injector = void 0;
|
|
987
|
+
this.hooks = void 0;
|
|
988
|
+
this.projectPkg = void 0;
|
|
977
989
|
this.commands = new Map();
|
|
978
990
|
}
|
|
979
991
|
|
|
@@ -1298,6 +1310,11 @@ function cast(value) {
|
|
|
1298
1310
|
}
|
|
1299
1311
|
|
|
1300
1312
|
let CliProxyAgent = class CliProxyAgent {
|
|
1313
|
+
constructor() {
|
|
1314
|
+
this.proxySettings = void 0;
|
|
1315
|
+
this.cliExeca = void 0;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1301
1318
|
hasProxy() {
|
|
1302
1319
|
return !!this.proxySettings.url;
|
|
1303
1320
|
}
|
|
@@ -1383,6 +1400,8 @@ function logToCurl({
|
|
|
1383
1400
|
|
|
1384
1401
|
let CliHttpLogClient = class CliHttpLogClient {
|
|
1385
1402
|
constructor(options = {}) {
|
|
1403
|
+
this.callee = void 0;
|
|
1404
|
+
this.logger = void 0;
|
|
1386
1405
|
this.callee = options.callee || "http";
|
|
1387
1406
|
}
|
|
1388
1407
|
|
|
@@ -1464,6 +1483,12 @@ CliHttpLogClient = __decorate([__param(0, Opts), __metadata("design:paramtypes",
|
|
|
1464
1483
|
|
|
1465
1484
|
var CliHttpClient_1;
|
|
1466
1485
|
let CliHttpClient = CliHttpClient_1 = class CliHttpClient extends CliHttpLogClient {
|
|
1486
|
+
constructor(...args) {
|
|
1487
|
+
super(...args);
|
|
1488
|
+
this.cliProxyAgent = void 0;
|
|
1489
|
+
this.host = void 0;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1467
1492
|
static getParamsSerializer(params) {
|
|
1468
1493
|
return querystring.stringify(cleanObject(params));
|
|
1469
1494
|
}
|
|
@@ -1579,41 +1604,43 @@ CliHttpClient = CliHttpClient_1 = __decorate([Injectable()], CliHttpClient);
|
|
|
1579
1604
|
const all = promises => Promise.all(promises);
|
|
1580
1605
|
|
|
1581
1606
|
async function loadPlugins(injector) {
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
project: {
|
|
1585
|
-
rootDir
|
|
1586
|
-
}
|
|
1587
|
-
} = injector.settings;
|
|
1607
|
+
const name = injector.settings.get("name");
|
|
1608
|
+
const rootDir = injector.settings.get("project.rootDir");
|
|
1588
1609
|
const projectPackageJson = injector.invoke(ProjectPackageJson);
|
|
1589
1610
|
const fs = injector.invoke(CliFs);
|
|
1590
1611
|
const promises = Object.keys(projectPackageJson.allDependencies).filter(mod => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`)).map(async mod => {
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1612
|
+
try {
|
|
1613
|
+
const {
|
|
1614
|
+
default: plugin
|
|
1615
|
+
} = await fs.importModule(mod, rootDir);
|
|
1594
1616
|
|
|
1595
|
-
|
|
1596
|
-
|
|
1617
|
+
if (!injector.has(plugin)) {
|
|
1618
|
+
var _GlobalProviders$get;
|
|
1597
1619
|
|
|
1598
|
-
|
|
1620
|
+
const provider = (_GlobalProviders$get = GlobalProviders.get(plugin)) == null ? void 0 : _GlobalProviders$get.clone();
|
|
1599
1621
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1622
|
+
if (provider != null && provider.imports.length) {
|
|
1623
|
+
await all(provider.imports.map(async token => {
|
|
1624
|
+
var _GlobalProviders$get2;
|
|
1603
1625
|
|
|
1604
|
-
|
|
1626
|
+
injector.add(token, (_GlobalProviders$get2 = GlobalProviders.get(token)) == null ? void 0 : _GlobalProviders$get2.clone());
|
|
1605
1627
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1628
|
+
if (injector.settings.get("loaded")) {
|
|
1629
|
+
await injector.invoke(token);
|
|
1630
|
+
}
|
|
1631
|
+
}));
|
|
1632
|
+
}
|
|
1611
1633
|
|
|
1612
|
-
|
|
1634
|
+
injector.add(plugin, provider);
|
|
1613
1635
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1636
|
+
if (injector.settings.get("loaded")) {
|
|
1637
|
+
await injector.invoke(plugin);
|
|
1638
|
+
}
|
|
1616
1639
|
}
|
|
1640
|
+
|
|
1641
|
+
injector.logger.info(chalk.green(figures.tick), mod, "module loaded");
|
|
1642
|
+
} catch (er) {
|
|
1643
|
+
injector.logger.warn(chalk.red(figures.cross), "Fail to load plugin", mod);
|
|
1617
1644
|
}
|
|
1618
1645
|
});
|
|
1619
1646
|
await all(promises);
|
|
@@ -1634,6 +1661,10 @@ function addSuffix(pattern, suffix) {
|
|
|
1634
1661
|
}
|
|
1635
1662
|
const SCOPE_SEPARATOR = "%2f";
|
|
1636
1663
|
let NpmRegistryClient = NpmRegistryClient_1 = class NpmRegistryClient {
|
|
1664
|
+
constructor() {
|
|
1665
|
+
this.httpClient = void 0;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1637
1668
|
static escapeName(name) {
|
|
1638
1669
|
// scoped packages contain slashes and the npm registry expects them to be escaped
|
|
1639
1670
|
return name.replace("/", SCOPE_SEPARATOR);
|
|
@@ -1759,6 +1790,14 @@ function mapPlugins(_ref) {
|
|
|
1759
1790
|
}
|
|
1760
1791
|
|
|
1761
1792
|
let CliPlugins = class CliPlugins {
|
|
1793
|
+
constructor() {
|
|
1794
|
+
this.name = void 0;
|
|
1795
|
+
this.npmRegistryClient = void 0;
|
|
1796
|
+
this.injector = void 0;
|
|
1797
|
+
this.cliHooks = void 0;
|
|
1798
|
+
this.packageJson = void 0;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1762
1801
|
async searchPlugins(keyword = "", options = {}) {
|
|
1763
1802
|
const result = await this.npmRegistryClient.search(this.getKeyword(keyword), options);
|
|
1764
1803
|
return result.filter(({
|
|
@@ -1817,6 +1856,10 @@ CliPlugins = __decorate([Injectable()], CliPlugins);
|
|
|
1817
1856
|
const runScript = require("@npmcli/run-script");
|
|
1818
1857
|
|
|
1819
1858
|
let CliRunScript = class CliRunScript {
|
|
1859
|
+
constructor() {
|
|
1860
|
+
this.projectPackageJson = void 0;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1820
1863
|
run(cmd, args, options = {}) {
|
|
1821
1864
|
return runScript(_extends({
|
|
1822
1865
|
event: "run"
|
|
@@ -3322,6 +3365,12 @@ const _excluded = ["path"];
|
|
|
3322
3365
|
const normalizePath = require("normalize-path");
|
|
3323
3366
|
|
|
3324
3367
|
class Renderer {
|
|
3368
|
+
constructor() {
|
|
3369
|
+
this.configuration = void 0;
|
|
3370
|
+
this.templateDir = void 0;
|
|
3371
|
+
this.fs = void 0;
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3325
3374
|
async render(path, data, options = {}) {
|
|
3326
3375
|
const {
|
|
3327
3376
|
output,
|
|
@@ -3462,6 +3511,8 @@ class Renderer {
|
|
|
3462
3511
|
|
|
3463
3512
|
}
|
|
3464
3513
|
|
|
3514
|
+
__decorate([Configuration(), __metadata("design:type", Object)], Renderer.prototype, "configuration", void 0);
|
|
3515
|
+
|
|
3465
3516
|
__decorate([Constant("templateDir"), __metadata("design:type", String)], Renderer.prototype, "templateDir", void 0);
|
|
3466
3517
|
|
|
3467
3518
|
__decorate([Inject(), __metadata("design:type", CliFs)], Renderer.prototype, "fs", void 0);
|
|
@@ -3474,11 +3525,6 @@ let RootRendererService = class RootRendererService extends Renderer {
|
|
|
3474
3525
|
}
|
|
3475
3526
|
|
|
3476
3527
|
};
|
|
3477
|
-
|
|
3478
|
-
__decorate([Constant("templateDir"), __metadata("design:type", String)], RootRendererService.prototype, "templateDir", void 0);
|
|
3479
|
-
|
|
3480
|
-
__decorate([Configuration(), __metadata("design:type", Object)], RootRendererService.prototype, "configuration", void 0);
|
|
3481
|
-
|
|
3482
3528
|
RootRendererService = __decorate([Injectable()], RootRendererService);
|
|
3483
3529
|
let SrcRendererService = class SrcRendererService extends Renderer {
|
|
3484
3530
|
get rootDir() {
|
|
@@ -3488,11 +3534,6 @@ let SrcRendererService = class SrcRendererService extends Renderer {
|
|
|
3488
3534
|
}
|
|
3489
3535
|
|
|
3490
3536
|
};
|
|
3491
|
-
|
|
3492
|
-
__decorate([Constant("templateDir"), __metadata("design:type", String)], SrcRendererService.prototype, "templateDir", void 0);
|
|
3493
|
-
|
|
3494
|
-
__decorate([Configuration(), __metadata("design:type", Object)], SrcRendererService.prototype, "configuration", void 0);
|
|
3495
|
-
|
|
3496
3537
|
SrcRendererService = __decorate([Injectable()], SrcRendererService);
|
|
3497
3538
|
let ScriptsRendererService = class ScriptsRendererService extends Renderer {
|
|
3498
3539
|
get rootDir() {
|
|
@@ -3502,14 +3543,14 @@ let ScriptsRendererService = class ScriptsRendererService extends Renderer {
|
|
|
3502
3543
|
}
|
|
3503
3544
|
|
|
3504
3545
|
};
|
|
3505
|
-
|
|
3506
|
-
__decorate([Constant("templateDir"), __metadata("design:type", String)], ScriptsRendererService.prototype, "templateDir", void 0);
|
|
3507
|
-
|
|
3508
|
-
__decorate([Configuration(), __metadata("design:type", Object)], ScriptsRendererService.prototype, "configuration", void 0);
|
|
3509
|
-
|
|
3510
3546
|
ScriptsRendererService = __decorate([Injectable()], ScriptsRendererService);
|
|
3511
3547
|
|
|
3512
3548
|
let CliYaml = class CliYaml {
|
|
3549
|
+
constructor() {
|
|
3550
|
+
this.projectPackageJson = void 0;
|
|
3551
|
+
this.fs = void 0;
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3513
3554
|
async read(path) {
|
|
3514
3555
|
const file = !this.fs.exists(path) ? this.fs.findUpFile(this.projectPackageJson.dir, path) : path;
|
|
3515
3556
|
|
|
@@ -3540,6 +3581,10 @@ __decorate([Inject(), __metadata("design:type", CliFs)], CliYaml.prototype, "fs"
|
|
|
3540
3581
|
CliYaml = __decorate([Injectable()], CliYaml);
|
|
3541
3582
|
|
|
3542
3583
|
let CliDockerComposeYaml = class CliDockerComposeYaml {
|
|
3584
|
+
constructor() {
|
|
3585
|
+
this.cliYaml = void 0;
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3543
3588
|
async read() {
|
|
3544
3589
|
return this.cliYaml.read("docker-compose.yml");
|
|
3545
3590
|
}
|
|
@@ -3627,6 +3672,8 @@ class CliError extends Error {
|
|
|
3627
3672
|
}) {
|
|
3628
3673
|
super(origin.message);
|
|
3629
3674
|
this.name = "CLI_ERROR";
|
|
3675
|
+
this.cli = void 0;
|
|
3676
|
+
this.origin = void 0;
|
|
3630
3677
|
this.cli = cli;
|
|
3631
3678
|
this.origin = origin;
|
|
3632
3679
|
this.stack = origin.stack;
|
|
@@ -3643,6 +3690,11 @@ function isHelpManual(argv) {
|
|
|
3643
3690
|
}
|
|
3644
3691
|
|
|
3645
3692
|
let CliCore = CliCore_1 = class CliCore {
|
|
3693
|
+
constructor() {
|
|
3694
|
+
this.injector = void 0;
|
|
3695
|
+
this.cliService = void 0;
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3646
3698
|
static checkNodeVersion(wanted, id) {
|
|
3647
3699
|
if (!semver.satisfies(process.version, wanted)) {
|
|
3648
3700
|
console.log(chalk.red("You are using Node " + process.version + ", but this version of " + id + " requires Node " + wanted + ".\nPlease upgrade your Node version."));
|
|
@@ -3660,7 +3712,7 @@ let CliCore = CliCore_1 = class CliCore {
|
|
|
3660
3712
|
const cli = injector.get(CliCore_1);
|
|
3661
3713
|
|
|
3662
3714
|
try {
|
|
3663
|
-
await cli.cliService.parseArgs(injector.settings.argv);
|
|
3715
|
+
await cli.cliService.parseArgs(injector.settings.get("argv"));
|
|
3664
3716
|
} catch (er) {
|
|
3665
3717
|
throw new CliError({
|
|
3666
3718
|
origin: er,
|
|
@@ -3676,7 +3728,7 @@ let CliCore = CliCore_1 = class CliCore {
|
|
|
3676
3728
|
const container = createContainer();
|
|
3677
3729
|
await injector.load(container, module);
|
|
3678
3730
|
await injector.emit("$afterInit");
|
|
3679
|
-
injector.settings.loaded
|
|
3731
|
+
injector.settings.set("loaded", true);
|
|
3680
3732
|
}
|
|
3681
3733
|
|
|
3682
3734
|
static updateNotifier(pkg) {
|