@puzzmo/cli 1.0.77 → 1.0.79
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/lib/commands/changed.js +2 -2
- package/lib/commands/changed.js.map +1 -1
- package/lib/commands/game/create.js +46 -18
- package/lib/commands/game/create.js.map +1 -1
- package/lib/commands/login.d.ts +2 -2
- package/lib/commands/login.js +17 -7
- package/lib/commands/login.js.map +1 -1
- package/lib/commands/upload.js +14 -3
- package/lib/commands/upload.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/queries/__generated__/cliTeamForTokenQuery.graphql.d.ts +19 -0
- package/lib/queries/__generated__/cliTeamForTokenQuery.graphql.js +87 -0
- package/lib/queries/__generated__/cliTeamForTokenQuery.graphql.js.map +1 -0
- package/lib/queries/teamForToken.d.ts +2 -0
- package/lib/queries/teamForToken.js +19 -0
- package/lib/queries/teamForToken.js.map +1 -0
- package/lib/util/config.d.ts +7 -1
- package/lib/util/config.js +6 -2
- package/lib/util/config.js.map +1 -1
- package/lib/util/validatePuzzmoFile.js +1 -1
- package/lib/util/validatePuzzmoFile.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/changed.ts +2 -2
- package/src/commands/game/create.ts +49 -19
- package/src/commands/login.ts +17 -7
- package/src/commands/upload.ts +15 -2
- package/src/index.ts +2 -2
- package/src/queries/__generated__/cliTeamForTokenQuery.graphql.ts +109 -0
- package/src/queries/teamForToken.ts +21 -0
- package/src/util/config.ts +10 -2
- package/src/util/validatePuzzmoFile.ts +1 -1
- package/templates/minesweeper/README.md +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { graphql, query } from "../util/belay.js";
|
|
2
|
+
const teamForTokenQuery = graphql `
|
|
3
|
+
query cliTeamForTokenQuery($token: String!) {
|
|
4
|
+
teamForToken(token: $token) {
|
|
5
|
+
name
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
9
|
+
/** Looks up the display name of the team a token belongs to; throws if the server rejects the token. */
|
|
10
|
+
export const fetchTeamName = async (apiURL, token) => {
|
|
11
|
+
const { data, errors } = await query(teamForTokenQuery, {
|
|
12
|
+
variables: { token },
|
|
13
|
+
url: `${apiURL}/graphql`,
|
|
14
|
+
});
|
|
15
|
+
if (errors?.length)
|
|
16
|
+
throw new Error(errors.map((e) => e.message).join("; "));
|
|
17
|
+
return data?.teamForToken?.name ?? null;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=teamForToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamForToken.js","sourceRoot":"","sources":["../../src/queries/teamForToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAGjD,MAAM,iBAAiB,GAAG,OAAO,CAAA;;;;;;CAMhC,CAAA;AAED,wGAAwG;AACxG,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAE,KAAa,EAA0B,EAAE;IAC3F,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAuB,iBAAiB,EAAE;QAC5E,SAAS,EAAE,EAAE,KAAK,EAAE;QACpB,GAAG,EAAE,GAAG,MAAM,UAAU;KACzB,CAAC,CAAA;IAEF,IAAI,MAAM,EAAE,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC5E,OAAO,IAAI,EAAE,YAAY,EAAE,IAAI,IAAI,IAAI,CAAA;AACzC,CAAC,CAAA"}
|
package/lib/util/config.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export declare const defaultSource = "https://api.puzzmo.com";
|
|
2
|
+
/** The Workshop: where teams manage their games and mint CLI tokens */
|
|
3
|
+
export declare const workshopURL = "https://workshop.puzzmo.com";
|
|
4
|
+
/** Where tokens come from. Appended to any message about a missing, unusable or wrong-team token. */
|
|
5
|
+
export declare const tokenHelp = "Tokens live in the Workshop at https://workshop.puzzmo.com/dashboard \u2014 open your team, then Settings \u2192 Access Tokens.";
|
|
2
6
|
export type TokenEntry = {
|
|
3
7
|
/** Server identifier (e.g. "api.puzzmo.com" or "localhost:8911") */
|
|
4
8
|
source: string;
|
|
5
9
|
/** The pzt- prefixed JWT issued by that server */
|
|
6
10
|
token: string;
|
|
11
|
+
/** The team's display name, looked up at login. Absent for env var tokens or when the lookup failed. */
|
|
12
|
+
teamName?: string;
|
|
7
13
|
};
|
|
8
14
|
type Config = {
|
|
9
15
|
tokens: TokenEntry[];
|
|
@@ -11,7 +17,7 @@ type Config = {
|
|
|
11
17
|
/** Reads ~/.puzzmo/config.json. Returns an empty token list if the file doesn't exist. */
|
|
12
18
|
export declare const readConfig: () => Config;
|
|
13
19
|
/** Saves a token for `source`, replacing any existing entry for that same source */
|
|
14
|
-
export declare const addToken: (source: string, token: string) => void;
|
|
20
|
+
export declare const addToken: (source: string, token: string, teamName?: string) => void;
|
|
15
21
|
/** Removes any saved token for `source`. Returns true if something was removed. */
|
|
16
22
|
export declare const removeToken: (source: string) => boolean;
|
|
17
23
|
/**
|
package/lib/util/config.js
CHANGED
|
@@ -4,6 +4,10 @@ import path from "node:path";
|
|
|
4
4
|
const configDir = path.join(os.homedir(), ".puzzmo");
|
|
5
5
|
const configPath = path.join(configDir, "config.json");
|
|
6
6
|
export const defaultSource = "https://api.puzzmo.com";
|
|
7
|
+
/** The Workshop: where teams manage their games and mint CLI tokens */
|
|
8
|
+
export const workshopURL = "https://workshop.puzzmo.com";
|
|
9
|
+
/** Where tokens come from. Appended to any message about a missing, unusable or wrong-team token. */
|
|
10
|
+
export const tokenHelp = `Tokens live in the Workshop at ${workshopURL}/dashboard — open your team, then Settings → Access Tokens.`;
|
|
7
11
|
/** Reads ~/.puzzmo/config.json. Returns an empty token list if the file doesn't exist. */
|
|
8
12
|
export const readConfig = () => {
|
|
9
13
|
try {
|
|
@@ -19,11 +23,11 @@ const writeConfig = (config) => {
|
|
|
19
23
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
20
24
|
};
|
|
21
25
|
/** Saves a token for `source`, replacing any existing entry for that same source */
|
|
22
|
-
export const addToken = (source, token) => {
|
|
26
|
+
export const addToken = (source, token, teamName) => {
|
|
23
27
|
const normalized = normalizeSource(source);
|
|
24
28
|
const { tokens } = readConfig();
|
|
25
29
|
const remaining = tokens.filter((t) => normalizeSource(t.source) !== normalized);
|
|
26
|
-
remaining.push({ source: normalized, token });
|
|
30
|
+
remaining.push({ source: normalized, token, ...(teamName ? { teamName } : {}) });
|
|
27
31
|
writeConfig({ tokens: remaining });
|
|
28
32
|
};
|
|
29
33
|
/** Removes any saved token for `source`. Returns true if something was removed. */
|
package/lib/util/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/util/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;AACpD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/util/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,SAAS,GAAG,IAAI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AAA;IACrC,KAAK,MAAM,SAAS,IAAI,OAAO,EAAE,CAAC;QAChC,IAAI,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAAE,SAAQ;QAC3F,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Validator } from "@cfworker/json-schema";
|
|
2
|
-
const schemaURL = "https://dev-dj9e.onrender.com/schema/puzzmo-file-schema.json"; //"https://
|
|
2
|
+
const schemaURL = "https://dev-dj9e.onrender.com/schema/puzzmo-file-schema.json"; //"https://workshop.puzzmo.com/schema/puzzmo-file-schema.json"
|
|
3
3
|
let cachedValidator;
|
|
4
4
|
/** Fetches and caches a JSON schema validator for puzzmo.json files */
|
|
5
5
|
const getValidator = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePuzzmoFile.js","sourceRoot":"","sources":["../../src/util/validatePuzzmoFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,uBAAuB,CAAA;AAI9D,MAAM,SAAS,GAAG,8DAA8D,CAAA,CAAC,
|
|
1
|
+
{"version":3,"file":"validatePuzzmoFile.js","sourceRoot":"","sources":["../../src/util/validatePuzzmoFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,uBAAuB,CAAA;AAI9D,MAAM,SAAS,GAAG,8DAA8D,CAAA,CAAC,8DAA8D;AAE/I,IAAI,eAAsC,CAAA;AAE1C,uEAAuE;AACvE,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;IAC9B,IAAI,eAAe;QAAE,OAAO,eAAe,CAAA;IAC3C,IAAI,GAAa,CAAA;IACjB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAA;IAC9B,CA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AAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAwB,EAAE,CAAA;IACxE,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,MAAM,CAAC,MAAM;aAClB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;aAClF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,gBAAgB,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;KACnD,CAAA;AACH,CAAC,CAAA;AAED,gGAAgG;AAChG,MAAM,mBAAmB,GAAG,CAAC,IAAa,EAAW,EAAE;IACrD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACzE,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACrC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,IAA+B,CAAA;IAC/D,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
package/package.json
CHANGED
package/src/commands/changed.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { execFileSync } from "node:child_process"
|
|
|
2
2
|
import fs from "node:fs"
|
|
3
3
|
import path from "node:path"
|
|
4
4
|
|
|
5
|
-
import { findTokensForTeam, getTokens, resolveServerForTeam, sourceToURL } from "../util/config.js"
|
|
5
|
+
import { findTokensForTeam, getTokens, resolveServerForTeam, sourceToURL, tokenHelp } from "../util/config.js"
|
|
6
6
|
import { type DiscoveredGame, discoverGames } from "../util/discoverGames.js"
|
|
7
7
|
import { fetchTeamGameVersions, type GameVersions } from "../queries/gameRuntimes.js"
|
|
8
8
|
|
|
@@ -40,7 +40,7 @@ export const changed = async (dir: string, options: ChangedOptions = {}) => {
|
|
|
40
40
|
const { json = false, list = false, matrix = false, against = "latest", includeUncommitted = false } = options
|
|
41
41
|
|
|
42
42
|
if (getTokens().length === 0) {
|
|
43
|
-
console.error(
|
|
43
|
+
console.error(`Not logged in. Run \`puzzmo login <token>\` or set PUZZMO_TOKEN.\n${tokenHelp}`)
|
|
44
44
|
process.exit(1)
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -14,7 +14,7 @@ import { newSession, type PipelineContext } from "../../skills/step.js"
|
|
|
14
14
|
import { importPipeline, optionalPromptSkills, type SkillDefinition } from "../../skills/registry.js"
|
|
15
15
|
import { seedImportedGame, importedSourceDir, referenceDir } from "./seedImport.js"
|
|
16
16
|
import { login } from "../login.js"
|
|
17
|
-
import { getDefaultToken } from "../../util/config.js"
|
|
17
|
+
import { decodeTokenPayload, getDefaultToken, getTokens, tokenHelp, type TokenEntry } from "../../util/config.js"
|
|
18
18
|
import { slugify } from "../../util/slugify.js"
|
|
19
19
|
import { detectRepoContext, type RepoContext, type RepoType } from "./detectRepo.js"
|
|
20
20
|
|
|
@@ -32,14 +32,14 @@ export type CreateOptions = {
|
|
|
32
32
|
prompt?: string
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/** Writes .mcp.json with dev server config */
|
|
36
|
-
const writeMcpConfig = (dir: string) => {
|
|
37
|
-
const token = getDefaultToken()
|
|
35
|
+
/** Writes .mcp.json with dev server config, authed as the game's team when we have its token */
|
|
36
|
+
const writeMcpConfig = (dir: string, teamToken: string | undefined) => {
|
|
37
|
+
const token = teamToken ?? getDefaultToken()
|
|
38
38
|
const mcpConfig = {
|
|
39
39
|
mcpServers: {
|
|
40
|
-
"
|
|
40
|
+
"workshop.puzzmo.com": {
|
|
41
41
|
type: "http",
|
|
42
|
-
url: "https://
|
|
42
|
+
url: "https://workshop.puzzmo.com/api/mcp",
|
|
43
43
|
headers: token ? { Authorization: `Bearer ${token}` } : undefined,
|
|
44
44
|
},
|
|
45
45
|
},
|
|
@@ -48,9 +48,9 @@ const writeMcpConfig = (dir: string) => {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** Sets up a standalone new repo for the game */
|
|
51
|
-
const setupNewRepo = (gameDir: string) => {
|
|
51
|
+
const setupNewRepo = (gameDir: string, teamToken: string | undefined) => {
|
|
52
52
|
fs.writeFileSync(path.join(gameDir, ".gitignore"), ["node_modules", "dist", ".DS_Store", ".yarn", ".pnp.*", ".puzzmo", ""].join("\n"))
|
|
53
|
-
writeMcpConfig(gameDir)
|
|
53
|
+
writeMcpConfig(gameDir, teamToken)
|
|
54
54
|
|
|
55
55
|
if (!fs.existsSync(path.join(gameDir, ".git"))) {
|
|
56
56
|
runCommand("git init", { cwd: gameDir })
|
|
@@ -60,7 +60,7 @@ const setupNewRepo = (gameDir: string) => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/** Places a game inside an existing repo's parent folder (games/, packages/, etc.) */
|
|
63
|
-
const setupRepoGame = (tmpDir: string, slug: string, repoRoot: string, parentFolder: string): string => {
|
|
63
|
+
const setupRepoGame = (tmpDir: string, slug: string, repoRoot: string, parentFolder: string, teamToken: string | undefined): string => {
|
|
64
64
|
const parentDir = path.join(repoRoot, parentFolder)
|
|
65
65
|
if (!fs.existsSync(parentDir)) fs.mkdirSync(parentDir, { recursive: true })
|
|
66
66
|
|
|
@@ -70,7 +70,7 @@ const setupRepoGame = (tmpDir: string, slug: string, repoRoot: string, parentFol
|
|
|
70
70
|
|
|
71
71
|
// Write .mcp.json at repo root if not already present
|
|
72
72
|
const mcpPath = path.join(repoRoot, ".mcp.json")
|
|
73
|
-
if (!fs.existsSync(mcpPath)) writeMcpConfig(repoRoot)
|
|
73
|
+
if (!fs.existsSync(mcpPath)) writeMcpConfig(repoRoot, teamToken)
|
|
74
74
|
|
|
75
75
|
runCommand("git add -A", { cwd: repoRoot })
|
|
76
76
|
gitCommit(`New game: ${slug}`, { cwd: repoRoot })
|
|
@@ -352,6 +352,13 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
352
352
|
|
|
353
353
|
const slug = opts.slug ?? slugify(name)
|
|
354
354
|
|
|
355
|
+
// Step 5: Login if token provided, then pick the team the game belongs to
|
|
356
|
+
if (opts.accessToken) {
|
|
357
|
+
p.log.step("Logging in...")
|
|
358
|
+
await login(opts.accessToken)
|
|
359
|
+
}
|
|
360
|
+
const team = await pickTeam(opts.teamID)
|
|
361
|
+
|
|
355
362
|
// Materialize the starter (after we know the slug/name). Imports get it too — porting a
|
|
356
363
|
// downloaded game into a project that already builds beats rebuilding the project by hand.
|
|
357
364
|
const templateDir = resolveTemplateDir("minesweeper")
|
|
@@ -362,7 +369,7 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
362
369
|
const replacements = {
|
|
363
370
|
__SLUG__: slug,
|
|
364
371
|
__DISPLAY_NAME__: name,
|
|
365
|
-
__TEAM_ID__:
|
|
372
|
+
__TEAM_ID__: team?.teamID ?? "REPLACE_ME",
|
|
366
373
|
// Prettier rewrites __DISPLAY_NAME__ to bold syntax in markdown, so match that form too.
|
|
367
374
|
"**DISPLAY_NAME**": name,
|
|
368
375
|
}
|
|
@@ -370,12 +377,6 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
370
377
|
if (strategy === "import") seedImportedGame(tmpDir, templateDir, materialize)
|
|
371
378
|
else materialize(templateDir, tmpDir)
|
|
372
379
|
|
|
373
|
-
// Step 5: Login if token provided
|
|
374
|
-
if (opts.accessToken) {
|
|
375
|
-
p.log.step("Logging in...")
|
|
376
|
-
login(opts.accessToken)
|
|
377
|
-
}
|
|
378
|
-
|
|
379
380
|
// Step 6: Place files
|
|
380
381
|
let gameDir: string
|
|
381
382
|
let repoType: RepoType = repo.repoType
|
|
@@ -384,7 +385,7 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
384
385
|
gameDir = path.resolve(slug)
|
|
385
386
|
if (fs.existsSync(gameDir)) fs.rmSync(gameDir, { recursive: true })
|
|
386
387
|
fs.renameSync(tmpDir, gameDir)
|
|
387
|
-
setupNewRepo(gameDir)
|
|
388
|
+
setupNewRepo(gameDir, team?.token)
|
|
388
389
|
repoType = "standalone"
|
|
389
390
|
} else {
|
|
390
391
|
if (!repo.repoRoot) {
|
|
@@ -418,7 +419,7 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
418
419
|
}
|
|
419
420
|
}
|
|
420
421
|
|
|
421
|
-
gameDir = setupRepoGame(tmpDir, slug, repo.repoRoot, parentFolder)
|
|
422
|
+
gameDir = setupRepoGame(tmpDir, slug, repo.repoRoot, parentFolder, team?.token)
|
|
422
423
|
}
|
|
423
424
|
|
|
424
425
|
// Step 7: Strategy-specific agent work
|
|
@@ -486,3 +487,32 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
486
487
|
/** `--pm` arrives as a plain string; anything unexpected falls back to the repo's own manager */
|
|
487
488
|
const packageManagerFrom = (value: string | undefined, fallback: PackageManagerName): PackageManagerName =>
|
|
488
489
|
value === "npm" || value === "yarn" || value === "pnpm" ? value : fallback
|
|
490
|
+
|
|
491
|
+
type TeamChoice = { teamID: string; token?: string }
|
|
492
|
+
|
|
493
|
+
/** Resolves the game's team: --teamID if given, else the only saved team, else a prompt across saved teams */
|
|
494
|
+
const pickTeam = async (teamID: string | undefined): Promise<TeamChoice | null> => {
|
|
495
|
+
const teams = new Map<string, TokenEntry>()
|
|
496
|
+
for (const entry of getTokens()) {
|
|
497
|
+
const entryTeamID = decodeTokenPayload(entry.token)?.teamID
|
|
498
|
+
if (entryTeamID && !teams.has(entryTeamID)) teams.set(entryTeamID, entry)
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (teamID) return { teamID, token: teams.get(teamID)?.token }
|
|
502
|
+
if (teams.size === 0) {
|
|
503
|
+
p.log.warn(`Not logged in, so puzzmo.json gets a placeholder teamID you'll need to fill in.\n${tokenHelp}`)
|
|
504
|
+
return null
|
|
505
|
+
}
|
|
506
|
+
if (teams.size === 1) {
|
|
507
|
+
const [[onlyTeamID, entry]] = teams
|
|
508
|
+
p.log.info(`Creating the game for team ${entry.teamName ?? onlyTeamID}.`)
|
|
509
|
+
return { teamID: onlyTeamID, token: entry.token }
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const selected = await p.select({
|
|
513
|
+
message: "Which team is this game for?",
|
|
514
|
+
options: [...teams].map(([id, entry]) => ({ value: id, label: entry.teamName ?? id, hint: `${id} on ${entry.source}` })),
|
|
515
|
+
})
|
|
516
|
+
if (p.isCancel(selected)) process.exit(0)
|
|
517
|
+
return { teamID: selected, token: teams.get(selected)?.token }
|
|
518
|
+
}
|
package/src/commands/login.ts
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import * as p from "@clack/prompts"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { fetchTeamName } from "../queries/teamForToken.js"
|
|
4
|
+
import { defaultSource, addToken, decodeTokenPayload, normalizeSource, sourceToURL, tokenHelp } from "../util/config.js"
|
|
4
5
|
|
|
5
|
-
/** Saves a CLI token to ~/.puzzmo/config.json under the given source server */
|
|
6
|
-
export const login = (token: string, source: string = defaultSource) => {
|
|
6
|
+
/** Saves a CLI token to ~/.puzzmo/config.json under the given source server, along with its team's name */
|
|
7
|
+
export const login = async (token: string, source: string = defaultSource) => {
|
|
7
8
|
if (!token.startsWith("pzt-")) {
|
|
8
|
-
p.log.error(
|
|
9
|
+
p.log.error(`Invalid CLI token — they start with "pzt-".\n${tokenHelp}`)
|
|
9
10
|
process.exit(1)
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const payload = decodeTokenPayload(token)
|
|
13
14
|
if (!payload?.teamID) {
|
|
14
|
-
p.log.error(
|
|
15
|
+
p.log.error(`Could not decode the team from this token, so it is not a Workshop access token.\n${tokenHelp}`)
|
|
15
16
|
process.exit(1)
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const normalized = normalizeSource(source)
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
// Only a nicety for later messages, so the token is still saved when the server can't be asked
|
|
21
|
+
let teamName: string | null = null
|
|
22
|
+
try {
|
|
23
|
+
teamName = await fetchTeamName(sourceToURL(normalized), token)
|
|
24
|
+
} catch (e) {
|
|
25
|
+
p.log.warn(`Could not look up the team name on ${normalized}: ${e instanceof Error ? e.message : String(e)}`)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
addToken(normalized, token, teamName ?? undefined)
|
|
29
|
+
const team = teamName ? `${teamName} (${payload.teamID})` : payload.teamID
|
|
30
|
+
p.log.success(`Logged in to ${normalized} for team ${team}. Token saved to ~/.puzzmo/config.json`)
|
|
21
31
|
}
|
package/src/commands/upload.ts
CHANGED
|
@@ -6,12 +6,14 @@ import * as p from "@clack/prompts"
|
|
|
6
6
|
|
|
7
7
|
import { GameNotFoundError, uploadFiles } from "../util/api.js"
|
|
8
8
|
import {
|
|
9
|
+
decodeTokenPayload,
|
|
9
10
|
defaultSource,
|
|
10
11
|
findTokensForTeam,
|
|
11
12
|
getTokens,
|
|
12
13
|
normalizeSource,
|
|
13
14
|
resolveServerForTeam,
|
|
14
15
|
sourceToURL,
|
|
16
|
+
tokenHelp,
|
|
15
17
|
type TokenEntry,
|
|
16
18
|
} from "../util/config.js"
|
|
17
19
|
import { createUserGame } from "../util/createGame.js"
|
|
@@ -54,7 +56,7 @@ export const upload = async (dir: string, options: UploadOptions = {}) => {
|
|
|
54
56
|
const autoCreate = options.createMissing ?? false
|
|
55
57
|
|
|
56
58
|
if (getTokens().length === 0) {
|
|
57
|
-
console.error(
|
|
59
|
+
console.error(`Not logged in. Run \`puzzmo login <token>\` or set PUZZMO_TOKEN.\n${tokenHelp}`)
|
|
58
60
|
process.exit(1)
|
|
59
61
|
}
|
|
60
62
|
|
|
@@ -111,7 +113,7 @@ export const upload = async (dir: string, options: UploadOptions = {}) => {
|
|
|
111
113
|
const matches = findTokensForTeam(teamID)
|
|
112
114
|
const message =
|
|
113
115
|
matches.length === 0
|
|
114
|
-
? `No saved token for team ${teamID}. Run \`puzzmo login <token>\` (use \`--source\` if the token is for a non-default server)
|
|
116
|
+
? `No saved token for team ${teamID}. Run \`puzzmo login <token>\` (use \`--source\` if the token is for a non-default server).\n${describeSavedTeams()}`
|
|
115
117
|
: `Token for team ${teamID} is registered against ${matches.map((m) => m.source).join(", ")} but none of those servers are reachable.`
|
|
116
118
|
console.error(`\n${prefix}Uploading ${slug} from ${distLabel}\n ${message}`)
|
|
117
119
|
results.push({ ok: false, slug, error: message })
|
|
@@ -417,3 +419,14 @@ const formatBytes = (bytes: number): string => {
|
|
|
417
419
|
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
|
|
418
420
|
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
|
|
419
421
|
}
|
|
422
|
+
|
|
423
|
+
/** Lists the teams the saved tokens belong to, so a teamID mismatch in puzzmo.json is easy to spot */
|
|
424
|
+
const describeSavedTeams = (): string => {
|
|
425
|
+
const tokens = getTokens()
|
|
426
|
+
if (!tokens.length) return ` No tokens are saved.\n ${tokenHelp}`
|
|
427
|
+
const lines = tokens.map((t) => {
|
|
428
|
+
const teamID = decodeTokenPayload(t.token)?.teamID ?? "(unreadable token)"
|
|
429
|
+
return ` - ${t.teamName ? `${t.teamName} (${teamID})` : teamID} on ${t.source}`
|
|
430
|
+
})
|
|
431
|
+
return ` Saved tokens are for:\n${lines.join("\n")}`
|
|
432
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ const loginCommand = defineCommand({
|
|
|
17
17
|
description: "Save a CLI auth token. Multiple tokens can be stored, one per --source server.",
|
|
18
18
|
},
|
|
19
19
|
args: {
|
|
20
|
-
token: { type: "positional", description: "The pzt- token from
|
|
20
|
+
token: { type: "positional", description: "The pzt- token from workshop.puzzmo.com", required: true },
|
|
21
21
|
source: { type: "string", description: "Server this token belongs to", default: defaultSource },
|
|
22
22
|
},
|
|
23
23
|
run: ({ args }) => login(args.token, args.source),
|
|
@@ -80,7 +80,7 @@ const gamesCommand = defineCommand({
|
|
|
80
80
|
})
|
|
81
81
|
|
|
82
82
|
const migrateCommand = defineCommand({
|
|
83
|
-
meta: { name: "migrate", description: "List and select migration skills from
|
|
83
|
+
meta: { name: "migrate", description: "List and select migration skills from workshop.puzzmo.com" },
|
|
84
84
|
run: () => migrate(),
|
|
85
85
|
})
|
|
86
86
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated SignedSource<<41e09eab646bd6490af9a749ed04083c>>
|
|
3
|
+
* @lightSyntaxTransform
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
|
|
10
|
+
import { ConcreteRequest } from 'relay-runtime';
|
|
11
|
+
export type cliTeamForTokenQuery$variables = {
|
|
12
|
+
token: string;
|
|
13
|
+
};
|
|
14
|
+
export type cliTeamForTokenQuery$data = {
|
|
15
|
+
readonly teamForToken: {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
} | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type cliTeamForTokenQuery = {
|
|
20
|
+
response: cliTeamForTokenQuery$data;
|
|
21
|
+
variables: cliTeamForTokenQuery$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
|
+
"kind": "Variable",
|
|
35
|
+
"name": "token",
|
|
36
|
+
"variableName": "token"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
v2 = {
|
|
40
|
+
"alias": null,
|
|
41
|
+
"args": null,
|
|
42
|
+
"kind": "ScalarField",
|
|
43
|
+
"name": "name",
|
|
44
|
+
"storageKey": null
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
"fragment": {
|
|
48
|
+
"argumentDefinitions": (v0/*:: as any*/),
|
|
49
|
+
"kind": "Fragment",
|
|
50
|
+
"metadata": null,
|
|
51
|
+
"name": "cliTeamForTokenQuery",
|
|
52
|
+
"selections": [
|
|
53
|
+
{
|
|
54
|
+
"alias": null,
|
|
55
|
+
"args": (v1/*:: as any*/),
|
|
56
|
+
"concreteType": "Team",
|
|
57
|
+
"kind": "LinkedField",
|
|
58
|
+
"name": "teamForToken",
|
|
59
|
+
"plural": false,
|
|
60
|
+
"selections": [
|
|
61
|
+
(v2/*:: as any*/)
|
|
62
|
+
],
|
|
63
|
+
"storageKey": null
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"type": "Query",
|
|
67
|
+
"abstractKey": null
|
|
68
|
+
},
|
|
69
|
+
"kind": "Request",
|
|
70
|
+
"operation": {
|
|
71
|
+
"argumentDefinitions": (v0/*:: as any*/),
|
|
72
|
+
"kind": "Operation",
|
|
73
|
+
"name": "cliTeamForTokenQuery",
|
|
74
|
+
"selections": [
|
|
75
|
+
{
|
|
76
|
+
"alias": null,
|
|
77
|
+
"args": (v1/*:: as any*/),
|
|
78
|
+
"concreteType": "Team",
|
|
79
|
+
"kind": "LinkedField",
|
|
80
|
+
"name": "teamForToken",
|
|
81
|
+
"plural": false,
|
|
82
|
+
"selections": [
|
|
83
|
+
(v2/*:: as any*/),
|
|
84
|
+
{
|
|
85
|
+
"alias": null,
|
|
86
|
+
"args": null,
|
|
87
|
+
"kind": "ScalarField",
|
|
88
|
+
"name": "id",
|
|
89
|
+
"storageKey": null
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"storageKey": null
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"params": {
|
|
97
|
+
"cacheID": "b4cfb3b8e689ae705b6bea83b73dee85",
|
|
98
|
+
"id": null,
|
|
99
|
+
"metadata": {},
|
|
100
|
+
"name": "cliTeamForTokenQuery",
|
|
101
|
+
"operationKind": "query",
|
|
102
|
+
"text": "query cliTeamForTokenQuery(\n $token: String!\n) {\n teamForToken(token: $token) {\n name\n id\n }\n}\n"
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
})();
|
|
106
|
+
|
|
107
|
+
(node as any).hash = "d72ebb664e2ea3dc63ba397109b1e06e";
|
|
108
|
+
|
|
109
|
+
export default node;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { graphql, query } from "../util/belay.js"
|
|
2
|
+
import type { cliTeamForTokenQuery } from "./__generated__/cliTeamForTokenQuery.graphql.js"
|
|
3
|
+
|
|
4
|
+
const teamForTokenQuery = graphql`
|
|
5
|
+
query cliTeamForTokenQuery($token: String!) {
|
|
6
|
+
teamForToken(token: $token) {
|
|
7
|
+
name
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
/** Looks up the display name of the team a token belongs to; throws if the server rejects the token. */
|
|
13
|
+
export const fetchTeamName = async (apiURL: string, token: string): Promise<string | null> => {
|
|
14
|
+
const { data, errors } = await query<cliTeamForTokenQuery>(teamForTokenQuery, {
|
|
15
|
+
variables: { token },
|
|
16
|
+
url: `${apiURL}/graphql`,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
if (errors?.length) throw new Error(errors.map((e) => e.message).join("; "))
|
|
20
|
+
return data?.teamForToken?.name ?? null
|
|
21
|
+
}
|
package/src/util/config.ts
CHANGED
|
@@ -7,11 +7,19 @@ const configPath = path.join(configDir, "config.json")
|
|
|
7
7
|
|
|
8
8
|
export const defaultSource = "https://api.puzzmo.com"
|
|
9
9
|
|
|
10
|
+
/** The Workshop: where teams manage their games and mint CLI tokens */
|
|
11
|
+
export const workshopURL = "https://workshop.puzzmo.com"
|
|
12
|
+
|
|
13
|
+
/** Where tokens come from. Appended to any message about a missing, unusable or wrong-team token. */
|
|
14
|
+
export const tokenHelp = `Tokens live in the Workshop at ${workshopURL}/dashboard — open your team, then Settings → Access Tokens.`
|
|
15
|
+
|
|
10
16
|
export type TokenEntry = {
|
|
11
17
|
/** Server identifier (e.g. "api.puzzmo.com" or "localhost:8911") */
|
|
12
18
|
source: string
|
|
13
19
|
/** The pzt- prefixed JWT issued by that server */
|
|
14
20
|
token: string
|
|
21
|
+
/** The team's display name, looked up at login. Absent for env var tokens or when the lookup failed. */
|
|
22
|
+
teamName?: string
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
type Config = { tokens: TokenEntry[] }
|
|
@@ -32,11 +40,11 @@ const writeConfig = (config: Config) => {
|
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
/** Saves a token for `source`, replacing any existing entry for that same source */
|
|
35
|
-
export const addToken = (source: string, token: string) => {
|
|
43
|
+
export const addToken = (source: string, token: string, teamName?: string) => {
|
|
36
44
|
const normalized = normalizeSource(source)
|
|
37
45
|
const { tokens } = readConfig()
|
|
38
46
|
const remaining = tokens.filter((t) => normalizeSource(t.source) !== normalized)
|
|
39
|
-
remaining.push({ source: normalized, token })
|
|
47
|
+
remaining.push({ source: normalized, token, ...(teamName ? { teamName } : {}) })
|
|
40
48
|
writeConfig({ tokens: remaining })
|
|
41
49
|
}
|
|
42
50
|
|
|
@@ -2,7 +2,7 @@ import { Validator, type Schema } from "@cfworker/json-schema"
|
|
|
2
2
|
|
|
3
3
|
import type { PuzzmoFile } from "./api.js"
|
|
4
4
|
|
|
5
|
-
const schemaURL = "https://dev-dj9e.onrender.com/schema/puzzmo-file-schema.json" //"https://
|
|
5
|
+
const schemaURL = "https://dev-dj9e.onrender.com/schema/puzzmo-file-schema.json" //"https://workshop.puzzmo.com/schema/puzzmo-file-schema.json"
|
|
6
6
|
|
|
7
7
|
let cachedValidator: Validator | undefined
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ Edit puzzles in `fixtures/puzzles/`. Game logic is in `src/main.ts`.
|
|
|
15
15
|
## Deployment
|
|
16
16
|
|
|
17
17
|
```
|
|
18
|
-
puzzmo login <your-token> # token from
|
|
18
|
+
puzzmo login <your-token> # token from workshop.puzzmo.com
|
|
19
19
|
yarn deploy # builds, then uploads to Puzzmo
|
|
20
20
|
yarn deploy:only # uploads the current dist/
|
|
21
21
|
```
|