@rharkor/caching-for-turbo 2.3.14 → 2.4.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 +1 -1
- package/__mocks__/@actions/core.ts +8 -0
- package/__mocks__/@rharkor/logger.ts +10 -0
- package/dist/cli/136.index.js +1 -1
- package/dist/cli/762.index.js +1 -1
- package/dist/cli/998.index.js +1 -1
- package/dist/cli/index.js +4109 -1340
- package/jest.config.ts +20 -0
- package/package.json +2 -2
- package/dist/cli/file.js +0 -12
- package/dist/cli/worker1.js +0 -170
package/jest.config.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Config } from '@jest/types'
|
|
2
|
+
|
|
3
|
+
const config: Config.InitialOptions = {
|
|
4
|
+
extensionsToTreatAsEsm: ['.ts'],
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.ts$': [
|
|
7
|
+
'ts-jest',
|
|
8
|
+
{
|
|
9
|
+
useESM: true,
|
|
10
|
+
tsconfig: 'tsconfig.json'
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
testMatch: ['<rootDir>/__tests__/**/*.test.ts'],
|
|
15
|
+
moduleNameMapper: {
|
|
16
|
+
'^@/(.*)$': '<rootDir>/src/$1'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default config
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rharkor/caching-for-turbo",
|
|
3
3
|
"description": "Sets up Turborepo Remote Caching to work with GitHub Actions built-in cache",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/rharkor/caching-for-turbo",
|
|
7
7
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"node": ">=20"
|
|
29
29
|
},
|
|
30
30
|
"license": "MIT",
|
|
31
|
-
"packageManager": "npm@11.
|
|
31
|
+
"packageManager": "npm@11.14.1",
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
}
|
package/dist/cli/file.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const pino = require('./pino')
|
|
4
|
-
const { once } = require('events')
|
|
5
|
-
|
|
6
|
-
module.exports = async function (opts = {}) {
|
|
7
|
-
const destOpts = Object.assign({}, opts, { dest: opts.destination || 1, sync: false })
|
|
8
|
-
delete destOpts.destination
|
|
9
|
-
const destination = pino.destination(destOpts)
|
|
10
|
-
await once(destination, 'ready')
|
|
11
|
-
return destination
|
|
12
|
-
}
|
package/dist/cli/worker1.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { realImport, realRequire } = require('real-require')
|
|
4
|
-
const { workerData, parentPort } = require('worker_threads')
|
|
5
|
-
const { WRITE_INDEX, READ_INDEX } = require('./indexes')
|
|
6
|
-
const { waitDiff } = require('./wait')
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
dataBuf,
|
|
10
|
-
filename,
|
|
11
|
-
stateBuf
|
|
12
|
-
} = workerData
|
|
13
|
-
|
|
14
|
-
let destination
|
|
15
|
-
|
|
16
|
-
const state = new Int32Array(stateBuf)
|
|
17
|
-
const data = Buffer.from(dataBuf)
|
|
18
|
-
|
|
19
|
-
async function start () {
|
|
20
|
-
let worker
|
|
21
|
-
try {
|
|
22
|
-
if (filename.endsWith('.ts') || filename.endsWith('.cts')) {
|
|
23
|
-
// TODO: add support for the TSM modules loader ( https://github.com/lukeed/tsm ).
|
|
24
|
-
if (!process[Symbol.for('ts-node.register.instance')]) {
|
|
25
|
-
realRequire('ts-node/register')
|
|
26
|
-
} else if (process.env.TS_NODE_DEV) {
|
|
27
|
-
realRequire('ts-node-dev')
|
|
28
|
-
}
|
|
29
|
-
// TODO: Support ES imports once tsc, tap & ts-node provide better compatibility guarantees.
|
|
30
|
-
// Remove extra forwardslash on Windows
|
|
31
|
-
worker = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
|
|
32
|
-
} else {
|
|
33
|
-
worker = (await realImport(filename))
|
|
34
|
-
}
|
|
35
|
-
} catch (error) {
|
|
36
|
-
// A yarn user that tries to start a ThreadStream for an external module
|
|
37
|
-
// provides a filename pointing to a zip file.
|
|
38
|
-
// eg. require.resolve('pino-elasticsearch') // returns /foo/pino-elasticsearch-npm-6.1.0-0c03079478-6915435172.zip/bar.js
|
|
39
|
-
// The `import` will fail to try to load it.
|
|
40
|
-
// This catch block executes the `require` fallback to load the module correctly.
|
|
41
|
-
// In fact, yarn modifies the `require` function to manage the zipped path.
|
|
42
|
-
// More details at https://github.com/pinojs/pino/pull/1113
|
|
43
|
-
// The error codes may change based on the node.js version (ENOTDIR > 12, ERR_MODULE_NOT_FOUND <= 12 )
|
|
44
|
-
if ((error.code === 'ENOTDIR' || error.code === 'ERR_MODULE_NOT_FOUND') &&
|
|
45
|
-
filename.startsWith('file://')) {
|
|
46
|
-
worker = realRequire(decodeURIComponent(filename.replace('file://', '')))
|
|
47
|
-
} else if (error.code === undefined || error.code === 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING') {
|
|
48
|
-
// When bundled with pkg, an undefined error is thrown when called with realImport
|
|
49
|
-
// When bundled with pkg and using node v20, an ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING error is thrown when called with realImport
|
|
50
|
-
// More info at: https://github.com/pinojs/thread-stream/issues/143
|
|
51
|
-
worker = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
|
|
52
|
-
} else {
|
|
53
|
-
throw error
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Depending on how the default export is performed, and on how the code is
|
|
58
|
-
// transpiled, we may find cases of two nested "default" objects.
|
|
59
|
-
// See https://github.com/pinojs/pino/issues/1243#issuecomment-982774762
|
|
60
|
-
if (typeof worker === 'object') worker = worker.default
|
|
61
|
-
if (typeof worker === 'object') worker = worker.default
|
|
62
|
-
|
|
63
|
-
destination = await worker(workerData.workerData)
|
|
64
|
-
|
|
65
|
-
destination.on('error', function (err) {
|
|
66
|
-
Atomics.store(state, WRITE_INDEX, -2)
|
|
67
|
-
Atomics.notify(state, WRITE_INDEX)
|
|
68
|
-
|
|
69
|
-
Atomics.store(state, READ_INDEX, -2)
|
|
70
|
-
Atomics.notify(state, READ_INDEX)
|
|
71
|
-
|
|
72
|
-
parentPort.postMessage({
|
|
73
|
-
code: 'ERROR',
|
|
74
|
-
err
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
destination.on('close', function () {
|
|
79
|
-
// process._rawDebug('worker close emitted')
|
|
80
|
-
const end = Atomics.load(state, WRITE_INDEX)
|
|
81
|
-
Atomics.store(state, READ_INDEX, end)
|
|
82
|
-
Atomics.notify(state, READ_INDEX)
|
|
83
|
-
setImmediate(() => {
|
|
84
|
-
process.exit(0)
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// No .catch() handler,
|
|
90
|
-
// in case there is an error it goes
|
|
91
|
-
// to unhandledRejection
|
|
92
|
-
start().then(function () {
|
|
93
|
-
parentPort.postMessage({
|
|
94
|
-
code: 'READY'
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
process.nextTick(run)
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
function run () {
|
|
101
|
-
const current = Atomics.load(state, READ_INDEX)
|
|
102
|
-
const end = Atomics.load(state, WRITE_INDEX)
|
|
103
|
-
|
|
104
|
-
// process._rawDebug(`pre state ${current} ${end}`)
|
|
105
|
-
|
|
106
|
-
if (end === current) {
|
|
107
|
-
if (end === data.length) {
|
|
108
|
-
waitDiff(state, READ_INDEX, end, Infinity, run)
|
|
109
|
-
} else {
|
|
110
|
-
waitDiff(state, WRITE_INDEX, end, Infinity, run)
|
|
111
|
-
}
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// process._rawDebug(`post state ${current} ${end}`)
|
|
116
|
-
|
|
117
|
-
if (end === -1) {
|
|
118
|
-
// process._rawDebug('end')
|
|
119
|
-
destination.end()
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const toWrite = data.toString('utf8', current, end)
|
|
124
|
-
// process._rawDebug('worker writing: ' + toWrite)
|
|
125
|
-
|
|
126
|
-
const res = destination.write(toWrite)
|
|
127
|
-
|
|
128
|
-
if (res) {
|
|
129
|
-
Atomics.store(state, READ_INDEX, end)
|
|
130
|
-
Atomics.notify(state, READ_INDEX)
|
|
131
|
-
setImmediate(run)
|
|
132
|
-
} else {
|
|
133
|
-
destination.once('drain', function () {
|
|
134
|
-
Atomics.store(state, READ_INDEX, end)
|
|
135
|
-
Atomics.notify(state, READ_INDEX)
|
|
136
|
-
run()
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
process.on('unhandledRejection', function (err) {
|
|
142
|
-
parentPort.postMessage({
|
|
143
|
-
code: 'ERROR',
|
|
144
|
-
err
|
|
145
|
-
})
|
|
146
|
-
process.exit(1)
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
process.on('uncaughtException', function (err) {
|
|
150
|
-
parentPort.postMessage({
|
|
151
|
-
code: 'ERROR',
|
|
152
|
-
err
|
|
153
|
-
})
|
|
154
|
-
process.exit(1)
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
process.once('exit', exitCode => {
|
|
158
|
-
if (exitCode !== 0) {
|
|
159
|
-
process.exit(exitCode)
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
if (destination?.writableNeedDrain && !destination?.writableEnded) {
|
|
163
|
-
parentPort.postMessage({
|
|
164
|
-
code: 'WARNING',
|
|
165
|
-
err: new Error('ThreadStream: process exited before destination stream was drained. this may indicate that the destination stream try to write to a another missing stream')
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
process.exit(0)
|
|
170
|
-
})
|