codemuster 0.1.0 → 0.2.0

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/lib/launcher.js +34 -0
  2. package/package.json +7 -7
package/lib/launcher.js CHANGED
@@ -218,6 +218,35 @@ function bundledBuild(pkg) {
218
218
  }
219
219
  }
220
220
 
221
+ async function updateNow({ args, stateDir, platform, arch, currentVersion, registry = REGISTRY, out = process.stdout }) {
222
+ const checkOnly = args.includes('--check');
223
+ const packument = await getJson(`${registry}/codemuster`);
224
+ const latest = (packument['dist-tags'] && packument['dist-tags'].latest) || null;
225
+ if (latest === null) {
226
+ out.write('codemuster: the registry named no latest version\n');
227
+ return 1;
228
+ }
229
+
230
+ if (compareVersions(latest, currentVersion) <= 0) {
231
+ out.write(`codemuster ${currentVersion} is already the newest\n`);
232
+ return 0;
233
+ }
234
+
235
+ if (checkOnly) {
236
+ out.write(`codemuster ${latest} is available; you are on ${currentVersion}. Run codemuster update to install it.\n`);
237
+ return 0;
238
+ }
239
+
240
+ out.write(`updating codemuster ${currentVersion} to ${latest}\n`);
241
+ const versionsDir = path.join(stateDir, 'versions');
242
+ await installVersion({ registry, version: latest, versionsDir, platform, arch });
243
+ pruneVersions(versionsDir);
244
+ fs.mkdirSync(stateDir, { recursive: true });
245
+ fs.writeFileSync(path.join(stateDir, 'last-update-check'), String(Date.now()));
246
+ out.write(`codemuster ${latest} is ready; the next command uses it\n`);
247
+ return 0;
248
+ }
249
+
221
250
  async function main(args, env = process.env) {
222
251
  const platform = process.platform;
223
252
  const arch = process.arch;
@@ -231,6 +260,10 @@ async function main(args, env = process.env) {
231
260
  build = newestBuild({ versionsDir, bundled: null, platform });
232
261
  }
233
262
 
263
+ if (args[0] === 'update') {
264
+ return updateNow({ args: args.slice(1), stateDir, platform, arch, currentVersion: build.version });
265
+ }
266
+
234
267
  if (shouldCheckForUpdate({ env, now: Date.now(), lastCheck: readLastCheck(stateDir) })) {
235
268
  childProcess
236
269
  .spawn(process.execPath, [path.join(__dirname, 'update.js'), stateDir, build.version], { detached: true, stdio: 'ignore', windowsHide: true })
@@ -253,4 +286,5 @@ module.exports = {
253
286
  shouldCheckForUpdate,
254
287
  tar,
255
288
  update,
289
+ updateNow,
256
290
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemuster",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "CodeMuster: full-coverage codebase audits with a coverage number, driven by your coding agent through one skill.",
5
5
  "license": "MIT",
6
6
  "author": "Tim Carter",
@@ -36,11 +36,11 @@
36
36
  "test": "node --test test/launcher.test.js"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@codemuster/darwin-arm64": "0.1.0",
40
- "@codemuster/darwin-x64": "0.1.0",
41
- "@codemuster/linux-arm64": "0.1.0",
42
- "@codemuster/linux-x64": "0.1.0",
43
- "@codemuster/win32-arm64": "0.1.0",
44
- "@codemuster/win32-x64": "0.1.0"
39
+ "@codemuster/darwin-arm64": "0.2.0",
40
+ "@codemuster/darwin-x64": "0.2.0",
41
+ "@codemuster/linux-arm64": "0.2.0",
42
+ "@codemuster/linux-x64": "0.2.0",
43
+ "@codemuster/win32-arm64": "0.2.0",
44
+ "@codemuster/win32-x64": "0.2.0"
45
45
  }
46
46
  }