Skip to content

Commit

Permalink
remove npm scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger committed Mar 8, 2024
1 parent c301d1f commit 9daf3ee
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
path: ~/.npm
key: node-modules-${{ hashFiles('app/package-lock.json') }}

- name: Install Node.js dependencies
run: |
cd app
npm ci
# - name: Install Node.js dependencies
# run: |
# cd app
# npm ci

- name: Setup Env Vars not in github secrets
- name: Setup Dummy Env Vars
run: |
cd app
cp .env.server.example .env.server
Expand Down
43 changes: 43 additions & 0 deletions app/ci-start-app-with-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const cp = require('child_process');
const readline = require('linebyline');

function spawn(name, cmd, args, done) {
const spawnOptions = {
detached: true,
};
const proc = cp.spawn(cmd, args, spawnOptions);

proc.stdin.destroy();

readline(proc.stdout).on('line', (data) => {
console.log(`\x1b[0m\x1b[33m[${name}][out]\x1b[0m ${data}`);
});
readline(proc.stderr).on('line', (data) => {
console.log(`\x1b[0m\x1b[33m[${name}][err]\x1b[0m ${data}`);
});
proc.on('exit', done);
}

const cb = (code) => {
if (code !== 0) {
process.exit(code);
}
};

spawn(
'db-cleanup',
'sh',
[
'-c',
'(docker container rm $(docker container ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true) && docker volume rm$(docker volume ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true',
],
cb
);

spawn('db', 'wasp', ['start', 'db'], cb);

spawn('wait-for-db', 'npx', ['wait-port', '5432'], cb);

spawn('db-migrate', 'wasp', ['db', 'migrate-dev'], cb);

spawn('app', 'wasp', ['start'], cb);
7 changes: 0 additions & 7 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"name": "opensaas",
"scripts": {
"example-app:start": "node ci-start-app.js",
"example-app:start-db": "npm run example-app:cleanup-db && wasp start db",
"example-app:start-app": "npm run example-app:wait-for-db && wasp db migrate-dev && wasp start",
"example-app:wait-for-db": "npx wait-port 5432",
"example-app:cleanup-db": "(docker container rm $(docker container ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true) && docker volume rm $(docker volume ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true",
"example-app:playwright": "playwright test",
"example-app:playwright:ui": "playwright test --ui"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.523.0",
Expand Down
2 changes: 1 addition & 1 deletion app/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default defineConfig({
// only run the web server on CI
webServer: process.env.CI
? {
command: 'npm run example-app:start',
command: 'node ci-start-app-with-scripts.js',
// Wait for the backend to start
url: 'http://localhost:3001',
reuseExistingServer: !process.env.CI,
Expand Down

0 comments on commit 9daf3ee

Please sign in to comment.