From 5cb7e7859d32250356641614d24ee995f1bfa989 Mon Sep 17 00:00:00 2001 From: Liviu Ionescu Date: Wed, 8 Feb 2023 20:47:20 +0200 Subject: [PATCH] #162: migrate form CommonJS to ES6 modules --- README-DEVELOPER.md | 5 ++- bin/xpm-dev.js | 2 +- bin/xpm.js | 2 +- index.js | 6 ++-- lib/main-dev.js | 13 +++++-- lib/main.js | 18 +++++++--- lib/utils/fs-utils.js | 14 +++++--- lib/utils/functions.js | 12 +++---- lib/utils/global-config.js | 21 +++++++---- lib/utils/policies.js | 9 ++--- lib/utils/spawn.js | 11 +++--- lib/utils/xpack.js | 45 +++++++++++++---------- lib/xpm-dev/binaries-update.js | 30 +++++++++++----- lib/xpm-dev/binaries.js | 19 +++++++--- lib/xpm/init.js | 49 +++++++++++++++---------- lib/xpm/install.js | 53 ++++++++++++++++------------ lib/xpm/link.js | 39 +++++++++++--------- lib/xpm/list.js | 36 ++++++++++++------- lib/xpm/run-action.js | 43 ++++++++++++++-------- lib/xpm/uninstall.js | 39 ++++++++++++-------- package-lock.json | 46 ++++++++---------------- package.json | 15 ++++---- tests/common.js | 23 ++++++------ tests/tap/120-utils-global-config.js | 5 +-- tests/tap/130-utils-spawn.js | 5 +-- tests/tap/140-utils-xpack.js | 17 ++++++--- tests/tap/500-xpm.js | 20 ++++++++--- tests/tap/520-xpm-init.js | 16 +++++++-- tests/tap/530-xpm-install.js | 16 +++++++-- tests/tap/540-xpm-run-action.js | 16 +++++++-- 30 files changed, 402 insertions(+), 243 deletions(-) diff --git a/README-DEVELOPER.md b/README-DEVELOPER.md index be05a49..37b5ab4 100644 --- a/README-DEVELOPER.md +++ b/README-DEVELOPER.md @@ -55,7 +55,6 @@ npm outdated Details about dependencies: - -- - - - @@ -200,7 +199,7 @@ To be accepted as a template, a project must: - be an xPack (have a `package.json` which includes an `xpack` property - have a property called `main` in `package.json`, pointing to a JavaScript - file that can be consumed by `require()` + file that can be consumed by `await import()` (formerly `require()`) - the main file must export a class called `XpmInitTemplate` - an instances of this class must have a `run()` method. - have all dependencies bundled in (via `bundleDependencies`) @@ -225,7 +224,7 @@ The full code is in `init.js`, but a simplified version looks like this: context.CliError = CliError context.CliExitCodes = CliExitCodes - const { XpmInitTemplate } = require(mainTemplatePath) + const { XpmInitTemplate } = await import(mainTemplatePath) const xpmInitTemplate = new XpmInitTemplate(context) const code = await xpmInitTemplate.run() ``` diff --git a/bin/xpm-dev.js b/bin/xpm-dev.js index 7fa8e6d..86c354e 100755 --- a/bin/xpm-dev.js +++ b/bin/xpm-dev.js @@ -37,7 +37,7 @@ // ---------------------------------------------------------------------------- // ES6: `import { Xpm } from 'main.js' -const { XpmDev } = require('../lib/main-dev.js') +import { XpmDev } from '../lib/main-dev.js' // ---------------------------------------------------------------------------- diff --git a/bin/xpm.js b/bin/xpm.js index 07b574d..56ee3da 100755 --- a/bin/xpm.js +++ b/bin/xpm.js @@ -37,7 +37,7 @@ // ---------------------------------------------------------------------------- // ES6: `import { Xpm } from 'main.js' -const { Xpm } = require('../lib/main.js') +import { Xpm } from '../lib/main.js' // ---------------------------------------------------------------------------- diff --git a/index.js b/index.js index 5bf1cad..066b65f 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,9 @@ */ // ES6: `import { Main } from './lib/main.js' -const { Main } = require('./lib/main.js') +import mainCsj from './lib/main.js' + +export const { Main } = mainCsj // ---------------------------------------------------------------------------- // Node.js specific export definitions. @@ -34,7 +36,7 @@ const { Main } = require('./lib/main.js') // By default, `module.exports = {}`. // The Main class is added as a property with the same name to this object. -module.exports.Main = Main +// module.exports.Main = Main // In ES6, it would be: // export class Main { ... } diff --git a/lib/main-dev.js b/lib/main-dev.js index 1b22b50..b380d80 100644 --- a/lib/main-dev.js +++ b/lib/main-dev.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -30,12 +31,20 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const path = require('path') +import path from 'path' + +import { fileURLToPath } from 'url' // ---------------------------------------------------------------------------- // ES6: `import { CliApplication, CliOptions } from 'cli-start-options' -const { CliApplication, CliOptions } = require('@ilg/cli-start-options') +// import { CliApplication, CliOptions } from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +const { CliApplication, CliOptions } = cliStartOptionsCsj +const __dirname = path.dirname(fileURLToPath(import.meta.url)) // ============================================================================ diff --git a/lib/main.js b/lib/main.js index 00a9ba8..b0d32e4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -29,20 +30,27 @@ // ---------------------------------------------------------------------------- -const fs = require('fs') +import fs from 'fs' // https://nodejs.org/docs/latest-v12.x/api/index.htm -const path = require('path') +import path from 'path' + +import { fileURLToPath } from 'url' // ---------------------------------------------------------------------------- // ES6: `import { CliApplication, CliOptions } from 'cli-start-options' -const { CliApplication, CliOptions } = require('@ilg/cli-start-options') +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +const { CliApplication, CliOptions } = cliStartOptionsCsj +const __dirname = path.dirname(fileURLToPath(import.meta.url)) // ============================================================================ // export -class Xpm extends CliApplication { +export class Xpm extends CliApplication { // -------------------------------------------------------------------------- /** @@ -129,7 +137,7 @@ class Xpm extends CliApplication { // By default, `module.exports = {}`. // The current class is added as a property to this object. -module.exports.Xpm = Xpm +// module.exports.Xpm = Xpm // In ES6, it would be: // export class Xpm { ... } diff --git a/lib/utils/fs-utils.js b/lib/utils/fs-utils.js index 05bdf12..76dd2a9 100644 --- a/lib/utils/fs-utils.js +++ b/lib/utils/fs-utils.js @@ -10,20 +10,24 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const assert = require('assert') -const fs = require('fs') +import assert from 'assert' +import fs from 'fs' +import path from 'path' + +// ---------------------------------------------------------------------------- + const fsPromises = fs.promises -const path = require('path') // ---------------------------------------------------------------------------- -class FsUtils { +export class FsUtils { static async chmodRecursive ({ inputPath, readOnly, log }) { assert(inputPath, 'mandatory inputPath') assert(log, 'mandatory log') @@ -104,7 +108,7 @@ class FsUtils { // By default, `module.exports = {}`. // The FsUtils class is added as a property of this object. -module.exports.FsUtils = FsUtils +// module.exports.FsUtils = FsUtils // In ES6, it would be: // export class FsUtils { ... } diff --git a/lib/utils/functions.js b/lib/utils/functions.js index 37b8489..c02b81b 100644 --- a/lib/utils/functions.js +++ b/lib/utils/functions.js @@ -15,15 +15,15 @@ // ---------------------------------------------------------------------------- -function isString (x) { +export function isString (x) { return Object.prototype.toString.call(x) === '[object String]' } -function isObject (x) { +export function isObject (x) { return typeof x === 'object' && !Array.isArray(x) } -function isBoolean (x) { +export function isBoolean (x) { return typeof x === 'boolean' } @@ -32,9 +32,9 @@ function isBoolean (x) { // By default, `module.exports = {}`. // Each function is added as a property of this object. -module.exports.isString = isString -module.exports.isObject = isObject -module.exports.isBoolean = isBoolean +// module.exports.isString = isString +// module.exports.isObject = isObject +// module.exports.isBoolean = isBoolean // In ES6, it would be: // import { isString, isObject, isBoolean } from 'functions.js' diff --git a/lib/utils/global-config.js b/lib/utils/global-config.js index c04db4d..cd06ce8 100644 --- a/lib/utils/global-config.js +++ b/lib/utils/global-config.js @@ -10,24 +10,31 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const assert = require('assert') -const fsPromises = require('fs').promises -const os = require('os') -const path = require('path') +import assert from 'assert' +import fs from 'fs' +import os from 'os' +import path from 'path' + +// ---------------------------------------------------------------------------- + +// import { CliError } from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' // ---------------------------------------------------------------------------- -const { CliError } = require('@ilg/cli-start-options') +const { CliError } = cliStartOptionsCsj +const fsPromises = fs.promises // ============================================================================ -class GlobalConfig { +export class GlobalConfig { // -------------------------------------------------------------------------- constructor () { @@ -142,7 +149,7 @@ class GlobalConfig { // By default, `module.exports = {}`. // The Config class is added as a property of this object. -module.exports.GlobalConfig = GlobalConfig +// module.exports.GlobalConfig = GlobalConfig // In ES6, it would be: // export class GlobalConfig { ... } diff --git a/lib/utils/policies.js b/lib/utils/policies.js index c9fd1f2..da87417 100644 --- a/lib/utils/policies.js +++ b/lib/utils/policies.js @@ -10,20 +10,21 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.html -const assert = require('assert') +import assert from 'assert' // https://www.npmjs.com/package/semver -const semver = require('semver') +import semver from 'semver' // ============================================================================ -class Policies { +export class Policies { constructor (minVersion, context) { this.minVersion = minVersion || '0.0.0' assert(context, 'mandatory context') @@ -44,7 +45,7 @@ class Policies { // By default, `module.exports = {}`. // The Policies class is added as a property of this object. -module.exports.Policies = Policies +// module.exports.Policies = Policies // In ES6, it would be: // export class Policies { ... } diff --git a/lib/utils/spawn.js b/lib/utils/spawn.js index b4127f5..47a99b3 100644 --- a/lib/utils/spawn.js +++ b/lib/utils/spawn.js @@ -10,18 +10,19 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ // ---------------------------------------------------------------------------- -const util = require('util') - // https://nodejs.org/docs/latest-v12.x/api/index.htmchild_process.html#child_process_child_process_spawn_command_args_options // const { spawn } = require('child_process') // https://www.npmjs.com/package/cross-spawn -const spawn = require('cross-spawn') +import spawn from 'cross-spawn' + +import util from 'util' // ============================================================================ @@ -106,7 +107,7 @@ const promiseSpawnUid = (cmd, args, opts, extra) => { return p } -class Spawn { +export class Spawn { spawnShellPromise (cmdString, opts) { if (!opts.stdio) { opts.stdio = 'inherit' @@ -191,7 +192,7 @@ class Spawn { // By default, `module.exports = {}`. // The current class is added as a property of this object. -module.exports.Spawn = Spawn +// module.exports.Spawn = Spawn // In ES6, it would be: // export class Spawn { ... } diff --git a/lib/utils/xpack.js b/lib/utils/xpack.js index fe684eb..fd50320 100644 --- a/lib/utils/xpack.js +++ b/lib/utils/xpack.js @@ -10,46 +10,55 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const assert = require('assert') -const fsPromises = require('fs').promises -const os = require('os') -const path = require('path') -const util = require('util') -const stream = require('stream') +import assert from 'assert' +import fs from 'fs' +import os from 'os' +import path from 'path' +import util from 'util' +import stream from 'stream' // ---------------------------------------------------------------------------- // https://www.npmjs.com/package/cacache -const cacache = require('cacache') +import cacache from 'cacache' // https://www.npmjs.com/package/decompress -const decompress = require('decompress') +import decompress from 'decompress' // https://www.npmjs.com/package/del -const del = require('del') +import del from 'del' // https://www.npmjs.com/package/node-fetch -const fetch = require('node-fetch') +import fetch from 'node-fetch' // https://www.npmjs.com/package/semver -const semver = require('semver') +import semver from 'semver' + +// ---------------------------------------------------------------------------- + +// import { CliError, CliErrorInput, CliExitCodes } +// from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' // ---------------------------------------------------------------------------- -const { CliError, CliErrorInput, CliExitCodes } = - require('@ilg/cli-start-options') +import { isString, isObject } from './functions.js' + +// ---------------------------------------------------------------------------- -const { isString, isObject } = require('./functions.js') +const { CliError, CliErrorInput, CliExitCodes } = cliStartOptionsCsj +const fsPromises = fs.promises // ============================================================================ -class Xpack { +export class Xpack { constructor (xpackPath, context) { assert(xpackPath, 'mandatory xpackPath') this.xpackPath = xpackPath @@ -722,7 +731,7 @@ class Xpack { // ============================================================================ -class ManifestIds { +export class ManifestIds { constructor (manifest) { if (manifest._id) { // If pacote returns an ID, it is considered more trustworthy, @@ -807,8 +816,8 @@ class ManifestIds { // By default, `module.exports = {}`. // The Test class is added as a property of this object. -module.exports.Xpack = Xpack -module.exports.ManifestIds = ManifestIds +// module.exports.Xpack = Xpack +// module.exports.ManifestIds = ManifestIds // In ES6, it would be: // export class Xpack { ... } diff --git a/lib/xpm-dev/binaries-update.js b/lib/xpm-dev/binaries-update.js index a9ad922..a042bde 100644 --- a/lib/xpm-dev/binaries-update.js +++ b/lib/xpm-dev/binaries-update.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,21 +23,32 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const fsPromises = require('fs').promises -const path = require('path') -const util = require('util') +import fs from 'fs' +import path from 'path' +import util from 'util' + +// ---------------------------------------------------------------------------- + +// import { CliCommand, CliError, CliErrorInput, +// CliExitCodes } from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' // ---------------------------------------------------------------------------- -const { Xpack } = require('../../lib/utils/xpack.js') -const { GlobalConfig } = require('../utils/global-config.js') +import { Xpack } from '../../lib/utils/xpack.js' + +import { GlobalConfig } from '../utils/global-config.js' + +// ---------------------------------------------------------------------------- -const { CliCommand, CliError, CliErrorInput, CliExitCodes } = - require('@ilg/cli-start-options') +const { + CliCommand, CliError, CliErrorInput, CliExitCodes +} = cliStartOptionsCsj +const fsPromises = fs.promises // ============================================================================ -class BinariesUpdate extends CliCommand { +export class BinariesUpdate extends CliCommand { // -------------------------------------------------------------------------- /** @@ -204,7 +216,7 @@ class BinariesUpdate extends CliCommand { // By default, `module.exports = {}`. // The BinariesUpdate class is added as a property of this object. -module.exports.BinariesUpdate = BinariesUpdate +// module.exports.BinariesUpdate = BinariesUpdate // In ES6, it would be: // export class BinariesUpdate { ... } diff --git a/lib/xpm-dev/binaries.js b/lib/xpm-dev/binaries.js index c2f37d5..651781f 100644 --- a/lib/xpm-dev/binaries.js +++ b/lib/xpm-dev/binaries.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -21,14 +22,22 @@ // ---------------------------------------------------------------------------- -const { Xpack } = require('../../lib/utils/xpack.js') -const { GlobalConfig } = require('../utils/global-config.js') +// import { CliCommand, CliErrorInput } from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +import { Xpack } from '../../lib/utils/xpack.js' + +import { GlobalConfig } from '../utils/global-config.js' + +// ---------------------------------------------------------------------------- -const { CliCommand, CliErrorInput } = require('@ilg/cli-start-options') +const { CliCommand, CliErrorInput } = cliStartOptionsCsj // ============================================================================ -class Binaries extends CliCommand { +export class Binaries extends CliCommand { // -------------------------------------------------------------------------- /** @@ -118,7 +127,7 @@ class Binaries extends CliCommand { // By default, `module.exports = {}`. // The Binaries class is added as a property of this object. -module.exports.Binaries = Binaries +// module.exports.Binaries = Binaries // In ES6, it would be: // export class Binaries { ... } diff --git a/lib/xpm/init.js b/lib/xpm/init.js index 8c65483..6e216d2 100644 --- a/lib/xpm/init.js +++ b/lib/xpm/init.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,38 +23,47 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const fsPromises = require('fs').promises -const os = require('os') -const path = require('path') -const util = require('util') - -// https://www.npmjs.com/package/pacote -const pacote = require('pacote') +import fs from 'fs' +import os from 'os' +import path from 'path' +import util from 'util' // ---------------------------------------------------------------------------- // https://www.npmjs.com/package/del -const del = require('del') +import del from 'del' // https://www.npmjs.com/package/liquidjs -const { Liquid } = require('liquidjs') +import { Liquid } from 'liquidjs' +// import liquidjsCsj from 'liquidjs' + +// https://www.npmjs.com/package/pacote +import pacote from 'pacote' // https://www.npmjs.com/package/parse-git-config -const parseGitConfig = require('parse-git-config') +import parseGitConfig from 'parse-git-config' // ---------------------------------------------------------------------------- -const { GlobalConfig } = require('../utils/global-config.js') -const { ManifestIds } = require('../utils/xpack.js') -const { Spawn } = require('../../lib/utils/spawn.js') -const { Xpack } = require('../utils/xpack.js') - // ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' -const { CliCommand, CliExitCodes, CliError } = require('@ilg/cli-start-options') +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +import { GlobalConfig } from '../utils/global-config.js' + +import { ManifestIds, Xpack } from '../utils/xpack.js' +import { Spawn } from '../../lib/utils/spawn.js' + +// ---------------------------------------------------------------------------- + +// const { Liquid } = liquidjsCsj +const { CliCommand, CliExitCodes, CliError } = cliStartOptionsCsj +const fsPromises = fs.promises // ============================================================================ -class Init extends CliCommand { +export class Init extends CliCommand { // -------------------------------------------------------------------------- /** @@ -270,7 +280,8 @@ class Init extends CliCommand { log.info(`Processing ${packFullName}...`) const mainTemplatePath = path.join(globalPackagePath, globalJson.main) - const { XpmInitTemplate } = require(mainTemplatePath) + // Use dynamic import. + const { XpmInitTemplate } = await import(mainTemplatePath) if (!XpmInitTemplate) { log.error('not an xPack template, check for XpmInitTemplate in exports') return CliExitCodes.ERROR.APPLICATION @@ -387,7 +398,7 @@ class Init extends CliCommand { // By default, `module.exports = {}`. // The current class is added as a property of this object. -module.exports.Init = Init +// module.exports.Init = Init // In ES6, it would be: // export class Init { ... } diff --git a/lib/xpm/install.js b/lib/xpm/install.js index 0795194..1026bf4 100644 --- a/lib/xpm/install.js +++ b/lib/xpm/install.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,56 +23,62 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const assert = require('assert') -const fsPromises = require('fs').promises -const path = require('path') -const os = require('os') -const util = require('util') +import assert from 'assert' +import fs from 'fs' +import path from 'path' +import os from 'os' +import util from 'util' // ---------------------------------------------------------------------------- // https://www.npmjs.com/package/cp-file -const cpFile = require('cp-file') +import cpFile from 'cp-file' // https://www.npmjs.com/package/del -const del = require('del') +import del from 'del' // https://www.npmjs.com/package/make-dir -const makeDir = require('make-dir') +import makeDir from 'make-dir' // https://www.npmjs.com/package/pacote -const pacote = require('pacote') +import pacote from 'pacote' // ---------------------------------------------------------------------------- -const { FsUtils } = require('../utils/fs-utils.js') -const { GlobalConfig } = require('../utils/global-config.js') -const { ManifestIds } = require('../utils/xpack.js') -const { Policies } = require('../utils/policies.js') -const { Spawn } = require('../../lib/utils/spawn.js') -const { Xpack } = require('../utils/xpack.js') +// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' // https://www.npmjs.com/package/cmd-shim // const cmdShim = require('cmd-shim') // Needed for the patch to generate absolute paths. // https://www.npmjs.com/@xpack/cmd-shim -const cmdShim = require('@xpack/cmd-shim') +import cmdShim from '@xpack/cmd-shim' // https://www.npmjs.com/package/@xpack/xpm-liquid -const { XpmLiquid } = require('@xpack/xpm-liquid') +import { XpmLiquid } from '@xpack/xpm-liquid' -// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' -const { CliCommand, CliExitCodes, CliError, CliErrorInput } = - require('@ilg/cli-start-options') +// ---------------------------------------------------------------------------- -// ============================================================================ +import { FsUtils } from '../utils/fs-utils.js' + +import { GlobalConfig } from '../utils/global-config.js' +import { ManifestIds, Xpack } from '../utils/xpack.js' +import { Policies } from '../utils/policies.js' +import { Spawn } from '../../lib/utils/spawn.js' + +// ---------------------------------------------------------------------------- + +const { CliCommand, CliExitCodes, CliError, CliErrorInput } = cliStartOptionsCsj +const fsPromises = fs.promises // Shims with paths relative to local xpacks fail in subtle ways, for example // arm-none-eabi-g++ cannot find . const useAbsolutePathsWindows = true -class Install extends CliCommand { +// ============================================================================ + +export class Install extends CliCommand { // -------------------------------------------------------------------------- /** @@ -1910,7 +1917,7 @@ class Install extends CliCommand { // By default, `module.exports = {}`. // The Install class is added as a property of this object. -module.exports.Install = Install +// module.exports.Install = Install // In ES6, it would be: // export class Install { ... } diff --git a/lib/xpm/link.js b/lib/xpm/link.js index 56b3cdd..995da05 100644 --- a/lib/xpm/link.js +++ b/lib/xpm/link.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,38 +23,44 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const fsPromises = require('fs').promises -const util = require('util') -const path = require('path') -const os = require('os') +import fs from 'fs' +import util from 'util' +import path from 'path' +import os from 'os' // ---------------------------------------------------------------------------- -// https://www.npmjs.com/package/make-dir -const makeDir = require('make-dir') - // https://www.npmjs.com/package/del -const del = require('del') +import del from 'del' + +// https://www.npmjs.com/package/make-dir +import makeDir from 'make-dir' // ---------------------------------------------------------------------------- -const { GlobalConfig } = require('../utils/global-config.js') -const { ManifestIds } = require('../utils/xpack.js') -const { Xpack } = require('../../lib/utils/xpack.js') +// import { CliCommand, CliError, CliErrorInput, CliExitCodes } +// from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' // https://www.npmjs.com/package/@xpack/xpm-liquid -const { XpmLiquid } = require('@xpack/xpm-liquid') +import { XpmLiquid } from '@xpack/xpm-liquid' -const { CliCommand, CliError, CliErrorInput, CliExitCodes } = - require('@ilg/cli-start-options') +// ---------------------------------------------------------------------------- + +import { GlobalConfig } from '../utils/global-config.js' + +import { ManifestIds, Xpack } from '../utils/xpack.js' // ---------------------------------------------------------------------------- +const { CliCommand, CliError, CliErrorInput, CliExitCodes } = cliStartOptionsCsj +const fsPromises = fs.promises + const dotLink = '.link' // ============================================================================ -class Link extends CliCommand { +export class Link extends CliCommand { // -------------------------------------------------------------------------- /** @@ -392,7 +399,7 @@ class Link extends CliCommand { // By default, `module.exports = {}`. // The Install class is added as a property of this object. -module.exports.Link = Link +// module.exports.Link = Link // In ES6, it would be: // export class Link { ... } diff --git a/lib/xpm/list.js b/lib/xpm/list.js index 831d2d7..6db462d 100644 --- a/lib/xpm/list.js +++ b/lib/xpm/list.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,26 +23,35 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const fsPromises = require('fs').promises -const util = require('util') -const path = require('path') +import fs from 'fs' +import util from 'util' +import path from 'path' // ---------------------------------------------------------------------------- // https://www.npmjs.com/package/semver -const semverCompare = require('semver/functions/compare') +import semver from 'semver' // ---------------------------------------------------------------------------- -const { GlobalConfig } = require('../utils/global-config.js') -const { Xpack } = require('../utils/xpack.js') +// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' +// import { CliCommand, CliExitCodes, CliError, CliErrorInput } +// from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' // https://www.npmjs.com/package/@xpack/xpm-liquid -const { XpmLiquid } = require('@xpack/xpm-liquid') +import { XpmLiquid } from '@xpack/xpm-liquid' -// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' -const { CliCommand, CliExitCodes, CliError, CliErrorInput } = - require('@ilg/cli-start-options') +// ---------------------------------------------------------------------------- + +import { GlobalConfig } from '../utils/global-config.js' + +import { Xpack } from '../utils/xpack.js' + +// ---------------------------------------------------------------------------- + +const { CliCommand, CliExitCodes, CliError, CliErrorInput } = cliStartOptionsCsj +const fsPromises = fs.promises // ============================================================================ @@ -51,7 +61,7 @@ const { CliCommand, CliExitCodes, CliError, CliErrorInput } = * @property {Xpack} xpack The object with xPack utilities. * @property {Object} packageJson The object parsed by xpack; may be null. */ -class List extends CliCommand { +export class List extends CliCommand { // -------------------------------------------------------------------------- /** @@ -448,7 +458,7 @@ class List extends CliCommand { for (const [name, xpackVersionsMap] of xpacksMapAscending) { const xpackVersionsMapAscending = new Map([...xpackVersionsMap.entries()].sort((a, b) => { - return semverCompare(a[0], b[0]) + return semver.compare(a[0], b[0]) })) let description = '' for (const [, content] of xpackVersionsMapAscending) { @@ -523,7 +533,7 @@ class List extends CliCommand { // By default, `module.exports = {}`. // The List class is added as a property of this object. -module.exports.List = List +// module.exports.List = List // In ES6, it would be: // export class List { ... } diff --git a/lib/xpm/run-action.js b/lib/xpm/run-action.js index ee8c53a..26013ea 100644 --- a/lib/xpm/run-action.js +++ b/lib/xpm/run-action.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,31 +23,43 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const assert = require('assert') -const fsPromises = require('fs').promises -const os = require('os') -const path = require('path') -const util = require('util') +import assert from 'assert' +import fs from 'fs' +import os from 'os' +import path from 'path' +import util from 'util' // ---------------------------------------------------------------------------- +// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' +// import { CliCommand, CliExitCodes, CliHelp, +// CliError, CliErrorInput, CliOptions } from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' + // https://www.npmjs.com/package/@xpack/xpm-liquid -const { XpmLiquid } = require('@xpack/xpm-liquid') +import { XpmLiquid } from '@xpack/xpm-liquid' -const { GlobalConfig } = require('../utils/global-config.js') -const { Spawn } = require('../utils/spawn.js') -const { Xpack } = require('../utils/xpack.js') +// ---------------------------------------------------------------------------- + +import { GlobalConfig } from '../utils/global-config.js' +import { Spawn } from '../utils/spawn.js' +import { Xpack } from '../utils/xpack.js' + +import { isString } from '../utils/functions.js' + +// ---------------------------------------------------------------------------- + +const fsPromises = fs.promises + +// ---------------------------------------------------------------------------- -// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' const { CliCommand, CliExitCodes, CliHelp, CliError, CliErrorInput, CliOptions -} = require('@ilg/cli-start-options') - -const { isString } = require('../utils/functions.js') +} = cliStartOptionsCsj /// ============================================================================ -class RunAction extends CliCommand { +export class RunAction extends CliCommand { // -------------------------------------------------------------------------- /** @@ -488,7 +501,7 @@ class RunAction extends CliCommand { // By default, `module.exports = {}`. // The current class is added as a property of this object. -module.exports.RunAction = RunAction +// module.exports.RunAction = RunAction // In ES6, it would be: // export class RunAction { ... } diff --git a/lib/xpm/uninstall.js b/lib/xpm/uninstall.js index e41db45..c950808 100644 --- a/lib/xpm/uninstall.js +++ b/lib/xpm/uninstall.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,30 +23,40 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const fsPromises = require('fs').promises -const util = require('util') -const os = require('os') -const path = require('path') +import fs from 'fs' +import util from 'util' +import os from 'os' +import path from 'path' // ---------------------------------------------------------------------------- // https://www.npmjs.com/package/del -const del = require('del') +import del from 'del' // ---------------------------------------------------------------------------- -const { FsUtils } = require('../utils/fs-utils.js') -const { GlobalConfig } = require('../utils/global-config.js') -const { Policies } = require('../utils/policies.js') -const { Xpack } = require('../utils/xpack.js') +// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' +// import { CliCommand, CliExitCodes, CliErrorSyntax, +// CliError, CliErrorInput } from '@ilg/cli-start-options' +import cliStartOptionsCsj from '@ilg/cli-start-options' // https://www.npmjs.com/package/@xpack/xpm-liquid -const { XpmLiquid } = require('@xpack/xpm-liquid') +import { XpmLiquid } from '@xpack/xpm-liquid' + +// ---------------------------------------------------------------------------- + +import { FsUtils } from '../utils/fs-utils.js' + +import { GlobalConfig } from '../utils/global-config.js' +import { Policies } from '../utils/policies.js' +import { Xpack } from '../utils/xpack.js' + +// ---------------------------------------------------------------------------- -// ES6: `import { CliCommand, CliExitCodes, CliError } from 'cli-start-options' const { CliCommand, CliExitCodes, CliErrorSyntax, CliError, CliErrorInput -} = require('@ilg/cli-start-options') +} = cliStartOptionsCsj +const fsPromises = fs.promises // ============================================================================ @@ -55,7 +66,7 @@ const { * @property {Xpack} xpack The object with xPack utilities. * @property {Object} packageJson The object parsed by xpack; may be null. */ -class Uninstall extends CliCommand { +export class Uninstall extends CliCommand { // -------------------------------------------------------------------------- /** @@ -645,7 +656,7 @@ class Uninstall extends CliCommand { // By default, `module.exports = {}`. // The Uninstall class is added as a property of this object. -module.exports.Uninstall = Uninstall +// module.exports.Uninstall = Uninstall // In ES6, it would be: // export class Uninstall { ... } diff --git a/package-lock.json b/package-lock.json index 0a56692..1634b40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,14 @@ { "name": "xpm", - "version": "0.14.9", + "version": "0.15.0-pre", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "xpm", - "version": "0.14.9", + "version": "0.15.0-pre", "bundleDependencies": [ "@ilg/cli-start-options", - "@xpack/es6-promisifier", "@xpack/cmd-shim", "@xpack/xpm-liquid", "cacache", @@ -29,9 +28,8 @@ ], "license": "MIT", "dependencies": { - "@ilg/cli-start-options": "^0.6.6", + "@ilg/cli-start-options": "^0.8.0", "@xpack/cmd-shim": "^4.1.0-2", - "@xpack/es6-promisifier": "^1.0.1", "@xpack/xpm-liquid": "^1.2.2", "cacache": "^16.1.3", "cp-file": "^9.1.0", @@ -57,7 +55,7 @@ "tap": "^16.3.4" }, "engines": { - "node": ">=12" + "node": " >=14.13.1 || >=15.3.0 || >=16.0.0" } }, "node_modules/@ampproject/remapping": { @@ -592,23 +590,23 @@ "dev": true }, "node_modules/@ilg/cli-start-options": { - "version": "0.6.6", - "resolved": "https://registry.npmjs.org/@ilg/cli-start-options/-/cli-start-options-0.6.6.tgz", - "integrity": "sha512-5UVt+k1YPuBtdP0wLf4o38QsYNgDrVQ5N+g18igVr4iGrC+rbAynZzlcSTJpImUTNtYN1WkfBeghx+Ra6lgttw==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@ilg/cli-start-options/-/cli-start-options-0.8.0.tgz", + "integrity": "sha512-Je/x3fKxP4G1pVrSJjeX9C/lfnPVjFo1wI4VvotqQi/PScvohCgHhg8K5mQPTr6QT76BDjTri8b8Vxuzujo2vw==", "inBundle": true, "dependencies": { "@ilg/es6-promisifier": "^0.3.1", - "del": "^6.0.0", + "del": "^6.1.1", "is-ci": "^3.0.0", "is-installed-globally": "^0.4.0", "latest-version": "^5.1.0", "make-dir": "^3.1.0", - "semver": "^7.3.5", + "semver": "^7.3.8", "semver-diff": "^3.1.1", "wscript-avoider": "^3.0.2" }, "engines": { - "node": ">=12" + "node": " >=14.13.1 || >=15.3.0 || >=16.0.0" } }, "node_modules/@ilg/es6-promisifier": { @@ -957,15 +955,6 @@ "node": ">=10" } }, - "node_modules/@xpack/es6-promisifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@xpack/es6-promisifier/-/es6-promisifier-1.0.1.tgz", - "integrity": "sha512-53y4Oib1hoG9LlIm+zR3cg8NamzQuPiEW3i4VgFkwiZzEb60DJibYqcOxmZ/0rJ+nS8oWUnRr+62FBJ9Dd+tFg==", - "inBundle": true, - "engines": { - "node": ">7.7.0" - } - }, "node_modules/@xpack/logger": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@xpack/logger/-/logger-5.0.2.tgz", @@ -12054,17 +12043,17 @@ "dev": true }, "@ilg/cli-start-options": { - "version": "0.6.6", - "resolved": "https://registry.npmjs.org/@ilg/cli-start-options/-/cli-start-options-0.6.6.tgz", - "integrity": "sha512-5UVt+k1YPuBtdP0wLf4o38QsYNgDrVQ5N+g18igVr4iGrC+rbAynZzlcSTJpImUTNtYN1WkfBeghx+Ra6lgttw==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@ilg/cli-start-options/-/cli-start-options-0.8.0.tgz", + "integrity": "sha512-Je/x3fKxP4G1pVrSJjeX9C/lfnPVjFo1wI4VvotqQi/PScvohCgHhg8K5mQPTr6QT76BDjTri8b8Vxuzujo2vw==", "requires": { "@ilg/es6-promisifier": "^0.3.1", - "del": "^6.0.0", + "del": "^6.1.1", "is-ci": "^3.0.0", "is-installed-globally": "^0.4.0", "latest-version": "^5.1.0", "make-dir": "^3.1.0", - "semver": "^7.3.5", + "semver": "^7.3.8", "semver-diff": "^3.1.1", "wscript-avoider": "^3.0.2" } @@ -12318,11 +12307,6 @@ "mkdirp-infer-owner": "^2.0.0" } }, - "@xpack/es6-promisifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@xpack/es6-promisifier/-/es6-promisifier-1.0.1.tgz", - "integrity": "sha512-53y4Oib1hoG9LlIm+zR3cg8NamzQuPiEW3i4VgFkwiZzEb60DJibYqcOxmZ/0rJ+nS8oWUnRr+62FBJ9Dd+tFg==" - }, "@xpack/logger": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@xpack/logger/-/logger-5.0.2.tgz", diff --git a/package.json b/package.json index 4792d7a..d248e33 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,11 @@ { "name": "xpm", - "version": "0.14.9", + "version": "0.15.0-pre", + "type": "module", "description": "The xPack project manager command line tool", - "main": "./index.js", + "exports": { + "import": "./index.js" + }, "directories": { "bin": "./bin", "lib": "./lib", @@ -27,7 +30,7 @@ "test-coverage": "tap --coverage --reporter=classic --timeout 600 --no-check-coverage \"tests/tap/*.js\"", "test-tap": "tap --reporter=classic --timeout 300 --no-coverage \"tests/tap/*.js\"", "tap": "tap --reporter=spec --timeout 300 --no-coverage", - "link": "npm link @ilg/cli-start-options; npm link @xpack/es6-promisifier", + "link": "npm link @ilg/cli-start-options", "prepublishOnly": "standard && npm run test-tap -s", "postpublish": "git push origin --follow-tags", "dumpconf": "env | sort | uniq", @@ -55,12 +58,11 @@ }, "homepage": "https://xpack.github.io/xpm/", "engines": { - "node": ">=12" + "node": " >=14.13.1 || >=15.3.0 || >=16.0.0" }, "dependencies": { - "@ilg/cli-start-options": "^0.6.6", + "@ilg/cli-start-options": "^0.8.0", "@xpack/cmd-shim": "^4.1.0-2", - "@xpack/es6-promisifier": "^1.0.1", "@xpack/xpm-liquid": "^1.2.2", "cacache": "^16.1.3", "cp-file": "^9.1.0", @@ -84,7 +86,6 @@ }, "bundleDependencies": [ "@ilg/cli-start-options", - "@xpack/es6-promisifier", "@xpack/cmd-shim", "@xpack/xpm-liquid", "cacache", diff --git a/tests/common.js b/tests/common.js index 5fbddf3..fb88d10 100644 --- a/tests/common.js +++ b/tests/common.js @@ -10,25 +10,26 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const assert = require('assert') -const fs = require('fs') -const tar = require('tar') -const zlib = require('zlib') -// ---------------------------------------------------------------------------- +import assert from 'assert' +import { spawn } from 'child_process' +import { Console } from 'console' +import fs from 'fs' +import { Writable } from 'stream' +import tar from 'tar' +import zlib from 'zlib' -const { spawn } = require('child_process') -const { Console } = require('console') -const { Writable } = require('stream') +// ---------------------------------------------------------------------------- // ES6: `import { CliHelp } from './utils/cli-helps.js' -const { Xpm } = require('../lib/main.js') +import { Xpm } from '../lib/main.js' // ---------------------------------------------------------------------------- @@ -47,7 +48,7 @@ const programName = 'xpm' * @class Main */ // export -class Common { +export class Common { /** * @summary Run xpm in a separate process. * @@ -160,7 +161,7 @@ class Common { // By default, `module.exports = {}`. // The Main class is added as a property to this object. -module.exports.Common = Common +// module.exports.Common = Common // In ES6, it would be: // export class Common { ... } diff --git a/tests/tap/120-utils-global-config.js b/tests/tap/120-utils-global-config.js index d243df0..046efa6 100644 --- a/tests/tap/120-utils-global-config.js +++ b/tests/tap/120-utils-global-config.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,9 +23,9 @@ // ---------------------------------------------------------------------------- // The `[node-tap](http://www.node-tap.org)` framework. -const test = require('tap').test +import { test } from 'tap' -const { GlobalConfig } = require('../../lib/utils/global-config.js') +import { GlobalConfig } from '../../lib/utils/global-config.js' // ---------------------------------------------------------------------------- diff --git a/tests/tap/130-utils-spawn.js b/tests/tap/130-utils-spawn.js index 783813e..7c4935a 100644 --- a/tests/tap/130-utils-spawn.js +++ b/tests/tap/130-utils-spawn.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,9 +23,9 @@ // ---------------------------------------------------------------------------- // The `[node-tap](http://www.node-tap.org)` framework. -const test = require('tap').test +import { test } from 'tap' -const { Spawn } = require('../../lib/utils/spawn.js') +import { Spawn } from '../../lib/utils/spawn.js' // ---------------------------------------------------------------------------- diff --git a/tests/tap/140-utils-xpack.js b/tests/tap/140-utils-xpack.js index 4465d5e..96377e6 100644 --- a/tests/tap/140-utils-xpack.js +++ b/tests/tap/140-utils-xpack.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,13 +23,21 @@ // ---------------------------------------------------------------------------- // The `[node-tap](http://www.node-tap.org)` framework. -const test = require('tap').test +import { test } from 'tap' -const { ManifestIds } = require('../../lib/utils/xpack.js') -const { Xpack } = require('../../lib/utils/xpack.js') +// ---------------------------------------------------------------------------- // const Common = require('../common.js').Common -const { CliLogger } = require('@ilg/cli-start-options') +// const { CliLogger } = require('@ilg/cli-start-options') +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +import { ManifestIds, Xpack } from '../../lib/utils/xpack.js' + +// ---------------------------------------------------------------------------- + +const { CliLogger } = cliStartOptionsCsj // ---------------------------------------------------------------------------- diff --git a/tests/tap/500-xpm.js b/tests/tap/500-xpm.js index 4554741..9b3f294 100644 --- a/tests/tap/500-xpm.js +++ b/tests/tap/500-xpm.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,16 +23,27 @@ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest-v12.x/api/index.htm -const path = require('path') +import path from 'path' +import { fileURLToPath } from 'url' // ---------------------------------------------------------------------------- // The `[node-tap](http://www.node-tap.org)` framework. -const { test } = require('tap') +import { test } from 'tap' + +// ---------------------------------------------------------------------------- + +// import { CliApplication } from '@ilg/cli-start-options'; +import cliStartOptionsCsj from '@ilg/cli-start-options' -const { Common } = require('../common.js') +// ---------------------------------------------------------------------------- + +import { Common } from '../common.js' + +// ---------------------------------------------------------------------------- -const { CliApplication } = require('@ilg/cli-start-options') +const { CliApplication } = cliStartOptionsCsj +const __dirname = path.dirname(fileURLToPath(import.meta.url)) // ---------------------------------------------------------------------------- diff --git a/tests/tap/520-xpm-init.js b/tests/tap/520-xpm-init.js index 8371278..14a6098 100644 --- a/tests/tap/520-xpm-init.js +++ b/tests/tap/520-xpm-init.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,12 +23,21 @@ // ---------------------------------------------------------------------------- // The `[node-tap](http://www.node-tap.org)` framework. -const { test } = require('tap') +import { test } from 'tap' -const { Common } = require('../common.js') +// ---------------------------------------------------------------------------- // ES6: `import { CliExitCodes } from 'cli-start-options' -const { CliExitCodes } = require('@ilg/cli-start-options') +// import { CliExitCodes } from '@ilg/cli-start-options'; +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +import { Common } from '../common.js' + +// ---------------------------------------------------------------------------- + +const { CliExitCodes } = cliStartOptionsCsj // ---------------------------------------------------------------------------- diff --git a/tests/tap/530-xpm-install.js b/tests/tap/530-xpm-install.js index a262037..81353a4 100644 --- a/tests/tap/530-xpm-install.js +++ b/tests/tap/530-xpm-install.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,12 +23,21 @@ // ---------------------------------------------------------------------------- // The `[node-tap](http://www.node-tap.org)` framework. -const test = require('tap').test +import { test } from 'tap' -const { Common } = require('../common.js') +// ---------------------------------------------------------------------------- // ES6: `import { CliExitCodes } from 'cli-start-options' -const { CliExitCodes } = require('@ilg/cli-start-options') +// import { CliExitCodes } from '@ilg/cli-start-options'; +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +import { Common } from '../common.js' + +// ---------------------------------------------------------------------------- + +const { CliExitCodes } = cliStartOptionsCsj // ---------------------------------------------------------------------------- diff --git a/tests/tap/540-xpm-run-action.js b/tests/tap/540-xpm-run-action.js index 96cc857..feb59de 100644 --- a/tests/tap/540-xpm-run-action.js +++ b/tests/tap/540-xpm-run-action.js @@ -10,6 +10,7 @@ */ 'use strict' + /* eslint valid-jsdoc: "error" */ /* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */ @@ -22,12 +23,21 @@ // ---------------------------------------------------------------------------- // The `[node-tap](http://www.node-tap.org)` framework. -const test = require('tap').test +import { test } from 'tap' -const Common = require('../common.js').Common +// ---------------------------------------------------------------------------- // ES6: `import { CliExitCodes } from 'cli-start-options' -const { CliExitCodes } = require('@ilg/cli-start-options') +// import { CliExitCodes } from '@ilg/cli-start-options'; +import cliStartOptionsCsj from '@ilg/cli-start-options' + +// ---------------------------------------------------------------------------- + +import { Common } from '../common.js' + +// ---------------------------------------------------------------------------- + +const { CliExitCodes } = cliStartOptionsCsj // ----------------------------------------------------------------------------