scripts: convert to ESM and deduplicate (#290)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
This makes it a bit easier to add any new files that may need to be cleaned up in the future. Also allows us to use top-level await for the `yarn dev` task. Co-authored-by: Francis Dinh <normandy@biribiri.dev> Reviewed-on: #290
This commit is contained in:
parent
6c7f1774e3
commit
8f782f8ce5
8 changed files with 93 additions and 82 deletions
|
@ -18,7 +18,7 @@
|
|||
"migrateandstart": "yarn migrate && yarn start",
|
||||
"gulp": "gulp build",
|
||||
"watch": "yarn dev",
|
||||
"dev": "node ./scripts/dev.js",
|
||||
"dev": "node ./scripts/dev.mjs",
|
||||
"lint": "yarn workspaces foreach run lint",
|
||||
"cy:open": "cypress open --browser --e2e --config-file=cypress.config.ts",
|
||||
"cy:run": "cypress run",
|
||||
|
@ -26,8 +26,8 @@
|
|||
"mocha": "yarn workspace backend run mocha",
|
||||
"test": "yarn mocha",
|
||||
"format": "gulp format",
|
||||
"clean": "node ./scripts/clean.js",
|
||||
"clean-all": "node ./scripts/clean-all.js",
|
||||
"clean": "node ./scripts/clean.mjs",
|
||||
"clean-all": "node ./scripts/clean-all.mjs",
|
||||
"cleanall": "yarn clean-all"
|
||||
},
|
||||
"resolutions": {
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
const fs = require('fs');
|
||||
|
||||
fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../packages/backend/tsconfig.tsbuildinfo', { force: true });
|
||||
fs.rmSync(__dirname + '/../packages/backend/node_modules', { recursive: true, force: true });
|
||||
|
||||
fs.rmSync(__dirname + '/../packages/client/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../packages/client/node_modules', { recursive: true, force: true });
|
||||
|
||||
fs.rmSync(__dirname + '/../packages/foundkey-js/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../packages/foundkey-js/node_modules', { recursive: true, force: true });
|
||||
|
||||
fs.rmSync(__dirname + '/../packages/sw/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../packages/sw/node_modules', { recursive: true, force: true });
|
||||
|
||||
fs.rmSync(__dirname + '/../built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../node_modules', { recursive: true, force: true });
|
14
scripts/clean-all.mjs
Normal file
14
scripts/clean-all.mjs
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { files, clean } from './clean.mjs';
|
||||
|
||||
const allFiles = [
|
||||
...files,
|
||||
'/../packages/backend/node_modules',
|
||||
'/../packages/client/node_modules',
|
||||
'/../packages/foundkey-js/node_modules',
|
||||
'/../packages/sw/node_modules',
|
||||
'/../node_modules',
|
||||
];
|
||||
|
||||
for (const file of allFiles) {
|
||||
clean(file);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
const fs = require('fs');
|
||||
|
||||
fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../packages/backend/tsconfig.tsbuildinfo', { force: true });
|
||||
fs.rmSync(__dirname + '/../packages/client/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../packages/foundkey-js/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../packages/sw/built', { recursive: true, force: true });
|
||||
fs.rmSync(__dirname + '/../built', { recursive: true, force: true });
|
19
scripts/clean.mjs
Normal file
19
scripts/clean.mjs
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { rmSync } from 'fs';
|
||||
import { __dirname } from './common.mjs';
|
||||
|
||||
export const files = [
|
||||
'/../packages/backend/built',
|
||||
'/../packages/backend/tsconfig.tsbuildinfo',
|
||||
'/../packages/client/built',
|
||||
'/../packages/foundkey-js/built',
|
||||
'/../packages/sw/built',
|
||||
'/../built',
|
||||
];
|
||||
|
||||
export function clean(filename) {
|
||||
rmSync(__dirname + filename, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
clean(file);
|
||||
}
|
5
scripts/common.mjs
Normal file
5
scripts/common.mjs
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname } from 'node:path';
|
||||
|
||||
export const __filename = fileURLToPath(import.meta.url);
|
||||
export const __dirname = dirname(__filename);
|
|
@ -1,54 +0,0 @@
|
|||
const execa = require('execa');
|
||||
|
||||
(async () => {
|
||||
await execa('npm', ['run', 'clean'], {
|
||||
cwd: __dirname + '/../',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
await execa('npm', ['run', 'build'], {
|
||||
cwd: __dirname + '/../packages/foundkey-js',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npx', ['gulp', 'watch'], {
|
||||
cwd: __dirname + '/../',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npm', ['run', 'watch'], {
|
||||
cwd: __dirname + '/../packages/backend',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npm', ['run', 'watch'], {
|
||||
cwd: __dirname + '/../packages/client',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npm', ['run', 'watch'], {
|
||||
cwd: __dirname + '/../packages/sw',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
const start = async () => {
|
||||
try {
|
||||
await execa('npm', ['run', 'start'], {
|
||||
cwd: __dirname + '/../',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
} catch (e) {
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
start();
|
||||
}
|
||||
};
|
||||
|
||||
start();
|
||||
})();
|
52
scripts/dev.mjs
Normal file
52
scripts/dev.mjs
Normal file
|
@ -0,0 +1,52 @@
|
|||
import execa from 'execa';
|
||||
import { __dirname } from './common.mjs';
|
||||
|
||||
await execa('npm', ['run', 'clean'], {
|
||||
cwd: __dirname + '/../',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
await execa('npm', ['run', 'build'], {
|
||||
cwd: __dirname + '/../packages/foundkey-js',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npx', ['gulp', 'watch'], {
|
||||
cwd: __dirname + '/../',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npm', ['run', 'watch'], {
|
||||
cwd: __dirname + '/../packages/backend',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npm', ['run', 'watch'], {
|
||||
cwd: __dirname + '/../packages/client',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
execa('npm', ['run', 'watch'], {
|
||||
cwd: __dirname + '/../packages/sw',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
|
||||
const start = async () => {
|
||||
try {
|
||||
await execa('npm', ['run', 'start'], {
|
||||
cwd: __dirname + '/../',
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
});
|
||||
} catch (e) {
|
||||
setTimeout(start, 3000);
|
||||
}
|
||||
};
|
||||
|
||||
start();
|
Loading…
Reference in a new issue