@oxog/dockcraft 1.0.0 → 1.1.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/CHANGELOG.md +220 -0
- package/README.md +132 -21
- package/dist/cli/index.js +912 -439
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +736 -386
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -12
- package/dist/index.d.ts +29 -12
- package/dist/index.js +732 -382
- package/dist/index.js.map +1 -1
- package/package.json +32 -16
- package/dist/cli/index.cjs +0 -2095
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.d.cts +0 -6
- package/dist/cli/index.d.ts +0 -6
package/dist/index.d.cts
CHANGED
|
@@ -6,8 +6,8 @@ interface DockcraftConfig {
|
|
|
6
6
|
name: string;
|
|
7
7
|
/** Optional preset to start from */
|
|
8
8
|
preset?: PresetName;
|
|
9
|
-
/** Application configuration */
|
|
10
|
-
app
|
|
9
|
+
/** Application configuration (optional when a preset provides it) */
|
|
10
|
+
app?: AppConfig;
|
|
11
11
|
/** Service definitions */
|
|
12
12
|
services?: ServicesConfig;
|
|
13
13
|
/** Output options */
|
|
@@ -19,21 +19,28 @@ interface DockcraftConfig {
|
|
|
19
19
|
* Application configuration
|
|
20
20
|
*/
|
|
21
21
|
interface AppConfig {
|
|
22
|
-
/** Application port (number or 'auto' for automatic assignment) */
|
|
23
|
-
port
|
|
22
|
+
/** Application port (number or 'auto' for automatic assignment, default: 3000) */
|
|
23
|
+
port?: number | 'auto';
|
|
24
24
|
/** Node.js Docker image version (default: '20-alpine') */
|
|
25
25
|
node?: string;
|
|
26
26
|
/** Working directory in container (default: '/app') */
|
|
27
27
|
workdir?: string;
|
|
28
|
-
/** Start command (default: 'npm start') */
|
|
28
|
+
/** Start command, used for the Dockerfile CMD (default: 'npm start') */
|
|
29
29
|
command?: string;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Build command run in the builder stage of multi-stage builds
|
|
32
|
+
* (default: 'npm run build'). Set to '' for apps without a build step;
|
|
33
|
+
* the production stage then copies the whole builder workdir instead of `dist/`.
|
|
34
|
+
*/
|
|
31
35
|
buildCommand?: string;
|
|
32
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Required environment variable names. They are listed in `.env.example`
|
|
38
|
+
* and passed through to the app container in docker-compose.yml.
|
|
39
|
+
*/
|
|
33
40
|
env?: string[];
|
|
34
41
|
/** Volume mappings */
|
|
35
42
|
volumes?: string[];
|
|
36
|
-
/** Health check endpoint path */
|
|
43
|
+
/** Health check endpoint path (e.g. '/health') */
|
|
37
44
|
healthcheck?: string;
|
|
38
45
|
/** Use multi-stage build (default: true) */
|
|
39
46
|
multiStage?: boolean;
|
|
@@ -104,6 +111,8 @@ interface RedisConfig extends ServiceConfig {
|
|
|
104
111
|
interface CustomServiceConfig extends ServiceConfig {
|
|
105
112
|
/** Custom Docker image (e.g., 'elasticsearch:8.11.0') */
|
|
106
113
|
image: string;
|
|
114
|
+
/** Health check command run inside the container with CMD-SHELL */
|
|
115
|
+
healthcheck?: string;
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
109
118
|
* Service configuration (union type for all supported services)
|
|
@@ -171,9 +180,9 @@ interface ResolvedServiceConfig {
|
|
|
171
180
|
name: string;
|
|
172
181
|
/** Docker image */
|
|
173
182
|
image: string;
|
|
174
|
-
/**
|
|
183
|
+
/** Port the service listens on inside the container */
|
|
175
184
|
port: number;
|
|
176
|
-
/**
|
|
185
|
+
/** Published host port (defaults to `port` when undefined) */
|
|
177
186
|
hostPort?: number;
|
|
178
187
|
/** Environment variables */
|
|
179
188
|
env: Record<string, string>;
|
|
@@ -358,7 +367,9 @@ declare class NoPortAvailableError extends DockcraftError {
|
|
|
358
367
|
* File write error
|
|
359
368
|
*/
|
|
360
369
|
declare class FileWriteError extends DockcraftError {
|
|
361
|
-
|
|
370
|
+
/** The underlying file system error, when there is one */
|
|
371
|
+
cause?: unknown;
|
|
372
|
+
constructor(path: string, code?: string, cause?: unknown);
|
|
362
373
|
}
|
|
363
374
|
/**
|
|
364
375
|
* Preset not found error
|
|
@@ -413,7 +424,8 @@ declare function listPresets(): string[];
|
|
|
413
424
|
|
|
414
425
|
/**
|
|
415
426
|
* Check if a port is available on localhost
|
|
416
|
-
* Returns true if port is available, false if in use
|
|
427
|
+
* Returns true if port is available, false if in use.
|
|
428
|
+
* Rejects with a RangeError for values that are not ports (1-65535).
|
|
417
429
|
*/
|
|
418
430
|
declare function isPortAvailable(port: number): Promise<boolean>;
|
|
419
431
|
/**
|
|
@@ -435,6 +447,11 @@ declare function getDefaultPort(service: string): number | undefined;
|
|
|
435
447
|
*/
|
|
436
448
|
declare function listDefaultPorts(): Record<string, number>;
|
|
437
449
|
|
|
450
|
+
/**
|
|
451
|
+
* Build a connection URL for a built-in service.
|
|
452
|
+
* User, password and database are percent-encoded, so passwords containing
|
|
453
|
+
* `@`, `:`, `/`, `#` or `?` produce valid URLs.
|
|
454
|
+
*/
|
|
438
455
|
declare function getConnectionString(service: string, config: {
|
|
439
456
|
host: string;
|
|
440
457
|
port: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ interface DockcraftConfig {
|
|
|
6
6
|
name: string;
|
|
7
7
|
/** Optional preset to start from */
|
|
8
8
|
preset?: PresetName;
|
|
9
|
-
/** Application configuration */
|
|
10
|
-
app
|
|
9
|
+
/** Application configuration (optional when a preset provides it) */
|
|
10
|
+
app?: AppConfig;
|
|
11
11
|
/** Service definitions */
|
|
12
12
|
services?: ServicesConfig;
|
|
13
13
|
/** Output options */
|
|
@@ -19,21 +19,28 @@ interface DockcraftConfig {
|
|
|
19
19
|
* Application configuration
|
|
20
20
|
*/
|
|
21
21
|
interface AppConfig {
|
|
22
|
-
/** Application port (number or 'auto' for automatic assignment) */
|
|
23
|
-
port
|
|
22
|
+
/** Application port (number or 'auto' for automatic assignment, default: 3000) */
|
|
23
|
+
port?: number | 'auto';
|
|
24
24
|
/** Node.js Docker image version (default: '20-alpine') */
|
|
25
25
|
node?: string;
|
|
26
26
|
/** Working directory in container (default: '/app') */
|
|
27
27
|
workdir?: string;
|
|
28
|
-
/** Start command (default: 'npm start') */
|
|
28
|
+
/** Start command, used for the Dockerfile CMD (default: 'npm start') */
|
|
29
29
|
command?: string;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Build command run in the builder stage of multi-stage builds
|
|
32
|
+
* (default: 'npm run build'). Set to '' for apps without a build step;
|
|
33
|
+
* the production stage then copies the whole builder workdir instead of `dist/`.
|
|
34
|
+
*/
|
|
31
35
|
buildCommand?: string;
|
|
32
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Required environment variable names. They are listed in `.env.example`
|
|
38
|
+
* and passed through to the app container in docker-compose.yml.
|
|
39
|
+
*/
|
|
33
40
|
env?: string[];
|
|
34
41
|
/** Volume mappings */
|
|
35
42
|
volumes?: string[];
|
|
36
|
-
/** Health check endpoint path */
|
|
43
|
+
/** Health check endpoint path (e.g. '/health') */
|
|
37
44
|
healthcheck?: string;
|
|
38
45
|
/** Use multi-stage build (default: true) */
|
|
39
46
|
multiStage?: boolean;
|
|
@@ -104,6 +111,8 @@ interface RedisConfig extends ServiceConfig {
|
|
|
104
111
|
interface CustomServiceConfig extends ServiceConfig {
|
|
105
112
|
/** Custom Docker image (e.g., 'elasticsearch:8.11.0') */
|
|
106
113
|
image: string;
|
|
114
|
+
/** Health check command run inside the container with CMD-SHELL */
|
|
115
|
+
healthcheck?: string;
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
109
118
|
* Service configuration (union type for all supported services)
|
|
@@ -171,9 +180,9 @@ interface ResolvedServiceConfig {
|
|
|
171
180
|
name: string;
|
|
172
181
|
/** Docker image */
|
|
173
182
|
image: string;
|
|
174
|
-
/**
|
|
183
|
+
/** Port the service listens on inside the container */
|
|
175
184
|
port: number;
|
|
176
|
-
/**
|
|
185
|
+
/** Published host port (defaults to `port` when undefined) */
|
|
177
186
|
hostPort?: number;
|
|
178
187
|
/** Environment variables */
|
|
179
188
|
env: Record<string, string>;
|
|
@@ -358,7 +367,9 @@ declare class NoPortAvailableError extends DockcraftError {
|
|
|
358
367
|
* File write error
|
|
359
368
|
*/
|
|
360
369
|
declare class FileWriteError extends DockcraftError {
|
|
361
|
-
|
|
370
|
+
/** The underlying file system error, when there is one */
|
|
371
|
+
cause?: unknown;
|
|
372
|
+
constructor(path: string, code?: string, cause?: unknown);
|
|
362
373
|
}
|
|
363
374
|
/**
|
|
364
375
|
* Preset not found error
|
|
@@ -413,7 +424,8 @@ declare function listPresets(): string[];
|
|
|
413
424
|
|
|
414
425
|
/**
|
|
415
426
|
* Check if a port is available on localhost
|
|
416
|
-
* Returns true if port is available, false if in use
|
|
427
|
+
* Returns true if port is available, false if in use.
|
|
428
|
+
* Rejects with a RangeError for values that are not ports (1-65535).
|
|
417
429
|
*/
|
|
418
430
|
declare function isPortAvailable(port: number): Promise<boolean>;
|
|
419
431
|
/**
|
|
@@ -435,6 +447,11 @@ declare function getDefaultPort(service: string): number | undefined;
|
|
|
435
447
|
*/
|
|
436
448
|
declare function listDefaultPorts(): Record<string, number>;
|
|
437
449
|
|
|
450
|
+
/**
|
|
451
|
+
* Build a connection URL for a built-in service.
|
|
452
|
+
* User, password and database are percent-encoded, so passwords containing
|
|
453
|
+
* `@`, `:`, `/`, `#` or `?` produce valid URLs.
|
|
454
|
+
*/
|
|
438
455
|
declare function getConnectionString(service: string, config: {
|
|
439
456
|
host: string;
|
|
440
457
|
port: number;
|