diff --git a/.github/workflows/coverall.yml b/.github/workflows/coverall.yml index 08e81cb4..75ca810f 100644 --- a/.github/workflows/coverall.yml +++ b/.github/workflows/coverall.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Use Node.js 14.x + - name: Use Node.js 16.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 16.x - run: npm ci - run: npm run test:cov - name: Coveralls GitHub Action diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 23308524..ab4caf3c 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Use Node.js 14.x + - name: Use Node.js 16.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 16.x - run: npm ci - run: npm run jsdoc - run: cp -f src/builder/declaration-schema.json docs diff --git a/bin/heta-build.js b/bin/heta-build.js index 449762a6..a7dc18ac 100644 --- a/bin/heta-build.js +++ b/bin/heta-build.js @@ -1,5 +1,6 @@ #!/usr/bin/env node -const program = require('commander'); +const { Command } = require('commander'); +const program = new Command(); const fs = require('fs'); const path = require('path'); const { Builder } = require('../src/builder'); @@ -19,6 +20,7 @@ let contactMessage = colors.bgRed(` `); program + .name('heta build') .description('Compile Heta based platform and create set of export files.') //.arguments(' [dir]') .usage('[options] [dir]') @@ -39,11 +41,13 @@ program .parse(process.argv); (async () => { + let args = program.args; + let opts = program.opts(); // print newer version message - if (!program.skipUpdates) await printVersionMessage(); + if (!opts.skipUpdates) await printVersionMessage(); // set target directory of platform and check if exist - let targetDir = path.resolve(program.args[0] || '.'); + let targetDir = path.resolve(args[0] || '.'); if (!fs.existsSync(targetDir) || !fs.statSync(targetDir).isDirectory()) { // check if it does not exist or not a directory process.stdout.write(`Target directory "${targetDir}" does not exist.\nSTOP!`); process.exit(1); // BRAKE @@ -52,16 +56,16 @@ program // === read declaration file === // search let searches = ['', '.json', '.json5', '.yml'] - .map((ext) => path.join(targetDir, (program.declaration || 'platform') + ext)); + .map((ext) => path.join(targetDir, (opts.declaration || 'platform') + ext)); let extensionNumber = searches .map((x) => fs.existsSync(x) && fs.statSync(x).isFile() ) // check if it exist and is file .indexOf(true); // is declaration file found ? - if (!program.declaration && extensionNumber === -1) { + if (!opts.declaration && extensionNumber === -1) { process.stdout.write('No declaration file, running with defaults...\n'); var declaration = {}; } else if (extensionNumber === -1) { - process.stdout.write(`Declaration file "${program.declaration}" not found.\nSTOP!`); + process.stdout.write(`Declaration file "${opts.declaration}" not found.\nSTOP!`); process.exit(1); // BRAKE } else { let declarationFile = searches[extensionNumber]; @@ -81,17 +85,17 @@ program // === options from CLI === let CLIDeclaration = { options: { - unitsCheck: program.unitsCheck, - skipExport: program.skipExport, - logMode: program.logMode, - debug: program.debug, - juliaOnly: program.juliaOnly, - distDir: program.distDir, - metaDir: program.metaDir + unitsCheck: opts.unitsCheck, + skipExport: opts.skipExport, + logMode: opts.logMode, + debug: opts.debug, + juliaOnly: opts.juliaOnly, + distDir: opts.distDir, + metaDir: opts.metaDir }, importModule: { - source: program.source, - type: program.type + source: opts.source, + type: opts.type } }; diff --git a/bin/heta-init.js b/bin/heta-init.js index 4b2d30ce..884ffad2 100644 --- a/bin/heta-init.js +++ b/bin/heta-init.js @@ -1,5 +1,6 @@ #!/usr/bin/env node -const program = require('commander'); +const { Command } = require('commander'); +const program = new Command(); const fs = require('fs-extra'); const path = require('path'); const { prompt } = require('inquirer'); @@ -39,33 +40,37 @@ const defaultPlatform = { }; program + .name('heta init') .description('Creates template heta platform files in directory') .usage('[options] [dir]') .option('-f, --force', 'rewrite files in target directory') .option('-s, --silent', 'use silent mode with default options') .parse(process.argv); +let args = program.args; +let opts = program.opts(); + // initialize file paths -let targetDir = path.resolve(program.args[0] || '.'); +let targetDir = path.resolve(args[0] || '.'); let filePath = path.join(targetDir, 'platform.json'); console.log('Creating a template platform in directory: "' + targetDir + '"...'); // directory does not exist -if(!program.force && !fs.existsSync(targetDir)){ +if(!opts.force && !fs.existsSync(targetDir)){ console.log(`Directory ${targetDir} does not exist. Use --force option to create directory.`); console.log('STOP.'); process.exit(1); } // files already exists -if(!program.force && fs.existsSync(filePath)){ +if(!opts.force && fs.existsSync(filePath)){ console.log('"platform.json" file already exists. Use --force option to rewrite file.'); console.log('STOP.'); process.exit(1); } // silent mode -if(program.silent){ +if(opts.silent){ let platform = defaultPlatform; // saving files diff --git a/bin/heta.js b/bin/heta.js index f0121bf8..7807db2a 100644 --- a/bin/heta.js +++ b/bin/heta.js @@ -1,7 +1,7 @@ #!/usr/bin/env node 'use strict'; - -const program = require('commander'); +const { Command } = require('commander'); +const program = new Command('heta'); const pkg = require('../package'); let version = pkg.version; diff --git a/package-lock.json b/package-lock.json index 72afd87d..eef67ff7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1238,9 +1238,9 @@ } }, "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==" }, "common-sequence": { "version": "2.0.2", @@ -1946,6 +1946,13 @@ "commander": "^2.20.3", "lodash": "^4.17.21", "pegjs": "^0.10.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + } } }, "html-escaper": { @@ -3387,6 +3394,14 @@ "lodash": "^4.17.21", "nunjucks": "^3.2.3", "pegjs": "^0.10.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + } } }, "sort-array": { diff --git a/package.json b/package.json index 676865a6..cf328b6d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "ajv": "^6.12.6", "ajv-errors": "^1.0.1", "colors": "^1.4.0", - "commander": "^2.20.3", + "commander": "^11.1.0", "fs-extra": "^7.0.1", "heta-parser": "^0.3.16", "inquirer": "^7.3.3",