@jbrowse/cli 4.0.4 → 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.
Files changed (51) hide show
  1. package/README.md +269 -111
  2. package/bin/run +2 -1
  3. package/bundle/index.js +289 -538
  4. package/dist/base.js +1 -2
  5. package/dist/bin.js +2 -4
  6. package/dist/cliFetch.js +3 -0
  7. package/dist/commands/add-assembly/index.js +19 -22
  8. package/dist/commands/add-assembly/utils.js +75 -92
  9. package/dist/commands/add-connection.js +16 -22
  10. package/dist/commands/add-track-json.js +13 -16
  11. package/dist/commands/add-track-utils/adapter-utils.js +6 -13
  12. package/dist/commands/add-track-utils/file-operations.js +8 -14
  13. package/dist/commands/add-track-utils/track-config.js +10 -18
  14. package/dist/commands/add-track-utils/validators.js +15 -27
  15. package/dist/commands/add-track.js +27 -33
  16. package/dist/commands/admin-server/index.js +24 -30
  17. package/dist/commands/admin-server/utils.js +27 -38
  18. package/dist/commands/create.js +16 -22
  19. package/dist/commands/make-pif/cigar-utils.js +3 -8
  20. package/dist/commands/make-pif/file-utils.js +10 -18
  21. package/dist/commands/make-pif/index.js +13 -16
  22. package/dist/commands/make-pif/pif-generator.js +14 -23
  23. package/dist/commands/process-utils.js +1 -4
  24. package/dist/commands/remove-track.js +8 -11
  25. package/dist/commands/set-default-session.js +13 -19
  26. package/dist/commands/shared/config-operations.js +7 -11
  27. package/dist/commands/shared/sort-utils.js +7 -14
  28. package/dist/commands/shared/validators.js +4 -8
  29. package/dist/commands/sort-bed.js +14 -17
  30. package/dist/commands/sort-gff.js +14 -17
  31. package/dist/commands/text-index/adapter-utils.js +5 -10
  32. package/dist/commands/text-index/aggregate.js +12 -15
  33. package/dist/commands/text-index/command.js +9 -12
  34. package/dist/commands/text-index/config-utils.js +24 -38
  35. package/dist/commands/text-index/file-list.js +11 -17
  36. package/dist/commands/text-index/index.js +4 -11
  37. package/dist/commands/text-index/indexing-utils.js +59 -43
  38. package/dist/commands/text-index/per-track.js +13 -16
  39. package/dist/commands/text-index/validators.js +3 -8
  40. package/dist/commands/track-utils.js +22 -33
  41. package/dist/commands/upgrade.js +20 -26
  42. package/dist/index.js +31 -39
  43. package/dist/types/common.js +5 -107
  44. package/dist/util.js +13 -20
  45. package/dist/utils.js +82 -58
  46. package/dist/version.js +1 -0
  47. package/package.json +7 -6
  48. package/dist/fetchWithProxy.js +0 -12
  49. package/dist/types/gff3Adapter.js +0 -42
  50. package/dist/types/streamUtils.js +0 -66
  51. package/dist/types/vcfAdapter.js +0 -39
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = run;
4
- const util_1 = require("util");
5
- const index_ts_1 = require("./index.js");
6
- const utils_ts_1 = require("../../utils.js");
7
- async function run(args) {
1
+ import { parseArgs } from 'util';
2
+ import { aggregateIndex, indexFileList, perTrackIndex } from "./index.js";
3
+ import { printHelp } from "../../utils.js";
4
+ export async function run(args) {
8
5
  const options = {
9
6
  help: {
10
7
  type: 'boolean',
@@ -74,7 +71,7 @@ async function run(args) {
74
71
  description: 'Just print out tracks that will be indexed by the process, without doing any indexing',
75
72
  },
76
73
  };
77
- const { values: flags } = (0, util_1.parseArgs)({
74
+ const { values: flags } = parseArgs({
78
75
  args,
79
76
  options,
80
77
  });
@@ -99,7 +96,7 @@ async function run(args) {
99
96
  '$ jbrowse text-index --file myfile.gff3.gz --file myfile.vcfgz --out indexes',
100
97
  ];
101
98
  if (flags.help) {
102
- (0, utils_ts_1.printHelp)({
99
+ printHelp({
103
100
  description,
104
101
  examples,
105
102
  usage: 'jbrowse text-index [options]',
@@ -109,12 +106,12 @@ async function run(args) {
109
106
  }
110
107
  const { perTrack, file } = flags;
111
108
  if (file) {
112
- await (0, index_ts_1.indexFileList)(flags);
109
+ await indexFileList(flags);
113
110
  }
114
111
  else if (perTrack) {
115
- await (0, index_ts_1.perTrackIndex)(flags);
112
+ await perTrackIndex(flags);
116
113
  }
117
114
  else {
118
- await (0, index_ts_1.aggregateIndex)(flags);
115
+ await aggregateIndex(flags);
119
116
  }
120
117
  }
@@ -1,25 +1,10 @@
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.parseCommaSeparatedString = parseCommaSeparatedString;
7
- exports.sanitizeNameForPath = sanitizeNameForPath;
8
- exports.validatePrefixSize = validatePrefixSize;
9
- exports.prepareIndexDriverFlags = prepareIndexDriverFlags;
10
- exports.readConf = readConf;
11
- exports.writeConf = writeConf;
12
- exports.loadConfigForIndexing = loadConfigForIndexing;
13
- exports.ensureTrixDir = ensureTrixDir;
14
- exports.getAssemblyNames = getAssemblyNames;
15
- exports.getTrackConfigs = getTrackConfigs;
16
- const fs_1 = __importDefault(require("fs"));
17
- const path_1 = __importDefault(require("path"));
18
- const common_ts_1 = require("../../types/common.js");
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { supported } from "../../types/common.js";
19
4
  /**
20
5
  * Parses a comma-separated string into an array of trimmed, non-empty strings
21
6
  */
22
- function parseCommaSeparatedString(value) {
7
+ export function parseCommaSeparatedString(value) {
23
8
  return (value
24
9
  ?.split(',')
25
10
  .map(s => s.trim())
@@ -29,13 +14,13 @@ function parseCommaSeparatedString(value) {
29
14
  * Sanitizes a name for use in file paths by replacing invalid characters
30
15
  * Replaces characters that are problematic in file paths: / \ : * ? " < > |
31
16
  */
32
- function sanitizeNameForPath(name) {
17
+ export function sanitizeNameForPath(name) {
33
18
  return name.replace(/[/\\:*?"<>|]/g, '_');
34
19
  }
35
20
  /**
36
21
  * Validates and parses a prefix size value
37
22
  */
38
- function validatePrefixSize(value) {
23
+ export function validatePrefixSize(value) {
39
24
  if (!value) {
40
25
  return undefined;
41
26
  }
@@ -48,7 +33,7 @@ function validatePrefixSize(value) {
48
33
  /**
49
34
  * Prepares common indexDriver parameters from raw flag values
50
35
  */
51
- function prepareIndexDriverFlags(flags) {
36
+ export function prepareIndexDriverFlags(flags) {
52
37
  return {
53
38
  attributes: parseCommaSeparatedString(flags.attributes),
54
39
  typesToExclude: parseCommaSeparatedString(flags.exclude),
@@ -56,26 +41,26 @@ function prepareIndexDriverFlags(flags) {
56
41
  prefixSize: validatePrefixSize(flags.prefixSize),
57
42
  };
58
43
  }
59
- function readConf(configPath) {
60
- return JSON.parse(fs_1.default.readFileSync(configPath, 'utf8'));
44
+ export function readConf(configPath) {
45
+ return JSON.parse(fs.readFileSync(configPath, 'utf8'));
61
46
  }
62
- function writeConf(obj, configPath) {
63
- fs_1.default.writeFileSync(configPath, JSON.stringify(obj, null, 2));
47
+ export function writeConf(obj, configPath) {
48
+ fs.writeFileSync(configPath, JSON.stringify(obj, null, 2));
64
49
  }
65
50
  /**
66
51
  * Loads config and prepares output location for indexing
67
52
  */
68
- async function loadConfigForIndexing(target, out, resolveConfigPath) {
53
+ export async function loadConfigForIndexing(target, out, resolveConfigPath) {
69
54
  const configPath = await resolveConfigPath(target, out);
70
- const outLocation = path_1.default.dirname(configPath);
55
+ const outLocation = path.dirname(configPath);
71
56
  const config = readConf(configPath);
72
57
  ensureTrixDir(outLocation);
73
58
  return { config, configPath, outLocation };
74
59
  }
75
- function ensureTrixDir(outLocation) {
76
- const trixDir = path_1.default.join(outLocation, 'trix');
77
- if (!fs_1.default.existsSync(trixDir)) {
78
- fs_1.default.mkdirSync(trixDir);
60
+ export function ensureTrixDir(outLocation) {
61
+ const trixDir = path.join(outLocation, 'trix');
62
+ if (!fs.existsSync(trixDir)) {
63
+ fs.mkdirSync(trixDir, { recursive: true });
79
64
  }
80
65
  return trixDir;
81
66
  }
@@ -92,7 +77,7 @@ function extractAssemblyNamesFromConfig(config) {
92
77
  }
93
78
  return [];
94
79
  }
95
- function getAssemblyNames(config, assemblies) {
80
+ export function getAssemblyNames(config, assemblies) {
96
81
  const asms = assemblies
97
82
  ? parseCommaSeparatedString(assemblies)
98
83
  : extractAssemblyNamesFromConfig(config);
@@ -101,12 +86,14 @@ function getAssemblyNames(config, assemblies) {
101
86
  }
102
87
  return asms;
103
88
  }
104
- function getTrackConfigs(config, trackIds, assemblyName, excludeTrackIds) {
89
+ export function getTrackConfigs(config, trackIds, assemblyName, excludeTrackIds) {
105
90
  const { tracks } = config;
106
91
  if (!tracks) {
107
92
  return [];
108
93
  }
109
- const trackIdsToIndex = trackIds || tracks.map(track => track.trackId);
94
+ const trackIdsToIndex = trackIds?.length
95
+ ? trackIds
96
+ : tracks.map(track => track.trackId);
110
97
  const excludeSet = new Set(excludeTrackIds || []);
111
98
  return trackIdsToIndex
112
99
  .map(trackId => {
@@ -118,11 +105,10 @@ function getTrackConfigs(config, trackIds, assemblyName, excludeTrackIds) {
118
105
  })
119
106
  .filter(track => {
120
107
  if (excludeSet.has(track.trackId)) {
121
- console.log(`Skipping ${track.trackId}: excluded via --exclude-tracks`);
108
+ // console.log(`Skipping ${track.trackId}: excluded via --exclude-tracks`)
122
109
  return false;
123
110
  }
124
- if (!(0, common_ts_1.supported)(track.adapter?.type)) {
125
- console.log(`Skipping ${track.trackId}: unsupported adapter type '${track.adapter?.type}'`);
111
+ if (!supported(track.adapter?.type)) {
126
112
  return false;
127
113
  }
128
114
  if (assemblyName && !track.assemblyNames.includes(assemblyName)) {
@@ -1,28 +1,22 @@
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.indexFileList = indexFileList;
7
- const path_1 = __importDefault(require("path"));
8
- const config_utils_ts_1 = require("./config-utils.js");
9
- const indexing_utils_ts_1 = require("./indexing-utils.js");
10
- const validators_ts_1 = require("./validators.js");
11
- async function indexFileList(flags) {
1
+ import path from 'path';
2
+ import { ensureTrixDir, prepareIndexDriverFlags, sanitizeNameForPath, } from "./config-utils.js";
3
+ import { indexDriver, prepareFileTrackConfigs } from "./indexing-utils.js";
4
+ import { validateFileInput } from "./validators.js";
5
+ export async function indexFileList(flags) {
12
6
  const { out, target, fileId, file, attributes, quiet, exclude, prefixSize } = flags;
13
- (0, validators_ts_1.validateFileInput)(file);
7
+ validateFileInput(file);
14
8
  const outFlag = target || out || '.';
15
- (0, config_utils_ts_1.ensureTrixDir)(outFlag);
16
- const trackConfigs = (0, indexing_utils_ts_1.prepareFileTrackConfigs)(file, fileId);
9
+ ensureTrixDir(outFlag);
10
+ const trackConfigs = prepareFileTrackConfigs(file, fileId);
17
11
  const name = trackConfigs.length > 1
18
12
  ? 'aggregate'
19
- : (0, config_utils_ts_1.sanitizeNameForPath)(path_1.default.basename(file[0]));
20
- await (0, indexing_utils_ts_1.indexDriver)({
13
+ : sanitizeNameForPath(path.basename(file[0]));
14
+ await indexDriver({
21
15
  trackConfigs,
22
16
  outLocation: outFlag,
23
17
  name,
24
18
  assemblyNames: [],
25
- ...(0, config_utils_ts_1.prepareIndexDriverFlags)({ attributes, exclude, quiet, prefixSize }),
19
+ ...prepareIndexDriverFlags({ attributes, exclude, quiet, prefixSize }),
26
20
  });
27
21
  console.log('Successfully created index for these files. See https://jbrowse.org/storybook/lgv/main/?path=/story/text-searching--page for info about usage');
28
22
  }
@@ -1,11 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = exports.indexFileList = exports.perTrackIndex = exports.aggregateIndex = void 0;
4
- var aggregate_ts_1 = require("./aggregate.js");
5
- Object.defineProperty(exports, "aggregateIndex", { enumerable: true, get: function () { return aggregate_ts_1.aggregateIndex; } });
6
- var per_track_ts_1 = require("./per-track.js");
7
- Object.defineProperty(exports, "perTrackIndex", { enumerable: true, get: function () { return per_track_ts_1.perTrackIndex; } });
8
- var file_list_ts_1 = require("./file-list.js");
9
- Object.defineProperty(exports, "indexFileList", { enumerable: true, get: function () { return file_list_ts_1.indexFileList; } });
10
- var command_ts_1 = require("./command.js");
11
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return command_ts_1.run; } });
1
+ export { aggregateIndex } from "./aggregate.js";
2
+ export { perTrackIndex } from "./per-track.js";
3
+ export { indexFileList } from "./file-list.js";
4
+ export { run } from "./command.js";
@@ -1,64 +1,80 @@
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.runIxIxx = runIxIxx;
7
- exports.indexFiles = indexFiles;
8
- exports.indexDriver = indexDriver;
9
- exports.prepareFileTrackConfigs = prepareFileTrackConfigs;
10
- const path_1 = __importDefault(require("path"));
11
- const stream_1 = require("stream");
12
- const cli_progress_1 = require("cli-progress");
13
- const ixixx_1 = require("ixixx");
14
- const adapter_utils_ts_1 = require("./adapter-utils.js");
15
- const common_ts_1 = require("../../types/common.js");
16
- const gff3Adapter_ts_1 = require("../../types/gff3Adapter.js");
17
- const vcfAdapter_ts_1 = require("../../types/vcfAdapter.js");
18
- async function runIxIxx({ readStream, outLocation, name, prefixSize, quiet, }) {
19
- const progressBar = new cli_progress_1.SingleBar({ format: '{bar} Sorting and writing index...', etaBuffer: 2000 }, cli_progress_1.Presets.shades_classic);
1
+ import path from 'path';
2
+ import { Readable } from 'stream';
3
+ import { generateMeta, guessAdapterFromFileName, indexGff3, indexVcf, } from '@jbrowse/text-indexing-core';
4
+ import { Presets, SingleBar } from 'cli-progress';
5
+ import { ixIxxStream } from 'ixixx';
6
+ import { getAdapterLocation, getLoc } from "./adapter-utils.js";
7
+ import { supported } from "../../types/common.js";
8
+ export async function runIxIxx({ readStream, outLocation, name, prefixSize, quiet, }) {
9
+ const progressBar = new SingleBar({ format: '{bar} Sorting and writing index...', etaBuffer: 2000 }, Presets.shades_classic);
20
10
  if (!quiet) {
21
11
  progressBar.start(1, 0);
22
12
  }
23
- await (0, ixixx_1.ixIxxStream)(readStream, path_1.default.join(outLocation, 'trix', `${name}.ix`), path_1.default.join(outLocation, 'trix', `${name}.ixx`), prefixSize);
13
+ const ixPath = path.join(outLocation, 'trix', `${name}.ix`);
14
+ const ixxPath = path.join(outLocation, 'trix', `${name}.ixx`);
15
+ await ixIxxStream(readStream, ixPath, ixxPath, prefixSize);
24
16
  if (!quiet) {
25
17
  progressBar.update(1);
26
18
  progressBar.stop();
27
19
  }
28
20
  }
29
- async function* indexFiles({ trackConfigs, attributes, outLocation, quiet, typesToExclude, }) {
21
+ export async function* indexFiles({ trackConfigs, attributes, outLocation, quiet, typesToExclude, }) {
30
22
  for (const config of trackConfigs) {
31
- const { adapter, textSearching } = config;
23
+ const { adapter, textSearching, trackId } = config;
32
24
  const { type } = adapter || {};
33
25
  const { indexingFeatureTypesToExclude = typesToExclude, indexingAttributes = attributes, } = textSearching || {};
34
- const loc = (0, adapter_utils_ts_1.getAdapterLocation)(adapter);
26
+ const loc = getAdapterLocation(adapter);
35
27
  if (!loc) {
36
28
  continue;
37
29
  }
30
+ const progressBar = new SingleBar({
31
+ format: `{bar} ${trackId} {percentage}% | ETA: {eta}s`,
32
+ etaBuffer: 2000,
33
+ }, Presets.shades_classic);
38
34
  if (type === 'Gff3TabixAdapter' || type === 'Gff3Adapter') {
39
- yield* (0, gff3Adapter_ts_1.indexGff3)({
35
+ yield* indexGff3({
40
36
  config,
41
37
  attributesToIndex: indexingAttributes,
42
- inLocation: (0, adapter_utils_ts_1.getLoc)(loc),
43
- outLocation,
44
- typesToExclude: indexingFeatureTypesToExclude,
45
- quiet,
38
+ inLocation: getLoc(loc),
39
+ outDir: outLocation,
40
+ featureTypesToExclude: indexingFeatureTypesToExclude,
41
+ onStart: totalBytes => {
42
+ if (!quiet) {
43
+ progressBar.start(totalBytes, 0);
44
+ }
45
+ },
46
+ onUpdate: receivedBytes => {
47
+ if (!quiet) {
48
+ progressBar.update(receivedBytes);
49
+ }
50
+ },
46
51
  });
47
52
  }
48
53
  else if (type === 'VcfTabixAdapter' || type === 'VcfAdapter') {
49
- yield* (0, vcfAdapter_ts_1.indexVcf)({
54
+ yield* indexVcf({
50
55
  config,
51
56
  attributesToIndex: indexingAttributes,
52
- inLocation: (0, adapter_utils_ts_1.getLoc)(loc),
53
- outLocation,
54
- typesToExclude: indexingFeatureTypesToExclude,
55
- quiet,
57
+ inLocation: getLoc(loc),
58
+ outDir: outLocation,
59
+ onStart: totalBytes => {
60
+ if (!quiet) {
61
+ progressBar.start(totalBytes, 0);
62
+ }
63
+ },
64
+ onUpdate: receivedBytes => {
65
+ if (!quiet) {
66
+ progressBar.update(receivedBytes);
67
+ }
68
+ },
56
69
  });
57
70
  }
71
+ if (!quiet) {
72
+ progressBar.stop();
73
+ }
58
74
  }
59
75
  }
60
- async function indexDriver({ trackConfigs, attributes, outLocation, name, quiet, typesToExclude, assemblyNames, prefixSize, }) {
61
- const readStream = stream_1.Readable.from(indexFiles({
76
+ export async function indexDriver({ trackConfigs, attributes, outLocation, name, quiet, typesToExclude, assemblyNames, prefixSize, }) {
77
+ const readStream = Readable.from(indexFiles({
62
78
  trackConfigs,
63
79
  attributes,
64
80
  outLocation,
@@ -72,23 +88,23 @@ async function indexDriver({ trackConfigs, attributes, outLocation, name, quiet,
72
88
  prefixSize,
73
89
  quiet,
74
90
  });
75
- await (0, common_ts_1.generateMeta)({
76
- trackConfigs,
77
- attributes,
78
- outLocation,
91
+ await generateMeta({
92
+ configs: trackConfigs,
93
+ attributesToIndex: attributes,
94
+ outDir: outLocation,
79
95
  name,
80
- typesToExclude,
96
+ featureTypesToExclude: typesToExclude,
81
97
  assemblyNames,
82
98
  });
83
99
  }
84
- function prepareFileTrackConfigs(files, fileIds) {
100
+ export function prepareFileTrackConfigs(files, fileIds) {
85
101
  return files
86
102
  .map((file, i) => {
87
- const config = (0, common_ts_1.guessAdapterFromFileName)(file);
103
+ const config = guessAdapterFromFileName(file);
88
104
  if (fileIds?.[i]) {
89
105
  config.trackId = fileIds[i];
90
106
  }
91
107
  return config;
92
108
  })
93
- .filter(fileConfig => (0, common_ts_1.supported)(fileConfig.adapter?.type));
109
+ .filter(fileConfig => supported(fileConfig.adapter?.type));
94
110
  }
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.perTrackIndex = perTrackIndex;
4
- const adapter_utils_ts_1 = require("./adapter-utils.js");
5
- const config_utils_ts_1 = require("./config-utils.js");
6
- const indexing_utils_ts_1 = require("./indexing-utils.js");
7
- const validators_ts_1 = require("./validators.js");
8
- const utils_ts_1 = require("../../utils.js");
9
- async function perTrackIndex(flags) {
1
+ import { createTrixAdapter } from "./adapter-utils.js";
2
+ import { getTrackConfigs, loadConfigForIndexing, parseCommaSeparatedString, prepareIndexDriverFlags, writeConf, } from "./config-utils.js";
3
+ import { indexDriver } from "./indexing-utils.js";
4
+ import { validateAssembliesForPerTrack } from "./validators.js";
5
+ import { resolveConfigPath } from "../../utils.js";
6
+ export async function perTrackIndex(flags) {
10
7
  const { out, target, tracks, excludeTracks, assemblies, attributes, quiet, force, exclude, prefixSize, } = flags;
11
- const { config, configPath, outLocation } = await (0, config_utils_ts_1.loadConfigForIndexing)(target, out, utils_ts_1.resolveConfigPath);
8
+ const { config, configPath, outLocation } = await loadConfigForIndexing(target, out, resolveConfigPath);
12
9
  const configTracks = config.tracks || [];
13
- (0, validators_ts_1.validateAssembliesForPerTrack)(assemblies);
14
- const confs = (0, config_utils_ts_1.getTrackConfigs)(config, (0, config_utils_ts_1.parseCommaSeparatedString)(tracks), undefined, (0, config_utils_ts_1.parseCommaSeparatedString)(excludeTracks));
10
+ validateAssembliesForPerTrack(assemblies);
11
+ const confs = getTrackConfigs(config, parseCommaSeparatedString(tracks), undefined, parseCommaSeparatedString(excludeTracks));
15
12
  if (!confs.length) {
16
13
  throw new Error('Tracks not found in config.json, please add track configurations before indexing.');
17
14
  }
@@ -23,12 +20,12 @@ async function perTrackIndex(flags) {
23
20
  continue;
24
21
  }
25
22
  console.log(`Indexing track ${trackId}...`);
26
- await (0, indexing_utils_ts_1.indexDriver)({
23
+ await indexDriver({
27
24
  trackConfigs: [trackConfig],
28
25
  outLocation,
29
26
  name: trackId,
30
27
  assemblyNames,
31
- ...(0, config_utils_ts_1.prepareIndexDriverFlags)({ attributes, exclude, quiet, prefixSize }),
28
+ ...prepareIndexDriverFlags({ attributes, exclude, quiet, prefixSize }),
32
29
  });
33
30
  if (!textSearching?.textSearchAdapter) {
34
31
  // modifies track with new text search adapter
@@ -38,7 +35,7 @@ async function perTrackIndex(flags) {
38
35
  ...trackConfig,
39
36
  textSearching: {
40
37
  ...textSearching,
41
- textSearchAdapter: (0, adapter_utils_ts_1.createTrixAdapter)(trackId, assemblyNames),
38
+ textSearchAdapter: createTrixAdapter(trackId, assemblyNames),
42
39
  },
43
40
  };
44
41
  hasChanges = true;
@@ -49,6 +46,6 @@ async function perTrackIndex(flags) {
49
46
  }
50
47
  }
51
48
  if (hasChanges) {
52
- (0, config_utils_ts_1.writeConf)({ ...config, tracks: configTracks }, configPath);
49
+ writeConf({ ...config, tracks: configTracks }, configPath);
53
50
  }
54
51
  }
@@ -1,19 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateTrackConfigs = validateTrackConfigs;
4
- exports.validateFileInput = validateFileInput;
5
- exports.validateAssembliesForPerTrack = validateAssembliesForPerTrack;
6
- function validateTrackConfigs(tracks) {
1
+ export function validateTrackConfigs(tracks) {
7
2
  if (!tracks.length) {
8
3
  throw new Error('Tracks not found in config.json, please add track configurations before indexing.');
9
4
  }
10
5
  }
11
- function validateFileInput(file) {
6
+ export function validateFileInput(file) {
12
7
  if (!file) {
13
8
  throw new Error('Cannot index file list without files');
14
9
  }
15
10
  }
16
- function validateAssembliesForPerTrack(assemblies) {
11
+ export function validateAssembliesForPerTrack(assemblies) {
17
12
  if (assemblies) {
18
13
  throw new Error(`Can't specify assemblies when indexing per track, remove assemblies flag to continue.`);
19
14
  }
@@ -1,29 +1,18 @@
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.loadTrackConfig = loadTrackConfig;
7
- exports.processTrackFiles = processTrackFiles;
8
- exports.addTrackToConfig = addTrackToConfig;
9
- exports.saveTrackConfigAndReport = saveTrackConfigAndReport;
10
- exports.buildTrackParams = buildTrackParams;
11
- exports.createTrackConfiguration = createTrackConfiguration;
12
- const path_1 = __importDefault(require("path"));
13
- const utils_ts_1 = require("../utils.js");
14
- const adapter_utils_ts_1 = require("./add-track-utils/adapter-utils.js");
15
- const file_operations_ts_1 = require("./add-track-utils/file-operations.js");
16
- const track_config_ts_1 = require("./add-track-utils/track-config.js");
17
- const validators_ts_1 = require("./add-track-utils/validators.js");
18
- const config_operations_ts_1 = require("./shared/config-operations.js");
19
- async function loadTrackConfig(targetConfigPath) {
20
- return await (0, utils_ts_1.readJsonFile)(targetConfigPath);
1
+ import path from 'path';
2
+ import { readJsonFile } from "../utils.js";
3
+ import { guessFileNames, guessTrackType, } from "./add-track-utils/adapter-utils.js";
4
+ import { loadFile } from "./add-track-utils/file-operations.js";
5
+ import { buildTrackConfig } from "./add-track-utils/track-config.js";
6
+ import { validateTrackId } from "./add-track-utils/validators.js";
7
+ import { findAndUpdateOrAdd, saveConfigAndReport as saveConfigAndReportBase, } from "./shared/config-operations.js";
8
+ export async function loadTrackConfig(targetConfigPath) {
9
+ return await readJsonFile(targetConfigPath);
21
10
  }
22
- async function processTrackFiles({ location, index, bed1, bed2, load, configDir, subDir, force, }) {
11
+ export async function processTrackFiles({ location, index, bed1, bed2, load, configDir, subDir, force, }) {
23
12
  if (load) {
24
- await Promise.all(Object.values((0, adapter_utils_ts_1.guessFileNames)({ location, index, bed1, bed2 }))
13
+ await Promise.all(Object.values(guessFileNames({ location, index, bed1, bed2 }))
25
14
  .filter(f => !!f)
26
- .map(src => (0, file_operations_ts_1.loadFile)({
15
+ .map(src => loadFile({
27
16
  src,
28
17
  destDir: configDir,
29
18
  mode: load,
@@ -32,9 +21,9 @@ async function processTrackFiles({ location, index, bed1, bed2, load, configDir,
32
21
  })));
33
22
  }
34
23
  }
35
- function addTrackToConfig({ configContents, trackConfig, trackId, force, overwrite, }) {
36
- (0, validators_ts_1.validateTrackId)(configContents, trackId, force, overwrite);
37
- const { updatedItems, wasOverwritten } = (0, config_operations_ts_1.findAndUpdateOrAdd)({
24
+ export function addTrackToConfig({ configContents, trackConfig, trackId, force, overwrite, }) {
25
+ validateTrackId(configContents, trackId, force, overwrite);
26
+ const { updatedItems, wasOverwritten } = findAndUpdateOrAdd({
38
27
  items: configContents.tracks || [],
39
28
  newItem: trackConfig,
40
29
  idField: 'trackId',
@@ -47,8 +36,8 @@ function addTrackToConfig({ configContents, trackConfig, trackId, force, overwri
47
36
  wasOverwritten,
48
37
  };
49
38
  }
50
- async function saveTrackConfigAndReport({ config, targetConfigPath, name, trackId, wasOverwritten, }) {
51
- await (0, config_operations_ts_1.saveConfigAndReport)({
39
+ export async function saveTrackConfigAndReport({ config, targetConfigPath, name, trackId, wasOverwritten, }) {
40
+ await saveConfigAndReportBase({
52
41
  config,
53
42
  target: targetConfigPath,
54
43
  itemType: 'track',
@@ -57,9 +46,9 @@ async function saveTrackConfigAndReport({ config, targetConfigPath, name, trackI
57
46
  wasOverwritten,
58
47
  });
59
48
  }
60
- function buildTrackParams({ flags, location, adapter, configContents, }) {
61
- const trackType = flags.trackType || (0, adapter_utils_ts_1.guessTrackType)(adapter.type);
62
- const trackId = flags.trackId || path_1.default.basename(location, path_1.default.extname(location));
49
+ export function buildTrackParams({ flags, location, adapter, configContents, }) {
50
+ const trackType = flags.trackType || guessTrackType(adapter.type);
51
+ const trackId = flags.trackId || path.basename(location, path.extname(location));
63
52
  const name = flags.name || trackId;
64
53
  const assemblyNames = flags.assemblyNames || configContents.assemblies?.[0]?.name || '';
65
54
  return {
@@ -69,8 +58,8 @@ function buildTrackParams({ flags, location, adapter, configContents, }) {
69
58
  assemblyNames,
70
59
  };
71
60
  }
72
- function createTrackConfiguration({ location, trackParams, flags, adapter, configContents, }) {
73
- return (0, track_config_ts_1.buildTrackConfig)({
61
+ export function createTrackConfiguration({ location, trackParams, flags, adapter, configContents, }) {
62
+ return buildTrackConfig({
74
63
  location,
75
64
  trackType: trackParams.trackType,
76
65
  trackId: trackParams.trackId,