@decohere/core 0.0.1-dev.116

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 (262) hide show
  1. package/commonjs/src/caching/cache-manager.js +98 -0
  2. package/commonjs/src/caching/cache.decorator.js +69 -0
  3. package/commonjs/src/caching/cache.js +6 -0
  4. package/commonjs/src/caching/index.js +23 -0
  5. package/commonjs/src/caching/invalidate-cache.decorator.js +92 -0
  6. package/commonjs/src/caching/memoize.decorator.js +36 -0
  7. package/commonjs/src/caching/node-cache-memoize.adapter.js +49 -0
  8. package/commonjs/src/cli/action.js +65 -0
  9. package/commonjs/src/cli/command.js +127 -0
  10. package/commonjs/src/cli/index.js +61 -0
  11. package/commonjs/src/cli/module.type.js +18 -0
  12. package/commonjs/src/cli/options.js +115 -0
  13. package/commonjs/src/collections/collections.js +21 -0
  14. package/commonjs/src/collections/find-duplicates.js +35 -0
  15. package/commonjs/src/collections/index.js +52 -0
  16. package/commonjs/src/collections/merge-arrays.js +34 -0
  17. package/commonjs/src/collections/sum.js +63 -0
  18. package/commonjs/src/collections/unique-objects.js +39 -0
  19. package/commonjs/src/composition/index.js +4 -0
  20. package/commonjs/src/configuration/configuration.types.js +11 -0
  21. package/commonjs/src/configuration/index.js +18 -0
  22. package/commonjs/src/diagnostics/index.js +22 -0
  23. package/commonjs/src/diagnostics/trace.js +86 -0
  24. package/commonjs/src/extensibility/decorator-factory-base.js +22 -0
  25. package/commonjs/src/extensibility/decorator-factory.js +31 -0
  26. package/commonjs/src/extensibility/extension.js +37 -0
  27. package/commonjs/src/extensibility/index.js +23 -0
  28. package/commonjs/src/extensibility/mixwith.js +36 -0
  29. package/commonjs/src/extensibility/pipeline.js +56 -0
  30. package/commonjs/src/extensibility/step.js +18 -0
  31. package/commonjs/src/interop/docker/docker.js +54 -0
  32. package/commonjs/src/interop/errors/interop.error.js +12 -0
  33. package/commonjs/src/interop/git/git.js +134 -0
  34. package/commonjs/src/interop/git/git.types.js +4 -0
  35. package/commonjs/src/interop/index.js +97 -0
  36. package/commonjs/src/interop/node/index.js +18 -0
  37. package/commonjs/src/interop/node/node.js +45 -0
  38. package/commonjs/src/interop/npm/npm.js +231 -0
  39. package/commonjs/src/interop/npm/npm.types.js +16 -0
  40. package/commonjs/src/interop/pnpm/pnpm.js +34 -0
  41. package/commonjs/src/interop/pnpm/pnpm.types.js +4 -0
  42. package/commonjs/src/interop/shell/shell.argv.js +45 -0
  43. package/commonjs/src/interop/shell/shell.js +105 -0
  44. package/commonjs/src/interop/shell/shell.types.js +4 -0
  45. package/commonjs/src/interop/types/detect-package-manager.js +71 -0
  46. package/commonjs/src/interop/types/package-manager.js +4 -0
  47. package/commonjs/src/interop/yarn/yarn.js +34 -0
  48. package/commonjs/src/interop/yarn/yarn.types.js +4 -0
  49. package/commonjs/src/io/copy-file.js +25 -0
  50. package/commonjs/src/io/delete-file.js +21 -0
  51. package/commonjs/src/io/directory-exists.js +24 -0
  52. package/commonjs/src/io/file-exists.js +19 -0
  53. package/commonjs/src/io/find-directories.js +21 -0
  54. package/commonjs/src/io/find-file.js +45 -0
  55. package/commonjs/src/io/index.js +66 -0
  56. package/commonjs/src/io/io.js +28 -0
  57. package/commonjs/src/io/read-file.js +39 -0
  58. package/commonjs/src/io/remove-dir.js +22 -0
  59. package/commonjs/src/io/types/directory.type.js +4 -0
  60. package/commonjs/src/io/types/file.js +28 -0
  61. package/commonjs/src/io/types/index.js +19 -0
  62. package/commonjs/src/io/url-to-path.js +33 -0
  63. package/commonjs/src/io/watch.js +261 -0
  64. package/commonjs/src/io/write-file.js +30 -0
  65. package/commonjs/src/objects/deep-merge.js +67 -0
  66. package/commonjs/src/objects/index.js +11 -0
  67. package/commonjs/src/reflection/index.js +20 -0
  68. package/commonjs/src/reflection/types/index.js +18 -0
  69. package/commonjs/src/reflection/types/reflection.types.js +26 -0
  70. package/commonjs/src/reflection/utilities.js +118 -0
  71. package/commonjs/src/semver/index.js +18 -0
  72. package/commonjs/src/semver/semver.js +92 -0
  73. package/commonjs/src/system/camel-case.js +13 -0
  74. package/commonjs/src/system/debounce.js +19 -0
  75. package/commonjs/src/system/decorator.js +46 -0
  76. package/commonjs/src/system/environment.js +23 -0
  77. package/commonjs/src/system/function.types.js +18 -0
  78. package/commonjs/src/system/index.js +24 -0
  79. package/commonjs/src/system/retry.decorator.js +40 -0
  80. package/commonjs/src/system/sleep.js +13 -0
  81. package/commonjs/src/system/type.utils.js +4 -0
  82. package/commonjs/src/testing/flush-promises.js +16 -0
  83. package/commonjs/src/testing/glob-with-memfs.js +22 -0
  84. package/commonjs/src/testing/index.js +22 -0
  85. package/commonjs/src/testing/memfs.js +52 -0
  86. package/commonjs/src/testing/mock-logger.js +36 -0
  87. package/commonjs/src/testing/spy-on-constructor.js +27 -0
  88. package/es6/src/caching/cache-manager.js +82 -0
  89. package/es6/src/caching/cache.decorator.js +51 -0
  90. package/es6/src/caching/cache.js +3 -0
  91. package/es6/src/caching/index.js +6 -0
  92. package/es6/src/caching/invalidate-cache.decorator.js +71 -0
  93. package/es6/src/caching/memoize.decorator.js +27 -0
  94. package/es6/src/caching/node-cache-memoize.adapter.js +37 -0
  95. package/es6/src/cli/action.js +47 -0
  96. package/es6/src/cli/command.js +106 -0
  97. package/es6/src/cli/index.js +4 -0
  98. package/es6/src/cli/module.type.js +11 -0
  99. package/es6/src/cli/options.js +76 -0
  100. package/es6/src/collections/collections.js +4 -0
  101. package/es6/src/collections/find-duplicates.js +17 -0
  102. package/es6/src/collections/index.js +1 -0
  103. package/es6/src/collections/merge-arrays.js +16 -0
  104. package/es6/src/collections/sum.js +45 -0
  105. package/es6/src/collections/unique-objects.js +21 -0
  106. package/es6/src/composition/index.js +1 -0
  107. package/es6/src/configuration/configuration.types.js +1 -0
  108. package/es6/src/configuration/index.js +1 -0
  109. package/es6/src/diagnostics/index.js +1 -0
  110. package/es6/src/diagnostics/trace.js +68 -0
  111. package/es6/src/extensibility/decorator-factory-base.js +39 -0
  112. package/es6/src/extensibility/decorator-factory.js +21 -0
  113. package/es6/src/extensibility/extension.js +27 -0
  114. package/es6/src/extensibility/index.js +6 -0
  115. package/es6/src/extensibility/mixwith.js +26 -0
  116. package/es6/src/extensibility/pipeline.js +46 -0
  117. package/es6/src/extensibility/step.js +16 -0
  118. package/es6/src/interop/docker/docker.js +44 -0
  119. package/es6/src/interop/errors/interop.error.js +2 -0
  120. package/es6/src/interop/git/git.js +124 -0
  121. package/es6/src/interop/git/git.types.js +1 -0
  122. package/es6/src/interop/index.js +21 -0
  123. package/es6/src/interop/node/index.js +1 -0
  124. package/es6/src/interop/node/node.js +35 -0
  125. package/es6/src/interop/npm/npm.js +180 -0
  126. package/es6/src/interop/npm/npm.types.js +6 -0
  127. package/es6/src/interop/pnpm/pnpm.js +24 -0
  128. package/es6/src/interop/pnpm/pnpm.types.js +1 -0
  129. package/es6/src/interop/shell/shell.argv.js +35 -0
  130. package/es6/src/interop/shell/shell.js +95 -0
  131. package/es6/src/interop/shell/shell.types.js +1 -0
  132. package/es6/src/interop/types/detect-package-manager.js +50 -0
  133. package/es6/src/interop/types/package-manager.js +1 -0
  134. package/es6/src/interop/yarn/yarn.js +24 -0
  135. package/es6/src/interop/yarn/yarn.types.js +1 -0
  136. package/es6/src/io/copy-file.js +10 -0
  137. package/es6/src/io/delete-file.js +6 -0
  138. package/es6/src/io/directory-exists.js +9 -0
  139. package/es6/src/io/file-exists.js +9 -0
  140. package/es6/src/io/find-directories.js +11 -0
  141. package/es6/src/io/find-file.js +27 -0
  142. package/es6/src/io/index.js +2 -0
  143. package/es6/src/io/io.js +11 -0
  144. package/es6/src/io/read-file.js +13 -0
  145. package/es6/src/io/remove-dir.js +7 -0
  146. package/es6/src/io/types/directory.type.js +1 -0
  147. package/es6/src/io/types/file.js +18 -0
  148. package/es6/src/io/types/index.js +2 -0
  149. package/es6/src/io/url-to-path.js +15 -0
  150. package/es6/src/io/watch.js +238 -0
  151. package/es6/src/io/write-file.js +15 -0
  152. package/es6/src/objects/deep-merge.js +57 -0
  153. package/es6/src/objects/index.js +1 -0
  154. package/es6/src/reflection/index.js +3 -0
  155. package/es6/src/reflection/types/index.js +1 -0
  156. package/es6/src/reflection/types/reflection.types.js +8 -0
  157. package/es6/src/reflection/utilities.js +74 -0
  158. package/es6/src/semver/index.js +1 -0
  159. package/es6/src/semver/semver.js +71 -0
  160. package/es6/src/system/camel-case.js +3 -0
  161. package/es6/src/system/debounce.js +9 -0
  162. package/es6/src/system/decorator.js +30 -0
  163. package/es6/src/system/environment.js +5 -0
  164. package/es6/src/system/function.types.js +26 -0
  165. package/es6/src/system/index.js +7 -0
  166. package/es6/src/system/retry.decorator.js +30 -0
  167. package/es6/src/system/sleep.js +3 -0
  168. package/es6/src/system/type.utils.js +1 -0
  169. package/es6/src/testing/flush-promises.js +6 -0
  170. package/es6/src/testing/glob-with-memfs.js +20 -0
  171. package/es6/src/testing/index.js +5 -0
  172. package/es6/src/testing/memfs.js +25 -0
  173. package/es6/src/testing/mock-logger.js +26 -0
  174. package/es6/src/testing/spy-on-constructor.js +31 -0
  175. package/package.json +106 -0
  176. package/types/src/caching/cache-manager.d.ts +59 -0
  177. package/types/src/caching/cache.d.ts +11 -0
  178. package/types/src/caching/cache.decorator.d.ts +18 -0
  179. package/types/src/caching/index.d.ts +6 -0
  180. package/types/src/caching/invalidate-cache.decorator.d.ts +17 -0
  181. package/types/src/caching/memoize.decorator.d.ts +16 -0
  182. package/types/src/caching/node-cache-memoize.adapter.d.ts +22 -0
  183. package/types/src/cli/action.d.ts +36 -0
  184. package/types/src/cli/command.d.ts +34 -0
  185. package/types/src/cli/index.d.ts +7 -0
  186. package/types/src/cli/module.type.d.ts +36 -0
  187. package/types/src/cli/options.d.ts +28 -0
  188. package/types/src/collections/collections.d.ts +4 -0
  189. package/types/src/collections/find-duplicates.d.ts +2 -0
  190. package/types/src/collections/index.d.ts +1 -0
  191. package/types/src/collections/merge-arrays.d.ts +2 -0
  192. package/types/src/collections/sum.d.ts +4 -0
  193. package/types/src/collections/unique-objects.d.ts +2 -0
  194. package/types/src/composition/index.d.ts +37 -0
  195. package/types/src/configuration/configuration.types.d.ts +10 -0
  196. package/types/src/configuration/index.d.ts +1 -0
  197. package/types/src/diagnostics/index.d.ts +1 -0
  198. package/types/src/diagnostics/trace.d.ts +10 -0
  199. package/types/src/extensibility/decorator-factory-base.d.ts +39 -0
  200. package/types/src/extensibility/decorator-factory.d.ts +19 -0
  201. package/types/src/extensibility/extension.d.ts +9 -0
  202. package/types/src/extensibility/index.d.ts +6 -0
  203. package/types/src/extensibility/mixwith.d.ts +6 -0
  204. package/types/src/extensibility/pipeline.d.ts +12 -0
  205. package/types/src/extensibility/step.d.ts +16 -0
  206. package/types/src/interop/docker/docker.d.ts +19 -0
  207. package/types/src/interop/errors/interop.error.d.ts +2 -0
  208. package/types/src/interop/git/git.d.ts +16 -0
  209. package/types/src/interop/git/git.types.d.ts +14 -0
  210. package/types/src/interop/index.d.ts +14 -0
  211. package/types/src/interop/node/index.d.ts +1 -0
  212. package/types/src/interop/node/node.d.ts +5 -0
  213. package/types/src/interop/npm/npm.d.ts +29 -0
  214. package/types/src/interop/npm/npm.types.d.ts +24 -0
  215. package/types/src/interop/pnpm/pnpm.d.ts +9 -0
  216. package/types/src/interop/pnpm/pnpm.types.d.ts +3 -0
  217. package/types/src/interop/shell/shell.argv.d.ts +5 -0
  218. package/types/src/interop/shell/shell.d.ts +6 -0
  219. package/types/src/interop/shell/shell.types.d.ts +9 -0
  220. package/types/src/interop/types/detect-package-manager.d.ts +4 -0
  221. package/types/src/interop/types/package-manager.d.ts +10 -0
  222. package/types/src/interop/yarn/yarn.d.ts +9 -0
  223. package/types/src/interop/yarn/yarn.types.d.ts +3 -0
  224. package/types/src/io/copy-file.d.ts +4 -0
  225. package/types/src/io/delete-file.d.ts +1 -0
  226. package/types/src/io/directory-exists.d.ts +1 -0
  227. package/types/src/io/file-exists.d.ts +1 -0
  228. package/types/src/io/find-directories.d.ts +2 -0
  229. package/types/src/io/find-file.d.ts +9 -0
  230. package/types/src/io/index.d.ts +2 -0
  231. package/types/src/io/io.d.ts +11 -0
  232. package/types/src/io/read-file.d.ts +4 -0
  233. package/types/src/io/remove-dir.d.ts +5 -0
  234. package/types/src/io/types/directory.type.d.ts +4 -0
  235. package/types/src/io/types/file.d.ts +20 -0
  236. package/types/src/io/types/index.d.ts +2 -0
  237. package/types/src/io/url-to-path.d.ts +2 -0
  238. package/types/src/io/watch.d.ts +16 -0
  239. package/types/src/io/write-file.d.ts +5 -0
  240. package/types/src/objects/deep-merge.d.ts +41 -0
  241. package/types/src/objects/index.d.ts +1 -0
  242. package/types/src/reflection/index.d.ts +3 -0
  243. package/types/src/reflection/types/index.d.ts +1 -0
  244. package/types/src/reflection/types/reflection.types.d.ts +21 -0
  245. package/types/src/reflection/utilities.d.ts +27 -0
  246. package/types/src/semver/index.d.ts +1 -0
  247. package/types/src/semver/semver.d.ts +18 -0
  248. package/types/src/system/camel-case.d.ts +1 -0
  249. package/types/src/system/debounce.d.ts +1 -0
  250. package/types/src/system/decorator.d.ts +15 -0
  251. package/types/src/system/environment.d.ts +6 -0
  252. package/types/src/system/function.types.d.ts +55 -0
  253. package/types/src/system/index.d.ts +7 -0
  254. package/types/src/system/retry.decorator.d.ts +6 -0
  255. package/types/src/system/sleep.d.ts +1 -0
  256. package/types/src/system/type.utils.d.ts +1 -0
  257. package/types/src/testing/flush-promises.d.ts +1 -0
  258. package/types/src/testing/glob-with-memfs.d.ts +3 -0
  259. package/types/src/testing/index.d.ts +5 -0
  260. package/types/src/testing/memfs.d.ts +5 -0
  261. package/types/src/testing/mock-logger.d.ts +13 -0
  262. package/types/src/testing/spy-on-constructor.d.ts +21 -0
@@ -0,0 +1,7 @@
1
+ export type { Action, ActionClassMap, ActionOptions, Actions, MergeOptions, Result, ResultStatus, } from "./action.js";
2
+ export { ActionMap, ActionResponse } from "./action.js";
3
+ export type { CommandHandler, CommandType } from "./command.js";
4
+ export { CommandError, CommandResponse, DecohereCommand } from "./command.js";
5
+ export type { ApplicationModule, CommandMap as CommandClassMap, ModuleConfig, WorkspaceFactoryOptions, } from "./module.type.js";
6
+ export { ModuleManifest } from "./module.type.js";
7
+ export { ConfigFileOption, ConfigurationOption, DryRunOption, EnvFileIfExistsOption, EnvFileOption, LogLevelOption, NoBuildOptions, NoCleanOptions, ProjectOption, } from "./options.js";
@@ -0,0 +1,36 @@
1
+ import type { ContainerBuilder } from "../composition/index.js";
2
+ import type { ActionClassMap } from "./action.js";
3
+ import type { CommandType, DecohereCommand } from "./command.js";
4
+ export type CommandMap = Record<string, CommandType>;
5
+ export type WorkspaceFactoryOptions = {
6
+ configFile?: string;
7
+ rootDir?: string;
8
+ };
9
+ export interface ApplicationModule {
10
+ id: string;
11
+ dispose?(): void;
12
+ asyncDispose?(): Promise<void>;
13
+ command: DecohereCommand;
14
+ }
15
+ export type ModuleConfig = {
16
+ actions?: ActionClassMap;
17
+ commands?: CommandMap;
18
+ };
19
+ /**
20
+ * Simple declaration interface for a CLI module.
21
+ * Extend this and implement the four abstract members.
22
+ */
23
+ export declare abstract class ModuleManifest {
24
+ /** Unique module identifier, used as the root command name. */
25
+ abstract readonly id: string;
26
+ /** Sub-command classes this module contributes. */
27
+ readonly commands: CommandMap;
28
+ /** Action classes this module contributes. */
29
+ readonly actions: ActionClassMap;
30
+ /** The root command class for this module. */
31
+ abstract readonly command: CommandType;
32
+ /** Register infrastructure services into the DI container. */
33
+ registerServices(_builder: ContainerBuilder): void;
34
+ /** Lazily create a workspace instance. Return null if this module does not use a workspace. */
35
+ createWorkspace(_options: WorkspaceFactoryOptions): Promise<object | null>;
36
+ }
@@ -0,0 +1,28 @@
1
+ import { Option } from "commander";
2
+ export declare class ConfigurationOption extends Option {
3
+ constructor(defaultValue: string);
4
+ }
5
+ export declare class ConfigFileOption extends Option {
6
+ constructor(defaultValue?: string);
7
+ }
8
+ export declare class LogLevelOption extends Option {
9
+ constructor();
10
+ }
11
+ export declare class EnvFileOption extends Option {
12
+ constructor();
13
+ }
14
+ export declare class EnvFileIfExistsOption extends Option {
15
+ constructor();
16
+ }
17
+ export declare class NoCleanOptions extends Option {
18
+ constructor(defaultValue: boolean);
19
+ }
20
+ export declare class NoBuildOptions extends Option {
21
+ constructor(defaultValue: boolean);
22
+ }
23
+ export declare class DryRunOption extends Option {
24
+ constructor(description: string, defaultValue?: boolean);
25
+ }
26
+ export declare class ProjectOption extends Option {
27
+ constructor();
28
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./find-duplicates.js";
2
+ export * from "./merge-arrays.js";
3
+ export * from "./sum.js";
4
+ export * from "./unique-objects.js";
@@ -0,0 +1,2 @@
1
+ export declare function findDuplicatesByKey<T>(items: T[], key: keyof T): [string, T[]][];
2
+ export declare function findDuplicatesBy<T>(items: T[], selector: (item: T) => string): [string, T[]][];
@@ -0,0 +1 @@
1
+ export * as collections from "./collections.js";
@@ -0,0 +1,2 @@
1
+ export declare function mergeByKey<T>(first: T[], second: T[], key: keyof T): T[];
2
+ export declare function mergeBy<T>(first: T[], second: T[], selector: (item: T) => string): T[];
@@ -0,0 +1,4 @@
1
+ export declare function sumByKey<T>(objects: T[], key: keyof T): number;
2
+ export declare function sumByKey<T>(objects: T[], key: keyof T): bigint;
3
+ export declare function sumBy<T>(objects: T[], key: (obj: T) => number): number;
4
+ export declare function sumBy<T>(objects: T[], key: (obj: T) => bigint): bigint;
@@ -0,0 +1,2 @@
1
+ export declare function uniqueObjectsByKey<T>(objects: T[], key: keyof T): T[];
2
+ export declare function uniqueObjectsBy<T>(objects: T[], key: (obj: T) => string): T[];
@@ -0,0 +1,37 @@
1
+ import type { Constructable } from "../reflection/index.js";
2
+ export type ResolveRequest<T extends object = object> = string | symbol | Constructable<T>;
3
+ export type Scope = "single-instance" | "request" | "transient";
4
+ export interface ServiceProvider {
5
+ /**
6
+ * @param key
7
+ * @throws {ServiceNotFoundException}
8
+ */
9
+ resolve<T extends object>(key: ResolveRequest<T>): T;
10
+ resolveMany<T extends object = object>(resolveRequest: ResolveRequest<T>): T[];
11
+ }
12
+ export interface LifetimeScope extends ServiceProvider {
13
+ /** A name must be unique among open scopes; omit it for per-request scopes. */
14
+ beginScope(name?: string): LifetimeScope;
15
+ [Symbol.dispose](): void;
16
+ [Symbol.asyncDispose](): Promise<void>;
17
+ }
18
+ export interface IContainer extends LifetimeScope {
19
+ }
20
+ export interface ContainerRegistrar {
21
+ registerTransient(key: string | symbol, type: Constructable): unknown;
22
+ registerTransient(type: Constructable): unknown;
23
+ registerRequestScoped<T>(type: () => T): unknown;
24
+ registerRequestScoped<T>(key: string | symbol, type: () => T): unknown;
25
+ registerRequestScoped(key: string | symbol, type: Constructable): unknown;
26
+ registerRequestScoped(type: Constructable): unknown;
27
+ registerSingleton(key: string | symbol | Constructable, instance: object): unknown;
28
+ registerSingleton(key: string | symbol, type: Constructable): unknown;
29
+ registerSingleton(type: Constructable): unknown;
30
+ registerType(type: Constructable, scope?: Scope): unknown;
31
+ registerTypes(...types: Constructable[]): unknown[];
32
+ registerTypes(scope: Scope, ...types: Constructable[]): unknown[];
33
+ }
34
+ export interface ContainerBuilder extends ContainerRegistrar {
35
+ readonly override: ContainerRegistrar;
36
+ build(): IContainer;
37
+ }
@@ -0,0 +1,10 @@
1
+ import type { Constructable } from "../reflection/index.js";
2
+ export declare const ConfigurationServiceToken: unique symbol;
3
+ export interface IConfigurationService {
4
+ readonly dataSources: readonly IConfigurationDataSource[];
5
+ get<T extends object>(typeOrString: Constructable<T> | string): Promise<T>;
6
+ }
7
+ export interface IConfigurationDataSource {
8
+ readonly name: string;
9
+ getData(): Promise<Record<string, unknown>>;
10
+ }
@@ -0,0 +1 @@
1
+ export * from "./configuration.types.js";
@@ -0,0 +1 @@
1
+ export { Trace, timed, trace } from "./trace.js";
@@ -0,0 +1,10 @@
1
+ export declare function trace(target: object, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
2
+ /**
3
+ * Always-on method timing. Logs duration at `info` regardless of `FORGE_TRACE`.
4
+ * Use this to time a specific method without raising the process log level.
5
+ */
6
+ export declare function timed(target: object, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
7
+ export declare function Trace(constructor: {
8
+ name: string;
9
+ prototype: object;
10
+ }): void;
@@ -0,0 +1,39 @@
1
+ import type { FunctionDecorator } from "./decorator-factory.js";
2
+ /**
3
+ * Base class for creating decorator factory instances with methods that can be
4
+ * conditionally disabled during unit testing.
5
+ *
6
+ * Example usage:
7
+ * ```typescript
8
+ * class MyDecoratorFactory extends DecoratorFactory {
9
+ * @ignoreInUnitTest
10
+ * cache(options?: CacheOptions) {
11
+ * return cache(options);
12
+ * }
13
+ *
14
+ * @ignoreInUnitTest
15
+ * logger(options?: LoggerOptions) {
16
+ * return logger(options);
17
+ * }
18
+ * }
19
+ *
20
+ * const decorators = new MyDecoratorFactory();
21
+ *
22
+ * class TestClass {
23
+ * @decorators.cache({ ttl: 1000 })
24
+ * async getData() {
25
+ * // This decorator will be disabled when TEST=true
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ export declare abstract class DecoratorFactoryBase {
31
+ /**
32
+ * Utility method to check if we're currently in a test environment
33
+ */
34
+ protected isTestEnvironment(): boolean;
35
+ /**
36
+ * Creates a no-op decorator that returns the original function unchanged
37
+ */
38
+ protected createNoOpDecorator(): FunctionDecorator;
39
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Decorator factory class that provides decorator methods which can be conditionally
3
+ * disabled during unit testing using the @ignoreInUnitTest decorator.
4
+ *
5
+ * Inspired by: https://jasonharper.blog/2018/03/13/decorate-the-decorator-to-exclude-in-unit-testing/
6
+ */
7
+ /**
8
+ * Decorator that disables the decorated decorator method when TEST environment variable is true.
9
+ * If TEST=true, it returns a no-op decorator that simply returns the original function unchanged.
10
+ */
11
+ export declare function ignoreInUnitTest(_target: object, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
12
+ /**
13
+ * Type definition for a function decorator
14
+ */
15
+ export type FunctionDecorator = (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor | undefined;
16
+ /**
17
+ * Type definition for a decorator factory function (returns a decorator)
18
+ */
19
+ export type DecoratorFactory<TOptions = unknown> = (options?: TOptions) => FunctionDecorator;
@@ -0,0 +1,9 @@
1
+ import type { Type } from "../reflection/types/reflection.types.js";
2
+ export type ExtensionOptions = {
3
+ /**
4
+ * Also install the method on the constructor. Use for singleton facades
5
+ * (`scribe.withPinoPretty()`) whose instance lives at `ctor.instance`.
6
+ */
7
+ static?: boolean;
8
+ };
9
+ export declare function extension(ctor: Type, options?: ExtensionOptions): (_target: object, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -0,0 +1,6 @@
1
+ export * from "./decorator-factory.js";
2
+ export * from "./decorator-factory-base.js";
3
+ export * from "./extension.js";
4
+ export * from "./mixwith.js";
5
+ export * from "./pipeline.js";
6
+ export * from "./step.js";
@@ -0,0 +1,6 @@
1
+ type Constructor<T = object> = abstract new (...args: unknown[]) => T;
2
+ type UnionToIntersection<T> = (T extends unknown ? (arg: T) => void : never) extends (arg: infer TResult) => void ? TResult : never;
3
+ type MixedInstance<TMixins extends readonly Constructor[]> = UnionToIntersection<InstanceType<TMixins[number]>>;
4
+ type MixedClass<TMixins extends readonly Constructor[]> = abstract new (...args: unknown[]) => MixedInstance<TMixins>;
5
+ export declare function mixwith<TMixins extends readonly Constructor[]>(...mixins: TMixins): MixedClass<TMixins>;
6
+ export {};
@@ -0,0 +1,12 @@
1
+ export interface PipelineStep<TContext extends Record<string, unknown> = Record<string, unknown>> {
2
+ run(ctx: TContext, next: Next): Promise<void> | void;
3
+ }
4
+ export type Next = () => Promise<void> | void;
5
+ export declare class Pipeline<T extends Record<string, unknown>> {
6
+ private readonly stack;
7
+ private readonly logger;
8
+ private currentStep;
9
+ constructor(...steps: [string, PipelineStep<T>, ((ctx: T) => boolean)?][]);
10
+ [Symbol.dispose](): void;
11
+ start(context: T): Promise<void>;
12
+ }
@@ -0,0 +1,16 @@
1
+ import type { Constructable } from "../reflection/index.js";
2
+ import type { PipelineStep } from "./pipeline.js";
3
+ /**
4
+ * Wraps a pipeline step with an optional `when` predicate.
5
+ * When `when` is provided, the step only runs if `when(ctx)` returns `true`.
6
+ * If `when` returns `false`, the pipeline logs `"Skipping step <name>"` and
7
+ * advances to the next step without invoking `run()`.
8
+ *
9
+ * Predicates are declared in the command constructor via `addDisableStepOption`,
10
+ * keeping skip conditions co-located with the option that controls them.
11
+ */
12
+ export declare class Step<T extends Record<string, unknown> = Record<string, unknown>> {
13
+ readonly type: Constructable<PipelineStep<T>>;
14
+ readonly when?: (ctx: T) => boolean;
15
+ constructor(type: Constructable<PipelineStep<T>>, when?: (ctx: T) => boolean);
16
+ }
@@ -0,0 +1,19 @@
1
+ import { Shell } from "../shell/shell.js";
2
+ export type DockerBuildOptions = {
3
+ cwd?: string;
4
+ dockerfile?: string;
5
+ tags?: string[];
6
+ buildArgs?: Record<string, string>;
7
+ secrets?: Record<string, string>;
8
+ noCache?: boolean;
9
+ pull?: boolean;
10
+ };
11
+ export type DockerPushOptions = {
12
+ cwd?: string;
13
+ };
14
+ export declare class Docker extends Shell {
15
+ readonly name: "docker";
16
+ protected program: string;
17
+ build(contextDir: string, options?: DockerBuildOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
18
+ push(tag: string, options?: DockerPushOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
19
+ }
@@ -0,0 +1,2 @@
1
+ export declare class InteropError extends Error {
2
+ }
@@ -0,0 +1,16 @@
1
+ import { Shell } from "../shell/shell.js";
2
+ import type { ShellResponse } from "../shell/shell.types.js";
3
+ import type { CommitOptions, GitOptions, PushOptions, StageOptions } from "./git.types.js";
4
+ export declare class Git extends Shell {
5
+ protected program: string;
6
+ getModifiedFiles(options?: GitOptions): Promise<string[]>;
7
+ getBranchName(options?: GitOptions): Promise<string>;
8
+ tag(tag: string, options?: GitOptions): Promise<ShellResponse>;
9
+ pushTag(tag: string, options?: GitOptions & {
10
+ remote?: string;
11
+ }): Promise<ShellResponse>;
12
+ commit(message: string, options: CommitOptions): Promise<ShellResponse>;
13
+ push(branch: string, options?: PushOptions): Promise<ShellResponse>;
14
+ pull(branch: string, options?: GitOptions): Promise<ShellResponse>;
15
+ stage(options: StageOptions): Promise<void>;
16
+ }
@@ -0,0 +1,14 @@
1
+ export type GitOptions = {
2
+ cwd?: string;
3
+ };
4
+ export type CommitOptions = {
5
+ files?: string[];
6
+ all?: boolean;
7
+ } & GitOptions;
8
+ export type PushOptions = {
9
+ setUpstream: string;
10
+ } & GitOptions;
11
+ export type StageOptions = {
12
+ files?: string[];
13
+ all?: string;
14
+ };
@@ -0,0 +1,14 @@
1
+ export * from "./docker/docker.js";
2
+ export * from "./git/git.js";
3
+ export * as git from "./git/git.types.js";
4
+ export * from "./node/node.js";
5
+ export * from "./npm/npm.js";
6
+ export * as npm from "./npm/npm.types.js";
7
+ export * from "./pnpm/pnpm.js";
8
+ export * as pnpm from "./pnpm/pnpm.types.js";
9
+ export * from "./shell/shell.js";
10
+ export * as shell from "./shell/shell.types.js";
11
+ export * from "./types/detect-package-manager.js";
12
+ export * from "./types/package-manager.js";
13
+ export * from "./yarn/yarn.js";
14
+ export * as yarn from "./yarn/yarn.types.js";
@@ -0,0 +1 @@
1
+ export * from "./node.js";
@@ -0,0 +1,5 @@
1
+ import { Shell } from "../shell/shell.js";
2
+ export declare class Node extends Shell {
3
+ protected program: string;
4
+ runScript(script: string, ...args: string[]): Promise<unknown>;
5
+ }
@@ -0,0 +1,29 @@
1
+ import { Shell } from "../shell/shell.js";
2
+ import type { PackageManager } from "../types/package-manager.js";
3
+ import type { NpmOptions, PublishOptions, VersionOptions, VersionType } from "./npm.types.js";
4
+ export declare class Npm extends Shell implements PackageManager {
5
+ readonly name: "npm";
6
+ protected program: string;
7
+ publish(directory: string, options?: PublishOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
8
+ /**
9
+ * @description Runs in the directory of the package
10
+ * @param options
11
+ * @returns
12
+ */
13
+ version(versionType: VersionType, options: VersionOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
14
+ link(directory: string, options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
15
+ install(options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
16
+ /**
17
+ * Install only `dependencies` as real folders: `--omit=dev` skips devDependencies and
18
+ * `--no-bin-links` skips the `.bin` symlinks, so the result holds no symlinks at all.
19
+ */
20
+ installProduction(options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
21
+ syncLockFile(options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
22
+ /**
23
+ * True when package@version exists on the registry.
24
+ * Uses ambient npm config (cwd `.npmrc`); do not pass tokens on argv.
25
+ */
26
+ private isPublished;
27
+ private createTempUserConfig;
28
+ private removeTempUserConfig;
29
+ }
@@ -0,0 +1,24 @@
1
+ export type NpmOptions = {
2
+ cwd?: string;
3
+ };
4
+ export type PublishOptions = {
5
+ dryRun?: boolean;
6
+ skipIfPublished?: boolean;
7
+ authToken?: string;
8
+ otp?: string;
9
+ provenance?: boolean;
10
+ /** @deprecated use channel */
11
+ versionType?: VersionType;
12
+ channel?: string;
13
+ } & NpmOptions;
14
+ export type VersionType = "major" | "minor" | "patch" | "prerelease";
15
+ export declare const VersionTypes: {
16
+ major: "major";
17
+ minor: "minor";
18
+ patch: "patch";
19
+ prerelease: "prerelease";
20
+ };
21
+ export type VersionOptions = {
22
+ preid?: string;
23
+ noTag?: boolean;
24
+ } & NpmOptions;
@@ -0,0 +1,9 @@
1
+ import { Shell } from "../shell/shell.js";
2
+ import type { PackageManager } from "../types/package-manager.js";
3
+ import type { PnpmOptions } from "./pnpm.types.js";
4
+ export declare class Pnpm extends Shell implements PackageManager {
5
+ readonly name: "pnpm";
6
+ protected program: string;
7
+ install(options?: PnpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
8
+ syncLockFile(options?: PnpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
9
+ }
@@ -0,0 +1,3 @@
1
+ export type PnpmOptions = {
2
+ cwd?: string;
3
+ };
@@ -0,0 +1,5 @@
1
+ declare function fields(args: string[]): Record<string, string | boolean | string[]>;
2
+ export declare const shellArgv: {
3
+ fields: typeof fields;
4
+ };
5
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { ShellOptions, ShellResponse } from "./shell.types.js";
2
+ export declare abstract class Shell {
3
+ protected abstract program: string;
4
+ protected run(options: ShellOptions, ...args: string[]): Promise<ShellResponse>;
5
+ private parseStream;
6
+ }
@@ -0,0 +1,9 @@
1
+ export type ShellResponse = {
2
+ message: string;
3
+ data: string[];
4
+ };
5
+ export interface ShellOptions {
6
+ cwd?: string;
7
+ /** Spawn env. Defaults to `process.env`. Not written to logs. */
8
+ env?: NodeJS.ProcessEnv;
9
+ }
@@ -0,0 +1,4 @@
1
+ import type { PackageManager } from "./package-manager.js";
2
+ export declare function detectPackageManager(cwd: string): PackageManager | undefined;
3
+ export declare function packageManagerFromString(name: string): PackageManager;
4
+ export declare function promptForPackageManager(): Promise<PackageManager>;
@@ -0,0 +1,10 @@
1
+ import type { ShellResponse } from "../shell/shell.types.js";
2
+ export interface PackageManager {
3
+ readonly name: "npm" | "pnpm" | "yarn";
4
+ install(options?: {
5
+ cwd?: string;
6
+ }): Promise<ShellResponse>;
7
+ syncLockFile(options?: {
8
+ cwd?: string;
9
+ }): Promise<ShellResponse>;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { Shell } from "../shell/shell.js";
2
+ import type { PackageManager } from "../types/package-manager.js";
3
+ import type { YarnOptions } from "./yarn.types.js";
4
+ export declare class Yarn extends Shell implements PackageManager {
5
+ readonly name: "yarn";
6
+ protected program: string;
7
+ install(options?: YarnOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
8
+ syncLockFile(options?: YarnOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
9
+ }
@@ -0,0 +1,3 @@
1
+ export type YarnOptions = {
2
+ cwd?: string;
3
+ };
@@ -0,0 +1,4 @@
1
+ export type CopyFileOptions = {
2
+ mkdir?: boolean;
3
+ };
4
+ export declare function copyFile(src: string, dest: string, options?: CopyFileOptions): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function deleteFile(filePath: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function directoryExists(path: string): Promise<boolean>;
@@ -0,0 +1 @@
1
+ export declare function fileExists(path: string): Promise<boolean>;
@@ -0,0 +1,2 @@
1
+ import type { Directory } from "./types/directory.type.js";
2
+ export declare function findDirectories(...pattern: string[]): Promise<Directory[]>;
@@ -0,0 +1,9 @@
1
+ import { FileEx } from "./types/file.js";
2
+ export type FindFileOptions = {
3
+ cwd: string;
4
+ ignore?: string | string[];
5
+ };
6
+ export declare function findFile(pattern: string): Promise<{
7
+ relativePath: string;
8
+ }>;
9
+ export declare function findFiles(patterns: string[], options?: FindFileOptions): Promise<FileEx[]>;
@@ -0,0 +1,2 @@
1
+ export * as io from "./io.js";
2
+ export * from "./types/index.js";
@@ -0,0 +1,11 @@
1
+ export * from "./copy-file.js";
2
+ export * from "./delete-file.js";
3
+ export * from "./directory-exists.js";
4
+ export * from "./file-exists.js";
5
+ export * from "./find-directories.js";
6
+ export * from "./find-file.js";
7
+ export * from "./read-file.js";
8
+ export * from "./remove-dir.js";
9
+ export * from "./url-to-path.js";
10
+ export * from "./watch.js";
11
+ export * from "./write-file.js";
@@ -0,0 +1,4 @@
1
+ import type { File } from "./types/file.js";
2
+ export declare function readFiles(filePaths: File[], encoding?: BufferEncoding): Promise<string[]>;
3
+ export declare function readFile(filePath: string, encoding?: BufferEncoding): Promise<string>;
4
+ export declare function readJsonFile<T>(filePath: string, encoding?: BufferEncoding): Promise<T>;
@@ -0,0 +1,5 @@
1
+ export type RemoveDirOptions = {
2
+ force: boolean;
3
+ recursive: boolean;
4
+ };
5
+ export declare function removeDir(path: string, options?: RemoveDirOptions): Promise<void>;
@@ -0,0 +1,4 @@
1
+ export type Directory = {
2
+ name: string;
3
+ parentPath: string;
4
+ };
@@ -0,0 +1,20 @@
1
+ export type File = {
2
+ fullPath: string;
3
+ relativePath: string;
4
+ };
5
+ export declare class FileEx implements File {
6
+ #private;
7
+ constructor(data: Partial<File> & {
8
+ content?: string;
9
+ });
10
+ fullPath: string;
11
+ relativePath: string;
12
+ toString(): string;
13
+ getContent(): Promise<string>;
14
+ }
15
+ export type Watcher = {
16
+ readonly ready: Promise<void>;
17
+ on(event: "ready", handler: () => unknown): Watcher;
18
+ on(event: "add" | "change" | "addDir" | "unlink" | "unlinkDir", handler: (file: File) => unknown): Watcher;
19
+ close(): void;
20
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./directory.type.js";
2
+ export * from "./file.js";
@@ -0,0 +1,2 @@
1
+ export declare const fileUrlToPath: (url: string) => string;
2
+ export declare const pathToFileUrl: (path: string) => string;
@@ -0,0 +1,16 @@
1
+ import { type Watcher } from "./types/file.js";
2
+ export type WatchOptions = {
3
+ include?: string[];
4
+ ignore?: string[];
5
+ cwd?: string;
6
+ ignoreInitial?: boolean;
7
+ };
8
+ export type WatchEventName = "add" | "change" | "addDir" | "unlink" | "unlinkDir";
9
+ export declare const WatchEvents: {
10
+ add: "add";
11
+ change: "change";
12
+ addDir: "addDir";
13
+ unlink: "unlink";
14
+ unlinkDir: "unlinkDir";
15
+ };
16
+ export declare function watch(directory: string, options?: WatchOptions): Watcher;
@@ -0,0 +1,5 @@
1
+ export type WriteFileOptions = {
2
+ mkdir?: boolean;
3
+ encoding?: BufferEncoding;
4
+ };
5
+ export declare function writeFile(filePath: string, content: string, options?: WriteFileOptions): Promise<void>;