@xcelera/cli 1.2.2 → 1.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/dist/action.js +81 -18
- package/dist/action.js.map +1 -1
- package/dist/cli.js +94 -19
- package/dist/cli.js.map +1 -0
- package/package.json +10 -3
- 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 -56
- 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,92 @@ 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
|
+
// handle expected errors
|
|
31286
|
+
if (response.headers.get('content-type')?.includes('application/json')) {
|
|
31287
|
+
const errorResponse = (await response.json());
|
|
31288
|
+
return {
|
|
31289
|
+
success: false,
|
|
31290
|
+
error: {
|
|
31291
|
+
code: response.status,
|
|
31292
|
+
message: errorResponse.error,
|
|
31293
|
+
details: errorResponse.details
|
|
31294
|
+
}
|
|
31295
|
+
};
|
|
31296
|
+
}
|
|
31297
|
+
// handle unexpected errors
|
|
31298
|
+
const errorText = await response.text();
|
|
31299
|
+
throw new Error(`Operation failed: ${response.status} ${response.statusText} - ${errorText}`);
|
|
31300
|
+
}
|
|
31301
|
+
const data = (await response.json());
|
|
31302
|
+
return {
|
|
31303
|
+
success: true,
|
|
31304
|
+
data
|
|
31305
|
+
};
|
|
31306
|
+
}
|
|
31307
|
+
catch (error) {
|
|
31308
|
+
if (isNetworkError(error)) {
|
|
31309
|
+
return {
|
|
31310
|
+
success: false,
|
|
31311
|
+
error: {
|
|
31312
|
+
message: 'Network error',
|
|
31313
|
+
details: error.message
|
|
31314
|
+
}
|
|
31315
|
+
};
|
|
31316
|
+
}
|
|
31317
|
+
throw error;
|
|
31252
31318
|
}
|
|
31253
|
-
const data = await response.json();
|
|
31254
|
-
return data;
|
|
31255
31319
|
}
|
|
31256
31320
|
function getApiBaseUrl() {
|
|
31257
|
-
if (process.env.NODE_ENV === 'development'
|
|
31258
|
-
process.env.GITHUB_ACTIONS !== 'true') {
|
|
31321
|
+
if (process.env.NODE_ENV === 'development') {
|
|
31259
31322
|
return 'http://localhost:3000';
|
|
31260
31323
|
}
|
|
31261
31324
|
return 'https://xcelera.dev';
|