@ts-ioc-container/bundler 3.1.0 → 5.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.
Files changed (54) hide show
  1. package/AGENTS.md +48 -48
  2. package/README.md +199 -144
  3. package/cjm/app.js +2 -2
  4. package/cjm/cli/Application.js +4 -5
  5. package/cjm/cli/options.js +4 -2
  6. package/cjm/cli/usage.js +11 -8
  7. package/cjm/domain/CliIo.js +7 -1
  8. package/cjm/exceptions/DomainException.js +7 -7
  9. package/cjm/features/build/BuildConfig.js +126 -77
  10. package/cjm/features/build/BuildController.js +36 -46
  11. package/cjm/features/build/domain/ImportPaths.js +31 -20
  12. package/cjm/features/build/domain/emit.js +2 -2
  13. package/cjm/features/build/domain/scan.js +20 -4
  14. package/cjm/features/build/domain/tokenCollisions.js +1 -1
  15. package/cjm/features/build/domain/tsconfig.js +10 -35
  16. package/cjm/features/build/services/BundleBuilder.js +35 -30
  17. package/cjm/features/build/services/TicConfigService.js +10 -31
  18. package/cjm/index.js +9 -10
  19. package/cjm/schema/ticConfigSchema.js +5 -1
  20. package/package.json +2 -2
  21. package/tic.schema.json +132 -77
  22. package/tpl/index.cjs +15 -15
  23. package/typings/app.d.ts +7 -6
  24. package/typings/cli/Application.d.ts.map +1 -1
  25. package/typings/cli/options.d.ts +7 -1
  26. package/typings/cli/options.d.ts.map +1 -1
  27. package/typings/cli/usage.d.ts.map +1 -1
  28. package/typings/domain/CliIo.d.ts +2 -0
  29. package/typings/domain/CliIo.d.ts.map +1 -1
  30. package/typings/domain/GlobalConfig.d.ts +1 -1
  31. package/typings/domain/GlobalConfig.d.ts.map +1 -1
  32. package/typings/exceptions/DomainException.d.ts +4 -4
  33. package/typings/exceptions/DomainException.d.ts.map +1 -1
  34. package/typings/features/build/BuildConfig.d.ts +102 -102
  35. package/typings/features/build/BuildConfig.d.ts.map +1 -1
  36. package/typings/features/build/BuildController.d.ts +23 -17
  37. package/typings/features/build/BuildController.d.ts.map +1 -1
  38. package/typings/features/build/domain/ImportPaths.d.ts +16 -14
  39. package/typings/features/build/domain/ImportPaths.d.ts.map +1 -1
  40. package/typings/features/build/domain/emit.d.ts +4 -4
  41. package/typings/features/build/domain/emit.d.ts.map +1 -1
  42. package/typings/features/build/domain/scan.d.ts +2 -0
  43. package/typings/features/build/domain/scan.d.ts.map +1 -1
  44. package/typings/features/build/domain/tsconfig.d.ts +9 -16
  45. package/typings/features/build/domain/tsconfig.d.ts.map +1 -1
  46. package/typings/features/build/services/BundleBuilder.d.ts +25 -29
  47. package/typings/features/build/services/BundleBuilder.d.ts.map +1 -1
  48. package/typings/features/build/services/TicConfigService.d.ts +11 -15
  49. package/typings/features/build/services/TicConfigService.d.ts.map +1 -1
  50. package/typings/index.d.ts +6 -7
  51. package/typings/schema/ticConfigSchema.d.ts.map +1 -1
  52. package/cjm/features/build/domain/configFiles.js +0 -35
  53. package/typings/features/build/domain/configFiles.d.ts +0 -13
  54. package/typings/features/build/domain/configFiles.d.ts.map +0 -1
package/tpl/index.cjs CHANGED
@@ -10,10 +10,10 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
10
10
  };
11
11
 
12
12
  return "import "
13
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"defaultName") : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":79}}})) != null ? stack1 : "")
14
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":79},"end":{"line":4,"column":131}}})) != null ? stack1 : "")
13
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"defaultName") : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":5,"column":7},"end":{"line":5,"column":79}}})) != null ? stack1 : "")
14
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":5,"column":79},"end":{"line":5,"column":131}}})) != null ? stack1 : "")
15
15
  + " from '"
16
- + ((stack1 = ((helper = (helper = lookupProperty(helpers,"specifier") || (depth0 != null ? lookupProperty(depth0,"specifier") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"specifier","hash":{},"data":data,"loc":{"start":{"line":4,"column":138},"end":{"line":4,"column":153}}}) : helper))) != null ? stack1 : "")
16
+ + ((stack1 = ((helper = (helper = lookupProperty(helpers,"specifier") || (depth0 != null ? lookupProperty(depth0,"specifier") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"specifier","hash":{},"data":data,"loc":{"start":{"line":5,"column":138},"end":{"line":5,"column":153}}}) : helper))) != null ? stack1 : "")
17
17
  + "';\n";
18
18
  },"2":function(container,depth0,helpers,partials,data) {
19
19
  var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function(parent, propertyName) {
@@ -23,8 +23,8 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
23
23
  return undefined
24
24
  };
25
25
 
26
- return ((stack1 = ((helper = (helper = lookupProperty(helpers,"defaultName") || (depth0 != null ? lookupProperty(depth0,"defaultName") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"defaultName","hash":{},"data":data,"loc":{"start":{"line":4,"column":26},"end":{"line":4,"column":43}}}) : helper))) != null ? stack1 : "")
27
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":43},"end":{"line":4,"column":72}}})) != null ? stack1 : "");
26
+ return ((stack1 = ((helper = (helper = lookupProperty(helpers,"defaultName") || (depth0 != null ? lookupProperty(depth0,"defaultName") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"defaultName","hash":{},"data":data,"loc":{"start":{"line":5,"column":26},"end":{"line":5,"column":43}}}) : helper))) != null ? stack1 : "")
27
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":5,"column":43},"end":{"line":5,"column":72}}})) != null ? stack1 : "");
28
28
  },"3":function(container,depth0,helpers,partials,data) {
29
29
  return ", ";
30
30
  },"4":function(container,depth0,helpers,partials,data) {
@@ -36,7 +36,7 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
36
36
  };
37
37
 
38
38
  return "{ "
39
- + ((stack1 = (lookupProperty(helpers,"join")||(depth0 && lookupProperty(depth0,"join"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"named") : depth0),", ",{"name":"join","hash":{},"data":data,"loc":{"start":{"line":4,"column":101},"end":{"line":4,"column":122}}})) != null ? stack1 : "")
39
+ + ((stack1 = (lookupProperty(helpers,"join")||(depth0 && lookupProperty(depth0,"join"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"named") : depth0),", ",{"name":"join","hash":{},"data":data,"loc":{"start":{"line":5,"column":101},"end":{"line":5,"column":122}}})) != null ? stack1 : "")
40
40
  + " }";
41
41
  },"5":function(container,depth0,helpers,partials,data) {
42
42
  var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
@@ -47,7 +47,7 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
47
47
  };
48
48
 
49
49
  return "export const registrations: IRegistration[] = [\n"
50
- + ((stack1 = lookupProperty(helpers,"each").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"registrations") : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":9,"column":0},"end":{"line":11,"column":9}}})) != null ? stack1 : "")
50
+ + ((stack1 = lookupProperty(helpers,"each").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"registrations") : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":10,"column":0},"end":{"line":12,"column":9}}})) != null ? stack1 : "")
51
51
  + "];\n";
52
52
  },"6":function(container,depth0,helpers,partials,data) {
53
53
  var stack1;
@@ -58,22 +58,22 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
58
58
  },"7":function(container,depth0,helpers,partials,data) {
59
59
  return "export const registrations: IRegistration[] = [];\n";
60
60
  },"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
61
- var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", lookupProperty = container.lookupProperty || function(parent, propertyName) {
61
+ var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, lookupProperty = container.lookupProperty || function(parent, propertyName) {
62
62
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
63
63
  return parent[propertyName];
64
64
  }
65
65
  return undefined
66
66
  };
67
67
 
68
- return "// Generated by `tic build` from "
69
- + ((stack1 = ((helper = (helper = lookupProperty(helpers,"configPath") || (depth0 != null ? lookupProperty(depth0,"configPath") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"configPath","hash":{},"data":data,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":49}}}) : helper))) != null ? stack1 : "")
70
- + ". Do not edit by hand.\nimport { type IContainer, type IContainerModule, type IRegistration"
71
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(0, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":2,"column":67},"end":{"line":2,"column":116}}})) != null ? stack1 : "")
68
+ return "// Generated by `tic build`. Do not edit by hand.\n// Paths: "
69
+ + ((stack1 = (lookupProperty(helpers,"join")||(depth0 && lookupProperty(depth0,"join"))||alias2).call(alias1,(depth0 != null ? lookupProperty(depth0,"paths") : depth0),", ",{"name":"join","hash":{},"data":data,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":31}}})) != null ? stack1 : "")
70
+ + "\nimport { type IContainer, type IContainerModule, type IRegistration"
71
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(0, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":3,"column":67},"end":{"line":3,"column":116}}})) != null ? stack1 : "")
72
72
  + " } from 'ts-ioc-container';\n"
73
- + ((stack1 = lookupProperty(helpers,"each").call(alias1,(depth0 != null ? lookupProperty(depth0,"imports") : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":3,"column":0},"end":{"line":5,"column":9}}})) != null ? stack1 : "")
73
+ + ((stack1 = lookupProperty(helpers,"each").call(alias1,(depth0 != null ? lookupProperty(depth0,"imports") : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":0},"end":{"line":6,"column":9}}})) != null ? stack1 : "")
74
74
  + "\n"
75
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data,"loc":{"start":{"line":7,"column":0},"end":{"line":15,"column":7}}})) != null ? stack1 : "")
75
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data,"loc":{"start":{"line":8,"column":0},"end":{"line":16,"column":7}}})) != null ? stack1 : "")
76
76
  + "\nexport class "
77
- + ((stack1 = ((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":17,"column":13},"end":{"line":17,"column":23}}}) : helper))) != null ? stack1 : "")
77
+ + ((stack1 = ((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":18,"column":13},"end":{"line":18,"column":23}}}) : helper))) != null ? stack1 : "")
78
78
  + " implements IContainerModule {\n applyTo(container: IContainer): void {\n for (const registration of registrations) container.addRegistration(registration);\n }\n}\n";
79
79
  },"useData":true});
package/typings/app.d.ts CHANGED
@@ -8,16 +8,17 @@ export declare function createContainer(io?: CliIo): IContainer;
8
8
  /** Runs the `tic` CLI and returns its exit code; output goes through `io`. */
9
9
  export declare function run(argv: string[], io?: CliIo): number;
10
10
  /**
11
- * Generates the bundle a config describes — one `tic build` step as a function. Nothing is
12
- * written unless generation succeeds.
11
+ * Generates the bundle a config file describes — `tic build` as a function — and returns
12
+ * it; nothing is written.
13
13
  *
14
- * @throws {TicConfigError} when the config or the tsconfig it extends is missing or invalid.
14
+ * @throws {TicConfigError} when the config file is missing or unreadable, the config or its tsconfig is invalid, the bundle has no name, or no tsconfig paths alias covers a selected class's file.
15
+ * @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
15
16
  */
16
- export declare function build({ cwd, ...request }?: BuildOptions): BuildResult;
17
+ export declare function build({ cwd, ...request }: BuildOptions): BuildResult;
17
18
  /**
18
- * Reads and validates a `*.bundle.json`, `*.bundle.yaml` or `*.bundle.yml`.
19
+ * Reads and validates a config file: JSON for `.json`, YAML for `.yaml` / `.yml`.
19
20
  *
20
- * @throws {TicConfigError} when the file is missing, cannot be parsed, or does not match the config shape.
21
+ * @throws {TicConfigError} when the file is missing, has another extension, cannot be parsed, or does not match the config shape.
21
22
  */
22
23
  export declare function loadConfig(file: string): ResolvedConfig;
23
24
  //# sourceMappingURL=app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../lib/cli/Application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,UAAU,EAAU,MAAM,kBAAkB,CAAC;AA6BpG;;;;;GAKG;AACH,qBAAa,WAAW;IAMpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,WAAW;IAIpD,OAAO;IAKP,mFAAmF;IACnF,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;CAmB/B"}
1
+ {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../lib/cli/Application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,UAAU,EAAU,MAAM,kBAAkB,CAAC;AA+BpG;;;;;GAKG;AACH,qBAAa,WAAW;IAMpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,WAAW;IAIpD,OAAO;IAKP,mFAAmF;IACnF,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;CAsB/B"}
@@ -9,9 +9,15 @@ export declare const commandArgs: ({ args }: InjectOptions) => string[];
9
9
  * from the first flag onwards belongs to the action — what precedes it is the
10
10
  * command and the action name.
11
11
  *
12
+ * With `positionals`, the default action of a command takes arguments too: everything
13
+ * after the command is parsed, and the words that are not flags or their values come
14
+ * back as `positionals` (`tic build app.bundle.json`).
15
+ *
12
16
  * @throws {UsageError} when a flag is unknown or a flag that takes a value has none.
13
17
  */
14
- export declare const parseOptions: (options: OptionsConfig) => (argv: string[]) => Record<string, unknown>;
18
+ export declare const parseOptions: (options: OptionsConfig, { positionals }?: {
19
+ positionals?: boolean;
20
+ }) => (argv: string[]) => Record<string, unknown>;
15
21
  /**
16
22
  * Mapper that validates a loosely-typed value — parsed options in practice —
17
23
  * against a schema and narrows it to the schema's output type.
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../lib/cli/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAGtC,KAAK,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;AAE7D,4FAA4F;AAC5F,eAAO,MAAM,WAAW,GAAI,UAAe,aAAa,KAAG,MAAM,EAAsB,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GACtB,SAAS,aAAa,MACtB,MAAM,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAOvC,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAClB,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,MAC5B,OAAO,OAAO,KAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAI3B,CAAC"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../lib/cli/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAGtC,KAAK,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;AAE7D,4FAA4F;AAC5F,eAAO,MAAM,WAAW,GAAI,UAAe,aAAa,KAAG,MAAM,EAAsB,CAAC;AAExF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACtB,SAAS,aAAa,EAAE,kBAAyB;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,MAC/E,MAAM,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CASvC,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAClB,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,MAC5B,OAAO,OAAO,KAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAI3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../lib/cli/usage.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,QAeN,CAAC"}
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../lib/cli/usage.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,QAkBN,CAAC"}
@@ -4,6 +4,8 @@ export interface CliIo {
4
4
  cwd: string;
5
5
  stdout: (line: string) => void;
6
6
  stderr: (line: string) => void;
7
+ /** All of standard input, or `undefined` when nothing is piped in (a terminal, or no stdin at all). */
8
+ stdin?: () => string | undefined;
7
9
  }
8
10
  export declare const CliIoKey: SingleToken<CliIo>;
9
11
  export declare const processIo: () => CliIo;
@@ -1 +1 @@
1
- {"version":3,"file":"CliIo.d.ts","sourceRoot":"","sources":["../../lib/domain/CliIo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,6FAA6F;AAC7F,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,QAAQ,oBAAkC,CAAC;AAExD,eAAO,MAAM,SAAS,QAAO,KAA6E,CAAC"}
1
+ {"version":3,"file":"CliIo.d.ts","sourceRoot":"","sources":["../../lib/domain/CliIo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,6FAA6F;AAC7F,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,uGAAuG;IACvG,KAAK,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,QAAQ,oBAAkC,CAAC;AAExD,eAAO,MAAM,SAAS,QAAO,KAK3B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type InjectFn, SingleToken } from 'ts-ioc-container';
2
2
  /** Settings every service shares for one run: the process-level context the CLI was started in. */
3
3
  export type GlobalConfig = {
4
- /** Directory relative paths (`--config`, `build({ config })`) resolve against. */
4
+ /** Directory a relative `<config>` path (and `build({ config })`) resolves against. */
5
5
  cwd: string;
6
6
  };
7
7
  export declare const GlobalConfigKey: SingleToken<GlobalConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalConfig.d.ts","sourceRoot":"","sources":["../../lib/domain/GlobalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9D,mGAAmG;AACnG,MAAM,MAAM,YAAY,GAAG;IACzB,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,eAAe,2BAAgD,CAAC;AAE7E,qFAAqF;AACrF,eAAO,MAAM,YAAY,GACtB,CAAC,SAAS,MAAM,YAAY,EAAE,KAAK,CAAC,KAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAE3B,CAAC"}
1
+ {"version":3,"file":"GlobalConfig.d.ts","sourceRoot":"","sources":["../../lib/domain/GlobalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9D,mGAAmG;AACnG,MAAM,MAAM,YAAY,GAAG;IACzB,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,eAAe,2BAAgD,CAAC;AAE7E,qFAAqF;AACrF,eAAO,MAAM,YAAY,GACtB,CAAC,SAAS,MAAM,YAAY,EAAE,KAAK,CAAC,KAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAE3B,CAAC"}
@@ -10,6 +10,10 @@ export declare abstract class TicError extends Error {
10
10
  export declare class TicConfigError extends TicError {
11
11
  constructor(message: string);
12
12
  }
13
+ /** A namespace is neither an existing folder nor a `tsconfig.json` `paths` alias of one. */
14
+ export declare class NamespaceNotFoundError extends TicError {
15
+ constructor(message: string);
16
+ }
13
17
  /** The command line names no command. */
14
18
  export declare class MissingCommandError extends TicError {
15
19
  constructor(usage: string);
@@ -26,8 +30,4 @@ export declare class UnknownActionError extends TicError {
26
30
  export declare class UsageError extends TicError {
27
31
  constructor(message: string);
28
32
  }
29
- /** `tic build --check` found generated bundles that differ from what a build would write. */
30
- export declare class StaleBundlesError extends TicError {
31
- constructor(count: number);
32
- }
33
33
  //# sourceMappingURL=DomainException.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomainException.d.ts","sourceRoot":"","sources":["../../lib/exceptions/DomainException.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,8BAAsB,QAAS,SAAQ,KAAK;IAExC,QAAQ,CAAC,IAAI,EAAE,MAAM;IADvB,SAAS,aACE,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,8FAA8F;AAC9F,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM;CAG5B;AAED,yCAAyC;AACzC,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,KAAK,EAAE,MAAM;CAG1B;AAED,wEAAwE;AACxE,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM;CAG5B;AAED,kFAAkF;AAClF,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAG5C;AAED,uFAAuF;AACvF,qBAAa,UAAW,SAAQ,QAAQ;gBAC1B,OAAO,EAAE,MAAM;CAG5B;AAED,6FAA6F;AAC7F,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,EAAE,MAAM;CAG1B"}
1
+ {"version":3,"file":"DomainException.d.ts","sourceRoot":"","sources":["../../lib/exceptions/DomainException.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,8BAAsB,QAAS,SAAQ,KAAK;IAExC,QAAQ,CAAC,IAAI,EAAE,MAAM;IADvB,SAAS,aACE,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,8FAA8F;AAC9F,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM;CAG5B;AAED,4FAA4F;AAC5F,qBAAa,sBAAuB,SAAQ,QAAQ;gBACtC,OAAO,EAAE,MAAM;CAG5B;AAED,yCAAyC;AACzC,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,KAAK,EAAE,MAAM;CAG1B;AAED,wEAAwE;AACxE,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM;CAG5B;AAED,kFAAkF;AAClF,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAG5C;AAED,uFAAuF;AACvF,qBAAa,UAAW,SAAQ,QAAQ;gBAC1B,OAAO,EAAE,MAAM;CAG5B"}
@@ -1,10 +1,32 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * Which files a bundle reads and parses: the first, cheap stage of selection,
4
+ * decided by path alone. `glob` names the folders the files come from; within them
5
+ * a file is parsed unless it matches one of `exclude`. Globs are relative to the
6
+ * config file and `/`-separated.
7
+ */
8
+ export interface GlobSelector {
9
+ /**
10
+ * Folder, or folders, to scan recursively: relative to the config file (`./src/services`),
11
+ * or tsconfig `paths` aliases (`@app/services`).
12
+ */
13
+ glob: string | string[];
14
+ /** Glob, or globs, of files never read. Replaces {@link DEFAULT_EXCLUDE} when given. */
15
+ exclude?: string | string[];
16
+ }
17
+ /** A {@link GlobSelector} with its defaults filled in and its globs compiled. */
18
+ export interface ResolvedGlobSelector {
19
+ /** The folders to scan, as written in the config. */
20
+ glob: string[];
21
+ exclude: RegExp[];
22
+ }
2
23
  /** Which exports of a file count: both kinds, only named exports, or only the default export. */
3
24
  export type ExportKind = 'any' | 'named' | 'default';
4
25
  /**
5
- * Which classes of a parsed file are registered. A class is selected when it is
6
- * exported, not abstract, and meets every criterion set here; an empty rule
7
- * selects every exported class.
26
+ * Which classes of a parsed file are registered: the second stage of selection,
27
+ * run on the files {@link GlobSelector} let through. A class is selected when
28
+ * it is exported, not abstract, and meets every criterion set here; an empty
29
+ * rule selects every exported class.
8
30
  */
9
31
  export interface ClassSelector {
10
32
  /** Default `any`. */
@@ -14,155 +36,133 @@ export interface ClassSelector {
14
36
  * composed one). Default {@link DEFAULT_DECORATORS}; `[]` requires none.
15
37
  */
16
38
  decorators?: string[];
17
- /** A glob the class name must match, e.g. `*Service`. An anonymous default export is named after its file. */
18
- name?: string;
19
39
  /**
20
- * Class names to drop after selection, e.g. one test double sitting next to the
21
- * real registration in the same file.
40
+ * Globs the class name must match one of, e.g. `*Service` or `["*Service", "*Repository"]`.
41
+ * An anonymous default export is named after its file.
42
+ */
43
+ glob?: string | string[];
44
+ /**
45
+ * Globs the class name must match none of, applied after every other criterion. A plain
46
+ * name is a glob too, so `["MockUserRepository", "*Fake"]` drops one class by name and a
47
+ * family by pattern.
22
48
  */
23
- excludeClasses?: string[];
24
- /** A glob the class name must NOT match, e.g. `*Mock`. An anonymous default export is named after its file. */
25
- excludeName?: string;
49
+ exclude?: string | string[];
26
50
  }
27
51
  /** A {@link ClassSelector} with its defaults filled in and its globs compiled. */
28
52
  export interface ResolvedClassSelector {
29
53
  export: ExportKind;
30
54
  decorators?: string[];
31
- name?: RegExp;
32
- excludeClasses?: string[];
33
- excludeName?: RegExp;
34
- }
35
- /**
36
- * `compilerOptions` of a bundle config: the tsconfig's own options plus the bundler's.
37
- * `importExtension` and `classes` are read by `tic build`; every other option (`paths`,
38
- * `baseUrl`, `rootDir`, `moduleResolution`, ...) is handed to TypeScript on top of the
39
- * extended tsconfig, exactly as a child tsconfig's would be.
40
- */
41
- export interface BundleCompilerOptions {
42
- /** Extension of generated imports. Inferred from the tsconfig's `moduleResolution` when omitted. */
43
- importExtension?: string;
44
- /** Which classes of a scanned file are registered. Default: every exported class decorated with `@register`. */
45
- classes?: ClassSelector;
46
- [option: string]: unknown;
55
+ glob?: RegExp[];
56
+ exclude?: RegExp[];
47
57
  }
48
58
  /**
49
- * The shape of `*.bundle.json`: one bundle, written as a tsconfig. `extends`, `include`,
50
- * `exclude` and `compilerOptions` mean what they mean in a tsconfig, so the files the bundle
51
- * scans are the files this config would compile; `output`, `name` and the bundler's
52
- * own compiler options describe the generated module. A project that needs several bundles
53
- * keeps one config file per bundle.
59
+ * A bundle config file: one bundle, described explicitly — the folders it scans and the
60
+ * classes it registers. `tic build <config>` prints the bundle to stdout; where it is
61
+ * saved is the caller's choice (`tic build app.bundle.json > src/di/app.bundle.ts`).
54
62
  */
55
63
  export interface BundleConfig {
56
64
  $schema?: string;
57
- /**
58
- * The generated file, relative to the config file. Default `<root>/<name>.bundle.ts`:
59
- * `<root>` is the compiled `rootDir`, else the common folder of the files compiled.
60
- */
61
- output?: string;
62
65
  /**
63
66
  * The bundle's name: letters, digits, `-` and `_`, starting with a letter. Default: the
64
- * config file's stem (`production.bundle.json` -> `production`), else {@link DEFAULT_BUNDLE_NAME}.
65
- * It names the default output (`production.bundle.ts`) and the generated class,
66
- * an `IContainerModule` (`ProductionBundle`, see {@link toClassName}).
67
+ * config file's stem (`production.bundle.json` -> `production`); required for a config
68
+ * file named otherwise. It names the generated class, an `IContainerModule`
69
+ * (`ProductionBundle`, see {@link toClassName}).
67
70
  */
68
71
  name?: string;
69
72
  /**
70
- * The tsconfig this config extends, as a tsconfig's own `extends`. Relative to the config
71
- * file. Default `./tsconfig.json`, which may be absent; a tsconfig named here must exist.
73
+ * The tsconfig whose `paths` aliases `glob.glob` may name and generated imports are
74
+ * written in, and whose `moduleResolution` sets the import extension. It contributes
75
+ * nothing else: the files scanned are `glob.glob` alone. Relative to the config file.
76
+ * Default `./tsconfig.json`, which may be absent; a tsconfig named here must exist.
77
+ */
78
+ tsconfig?: string;
79
+ /** Extension of generated imports. Inferred from the tsconfig's `moduleResolution` when omitted. */
80
+ importExtension?: string;
81
+ /**
82
+ * Which files are parsed: the folders in `glob.glob`, minus {@link DEFAULT_EXCLUDE} unless
83
+ * `exclude` says otherwise. A folder or a list of folders is shorthand for `{ glob }`, as on {@link ClassSelector}.
72
84
  */
73
- extends?: string;
85
+ glob: string | string[] | GlobSelector;
74
86
  /**
75
- * The base folder this config's relative `include`, `exclude` and `output` resolve against,
76
- * so they need not repeat a shared prefix such as `src`. Relative to the config file; default
77
- * the config file's directory. It is also handed to TypeScript as `compilerOptions.baseUrl`
78
- * (unless that is set too), so the generated imports use it as well.
87
+ * Which classes of a parsed file are registered. Default: every exported class decorated
88
+ * with `@register`. A glob or a list of globs is shorthand for `{ glob }`, as on `glob`.
79
89
  */
80
- baseUrl?: string;
81
- /** tsconfig `include`: replaces the extended tsconfig's. Relative to `baseUrl`. */
82
- include?: string[];
83
- /** tsconfig `exclude`: replaces the extended tsconfig's. Relative to `baseUrl`. {@link DEFAULT_EXCLUDE} applies regardless. */
84
- exclude?: string[];
85
- compilerOptions?: BundleCompilerOptions;
90
+ className?: string | string[] | ClassSelector;
86
91
  }
87
- export declare const DEFAULT_EXTENDS = "./tsconfig.json";
88
- /** The bundle name when the config file gives none, e.g. building from `tsconfig.json` alone. */
89
- export declare const DEFAULT_BUNDLE_NAME = "base";
90
- /** What `classes.decorators` requires when omitted: the library's own `@register`. */
92
+ export declare const DEFAULT_TSCONFIG = "./tsconfig.json";
93
+ /** What `className.decorators` requires when omitted: the library's own `@register`. */
91
94
  export declare const DEFAULT_DECORATORS: string[];
92
- /** Files never scanned, whatever the tsconfig compiles: tests, and anything under `node_modules`. */
93
95
  export declare const DEFAULT_EXCLUDE: string[];
94
- /** The tsconfig part of a bundle config, handed to TypeScript as a tsconfig of its own. */
95
- export interface TsconfigOverrides {
96
- include?: string[];
97
- exclude?: string[];
98
- /** `compilerOptions` without the bundler's own options. */
99
- compilerOptions: Record<string, unknown>;
100
- }
101
96
  /** A {@link BundleConfig} whose defaults are filled in and whose paths are absolute. */
102
97
  export interface ResolvedConfig {
103
98
  /** The config file itself. */
104
99
  file: string;
100
+ /** Its folder: what the config's relative paths resolve against. */
105
101
  dir: string;
106
- /** `undefined`: derived from what is compiled at build time (see {@link BundleConfig.output}). */
107
- output?: string;
108
102
  /** The bundle name: `production` for `production.bundle.json`. */
109
103
  name: string;
110
104
  /** The generated class: `ProductionBundle`. */
111
- className: string;
112
- /** The extended tsconfig; `required` when the config names it, so it must exist. */
105
+ bundleClassName: string;
106
+ /** The tsconfig of `paths` aliases; `required` when the config names it, so it must exist. */
113
107
  tsconfig: {
114
108
  file: string;
115
109
  required: boolean;
116
110
  };
117
- /** What the config sets on top of {@link tsconfig}. */
118
- overrides: TsconfigOverrides;
119
111
  importExtension?: string;
120
- classes: ResolvedClassSelector;
112
+ glob: ResolvedGlobSelector;
113
+ className: ResolvedClassSelector;
114
+ /** Non-fatal problems found while resolving, e.g. a `glob.exclude` that drops a default test glob. */
115
+ warnings: string[];
121
116
  }
122
117
  /**
123
- * One `*.bundle.json` / `*.bundle.yaml`: a tsconfig with the bundler's fields. The published
124
- * `tic.schema.json` is generated from it (`ticConfigJsonSchema`), so the schema editors
125
- * validate against cannot drift from what `tic build` accepts.
118
+ * One `*.bundle.json` / `*.bundle.yaml`. The published `tic.schema.json` is generated
119
+ * from it (`ticConfigJsonSchema`), so the schema editors validate against cannot drift
120
+ * from what `tic build` accepts.
126
121
  */
127
122
  export declare const BUNDLE_CONFIG_SCHEMA: z.ZodObject<{
128
123
  $schema: z.ZodOptional<z.ZodString>;
129
- extends: z.ZodOptional<z.ZodString>;
130
- baseUrl: z.ZodOptional<z.ZodString>;
131
- output: z.ZodOptional<z.ZodString>;
132
124
  name: z.ZodOptional<z.ZodString>;
133
- include: z.ZodOptional<z.ZodCustom<string[], string[]>>;
134
- exclude: z.ZodOptional<z.ZodCustom<string[], string[]>>;
135
- compilerOptions: z.ZodOptional<z.ZodObject<{
136
- importExtension: z.ZodOptional<z.ZodString>;
137
- classes: z.ZodOptional<z.ZodObject<{
138
- export: z.ZodDefault<z.ZodEnum<{
139
- default: "default";
140
- any: "any";
141
- named: "named";
142
- }>>;
143
- decorators: z.ZodDefault<z.ZodCustom<string[], string[]>>;
144
- name: z.ZodOptional<z.ZodString>;
145
- excludeClasses: z.ZodOptional<z.ZodCustom<string[], string[]>>;
146
- excludeName: z.ZodOptional<z.ZodString>;
147
- }, z.core.$strict>>;
148
- paths: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
149
- rootDir: z.ZodOptional<z.ZodString>;
150
- }, z.core.$loose>>;
125
+ tsconfig: z.ZodOptional<z.ZodString>;
126
+ importExtension: z.ZodOptional<z.ZodString>;
127
+ glob: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
128
+ glob: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
129
+ exclude: z.ZodDefault<z.ZodCustom<string | string[], string | string[]>>;
130
+ }, z.core.$strict>]>;
131
+ className: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
132
+ export: z.ZodDefault<z.ZodEnum<{
133
+ default: "default";
134
+ any: "any";
135
+ named: "named";
136
+ }>>;
137
+ decorators: z.ZodDefault<z.ZodCustom<string[], string[]>>;
138
+ glob: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
139
+ exclude: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
140
+ }, z.core.$strict>]>>;
151
141
  }, z.core.$strict>;
152
142
  /**
153
- * A config file is named `<name>.bundle.json`, `<name>.bundle.yaml` or `<name>.bundle.yml`,
154
- * e.g. `app.bundle.json`, `production.bundle.yaml`. Every format has the same shape.
143
+ * A config file is named `<name>.bundle.json`, `<name>.bundle.yaml` or `<name>.bundle.yml`
144
+ * by convention, e.g. `app.bundle.json`; any `.json` / `.yaml` / `.yml` file works.
155
145
  */
156
146
  export declare const CONFIG_FILE_SUFFIXES: string[];
157
- /** The config suffix `file` ends with, if any. */
158
- export declare const configSuffix: (file: string) => string | undefined;
147
+ /** What stands for standard input where a config file is expected: `tic build -`. */
148
+ export declare const STDIN = "-";
149
+ /** The format of a config file, by extension; `undefined` for any other file. */
150
+ export declare const configFormat: (file: string) => ConfigFormat | undefined;
151
+ /** The format of config text: JSON or YAML. */
152
+ export type ConfigFormat = 'json' | 'yaml';
153
+ /**
154
+ * Parses config text in its format. An empty YAML document is `{}`.
155
+ *
156
+ * @throws {TicConfigError} when the text is not valid in its format.
157
+ */
158
+ export declare function parseConfig(text: string, format: ConfigFormat): unknown;
159
159
  /** The generated class for a bundle name: `production` -> `ProductionBundle`, `my-app_v2` -> `MyAppV2Bundle`. */
160
160
  export declare function toClassName(name: string): string;
161
161
  /**
162
- * Validates parsed `*.bundle.json` content and resolves its paths against `file`'s
163
- * directory, or its `baseUrl` for `include` / `exclude` / `output`.
162
+ * Validates parsed config content and resolves its paths against `file`'s directory.
163
+ * Without a `name` the bundle is named after the file: `production.bundle.json` -> `production`.
164
164
  *
165
- * @throws {TicConfigError} when the content does not match the config shape; the message names the field.
165
+ * @throws {TicConfigError} when the content does not match the config shape, or names no bundle; the message names the field.
166
166
  */
167
167
  export declare function resolveConfig(content: unknown, file: string): ResolvedConfig;
168
168
  //# sourceMappingURL=BuildConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuildConfig.d.ts","sourceRoot":"","sources":["../../../lib/features/build/BuildConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,iGAAiG;AACjG,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,8GAA8G;IAC9G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,cAAc,CAA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1
  import { z } from 'zod';
2
+ import { type CliIo } from '../../domain/CliIo.js';
2
3
  import { type ILogger } from '../../services/ConsoleLogger.js';
3
4
  import { type IOutputService } from '../../services/OutputService.js';
4
5
  import { type IBundleBuilder } from './services/BundleBuilder.js';
5
- import { type ITicConfigService } from './services/TicConfigService.js';
6
- export declare const BUILD_OPTIONS: z.ZodObject<{
7
- config: z.ZodDefault<z.ZodArray<z.ZodString>>;
8
- check: z.ZodDefault<z.ZodBoolean>;
9
- }, z.core.$strip>;
6
+ export declare const BUILD_OPTIONS: z.ZodPipe<z.ZodObject<{
7
+ positionals: z.ZodArray<z.ZodString>;
8
+ }, z.core.$strip>, z.ZodTransform<{
9
+ config: string;
10
+ }, {
11
+ positionals: string[];
12
+ }>>;
10
13
  export type BuildCliOptions = z.output<typeof BUILD_OPTIONS>;
11
- /** `tic build [--config <path>]... [--check]`. */
14
+ /** `tic build [<config> | -]`: the bundle goes to stdout; without a config file, the config comes from stdin. */
12
15
  export declare class BuildController {
13
- private readonly cwd;
14
- private readonly configs;
16
+ private readonly io;
15
17
  private readonly builder;
16
18
  private readonly output;
17
19
  private readonly logger;
18
- constructor(cwd: string, configs: ITicConfigService, builder: IBundleBuilder, output: IOutputService, logger: ILogger);
20
+ constructor(io: CliIo, builder: IBundleBuilder, output: IOutputService, logger: ILogger);
19
21
  /**
20
- * Builds every config named with `--config`, else every `*.bundle.{json,yaml,yml}` of the
21
- * package, else one bundle from its `tsconfig.json`. With `--check` nothing is written and
22
- * an out-of-date bundle fails the run. One line per bundle goes to stdout, warnings to
23
- * stderr; an error names the config it came from.
22
+ * Builds the bundle the config file `<config>` describes — or, without one (or with `-`),
23
+ * the config piped into stdin — and prints it to stdout. Saving it is the shell's job:
24
+ * `tic build app.bundle.json > src/di/app.bundle.ts`, `cat app.bundle.yml | tic build > out.ts`.
25
+ * Warnings go to stderr, so they never end up in the bundle; an error names the config.
24
26
  *
25
- * @throws {UsageError} when an option is unknown or `--config` has no value.
26
- * @throws {TicConfigError} when a config or its tsconfig is missing or invalid, or none can be found.
27
- * @throws {StaleBundlesError} when `--check` finds a bundle that differs from what a build would write.
27
+ * @throws {UsageError} when an option is unknown, there is more than one `<config>`, or the config should come from stdin and nothing is piped in.
28
+ * @throws {TicConfigError} when the config file is missing or unreadable, the config or its tsconfig is invalid, the bundle has no name, or no tsconfig paths alias covers a selected class's file.
29
+ * @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
28
30
  */
29
- build(options: BuildCliOptions): void;
31
+ build({ config }: BuildCliOptions): void;
32
+ /**
33
+ * @throws {UsageError} when nothing is piped into stdin.
34
+ */
35
+ private stdin;
30
36
  }
31
37
  //# sourceMappingURL=BuildController.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuildController.d.ts","sourceRoot":"","sources":["../../../lib/features/build/BuildController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,KAAK,cAAc,EAAwC,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,KAAK,iBAAiB,EAAuC,MAAM,6BAA6B,CAAC;AAE1G,eAAO,MAAM,aAAa;;;iBAGxB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAW7D,kDAAkD;AAClD,qBACa,eAAe;IAEK,OAAO,CAAC,QAAQ,CAAC,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,OAAO;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAJD,GAAG,EAAE,MAAM,EACN,OAAO,EAAE,iBAAiB,EAC7B,OAAO,EAAE,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