Skip to content

Commit a5516a4

Browse files
committed
Split frontend into 2 modules.
1 parent 727cec6 commit a5516a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+460
-112
lines changed

Diff for: .eslintrc.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ module.exports = {
3333
{
3434
target: "apps/backend/",
3535
from: "apps/frontend/",
36-
message: "Backend should not import from frontend. Use hotel-management-shared instead.",
36+
message: "Backend should not import from frontend. Move code to libs and import from there instead.",
3737
},
3838
{
3939
target: "apps/frontend/",
4040
from: "apps/backend/",
41-
message: "Frontend should not import from backend. Use hotel-management-shared instead.",
41+
message: "Frontend should not import from backend. Move code to libs and import from there instead.",
4242
},
4343
],
4444
},

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
!.yarn/plugins
55
.pnp.*
66

7+
# rollup
8+
.rollup.cache
9+
710
# Logs
811
logs
912
*.log
File renamed without changes.
File renamed without changes.

Diff for: apps/frontend/core/e2e/vue.spec.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: apps/frontend/core/package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "hotel-management-frontend-core",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "run -T vite",
8+
"build": "run -T run-p type-check build-only",
9+
"clean": "run -T rimraf ./dist",
10+
"preview": "run -T vite preview",
11+
"test:unit": "run -T vitest --environment jsdom --root src/",
12+
"test:e2e": "run -T playwright test",
13+
"build-only": "run -T vite build",
14+
"type-check": "run -T vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
15+
"lint": "run -T eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
16+
},
17+
"dependencies": {
18+
"hotel-management-frontend-rooms": "workspace:apps/frontend/rooms",
19+
"hotel-management-shared": "workspace:libs/shared"
20+
}
21+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: apps/frontend/core/src/assets/main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "../../../../../node_modules/@picocss/pico/css/pico.min.css";

Diff for: apps/frontend/src/components/HotelList.vue renamed to apps/frontend/core/src/components/HotelList.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup lang="ts">
22
// import type { Hotel } from "hotel-management-shared";
33
4-
import type { BackendHotel } from "../../../backend/dist/main.js";
4+
import type { Hotel } from "hotel-management-shared";
55
66
const props = defineProps<{
7-
hotels: BackendHotel[];
7+
hotels: Hotel[];
88
}>();
99
</script>
1010

Diff for: apps/frontend/core/src/main.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { createApp } from "vue";
2+
import { createRouter, createWebHistory } from "vue-router";
3+
import { createPinia } from "pinia";
4+
import Rooms from "hotel-management-frontend-rooms";
5+
6+
import App from "./App.vue";
7+
import { routes } from "./routes.js";
8+
9+
import "./assets/main.scss";
10+
11+
const libs = { "hotel-management-frontend-rooms": Rooms };
12+
13+
for (const [libName, lib] of Object.entries(libs)) {
14+
routes.push(...lib.routes);
15+
}
16+
17+
console.dir(routes);
18+
19+
const router = createRouter({
20+
history: createWebHistory(import.meta.env.BASE_URL),
21+
routes,
22+
});
23+
24+
const app = createApp(App);
25+
26+
app.use(createPinia());
27+
app.use(router);
28+
29+
app.mount("#app");
File renamed without changes.

Diff for: apps/frontend/core/src/routes.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import HomePage from "./pages/HomePage.vue";
2+
3+
export const routes = [
4+
{
5+
path: "/",
6+
name: "home",
7+
component: HomePage,
8+
},
9+
];
File renamed without changes.
File renamed without changes.

Diff for: apps/frontend/core/tsconfig.config.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "@vue/tsconfig/tsconfig.node.json",
3+
"include": [
4+
"vite.config.*",
5+
"vitest.config.*",
6+
"cypress.config.*",
7+
"playwright.config.*",
8+
"core/playwright.config.ts",
9+
"core/vite.config.ts"
10+
],
11+
"compilerOptions": {
12+
"composite": true,
13+
"types": ["node"]
14+
}
15+
}

Diff for: apps/frontend/core/tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../../../tsconfig.json",
3+
"references": [
4+
{ "path": "./tsconfig.config.json" },
5+
{ "path": "./tsconfig.app.json" },
6+
{ "path": "./tsconfig.vitest.json" },
7+
{ "path": "../../../libs/shared/tsconfig.json" },
8+
{ "path": "../rooms/tsconfig.json" }
9+
]
10+
}
File renamed without changes.
File renamed without changes.

Diff for: apps/frontend/package.json

-38
This file was deleted.

Diff for: apps/frontend/rooms/.eslintrc.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-env node */
2+
require("@rushstack/eslint-patch/modern-module-resolution");
3+
4+
module.exports = {
5+
extends: ["plugin:vue/vue3-essential", "@vue/eslint-config-typescript"],
6+
};

Diff for: apps/frontend/rooms/e2e/tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@vue/tsconfig/tsconfig.node.json",
3+
"include": ["./**/*"]
4+
}

Diff for: apps/frontend/rooms/e2e/vue.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
// See here how to get started:
4+
// https://playwright.dev/docs/intro
5+
test("visits the app root url", async ({ page }) => {
6+
await page.goto("/");
7+
await expect(page.locator("div.greetings > h1")).toHaveText("You did it!");
8+
});

Diff for: apps/frontend/rooms/env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

Diff for: apps/frontend/rooms/package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "hotel-management-frontend-rooms",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"main": "./dist/lib.js",
7+
"module": "./dist/lib.js",
8+
"types": "./dist/lib.d.ts",
9+
"exports": {
10+
".": {
11+
"require": "./dist/lib.js",
12+
"import": "./dist/lib.js",
13+
"types": "./dist/lib.d.ts"
14+
}
15+
},
16+
"scripts": {
17+
"dev": "run -T vite",
18+
"build": "run -T run-p type-check build-only",
19+
"clean": "run -T rimraf ./dist",
20+
"preview": "run -T vite preview",
21+
"test:unit": "run -T vitest --environment jsdom --root src/",
22+
"test:e2e": "run -T playwright test",
23+
"build-only": "run -T vite build",
24+
"type-check": "run -T vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
25+
"lint": "run -T eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
26+
},
27+
"dependencies": {
28+
"hotel-management-shared": "workspace:libs/shared"
29+
}
30+
}

Diff for: apps/frontend/rooms/playwright.config.ts

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import type { PlaywrightTestConfig } from "@playwright/test";
2+
import { devices } from "@playwright/test";
3+
4+
/**
5+
* Read environment variables from file.
6+
* https://github.com/motdotla/dotenv
7+
*/
8+
// require('dotenv').config();
9+
10+
/**
11+
* See https://playwright.dev/docs/test-configuration.
12+
*/
13+
const config: PlaywrightTestConfig = {
14+
testDir: "./e2e",
15+
/* Maximum time one test can run for. */
16+
timeout: 30 * 1000,
17+
expect: {
18+
/**
19+
* Maximum time expect() should wait for the condition to be met.
20+
* For example in `await expect(locator).toHaveText();`
21+
*/
22+
timeout: 5000,
23+
},
24+
/* Fail the build on CI if you accidentally left test.only in the source code. */
25+
forbidOnly: !!process.env.CI,
26+
/* Retry on CI only */
27+
retries: process.env.CI ? 2 : 0,
28+
/* Opt out of parallel tests on CI. */
29+
workers: process.env.CI ? 1 : undefined,
30+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
31+
reporter: "html",
32+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
33+
use: {
34+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
35+
actionTimeout: 0,
36+
/* Base URL to use in actions like `await page.goto('/')`. */
37+
baseURL: "http://localhost:5173",
38+
39+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
40+
trace: "on-first-retry",
41+
42+
/* Only on CI systems run the tests headless */
43+
headless: !!process.env.CI,
44+
},
45+
46+
/* Configure projects for major browsers */
47+
projects: [
48+
{
49+
name: "chromium",
50+
use: {
51+
...devices["Desktop Chrome"],
52+
},
53+
},
54+
{
55+
name: "firefox",
56+
use: {
57+
...devices["Desktop Firefox"],
58+
},
59+
},
60+
{
61+
name: "webkit",
62+
use: {
63+
...devices["Desktop Safari"],
64+
},
65+
},
66+
67+
/* Test against mobile viewports. */
68+
// {
69+
// name: 'Mobile Chrome',
70+
// use: {
71+
// ...devices['Pixel 5'],
72+
// },
73+
// },
74+
// {
75+
// name: 'Mobile Safari',
76+
// use: {
77+
// ...devices['iPhone 12'],
78+
// },
79+
// },
80+
81+
/* Test against branded browsers. */
82+
// {
83+
// name: 'Microsoft Edge',
84+
// use: {
85+
// channel: 'msedge',
86+
// },
87+
// },
88+
// {
89+
// name: 'Google Chrome',
90+
// use: {
91+
// channel: 'chrome',
92+
// },
93+
// },
94+
],
95+
96+
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
97+
// outputDir: 'test-results/',
98+
99+
/* Run your local dev server before starting the tests */
100+
webServer: {
101+
/**
102+
* Use the dev server by default for faster feedback loop.
103+
* Use the preview server on CI for more realistic testing.
104+
Playwright will re-use the local server if there is already a dev-server running.
105+
*/
106+
command: process.env.CI ? "vite preview --port 5173" : "vite dev",
107+
port: 5173,
108+
reuseExistingServer: !process.env.CI,
109+
},
110+
};
111+
112+
export default config;

Diff for: apps/frontend/rooms/public/favicon.ico

4.19 KB
Binary file not shown.

Diff for: apps/frontend/rooms/src/assets/logo.svg

+1

Diff for: apps/frontend/rooms/src/assets/main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "../../../../../node_modules/@picocss/pico/css/pico.min.css";

Diff for: apps/frontend/rooms/src/lib.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { routes } from "./routes";
2+
3+
export default {
4+
routes,
5+
};

Diff for: apps/frontend/rooms/src/pages/RoomsPage.vue

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script setup lang="ts"></script>
2+
3+
<template>
4+
<h1>Rooms</h1>
5+
</template>

Diff for: apps/frontend/rooms/src/routes.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import RoomsPage from "./pages/RoomsPage.vue";
2+
3+
export const routes = [
4+
{
5+
path: "/rooms",
6+
name: "rooms",
7+
component: RoomsPage,
8+
},
9+
];

Diff for: apps/frontend/rooms/tsconfig.app.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "@vue/tsconfig/tsconfig.web.json",
3+
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
4+
"exclude": ["src/**/__tests__/*"],
5+
"compilerOptions": {
6+
"composite": true,
7+
"baseUrl": ".",
8+
"paths": {
9+
"@/*": ["./src/*"]
10+
}
11+
}
12+
}

Diff for: apps/frontend/rooms/tsconfig.app.tsbuildinfo

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"4.8.4"}
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
2-
"extends": "../../tsconfig.json",
3-
"files": [],
2+
"extends": "../../../tsconfig.json",
43
"references": [
54
{ "path": "./tsconfig.config.json" },
65
{ "path": "./tsconfig.app.json" },
76
{ "path": "./tsconfig.vitest.json" },
8-
{ "path": "../../libs/shared/tsconfig.json" }
7+
{ "path": "../../../libs/shared/tsconfig.json" }
98
]
109
}

0 commit comments

Comments
 (0)