Skip to content

Commit

Permalink
Add catalog specification.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswilddev committed Dec 27, 2020
1 parent a447b02 commit b645c2d
Show file tree
Hide file tree
Showing 16 changed files with 2,366 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
]
}
13 changes: 13 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on: push

jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run-script build
19 changes: 19 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
release:
types: [created]

jobs:
release:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run-script build
- run: "sed -i \"s/\\\"version\\\": \\\"0.0.0\\\",/\\\"version\\\": \\\"${GITHUB_REF/refs\\/tags\\/v/}\\\",/g\" package.json"
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.d.ts
*.js
node_modules
16 changes: 15 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": true,
"[typescript]": {
"editor.formatOnSave": false,
},
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.insertSpaces": true,
Expand All @@ -9,5 +15,13 @@
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.eol": "\n"
"files.eol": "\n",
"files.exclude": {
".DS_Store": true,
"**/.git": true,
"**/*.d.ts": true,
"**/*.js": true,
"node_modules": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "npm install && npm run-script build",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export type CatalogGameVersionLocalization = {
/**
* The name of the game as of the version localization.
*/
readonly gameName: string;

/**
* The code of the localization the version localization implements.
*/
readonly localizationCode: string;

/**
* The second half of the URL for the version localization's WASM file. Must
* refer to an existing WASM file.
*/
readonly wasmUrlSuffix: string;
};
24 changes: 24 additions & 0 deletions catalog/catalog-game/catalog-game-version/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { CatalogGameVersionLocalization } from "./catalog-game-version-localization";

export { CatalogGameVersionLocalization } from "./catalog-game-version-localization";

/**
* A version of a game within a catalog.
*/
export type CatalogGameVersion = {
/**
* Invariant identifier for the version. Do not change.
*/
readonly code: string;

/**
* The date on which the version was published.
*/
readonly date: number;

/**
* The localizations of the game version. Must not be empty. Do not remove
* records on update.
*/
readonly versionLocalizations: ReadonlyArray<CatalogGameVersionLocalization>;
};
17 changes: 17 additions & 0 deletions catalog/catalog-game/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { CatalogGameVersion } from "./catalog-game-version";

export {
CatalogGameVersionLocalization,
CatalogGameVersion,
} from "./catalog-game-version";

/**
* A game within a catalog.
*/
export type CatalogGame = {
/**
* The versions of the game. Must not be empty. Do not remove records on
* update.
*/
readonly versions: ReadonlyArray<CatalogGameVersion>;
};
21 changes: 21 additions & 0 deletions catalog/catalog-localization/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* A localization of a catalog.
*/
export type CatalogLocalization = {
/**
* Invariant identifier for the localization. Do not change.
*/
readonly code: string;

/**
* The name of the localization, in its own language, for display to the user
* in a menu.
*/
readonly uiName: string;

/**
* The second half of the URL for the localization's icon. Must refer to an
* existing PNG or JPEG.
*/
readonly iconUrlSuffix: string;
};
32 changes: 32 additions & 0 deletions catalog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { CatalogGame } from "./catalog-game";
import { CatalogLocalization } from "./catalog-localization";

export {
CatalogGameVersionLocalization,
CatalogGameVersion,
CatalogGame,
} from "./catalog-game";

export { CatalogLocalization } from "./catalog-localization";

/**
* Describes a catalog of versioned, localized Neomura games.
*/
export type Catalog = {
/**
* The first half of all URLs in the catalog.
*/
readonly urlPrefix: string;

/**
* All localizations supported by games in the catalog. Must not be empty.
* Do not remove records on update.
*/
readonly localizations: ReadonlyArray<CatalogLocalization>;

/**
* All games within the catalog. Must not be empty. Do not remove records on
* update.
*/
readonly games: ReadonlyArray<CatalogGame>;
};
7 changes: 7 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {
CatalogGameVersionLocalization,
CatalogGameVersion,
CatalogGame,
CatalogLocalization,
Catalog,
} from "./catalog";
Loading

0 comments on commit b645c2d

Please sign in to comment.