Skip to content

Commit

Permalink
fix: Add basic Windows development support (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: cpojer <[email protected]>
  • Loading branch information
Saeris and cpojer authored May 8, 2024
1 parent 87d72ff commit 059493e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 16 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ module.exports = {
.split('\n')
.slice(1)
.map((n) =>
join(__dirname, n.replaceAll(/\s*-\s+/g, '').replaceAll("'", '')),
join(
__dirname,
n
.replaceAll(/\s*-\s+/g, '')
.replaceAll("'", '')
.replaceAll('\r', ''),
),
),
),
},
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ on:

jobs:
action:
runs-on: 'ubuntu-latest'
timeout-minutes: 20
permissions:
contents: read
deployments: write
strategy:
matrix:
node-version: [22]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
Expand All @@ -27,6 +28,10 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Use Git Bash
if: matrix.os == 'windows-latest'
run: npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
Expand Down Expand Up @@ -61,4 +66,9 @@ jobs:
run: pnpx playwright install --with-deps chromium

- name: Run tests
if: matrix.os != 'windows-latest'
run: pnpm test:ci

- name: Run tests (Windows)
if: matrix.os == 'windows-latest'
run: pnpm vitest:run-ci
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ If you like Athena Crisis, [please consider a sponsorship to support its develop

Athena Crisis requires [Node.js](https://nodejs.org/en/download/package-manager) and the latest major version of [`pnpm`](https://pnpm.io/installation).

> [!NOTE]
>
> <details><summary>Windows Specific Config</summary>
> Developers on Windows will want to ensure that they are using `bash` to run `package.json` scripts. You can configure npm to use git bash by default with the following:
>
> ```bash
> npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
> ```
>
> </details>
```bash
pnpm install && pnpm dev:setup
pnpm dev
Expand Down
9 changes: 5 additions & 4 deletions codegen/generate-campaign-names.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { join, posix, sep } from 'node:path';
import { pathToFileURL } from 'node:url';
import toSlug from '@deities/hephaestus/toSlug.tsx';
import chalk from 'chalk';
import { globSync } from 'glob';
Expand All @@ -14,13 +15,13 @@ const globs: ReadonlyArray<string> = [
'./hermes/map-fixtures/*.tsx',
'./fixtures/map/*.tsx',
];
const outputFile = join(root, 'hermes/CampaignMapName.tsx');
const outputFile = join(root, './hermes/CampaignMapName.tsx');

const maps = (
await Promise.all(
globs
.flatMap((path) => globSync(join(root, path)))
.map((file) => import(file)),
.flatMap((path) => globSync(join(root, path).split(sep).join(posix.sep)))
.map((file) => import(pathToFileURL(file).toString())),
)
)
.filter((module) => module.metadata.tags?.includes('campaign'))
Expand Down
8 changes: 6 additions & 2 deletions codegen/generate-graphql.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm
import { writeFileSync } from 'node:fs';
import { join, relative } from 'node:path';
import { join, posix, relative, sep } from 'node:path';
import chalk from 'chalk';
import { globSync } from 'glob';
import { format } from 'prettier';
Expand All @@ -13,7 +13,11 @@ const root = process.cwd();
const path = join(root, 'artemis/graphql');
const outputFile = join(path, 'schemaImportMap.tsx');

const files = (await Promise.all(globSync(`${path}/{nodes,mutations}/*.tsx`)))
const files = (
await Promise.all(
globSync(`${path}/{nodes,mutations}/*.tsx`.split(sep).join(posix.sep)),
)
)
.map((file) => relative(path, file.slice(0, file.lastIndexOf('.'))))
.sort((a, b) => String(a).localeCompare(String(b)));

Expand Down
21 changes: 13 additions & 8 deletions codegen/generate-translations.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm
import { writeFileSync } from 'node:fs';
import { basename, extname, join } from 'node:path';
import { basename, extname, join, posix, sep } from 'node:path';
import { pathToFileURL } from 'node:url';
import getMessageKey from '@deities/apollo/lib/getMessageKey.tsx';
import { mapBuildings } from '@deities/athena/info/Building.tsx';
import { mapDecorators } from '@deities/athena/info/Decorator.tsx';
Expand Down Expand Up @@ -48,23 +49,27 @@ const globs: ReadonlyArray<string> = [
];
const maps = await Promise.all(
globs.flatMap((path) =>
globSync(join(root, path))
globSync(join(root, path).split(sep).join(posix.sep))
.sort()
.map((filename) =>
(import(filename) as Promise<MapModule>).then((module) => ({
id: basename(filename, extname(filename)),
module,
})),
(import(pathToFileURL(filename).toString()) as Promise<MapModule>).then(
(module) => ({
id: basename(filename, extname(filename)),
module,
}),
),
),
),
);
const mapsById = new Map(maps.map(({ id, module }) => [id, module]));

const campaigns = await Promise.all(
globSync(join(root, './fixtures/campaign/*.tsx'))
globSync(join(root, './fixtures/campaign/*.tsx').split(sep).join(posix.sep))
.sort()
.map((filename) =>
(import(filename) as Promise<CampaignModule>).then((module) => ({
(
import(pathToFileURL(filename).toString()) as Promise<CampaignModule>
).then((module) => ({
id: basename(filename, extname(filename)),
module,
})),
Expand Down

0 comments on commit 059493e

Please sign in to comment.