Merge branch 'master' into 050-basic-active-effects

This commit is contained in:
Johannes Loher 2021-02-12 13:24:15 +01:00
commit 9941f21b69
28 changed files with 9566 additions and 8193 deletions

9
.gitignore vendored
View file

@ -17,3 +17,12 @@ dist
# Junit results # Junit results
results.xml results.xml
junit.xml
# yarn
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

View file

@ -1,50 +1,40 @@
image: node:lts image: node:lts
stages: stages:
- prepare
- test - test
- build - build
- release - release
cache: &global_cache before_script:
key: - yarn install --immutable
files:
- package-lock.json
policy: pull
paths:
- node_modules/
install-dependencies: cache: &global_cache
stage: prepare paths:
script: - .yarn/cache
- npm install
cache:
<<: *global_cache
policy: pull-push
lint: lint:
stage: test stage: test
script: script:
- npm run lint - yarn lint
cache: cache:
<<: *global_cache <<: *global_cache
test: test:
stage: test stage: test
script: script:
- npm run test:ci - yarn test:ci
cache: cache:
<<: *global_cache <<: *global_cache
artifacts: artifacts:
when: always when: always
reports: reports:
junit: junit:
- results.xml - junit.xml
build: build:
stage: build stage: build
script: script:
- npm run build - yarn build
- mv dist ds4 - mv dist ds4
cache: cache:
<<: *global_cache <<: *global_cache
@ -56,6 +46,7 @@ build:
.release-template: &release-template .release-template: &release-template
stage: release stage: release
before_script: before_script:
- yarn install
- apt update - apt update
- apt install --yes jq - apt install --yes jq
- REPOSITORY_URL=$(echo "${CI_REPOSITORY_URL}" | sed -e "s|gitlab-ci-token:.*@|${RELEASE_TOKEN}:${RELEASE_TOKEN_SECRET}@|g") - REPOSITORY_URL=$(echo "${CI_REPOSITORY_URL}" | sed -e "s|gitlab-ci-token:.*@|${RELEASE_TOKEN}:${RELEASE_TOKEN_SECRET}@|g")
@ -67,7 +58,7 @@ build:
cache: cache:
<<: *global_cache <<: *global_cache
script: | script: |
npm run updateManifest -- --update=${RELEASE_TYPE} yarn updateManifest -- --update=${RELEASE_TYPE}
RELEASE_VERSION=$(jq -r '.version' < package.json) RELEASE_VERSION=$(jq -r '.version' < package.json)
git add package.json package-lock.json src/system.json git add package.json package-lock.json src/system.json
git --no-pager diff git --no-pager diff

View file

@ -3,6 +3,7 @@
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"gruntfuggly.todo-tree", "gruntfuggly.todo-tree",
"eg2.vscode-npm-script" "eg2.vscode-npm-script",
"arcanis.vscode-zipfs"
] ]
} }

10
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,10 @@
{
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}

55
.yarn/releases/yarn-berry.cjs vendored Executable file

File diff suppressed because one or more lines are too long

20
.yarn/sdks/eslint/bin/eslint.js vendored Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/bin/eslint.js
require(absPnpApiPath).setup();
}
}
// Defer to the real eslint/bin/eslint.js your application uses
module.exports = absRequire(`eslint/bin/eslint.js`);

20
.yarn/sdks/eslint/lib/api.js vendored Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/lib/api.js
require(absPnpApiPath).setup();
}
}
// Defer to the real eslint/lib/api.js your application uses
module.exports = absRequire(`eslint/lib/api.js`);

6
.yarn/sdks/eslint/package.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"name": "eslint",
"version": "7.19.0-pnpify",
"main": "./lib/api.js",
"type": "commonjs"
}

5
.yarn/sdks/integrations.yml vendored Normal file
View file

@ -0,0 +1,5 @@
# This file is automatically generated by PnPify.
# Manual changes will be lost!
integrations:
- vscode

30
.yarn/sdks/prettier/index.js vendored Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);
const relPnpApiPath = "../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/index.js
require(absPnpApiPath).setup();
}
const pnpifyResolution = require.resolve(`@yarnpkg/pnpify`, {paths: [dirname(absPnpApiPath)]});
if (typeof global[`__yarnpkg_sdk_is_using_pnpify__`] === `undefined`) {
Object.defineProperty(global, `__yarnpkg_sdk_is_using_pnpify__`, {configurable: true, value: true});
process.env.NODE_OPTIONS += ` -r ${pnpifyResolution}`;
// Apply PnPify to the current process
absRequire(pnpifyResolution).patchFs();
}
}
// Defer to the real prettier/index.js your application uses
module.exports = absRequire(`prettier/index.js`);

6
.yarn/sdks/prettier/package.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"name": "prettier",
"version": "2.2.1-pnpify",
"main": "./index.js",
"type": "commonjs"
}

20
.yarn/sdks/typescript/bin/tsc vendored Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsc
require(absPnpApiPath).setup();
}
}
// Defer to the real typescript/bin/tsc your application uses
module.exports = absRequire(`typescript/bin/tsc`);

20
.yarn/sdks/typescript/bin/tsserver vendored Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsserver
require(absPnpApiPath).setup();
}
}
// Defer to the real typescript/bin/tsserver your application uses
module.exports = absRequire(`typescript/bin/tsserver`);

20
.yarn/sdks/typescript/lib/tsc.js vendored Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsc.js
require(absPnpApiPath).setup();
}
}
// Defer to the real typescript/lib/tsc.js your application uses
module.exports = absRequire(`typescript/lib/tsc.js`);

111
.yarn/sdks/typescript/lib/tsserver.js vendored Normal file
View file

@ -0,0 +1,111 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const moduleWrapper = tsserver => {
const {isAbsolute} = require(`path`);
const pnpApi = require(`pnpapi`);
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
return `${locator.name}@${locator.reference}`;
}));
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
// doesn't understand. This layer makes sure to remove the protocol
// before forwarding it to TS, and to add it back on all returned paths.
function toEditorPath(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || str.match(/\$\$virtual\//))) {
// We also take the opportunity to turn virtual paths into physical ones;
// this makes is much easier to work with workspaces that list peer
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
// file instances instead of the real ones.
//
// We only do this to modules owned by the the dependency tree roots.
// This avoids breaking the resolution when jumping inside a vendor
// with peer dep (otherwise jumping into react-dom would show resolution
// errors on react).
//
const resolved = pnpApi.resolveVirtual(str);
if (resolved) {
const locator = pnpApi.findPackageLocator(resolved);
if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) {
str = resolved;
}
}
str = str.replace(/\\/g, `/`)
str = str.replace(/^\/?/, `/`);
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
// VSCode only adds it automatically for supported schemes,
// so we have to do it manually for the `zip` scheme.
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
if (str.match(/\.zip\//)) {
str = `${isVSCode ? `^` : ``}zip:${str}`;
}
}
return str;
}
function fromEditorPath(str) {
return process.platform === `win32`
? str.replace(/^\^?zip:\//, ``)
: str.replace(/^\^?zip:/, ``);
}
// And here is the point where we hijack the VSCode <-> TS communications
// by adding ourselves in the middle. We locate everything that looks
// like an absolute path of ours and normalize it.
const Session = tsserver.server.Session;
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
let isVSCode = false;
return Object.assign(Session.prototype, {
onMessage(/** @type {string} */ message) {
const parsedMessage = JSON.parse(message)
if (
parsedMessage != null &&
typeof parsedMessage === `object` &&
parsedMessage.arguments &&
parsedMessage.arguments.hostInfo === `vscode`
) {
isVSCode = true;
}
return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
return typeof value === `string` ? fromEditorPath(value) : value;
}));
},
send(/** @type {any} */ msg) {
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
return typeof value === `string` ? toEditorPath(value) : value;
})));
}
});
};
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsserver.js
require(absPnpApiPath).setup();
}
}
// Defer to the real typescript/lib/tsserver.js your application uses
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));

20
.yarn/sdks/typescript/lib/typescript.js vendored Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/typescript.js
require(absPnpApiPath).setup();
}
}
// Defer to the real typescript/lib/typescript.js your application uses
module.exports = absRequire(`typescript/lib/typescript.js`);

6
.yarn/sdks/typescript/package.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"name": "typescript",
"version": "4.1.5-pnpify",
"main": "./lib/typescript.js",
"type": "commonjs"
}

2
.yarnrc.yml Normal file
View file

@ -0,0 +1,2 @@
yarnPath: ".yarn/releases/yarn-berry.cjs"
nodeLinker: pnp

View file

@ -18,10 +18,12 @@ https://git.f3l.de/dungeonslayers/ds4/-/raw/latest/src/system.json?inline=false
### Prerequisites ### Prerequisites
In order to build this system, recent versions of `node` and `npm` are required. In order to build this system, recent versions of `node` and `yarn` are
We recommend using the latest lts version of `node`, which is `v14.15.4` at the required. Most likely using `npm` also works but only `yarn` is officially
time of writing. If you use `nvm` to manage your `node` versions, you can simply supported. We recommend using the latest lts version of `node`, which is
run `v14.15.5` at the time of writing. If you use `nvm` to manage your `node`
versions, you can simply run
``` ```
nvm install nvm install
``` ```
@ -31,7 +33,7 @@ in the project's root directory.
You also need to install the the project's dependencies. To do so, run You also need to install the the project's dependencies. To do so, run
``` ```
npm install yarn install
``` ```
### Building ### Building
@ -39,13 +41,13 @@ npm install
You can build the project by running You can build the project by running
``` ```
npm run build yarn build
``` ```
Alternatively, you can run Alternatively, you can run
``` ```
npm run build:watch yarn build:watch
``` ```
to watch for changes and automatically build as necessary. to watch for changes and automatically build as necessary.
@ -68,7 +70,7 @@ On platforms other than Linux you need to adjust the path accordingly.
Then run Then run
``` ```
npm run link yarn link-project
``` ```
### Running the tests ### Running the tests
@ -76,7 +78,7 @@ npm run link
You can run the tests with the following command: You can run the tests with the following command:
``` ```
npm test yarn test
``` ```
## Contributing ## Contributing

9
jest.config.js Normal file
View file

@ -0,0 +1,9 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
globals: {
"ts-jest": {
tsconfig: "<rootDir>/spec/tsconfig.spec.json",
},
},
};

8133
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -33,22 +33,21 @@
"scripts": { "scripts": {
"build": "gulp build", "build": "gulp build",
"build:watch": "gulp watch", "build:watch": "gulp watch",
"link": "gulp link", "link-project": "gulp link",
"clean": "gulp clean && gulp link --clean", "clean": "gulp clean && gulp link --clean",
"update": "npm install --save-dev github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "update": "yarn add --dev foundry-vtt-types@github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9",
"updateManifest": "gulp updateManifest", "updateManifest": "gulp updateManifest",
"lint": "eslint 'src/**/*.ts' --cache", "lint": "eslint 'src/**/*.ts' --cache",
"lint:fix": "eslint 'src/**/*.ts' --cache --fix", "lint:fix": "eslint 'src/**/*.ts' --cache --fix",
"test": "ts-node ./node_modules/jasmine/bin/jasmine", "test": "jest",
"test:ci": "ts-node ./node_modules/jasmine-xml-reporter/bin/jasmine --junitreport", "test:ci": "jest --ci --reporters=default --reporters=jest-junit",
"format": "prettier --write 'src/**/*.(ts|json|scss)'" "format": "prettier --write 'src/**/*.(ts|json|scss)'"
}, },
"devDependencies": { "devDependencies": {
"@types/fs-extra": "^9.0.6", "@types/fs-extra": "^9.0.6",
"@types/jasmine": "^3.6.3", "@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.14.2", "@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2", "@typescript-eslint/parser": "^4.14.2",
"archiver": "^5.2.0",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"eslint": "^7.19.0", "eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0", "eslint-config-prettier": "^7.2.0",
@ -56,18 +55,16 @@
"foundry-vtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "foundry-vtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9",
"fs-extra": "^9.1.0", "fs-extra": "^9.1.0",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-git": "^2.10.1",
"gulp-less": "^4.0.1",
"gulp-sass": "^4.1.0", "gulp-sass": "^4.1.0",
"gulp-typescript": "^6.0.0-alpha.1", "gulp-typescript": "^6.0.0-alpha.1",
"husky": "^4.3.8", "husky": "^4.3.8",
"jasmine": "^3.6.4", "jest": "^26.6.3",
"jasmine-xml-reporter": "^1.2.1", "jest-junit": "^12.0.0",
"json-stringify-pretty-compact": "^2.0.0", "json-stringify-pretty-compact": "^2.0.0",
"lint-staged": "^10.5.4", "lint-staged": "^10.5.4",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"sass": "^1.32.6", "sass": "^1.32.6",
"ts-node": "^9.1.1", "ts-jest": "^26.5.1",
"typescript": "^4.1.3", "typescript": "^4.1.3",
"yargs": "^16.2.0" "yargs": "^16.2.0"
}, },

View file

@ -1,4 +1,3 @@
import "jasmine";
import * as fs from "fs-extra"; import * as fs from "fs-extra";
import * as path from "path"; import * as path from "path";

View file

@ -1,7 +1,5 @@
import { rollCheckMultipleDice, rollCheckSingleDie } from "../../../src/module/rolls/roll-executor"; import { RollResult, RollResultStatus } from "../../src/module/rolls/roll-data";
import { rollCheckMultipleDice, rollCheckSingleDie } from "../../src/module/rolls/roll-executor";
import "jasmine";
import { RollResult, RollResultStatus } from "../../../src/module/rolls/roll-data";
describe("DS4 Rolls with one die and no modifications.", () => { describe("DS4 Rolls with one die and no modifications.", () => {
it("Should do a regular success roll.", () => { it("Should do a regular success roll.", () => {

View file

@ -1,24 +1,23 @@
import "jasmine"; import { isDiceSwapNecessary } from "../../src/module/rolls/roll-utils";
import { isDiceSwapNecessary } from "../../../src/module/rolls/roll-utils";
describe("Utility function testing if dice swap is necessary", () => { describe("Utility function testing if dice swap is necessary", () => {
it("Should not swap if all dice are crit successes.", () => { it("Should not swap if all dice are crit successes.", () => {
expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalse(); expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalsy();
}); });
it("Should not swap if no die is crit success.", () => { it("Should not swap if no die is crit success.", () => {
expect(isDiceSwapNecessary([[], [2, 2, 2]], 9)).toBeFalse(); expect(isDiceSwapNecessary([[], [2, 2, 2]], 9)).toBeFalsy();
}); });
it("Should not swap if all dice are already in use", () => { it("Should not swap if all dice are already in use", () => {
expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalse(); expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalsy();
}); });
it("Should not swap if result does not get any better", () => { it("Should not swap if result does not get any better", () => {
expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalse(); expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalsy();
}); });
it("Should swap if result does get better", () => { it("Should swap if result does get better", () => {
expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTrue(); expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTruthy();
}); });
}); });

View file

@ -1,7 +0,0 @@
{
"spec_dir": "spec",
"spec_files": ["**/*[sS]pec.ts"],
"helpers": ["helpers/**/*.ts"],
"stopSpecOnExpectationFailure": false,
"random": true
}

7
spec/tsconfig.spec.json Normal file
View file

@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["foundry-vtt-types", "jest"]
},
"include": ["src", "./"]
}

9150
yarn.lock Normal file

File diff suppressed because it is too large Load diff