-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more checks to the CI pipeline (#39)
* Added better checks to validate i18n and ts * Updated prettier check to use tools instead * Added types for react-measure * Removed dependencies from another PR
- Loading branch information
1 parent
b3d0826
commit d5a726d
Showing
6 changed files
with
92 additions
and
17 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 |
---|---|---|
@@ -1,17 +1,9 @@ | ||
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') | ||
[ -z "$FILES" ] && exit 0 | ||
|
||
# Prettify all selected files | ||
echo "$FILES" | npm run prettier:write | ||
|
||
# Add back the modified/prettified files to staging | ||
echo "$FILES" | xargs git add | ||
|
||
if npm run prettier:check; then | ||
echo "Prettier passed" | ||
if npm run lint; then | ||
echo "Lint passed" | ||
else | ||
echo "Prettier failed" | ||
echo "Lint failed" | ||
exit 1 | ||
fi | ||
|
||
npm run lint |
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 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,46 @@ | ||
import fs from 'fs'; | ||
import { createRequire } from 'module'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
const manifest = require(__dirname + '/../static/manifest.json'); | ||
const defaultLocale = manifest.default_locale; | ||
|
||
const defaultTranslations = require( | ||
__dirname + `/../static/_locales/${defaultLocale}/messages.json`, | ||
); | ||
const defaultTranslationKeys = Object.keys(defaultTranslations); | ||
const locales = fs.readdirSync(__dirname + '/../static/_locales'); | ||
|
||
let errors = []; | ||
locales.forEach((locale) => { | ||
if (locale === defaultLocale) { | ||
return; | ||
} | ||
|
||
const translations = require( | ||
__dirname + `/../static/_locales/${locale}/messages.json`, | ||
); | ||
|
||
for (const key of defaultTranslationKeys) { | ||
if (!translations[key]) { | ||
errors.push({ | ||
locale, | ||
key, | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
if (errors.length > 0) { | ||
console.error('Missing translations:'); | ||
errors.forEach((error) => { | ||
console.error(`- ${error.locale}: ${error.key}`); | ||
}); | ||
process.exit(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,22 @@ | ||
// Check prettier only on changed files | ||
import { execSync } from 'child_process'; | ||
|
||
const changedFiles = execSync('git diff --name-only HEAD') | ||
.toString() | ||
.split('\n'); | ||
|
||
const EXTENSIONS = ['js', 'mjs', 'ts', 'tsx']; | ||
const prettierFiles = changedFiles.filter((file) => | ||
EXTENSIONS.some((ext) => file.endsWith(ext)), | ||
); | ||
|
||
if (prettierFiles.length > 0) { | ||
try { | ||
execSync( | ||
`npx prettier --ignore-path .gitignore --check ${prettierFiles.join(' ')}`, | ||
); | ||
} catch (error) { | ||
console.error('Prettier check failed'); | ||
process.exit(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