@joltdesign/scripts 0.19.3 → 0.21.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.
- package/README.md +85 -0
- package/dist/AWSClient.js +102 -0
- package/dist/AWSClient.js.map +1 -0
- package/dist/AWSConsoleUrlGenerator.js +59 -0
- package/dist/AWSConsoleUrlGenerator.js.map +1 -0
- package/dist/Command/AWS.js +354 -25
- package/dist/Command/AWS.js.map +1 -1
- package/dist/Command/Build.js +1 -1
- package/dist/Command/Build.js.map +1 -1
- package/dist/Command/Cache.js +1 -1
- package/dist/Command/Cache.js.map +1 -1
- package/dist/Command/Cmd.js +2 -2
- package/dist/Command/Cmd.js.map +1 -1
- package/dist/Command/Config.js +161 -3
- package/dist/Command/Config.js.map +1 -1
- package/dist/Command/DB.js +34 -19
- package/dist/Command/DB.js.map +1 -1
- package/dist/Command/Docker.js +10 -8
- package/dist/Command/Docker.js.map +1 -1
- package/dist/Command/JoltCommand.js +44 -1
- package/dist/Command/JoltCommand.js.map +1 -1
- package/dist/Command/Nexcess.js +64 -3
- package/dist/Command/Nexcess.js.map +1 -1
- package/dist/Command/Prepare.js +17 -5
- package/dist/Command/Prepare.js.map +1 -1
- package/dist/Command/SSH.js +13 -13
- package/dist/Command/SSH.js.map +1 -1
- package/dist/Command/WP.js +725 -5
- package/dist/Command/WP.js.map +1 -1
- package/dist/Config.js +91 -17
- package/dist/Config.js.map +1 -1
- package/dist/cli.js +12 -4
- package/dist/cli.js.map +1 -1
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/schemas.js +109 -0
- package/dist/schemas.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils.js +145 -11
- package/dist/utils.js.map +1 -1
- package/jolt-config.schema.json +308 -0
- package/package.json +25 -10
package/README.md
CHANGED
|
@@ -1 +1,86 @@
|
|
|
1
1
|
# jolt-scripts
|
|
2
|
+
|
|
3
|
+
A TypeScript CLI tool that provides DevOps automation commands for WordPress/Docker development and AWS deployment workflows.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
Jolt Scripts supports configuration through multiple sources (in order of precedence):
|
|
8
|
+
1. `.jolt.json` (JSON format)
|
|
9
|
+
2. `./bin/.env` (Environment variables)
|
|
10
|
+
3. `.env` (Environment variables)
|
|
11
|
+
|
|
12
|
+
### JSON Schema
|
|
13
|
+
|
|
14
|
+
A JSON schema is automatically generated from the Zod schema at `jolt-config.schema.json` for IDE autocompletion and validation. The schema is regenerated automatically when building the project. You can reference it in your `.jolt.json` file:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"$schema": "./node_modules/@joltdesign/scripts/jolt-config.schema.json",
|
|
19
|
+
"imageName": "my-app",
|
|
20
|
+
"awsRegion": "us-east-1",
|
|
21
|
+
"ecsCluster": "production-cluster"
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Configuration Properties
|
|
26
|
+
|
|
27
|
+
The configuration supports the following properties:
|
|
28
|
+
|
|
29
|
+
#### AWS Configuration
|
|
30
|
+
- `awsRegion`: AWS region for operations (default: "eu-west-1")
|
|
31
|
+
- `ecsCluster`/`devEcsCluster`: ECS cluster names for production/development
|
|
32
|
+
- `ecsService`/`devEcsService`: ECS service names for production/development
|
|
33
|
+
- `codebuildProject`/`devCodebuildProject`: CodeBuild project names
|
|
34
|
+
- `cloudfrontDistribution`: CloudFront distribution ID
|
|
35
|
+
|
|
36
|
+
#### Docker Configuration
|
|
37
|
+
- `imageName`: Docker image name for production builds
|
|
38
|
+
- `devImageName`: Docker image name for development (overrides imageName + dev suffix)
|
|
39
|
+
- `buildPlatform`: Docker build platform (e.g., "linux/amd64")
|
|
40
|
+
- `buildContext`: Docker build context path (default: ".")
|
|
41
|
+
- `ecrBaseUrl`: ECR repository base URL
|
|
42
|
+
|
|
43
|
+
#### SSH & Deployment Configuration
|
|
44
|
+
- `sshAccount`/`devSshAccount`: SSH accounts for deployments (user@host format)
|
|
45
|
+
- `sshPort`: SSH port number (default: "22")
|
|
46
|
+
- `liveFolder`/`devFolder`: Remote folder paths for deployments
|
|
47
|
+
- `branch`/`devBranch`: Git branches for deployments
|
|
48
|
+
- `repo`: Git repository URL
|
|
49
|
+
|
|
50
|
+
#### Site-Specific Configuration
|
|
51
|
+
Use the `sites` object to define site-specific overrides:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"ecsCluster": "production-cluster",
|
|
56
|
+
"sites": {
|
|
57
|
+
"staging": {
|
|
58
|
+
"ecsCluster": "staging-cluster",
|
|
59
|
+
"ecsService": "my-app-staging"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Command Overrides
|
|
66
|
+
Override external tool commands:
|
|
67
|
+
- `dockerCommand`, `composeCommand`, `terraformCommand`
|
|
68
|
+
- `nodeCommand`, `yarnCommand`, `awsCommand`
|
|
69
|
+
- `sshCommand`, `rsyncCommand`, `gitCommand`, `gzipCommand`
|
|
70
|
+
|
|
71
|
+
#### Prepare Commands
|
|
72
|
+
Define preparation commands to run before builds:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"prepareCommands": [
|
|
77
|
+
"yarn install",
|
|
78
|
+
{
|
|
79
|
+
"cmd": "yarn build",
|
|
80
|
+
"name": "Build application",
|
|
81
|
+
"timing": "normal",
|
|
82
|
+
"fail": true
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
```
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { CloudFrontClient } from '@aws-sdk/client-cloudfront';
|
|
2
|
+
import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
|
|
3
|
+
import { CodeBuildClient } from '@aws-sdk/client-codebuild';
|
|
4
|
+
import { ECRClient } from '@aws-sdk/client-ecr';
|
|
5
|
+
import { ECSClient } from '@aws-sdk/client-ecs';
|
|
6
|
+
import { S3Client } from '@aws-sdk/client-s3';
|
|
7
|
+
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
|
|
8
|
+
/**
|
|
9
|
+
* AWS SDK client manager for the Jolt Scripts CLI
|
|
10
|
+
* Provides configured clients for various AWS services
|
|
11
|
+
*/
|
|
12
|
+
export class AWSClientManager {
|
|
13
|
+
constructor(region) {
|
|
14
|
+
this.region = region;
|
|
15
|
+
this.clients = new Map();
|
|
16
|
+
this.credentialProvider = fromNodeProviderChain();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get or create an ECS client
|
|
20
|
+
*/
|
|
21
|
+
getECSClient() {
|
|
22
|
+
if (!this.clients.has('ecs')) {
|
|
23
|
+
this.clients.set('ecs', new ECSClient({
|
|
24
|
+
region: this.region,
|
|
25
|
+
credentials: this.credentialProvider,
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
return this.clients.get('ecs');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get or create an S3 client
|
|
32
|
+
*/
|
|
33
|
+
getS3Client() {
|
|
34
|
+
if (!this.clients.has('s3')) {
|
|
35
|
+
this.clients.set('s3', new S3Client({
|
|
36
|
+
region: this.region,
|
|
37
|
+
credentials: this.credentialProvider,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
return this.clients.get('s3');
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get or create a CloudWatch Logs client
|
|
44
|
+
*/
|
|
45
|
+
getCloudWatchLogsClient() {
|
|
46
|
+
if (!this.clients.has('logs')) {
|
|
47
|
+
this.clients.set('logs', new CloudWatchLogsClient({
|
|
48
|
+
region: this.region,
|
|
49
|
+
credentials: this.credentialProvider,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
return this.clients.get('logs');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get or create a CodeBuild client
|
|
56
|
+
*/
|
|
57
|
+
getCodeBuildClient() {
|
|
58
|
+
if (!this.clients.has('codebuild')) {
|
|
59
|
+
this.clients.set('codebuild', new CodeBuildClient({
|
|
60
|
+
region: this.region,
|
|
61
|
+
credentials: this.credentialProvider,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
return this.clients.get('codebuild');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get or create a CloudFront client
|
|
68
|
+
*/
|
|
69
|
+
getCloudFrontClient() {
|
|
70
|
+
if (!this.clients.has('cloudfront')) {
|
|
71
|
+
this.clients.set('cloudfront', new CloudFrontClient({
|
|
72
|
+
region: this.region,
|
|
73
|
+
credentials: this.credentialProvider,
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
return this.clients.get('cloudfront');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get or create an ECR client
|
|
80
|
+
*/
|
|
81
|
+
getECRClient() {
|
|
82
|
+
if (!this.clients.has('ecr')) {
|
|
83
|
+
this.clients.set('ecr', new ECRClient({
|
|
84
|
+
region: this.region,
|
|
85
|
+
credentials: this.credentialProvider,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
return this.clients.get('ecr');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clean up all clients
|
|
92
|
+
*/
|
|
93
|
+
destroy() {
|
|
94
|
+
for (const client of this.clients.values()) {
|
|
95
|
+
if (client.destroy) {
|
|
96
|
+
client.destroy();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.clients.clear();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=AWSClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AWSClient.js","sourceRoot":"","sources":["../src/AWSClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,oBAAo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ACZ,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,WAAW,EAAE,IAAI,CAAC,kBAAkB;aACrC,CAAC,CACH,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,CAAC,OAAO,EAAE,CAAA;YAClB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Console URL Generator
|
|
3
|
+
*
|
|
4
|
+
* Utility for generating AWS console URLs for various services
|
|
5
|
+
*/
|
|
6
|
+
export const AWSConsoleUrlGenerator = {
|
|
7
|
+
/**
|
|
8
|
+
* Generate ECS service console URL
|
|
9
|
+
*/
|
|
10
|
+
ecsService(region, cluster, service) {
|
|
11
|
+
return `https://${region}.console.aws.amazon.com/ecs/v2/clusters/${cluster}/services/${service}`;
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Generate ECS cluster console URL
|
|
15
|
+
*/
|
|
16
|
+
ecsCluster(region, cluster) {
|
|
17
|
+
return `https://${region}.console.aws.amazon.com/ecs/v2/clusters/${cluster}`;
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Generate S3 bucket console URL
|
|
21
|
+
*/
|
|
22
|
+
s3Bucket(_region, bucket) {
|
|
23
|
+
return `https://s3.console.aws.amazon.com/s3/buckets/${bucket}`;
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Generate CloudWatch log group console URL
|
|
27
|
+
*/
|
|
28
|
+
cloudWatchLogGroup(region, logGroup) {
|
|
29
|
+
const encodedLogGroup = encodeURIComponent(logGroup);
|
|
30
|
+
return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:log-groups/log-group/${encodedLogGroup}`;
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Generate CodeBuild project console URL
|
|
34
|
+
*/
|
|
35
|
+
codeBuildProject(region, projectName) {
|
|
36
|
+
return `https://${region}.console.aws.amazon.com/codesuite/codebuild/projects/${projectName}`;
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Generate CodeBuild build console URL
|
|
40
|
+
*/
|
|
41
|
+
codeBuildBuild(region, projectName, buildId) {
|
|
42
|
+
return `https://${region}.console.aws.amazon.com/codesuite/codebuild/projects/${projectName}/build/${buildId}`;
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Generate CloudFront distribution console URL
|
|
46
|
+
*/
|
|
47
|
+
cloudFrontDistribution(_region, distributionId) {
|
|
48
|
+
// CloudFront console is always in us-east-1 region but we include region for consistency
|
|
49
|
+
return `https://console.aws.amazon.com/cloudfront/v3/home#/distributions/${distributionId}`;
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Extract bucket name from S3 URI
|
|
53
|
+
*/
|
|
54
|
+
extractS3Bucket(s3Uri) {
|
|
55
|
+
const match = s3Uri.match(/^s3:\/\/([^/]+)/);
|
|
56
|
+
return match ? match[1] : null;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=AWSConsoleUrlGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AWSConsoleUrlGenerator.js","sourceRoot":"","sources":["../src/AWSConsoleUrlGenerator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC;;OAEG;IACH,UAAU,CAAC,MAAc,EAAE,OAAe,EAAE,OAAe;QACzD,OAAO,WAAW,MAAM,2CAA2C,OAAO,aAAa,OAAO,EAAE,CAAA;I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