@ts-ioc-container/bundler 6.0.0 → 8.0.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/AGENTS.md +28 -15
- package/README.md +63 -28
- package/cjm/app.js +16 -6
- package/cjm/cli/usage.js +8 -5
- package/cjm/features/{build → bundle}/BuildConfig.js +42 -10
- package/cjm/features/{build → bundle}/BuildModule.js +6 -4
- package/cjm/features/{build/BuildController.js → bundle/BundleController.js} +39 -20
- package/cjm/features/{build → bundle}/domain/tokenCollisions.js +1 -1
- package/cjm/features/{build/services/BundleBuilder.js → bundle/services/BundleService.js} +25 -41
- package/cjm/features/bundle/services/BundleView.js +58 -0
- package/cjm/features/{build → bundle}/services/TicConfigService.js +16 -5
- package/cjm/index.js +22 -21
- package/cjm/schema/ticConfigSchema.js +3 -3
- package/cjm/services/ConsoleLogger.js +3 -0
- package/package.json +2 -2
- package/tic.schema.json +4 -10
- package/typings/app.d.ts +26 -7
- package/typings/cli/usage.d.ts.map +1 -1
- package/typings/features/{build → bundle}/BuildConfig.d.ts +51 -8
- package/typings/features/bundle/BuildConfig.d.ts.map +1 -0
- package/typings/features/bundle/BuildModule.d.ts.map +1 -0
- package/typings/features/bundle/BundleController.d.ts +45 -0
- package/typings/features/bundle/BundleController.d.ts.map +1 -0
- package/typings/features/bundle/domain/ImportPaths.d.ts.map +1 -0
- package/typings/features/bundle/domain/glob.d.ts.map +1 -0
- package/typings/features/bundle/domain/scan.d.ts.map +1 -0
- package/typings/features/bundle/domain/tokenCollisions.d.ts.map +1 -0
- package/typings/features/bundle/domain/tsconfig.d.ts.map +1 -0
- package/typings/features/bundle/services/BundleService.d.ts +39 -0
- package/typings/features/bundle/services/BundleService.d.ts.map +1 -0
- package/typings/features/bundle/services/BundleView.d.ts +33 -0
- package/typings/features/bundle/services/BundleView.d.ts.map +1 -0
- package/typings/features/{build → bundle}/services/TicConfigService.d.ts +14 -8
- package/typings/features/bundle/services/TicConfigService.d.ts.map +1 -0
- package/typings/index.d.ts +12 -12
- package/typings/schema/ticConfigSchema.d.ts.map +1 -1
- package/typings/services/ConsoleLogger.d.ts +4 -1
- package/typings/services/ConsoleLogger.d.ts.map +1 -1
- package/cjm/features/build/domain/emit.js +0 -34
- package/typings/features/build/BuildConfig.d.ts.map +0 -1
- package/typings/features/build/BuildController.d.ts +0 -37
- package/typings/features/build/BuildController.d.ts.map +0 -1
- package/typings/features/build/BuildModule.d.ts.map +0 -1
- package/typings/features/build/domain/ImportPaths.d.ts.map +0 -1
- package/typings/features/build/domain/emit.d.ts +0 -36
- package/typings/features/build/domain/emit.d.ts.map +0 -1
- package/typings/features/build/domain/glob.d.ts.map +0 -1
- package/typings/features/build/domain/scan.d.ts.map +0 -1
- package/typings/features/build/domain/tokenCollisions.d.ts.map +0 -1
- package/typings/features/build/domain/tsconfig.d.ts.map +0 -1
- package/typings/features/build/services/BundleBuilder.d.ts +0 -61
- package/typings/features/build/services/BundleBuilder.d.ts.map +0 -1
- package/typings/features/build/services/TicConfigService.d.ts.map +0 -1
- /package/cjm/features/{build → bundle}/domain/ImportPaths.js +0 -0
- /package/cjm/features/{build → bundle}/domain/glob.js +0 -0
- /package/cjm/features/{build → bundle}/domain/scan.js +0 -0
- /package/cjm/features/{build → bundle}/domain/tsconfig.js +0 -0
- /package/typings/features/{build → bundle}/BuildModule.d.ts +0 -0
- /package/typings/features/{build → bundle}/domain/ImportPaths.d.ts +0 -0
- /package/typings/features/{build → bundle}/domain/glob.d.ts +0 -0
- /package/typings/features/{build → bundle}/domain/scan.d.ts +0 -0
- /package/typings/features/{build → bundle}/domain/tokenCollisions.d.ts +0 -0
- /package/typings/features/{build → bundle}/domain/tsconfig.d.ts +0 -0
|
@@ -15,45 +15,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.BundleService = exports.IBundleServiceKey = void 0;
|
|
19
19
|
const node_path_1 = __importDefault(require("node:path"));
|
|
20
20
|
const ts_ioc_container_1 = require("ts-ioc-container");
|
|
21
|
-
const GlobalConfig_1 = require("../../../domain/GlobalConfig");
|
|
22
|
-
const HandlebarsRenderService_1 = require("../../../services/HandlebarsRenderService");
|
|
23
21
|
const NodeFileSystemService_1 = require("../../../services/NodeFileSystemService");
|
|
24
22
|
const DomainException_1 = require("../../../exceptions/DomainException");
|
|
25
|
-
const
|
|
26
|
-
const emit_1 = require("../domain/emit");
|
|
23
|
+
const BundleView_1 = require("./BundleView");
|
|
27
24
|
const glob_1 = require("../domain/glob");
|
|
28
25
|
const scan_1 = require("../domain/scan");
|
|
29
26
|
const tokenCollisions_1 = require("../domain/tokenCollisions");
|
|
30
27
|
const tsconfig_1 = require("../domain/tsconfig");
|
|
31
|
-
exports.
|
|
32
|
-
let
|
|
33
|
-
cwd;
|
|
34
|
-
configs;
|
|
28
|
+
exports.IBundleServiceKey = new ts_ioc_container_1.SingleToken('IBundleService');
|
|
29
|
+
let BundleService = class BundleService {
|
|
35
30
|
fs;
|
|
36
|
-
|
|
37
|
-
constructor(
|
|
38
|
-
this.cwd = cwd;
|
|
39
|
-
this.configs = configs;
|
|
31
|
+
view;
|
|
32
|
+
constructor(fs, view) {
|
|
40
33
|
this.fs = fs;
|
|
41
|
-
this.
|
|
34
|
+
this.view = view;
|
|
42
35
|
}
|
|
43
|
-
|
|
44
|
-
const resolved = 'text' in request
|
|
45
|
-
? this.configs.parse(request.text, this.cwd)
|
|
46
|
-
: this.configs.load(node_path_1.default.resolve(this.cwd, request.config));
|
|
47
|
-
const { content, registrations, warnings } = this.generate(resolved);
|
|
48
|
-
return {
|
|
49
|
-
config: 'text' in request ? undefined : resolved.file,
|
|
50
|
-
bundle: resolved.bundleClassName,
|
|
51
|
-
registrations,
|
|
52
|
-
content,
|
|
53
|
-
warnings: [...resolved.warnings, ...warnings],
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
generate(config) {
|
|
36
|
+
bundle(config) {
|
|
57
37
|
const paths = (0, tsconfig_1.loadImportPaths)(config.tsconfig, config.importExtension);
|
|
58
38
|
const relative = (file) => (0, glob_1.toPosix)(node_path_1.default.relative(config.dir, file));
|
|
59
39
|
const exclude = config.paths.exclude.flatMap((glob) => paths.resolveGlob(glob, config.dir)).map(glob_1.globToRegExp);
|
|
@@ -71,7 +51,7 @@ let BundleBuilder = class BundleBuilder {
|
|
|
71
51
|
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
|
72
52
|
.flatMap((file) => {
|
|
73
53
|
const text = this.fs.readFile(file);
|
|
74
|
-
return text.startsWith(
|
|
54
|
+
return text.startsWith(BundleView_1.GENERATED_HEADER) ? [] : (0, scan_1.findClasses)(file, config.match, text);
|
|
75
55
|
})
|
|
76
56
|
.map((cls) => ({ ...cls, specifier: paths.specifier(cls.file) }));
|
|
77
57
|
const uncovered = [...new Set(classes.filter((cls) => cls.specifier === undefined).map((cls) => cls.file))];
|
|
@@ -79,20 +59,24 @@ let BundleBuilder = class BundleBuilder {
|
|
|
79
59
|
throw new DomainException_1.TicConfigError(`no tsconfig paths alias covers ${uncovered.map((file) => (0, glob_1.toPosix)(node_path_1.default.relative(config.dir, file))).join(', ')}; ` +
|
|
80
60
|
`the bundle goes to stdout, so every import is written through an alias — add a "paths" entry to ${(0, glob_1.toPosix)(node_path_1.default.relative(config.dir, config.tsconfig.file))}`);
|
|
81
61
|
}
|
|
82
|
-
const content = this.
|
|
62
|
+
const content = this.view.render({
|
|
83
63
|
name: config.bundleClassName,
|
|
84
64
|
paths: config.paths.include,
|
|
85
65
|
classes: classes.map((cls) => ({ ...cls, specifier: cls.specifier })),
|
|
86
|
-
})
|
|
87
|
-
return {
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
bundle: config.bundleClassName,
|
|
69
|
+
registrations: classes.length,
|
|
70
|
+
files: [...new Set(classes.map((cls) => cls.file))],
|
|
71
|
+
content,
|
|
72
|
+
warnings: [...config.warnings, ...(0, tokenCollisions_1.tokenCollisions)(classes)],
|
|
73
|
+
};
|
|
88
74
|
}
|
|
89
75
|
};
|
|
90
|
-
exports.
|
|
91
|
-
exports.
|
|
92
|
-
(0, ts_ioc_container_1.register)(exports.
|
|
93
|
-
__param(0, (0, ts_ioc_container_1.inject)((0,
|
|
94
|
-
__param(1, (0, ts_ioc_container_1.inject)((0, ts_ioc_container_1.by)(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
__metadata("design:paramtypes", [String, Object, Object, Object])
|
|
98
|
-
], BundleBuilder);
|
|
76
|
+
exports.BundleService = BundleService;
|
|
77
|
+
exports.BundleService = BundleService = __decorate([
|
|
78
|
+
(0, ts_ioc_container_1.register)(exports.IBundleServiceKey),
|
|
79
|
+
__param(0, (0, ts_ioc_container_1.inject)((0, ts_ioc_container_1.by)(NodeFileSystemService_1.IFileSystemServiceKey))),
|
|
80
|
+
__param(1, (0, ts_ioc_container_1.inject)((0, ts_ioc_container_1.by)(BundleView_1.IBundleViewKey))),
|
|
81
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
82
|
+
], BundleService);
|
|
@@ -0,0 +1,58 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BundleView = exports.IBundleViewKey = exports.GENERATED_HEADER = void 0;
|
|
16
|
+
const ts_ioc_container_1 = require("ts-ioc-container");
|
|
17
|
+
const HandlebarsRenderService_1 = require("../../../services/HandlebarsRenderService");
|
|
18
|
+
exports.GENERATED_HEADER = '// Generated by `tic build`';
|
|
19
|
+
const BUNDLE_PROTOCOL = 'Bundle.ts.hbs';
|
|
20
|
+
const RUNTIME_IMPORTS = ['IContainer', 'IContainerModule', 'Registration'];
|
|
21
|
+
exports.IBundleViewKey = new ts_ioc_container_1.SingleToken('IBundleView');
|
|
22
|
+
let BundleView = class BundleView {
|
|
23
|
+
renderer;
|
|
24
|
+
constructor(renderer) {
|
|
25
|
+
this.renderer = renderer;
|
|
26
|
+
}
|
|
27
|
+
render(input) {
|
|
28
|
+
return this.renderer.render(BUNDLE_PROTOCOL, toData(input));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.BundleView = BundleView;
|
|
32
|
+
exports.BundleView = BundleView = __decorate([
|
|
33
|
+
(0, ts_ioc_container_1.register)(exports.IBundleViewKey),
|
|
34
|
+
__param(0, (0, ts_ioc_container_1.inject)((0, ts_ioc_container_1.by)(HandlebarsRenderService_1.IRenderServiceKey))),
|
|
35
|
+
__metadata("design:paramtypes", [Object])
|
|
36
|
+
], BundleView);
|
|
37
|
+
function toData({ name, paths, classes }) {
|
|
38
|
+
const taken = new Set([...RUNTIME_IMPORTS, 'container', name]);
|
|
39
|
+
const uniqueName = (wanted) => {
|
|
40
|
+
let candidate = wanted;
|
|
41
|
+
for (let n = 2; taken.has(candidate); n++)
|
|
42
|
+
candidate = `${wanted}_${n}`;
|
|
43
|
+
taken.add(candidate);
|
|
44
|
+
return candidate;
|
|
45
|
+
};
|
|
46
|
+
const byFile = new Map();
|
|
47
|
+
const bindings = classes.map((cls) => {
|
|
48
|
+
const binding = uniqueName(cls.localName);
|
|
49
|
+
const entry = byFile.get(cls.file) ?? { specifier: cls.specifier, named: [] };
|
|
50
|
+
byFile.set(cls.file, entry);
|
|
51
|
+
if (cls.exportName === 'default')
|
|
52
|
+
entry.defaultName = binding;
|
|
53
|
+
else
|
|
54
|
+
entry.named.push(binding === cls.exportName ? binding : `${cls.exportName} as ${binding}`);
|
|
55
|
+
return binding;
|
|
56
|
+
});
|
|
57
|
+
return { paths, name, imports: [...byFile.values()], registrations: bindings };
|
|
58
|
+
}
|
|
@@ -27,16 +27,27 @@ let TicConfigService = class TicConfigService {
|
|
|
27
27
|
constructor(fs) {
|
|
28
28
|
this.fs = fs;
|
|
29
29
|
}
|
|
30
|
-
load(
|
|
30
|
+
load(files) {
|
|
31
|
+
if (typeof files === 'string' || files.length === 1) {
|
|
32
|
+
const [file] = [files].flat();
|
|
33
|
+
return (0, BuildConfig_1.resolveConfig)(this.read(file), file);
|
|
34
|
+
}
|
|
35
|
+
const folders = [...new Set(files.map((file) => node_path_1.default.dirname(file)))];
|
|
36
|
+
if (folders.length > 1) {
|
|
37
|
+
throw new DomainException_1.TicConfigError(`configs merged into one bundle must sit in one folder, since their relative paths resolve against it: ${folders.join(', ')}`);
|
|
38
|
+
}
|
|
39
|
+
return (0, BuildConfig_1.resolveConfig)((0, BuildConfig_1.mergeConfigs)(files.map((file) => ({ file, content: this.read(file) }))), files[files.length - 1]);
|
|
40
|
+
}
|
|
41
|
+
parse(text, dir) {
|
|
42
|
+
return (0, BuildConfig_1.resolveConfig)((0, BuildConfig_1.parseConfig)(text, 'yaml'), node_path_1.default.join(dir, BuildConfig_1.STDIN));
|
|
43
|
+
}
|
|
44
|
+
read(file) {
|
|
31
45
|
const format = (0, BuildConfig_1.configFormat)(file);
|
|
32
46
|
if (format === undefined)
|
|
33
47
|
throw new DomainException_1.TicConfigError(`expected a .json, .yaml or .yml config file: ${file}`);
|
|
34
48
|
if (!this.fs.fileExists(file))
|
|
35
49
|
throw new DomainException_1.TicConfigError(`config file not found: ${file}`);
|
|
36
|
-
return (0, BuildConfig_1.
|
|
37
|
-
}
|
|
38
|
-
parse(text, dir) {
|
|
39
|
-
return (0, BuildConfig_1.resolveConfig)((0, BuildConfig_1.parseConfig)(text, 'yaml'), node_path_1.default.join(dir, BuildConfig_1.STDIN));
|
|
50
|
+
return (0, BuildConfig_1.parseConfig)(this.fs.readFile(file), format);
|
|
40
51
|
}
|
|
41
52
|
};
|
|
42
53
|
exports.TicConfigService = TicConfigService;
|
package/cjm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ExceptionHandler = exports.UsageError = exports.UnknownActionError = exports.UnknownCommandError = exports.MissingCommandError = exports.NamespaceNotFoundError = exports.TicConfigError = exports.TicError = exports.renderProtocol = exports.HandlebarsRenderService = exports.IRenderServiceKey = exports.NodeFileSystemService = exports.IFileSystemServiceKey = exports.ConsoleLogger = void 0;
|
|
3
|
+
exports.StdOutputService = exports.IOutputServiceKey = exports.CommonModule = exports.HelpModule = exports.globToRegExp = exports.tokenCollisions = exports.GENERATED_HEADER = exports.IBundleViewKey = exports.BundleView = exports.listSourceFiles = exports.isSourceFile = exports.findClasses = exports.loadImportPaths = exports.ImportPaths = exports.ticConfigJsonSchema = exports.toClassName = exports.DEFAULT_DECORATORS = exports.DEFAULT_EXCLUDE = exports.DEFAULT_TSCONFIG = exports.configFormat = exports.STDIN = exports.CONFIG_FILE_SUFFIXES = exports.parseConfig = exports.mergeConfigs = exports.BUNDLE_CONFIG_FILE_SCHEMA = exports.BUNDLE_CONFIG_SCHEMA = exports.resolveConfig = exports.ITicConfigServiceKey = exports.TicConfigService = exports.IBundleServiceKey = exports.BundleService = exports.BUILD_OPTIONS = exports.BundleController = exports.BuildModule = exports.USAGE = exports.IErrorHandlerKey = exports.validate = exports.parseOptions = exports.commandArgs = exports.DEFAULT_ACTION = exports.onDefault = exports.action = exports.Application = exports.globalConfig = exports.GlobalConfigKey = exports.CliIoKey = exports.createContainer = exports.loadConfig = exports.run = exports.build = void 0;
|
|
4
|
+
exports.ExceptionHandler = exports.UsageError = exports.UnknownActionError = exports.UnknownCommandError = exports.MissingCommandError = exports.NamespaceNotFoundError = exports.TicConfigError = exports.TicError = exports.renderProtocol = exports.HandlebarsRenderService = exports.IRenderServiceKey = exports.NodeFileSystemService = exports.IFileSystemServiceKey = exports.ConsoleLogger = exports.ILoggerKey = void 0;
|
|
5
5
|
var app_1 = require("./app");
|
|
6
6
|
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return app_1.build; } });
|
|
7
7
|
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return app_1.run; } });
|
|
@@ -22,20 +22,22 @@ Object.defineProperty(exports, "parseOptions", { enumerable: true, get: function
|
|
|
22
22
|
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return cli_1.validate; } });
|
|
23
23
|
Object.defineProperty(exports, "IErrorHandlerKey", { enumerable: true, get: function () { return cli_1.IErrorHandlerKey; } });
|
|
24
24
|
Object.defineProperty(exports, "USAGE", { enumerable: true, get: function () { return cli_1.USAGE; } });
|
|
25
|
-
var BuildModule_1 = require("./features/
|
|
25
|
+
var BuildModule_1 = require("./features/bundle/BuildModule");
|
|
26
26
|
Object.defineProperty(exports, "BuildModule", { enumerable: true, get: function () { return BuildModule_1.BuildModule; } });
|
|
27
|
-
var
|
|
28
|
-
Object.defineProperty(exports, "
|
|
29
|
-
Object.defineProperty(exports, "BUILD_OPTIONS", { enumerable: true, get: function () { return
|
|
30
|
-
var
|
|
31
|
-
Object.defineProperty(exports, "
|
|
32
|
-
Object.defineProperty(exports, "
|
|
33
|
-
var TicConfigService_1 = require("./features/
|
|
27
|
+
var BundleController_1 = require("./features/bundle/BundleController");
|
|
28
|
+
Object.defineProperty(exports, "BundleController", { enumerable: true, get: function () { return BundleController_1.BundleController; } });
|
|
29
|
+
Object.defineProperty(exports, "BUILD_OPTIONS", { enumerable: true, get: function () { return BundleController_1.BUILD_OPTIONS; } });
|
|
30
|
+
var BundleService_1 = require("./features/bundle/services/BundleService");
|
|
31
|
+
Object.defineProperty(exports, "BundleService", { enumerable: true, get: function () { return BundleService_1.BundleService; } });
|
|
32
|
+
Object.defineProperty(exports, "IBundleServiceKey", { enumerable: true, get: function () { return BundleService_1.IBundleServiceKey; } });
|
|
33
|
+
var TicConfigService_1 = require("./features/bundle/services/TicConfigService");
|
|
34
34
|
Object.defineProperty(exports, "TicConfigService", { enumerable: true, get: function () { return TicConfigService_1.TicConfigService; } });
|
|
35
35
|
Object.defineProperty(exports, "ITicConfigServiceKey", { enumerable: true, get: function () { return TicConfigService_1.ITicConfigServiceKey; } });
|
|
36
|
-
var BuildConfig_1 = require("./features/
|
|
36
|
+
var BuildConfig_1 = require("./features/bundle/BuildConfig");
|
|
37
37
|
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return BuildConfig_1.resolveConfig; } });
|
|
38
38
|
Object.defineProperty(exports, "BUNDLE_CONFIG_SCHEMA", { enumerable: true, get: function () { return BuildConfig_1.BUNDLE_CONFIG_SCHEMA; } });
|
|
39
|
+
Object.defineProperty(exports, "BUNDLE_CONFIG_FILE_SCHEMA", { enumerable: true, get: function () { return BuildConfig_1.BUNDLE_CONFIG_FILE_SCHEMA; } });
|
|
40
|
+
Object.defineProperty(exports, "mergeConfigs", { enumerable: true, get: function () { return BuildConfig_1.mergeConfigs; } });
|
|
39
41
|
Object.defineProperty(exports, "parseConfig", { enumerable: true, get: function () { return BuildConfig_1.parseConfig; } });
|
|
40
42
|
Object.defineProperty(exports, "CONFIG_FILE_SUFFIXES", { enumerable: true, get: function () { return BuildConfig_1.CONFIG_FILE_SUFFIXES; } });
|
|
41
43
|
Object.defineProperty(exports, "STDIN", { enumerable: true, get: function () { return BuildConfig_1.STDIN; } });
|
|
@@ -46,22 +48,21 @@ Object.defineProperty(exports, "DEFAULT_DECORATORS", { enumerable: true, get: fu
|
|
|
46
48
|
Object.defineProperty(exports, "toClassName", { enumerable: true, get: function () { return BuildConfig_1.toClassName; } });
|
|
47
49
|
var ticConfigSchema_1 = require("./schema/ticConfigSchema");
|
|
48
50
|
Object.defineProperty(exports, "ticConfigJsonSchema", { enumerable: true, get: function () { return ticConfigSchema_1.ticConfigJsonSchema; } });
|
|
49
|
-
var ImportPaths_1 = require("./features/
|
|
51
|
+
var ImportPaths_1 = require("./features/bundle/domain/ImportPaths");
|
|
50
52
|
Object.defineProperty(exports, "ImportPaths", { enumerable: true, get: function () { return ImportPaths_1.ImportPaths; } });
|
|
51
|
-
var tsconfig_1 = require("./features/
|
|
53
|
+
var tsconfig_1 = require("./features/bundle/domain/tsconfig");
|
|
52
54
|
Object.defineProperty(exports, "loadImportPaths", { enumerable: true, get: function () { return tsconfig_1.loadImportPaths; } });
|
|
53
|
-
var scan_1 = require("./features/
|
|
55
|
+
var scan_1 = require("./features/bundle/domain/scan");
|
|
54
56
|
Object.defineProperty(exports, "findClasses", { enumerable: true, get: function () { return scan_1.findClasses; } });
|
|
55
57
|
Object.defineProperty(exports, "isSourceFile", { enumerable: true, get: function () { return scan_1.isSourceFile; } });
|
|
56
58
|
Object.defineProperty(exports, "listSourceFiles", { enumerable: true, get: function () { return scan_1.listSourceFiles; } });
|
|
57
|
-
var
|
|
58
|
-
Object.defineProperty(exports, "
|
|
59
|
-
Object.defineProperty(exports, "
|
|
60
|
-
Object.defineProperty(exports, "
|
|
61
|
-
|
|
62
|
-
var tokenCollisions_1 = require("./features/build/domain/tokenCollisions");
|
|
59
|
+
var BundleView_1 = require("./features/bundle/services/BundleView");
|
|
60
|
+
Object.defineProperty(exports, "BundleView", { enumerable: true, get: function () { return BundleView_1.BundleView; } });
|
|
61
|
+
Object.defineProperty(exports, "IBundleViewKey", { enumerable: true, get: function () { return BundleView_1.IBundleViewKey; } });
|
|
62
|
+
Object.defineProperty(exports, "GENERATED_HEADER", { enumerable: true, get: function () { return BundleView_1.GENERATED_HEADER; } });
|
|
63
|
+
var tokenCollisions_1 = require("./features/bundle/domain/tokenCollisions");
|
|
63
64
|
Object.defineProperty(exports, "tokenCollisions", { enumerable: true, get: function () { return tokenCollisions_1.tokenCollisions; } });
|
|
64
|
-
var glob_1 = require("./features/
|
|
65
|
+
var glob_1 = require("./features/bundle/domain/glob");
|
|
65
66
|
Object.defineProperty(exports, "globToRegExp", { enumerable: true, get: function () { return glob_1.globToRegExp; } });
|
|
66
67
|
var HelpModule_1 = require("./features/help/HelpModule");
|
|
67
68
|
Object.defineProperty(exports, "HelpModule", { enumerable: true, get: function () { return HelpModule_1.HelpModule; } });
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ticConfigJsonSchema = ticConfigJsonSchema;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const BuildConfig_1 = require("../features/
|
|
5
|
+
const BuildConfig_1 = require("../features/bundle/BuildConfig");
|
|
6
6
|
function ticConfigJsonSchema() {
|
|
7
|
-
const schema = zod_1.z.toJSONSchema(BuildConfig_1.
|
|
7
|
+
const schema = zod_1.z.toJSONSchema(BuildConfig_1.BUNDLE_CONFIG_FILE_SCHEMA, {
|
|
8
8
|
io: 'input',
|
|
9
9
|
target: 'draft-7',
|
|
10
10
|
unrepresentable: 'any',
|
|
@@ -18,7 +18,7 @@ function ticConfigJsonSchema() {
|
|
|
18
18
|
$schema,
|
|
19
19
|
$id: 'https://github.com/IgorBabkin/ts-ioc-container/tree/main/packages/bundler/tic.schema.json',
|
|
20
20
|
title: '*.bundle.json / *.bundle.yaml',
|
|
21
|
-
description: "One bundle generated by `tic build` (@ts-ioc-container/bundler). `tic build app.bundle.json` prints the bundle to stdout, and `cat app.bundle.json | tic build` reads the config from stdin. Relative paths resolve against this file's directory (for piped text, the working directory).",
|
|
21
|
+
description: "One bundle generated by `tic build` (@ts-ioc-container/bundler). `tic build app.bundle.json` prints the bundle to stdout, `tic build common.bundle.json prod.bundle.json` merges several configs left to right, and `cat app.bundle.json | tic build` reads the config from stdin. Relative paths resolve against this file's directory (for piped text, the working directory).",
|
|
22
22
|
...rest,
|
|
23
23
|
};
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-ioc-container/bundler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Bundles your dependencies into a single container module for ts-ioc-container: the `tic` CLI scans folders (by path or tsconfig alias) and generates one typed bundle that registers every class — `container.useModule(new AppBundle())`.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"reflect-metadata": "^0.2.2",
|
|
53
53
|
"yaml": "^2.8.3",
|
|
54
54
|
"zod": "^4.6.5",
|
|
55
|
-
"ts-ioc-container": "76.0.
|
|
55
|
+
"ts-ioc-container": "76.0.2"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"typescript": ">=5"
|
package/tic.schema.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$id": "https://github.com/IgorBabkin/ts-ioc-container/tree/main/packages/bundler/tic.schema.json",
|
|
4
4
|
"title": "*.bundle.json / *.bundle.yaml",
|
|
5
|
-
"description": "One bundle generated by `tic build` (@ts-ioc-container/bundler). `tic build app.bundle.json` prints the bundle to stdout, and `cat app.bundle.json | tic build` reads the config from stdin. Relative paths resolve against this file's directory (for piped text, the working directory).",
|
|
5
|
+
"description": "One bundle generated by `tic build` (@ts-ioc-container/bundler). `tic build app.bundle.json` prints the bundle to stdout, `tic build common.bundle.json prod.bundle.json` merges several configs left to right, and `cat app.bundle.json | tic build` reads the config from stdin. Relative paths resolve against this file's directory (for piped text, the working directory).",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"$schema": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"type": "string"
|
|
25
25
|
},
|
|
26
26
|
"paths": {
|
|
27
|
+
"description": "Which files this bundle reads and parses — decided by path alone, before parsing. `include` names the folders the files come from; within them a file is parsed unless it matches one of `exclude`. Globs are relative to the config file. Required in the merged config.",
|
|
27
28
|
"type": "object",
|
|
28
29
|
"properties": {
|
|
29
30
|
"include": {
|
|
@@ -68,13 +69,9 @@
|
|
|
68
69
|
]
|
|
69
70
|
}
|
|
70
71
|
},
|
|
71
|
-
"
|
|
72
|
-
"include"
|
|
73
|
-
],
|
|
74
|
-
"additionalProperties": false,
|
|
75
|
-
"description": "Which files this bundle reads and parses — decided by path alone, before parsing. `include` names the folders the files come from; within them a file is parsed unless it matches one of `exclude`. Globs are relative to the config file."
|
|
72
|
+
"additionalProperties": false
|
|
76
73
|
},
|
|
77
|
-
"
|
|
74
|
+
"match": {
|
|
78
75
|
"anyOf": [
|
|
79
76
|
{
|
|
80
77
|
"type": "string",
|
|
@@ -155,8 +152,5 @@
|
|
|
155
152
|
"description": "Which classes of a parsed file are registered. A class is selected when it is exported, not abstract, and meets every criterion set here; by default that is every exported class decorated with @register. A glob, or a list of globs, is shorthand for { \"glob\": ... }."
|
|
156
153
|
}
|
|
157
154
|
},
|
|
158
|
-
"required": [
|
|
159
|
-
"paths"
|
|
160
|
-
],
|
|
161
155
|
"additionalProperties": false
|
|
162
156
|
}
|
package/typings/app.d.ts
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { type IContainer } from 'ts-ioc-container';
|
|
3
3
|
import { type CliIo } from './domain/CliIo.js';
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
4
|
+
import { type BundleConfig } from './features/bundle/BuildConfig.js';
|
|
5
|
+
import { type Bundle } from './features/bundle/services/BundleService.js';
|
|
6
|
+
/** What one build does. Paths resolve against the run's working directory. */
|
|
7
|
+
export type BundleRequest = {
|
|
8
|
+
/**
|
|
9
|
+
* Path of the config file — `*.json`, `*.yaml` or `*.yml` — relative to the working directory;
|
|
10
|
+
* or of several in one folder, merged left to right into one bundle.
|
|
11
|
+
*/
|
|
12
|
+
config: string | string[];
|
|
13
|
+
} | {
|
|
14
|
+
/**
|
|
15
|
+
* The config as text, e.g. read from stdin: YAML or JSON. Its relative paths resolve
|
|
16
|
+
* against the working directory, and it must set `name`.
|
|
17
|
+
*/
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
export type BuildOptions = BundleRequest & {
|
|
21
|
+
/** Default `process.cwd()`. */
|
|
22
|
+
cwd?: string;
|
|
23
|
+
};
|
|
6
24
|
/** The composition root: one container per run, holding every module of the CLI. */
|
|
7
25
|
export declare function createContainer(io?: CliIo): IContainer;
|
|
8
26
|
/** Runs the `tic` CLI and returns its exit code; output goes through `io`. */
|
|
@@ -11,14 +29,15 @@ export declare function run(argv: string[], io?: CliIo): number;
|
|
|
11
29
|
* Generates the bundle a config file describes — `tic build` as a function — and returns
|
|
12
30
|
* it; nothing is written.
|
|
13
31
|
*
|
|
14
|
-
* @throws {TicConfigError} when
|
|
32
|
+
* @throws {TicConfigError} when a config file is missing or unreadable, several are in different folders, the config or its tsconfig is invalid, the bundle has no name, or no tsconfig paths alias covers a selected class's file.
|
|
15
33
|
* @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
|
|
16
34
|
*/
|
|
17
|
-
export declare function build({ cwd, ...request }: BuildOptions):
|
|
35
|
+
export declare function build({ cwd, ...request }: BuildOptions): Bundle;
|
|
18
36
|
/**
|
|
19
|
-
* Reads and validates a config file: JSON for `.json`, YAML for `.yaml` / `.yml`.
|
|
37
|
+
* Reads and validates a config file: JSON for `.json`, YAML for `.yaml` / `.yml`. Given several
|
|
38
|
+
* in one folder, it merges them left to right, as `tic build a.bundle.yml b.bundle.yml` does.
|
|
20
39
|
*
|
|
21
|
-
* @throws {TicConfigError} when
|
|
40
|
+
* @throws {TicConfigError} when a file is missing, has another extension, cannot be parsed, or does not match the config shape; when several files are in different folders.
|
|
22
41
|
*/
|
|
23
|
-
export declare function loadConfig(
|
|
42
|
+
export declare function loadConfig(files: string | string[]): BundleConfig;
|
|
24
43
|
//# sourceMappingURL=app.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../lib/cli/usage.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../lib/cli/usage.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,QAqBN,CAAC"}
|
|
@@ -63,8 +63,10 @@ export interface ResolvedClassSelector {
|
|
|
63
63
|
* A bundle config file: one bundle, described explicitly — the folders it scans and the
|
|
64
64
|
* classes it registers. `tic build <config>` prints the bundle to stdout; where it is
|
|
65
65
|
* saved is the caller's choice (`tic build app.bundle.json > src/di/app.bundle.ts`).
|
|
66
|
+
* `tic build common.bundle.yml prod.bundle.yml` merges several into one, left to right
|
|
67
|
+
* (see {@link mergeConfigs}).
|
|
66
68
|
*/
|
|
67
|
-
export interface
|
|
69
|
+
export interface BundleConfigFile {
|
|
68
70
|
$schema?: string;
|
|
69
71
|
/**
|
|
70
72
|
* The bundle's name: letters, digits, `-` and `_`, starting with a letter. Default: the
|
|
@@ -85,20 +87,21 @@ export interface BundleConfig {
|
|
|
85
87
|
/**
|
|
86
88
|
* Which files are parsed: the folders in `paths.include`, minus {@link DEFAULT_EXCLUDE} unless
|
|
87
89
|
* `exclude` says otherwise. Always an object: there is no folder or folder-list shorthand.
|
|
90
|
+
* Required — though in a config merged with others, only the merged config must have it.
|
|
88
91
|
*/
|
|
89
92
|
paths: PathSelector;
|
|
90
93
|
/**
|
|
91
94
|
* Which classes of a parsed file are registered. Default: every exported class decorated
|
|
92
95
|
* with `@register`. A glob or a list of globs is shorthand for `{ glob }`.
|
|
93
96
|
*/
|
|
94
|
-
|
|
97
|
+
match?: string | string[] | ClassSelector;
|
|
95
98
|
}
|
|
96
99
|
export declare const DEFAULT_TSCONFIG = "./tsconfig.json";
|
|
97
|
-
/** What `
|
|
100
|
+
/** What `match.decorators` requires when omitted: the library's own `@register`. */
|
|
98
101
|
export declare const DEFAULT_DECORATORS: string[];
|
|
99
102
|
export declare const DEFAULT_EXCLUDE: string[];
|
|
100
|
-
/** A {@link
|
|
101
|
-
export interface
|
|
103
|
+
/** A {@link BundleConfigFile} whose defaults are filled in and whose paths are absolute. */
|
|
104
|
+
export interface BundleConfig {
|
|
102
105
|
/** The config file itself. */
|
|
103
106
|
file: string;
|
|
104
107
|
/** Its folder: what the config's relative paths resolve against. */
|
|
@@ -114,7 +117,7 @@ export interface ResolvedConfig {
|
|
|
114
117
|
};
|
|
115
118
|
importExtension?: string;
|
|
116
119
|
paths: ResolvedPathSelector;
|
|
117
|
-
|
|
120
|
+
match: ResolvedClassSelector;
|
|
118
121
|
/** Non-fatal problems found while resolving, e.g. a `paths.exclude` that drops a default test glob. */
|
|
119
122
|
warnings: string[];
|
|
120
123
|
}
|
|
@@ -132,7 +135,28 @@ export declare const BUNDLE_CONFIG_SCHEMA: z.ZodObject<{
|
|
|
132
135
|
include: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
133
136
|
exclude: z.ZodDefault<z.ZodCustom<string | string[], string | string[]>>;
|
|
134
137
|
}, z.core.$strict>;
|
|
135
|
-
|
|
138
|
+
match: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
139
|
+
export: z.ZodDefault<z.ZodEnum<{
|
|
140
|
+
default: "default";
|
|
141
|
+
any: "any";
|
|
142
|
+
named: "named";
|
|
143
|
+
}>>;
|
|
144
|
+
decorators: z.ZodDefault<z.ZodCustom<string[], string[]>>;
|
|
145
|
+
glob: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
|
|
146
|
+
exclude: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
|
|
147
|
+
}, z.core.$strict>]>>;
|
|
148
|
+
}, z.core.$strict>;
|
|
149
|
+
/**
|
|
150
|
+
* One config file among several merged into one bundle: it may leave `paths.include`, or
|
|
151
|
+
* `paths` altogether, to another — only the merged config must have it. The published
|
|
152
|
+
* `tic.schema.json` is generated from it, so editors accept a shared config.
|
|
153
|
+
*/
|
|
154
|
+
export declare const BUNDLE_CONFIG_FILE_SCHEMA: z.ZodObject<{
|
|
155
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
156
|
+
name: z.ZodOptional<z.ZodString>;
|
|
157
|
+
tsconfig: z.ZodOptional<z.ZodString>;
|
|
158
|
+
importExtension: z.ZodOptional<z.ZodString>;
|
|
159
|
+
match: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
136
160
|
export: z.ZodDefault<z.ZodEnum<{
|
|
137
161
|
default: "default";
|
|
138
162
|
any: "any";
|
|
@@ -142,6 +166,10 @@ export declare const BUNDLE_CONFIG_SCHEMA: z.ZodObject<{
|
|
|
142
166
|
glob: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
|
|
143
167
|
exclude: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
|
|
144
168
|
}, z.core.$strict>]>>;
|
|
169
|
+
paths: z.ZodOptional<z.ZodObject<{
|
|
170
|
+
include: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
171
|
+
exclude: z.ZodOptional<z.ZodDefault<z.ZodCustom<string | string[], string | string[]>>>;
|
|
172
|
+
}, z.core.$strict>>;
|
|
145
173
|
}, z.core.$strict>;
|
|
146
174
|
/**
|
|
147
175
|
* A config file is named `<name>.bundle.json`, `<name>.bundle.yaml` or `<name>.bundle.yml`
|
|
@@ -162,11 +190,26 @@ export type ConfigFormat = 'json' | 'yaml';
|
|
|
162
190
|
export declare function parseConfig(text: string, format: ConfigFormat): unknown;
|
|
163
191
|
/** The generated class for a bundle name: `production` -> `ProductionBundle`, `my-app_v2` -> `MyAppV2Bundle`. */
|
|
164
192
|
export declare function toClassName(name: string): string;
|
|
193
|
+
/**
|
|
194
|
+
* Merges the contents of several config files into one, left to right, as webpack-merge
|
|
195
|
+
* does: objects merge field by field, a list field — `paths.include`, `paths.exclude`,
|
|
196
|
+
* `match.glob`, `match.exclude`, `match.decorators` — concatenates without duplicates
|
|
197
|
+
* (one glob or folder counting as a list of one), and any other value set by a later file
|
|
198
|
+
* replaces an earlier one. The `match` shorthand merges as `match.glob`. Each file is
|
|
199
|
+
* validated alone first, so a shared file may leave out `paths`; defaults apply to the
|
|
200
|
+
* merged config only, so a `paths.exclude` in any file replaces {@link DEFAULT_EXCLUDE}.
|
|
201
|
+
*
|
|
202
|
+
* @throws {TicConfigError} when a file's content does not match the config file shape; the message names the file and the field.
|
|
203
|
+
*/
|
|
204
|
+
export declare function mergeConfigs(configs: {
|
|
205
|
+
file: string;
|
|
206
|
+
content: unknown;
|
|
207
|
+
}[]): unknown;
|
|
165
208
|
/**
|
|
166
209
|
* Validates parsed config content and resolves its paths against `file`'s directory.
|
|
167
210
|
* Without a `name` the bundle is named after the file: `production.bundle.json` -> `production`.
|
|
168
211
|
*
|
|
169
212
|
* @throws {TicConfigError} when the content does not match the config shape, or names no bundle; the message names the field.
|
|
170
213
|
*/
|
|
171
|
-
export declare function resolveConfig(content: unknown, file: string):
|
|
214
|
+
export declare function resolveConfig(content: unknown, file: string): BundleConfig;
|
|
172
215
|
//# sourceMappingURL=BuildConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildConfig.d.ts","sourceRoot":"","sources":["../../../lib/features/bundle/BuildConfig.ts"],"names":[],"mappings":"AAEA,O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AACjH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhD;AA6BD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EAAE,GAAG,OAAO,CAMnF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAwB1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildModule.d.ts","sourceRoot":"","sources":["../../../lib/features/bundle/BuildModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAqB,MAAM,kBAAkB,CAAC;AAM7F,qBAAa,WAAY,YAAW,gBAAgB;IAClD,OAAO,CAAC,SAAS,EAAE,UAAU,GAAG,IAAI;CAOrC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type CliIo } from '../../domain/CliIo.js';
|
|
3
|
+
import { type ILogger } from '../../services/ConsoleLogger.js';
|
|
4
|
+
import { type IOutputService } from '../../services/OutputService.js';
|
|
5
|
+
import { type IBundleService } from './services/BundleService.js';
|
|
6
|
+
import { type ITicConfigService } from './services/TicConfigService.js';
|
|
7
|
+
export declare const BUILD_OPTIONS: z.ZodPipe<z.ZodObject<{
|
|
8
|
+
positionals: z.ZodArray<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
10
|
+
configs: string[];
|
|
11
|
+
}, {
|
|
12
|
+
positionals: string[];
|
|
13
|
+
}>>;
|
|
14
|
+
export type BuildCliOptions = z.output<typeof BUILD_OPTIONS>;
|
|
15
|
+
/**
|
|
16
|
+
* `tic build [<config>... | -]`: the bundle goes to stdout; several configs are merged left to right
|
|
17
|
+
* into one, and without a config file the config comes from stdin.
|
|
18
|
+
*/
|
|
19
|
+
export declare class BundleController {
|
|
20
|
+
private readonly io;
|
|
21
|
+
private readonly configService;
|
|
22
|
+
private readonly bundleService;
|
|
23
|
+
private readonly output;
|
|
24
|
+
private readonly logger;
|
|
25
|
+
constructor(io: CliIo, configService: ITicConfigService, bundleService: IBundleService, output: IOutputService, logger: ILogger);
|
|
26
|
+
/**
|
|
27
|
+
* Builds the bundle the config file `<config>` describes — several merged left to right
|
|
28
|
+
* into one, or without one (or with `-`), the config piped into stdin — and prints it to
|
|
29
|
+
* stdout. Saving it is the shell's job: `tic build app.bundle.json > src/di/app.bundle.ts`,
|
|
30
|
+
* `tic build common.bundle.yml prod.bundle.yml > src/di/prod.bundle.ts`,
|
|
31
|
+
* `cat app.bundle.yml | tic build > out.ts`.
|
|
32
|
+
* The files in the bundle, one path per line relative to the working directory, and warnings
|
|
33
|
+
* go to stderr, so they never end up in the bundle; an error names the configs.
|
|
34
|
+
*
|
|
35
|
+
* @throws {UsageError} when an option is unknown, `-` is given with config files, or the config should come from stdin and nothing is piped in.
|
|
36
|
+
* @throws {TicConfigError} when a config file is missing or unreadable, several are in different folders, the config or its tsconfig is invalid, the bundle has no name, or no tsconfig paths alias covers a selected class's file.
|
|
37
|
+
* @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
|
|
38
|
+
*/
|
|
39
|
+
bundle({ configs }: BuildCliOptions): void;
|
|
40
|
+
/**
|
|
41
|
+
* @throws {UsageError} when nothing is piped into stdin.
|
|
42
|
+
*/
|
|
43
|
+
private stdin;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=BundleController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BundleController.d.ts","sourceRoot":"","sources":["../../../lib/features/bundle/BundleController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,oBAAoB,CAA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;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW;gBAczF,OAAO,EAAE,KAAK,EAAE,EACxB,SAAS,EAAE,MAAM;IAG5B;;;;OAIG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAa5D;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAOpD;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK3C,OAAO,CAAC,SAAS;IAWjB,8GAA8G;IAC9G,OAAO,CAAC,YAAY;IAYpB,yGAAyG;IACzG,OAAO,CAAC,UAAU;CAanB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../../lib/features/bundle/domain/glob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiBjD;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,KAAG,MAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../lib/features/bundle/domain/scan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;CACpD;AAKD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAiE,CAAC;AAE9G,mHAAmH;AACnH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,EAAE,CAc5F;AA2BD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,SAA6B,GAChC,eAAe,EAAE,CAkFnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenCollisions.d.ts","sourceRoot":"","sources":["../../../../lib/features/bundle/domain/tokenCollisions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,EAAE,CAmBpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../../../lib/features/bundle/domain/tsconfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,CAapH"}
|