Skip to content

Commit

Permalink
fix: build and tests paths
Browse files Browse the repository at this point in the history
  • Loading branch information
arthaud-proust committed Sep 17, 2023
1 parent e29891c commit b1182fa
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 18 deletions.
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
},
};
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import Life from "./components/Life.vue";
import "./styles.css";
import Life from "@/components/Life.vue";
import "@/styles.css";
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Cell.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ALIVE, CellState } from "../types/life";
import { ALIVE, CellState } from "@/types/life";
defineProps<{
state: CellState;
Expand Down
7 changes: 3 additions & 4 deletions src/components/Life.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import MatrixGrid from "@/components/MatrixGrid.vue";
import { startGame } from "@/services/game";
import { ALIVE as A, DEAD as D, Matrix } from "@/types/life";
import { ref } from "vue";
import { startGame } from "../services/game";
import { ALIVE as A, DEAD as D, Matrix } from "../types/life";
import MatrixGrid from "./MatrixGrid.vue";
const planner: Matrix = [
[D, D, D, D, D],
Expand All @@ -13,7 +13,6 @@ const planner: Matrix = [
];
// prettier-ignore
const plannerCannon: Matrix = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand Down
4 changes: 2 additions & 2 deletions src/components/MatrixGrid.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import Cell from "@/components/Cell.vue";
import { Matrix } from "@/types/life";
import { useElementSize } from "@vueuse/core";
import { ref } from "vue";
import { Matrix } from "../types/life";
import Cell from "./Cell.vue";
defineProps<{
matrix: Matrix;
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp } from "vue";
import App from "./App.vue";
import App from "@/App.vue";

createApp(App).mount("#app");
2 changes: 1 addition & 1 deletion src/rules/life.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ALIVE, DEAD, Matrix } from "../types/life.ts";
import { ALIVE, DEAD, Matrix } from "@/types/life.ts";

import {
getCellState,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/life.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Here should not appear code related to display, animations, startup state, etc.
* So, only game rules in this file!
*/
import { ALIVE, CellCoords, CellState, DEAD, Matrix } from "../types/life";
import { ALIVE, CellCoords, CellState, DEAD, Matrix } from "@/types/life";

const ALIVE_NEIGHBORS_CELLS_COUNT_TO_BORN = 3;
const ALIVE_NEIGHBORS_CELLS_COUNT_TO_LIVE = [2, 3];
Expand Down
8 changes: 6 additions & 2 deletions src/services/game.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { ALIVE, DEAD, Matrix } from "../types/life";
import { ALIVE, DEAD, Matrix } from "@/types/life";

import { getExtendedMatrix, getNextMatrix, matrixToString } from "./game.ts";
import {
getExtendedMatrix,
getNextMatrix,
matrixToString,
} from "@/services/game.ts";

describe("matToString", () => {
test("should return formated cells", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/services/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Separation of Concerns Principle :
* Here should only appear code related to game start, run and display.
*/
import { ALIVE, DEAD, Matrix } from "../types/life";
import { ALIVE, DEAD, Matrix } from "@/types/life";

import { getNextStepCellState } from "../rules/life.ts";
import { getNextStepCellState } from "@/rules/life.ts";

const FRAME_INTERVAL = 100;

Expand Down
5 changes: 5 additions & 0 deletions src/vue-shim.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module "*.vue" {
import { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,

"paths": {
"@/*": [
"./src/*" // set path `@/*` as alias of `src/*`
]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
8 changes: 7 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { defineConfig } from "vite";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});

0 comments on commit b1182fa

Please sign in to comment.