UNPKG

xpm

Version:

The xPack project manager command line tool

96 lines (73 loc) 3.06 kB
/* * This file is part of the xPack project (http://xpack.github.io). * Copyright (c) 2017-2026 Liviu Ionescu. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software * for any purpose is hereby granted, under the terms of the MIT license. * * If a copy of the license was not distributed with this file, it can * be obtained from https://opensource.org/license/mit. */ 'use strict' // ---------------------------------------------------------------------------- /** * The Xpm main module. * * It is re-exported publicly by `index.js`. * * To import classes from this module into Node.js applications, use: * * ```javascript * const Xpm = require('xpm').Xpm * ``` */ // ---------------------------------------------------------------------------- // https://nodejs.org/docs/latest/api/ import path from 'path' import { fileURLToPath } from 'url' // ---------------------------------------------------------------------------- // ES6: `import { CliApplication, CliOptions } from '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)) // ============================================================================ export class XpmDev extends CliApplication { // -------------------------------------------------------------------------- /** * @summary Initialise the application class object. * * @returns {undefined} Nothing. * * @description * Initialise the options manager with application * specific commands and common options. * * @override */ static doInitialise() { const Self = this // ------------------------------------------------------------------------ // Mandatory, must be set here, not in the library, since it takes // the shortcut of using `__dirname` of the main file. Self.rootPath = path.dirname(__dirname) // Enable -i|--interactive Self.hasInteractiveMode = true // ------------------------------------------------------------------------ // Initialise the tree of known commands. // Paths should be relative to the package root. CliOptions.addCommand(['binaries'], 'src/xpm-dev/binaries.js') CliOptions.addCommand(['binaries-update'], 'src/xpm-dev/binaries-update.js') // 24 hours in seconds. Self.checkUpdatesIntervalSeconds = 60 * 60 * 24 // The common options were already initialised by the caller, // and are ok, no need to redefine them. } // -------------------------------------------------------------------------- // Constructor: use parent definition. // main(): use parent definition // help(): use parent definition. // (isn't object oriented code reuse great?) } // ----------------------------------------------------------------------------