@adobe/helix-onedrive-cli 1.10.7 → 1.10.11

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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.10.11](https://github.com/adobe/helix-onedrive-cli/compare/v1.10.10...v1.10.11) (2021-12-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/helix-shared-config to v1.7.1 ([#250](https://github.com/adobe/helix-onedrive-cli/issues/250)) ([e96f966](https://github.com/adobe/helix-onedrive-cli/commit/e96f966c31ccb1f041e9073fc9b4c0842f9f223f))
7
+
8
+ ## [1.10.10](https://github.com/adobe/helix-onedrive-cli/compare/v1.10.9...v1.10.10) (2021-12-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency chalk to v5 ([#246](https://github.com/adobe/helix-onedrive-cli/issues/246)) ([1f0c12d](https://github.com/adobe/helix-onedrive-cli/commit/1f0c12d988ad3777719c1df6790c2b1361b98f7f))
14
+
15
+ ## [1.10.9](https://github.com/adobe/helix-onedrive-cli/compare/v1.10.8...v1.10.9) (2021-12-04)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update dependency @adobe/helix-shared-config to v1.7.0 ([aa6a97c](https://github.com/adobe/helix-onedrive-cli/commit/aa6a97cd589748f7f6bfa241c6fbd81992102a90))
21
+
22
+ ## [1.10.8](https://github.com/adobe/helix-onedrive-cli/compare/v1.10.7...v1.10.8) (2021-12-02)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **deps:** update dependency @adobe/helix-shared-config to v1.6.0 ([f53cd98](https://github.com/adobe/helix-onedrive-cli/commit/f53cd9816616d77e4dfbb1c44f653e7c7c86bb41))
28
+
1
29
  ## [1.10.7](https://github.com/adobe/helix-onedrive-cli/compare/v1.10.6...v1.10.7) (2021-11-27)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@adobe/helix-onedrive-cli",
3
- "version": "1.10.7",
3
+ "version": "1.10.11",
4
4
  "description": "Helix OneDrive CLI",
5
5
  "main": "src/index.js",
6
+ "type": "module",
6
7
  "bin": {
7
8
  "1d": "src/index.js"
8
9
  },
9
10
  "scripts": {
10
11
  "start": "nodemon --watch src src/browser.js",
11
- "test": " nyc --reporter=text --reporter=lcov --check-coverage --branches 4 --statements 20 --lines 20 mocha",
12
- "test-ci": "nyc --reporter=text --reporter=lcov --check-coverage --branches 4 --statements 20 --lines 20 mocha --reporter xunit --reporter-options output=./junit/test-results.xml && codecov",
13
- "lint": "./node_modules/.bin/eslint .",
12
+ "test": "c8 --reporter=text --reporter=lcov --check-coverage --branches 4 --statements 20 --lines 20 mocha",
13
+ "test-ci": "c8 --reporter=text --reporter=lcov --check-coverage --branches 4 --statements 20 --lines 20 mocha --reporter xunit --reporter-options output=./junit/test-results.xml && codecov",
14
+ "lint": "eslint .",
14
15
  "semantic-release": "semantic-release",
15
- "commit": "git-cz"
16
+ "prepare": "husky install"
16
17
  },
17
18
  "repository": {
18
19
  "type": "git",
19
20
  "url": "https://github.com/adobe/helix-onedrive-cli"
20
21
  },
21
- "author": "",
22
22
  "license": "Apache-2.0",
23
23
  "bugs": {
24
24
  "url": "https://github.com/adobe/helix-onedrive-cli/issues"
@@ -27,43 +27,33 @@
27
27
  "dependencies": {
28
28
  "@adobe/helix-log": "6.0.0",
29
29
  "@adobe/helix-onedrive-support": "6.0.1",
30
- "@adobe/helix-shared-config": "1.5.3",
31
- "chalk": "4.1.2",
30
+ "chalk-template": "0.2.0",
31
+ "@adobe/helix-shared-config": "1.7.1",
32
32
  "cookie-parser": "1.4.6",
33
33
  "dotenv": "10.0.0",
34
34
  "express": "4.17.1",
35
35
  "fs-extra": "10.0.0",
36
36
  "open": "8.4.0",
37
- "yargs": "17.2.1"
37
+ "yargs": "17.3.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@adobe/eslint-config-helix": "1.3.1",
41
41
  "@semantic-release/changelog": "6.0.1",
42
42
  "@semantic-release/git": "10.0.1",
43
43
  "@semantic-release/npm": "8.0.3",
44
+ "c8": "7.10.0",
44
45
  "codecov": "3.8.3",
45
- "commitizen": "4.2.4",
46
- "cz-conventional-changelog": "3.3.0",
47
- "eslint": "8.3.0",
46
+ "eslint": "8.4.0",
48
47
  "eslint-plugin-header": "3.1.1",
49
48
  "eslint-plugin-import": "2.25.3",
50
- "ghooks": "2.0.4",
49
+ "husky": "7.0.4",
51
50
  "junit-report-builder": "3.0.0",
52
51
  "lint-staged": "12.1.2",
53
52
  "mocha": "9.1.3",
54
53
  "nodemon": "2.0.15",
55
- "nyc": "15.1.0",
56
54
  "semantic-release": "18.0.1"
57
55
  },
58
56
  "lint-staged": {
59
57
  "*.js": "eslint"
60
- },
61
- "config": {
62
- "commitizen": {
63
- "path": "node_modules/cz-conventional-changelog"
64
- },
65
- "ghooks": {
66
- "pre-commit": "npx lint-staged"
67
- }
68
58
  }
69
59
  }
package/src/browser.js CHANGED
@@ -10,11 +10,13 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  /* eslint-disable no-console */
13
- const crypto = require('crypto');
14
- const express = require('express');
15
- const cookieParser = require('cookie-parser');
16
- const { getOneDriveClient } = require('./client.js');
17
- require('dotenv').config();
13
+ import crypto from 'crypto';
14
+ import express from 'express';
15
+ import cookieParser from 'cookie-parser';
16
+ import { config } from 'dotenv';
17
+ import { getOneDriveClient } from './client.js';
18
+
19
+ config();
18
20
 
19
21
  const redirectUri = 'http://localhost:4502/token';
20
22
 
package/src/cli.js CHANGED
@@ -11,15 +11,12 @@
11
11
  */
12
12
 
13
13
  /* eslint-disable global-require, no-console */
14
-
15
- 'use strict';
16
-
17
- const yargs = require('yargs');
18
- const logger = require('./logging.js');
14
+ import yargs from 'yargs';
15
+ import { logger } from './logging.js';
19
16
 
20
17
  const MIN_MSG = 'You need at least one command.';
21
18
 
22
- class CLI {
19
+ export default class CLI {
23
20
  constructor(plugins = []) {
24
21
  this._failFn = (message, err, argv) => {
25
22
  const msg = err ? err.message : message;
@@ -32,9 +29,9 @@ class CLI {
32
29
  this._plugins = plugins;
33
30
  }
34
31
 
35
- run(argv) {
32
+ async run(argv) {
36
33
  const y = yargs();
37
- this._plugins.forEach((p) => p(y));
34
+ await Promise.all(this._plugins.map(async (p) => p(y)));
38
35
  return y
39
36
  .option('verbose', {
40
37
  alias: 'v',
@@ -47,7 +44,7 @@ class CLI {
47
44
  }
48
45
  return args;
49
46
  })
50
- .wrap(yargs.terminalWidth())
47
+ .wrap(y.terminalWidth())
51
48
  .fail(this._failFn)
52
49
  .exitProcess(false)
53
50
  .strict()
@@ -57,5 +54,3 @@ class CLI {
57
54
  .parse(argv);
58
55
  }
59
56
  }
60
-
61
- module.exports = CLI;
package/src/client.js CHANGED
@@ -9,12 +9,10 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const fs = require('fs-extra');
13
- const chalk = require('chalk');
14
- const { OneDrive } = require('@adobe/helix-onedrive-support');
15
- const logger = require('./logging.js');
16
-
17
- const { debug, info } = logger;
12
+ import fs from 'fs-extra';
13
+ import chalk from 'chalk-template';
14
+ import { OneDrive } from '@adobe/helix-onedrive-support';
15
+ import { logger, debug, info } from './logging.js';
18
16
 
19
17
  const STATE_FILE = '.hlx-1d.json';
20
18
  const AUTH_FILE = '.auth.json';
@@ -23,11 +21,11 @@ const DEFAULT_CLIENT_ID = '04b07795-8ddb-461a-bbee-02f9e1bf7b46';
23
21
 
24
22
  let state = {};
25
23
 
26
- function getState() {
24
+ export function getState() {
27
25
  return state;
28
26
  }
29
27
 
30
- async function loadState() {
28
+ export async function loadState() {
31
29
  try {
32
30
  state = await fs.readJson(STATE_FILE);
33
31
  } catch (e) {
@@ -35,7 +33,7 @@ async function loadState() {
35
33
  }
36
34
  return state;
37
35
  }
38
- async function saveState() {
36
+ export async function saveState() {
39
37
  await fs.writeJson(STATE_FILE, state);
40
38
  }
41
39
 
@@ -46,7 +44,7 @@ let client = null;
46
44
  *
47
45
  * @returns {OneDrive} OneDrive client
48
46
  */
49
- async function getOneDriveClient() {
47
+ export async function getOneDriveClient() {
50
48
  if (client) {
51
49
  return client;
52
50
  }
@@ -102,10 +100,3 @@ async function getOneDriveClient() {
102
100
  });
103
101
  return client;
104
102
  }
105
-
106
- module.exports = {
107
- getState,
108
- loadState,
109
- saveState,
110
- getOneDriveClient,
111
- };
@@ -9,10 +9,15 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- Object.assign(exports, {
12
+ import { resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+ import { loadCommands } from '../utils.js';
15
+
16
+ export default {
13
17
  command: 'columns <command>',
14
18
  desc: 'Execute commands related to table columns in Excel',
15
- builder: (y) => y
16
- .commandDir('columns_cmd'),
19
+ builder: async (y) => {
20
+ await loadCommands(y, resolve(fileURLToPath(import.meta.url), '..', 'columns_cmd'));
21
+ },
17
22
  handler: () => {},
18
- });
23
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -50,8 +44,8 @@ async function handler(args) {
50
44
  });
51
45
  }
52
46
 
53
- Object.assign(exports, {
47
+ export default {
54
48
  command: ['get <table-name> <column-name>'],
55
49
  desc: 'Retrieve a column in a table',
56
50
  handler: (y) => handler(y),
57
- });
51
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -49,8 +43,8 @@ async function handler(args) {
49
43
  });
50
44
  }
51
45
 
52
- Object.assign(exports, {
46
+ export default {
53
47
  command: ['list <table-name>', 'ls'],
54
48
  desc: 'List columns in a table',
55
49
  handler: (y) => handler(y),
56
- });
50
+ };
@@ -9,16 +9,21 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- Object.assign(exports, {
12
+ import { resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+ import { loadCommands } from '../utils.js';
15
+
16
+ export default {
13
17
  command: 'names <command>',
14
18
  desc: 'Execute commands related to named items in Excel',
15
- builder: (y) => y
16
- .commandDir('names_cmd')
17
- .option('s', {
19
+ builder: async (y) => {
20
+ await loadCommands(y, resolve(fileURLToPath(import.meta.url), '..', 'names_cmd'));
21
+ y.option('s', {
18
22
  alias: 'sheet',
19
23
  type: 'string',
20
24
  description: 'Worksheet to operate on',
21
25
  default: null,
22
- }),
26
+ });
27
+ },
23
28
  handler: () => {},
24
- });
29
+ };
@@ -9,14 +9,8 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
-
17
- const {
18
- loadState, getOneDriveClient,
19
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { getOneDriveClient, loadState } from '../../client.js';
20
14
 
21
15
  function getDriveItem(url) {
22
16
  // todo: parse better
@@ -47,9 +41,9 @@ async function handler(args) {
47
41
  await container.addNamedItem(name, value, comment);
48
42
  }
49
43
 
50
- Object.assign(exports, {
44
+ export default {
51
45
  command: 'add <name> <value> [comment]',
52
46
  desc: 'add a named item to a work book or work sheet',
53
47
  alias: 'add',
54
48
  handler: (y) => handler(y),
55
- });
49
+ };
@@ -9,14 +9,8 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
-
17
- const {
18
- loadState, getOneDriveClient,
19
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { getOneDriveClient, loadState } from '../../client.js';
20
14
 
21
15
  function getDriveItem(url) {
22
16
  // todo: parse better
@@ -48,8 +42,8 @@ async function handler(args) {
48
42
  }));
49
43
  }
50
44
 
51
- Object.assign(exports, {
45
+ export default {
52
46
  command: ['delete <names...>', 'rm'],
53
47
  desc: 'delete a name in a work book or work sheet',
54
48
  handler: (y) => handler(y),
55
- });
49
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -63,8 +57,8 @@ async function handler(args) {
63
57
  }
64
58
  }
65
59
 
66
- Object.assign(exports, {
60
+ export default {
67
61
  command: ['list [name]', 'ls'],
68
62
  desc: 'List all names in a work book or work sheet',
69
63
  handler: (y) => handler(y),
70
- });
64
+ };
package/src/excel/rows.js CHANGED
@@ -9,10 +9,15 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- Object.assign(exports, {
12
+ import { resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+ import { loadCommands } from '../utils.js';
15
+
16
+ export default {
13
17
  command: 'rows <command>',
14
- desc: 'Execute commands related to table rowts in Excel',
15
- builder: (y) => y
16
- .commandDir('rows_cmd'),
18
+ desc: 'Execute commands related to table rows in Excel',
19
+ builder: async (y) => {
20
+ await loadCommands(y, resolve(fileURLToPath(import.meta.url), '..', 'rows_cmd'));
21
+ },
17
22
  handler: () => {},
18
- });
23
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -46,8 +40,8 @@ async function handler(args) {
46
40
  info(chalk`{yellow ${count}}`);
47
41
  }
48
42
 
49
- Object.assign(exports, {
43
+ export default {
50
44
  command: ['count <table-name>'],
51
45
  desc: 'Shows number of rows in a table',
52
46
  handler: (y) => handler(y),
53
- });
47
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -54,8 +48,8 @@ async function handler(args) {
54
48
  }
55
49
  }
56
50
 
57
- Object.assign(exports, {
51
+ export default {
58
52
  command: ['get <table-name> [index]'],
59
53
  desc: 'List some or all rows in a table',
60
54
  handler: (y) => handler(y),
61
- });
55
+ };
@@ -9,10 +9,15 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- Object.assign(exports, {
12
+ import { resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+ import { loadCommands } from '../utils.js';
15
+
16
+ export default {
13
17
  command: 'sheets <command>',
14
18
  desc: 'Execute commands related to work sheets in Excel',
15
- builder: (y) => y
16
- .commandDir('sheets_cmd'),
19
+ builder: async (y) => {
20
+ await loadCommands(y, resolve(fileURLToPath(import.meta.url), '..', 'sheets_cmd'));
21
+ },
17
22
  handler: () => {},
18
- });
23
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -46,8 +40,8 @@ async function handler(args) {
46
40
  });
47
41
  }
48
42
 
49
- Object.assign(exports, {
43
+ export default {
50
44
  command: ['list', 'ls'],
51
45
  desc: 'List all work sheets in a work book',
52
46
  handler: (y) => handler(y),
53
- });
47
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -50,7 +44,7 @@ async function handler(args) {
50
44
  info(chalk`{yellow ${JSON.stringify(values, undefined, 2)}}`);
51
45
  }
52
46
 
53
- Object.assign(exports, {
47
+ export default {
54
48
  command: ['range <sheet-name>', 'r'],
55
49
  desc: 'returns a range in a sheet',
56
50
  builder: (y) => y
@@ -60,4 +54,4 @@ Object.assign(exports, {
60
54
  description: 'address range (e.g. A1:C2)',
61
55
  }),
62
56
  handler: (y) => handler(y),
63
- });
57
+ };
@@ -9,10 +9,15 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- Object.assign(exports, {
12
+ import { resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+ import { loadCommands } from '../utils.js';
15
+
16
+ export default {
13
17
  command: 'tables <command>',
14
18
  desc: 'Execute commands related to tables in Excel',
15
- builder: (y) => y
16
- .commandDir('tables_cmd'),
19
+ builder: async (y) => {
20
+ await loadCommands(y, resolve(fileURLToPath(import.meta.url), '..', 'tables_cmd'));
21
+ },
17
22
  handler: () => {},
18
- });
23
+ };
@@ -9,15 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- 'use strict';
14
-
15
- const chalk = require('chalk');
16
- const { info } = require('../../logging.js');
17
-
18
- const {
19
- loadState, getOneDriveClient,
20
- } = require('../../client.js');
12
+ import chalk from 'chalk-template';
13
+ import { info } from '../../logging.js';
14
+ import { getOneDriveClient, loadState } from '../../client.js';
21
15
 
22
16
  function getDriveItem(url) {
23
17
  // todo: parse better
@@ -46,8 +40,8 @@ async function handler(args) {
46
40
  });
47
41
  }
48
42
 
49
- Object.assign(exports, {
43
+ export default {
50
44
  command: ['list', 'ls'],
51
45
  desc: 'List all tables in a work book',
52
46
  handler: (y) => handler(y),
53
- });
47
+ };
package/src/index.js CHANGED
@@ -13,11 +13,10 @@
13
13
  */
14
14
 
15
15
  // tell helix-fetch to avoid using persistent H2 connections that would keep us alive
16
- process.env.HELIX_FETCH_FORCE_HTTP1 = true;
17
-
18
- const CLI = require('./cli.js');
19
- require('dotenv').config();
20
-
21
- const cmdsOneDrive = require('./onedrive.cmd.js');
16
+ import CLI from './cli.js';
17
+ import { config } from 'dotenv';
18
+ import cmdsOneDrive from './onedrive.cmd.js';
22
19
 
20
+ process.env.HELIX_FETCH_FORCE_HTTP1 = true;
21
+ config();
23
22
  new CLI([cmdsOneDrive]).run(process.argv.slice(2));
package/src/logging.js CHANGED
@@ -9,15 +9,12 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const { createDefaultLogger, SimpleInterface } = require('@adobe/helix-log');
12
+ import { createDefaultLogger, SimpleInterface } from '@adobe/helix-log';
13
13
 
14
14
  const rootLogger = createDefaultLogger();
15
- const logger = new SimpleInterface({ logger: rootLogger });
16
15
 
17
- module.exports = {
18
- logger,
19
- debug: logger.debug.bind(logger),
20
- info: logger.info.bind(logger),
21
- warn: logger.warn.bind(logger),
22
- error: logger.error.bind(logger),
23
- };
16
+ export const logger = new SimpleInterface({ logger: rootLogger });
17
+ export const debug = logger.debug.bind(logger);
18
+ export const info = logger.info.bind(logger);
19
+ export const warn = logger.warn.bind(logger);
20
+ export const error = logger.error.bind(logger);
@@ -9,13 +9,13 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
+ import { resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+ import { loadCommands } from './utils.js';
15
+ import onedrive from './onedrive.js';
12
16
 
13
- 'use strict';
14
-
15
- const onedrive = require('./onedrive.js');
16
-
17
- function install(yargs) {
18
- return yargs
17
+ export default async function install(yargs) {
18
+ yargs
19
19
  .command({
20
20
  command: 'me',
21
21
  desc: 'Show information about the logged in user.',
@@ -122,8 +122,7 @@ function install(yargs) {
122
122
  description: 'Skip initial building of path hierarchy',
123
123
  default: false,
124
124
  }),
125
- })
126
- .commandDir('excel');
125
+ });
126
+ await loadCommands(yargs, resolve(fileURLToPath(import.meta.url), '..', 'excel'));
127
+ return yargs;
127
128
  }
128
-
129
- module.exports = install;
package/src/onedrive.js CHANGED
@@ -9,17 +9,17 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- const fs = require('fs-extra');
13
- const path = require('path');
14
- const chalk = require('chalk');
15
- const openBrowser = require('open');
16
- const readline = require('readline');
17
- const { URLSearchParams } = require('url');
18
- const { MountConfig } = require('@adobe/helix-shared-config');
19
- const { error, info, debug } = require('./logging.js');
20
- const {
21
- getState, loadState, saveState, getOneDriveClient,
22
- } = require('./client.js');
12
+ import fs from 'fs-extra';
13
+ import path from 'path';
14
+ import chalk from 'chalk-template';
15
+ import openBrowser from 'open';
16
+ import readline from 'readline';
17
+ import { URLSearchParams } from 'url';
18
+ import { MountConfig } from '@adobe/helix-shared-config';
19
+ import { debug, error, info } from './logging.js';
20
+ import {
21
+ getOneDriveClient, getState, loadState, saveState,
22
+ } from './client.js';
23
23
 
24
24
  const AUTH_FILE = '.auth.json';
25
25
 
@@ -414,7 +414,7 @@ async function poll(args) {
414
414
  }
415
415
  }
416
416
 
417
- module.exports = {
417
+ export default {
418
418
  me,
419
419
  resolve,
420
420
  ls,
package/src/utils.js ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright 2019 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import path from 'path';
13
+ import fs from 'fs/promises';
14
+
15
+ export async function loadCommands(yargs, dir) {
16
+ const d = await fs.readdir(dir);
17
+ for (const filename of d) {
18
+ if (filename.endsWith('.js')) {
19
+ // eslint-disable-next-line no-await-in-loop
20
+ const cmd = (await import(path.resolve(dir, filename))).default;
21
+ yargs.command(cmd);
22
+ }
23
+ }
24
+ }