Skip to content

Commit

Permalink
Prettier (#24)
Browse files Browse the repository at this point in the history
* Align prettier config with synthetix

* Apply prettier

* lockfile update

* Check svg are pretty too

* Add missing package name

* Ensure we can package application
  • Loading branch information
noisekit authored Aug 25, 2023
1 parent 7b9a3cb commit d7f1bac
Show file tree
Hide file tree
Showing 27 changed files with 597 additions and 523 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ jobs:
checks:
docker:
- image: cimg/node:<< pipeline.parameters.node-version >>
working_directory: ~/app
steps:
- checkout
- npm-install
- run: npm run lint:check
- run: npm run pretty:check
- run: npm run config:check
- run: npm run svg:check
- run: npm run package

ipfs-deploy:
docker:
Expand Down
9 changes: 2 additions & 7 deletions .erb/configs/webpack.config.renderer.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ const skipDLLs =
/**
* Warn if the DLL is not built
*/
if (
!skipDLLs &&
!(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest))
) {
if (!skipDLLs && !(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest))) {
execSync('npm run postinstall');
}

Expand Down Expand Up @@ -178,9 +175,7 @@ const configuration: webpack.Configuration = {
console.log('Starting Main Process...');
let args = ['run', 'start:main'];
if (process.env.MAIN_ARGS) {
args = args.concat(
['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat()
);
args = args.concat(['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat());
}
spawn('npm', args, {
shell: true,
Expand Down
4 changes: 1 addition & 3 deletions .erb/scripts/check-build-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const mainPath = path.join(webpackPaths.distMainPath, 'main.js');
const rendererPath = path.join(webpackPaths.distRendererPath, 'renderer.js');

if (!fs.existsSync(mainPath)) {
throw new Error(
'The main process is not built yet. Build it by running "npm run build:main"'
);
throw new Error('The main process is not built yet. Build it by running "npm run build:main"');
}

if (!fs.existsSync(rendererPath)) {
Expand Down
6 changes: 1 addition & 5 deletions .erb/scripts/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { sync as rimrafSync } from 'rimraf';
import fs from 'fs';
import webpackPaths from '../configs/webpack.paths';

const foldersToRemove = [
webpackPaths.distPath,
webpackPaths.buildPath,
webpackPaths.dllPath,
];
const foldersToRemove = [webpackPaths.distPath, webpackPaths.buildPath, webpackPaths.dllPath];

foldersToRemove.forEach((folder) => {
if (fs.existsSync(folder)) rimrafSync(folder);
Expand Down
9 changes: 2 additions & 7 deletions .erb/scripts/electron-rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import fs from 'fs';
import { dependencies } from '../../release/app/package.json';
import webpackPaths from '../configs/webpack.paths';

if (
Object.keys(dependencies || {}).length > 0 &&
fs.existsSync(webpackPaths.appNodeModulesPath)
) {
if (Object.keys(dependencies || {}).length > 0 && fs.existsSync(webpackPaths.appNodeModulesPath)) {
const electronRebuildCmd =
'../../node_modules/.bin/electron-rebuild --force --types prod,dev,optional --module-dir .';
const cmd =
process.platform === 'win32'
? electronRebuildCmd.replace(/\//g, '\\')
: electronRebuildCmd;
process.platform === 'win32' ? electronRebuildCmd.replace(/\//g, '\\') : electronRebuildCmd;
execSync(cmd, {
cwd: webpackPaths.appPath,
stdio: 'inherit',
Expand Down
4 changes: 1 addition & 3 deletions .erb/scripts/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ exports.default = async function notarizeMacos(context) {
}

if (!('APPLE_ID' in process.env && 'APPLE_ID_PASS' in process.env)) {
console.warn(
'Skipping notarizing step. APPLE_ID and APPLE_ID_PASS env variables must be set'
);
console.warn('Skipping notarizing step. APPLE_ID and APPLE_ID_PASS env variables must be set');
return;
}

Expand Down
5 changes: 1 addition & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ module.exports = {
'import/no-unresolved': 'off',
'import/no-import-module-exports': 'off',
'no-console': ['error', { allow: ['error'] }],
'no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
// Prettier
'comma-dangle': 'off',
indent: 'off',
Expand Down
21 changes: 21 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"printWidth": 100,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"overrides": [
{
"files": [".prettierrc", ".eslintrc"],
"options": {
"parser": "json"
}
},
{
"files": "*.svg",
"options": {
"parser": "html",
"singleQuote": false
}
}
]
}
7 changes: 5 additions & 2 deletions assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 4 additions & 13 deletions assets/iconsgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ async function icns(inputFile, outputDir) {
const iconsetDir = `${os.tmpdir()}/icon.iconset`;
await fs.promises.mkdir(iconsetDir, { recursive: true });
for (const size of [16, 32, 128, 256, 512, 1024]) {
await createResizedImage(
inputFile,
path.join(iconsetDir, `icon_${size}x${size}.png`),
size
);
await createResizedImage(inputFile, path.join(iconsetDir, `icon_${size}x${size}.png`), size);
await createResizedImage(
inputFile,
path.join(iconsetDir, `icon_${size}x${size}@2x.png`),
Expand All @@ -31,9 +27,8 @@ async function icns(inputFile, outputDir) {
const icnsFile = path.join(outputDir, 'icon.icns');
await new Promise(
(resolve, reject) =>
cp.exec(
`iconutil --convert icns --output ${icnsFile} ${iconsetDir}`,
(err) => (err ? reject(err) : resolve())
cp.exec(`iconutil --convert icns --output ${icnsFile} ${iconsetDir}`, (err) =>
err ? reject(err) : resolve()
),
{ stdio: 'inherit' }
);
Expand All @@ -55,11 +50,7 @@ async function main(inputFile, outputDir) {
await createResizedImage(inputFile, path.join(outputDir, 'icon.png'), 256);

for (const size of [16, 24, 32, 48, 64, 96, 128, 256, 512, 1024]) {
await createResizedImage(
inputFile,
path.join(outputDir, 'icons', `${size}x${size}.png`),
size
);
await createResizedImage(inputFile, path.join(outputDir, 'icons', `${size}x${size}.png`), size);
await createResizedImage(
inputFile,
path.join(outputDir, 'icons', `${size}x${size}@2x.png`),
Expand Down
Loading

0 comments on commit d7f1bac

Please sign in to comment.