@jbrowse/cli 3.5.1 → 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/README.md +291 -607
- package/bin/run +1 -6
- package/bundle/index.js +4459 -0
- 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/index.js +119 -0
- package/dist/utils.js +154 -0
- package/package.json +13 -38
- package/bin/dev +0 -17
- package/bin/dev.cmd +0 -3
- package/bin/run.cmd +0 -3
- package/lib/base.js +0 -157
- package/lib/commands/add-assembly.js +0 -491
- package/lib/commands/add-connection.js +0 -170
- package/lib/commands/add-track-json.js +0 -67
- package/lib/commands/add-track.js +0 -564
- package/lib/commands/admin-server.js +0 -153
- package/lib/commands/create.js +0 -111
- package/lib/commands/make-pif.js +0 -116
- package/lib/commands/remove-track.js +0 -37
- package/lib/commands/set-default-session.js +0 -98
- package/lib/commands/sort-bed.js +0 -45
- package/lib/commands/sort-gff.js +0 -45
- package/lib/commands/text-index.js +0 -380
- package/lib/commands/upgrade.js +0 -109
- package/lib/index.js +0 -6
- package/oclif.manifest.json +0 -1169
- /package/{lib → dist}/fetchWithProxy.js +0 -0
- /package/{lib → dist}/types/common.js +0 -0
- /package/{lib → dist}/types/gff3Adapter.js +0 -0
- /package/{lib → dist}/types/vcfAdapter.js +0 -0
- /package/{lib → dist}/util.js +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
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.resolveTrackConfigPath = resolveTrackConfigPath;
|
|
7
|
+
exports.loadTrackConfig = loadTrackConfig;
|
|
8
|
+
exports.processTrackFiles = processTrackFiles;
|
|
9
|
+
exports.addTrackToConfig = addTrackToConfig;
|
|
10
|
+
exports.saveTrackConfigAndReport = saveTrackConfigAndReport;
|
|
11
|
+
exports.buildTrackParams = buildTrackParams;
|
|
12
|
+
exports.createTrackConfiguration = createTrackConfiguration;
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
const adapter_utils_1 = require("./add-track-utils/adapter-utils");
|
|
17
|
+
const file_operations_1 = require("./add-track-utils/file-operations");
|
|
18
|
+
const track_config_1 = require("./add-track-utils/track-config");
|
|
19
|
+
const validators_1 = require("./add-track-utils/validators");
|
|
20
|
+
function resolveTrackConfigPath(output) {
|
|
21
|
+
const isDir = fs_1.default.lstatSync(output).isDirectory();
|
|
22
|
+
return isDir ? `${output}/config.json` : output;
|
|
23
|
+
}
|
|
24
|
+
async function loadTrackConfig(targetConfigPath) {
|
|
25
|
+
return await (0, utils_1.readJsonFile)(targetConfigPath);
|
|
26
|
+
}
|
|
27
|
+
async function processTrackFiles({ location, index, bed1, bed2, load, configDir, subDir, force, }) {
|
|
28
|
+
if (load) {
|
|
29
|
+
await Promise.all(Object.values((0, adapter_utils_1.guessFileNames)({ location, index, bed1, bed2 }))
|
|
30
|
+
.filter(f => !!f)
|
|
31
|
+
.map(src => (0, file_operations_1.loadFile)({
|
|
32
|
+
src,
|
|
33
|
+
destDir: configDir,
|
|
34
|
+
mode: load,
|
|
35
|
+
subDir,
|
|
36
|
+
force,
|
|
37
|
+
})));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function addTrackToConfig({ configContents, trackConfig, trackId, force, overwrite, }) {
|
|
41
|
+
const idx = (0, validators_1.validateTrackId)(configContents, trackId, force, overwrite);
|
|
42
|
+
const updatedConfig = { ...configContents };
|
|
43
|
+
if (idx !== -1) {
|
|
44
|
+
(0, utils_1.debug)(`Found existing trackId ${trackId} in configuration`);
|
|
45
|
+
(0, utils_1.debug)(`Overwriting track ${trackId} in configuration`);
|
|
46
|
+
updatedConfig.tracks[idx] = trackConfig;
|
|
47
|
+
return { updatedConfig, wasOverwritten: true };
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
updatedConfig.tracks.push(trackConfig);
|
|
51
|
+
return { updatedConfig, wasOverwritten: false };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function saveTrackConfigAndReport({ config, targetConfigPath, name, trackId, wasOverwritten, }) {
|
|
55
|
+
(0, utils_1.debug)(`Writing configuration to file ${targetConfigPath}`);
|
|
56
|
+
await (0, utils_1.writeJsonFile)(targetConfigPath, config);
|
|
57
|
+
console.log(`${wasOverwritten ? 'Overwrote' : 'Added'} track with name "${name}" and trackId "${trackId}" ${wasOverwritten ? 'in' : 'to'} ${targetConfigPath}`);
|
|
58
|
+
}
|
|
59
|
+
function buildTrackParams({ flags, location, adapter, configContents, }) {
|
|
60
|
+
const trackType = flags.trackType || (0, adapter_utils_1.guessTrackType)(adapter.type);
|
|
61
|
+
const trackId = flags.trackId || path_1.default.basename(location, path_1.default.extname(location));
|
|
62
|
+
const name = flags.name || trackId;
|
|
63
|
+
const assemblyNames = flags.assemblyNames || configContents.assemblies?.[0]?.name || '';
|
|
64
|
+
return {
|
|
65
|
+
trackType,
|
|
66
|
+
trackId,
|
|
67
|
+
name,
|
|
68
|
+
assemblyNames,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function createTrackConfiguration({ location, trackParams, flags, adapter, configContents, skipCheck, }) {
|
|
72
|
+
return (0, track_config_1.buildTrackConfig)({
|
|
73
|
+
location,
|
|
74
|
+
trackType: trackParams.trackType,
|
|
75
|
+
trackId: trackParams.trackId,
|
|
76
|
+
name: trackParams.name,
|
|
77
|
+
assemblyNames: trackParams.assemblyNames,
|
|
78
|
+
category: flags.category,
|
|
79
|
+
description: flags.description,
|
|
80
|
+
config: flags.config,
|
|
81
|
+
adapter,
|
|
82
|
+
configContents,
|
|
83
|
+
skipCheck,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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.run = run;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const decompress_1 = __importDefault(require("decompress"));
|
|
11
|
+
const fetchWithProxy_1 = __importDefault(require("../fetchWithProxy"));
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const description = 'Upgrades JBrowse 2 to latest version';
|
|
14
|
+
const examples = [
|
|
15
|
+
'# Upgrades current directory to latest jbrowse release',
|
|
16
|
+
'$ jbrowse upgrade',
|
|
17
|
+
'',
|
|
18
|
+
'# Upgrade jbrowse instance at a specific filesystem path',
|
|
19
|
+
'$ jbrowse upgrade /path/to/jbrowse2/installation',
|
|
20
|
+
'',
|
|
21
|
+
'# Upgrade to a specific tag',
|
|
22
|
+
'$ jbrowse upgrade /path/to/jbrowse2/installation --tag v1.0.0',
|
|
23
|
+
'',
|
|
24
|
+
'# List versions available on github',
|
|
25
|
+
'$ jbrowse upgrade --listVersions',
|
|
26
|
+
'',
|
|
27
|
+
'# Upgrade from a specific URL',
|
|
28
|
+
'$ jbrowse upgrade --url https://sample.com/jbrowse2.zip',
|
|
29
|
+
'',
|
|
30
|
+
'# Get nightly release from main branch',
|
|
31
|
+
'$ jbrowse upgrade --nightly',
|
|
32
|
+
];
|
|
33
|
+
const options = {
|
|
34
|
+
help: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
short: 'h',
|
|
37
|
+
description: 'Display help for command',
|
|
38
|
+
},
|
|
39
|
+
// will need to account for pagination once there is a lot of releases
|
|
40
|
+
listVersions: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
short: 'l',
|
|
43
|
+
description: 'Lists out all versions of JBrowse 2',
|
|
44
|
+
},
|
|
45
|
+
tag: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
short: 't',
|
|
48
|
+
description: 'Version of JBrowse 2 to install. Format is v1.0.0.\nDefaults to latest',
|
|
49
|
+
},
|
|
50
|
+
branch: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'Download a development build from a named git branch',
|
|
53
|
+
},
|
|
54
|
+
nightly: {
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
description: 'Download the latest development build from the main branch',
|
|
57
|
+
},
|
|
58
|
+
clean: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
description: 'Removes old js,map,and LICENSE files in the installation',
|
|
61
|
+
},
|
|
62
|
+
url: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
short: 'u',
|
|
65
|
+
description: 'A direct URL to a JBrowse 2 release',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
async function run(args) {
|
|
69
|
+
const { positionals, values: runFlags } = (0, util_1.parseArgs)({
|
|
70
|
+
options,
|
|
71
|
+
args,
|
|
72
|
+
allowPositionals: true,
|
|
73
|
+
});
|
|
74
|
+
const argsPath = positionals[0];
|
|
75
|
+
const { clean, listVersions, tag, url, branch, nightly } = runFlags;
|
|
76
|
+
if (runFlags.help) {
|
|
77
|
+
(0, utils_1.printHelp)({
|
|
78
|
+
options,
|
|
79
|
+
examples,
|
|
80
|
+
usage: 'jbrowse upgrade [localPath] [options]',
|
|
81
|
+
description,
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (listVersions) {
|
|
86
|
+
const versions = (await (0, utils_1.fetchGithubVersions)()).map(v => v.tag_name);
|
|
87
|
+
console.log(`All JBrowse versions:\n${versions.join('\n')}`);
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
|
90
|
+
if (!argsPath) {
|
|
91
|
+
throw new Error('No directory supplied');
|
|
92
|
+
}
|
|
93
|
+
if (!fs_1.default.existsSync(path_1.default.join(argsPath, 'manifest.json'))) {
|
|
94
|
+
throw new Error(`No manifest.json found in this directory, are you sure it is an
|
|
95
|
+
existing jbrowse 2 installation?`);
|
|
96
|
+
}
|
|
97
|
+
const locationUrl = url ||
|
|
98
|
+
(nightly ? await (0, utils_1.getBranch)('main') : '') ||
|
|
99
|
+
(branch ? await (0, utils_1.getBranch)(branch) : '') ||
|
|
100
|
+
(tag ? await (0, utils_1.getTag)(tag) : await (0, utils_1.getLatest)());
|
|
101
|
+
console.log(`Fetching ${locationUrl}...`);
|
|
102
|
+
const response = await (0, fetchWithProxy_1.default)(locationUrl);
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
throw new Error(`HTTP ${response.status} fetching ${locationUrl}: ${response.statusText}`);
|
|
105
|
+
}
|
|
106
|
+
const type = response.headers.get('content-type');
|
|
107
|
+
if (url &&
|
|
108
|
+
type !== 'application/zip' &&
|
|
109
|
+
type !== 'application/octet-stream') {
|
|
110
|
+
throw new Error('The URL provided does not seem to be a JBrowse installation URL');
|
|
111
|
+
}
|
|
112
|
+
if (clean) {
|
|
113
|
+
fs_1.default.rmSync(path_1.default.join(argsPath, 'static'), { recursive: true, force: true });
|
|
114
|
+
for (const f of fs_1.default
|
|
115
|
+
.readdirSync(argsPath)
|
|
116
|
+
.filter(f => f.includes('worker.js'))) {
|
|
117
|
+
fs_1.default.unlinkSync(path_1.default.join(argsPath, f));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
await (0, decompress_1.default)(Buffer.from(await response.arrayBuffer()), argsPath);
|
|
121
|
+
console.log(`Unpacked ${locationUrl} at ${argsPath}`);
|
|
122
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.main = main;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
// Command imports
|
|
12
|
+
const add_assembly_1 = require("./commands/add-assembly");
|
|
13
|
+
const add_connection_1 = require("./commands/add-connection");
|
|
14
|
+
const add_track_1 = require("./commands/add-track");
|
|
15
|
+
const add_track_json_1 = require("./commands/add-track-json");
|
|
16
|
+
const admin_server_1 = require("./commands/admin-server");
|
|
17
|
+
const create_1 = require("./commands/create");
|
|
18
|
+
const make_pif_1 = require("./commands/make-pif");
|
|
19
|
+
const remove_track_1 = require("./commands/remove-track");
|
|
20
|
+
const set_default_session_1 = require("./commands/set-default-session");
|
|
21
|
+
const sort_bed_1 = require("./commands/sort-bed");
|
|
22
|
+
const sort_gff_1 = require("./commands/sort-gff");
|
|
23
|
+
const text_index_1 = require("./commands/text-index");
|
|
24
|
+
const upgrade_1 = require("./commands/upgrade");
|
|
25
|
+
const commands = {
|
|
26
|
+
create: create_1.run,
|
|
27
|
+
'add-assembly': add_assembly_1.run,
|
|
28
|
+
'add-track': add_track_1.run,
|
|
29
|
+
'text-index': text_index_1.run,
|
|
30
|
+
'admin-server': admin_server_1.run,
|
|
31
|
+
upgrade: upgrade_1.run,
|
|
32
|
+
'make-pif': make_pif_1.run,
|
|
33
|
+
'sort-gff': sort_gff_1.run,
|
|
34
|
+
'sort-bed': sort_bed_1.run,
|
|
35
|
+
'add-connection': add_connection_1.run,
|
|
36
|
+
'add-track-json': add_track_json_1.run,
|
|
37
|
+
'remove-track': remove_track_1.run,
|
|
38
|
+
'set-default-session': set_default_session_1.run,
|
|
39
|
+
};
|
|
40
|
+
async function main(args) {
|
|
41
|
+
try {
|
|
42
|
+
const { values: flags, positionals } = (0, util_1.parseArgs)({
|
|
43
|
+
args,
|
|
44
|
+
options: {
|
|
45
|
+
help: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
short: 'h',
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
version: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
short: 'v',
|
|
53
|
+
default: false,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
allowPositionals: true,
|
|
57
|
+
strict: false, // Allow unknown flags to be passed to subcommands
|
|
58
|
+
});
|
|
59
|
+
// Check if help or version is requested at the global level
|
|
60
|
+
if (flags.help && positionals.length === 0) {
|
|
61
|
+
showGlobalHelp();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (flags.version && positionals.length === 0) {
|
|
65
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../package.json'), 'utf8'));
|
|
66
|
+
console.log(`@jbrowse/cli version ${packageJson.version}`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const commandName = positionals[0];
|
|
70
|
+
if (!commandName) {
|
|
71
|
+
console.error('Error: Missing command');
|
|
72
|
+
showGlobalHelp();
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
const command = commands[commandName];
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
77
|
+
if (!command) {
|
|
78
|
+
console.error(`Error: Unknown command "${commandName}"`);
|
|
79
|
+
console.error(`Available commands: ${Object.keys(commands).join(', ')}`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
// Pass the remaining arguments to the command
|
|
83
|
+
const commandArgs = args.slice(1); // Remove the command name from args
|
|
84
|
+
await command(commandArgs);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error('Error:', error instanceof Error ? error.message : error);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function showGlobalHelp() {
|
|
92
|
+
console.log(`
|
|
93
|
+
JBrowse CLI
|
|
94
|
+
|
|
95
|
+
USAGE
|
|
96
|
+
$ jbrowse <command> [options]
|
|
97
|
+
|
|
98
|
+
COMMANDS
|
|
99
|
+
create Downloads and installs the latest JBrowse 2 release
|
|
100
|
+
add-assembly Add an assembly to a JBrowse 2 configuration
|
|
101
|
+
add-track Add a track to a JBrowse 2 configuration
|
|
102
|
+
text-index Make a text-indexing file for any given track(s)
|
|
103
|
+
admin-server Start up a small admin server for JBrowse configuration
|
|
104
|
+
upgrade Upgrades JBrowse 2 to latest version
|
|
105
|
+
make-pif Creates pairwise indexed PAF (PIF), with bgzip and tabix
|
|
106
|
+
sort-gff Helper utility to sort GFF files for tabix
|
|
107
|
+
sort-bed Helper utility to sort BED files for tabix
|
|
108
|
+
add-connection Add a connection to a JBrowse 2 configuration
|
|
109
|
+
add-track-json Add a track configuration directly from a JSON hunk
|
|
110
|
+
remove-track Remove a track configuration from a JBrowse 2 configuration
|
|
111
|
+
set-default-session Set a default session with views and tracks
|
|
112
|
+
|
|
113
|
+
OPTIONS
|
|
114
|
+
-h, --help Show help
|
|
115
|
+
-v, --version Show version
|
|
116
|
+
|
|
117
|
+
Use "jbrowse <command> --help" for more information about a command.
|
|
118
|
+
`);
|
|
119
|
+
}
|
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,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "A command line tool for working with JBrowse 2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
7
|
-
"jbrowse2"
|
|
8
|
-
"oclif"
|
|
7
|
+
"jbrowse2"
|
|
9
8
|
],
|
|
10
9
|
"license": "Apache-2.0",
|
|
11
10
|
"homepage": "https://jbrowse.org",
|
|
@@ -16,39 +15,27 @@
|
|
|
16
15
|
"directory": "products/jbrowse-cli"
|
|
17
16
|
},
|
|
18
17
|
"author": "JBrowse Team",
|
|
19
|
-
"main": "
|
|
20
|
-
"types": "lib/index.d.ts",
|
|
18
|
+
"main": "dist/index.js",
|
|
21
19
|
"bin": {
|
|
22
|
-
"jbrowse": "./bin
|
|
20
|
+
"jbrowse": "./dist/bin.js"
|
|
23
21
|
},
|
|
24
22
|
"files": [
|
|
25
23
|
"/bin",
|
|
26
|
-
"/
|
|
27
|
-
"/
|
|
28
|
-
"/oclif.manifest.json"
|
|
24
|
+
"/bundle",
|
|
25
|
+
"/dist"
|
|
29
26
|
],
|
|
30
27
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
28
|
+
"node": ">=18.3.0"
|
|
32
29
|
},
|
|
33
30
|
"scripts": {
|
|
34
31
|
"prebuild": "npm run clean",
|
|
35
|
-
"build": "tsc --build",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"prepack": "npm run clean && npm run build && npm run manifest && npm run docs",
|
|
39
|
-
"manifest": "oclif manifest",
|
|
40
|
-
"version": "npm run docs && npm run docs:version:add",
|
|
32
|
+
"build": "tsc --build && webpack",
|
|
33
|
+
"clean": "rimraf dist bundle",
|
|
34
|
+
"prepack": "npm run clean && npm run docs",
|
|
41
35
|
"predocs": "npm run build",
|
|
42
|
-
"docs": "
|
|
43
|
-
"docs:create": "oclif readme",
|
|
44
|
-
"docs:format": "prettier --write README.md",
|
|
45
|
-
"docs:version:add": "git add README.md"
|
|
36
|
+
"docs": "./generate_readme.sh > README.md"
|
|
46
37
|
},
|
|
47
38
|
"dependencies": {
|
|
48
|
-
"@oclif/core": "^4.0.19",
|
|
49
|
-
"@oclif/plugin-help": "^6.0.15",
|
|
50
|
-
"boxen": "^4.2.0",
|
|
51
|
-
"chalk": "^4.1.0",
|
|
52
39
|
"cli-progress": "^3.9.0",
|
|
53
40
|
"command-exists": "^1.2.9",
|
|
54
41
|
"cors": "^2.8.5",
|
|
@@ -56,22 +43,10 @@
|
|
|
56
43
|
"express": "^4.17.1",
|
|
57
44
|
"ixixx": "^2.0.1",
|
|
58
45
|
"json-parse-better-errors": "^1.0.2",
|
|
59
|
-
"node-fetch-native": "^1.6.4"
|
|
60
|
-
"tslib": "^2.3.1"
|
|
61
|
-
},
|
|
62
|
-
"devDependencies": {
|
|
63
|
-
"typescript": "^5.1.3"
|
|
64
|
-
},
|
|
65
|
-
"oclif": {
|
|
66
|
-
"commands": "./lib/commands",
|
|
67
|
-
"bin": "jbrowse",
|
|
68
|
-
"plugins": [
|
|
69
|
-
"@oclif/plugin-help"
|
|
70
|
-
],
|
|
71
|
-
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/products/jbrowse-cli/<%- commandPath %>"
|
|
46
|
+
"node-fetch-native": "^1.6.4"
|
|
72
47
|
},
|
|
73
48
|
"publishConfig": {
|
|
74
49
|
"access": "public"
|
|
75
50
|
},
|
|
76
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3b7ba0005a28fb0903b7b31f15259c2cfccecfa1"
|
|
77
52
|
}
|
package/bin/dev
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const oclif = require('@oclif/core')
|
|
4
|
-
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const project = path.join(__dirname, '..', 'tsconfig.json')
|
|
7
|
-
|
|
8
|
-
// In dev mode -> use ts-node and dev plugins
|
|
9
|
-
process.env.NODE_ENV = 'development'
|
|
10
|
-
|
|
11
|
-
require('ts-node').register({ project })
|
|
12
|
-
|
|
13
|
-
// In dev mode, always show stack traces
|
|
14
|
-
oclif.settings.debug = true
|
|
15
|
-
|
|
16
|
-
// Start the CLI
|
|
17
|
-
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
package/bin/dev.cmd
DELETED
package/bin/run.cmd
DELETED