@ts-ioc-container/bundler 1.5.0 → 2.1.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 +47 -31
- package/README.md +157 -280
- package/cjm/app.js +39 -0
- package/cjm/bin.js +2 -2
- package/cjm/cli/Application.js +58 -0
- package/cjm/cli/IErrorHandler.js +5 -0
- package/cjm/cli/decorators.js +9 -0
- package/cjm/cli/index.js +17 -0
- package/cjm/cli/options.js +25 -0
- package/cjm/cli/usage.js +19 -0
- package/cjm/domain/CliIo.js +7 -0
- package/cjm/domain/GlobalConfig.js +7 -0
- package/cjm/exceptions/DomainException.js +54 -0
- package/cjm/exceptions/ExceptionHandler.js +38 -0
- package/cjm/features/build/BuildConfig.js +183 -0
- package/cjm/features/build/BuildController.js +91 -0
- package/cjm/features/build/BuildModule.js +16 -0
- package/cjm/{ImportPaths.js → features/build/domain/ImportPaths.js} +7 -29
- package/cjm/features/build/domain/configFiles.js +35 -0
- package/cjm/{emit.js → features/build/domain/emit.js} +10 -9
- package/cjm/{scan.js → features/build/domain/scan.js} +6 -3
- package/cjm/features/build/domain/tokenCollisions.js +29 -0
- package/cjm/features/build/domain/tsconfig.js +78 -0
- package/cjm/features/build/services/BundleBuilder.js +116 -0
- package/cjm/features/build/services/TicConfigService.js +68 -0
- package/cjm/features/help/HelpController.js +39 -0
- package/cjm/features/help/HelpModule.js +12 -0
- package/cjm/features/help/VersionController.js +45 -0
- package/cjm/index.js +87 -28
- package/cjm/modules/CommonModule.js +28 -0
- package/cjm/schema/ticConfigSchema.js +24 -0
- package/cjm/services/ConsoleLogger.js +36 -0
- package/cjm/services/HandlebarsRenderService.js +33 -0
- package/cjm/services/NodeFileSystemService.js +32 -0
- package/cjm/services/OutputService.js +33 -0
- package/package.json +10 -7
- package/tic.schema.json +118 -147
- package/tpl/index.cjs +36 -16
- package/typings/app.d.ts +24 -0
- package/typings/cli/Application.d.ts +16 -0
- package/typings/cli/Application.d.ts.map +1 -0
- package/typings/cli/IErrorHandler.d.ts +7 -0
- package/typings/cli/IErrorHandler.d.ts.map +1 -0
- package/typings/cli/decorators.d.ts +10 -0
- package/typings/cli/decorators.d.ts.map +1 -0
- package/typings/cli/index.d.ts +6 -0
- package/typings/cli/index.d.ts.map +1 -0
- package/typings/cli/options.d.ts +23 -0
- package/typings/cli/options.d.ts.map +1 -0
- package/typings/cli/usage.d.ts +2 -0
- package/typings/cli/usage.d.ts.map +1 -0
- package/typings/domain/CliIo.d.ts +10 -0
- package/typings/domain/CliIo.d.ts.map +1 -0
- package/typings/domain/GlobalConfig.d.ts +10 -0
- package/typings/domain/GlobalConfig.d.ts.map +1 -0
- package/typings/exceptions/DomainException.d.ts +37 -0
- package/typings/exceptions/DomainException.d.ts.map +1 -0
- package/typings/exceptions/ExceptionHandler.d.ts +12 -0
- package/typings/exceptions/ExceptionHandler.d.ts.map +1 -0
- package/typings/features/build/BuildConfig.d.ts +179 -0
- package/typings/features/build/BuildConfig.d.ts.map +1 -0
- package/typings/features/build/BuildController.d.ts +32 -0
- package/typings/features/build/BuildController.d.ts.map +1 -0
- package/typings/features/build/BuildModule.d.ts +5 -0
- package/typings/features/build/BuildModule.d.ts.map +1 -0
- package/typings/{ImportPaths.d.ts → features/build/domain/ImportPaths.d.ts} +4 -16
- package/typings/features/build/domain/ImportPaths.d.ts.map +1 -0
- package/typings/features/build/domain/configFiles.d.ts +13 -0
- package/typings/features/build/domain/configFiles.d.ts.map +1 -0
- package/typings/features/build/domain/emit.d.ts +42 -0
- package/typings/features/build/domain/emit.d.ts.map +1 -0
- package/typings/features/build/domain/glob.d.ts.map +1 -0
- package/typings/{scan.d.ts → features/build/domain/scan.d.ts} +4 -2
- package/typings/features/build/domain/scan.d.ts.map +1 -0
- package/typings/features/build/domain/tokenCollisions.d.ts +14 -0
- package/typings/features/build/domain/tokenCollisions.d.ts.map +1 -0
- package/typings/features/build/domain/tsconfig.d.ts +25 -0
- package/typings/features/build/domain/tsconfig.d.ts.map +1 -0
- package/typings/features/build/services/BundleBuilder.d.ts +68 -0
- package/typings/features/build/services/BundleBuilder.d.ts.map +1 -0
- package/typings/features/build/services/TicConfigService.d.ts +37 -0
- package/typings/features/build/services/TicConfigService.d.ts.map +1 -0
- package/typings/features/help/HelpController.d.ts +8 -0
- package/typings/features/help/HelpController.d.ts.map +1 -0
- package/typings/features/help/HelpModule.d.ts +5 -0
- package/typings/features/help/HelpModule.d.ts.map +1 -0
- package/typings/features/help/VersionController.d.ts +8 -0
- package/typings/features/help/VersionController.d.ts.map +1 -0
- package/typings/index.d.ts +25 -11
- package/typings/modules/CommonModule.d.ts +9 -0
- package/typings/modules/CommonModule.d.ts.map +1 -0
- package/typings/schema/ticConfigSchema.d.ts +7 -0
- package/typings/schema/ticConfigSchema.d.ts.map +1 -0
- package/typings/services/ConsoleLogger.d.ts +20 -0
- package/typings/services/ConsoleLogger.d.ts.map +1 -0
- package/typings/services/HandlebarsRenderService.d.ts +23 -0
- package/typings/services/HandlebarsRenderService.d.ts.map +1 -0
- package/typings/services/NodeFileSystemService.d.ts +21 -0
- package/typings/services/NodeFileSystemService.d.ts.map +1 -0
- package/typings/services/OutputService.d.ts +13 -0
- package/typings/services/OutputService.d.ts.map +1 -0
- package/cjm/build.js +0 -132
- package/cjm/cli.js +0 -84
- package/cjm/config.js +0 -162
- package/cjm/errors.js +0 -15
- package/cjm/exportPredicate.js +0 -13
- package/cjm/inclusion.js +0 -24
- package/cjm/predicateFile.js +0 -30
- package/cjm/render.js +0 -15
- package/cjm/utils.js +0 -2
- package/typings/build.d.ts +0 -45
- package/typings/cli.d.ts +0 -8
- package/typings/config.d.ts +0 -123
- package/typings/emit.d.ts +0 -18
- package/typings/errors.d.ts +0 -13
- package/typings/exportPredicate.d.ts +0 -36
- package/typings/inclusion.d.ts +0 -42
- package/typings/predicateFile.d.ts +0 -16
- package/typings/render.d.ts +0 -8
- package/typings/utils.d.ts +0 -3
- /package/cjm/{glob.js → features/build/domain/glob.js} +0 -0
- /package/typings/{glob.d.ts → features/build/domain/glob.d.ts} +0 -0
package/AGENTS.md
CHANGED
|
@@ -7,40 +7,56 @@ nothing here runs inside the container, and the core package is not changed by
|
|
|
7
7
|
it.
|
|
8
8
|
|
|
9
9
|
- The CLI is `ts-ioc-container`, with `tic` as a shortcut (both `bin` entries,
|
|
10
|
-
same program).
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
same program). One config file describes one bundle: `<name>.bundle.json`, or the same in
|
|
11
|
+
YAML as `<name>.bundle.yaml` / `.yml` (an empty YAML file = all defaults)
|
|
12
|
+
(schema: `tic.schema.json`), flat — `output`, `name`, `tags`, `extends`,
|
|
13
|
+
`importExtension`, `files`, `classes`, all optional. `tic build` works on
|
|
14
|
+
the package it is invoked in (nearest `package.json` up from the working
|
|
15
|
+
directory; never a workspace root): it builds every `*.bundle.{json,yaml,yml}` there
|
|
16
|
+
(or the ones named with repeatable `-c`), else — zero config — one bundle
|
|
17
|
+
from that package's `tsconfig.json` with every default. Each writes one class — `export class AppBundle implements IContainerModule`,
|
|
18
|
+
applied with `container.useModule(new AppBundle())`. Several bundles (e.g.
|
|
19
|
+
`production.bundle.json`, `development.bundle.json`) mean several configs.
|
|
20
|
+
`--check` writes nothing and exits 1 when an output is stale — run it in CI.
|
|
21
|
+
- A config `extends` a tsconfig (default `./tsconfig.json`, may be absent; one
|
|
22
|
+
named explicitly must exist), like a child tsconfig: what it compiles is the
|
|
23
|
+
bundle's file set, and its `paths` aliases and module resolution shape the
|
|
24
|
+
generated imports (most specific alias, else a relative path). `output`
|
|
25
|
+
defaults to `<root>/<name>.bundle.ts`: root = tsconfig `rootDir`, else the
|
|
26
|
+
common folder of its files. `name` defaults to the config's stem
|
|
27
|
+
(`production.bundle.json` → `production`), else `base`; the class is
|
|
28
|
+
`toClassName(name)` — `ProductionBundle`, `BaseBundle`.
|
|
29
|
+
- Selection has two stages. `files: { paths, include, exclude }` decides by path
|
|
30
|
+
which files are read and parsed at all. `paths` override the tsconfig's file
|
|
31
|
+
set with folders (relative to the config, or tsconfig aliases); required when
|
|
32
|
+
there is no tsconfig. A candidate must match one of `include` (default: all)
|
|
33
|
+
and none of `exclude` (default: test files, `__tests__/`, `node_modules/`; a
|
|
34
|
+
non-empty list replaces it, and the build warns if it drops a default). Globs
|
|
35
|
+
are relative to the config. With file naming conventions, `include` is the
|
|
36
|
+
speed lever — nothing else is read. Files `tic build` generated are never input.
|
|
37
|
+
- `classes: { export, decorators, name, excludeClasses, excludeName }`
|
|
38
|
+
then picks classes of the parsed files; default is every exported,
|
|
39
|
+
non-abstract class decorated with `@register` (`decorators` defaults to
|
|
40
|
+
`["register"]`; `[]` requires none); positive criteria must all hold and then `excludeClasses` (exact
|
|
41
|
+
names) and `excludeName` (glob) drop classes.
|
|
20
42
|
Decorators match by name, so composed ones must be listed. The build warns when
|
|
21
43
|
two selected classes pass the same plain-identifier first decorator argument (a
|
|
22
44
|
same-token heuristic), unless a decorator they share has differing arguments
|
|
23
45
|
(scope-gated, e.g. `@perPage('a')` vs `@perPage('b')`).
|
|
24
46
|
- Never edit a `*.bundle.ts` by hand — change the classes or the config and
|
|
25
47
|
rerun `tic build`.
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`
|
|
41
|
-
- For a lean production build, the production entry must import only the
|
|
42
|
-
production bundle (README "One bundle per environment"); statically importing
|
|
43
|
-
both bundles ships both.
|
|
44
|
-
- Programmatic API: `build({ config, cwd, check })`, `run(argv, io)`,
|
|
45
|
-
`loadConfig(file)`; errors are `TicConfigError` / `NamespaceNotFoundError`
|
|
46
|
-
(both `TicError`).
|
|
48
|
+
- Unknown config fields are errors, at every level.
|
|
49
|
+
- Programmatic API: `build({ config, cwd, check })` (one config, one output),
|
|
50
|
+
`findConfigFiles(dir)`, `run(argv, io)`, `loadConfig(file)`; every error the
|
|
51
|
+
bundler raises on purpose is a `TicError` with a stable `code`
|
|
52
|
+
(`TicConfigError` = `INVALID_CONFIG`, `NamespaceNotFoundError`, `UsageError`,
|
|
53
|
+
`StaleBundlesError`, …).
|
|
54
|
+
- Internals follow `release-monorepo-semantically` (ADR 0023): `createContainer(io)`
|
|
55
|
+
in `lib/app.ts` is the composition root; `Application` resolves the controller
|
|
56
|
+
registered under the command name (`@register('build')`) and runs its
|
|
57
|
+
`@onDefault(invoke)` action, which parses its own options with
|
|
58
|
+
`@inject(pipe(commandArgs, parseOptions(spec), validate(SCHEMA)))`. Work lives in
|
|
59
|
+
services behind tokens (`IBundleBuilderKey`, `ITicConfigServiceKey`, …); pure
|
|
60
|
+
logic in `lib/features/build/domain/`. A new command is a controller plus a module.
|
|
61
|
+
- The config schema is `BUNDLE_CONFIG_SCHEMA` (zod); `tic.schema.json` is generated
|
|
62
|
+
from it with `pnpm run generate:schema` — never edit it by hand.
|