Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
presets: [
'@babel/preset-typescript',
['@babel/preset-react', { runtime: 'automatic' }]
],
};

16 changes: 16 additions & 0 deletions .crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"project_id_env": "CROWDIN_PROJECT_ID"
"api_token_env": "CROWDIN_PERSONAL_TOKEN"
"preserve_hierarchy": true
"base_path": "."

"preserve_hierarchy": true

"files": [
{
"source": "src/locales/en_001.json",
"dest": "DeadForge.json",
"translation": "src/locales/%locale_with_underscore%.json",
"type": "i18next_json",
"scheme": nested
}
]
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_STORE_URL=http://localhost:3001/DeadForge/store/
REACT_APP_STORE_PROD_URL=https://deadcode.is-a.dev/DeadForge/store/
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_STORE_URL=https://deadcode.is-a.dev/DeadForge/store/
REACT_APP_STORE_PROD_URL=https://deadcode.is-a.dev/DeadForge/store/
7 changes: 7 additions & 0 deletions .eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/no-require-imports */
module.exports = {
rules: {
'array-destructure-comma-spacing': require('./rules/array-destructure-comma-spacing'),
'format-jsx-paren': require('./rules/format-jsx-paren')
}
};
77 changes: 77 additions & 0 deletions .eslint/rules/array-destructure-comma-spacing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module.exports = {
meta: {
type: 'layout',
docs: {
description: 'enforce space after commas in array destructuring except when the element before is empty, and disallow trailing comma before last empty element',
category: 'Stylistic Issues',
recommended: false
},
fixable: 'whitespace',
schema: [],
messages: {
missingSpace: 'Expected a space after comma in array destructuring.',
unexpectedSpace: 'Unexpected space after comma before empty element.',
unexpectedTrailingComma: 'Unexpected trailing comma before last empty element in array destructuring.'
}
},

create(context) {
const sourceCode = context.getSourceCode();

return {
ArrayPattern(node) {
const tokens = sourceCode.getTokens(node);

tokens.forEach((token, i) => {
if (token.value !== ',') return;

const prev = tokens[i - 1];
const next = tokens[i + 1];
if (!prev || !next) return;

const hasSpace = sourceCode.isSpaceBetweenTokens(token, next);

if (prev.value === '[') {
if (hasSpace) {
context.report({
loc: token.loc,
messageId: 'unexpectedSpace',
fix(fixer) {
return fixer.replaceTextRange(
[token.range[1], next.range[0]],
''
);
}
});
}
} else {
if (!hasSpace) {
context.report({
loc: token.loc,
messageId: 'missingSpace',
fix(fixer) {
return fixer.insertTextAfter(token, ' ');
}
});
}
}
});

const elements = node.elements;
if (elements.length > 0 && elements[elements.length - 1] === null) {
const closeBracket = sourceCode.getLastToken(node);
const tokenBeforeClose = sourceCode.getTokenBefore(closeBracket);
if (tokenBeforeClose && tokenBeforeClose.value === ',') {
context.report({
loc: tokenBeforeClose.loc,
messageId: 'unexpectedTrailingComma',
fix(fixer) {
return fixer.remove(tokenBeforeClose);
}
});
}
}
}
};
}
};
90 changes: 90 additions & 0 deletions .eslint/rules/format-jsx-paren.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
module.exports = {
meta: {
type: "layout",
docs: {
description: "Enforce line breaks between parentheses and JSX tags in multiline expressions",
category: "Stylistic Issues",
recommended: false,
},
fixable: "whitespace",
schema: [], // no options
messages: {
openingTagSameLine: "Opening JSX tag must not be on the same line as the preceding parenthesis in multiline expressions",
closingTagSameLine: "Closing JSX tag must not be on the same line as the following parenthesis in multiline expressions",
},
},

create: function (context) {
const sourceCode = context.getSourceCode();

/**
* Checks if a JSX expression spans multiple lines
* @param {Node} jsxElement - The JSX element to check
* @returns {boolean} - Whether the JSX expression spans multiple lines
*/
function isMultilineJSX(jsxElement) {
const startLine = jsxElement.loc.start.line;
const endLine = jsxElement.loc.end.line;
return startLine !== endLine;
}

return {
JSXElement(node) {
// Skip if not wrapped in parentheses or not multiline
if (!isMultilineJSX(node)) {
return;
}

// Get the parent node which might have the parentheses
const parent = node.parent;
if (!parent) return;

// Look for a return statement or expression with parentheses
if (parent.type === "ReturnStatement" || parent.type === "ArrowFunctionExpression") {
const tokenBefore = sourceCode.getTokenBefore(node);
const tokenAfter = sourceCode.getTokenAfter(node);

// Check if there's an opening parenthesis before the JSX element
if (tokenBefore && tokenBefore.value === '(') {
const openingParenLine = tokenBefore.loc.start.line;
const jsxOpeningLine = node.loc.start.line;

if (openingParenLine === jsxOpeningLine) {
context.report({
node: node,
loc: {
start: tokenBefore.loc.end,
end: node.loc.start
},
messageId: "openingTagSameLine",
fix: function (fixer) {
return fixer.insertTextAfter(tokenBefore, "\n");
}
});
}
}

// Check if there's a closing parenthesis after the JSX element
if (tokenAfter && tokenAfter.value === ')') {
const closingJsxLine = node.loc.end.line;
const closingParenLine = tokenAfter.loc.start.line;

if (closingJsxLine === closingParenLine) {
context.report({
node: node,
loc: {
start: node.loc.end,
end: tokenAfter.loc.start
},
messageId: "closingTagSameLine",
fix: function (fixer) {
return fixer.insertTextBefore(tokenAfter, "\n");
}
});
}
}
}
}
};
}
};
15 changes: 9 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches:
- release

permissions:
contents: write
pull-requests: read
actions: read

jobs:
release:
runs-on: windows-latest
Expand All @@ -16,19 +21,17 @@ jobs:
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 20
node-version: 22.14.0

- name: Install dependencies
run: npm install --force

- name: Build React and Electron
run: npm run full-build

- name: Build/release Electron app
uses: DeadCodeGames/action-electron-builder@effa1ea435ec026b5c7b953273d18d55b17b5d04
uses: DeadCodeGames/action-electron-builder@908b7cf133f1e9bef6d538ab50ad2f7449538cc7
with:
github_token: ${{ secrets.build_token }}
args: "--win --publish always"
skip_install: true

build_script_name: "full-build"
build_script_env: "set CI=false"
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
39 changes: 31 additions & 8 deletions .github/workflows/buildpr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,39 @@ on:
- opened
- synchronize

jobs:
permissions:
contents: read
pull-requests: read
actions: read

jobs:
test-lint:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v1

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 22.14.0

- name: Install dependencies
run: npm install --force

- name: Run lint
run: npm run lint

test-build:
strategy:
matrix:
include:
- os: windows-latest
args: -w
- os: ubuntu-22.04
args: -l
- os: macos-latest
args: -m
#- os: ubuntu-22.04
# args: -l
#- os: macos-latest
# args: -m

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -26,17 +48,18 @@ jobs:
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 20
node-version: 22.14.0

- name: Install dependencies
run: npm install --force
run: set CI=false && npm install --force

- name: Build/release Electron app
uses: DeadCodeGames/action-electron-builder@effa1ea435ec026b5c7b953273d18d55b17b5d04
uses: DeadCodeGames/action-electron-builder@908b7cf133f1e9bef6d538ab50ad2f7449538cc7
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
args: ${{ matrix.args }}
build_script_name: "full-build"
build_script_env: "set CI=false"
skip_install: true

- name: Upload artifacts
Expand Down
Loading