@ts-ioc-container/bundler 3.1.0 → 4.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 +45 -48
- package/README.md +177 -145
- package/cjm/app.js +2 -2
- package/cjm/cli/Application.js +4 -5
- package/cjm/cli/options.js +4 -2
- package/cjm/cli/usage.js +11 -8
- package/cjm/domain/CliIo.js +7 -1
- package/cjm/exceptions/DomainException.js +7 -7
- package/cjm/features/build/BuildConfig.js +108 -71
- package/cjm/features/build/BuildController.js +36 -46
- package/cjm/features/build/domain/ImportPaths.js +31 -20
- package/cjm/features/build/domain/emit.js +2 -2
- package/cjm/features/build/domain/scan.js +20 -4
- package/cjm/features/build/domain/tokenCollisions.js +1 -1
- package/cjm/features/build/domain/tsconfig.js +10 -35
- package/cjm/features/build/services/BundleBuilder.js +36 -29
- package/cjm/features/build/services/TicConfigService.js +10 -31
- package/cjm/index.js +9 -10
- package/cjm/schema/ticConfigSchema.js +5 -1
- package/package.json +2 -2
- package/tic.schema.json +117 -84
- package/tpl/index.cjs +15 -15
- package/typings/app.d.ts +7 -6
- package/typings/cli/Application.d.ts.map +1 -1
- package/typings/cli/options.d.ts +7 -1
- package/typings/cli/options.d.ts.map +1 -1
- package/typings/cli/usage.d.ts.map +1 -1
- package/typings/domain/CliIo.d.ts +2 -0
- package/typings/domain/CliIo.d.ts.map +1 -1
- package/typings/domain/GlobalConfig.d.ts +1 -1
- package/typings/domain/GlobalConfig.d.ts.map +1 -1
- package/typings/exceptions/DomainException.d.ts +4 -4
- package/typings/exceptions/DomainException.d.ts.map +1 -1
- package/typings/features/build/BuildConfig.d.ts +107 -103
- package/typings/features/build/BuildConfig.d.ts.map +1 -1
- package/typings/features/build/BuildController.d.ts +23 -17
- package/typings/features/build/BuildController.d.ts.map +1 -1
- package/typings/features/build/domain/ImportPaths.d.ts +16 -14
- package/typings/features/build/domain/ImportPaths.d.ts.map +1 -1
- package/typings/features/build/domain/emit.d.ts +4 -4
- package/typings/features/build/domain/emit.d.ts.map +1 -1
- package/typings/features/build/domain/scan.d.ts +2 -0
- package/typings/features/build/domain/scan.d.ts.map +1 -1
- package/typings/features/build/domain/tsconfig.d.ts +9 -16
- package/typings/features/build/domain/tsconfig.d.ts.map +1 -1
- package/typings/features/build/services/BundleBuilder.d.ts +25 -29
- package/typings/features/build/services/BundleBuilder.d.ts.map +1 -1
- package/typings/features/build/services/TicConfigService.d.ts +11 -15
- package/typings/features/build/services/TicConfigService.d.ts.map +1 -1
- package/typings/index.d.ts +6 -7
- package/typings/schema/ticConfigSchema.d.ts.map +1 -1
- package/cjm/features/build/domain/configFiles.js +0 -35
- package/typings/features/build/domain/configFiles.d.ts +0 -13
- package/typings/features/build/domain/configFiles.d.ts.map +0 -1
|
@@ -36,49 +36,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.loadImportPaths = loadImportPaths;
|
|
40
40
|
const node_fs_1 = require("node:fs");
|
|
41
41
|
const node_path_1 = __importDefault(require("node:path"));
|
|
42
42
|
const ts = __importStar(require("typescript"));
|
|
43
43
|
const DomainException_1 = require("../../../exceptions/DomainException");
|
|
44
44
|
const ImportPaths_1 = require("./ImportPaths");
|
|
45
|
-
const scan_1 = require("./scan");
|
|
46
45
|
const NO_INPUTS = 18003;
|
|
47
|
-
function
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (const parts of rest) {
|
|
53
|
-
let i = 0;
|
|
54
|
-
while (i < length && i < parts.length && parts[i] === first[i])
|
|
55
|
-
i++;
|
|
56
|
-
length = i;
|
|
46
|
+
function loadImportPaths(tsconfig, importExtension) {
|
|
47
|
+
if (!(0, node_fs_1.existsSync)(tsconfig.file)) {
|
|
48
|
+
if (tsconfig.required)
|
|
49
|
+
throw new DomainException_1.TicConfigError(`tsconfig not found: ${tsconfig.file}`);
|
|
50
|
+
return new ImportPaths_1.ImportPaths([], importExtension ?? '');
|
|
57
51
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
function asTsconfig(config) {
|
|
61
|
-
if (!(0, node_fs_1.existsSync)(config.tsconfig.file)) {
|
|
62
|
-
if (config.tsconfig.required)
|
|
63
|
-
throw new DomainException_1.TicConfigError(`tsconfig not found: ${config.tsconfig.file}`);
|
|
64
|
-
return { config: config.overrides };
|
|
65
|
-
}
|
|
66
|
-
if (config.file === config.tsconfig.file)
|
|
67
|
-
return ts.readConfigFile(config.file, ts.sys.readFile);
|
|
68
|
-
return { config: { extends: config.tsconfig.file, ...config.overrides } };
|
|
69
|
-
}
|
|
70
|
-
function loadTsconfig(config) {
|
|
71
|
-
const { config: json, error } = asTsconfig(config);
|
|
72
|
-
const configFileName = config.file === config.tsconfig.file ? config.file : undefined;
|
|
73
|
-
const parsed = ts.parseJsonConfigFileContent(json ?? {}, ts.sys, config.dir, undefined, configFileName);
|
|
52
|
+
const { config, error } = ts.readConfigFile(tsconfig.file, ts.sys.readFile);
|
|
53
|
+
const parsed = ts.parseJsonConfigFileContent(config, ts.sys, node_path_1.default.dirname(tsconfig.file), undefined, tsconfig.file);
|
|
74
54
|
const [fatal] = [error, ...parsed.errors].filter((d) => !!d && d.code !== NO_INPUTS);
|
|
75
55
|
if (fatal) {
|
|
76
|
-
throw new DomainException_1.TicConfigError(`${
|
|
56
|
+
throw new DomainException_1.TicConfigError(`${tsconfig.file}: ${ts.flattenDiagnosticMessageText(fatal.messageText, '\n')}`);
|
|
77
57
|
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
importPaths: ImportPaths_1.ImportPaths.fromOptions(parsed.options, config.file, config.importExtension),
|
|
81
|
-
fileNames,
|
|
82
|
-
rootDir: parsed.options.rootDir ?? commonDir(fileNames.filter(scan_1.isSourceFile)) ?? config.dir,
|
|
83
|
-
};
|
|
58
|
+
return ImportPaths_1.ImportPaths.fromOptions(parsed.options, tsconfig.file, importExtension);
|
|
84
59
|
}
|
|
@@ -21,15 +21,13 @@ const ts_ioc_container_1 = require("ts-ioc-container");
|
|
|
21
21
|
const GlobalConfig_1 = require("../../../domain/GlobalConfig");
|
|
22
22
|
const HandlebarsRenderService_1 = require("../../../services/HandlebarsRenderService");
|
|
23
23
|
const NodeFileSystemService_1 = require("../../../services/NodeFileSystemService");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const DomainException_1 = require("../../../exceptions/DomainException");
|
|
25
|
+
const TicConfigService_1 = require("./TicConfigService");
|
|
26
26
|
const emit_1 = require("../domain/emit");
|
|
27
27
|
const glob_1 = require("../domain/glob");
|
|
28
28
|
const scan_1 = require("../domain/scan");
|
|
29
29
|
const tokenCollisions_1 = require("../domain/tokenCollisions");
|
|
30
30
|
const tsconfig_1 = require("../domain/tsconfig");
|
|
31
|
-
const TicConfigService_1 = require("./TicConfigService");
|
|
32
|
-
const DEFAULT_EXCLUDE_GLOBS = BuildConfig_1.DEFAULT_EXCLUDE.map(glob_1.globToRegExp);
|
|
33
31
|
exports.IBundleBuilderKey = new ts_ioc_container_1.SingleToken('IBundleBuilder');
|
|
34
32
|
let BundleBuilder = class BundleBuilder {
|
|
35
33
|
cwd;
|
|
@@ -42,44 +40,53 @@ let BundleBuilder = class BundleBuilder {
|
|
|
42
40
|
this.fs = fs;
|
|
43
41
|
this.renderer = renderer;
|
|
44
42
|
}
|
|
45
|
-
build(
|
|
46
|
-
const resolved =
|
|
47
|
-
?
|
|
48
|
-
: this.configs.load(node_path_1.default.resolve(this.cwd, config));
|
|
49
|
-
const {
|
|
50
|
-
const current = this.fs.fileExists(output) ? this.fs.readFile(output) : undefined;
|
|
51
|
-
const status = current === content ? 'unchanged' : check ? 'stale' : 'written';
|
|
52
|
-
if (status === 'written')
|
|
53
|
-
this.fs.writeFile(output, content);
|
|
43
|
+
build(request) {
|
|
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);
|
|
54
48
|
return {
|
|
55
|
-
config: resolved.file,
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
config: 'text' in request ? undefined : resolved.file,
|
|
50
|
+
bundle: resolved.bundleClassName,
|
|
51
|
+
registrations,
|
|
52
|
+
content,
|
|
53
|
+
warnings: [...resolved.warnings, ...warnings],
|
|
58
54
|
};
|
|
59
55
|
}
|
|
60
56
|
generate(config) {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
57
|
+
const paths = (0, tsconfig_1.loadImportPaths)(config.tsconfig, config.importExtension);
|
|
58
|
+
const relative = (file) => (0, glob_1.toPosix)(node_path_1.default.relative(config.dir, file));
|
|
59
|
+
const { include, exclude } = config.glob;
|
|
63
60
|
const isExcluded = (file) => {
|
|
64
|
-
|
|
61
|
+
const filename = relative(file);
|
|
62
|
+
if (include && !include.some((glob) => glob.test(filename)))
|
|
65
63
|
return true;
|
|
66
|
-
|
|
67
|
-
return DEFAULT_EXCLUDE_GLOBS.some((glob) => glob.test(filename));
|
|
64
|
+
return exclude.some((glob) => glob.test(filename));
|
|
68
65
|
};
|
|
69
|
-
const files =
|
|
70
|
-
const
|
|
66
|
+
const files = new Set();
|
|
67
|
+
for (const entry of config.glob.paths) {
|
|
68
|
+
const dir = paths.resolveNamespace(entry.path, config.dir);
|
|
69
|
+
for (const file of (0, scan_1.listSourceFiles)(dir, entry.recursive, isExcluded))
|
|
70
|
+
files.add(file);
|
|
71
|
+
}
|
|
72
|
+
const classes = [...files]
|
|
71
73
|
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
|
72
74
|
.flatMap((file) => {
|
|
73
75
|
const text = this.fs.readFile(file);
|
|
74
|
-
return text.startsWith(emit_1.GENERATED_HEADER) ? [] : (0, scan_1.findClasses)(file, config.
|
|
76
|
+
return text.startsWith(emit_1.GENERATED_HEADER) ? [] : (0, scan_1.findClasses)(file, config.className, text);
|
|
75
77
|
})
|
|
76
|
-
.map((cls) => ({ ...cls, specifier: paths.specifier(
|
|
78
|
+
.map((cls) => ({ ...cls, specifier: paths.specifier(cls.file) }));
|
|
79
|
+
const uncovered = [...new Set(classes.filter((cls) => cls.specifier === undefined).map((cls) => cls.file))];
|
|
80
|
+
if (uncovered.length > 0) {
|
|
81
|
+
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(', ')}; ` +
|
|
82
|
+
`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))}`);
|
|
83
|
+
}
|
|
77
84
|
const content = this.renderer.render(emit_1.BUNDLE_PROTOCOL, (0, emit_1.bundleView)({
|
|
78
|
-
name: config.
|
|
79
|
-
|
|
80
|
-
classes,
|
|
85
|
+
name: config.bundleClassName,
|
|
86
|
+
paths: config.glob.paths.map((entry) => entry.path),
|
|
87
|
+
classes: classes.map((cls) => ({ ...cls, specifier: cls.specifier })),
|
|
81
88
|
}));
|
|
82
|
-
return {
|
|
89
|
+
return { content, registrations: classes.length, warnings: (0, tokenCollisions_1.tokenCollisions)(classes) };
|
|
83
90
|
}
|
|
84
91
|
};
|
|
85
92
|
exports.BundleBuilder = BundleBuilder;
|
|
@@ -15,54 +15,33 @@ 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.TicConfigService = exports.ITicConfigServiceKey =
|
|
18
|
+
exports.TicConfigService = exports.ITicConfigServiceKey = 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 yaml_1 = require("yaml");
|
|
22
|
-
const GlobalConfig_1 = require("../../../domain/GlobalConfig");
|
|
23
21
|
const DomainException_1 = require("../../../exceptions/DomainException");
|
|
24
22
|
const NodeFileSystemService_1 = require("../../../services/NodeFileSystemService");
|
|
25
23
|
const BuildConfig_1 = require("../BuildConfig");
|
|
26
|
-
const configFiles_1 = require("../domain/configFiles");
|
|
27
|
-
exports.TSCONFIG_FILE = 'tsconfig.json';
|
|
28
24
|
exports.ITicConfigServiceKey = new ts_ioc_container_1.SingleToken('ITicConfigService');
|
|
29
25
|
let TicConfigService = class TicConfigService {
|
|
30
|
-
cwd;
|
|
31
26
|
fs;
|
|
32
|
-
constructor(
|
|
33
|
-
this.cwd = cwd;
|
|
27
|
+
constructor(fs) {
|
|
34
28
|
this.fs = fs;
|
|
35
29
|
}
|
|
36
30
|
load(file) {
|
|
31
|
+
const format = (0, BuildConfig_1.configFormat)(file);
|
|
32
|
+
if (format === undefined)
|
|
33
|
+
throw new DomainException_1.TicConfigError(`expected a .json, .yaml or .yml config file: ${file}`);
|
|
37
34
|
if (!this.fs.fileExists(file))
|
|
38
35
|
throw new DomainException_1.TicConfigError(`config file not found: ${file}`);
|
|
39
|
-
return (0, BuildConfig_1.resolveConfig)(
|
|
36
|
+
return (0, BuildConfig_1.resolveConfig)((0, BuildConfig_1.parseConfig)(this.fs.readFile(file), format), file);
|
|
40
37
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return named.map((config) => node_path_1.default.resolve(this.cwd, config));
|
|
44
|
-
const root = (0, configFiles_1.findPackageRoot)(this.cwd);
|
|
45
|
-
const found = (0, configFiles_1.findConfigFiles)(root);
|
|
46
|
-
if (found.length > 0)
|
|
47
|
-
return found;
|
|
48
|
-
if (this.fs.fileExists(node_path_1.default.join(root, exports.TSCONFIG_FILE)))
|
|
49
|
-
return [undefined];
|
|
50
|
-
throw new DomainException_1.TicConfigError(`no *.bundle.{json,yaml,yml} or ${exports.TSCONFIG_FILE} in ${root}; name a config with --config`);
|
|
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));
|
|
51
40
|
}
|
|
52
41
|
};
|
|
53
42
|
exports.TicConfigService = TicConfigService;
|
|
54
43
|
exports.TicConfigService = TicConfigService = __decorate([
|
|
55
44
|
(0, ts_ioc_container_1.register)(exports.ITicConfigServiceKey),
|
|
56
|
-
__param(0, (0, ts_ioc_container_1.inject)((0,
|
|
57
|
-
|
|
58
|
-
__metadata("design:paramtypes", [String, Object])
|
|
45
|
+
__param(0, (0, ts_ioc_container_1.inject)((0, ts_ioc_container_1.by)(NodeFileSystemService_1.IFileSystemServiceKey))),
|
|
46
|
+
__metadata("design:paramtypes", [Object])
|
|
59
47
|
], TicConfigService);
|
|
60
|
-
function parseConfig(file, text) {
|
|
61
|
-
const yaml = file.endsWith('.yaml') || file.endsWith('.yml');
|
|
62
|
-
try {
|
|
63
|
-
return yaml ? ((0, yaml_1.parse)(text) ?? {}) : JSON.parse(text);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
throw new DomainException_1.TicConfigError(`${file} is not valid ${yaml ? 'YAML' : 'JSON'}: ${e.message}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
package/cjm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ILoggerKey = exports.StdOutputService = exports.IOutputServiceKey = exports.CommonModule = exports.HelpModule = exports.globToRegExp = exports.tokenCollisions = exports.GENERATED_HEADER = exports.BUNDLE_PROTOCOL = exports.bundleView = exports.emitBundle = exports.isSourceFile = exports.findClasses = exports.
|
|
4
|
-
exports.ExceptionHandler = exports.
|
|
3
|
+
exports.ILoggerKey = exports.StdOutputService = exports.IOutputServiceKey = exports.CommonModule = exports.HelpModule = exports.globToRegExp = exports.tokenCollisions = exports.GENERATED_HEADER = exports.BUNDLE_PROTOCOL = exports.bundleView = exports.emitBundle = 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.BUNDLE_CONFIG_SCHEMA = exports.resolveConfig = exports.ITicConfigServiceKey = exports.TicConfigService = exports.IBundleBuilderKey = exports.BundleBuilder = exports.BUILD_OPTIONS = exports.BuildController = 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 = 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; } });
|
|
@@ -33,28 +33,27 @@ Object.defineProperty(exports, "IBundleBuilderKey", { enumerable: true, get: fun
|
|
|
33
33
|
var TicConfigService_1 = require("./features/build/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
|
-
Object.defineProperty(exports, "TSCONFIG_FILE", { enumerable: true, get: function () { return TicConfigService_1.TSCONFIG_FILE; } });
|
|
37
36
|
var BuildConfig_1 = require("./features/build/BuildConfig");
|
|
38
37
|
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return BuildConfig_1.resolveConfig; } });
|
|
39
38
|
Object.defineProperty(exports, "BUNDLE_CONFIG_SCHEMA", { enumerable: true, get: function () { return BuildConfig_1.BUNDLE_CONFIG_SCHEMA; } });
|
|
39
|
+
Object.defineProperty(exports, "parseConfig", { enumerable: true, get: function () { return BuildConfig_1.parseConfig; } });
|
|
40
40
|
Object.defineProperty(exports, "CONFIG_FILE_SUFFIXES", { enumerable: true, get: function () { return BuildConfig_1.CONFIG_FILE_SUFFIXES; } });
|
|
41
|
-
Object.defineProperty(exports, "
|
|
41
|
+
Object.defineProperty(exports, "STDIN", { enumerable: true, get: function () { return BuildConfig_1.STDIN; } });
|
|
42
|
+
Object.defineProperty(exports, "configFormat", { enumerable: true, get: function () { return BuildConfig_1.configFormat; } });
|
|
43
|
+
Object.defineProperty(exports, "DEFAULT_TSCONFIG", { enumerable: true, get: function () { return BuildConfig_1.DEFAULT_TSCONFIG; } });
|
|
42
44
|
Object.defineProperty(exports, "DEFAULT_EXCLUDE", { enumerable: true, get: function () { return BuildConfig_1.DEFAULT_EXCLUDE; } });
|
|
43
|
-
Object.defineProperty(exports, "DEFAULT_BUNDLE_NAME", { enumerable: true, get: function () { return BuildConfig_1.DEFAULT_BUNDLE_NAME; } });
|
|
44
45
|
Object.defineProperty(exports, "DEFAULT_DECORATORS", { enumerable: true, get: function () { return BuildConfig_1.DEFAULT_DECORATORS; } });
|
|
45
46
|
Object.defineProperty(exports, "toClassName", { enumerable: true, get: function () { return BuildConfig_1.toClassName; } });
|
|
46
|
-
var configFiles_1 = require("./features/build/domain/configFiles");
|
|
47
|
-
Object.defineProperty(exports, "findConfigFiles", { enumerable: true, get: function () { return configFiles_1.findConfigFiles; } });
|
|
48
|
-
Object.defineProperty(exports, "findPackageRoot", { enumerable: true, get: function () { return configFiles_1.findPackageRoot; } });
|
|
49
47
|
var ticConfigSchema_1 = require("./schema/ticConfigSchema");
|
|
50
48
|
Object.defineProperty(exports, "ticConfigJsonSchema", { enumerable: true, get: function () { return ticConfigSchema_1.ticConfigJsonSchema; } });
|
|
51
49
|
var ImportPaths_1 = require("./features/build/domain/ImportPaths");
|
|
52
50
|
Object.defineProperty(exports, "ImportPaths", { enumerable: true, get: function () { return ImportPaths_1.ImportPaths; } });
|
|
53
51
|
var tsconfig_1 = require("./features/build/domain/tsconfig");
|
|
54
|
-
Object.defineProperty(exports, "
|
|
52
|
+
Object.defineProperty(exports, "loadImportPaths", { enumerable: true, get: function () { return tsconfig_1.loadImportPaths; } });
|
|
55
53
|
var scan_1 = require("./features/build/domain/scan");
|
|
56
54
|
Object.defineProperty(exports, "findClasses", { enumerable: true, get: function () { return scan_1.findClasses; } });
|
|
57
55
|
Object.defineProperty(exports, "isSourceFile", { enumerable: true, get: function () { return scan_1.isSourceFile; } });
|
|
56
|
+
Object.defineProperty(exports, "listSourceFiles", { enumerable: true, get: function () { return scan_1.listSourceFiles; } });
|
|
58
57
|
var emit_1 = require("./features/build/domain/emit");
|
|
59
58
|
Object.defineProperty(exports, "emitBundle", { enumerable: true, get: function () { return emit_1.emitBundle; } });
|
|
60
59
|
Object.defineProperty(exports, "bundleView", { enumerable: true, get: function () { return emit_1.bundleView; } });
|
|
@@ -84,10 +83,10 @@ Object.defineProperty(exports, "renderProtocol", { enumerable: true, get: functi
|
|
|
84
83
|
var DomainException_1 = require("./exceptions/DomainException");
|
|
85
84
|
Object.defineProperty(exports, "TicError", { enumerable: true, get: function () { return DomainException_1.TicError; } });
|
|
86
85
|
Object.defineProperty(exports, "TicConfigError", { enumerable: true, get: function () { return DomainException_1.TicConfigError; } });
|
|
86
|
+
Object.defineProperty(exports, "NamespaceNotFoundError", { enumerable: true, get: function () { return DomainException_1.NamespaceNotFoundError; } });
|
|
87
87
|
Object.defineProperty(exports, "MissingCommandError", { enumerable: true, get: function () { return DomainException_1.MissingCommandError; } });
|
|
88
88
|
Object.defineProperty(exports, "UnknownCommandError", { enumerable: true, get: function () { return DomainException_1.UnknownCommandError; } });
|
|
89
89
|
Object.defineProperty(exports, "UnknownActionError", { enumerable: true, get: function () { return DomainException_1.UnknownActionError; } });
|
|
90
90
|
Object.defineProperty(exports, "UsageError", { enumerable: true, get: function () { return DomainException_1.UsageError; } });
|
|
91
|
-
Object.defineProperty(exports, "StaleBundlesError", { enumerable: true, get: function () { return DomainException_1.StaleBundlesError; } });
|
|
92
91
|
var ExceptionHandler_1 = require("./exceptions/ExceptionHandler");
|
|
93
92
|
Object.defineProperty(exports, "ExceptionHandler", { enumerable: true, get: function () { return ExceptionHandler_1.ExceptionHandler; } });
|
|
@@ -8,13 +8,17 @@ function ticConfigJsonSchema() {
|
|
|
8
8
|
io: 'input',
|
|
9
9
|
target: 'draft-7',
|
|
10
10
|
unrepresentable: 'any',
|
|
11
|
+
override: ({ jsonSchema }) => {
|
|
12
|
+
if (jsonSchema.type === 'object')
|
|
13
|
+
jsonSchema.additionalProperties = false;
|
|
14
|
+
},
|
|
11
15
|
});
|
|
12
16
|
const { $schema, ...rest } = schema;
|
|
13
17
|
return {
|
|
14
18
|
$schema,
|
|
15
19
|
$id: 'https://github.com/IgorBabkin/ts-ioc-container/tree/main/packages/bundler/tic.schema.json',
|
|
16
20
|
title: '*.bundle.json / *.bundle.yaml',
|
|
17
|
-
description: "One bundle generated by `tic build` (@ts-ioc-container/bundler). `tic build
|
|
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).",
|
|
18
22
|
...rest,
|
|
19
23
|
};
|
|
20
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-ioc-container/bundler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.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": "
|
|
55
|
+
"ts-ioc-container": "76.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"typescript": ">=5"
|
package/tic.schema.json
CHANGED
|
@@ -2,124 +2,157 @@
|
|
|
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
|
|
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).",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"$schema": {
|
|
9
9
|
"type": "string"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"description": "The tsconfig this bundle extends, as a tsconfig's own `extends`: its file set, `paths` aliases and module resolution apply unless this file overrides them. Relative to this file. The default may be absent; a tsconfig named here must exist.",
|
|
14
|
-
"type": "string",
|
|
15
|
-
"minLength": 1
|
|
16
|
-
},
|
|
17
|
-
"baseUrl": {
|
|
18
|
-
"description": "The base folder this config's relative `include`, `exclude` and `output` resolve against, so they need not repeat a shared prefix such as `src`. Relative to this file; default this file's directory. Also handed to TypeScript as `compilerOptions.baseUrl` (unless that is set too), so generated imports use it.",
|
|
11
|
+
"name": {
|
|
12
|
+
"description": "The bundle's name: letters, digits, \"-\" and \"_\", starting with a letter. Default: the config file's stem (production.bundle.json → production); required for a config file named otherwise. It names the generated IContainerModule class (ProductionBundle).",
|
|
19
13
|
"type": "string",
|
|
20
|
-
"
|
|
14
|
+
"pattern": "^[A-Za-z][\\w-]*$"
|
|
21
15
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
16
|
+
"tsconfig": {
|
|
17
|
+
"default": "./tsconfig.json",
|
|
18
|
+
"description": "The tsconfig whose `paths` aliases glob.paths may name and generated imports are written in, and whose module resolution sets the import extension. It adds no files: the bundle scans glob.paths alone. Relative to the config file. The default may be absent; a tsconfig named here must exist.",
|
|
24
19
|
"type": "string",
|
|
25
20
|
"minLength": 1
|
|
26
21
|
},
|
|
27
|
-
"
|
|
28
|
-
"description": "
|
|
29
|
-
"type": "string"
|
|
30
|
-
"pattern": "^[A-Za-z][\\w-]*$"
|
|
31
|
-
},
|
|
32
|
-
"include": {
|
|
33
|
-
"description": "tsconfig `include`: replaces the extended tsconfig's. Relative to `baseUrl`. When `baseUrl` is set and this is omitted, the whole `baseUrl` folder (`.`) is scanned.",
|
|
34
|
-
"type": "array",
|
|
35
|
-
"items": {
|
|
36
|
-
"type": "string",
|
|
37
|
-
"minLength": 1
|
|
38
|
-
}
|
|
22
|
+
"importExtension": {
|
|
23
|
+
"description": "Extension of generated imports, e.g. \".js\". Inferred from the tsconfig: \".js\" under node16/nodenext resolution, none otherwise.",
|
|
24
|
+
"type": "string"
|
|
39
25
|
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
"glob": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"paths": {
|
|
30
|
+
"minItems": 1,
|
|
31
|
+
"type": "array",
|
|
32
|
+
"items": {
|
|
33
|
+
"anyOf": [
|
|
34
|
+
{
|
|
35
|
+
"type": "string",
|
|
36
|
+
"minLength": 1
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"path": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"minLength": 1
|
|
44
|
+
},
|
|
45
|
+
"recursive": {
|
|
46
|
+
"default": true,
|
|
47
|
+
"type": "boolean"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"required": [
|
|
51
|
+
"path"
|
|
52
|
+
],
|
|
53
|
+
"additionalProperties": false
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"description": "Folders to scan: paths relative to the config file (./src/services) or tsconfig paths aliases (@app/services). Sub-folders are scanned too unless an entry says { \"path\": \"...\", \"recursive\": false }."
|
|
58
|
+
},
|
|
59
|
+
"include": {
|
|
60
|
+
"description": "Globs a file must match one of, e.g. [\"**/*.service.ts\", \"**/*.repository.ts\"]. Default: every source file.",
|
|
61
|
+
"type": "array",
|
|
62
|
+
"items": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"minLength": 1
|
|
65
|
+
},
|
|
66
|
+
"minItems": 1
|
|
67
|
+
},
|
|
68
|
+
"exclude": {
|
|
69
|
+
"default": [
|
|
70
|
+
"**/*.spec.ts",
|
|
71
|
+
"**/*.test.ts",
|
|
72
|
+
"**/*.spec.tsx",
|
|
73
|
+
"**/*.test.tsx",
|
|
74
|
+
"**/__tests__/**",
|
|
75
|
+
"**/node_modules/**"
|
|
76
|
+
],
|
|
77
|
+
"description": "Globs of files never read. Replaces the default when given. A non-empty list that omits a default glob makes `tic build` warn.",
|
|
78
|
+
"type": "array",
|
|
79
|
+
"items": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"minLength": 1
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"required": [
|
|
86
|
+
"paths"
|
|
87
|
+
],
|
|
88
|
+
"additionalProperties": false,
|
|
89
|
+
"description": "Which files this bundle reads and parses — decided by path alone, before parsing. `paths` are the folders the files come from; within them a file is parsed when it matches one of `include` and none of `exclude`. Globs are relative to the config file. With a file naming convention, `include` keeps every other file unread."
|
|
47
90
|
},
|
|
48
|
-
"
|
|
91
|
+
"className": {
|
|
49
92
|
"type": "object",
|
|
50
93
|
"properties": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
94
|
+
"export": {
|
|
95
|
+
"default": "any",
|
|
96
|
+
"description": "Which exports count.",
|
|
97
|
+
"type": "string",
|
|
98
|
+
"enum": [
|
|
99
|
+
"any",
|
|
100
|
+
"named",
|
|
101
|
+
"default"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"decorators": {
|
|
105
|
+
"default": [
|
|
106
|
+
"register"
|
|
107
|
+
],
|
|
108
|
+
"description": "The class must carry one of these decorators, recognised by name (e.g. \"register\", or a composed decorator). Default [\"register\"]; [] requires none.",
|
|
109
|
+
"type": "array",
|
|
110
|
+
"items": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"minLength": 1
|
|
113
|
+
}
|
|
54
114
|
},
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
"default": "any",
|
|
60
|
-
"description": "Which exports count.",
|
|
115
|
+
"glob": {
|
|
116
|
+
"description": "Glob, or globs, the class name must match one of, e.g. \"*Service\" or [\"*Service\", \"*Repository\"]. An anonymous default export is named after its file.",
|
|
117
|
+
"anyOf": [
|
|
118
|
+
{
|
|
61
119
|
"type": "string",
|
|
62
|
-
"
|
|
63
|
-
"any",
|
|
64
|
-
"named",
|
|
65
|
-
"default"
|
|
66
|
-
]
|
|
120
|
+
"minLength": 1
|
|
67
121
|
},
|
|
68
|
-
|
|
69
|
-
"default": [
|
|
70
|
-
"register"
|
|
71
|
-
],
|
|
72
|
-
"description": "The class must carry one of these decorators, recognised by name (e.g. \"register\", or a composed decorator). Default [\"register\"]; [] requires none.",
|
|
122
|
+
{
|
|
73
123
|
"type": "array",
|
|
74
124
|
"items": {
|
|
75
125
|
"type": "string",
|
|
76
126
|
"minLength": 1
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
127
|
+
},
|
|
128
|
+
"minItems": 1
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"exclude": {
|
|
133
|
+
"description": "Glob, or globs, the class name must match none of, applied after every other criterion. A plain name is a glob too: [\"MockUserRepository\", \"*Fake\"].",
|
|
134
|
+
"anyOf": [
|
|
135
|
+
{
|
|
81
136
|
"type": "string",
|
|
82
137
|
"minLength": 1
|
|
83
138
|
},
|
|
84
|
-
|
|
85
|
-
"description": "Class names to drop after selection, e.g. one test double sitting next to the real registration in the same file.",
|
|
139
|
+
{
|
|
86
140
|
"type": "array",
|
|
87
141
|
"items": {
|
|
88
142
|
"type": "string",
|
|
89
143
|
"minLength": 1
|
|
90
144
|
},
|
|
91
145
|
"minItems": 1
|
|
92
|
-
},
|
|
93
|
-
"excludeName": {
|
|
94
|
-
"description": "Glob the class name must NOT match, e.g. \"*Mock\". An anonymous default export is named after its file.",
|
|
95
|
-
"type": "string",
|
|
96
|
-
"minLength": 1
|
|
97
146
|
}
|
|
98
|
-
|
|
99
|
-
"additionalProperties": false,
|
|
100
|
-
"description": "Which classes of a scanned 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."
|
|
101
|
-
},
|
|
102
|
-
"paths": {
|
|
103
|
-
"description": "tsconfig `paths`: aliases the generated imports are written in.",
|
|
104
|
-
"type": "object",
|
|
105
|
-
"propertyNames": {
|
|
106
|
-
"type": "string"
|
|
107
|
-
},
|
|
108
|
-
"additionalProperties": {
|
|
109
|
-
"type": "array",
|
|
110
|
-
"items": {
|
|
111
|
-
"type": "string"
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"rootDir": {
|
|
116
|
-
"description": "tsconfig `rootDir`: where the default output (<rootDir>/<name>.bundle.ts) goes.",
|
|
117
|
-
"type": "string"
|
|
147
|
+
]
|
|
118
148
|
}
|
|
119
149
|
},
|
|
120
|
-
"additionalProperties":
|
|
121
|
-
"description": "
|
|
150
|
+
"additionalProperties": false,
|
|
151
|
+
"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."
|
|
122
152
|
}
|
|
123
153
|
},
|
|
154
|
+
"required": [
|
|
155
|
+
"glob"
|
|
156
|
+
],
|
|
124
157
|
"additionalProperties": false
|
|
125
158
|
}
|