feat: update keycloak theme
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var _minimist = require('minimist');
|
||||
|
||||
var _minimist2 = _interopRequireDefault(_minimist);
|
||||
|
||||
var _shx = require('./shx');
|
||||
|
||||
var _config = require('./config');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var parsedArgs = (0, _minimist2.default)(process.argv.slice(2), { stopEarly: true, boolean: true });
|
||||
|
||||
// `input` is null if we're running from a TTY, or a string of all stdin if
|
||||
// running from the right-hand side of a pipe
|
||||
var run = function run(input) {
|
||||
// Pass stdin to shx as the 'this' parameter
|
||||
process.exitCode = _shx.shx.call(input, process.argv);
|
||||
|
||||
// We use process.exitCode to ensure we don't terminate the process before
|
||||
// streams finish. See:
|
||||
// https://github.com/shelljs/shx/issues/85
|
||||
};
|
||||
|
||||
// ShellJS doesn't support input streams, so we have to collect all input first
|
||||
if ((0, _config.shouldReadStdin)(parsedArgs._)) {
|
||||
// Read all stdin first, and then pass that onto ShellJS
|
||||
var chunks = [];
|
||||
process.stdin.on('data', function (data) {
|
||||
return chunks.push(data);
|
||||
});
|
||||
process.stdin.on('end', function () {
|
||||
return run(chunks.join(''));
|
||||
});
|
||||
} else {
|
||||
// There's no stdin, so we can immediately invoke the ShellJS function
|
||||
run(null);
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.shouldReadStdin = exports.SHELLJS_PIPE_INFO = exports.CONFIG_FILE = exports.OPTION_BLOCKLIST = exports.CMD_BLOCKLIST = exports.EXIT_CODES = undefined;
|
||||
|
||||
var _minimist = require('minimist');
|
||||
|
||||
var _minimist2 = _interopRequireDefault(_minimist);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var EXIT_CODES = exports.EXIT_CODES = {
|
||||
SHX_ERROR: 27, // https://xkcd.com/221/
|
||||
CMD_FAILED: 1, // TODO: Once shelljs/shelljs#269 lands, use `error()`
|
||||
SUCCESS: 0
|
||||
};
|
||||
|
||||
var CMD_BLOCKLIST = exports.CMD_BLOCKLIST = ['cd', 'pushd', 'popd', 'dirs', 'set', 'exit', 'exec', 'ShellString'];
|
||||
|
||||
var OPTION_BLOCKLIST = exports.OPTION_BLOCKLIST = ['globOptions', // we don't have good control over globbing in the shell
|
||||
'execPath', // we don't currently support exec
|
||||
'bufLength', // we don't use buffers in shx
|
||||
'maxdepth'];
|
||||
|
||||
var CONFIG_FILE = exports.CONFIG_FILE = '.shxrc.json';
|
||||
|
||||
var SHELLJS_PIPE_INFO = exports.SHELLJS_PIPE_INFO = {
|
||||
cat: { minArgs: 1 },
|
||||
grep: { minArgs: 2 },
|
||||
head: { minArgs: 1 },
|
||||
sed: { minArgs: 2 },
|
||||
sort: { minArgs: 1 },
|
||||
tail: { minArgs: 1 },
|
||||
uniq: { minArgs: 1 }
|
||||
};
|
||||
|
||||
// All valid options
|
||||
var allOptionsList = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
||||
|
||||
var shouldReadStdin = exports.shouldReadStdin = function shouldReadStdin(args) {
|
||||
var cmd = args[0];
|
||||
var cmdInfo = SHELLJS_PIPE_INFO[cmd];
|
||||
var parsedArgs = (0, _minimist2.default)(args.slice(1), {
|
||||
stopEarly: true,
|
||||
boolean: allOptionsList // treat all short options as booleans
|
||||
});
|
||||
var requiredNumArgs = cmdInfo ? cmdInfo.minArgs : -1;
|
||||
|
||||
// If a non-boolean option is passed in, increment the required argument
|
||||
// count (this is the case for `-n` for `head` and `tail`)
|
||||
if (parsedArgs.n && (cmd === 'head' || cmd === 'tail')) {
|
||||
requiredNumArgs++;
|
||||
}
|
||||
|
||||
return Boolean(!process.stdin.isTTY && parsedArgs._.length < requiredNumArgs);
|
||||
};
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _shelljs = require('shelljs');
|
||||
|
||||
var _shelljs2 = _interopRequireDefault(_shelljs);
|
||||
|
||||
var _config = require('./config');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// Global options defined directly in shx.
|
||||
var locallyDefinedOptions = ['version'];
|
||||
|
||||
var shxOptions = Object.keys(_shelljs2.default.config).filter(function (key) {
|
||||
return typeof _shelljs2.default.config[key] !== 'function';
|
||||
}).filter(function (key) {
|
||||
return _config.OPTION_BLOCKLIST.indexOf(key) === -1;
|
||||
}).concat(locallyDefinedOptions).map(function (key) {
|
||||
return ' * --' + key;
|
||||
});
|
||||
|
||||
exports.default = function () {
|
||||
// Note: compute this at runtime so that we have all plugins loaded.
|
||||
var commandList = Object.keys(_shelljs2.default).filter(function (cmd) {
|
||||
return typeof _shelljs2.default[cmd] === 'function';
|
||||
}).filter(function (cmd) {
|
||||
return _config.CMD_BLOCKLIST.indexOf(cmd) === -1;
|
||||
}).map(function (cmd) {
|
||||
return ' * ' + cmd;
|
||||
});
|
||||
|
||||
return '\nshx: A wrapper for shelljs UNIX commands.\n\nUsage: shx [shx-options] <command> [cmd-options] [cmd-args]\n\nExample:\n\n $ shx ls .\n foo.txt\n baz.js\n $ shx rm -rf *.txt && shx ls .\n baz.js\n\nCommands:\n\n' + commandList.join('\n') + '\n\nShx Options (please see https://github.com/shelljs/shelljs for details on each\noption):\n\n' + shxOptions.join('\n') + '\n';
|
||||
};
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var _plugin = require('shelljs/plugin');
|
||||
|
||||
var _plugin2 = _interopRequireDefault(_plugin);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var shellTrue = function shellTrue() {
|
||||
return '';
|
||||
};
|
||||
|
||||
var shellFalse = function shellFalse() {
|
||||
_plugin2.default.error('', { silent: true });
|
||||
};
|
||||
|
||||
_plugin2.default.register('true', shellTrue, {
|
||||
allowGlobbing: false,
|
||||
wrapOutput: true
|
||||
});
|
||||
|
||||
_plugin2.default.register('false', shellFalse, {
|
||||
allowGlobbing: false,
|
||||
wrapOutput: true
|
||||
});
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
// This function takes the raw result of a shelljs command and figures out how to print it.
|
||||
// Invoke this *REGARDLESS* of what the command returns, it will figure it out.
|
||||
var printCmdRet = exports.printCmdRet = function printCmdRet(ret) {
|
||||
// Don't print these types
|
||||
if (typeof ret === 'boolean' || !ret) return;
|
||||
|
||||
if (typeof ret.stdout === 'string') {
|
||||
process.stdout.write(ret.stdout);
|
||||
} else {
|
||||
process.stdout.write(ret);
|
||||
}
|
||||
};
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.shx = shx;
|
||||
|
||||
var _shelljs = require('shelljs');
|
||||
|
||||
var _shelljs2 = _interopRequireDefault(_shelljs);
|
||||
|
||||
var _minimist = require('minimist');
|
||||
|
||||
var _minimist2 = _interopRequireDefault(_minimist);
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _help = require('./help');
|
||||
|
||||
var _help2 = _interopRequireDefault(_help);
|
||||
|
||||
var _config = require('./config');
|
||||
|
||||
var _printCmdRet = require('./printCmdRet');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
|
||||
|
||||
_shelljs2.default.help = _help2.default;
|
||||
|
||||
var convertSedRegex = function convertSedRegex(args) {
|
||||
var newArgs = [];
|
||||
var lookingForSubstString = true;
|
||||
args.forEach(function (arg) {
|
||||
// A regex or replacement string can be any sequence of zero or more
|
||||
// (a) non-slashes or (b) escaped chars.
|
||||
var escapedChar = '\\\\.'; // This may match an escaped slash (i.e., "\/")
|
||||
var nonSlash = '[^/]';
|
||||
var nonSlashSequence = '(?:' + escapedChar + '|' + nonSlash + ')*';
|
||||
var sedPattern = '^s/(' + nonSlashSequence + ')/(' + nonSlashSequence + ')/(g?)$';
|
||||
var match = arg.match(new RegExp(sedPattern));
|
||||
if (match && lookingForSubstString) {
|
||||
var regexString = match[1].replace(/\\\//g, '/');
|
||||
var replacement = match[2].replace(/\\\//g, '/').replace(/\\./g, '.');
|
||||
var regexFlags = match[3];
|
||||
if (regexString === '') {
|
||||
// Unix sed gives an error if the pattern is the empty string, so we
|
||||
// forbid this case even though JavaScript's .replace() has well-defined
|
||||
// behavior.
|
||||
throw new Error('Bad sed pattern (empty regex)');
|
||||
}
|
||||
newArgs.push(new RegExp(regexString, regexFlags));
|
||||
newArgs.push(replacement);
|
||||
lookingForSubstString = false;
|
||||
} else {
|
||||
newArgs.push(arg);
|
||||
}
|
||||
});
|
||||
return newArgs;
|
||||
};
|
||||
|
||||
function shx(argv) {
|
||||
var parsedArgs = (0, _minimist2.default)(argv.slice(2), { stopEarly: true, boolean: true });
|
||||
if (parsedArgs.version) {
|
||||
var shxVersion = require('../package.json').version;
|
||||
var shelljsVersion = require('shelljs/package.json').version;
|
||||
console.log('shx v' + shxVersion + ' (using ShellJS v' + shelljsVersion + ')');
|
||||
return _config.EXIT_CODES.SUCCESS;
|
||||
}
|
||||
|
||||
var _parsedArgs$_ = _toArray(parsedArgs._),
|
||||
fnName = _parsedArgs$_[0],
|
||||
args = _parsedArgs$_.slice(1);
|
||||
|
||||
if (!fnName) {
|
||||
console.error('Error: Missing ShellJS command name');
|
||||
console.error((0, _help2.default)());
|
||||
return _config.EXIT_CODES.SHX_ERROR;
|
||||
}
|
||||
|
||||
// Load ShellJS plugins
|
||||
var CONFIG_PATH = _path2.default.join(process.cwd(), _config.CONFIG_FILE);
|
||||
if (_fs2.default.existsSync(CONFIG_PATH)) {
|
||||
var shxConfig = void 0;
|
||||
try {
|
||||
shxConfig = require(CONFIG_PATH);
|
||||
} catch (e) {
|
||||
throw new Error('Unable to read config file ' + _config.CONFIG_FILE);
|
||||
}
|
||||
|
||||
(shxConfig.plugins || []).forEach(function (pluginName) {
|
||||
try {
|
||||
require(pluginName);
|
||||
} catch (e) {
|
||||
throw new Error('Unable to find plugin \'' + pluginName + '\'');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Always load true-false plugin
|
||||
require('./plugin-true-false');
|
||||
|
||||
// validate command
|
||||
if (typeof _shelljs2.default[fnName] !== 'function') {
|
||||
console.error('Error: Invalid ShellJS command: ' + fnName + '.');
|
||||
console.error((0, _help2.default)());
|
||||
return _config.EXIT_CODES.SHX_ERROR;
|
||||
} else if (_config.CMD_BLOCKLIST.indexOf(fnName) > -1) {
|
||||
console.error('Warning: shx ' + fnName + ' is not supported');
|
||||
console.error('Please run `shx help` for a list of commands.');
|
||||
return _config.EXIT_CODES.SHX_ERROR;
|
||||
}
|
||||
|
||||
var input = this !== null ? new _shelljs2.default.ShellString(this) : null;
|
||||
|
||||
// Set shell.config with parsed options
|
||||
Object.assign(_shelljs2.default.config, parsedArgs);
|
||||
|
||||
// Workaround for sed syntax
|
||||
var ret = void 0;
|
||||
if (fnName === 'sed') {
|
||||
var newArgs = convertSedRegex(args);
|
||||
ret = _shelljs2.default[fnName].apply(input, newArgs);
|
||||
} else {
|
||||
ret = _shelljs2.default[fnName].apply(input, args);
|
||||
}
|
||||
if (ret === null) ret = _shelljs2.default.ShellString('', '', 1);
|
||||
|
||||
/* instanbul ignore next */
|
||||
var code = Object.prototype.hasOwnProperty.call(ret, 'code') && ret.code;
|
||||
|
||||
if ((fnName === 'pwd' || fnName === 'which') && !ret.match(/\n$/) && ret.length > 1) {
|
||||
ret += '\n';
|
||||
}
|
||||
|
||||
// echo already prints
|
||||
if (fnName !== 'echo') (0, _printCmdRet.printCmdRet)(ret);
|
||||
if (typeof ret === 'boolean') {
|
||||
code = ret ? 0 : 1;
|
||||
}
|
||||
|
||||
if (typeof code === 'number') {
|
||||
return code;
|
||||
} else if (_shelljs2.default.error()) {
|
||||
/* istanbul ignore next */
|
||||
return _config.EXIT_CODES.CMD_FAILED;
|
||||
}
|
||||
|
||||
return _config.EXIT_CODES.SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user