sfmc-dataloader 2.0.0 → 2.0.2

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 (2) hide show
  1. package/lib/cli.mjs +19 -0
  2. package/package.json +1 -1
package/lib/cli.mjs CHANGED
@@ -1,6 +1,8 @@
1
+ import { readFileSync } from 'node:fs';
1
2
  import { parseArgs } from 'node:util';
2
3
  import process from 'node:process';
3
4
  import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
4
6
  import SDK from 'sfmc-sdk';
5
7
  import {
6
8
  loadMcdevProject,
@@ -18,6 +20,17 @@ import { confirmClearBeforeImport } from './confirm-clear.mjs';
18
20
  import { multiBuExport } from './multi-bu-export.mjs';
19
21
  import { crossBuImport } from './cross-bu-import.mjs';
20
22
 
23
+ /** @returns {string} semver from this package's package.json */
24
+ function readCliPackageVersion() {
25
+ const injected = globalThis.__sfmc_dataloader_version__;
26
+ if (typeof injected === 'string' && injected.length > 0) {
27
+ return injected;
28
+ }
29
+ const pkgPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
30
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
31
+ return typeof pkg.version === 'string' ? pkg.version : '';
32
+ }
33
+
21
34
  function printHelp() {
22
35
  console.log(`mcdata — SFMC Data Extension export/import (mcdev project)
23
36
 
@@ -29,6 +42,7 @@ Usage:
29
42
  mcdata import --to <cred>/<bu> [--to <cred>/<bu> ...] --file <path> [--file <path> ...] [options]
30
43
 
31
44
  Options:
45
+ --version Print version and exit
32
46
  -p, --project <dir> mcdev project root (default: cwd)
33
47
  --format <csv|tsv|json> File format (default: csv)
34
48
  --json-pretty Pretty-print JSON on export
@@ -82,6 +96,7 @@ export async function main(argv) {
82
96
  'i-accept-clear-data-risk': { type: 'boolean', default: false },
83
97
  'json-pretty': { type: 'boolean', default: false },
84
98
  help: { type: 'boolean', short: 'h', default: false },
99
+ version: { type: 'boolean', default: false },
85
100
  },
86
101
  });
87
102
  values = parsed.values;
@@ -96,6 +111,10 @@ export async function main(argv) {
96
111
  printHelp();
97
112
  return 0;
98
113
  }
114
+ if (values.version) {
115
+ console.log(readCliPackageVersion());
116
+ return 0;
117
+ }
99
118
  if (positionals.length === 0) {
100
119
  printHelp();
101
120
  return 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfmc-dataloader",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "SFMC Data Loader CLI (mcdata) to export and import Marketing Cloud Data Extension rows using mcdev project config and sfmc-sdk",
5
5
  "author": "Jörn Berkefeld <joern.berkefeld@gmail.com>",
6
6
  "license": "MIT",