@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
@@ -5,30 +5,32 @@ interface Alias {
5
5
  targets: string[];
6
6
  }
7
7
  /**
8
- * Import paths as a project's `tsconfig.json` sees them: writes imports in the
9
- * form of its `paths` aliases, else its `baseUrl`, where one matches.
8
+ * Import paths as a project's `tsconfig.json` sees them: resolves namespaces
9
+ * written as `paths` aliases to folders, and writes imports back in alias form.
10
10
  */
11
11
  export declare class ImportPaths {
12
12
  private readonly aliases;
13
13
  readonly extension: string;
14
- /** Absolute, `/`-separated: non-relative imports resolve against it. */
15
- private readonly baseUrl?;
16
14
  /**
17
- * From a parsed tsconfig's options: its `paths` aliases and `baseUrl`, and the extension
18
- * imports need under its `moduleResolution`; `importExtension` overrides the latter.
15
+ * From a parsed tsconfig's options: its `paths` aliases, and the extension imports need
16
+ * under its `moduleResolution`; `importExtension` overrides the latter.
19
17
  */
20
18
  static fromOptions(options: ts.CompilerOptions, tsconfigFile: string, importExtension?: string): ImportPaths;
21
- constructor(aliases: Alias[], extension: string,
22
- /** Absolute, `/`-separated: non-relative imports resolve against it. */
23
- baseUrl?: string | undefined);
19
+ constructor(aliases: Alias[], extension: string);
24
20
  /**
25
- * The specifier `fromFile` imports `toFile` by: its most specific `paths` alias, else a
26
- * path relative to `baseUrl` when the file is under it, else a path relative to `fromFile`.
21
+ * The folder a namespace names: a path relative to `baseDir`, or a `paths` alias.
22
+ *
23
+ * @throws {NamespaceNotFoundError} when the namespace is neither an existing folder nor an alias of one.
27
24
  */
28
- specifier(fromFile: string, toFile: string): string;
29
- /** `bare` written relative to `baseUrl`, when it is under it; `undefined` otherwise. */
30
- private baseUrlSpecifier;
25
+ resolveNamespace(namespace: string, baseDir: string): string;
26
+ /**
27
+ * The specifier `file` is imported by: its most specific `paths` alias. `undefined` when no
28
+ * alias covers it — a bundle is written to stdout, so it has no location a relative import
29
+ * could start from.
30
+ */
31
+ specifier(file: string): string | undefined;
31
32
  private bestAlias;
33
+ private aliasTargets;
32
34
  /** A longer matched target prefix is a more specific alias; an exact file alias beats every wildcard. */
33
35
  private matchAlias;
34
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImportPaths.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/ImportPaths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAUD;;;GAGG;AACH,qBAAa,WAAW;IAuBpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAzB3B;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW;gBAkBzF,OAAO,EAAE,KAAK,EAAE,EACxB,SAAS,EAAE,MAAM;IAC1B,wEAAwE;IACvD,OAAO,CAAC,EAAE,MAAM,YAAA;IAGnC;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAanD,wFAAwF;IACxF,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,SAAS;IAWjB,yGAAyG;IACzG,OAAO,CAAC,UAAU;CAanB"}
1
+ {"version":3,"file":"ImportPaths.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/ImportPaths.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAaD;;;GAGG;AACH,qBAAa,WAAW;IAmBpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAnB5B;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW;gBAczF,OAAO,EAAE,KAAK,EAAE,EACxB,SAAS,EAAE,MAAM;IAG5B;;;;OAIG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAa5D;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK3C,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,YAAY;IAWpB,yGAAyG;IACzG,OAAO,CAAC,UAAU;CAanB"}
@@ -2,8 +2,8 @@ import type { DiscoveredClass } from './scan.js';
2
2
  export interface EmitInput {
3
3
  /** Name of the generated class. */
4
4
  name: string;
5
- /** Shown in the header: where the output came from. */
6
- configPath: string;
5
+ /** Shown in the header: the folders scanned. */
6
+ paths: string[];
7
7
  classes: (DiscoveredClass & {
8
8
  specifier: string;
9
9
  })[];
@@ -12,7 +12,7 @@ export interface EmitInput {
12
12
  export declare const GENERATED_HEADER = "// Generated by `tic build`";
13
13
  /** What `protocols/Bundle.ts.hbs` renders. */
14
14
  export interface BundleView {
15
- configPath: string;
15
+ paths: string[];
16
16
  name: string;
17
17
  imports: {
18
18
  specifier: string;
@@ -27,7 +27,7 @@ export declare const BUNDLE_PROTOCOL = "Bundle.ts.hbs";
27
27
  * Prepares the data the bundle protocol renders: unique local names, and one import
28
28
  * per file in file order.
29
29
  */
30
- export declare function bundleView({ name, configPath, classes }: EmitInput): BundleView;
30
+ export declare function bundleView({ name, paths, classes }: EmitInput): BundleView;
31
31
  /**
32
32
  * Renders the generated bundle — static imports, `registrations`, and the bundle applying them —
33
33
  * from its protocol, `protocols/Bundle.ts.hbs`.
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/emit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,eAAe,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CACtD;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,gCAAgC,CAAC;AAE9D,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACxE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29,8 @@ export interface DiscoveredClass {
29
29
  }
30
30
  /** A TypeScript source file the bundler may parse: not a declaration file. */
31
31
  export declare const isSourceFile: (file: string) => boolean;
32
+ /** Source files of `dir` and its sub-folders, sorted by path so the generated output is stable across machines. */
33
+ export declare function listSourceFiles(dir: string, isExcluded: (file: string) => boolean): string[];
32
34
  /**
33
35
  * The exported, non-abstract classes of one file that `selector` selects, in
34
36
  * declaration order. Syntax only: decorators are recognised by name, not by type.
@@ -1 +1 @@
1
- {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/scan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;CACpD;AAKD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAiE,CAAC;AA2B9G;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,SAA6B,GAChC,eAAe,EAAE,CAmFnB"}
1
+ {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/scan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;CACpD;AAKD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAiE,CAAC;AAE9G,mHAAmH;AACnH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,EAAE,CAc5F;AA2BD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,SAA6B,GAChC,eAAe,EAAE,CAkFnB"}
@@ -1,21 +1,14 @@
1
- import type { ResolvedConfig } from '../BuildConfig.js';
2
1
  import { ImportPaths } from './ImportPaths.js';
3
- /** What a bundle compiles: the bundle config read as a tsconfig, on top of the tsconfig it extends. */
4
- export interface CompiledTsconfig {
5
- importPaths: ImportPaths;
6
- /** Absolute paths of the files compiled. */
7
- fileNames: string[];
8
- /**
9
- * Where the sources live, as tsc sees it: `rootDir`, else the longest common folder of
10
- * the non-declaration files compiled, else the config's folder.
11
- */
12
- rootDir: string;
13
- }
14
2
  /**
15
- * Compiles a bundle config as a tsconfig, following `extends`: the files it compiles
16
- * (`include` / `exclude`, as overridden), its `paths` aliases and import extension.
3
+ * Reads a bundle's tsconfig, following its own `extends`: its `paths` aliases and the
4
+ * import extension its `moduleResolution` needs; `importExtension` overrides the latter.
5
+ * Nothing else is taken from it — which files it compiles plays no part in a bundle.
6
+ * An absent tsconfig that was not named explicitly yields no aliases.
17
7
  *
18
- * @throws {TicConfigError} when a required tsconfig is missing, or the config or a tsconfig it extends is invalid.
8
+ * @throws {TicConfigError} when a required tsconfig is missing or cannot be parsed.
19
9
  */
20
- export declare function loadTsconfig(config: ResolvedConfig): CompiledTsconfig;
10
+ export declare function loadImportPaths(tsconfig: {
11
+ file: string;
12
+ required: boolean;
13
+ }, importExtension?: string): ImportPaths;
21
14
  //# sourceMappingURL=tsconfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/tsconfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAM5C,uGAAuG;AACvG,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,WAAW,CAAC;IACzB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AA+BD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAerE"}
1
+ {"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/tsconfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,CAapH"}
@@ -3,48 +3,42 @@ import { type IRenderService } from '../../../services/HandlebarsRenderService.j
3
3
  import { type IFileSystemService } from '../../../services/NodeFileSystemService.js';
4
4
  import { type ITicConfigService } from './TicConfigService.js';
5
5
  /** What one build does. Paths resolve against the run's working directory. */
6
- export interface BuildRequest {
6
+ export type BuildRequest = {
7
+ /** Path of the config file — `*.json`, `*.yaml` or `*.yml` — relative to the working directory. */
8
+ config: string;
9
+ } | {
7
10
  /**
8
- * Path of the `*.bundle.json` to build, relative to the working directory. Omitted: build
9
- * from the `tsconfig.json` of the package the working directory is in (see `findPackageRoot`),
10
- * every setting at its default.
11
+ * The config as text, e.g. read from stdin: YAML or JSON. Its relative paths resolve
12
+ * against the working directory, and it must set `name`.
11
13
  */
12
- config?: string;
13
- /** Compare instead of writing: outputs that would change are reported `stale`. */
14
- check?: boolean;
15
- }
16
- export interface BuildOptions extends BuildRequest {
14
+ text: string;
15
+ };
16
+ export type BuildOptions = BuildRequest & {
17
17
  /** Default `process.cwd()`. */
18
18
  cwd?: string;
19
- }
20
- /** `written` / `unchanged` after a build; `stale` / `unchanged` after a check. */
21
- export type OutputStatus = 'written' | 'unchanged' | 'stale';
22
- export interface OutputResult {
23
- /** Absolute path of the generated file. */
24
- file: string;
19
+ };
20
+ export interface BuildResult {
21
+ /** Absolute path of the config file that was built; `undefined` for config text. */
22
+ config?: string;
25
23
  /** Name of the generated class. */
26
24
  bundle: string;
27
- status: OutputStatus;
28
25
  registrations: number;
26
+ /** The generated bundle. Nothing is written: saving it is the caller's job (`tic build app.bundle.json > src/di/app.bundle.ts`). */
29
27
  content: string;
30
- }
31
- export interface BuildResult {
32
- /** Absolute path of the config that was built. */
33
- config: string;
34
- output: OutputResult;
35
28
  /**
36
- * Non-fatal problems found while building, e.g. two selected classes passing the same
37
- * decorator token.
29
+ * Non-fatal problems found while building, e.g. a `glob.exclude` that drops a default
30
+ * test glob or two selected classes passing the same decorator token.
38
31
  */
39
32
  warnings: string[];
40
33
  }
41
34
  export interface IBundleBuilder {
42
35
  /**
43
- * Generates the bundle a config describes. Nothing is written unless generation succeeds.
36
+ * Generates the bundle a config describes and returns it; nothing is written.
44
37
  *
45
- * @throws {TicConfigError} when the config or the tsconfig it extends is missing or invalid.
38
+ * @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.
39
+ * @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
46
40
  */
47
- build(request?: BuildRequest): BuildResult;
41
+ build(request: BuildRequest): BuildResult;
48
42
  }
49
43
  export declare const IBundleBuilderKey: SingleToken<IBundleBuilder>;
50
44
  export declare class BundleBuilder implements IBundleBuilder {
@@ -54,11 +48,13 @@ export declare class BundleBuilder implements IBundleBuilder {
54
48
  private readonly renderer;
55
49
  constructor(cwd: string, configs: ITicConfigService, fs: IFileSystemService, renderer: IRenderService);
56
50
  /**
57
- * @throws {TicConfigError} when the config or the tsconfig it extends is missing or invalid.
51
+ * @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.
52
+ * @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
58
53
  */
59
- build({ config, check }?: BuildRequest): BuildResult;
54
+ build(request: BuildRequest): BuildResult;
60
55
  /**
61
- * @throws {TicConfigError} when the config or the tsconfig it extends is missing or invalid.
56
+ * @throws {TicConfigError} when the tsconfig is missing or invalid, or no tsconfig paths alias covers a selected class's file.
57
+ * @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
62
58
  */
63
59
  private generate;
64
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BundleBuilder.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/services/BundleBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,2CAA2C,CAAC;AACnG,OAAO,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;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,KAAa,EAAE,GAAE,YAAiB,GAAG,WAAW;IAiBhE;;OAEG;IACH,OAAO,CAAC,QAAQ;CA8BjB"}
1
+ {"version":3,"file":"BundleBuilder.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/services/BundleBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,2CAA2C,CAAC;AACnG,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,yCAAyC,CAAC;AAGzG,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,oBAAoB,CAAC;AAOlF,8EAA8E;AAC9E,MAAM,MAAM,YAAY,GACpB;IACE,mGAAmG;IACnG,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG;IACxC,+BAA+B;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,oIAAoI;IACpI,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAAC;CAC3C;AAED,eAAO,MAAM,iBAAiB,6BAAoD,CAAC;AAEnF,qBACa,aAAc,YAAW,cAAc;IAEnB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,OAAO;IACvB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAHV,GAAG,EAAE,MAAM,EACN,OAAO,EAAE,iBAAiB,EACzB,EAAE,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,cAAc;IAG1E;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW;IAezC;;;OAGG;IACH,OAAO,CAAC,QAAQ;CA0CjB"}
@@ -1,37 +1,33 @@
1
1
  import { SingleToken } from 'ts-ioc-container';
2
2
  import { type IFileSystemService } from '../../../services/NodeFileSystemService.js';
3
3
  import { type ResolvedConfig } from '../BuildConfig.js';
4
- /** The tsconfig a build without a config file extends. */
5
- export declare const TSCONFIG_FILE = "tsconfig.json";
6
4
  export interface ITicConfigService {
7
5
  /**
8
- * Reads and validates a `*.bundle.json`, `*.bundle.yaml` or `*.bundle.yml`.
6
+ * Reads and validates a config file: JSON for `.json`, YAML for `.yaml` / `.yml`.
9
7
  *
10
- * @throws {TicConfigError} when the file is missing, cannot be parsed, or does not match the config shape.
8
+ * @throws {TicConfigError} when the file is missing, has another extension, cannot be parsed, or does not match the config shape.
11
9
  */
12
10
  load(file: string): ResolvedConfig;
13
11
  /**
14
- * The configs to build, as absolute paths: the ones named (relative to the working
15
- * directory), else every `*.bundle.{json,yaml,yml}` at the root of the package the working
16
- * directory is in, else `[undefined]` — one build from that package's `tsconfig.json`
17
- * with default settings. Never looks past the package into a workspace root.
12
+ * Validates config text from somewhere other than a file — stdin, say. It is parsed as YAML,
13
+ * which JSON is a subset of; its relative paths resolve against `dir`, and it has no file
14
+ * name to take the bundle name from, so it must set `name`.
18
15
  *
19
- * @throws {TicConfigError} when none is named and the package has neither a config nor a `tsconfig.json`, or one bundle is described in two formats.
16
+ * @throws {TicConfigError} when the text cannot be parsed, does not match the config shape, or has no `name`.
20
17
  */
21
- discover(named: string[]): (string | undefined)[];
18
+ parse(text: string, dir: string): ResolvedConfig;
22
19
  }
23
20
  export declare const ITicConfigServiceKey: SingleToken<ITicConfigService>;
24
21
  export declare class TicConfigService implements ITicConfigService {
25
- private readonly cwd;
26
22
  private readonly fs;
27
- constructor(cwd: string, fs: IFileSystemService);
23
+ constructor(fs: IFileSystemService);
28
24
  /**
29
- * @throws {TicConfigError} when the file is missing, cannot be parsed, or does not match the config shape.
25
+ * @throws {TicConfigError} when the file is missing, has another extension, cannot be parsed, or does not match the config shape.
30
26
  */
31
27
  load(file: string): ResolvedConfig;
32
28
  /**
33
- * @throws {TicConfigError} when none is named and the package has neither a config nor a `tsconfig.json`, or one bundle is described in two formats.
29
+ * @throws {TicConfigError} when the text cannot be parsed, does not match the config shape, or has no `name`.
34
30
  */
35
- discover(named: string[]): (string | undefined)[];
31
+ parse(text: string, dir: string): ResolvedConfig;
36
32
  }
37
33
  //# sourceMappingURL=TicConfigService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TicConfigService.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/services/TicConfigService.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIrE,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,yCAAyC,CAAC;AACzG,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,gBAAgB,CAAC;AAGpE,0DAA0D;AAC1D,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;IAEnC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;CACnD;AAED,eAAO,MAAM,oBAAoB,gCAA0D,CAAC;AAE5F,qBACa,gBAAiB,YAAW,iBAAiB;IAEzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACd,OAAO,CAAC,QAAQ,CAAC,EAAE;gBADR,GAAG,EAAE,MAAM,EACL,EAAE,EAAE,kBAAkB;IAG5E;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc;IAKlC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE;CAQlD"}
1
+ {"version":3,"file":"TicConfigService.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/services/TicConfigService.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,yCAAyC,CAAC;AACzG,OAAO,EAA6B,KAAK,cAAc,EAAwB,MAAM,gBAAgB,CAAC;AAEtG,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;IAEnC;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAClD;AAED,eAAO,MAAM,oBAAoB,gCAA0D,CAAC;AAE5F,qBACa,gBAAiB,YAAW,iBAAiB;IACT,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,kBAAkB;IAEtF;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc;IAOlC;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,cAAc;CAGjD"}
@@ -4,14 +4,13 @@ export { type GlobalConfig, GlobalConfigKey, globalConfig } from './domain/Globa
4
4
  export { Application, action, onDefault, DEFAULT_ACTION, commandArgs, parseOptions, validate, type IErrorHandler, IErrorHandlerKey, USAGE, } from './cli.js';
5
5
  export { BuildModule } from './features/build/BuildModule.js';
6
6
  export { BuildController, BUILD_OPTIONS, type BuildCliOptions } from './features/build/BuildController.js';
7
- export { BundleBuilder, IBundleBuilderKey, type IBundleBuilder, type BuildRequest, type BuildOptions, type BuildResult, type OutputResult, type OutputStatus, } from './features/build/services/BundleBuilder.js';
8
- export { TicConfigService, ITicConfigServiceKey, TSCONFIG_FILE, type ITicConfigService, } from './features/build/services/TicConfigService.js';
9
- export { resolveConfig, BUNDLE_CONFIG_SCHEMA, CONFIG_FILE_SUFFIXES, DEFAULT_EXTENDS, DEFAULT_EXCLUDE, DEFAULT_BUNDLE_NAME, DEFAULT_DECORATORS, toClassName, type BundleConfig, type BundleCompilerOptions, type ClassSelector, type ExportKind, type ResolvedClassSelector, type ResolvedConfig, type TsconfigOverrides, } from './features/build/BuildConfig.js';
10
- export { findConfigFiles, findPackageRoot } from './features/build/domain/configFiles.js';
7
+ export { BundleBuilder, IBundleBuilderKey, type IBundleBuilder, type BuildRequest, type BuildOptions, type BuildResult, } from './features/build/services/BundleBuilder.js';
8
+ export { TicConfigService, ITicConfigServiceKey, type ITicConfigService, } from './features/build/services/TicConfigService.js';
9
+ export { resolveConfig, BUNDLE_CONFIG_SCHEMA, parseConfig, CONFIG_FILE_SUFFIXES, STDIN, configFormat, DEFAULT_TSCONFIG, DEFAULT_EXCLUDE, DEFAULT_DECORATORS, toClassName, type BundleConfig, type ClassSelector, type ExportKind, type ResolvedClassSelector, type GlobSelector, type ResolvedGlobSelector, type ResolvedConfig, type ConfigFormat, } from './features/build/BuildConfig.js';
11
10
  export { ticConfigJsonSchema } from './schema/ticConfigSchema.js';
12
11
  export { ImportPaths } from './features/build/domain/ImportPaths.js';
13
- export { loadTsconfig, type CompiledTsconfig } from './features/build/domain/tsconfig.js';
14
- export { findClasses, isSourceFile, type DiscoveredClass } from './features/build/domain/scan.js';
12
+ export { loadImportPaths } from './features/build/domain/tsconfig.js';
13
+ export { findClasses, isSourceFile, listSourceFiles, type DiscoveredClass } from './features/build/domain/scan.js';
15
14
  export { emitBundle, bundleView, BUNDLE_PROTOCOL, GENERATED_HEADER, type EmitInput, type BundleView, } from './features/build/domain/emit.js';
16
15
  export { tokenCollisions } from './features/build/domain/tokenCollisions.js';
17
16
  export { globToRegExp } from './features/build/domain/glob.js';
@@ -21,6 +20,6 @@ export { type IOutputService, IOutputServiceKey, StdOutputService } from './serv
21
20
  export { type ILogger, ILoggerKey, ConsoleLogger } from './services/ConsoleLogger.js';
22
21
  export { type IFileSystemService, IFileSystemServiceKey, NodeFileSystemService, } from './services/NodeFileSystemService.js';
23
22
  export { type IRenderService, IRenderServiceKey, HandlebarsRenderService, renderProtocol, } from './services/HandlebarsRenderService.js';
24
- export { TicError, TicConfigError, MissingCommandError, UnknownCommandError, UnknownActionError, UsageError, StaleBundlesError, } from './exceptions/DomainException.js';
23
+ export { TicError, TicConfigError, NamespaceNotFoundError, MissingCommandError, UnknownCommandError, UnknownActionError, UsageError, } from './exceptions/DomainException.js';
25
24
  export { ExceptionHandler } from './exceptions/ExceptionHandler.js';
26
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ticConfigSchema.d.ts","sourceRoot":"","sources":["../../lib/schema/ticConfigSchema.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgB7D"}
1
+ {"version":3,"file":"ticConfigSchema.d.ts","sourceRoot":"","sources":["../../lib/schema/ticConfigSchema.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoB7D"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.findPackageRoot = findPackageRoot;
7
- exports.findConfigFiles = findConfigFiles;
8
- const node_fs_1 = require("node:fs");
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const DomainException_1 = require("../../../exceptions/DomainException");
11
- const BuildConfig_1 = require("../BuildConfig");
12
- function findPackageRoot(dir) {
13
- const start = node_path_1.default.resolve(dir);
14
- for (let current = start;; current = node_path_1.default.dirname(current)) {
15
- if ((0, node_fs_1.existsSync)(node_path_1.default.join(current, 'package.json')))
16
- return current;
17
- if (node_path_1.default.dirname(current) === current)
18
- return start;
19
- }
20
- }
21
- function findConfigFiles(dir) {
22
- const files = (0, node_fs_1.readdirSync)(dir, { withFileTypes: true })
23
- .filter((entry) => entry.isFile() && (0, BuildConfig_1.configSuffix)(entry.name) !== undefined)
24
- .map((entry) => entry.name)
25
- .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
26
- const byStem = new Map();
27
- for (const file of files) {
28
- const stem = file.slice(0, -(0, BuildConfig_1.configSuffix)(file).length);
29
- const other = byStem.get(stem);
30
- if (other)
31
- throw new DomainException_1.TicConfigError(`${other} and ${file} describe the same bundle; keep one`);
32
- byStem.set(stem, file);
33
- }
34
- return files.map((file) => node_path_1.default.join(dir, file));
35
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * The root of the package `dir` belongs to: the nearest folder, `dir` or above, with a
3
- * `package.json` — the project root in a single-package project, the package in a
4
- * monorepo. `dir` itself when no folder above has one.
5
- */
6
- export declare function findPackageRoot(dir: string): string;
7
- /**
8
- * The `*.bundle.{json,yaml,yml}` configs in `dir` (not its sub-folders), sorted by name.
9
- *
10
- * @throws {TicConfigError} when one bundle is described in two formats, e.g. `app.bundle.json` and `app.bundle.yaml`.
11
- */
12
- export declare function findConfigFiles(dir: string): string[];
13
- //# sourceMappingURL=configFiles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configFiles.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/configFiles.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAarD"}