Initial import with skill sheet working

This commit is contained in:
2024-12-04 00:11:23 +01:00
commit 9050c80ab4
4488 changed files with 671048 additions and 0 deletions

21
node_modules/liftoff/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2017 Tyler Kellen <tyler@sleekcode.net>, 2017-2021 Blaine Bublitz <blaine.bublitz@gmail.com>, Eric Schoffstall <yo@contra.io> and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

624
node_modules/liftoff/README.md generated vendored Normal file
View File

@@ -0,0 +1,624 @@
<p align="center">
<a href="http://liftoffjs.com">
<img height="100" width="297" src="https://cdn.rawgit.com/tkellen/js-liftoff/master/artwork/liftoff.svg"/>
</a>
</p>
<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>
# liftoff
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
Launch your command line tool with ease.
## What is it?
[See this blog post][liftoff-blog], [check out this proof of concept][hacker], or read on.
Say you're writing a CLI tool. Let's call it [hacker]. You want to configure it using a `Hackerfile`. This is node, so you install `hacker` locally for each project you use it in. But, in order to get the `hacker` command in your PATH, you also install it globally.
Now, when you run `hacker`, you want to configure what it does using the `Hackerfile` in your current directory, and you want it to execute using the local installation of your tool. Also, it'd be nice if the `hacker` command was smart enough to traverse up your folders until it finds a `Hackerfile`&mdash;for those times when you're not in the root directory of your project. Heck, you might even want to launch `hacker` from a folder outside of your project by manually specifying a working directory. Liftoff manages this for you.
So, everything is working great. Now you can find your local `hacker` and `Hackerfile` with ease. Unfortunately, it turns out you've authored your `Hackerfile` in coffee-script, or some other JS variant. In order to support _that_, you have to load the compiler for it, and then register the extension for it with node. Good news, Liftoff can do that, and a whole lot more, too.
## Usage
```js
const Liftoff = require('liftoff');
const Hacker = new Liftoff({
name: 'hacker',
processTitle: 'hacker',
moduleName: 'hacker',
configName: 'hackerfile',
extensions: {
'.js': null,
'.json': null,
'.coffee': 'coffee-script/register',
},
v8flags: ['--harmony'], // or v8flags: require('v8flags')
});
Hacker.prepare({}, function (env) {
Hacker.execute(env, function (env) {
// Do post-execute things
});
});
```
## API
### constructor(opts)
Create an instance of Liftoff to invoke your application.
#### opts.name
Sugar for setting `processTitle`, `moduleName`, `configName` automatically.
Type: `String`
Default: `null`
These are equivalent:
```js
const Hacker = Liftoff({
processTitle: 'hacker',
moduleName: 'hacker',
configName: 'hackerfile',
});
```
```js
const Hacker = Liftoff({ name: 'hacker' });
```
Type: `String`
Default: `null`
#### opts.configName
Sets the name of the configuration file Liftoff will attempt to find. Case-insensitive.
Type: `String`
Default: `null`
#### opts.extensions
Set extensions to include when searching for a configuration file. If an external module is needed to load a given extension (e.g. `.coffee`), the module name should be specified as the value for the key.
Type: `Object`
Default: `{".js":null,".json":null}`
**Examples:**
In this example Liftoff will look for `myappfile{.js,.json,.coffee}`. If a config with the extension `.coffee` is found, Liftoff will try to require `coffee-script/require` from the current working directory.
```js
const MyApp = new Liftoff({
name: 'myapp',
extensions: {
'.js': null,
'.json': null,
'.coffee': 'coffee-script/register',
},
});
```
In this example, Liftoff will look for `.myapp{rc}`.
```js
const MyApp = new Liftoff({
name: 'myapp',
configName: '.myapp',
extensions: {
rc: null,
},
});
```
In this example, Liftoff will automatically attempt to load the correct module for any javascript variant supported by [interpret] (as long as it does not require a register method).
```js
const MyApp = new Liftoff({
name: 'myapp',
extensions: require('interpret').jsVariants,
});
```
#### opts.v8flags
Any flag specified here will be applied to node, not your program. Useful for supporting invocations like `myapp --harmony command`, where `--harmony` should be passed to node, not your program. This functionality is implemented using [flagged-respawn]. To support all v8flags, see [v8flags].
Type: `Array` or `Function`
Default: `null`
If this method is a function, it should take a node-style callback that yields an array of flags.
#### opts.processTitle
Sets what the [process title][process-title] will be.
Type: `String`
Default: `null`
#### opts.completions(type)
A method to handle bash/zsh/whatever completions.
Type: `Function`
Default: `null`
#### opts.configFiles
An array of configuration files to find with each value being a [path arguments](#path-arguments).
The order of the array indicates the priority that config file overrides are applied. See [Config Files](#config-files) for the config file specification and description of overrides.
**Note:** This option is useful if, for example, you want to support an `.apprc` file in addition to an `appfile.js`. If you only need a single configuration file, you probably don't need this. In addition to letting you find multiple files, this option allows more fine-grained control over how configuration files are located.
Type: `Array`
Default: `null`
#### Path arguments
The [`fined`][fined] module accepts a string representing the path to search or an object with the following keys:
- `path` **(required)**
The path to search. Using only a string expands to this property.
Type: `String`
Default: `null`
- `name`
The basename of the file to find. Extensions are appended during lookup.
Type: `String`
Default: Top-level key in `configFiles`
- `extensions`
The extensions to append to `name` during lookup. See also: [`opts.extensions`](#optsextensions).
Type: `String` or `Array` or `Object`
Default: The value of [`opts.extensions`](#optsextensions)
- `cwd`
The base directory of `path` (if relative).
Type: `String`
Default: The value of [`opts.cwd`](#optscwd)
- `findUp`
Whether the `path` should be traversed up to find the file.
Type: `Boolean`
Default: `false`
**Examples:**
In this example Liftoff will look for the `.hacker.js` file relative to the `cwd` as declared in `configFiles`.
```js
const MyApp = new Liftoff({
name: 'hacker',
configFiles: [
{ name: '.hacker', path: '.' }
],
});
```
In this example, Liftoff will look for `.hackerrc` in the home directory.
```js
const MyApp = new Liftoff({
name: 'hacker',
configFiles: [
{
name: '.hacker',
path: '~',
extensions: {
rc: null,
},
},
],
});
```
In this example, Liftoff will look in the `cwd` and then lookup the tree for the `.hacker.js` file.
```js
const MyApp = new Liftoff({
name: 'hacker',
configFiles: [
{
name: '.hacker',
path: '.',
findUp: true,
},
],
});
```
In this example, Liftoff will use the home directory as the `cwd` and looks for `~/.hacker.js`.
```js
const MyApp = new Liftoff({
name: 'hacker',
configFiles: [
{
name: '.hacker',
path: '.',
cwd: '~',
},
],
});
```
### prepare(opts, callback(env))
Prepares the environment for your application with provided options, and invokes your callback with the calculated environment as the first argument. The environment can be modified before using it as the first argument to `execute`.
**Example Configuration w/ Options Parsing:**
```js
const Liftoff = require('liftoff');
const MyApp = new Liftoff({ name: 'myapp' });
const argv = require('minimist')(process.argv.slice(2));
const onExecute = function (env, argv) {
// Do post-execute things
};
const onPrepare = function (env) {
console.log('my environment is:', env);
console.log('my liftoff config is:', this);
MyApp.execute(env, onExecute);
};
MyApp.prepare(
{
cwd: argv.cwd,
configPath: argv.myappfile,
preload: argv.preload,
completion: argv.completion,
},
onPrepare
);
```
**Example w/ modified environment**
```js
const Liftoff = require('liftoff');
const Hacker = new Liftoff({
name: 'hacker',
configFiles: [
{ name: '.hacker', path: '.', cwd: '~' }
],
});
const onExecute = function (env, argv) {
// Do post-execute things
};
const onPrepare = function (env) {
const config = env.config['.hacker'];
Hacker.execute(env, config.forcedFlags, onExecute);
};
Hacker.prepare({}, onPrepare);
```
#### opts.cwd
Change the current working directory for this execution. Relative paths are calculated against `process.cwd()`.
Type: `String`
Default: `process.cwd()`
**Example Configuration:**
```js
const argv = require('minimist')(process.argv.slice(2));
MyApp.prepare(
{
cwd: argv.cwd,
},
function (env) {
MyApp.execute(env, invoke);
}
);
```
**Matching CLI Invocation:**
```
myapp --cwd ../
```
#### opts.configPath
Don't search for a config, use the one provided. **Note:** Liftoff will assume the current working directory is the directory containing the config file unless an alternate location is explicitly specified using `cwd`.
Type: `String`
Default: `null`
**Example Configuration:**
```js
var argv = require('minimist')(process.argv.slice(2));
MyApp.prepare(
{
configPath: argv.myappfile,
},
function (env) {
MyApp.execute(env, invoke);
}
);
```
**Matching CLI Invocation:**
```sh
myapp --myappfile /var/www/project/Myappfile.js
```
**Examples using `cwd` and `configPath` together:**
These are functionally identical:
```sh
myapp --myappfile /var/www/project/Myappfile.js
myapp --cwd /var/www/project
```
These can run myapp from a shared directory as though it were located in another project:
```sh
myapp --myappfile /Users/name/Myappfile.js --cwd /var/www/project1
myapp --myappfile /Users/name/Myappfile.js --cwd /var/www/project2
```
#### opts.preload
A string or array of modules to attempt requiring from the local working directory before invoking the execute callback.
Type: `String|Array`
Default: `null`
**Example Configuration:**
```js
var argv = require('minimist')(process.argv.slice(2));
MyApp.prepare(
{
preload: argv.preload,
},
function (env) {
MyApp.execute(env, invoke);
}
);
```
**Matching CLI Invocation:**
```sh
myapp --preload coffee-script/register
```
#### callback(env)
A function called after your environment is prepared. A good place to modify the environment before calling `execute`. When invoked, `this` will be your instance of Liftoff. The `env` param will contain the following keys:
- `cwd`: the current working directory
- `preload`: an array of modules that liftoff tried to pre-load
- `configNameSearch`: the config files searched for
- `configPath`: the full path to your configuration file (if found)
- `configBase`: the base directory of your configuration file (if found)
- `modulePath`: the full path to the local module your project relies on (if found)
- `modulePackage`: the contents of the local module's package.json (if found)
- `configFiles`: an array of filepaths for each found config file (filepath values will be null if not found)
- `config`: an array of loaded config objects in the same order as `configFiles`
### execute(env, [forcedFlags], callback(env, argv))
A function to start your application, based on the `env` given. Optionally takes an array of `forcedFlags`, which will force a respawn with those node or V8 flags during startup. Invokes your callback with the environment and command-line arguments (minus node & v8 flags) after the application has been executed.
**Example:**
```js
const Liftoff = require('liftoff');
const MyApp = new Liftoff({ name: 'myapp' });
const onExecute = function (env, argv) {
// Do post-execute things
console.log('my environment is:', env);
console.log('my cli options are:', argv);
console.log('my liftoff config is:', this);
};
const onPrepare = function (env) {
var forcedFlags = ['--trace-deprecation'];
MyApp.execute(env, forcedFlags, onExecute);
};
MyApp.prepare({}, onPrepare);
```
#### callback(env, argv)
A function called after your application is executed. When invoked, `this` will be your instance of Liftoff, `argv` will be all command-line arguments (minus node & v8 flags), and `env` will contain the following keys:
- `cwd`: the current working directory
- `preload`: an array of modules that liftoff tried to pre-load
- `configNameSearch`: the config files searched for
- `configPath`: the full path to your configuration file (if found)
- `configBase`: the base directory of your configuration file (if found)
- `modulePath`: the full path to the local module your project relies on (if found)
- `modulePackage`: the contents of the local module's package.json (if found)
- `configFiles`: an array of filepaths for each found config file (filepath values will be null if not found)
- `config`: an array of loaded config objects in the same order as `configFiles`
### events
#### `on('preload:before', function(name) {})`
Emitted before a module is pre-load. (But for only a module which is specified by `opts.preload`.)
```js
var Hacker = new Liftoff({ name: 'hacker', preload: 'coffee-script' });
Hacker.on('preload:before', function (name) {
console.log('Requiring external module: ' + name + '...');
});
```
#### `on('preload:success', function(name, module) {})`
Emitted when a module has been pre-loaded.
```js
var Hacker = new Liftoff({ name: 'hacker' });
Hacker.on('preload:success', function (name, module) {
console.log('Required external module: ' + name + '...');
// automatically register coffee-script extensions
if (name === 'coffee-script') {
module.register();
}
});
```
#### `on('preload:failure', function(name, err) {})`
Emitted when a requested module cannot be preloaded.
```js
var Hacker = new Liftoff({ name: 'hacker' });
Hacker.on('preload:failure', function (name, err) {
console.log('Unable to load:', name, err);
});
```
#### `on('loader:success, function(name, module) {})`
Emitted when a loader that matches an extension has been loaded.
```js
var Hacker = new Liftoff({
name: 'hacker',
extensions: {
'.ts': 'ts-node/register',
},
});
Hacker.on('loader:success', function (name, module) {
console.log('Required external module: ' + name + '...');
});
```
#### `on('loader:failure', function(name, err) {})`
Emitted when no loader for an extension can be loaded. Emits an error for each failed loader.
```js
var Hacker = new Liftoff({
name: 'hacker',
extensions: {
'.ts': 'ts-node/register',
},
});
Hacker.on('loader:failure', function (name, err) {
console.log('Unable to load:', name, err);
});
```
#### `on('respawn', function(flags, child) {})`
Emitted when Liftoff re-spawns your process (when a [`v8flags`](#optsv8flags) is detected).
```js
var Hacker = new Liftoff({
name: 'hacker',
v8flags: ['--harmony'],
});
Hacker.on('respawn', function (flags, child) {
console.log('Detected node flags:', flags);
console.log('Respawned to PID:', child.pid);
});
```
Event will be triggered for this command:
`hacker --harmony commmand`
## Config files
Liftoff supports a small definition of config files, but all details provided by users will be available in `env.config`.
### `extends`
All `extends` properties will be traversed and become the basis for the resulting config object. Any path provided for `extends` will be loaded with node's `require`, so all extensions and loaders supported on the Liftoff instance will be available to them.
### Field matching the `configName`
Users can override the `configPath` via their config files by specifying a field with the same name as the primary `configName`. For example, the `hackerfile` property in a `configFile` will resolve the `configPath` and `configBase` against the path.
### `preload`
If specified as a string or array of strings, they will be added to the list of preloads in the environment.
## Examples
Check out how [gulp][gulp-cli-index] uses Liftoff.
For a bare-bones example, try [the hacker project][hacker-index].
To try the example, do the following:
1. Install the sample project `hacker` with `npm install -g hacker`.
2. Make a `Hackerfile.js` with some arbitrary javascript it.
3. Install hacker next to it with `npm install hacker`.
4. Run `hacker` while in the same parent folder.
## License
MIT
<!-- prettier-ignore-start -->
[downloads-image]: https://img.shields.io/npm/dm/liftoff.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/liftoff
[npm-image]: https://img.shields.io/npm/v/liftoff.svg?style=flat-square
[ci-url]: https://github.com/gulpjs/liftoff/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/liftoff/dev?style=flat-square
[coveralls-url]: https://coveralls.io/r/gulpjs/liftoff
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/liftoff/master.svg?style=flat-square
<!-- prettier-ignore-end -->
<!-- prettier-ignore-start -->
[liftoff-blog]: https://bocoup.com/blog/building-command-line-tools-in-node-with-liftoff
[hacker]: https://github.com/gulpjs/hacker
[interpret]: https://github.com/gulpjs/interpret
[flagged-respawn]: http://github.com/gulpjs/flagged-respawn
[v8flags]: https://github.com/gulpjs/v8flags
[fined]: https://github.com/gulpjs/fined
[process-title]: http://nodejs.org/api/process.html#process_process_title
[gulp-cli-index]: https://github.com/gulpjs/gulp-cli/blob/master/index.js
[hacker-index]: https://github.com/gulpjs/js-hacker/blob/master/bin/hacker.js
<!-- prettier-ignore-end -->

338
node_modules/liftoff/index.js generated vendored Normal file
View File

@@ -0,0 +1,338 @@
var util = require('util');
var path = require('path');
var EE = require('events').EventEmitter;
var extend = require('extend');
var resolve = require('resolve');
var flaggedRespawn = require('flagged-respawn');
var isPlainObject = require('is-plain-object').isPlainObject;
var fined = require('fined');
var findCwd = require('./lib/find_cwd');
var arrayFind = require('./lib/array_find');
var findConfig = require('./lib/find_config');
var fileSearch = require('./lib/file_search');
var needsLookup = require('./lib/needs_lookup');
var parseOptions = require('./lib/parse_options');
var silentRequire = require('./lib/silent_require');
var buildConfigName = require('./lib/build_config_name');
var registerLoader = require('./lib/register_loader');
var getNodeFlags = require('./lib/get_node_flags');
function isString(val) {
return typeof val === 'string';
}
function Liftoff(opts) {
EE.call(this);
extend(this, parseOptions(opts));
}
util.inherits(Liftoff, EE);
Liftoff.prototype.requireLocal = function (moduleName, basedir) {
try {
this.emit('preload:before', moduleName);
var result = require(resolve.sync(moduleName, { basedir: basedir }));
this.emit('preload:success', moduleName, result);
return result;
} catch (e) {
this.emit('preload:failure', moduleName, e);
}
};
Liftoff.prototype.buildEnvironment = function (opts) {
opts = opts || {};
// get modules we want to preload
var preload = opts.preload || [];
// ensure items to preload is an array
if (!Array.isArray(preload)) {
preload = [preload];
}
// make a copy of search paths that can be mutated for this run
var searchPaths = this.searchPaths.slice();
// store the instance configName to use in closures without access to `this`
var configName = this.configName;
// calculate current cwd
var cwd = findCwd(opts);
var exts = this.extensions;
var eventEmitter = this;
function findAndRegisterLoader(pathObj, defaultObj) {
var found = fined(pathObj, defaultObj);
if (!found) {
return null;
}
if (isPlainObject(found.extension)) {
registerLoader(eventEmitter, found.extension, found.path, cwd);
}
return found.path;
}
function getModulePath(cwd, xtends) {
// If relative, we need to use fined to look up the file. If not, assume a node_module
if (needsLookup(xtends)) {
var defaultObj = { cwd: cwd, extensions: exts };
// Using `xtends` like this should allow people to use a string or any object that fined accepts
var foundPath = findAndRegisterLoader(xtends, defaultObj);
if (!foundPath) {
var name;
if (typeof xtends === 'string') {
name = xtends;
} else {
name = xtends.path || xtends.name;
}
var msg = 'Unable to locate one of your extends.';
if (name) {
msg += ' Looking for file: ' + path.resolve(cwd, name);
}
throw new Error(msg);
}
return foundPath;
}
return xtends;
}
var visited = {};
function loadConfig(cwd, xtends, preferred) {
var configFilePath = getModulePath(cwd, xtends);
if (visited[configFilePath]) {
throw new Error(
'We encountered a circular extend for file: ' +
configFilePath +
'. Please remove the recursive extends.'
);
}
var configFile;
try {
configFile = require(configFilePath);
} catch (e) {
// TODO: Consider surfacing the `require` error
throw new Error(
'Encountered error when loading config file: ' + configFilePath
);
}
// resolve something like `{ gulpfile: "./abc.xyz" }` to the absolute path
// based on the path of the configFile
if (Object.prototype.hasOwnProperty.call(configFile, configName)) {
if (isString(configFile[configName])) {
configFile[configName] = path.resolve(path.dirname(configFilePath), configFile[configName]);
}
}
visited[configFilePath] = true;
if (configFile && configFile.extends) {
var nextCwd = path.dirname(configFilePath);
return loadConfig(nextCwd, configFile.extends, configFile);
}
// Always extend into an empty object so we can call `delete` on `config.extends`
var config = extend(true /* deep */, {}, configFile, preferred);
delete config.extends;
return config;
}
var configFiles = [];
if (Array.isArray(this.configFiles)) {
configFiles = this.configFiles.map(function (pathObj) {
var defaultObj = { cwd: cwd, extensions: exts };
return findAndRegisterLoader(pathObj, defaultObj);
});
}
var config = configFiles.map(function (startingLocation) {
var defaultConfig = {};
if (!startingLocation) {
return defaultConfig;
}
return loadConfig(cwd, startingLocation, defaultConfig);
});
var configPathOverride = arrayFind(config, function (cfg) {
if (Object.prototype.hasOwnProperty.call(cfg, configName)) {
if (isString(cfg[configName])) {
return cfg[configName];
}
}
});
var additionPreloads = arrayFind(config, function (cfg) {
if (Object.prototype.hasOwnProperty.call(cfg, 'preload')) {
if (Array.isArray(cfg.preload)) {
if (cfg.preload.every(isString)) {
return cfg.preload;
}
}
if (isString(cfg.preload)) {
return cfg.preload;
}
}
});
// if cwd was provided explicitly, only use it for searching config
if (opts.cwd) {
searchPaths = [cwd];
} else {
// otherwise just search in cwd first
searchPaths.unshift(cwd);
}
// calculate the regex to use for finding the config file
var configNameSearch = buildConfigName({
configName: configName,
extensions: Object.keys(this.extensions),
});
// calculate configPath
var configPath = findConfig({
configNameSearch: configNameSearch,
searchPaths: searchPaths,
configPath: opts.configPath || configPathOverride,
});
// if we have a config path, save the directory it resides in.
var configBase;
if (configPath) {
configBase = path.dirname(configPath);
// if cwd wasn't provided explicitly, it should match configBase
if (!opts.cwd) {
cwd = configBase;
}
}
// TODO: break this out into lib/
// locate local module and package next to config or explicitly provided cwd
var modulePath;
var modulePackage;
try {
var delim = path.delimiter;
var paths = process.env.NODE_PATH ? process.env.NODE_PATH.split(delim) : [];
modulePath = resolve.sync(this.moduleName, {
basedir: configBase || cwd,
paths: paths,
});
modulePackage = silentRequire(fileSearch('package.json', [modulePath]));
} catch (e) {}
// if we have a configuration but we failed to find a local module, maybe
// we are developing against ourselves?
if (!modulePath && configPath) {
// check the package.json sibling to our config to see if its `name`
// matches the module we're looking for
var modulePackagePath = fileSearch('package.json', [configBase]);
modulePackage = silentRequire(modulePackagePath);
if (modulePackage && modulePackage.name === this.moduleName) {
// if it does, our module path is `main` inside package.json
modulePath = path.join(
path.dirname(modulePackagePath),
modulePackage.main || 'index.js'
);
cwd = configBase;
} else {
// clear if we just required a package for some other project
modulePackage = {};
}
}
return {
cwd: cwd,
preload: preload.concat(additionPreloads || []),
completion: opts.completion,
configNameSearch: configNameSearch,
configPath: configPath,
configBase: configBase,
modulePath: modulePath,
modulePackage: modulePackage || {},
configFiles: configFiles,
config: config,
};
};
Liftoff.prototype.handleFlags = function (cb) {
if (typeof this.v8flags === 'function') {
this.v8flags(function (err, flags) {
if (err) {
cb(err);
} else {
cb(null, flags);
}
});
} else {
process.nextTick(
function () {
cb(null, this.v8flags);
}.bind(this)
);
}
};
Liftoff.prototype.prepare = function (opts, fn) {
if (typeof fn !== 'function') {
throw new Error('You must provide a callback function.');
}
process.title = this.processTitle;
var env = this.buildEnvironment(opts);
fn.call(this, env);
};
Liftoff.prototype.execute = function (env, forcedFlags, fn) {
var completion = env.completion;
if (completion && this.completions) {
return this.completions(completion);
}
if (typeof forcedFlags === 'function') {
fn = forcedFlags;
forcedFlags = undefined;
}
if (typeof fn !== 'function') {
throw new Error('You must provide a callback function.');
}
this.handleFlags(
function (err, flags) {
if (err) {
throw err;
}
flags = flags || [];
flaggedRespawn(flags, process.argv, forcedFlags, execute.bind(this));
function execute(ready, child, argv) {
if (child !== process) {
var execArgv = getNodeFlags.fromReorderedArgv(argv);
this.emit('respawn', execArgv, child);
}
if (ready) {
preloadModules(this, env);
registerLoader(this, this.extensions, env.configPath, env.cwd);
fn.call(this, env, argv);
}
}
}.bind(this)
);
};
function preloadModules(inst, env) {
var basedir = env.cwd;
env.preload.filter(toUnique).forEach(function (module) {
inst.requireLocal(module, basedir);
});
}
function toUnique(elem, index, array) {
return array.indexOf(elem) === index;
}
module.exports = Liftoff;

18
node_modules/liftoff/lib/array_find.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
function arrayFind(arr, fn) {
if (!Array.isArray(arr)) {
return;
}
var idx = 0;
while (idx < arr.length) {
var result = fn(arr[idx]);
if (result) {
return result;
}
idx++;
}
}
module.exports = arrayFind;

17
node_modules/liftoff/lib/build_config_name.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
module.exports = function (opts) {
opts = opts || {};
var configName = opts.configName;
var extensions = opts.extensions;
if (!configName) {
throw new Error('Please specify a configName.');
}
if (configName instanceof RegExp) {
return [configName];
}
if (!Array.isArray(extensions)) {
throw new Error('Please provide an array of valid extensions.');
}
return extensions.map(function (ext) {
return configName + ext;
});
};

14
node_modules/liftoff/lib/file_search.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
var findup = require('findup-sync');
module.exports = function (search, paths) {
var path;
var len = paths.length;
for (var i = 0; i < len; i++) {
if (path) {
break;
} else {
path = findup(search, { cwd: paths[i], nocase: true });
}
}
return path;
};

27
node_modules/liftoff/lib/find_config.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
var fs = require('fs');
var path = require('path');
var fileSearch = require('./file_search');
module.exports = function (opts) {
opts = opts || {};
var configNameSearch = opts.configNameSearch;
var configPath = opts.configPath;
var searchPaths = opts.searchPaths;
// only search for a config if a path to one wasn't explicitly provided
if (!configPath) {
if (!Array.isArray(searchPaths)) {
throw new Error(
'Please provide an array of paths to search for config in.'
);
}
if (!configNameSearch) {
throw new Error('Please provide a configNameSearch.');
}
configPath = fileSearch(configNameSearch, searchPaths);
}
// confirm the configPath exists and return an absolute path to it
if (fs.existsSync(configPath)) {
return path.resolve(configPath);
}
return null;
};

18
node_modules/liftoff/lib/find_cwd.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var path = require('path');
module.exports = function (opts) {
if (!opts) {
opts = {};
}
var cwd = opts.cwd;
var configPath = opts.configPath;
// if a path to the desired config was specified
// but no cwd was provided, use configPath dir
if (typeof configPath === 'string' && !cwd) {
cwd = path.dirname(path.resolve(configPath));
}
if (typeof cwd === 'string') {
return path.resolve(cwd);
}
return process.cwd();
};

29
node_modules/liftoff/lib/get_node_flags.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
function arrayOrFunction(arrayOrFunc, env) {
if (typeof arrayOrFunc === 'function') {
return arrayOrFunc.call(this, env);
}
if (Array.isArray(arrayOrFunc)) {
return arrayOrFunc;
}
if (typeof arrayOrFunc === 'string') {
return [arrayOrFunc];
}
return [];
}
function fromReorderedArgv(reorderedArgv) {
var nodeFlags = [];
for (var i = 1, n = reorderedArgv.length; i < n; i++) {
var arg = reorderedArgv[i];
if (!/^-/.test(arg) || arg === '--') {
break;
}
nodeFlags.push(arg);
}
return nodeFlags;
}
module.exports = {
arrayOrFunction: arrayOrFunction,
fromReorderedArgv: fromReorderedArgv,
};

18
node_modules/liftoff/lib/needs_lookup.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var isPlainObject = require('is-plain-object').isPlainObject;
function needsLookup(xtends) {
if (typeof xtends === 'string' && xtends[0] === '.') {
return true;
}
if (isPlainObject(xtends)) {
// Objects always need lookup because they can't be used with `require()`
return true;
}
return false;
}
module.exports = needsLookup;

35
node_modules/liftoff/lib/parse_options.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var extend = require('extend');
module.exports = function (opts) {
var defaults = {
extensions: {
'.js': null,
'.json': null,
},
searchPaths: [],
};
if (!opts) {
opts = {};
}
if (opts.name) {
if (!opts.processTitle) {
opts.processTitle = opts.name;
}
if (!opts.configName) {
opts.configName = opts.name + 'file';
}
if (!opts.moduleName) {
opts.moduleName = opts.name;
}
}
if (!opts.processTitle) {
throw new Error('You must specify a processTitle.');
}
if (!opts.configName) {
throw new Error('You must specify a configName.');
}
if (!opts.moduleName) {
throw new Error('You must specify a moduleName.');
}
return extend(defaults, opts);
};

26
node_modules/liftoff/lib/register_loader.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var rechoir = require('rechoir');
module.exports = function (eventEmitter, extensions, configPath, cwd) {
extensions = extensions || {};
if (typeof configPath !== 'string') {
return;
}
var autoloads = rechoir.prepare(extensions, configPath, cwd, true);
if (autoloads instanceof Error) {
// Only errors
autoloads.failures.forEach(function (failed) {
eventEmitter.emit('loader:failure', failed.moduleName, failed.error);
});
return;
}
if (!Array.isArray(autoloads)) {
// Already required or no config.
return;
}
var succeeded = autoloads[autoloads.length - 1];
eventEmitter.emit('loader:success', succeeded.moduleName, succeeded.module);
};

5
node_modules/liftoff/lib/silent_require.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
module.exports = function (path) {
try {
return require(path);
} catch (e) {}
};

59
node_modules/liftoff/package.json generated vendored Normal file
View File

@@ -0,0 +1,59 @@
{
"name": "liftoff",
"version": "5.0.0",
"description": "Launch your command line tool with ease.",
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
"contributors": [
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)",
"Tyler Kellen <tyler@sleekcode.net> (https://github.com/tkellen)",
"Takayuki Sato (https://github.com/sttk)"
],
"repository": "gulpjs/liftoff",
"license": "MIT",
"engines": {
"node": ">=10.13.0"
},
"main": "index.js",
"files": [
"index.js",
"lib",
"LICENSE"
],
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "nyc mocha --async-only"
},
"dependencies": {
"extend": "^3.0.2",
"findup-sync": "^5.0.0",
"fined": "^2.0.0",
"flagged-respawn": "^2.0.0",
"is-plain-object": "^5.0.0",
"rechoir": "^0.8.0",
"resolve": "^1.20.0"
},
"devDependencies": {
"coffeescript": "^2.6.1",
"eslint": "^7.0.0",
"eslint-config-gulp": "^5.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-node": "^11.1.0",
"expect": "^27.0.0",
"mocha": "^8.0.0",
"nyc": "^15.0.0",
"sinon": "^11.0.0"
},
"nyc": {
"reporter": [
"lcov",
"text-summary"
]
},
"prettier": {
"singleQuote": true
},
"keywords": [
"command line"
]
}