@rharkor/caching-for-turbo 2.0.0 → 2.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/.env.example +6 -1
- package/README.md +14 -46
- package/dist/cli/index.js +66 -40
- package/dist/cli/index.js.map +1 -1
- package/package.json +2 -62
- package/.devcontainer/devcontainer.json +0 -41
- package/.gitattributes +0 -3
- package/.github/workflows/check-dist.yml +0 -43
- package/.github/workflows/ci.yml +0 -152
- package/.github/workflows/codeql-analysis.yml +0 -46
- package/.github/workflows/release.yml +0 -47
- package/.node-version +0 -1
- package/.prettierignore +0 -3
- package/.prettierrc.json +0 -16
- package/.releaserc.json +0 -132
- package/CHANGELOG.md +0 -9
- package/check-full-turbo.sh +0 -12
- package/eslint.config.mjs +0 -27
- package/renovate.json +0 -17
- package/script/release +0 -59
- package/src/cli.ts +0 -94
- package/src/dev/cleanup.ts +0 -14
- package/src/dev-run.ts +0 -16
- package/src/index.ts +0 -6
- package/src/lib/constants.ts +0 -29
- package/src/lib/core.ts +0 -62
- package/src/lib/env/index.ts +0 -22
- package/src/lib/ping.ts +0 -7
- package/src/lib/providers/cache/index.ts +0 -87
- package/src/lib/providers/cache/utils.ts +0 -70
- package/src/lib/providers/s3/index.ts +0 -237
- package/src/lib/providers.ts +0 -42
- package/src/lib/server/cleanup.ts +0 -111
- package/src/lib/server/index.ts +0 -85
- package/src/lib/server/utils.ts +0 -91
- package/src/main.ts +0 -21
- package/src/post.ts +0 -26
- package/tsconfig.json +0 -19
- package/turbo.json +0 -9
package/.env.example
CHANGED
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ the following step **before** you run `turbo build`:
|
|
|
55
55
|
|
|
56
56
|
```yaml
|
|
57
57
|
- name: Cache for Turbo
|
|
58
|
-
uses: rharkor/caching-for-turbo@v2.
|
|
58
|
+
uses: rharkor/caching-for-turbo@v2.1.0
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
This GitHub Action facilitates:
|
|
@@ -69,16 +69,16 @@ This GitHub Action facilitates:
|
|
|
69
69
|
|
|
70
70
|
## Local Development
|
|
71
71
|
|
|
72
|
-
You can also use this package as a
|
|
73
|
-
during development. This allows you to use the same caching
|
|
74
|
-
(including S3) that you use in CI.
|
|
72
|
+
You can also use this package as a global dependency to run the cache server
|
|
73
|
+
locally during development. This allows you to use the same caching
|
|
74
|
+
infrastructure (including S3) that you use in CI.
|
|
75
75
|
|
|
76
76
|
### Installation
|
|
77
77
|
|
|
78
|
-
Add this package as a
|
|
78
|
+
Add this package as a global dependency:
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
|
-
npm install
|
|
81
|
+
npm install -g @rharkor/caching-for-turbo
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
### Usage
|
|
@@ -88,22 +88,22 @@ server:
|
|
|
88
88
|
|
|
89
89
|
```bash
|
|
90
90
|
# Start the server in background mode (recommended for development)
|
|
91
|
-
|
|
91
|
+
turbogha
|
|
92
92
|
|
|
93
93
|
# Or run the server in foreground mode
|
|
94
|
-
|
|
94
|
+
turbogha --server
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
To stop the server, you can use the following command:
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
|
-
|
|
100
|
+
turbogha --kill
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
To ping the server, you can use the following command:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
|
-
|
|
106
|
+
turbogha --ping
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
### Environment Configuration
|
|
@@ -140,7 +140,6 @@ export TURBO_TEAM=turbogha
|
|
|
140
140
|
turbo build
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
_**Note:** Store the environment variables in a .env for turbo to use them._
|
|
144
143
|
_See: https://turborepo.com/docs/reference/system-environment-variables_
|
|
145
144
|
|
|
146
145
|
### Stopping the Server
|
|
@@ -148,41 +147,11 @@ _See: https://turborepo.com/docs/reference/system-environment-variables_
|
|
|
148
147
|
To stop the cache server:
|
|
149
148
|
|
|
150
149
|
```bash
|
|
150
|
+
turbogha --kill
|
|
151
|
+
# or
|
|
151
152
|
curl -X DELETE http://localhost:41230/shutdown
|
|
152
153
|
```
|
|
153
154
|
|
|
154
|
-
### Development Workflow Example
|
|
155
|
-
|
|
156
|
-
1. **Start the cache server:**
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
npx turbogha
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
2. **Set up environment variables:**
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
export TURBO_API=http://localhost:41230
|
|
166
|
-
export TURBO_TOKEN=turbogha
|
|
167
|
-
export TURBO_TEAM=turbogha
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
3. **Run your builds with remote caching:**
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
turbo build
|
|
174
|
-
turbo test
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
4. **Stop the server when done:**
|
|
178
|
-
```bash
|
|
179
|
-
curl -X DELETE http://localhost:41230/shutdown
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
This setup allows you to use the same S3-based caching infrastructure locally
|
|
183
|
-
that you use in your CI pipeline, ensuring consistent caching behavior across
|
|
184
|
-
environments.
|
|
185
|
-
|
|
186
155
|
## Configurable Options
|
|
187
156
|
|
|
188
157
|
Customize the caching behavior with the following optional settings (defaults
|
|
@@ -231,7 +200,7 @@ Example S3 configuration:
|
|
|
231
200
|
|
|
232
201
|
```yaml
|
|
233
202
|
- name: Cache for Turbo
|
|
234
|
-
uses: rharkor/caching-for-turbo@v2.
|
|
203
|
+
uses: rharkor/caching-for-turbo@v2.1.0
|
|
235
204
|
with:
|
|
236
205
|
provider: s3
|
|
237
206
|
s3-access-key-id: ${{ secrets.S3_ACCESS_KEY_ID }}
|
|
@@ -269,7 +238,7 @@ Example with cleanup configuration:
|
|
|
269
238
|
|
|
270
239
|
```yaml
|
|
271
240
|
- name: Cache for Turbo
|
|
272
|
-
uses: rharkor/caching-for-turbo@v2.
|
|
241
|
+
uses: rharkor/caching-for-turbo@v2.1.0
|
|
273
242
|
with:
|
|
274
243
|
provider: s3
|
|
275
244
|
s3-access-key-id: ${{ secrets.S3_ACCESS_KEY_ID }}
|
|
@@ -314,4 +283,3 @@ file.
|
|
|
314
283
|
This project is inspired by
|
|
315
284
|
[dtinth](https://github.com/dtinth/setup-github-actions-caching-for-turbo) and
|
|
316
285
|
has been comprehensively rewritten for enhanced robustness and reliability.
|
|
317
|
-
|
package/dist/cli/index.js
CHANGED
|
@@ -202048,7 +202048,7 @@ const ping = async () => {
|
|
|
202048
202048
|
// EXTERNAL MODULE: external "fs/promises"
|
|
202049
202049
|
var promises_ = __nccwpck_require__(91943);
|
|
202050
202050
|
;// CONCATENATED MODULE: ./package.json
|
|
202051
|
-
const package_namespaceObject = {"rE":"1.0
|
|
202051
|
+
const package_namespaceObject = {"rE":"2.1.0"};
|
|
202052
202052
|
;// CONCATENATED MODULE: ./src/cli.ts
|
|
202053
202053
|
|
|
202054
202054
|
|
|
@@ -202063,19 +202063,20 @@ const package_namespaceObject = {"rE":"1.0.2"};
|
|
|
202063
202063
|
const cli_main = async () => {
|
|
202064
202064
|
await logger.init();
|
|
202065
202065
|
const args = process.argv.slice(2);
|
|
202066
|
-
|
|
202067
|
-
|
|
202066
|
+
const command = args[0];
|
|
202067
|
+
const help = `
|
|
202068
202068
|
Turborepo GitHub Actions Cache Server
|
|
202069
202069
|
|
|
202070
202070
|
Usage:
|
|
202071
|
-
turbogha [options]
|
|
202071
|
+
turbogha <command> [options]
|
|
202072
202072
|
|
|
202073
|
-
|
|
202074
|
-
|
|
202075
|
-
--
|
|
202076
|
-
|
|
202077
|
-
|
|
202078
|
-
|
|
202073
|
+
Commands:
|
|
202074
|
+
start Start the cache server (default: background mode)
|
|
202075
|
+
start --foreground Start the cache server in foreground mode
|
|
202076
|
+
kill Kill the running server
|
|
202077
|
+
ping Ping the server to check if it's running
|
|
202078
|
+
help Show this help message
|
|
202079
|
+
version Show version
|
|
202079
202080
|
|
|
202080
202081
|
Environment Variables:
|
|
202081
202082
|
The following environment variables are supported for S3 configuration:
|
|
@@ -202088,47 +202089,72 @@ Environment Variables:
|
|
|
202088
202089
|
- PROVIDER: Cache provider (github or s3)
|
|
202089
202090
|
|
|
202090
202091
|
Examples:
|
|
202091
|
-
#
|
|
202092
|
-
turbogha
|
|
202092
|
+
# Start server in background and export environment variables
|
|
202093
|
+
turbogha start
|
|
202093
202094
|
|
|
202094
|
-
#
|
|
202095
|
-
turbogha --
|
|
202095
|
+
# Start server in foreground mode
|
|
202096
|
+
turbogha start --foreground
|
|
202096
202097
|
|
|
202097
202098
|
# Ping the server
|
|
202098
|
-
turbogha
|
|
202099
|
+
turbogha ping
|
|
202100
|
+
|
|
202101
|
+
# Kill the server
|
|
202102
|
+
turbogha kill
|
|
202099
202103
|
|
|
202100
202104
|
# With S3 configuration
|
|
202101
|
-
S3_ACCESS_KEY_ID=your-key S3_SECRET_ACCESS_KEY=your-secret S3_BUCKET=your-bucket S3_REGION=us-east-1 turbogha
|
|
202102
|
-
|
|
202105
|
+
S3_ACCESS_KEY_ID=your-key S3_SECRET_ACCESS_KEY=your-secret S3_BUCKET=your-bucket S3_REGION=us-east-1 turbogha start
|
|
202106
|
+
`;
|
|
202107
|
+
if (!command ||
|
|
202108
|
+
command === '--help' ||
|
|
202109
|
+
command === '-h' ||
|
|
202110
|
+
command === 'help') {
|
|
202111
|
+
console.log(help);
|
|
202103
202112
|
process.exit(0);
|
|
202104
202113
|
}
|
|
202105
|
-
if (
|
|
202114
|
+
if (command === '--version' || command === '-v' || command === 'version') {
|
|
202106
202115
|
console.log(package_namespaceObject.rE);
|
|
202107
202116
|
process.exit(0);
|
|
202108
202117
|
}
|
|
202118
|
+
const startForeground = async () => {
|
|
202119
|
+
// Empty log file
|
|
202120
|
+
await (0,promises_.writeFile)(serverLogFile, '', { flag: 'w' });
|
|
202121
|
+
// Run server in foreground mode
|
|
202122
|
+
console.log('Starting Turborepo cache server in foreground mode...');
|
|
202123
|
+
await server();
|
|
202124
|
+
};
|
|
202125
|
+
if (command === '--server') {
|
|
202126
|
+
await startForeground();
|
|
202127
|
+
return;
|
|
202128
|
+
}
|
|
202109
202129
|
try {
|
|
202110
|
-
|
|
202111
|
-
|
|
202112
|
-
|
|
202113
|
-
|
|
202114
|
-
|
|
202115
|
-
|
|
202116
|
-
|
|
202117
|
-
|
|
202118
|
-
|
|
202119
|
-
|
|
202120
|
-
|
|
202121
|
-
|
|
202122
|
-
|
|
202123
|
-
|
|
202124
|
-
|
|
202125
|
-
|
|
202126
|
-
|
|
202127
|
-
|
|
202128
|
-
|
|
202129
|
-
|
|
202130
|
-
|
|
202131
|
-
|
|
202130
|
+
switch (command) {
|
|
202131
|
+
case 'ping':
|
|
202132
|
+
await ping();
|
|
202133
|
+
break;
|
|
202134
|
+
case 'kill':
|
|
202135
|
+
await killServer();
|
|
202136
|
+
break;
|
|
202137
|
+
case 'start': {
|
|
202138
|
+
const isForeground = args.includes('--foreground');
|
|
202139
|
+
if (isForeground) {
|
|
202140
|
+
await startForeground();
|
|
202141
|
+
}
|
|
202142
|
+
else {
|
|
202143
|
+
// Run server in background mode and export environment variables
|
|
202144
|
+
console.log('Starting Turborepo cache server...');
|
|
202145
|
+
// Empty log file
|
|
202146
|
+
await (0,promises_.writeFile)(serverLogFile, '', { flag: 'w' });
|
|
202147
|
+
await launchServer();
|
|
202148
|
+
console.log('\nServer is running! You can now use Turbo with remote caching.');
|
|
202149
|
+
console.log('\nTo stop the server, run:');
|
|
202150
|
+
console.log('turbogha kill');
|
|
202151
|
+
}
|
|
202152
|
+
break;
|
|
202153
|
+
}
|
|
202154
|
+
default:
|
|
202155
|
+
console.error(`Unknown command: ${command}`);
|
|
202156
|
+
console.log(help);
|
|
202157
|
+
process.exit(1);
|
|
202132
202158
|
}
|
|
202133
202159
|
}
|
|
202134
202160
|
catch (error) {
|