generated from idrinth-api-bench/project-defaults
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
266 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
2xx | ||
APIs | ||
Autowiring | ||
Benchmarking | ||
Björn | ||
Büttner | ||
CLI | ||
Codacy | ||
Destructuring | ||
DockerHub | ||
Dockerfiles | ||
ENV | ||
Fastify | ||
vue | ||
Gitea | ||
Gitlab | ||
HAR | ||
Idrinth's | ||
airtimeux.com | ||
JSON | ||
Javascript | ||
Jira | ||
MSSQL | ||
Matomo | ||
Microservice | ||
Middleware | ||
Middlewares | ||
Mindmap | ||
NPMJS | ||
Node.js | ||
OpenApi | ||
OpenSauced | ||
PascalCase | ||
Postgres | ||
README | ||
Roadmap | ||
SHA | ||
Web-UI | ||
XML | ||
XRAY_CLIENT_ID | ||
XRAY_CLIENT_SECRET | ||
XRAY_ENDPOINT | ||
XRAY_PASSWORD | ||
XRAY_TEST_PLAN_KEY | ||
XRAY_USER_NAME | ||
XRay | ||
aBc | ||
api-bench | ||
api-bench-cli | ||
api-bench-gitea-action | ||
api-bench-gitlab-runner | ||
api-bench-history-microservice | ||
api-bench-history-website | ||
api-bench-runner | ||
api-benchmark | ||
autowire | ||
autowired | ||
benchmarking | ||
bugfixes | ||
bvanderlaan | ||
camelCase | ||
ci-images | ||
coai | ||
codecheck | ||
csrf-header | ||
data.yml | ||
deprecations | ||
dockerfiles | ||
eslint | ||
faq | ||
gitea | ||
gitlab | ||
gitlab-runner | ||
history-microservice | ||
iab | ||
idrinth | ||
idrinth-api-bench | ||
jeffbski | ||
json | ||
jungwild | ||
macOS | ||
markmap | ||
matteofigus | ||
microservice | ||
microservices | ||
middleware | ||
middlewares | ||
mindmap | ||
mono-repo | ||
npm | ||
ns | ||
package.json | ||
pino | ||
pre | ||
programmatically | ||
readme | ||
rest-APIs | ||
sexualised | ||
src | ||
subprojects | ||
tracking.bjoern-buettner.me | ||
ui | ||
UI | ||
webmaster@idrinth-api-ben.ch | ||
winston | ||
www.contributor-covenant.org | ||
www.youtube-nocookie.com | ||
xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ jobs: | |
package-lock.json | ||
- run: npm ci | ||
- run: npm run language | ||
- run: npm run ftas | ||
- run: npm run fta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const FIRST_ARGUMENT = 2; | ||
export const EXIT_SUCCESS = 0; | ||
export const EXIT_FAILURE = 1; | ||
export const EMPTY = 0; | ||
export const ERROR_FTA_SCORE = 60; | ||
export const WARNING_FTA_SCORE = 60; | ||
export const PADDING_DEFAULT = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { | ||
EXIT_FAILURE, | ||
EXIT_SUCCESS, | ||
FIRST_ARGUMENT, | ||
ERROR_FTA_SCORE, | ||
WARNING_FTA_SCORE, | ||
PADDING_DEFAULT, | ||
} from './constants.js'; | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import { | ||
execSync, | ||
} from 'child_process'; | ||
|
||
const platform = process.platform; | ||
const architecture = process.arch; | ||
|
||
// eslint-disable-next-line complexity | ||
const getBinaryPath = () => { | ||
const targetDirectory = path.join( | ||
process.cwd(), | ||
'node_modules', | ||
'fta-cli', | ||
'binaries', | ||
); | ||
|
||
switch (platform) { | ||
case 'win32': | ||
if (architecture === 'x64') { | ||
return path.join(targetDirectory, 'x86_64-pc-windows-msvc', 'fta.exe',); | ||
} | ||
if (architecture === 'arm64') { | ||
return path.join( | ||
targetDirectory, | ||
'aarch64-pc-windows-msvc', | ||
'fta.exe', | ||
); | ||
} | ||
break; | ||
case 'darwin': | ||
if (architecture === 'x64') { | ||
return path.join(targetDirectory, 'x86_64-apple-darwin', 'fta',); | ||
} else if (architecture === 'arm64') { | ||
return path.join(targetDirectory, 'aarch64-apple-darwin', 'fta',); | ||
} | ||
break; | ||
case 'linux': | ||
if (architecture === 'x64') { | ||
return path.join(targetDirectory, 'x86_64-unknown-linux-musl', 'fta',); | ||
} else if (architecture === 'arm64') { | ||
return path.join(targetDirectory, 'aarch64-unknown-linux-musl', 'fta',); | ||
} else if (architecture === 'arm') { | ||
return path.join(targetDirectory, 'arm-unknown-linux-musleabi', 'fta',); | ||
} | ||
break; | ||
default: | ||
throw new Error('Unsupported platform: ' + platform,); | ||
} | ||
|
||
throw new Error('Binary not found for the current platform',); | ||
}; | ||
|
||
const setUnixPerms = (binaryPath,) => { | ||
if (platform === 'darwin' || platform === 'linux') { | ||
try { | ||
fs.chmodSync(binaryPath, '755',); | ||
} catch (e) { | ||
console.warn('Could not chmod fta binary: ', e,); | ||
} | ||
} | ||
}; | ||
|
||
const binary = getBinaryPath(); | ||
setUnixPerms(binary,); | ||
const output = JSON.parse(execSync( | ||
`${ binary } ${ process.cwd() } --json`, | ||
Check warning Code scanning / CodeQL Shell command built from environment values Medium
This shell command depends on an uncontrolled
absolute path Error loading related location Loading This shell command depends on an uncontrolled absolute path Error loading related location Loading |
||
{ | ||
encoding: 'utf8', | ||
stdio: 'pipe', | ||
}, | ||
).toString(),); | ||
|
||
let hardToMaintain = false; | ||
let maxLength = 0; | ||
let maxScore = 0; | ||
let maxAfter = 0; | ||
|
||
for (const file of output) { | ||
file.name = `${ process.argv[FIRST_ARGUMENT] }/${ file.file_name }`; | ||
maxLength = maxLength > file.name.length ? maxLength : file.name.length; | ||
maxScore = maxScore > `${ file.fta_score }`.split('.',).shift().length | ||
? maxScore | ||
: `${ file.fta_score }`.split('.',).shift().length; | ||
maxAfter = maxAfter > `${ file.fta_score }`.split('.',).pop().length | ||
? maxScore | ||
: `${ file.fta_score }`.split('.',).pop().length; | ||
} | ||
|
||
for (const file of output) { | ||
const padding = new Array(maxLength - file.name.length + PADDING_DEFAULT,) | ||
.fill(' ',) | ||
.join('',); | ||
const before = new Array( | ||
maxScore | ||
- `${ file.fta_score }`.split('.',).shift().length | ||
+ PADDING_DEFAULT, | ||
) | ||
.fill(' ',) | ||
.join('',); | ||
const after = new Array( | ||
maxAfter | ||
- `${ file.fta_score }`.split('.',).pop().length | ||
+ PADDING_DEFAULT, | ||
) | ||
.fill('0',) | ||
.join('',); | ||
const message = [ | ||
`${ file.name }${ padding }`, | ||
`${ before }${ file.fta_score }${ after.replace(/0$/u, ' ',) }`, | ||
` ${ file.assessment }`, | ||
].join('|',); | ||
if (file.fta_score > ERROR_FTA_SCORE) { | ||
hardToMaintain = true; | ||
console.error(message,); | ||
} else if (file.fta_score > WARNING_FTA_SCORE) { | ||
console.warn(message,); | ||
} else { | ||
console.log(message,); | ||
} | ||
} | ||
|
||
process.exit(hardToMaintain ? EXIT_FAILURE : EXIT_SUCCESS,); |