@docker-harpoon/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/api/index.d.ts +7 -0
  2. package/dist/api/index.d.ts.map +1 -0
  3. package/dist/api/index.js +10 -0
  4. package/dist/api/promise.d.ts +179 -0
  5. package/dist/api/promise.d.ts.map +1 -0
  6. package/dist/api/promise.js +282 -0
  7. package/dist/bindings/index.d.ts +8 -0
  8. package/dist/bindings/index.d.ts.map +1 -0
  9. package/dist/bindings/index.js +6 -0
  10. package/dist/bindings/types.d.ts +116 -0
  11. package/dist/bindings/types.d.ts.map +1 -0
  12. package/dist/bindings/types.js +46 -0
  13. package/dist/build-strategies/index.d.ts +30 -0
  14. package/dist/build-strategies/index.d.ts.map +1 -0
  15. package/dist/build-strategies/index.js +47 -0
  16. package/dist/build-strategies/standard.d.ts +16 -0
  17. package/dist/build-strategies/standard.d.ts.map +1 -0
  18. package/dist/build-strategies/standard.js +39 -0
  19. package/dist/build-strategies/types.d.ts +81 -0
  20. package/dist/build-strategies/types.d.ts.map +1 -0
  21. package/dist/build-strategies/types.js +25 -0
  22. package/dist/config-patchers/index.d.ts +33 -0
  23. package/dist/config-patchers/index.d.ts.map +1 -0
  24. package/dist/config-patchers/index.js +75 -0
  25. package/dist/config-patchers/types.d.ts +89 -0
  26. package/dist/config-patchers/types.d.ts.map +1 -0
  27. package/dist/config-patchers/types.js +25 -0
  28. package/dist/dockerfile-transformers/core.d.ts +59 -0
  29. package/dist/dockerfile-transformers/core.d.ts.map +1 -0
  30. package/dist/dockerfile-transformers/core.js +271 -0
  31. package/dist/dockerfile-transformers/index.d.ts +42 -0
  32. package/dist/dockerfile-transformers/index.d.ts.map +1 -0
  33. package/dist/dockerfile-transformers/index.js +67 -0
  34. package/dist/dockerfile-transformers/types.d.ts +116 -0
  35. package/dist/dockerfile-transformers/types.d.ts.map +1 -0
  36. package/dist/dockerfile-transformers/types.js +29 -0
  37. package/dist/errors.d.ts +75 -0
  38. package/dist/errors.d.ts.map +1 -0
  39. package/dist/errors.js +119 -0
  40. package/dist/helpers/database.d.ts +54 -0
  41. package/dist/helpers/database.d.ts.map +1 -0
  42. package/dist/helpers/database.js +108 -0
  43. package/dist/helpers/index.d.ts +8 -0
  44. package/dist/helpers/index.d.ts.map +1 -0
  45. package/dist/helpers/index.js +6 -0
  46. package/dist/index.d.ts +41 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +44 -0
  49. package/dist/resources/container.d.ts +42 -0
  50. package/dist/resources/container.d.ts.map +1 -0
  51. package/dist/resources/container.js +256 -0
  52. package/dist/resources/image.d.ts +37 -0
  53. package/dist/resources/image.d.ts.map +1 -0
  54. package/dist/resources/image.js +113 -0
  55. package/dist/resources/index.d.ts +12 -0
  56. package/dist/resources/index.d.ts.map +1 -0
  57. package/dist/resources/index.js +8 -0
  58. package/dist/resources/network.d.ts +21 -0
  59. package/dist/resources/network.d.ts.map +1 -0
  60. package/dist/resources/network.js +86 -0
  61. package/package.json +28 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Build Strategies Registry
3
+ *
4
+ * Central registry for build strategy implementations.
5
+ * Provides factory functions and strategy lookup.
6
+ *
7
+ * Note: Tool-specific strategies (monorepo simulation, etc.) are provided
8
+ * by their respective binding packages (@harpoon/monorepo, etc.)
9
+ */
10
+ import type { BuildStrategy, BuildStrategyRegistry } from './types';
11
+ export { BuildStrategyError } from './types';
12
+ export type { BuildStrategy, BuildStrategyInput, BuildContext, BuildStrategyRegistry, } from './types';
13
+ /**
14
+ * Build strategy registry singleton.
15
+ */
16
+ export declare const buildStrategyRegistry: BuildStrategyRegistry;
17
+ /**
18
+ * Register a build strategy.
19
+ */
20
+ export declare function registerBuildStrategy(strategy: BuildStrategy): void;
21
+ /**
22
+ * Get a build strategy by name.
23
+ */
24
+ export declare function getBuildStrategy(name: string): BuildStrategy | undefined;
25
+ /**
26
+ * List all registered build strategy names.
27
+ */
28
+ export declare function listBuildStrategies(): readonly string[];
29
+ export { standardStrategy } from './standard';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build-strategies/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,qBAQnC,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAEnE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAExE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,MAAM,EAAE,CAEvD;AAUD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Build Strategies Registry
3
+ *
4
+ * Central registry for build strategy implementations.
5
+ * Provides factory functions and strategy lookup.
6
+ *
7
+ * Note: Tool-specific strategies (monorepo simulation, etc.) are provided
8
+ * by their respective binding packages (@harpoon/monorepo, etc.)
9
+ */
10
+ // Re-export types
11
+ export { BuildStrategyError } from './types';
12
+ // ============ Registry Implementation ============
13
+ const strategies = new Map();
14
+ /**
15
+ * Build strategy registry singleton.
16
+ */
17
+ export const buildStrategyRegistry = {
18
+ get: (name) => strategies.get(name),
19
+ register: (strategy) => {
20
+ strategies.set(strategy.name, strategy);
21
+ },
22
+ list: () => Object.freeze([...strategies.keys()]),
23
+ };
24
+ /**
25
+ * Register a build strategy.
26
+ */
27
+ export function registerBuildStrategy(strategy) {
28
+ buildStrategyRegistry.register(strategy);
29
+ }
30
+ /**
31
+ * Get a build strategy by name.
32
+ */
33
+ export function getBuildStrategy(name) {
34
+ return buildStrategyRegistry.get(name);
35
+ }
36
+ /**
37
+ * List all registered build strategy names.
38
+ */
39
+ export function listBuildStrategies() {
40
+ return buildStrategyRegistry.list();
41
+ }
42
+ // ============ Built-in Strategies ============
43
+ import { standardStrategy } from './standard';
44
+ // Register only the standard (generic) strategy
45
+ registerBuildStrategy(standardStrategy);
46
+ // Re-export
47
+ export { standardStrategy } from './standard';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Standard Build Strategy
3
+ *
4
+ * Passthrough strategy that uses the provided context as-is.
5
+ * No build context transformation is performed.
6
+ */
7
+ import type { BuildStrategy } from './types';
8
+ /**
9
+ * Standard build strategy.
10
+ *
11
+ * Uses the build context as-is without any transformation.
12
+ * Validates that the Dockerfile exists.
13
+ */
14
+ export declare const standardStrategy: BuildStrategy;
15
+ export default standardStrategy;
16
+ //# sourceMappingURL=standard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../src/build-strategies/standard.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAoC,MAAM,SAAS,CAAC;AAK/E;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,aA4B9B,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Standard Build Strategy
3
+ *
4
+ * Passthrough strategy that uses the provided context as-is.
5
+ * No build context transformation is performed.
6
+ */
7
+ import { Effect } from 'effect';
8
+ import * as path from 'path';
9
+ import * as fs from 'fs/promises';
10
+ import { BuildStrategyError } from './types';
11
+ // ============ Strategy Implementation ============
12
+ /**
13
+ * Standard build strategy.
14
+ *
15
+ * Uses the build context as-is without any transformation.
16
+ * Validates that the Dockerfile exists.
17
+ */
18
+ export const standardStrategy = {
19
+ name: 'standard',
20
+ description: 'Standard Dockerfile build with no context transformation',
21
+ prepare: (input) => Effect.gen(function* () {
22
+ const dockerfilePath = input.dockerfile
23
+ ? path.resolve(input.context, input.dockerfile)
24
+ : path.resolve(input.context, 'Dockerfile');
25
+ // Verify Dockerfile exists
26
+ yield* Effect.tryPromise({
27
+ try: () => fs.access(dockerfilePath),
28
+ catch: () => new BuildStrategyError('standard', `Dockerfile not found at ${dockerfilePath} for ${input.tag}`),
29
+ });
30
+ const result = {
31
+ contextPath: input.context,
32
+ dockerfilePath,
33
+ requiresCleanup: false,
34
+ };
35
+ return result;
36
+ }),
37
+ };
38
+ // Export as default
39
+ export default standardStrategy;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Build Strategy Types
3
+ *
4
+ * Interfaces for pluggable Docker build context preparation strategies.
5
+ * Strategies prepare the build context before invoking docker build.
6
+ */
7
+ import { Effect } from 'effect';
8
+ /**
9
+ * Input provided to a build strategy.
10
+ */
11
+ export interface BuildStrategyInput {
12
+ /** Docker image tag to build */
13
+ readonly tag: string;
14
+ /** Path to the build context directory */
15
+ readonly context: string;
16
+ /** Optional path to Dockerfile relative to context */
17
+ readonly dockerfile?: string;
18
+ /** Docker build arguments */
19
+ readonly buildArgs?: Readonly<Record<string, string>>;
20
+ /** App name for monorepo strategies */
21
+ readonly monorepoAppName?: string;
22
+ /** Source directory for shared monorepo folders */
23
+ readonly monorepoSource?: string;
24
+ /** Strategy-specific options */
25
+ readonly options?: Readonly<Record<string, unknown>>;
26
+ }
27
+ /**
28
+ * Result of build context preparation.
29
+ */
30
+ export interface BuildContext {
31
+ /** Path to the prepared build context */
32
+ readonly contextPath: string;
33
+ /** Path to the Dockerfile to use */
34
+ readonly dockerfilePath: string;
35
+ /** Whether the context is a temp directory requiring cleanup */
36
+ readonly requiresCleanup: boolean;
37
+ /** Optional modified Dockerfile content */
38
+ readonly dockerfileContent?: string;
39
+ /** Temp directory path (if requiresCleanup is true) */
40
+ readonly tempDir?: string;
41
+ }
42
+ /**
43
+ * Error during build strategy execution.
44
+ */
45
+ export declare class BuildStrategyError extends Error {
46
+ readonly _tag: "BuildStrategyError";
47
+ readonly strategyName: string;
48
+ readonly cause?: Error | undefined;
49
+ constructor(strategyName: string, message: string, cause?: Error);
50
+ }
51
+ /**
52
+ * A pluggable build strategy.
53
+ *
54
+ * Strategies transform the build context before docker build is invoked.
55
+ * Examples: standard (passthrough), monorepo-simulation, template-substitution
56
+ */
57
+ export interface BuildStrategy {
58
+ /** Unique strategy identifier */
59
+ readonly name: string;
60
+ /** Human-readable description */
61
+ readonly description: string;
62
+ /**
63
+ * Prepare the build context.
64
+ *
65
+ * @param input Build strategy input
66
+ * @returns Effect yielding the prepared build context
67
+ */
68
+ readonly prepare: (input: BuildStrategyInput) => Effect.Effect<BuildContext, BuildStrategyError>;
69
+ }
70
+ /**
71
+ * Registry of available build strategies.
72
+ */
73
+ export interface BuildStrategyRegistry {
74
+ /** Get a strategy by name */
75
+ readonly get: (name: string) => BuildStrategy | undefined;
76
+ /** Register a new strategy */
77
+ readonly register: (strategy: BuildStrategy) => void;
78
+ /** List all registered strategy names */
79
+ readonly list: () => readonly string[];
80
+ }
81
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/build-strategies/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gCAAgC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,sDAAsD;IACtD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM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AW,qBAAqB;IACpC,6BAA6B;IAC7B,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAE1D,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;IAErD,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;CACxC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Build Strategy Types
3
+ *
4
+ * Interfaces for pluggable Docker build context preparation strategies.
5
+ * Strategies prepare the build context before invoking docker build.
6
+ */
7
+ /**
8
+ * Error during build strategy execution.
9
+ */
10
+ export class BuildStrategyError extends Error {
11
+ _tag = 'BuildStrategyError';
12
+ strategyName;
13
+ cause;
14
+ constructor(strategyName, message, cause) {
15
+ super(message);
16
+ this.name = 'BuildStrategyError';
17
+ this.strategyName = strategyName;
18
+ if (cause) {
19
+ this.cause = cause;
20
+ }
21
+ if (Error.captureStackTrace) {
22
+ Error.captureStackTrace(this, this.constructor);
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Config Patchers Registry
3
+ *
4
+ * Central registry for config patcher implementations.
5
+ * Provides factory functions and patcher lookup.
6
+ *
7
+ * Note: Tool-specific patchers (Prisma, pnpm, etc.) are provided
8
+ * by their respective binding packages (@harpoon/prisma, @harpoon/monorepo, etc.)
9
+ */
10
+ import type { ConfigPatcher, ConfigPatcherRegistry, PatcherChain } from './types';
11
+ export { ConfigPatchError } from './types';
12
+ export type { ConfigPatcher, PatchContext, PatchResult, ConfigPatcherRegistry, PatcherChain, } from './types';
13
+ /**
14
+ * Config patcher registry singleton.
15
+ */
16
+ export declare const configPatcherRegistry: ConfigPatcherRegistry;
17
+ /**
18
+ * Register a config patcher.
19
+ */
20
+ export declare function registerConfigPatcher(patcher: ConfigPatcher): void;
21
+ /**
22
+ * Get a config patcher by name.
23
+ */
24
+ export declare function getConfigPatcher(name: string): ConfigPatcher | undefined;
25
+ /**
26
+ * List all registered config patcher names.
27
+ */
28
+ export declare function listConfigPatchers(): readonly string[];
29
+ /**
30
+ * Create a patcher chain that runs multiple patchers in sequence.
31
+ */
32
+ export declare function createPatcherChain(patcherNames?: readonly string[]): PatcherChain;
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config-patchers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EAGrB,YAAY,EACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,YAAY,GACb,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,qBAsBnC,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAElE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAExE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEtD;AAID;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAC/B,YAAY,CAsBd"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Config Patchers Registry
3
+ *
4
+ * Central registry for config patcher implementations.
5
+ * Provides factory functions and patcher lookup.
6
+ *
7
+ * Note: Tool-specific patchers (Prisma, pnpm, etc.) are provided
8
+ * by their respective binding packages (@harpoon/prisma, @harpoon/monorepo, etc.)
9
+ */
10
+ import { Effect } from 'effect';
11
+ // Re-export types
12
+ export { ConfigPatchError } from './types';
13
+ // ============ Registry Implementation ============
14
+ const patchers = new Map();
15
+ /**
16
+ * Config patcher registry singleton.
17
+ */
18
+ export const configPatcherRegistry = {
19
+ get: (name) => patchers.get(name),
20
+ register: (patcher) => {
21
+ patchers.set(patcher.name, patcher);
22
+ },
23
+ list: () => Object.freeze([...patchers.keys()]),
24
+ getApplicable: (ctx) => Effect.gen(function* () {
25
+ const applicable = [];
26
+ for (const patcher of patchers.values()) {
27
+ const shouldApply = yield* patcher.shouldApply(ctx);
28
+ if (shouldApply) {
29
+ applicable.push(patcher);
30
+ }
31
+ }
32
+ return Object.freeze(applicable);
33
+ }),
34
+ };
35
+ /**
36
+ * Register a config patcher.
37
+ */
38
+ export function registerConfigPatcher(patcher) {
39
+ configPatcherRegistry.register(patcher);
40
+ }
41
+ /**
42
+ * Get a config patcher by name.
43
+ */
44
+ export function getConfigPatcher(name) {
45
+ return configPatcherRegistry.get(name);
46
+ }
47
+ /**
48
+ * List all registered config patcher names.
49
+ */
50
+ export function listConfigPatchers() {
51
+ return configPatcherRegistry.list();
52
+ }
53
+ // ============ Patcher Chain ============
54
+ /**
55
+ * Create a patcher chain that runs multiple patchers in sequence.
56
+ */
57
+ export function createPatcherChain(patcherNames) {
58
+ return {
59
+ run: (ctx) => Effect.gen(function* () {
60
+ const results = [];
61
+ // Get patchers to run
62
+ const patchersToRun = patcherNames
63
+ ? patcherNames
64
+ .map((name) => patchers.get(name))
65
+ .filter((p) => p !== undefined)
66
+ : yield* configPatcherRegistry.getApplicable(ctx);
67
+ // Run each patcher
68
+ for (const patcher of patchersToRun) {
69
+ const result = yield* patcher.apply(ctx);
70
+ results.push(result);
71
+ }
72
+ return Object.freeze(results);
73
+ }),
74
+ };
75
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Config Patcher Types
3
+ *
4
+ * Interfaces for pluggable configuration modification hooks.
5
+ * Patchers modify project config files before Docker builds.
6
+ */
7
+ import { Effect } from 'effect';
8
+ /**
9
+ * Context provided to config patchers.
10
+ */
11
+ export interface PatchContext {
12
+ /** Path to the app directory */
13
+ readonly appDir: string;
14
+ /** Name of the app being built */
15
+ readonly appName: string;
16
+ /** Path to package.json in the app */
17
+ readonly packageJsonPath: string;
18
+ /** Temp directory (if using monorepo simulation) */
19
+ readonly tempDir?: string;
20
+ /** Additional context data */
21
+ readonly metadata?: Readonly<Record<string, unknown>>;
22
+ }
23
+ /**
24
+ * Result of applying a config patch.
25
+ */
26
+ export interface PatchResult {
27
+ /** Whether the patch was applied */
28
+ readonly applied: boolean;
29
+ /** Files that were modified */
30
+ readonly modifiedFiles: readonly string[];
31
+ /** Description of what was patched */
32
+ readonly description?: string;
33
+ }
34
+ /**
35
+ * Error during config patching.
36
+ */
37
+ export declare class ConfigPatchError extends Error {
38
+ readonly _tag: "ConfigPatchError";
39
+ readonly patcherName: string;
40
+ readonly cause?: Error | undefined;
41
+ constructor(patcherName: string, message: string, cause?: Error);
42
+ }
43
+ /**
44
+ * A pluggable config patcher.
45
+ *
46
+ * Patchers modify configuration files (package.json, prisma config, etc.)
47
+ * before the Docker build process begins.
48
+ */
49
+ export interface ConfigPatcher {
50
+ /** Unique patcher identifier */
51
+ readonly name: string;
52
+ /** Human-readable description */
53
+ readonly description: string;
54
+ /**
55
+ * Check if this patcher should be applied.
56
+ *
57
+ * @param ctx Patch context
58
+ * @returns Effect yielding true if patcher should run
59
+ */
60
+ readonly shouldApply: (ctx: PatchContext) => Effect.Effect<boolean, ConfigPatchError>;
61
+ /**
62
+ * Apply the configuration patch.
63
+ *
64
+ * @param ctx Patch context
65
+ * @returns Effect yielding the patch result
66
+ */
67
+ readonly apply: (ctx: PatchContext) => Effect.Effect<PatchResult, ConfigPatchError>;
68
+ }
69
+ /**
70
+ * Registry of available config patchers.
71
+ */
72
+ export interface ConfigPatcherRegistry {
73
+ /** Get a patcher by name */
74
+ readonly get: (name: string) => ConfigPatcher | undefined;
75
+ /** Register a new patcher */
76
+ readonly register: (patcher: ConfigPatcher) => void;
77
+ /** List all registered patcher names */
78
+ readonly list: () => readonly string[];
79
+ /** Get patchers that should run for a given context */
80
+ readonly getApplicable: (ctx: PatchContext) => Effect.Effect<readonly ConfigPatcher[], ConfigPatchError>;
81
+ }
82
+ /**
83
+ * Chain multiple patchers together.
84
+ */
85
+ export interface PatcherChain {
86
+ /** Run all applicable patchers in sequence */
87
+ readonly run: (ctx: PatchContext) => Effect.Effect<readonly PatchResult[], ConfigPatchError>;
88
+ }
89
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config-patchers/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,sCAAsC;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,+BAA+B;IAC/B,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAE1C,sCAAsC;IACtC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAG,kBAAkB,CAAU;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QA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@@
1
+ /**
2
+ * Config Patcher Types
3
+ *
4
+ * Interfaces for pluggable configuration modification hooks.
5
+ * Patchers modify project config files before Docker builds.
6
+ */
7
+ /**
8
+ * Error during config patching.
9
+ */
10
+ export class ConfigPatchError extends Error {
11
+ _tag = 'ConfigPatchError';
12
+ patcherName;
13
+ cause;
14
+ constructor(patcherName, message, cause) {
15
+ super(message);
16
+ this.name = 'ConfigPatchError';
17
+ this.patcherName = patcherName;
18
+ if (cause) {
19
+ this.cause = cause;
20
+ }
21
+ if (Error.captureStackTrace) {
22
+ Error.captureStackTrace(this, this.constructor);
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Dockerfile Transformer Core
3
+ *
4
+ * Core parsing, serialization, and pipeline utilities for Dockerfile transformation.
5
+ * This module provides the foundation for all Dockerfile transformers.
6
+ */
7
+ import { Effect } from 'effect';
8
+ import type { DockerfileInstruction, TransformContext, InstructionTransformer, TransformPipeline, TransformResult } from './types';
9
+ import { TransformerError } from './types';
10
+ /**
11
+ * Parses a Dockerfile into structured instructions.
12
+ * Pure function - synchronous for direct use.
13
+ *
14
+ * @param dockerfile Raw Dockerfile content
15
+ * @returns Array of parsed instructions
16
+ */
17
+ export declare function parseDockerfile(dockerfile: string): DockerfileInstruction[];
18
+ /**
19
+ * Effect-wrapped parser for composable error handling.
20
+ */
21
+ export declare function parseDockerfileEffect(dockerfile: string): Effect.Effect<DockerfileInstruction[], TransformerError>;
22
+ /**
23
+ * Serializes instructions back to Dockerfile format.
24
+ *
25
+ * @param instructions Parsed Dockerfile instructions
26
+ * @returns Dockerfile content as string
27
+ */
28
+ export declare function serializeDockerfile(instructions: readonly DockerfileInstruction[]): string;
29
+ /**
30
+ * Creates a new transformation pipeline.
31
+ *
32
+ * @param transformers Initial transformers to add
33
+ * @returns A TransformPipeline instance
34
+ */
35
+ export declare function createPipeline(transformers?: readonly InstructionTransformer[]): TransformPipeline;
36
+ /**
37
+ * Transform a Dockerfile using a pipeline and return full result.
38
+ */
39
+ export declare function transformDockerfile(dockerfile: string, ctx: TransformContext, pipeline: TransformPipeline): Effect.Effect<TransformResult, TransformerError>;
40
+ /**
41
+ * Creates a simple instruction that replaces the original line.
42
+ */
43
+ export declare function replaceInstruction(inst: DockerfileInstruction, newOriginal: string, newArgs?: readonly string[]): DockerfileInstruction;
44
+ /**
45
+ * Creates multiple instructions from one (for splitting).
46
+ */
47
+ export declare function splitInstruction(inst: DockerfileInstruction, replacements: readonly {
48
+ original: string;
49
+ args?: readonly string[];
50
+ }[]): DockerfileInstruction[];
51
+ /**
52
+ * Check if an instruction's args contain a pattern.
53
+ */
54
+ export declare function argsContain(inst: DockerfileInstruction, pattern: string | RegExp): boolean;
55
+ /**
56
+ * Get a specific argument by index (0-based).
57
+ */
58
+ export declare function getArg(inst: DockerfileInstruction, index: number): string | undefined;
59
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/dockerfile-transformers/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAuE3C;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAkD3E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,EAAE,gBAAgB,CAAC,CAW1D;AAID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,SAAS,qBAAqB,EAAE,GAC7C,MAAM,CAER;AAID;;;;;GAKG;AACH,wBAAgB,cAAc,CAC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