@jbrowse/cli 4.1.1 → 4.1.3

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.
@@ -0,0 +1,3 @@
1
+ export default function cliFetch(url, options = {}) {
2
+ return fetch(url, options);
3
+ }
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import { parseArgs } from 'util';
3
3
  import parseJSON from 'json-parse-better-errors';
4
- import fetch from "../fetchWithProxy.js";
4
+ import fetch from "../cliFetch.js";
5
5
  import { debug, printHelp, readJsonFile, resolveConfigPath, writeJsonFile, } from "../utils.js";
6
6
  async function resolveURL(location, check = true) {
7
7
  let locationUrl;
@@ -12,7 +12,7 @@ export async function loadFile({ src, destDir, mode, subDir = '', force = false,
12
12
  await unlink(dest);
13
13
  }
14
14
  catch (e) {
15
- if (e.code !== 'ENOENT') {
15
+ if (e && typeof e === 'object' && 'code' in e && e.code !== 'ENOENT') {
16
16
  throw e;
17
17
  }
18
18
  }
@@ -76,7 +76,7 @@ export async function run(args) {
76
76
  debug(`Admin key stored at ${keyPath}`);
77
77
  }
78
78
  catch (error) {
79
- console.error(`Failed to write admin key to ${keyPath}:`, error.message);
79
+ console.error(`Failed to write admin key to ${keyPath}:`, error instanceof Error ? error.message : error);
80
80
  // Continue anyway, as this is not critical
81
81
  }
82
82
  // Create server reference for shutdown route
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import { parseArgs } from 'util';
3
3
  import decompress from 'decompress';
4
- import fetch from "../fetchWithProxy.js";
4
+ import fetch from "../cliFetch.js";
5
5
  import { fetchGithubVersions, getBranch, getLatest, getTag, printHelp, } from "../utils.js";
6
6
  const fsPromises = fs.promises;
7
7
  const description = 'Downloads and installs the latest JBrowse 2 release';
@@ -91,7 +91,9 @@ export function getTrackConfigs(config, trackIds, assemblyName, excludeTrackIds)
91
91
  if (!tracks) {
92
92
  return [];
93
93
  }
94
- const trackIdsToIndex = trackIds || tracks.map(track => track.trackId);
94
+ const trackIdsToIndex = trackIds?.length
95
+ ? trackIds
96
+ : tracks.map(track => track.trackId);
95
97
  const excludeSet = new Set(excludeTrackIds || []);
96
98
  return trackIdsToIndex
97
99
  .map(trackId => {
@@ -103,11 +105,10 @@ export function getTrackConfigs(config, trackIds, assemblyName, excludeTrackIds)
103
105
  })
104
106
  .filter(track => {
105
107
  if (excludeSet.has(track.trackId)) {
106
- console.log(`Skipping ${track.trackId}: excluded via --exclude-tracks`);
108
+ // console.log(`Skipping ${track.trackId}: excluded via --exclude-tracks`)
107
109
  return false;
108
110
  }
109
111
  if (!supported(track.adapter?.type)) {
110
- console.log(`Skipping ${track.trackId}: unsupported adapter type '${track.adapter?.type}'`);
111
112
  return false;
112
113
  }
113
114
  if (assemblyName && !track.assemblyNames.includes(assemblyName)) {
@@ -2,7 +2,7 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { parseArgs } from 'util';
4
4
  import decompress from 'decompress';
5
- import fetch from "../fetchWithProxy.js";
5
+ import fetch from "../cliFetch.js";
6
6
  import { fetchGithubVersions, getBranch, getLatest, getTag, printHelp, } from "../utils.js";
7
7
  const description = 'Upgrades JBrowse 2 to latest version';
8
8
  const examples = [
@@ -1,4 +1,4 @@
1
- import fetch from "../fetchWithProxy.js";
1
+ import fetch from "../cliFetch.js";
2
2
  export async function createRemoteStream(urlIn) {
3
3
  const res = await fetch(urlIn);
4
4
  if (!res.ok) {
package/dist/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { promises as fsPromises } from 'fs';
2
2
  import path from 'path';
3
3
  import parseJSON from 'json-parse-better-errors';
4
- import fetch from "./fetchWithProxy.js";
4
+ import fetch from "./cliFetch.js";
5
5
  export function debug(message) {
6
6
  if (process.env.DEBUG) {
7
7
  console.log(`DEBUG: ${message}`);
@@ -80,12 +80,12 @@ export async function getLatest() {
80
80
  for await (const versions of fetchVersions()) {
81
81
  // if a release was just uploaded, or an erroneous build was made then it
82
82
  // might have no build asset
83
- const nonprereleases = versions
83
+ const nonprerelease = versions
84
84
  .filter(release => !release.prerelease)
85
- .filter(release => release.assets?.length);
86
- if (nonprereleases.length > 0) {
87
- // @ts-expect-error
88
- const file = nonprereleases[0].assets.find(f => f.name.includes('jbrowse-web'))?.browser_download_url;
85
+ .find(release => release.assets?.length);
86
+ const first = nonprerelease;
87
+ if (first?.assets) {
88
+ const file = first.assets.find(f => f.name.includes('jbrowse-web'))?.browser_download_url;
89
89
  if (!file) {
90
90
  throw new Error('no jbrowse-web download found');
91
91
  }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '4.1.1';
1
+ export const version = '4.1.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/cli",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "type": "module",
5
5
  "description": "A command line tool for working with JBrowse 2",
6
6
  "keywords": [
@@ -31,14 +31,13 @@
31
31
  "dependencies": {
32
32
  "cli-progress": "^3.12.0",
33
33
  "command-exists": "^1.2.9",
34
- "cors": "^2.8.5",
34
+ "cors": "^2.8.6",
35
35
  "decompress": "^4.2.1",
36
36
  "express": "^5.2.1",
37
37
  "ixixx": "^3.0.3",
38
38
  "json-parse-better-errors": "^1.0.2",
39
- "node-fetch-native": "^1.6.7",
40
39
  "tmp": "^0.2.5",
41
- "@jbrowse/text-indexing-core": "^4.1.1"
40
+ "@jbrowse/text-indexing-core": "^4.1.3"
42
41
  },
43
42
  "publishConfig": {
44
43
  "access": "public"
@@ -1,9 +0,0 @@
1
- import { fetch } from 'node-fetch-native/node';
2
- import { createProxy } from 'node-fetch-native/proxy';
3
- const proxy = createProxy();
4
- // The correct proxy `Agent` implementation to use will be determined
5
- // via the `http_proxy` / `https_proxy` / `no_proxy` / etc. env vars
6
- // https://github.com/unjs/node-fetch-native?tab=readme-ov-file#proxy-support
7
- export default function fetchWithProxy(url, options = {}) {
8
- return fetch(url, { ...options, ...proxy });
9
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.indexGff3 = indexGff3;
4
- const util_ts_1 = require("../util.js");
5
- const streamUtils_ts_1 = require("./streamUtils.js");
6
- async function* indexGff3({ config, attributesToIndex, inLocation, outLocation, typesToExclude, quiet, }) {
7
- const { trackId } = config;
8
- const { rl, progressBar } = await (0, streamUtils_ts_1.createIndexingStream)({
9
- inLocation,
10
- outLocation,
11
- trackId,
12
- quiet,
13
- });
14
- const excludeSet = new Set(typesToExclude);
15
- const encodedTrackId = encodeURIComponent(trackId);
16
- for await (const line of rl) {
17
- if (!line.trim()) {
18
- continue;
19
- }
20
- else if (line.startsWith('#')) {
21
- continue;
22
- }
23
- else if (line.startsWith('>')) {
24
- break;
25
- }
26
- const [seq_id, , type, start, end, , , , col9] = line.split('\t');
27
- if (!excludeSet.has(type)) {
28
- const col9attrs = (0, streamUtils_ts_1.parseAttributes)(col9, util_ts_1.decodeURIComponentNoThrow);
29
- const attrs = attributesToIndex
30
- .map(attr => col9attrs[attr])
31
- .filter((f) => !!f);
32
- if (attrs.length > 0) {
33
- const locStr = `${seq_id}:${start}..${end}`;
34
- const encodedAttrs = attrs.map(a => `"${encodeURIComponent(a)}"`);
35
- const record = `["${encodeURIComponent(locStr)}"|"${encodedTrackId}"|${encodedAttrs.join('|')}]`;
36
- const uniqueAttrs = [...new Set(attrs)];
37
- yield `${record} ${uniqueAttrs.join(' ')}\n`;
38
- }
39
- }
40
- }
41
- progressBar.stop();
42
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createIndexingStream = createIndexingStream;
4
- exports.parseAttributes = parseAttributes;
5
- const cli_progress_1 = require("cli-progress");
6
- const util_ts_1 = require("../util.js");
7
- async function* readLines(reader, progressBar) {
8
- const decoder = new TextDecoder();
9
- let buffer = '';
10
- let receivedBytes = 0;
11
- try {
12
- let result = await reader.read();
13
- while (!result.done) {
14
- receivedBytes += result.value.length;
15
- progressBar.update(receivedBytes);
16
- buffer += decoder.decode(result.value, { stream: true });
17
- const lines = buffer.split('\n');
18
- buffer = lines.pop();
19
- for (const line of lines) {
20
- yield line;
21
- }
22
- result = await reader.read();
23
- }
24
- }
25
- finally {
26
- reader.releaseLock();
27
- }
28
- buffer += decoder.decode();
29
- if (buffer) {
30
- yield buffer;
31
- }
32
- }
33
- async function createIndexingStream({ inLocation, outLocation, trackId, quiet, }) {
34
- const progressBar = new cli_progress_1.SingleBar({
35
- format: `{bar} ${trackId} {percentage}% | ETA: {eta}s`,
36
- etaBuffer: 2000,
37
- }, cli_progress_1.Presets.shades_classic);
38
- const { totalBytes, stream } = await (0, util_ts_1.getLocalOrRemoteStream)(inLocation, outLocation);
39
- if (!quiet) {
40
- progressBar.start(totalBytes, 0);
41
- }
42
- if (!stream) {
43
- throw new Error(`Failed to fetch ${inLocation}: no response body`);
44
- }
45
- const inputStream = /.b?gz$/.exec(inLocation)
46
- ? // @ts-ignore root tsconfig includes DOM lib which has incompatible stream types
47
- stream.pipeThrough(new DecompressionStream('gzip'))
48
- : stream;
49
- const rl = readLines(inputStream.getReader(), progressBar);
50
- return { rl, progressBar };
51
- }
52
- function parseAttributes(infoString, decodeFunc) {
53
- const result = {};
54
- for (const field of infoString.split(';')) {
55
- const trimmed = field.trim();
56
- if (trimmed) {
57
- const eqIdx = trimmed.indexOf('=');
58
- if (eqIdx !== -1) {
59
- const key = trimmed.slice(0, eqIdx).trim();
60
- const val = trimmed.slice(eqIdx + 1);
61
- result[key] = decodeFunc(val).trim().replaceAll(',', ' ');
62
- }
63
- }
64
- }
65
- return result;
66
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.indexVcf = indexVcf;
4
- const util_ts_1 = require("../util.js");
5
- const streamUtils_ts_1 = require("./streamUtils.js");
6
- async function* indexVcf({ config, attributesToIndex, inLocation, outLocation, quiet, }) {
7
- const { trackId } = config;
8
- const { rl, progressBar } = await (0, streamUtils_ts_1.createIndexingStream)({
9
- inLocation,
10
- outLocation,
11
- trackId,
12
- quiet,
13
- });
14
- const encodedTrackId = encodeURIComponent(trackId);
15
- for await (const line of rl) {
16
- if (line.startsWith('#')) {
17
- continue;
18
- }
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- const [ref, pos, id, _ref, _alt, _qual, _filter, info] = line.split('\t');
21
- if (id === '.') {
22
- continue;
23
- }
24
- const fields = (0, streamUtils_ts_1.parseAttributes)(info, util_ts_1.decodeURIComponentNoThrow);
25
- const end = fields.END;
26
- const locStr = `${ref}:${pos}..${end || +pos + 1}`;
27
- const encodedLocStr = encodeURIComponent(locStr);
28
- const infoAttrs = attributesToIndex
29
- .map(attr => fields[attr])
30
- .filter((f) => !!f);
31
- const encodedInfoAttrs = infoAttrs.map(a => `"${encodeURIComponent(a)}"`);
32
- for (const variantId of id.split(',')) {
33
- const encodedId = encodeURIComponent(variantId);
34
- const record = `["${encodedLocStr}"|"${encodedTrackId}"|"${encodedId}"${encodedInfoAttrs.length > 0 ? `|${encodedInfoAttrs.join('|')}` : ''}]`;
35
- yield `${record} ${variantId}\n`;
36
- }
37
- }
38
- progressBar.stop();
39
- }