turborepo-remote-cache 1.7.0 → 1.7.2
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 +5 -2
- package/build/plugins/remote-cache/index.js +1 -1
- package/build/plugins/remote-cache/index.js.map +1 -1
- package/build/plugins/remote-cache/storage/google-cloud-storage.js +16 -7
- package/build/plugins/remote-cache/storage/google-cloud-storage.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
 [ [](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/ci.yml) [](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/release.yml) [](https://github.com/ducktors/turborepo-remote-cache/actions/workflows/docker.yml) [](https://coveralls.io/github/ducktors/turborepo-remote-cache?branch=main) [](https://hub.docker.com/r/fox1t/turborepo-remote-cache) []([https://img.shields.io/npm/dt/turborepo-remote-cache](https://www.npmjs.com/package/turborepo-remote-cache)) [](https://github.com/semantic-release/semantic-release) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
4
|
+
[](#contributors-)
|
|
5
5
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
6
6
|
|
|
7
7
|
|
|
@@ -74,6 +74,9 @@ fix: fix a bug ---> 1.0.x
|
|
|
74
74
|
<tr>
|
|
75
75
|
<td align="center"><a href="https://github.com/jgoz"><img src="https://avatars.githubusercontent.com/u/132233?v=4?s=100" width="100px;" alt="John Gozde"/><br /><sub><b>John Gozde</b></sub></a><br /><a href="https://github.com/ducktors/turborepo-remote-cache/commits?author=jgoz" title="Code">💻</a></td>
|
|
76
76
|
<td align="center"><a href="https://github.com/sppatel"><img src="https://avatars.githubusercontent.com/u/989367?v=4?s=100" width="100px;" alt="Sachin Patel"/><br /><sub><b>Sachin Patel</b></sub></a><br /><a href="https://github.com/ducktors/turborepo-remote-cache/commits?author=sppatel" title="Code">💻</a></td>
|
|
77
|
+
<td align="center"><a href="http://www.andrewsnagy.com"><img src="https://avatars.githubusercontent.com/u/564256?v=4?s=100" width="100px;" alt="Andrew Nagy"/><br /><sub><b>Andrew Nagy</b></sub></a><br /><a href="https://github.com/ducktors/turborepo-remote-cache/commits?author=tm1000" title="Code">💻</a></td>
|
|
78
|
+
<td align="center"><a href="https://github.com/emalihin"><img src="https://avatars.githubusercontent.com/u/6379998?v=4?s=100" width="100px;" alt="Eugene Malihins"/><br /><sub><b>Eugene Malihins</b></sub></a><br /><a href="https://github.com/ducktors/turborepo-remote-cache/commits?author=emalihin" title="Code">💻</a></td>
|
|
79
|
+
<td align="center"><a href="http://joedevivo.com"><img src="https://avatars.githubusercontent.com/u/55951?v=4?s=100" width="100px;" alt="Joe DeVivo"/><br /><sub><b>Joe DeVivo</b></sub></a><br /><a href="#infra-joedevivo" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
77
80
|
</tr>
|
|
78
81
|
</tbody>
|
|
79
82
|
</table>
|
|
@@ -31,7 +31,7 @@ async function turboRemoteCache(instance, options) {
|
|
|
31
31
|
region: instance.config.S3_REGION,
|
|
32
32
|
endpoint: instance.config.S3_ENDPOINT,
|
|
33
33
|
clientEmail: instance.config.GCS_CLIENT_EMAIL,
|
|
34
|
-
privateKey: instance.config.GCS_PRIVATE_KEY,
|
|
34
|
+
privateKey: instance.config.GCS_PRIVATE_KEY?.replace(/\\n/g, '\n'),
|
|
35
35
|
projectId: instance.config.GCS_PROJECT_ID,
|
|
36
36
|
}));
|
|
37
37
|
await instance.register(async function (i) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/remote-cache/index.ts"],"names":[],"mappings":";;AACA,qCAAqD;AACrD,qCAAkF;AAClF,uCAA0C;AAC1C,mCAA6C;AAE7C,KAAK,UAAU,gBAAgB,CAC7B,QAAyB,EACzB,OAKC;IAED,MAAM,EACJ,aAAa,EACb,SA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ACH,CAAC;AAED,kBAAe,gBAAgB,CAAA","sourcesContent":["import { FastifyInstance } from 'fastify'\nimport { badRequest, unauthorized } from '@hapi/boom'\nimport { getArtifact, putArtifact, artifactsEvents, headArtifact } from './routes'\nimport { createLocation } from './storage'\nimport { STORAGE_PROVIDERS } from '../../env'\n\nasync function turboRemoteCache(\n instance: FastifyInstance,\n options: {\n allowedTokens: string[]\n bodyLimit?: number\n apiVersion?: `v${number}`\n provider?: STORAGE_PROVIDERS\n },\n) {\n const {\n allowedTokens,\n bodyLimit = 104857600,\n apiVersion = 'v8',\n provider = STORAGE_PROVIDERS.LOCAL,\n } = options\n if (!(Array.isArray(allowedTokens) && allowedTokens.length)) {\n throw new Error(\n `'allowedTokens' options must be a string[], ${typeof allowedTokens} provided instead`,\n )\n }\n\n instance.addContentTypeParser<Buffer>(\n 'application/octet-stream',\n { parseAs: 'buffer', bodyLimit },\n async function parser(request, payload) {\n return payload\n },\n )\n\n const tokens = new Set<string>(allowedTokens)\n instance.addHook('onRequest', async function (request) {\n let authHeader = request.headers['authorization']\n authHeader = Array.isArray(authHeader) ? authHeader.join() : authHeader\n\n if (!authHeader) {\n throw badRequest(`Missing Authorization header`)\n }\n const [, token] = authHeader.split('Bearer ')\n if (!tokens.has(token)) {\n throw unauthorized(`Invalid authorization token`)\n }\n })\n\n instance.decorate(\n 'location',\n createLocation(provider, {\n accessKey: instance.config.S3_ACCESS_KEY,\n secretKey: instance.config.S3_SECRET_KEY,\n path: instance.config.STORAGE_PATH,\n region: instance.config.S3_REGION,\n endpoint: instance.config.S3_ENDPOINT,\n clientEmail: instance.config.GCS_CLIENT_EMAIL,\n privateKey: instance.config.GCS_PRIVATE_KEY?.replace(/\\\\n/g, '\\n'),\n projectId: instance.config.GCS_PROJECT_ID,\n }),\n )\n\n await instance.register(\n async function (i) {\n i.route(getArtifact)\n i.route(headArtifact)\n i.route(putArtifact)\n i.route(artifactsEvents)\n },\n { prefix: `/${apiVersion}` },\n )\n}\n\nexport default turboRemoteCache\n"]}
|
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createGoogleCloudStorage = void 0;
|
|
4
4
|
const storage_1 = require("@google-cloud/storage");
|
|
5
|
-
function
|
|
5
|
+
function createStorage({ clientEmail, privateKey, projectId }) {
|
|
6
6
|
if (!clientEmail || !privateKey || !projectId) {
|
|
7
|
-
|
|
7
|
+
return new storage_1.Storage();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return new storage_1.Storage({
|
|
11
|
+
projectId,
|
|
12
|
+
credentials: {
|
|
13
|
+
client_email: clientEmail,
|
|
14
|
+
private_key: privateKey,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
8
17
|
}
|
|
9
|
-
|
|
18
|
+
}
|
|
19
|
+
function createGoogleCloudStorage({ bucket, clientEmail, privateKey, projectId, }) {
|
|
20
|
+
const storage = createStorage({
|
|
21
|
+
clientEmail,
|
|
22
|
+
privateKey,
|
|
10
23
|
projectId,
|
|
11
|
-
credentials: {
|
|
12
|
-
client_email: clientEmail,
|
|
13
|
-
private_key: privateKey,
|
|
14
|
-
},
|
|
15
24
|
});
|
|
16
25
|
const turboBucket = storage.bucket(bucket);
|
|
17
26
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-storage.js","sourceRoot":"","sources":["../../../../src/plugins/remote-cache/storage/google-cloud-storage.ts"],"names":[],"mappings":";;;AACA,mDAA+C;AAS/C,
|
|
1
|
+
{"version":3,"file":"google-cloud-storage.js","sourceRoot":"","sources":["../../../../src/plugins/remote-cache/storage/google-cloud-storage.ts"],"names":[],"mappings":";;;AACA,mDAA+C;AAS/C,SAAS,aAAa,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE;IAC3D,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE;QAC7C,OAAO,IAAI,iBAAO,EAAE,CAAA;KACrB;SAAM;QACL,OAAO,IAAI,iBAAO,CAAC;YACjB,SAAS;YACT,WAAW,EAAE;gBACX,YAAY,EAAE,WAAW;gBACzB,WAAW,EAAE,UAAU;aACxB;SACF,CAAC,CAAA;KACH;AACH,CAAC;AAED,SAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,WAAW,EACX,UAAU,EACV,SAAS,GACiB;IAC1B,MAAM,OAAO,GAAG,aAAa,CAAC;QAC5B,WAAW;QACX,UAAU;QACV,SAAS;KACV,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAE1C,OAAO;QACL,MAAM,EAAE,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE;YAC3B,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC3C,CAAC;QACD,gBAAgB,CAAC,YAAY;YAC3B,OAAO,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,gBAAgB,EAAuB,CAAA;QAC/E,CAAC;QACD,iBAAiB,CAAC,YAAY;YAC5B,OAAO,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,iBAAiB,EAAE,CAAA;QAC3D,CAAC;KACF,CAAA;AACH,CAAC;AAzBD,4DAyBC","sourcesContent":["import { StorageProvider } from './index'\nimport { Storage } from '@google-cloud/storage'\n\nexport interface GoogleCloudStorageOptions {\n bucket: string\n projectId: string\n clientEmail: string\n privateKey: string\n}\n\nfunction createStorage({ clientEmail, privateKey, projectId }) {\n if (!clientEmail || !privateKey || !projectId) {\n return new Storage()\n } else {\n return new Storage({\n projectId,\n credentials: {\n client_email: clientEmail,\n private_key: privateKey,\n },\n })\n }\n}\n\nexport function createGoogleCloudStorage({\n bucket,\n clientEmail,\n privateKey,\n projectId,\n}: GoogleCloudStorageOptions): StorageProvider {\n const storage = createStorage({\n clientEmail,\n privateKey,\n projectId,\n })\n\n const turboBucket = storage.bucket(bucket)\n\n return {\n exists: (artifactPath, cb) => {\n turboBucket.file(artifactPath).exists(cb)\n },\n createReadStream(artifactPath) {\n return turboBucket.file(artifactPath).createReadStream() as NodeJS.ReadStream\n },\n createWriteStream(artifactPath) {\n return turboBucket.file(artifactPath).createWriteStream()\n },\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turborepo-remote-cache",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Turborepo remote cache server",
|
|
5
5
|
"main": "build",
|
|
6
6
|
"author": "Maksim Sinik <maksim@sinik.it>",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dev:start": "node --inspect -r @cspotcode/source-map-support/register -r dotenv/config build/index.js",
|
|
19
19
|
"check:types": "tsc -p ./tsconfig.json --noEmit",
|
|
20
20
|
"test": "cross-env TS_NODE_PROJECT=./test/tsconfig.json tap --ts",
|
|
21
|
+
"posttest": "tap --coverage-report=lcov",
|
|
21
22
|
"test:watch": "npm run test -- --watch",
|
|
22
23
|
"test:report": "npm run test -- --output-file=out.tap && tap-mocha-reporter xunit < out.tap > junit-testresults.xml",
|
|
23
24
|
"commitlint": "commitlint",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"coveralls": "^3.1.1",
|
|
73
74
|
"cross-env": "^7.0.3",
|
|
74
75
|
"cz-conventional-changelog": "^3.3.0",
|
|
75
|
-
"dotenv": "^
|
|
76
|
+
"dotenv": "^14.1.0",
|
|
76
77
|
"esbuild": "^0.14.5",
|
|
77
78
|
"eslint": "^8.4.1",
|
|
78
79
|
"eslint-config-prettier": "^8.3.0",
|