fluncle 0.49.0 → 0.51.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/bin/fluncle.mjs +42 -62
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -408,7 +408,7 @@ function compareVersions(left, right) {
408
408
  const leftParts = parseVersion(left);
409
409
  const rightParts = parseVersion(right);
410
410
  for (let index = 0;index < 3; index += 1) {
411
- const difference = leftParts[index] - rightParts[index];
411
+ const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
412
412
  if (difference !== 0) {
413
413
  return difference;
414
414
  }
@@ -417,16 +417,13 @@ function compareVersions(left, right) {
417
417
  }
418
418
  function parseVersion(version) {
419
419
  const parts = version.split(".").map((part) => Number.parseInt(part, 10));
420
- return [
421
- Number.isInteger(parts[0]) ? parts[0] : 0,
422
- Number.isInteger(parts[1]) ? parts[1] : 0,
423
- Number.isInteger(parts[2]) ? parts[2] : 0
424
- ];
420
+ const integerOrZero = (value) => value !== undefined && Number.isInteger(value) ? value : 0;
421
+ return [integerOrZero(parts[0]), integerOrZero(parts[1]), integerOrZero(parts[2])];
425
422
  }
426
423
  var currentVersion;
427
424
  var init_version = __esm(() => {
428
425
  init_output();
429
- currentVersion = "0.49.0".trim() ? "0.49.0".trim() : "0.1.0";
426
+ currentVersion = "0.51.0".trim() ? "0.51.0".trim() : "0.1.0";
430
427
  });
431
428
 
432
429
  // src/update-notifier.ts
@@ -483,6 +480,9 @@ function shouldNotify(args) {
483
480
  function firstPositional(args) {
484
481
  for (let index = 0;index < args.length; index += 1) {
485
482
  const arg = args[index];
483
+ if (arg === undefined) {
484
+ continue;
485
+ }
486
486
  if (arg === "--env") {
487
487
  index += 1;
488
488
  continue;
@@ -1237,6 +1237,9 @@ async function mixtapeDistributeCommand(idOrLogId, options, onProgress = () => {
1237
1237
  }
1238
1238
  const results = [];
1239
1239
  if (doYoutube) {
1240
+ if (!options.video) {
1241
+ throw new CliError2("missing_video", "YouTube distribution needs --video <mp4>");
1242
+ }
1240
1243
  onProgress("YouTube: uploading video…");
1241
1244
  const { distributeYoutube: distributeYoutube2 } = await Promise.resolve().then(() => (init_mixtape_youtube(), exports_mixtape_youtube));
1242
1245
  const result = await distributeYoutube2(mixtapeId, options.video, onProgress);
@@ -1244,6 +1247,9 @@ async function mixtapeDistributeCommand(idOrLogId, options, onProgress = () => {
1244
1247
  onProgress(`YouTube: ${result.url}`);
1245
1248
  }
1246
1249
  if (doMixcloud) {
1250
+ if (!options.audio) {
1251
+ throw new CliError2("missing_audio", "Mixcloud distribution needs --audio <file>");
1252
+ }
1247
1253
  onProgress("Mixcloud: uploading audio…");
1248
1254
  const { distributeMixcloud: distributeMixcloud2 } = await Promise.resolve().then(() => (init_mixtape_mixcloud(), exports_mixtape_mixcloud));
1249
1255
  const result = await distributeMixcloud2(mixtapeId, options.audio, onProgress, options.unlisted);
@@ -1327,11 +1333,15 @@ function parseCueSheet(text) {
1327
1333
  }
1328
1334
  const match = trimmed.match(/^(\d{1,2}:\d{2}(?::\d{2})?)\s+(.+)$/);
1329
1335
  if (match) {
1330
- const startMs = parseDuration(match[1]);
1336
+ const [, time, ref] = match;
1337
+ if (time === undefined || ref === undefined) {
1338
+ continue;
1339
+ }
1340
+ const startMs = parseDuration(time);
1331
1341
  if (startMs === null) {
1332
1342
  continue;
1333
1343
  }
1334
- entries.push({ ref: match[2].trim(), startMs });
1344
+ entries.push({ ref: ref.trim(), startMs });
1335
1345
  } else {
1336
1346
  entries.push({ ref: trimmed });
1337
1347
  }
@@ -1354,12 +1364,18 @@ function parseDuration(input) {
1354
1364
  }
1355
1365
  if (parts.length === 3) {
1356
1366
  const [hours, minutes2, seconds2] = nums;
1367
+ if (hours === undefined || minutes2 === undefined || seconds2 === undefined) {
1368
+ return null;
1369
+ }
1357
1370
  if (minutes2 >= 60 || seconds2 >= 60) {
1358
1371
  return null;
1359
1372
  }
1360
1373
  return Math.round((hours * 3600 + minutes2 * 60 + seconds2) * 1000);
1361
1374
  }
1362
1375
  const [minutes, seconds] = nums;
1376
+ if (minutes === undefined || seconds === undefined) {
1377
+ return null;
1378
+ }
1363
1379
  if (seconds >= 60) {
1364
1380
  return null;
1365
1381
  }
@@ -1881,7 +1897,7 @@ function compareVersions2(left, right) {
1881
1897
  const leftParts = parseVersion2(left);
1882
1898
  const rightParts = parseVersion2(right);
1883
1899
  for (let index = 0;index < 3; index += 1) {
1884
- const difference = leftParts[index] - rightParts[index];
1900
+ const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
1885
1901
  if (difference !== 0) {
1886
1902
  return difference;
1887
1903
  }
@@ -1890,16 +1906,13 @@ function compareVersions2(left, right) {
1890
1906
  }
1891
1907
  function parseVersion2(version) {
1892
1908
  const parts = version.split(".").map((part) => Number.parseInt(part, 10));
1893
- return [
1894
- Number.isInteger(parts[0]) ? parts[0] : 0,
1895
- Number.isInteger(parts[1]) ? parts[1] : 0,
1896
- Number.isInteger(parts[2]) ? parts[2] : 0
1897
- ];
1909
+ const integerOrZero = (value) => value !== undefined && Number.isInteger(value) ? value : 0;
1910
+ return [integerOrZero(parts[0]), integerOrZero(parts[1]), integerOrZero(parts[2])];
1898
1911
  }
1899
1912
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
1900
1913
  var init_version2 = __esm(() => {
1901
1914
  init_output();
1902
- currentVersion2 = "0.49.0".trim() ? "0.49.0".trim() : "0.1.0";
1915
+ currentVersion2 = "0.51.0".trim() ? "0.51.0".trim() : "0.1.0";
1903
1916
  });
1904
1917
 
1905
1918
  // src/commands/track.ts
@@ -2081,7 +2094,6 @@ __export(exports_admin_tracks, {
2081
2094
  vehiclesCommand: () => vehiclesCommand,
2082
2095
  queueCommand: () => queueCommand,
2083
2096
  observeQueueCommand: () => observeQueueCommand,
2084
- enrichSweepCommand: () => enrichSweepCommand,
2085
2097
  enrichQueueCommand: () => enrichQueueCommand,
2086
2098
  contextQueueCommand: () => contextQueueCommand,
2087
2099
  backfillLastfmCommand: () => backfillLastfmCommand,
@@ -2146,9 +2158,6 @@ async function observeQueueCommand(limit) {
2146
2158
  order: "asc"
2147
2159
  });
2148
2160
  }
2149
- async function enrichSweepCommand(limit) {
2150
- return adminApiPost(`/api/admin/tracks/enrich?limit=${limit}`);
2151
- }
2152
2161
  async function backfillLastfmCommand(limit, dryRun, cursor) {
2153
2162
  const params = new URLSearchParams({ dryRun: String(dryRun), limit: String(limit) });
2154
2163
  if (cursor) {
@@ -2996,6 +3005,9 @@ async function paginateWithKeyboard(options) {
2996
3005
  const columns = stdout.columns ?? 80;
2997
3006
  const before = pages.slice(0, index).reduce((count, page2) => count + page2.lines.length, 0);
2998
3007
  const page = pages[index];
3008
+ if (page === undefined) {
3009
+ return;
3010
+ }
2999
3011
  const start = before + 1;
3000
3012
  const end = before + page.lines.length;
3001
3013
  const loading = busy ? " · loading…" : "";
@@ -3007,7 +3019,7 @@ async function paginateWithKeyboard(options) {
3007
3019
  `);
3008
3020
  }
3009
3021
  function loadNext() {
3010
- const cursor = pages[index].nextCursor;
3022
+ const cursor = pages[index]?.nextCursor;
3011
3023
  if (cursor === undefined) {
3012
3024
  return;
3013
3025
  }
@@ -5384,18 +5396,6 @@ function addAdminCommands(program2) {
5384
5396
  const { enrichQueueCommand: enrichQueueCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5385
5397
  await runAdminEnrichQueue(options, enrichQueueCommand2);
5386
5398
  });
5387
- adminTracks.command("enrich").description("Re-fire enrichment for everything in the enrich-queue (--all; idempotent self-heal)").option("--all", "Sweep the whole enrich-queue (required)", false).option("--limit <limit>", "Max findings to re-trigger", "25").option("--json", "Print JSON", false).action(async (options) => {
5388
- const { enrichSweepCommand: enrichSweepCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5389
- await runAdminEnrich(options, enrichSweepCommand2);
5390
- });
5391
- adminTracks.command("enrich-sweep", { hidden: true }).description("Enrich sweep (alias of `admin tracks enrich --all`)").option("--limit <limit>", "Max findings to re-trigger", "25").option("--json", "Print JSON", false).action(async (options) => {
5392
- const { enrichSweepCommand: enrichSweepCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5393
- await runAdminEnrich({ ...options, all: true }, enrichSweepCommand2);
5394
- });
5395
- admin.command("enrich-sweep", { hidden: true }).description("Enrich sweep (alias of `admin tracks enrich --all`)").option("--limit <limit>", "Max findings to re-trigger", "25").option("--json", "Print JSON", false).action(async (options) => {
5396
- const { enrichSweepCommand: enrichSweepCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5397
- await runAdminEnrich({ ...options, all: true }, enrichSweepCommand2);
5398
- });
5399
5399
  adminTracks.command("vehicles").description("Recent video vehicles, newest first (the style ledger for diversity)").option("--limit <limit>", "Number of vehicles to show", "10").option("--json", "Print JSON", false).action(async (options) => {
5400
5400
  const { vehiclesCommand: vehiclesCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
5401
5401
  await runAdminVehicles(options, vehiclesCommand2);
@@ -6136,35 +6136,6 @@ async function runAdminEnrichQueue(options, enrichQueueCommand2) {
6136
6136
  console.log(trackRows2(tracks).join(`
6137
6137
  `));
6138
6138
  }
6139
- async function runAdminEnrich(options, enrichSweepCommand2) {
6140
- if (!options.all) {
6141
- throw new Error("Usage: fluncle admin tracks enrich --all [--limit 25] [--json] (sweeps the whole enrich-queue)");
6142
- }
6143
- const limit = parseListLimit(options.limit);
6144
- const result = await enrichSweepCommand2(limit);
6145
- if (options.json) {
6146
- printJson({
6147
- ok: true,
6148
- reEnriched: result.reEnriched,
6149
- reEnrichedCount: result.reEnrichedCount,
6150
- skipped: result.skipped,
6151
- skippedCount: result.skippedCount
6152
- });
6153
- return;
6154
- }
6155
- if (result.reEnrichedCount === 0 && result.skippedCount === 0) {
6156
- console.log("Nothing to sweep. The enrich-queue is empty.");
6157
- return;
6158
- }
6159
- const noun = result.reEnrichedCount === 1 ? "finding" : "findings";
6160
- console.log(`Re-fired enrichment for ${result.reEnrichedCount} ${noun}.`);
6161
- for (const entry of result.reEnriched) {
6162
- console.log(` ${entry.logId || entry.trackId} (was ${entry.status})`);
6163
- }
6164
- if (result.skippedCount > 0) {
6165
- console.log(`Skipped ${result.skippedCount} with no Log ID yet.`);
6166
- }
6167
- }
6168
6139
  async function runAdminVehicles(options, vehiclesCommand2) {
6169
6140
  const limit = parseListLimit(options.limit);
6170
6141
  const vehicles = await vehiclesCommand2(limit);
@@ -6269,6 +6240,9 @@ function assertParseArgsCompatibleOptionValues(args) {
6269
6240
  }
6270
6241
  for (let index = 0;index < args.length; index += 1) {
6271
6242
  const arg = args[index];
6243
+ if (arg === undefined) {
6244
+ continue;
6245
+ }
6272
6246
  if (arg === "--") {
6273
6247
  return;
6274
6248
  }
@@ -6298,6 +6272,9 @@ function positionalArgs(args) {
6298
6272
  const positionals = [];
6299
6273
  for (let index = 0;index < args.length; index += 1) {
6300
6274
  const arg = args[index];
6275
+ if (arg === undefined) {
6276
+ continue;
6277
+ }
6301
6278
  if (arg === "--") {
6302
6279
  positionals.push(...args.slice(index + 1));
6303
6280
  return positionals;
@@ -6326,6 +6303,9 @@ function positionalArgs(args) {
6326
6303
  function topLevelCommand(args) {
6327
6304
  for (let index = 0;index < args.length; index += 1) {
6328
6305
  const arg = args[index];
6306
+ if (arg === undefined) {
6307
+ continue;
6308
+ }
6329
6309
  if (arg === "--env") {
6330
6310
  index += 1;
6331
6311
  continue;
package/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "url": "git+https://github.com/mauricekleine/fluncle.git"
32
32
  },
33
33
  "type": "module",
34
- "version": "0.49.0"
34
+ "version": "0.51.0"
35
35
  }