@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.js
CHANGED
|
@@ -176,14 +176,13 @@ exports.CliExeca = class CliExeca {
|
|
|
176
176
|
constructor() {
|
|
177
177
|
this.raw = execa__default['default'];
|
|
178
178
|
}
|
|
179
|
+
|
|
179
180
|
/**
|
|
180
181
|
*
|
|
181
182
|
* @param cmd
|
|
182
183
|
* @param args
|
|
183
184
|
* @param opts
|
|
184
185
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
186
|
run(cmd, args, opts) {
|
|
188
187
|
const cp = this.raw(cmd, args, opts);
|
|
189
188
|
const stdout = streamToObservable(cp.stdout.pipe(split()), {
|
|
@@ -370,9 +369,14 @@ function defaultPreferences(pkg) {
|
|
|
370
369
|
|
|
371
370
|
exports.ProjectPackageJson = class ProjectPackageJson {
|
|
372
371
|
constructor(configuration) {
|
|
373
|
-
this.configuration =
|
|
372
|
+
this.configuration = void 0;
|
|
374
373
|
this.rewrite = false;
|
|
375
374
|
this.reinstall = false;
|
|
375
|
+
this.cliExeca = void 0;
|
|
376
|
+
this.fs = void 0;
|
|
377
|
+
this.GH_TOKEN = void 0;
|
|
378
|
+
this.raw = void 0;
|
|
379
|
+
this.configuration = configuration;
|
|
376
380
|
this.setRaw({
|
|
377
381
|
name: "",
|
|
378
382
|
version: "1.0.0",
|
|
@@ -974,6 +978,10 @@ function parseOption(value, options) {
|
|
|
974
978
|
}
|
|
975
979
|
|
|
976
980
|
let CliHooks = class CliHooks {
|
|
981
|
+
constructor() {
|
|
982
|
+
this.injector = void 0;
|
|
983
|
+
}
|
|
984
|
+
|
|
977
985
|
async emit(hookName, cmd, ...args) {
|
|
978
986
|
const providers = this.injector.getProviders();
|
|
979
987
|
let results = [];
|
|
@@ -1009,6 +1017,10 @@ exports.CliService = class CliService {
|
|
|
1009
1017
|
constructor() {
|
|
1010
1018
|
this.program = new commander.Command();
|
|
1011
1019
|
this.reinstallAfterRun = false;
|
|
1020
|
+
this.pkg = void 0;
|
|
1021
|
+
this.injector = void 0;
|
|
1022
|
+
this.hooks = void 0;
|
|
1023
|
+
this.projectPkg = void 0;
|
|
1012
1024
|
this.commands = new Map();
|
|
1013
1025
|
}
|
|
1014
1026
|
|
|
@@ -1333,6 +1345,11 @@ function cast(value) {
|
|
|
1333
1345
|
}
|
|
1334
1346
|
|
|
1335
1347
|
let CliProxyAgent = class CliProxyAgent {
|
|
1348
|
+
constructor() {
|
|
1349
|
+
this.proxySettings = void 0;
|
|
1350
|
+
this.cliExeca = void 0;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1336
1353
|
hasProxy() {
|
|
1337
1354
|
return !!this.proxySettings.url;
|
|
1338
1355
|
}
|
|
@@ -1418,6 +1435,8 @@ function logToCurl({
|
|
|
1418
1435
|
|
|
1419
1436
|
let CliHttpLogClient = class CliHttpLogClient {
|
|
1420
1437
|
constructor(options = {}) {
|
|
1438
|
+
this.callee = void 0;
|
|
1439
|
+
this.logger = void 0;
|
|
1421
1440
|
this.callee = options.callee || "http";
|
|
1422
1441
|
}
|
|
1423
1442
|
|
|
@@ -1499,6 +1518,12 @@ CliHttpLogClient = tslib.__decorate([tslib.__param(0, di.Opts), tslib.__metadata
|
|
|
1499
1518
|
|
|
1500
1519
|
var CliHttpClient_1;
|
|
1501
1520
|
exports.CliHttpClient = CliHttpClient_1 = class CliHttpClient extends CliHttpLogClient {
|
|
1521
|
+
constructor(...args) {
|
|
1522
|
+
super(...args);
|
|
1523
|
+
this.cliProxyAgent = void 0;
|
|
1524
|
+
this.host = void 0;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1502
1527
|
static getParamsSerializer(params) {
|
|
1503
1528
|
return querystring__default['default'].stringify(core.cleanObject(params));
|
|
1504
1529
|
}
|
|
@@ -1614,41 +1639,43 @@ exports.CliHttpClient = CliHttpClient_1 = tslib.__decorate([di.Injectable()], ex
|
|
|
1614
1639
|
const all = promises => Promise.all(promises);
|
|
1615
1640
|
|
|
1616
1641
|
async function loadPlugins(injector) {
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1619
|
-
project: {
|
|
1620
|
-
rootDir
|
|
1621
|
-
}
|
|
1622
|
-
} = injector.settings;
|
|
1642
|
+
const name = injector.settings.get("name");
|
|
1643
|
+
const rootDir = injector.settings.get("project.rootDir");
|
|
1623
1644
|
const projectPackageJson = injector.invoke(exports.ProjectPackageJson);
|
|
1624
1645
|
const fs = injector.invoke(exports.CliFs);
|
|
1625
1646
|
const promises = Object.keys(projectPackageJson.allDependencies).filter(mod => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`)).map(async mod => {
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1647
|
+
try {
|
|
1648
|
+
const {
|
|
1649
|
+
default: plugin
|
|
1650
|
+
} = await fs.importModule(mod, rootDir);
|
|
1629
1651
|
|
|
1630
|
-
|
|
1631
|
-
|
|
1652
|
+
if (!injector.has(plugin)) {
|
|
1653
|
+
var _GlobalProviders$get;
|
|
1632
1654
|
|
|
1633
|
-
|
|
1655
|
+
const provider = (_GlobalProviders$get = di.GlobalProviders.get(plugin)) == null ? void 0 : _GlobalProviders$get.clone();
|
|
1634
1656
|
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1657
|
+
if (provider != null && provider.imports.length) {
|
|
1658
|
+
await all(provider.imports.map(async token => {
|
|
1659
|
+
var _GlobalProviders$get2;
|
|
1638
1660
|
|
|
1639
|
-
|
|
1661
|
+
injector.add(token, (_GlobalProviders$get2 = di.GlobalProviders.get(token)) == null ? void 0 : _GlobalProviders$get2.clone());
|
|
1640
1662
|
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1663
|
+
if (injector.settings.get("loaded")) {
|
|
1664
|
+
await injector.invoke(token);
|
|
1665
|
+
}
|
|
1666
|
+
}));
|
|
1667
|
+
}
|
|
1646
1668
|
|
|
1647
|
-
|
|
1669
|
+
injector.add(plugin, provider);
|
|
1648
1670
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1671
|
+
if (injector.settings.get("loaded")) {
|
|
1672
|
+
await injector.invoke(plugin);
|
|
1673
|
+
}
|
|
1651
1674
|
}
|
|
1675
|
+
|
|
1676
|
+
injector.logger.info(chalk__default['default'].green(listr2.figures.tick), mod, "module loaded");
|
|
1677
|
+
} catch (er) {
|
|
1678
|
+
injector.logger.warn(chalk__default['default'].red(listr2.figures.cross), "Fail to load plugin", mod);
|
|
1652
1679
|
}
|
|
1653
1680
|
});
|
|
1654
1681
|
await all(promises);
|
|
@@ -1669,6 +1696,10 @@ function addSuffix(pattern, suffix) {
|
|
|
1669
1696
|
}
|
|
1670
1697
|
const SCOPE_SEPARATOR = "%2f";
|
|
1671
1698
|
exports.NpmRegistryClient = NpmRegistryClient_1 = class NpmRegistryClient {
|
|
1699
|
+
constructor() {
|
|
1700
|
+
this.httpClient = void 0;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1672
1703
|
static escapeName(name) {
|
|
1673
1704
|
// scoped packages contain slashes and the npm registry expects them to be escaped
|
|
1674
1705
|
return name.replace("/", SCOPE_SEPARATOR);
|
|
@@ -1794,6 +1825,14 @@ function mapPlugins(_ref) {
|
|
|
1794
1825
|
}
|
|
1795
1826
|
|
|
1796
1827
|
exports.CliPlugins = class CliPlugins {
|
|
1828
|
+
constructor() {
|
|
1829
|
+
this.name = void 0;
|
|
1830
|
+
this.npmRegistryClient = void 0;
|
|
1831
|
+
this.injector = void 0;
|
|
1832
|
+
this.cliHooks = void 0;
|
|
1833
|
+
this.packageJson = void 0;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1797
1836
|
async searchPlugins(keyword = "", options = {}) {
|
|
1798
1837
|
const result = await this.npmRegistryClient.search(this.getKeyword(keyword), options);
|
|
1799
1838
|
return result.filter(({
|
|
@@ -1852,6 +1891,10 @@ exports.CliPlugins = tslib.__decorate([di.Injectable()], exports.CliPlugins);
|
|
|
1852
1891
|
const runScript = require("@npmcli/run-script");
|
|
1853
1892
|
|
|
1854
1893
|
exports.CliRunScript = class CliRunScript {
|
|
1894
|
+
constructor() {
|
|
1895
|
+
this.projectPackageJson = void 0;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1855
1898
|
run(cmd, args, options = {}) {
|
|
1856
1899
|
return runScript(_extends({
|
|
1857
1900
|
event: "run"
|
|
@@ -3357,6 +3400,12 @@ const _excluded = ["path"];
|
|
|
3357
3400
|
const normalizePath = require("normalize-path");
|
|
3358
3401
|
|
|
3359
3402
|
class Renderer {
|
|
3403
|
+
constructor() {
|
|
3404
|
+
this.configuration = void 0;
|
|
3405
|
+
this.templateDir = void 0;
|
|
3406
|
+
this.fs = void 0;
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3360
3409
|
async render(path$1, data, options = {}) {
|
|
3361
3410
|
const {
|
|
3362
3411
|
output,
|
|
@@ -3495,6 +3544,8 @@ class Renderer {
|
|
|
3495
3544
|
|
|
3496
3545
|
}
|
|
3497
3546
|
|
|
3547
|
+
tslib.__decorate([di.Configuration(), tslib.__metadata("design:type", Object)], Renderer.prototype, "configuration", void 0);
|
|
3548
|
+
|
|
3498
3549
|
tslib.__decorate([di.Constant("templateDir"), tslib.__metadata("design:type", String)], Renderer.prototype, "templateDir", void 0);
|
|
3499
3550
|
|
|
3500
3551
|
tslib.__decorate([di.Inject(), tslib.__metadata("design:type", exports.CliFs)], Renderer.prototype, "fs", void 0);
|
|
@@ -3507,11 +3558,6 @@ exports.RootRendererService = class RootRendererService extends Renderer {
|
|
|
3507
3558
|
}
|
|
3508
3559
|
|
|
3509
3560
|
};
|
|
3510
|
-
|
|
3511
|
-
tslib.__decorate([di.Constant("templateDir"), tslib.__metadata("design:type", String)], exports.RootRendererService.prototype, "templateDir", void 0);
|
|
3512
|
-
|
|
3513
|
-
tslib.__decorate([di.Configuration(), tslib.__metadata("design:type", Object)], exports.RootRendererService.prototype, "configuration", void 0);
|
|
3514
|
-
|
|
3515
3561
|
exports.RootRendererService = tslib.__decorate([di.Injectable()], exports.RootRendererService);
|
|
3516
3562
|
exports.SrcRendererService = class SrcRendererService extends Renderer {
|
|
3517
3563
|
get rootDir() {
|
|
@@ -3521,11 +3567,6 @@ exports.SrcRendererService = class SrcRendererService extends Renderer {
|
|
|
3521
3567
|
}
|
|
3522
3568
|
|
|
3523
3569
|
};
|
|
3524
|
-
|
|
3525
|
-
tslib.__decorate([di.Constant("templateDir"), tslib.__metadata("design:type", String)], exports.SrcRendererService.prototype, "templateDir", void 0);
|
|
3526
|
-
|
|
3527
|
-
tslib.__decorate([di.Configuration(), tslib.__metadata("design:type", Object)], exports.SrcRendererService.prototype, "configuration", void 0);
|
|
3528
|
-
|
|
3529
3570
|
exports.SrcRendererService = tslib.__decorate([di.Injectable()], exports.SrcRendererService);
|
|
3530
3571
|
exports.ScriptsRendererService = class ScriptsRendererService extends Renderer {
|
|
3531
3572
|
get rootDir() {
|
|
@@ -3535,14 +3576,14 @@ exports.ScriptsRendererService = class ScriptsRendererService extends Renderer {
|
|
|
3535
3576
|
}
|
|
3536
3577
|
|
|
3537
3578
|
};
|
|
3538
|
-
|
|
3539
|
-
tslib.__decorate([di.Constant("templateDir"), tslib.__metadata("design:type", String)], exports.ScriptsRendererService.prototype, "templateDir", void 0);
|
|
3540
|
-
|
|
3541
|
-
tslib.__decorate([di.Configuration(), tslib.__metadata("design:type", Object)], exports.ScriptsRendererService.prototype, "configuration", void 0);
|
|
3542
|
-
|
|
3543
3579
|
exports.ScriptsRendererService = tslib.__decorate([di.Injectable()], exports.ScriptsRendererService);
|
|
3544
3580
|
|
|
3545
3581
|
exports.CliYaml = class CliYaml {
|
|
3582
|
+
constructor() {
|
|
3583
|
+
this.projectPackageJson = void 0;
|
|
3584
|
+
this.fs = void 0;
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3546
3587
|
async read(path) {
|
|
3547
3588
|
const file = !this.fs.exists(path) ? this.fs.findUpFile(this.projectPackageJson.dir, path) : path;
|
|
3548
3589
|
|
|
@@ -3573,6 +3614,10 @@ tslib.__decorate([di.Inject(), tslib.__metadata("design:type", exports.CliFs)],
|
|
|
3573
3614
|
exports.CliYaml = tslib.__decorate([di.Injectable()], exports.CliYaml);
|
|
3574
3615
|
|
|
3575
3616
|
exports.CliDockerComposeYaml = class CliDockerComposeYaml {
|
|
3617
|
+
constructor() {
|
|
3618
|
+
this.cliYaml = void 0;
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3576
3621
|
async read() {
|
|
3577
3622
|
return this.cliYaml.read("docker-compose.yml");
|
|
3578
3623
|
}
|
|
@@ -3660,6 +3705,8 @@ class CliError extends Error {
|
|
|
3660
3705
|
}) {
|
|
3661
3706
|
super(origin.message);
|
|
3662
3707
|
this.name = "CLI_ERROR";
|
|
3708
|
+
this.cli = void 0;
|
|
3709
|
+
this.origin = void 0;
|
|
3663
3710
|
this.cli = cli;
|
|
3664
3711
|
this.origin = origin;
|
|
3665
3712
|
this.stack = origin.stack;
|
|
@@ -3676,6 +3723,11 @@ function isHelpManual(argv) {
|
|
|
3676
3723
|
}
|
|
3677
3724
|
|
|
3678
3725
|
exports.CliCore = CliCore_1 = class CliCore {
|
|
3726
|
+
constructor() {
|
|
3727
|
+
this.injector = void 0;
|
|
3728
|
+
this.cliService = void 0;
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3679
3731
|
static checkNodeVersion(wanted, id) {
|
|
3680
3732
|
if (!semver.satisfies(process.version, wanted)) {
|
|
3681
3733
|
console.log(chalk__default['default'].red("You are using Node " + process.version + ", but this version of " + id + " requires Node " + wanted + ".\nPlease upgrade your Node version."));
|
|
@@ -3693,7 +3745,7 @@ exports.CliCore = CliCore_1 = class CliCore {
|
|
|
3693
3745
|
const cli = injector.get(CliCore_1);
|
|
3694
3746
|
|
|
3695
3747
|
try {
|
|
3696
|
-
await cli.cliService.parseArgs(injector.settings.argv);
|
|
3748
|
+
await cli.cliService.parseArgs(injector.settings.get("argv"));
|
|
3697
3749
|
} catch (er) {
|
|
3698
3750
|
throw new CliError({
|
|
3699
3751
|
origin: er,
|
|
@@ -3709,7 +3761,7 @@ exports.CliCore = CliCore_1 = class CliCore {
|
|
|
3709
3761
|
const container = di.createContainer();
|
|
3710
3762
|
await injector.load(container, module);
|
|
3711
3763
|
await injector.emit("$afterInit");
|
|
3712
|
-
injector.settings.loaded
|
|
3764
|
+
injector.settings.set("loaded", true);
|
|
3713
3765
|
}
|
|
3714
3766
|
|
|
3715
3767
|
static updateNotifier(pkg) {
|