@kadi.build/deploy-ability 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +523 -0
- package/dist/constants.d.ts +82 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +82 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors/certificate-error.d.ts +95 -0
- package/dist/errors/certificate-error.d.ts.map +1 -0
- package/dist/errors/certificate-error.js +111 -0
- package/dist/errors/certificate-error.js.map +1 -0
- package/dist/errors/deployment-error.d.ts +122 -0
- package/dist/errors/deployment-error.d.ts.map +1 -0
- package/dist/errors/deployment-error.js +185 -0
- package/dist/errors/deployment-error.js.map +1 -0
- package/dist/errors/index.d.ts +13 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +18 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/profile-error.d.ts +106 -0
- package/dist/errors/profile-error.d.ts.map +1 -0
- package/dist/errors/profile-error.js +127 -0
- package/dist/errors/profile-error.js.map +1 -0
- package/dist/errors/provider-error.d.ts +104 -0
- package/dist/errors/provider-error.d.ts.map +1 -0
- package/dist/errors/provider-error.js +120 -0
- package/dist/errors/provider-error.js.map +1 -0
- package/dist/errors/wallet-error.d.ts +131 -0
- package/dist/errors/wallet-error.d.ts.map +1 -0
- package/dist/errors/wallet-error.js +154 -0
- package/dist/errors/wallet-error.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/targets/akash/bid-selectors.d.ts +251 -0
- package/dist/targets/akash/bid-selectors.d.ts.map +1 -0
- package/dist/targets/akash/bid-selectors.js +322 -0
- package/dist/targets/akash/bid-selectors.js.map +1 -0
- package/dist/targets/akash/bid-types.d.ts +297 -0
- package/dist/targets/akash/bid-types.d.ts.map +1 -0
- package/dist/targets/akash/bid-types.js +89 -0
- package/dist/targets/akash/bid-types.js.map +1 -0
- package/dist/targets/akash/blockchain-client.d.ts +577 -0
- package/dist/targets/akash/blockchain-client.d.ts.map +1 -0
- package/dist/targets/akash/blockchain-client.js +803 -0
- package/dist/targets/akash/blockchain-client.js.map +1 -0
- package/dist/targets/akash/certificate-manager.d.ts +228 -0
- package/dist/targets/akash/certificate-manager.d.ts.map +1 -0
- package/dist/targets/akash/certificate-manager.js +395 -0
- package/dist/targets/akash/certificate-manager.js.map +1 -0
- package/dist/targets/akash/constants.d.ts +231 -0
- package/dist/targets/akash/constants.d.ts.map +1 -0
- package/dist/targets/akash/constants.js +225 -0
- package/dist/targets/akash/constants.js.map +1 -0
- package/dist/targets/akash/deployer.d.ts +136 -0
- package/dist/targets/akash/deployer.d.ts.map +1 -0
- package/dist/targets/akash/deployer.js +599 -0
- package/dist/targets/akash/deployer.js.map +1 -0
- package/dist/targets/akash/environment.d.ts +241 -0
- package/dist/targets/akash/environment.d.ts.map +1 -0
- package/dist/targets/akash/environment.js +245 -0
- package/dist/targets/akash/environment.js.map +1 -0
- package/dist/targets/akash/index.d.ts +1113 -0
- package/dist/targets/akash/index.d.ts.map +1 -0
- package/dist/targets/akash/index.js +909 -0
- package/dist/targets/akash/index.js.map +1 -0
- package/dist/targets/akash/lease-monitor.d.ts +51 -0
- package/dist/targets/akash/lease-monitor.d.ts.map +1 -0
- package/dist/targets/akash/lease-monitor.js +110 -0
- package/dist/targets/akash/lease-monitor.js.map +1 -0
- package/dist/targets/akash/logs.d.ts +71 -0
- package/dist/targets/akash/logs.d.ts.map +1 -0
- package/dist/targets/akash/logs.js +311 -0
- package/dist/targets/akash/logs.js.map +1 -0
- package/dist/targets/akash/logs.types.d.ts +102 -0
- package/dist/targets/akash/logs.types.d.ts.map +1 -0
- package/dist/targets/akash/logs.types.js +9 -0
- package/dist/targets/akash/logs.types.js.map +1 -0
- package/dist/targets/akash/pricing.d.ts +247 -0
- package/dist/targets/akash/pricing.d.ts.map +1 -0
- package/dist/targets/akash/pricing.js +246 -0
- package/dist/targets/akash/pricing.js.map +1 -0
- package/dist/targets/akash/provider-client.d.ts +114 -0
- package/dist/targets/akash/provider-client.d.ts.map +1 -0
- package/dist/targets/akash/provider-client.js +318 -0
- package/dist/targets/akash/provider-client.js.map +1 -0
- package/dist/targets/akash/provider-metadata.d.ts +228 -0
- package/dist/targets/akash/provider-metadata.d.ts.map +1 -0
- package/dist/targets/akash/provider-metadata.js +14 -0
- package/dist/targets/akash/provider-metadata.js.map +1 -0
- package/dist/targets/akash/provider-service.d.ts +133 -0
- package/dist/targets/akash/provider-service.d.ts.map +1 -0
- package/dist/targets/akash/provider-service.js +391 -0
- package/dist/targets/akash/provider-service.js.map +1 -0
- package/dist/targets/akash/query-client.d.ts +125 -0
- package/dist/targets/akash/query-client.d.ts.map +1 -0
- package/dist/targets/akash/query-client.js +332 -0
- package/dist/targets/akash/query-client.js.map +1 -0
- package/dist/targets/akash/sdl-generator.d.ts +31 -0
- package/dist/targets/akash/sdl-generator.d.ts.map +1 -0
- package/dist/targets/akash/sdl-generator.js +279 -0
- package/dist/targets/akash/sdl-generator.js.map +1 -0
- package/dist/targets/akash/types.d.ts +285 -0
- package/dist/targets/akash/types.d.ts.map +1 -0
- package/dist/targets/akash/types.js +54 -0
- package/dist/targets/akash/types.js.map +1 -0
- package/dist/targets/akash/wallet-manager.d.ts +526 -0
- package/dist/targets/akash/wallet-manager.d.ts.map +1 -0
- package/dist/targets/akash/wallet-manager.js +953 -0
- package/dist/targets/akash/wallet-manager.js.map +1 -0
- package/dist/targets/local/compose-generator.d.ts +244 -0
- package/dist/targets/local/compose-generator.d.ts.map +1 -0
- package/dist/targets/local/compose-generator.js +324 -0
- package/dist/targets/local/compose-generator.js.map +1 -0
- package/dist/targets/local/deployer.d.ts +82 -0
- package/dist/targets/local/deployer.d.ts.map +1 -0
- package/dist/targets/local/deployer.js +367 -0
- package/dist/targets/local/deployer.js.map +1 -0
- package/dist/targets/local/engine-manager.d.ts +155 -0
- package/dist/targets/local/engine-manager.d.ts.map +1 -0
- package/dist/targets/local/engine-manager.js +250 -0
- package/dist/targets/local/engine-manager.js.map +1 -0
- package/dist/targets/local/index.d.ts +40 -0
- package/dist/targets/local/index.d.ts.map +1 -0
- package/dist/targets/local/index.js +43 -0
- package/dist/targets/local/index.js.map +1 -0
- package/dist/targets/local/network-manager.d.ts +160 -0
- package/dist/targets/local/network-manager.d.ts.map +1 -0
- package/dist/targets/local/network-manager.js +337 -0
- package/dist/targets/local/network-manager.js.map +1 -0
- package/dist/targets/local/types.d.ts +327 -0
- package/dist/targets/local/types.d.ts.map +1 -0
- package/dist/targets/local/types.js +9 -0
- package/dist/targets/local/types.js.map +1 -0
- package/dist/types/common.d.ts +585 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +13 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/options.d.ts +329 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +10 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/profiles.d.ts +329 -0
- package/dist/types/profiles.d.ts.map +1 -0
- package/dist/types/profiles.js +27 -0
- package/dist/types/profiles.js.map +1 -0
- package/dist/types/results.d.ts +443 -0
- package/dist/types/results.d.ts.map +1 -0
- package/dist/types/results.js +64 -0
- package/dist/types/results.js.map +1 -0
- package/dist/types/validators.d.ts +118 -0
- package/dist/types/validators.d.ts.map +1 -0
- package/dist/types/validators.js +198 -0
- package/dist/types/validators.js.map +1 -0
- package/dist/utils/command-runner.d.ts +128 -0
- package/dist/utils/command-runner.d.ts.map +1 -0
- package/dist/utils/command-runner.js +210 -0
- package/dist/utils/command-runner.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +68 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +93 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/profile-loader.d.ts +76 -0
- package/dist/utils/profile-loader.d.ts.map +1 -0
- package/dist/utils/profile-loader.js +194 -0
- package/dist/utils/profile-loader.js.map +1 -0
- package/dist/utils/registry/index.d.ts +27 -0
- package/dist/utils/registry/index.d.ts.map +1 -0
- package/dist/utils/registry/index.js +29 -0
- package/dist/utils/registry/index.js.map +1 -0
- package/dist/utils/registry/manager.d.ts +319 -0
- package/dist/utils/registry/manager.d.ts.map +1 -0
- package/dist/utils/registry/manager.js +671 -0
- package/dist/utils/registry/manager.js.map +1 -0
- package/dist/utils/registry/setup.d.ts +135 -0
- package/dist/utils/registry/setup.d.ts.map +1 -0
- package/dist/utils/registry/setup.js +207 -0
- package/dist/utils/registry/setup.js.map +1 -0
- package/dist/utils/registry/transformer.d.ts +92 -0
- package/dist/utils/registry/transformer.d.ts.map +1 -0
- package/dist/utils/registry/transformer.js +131 -0
- package/dist/utils/registry/transformer.js.map +1 -0
- package/dist/utils/registry/types.d.ts +241 -0
- package/dist/utils/registry/types.d.ts.map +1 -0
- package/dist/utils/registry/types.js +10 -0
- package/dist/utils/registry/types.js.map +1 -0
- package/docs/EXAMPLES.md +293 -0
- package/docs/PLACEMENT.md +433 -0
- package/docs/STORAGE.md +318 -0
- package/docs/building-provider-reliability-tracker.md +2581 -0
- package/package.json +109 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Validators and Constructors for Branded Types
|
|
3
|
+
*
|
|
4
|
+
* This module provides runtime validation and safe constructors for branded types
|
|
5
|
+
* using Zod. Instead of blind type assertions (as SomeType), these schemas validate
|
|
6
|
+
* input and provide compile-time guarantees.
|
|
7
|
+
*
|
|
8
|
+
* **Philosophy:**
|
|
9
|
+
* - Branded types provide documentation and prevent mixing incompatible values
|
|
10
|
+
* - Zod schemas enforce the brand contract at runtime
|
|
11
|
+
* - Single point of validation - once created, branded values are trusted
|
|
12
|
+
*
|
|
13
|
+
* **Why Zod:**
|
|
14
|
+
* - Composable, reusable schemas
|
|
15
|
+
* - Excellent error messages
|
|
16
|
+
* - Type inference works perfectly with branded types
|
|
17
|
+
* - Industry standard (Vercel, tRPC, Remix, etc.)
|
|
18
|
+
*
|
|
19
|
+
* @module types/validators
|
|
20
|
+
*/
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// Wallet Address Validation
|
|
24
|
+
// =============================================================================
|
|
25
|
+
/**
|
|
26
|
+
* Zod schema for Akash wallet addresses
|
|
27
|
+
*
|
|
28
|
+
* Akash wallet addresses are bech32-encoded and always start with "akash1".
|
|
29
|
+
*
|
|
30
|
+
* **Validation rules:**
|
|
31
|
+
* - Must start with "akash1"
|
|
32
|
+
* - Must be at least 44 characters (akash1 + 38 character bech32 address)
|
|
33
|
+
* - Must contain only lowercase alphanumeric characters (bech32 charset)
|
|
34
|
+
*
|
|
35
|
+
* **Note:** This performs basic format validation. It does NOT verify:
|
|
36
|
+
* - Whether the address exists on-chain
|
|
37
|
+
* - Whether the checksum is valid (full bech32 validation would require additional library)
|
|
38
|
+
*
|
|
39
|
+
* @example Valid addresses
|
|
40
|
+
* ```typescript
|
|
41
|
+
* WalletAddressSchema.parse('akash1...'); // 44+ chars starting with akash1
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Invalid addresses (will throw ZodError)
|
|
45
|
+
* ```typescript
|
|
46
|
+
* WalletAddressSchema.parse('cosmos1...'); // Wrong prefix
|
|
47
|
+
* WalletAddressSchema.parse('akash1abc'); // Too short
|
|
48
|
+
* WalletAddressSchema.parse('AKASH1...'); // Uppercase not allowed
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
const WalletAddressSchemaInternal = z
|
|
52
|
+
.string()
|
|
53
|
+
.min(44, 'Wallet address must be at least 44 characters')
|
|
54
|
+
.startsWith('akash1', 'Wallet address must start with "akash1"')
|
|
55
|
+
.regex(/^akash1[02-9ac-hj-np-z]+$/, 'Wallet address must be lowercase bech32 format');
|
|
56
|
+
export const WalletAddressSchema = WalletAddressSchemaInternal;
|
|
57
|
+
/**
|
|
58
|
+
* Validates and creates a WalletAddress branded type
|
|
59
|
+
*
|
|
60
|
+
* Throws ZodError if validation fails with detailed error messages.
|
|
61
|
+
*
|
|
62
|
+
* @param address - String to validate as wallet address
|
|
63
|
+
* @returns Branded WalletAddress
|
|
64
|
+
* @throws {ZodError} If address format is invalid
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const addr = createWalletAddress('akash1...');
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function createWalletAddress(address) {
|
|
72
|
+
WalletAddressSchema.parse(address);
|
|
73
|
+
return address;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Type guard to check if a string is a valid wallet address
|
|
77
|
+
*
|
|
78
|
+
* @param address - String to check
|
|
79
|
+
* @returns true if address is valid
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* if (isWalletAddress(address)) {
|
|
84
|
+
* // TypeScript knows address is WalletAddress
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function isWalletAddress(address) {
|
|
89
|
+
return WalletAddressSchema.safeParse(address).success;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Safely converts unknown value to WalletAddress
|
|
93
|
+
*
|
|
94
|
+
* Returns undefined instead of throwing if validation fails.
|
|
95
|
+
* Useful for optional fields or untrusted input.
|
|
96
|
+
*
|
|
97
|
+
* @param value - Value to convert
|
|
98
|
+
* @returns WalletAddress if valid, undefined otherwise
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const addr = toWalletAddress(untrustedInput);
|
|
103
|
+
* if (addr) {
|
|
104
|
+
* // Use validated address
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export function toWalletAddress(value) {
|
|
109
|
+
const result = WalletAddressSchema.safeParse(value);
|
|
110
|
+
return result.success ? result.data : undefined;
|
|
111
|
+
}
|
|
112
|
+
// =============================================================================
|
|
113
|
+
// Deployment Sequence Validation
|
|
114
|
+
// =============================================================================
|
|
115
|
+
/**
|
|
116
|
+
* Zod schema for deployment sequences (dseq)
|
|
117
|
+
*
|
|
118
|
+
* Deployment sequences are positive integers assigned by the Akash blockchain
|
|
119
|
+
* to uniquely identify deployments. They start from 1 and increment.
|
|
120
|
+
*
|
|
121
|
+
* **Validation rules:**
|
|
122
|
+
* - Must be a positive integer (>= 1)
|
|
123
|
+
* - Must be a safe integer (within JavaScript's MAX_SAFE_INTEGER)
|
|
124
|
+
*
|
|
125
|
+
* @example Valid dseq
|
|
126
|
+
* ```typescript
|
|
127
|
+
* DeploymentSequenceSchema.parse(12345); // ✓
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @example Invalid dseq (will throw ZodError)
|
|
131
|
+
* ```typescript
|
|
132
|
+
* DeploymentSequenceSchema.parse(0); // Must be >= 1
|
|
133
|
+
* DeploymentSequenceSchema.parse(-100); // Must be positive
|
|
134
|
+
* DeploymentSequenceSchema.parse(1.5); // Must be integer
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
const DeploymentSequenceSchemaInternal = z
|
|
138
|
+
.number()
|
|
139
|
+
.int('Deployment sequence must be an integer')
|
|
140
|
+
.positive('Deployment sequence must be positive')
|
|
141
|
+
.min(1, 'Deployment sequence must be at least 1')
|
|
142
|
+
.safe('Deployment sequence exceeds safe integer range');
|
|
143
|
+
export const DeploymentSequenceSchema = DeploymentSequenceSchemaInternal;
|
|
144
|
+
/**
|
|
145
|
+
* Validates and creates a DeploymentSequence branded type
|
|
146
|
+
*
|
|
147
|
+
* Throws ZodError if validation fails.
|
|
148
|
+
*
|
|
149
|
+
* @param dseq - Number to validate as deployment sequence
|
|
150
|
+
* @returns Branded DeploymentSequence
|
|
151
|
+
* @throws {ZodError} If dseq is invalid
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const dseq = createDeploymentSequence(12345);
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export function createDeploymentSequence(dseq) {
|
|
159
|
+
DeploymentSequenceSchema.parse(dseq);
|
|
160
|
+
return dseq;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Type guard to check if a number is a valid deployment sequence
|
|
164
|
+
*
|
|
165
|
+
* @param dseq - Number to check
|
|
166
|
+
* @returns true if dseq is valid
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* if (isDeploymentSequence(dseq)) {
|
|
171
|
+
* // TypeScript knows dseq is DeploymentSequence
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export function isDeploymentSequence(dseq) {
|
|
176
|
+
return DeploymentSequenceSchema.safeParse(dseq).success;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Safely converts unknown value to DeploymentSequence
|
|
180
|
+
*
|
|
181
|
+
* Returns undefined instead of throwing if validation fails.
|
|
182
|
+
*
|
|
183
|
+
* @param value - Value to convert
|
|
184
|
+
* @returns DeploymentSequence if valid, undefined otherwise
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const dseq = toDeploymentSequence(untrustedInput);
|
|
189
|
+
* if (dseq) {
|
|
190
|
+
* // Use validated dseq
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export function toDeploymentSequence(value) {
|
|
195
|
+
const result = DeploymentSequenceSchema.safeParse(value);
|
|
196
|
+
return result.success ? result.data : undefined;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=validators.js.map
|
|
@@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AAsC,CAAC;KAChD,GAAG,CAAC,CAAC,EAAE,wCAAwC,CAAC;KAChD,IAAI,CAAC,gDAAgD,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,gCAAgC,CAAC;AAEzE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,IAA0B,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,wBAAwB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAE,MAAM,CAAC,IAA2B,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command execution utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe command execution with Result types,
|
|
5
|
+
* timeout support, and proper error handling.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/command-runner
|
|
8
|
+
*/
|
|
9
|
+
import { type Result } from '../types/index.js';
|
|
10
|
+
import { DeploymentError } from '../errors/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Options for command execution
|
|
13
|
+
*/
|
|
14
|
+
export interface CommandOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Working directory for command execution
|
|
17
|
+
*/
|
|
18
|
+
readonly cwd?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Environment variables to set
|
|
21
|
+
*/
|
|
22
|
+
readonly env?: Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Timeout in milliseconds
|
|
25
|
+
* @default 120000 (2 minutes)
|
|
26
|
+
*/
|
|
27
|
+
readonly timeout?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Silent mode - capture output instead of streaming
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
readonly silent?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Abort signal for cancellation
|
|
35
|
+
*/
|
|
36
|
+
readonly signal?: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Command execution result data
|
|
40
|
+
*/
|
|
41
|
+
export interface CommandResult {
|
|
42
|
+
/**
|
|
43
|
+
* Standard output from the command
|
|
44
|
+
*/
|
|
45
|
+
readonly stdout: string;
|
|
46
|
+
/**
|
|
47
|
+
* Standard error output from the command
|
|
48
|
+
*/
|
|
49
|
+
readonly stderr: string;
|
|
50
|
+
/**
|
|
51
|
+
* Exit code
|
|
52
|
+
*/
|
|
53
|
+
readonly exitCode: number;
|
|
54
|
+
/**
|
|
55
|
+
* Execution time in milliseconds
|
|
56
|
+
*/
|
|
57
|
+
readonly duration: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Execute a shell command with proper error handling
|
|
61
|
+
*
|
|
62
|
+
* Returns a Result type instead of throwing, making error handling explicit
|
|
63
|
+
* and type-safe.
|
|
64
|
+
*
|
|
65
|
+
* @param command - Command to execute
|
|
66
|
+
* @param options - Execution options
|
|
67
|
+
* @returns Result with command output or error
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const result = await runCommand('docker version', { silent: true });
|
|
72
|
+
*
|
|
73
|
+
* if (result.success) {
|
|
74
|
+
* console.log('Docker version:', result.data.stdout);
|
|
75
|
+
* } else {
|
|
76
|
+
* console.error('Command failed:', result.error.message);
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example With timeout and abort
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const controller = new AbortController();
|
|
83
|
+
* setTimeout(() => controller.abort(), 5000);
|
|
84
|
+
*
|
|
85
|
+
* const result = await runCommand('long-running-command', {
|
|
86
|
+
* timeout: 10000,
|
|
87
|
+
* signal: controller.signal
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function runCommand(command: string, options?: CommandOptions): Promise<Result<CommandResult, DeploymentError>>;
|
|
92
|
+
/**
|
|
93
|
+
* Execute a command and return only stdout
|
|
94
|
+
*
|
|
95
|
+
* Convenience wrapper that throws on error and returns just the stdout string
|
|
96
|
+
*
|
|
97
|
+
* @param command - Command to execute
|
|
98
|
+
* @param options - Execution options
|
|
99
|
+
* @returns Standard output from the command
|
|
100
|
+
* @throws {DeploymentError} If command fails
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* try {
|
|
105
|
+
* const version = await runCommandSimple('docker --version', { silent: true });
|
|
106
|
+
* console.log(version);
|
|
107
|
+
* } catch (error) {
|
|
108
|
+
* console.error('Failed:', error.message);
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function runCommandSimple(command: string, options?: CommandOptions): Promise<string>;
|
|
113
|
+
/**
|
|
114
|
+
* Check if a command exists in the system PATH
|
|
115
|
+
*
|
|
116
|
+
* @param command - Command name to check
|
|
117
|
+
* @returns True if command exists
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const hasDocker = await commandExists('docker');
|
|
122
|
+
* if (!hasDocker) {
|
|
123
|
+
* console.error('Docker is not installed');
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function commandExists(command: string): Promise<boolean>;
|
|
128
|
+
//# sourceMappingURL=command-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.d.ts","sourceRoot":"","sources":["../../src/utils/command-run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,CAcrE"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command execution utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe command execution with Result types,
|
|
5
|
+
* timeout support, and proper error handling.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/command-runner
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from 'node:child_process';
|
|
10
|
+
import debug from 'debug';
|
|
11
|
+
import { success, failure } from '../types/index.js';
|
|
12
|
+
import { DeploymentError } from '../errors/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* Debug logger for command execution
|
|
15
|
+
*/
|
|
16
|
+
const log = debug('deploy-ability:command');
|
|
17
|
+
/**
|
|
18
|
+
* Execute a shell command with proper error handling
|
|
19
|
+
*
|
|
20
|
+
* Returns a Result type instead of throwing, making error handling explicit
|
|
21
|
+
* and type-safe.
|
|
22
|
+
*
|
|
23
|
+
* @param command - Command to execute
|
|
24
|
+
* @param options - Execution options
|
|
25
|
+
* @returns Result with command output or error
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const result = await runCommand('docker version', { silent: true });
|
|
30
|
+
*
|
|
31
|
+
* if (result.success) {
|
|
32
|
+
* console.log('Docker version:', result.data.stdout);
|
|
33
|
+
* } else {
|
|
34
|
+
* console.error('Command failed:', result.error.message);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example With timeout and abort
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const controller = new AbortController();
|
|
41
|
+
* setTimeout(() => controller.abort(), 5000);
|
|
42
|
+
*
|
|
43
|
+
* const result = await runCommand('long-running-command', {
|
|
44
|
+
* timeout: 10000,
|
|
45
|
+
* signal: controller.signal
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export async function runCommand(command, options = {}) {
|
|
50
|
+
const { cwd, env, timeout = 120_000, silent = false, signal, } = options;
|
|
51
|
+
log('Executing command: %s', command);
|
|
52
|
+
if (cwd)
|
|
53
|
+
log('Working directory: %s', cwd);
|
|
54
|
+
if (timeout)
|
|
55
|
+
log('Timeout: %dms', timeout);
|
|
56
|
+
const startTime = Date.now();
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
// Check if already aborted
|
|
59
|
+
if (signal?.aborted) {
|
|
60
|
+
resolve(failure(new DeploymentError('Command execution was cancelled', 'COMMAND_CANCELLED', { command }, false, undefined, 'warning')));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const child = spawn(command, {
|
|
64
|
+
cwd,
|
|
65
|
+
env: env ? { ...process.env, ...env } : undefined,
|
|
66
|
+
shell: true,
|
|
67
|
+
stdio: silent ? ['ignore', 'pipe', 'pipe'] : 'inherit',
|
|
68
|
+
});
|
|
69
|
+
let stdout = '';
|
|
70
|
+
let stderr = '';
|
|
71
|
+
let timeoutId;
|
|
72
|
+
let killed = false;
|
|
73
|
+
// Capture output if in silent mode
|
|
74
|
+
if (silent) {
|
|
75
|
+
child.stdout?.on('data', (chunk) => {
|
|
76
|
+
stdout += chunk.toString();
|
|
77
|
+
});
|
|
78
|
+
child.stderr?.on('data', (chunk) => {
|
|
79
|
+
stderr += chunk.toString();
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// Setup timeout
|
|
83
|
+
if (timeout > 0) {
|
|
84
|
+
timeoutId = setTimeout(() => {
|
|
85
|
+
if (!killed) {
|
|
86
|
+
log('Command timed out after %dms: %s', timeout, command);
|
|
87
|
+
killed = true;
|
|
88
|
+
child.kill('SIGTERM');
|
|
89
|
+
// Force kill after 5 seconds if still running
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
if (!child.killed) {
|
|
92
|
+
child.kill('SIGKILL');
|
|
93
|
+
}
|
|
94
|
+
}, 5000);
|
|
95
|
+
}
|
|
96
|
+
}, timeout);
|
|
97
|
+
}
|
|
98
|
+
// Setup abort signal handler
|
|
99
|
+
const abortHandler = () => {
|
|
100
|
+
if (!killed && !child.killed) {
|
|
101
|
+
log('Command aborted: %s', command);
|
|
102
|
+
killed = true;
|
|
103
|
+
child.kill('SIGTERM');
|
|
104
|
+
setTimeout(() => {
|
|
105
|
+
if (!child.killed) {
|
|
106
|
+
child.kill('SIGKILL');
|
|
107
|
+
}
|
|
108
|
+
}, 5000);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
signal?.addEventListener('abort', abortHandler);
|
|
112
|
+
// Handle process errors
|
|
113
|
+
child.on('error', (error) => {
|
|
114
|
+
if (timeoutId)
|
|
115
|
+
clearTimeout(timeoutId);
|
|
116
|
+
signal?.removeEventListener('abort', abortHandler);
|
|
117
|
+
log('Command error: %s', error.message);
|
|
118
|
+
resolve(failure(new DeploymentError(`Failed to execute command: ${error.message}`, 'COMMAND_EXECUTION_ERROR', { command, error: error.message }, true, 'Check that the command exists and is executable', 'error', error)));
|
|
119
|
+
});
|
|
120
|
+
// Handle process exit
|
|
121
|
+
child.on('close', (exitCode) => {
|
|
122
|
+
if (timeoutId)
|
|
123
|
+
clearTimeout(timeoutId);
|
|
124
|
+
signal?.removeEventListener('abort', abortHandler);
|
|
125
|
+
const duration = Date.now() - startTime;
|
|
126
|
+
log('Command completed in %dms with exit code %d', duration, exitCode);
|
|
127
|
+
// Handle timeout
|
|
128
|
+
if (killed && signal?.aborted) {
|
|
129
|
+
resolve(failure(new DeploymentError('Command execution was cancelled', 'COMMAND_CANCELLED', { command, duration }, false, undefined, 'warning')));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (killed) {
|
|
133
|
+
resolve(failure(new DeploymentError(`Command timed out after ${timeout}ms`, 'COMMAND_TIMEOUT', { command, timeout, duration }, true, 'Try increasing the timeout or check if the command is hanging', 'error')));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Success case
|
|
137
|
+
if (exitCode === 0) {
|
|
138
|
+
resolve(success({
|
|
139
|
+
stdout,
|
|
140
|
+
stderr,
|
|
141
|
+
exitCode: 0,
|
|
142
|
+
duration,
|
|
143
|
+
}));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// Non-zero exit code
|
|
147
|
+
resolve(failure(new DeploymentError(`Command failed with exit code ${exitCode}`, 'COMMAND_FAILED', {
|
|
148
|
+
command,
|
|
149
|
+
exitCode,
|
|
150
|
+
stdout: silent ? stdout : undefined,
|
|
151
|
+
stderr: silent ? stderr : undefined,
|
|
152
|
+
duration,
|
|
153
|
+
}, true, 'Check command output for error details', 'error')));
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Execute a command and return only stdout
|
|
159
|
+
*
|
|
160
|
+
* Convenience wrapper that throws on error and returns just the stdout string
|
|
161
|
+
*
|
|
162
|
+
* @param command - Command to execute
|
|
163
|
+
* @param options - Execution options
|
|
164
|
+
* @returns Standard output from the command
|
|
165
|
+
* @throws {DeploymentError} If command fails
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* try {
|
|
170
|
+
* const version = await runCommandSimple('docker --version', { silent: true });
|
|
171
|
+
* console.log(version);
|
|
172
|
+
* } catch (error) {
|
|
173
|
+
* console.error('Failed:', error.message);
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export async function runCommandSimple(command, options = {}) {
|
|
178
|
+
const result = await runCommand(command, { ...options, silent: true });
|
|
179
|
+
if (result.success) {
|
|
180
|
+
return result.data.stdout.trim();
|
|
181
|
+
}
|
|
182
|
+
throw result.error;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Check if a command exists in the system PATH
|
|
186
|
+
*
|
|
187
|
+
* @param command - Command name to check
|
|
188
|
+
* @returns True if command exists
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const hasDocker = await commandExists('docker');
|
|
193
|
+
* if (!hasDocker) {
|
|
194
|
+
* console.error('Docker is not installed');
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export async function commandExists(command) {
|
|
199
|
+
// Validate command is not empty
|
|
200
|
+
if (!command || command.trim().length === 0) {
|
|
201
|
+
log('Command is empty, returning false');
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
const checkCommand = process.platform === 'win32'
|
|
205
|
+
? `where ${command}`
|
|
206
|
+
: `command -v ${command}`;
|
|
207
|
+
const result = await runCommand(checkCommand, { silent: true });
|
|
208
|
+
return result.success;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=command-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.js","sourceRoot":"","sources":["../../src/utils/command-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AA2D5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAe,EACf,UAA0B,EAAE;IAE5B,MAAM,EACJ,GAAG,EACH,GAAG,EACH,OAAO,GAAG,OAAO,EACjB,MAAM,GAAG,KAAK,EACd,MAAM,GACP,GAAG,OAAO,CAAC;IAEZ,GAAG,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;IACtC,IAAI,GAAG;QAAE,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;IAC3C,IAAI,OAAO;QAAE,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAE3C,MAAM,SAAS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AM,GAAG,MAAM,UAAU,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities barrel export
|
|
3
|
+
*
|
|
4
|
+
* @module utils
|
|
5
|
+
*/
|
|
6
|
+
export { ConsoleLogger, SilentLogger, createLogger, defaultLogger, } from './logger.js';
|
|
7
|
+
export { loadAgentConfig, loadDeploymentProfile, loadFirstProfile, loadProfile, getAvailableProfiles, } from './profile-loader.js';
|
|
8
|
+
export { runCommand, runCommandSimple, commandExists, type CommandOptions, type CommandResult, } from './command-runner.js';
|
|
9
|
+
export { setupRegistryIfNeeded, hasLocalImages, TemporaryContainerRegistryManager, transformProfileWithRegistry, isLocalImagePattern, type RegistryContext, type RegistryOptions, type ContainerMapping, type RegistryCredentials, type RegistryInfo, type RegistryUrls, type ContainerInfo, } from './registry/index.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iCAAiC,EACjC,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities barrel export
|
|
3
|
+
*
|
|
4
|
+
* @module utils
|
|
5
|
+
*/
|
|
6
|
+
export { ConsoleLogger, SilentLogger, createLogger, defaultLogger, } from './logger.js';
|
|
7
|
+
export { loadAgentConfig, loadDeploymentProfile, loadFirstProfile, loadProfile, getAvailableProfiles, } from './profile-loader.js';
|
|
8
|
+
export { runCommand, runCommandSimple, commandExists, } from './command-runner.js';
|
|
9
|
+
export { setupRegistryIfNeeded, hasLocalImages, TemporaryContainerRegistryManager, transformProfileWithRegistry, isLocalImagePattern, } from './registry/index.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iCAAiC,EACjC,4BAA4B,EAC5B,mBAAmB,GAQpB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides default logger implementation and logger factory functions
|
|
5
|
+
*
|
|
6
|
+
* @module utils/logger
|
|
7
|
+
*/
|
|
8
|
+
import type { DeploymentLogger } from '../types/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Default console-based logger implementation
|
|
11
|
+
*
|
|
12
|
+
* Uses console methods for output with timestamps and level prefixes
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConsoleLogger implements DeploymentLogger {
|
|
15
|
+
private readonly verbose;
|
|
16
|
+
constructor(verbose?: boolean);
|
|
17
|
+
/**
|
|
18
|
+
* Log informational message
|
|
19
|
+
*/
|
|
20
|
+
log(message: string, ...args: unknown[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Log error message
|
|
23
|
+
*/
|
|
24
|
+
error(message: string, ...args: unknown[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Log warning message
|
|
27
|
+
*/
|
|
28
|
+
warn(message: string, ...args: unknown[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* Log debug message (only if verbose mode enabled)
|
|
31
|
+
*/
|
|
32
|
+
debug(message: string, ...args: unknown[]): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get current timestamp for log messages
|
|
35
|
+
*/
|
|
36
|
+
private getTimestamp;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Silent logger that discards all output
|
|
40
|
+
*
|
|
41
|
+
* Useful for testing or when logging is not desired
|
|
42
|
+
*/
|
|
43
|
+
export declare class SilentLogger implements DeploymentLogger {
|
|
44
|
+
log(_message: string, ..._args: unknown[]): void;
|
|
45
|
+
error(_message: string, ..._args: unknown[]): void;
|
|
46
|
+
warn(_message: string, ..._args: unknown[]): void;
|
|
47
|
+
debug(_message: string, ..._args: unknown[]): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a logger instance
|
|
51
|
+
*
|
|
52
|
+
* @param options - Logger configuration options
|
|
53
|
+
* @returns Logger instance
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const logger = createLogger({ verbose: true });
|
|
57
|
+
* logger.log('Deployment started');
|
|
58
|
+
*/
|
|
59
|
+
export declare function createLogger(options: {
|
|
60
|
+
verbose?: boolean;
|
|
61
|
+
silent?: boolean;
|
|
62
|
+
custom?: DeploymentLogger;
|
|
63
|
+
}): DeploymentLogger;
|
|
64
|
+
/**
|
|
65
|
+
* Default logger instance (console-based, non-verbose)
|
|
66
|
+
*/
|
|
67
|
+
export declare const defaultLogger: DeploymentLogger;
|
|
68
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;GAIG;AACH,qBAAa,aAAc,YAAW,gBAAgB;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAEtB,OAAO,GAAE,OAAe;IAIpC;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMhD;;OAEG;IACH,OAAO,CAAC,YAAY;CAGrB;AAED;;;;GAIG;AACH,qBAAa,YAAa,YAAW,gBAAgB;IACnD,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI;IAIlD,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,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