@puzzmo/cli 1.0.81 → 1.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/lib/commands/changed.js +1 -1
- package/lib/commands/changed.js.map +1 -1
- package/lib/commands/puzzles.d.ts +8 -0
- package/lib/commands/puzzles.js +107 -0
- package/lib/commands/puzzles.js.map +1 -0
- package/lib/commands/upload.js +10 -2
- package/lib/commands/upload.js.map +1 -1
- package/lib/commands/validate.js +2 -0
- package/lib/commands/validate.js.map +1 -1
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -1
- package/lib/queries/__generated__/cliAddPuzzlesToPoolMutation.graphql.d.ts +30 -0
- package/lib/queries/__generated__/cliAddPuzzlesToPoolMutation.graphql.js +123 -0
- package/lib/queries/__generated__/cliAddPuzzlesToPoolMutation.graphql.js.map +1 -0
- package/lib/queries/__generated__/cliGamesForAccessTokenQuery.graphql.d.ts +19 -0
- package/lib/queries/__generated__/cliGamesForAccessTokenQuery.graphql.js +67 -0
- package/lib/queries/__generated__/cliGamesForAccessTokenQuery.graphql.js.map +1 -0
- package/lib/queries/__generated__/cliValidatePoolPuzzlesQuery.graphql.d.ts +27 -0
- package/lib/queries/__generated__/cliValidatePoolPuzzlesQuery.graphql.js +105 -0
- package/lib/queries/__generated__/cliValidatePoolPuzzlesQuery.graphql.js.map +1 -0
- package/lib/queries/puzzlePool.d.ts +21 -0
- package/lib/queries/puzzlePool.js +59 -0
- package/lib/queries/puzzlePool.js.map +1 -0
- package/lib/util/api.d.ts +4 -0
- package/lib/util/api.js +3 -2
- package/lib/util/api.js.map +1 -1
- package/lib/util/discoverGames.d.ts +7 -2
- package/lib/util/discoverGames.js +7 -4
- package/lib/util/discoverGames.js.map +1 -1
- package/package.json +1 -1
- package/schemas/puzzmo-file-schema.json +4 -0
- package/src/commands/changed.ts +1 -1
- package/src/commands/puzzles.ts +121 -0
- package/src/commands/upload.ts +9 -2
- package/src/commands/validate.ts +1 -0
- package/src/index.ts +17 -0
- package/src/queries/__generated__/cliAddPuzzlesToPoolMutation.graphql.ts +157 -0
- package/src/queries/__generated__/cliGamesForAccessTokenQuery.graphql.ts +88 -0
- package/src/queries/__generated__/cliValidatePoolPuzzlesQuery.graphql.ts +136 -0
- package/src/queries/puzzlePool.ts +65 -0
- package/src/util/api.ts +9 -3
- package/src/util/discoverGames.ts +15 -6
package/src/commands/upload.ts
CHANGED
|
@@ -161,7 +161,7 @@ type UploadOneOptions = {
|
|
|
161
161
|
/** Uploads a single discovered game; throws on failure */
|
|
162
162
|
const uploadOneGame = async (game: DiscoveredGame, opts: UploadOneOptions): Promise<GameSuccess> => {
|
|
163
163
|
const { credential, apiURL, sha, description, repoURL, verbose } = opts
|
|
164
|
-
const { puzzmoFile, distDir, iconPath } = game
|
|
164
|
+
const { puzzmoFile, distDir, iconPath, helpPath } = game
|
|
165
165
|
const gameSlug = puzzmoFile.game.slug
|
|
166
166
|
|
|
167
167
|
const files = collectFiles(distDir)
|
|
@@ -193,10 +193,17 @@ const uploadOneGame = async (game: DiscoveredGame, opts: UploadOneOptions): Prom
|
|
|
193
193
|
(batch, totalBatches, uploaded) => {
|
|
194
194
|
console.log(` Batch ${batch}/${totalBatches} done (${plural(uploaded, "file")} uploaded)`)
|
|
195
195
|
},
|
|
196
|
-
{
|
|
196
|
+
{
|
|
197
|
+
verbose,
|
|
198
|
+
description,
|
|
199
|
+
repoURL,
|
|
200
|
+
iconSVG: iconPath ? fs.readFileSync(iconPath, "utf-8") : null,
|
|
201
|
+
helpMD: helpPath ? fs.readFileSync(helpPath, "utf-8") : null,
|
|
202
|
+
},
|
|
197
203
|
)
|
|
198
204
|
|
|
199
205
|
if (result.iconChanged && iconPath) console.log(` Icon updated from ${path.relative(game.puzzmoJsonDir, iconPath)}.`)
|
|
206
|
+
if (result.helpChanged && helpPath) console.log(` In-game help updated from ${path.relative(game.puzzmoJsonDir, helpPath)}, live now.`)
|
|
200
207
|
|
|
201
208
|
if (result.integrationsChanged && result.versionsURL) {
|
|
202
209
|
console.log(` Uploaded. A new version has been staged for your team to try before it goes live:`)
|
package/src/commands/validate.ts
CHANGED
|
@@ -34,6 +34,7 @@ export const validate = async (dir: string) => {
|
|
|
34
34
|
log(` dist: ${distRel}`)
|
|
35
35
|
if (integrations.length) log(` integrations: ${integrations.join(", ")}`)
|
|
36
36
|
if (game.iconPath) log(` icon: ${path.relative(rootDir, game.iconPath)}`)
|
|
37
|
+
if (game.helpPath) log(` help: ${path.relative(rootDir, game.helpPath)}`)
|
|
37
38
|
for (const e of distErrors) console.error(` ${e}`)
|
|
38
39
|
for (const warning of lintPuzzmoFile(game.puzzmoFile)) log(` warning: ${warning}`)
|
|
39
40
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { type ChangedAgainst, changed } from "./commands/changed.js"
|
|
|
7
7
|
import { gameCreate } from "./commands/game/create.js"
|
|
8
8
|
import { login } from "./commands/login.js"
|
|
9
9
|
import { migrate } from "./commands/migrate.js"
|
|
10
|
+
import { puzzlesUpload } from "./commands/puzzles.js"
|
|
10
11
|
import { upload } from "./commands/upload.js"
|
|
11
12
|
import { validate } from "./commands/validate.js"
|
|
12
13
|
import { defaultSource } from "./util/config.js"
|
|
@@ -79,6 +80,21 @@ const gamesCommand = defineCommand({
|
|
|
79
80
|
subCommands: { changed: changedCommand, upload: uploadCommand, validate: validateCommand },
|
|
80
81
|
})
|
|
81
82
|
|
|
83
|
+
const puzzlesUploadCommand = defineCommand({
|
|
84
|
+
meta: { name: "upload", description: "Add puzzle files to the end of a game's puzzle pool" },
|
|
85
|
+
args: {
|
|
86
|
+
path: { type: "positional", description: "A puzzle file, or a directory of them", required: true },
|
|
87
|
+
game: { type: "string", description: "The game slug to upload puzzles for", required: true },
|
|
88
|
+
"dry-run": { type: "boolean", description: "Validate the files without uploading them" },
|
|
89
|
+
},
|
|
90
|
+
run: ({ args }) => puzzlesUpload(args.path, { game: args.game, dryRun: args["dry-run"] }),
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const puzzlesCommand = defineCommand({
|
|
94
|
+
meta: { name: "puzzles", description: "Manage the puzzles scheduled for your games" },
|
|
95
|
+
subCommands: { upload: puzzlesUploadCommand },
|
|
96
|
+
})
|
|
97
|
+
|
|
82
98
|
const migrateCommand = defineCommand({
|
|
83
99
|
meta: { name: "migrate", description: "List and select migration skills from workshop.puzzmo.com" },
|
|
84
100
|
run: () => migrate(),
|
|
@@ -145,6 +161,7 @@ const main = defineCommand({
|
|
|
145
161
|
subCommands: {
|
|
146
162
|
login: loginCommand,
|
|
147
163
|
games: gamesCommand,
|
|
164
|
+
puzzles: puzzlesCommand,
|
|
148
165
|
migrate: migrateCommand,
|
|
149
166
|
game: gameCommand,
|
|
150
167
|
upload: uploadAlias,
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated SignedSource<<892c3aa4f6c7673e590b4a9bcc8514c2>>
|
|
3
|
+
* @lightSyntaxTransform
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
|
|
10
|
+
import { ConcreteRequest } from 'relay-runtime';
|
|
11
|
+
export type McpPuzzleFileInput = {
|
|
12
|
+
content: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
};
|
|
15
|
+
export type cliAddPuzzlesToPoolMutation$variables = {
|
|
16
|
+
gameSlug: string;
|
|
17
|
+
puzzles: ReadonlyArray<McpPuzzleFileInput>;
|
|
18
|
+
token: string;
|
|
19
|
+
};
|
|
20
|
+
export type cliAddPuzzlesToPoolMutation$data = {
|
|
21
|
+
readonly addPuzzlesToPool: {
|
|
22
|
+
readonly failed: ReadonlyArray<{
|
|
23
|
+
readonly filename: string;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
}>;
|
|
26
|
+
readonly poolCount: number;
|
|
27
|
+
readonly uploadedFilenames: ReadonlyArray<string>;
|
|
28
|
+
} | null | undefined;
|
|
29
|
+
};
|
|
30
|
+
export type cliAddPuzzlesToPoolMutation = {
|
|
31
|
+
response: cliAddPuzzlesToPoolMutation$data;
|
|
32
|
+
variables: cliAddPuzzlesToPoolMutation$variables;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const node: ConcreteRequest = (function(){
|
|
36
|
+
var v0 = {
|
|
37
|
+
"defaultValue": null,
|
|
38
|
+
"kind": "LocalArgument",
|
|
39
|
+
"name": "gameSlug"
|
|
40
|
+
},
|
|
41
|
+
v1 = {
|
|
42
|
+
"defaultValue": null,
|
|
43
|
+
"kind": "LocalArgument",
|
|
44
|
+
"name": "puzzles"
|
|
45
|
+
},
|
|
46
|
+
v2 = {
|
|
47
|
+
"defaultValue": null,
|
|
48
|
+
"kind": "LocalArgument",
|
|
49
|
+
"name": "token"
|
|
50
|
+
},
|
|
51
|
+
v3 = [
|
|
52
|
+
{
|
|
53
|
+
"alias": null,
|
|
54
|
+
"args": [
|
|
55
|
+
{
|
|
56
|
+
"kind": "Variable",
|
|
57
|
+
"name": "gameSlug",
|
|
58
|
+
"variableName": "gameSlug"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"kind": "Variable",
|
|
62
|
+
"name": "puzzles",
|
|
63
|
+
"variableName": "puzzles"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"kind": "Variable",
|
|
67
|
+
"name": "token",
|
|
68
|
+
"variableName": "token"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"concreteType": "McpPoolUploadResult",
|
|
72
|
+
"kind": "LinkedField",
|
|
73
|
+
"name": "addPuzzlesToPool",
|
|
74
|
+
"plural": false,
|
|
75
|
+
"selections": [
|
|
76
|
+
{
|
|
77
|
+
"alias": null,
|
|
78
|
+
"args": null,
|
|
79
|
+
"kind": "ScalarField",
|
|
80
|
+
"name": "uploadedFilenames",
|
|
81
|
+
"storageKey": null
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"alias": null,
|
|
85
|
+
"args": null,
|
|
86
|
+
"concreteType": "McpPoolUploadFailure",
|
|
87
|
+
"kind": "LinkedField",
|
|
88
|
+
"name": "failed",
|
|
89
|
+
"plural": true,
|
|
90
|
+
"selections": [
|
|
91
|
+
{
|
|
92
|
+
"alias": null,
|
|
93
|
+
"args": null,
|
|
94
|
+
"kind": "ScalarField",
|
|
95
|
+
"name": "filename",
|
|
96
|
+
"storageKey": null
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"alias": null,
|
|
100
|
+
"args": null,
|
|
101
|
+
"kind": "ScalarField",
|
|
102
|
+
"name": "message",
|
|
103
|
+
"storageKey": null
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"storageKey": null
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"alias": null,
|
|
110
|
+
"args": null,
|
|
111
|
+
"kind": "ScalarField",
|
|
112
|
+
"name": "poolCount",
|
|
113
|
+
"storageKey": null
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"storageKey": null
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
return {
|
|
120
|
+
"fragment": {
|
|
121
|
+
"argumentDefinitions": [
|
|
122
|
+
(v0/*:: as any*/),
|
|
123
|
+
(v1/*:: as any*/),
|
|
124
|
+
(v2/*:: as any*/)
|
|
125
|
+
],
|
|
126
|
+
"kind": "Fragment",
|
|
127
|
+
"metadata": null,
|
|
128
|
+
"name": "cliAddPuzzlesToPoolMutation",
|
|
129
|
+
"selections": (v3/*:: as any*/),
|
|
130
|
+
"type": "Mutation",
|
|
131
|
+
"abstractKey": null
|
|
132
|
+
},
|
|
133
|
+
"kind": "Request",
|
|
134
|
+
"operation": {
|
|
135
|
+
"argumentDefinitions": [
|
|
136
|
+
(v2/*:: as any*/),
|
|
137
|
+
(v0/*:: as any*/),
|
|
138
|
+
(v1/*:: as any*/)
|
|
139
|
+
],
|
|
140
|
+
"kind": "Operation",
|
|
141
|
+
"name": "cliAddPuzzlesToPoolMutation",
|
|
142
|
+
"selections": (v3/*:: as any*/)
|
|
143
|
+
},
|
|
144
|
+
"params": {
|
|
145
|
+
"cacheID": "a779ada059e34a22a12c7175df0e50fc",
|
|
146
|
+
"id": null,
|
|
147
|
+
"metadata": {},
|
|
148
|
+
"name": "cliAddPuzzlesToPoolMutation",
|
|
149
|
+
"operationKind": "mutation",
|
|
150
|
+
"text": "mutation cliAddPuzzlesToPoolMutation(\n $token: String!\n $gameSlug: String!\n $puzzles: [McpPuzzleFileInput!]!\n) {\n addPuzzlesToPool(token: $token, gameSlug: $gameSlug, puzzles: $puzzles) {\n uploadedFilenames\n failed {\n filename\n message\n }\n poolCount\n }\n}\n"
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
})();
|
|
154
|
+
|
|
155
|
+
(node as any).hash = "f79544fe70b713f8304a444df02b2016";
|
|
156
|
+
|
|
157
|
+
export default node;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated SignedSource<<76fc8a9b6e4d8ebe2c47a8b32617c0be>>
|
|
3
|
+
* @lightSyntaxTransform
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
|
|
10
|
+
import { ConcreteRequest } from 'relay-runtime';
|
|
11
|
+
export type cliGamesForAccessTokenQuery$variables = {
|
|
12
|
+
token: string;
|
|
13
|
+
};
|
|
14
|
+
export type cliGamesForAccessTokenQuery$data = {
|
|
15
|
+
readonly gamesForAccessToken: ReadonlyArray<{
|
|
16
|
+
readonly slug: string;
|
|
17
|
+
}> | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type cliGamesForAccessTokenQuery = {
|
|
20
|
+
response: cliGamesForAccessTokenQuery$data;
|
|
21
|
+
variables: cliGamesForAccessTokenQuery$variables;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const node: ConcreteRequest = (function(){
|
|
25
|
+
var v0 = [
|
|
26
|
+
{
|
|
27
|
+
"defaultValue": null,
|
|
28
|
+
"kind": "LocalArgument",
|
|
29
|
+
"name": "token"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
v1 = [
|
|
33
|
+
{
|
|
34
|
+
"alias": null,
|
|
35
|
+
"args": [
|
|
36
|
+
{
|
|
37
|
+
"kind": "Variable",
|
|
38
|
+
"name": "token",
|
|
39
|
+
"variableName": "token"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"concreteType": "AccessibleGame",
|
|
43
|
+
"kind": "LinkedField",
|
|
44
|
+
"name": "gamesForAccessToken",
|
|
45
|
+
"plural": true,
|
|
46
|
+
"selections": [
|
|
47
|
+
{
|
|
48
|
+
"alias": null,
|
|
49
|
+
"args": null,
|
|
50
|
+
"kind": "ScalarField",
|
|
51
|
+
"name": "slug",
|
|
52
|
+
"storageKey": null
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"storageKey": null
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
return {
|
|
59
|
+
"fragment": {
|
|
60
|
+
"argumentDefinitions": (v0/*:: as any*/),
|
|
61
|
+
"kind": "Fragment",
|
|
62
|
+
"metadata": null,
|
|
63
|
+
"name": "cliGamesForAccessTokenQuery",
|
|
64
|
+
"selections": (v1/*:: as any*/),
|
|
65
|
+
"type": "Query",
|
|
66
|
+
"abstractKey": null
|
|
67
|
+
},
|
|
68
|
+
"kind": "Request",
|
|
69
|
+
"operation": {
|
|
70
|
+
"argumentDefinitions": (v0/*:: as any*/),
|
|
71
|
+
"kind": "Operation",
|
|
72
|
+
"name": "cliGamesForAccessTokenQuery",
|
|
73
|
+
"selections": (v1/*:: as any*/)
|
|
74
|
+
},
|
|
75
|
+
"params": {
|
|
76
|
+
"cacheID": "95e52459ee4e3b5b63aebf0a956d84b9",
|
|
77
|
+
"id": null,
|
|
78
|
+
"metadata": {},
|
|
79
|
+
"name": "cliGamesForAccessTokenQuery",
|
|
80
|
+
"operationKind": "query",
|
|
81
|
+
"text": "query cliGamesForAccessTokenQuery(\n $token: String!\n) {\n gamesForAccessToken(token: $token) {\n slug\n }\n}\n"
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
})();
|
|
85
|
+
|
|
86
|
+
(node as any).hash = "5e25f82f0177e712ee4d7e9e95245d28";
|
|
87
|
+
|
|
88
|
+
export default node;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated SignedSource<<8b45a4259087b0ba56f45d09b2de210b>>
|
|
3
|
+
* @lightSyntaxTransform
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
|
|
10
|
+
import { ConcreteRequest } from 'relay-runtime';
|
|
11
|
+
export type McpPuzzleFileInput = {
|
|
12
|
+
content: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
};
|
|
15
|
+
export type cliValidatePoolPuzzlesQuery$variables = {
|
|
16
|
+
gameSlug: string;
|
|
17
|
+
puzzles: ReadonlyArray<McpPuzzleFileInput>;
|
|
18
|
+
token: string;
|
|
19
|
+
};
|
|
20
|
+
export type cliValidatePoolPuzzlesQuery$data = {
|
|
21
|
+
readonly validatePoolPuzzles: ReadonlyArray<{
|
|
22
|
+
readonly errors: ReadonlyArray<string>;
|
|
23
|
+
readonly filename: string;
|
|
24
|
+
readonly valid: boolean;
|
|
25
|
+
}> | null | undefined;
|
|
26
|
+
};
|
|
27
|
+
export type cliValidatePoolPuzzlesQuery = {
|
|
28
|
+
response: cliValidatePoolPuzzlesQuery$data;
|
|
29
|
+
variables: cliValidatePoolPuzzlesQuery$variables;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const node: ConcreteRequest = (function(){
|
|
33
|
+
var v0 = {
|
|
34
|
+
"defaultValue": null,
|
|
35
|
+
"kind": "LocalArgument",
|
|
36
|
+
"name": "gameSlug"
|
|
37
|
+
},
|
|
38
|
+
v1 = {
|
|
39
|
+
"defaultValue": null,
|
|
40
|
+
"kind": "LocalArgument",
|
|
41
|
+
"name": "puzzles"
|
|
42
|
+
},
|
|
43
|
+
v2 = {
|
|
44
|
+
"defaultValue": null,
|
|
45
|
+
"kind": "LocalArgument",
|
|
46
|
+
"name": "token"
|
|
47
|
+
},
|
|
48
|
+
v3 = [
|
|
49
|
+
{
|
|
50
|
+
"alias": null,
|
|
51
|
+
"args": [
|
|
52
|
+
{
|
|
53
|
+
"kind": "Variable",
|
|
54
|
+
"name": "gameSlug",
|
|
55
|
+
"variableName": "gameSlug"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"kind": "Variable",
|
|
59
|
+
"name": "puzzles",
|
|
60
|
+
"variableName": "puzzles"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"kind": "Variable",
|
|
64
|
+
"name": "token",
|
|
65
|
+
"variableName": "token"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"concreteType": "McpPoolPuzzleValidation",
|
|
69
|
+
"kind": "LinkedField",
|
|
70
|
+
"name": "validatePoolPuzzles",
|
|
71
|
+
"plural": true,
|
|
72
|
+
"selections": [
|
|
73
|
+
{
|
|
74
|
+
"alias": null,
|
|
75
|
+
"args": null,
|
|
76
|
+
"kind": "ScalarField",
|
|
77
|
+
"name": "filename",
|
|
78
|
+
"storageKey": null
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"alias": null,
|
|
82
|
+
"args": null,
|
|
83
|
+
"kind": "ScalarField",
|
|
84
|
+
"name": "valid",
|
|
85
|
+
"storageKey": null
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"alias": null,
|
|
89
|
+
"args": null,
|
|
90
|
+
"kind": "ScalarField",
|
|
91
|
+
"name": "errors",
|
|
92
|
+
"storageKey": null
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"storageKey": null
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
return {
|
|
99
|
+
"fragment": {
|
|
100
|
+
"argumentDefinitions": [
|
|
101
|
+
(v0/*:: as any*/),
|
|
102
|
+
(v1/*:: as any*/),
|
|
103
|
+
(v2/*:: as any*/)
|
|
104
|
+
],
|
|
105
|
+
"kind": "Fragment",
|
|
106
|
+
"metadata": null,
|
|
107
|
+
"name": "cliValidatePoolPuzzlesQuery",
|
|
108
|
+
"selections": (v3/*:: as any*/),
|
|
109
|
+
"type": "Query",
|
|
110
|
+
"abstractKey": null
|
|
111
|
+
},
|
|
112
|
+
"kind": "Request",
|
|
113
|
+
"operation": {
|
|
114
|
+
"argumentDefinitions": [
|
|
115
|
+
(v2/*:: as any*/),
|
|
116
|
+
(v0/*:: as any*/),
|
|
117
|
+
(v1/*:: as any*/)
|
|
118
|
+
],
|
|
119
|
+
"kind": "Operation",
|
|
120
|
+
"name": "cliValidatePoolPuzzlesQuery",
|
|
121
|
+
"selections": (v3/*:: as any*/)
|
|
122
|
+
},
|
|
123
|
+
"params": {
|
|
124
|
+
"cacheID": "934ec64898f9b820ebc69f223fd50cc5",
|
|
125
|
+
"id": null,
|
|
126
|
+
"metadata": {},
|
|
127
|
+
"name": "cliValidatePoolPuzzlesQuery",
|
|
128
|
+
"operationKind": "query",
|
|
129
|
+
"text": "query cliValidatePoolPuzzlesQuery(\n $token: String!\n $gameSlug: String!\n $puzzles: [McpPuzzleFileInput!]!\n) {\n validatePoolPuzzles(token: $token, gameSlug: $gameSlug, puzzles: $puzzles) {\n filename\n valid\n errors\n }\n}\n"
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
})();
|
|
133
|
+
|
|
134
|
+
(node as any).hash = "08673f877fe016f880516c4a9fdcf03d";
|
|
135
|
+
|
|
136
|
+
export default node;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { graphql, query } from "../util/belay.js"
|
|
2
|
+
import type { cliAddPuzzlesToPoolMutation } from "./__generated__/cliAddPuzzlesToPoolMutation.graphql.js"
|
|
3
|
+
import type { cliGamesForAccessTokenQuery } from "./__generated__/cliGamesForAccessTokenQuery.graphql.js"
|
|
4
|
+
import type { cliValidatePoolPuzzlesQuery } from "./__generated__/cliValidatePoolPuzzlesQuery.graphql.js"
|
|
5
|
+
|
|
6
|
+
const gamesForAccessTokenQuery = graphql`
|
|
7
|
+
query cliGamesForAccessTokenQuery($token: String!) {
|
|
8
|
+
gamesForAccessToken(token: $token) {
|
|
9
|
+
slug
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
const validatePoolPuzzlesQuery = graphql`
|
|
15
|
+
query cliValidatePoolPuzzlesQuery($token: String!, $gameSlug: String!, $puzzles: [McpPuzzleFileInput!]!) {
|
|
16
|
+
validatePoolPuzzles(token: $token, gameSlug: $gameSlug, puzzles: $puzzles) {
|
|
17
|
+
filename
|
|
18
|
+
valid
|
|
19
|
+
errors
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`
|
|
23
|
+
|
|
24
|
+
const addPuzzlesToPoolMutation = graphql`
|
|
25
|
+
mutation cliAddPuzzlesToPoolMutation($token: String!, $gameSlug: String!, $puzzles: [McpPuzzleFileInput!]!) {
|
|
26
|
+
addPuzzlesToPool(token: $token, gameSlug: $gameSlug, puzzles: $puzzles) {
|
|
27
|
+
uploadedFilenames
|
|
28
|
+
failed {
|
|
29
|
+
filename
|
|
30
|
+
message
|
|
31
|
+
}
|
|
32
|
+
poolCount
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
export type PuzzleFile = { filename: string; content: string }
|
|
38
|
+
|
|
39
|
+
/** The slugs of the games a token can manage, or null when the server rejects the token. */
|
|
40
|
+
export const fetchGameSlugsForToken = async (apiURL: string, token: string): Promise<string[] | null> => {
|
|
41
|
+
const { data } = await query<cliGamesForAccessTokenQuery>(gamesForAccessTokenQuery, { variables: { token }, url: `${apiURL}/graphql` })
|
|
42
|
+
return data?.gamesForAccessToken?.map((g) => g.slug) ?? null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Checks puzzle files against the game's pool rules without uploading them. */
|
|
46
|
+
export const validatePoolPuzzles = async (apiURL: string, token: string, gameSlug: string, puzzles: PuzzleFile[]) => {
|
|
47
|
+
const { data, errors } = await query<cliValidatePoolPuzzlesQuery>(validatePoolPuzzlesQuery, {
|
|
48
|
+
variables: { token, gameSlug, puzzles },
|
|
49
|
+
url: `${apiURL}/graphql`,
|
|
50
|
+
})
|
|
51
|
+
if (errors?.length) throw new Error(errors.map((e) => e.message).join("; "))
|
|
52
|
+
if (!data?.validatePoolPuzzles) throw new Error(`No game named "${gameSlug}" is accessible with that token.`)
|
|
53
|
+
return data.validatePoolPuzzles
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Adds puzzle files to the end of the game's pool; invalid files come back in `failed`. */
|
|
57
|
+
export const addPuzzlesToPool = async (apiURL: string, token: string, gameSlug: string, puzzles: PuzzleFile[]) => {
|
|
58
|
+
const { data, errors } = await query<cliAddPuzzlesToPoolMutation>(addPuzzlesToPoolMutation, {
|
|
59
|
+
variables: { token, gameSlug, puzzles },
|
|
60
|
+
url: `${apiURL}/graphql`,
|
|
61
|
+
})
|
|
62
|
+
if (errors?.length) throw new Error(errors.map((e) => e.message).join("; "))
|
|
63
|
+
if (!data?.addPuzzlesToPool) throw new Error(`No game named "${gameSlug}" is accessible with that token.`)
|
|
64
|
+
return data.addPuzzlesToPool
|
|
65
|
+
}
|
package/src/util/api.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type PuzzmoFile = {
|
|
|
13
13
|
description?: string
|
|
14
14
|
highlightColor?: string
|
|
15
15
|
iconPath?: string
|
|
16
|
+
helpPath?: string
|
|
16
17
|
}
|
|
17
18
|
// This is what we're calling 'augmentations' publicly
|
|
18
19
|
integrations?: Record<string, unknown>
|
|
@@ -39,6 +40,7 @@ type InitResponse = {
|
|
|
39
40
|
basePath: string
|
|
40
41
|
integrationsChanged?: boolean
|
|
41
42
|
iconChanged?: boolean
|
|
43
|
+
helpChanged?: boolean
|
|
42
44
|
gameURL?: string
|
|
43
45
|
versionsURL?: string
|
|
44
46
|
error?: string
|
|
@@ -49,6 +51,7 @@ type CompleteResponse = {
|
|
|
49
51
|
versionID: string
|
|
50
52
|
integrationsChanged: boolean
|
|
51
53
|
iconChanged: boolean
|
|
54
|
+
helpChanged: boolean
|
|
52
55
|
gameURL: string | null
|
|
53
56
|
versionsURL: string | null
|
|
54
57
|
error?: string
|
|
@@ -66,6 +69,8 @@ export type UploadFilesOptions = {
|
|
|
66
69
|
repoURL?: string | null
|
|
67
70
|
/** Contents of the SVG named by `game.iconPath`, synced onto the game */
|
|
68
71
|
iconSVG?: string | null
|
|
72
|
+
/** Contents of the Markdown named by `game.helpPath`, synced onto the game's in-game help */
|
|
73
|
+
helpMD?: string | null
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
/** Wraps fetch to surface the underlying network cause (DNS, ECONNREFUSED, TLS, etc.) */
|
|
@@ -170,7 +175,7 @@ export const uploadFiles = async (
|
|
|
170
175
|
onProgress?: UploadProgress,
|
|
171
176
|
options: UploadFilesOptions = {},
|
|
172
177
|
): Promise<CompleteResponse> => {
|
|
173
|
-
const { verbose = false, description, repoURL, iconSVG } = options
|
|
178
|
+
const { verbose = false, description, repoURL, iconSVG, helpMD } = options
|
|
174
179
|
if (verbose) console.log(` API URL: ${apiURL}`)
|
|
175
180
|
|
|
176
181
|
// Step 1: Init session (includes puzzmo.json metadata)
|
|
@@ -179,7 +184,7 @@ export const uploadFiles = async (
|
|
|
179
184
|
init = (await jsonPost(
|
|
180
185
|
`${apiURL}/cliUpload`,
|
|
181
186
|
token,
|
|
182
|
-
{ gameSlug, sha, puzzmoFile, description, repoURL, iconSVG },
|
|
187
|
+
{ gameSlug, sha, puzzmoFile, description, repoURL, iconSVG, helpMD },
|
|
183
188
|
"upload init",
|
|
184
189
|
verbose,
|
|
185
190
|
)) as InitResponse
|
|
@@ -204,13 +209,14 @@ export const uploadFiles = async (
|
|
|
204
209
|
// Step 3: Complete
|
|
205
210
|
const complete = (await jsonPost(`${apiURL}/cliUpload/${init.sessionID}/complete`, token, {}, "upload complete", verbose)) as Omit<
|
|
206
211
|
CompleteResponse,
|
|
207
|
-
"integrationsChanged" | "iconChanged" | "gameURL" | "versionsURL"
|
|
212
|
+
"integrationsChanged" | "iconChanged" | "helpChanged" | "gameURL" | "versionsURL"
|
|
208
213
|
>
|
|
209
214
|
if (verbose) console.log(` Assets base: ${complete.assetsBase}`)
|
|
210
215
|
return {
|
|
211
216
|
...complete,
|
|
212
217
|
integrationsChanged: !!init.integrationsChanged,
|
|
213
218
|
iconChanged: !!init.iconChanged,
|
|
219
|
+
helpChanged: !!init.helpChanged,
|
|
214
220
|
gameURL: init.gameURL ?? null,
|
|
215
221
|
versionsURL: init.versionsURL ?? null,
|
|
216
222
|
}
|
|
@@ -27,6 +27,8 @@ export type DiscoveredGame = {
|
|
|
27
27
|
distDir: string
|
|
28
28
|
/** Absolute path to the icon SVG named by `game.iconPath`, or null when the file sets no icon */
|
|
29
29
|
iconPath: string | null
|
|
30
|
+
/** Absolute path to the help Markdown named by `game.helpPath`, or null when the file sets no help */
|
|
31
|
+
helpPath: string | null
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/** A puzzmo.json that was found but could not be used (invalid JSON, schema errors, missing dist) */
|
|
@@ -46,13 +48,16 @@ export type DiscoveryResult = {
|
|
|
46
48
|
export type DiscoverOptions = {
|
|
47
49
|
/** Require each game to have a non-empty dist folder (default true). Set false for commands that run before a build. */
|
|
48
50
|
requireDist?: boolean
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Require `game.iconPath` and `game.helpPath` to point at files (default true). Set false for commands that only read puzzmo.json
|
|
53
|
+
* metadata.
|
|
54
|
+
*/
|
|
55
|
+
requireLinkedFiles?: boolean
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
/** Walks `rootDir` looking for puzzmo.json files, validates each, and resolves their dist directory */
|
|
54
59
|
export const discoverGames = async (rootDir: string, options: DiscoverOptions = {}): Promise<DiscoveryResult> => {
|
|
55
|
-
const { requireDist = true,
|
|
60
|
+
const { requireDist = true, requireLinkedFiles = true } = options
|
|
56
61
|
const root = path.resolve(rootDir)
|
|
57
62
|
const puzzmoJsonPaths = findPuzzmoJsonFiles(root)
|
|
58
63
|
|
|
@@ -80,11 +85,15 @@ export const discoverGames = async (rootDir: string, options: DiscoverOptions =
|
|
|
80
85
|
const puzzmoJsonDir = path.dirname(puzzmoJsonPath)
|
|
81
86
|
const distDir = resolveDistDir(puzzmoFile, puzzmoJsonDir, root)
|
|
82
87
|
|
|
83
|
-
// The icon
|
|
88
|
+
// The icon and help are checked here rather than at upload time so `validate` catches a stale path too.
|
|
84
89
|
const iconPath = puzzmoFile.game.iconPath ? path.resolve(puzzmoJsonDir, puzzmoFile.game.iconPath) : null
|
|
85
|
-
if (
|
|
90
|
+
if (requireLinkedFiles && iconPath && !isFile(iconPath))
|
|
86
91
|
fileErrors.push(`Icon file not found for ${puzzmoFile.game.slug}: "${puzzmoFile.game.iconPath}" (${iconPath}) does not exist.`)
|
|
87
92
|
|
|
93
|
+
const helpPath = puzzmoFile.game.helpPath ? path.resolve(puzzmoJsonDir, puzzmoFile.game.helpPath) : null
|
|
94
|
+
if (requireLinkedFiles && helpPath && !isFile(helpPath))
|
|
95
|
+
fileErrors.push(`Help file not found for ${puzzmoFile.game.slug}: "${puzzmoFile.game.helpPath}" (${helpPath}) does not exist.`)
|
|
96
|
+
|
|
88
97
|
if (requireDist) {
|
|
89
98
|
if (!distDir) {
|
|
90
99
|
// output.dir set but missing usually means "not built yet", which the generic message hides.
|
|
@@ -104,7 +113,7 @@ export const discoverGames = async (rootDir: string, options: DiscoverOptions =
|
|
|
104
113
|
continue
|
|
105
114
|
}
|
|
106
115
|
|
|
107
|
-
games.push({ puzzmoJsonPath, puzzmoJsonDir, puzzmoFile, distDir: distDir ?? "", iconPath })
|
|
116
|
+
games.push({ puzzmoJsonPath, puzzmoJsonDir, puzzmoFile, distDir: distDir ?? "", iconPath, helpPath })
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
return { games, errors }
|