@xcelera/cli 1.2.1 → 1.3.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/dist/action.js +59 -18
- package/dist/action.js.map +1 -1
- package/dist/cli.js +348 -0
- package/dist/cli.js.map +1 -0
- package/package.json +9 -4
- package/.commitlintrc.json +0 -3
- package/.devcontainer/devcontainer.json +0 -41
- package/.env.example +0 -61
- package/.gitattributes +0 -3
- package/.github/dependabot.yml +0 -30
- package/.github/workflows/check-dist.yml +0 -72
- package/.github/workflows/ci.yml +0 -70
- package/.github/workflows/codeql-analysis.yml +0 -48
- package/.github/workflows/licensed.yml +0 -74
- package/.github/workflows/linter.yml +0 -53
- package/.github/workflows/release.yml +0 -53
- package/.licensed.yml +0 -18
- package/.licenses/npm/@actions/core.dep.yml +0 -20
- package/.licenses/npm/@actions/exec.dep.yml +0 -20
- package/.licenses/npm/@actions/http-client.dep.yml +0 -32
- package/.licenses/npm/@actions/io.dep.yml +0 -20
- package/.licenses/npm/@fastify/busboy.dep.yml +0 -30
- package/.licenses/npm/tunnel.dep.yml +0 -35
- package/.licenses/npm/undici.dep.yml +0 -34
- package/.markdown-lint.yml +0 -24
- package/.node-version +0 -1
- package/.nvmrc +0 -1
- package/.prettierignore +0 -5
- package/.prettierrc.yml +0 -16
- package/.vscode/launch.json +0 -15
- package/.yaml-lint.yml +0 -14
- package/CODEOWNERS +0 -7
- package/action.yml +0 -29
- package/badges/coverage.svg +0 -1
- package/eslint.config.mjs +0 -81
- package/jest.config.js +0 -40
- package/release.config.mjs +0 -12
- package/rollup.config.ts +0 -30
- package/script/release +0 -133
- package/src/action.ts +0 -35
- package/src/api.ts +0 -46
- package/src/cli.ts +0 -79
- package/src/git.ts +0 -66
- package/src/types/git.ts +0 -5
- package/src/types/parse-github-url.d.ts +0 -12
- package/tsconfig.base.json +0 -23
- package/tsconfig.eslint.json +0 -18
- package/tsconfig.json +0 -11
package/dist/action.js
CHANGED
|
@@ -31233,29 +31233,70 @@ function requireGithub () {
|
|
|
31233
31233
|
|
|
31234
31234
|
var githubExports = requireGithub();
|
|
31235
31235
|
|
|
31236
|
+
const objectToString = Object.prototype.toString;
|
|
31237
|
+
|
|
31238
|
+
const isError = value => objectToString.call(value) === '[object Error]';
|
|
31239
|
+
|
|
31240
|
+
const errorMessages = new Set([
|
|
31241
|
+
'network error', // Chrome
|
|
31242
|
+
'Failed to fetch', // Chrome
|
|
31243
|
+
'NetworkError when attempting to fetch resource.', // Firefox
|
|
31244
|
+
'The Internet connection appears to be offline.', // Safari 16
|
|
31245
|
+
'Load failed', // Safari 17+
|
|
31246
|
+
'Network request failed', // `cross-fetch`
|
|
31247
|
+
'fetch failed', // Undici (Node.js)
|
|
31248
|
+
'terminated', // Undici (Node.js)
|
|
31249
|
+
]);
|
|
31250
|
+
|
|
31251
|
+
function isNetworkError(error) {
|
|
31252
|
+
const isValid = error
|
|
31253
|
+
&& isError(error)
|
|
31254
|
+
&& error.name === 'TypeError'
|
|
31255
|
+
&& typeof error.message === 'string';
|
|
31256
|
+
|
|
31257
|
+
if (!isValid) {
|
|
31258
|
+
return false;
|
|
31259
|
+
}
|
|
31260
|
+
|
|
31261
|
+
// We do an extra check for Safari 17+ as it has a very generic error message.
|
|
31262
|
+
// Network errors in Safari have no stack.
|
|
31263
|
+
if (error.message === 'Load failed') {
|
|
31264
|
+
return error.stack === undefined;
|
|
31265
|
+
}
|
|
31266
|
+
|
|
31267
|
+
return errorMessages.has(error.message);
|
|
31268
|
+
}
|
|
31269
|
+
|
|
31236
31270
|
async function requestAudit(url, token, github) {
|
|
31237
31271
|
const apiUrl = `${getApiBaseUrl()}/api/v1/audit`;
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31244
|
-
|
|
31245
|
-
|
|
31246
|
-
|
|
31247
|
-
|
|
31248
|
-
|
|
31249
|
-
|
|
31250
|
-
|
|
31251
|
-
|
|
31272
|
+
try {
|
|
31273
|
+
const response = await fetch(apiUrl, {
|
|
31274
|
+
method: 'POST',
|
|
31275
|
+
headers: {
|
|
31276
|
+
'Content-Type': 'application/json',
|
|
31277
|
+
Authorization: `Bearer ${token}`
|
|
31278
|
+
},
|
|
31279
|
+
body: JSON.stringify({
|
|
31280
|
+
url,
|
|
31281
|
+
github
|
|
31282
|
+
})
|
|
31283
|
+
});
|
|
31284
|
+
if (!response.ok) {
|
|
31285
|
+
const errorText = await response.text();
|
|
31286
|
+
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
|
|
31287
|
+
}
|
|
31288
|
+
const data = await response.json();
|
|
31289
|
+
return data;
|
|
31290
|
+
}
|
|
31291
|
+
catch (error) {
|
|
31292
|
+
if (isNetworkError(error)) {
|
|
31293
|
+
throw new Error('Network error', { cause: error });
|
|
31294
|
+
}
|
|
31295
|
+
throw error;
|
|
31252
31296
|
}
|
|
31253
|
-
const data = await response.json();
|
|
31254
|
-
return data;
|
|
31255
31297
|
}
|
|
31256
31298
|
function getApiBaseUrl() {
|
|
31257
|
-
if (process.env.NODE_ENV === 'development'
|
|
31258
|
-
process.env.GITHUB_ACTIONS !== 'true') {
|
|
31299
|
+
if (process.env.NODE_ENV === 'development') {
|
|
31259
31300
|
return 'http://localhost:3000';
|
|
31260
31301
|
}
|
|
31261
31302
|
return 'https://xcelera.dev';
|