@jbrowse/cli 3.6.0 → 3.6.1
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/bin/run +1 -1
- package/dist/base.js +5 -0
- package/dist/bin.js +3 -0
- package/dist/commands/add-assembly.js +143 -0
- package/dist/commands/add-connection.js +177 -0
- package/dist/commands/add-track-json.js +81 -0
- package/dist/commands/add-track-utils/adapter-utils.js +304 -0
- package/dist/commands/add-track-utils/file-operations.js +36 -0
- package/dist/commands/add-track-utils/track-config.js +63 -0
- package/dist/commands/add-track-utils/validators.js +74 -0
- package/dist/commands/add-track.js +193 -0
- package/dist/commands/admin-server-utils.js +238 -0
- package/dist/commands/admin-server.js +51 -0
- package/dist/commands/assembly-utils.js +410 -0
- package/dist/commands/create.js +121 -0
- package/dist/commands/make-pif-utils/cigar-utils.js +29 -0
- package/dist/commands/make-pif-utils/file-utils.js +38 -0
- package/dist/commands/make-pif-utils/pif-generator.js +64 -0
- package/dist/commands/make-pif-utils/validators.js +22 -0
- package/dist/commands/make-pif.js +58 -0
- package/dist/commands/remove-track.js +58 -0
- package/dist/commands/set-default-session.js +104 -0
- package/dist/commands/sort-bed-utils/constants.js +12 -0
- package/dist/commands/sort-bed-utils/process-utils.js +23 -0
- package/dist/commands/sort-bed-utils/sort-utils.js +24 -0
- package/dist/commands/sort-bed-utils/validators.js +22 -0
- package/dist/commands/sort-bed.js +49 -0
- package/dist/commands/sort-gff-utils/constants.js +13 -0
- package/dist/commands/sort-gff-utils/process-utils.js +23 -0
- package/dist/commands/sort-gff-utils/sort-utils.js +55 -0
- package/dist/commands/sort-gff-utils/validators.js +21 -0
- package/dist/commands/sort-gff.js +49 -0
- package/dist/commands/text-index-utils/adapter-utils.js +63 -0
- package/dist/commands/text-index-utils/aggregate.js +87 -0
- package/dist/commands/text-index-utils/config-utils.js +59 -0
- package/dist/commands/text-index-utils/file-list.js +31 -0
- package/dist/commands/text-index-utils/index.js +9 -0
- package/dist/commands/text-index-utils/indexing-utils.js +84 -0
- package/dist/commands/text-index-utils/per-track.js +65 -0
- package/dist/commands/text-index-utils/validators.js +20 -0
- package/dist/commands/text-index.js +113 -0
- package/dist/commands/track-utils.js +85 -0
- package/dist/commands/upgrade.js +122 -0
- package/dist/fetchWithProxy.js +12 -0
- package/dist/index.js +119 -0
- package/dist/types/common.js +128 -0
- package/dist/types/gff3Adapter.js +73 -0
- package/dist/types/vcfAdapter.js +76 -0
- package/dist/util.js +35 -0
- package/dist/utils.js +154 -0
- package/package.json +3 -3
package/dist/utils.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.debug = debug;
|
|
7
|
+
exports.readFile = readFile;
|
|
8
|
+
exports.readJsonFile = readJsonFile;
|
|
9
|
+
exports.writeJsonFile = writeJsonFile;
|
|
10
|
+
exports.resolveFileLocation = resolveFileLocation;
|
|
11
|
+
exports.readInlineOrFileJson = readInlineOrFileJson;
|
|
12
|
+
exports.fetchGithubVersions = fetchGithubVersions;
|
|
13
|
+
exports.getLatest = getLatest;
|
|
14
|
+
exports.fetchVersions = fetchVersions;
|
|
15
|
+
exports.getTag = getTag;
|
|
16
|
+
exports.getBranch = getBranch;
|
|
17
|
+
exports.printHelp = printHelp;
|
|
18
|
+
const fs_1 = require("fs");
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const json_parse_better_errors_1 = __importDefault(require("json-parse-better-errors"));
|
|
21
|
+
const fetchWithProxy_1 = __importDefault(require("./fetchWithProxy"));
|
|
22
|
+
function debug(message) {
|
|
23
|
+
if (process.env.DEBUG) {
|
|
24
|
+
console.log(`DEBUG: ${message}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function readFile(location) {
|
|
28
|
+
return fs_1.promises.readFile(location, { encoding: 'utf8' });
|
|
29
|
+
}
|
|
30
|
+
async function readJsonFile(location) {
|
|
31
|
+
const contents = await fs_1.promises.readFile(location, { encoding: 'utf8' });
|
|
32
|
+
return (0, json_parse_better_errors_1.default)(contents);
|
|
33
|
+
}
|
|
34
|
+
async function writeJsonFile(location, contents) {
|
|
35
|
+
debug(`Writing JSON file to ${process.cwd()} ${location}`);
|
|
36
|
+
return fs_1.promises.writeFile(location, JSON.stringify(contents, null, 2));
|
|
37
|
+
}
|
|
38
|
+
async function resolveFileLocation(location, check = true, inPlace = false) {
|
|
39
|
+
let locationUrl;
|
|
40
|
+
try {
|
|
41
|
+
locationUrl = new URL(location);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// ignore
|
|
45
|
+
}
|
|
46
|
+
if (locationUrl) {
|
|
47
|
+
if (check) {
|
|
48
|
+
// @ts-expect-error
|
|
49
|
+
const response = await (0, fetchWithProxy_1.default)(locationUrl, { method: 'HEAD' });
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`${locationUrl} result ${response.statusText}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return locationUrl.href;
|
|
55
|
+
}
|
|
56
|
+
let locationPath;
|
|
57
|
+
try {
|
|
58
|
+
locationPath = check ? await fs_1.promises.realpath(location) : location;
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
// ignore
|
|
62
|
+
}
|
|
63
|
+
if (locationPath) {
|
|
64
|
+
const filePath = path_1.default.relative(process.cwd(), locationPath);
|
|
65
|
+
if (inPlace && filePath.startsWith('..')) {
|
|
66
|
+
console.warn(`Location ${filePath} is not in the JBrowse directory. Make sure it is still in your server directory.`);
|
|
67
|
+
}
|
|
68
|
+
return inPlace ? location : filePath;
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`Could not resolve to a file or a URL: "${location}"`);
|
|
71
|
+
}
|
|
72
|
+
async function readInlineOrFileJson(inlineOrFileName) {
|
|
73
|
+
let result;
|
|
74
|
+
// see if it's inline JSON
|
|
75
|
+
try {
|
|
76
|
+
result = (0, json_parse_better_errors_1.default)(inlineOrFileName);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
debug(`Not valid inline JSON, attempting to parse as filename: '${inlineOrFileName}'`);
|
|
80
|
+
// not inline JSON, must be location of a JSON file
|
|
81
|
+
result = await readJsonFile(inlineOrFileName);
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
async function fetchGithubVersions() {
|
|
86
|
+
let versions = [];
|
|
87
|
+
for await (const iter of fetchVersions()) {
|
|
88
|
+
versions = [...versions, ...iter];
|
|
89
|
+
}
|
|
90
|
+
return versions;
|
|
91
|
+
}
|
|
92
|
+
async function getLatest() {
|
|
93
|
+
for await (const versions of fetchVersions()) {
|
|
94
|
+
// if a release was just uploaded, or an erroneous build was made then it
|
|
95
|
+
// might have no build asset
|
|
96
|
+
const nonprereleases = versions
|
|
97
|
+
.filter(release => !release.prerelease)
|
|
98
|
+
.filter(release => release.assets?.length);
|
|
99
|
+
if (nonprereleases.length > 0) {
|
|
100
|
+
// @ts-expect-error
|
|
101
|
+
const file = nonprereleases[0].assets.find(f => f.name.includes('jbrowse-web'))?.browser_download_url;
|
|
102
|
+
if (!file) {
|
|
103
|
+
throw new Error('no jbrowse-web download found');
|
|
104
|
+
}
|
|
105
|
+
return file;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
throw new Error('no version tags found');
|
|
109
|
+
}
|
|
110
|
+
async function* fetchVersions() {
|
|
111
|
+
let page = 1;
|
|
112
|
+
let result;
|
|
113
|
+
do {
|
|
114
|
+
const url = `https://api.github.com/repos/GMOD/jbrowse-components/releases?page=${page}`;
|
|
115
|
+
const response = await (0, fetchWithProxy_1.default)(url);
|
|
116
|
+
if (response.ok) {
|
|
117
|
+
result = (await response.json());
|
|
118
|
+
yield result.filter(release => release.tag_name.startsWith('v'));
|
|
119
|
+
page++;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw new Error(`HTTP ${response.status} fetching ${url}`);
|
|
123
|
+
}
|
|
124
|
+
} while (result.length);
|
|
125
|
+
}
|
|
126
|
+
async function getTag(tag) {
|
|
127
|
+
const response = await (0, fetchWithProxy_1.default)(`https://api.github.com/repos/GMOD/jbrowse-components/releases/tags/${tag}`);
|
|
128
|
+
if (response.ok) {
|
|
129
|
+
const result = (await response.json());
|
|
130
|
+
const file = result.assets?.find(f => f.name.includes('jbrowse-web'))?.browser_download_url;
|
|
131
|
+
if (!file) {
|
|
132
|
+
throw new Error('Could not find version specified. Use --listVersions to see all available versions');
|
|
133
|
+
}
|
|
134
|
+
return file;
|
|
135
|
+
}
|
|
136
|
+
throw new Error(`Could not find version: ${response.statusText}`);
|
|
137
|
+
}
|
|
138
|
+
async function getBranch(branch) {
|
|
139
|
+
return `https://s3.amazonaws.com/jbrowse.org/code/jb2/${branch}/jbrowse-web-${branch}.zip`;
|
|
140
|
+
}
|
|
141
|
+
function printHelp({ description, options, examples, usage, }) {
|
|
142
|
+
console.log(description);
|
|
143
|
+
console.log(`\nUsage: ${usage || 'jbrowse <command> [options]'}`);
|
|
144
|
+
console.log('\nOptions:');
|
|
145
|
+
for (const [name, option] of Object.entries(options)) {
|
|
146
|
+
const short = 'short' in option && option.short
|
|
147
|
+
? `-${option.short}`
|
|
148
|
+
: ' ';
|
|
149
|
+
const namePadded = `--${name}`.padEnd(25, ' ');
|
|
150
|
+
const desc = option.description?.replace(/\n/g, `\n${' '.repeat(29)}`);
|
|
151
|
+
console.log(` ${short}, ${namePadded} ${desc}`);
|
|
152
|
+
}
|
|
153
|
+
console.log(`\n${examples.join('\n')}`);
|
|
154
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/cli",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "A command line tool for working with JBrowse 2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "JBrowse Team",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
19
|
"bin": {
|
|
20
|
-
"jbrowse": "./bin
|
|
20
|
+
"jbrowse": "./dist/bin.js"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"/bin",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3b7ba0005a28fb0903b7b31f15259c2cfccecfa1"
|
|
52
52
|
}
|