Skip to content

Commit

Permalink
Chores nov 19 (#89)
Browse files Browse the repository at this point in the history
* fix broken builds on some linux machines

* add depcheck to optimize dependencies (missing, unused, etc.)

* fix #88
  • Loading branch information
manuelbieh authored Nov 6, 2019
1 parent 49fc2fa commit 21e6dfe
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"i18n:scan": "cross-env NODE_ENV=i18n yarn-or-npm transpile && yarn-or-npm i18next-scanner './build/transpiled/**/*.js' && yarn clean:transpiled",
"link-react": "yarn-or-npm link react react-dom",
"lint": "concurrently \"yarn-or-npm lint:js\" \"yarn-or-npm lint:css\"",
"lint:js": "eslint src/**/*.{js,jsx,ts,tsx}",
"lint:js": "eslint --ext .js,.jsx,.ts,.tsx src/",
"lint:css": "stylelint src/**/*.css",
"lint:deps": "depcruise -c .dependency-cruiser.js src/",
"plop": "plop",
Expand Down Expand Up @@ -120,6 +120,7 @@
"cross-spawn": "^7.0.1",
"css-hot-loader": "^1.4.4",
"css-loader": "^3.2.0",
"depcheck": "^0.9.0",
"dependency-cruiser": "^5.2.2",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
Expand Down
4 changes: 3 additions & 1 deletion scripts/build-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const generateStaticHTML = async () => {
try {
// TODO: add try/wait/retry here instead of just generally waiting for 2000 ms
await sleep(2000);
const browser = await puppeteer.launch();
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
const page = await browser.newPage();
await page.goto(`${HOST}:${PORT}`);
const pageContent = await page.content();
Expand Down
41 changes: 41 additions & 0 deletions scripts/depcheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// TODO: this file is still WIP and is not properly configured yet
import depcheck from 'depcheck';

const options = {
ignoreBinPackage: false,
skipMissing: false,
ignoreDirs: ['dist', 'build'],
ignoreMatches: [
// a lot of false positives for dev tooling related packages
'eslint-*',
'stylelint-*',
'@babel/*',
'babel-*',
'@types/*',
'@typescript-eslint/*',
// more false positives
'husky',
'lint-staged',
'install-deps-postmerge',
'style-loader',
'@svgr/webpack',
],
parsers: {
'*.js': depcheck.parser.es6,
'*.jsx': depcheck.parser.jsx,
'*.ts': depcheck.parser.typescript,
'*.tsx': depcheck.parser.typescript,
},
detectors: [depcheck.detector.requireCallExpression, depcheck.detector.importDeclaration],
specials: [depcheck.special.eslint, depcheck.special.webpack],
};

depcheck(`${__dirname}/..`, options, (unused) => {
// console.log(unused.dependencies); // an array containing the unused dependencies
// console.log(unused.devDependencies); // an array containing the unused devDependencies
// console.log(unused.missing); // a lookup containing the dependencies missing in `package.json` and where they are used
// console.log(unused.using); // a lookup indicating each dependency is used by which files
// console.log(unused.invalidFiles); // files that cannot access or parse
// console.log(unused.invalidDirs); // directories that cannot access
console.log(unused);
});
3 changes: 3 additions & 0 deletions src/server/lib/i18n/lokalise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const writeFiles = async (data: string, targetFolder: string) => {
const translationsBundle = path.join(getTempDir(), 'locales.zip');

// Extract translation files from zipfile to temp folder
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.writeFileSync(translationsBundle, data);

// Decompress downloaded translations into temp dir to extract translations into
Expand All @@ -92,13 +93,15 @@ export const writeFiles = async (data: string, targetFolder: string) => {
const files = glob.sync(path.join(getTempDir(), '**/*.json'));

files.forEach((file) => {
// eslint-disable-next-line security/detect-non-literal-fs-filename
const fileContent = JSON.parse(fs.readFileSync(file, { encoding: 'utf-8' }));
const locale = path.basename(file, '.json');

Object.entries(fileContent).forEach(([namespace, values]) => {
mkdirp.sync(`${targetFolder}/${locale}`);

// write namespaced translations to locale/namespace.json in target folder
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.writeFileSync(
`${targetFolder}/${locale}/${namespace}.json`,
JSON.stringify(values),
Expand Down
94 changes: 92 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3348,6 +3348,11 @@ buffer@^5.2.1:
base64-js "^1.0.2"
ieee754 "^1.1.4"

builtin-modules@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484"
integrity sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==

builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
Expand Down Expand Up @@ -4455,6 +4460,11 @@ dateformat@^2.0.0:
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.2.0.tgz#4065e2013cf9fb916ddfd82efb506ad4c6769062"
integrity sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=

de-indent@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=

[email protected], debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand Down Expand Up @@ -4672,6 +4682,26 @@ delegates@^1.0.0:
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=

depcheck@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/depcheck/-/depcheck-0.9.0.tgz#fab778e91908b5196d38a0fde45291495fc13c3b"
integrity sha512-YdFTkVXUsW7z+b72iQFWjXEs4+7mtGp40WsX6FW5W33WajkDh/peXqYTp7ds6+NlosSLpo1mOMOBj3Xd8csbzQ==
dependencies:
"@babel/parser" "^7.6.4"
"@babel/traverse" "^7.6.3"
builtin-modules "^3.0.0"
deps-regex "^0.1.4"
js-yaml "^3.4.2"
lodash "^4.17.15"
minimatch "^3.0.2"
node-sass-tilde-importer "^1.0.2"
please-upgrade-node "^3.2.0"
require-package-name "^2.0.1"
resolve "^1.12.0"
vue-template-compiler "^2.6.10"
walkdir "^0.4.1"
yargs "^14.2.0"

depd@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
Expand Down Expand Up @@ -4705,6 +4735,11 @@ dependency-cruiser@^5.2.2:
tsconfig-paths-webpack-plugin "3.2.0"
wrap-ansi "6.1.0"

deps-regex@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/deps-regex/-/deps-regex-0.1.4.tgz#518667b7691460a5e7e0a341be76eb7ce8090184"
integrity sha1-UYZnt2kUYKXn4KNBvnbrfOgJAYQ=

des.js@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.0.tgz#c074d2e2aa6a8a9a07dbd61f9a15c2cd83ec8ecc"
Expand Down Expand Up @@ -5986,6 +6021,11 @@ find-cache-dir@^3.0.0:
make-dir "^3.0.0"
pkg-dir "^4.1.0"

find-parent-dir@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54"
integrity sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=

[email protected], find-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
Expand Down Expand Up @@ -6749,7 +6789,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
integrity sha1-k0EP0hsAlzUVH4howvJx80J+I/0=

[email protected]:
[email protected], he@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
Expand Down Expand Up @@ -8212,7 +8252,7 @@ js-tokens@^3.0.2:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=

js-yaml@^3.13.0, js-yaml@^3.13.1:
js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.4.2:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
Expand Down Expand Up @@ -9506,6 +9546,13 @@ node-releases@^1.1.38:
dependencies:
semver "^6.3.0"

node-sass-tilde-importer@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/node-sass-tilde-importer/-/node-sass-tilde-importer-1.0.2.tgz#1a15105c153f648323b4347693fdb0f331bad1ce"
integrity sha512-Swcmr38Y7uB78itQeBm3mThjxBy9/Ah/ykPIaURY/L6Nec9AyRoL/jJ7ECfMR+oZeCTVQNxVMu/aHU+TLRVbdg==
dependencies:
find-parent-dir "^0.3.0"

nodemon@^1.19.4:
version "1.19.4"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-1.19.4.tgz#56db5c607408e0fdf8920d2b444819af1aae0971"
Expand Down Expand Up @@ -11526,6 +11573,11 @@ require-main-filename@^2.0.0:
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==

require-package-name@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/require-package-name/-/require-package-name-2.0.1.tgz#c11e97276b65b8e2923f75dabf5fb2ef0c3841b9"
integrity sha1-wR6XJ2tluOKSP3Xav1+y7ww4Qbk=

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
Expand Down Expand Up @@ -13627,6 +13679,14 @@ void-elements@^2.0.1:
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec"
integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=

vue-template-compiler@^2.6.10:
version "2.6.10"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.6.10.tgz#323b4f3495f04faa3503337a82f5d6507799c9cc"
integrity sha512-jVZkw4/I/HT5ZMvRnhv78okGusqe0+qH2A0Em0Cp8aq78+NK9TII263CDVz2QXZsIT+yyV/gZc/j/vlwa+Epyg==
dependencies:
de-indent "^1.0.2"
he "^1.1.0"

w3c-hr-time@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045"
Expand All @@ -13639,6 +13699,11 @@ wait-for-expect@^1.3.0:
resolved "https://registry.yarnpkg.com/wait-for-expect/-/wait-for-expect-1.3.0.tgz#65241ce355425f907f5d127bdb5e72c412ff830c"
integrity sha512-8fJU7jiA96HfGPt+P/UilelSAZfhMBJ52YhKzlmZQvKEZU2EcD1GQ0yqGB6liLdHjYtYAoGVigYwdxr5rktvzA==

walkdir@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/walkdir/-/walkdir-0.4.1.tgz#dc119f83f4421df52e3061e514228a2db20afa39"
integrity sha512-3eBwRyEln6E1MSzcxcVpQIhRG8Q1jLvEqRmCZqS3dsfXEDR/AhOF4d+jHg1qvDCpYaVRZjENPQyrVxAkQqxPgQ==

walker@^1.0.7, walker@~1.0.5:
version "1.0.7"
resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"
Expand Down Expand Up @@ -14085,6 +14150,14 @@ yargs-parser@^13.1.0, yargs-parser@^13.1.1:
camelcase "^5.0.0"
decamelize "^1.2.0"

yargs-parser@^15.0.0:
version "15.0.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-15.0.0.tgz#cdd7a97490ec836195f59f3f4dbe5ea9e8f75f08"
integrity sha512-xLTUnCMc4JhxrPEPUYD5IBR1mWCK/aT6+RJ/K29JY2y1vD+FhtgKK0AXRWvI262q3QSffAQuTouFIKUuHX89wQ==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"

[email protected], yargs@^12.0.5:
version "12.0.5"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
Expand Down Expand Up @@ -14136,6 +14209,23 @@ yargs@^13.3.0:
y18n "^4.0.0"
yargs-parser "^13.1.1"

yargs@^14.2.0:
version "14.2.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.0.tgz#f116a9242c4ed8668790b40759b4906c276e76c3"
integrity sha512-/is78VKbKs70bVZH7w4YaZea6xcJWOAwkhbR0CFuZBmYtfTYF0xjGJF43AYd8g2Uii1yJwmS5GR2vBmrc32sbg==
dependencies:
cliui "^5.0.0"
decamelize "^1.2.0"
find-up "^3.0.0"
get-caller-file "^2.0.1"
require-directory "^2.1.1"
require-main-filename "^2.0.0"
set-blocking "^2.0.0"
string-width "^3.0.0"
which-module "^2.0.0"
y18n "^4.0.0"
yargs-parser "^15.0.0"

yarn-or-npm@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/yarn-or-npm/-/yarn-or-npm-2.0.4.tgz#46e38aafce74c350e6c0cca72712fca7410fad98"
Expand Down

0 comments on commit 21e6dfe

Please sign in to comment.