diff --git a/studio/apps/web-react/vite/PublishApiHandler.ts b/studio/apps/web-react/vite/PublishApiHandler.ts index 3c44d61..ae99847 100644 --- a/studio/apps/web-react/vite/PublishApiHandler.ts +++ b/studio/apps/web-react/vite/PublishApiHandler.ts @@ -46,7 +46,11 @@ export class PublishApiHandler { if (error instanceof Error && /not found/.test(error.message)) { return { status: 404, body: { error: error.message } }; } - return { status: 500, body: { error: 'La création de la proposition a échoué.' } }; + const detail = error instanceof Error ? ` ${error.message}` : ''; + return { + status: 500, + body: { error: `La création de la proposition a échoué.${detail}` }, + }; } } diff --git a/studio/src/infrastructure/git/GitProductionGameDataProposalGateway.ts b/studio/src/infrastructure/git/GitProductionGameDataProposalGateway.ts index 14bab9c..a1ef94c 100644 --- a/studio/src/infrastructure/git/GitProductionGameDataProposalGateway.ts +++ b/studio/src/infrastructure/git/GitProductionGameDataProposalGateway.ts @@ -1,5 +1,5 @@ import { execFile } from 'node:child_process'; -import { cp, mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises'; +import { cp, mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { dirname, join } from 'node:path'; import { promisify } from 'node:util'; @@ -41,7 +41,7 @@ export class GitProductionGameDataProposalGateway implements ProductionGameDataP join(worktreePath, internalCatalogPath), { recursive: true }, ); - await this.npm(['version', 'patch', '--no-git-tag-version'], worktreePath); + await this.bumpPatchVersion(worktreePath); await this.git([ '-C', worktreePath, @@ -78,8 +78,31 @@ export class GitProductionGameDataProposalGateway implements ProductionGameDataP await executeFile('git', args, { cwd: this.repositoryPath }); } - private async npm(args: readonly string[], cwd: string): Promise { - const executable = process.platform === 'win32' ? 'npm.cmd' : 'npm'; - await executeFile(executable, args, { cwd }); + private async bumpPatchVersion(worktreePath: string): Promise { + const packagePath = join(worktreePath, 'package.json'); + const lockPath = join(worktreePath, 'package-lock.json'); + const packageDocument = JSON.parse(await readFile(packagePath, 'utf8')) as { + version: string; + }; + const lockDocument = JSON.parse(await readFile(lockPath, 'utf8')) as { + version: string; + packages: Record; + }; + const versionParts = packageDocument.version.split('.').map(Number); + if ( + versionParts.length !== 3 + || versionParts.some((part) => !Number.isInteger(part) || part < 0) + ) { + throw new Error(`Unsupported package version '${packageDocument.version}'.`); + } + const nextVersion = `${versionParts[0]}.${versionParts[1]}.${versionParts[2] + 1}`; + packageDocument.version = nextVersion; + lockDocument.version = nextVersion; + lockDocument.packages[''] ??= {}; + lockDocument.packages[''].version = nextVersion; + await Promise.all([ + writeFile(packagePath, `${JSON.stringify(packageDocument, null, 2)}\n`, 'utf8'), + writeFile(lockPath, `${JSON.stringify(lockDocument, null, 2)}\n`, 'utf8'), + ]); } } diff --git a/studio/store/catalog/commanders.json b/studio/store/catalog/commanders.json index 64987a5..4efc39a 100644 --- a/studio/store/catalog/commanders.json +++ b/studio/store/catalog/commanders.json @@ -34,5 +34,39 @@ ], "freeRecruitThreshold": 20 } + }, + { + "id": "Erwan", + "name": "Erwan", + "description": "aucune", + "icon": "aucune", + "baseStats": { + "pawnMax": 45, + "health": 99, + "maxDefenseLevel": 2, + "wallVisualSet": "default", + "defensePowerPerLevel": 8, + "pawnDefinitionIdByColor": { + "red": "Aegis-soldier-melee-red", + "blue": "Aegis-soldier-melee-blue", + "green": "Aegis-soldier-melee-green" + }, + "commanderPawnDefinitionIds": [ + "commander-1-1" + ], + "officerPawnDefinitionIds": [ + "Aegis_officer_1", + "Aegis_officer_2", + "Aegis_officer_4" + ], + "movementsPerTurn": 3, + "skills": [ + "free-recruits", + "destroy-defense-pawns", + "expand-pawn-capacity", + "tactical-demolition" + ], + "freeRecruitThreshold": 20 + } } ]