Initial commit
This commit is contained in:
284
themes/keepit/node_modules/@babel/cli/lib/babel/dir.js
generated
vendored
Normal file
284
themes/keepit/node_modules/@babel/cli/lib/babel/dir.js
generated
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
function _slash() {
|
||||
const data = require("slash");
|
||||
|
||||
_slash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var util = require("./util");
|
||||
|
||||
var watcher = require("./watcher");
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
||||
|
||||
const FILE_TYPE = Object.freeze({
|
||||
NON_COMPILABLE: "NON_COMPILABLE",
|
||||
COMPILED: "COMPILED",
|
||||
IGNORED: "IGNORED",
|
||||
ERR_COMPILATION: "ERR_COMPILATION"
|
||||
});
|
||||
|
||||
function outputFileSync(filePath, data) {
|
||||
(((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "10.12") ? _fs().mkdirSync : require("make-dir").sync)(_path().dirname(filePath), {
|
||||
recursive: true
|
||||
});
|
||||
|
||||
_fs().writeFileSync(filePath, data);
|
||||
}
|
||||
|
||||
function _default(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _ref() {
|
||||
_ref = _asyncToGenerator(function* ({
|
||||
cliOptions,
|
||||
babelOptions
|
||||
}) {
|
||||
function write(_x2, _x3) {
|
||||
return _write.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _write() {
|
||||
_write = _asyncToGenerator(function* (src, base) {
|
||||
let relative = _path().relative(base, src);
|
||||
|
||||
if (!util.isCompilableExtension(relative, cliOptions.extensions)) {
|
||||
return FILE_TYPE.NON_COMPILABLE;
|
||||
}
|
||||
|
||||
relative = util.withExtension(relative, cliOptions.keepFileExtension ? _path().extname(relative) : cliOptions.outFileExtension);
|
||||
const dest = getDest(relative, base);
|
||||
|
||||
try {
|
||||
const res = yield util.compile(src, Object.assign({}, babelOptions, {
|
||||
sourceFileName: _slash()(_path().relative(dest + "/..", src))
|
||||
}));
|
||||
if (!res) return FILE_TYPE.IGNORED;
|
||||
|
||||
if (res.map && babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
|
||||
const mapLoc = dest + ".map";
|
||||
res.code = util.addSourceMappingUrl(res.code, mapLoc);
|
||||
res.map.file = _path().basename(relative);
|
||||
outputFileSync(mapLoc, JSON.stringify(res.map));
|
||||
}
|
||||
|
||||
outputFileSync(dest, res.code);
|
||||
util.chmod(src, dest);
|
||||
|
||||
if (cliOptions.verbose) {
|
||||
console.log(_path().relative(process.cwd(), src) + " -> " + dest);
|
||||
}
|
||||
|
||||
return FILE_TYPE.COMPILED;
|
||||
} catch (err) {
|
||||
if (cliOptions.watch) {
|
||||
console.error(err);
|
||||
return FILE_TYPE.ERR_COMPILATION;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
return _write.apply(this, arguments);
|
||||
}
|
||||
|
||||
function getDest(filename, base) {
|
||||
if (cliOptions.relative) {
|
||||
return _path().join(base, cliOptions.outDir, filename);
|
||||
}
|
||||
|
||||
return _path().join(cliOptions.outDir, filename);
|
||||
}
|
||||
|
||||
function handleFile(_x4, _x5) {
|
||||
return _handleFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _handleFile() {
|
||||
_handleFile = _asyncToGenerator(function* (src, base) {
|
||||
const written = yield write(src, base);
|
||||
|
||||
if (cliOptions.copyFiles && written === FILE_TYPE.NON_COMPILABLE || cliOptions.copyIgnored && written === FILE_TYPE.IGNORED) {
|
||||
const filename = _path().relative(base, src);
|
||||
|
||||
const dest = getDest(filename, base);
|
||||
outputFileSync(dest, _fs().readFileSync(src));
|
||||
util.chmod(src, dest);
|
||||
}
|
||||
|
||||
return written === FILE_TYPE.COMPILED;
|
||||
});
|
||||
return _handleFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function handle(_x6) {
|
||||
return _handle.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _handle() {
|
||||
_handle = _asyncToGenerator(function* (filenameOrDir) {
|
||||
if (!_fs().existsSync(filenameOrDir)) return 0;
|
||||
|
||||
const stat = _fs().statSync(filenameOrDir);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
const dirname = filenameOrDir;
|
||||
let count = 0;
|
||||
const files = util.readdir(dirname, cliOptions.includeDotfiles);
|
||||
|
||||
for (const filename of files) {
|
||||
const src = _path().join(dirname, filename);
|
||||
|
||||
const written = yield handleFile(src, dirname);
|
||||
if (written) count += 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
} else {
|
||||
const filename = filenameOrDir;
|
||||
const written = yield handleFile(filename, _path().dirname(filename));
|
||||
return written ? 1 : 0;
|
||||
}
|
||||
});
|
||||
return _handle.apply(this, arguments);
|
||||
}
|
||||
|
||||
let compiledFiles = 0;
|
||||
let startTime = null;
|
||||
const logSuccess = util.debounce(function () {
|
||||
if (startTime === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const diff = process.hrtime(startTime);
|
||||
console.log(`Successfully compiled ${compiledFiles} ${compiledFiles !== 1 ? "files" : "file"} with Babel (${diff[0] * 1e3 + Math.round(diff[1] / 1e6)}ms).`);
|
||||
compiledFiles = 0;
|
||||
startTime = null;
|
||||
}, 100);
|
||||
if (cliOptions.watch) watcher.enable({
|
||||
enableGlobbing: true
|
||||
});
|
||||
|
||||
if (!cliOptions.skipInitialBuild) {
|
||||
if (cliOptions.deleteDirOnStart) {
|
||||
util.deleteDir(cliOptions.outDir);
|
||||
}
|
||||
|
||||
(((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "10.12") ? _fs().mkdirSync : require("make-dir").sync)(cliOptions.outDir, {
|
||||
recursive: true
|
||||
});
|
||||
startTime = process.hrtime();
|
||||
|
||||
for (const filename of cliOptions.filenames) {
|
||||
compiledFiles += yield handle(filename);
|
||||
}
|
||||
|
||||
if (!cliOptions.quiet) {
|
||||
logSuccess();
|
||||
logSuccess.flush();
|
||||
}
|
||||
}
|
||||
|
||||
if (cliOptions.watch) {
|
||||
let processing = 0;
|
||||
const {
|
||||
filenames
|
||||
} = cliOptions;
|
||||
let getBase;
|
||||
|
||||
if (filenames.length === 1) {
|
||||
const base = filenames[0];
|
||||
|
||||
const absoluteBase = _path().resolve(base);
|
||||
|
||||
getBase = filename => {
|
||||
return filename === absoluteBase ? _path().dirname(base) : base;
|
||||
};
|
||||
} else {
|
||||
const filenameToBaseMap = new Map(filenames.map(filename => {
|
||||
const absoluteFilename = _path().resolve(filename);
|
||||
|
||||
return [absoluteFilename, _path().dirname(filename)];
|
||||
}));
|
||||
const absoluteFilenames = new Map(filenames.map(filename => {
|
||||
const absoluteFilename = _path().resolve(filename);
|
||||
|
||||
return [absoluteFilename, filename];
|
||||
}));
|
||||
|
||||
const {
|
||||
sep
|
||||
} = _path();
|
||||
|
||||
getBase = filename => {
|
||||
const base = filenameToBaseMap.get(filename);
|
||||
|
||||
if (base !== undefined) {
|
||||
return base;
|
||||
}
|
||||
|
||||
for (const [absoluteFilenameOrDir, relative] of absoluteFilenames) {
|
||||
if (filename.startsWith(absoluteFilenameOrDir + sep)) {
|
||||
filenameToBaseMap.set(filename, relative);
|
||||
return relative;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
}
|
||||
|
||||
filenames.forEach(filenameOrDir => {
|
||||
watcher.watch(filenameOrDir);
|
||||
});
|
||||
watcher.onFilesChange(_asyncToGenerator(function* (filenames) {
|
||||
processing++;
|
||||
if (startTime === null) startTime = process.hrtime();
|
||||
|
||||
try {
|
||||
const written = yield Promise.all(filenames.map(filename => handleFile(filename, getBase(filename))));
|
||||
compiledFiles += written.filter(Boolean).length;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
processing--;
|
||||
if (processing === 0 && !cliOptions.quiet) logSuccess();
|
||||
}));
|
||||
}
|
||||
});
|
||||
return _ref.apply(this, arguments);
|
||||
}
|
||||
272
themes/keepit/node_modules/@babel/cli/lib/babel/file.js
generated
vendored
Normal file
272
themes/keepit/node_modules/@babel/cli/lib/babel/file.js
generated
vendored
Normal file
@@ -0,0 +1,272 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
function _convertSourceMap() {
|
||||
const data = require("convert-source-map");
|
||||
|
||||
_convertSourceMap = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _traceMapping() {
|
||||
const data = require("@jridgewell/trace-mapping");
|
||||
|
||||
_traceMapping = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _slash() {
|
||||
const data = require("slash");
|
||||
|
||||
_slash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var util = require("./util");
|
||||
|
||||
var watcher = require("./watcher");
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
||||
|
||||
function _default(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _ref() {
|
||||
_ref = _asyncToGenerator(function* ({
|
||||
cliOptions,
|
||||
babelOptions
|
||||
}) {
|
||||
function buildResult(fileResults) {
|
||||
const mapSections = [];
|
||||
let code = "";
|
||||
let offset = 0;
|
||||
|
||||
for (const result of fileResults) {
|
||||
if (!result) continue;
|
||||
mapSections.push({
|
||||
offset: {
|
||||
line: offset,
|
||||
column: 0
|
||||
},
|
||||
map: result.map || emptyMap()
|
||||
});
|
||||
code += result.code + "\n";
|
||||
offset += countNewlines(result.code) + 1;
|
||||
}
|
||||
|
||||
const map = new (_traceMapping().AnyMap)({
|
||||
version: 3,
|
||||
file: cliOptions.sourceMapTarget || _path().basename(cliOptions.outFile || "") || "stdout",
|
||||
sections: mapSections
|
||||
});
|
||||
map.sourceRoot = babelOptions.sourceRoot;
|
||||
|
||||
if (babelOptions.sourceMaps === "inline" || !cliOptions.outFile && babelOptions.sourceMaps) {
|
||||
code += "\n" + _convertSourceMap().fromObject((0, _traceMapping().encodedMap)(map)).toComment();
|
||||
}
|
||||
|
||||
return {
|
||||
map: map,
|
||||
code: code
|
||||
};
|
||||
}
|
||||
|
||||
function countNewlines(code) {
|
||||
let count = 0;
|
||||
let index = -1;
|
||||
|
||||
while ((index = code.indexOf("\n", index + 1)) !== -1) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function emptyMap() {
|
||||
return {
|
||||
version: 3,
|
||||
names: [],
|
||||
sources: [],
|
||||
mappings: []
|
||||
};
|
||||
}
|
||||
|
||||
function output(fileResults) {
|
||||
const result = buildResult(fileResults);
|
||||
|
||||
if (cliOptions.outFile) {
|
||||
(((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "10.12") ? _fs().mkdirSync : require("make-dir").sync)(_path().dirname(cliOptions.outFile), {
|
||||
recursive: true
|
||||
});
|
||||
|
||||
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
|
||||
const mapLoc = cliOptions.outFile + ".map";
|
||||
result.code = util.addSourceMappingUrl(result.code, mapLoc);
|
||||
|
||||
_fs().writeFileSync(mapLoc, JSON.stringify((0, _traceMapping().encodedMap)(result.map)));
|
||||
}
|
||||
|
||||
_fs().writeFileSync(cliOptions.outFile, result.code);
|
||||
} else {
|
||||
process.stdout.write(result.code + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
function readStdin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let code = "";
|
||||
process.stdin.setEncoding("utf8");
|
||||
process.stdin.on("readable", function () {
|
||||
const chunk = process.stdin.read();
|
||||
if (chunk !== null) code += chunk;
|
||||
});
|
||||
process.stdin.on("end", function () {
|
||||
resolve(code);
|
||||
});
|
||||
process.stdin.on("error", reject);
|
||||
});
|
||||
}
|
||||
|
||||
function stdin() {
|
||||
return _stdin.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _stdin() {
|
||||
_stdin = _asyncToGenerator(function* () {
|
||||
const code = yield readStdin();
|
||||
const res = yield util.transformRepl(cliOptions.filename, code, Object.assign({}, babelOptions, {
|
||||
sourceFileName: "stdin"
|
||||
}));
|
||||
output([res]);
|
||||
});
|
||||
return _stdin.apply(this, arguments);
|
||||
}
|
||||
|
||||
function walk(_x2) {
|
||||
return _walk.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _walk() {
|
||||
_walk = _asyncToGenerator(function* (filenames) {
|
||||
const _filenames = [];
|
||||
filenames.forEach(function (filename) {
|
||||
if (!_fs().existsSync(filename)) return;
|
||||
|
||||
const stat = _fs().statSync(filename);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
const dirname = filename;
|
||||
util.readdirForCompilable(filename, cliOptions.includeDotfiles, cliOptions.extensions).forEach(function (filename) {
|
||||
_filenames.push(_path().join(dirname, filename));
|
||||
});
|
||||
} else {
|
||||
_filenames.push(filename);
|
||||
}
|
||||
});
|
||||
const results = yield Promise.all(_filenames.map(_asyncToGenerator(function* (filename) {
|
||||
let sourceFilename = filename;
|
||||
|
||||
if (cliOptions.outFile) {
|
||||
sourceFilename = _path().relative(_path().dirname(cliOptions.outFile), sourceFilename);
|
||||
}
|
||||
|
||||
sourceFilename = _slash()(sourceFilename);
|
||||
|
||||
try {
|
||||
return yield util.compile(filename, Object.assign({}, babelOptions, {
|
||||
sourceFileName: sourceFilename,
|
||||
sourceMaps: babelOptions.sourceMaps === "inline" ? true : babelOptions.sourceMaps
|
||||
}));
|
||||
} catch (err) {
|
||||
if (!cliOptions.watch) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.error(err);
|
||||
return null;
|
||||
}
|
||||
})));
|
||||
output(results);
|
||||
});
|
||||
return _walk.apply(this, arguments);
|
||||
}
|
||||
|
||||
function files(_x3) {
|
||||
return _files.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _files() {
|
||||
_files = _asyncToGenerator(function* (filenames) {
|
||||
if (cliOptions.watch) {
|
||||
watcher.enable({
|
||||
enableGlobbing: false
|
||||
});
|
||||
}
|
||||
|
||||
if (!cliOptions.skipInitialBuild) {
|
||||
yield walk(filenames);
|
||||
}
|
||||
|
||||
if (cliOptions.watch) {
|
||||
filenames.forEach(watcher.watch);
|
||||
watcher.onFilesChange((changes, event, cause) => {
|
||||
const actionableChange = changes.some(filename => util.isCompilableExtension(filename, cliOptions.extensions) || filenames.includes(filename));
|
||||
if (!actionableChange) return;
|
||||
|
||||
if (cliOptions.verbose) {
|
||||
console.log(`${event} ${cause}`);
|
||||
}
|
||||
|
||||
walk(filenames).catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return _files.apply(this, arguments);
|
||||
}
|
||||
|
||||
if (cliOptions.filenames.length) {
|
||||
yield files(cliOptions.filenames);
|
||||
} else {
|
||||
yield stdin();
|
||||
}
|
||||
});
|
||||
return _ref.apply(this, arguments);
|
||||
}
|
||||
20
themes/keepit/node_modules/@babel/cli/lib/babel/index.js
generated
vendored
Normal file
20
themes/keepit/node_modules/@babel/cli/lib/babel/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
|
||||
var _options = require("./options");
|
||||
|
||||
var _dir = require("./dir");
|
||||
|
||||
var _file = require("./file");
|
||||
|
||||
const opts = (0, _options.default)(process.argv);
|
||||
|
||||
if (opts) {
|
||||
const fn = opts.cliOptions.outDir ? _dir.default : _file.default;
|
||||
fn(opts).catch(err => {
|
||||
console.error(err);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
} else {
|
||||
process.exitCode = 2;
|
||||
}
|
||||
285
themes/keepit/node_modules/@babel/cli/lib/babel/options.js
generated
vendored
Normal file
285
themes/keepit/node_modules/@babel/cli/lib/babel/options.js
generated
vendored
Normal file
@@ -0,0 +1,285 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = parseArgv;
|
||||
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _commander() {
|
||||
const data = require("commander");
|
||||
|
||||
_commander = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _core() {
|
||||
const data = require("@babel/core");
|
||||
|
||||
_core = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _glob() {
|
||||
const data = require("glob");
|
||||
|
||||
_glob = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
_commander().option("-f, --filename [filename]", "The filename to use when reading from stdin. This will be used in source-maps, errors etc.");
|
||||
|
||||
_commander().option("--presets [list]", "A comma-separated list of preset names.", collect);
|
||||
|
||||
_commander().option("--plugins [list]", "A comma-separated list of plugin names.", collect);
|
||||
|
||||
_commander().option("--config-file [path]", "Path to a .babelrc file to use.");
|
||||
|
||||
_commander().option("--env-name [name]", "The name of the 'env' to use when loading configs and plugins. " + "Defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'.");
|
||||
|
||||
_commander().option("--root-mode [mode]", "The project-root resolution mode. " + "One of 'root' (the default), 'upward', or 'upward-optional'.");
|
||||
|
||||
_commander().option("--source-type [script|module]", "");
|
||||
|
||||
_commander().option("--no-babelrc", "Whether or not to look up .babelrc and .babelignore files.");
|
||||
|
||||
_commander().option("--ignore [list]", "List of glob paths to **not** compile.", collect);
|
||||
|
||||
_commander().option("--only [list]", "List of glob paths to **only** compile.", collect);
|
||||
|
||||
_commander().option("--no-highlight-code", "Enable or disable ANSI syntax highlighting of code frames. (on by default)");
|
||||
|
||||
_commander().option("--no-comments", "Write comments to generated output. (true by default)");
|
||||
|
||||
_commander().option("--retain-lines", "Retain line numbers. This will result in really ugly code.");
|
||||
|
||||
_commander().option("--compact [true|false|auto]", "Do not include superfluous whitespace characters and line terminators.", booleanify);
|
||||
|
||||
_commander().option("--minified", "Save as many bytes when printing. (false by default)");
|
||||
|
||||
_commander().option("--auxiliary-comment-before [string]", "Print a comment before any injected non-user code.");
|
||||
|
||||
_commander().option("--auxiliary-comment-after [string]", "Print a comment after any injected non-user code.");
|
||||
|
||||
_commander().option("-s, --source-maps [true|false|inline|both]", "", booleanify);
|
||||
|
||||
_commander().option("--source-map-target [string]", "Set `file` on returned source map.");
|
||||
|
||||
_commander().option("--source-file-name [string]", "Set `sources[0]` on returned source map.");
|
||||
|
||||
_commander().option("--source-root [filename]", "The root from which all sources are relative.");
|
||||
|
||||
{
|
||||
_commander().option("--module-root [filename]", "Optional prefix for the AMD module formatter that will be prepended to the filename on module definitions.");
|
||||
|
||||
_commander().option("-M, --module-ids", "Insert an explicit id for modules.");
|
||||
|
||||
_commander().option("--module-id [string]", "Specify a custom name for module ids.");
|
||||
}
|
||||
|
||||
_commander().option("-x, --extensions [extensions]", "List of extensions to compile when a directory has been the input. [" + _core().DEFAULT_EXTENSIONS.join() + "]", collect);
|
||||
|
||||
_commander().option("--keep-file-extension", "Preserve the file extensions of the input files.");
|
||||
|
||||
_commander().option("-w, --watch", "Recompile files on changes.");
|
||||
|
||||
_commander().option("--skip-initial-build", "Do not compile files before watching.");
|
||||
|
||||
_commander().option("-o, --out-file [out]", "Compile all input files into a single file.");
|
||||
|
||||
_commander().option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory.");
|
||||
|
||||
_commander().option("--relative", "Compile into an output directory relative to input directory or file. Requires --out-dir [out]");
|
||||
|
||||
_commander().option("-D, --copy-files", "When compiling a directory copy over non-compilable files.");
|
||||
|
||||
_commander().option("--include-dotfiles", "Include dotfiles when compiling and copying non-compilable files.");
|
||||
|
||||
_commander().option("--no-copy-ignored", "Exclude ignored files when copying non-compilable files.");
|
||||
|
||||
_commander().option("--verbose", "Log everything. This option conflicts with --quiet");
|
||||
|
||||
_commander().option("--quiet", "Don't log anything. This option conflicts with --verbose");
|
||||
|
||||
_commander().option("--delete-dir-on-start", "Delete the out directory before compilation.");
|
||||
|
||||
_commander().option("--out-file-extension [string]", "Use a specific extension for the output files");
|
||||
|
||||
_commander().version("7.17.10" + " (@babel/core " + _core().version + ")");
|
||||
|
||||
_commander().usage("[options] <files ...>");
|
||||
|
||||
_commander().action(() => {});
|
||||
|
||||
function parseArgv(args) {
|
||||
_commander().parse(args);
|
||||
|
||||
const errors = [];
|
||||
|
||||
let filenames = _commander().args.reduce(function (globbed, input) {
|
||||
let files = _glob().sync(input);
|
||||
|
||||
if (!files.length) files = [input];
|
||||
globbed.push(...files);
|
||||
return globbed;
|
||||
}, []);
|
||||
|
||||
filenames = Array.from(new Set(filenames));
|
||||
filenames.forEach(function (filename) {
|
||||
if (!_fs().existsSync(filename)) {
|
||||
errors.push(filename + " does not exist");
|
||||
}
|
||||
});
|
||||
|
||||
if (_commander().outDir && !filenames.length) {
|
||||
errors.push("--out-dir requires filenames");
|
||||
}
|
||||
|
||||
if (_commander().outFile && _commander().outDir) {
|
||||
errors.push("--out-file and --out-dir cannot be used together");
|
||||
}
|
||||
|
||||
if (_commander().relative && !_commander().outDir) {
|
||||
errors.push("--relative requires --out-dir usage");
|
||||
}
|
||||
|
||||
if (_commander().watch) {
|
||||
if (!_commander().outFile && !_commander().outDir) {
|
||||
errors.push("--watch requires --out-file or --out-dir");
|
||||
}
|
||||
|
||||
if (!filenames.length) {
|
||||
errors.push("--watch requires filenames");
|
||||
}
|
||||
}
|
||||
|
||||
if (_commander().skipInitialBuild && !_commander().watch) {
|
||||
errors.push("--skip-initial-build requires --watch");
|
||||
}
|
||||
|
||||
if (_commander().deleteDirOnStart && !_commander().outDir) {
|
||||
errors.push("--delete-dir-on-start requires --out-dir");
|
||||
}
|
||||
|
||||
if (_commander().verbose && _commander().quiet) {
|
||||
errors.push("--verbose and --quiet cannot be used together");
|
||||
}
|
||||
|
||||
if (!_commander().outDir && filenames.length === 0 && typeof _commander().filename !== "string" && _commander().babelrc !== false) {
|
||||
errors.push("stdin compilation requires either -f/--filename [filename] or --no-babelrc");
|
||||
}
|
||||
|
||||
if (_commander().keepFileExtension && _commander().outFileExtension) {
|
||||
errors.push("--out-file-extension cannot be used with --keep-file-extension");
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
console.error("babel:");
|
||||
errors.forEach(function (e) {
|
||||
console.error(" " + e);
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
const opts = _commander().opts();
|
||||
|
||||
const babelOptions = {
|
||||
presets: opts.presets,
|
||||
plugins: opts.plugins,
|
||||
rootMode: opts.rootMode,
|
||||
configFile: opts.configFile,
|
||||
envName: opts.envName,
|
||||
sourceType: opts.sourceType,
|
||||
ignore: opts.ignore,
|
||||
only: opts.only,
|
||||
retainLines: opts.retainLines,
|
||||
compact: opts.compact,
|
||||
minified: opts.minified,
|
||||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||||
sourceMaps: opts.sourceMaps,
|
||||
sourceFileName: opts.sourceFileName,
|
||||
sourceRoot: opts.sourceRoot,
|
||||
babelrc: opts.babelrc === true ? undefined : opts.babelrc,
|
||||
highlightCode: opts.highlightCode === true ? undefined : opts.highlightCode,
|
||||
comments: opts.comments === true ? undefined : opts.comments
|
||||
};
|
||||
{
|
||||
Object.assign(babelOptions, {
|
||||
moduleRoot: opts.moduleRoot,
|
||||
moduleIds: opts.moduleIds,
|
||||
moduleId: opts.moduleId
|
||||
});
|
||||
}
|
||||
|
||||
for (const key of Object.keys(babelOptions)) {
|
||||
if (babelOptions[key] === undefined) {
|
||||
delete babelOptions[key];
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
babelOptions,
|
||||
cliOptions: {
|
||||
filename: opts.filename,
|
||||
filenames,
|
||||
extensions: opts.extensions,
|
||||
keepFileExtension: opts.keepFileExtension,
|
||||
outFileExtension: opts.outFileExtension,
|
||||
watch: opts.watch,
|
||||
skipInitialBuild: opts.skipInitialBuild,
|
||||
outFile: opts.outFile,
|
||||
outDir: opts.outDir,
|
||||
relative: opts.relative,
|
||||
copyFiles: opts.copyFiles,
|
||||
copyIgnored: opts.copyFiles && opts.copyIgnored,
|
||||
includeDotfiles: opts.includeDotfiles,
|
||||
verbose: opts.verbose,
|
||||
quiet: opts.quiet,
|
||||
deleteDirOnStart: opts.deleteDirOnStart,
|
||||
sourceMapTarget: opts.sourceMapTarget
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function booleanify(val) {
|
||||
if (val === "true" || val == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (val === "false" || val == 0 || !val) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
function collect(value, previousValue) {
|
||||
if (typeof value !== "string") return previousValue;
|
||||
const values = value.split(",");
|
||||
|
||||
if (previousValue) {
|
||||
previousValue.push(...values);
|
||||
return previousValue;
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
181
themes/keepit/node_modules/@babel/cli/lib/babel/util.js
generated
vendored
Normal file
181
themes/keepit/node_modules/@babel/cli/lib/babel/util.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.addSourceMappingUrl = addSourceMappingUrl;
|
||||
exports.chmod = chmod;
|
||||
exports.compile = compile;
|
||||
exports.debounce = debounce;
|
||||
exports.deleteDir = deleteDir;
|
||||
exports.isCompilableExtension = isCompilableExtension;
|
||||
exports.readdir = readdir;
|
||||
exports.readdirForCompilable = readdirForCompilable;
|
||||
exports.transformRepl = transformRepl;
|
||||
exports.withExtension = withExtension;
|
||||
|
||||
function _fsReaddirRecursive() {
|
||||
const data = require("fs-readdir-recursive");
|
||||
|
||||
_fsReaddirRecursive = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function babel() {
|
||||
const data = require("@babel/core");
|
||||
|
||||
babel = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var watcher = require("./watcher");
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
||||
|
||||
function chmod(src, dest) {
|
||||
try {
|
||||
_fs().chmodSync(dest, _fs().statSync(src).mode);
|
||||
} catch (err) {
|
||||
console.warn(`Cannot change permissions of ${dest}`);
|
||||
}
|
||||
}
|
||||
|
||||
function readdir(dirname, includeDotfiles, filter) {
|
||||
return _fsReaddirRecursive()(dirname, (filename, _index, currentDirectory) => {
|
||||
const stat = _fs().statSync(_path().join(currentDirectory, filename));
|
||||
|
||||
if (stat.isDirectory()) return true;
|
||||
return (includeDotfiles || filename[0] !== ".") && (!filter || filter(filename));
|
||||
});
|
||||
}
|
||||
|
||||
function readdirForCompilable(dirname, includeDotfiles, altExts) {
|
||||
return readdir(dirname, includeDotfiles, function (filename) {
|
||||
return isCompilableExtension(filename, altExts);
|
||||
});
|
||||
}
|
||||
|
||||
function isCompilableExtension(filename, altExts) {
|
||||
const exts = altExts || babel().DEFAULT_EXTENSIONS;
|
||||
|
||||
const ext = _path().extname(filename);
|
||||
|
||||
return exts.includes(ext);
|
||||
}
|
||||
|
||||
function addSourceMappingUrl(code, loc) {
|
||||
return code + "\n//# sourceMappingURL=" + _path().basename(loc);
|
||||
}
|
||||
|
||||
const CALLER = {
|
||||
name: "@babel/cli"
|
||||
};
|
||||
|
||||
function transformRepl(filename, code, opts) {
|
||||
opts = Object.assign({}, opts, {
|
||||
caller: CALLER,
|
||||
filename
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
babel().transform(code, opts, (err, result) => {
|
||||
if (err) reject(err);else resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function compile(_x, _x2) {
|
||||
return _compile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _compile() {
|
||||
_compile = _asyncToGenerator(function* (filename, opts) {
|
||||
opts = Object.assign({}, opts, {
|
||||
caller: CALLER
|
||||
});
|
||||
const result = yield new Promise((resolve, reject) => {
|
||||
babel().transformFile(filename, opts, (err, result) => {
|
||||
if (err) reject(err);else resolve(result);
|
||||
});
|
||||
});
|
||||
|
||||
if (result) {
|
||||
{
|
||||
if (!result.externalDependencies) return result;
|
||||
}
|
||||
watcher.updateExternalDependencies(filename, result.externalDependencies);
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
return _compile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function deleteDir(path) {
|
||||
if (_fs().existsSync(path)) {
|
||||
_fs().readdirSync(path).forEach(function (file) {
|
||||
const curPath = path + "/" + file;
|
||||
|
||||
if (_fs().lstatSync(curPath).isDirectory()) {
|
||||
deleteDir(curPath);
|
||||
} else {
|
||||
_fs().unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
|
||||
_fs().rmdirSync(path);
|
||||
}
|
||||
}
|
||||
|
||||
process.on("uncaughtException", function (err) {
|
||||
console.error(err);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
function withExtension(filename, ext = ".js") {
|
||||
const newBasename = _path().basename(filename, _path().extname(filename)) + ext;
|
||||
return _path().join(_path().dirname(filename), newBasename);
|
||||
}
|
||||
|
||||
function debounce(fn, time) {
|
||||
let timer;
|
||||
|
||||
function debounced() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(fn, time);
|
||||
}
|
||||
|
||||
debounced.flush = () => {
|
||||
clearTimeout(timer);
|
||||
fn();
|
||||
};
|
||||
|
||||
return debounced;
|
||||
}
|
||||
132
themes/keepit/node_modules/@babel/cli/lib/babel/watcher.js
generated
vendored
Normal file
132
themes/keepit/node_modules/@babel/cli/lib/babel/watcher.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.enable = enable;
|
||||
exports.onFilesChange = onFilesChange;
|
||||
exports.updateExternalDependencies = updateExternalDependencies;
|
||||
exports.watch = watch;
|
||||
|
||||
function _module() {
|
||||
const data = require("module");
|
||||
|
||||
_module = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const fileToDeps = new Map();
|
||||
const depToFiles = new Map();
|
||||
let isWatchMode = false;
|
||||
let watcher;
|
||||
|
||||
function enable({
|
||||
enableGlobbing
|
||||
}) {
|
||||
isWatchMode = true;
|
||||
const {
|
||||
FSWatcher
|
||||
} = requireChokidar();
|
||||
watcher = new FSWatcher({
|
||||
disableGlobbing: !enableGlobbing,
|
||||
persistent: true,
|
||||
ignoreInitial: true,
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: 50,
|
||||
pollInterval: 10
|
||||
}
|
||||
});
|
||||
watcher.on("unlink", unwatchFile);
|
||||
}
|
||||
|
||||
function watch(filename) {
|
||||
if (!isWatchMode) {
|
||||
throw new Error("Internal Babel error: .watch called when not in watch mode.");
|
||||
}
|
||||
|
||||
watcher.add(_path().resolve(filename));
|
||||
}
|
||||
|
||||
function onFilesChange(callback) {
|
||||
if (!isWatchMode) {
|
||||
throw new Error("Internal Babel error: .onFilesChange called when not in watch mode.");
|
||||
}
|
||||
|
||||
watcher.on("all", (event, filename) => {
|
||||
var _depToFiles$get;
|
||||
|
||||
if (event !== "change" && event !== "add") return;
|
||||
|
||||
const absoluteFile = _path().resolve(filename);
|
||||
|
||||
callback([absoluteFile, ...((_depToFiles$get = depToFiles.get(absoluteFile)) != null ? _depToFiles$get : [])], event, absoluteFile);
|
||||
});
|
||||
}
|
||||
|
||||
function updateExternalDependencies(filename, dependencies) {
|
||||
if (!isWatchMode) return;
|
||||
|
||||
const absFilename = _path().resolve(filename);
|
||||
|
||||
const absDependencies = new Set(Array.from(dependencies, dep => _path().resolve(dep)));
|
||||
|
||||
if (fileToDeps.has(absFilename)) {
|
||||
for (const dep of fileToDeps.get(absFilename)) {
|
||||
if (!absDependencies.has(dep)) {
|
||||
removeFileDependency(absFilename, dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const dep of absDependencies) {
|
||||
if (!depToFiles.has(dep)) {
|
||||
depToFiles.set(dep, new Set());
|
||||
watcher.add(dep);
|
||||
}
|
||||
|
||||
depToFiles.get(dep).add(absFilename);
|
||||
}
|
||||
|
||||
fileToDeps.set(absFilename, absDependencies);
|
||||
}
|
||||
|
||||
function removeFileDependency(filename, dep) {
|
||||
depToFiles.get(dep).delete(filename);
|
||||
|
||||
if (depToFiles.get(dep).size === 0) {
|
||||
depToFiles.delete(dep);
|
||||
watcher.unwatch(dep);
|
||||
}
|
||||
}
|
||||
|
||||
function unwatchFile(filename) {
|
||||
if (!fileToDeps.has(filename)) return;
|
||||
|
||||
for (const dep of fileToDeps.get(filename)) {
|
||||
removeFileDependency(filename, dep);
|
||||
}
|
||||
|
||||
fileToDeps.delete(filename);
|
||||
}
|
||||
|
||||
function requireChokidar() {
|
||||
try {
|
||||
return parseInt(process.versions.node) >= 8 ? require("chokidar") : require("@nicolo-ribaudo/chokidar-2");
|
||||
} catch (err) {
|
||||
console.error("The optional dependency chokidar failed to install and is required for " + "--watch. Chokidar is likely not supported on your platform.");
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user