mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
* fix: try to fix make docker container.sh * fix: specify correct docker build scripts folder * fix: validate branch to valid docker tag name * feat: combined workflows * feat: add readable names for github actions * feat: add docker pull command comment * fix: comment publishing comment with docker instructions * feat: improve build & test performance * feat: add option to skip cache * fix: flush cache * fix: flush cache * feat: merge tests and build steps * fix: github action outputs keys * feat: add lint job * feat: change file to trigger lint * fix: omit webapp path * fix: trigger lint * fix: continue on linting errors * feat: add publishing container to github docker registry * feat: add lint status * chore: re-trigger-lint * feat: add java checkstyle * fix: java linting * fix: github token * fix: update jave checkstyle action * chore: simplify frontend lint action * chore: remove changed java files * feat: revert lint trigger frontend * feat: add docker credentials helper * fix: remove credentials warning * fix: tests and clean command * CB-5228 feat: run frontend tests for every build * fix: clean tasks * feat: update cli tools
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
import { exec, execSync } from 'child_process';
|
|
import fs from 'fs';
|
|
import { resolve } from 'path';
|
|
import { createInterface } from 'readline';
|
|
|
|
const snippetPath = resolve(process.argv[2]);
|
|
const snippetName = process.argv[3];
|
|
const snippets = JSON.parse(fs.readFileSync(snippetPath, 'utf8'));
|
|
const licenseSnippet = snippets[snippetName];
|
|
|
|
const scopes = licenseSnippet.scope.split(',');
|
|
const license = licenseSnippet.body;
|
|
const extensions = new Set();
|
|
|
|
for (const scope of scopes) {
|
|
switch (scope.trim()) {
|
|
case 'typescript':
|
|
extensions.add('.ts');
|
|
break;
|
|
case 'typescriptreact':
|
|
extensions.add('.tsx');
|
|
break;
|
|
case 'javascript':
|
|
extensions.add('.js');
|
|
break;
|
|
case 'javascriptreact':
|
|
extensions.add('.jsx');
|
|
break;
|
|
case 'css':
|
|
extensions.add('.css');
|
|
break;
|
|
case 'scss':
|
|
extensions.add('.scss');
|
|
break;
|
|
}
|
|
}
|
|
|
|
const output = exec('git diff --cached --name-only --diff-filter=ACMR');
|
|
const rl = createInterface(output.stdout);
|
|
const invalidFiles = [];
|
|
|
|
for await (const line of rl) {
|
|
const extension = line.slice(line.lastIndexOf('.'));
|
|
if (extensions.has(extension)) {
|
|
const fileRl = createInterface(fs.createReadStream(line));
|
|
|
|
let fileLineIndex = 0;
|
|
for await (const fileLine of fileRl) {
|
|
if (fileLine.startsWith('#!/usr/bin/env')) {
|
|
continue;
|
|
}
|
|
if (fileLine !== license[fileLineIndex]) {
|
|
invalidFiles.push(line);
|
|
break;
|
|
}
|
|
fileLineIndex++;
|
|
if (fileLineIndex === license.length) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (invalidFiles.length > 0) {
|
|
execSync('git restore --staged ' + invalidFiles.join(' '));
|
|
process.stdout.write('Found files without license header. Please add license to all unstaged files.');
|
|
process.exit(1);
|
|
}
|