@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 CHANGED
@@ -7,4 +7,9 @@ S3_PREFIX=turbogha/
7
7
  PROVIDER=s3
8
8
  MAX_AGE=1d
9
9
  MAX_FILES=100
10
- MAX_SIZE=100mb
10
+ MAX_SIZE=100mb
11
+
12
+ TURBOGHA_PORT=41230
13
+ TURBO_API=http://localhost:41230
14
+ TURBO_TOKEN=turbogha
15
+ TURBO_TEAM=turbogha
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.0.0
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 devDependency to run the cache server locally
73
- during development. This allows you to use the same caching infrastructure
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 devDependency to your project:
78
+ Add this package as a global dependency:
79
79
 
80
80
  ```bash
81
- npm install --save-dev @rharkor/caching-for-turbo
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
- npx turbogha
91
+ turbogha
92
92
 
93
93
  # Or run the server in foreground mode
94
- npx turbogha --server
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
- curl -X DELETE http://localhost:41230/shutdown
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
- npx turbogha --ping
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.0.0
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.0.0
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.2"};
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
- if (args.includes('--help') || args.includes('-h')) {
202067
- console.log(`
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
- Options:
202074
- --server Run the server in foreground mode
202075
- --help, -h Show this help message
202076
- --version, -v Show version
202077
- --ping Ping the server
202078
- --kill Kill the server
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
- # Run server in background and export environment variables
202092
- turbogha
202092
+ # Start server in background and export environment variables
202093
+ turbogha start
202093
202094
 
202094
- # Run server in foreground mode
202095
- turbogha --server
202095
+ # Start server in foreground mode
202096
+ turbogha start --foreground
202096
202097
 
202097
202098
  # Ping the server
202098
- turbogha --ping
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 (args.includes('--version') || args.includes('-v')) {
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
- if (args.includes('--ping')) {
202111
- await ping();
202112
- }
202113
- else if (args.includes('--kill')) {
202114
- await killServer();
202115
- }
202116
- else if (args.includes('--server')) {
202117
- // Empty log file
202118
- await (0,promises_.writeFile)(serverLogFile, '', { flag: 'w' });
202119
- // Run server in foreground mode
202120
- console.log('Starting Turborepo cache server in foreground mode...');
202121
- await server();
202122
- }
202123
- else {
202124
- // Run server in background mode and export environment variables
202125
- console.log('Starting Turborepo cache server...');
202126
- // Empty log file
202127
- await (0,promises_.writeFile)(serverLogFile, '', { flag: 'w' });
202128
- await launchServer();
202129
- console.log('\nServer is running! You can now use Turbo with remote caching.');
202130
- console.log('\nTo stop the server, run:');
202131
- console.log('curl -X DELETE http://localhost:41230/shutdown');
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) {