@radiantearth/stac-migrate 2.0.1 → 2.1.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 (5) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +81 -41
  3. package/bin/cli.js +20 -20
  4. package/migrate.js +244 -190
  5. package/package.json +10 -7
package/bin/cli.js CHANGED
@@ -1,73 +1,73 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs');
3
- const yargs = require('yargs/yargs')
4
- const { hideBin } = require('yargs/helpers')
3
+ const yargs = require('yargs/yargs');
4
+ const { hideBin } = require('yargs/helpers');
5
5
  const Migrate = require('../migrate');
6
- const package = require("../package.json");
6
+ const package = require('../package.json');
7
7
 
8
8
  const args = yargs(hideBin(process.argv))
9
9
  .option('_', {
10
10
  type: 'string',
11
- describe: 'File to load the STAC data from'
11
+ describe: 'File to load the STAC data from',
12
12
  })
13
13
  .option('dest', {
14
14
  type: 'string',
15
15
  description: 'File to save the result to',
16
- alias: 'd'
16
+ alias: 'd',
17
17
  })
18
18
  .option('collection', {
19
19
  type: 'boolean',
20
20
  description: 'Enforce the collection migration',
21
21
  conflicts: ['catalog', 'collections', 'item', 'item_collection'],
22
-
23
22
  })
24
23
  .option('catalog', {
25
24
  type: 'boolean',
26
25
  description: 'Enforce the catalog migration',
27
- conflicts: ['collection', 'collections', 'item', 'item_collection']
26
+ conflicts: ['collection', 'collections', 'item', 'item_collection'],
28
27
  })
29
28
  .option('item', {
30
29
  type: 'boolean',
31
30
  description: 'Enforce the item migration',
32
- conflicts: ['catalog', 'collection', 'collections', 'item_collection']
31
+ conflicts: ['catalog', 'collection', 'collections', 'item_collection'],
33
32
  })
34
33
  .option('item_collection', {
35
34
  type: 'boolean',
36
35
  description: 'Enforce the item collection migration',
37
- conflicts: ['catalog', 'collection', 'collections', 'item']
36
+ conflicts: ['catalog', 'collection', 'collections', 'item'],
38
37
  })
39
38
  .option('collections', {
40
39
  type: 'boolean',
41
40
  description: 'Enforce the collection collection migration',
42
- conflicts: ['catalog', 'collection', 'item', 'item_collection']
41
+ conflicts: ['catalog', 'collection', 'item', 'item_collection'],
43
42
  })
44
43
  .option('collection_path', {
45
44
  type: 'string',
46
45
  description: 'Pass the path to a collection to the item, only possible if --item has been specified.',
47
- conflicts: ['catalog', 'collection', 'collections', 'item_collection']
46
+ conflicts: ['catalog', 'collection', 'collections', 'item_collection'],
48
47
  })
49
48
  .option('indent', {
50
49
  type: 'number',
51
50
  description: 'Number of spaces to use for JSON indentation',
52
- default: 2
51
+ default: 2,
53
52
  })
54
53
  .help()
55
- .parse()
54
+ .parse();
56
55
 
57
56
  run(args);
58
57
 
59
58
  function run(args) {
60
- console.log("STAC Migrate v" + package.version);
61
- let fn = ['collection', 'collections', 'catalog', 'item', 'item_collection'].find(type => Boolean(args[type])) || 'stac';
59
+ console.log('STAC Migrate v' + package.version);
60
+ let fn =
61
+ ['collection', 'collections', 'catalog', 'item', 'item_collection'].find((type) => Boolean(args[type])) || 'stac';
62
62
  let fns = {
63
63
  item_collection: 'itemCollection',
64
- collections: 'collectionCollection'
64
+ collections: 'collectionCollection',
65
65
  };
66
66
  if (fns[fn]) {
67
67
  fn = fns[fn];
68
68
  }
69
69
  if (args._.length !== 1) {
70
- throw new Error("Please provide exactly one source file.");
70
+ throw new Error('Please provide exactly one source file.');
71
71
  }
72
72
  let src = args._[0];
73
73
  let dest = args.dest || src;
@@ -80,8 +80,8 @@ function run(args) {
80
80
  let collestionObj = JSON.parse(collestionStr);
81
81
  options.push(collestionObj);
82
82
  }
83
- Migrate[fn](...options)
83
+ Migrate[fn](...options);
84
84
  dataStr = JSON.stringify(dataObj, null, args.indent);
85
85
  fs.writeFileSync(dest, dataStr);
86
- console.log("Migrated successfully: " + dest);
87
- }
86
+ console.log('Migrated successfully: ' + dest);
87
+ }