dewctl 0.5.4 → 0.5.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dewctl",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Build and publish three.js games on Dewdrop.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/client.js CHANGED
@@ -48,6 +48,7 @@ export class Client {
48
48
  game(game,signal){return this.api(`/v1/games/${game}`,{signal});}
49
49
  releases(game){return this.api(`/v1/games/${game}/releases`);}
50
50
  deleteRelease(game,release){return this.api(`/v1/games/${game}/releases/${release}`,{method:'DELETE'});}
51
+ deleteGame(game){return this.api(`/v1/games/${game}`,{method:'DELETE'});}
51
52
  // Makes the game this developer's if it is new, and confirms it is theirs if not: asked before anything is built, so
52
53
  // a name someone else has, or a sign-in that has ended, is known at once.
53
54
  async claim(game,signal) {
package/src/main.js CHANGED
@@ -26,17 +26,21 @@ const HELP=`${RUN} — make three.js games on Dewdrop
26
26
  share EMAIL Let another developer play and update the dev version
27
27
  unshare EMAIL Take that back
28
28
  status Show the dev and published versions and where to play them
29
- releases List the uploads Dewdrop keeps: every published version, the dev version
30
- and each member's latest upload; any id, or its first 8 characters,
31
- feeds --release and delete
32
- delete ID Delete a published version nothing runs, freeing its space (owner only)
29
+ releases List the uploads Dewdrop keeps: every published version, the dev version,
30
+ each member's latest upload, and every other dev build for two weeks;
31
+ any id, or its first 8 characters, feeds --release and delete
32
+ delete ID Delete an upload nothing runs, freeing its space (owner only)
33
+ delete-game NAME Delete this game, its name typed again to confirm: both versions stop
34
+ now, and it is removed with its uploads and its players' saves. This
35
+ can't be undone (owner only)
33
36
  --version Show this CLI's version
34
37
 
35
38
  Run the commands in your game's folder: they read the game from its dewdrop.json.
36
39
  Docs: ${DEWDROP}/docs
37
40
  `;
38
- // Each command's flags; share and unshare also take one address, and delete one release. Anything else on the line is refused.
39
- const COMMANDS={init:['--game'],login:[],logout:[],dev:['--watch','--release'],stop:[],publish:['--release'],unpublish:[],share:[],unshare:[],status:[],releases:[],delete:[]};
41
+ // Each command's flags; share and unshare also take one address, delete one release and delete-game the game's name.
42
+ // Anything else on the line is refused.
43
+ const COMMANDS={init:['--game'],login:[],logout:[],dev:['--watch','--release'],stop:[],publish:['--release'],unpublish:[],share:[],unshare:[],status:[],releases:[],delete:[],'delete-game':[]};
40
44
  const VALUED=['--game','--release'];
41
45
  function options(command,args) {
42
46
  const out={};
@@ -48,6 +52,7 @@ function options(command,args) {
48
52
  else out[key.slice(2)]=args[++i];
49
53
  } else if(['share','unshare'].includes(command)&&!key.startsWith('-')&&out.email===undefined)out.email=key;
50
54
  else if(command==='delete'&&!key.startsWith('-')&&out.release===undefined)out.release=key;
55
+ else if(command==='delete-game'&&!key.startsWith('-')&&out.name===undefined)out.name=key;
51
56
  else throw new Error(`${command} doesn't take ${key}. Run ${RUN} --help to see what it takes.`);
52
57
  }
53
58
  if(out.release!==undefined&&!/^[a-f0-9]{8,64}$/.test(out.release))throw new Error(`${command==='delete'?'delete':'--release'} takes a release id, or its first 8 or more characters, from ${RUN} releases.`);
@@ -141,8 +146,8 @@ async function main() {
141
146
  if(command==='releases'){
142
147
  const [{releases},state]=await Promise.all([client.releases(game),client.game(game)]);
143
148
  if(!releases.length){console.log(`No uploads of ${game} yet. Run ${RUN} dev to make one.`);return;}
144
- // What each release is to the game, the reason Dewdrop keeps it.
145
- const status=release=>[release.sha256===state.dev.release&&'dev',release.sha256===state.live.release&&'published'].filter(Boolean).join(', ')||(release.published?'published before':'latest upload');
149
+ // What each release is to the game, the reason Dewdrop keeps it, and for an old dev build when it goes.
150
+ const status=release=>[release.sha256===state.dev.release&&'dev',release.sha256===state.live.release&&'published'].filter(Boolean).join(', ')||(release.published?'published before':release.expires?`dev build until ${new Date(release.expires).toISOString().slice(0,10)}`:'latest upload');
146
151
  console.log(columns([['RELEASE','UPLOADED (UTC)','SIZE','STATUS','BY'],...releases.map(release=>[release.sha256.slice(0,12),new Date(release.created).toISOString().slice(0,16).replace('T',' '),size(release.bytes),status(release),release.email])]));
147
152
  return;
148
153
  }
@@ -152,6 +157,11 @@ async function main() {
152
157
  await client.deleteRelease(game,release);
153
158
  console.log(`Deleted ${release.slice(0,12)} from ${game}.`);return;
154
159
  }
160
+ if(command==='delete-game'){
161
+ if(flags.name!==game)throw new Error(`delete-game takes the game's name to confirm. Run ${RUN} delete-game ${game} to delete ${game}.`);
162
+ await client.deleteGame(game);
163
+ console.log(`Deleted ${game}. Both versions are stopped, players can no longer open it, and it is removed with its uploads and its players' saves.`);return;
164
+ }
155
165
  if(['share','unshare'].includes(command)) {
156
166
  if(!flags.email)throw new Error(`${command} needs the developer's email address.`);
157
167
  await client.member(game,flags.email,command==='share');