@ts-ioc-container/bundler 8.1.0 → 8.3.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 CHANGED
@@ -14,8 +14,9 @@ it.
14
14
  prints the bundle to **stdout**; it writes nothing. Saving is the shell's
15
15
  job: `tic build app.bundle.json > src/di/app.bundle.ts`,
16
16
  `cat dev.bundle.json | tic build > src/di/dev.bundle.ts`; CI checks with
17
- `tic build app.bundle.json | diff - src/di/app.bundle.ts`. Warnings and errors
18
- go to stderr. The bundle is `export class AppBundle implements
17
+ `tic build app.bundle.json | diff - src/di/app.bundle.ts`. Progress (each
18
+ bundled class as ` Name: path`, then a `Bundled …` summary), warnings and
19
+ errors go to stderr. The bundle is `export class AppBundle implements
19
20
  IContainerModule`, applied with `container.useModule(new AppBundle())`.
20
21
  - Every import in a bundle is written through a tsconfig `paths` alias, so the
21
22
  bundle works wherever it is saved; a selected class no alias covers fails the
package/README.md CHANGED
@@ -39,8 +39,15 @@ tic build [<config>...]
39
39
  `tic build` prints the bundle to **stdout** and writes nothing. `<config>` is a
40
40
  config file — JSON for `.json`, YAML for `.yaml` / `.yml`. Several are
41
41
  [merged](#merging-configs) left to right into one bundle. Without one (or with
42
- `-`) the config is read from **stdin**. Warnings and errors go to stderr, so
43
- they never end up in the bundle.
42
+ `-`) the config is read from **stdin**. Progress, warnings and errors go to
43
+ stderr, so they never end up in the bundle:
44
+
45
+ ```text
46
+ Bundling AppBundle...
47
+ Clock: src/infra/Clock.ts
48
+ Greeter: src/services/Greeter.ts
49
+ Bundled AppBundle: 2 dependencies from 2 files
50
+ ```
44
51
 
45
52
  ```bash
46
53
  # a config file in, the bundle saved by the shell
package/cjm/cli/usage.js CHANGED
@@ -16,7 +16,7 @@ exports.USAGE = [
16
16
  ' -h, --help show this help',
17
17
  ' -v, --version show the version',
18
18
  '',
19
- 'The bundle goes to stdout; the classes in it (name and file) and warnings to stderr.',
19
+ 'The bundle goes to stdout; progress (the classes in it and a summary) and warnings to stderr.',
20
20
  'Saving it is up to you:',
21
21
  ' tic build app.bundle.json > src/di/app.bundle.ts',
22
22
  ' tic build common.bundle.yml prod.bundle.yml > src/di/prod.bundle.ts # merged left to right',
@@ -40,6 +40,7 @@ exports.BUILD_OPTIONS = zod_1.z.object({ positionals: zod_1.z.array(zod_1.z.stri
40
40
  return { configs: positionals.length > 0 ? positionals : [BuildConfig_1.STDIN] };
41
41
  });
42
42
  const buildArgs = (0, cli_1.parseOptions)({}, { positionals: true });
43
+ const count = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
43
44
  let BundleController = class BundleController {
44
45
  io;
45
46
  configService;
@@ -60,13 +61,18 @@ let BundleController = class BundleController {
60
61
  const config = stdin
61
62
  ? this.configService.parse(this.stdin(), this.io.cwd)
62
63
  : this.configService.load(configs.map((file) => node_path_1.default.resolve(this.io.cwd, file)));
63
- const { content, classes, warnings } = this.bundleService.bundle(config);
64
+ this.logger.info(`Bundling ${config.bundleClassName}...`);
65
+ const { bundle, content, classes, files, warnings } = this.bundleService.bundle(config);
64
66
  for (const { file, className } of classes) {
65
- this.logger.info(`${className}: ${(0, glob_1.toPosix)(node_path_1.default.relative(this.io.cwd, file))}`);
67
+ this.logger.info(` ${className}: ${(0, glob_1.toPosix)(node_path_1.default.relative(this.io.cwd, file))}`);
66
68
  }
67
69
  for (const warning of warnings)
68
70
  this.logger.warn(`${label}: ${warning}`);
69
71
  this.output.write(content.replace(/\n$/, ''));
72
+ const summary = [count(classes.length, 'dependency', 'dependencies'), `from ${count(files.length, 'file')}`];
73
+ if (warnings.length > 0)
74
+ summary.push(`(${count(warnings.length, 'warning')})`);
75
+ this.logger.info(`Bundled ${bundle}: ${summary.join(' ')}`);
70
76
  }
71
77
  catch (e) {
72
78
  if (e instanceof DomainException_1.TicError && !(e instanceof DomainException_1.UsageError))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-ioc-container/bundler",
3
- "version": "8.1.0",
3
+ "version": "8.3.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.2"
55
+ "ts-ioc-container": "76.1.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "typescript": ">=5"
@@ -29,9 +29,10 @@ export declare class BundleController {
29
29
  * stdout. Saving it is the shell's job: `tic build app.bundle.json > src/di/app.bundle.ts`,
30
30
  * `tic build common.bundle.yml prod.bundle.yml > src/di/prod.bundle.ts`,
31
31
  * `cat app.bundle.yml | tic build > out.ts`.
32
- * The classes in the bundle, one per line as its name and its file's path relative to the
33
- * working directory (`Clock: src/infra/Clock.ts`), and warnings go to stderr, so they
34
- * never end up in the bundle; an error names the configs.
32
+ * Progress goes to stderr, so it never ends up in the bundle: `Bundling AppBundle...`, then
33
+ * each class in it, one per line as its name and its file's path relative to the working
34
+ * directory (` Clock: src/infra/Clock.ts`), the warnings, and a summary
35
+ * (`Bundled AppBundle: 3 dependencies from 2 files (1 warning)`). An error names the configs.
35
36
  *
36
37
  * @throws {UsageError} when an option is unknown, `-` is given with config files, or the config should come from stdin and nothing is piped in.
37
38
  * @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.
@@ -1 +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,CAAC;AAE1D,OAAO,EAAE,KAAK,OAAO,EAAc,M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