Skip to content

Commit

Permalink
feat: generate project
Browse files Browse the repository at this point in the history
Ref: #383
  • Loading branch information
Apoorva64 committed Jun 13, 2023
1 parent e9b1571 commit 165f0c8
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apps/front-end/back-office-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
"sourceRoot": "apps/front-end/back-office-e2e/src",
"projectType": "application",
"targets": {
"front-end-serve": {
"executor": "@angular-devkit/architect:allOf",
"options": {
"targets": [
{
"target": "front-end-back-office:serve"
},
{
"target": "front-end-front-office:serve"
}
]
}
},

"e2e": {
"executor": "@mands/nx-playwright:playwright-executor",
"options": {
Expand Down
22 changes: 22 additions & 0 deletions apps/front-end/cross-office-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"jest/no-done-callback": "off"
}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {
"jest/no-done-callback": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
21 changes: 21 additions & 0 deletions apps/front-end/cross-office-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { PlaywrightTestConfig } from '@playwright/test';

import { baseConfig } from '../../../playwright.config.base';

const config: PlaywrightTestConfig = {
...baseConfig,
globalSetup: require.resolve(
'apps/front-end/cross-office-e2e/src/support/global-setup.ts'
),
globalTeardown: require.resolve(
'apps/front-end/cross-office-e2e/src/support/global-teardown.ts'
),
use: {
...baseConfig.use,
ignoreHTTPSErrors: true,
video: 'on-first-retry',
screenshot: 'only-on-failure',
},
};

export default config;
38 changes: 38 additions & 0 deletions apps/front-end/cross-office-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "front-end-cross-office-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/front-end/cross-office-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@mands/nx-playwright:playwright-executor",
"options": {
"e2eFolder": "apps/front-end/cross-office-e2e",
"packageRunner": "pnpm"
},
"configurations": {
"production": {}
}
},
"ts-check": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "tsc --build --force --verbose apps/undefined-e2e/tsconfig.json"
}
]
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"apps/front-end/cross-office-e2e/**/*.{ts,tsx,js,jsx}"
]
}
}
},
"tags": []
}
7 changes: 7 additions & 0 deletions apps/front-end/cross-office-e2e/src/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test } from '@playwright/test';

test('should start page', async ({ page }) => {
await page.goto('/');

expect(true).toBeTruthy();
});
63 changes: 63 additions & 0 deletions apps/front-end/cross-office-e2e/src/support/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* eslint-disable */
import axios from 'axios';
import { subProcess, subProcessSync } from 'subspawn';
import { environment, protocol } from '@webonjour/shared/environments';

var __TEARDOWN_MESSAGE__: string;

module.exports = async function () {
// Start services that the app needs to run (e.g. database, docker-compose, etc.).
console.log('\nSetting up...\n');

let executor = 'docker-compose';

// Check if docker compose is installed
try {
subProcessSync('docker-compose --version', true);
} catch (e) {
executor = 'podman-compose';
try {
subProcessSync('podman-compose --version', true);
} catch (e) {
executor = 'docker compose';
try {
subProcessSync('docker compose --version', true);
} catch (e) {
console.log('Please install docker-compose or podman-compose');
process.exit(1);
}
}
}

subProcessSync(`${executor} -f docker-compose.yml up -d`, true);
// wait for the database to start
for (let i = 0; i < 200; i++) {
try {
// subProcessSync("npx prisma migrate dev deploy", true);
subProcessSync('npx prisma migrate reset --force', true);
subProcessSync('npx prisma generate', true);
break;
} catch (e) {
console.log('Waiting for database to start...');
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
subProcess('API', 'npx nx serve backend-api', true);

axios.defaults.baseURL = `${protocol(environment.api.secure)}://${
environment.api.domain
}`;
console.log('axios.defaults.baseURL', axios.defaults.baseURL);
// wait for the server to start
for (let i = 0; i < 200; i++) {
try {
await axios.get(`/health`);
break;
} catch (e) {
console.log('Waiting for server to start...');
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
// Hint: Use `globalThis` to pass variables to global teardown.
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';
};
33 changes: 33 additions & 0 deletions apps/front-end/cross-office-e2e/src/support/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable */

import { killSubProcesses, subProcessSync } from 'subspawn';

module.exports = async function () {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown.
// stop the server

let executor = 'docker-compose';

// Check if docker compose is installed
try {
subProcessSync('docker-compose --version', true);
} catch (e) {
executor = 'podman-compose';
try {
subProcessSync('podman-compose --version', true);
} catch (e) {
executor = 'docker compose';
try {
subProcessSync('docker compose --version', true);
} catch (e) {
console.log('Please install docker-compose or podman-compose');
process.exit(1);
}
}
}

killSubProcesses('API');
subProcessSync(`${executor} -f docker-compose.yml down`, true);
console.log(globalThis.__TEARDOWN_MESSAGE__);
};
10 changes: 10 additions & 0 deletions apps/front-end/cross-office-e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../../dist/out-tsc",
"allowJs": true,
"types": ["jest", "node"]
},
"include": ["**/*.ts", "**/*.js"]
}
10 changes: 10 additions & 0 deletions apps/front-end/cross-office-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.e2e.json"
}
]
}

0 comments on commit 165f0c8

Please sign in to comment.