@tsed/cli-core 3.20.9 → 3.20.12
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 +28 -26
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +29 -27
- package/lib/index.modern.js.map +1 -1
- package/package.json +1 -1
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';
|
|
@@ -1579,41 +1579,43 @@ CliHttpClient = CliHttpClient_1 = __decorate([Injectable()], CliHttpClient);
|
|
|
1579
1579
|
const all = promises => Promise.all(promises);
|
|
1580
1580
|
|
|
1581
1581
|
async function loadPlugins(injector) {
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
project: {
|
|
1585
|
-
rootDir
|
|
1586
|
-
}
|
|
1587
|
-
} = injector.settings;
|
|
1582
|
+
const name = injector.settings.get("name");
|
|
1583
|
+
const rootDir = injector.settings.get("project.rootDir");
|
|
1588
1584
|
const projectPackageJson = injector.invoke(ProjectPackageJson);
|
|
1589
1585
|
const fs = injector.invoke(CliFs);
|
|
1590
1586
|
const promises = Object.keys(projectPackageJson.allDependencies).filter(mod => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`)).map(async mod => {
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1587
|
+
try {
|
|
1588
|
+
const {
|
|
1589
|
+
default: plugin
|
|
1590
|
+
} = await fs.importModule(mod, rootDir);
|
|
1594
1591
|
|
|
1595
|
-
|
|
1596
|
-
|
|
1592
|
+
if (!injector.has(plugin)) {
|
|
1593
|
+
var _GlobalProviders$get;
|
|
1597
1594
|
|
|
1598
|
-
|
|
1595
|
+
const provider = (_GlobalProviders$get = GlobalProviders.get(plugin)) == null ? void 0 : _GlobalProviders$get.clone();
|
|
1599
1596
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1597
|
+
if (provider != null && provider.imports.length) {
|
|
1598
|
+
await all(provider.imports.map(async token => {
|
|
1599
|
+
var _GlobalProviders$get2;
|
|
1603
1600
|
|
|
1604
|
-
|
|
1601
|
+
injector.add(token, (_GlobalProviders$get2 = GlobalProviders.get(token)) == null ? void 0 : _GlobalProviders$get2.clone());
|
|
1605
1602
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1603
|
+
if (injector.settings.get("loaded")) {
|
|
1604
|
+
await injector.invoke(token);
|
|
1605
|
+
}
|
|
1606
|
+
}));
|
|
1607
|
+
}
|
|
1611
1608
|
|
|
1612
|
-
|
|
1609
|
+
injector.add(plugin, provider);
|
|
1613
1610
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1611
|
+
if (injector.settings.get("loaded")) {
|
|
1612
|
+
await injector.invoke(plugin);
|
|
1613
|
+
}
|
|
1616
1614
|
}
|
|
1615
|
+
|
|
1616
|
+
injector.logger.info(chalk.green(figures.tick), mod, "module loaded");
|
|
1617
|
+
} catch (er) {
|
|
1618
|
+
injector.logger.warn(chalk.red(figures.cross), "Fail to load plugin", mod);
|
|
1617
1619
|
}
|
|
1618
1620
|
});
|
|
1619
1621
|
await all(promises);
|
|
@@ -3660,7 +3662,7 @@ let CliCore = CliCore_1 = class CliCore {
|
|
|
3660
3662
|
const cli = injector.get(CliCore_1);
|
|
3661
3663
|
|
|
3662
3664
|
try {
|
|
3663
|
-
await cli.cliService.parseArgs(injector.settings.argv);
|
|
3665
|
+
await cli.cliService.parseArgs(injector.settings.get("argv"));
|
|
3664
3666
|
} catch (er) {
|
|
3665
3667
|
throw new CliError({
|
|
3666
3668
|
origin: er,
|
|
@@ -3676,7 +3678,7 @@ let CliCore = CliCore_1 = class CliCore {
|
|
|
3676
3678
|
const container = createContainer();
|
|
3677
3679
|
await injector.load(container, module);
|
|
3678
3680
|
await injector.emit("$afterInit");
|
|
3679
|
-
injector.settings.loaded
|
|
3681
|
+
injector.settings.set("loaded", true);
|
|
3680
3682
|
}
|
|
3681
3683
|
|
|
3682
3684
|
static updateNotifier(pkg) {
|