diff --git a/.gitignore b/.gitignore index fdcffad..f522dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ package-lock.json .temp node_modules/ dist/yarn-error.log +.task/ diff --git a/.versionrc.json b/.versionrc.json index b4a1cf4..b49c3dc 100644 --- a/.versionrc.json +++ b/.versionrc.json @@ -1,4 +1,7 @@ { + "scripts": { + "postchangelog": "gotask changelog" + }, "types": [ { "type": "feat", "section": "Features" }, { "type": "fix", "section": "Bug Fixes" }, diff --git a/CHANGELOG.md b/CHANGELOG.md index 0452040..26f62a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,20 +2,29 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## [2.2.0](///compare/v2.1.0...v2.2.0) (2022-04-11) +## 2.3.0 (2022-04-17) ### Features -* allow to edit the print layout 381d497 +* add 'reset ship' button +* add changelog to app +* add version to About component -## [2.1.0](///compare/v2.0.0...v2.1.0) (2022-04-07) +## 2.2.0 (2022-04-11) ### Features -* add localStorage memory bf7206a -* can move main system comps in the print output b425f4a +* allow to edit the print layout + +## 2.1.0 (2022-04-07) -* add standard-version 2fd047f +### Features + +* add localStorage memory +* can move main system comps in the print output + + +* add standard-version diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..cddf613 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,22 @@ +# https://taskfile.dev + +version: "3" + +vars: + GREETING: Hello, World! + +tasks: + release: + cmds: + - standard-version -a + changelog: + sources: [CHANGELOG.md] + generates: [src/lib/components/Changelog.svelte] + cmds: + - pnpx showdown makehtml -i CHANGELOG.md -o src/lib/components/Changelog.svelte + - git add src/lib/components/Changelog.svelte + + default: + cmds: + - echo "{{.GREETING}}" + silent: true diff --git a/package.json b/package.json index 6db6c2f..f298326 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aotds-docks", - "version": "2.2.0", + "version": "2.3.0", "type": "module", "private": true, "scripts": { @@ -18,14 +18,19 @@ "@sveltejs/adapter-static": "^1.0.0-next.29", "@sveltejs/kit": "^1.0.0-next.304", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.38", + "@testing-library/svelte": "^3.1.1", + "@testing-library/user-event": "^13.5.0", "eslint": "^8.10.0", "eslint-config-prettier": "^8.4.0", "eslint-plugin-svelte3": "^3.4.1", "prettier": "~2.5.1", "prettier-plugin-svelte": "^2.6.0", + "showdown": "^2.0.3", "standard-version": "^9.3.2", "storybook-builder-vite": "0.1.21", - "svelte": "^3.46.4" + "svelte": "^3.46.4", + "vitest": "^0.9.3", + "vitest-svelte-kit": "^0.0.6" }, "dependencies": { "@storybook/addon-essentials": "^6.4.19", diff --git a/src/lib/components/About.svelte b/src/lib/components/About.svelte index 74a4977..364478c 100644 --- a/src/lib/components/About.svelte +++ b/src/lib/components/About.svelte @@ -1,71 +1,92 @@ - -

Welcome to the docks

+{#if showChangelog} + +

Changelog for the Docks

+
+ +
+
+{:else} + +
+

Welcome to the docks

-

- This app is a ship builder for the game - Full Thrust - . -

+
+
version {import.meta.env.PACKAGE_VERSION}
+ (showChangelog = true)}>changelog +
+
-

- The contruction rules are following the - - Cross Dimensions rules - - as closely as possible. -

+

+ This app is a ship builder for the game + Full Thrust + . +

-

- The app is mostly developed for Firefox. I also check as much as I can that - I don't mess things too badly on Chrome. For the other browsers... caveat - emptor. -

+

+ The contruction rules are following the + + Cross Dimensions rules + + as closely as possible. +

-

- Written by - Yanick Champoux - . Code available on - Github -

-
- +

+ The app is mostly developed for Firefox. I also check as much as I can + that I don't mess things too badly on Chrome. For the other browsers... + caveat emptor. +

+ +

+ Written by + Yanick Champoux + . Code available on + Github. +

+ +{/if} diff --git a/src/lib/components/About.test.js b/src/lib/components/About.test.js new file mode 100644 index 0000000..e25dfe2 --- /dev/null +++ b/src/lib/components/About.test.js @@ -0,0 +1,11 @@ +import { test, expect } from "vitest"; +import { render } from "@testing-library/svelte"; + +import About from "./About.svelte"; + +test("version is present", () => { + import.meta.env.PACKAGE_VERSION = '1.2.3'; + const { queryByText } = render(About); + + expect(queryByText(/version 1.2.3/)).toBeTruthy(); +}); diff --git a/src/lib/components/App.svelte b/src/lib/components/App.svelte index 2dd8b48..162c76b 100644 --- a/src/lib/components/App.svelte +++ b/src/lib/components/App.svelte @@ -1,54 +1,51 @@ - +
+ +
(activeTab = detail)} /> - -
activeTab = detail}/> - -
+
-
-
+
+
-
- -{#if activeTab === 'print'} - -{/if} +
+ {#if activeTab === "print"} + + {/if}
diff --git a/src/lib/components/Changelog.stories.svelte b/src/lib/components/Changelog.stories.svelte new file mode 100644 index 0000000..183f8b9 --- /dev/null +++ b/src/lib/components/Changelog.stories.svelte @@ -0,0 +1,15 @@ + + + + + + + diff --git a/src/lib/components/Changelog.svelte b/src/lib/components/Changelog.svelte new file mode 100644 index 0000000..986e393 --- /dev/null +++ b/src/lib/components/Changelog.svelte @@ -0,0 +1,21 @@ +

Changelog

+

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

+

2.3.0 (2022-04-17)

+

Features

+
    +
  • add 'reset ship' button
  • +
  • add changelog to app
  • +
  • add version to About component
  • +
+

2.2.0 (2022-04-11)

+

Features

+
    +
  • allow to edit the print layout
  • +
+

2.1.0 (2022-04-07)

+

Features

+
    +
  • add localStorage memory

  • +
  • can move main system comps in the print output

  • +
  • add standard-version

  • +
\ No newline at end of file diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index 26ecf9b..c0c9657 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -1,76 +1,94 @@
-

The Docks

-

- a Full Thrust ship builder -

- (showAbout = true)}>about the app +

The Docks

+

+ a Full Thrust ship + builder +

+ (showAbout = true)}>about the app
-
- - editor - json view - print view - + - + diff --git a/src/lib/components/Header.test.js b/src/lib/components/Header.test.js new file mode 100644 index 0000000..1270067 --- /dev/null +++ b/src/lib/components/Header.test.js @@ -0,0 +1,10 @@ +import { test, expect } from "vitest"; +import { render } from "@testing-library/svelte"; + +import App from "./Header.svelte"; + +test("reset ship link is present", () => { + const { queryByText } = render(App); + + expect(queryByText("reset ship")).toBeTruthy(); +}); diff --git a/src/lib/shipDux/index.js b/src/lib/shipDux/index.js index bae5914..16f884c 100644 --- a/src/lib/shipDux/index.js +++ b/src/lib/shipDux/index.js @@ -25,6 +25,7 @@ const dux = new Updux({ setShipReqs: null, setUITransform: null, resetLayout: null, + resetShip: null, }, }); @@ -37,6 +38,8 @@ function resetUITransform(thing) { ); } +dux.setMutation("resetShip", () => () => dux.initial); + dux.setMutation("resetLayout", () => resetUITransform); dux.setMutation("setShipMass", (mass) => u({ reqs: { mass } })); diff --git a/src/lib/shipDux/propulsion/drive.js b/src/lib/shipDux/propulsion/drive.js index f165e7d..c6fbb48 100644 --- a/src/lib/shipDux/propulsion/drive.js +++ b/src/lib/shipDux/propulsion/drive.js @@ -7,7 +7,7 @@ import reqs from "../reqs.js"; const dux = new Updux({ subduxes: { reqs }, initial: { - rating: 1, + rating: 0, advanced: false, }, actions: { @@ -20,7 +20,7 @@ dux.setMutation("setDrive", (changes) => u(changes)); dux.setMutation("setDriveReqs", (reqs) => u({ reqs })); // needs to be at the top level -export const calculateDriveReqs = store => +export const calculateDriveReqs = (store) => createSelector( [ (ship) => ship.reqs.mass, @@ -29,7 +29,7 @@ export const calculateDriveReqs = store => ], (ship_mass, rating, advanced) => store.dispatch.setDriveReqs(calcDriveReqs(ship_mass, rating, advanced)) - ); + ); export function calcDriveReqs(shipMass, rating, advanced = false) { const mass = Math.ceil(rating * 0.05 * shipMass); diff --git a/svelte.config.js b/svelte.config.js index 8940ae6..da83039 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -8,6 +8,11 @@ export default { adapter: adapter({ fallback: "index.html" }), paths: { base: dev ? "" : "/aotds-docks" }, vite: { + define: { + "import.meta.env.PACKAGE_VERSION": JSON.stringify( + process.env.npm_package_version + ), + }, build: { rollupOptions: { plugins: [analyze()], diff --git a/vitest.config.js b/vitest.config.js new file mode 100644 index 0000000..78214f1 --- /dev/null +++ b/vitest.config.js @@ -0,0 +1,9 @@ +import { extractFromSvelteConfig } from "vitest-svelte-kit"; + +export default extractFromSvelteConfig().then((config) => ({ + ...config, + test: { + globals: true, + environment: "jsdom", + }, + }));