star-sdk-cli 0.1.9 → 0.1.11

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +47 -12
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -23,6 +23,23 @@ import Star from 'star-sdk';
23
23
 
24
24
  **CRITICAL:** Always use \`import Star from 'star-sdk'\` - not destructured imports.
25
25
 
26
+ ## Setup (Required for Leaderboards)
27
+
28
+ Before writing any leaderboard code, register your game by running this command in the terminal:
29
+
30
+ \`\`\`bash
31
+ npx star-sdk init "Your Game Name"
32
+ \`\`\`
33
+
34
+ This creates a \`.starrc\` file containing your gameId. Open \`.starrc\`, copy the \`gameId\` value, and pass it to \`Star.init()\`:
35
+
36
+ \`\`\`javascript
37
+ import Star from 'star-sdk';
38
+ Star.init({ gameId: '<paste gameId from .starrc>' });
39
+ \`\`\`
40
+
41
+ **The gameId is a unique token issued by the Star API. Do not make one up \u2014 it will not work. You must run \`npx star-sdk init\` first and use the gameId it gives you.**
42
+
26
43
  ## API Overview
27
44
 
28
45
  | API | Use When | Docs |
@@ -35,6 +52,7 @@ import Star from 'star-sdk';
35
52
 
36
53
  \`\`\`javascript
37
54
  import Star from 'star-sdk';
55
+ Star.init({ gameId: '<gameId from .starrc>' }); // run: npx star-sdk init
38
56
 
39
57
  Star.game(ctx => {
40
58
  const { canvas, width, height, ctx: c } = ctx;
@@ -108,6 +126,7 @@ Only these 17 presets exist:
108
126
 
109
127
  \`\`\`javascript
110
128
  import Star from 'star-sdk';
129
+ Star.init({ gameId: '<gameId from .starrc>' }); // run: npx star-sdk init
111
130
 
112
131
  Star.game(ctx => {
113
132
  const { canvas, width, height, ctx: c } = ctx;
@@ -663,7 +682,7 @@ game(({ ctx, width, height, loop, toStagePoint, canvas }) => {
663
682
  import { game } from 'star-canvas';
664
683
  import { createLeaderboard } from 'star-leaderboard';
665
684
 
666
- const leaderboard = createLeaderboard();
685
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
667
686
 
668
687
  game(({ ctx, width, height, loop, ui, on, canvas, toStagePoint }) => {
669
688
  let score = 0;
@@ -1004,6 +1023,16 @@ var LEADERBOARD_DOCS = `**Installation**
1004
1023
  yarn add star-leaderboard
1005
1024
  \`\`\`
1006
1025
 
1026
+ **Setup (do this first):**
1027
+
1028
+ Register your game by running this in the terminal:
1029
+
1030
+ \`\`\`bash
1031
+ npx star-sdk init "Game Name"
1032
+ \`\`\`
1033
+
1034
+ This creates a \`.starrc\` file. Open it, copy the \`gameId\` value, and use it below. The gameId is a server-issued token \u2014 do not invent one. It must come from \`npx star-sdk init\`.
1035
+
1007
1036
  ### Star Leaderboard SDK
1008
1037
 
1009
1038
  **Simple leaderboards for Star games.** Submit scores, show rankings, share results. Never crashes your game.
@@ -1011,7 +1040,7 @@ yarn add star-leaderboard
1011
1040
  **Import:**
1012
1041
  \`\`\`javascript
1013
1042
  import { createLeaderboard } from 'star-leaderboard';
1014
- const leaderboard = createLeaderboard();
1043
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
1015
1044
  \`\`\`
1016
1045
 
1017
1046
  **CRITICAL:** Import in JavaScript - don't add \`<script>\` tags.
@@ -1024,7 +1053,7 @@ const leaderboard = createLeaderboard();
1024
1053
  import { createLeaderboard } from 'star-leaderboard';
1025
1054
  import { game } from 'star-canvas';
1026
1055
 
1027
- const leaderboard = createLeaderboard();
1056
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
1028
1057
 
1029
1058
  game(({ ctx, width, height, loop, ui, on, canvas }) => {
1030
1059
  let score = 0;
@@ -1080,7 +1109,7 @@ leaderboard.showLeaderboard() // Same as show()
1080
1109
  \`\`\`javascript
1081
1110
  import { createLeaderboard } from 'star-leaderboard';
1082
1111
 
1083
- const leaderboard = createLeaderboard();
1112
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
1084
1113
 
1085
1114
  function gameOver(finalScore) {
1086
1115
  // Fire and forget - simplest approach
@@ -1094,7 +1123,7 @@ function gameOver(finalScore) {
1094
1123
  \`\`\`javascript
1095
1124
  import { createLeaderboard } from 'star-leaderboard';
1096
1125
 
1097
- const leaderboard = createLeaderboard();
1126
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
1098
1127
 
1099
1128
  async function gameOver(finalScore) {
1100
1129
  const { success, rank } = await leaderboard.submit(finalScore);
@@ -1113,7 +1142,7 @@ async function gameOver(finalScore) {
1113
1142
  import { createLeaderboard } from 'star-leaderboard';
1114
1143
  import { game } from 'star-canvas';
1115
1144
 
1116
- const leaderboard = createLeaderboard();
1145
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
1117
1146
 
1118
1147
  game(({ ui, on }) => {
1119
1148
  ui.render(\`
@@ -1134,7 +1163,7 @@ game(({ ui, on }) => {
1134
1163
  \`\`\`javascript
1135
1164
  import { createLeaderboard } from 'star-leaderboard';
1136
1165
 
1137
- const leaderboard = createLeaderboard();
1166
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
1138
1167
 
1139
1168
  async function showCustomLeaderboard() {
1140
1169
  const { scores, you, config } = await leaderboard.getScores({
@@ -1159,7 +1188,7 @@ async function showCustomLeaderboard() {
1159
1188
  import { createLeaderboard } from 'star-leaderboard';
1160
1189
  import { game } from 'star-canvas';
1161
1190
 
1162
- const leaderboard = createLeaderboard();
1191
+ const leaderboard = createLeaderboard({ gameId: '<gameId from .starrc>' });
1163
1192
 
1164
1193
  game(({ ctx, width, height, loop, ui, on, canvas }) => {
1165
1194
  let score = 0;
@@ -1210,6 +1239,10 @@ game(({ ctx, width, height, loop, ui, on, canvas }) => {
1210
1239
 
1211
1240
  ---
1212
1241
 
1242
+ **Configuration:**
1243
+
1244
+ Your gameId comes from \`.starrc\` (created by \`npx star-sdk init\`). See Setup at the top.
1245
+
1213
1246
  ---
1214
1247
 
1215
1248
  **getScores Options:**
@@ -1382,12 +1415,14 @@ async function initCommand(name, email) {
1382
1415
  log(`${colors.dim}Config saved to${colors.reset} ${colors.bright}.starrc${colors.reset}`);
1383
1416
  log("");
1384
1417
  log(`${colors.dim}Next steps:${colors.reset}`);
1385
- log(` 1. Import Star SDK in your game`);
1386
- log(` 2. Use Star.leaderboard.submit(score) to submit scores`);
1418
+ log(` 1. Install the leaderboard package: ${colors.cyan}yarn add star-leaderboard${colors.reset}`);
1419
+ log(` 2. Submit scores and show the leaderboard`);
1387
1420
  log("");
1388
1421
  log(`${colors.dim}Example:${colors.reset}`);
1389
- log(` ${colors.cyan}import Star from 'star-sdk';${colors.reset}`);
1390
- log(` ${colors.cyan}Star.leaderboard.submit(1500);${colors.reset}`);
1422
+ log(` ${colors.cyan}import { createLeaderboard } from 'star-leaderboard';${colors.reset}`);
1423
+ log(` ${colors.cyan}const leaderboard = createLeaderboard({ gameId: '${data.gameId}' });${colors.reset}`);
1424
+ log(` ${colors.cyan}leaderboard.submit(1500);${colors.reset}`);
1425
+ log(` ${colors.cyan}leaderboard.show();${colors.reset}`);
1391
1426
  log("");
1392
1427
  log(`${colors.dim}Using an AI coding agent?${colors.reset}`);
1393
1428
  log(` ${colors.cyan}npx star-sdk install${colors.reset} ${colors.dim}Claude Code, Codex, Cursor, Windsurf, Aider${colors.reset}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "star-sdk-cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "CLI tool for Star SDK - register games and manage leaderboards",
5
5
  "type": "module",
6
6
  "bin": {