New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft.azure/autorest-core

Package Overview
Dependencies
Maintainers
2
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft.azure/autorest-core - npm Package Compare versions

Comparing version 2.0.4184 to 2.0.4186

dist/lib/openapi/conversion.d.ts

4

dist/lib/pipeline/artifact-emitter.js

@@ -42,7 +42,7 @@ "use strict";

if (IsOutputArtifactOrMapRequested(config, artifactType + ".yaml")) {
const h = await sink.WriteData(`${++emitCtr}.yaml`, yaml_1.Stringify(object.Value), merging_1.IdentitySourceMapping(handle.key, ast.Value), [handle]);
const h = await sink.WriteData(`${++emitCtr}.yaml`, yaml_1.Stringify(yaml_1.Normalize(object.Value)), merging_1.IdentitySourceMapping(handle.key, ast.Value), [handle]);
await EmitArtifactInternal(config, artifactType + ".yaml", uri + ".yaml", h);
}
if (IsOutputArtifactOrMapRequested(config, artifactType + ".json")) {
const h = await sink.WriteData(`${++emitCtr}.json`, JSON.stringify(object.Value, null, 2), merging_1.IdentitySourceMapping(handle.key, ast.Value), [handle]);
const h = await sink.WriteData(`${++emitCtr}.json`, JSON.stringify(yaml_1.Normalize(object.Value), null, 2), merging_1.IdentitySourceMapping(handle.key, ast.Value), [handle]);
await EmitArtifactInternal(config, artifactType + ".json", uri + ".json", h);

@@ -49,0 +49,0 @@ }

@@ -19,2 +19,3 @@ "use strict";

const swagger_loader_1 = require("./swagger-loader");
const conversion_1 = require("../openapi/conversion");
;

@@ -46,6 +47,5 @@ function CreatePluginIdentity() {

}
function CreatePluginTransformer() {
function CreatePerFilePlugin(processorBuilder) {
return async (config, input, sink) => {
const isObject = config.GetEntry("is-object") === false ? false : true;
const manipulator = new manipulation_1.Manipulator(config);
const processor = await processorBuilder(config);
const files = await input.Enum();

@@ -55,4 +55,4 @@ const result = [];

const fileIn = await input.ReadStrict(file);
const fileOut = await manipulator.Process(fileIn, sink, isObject, fileIn.Description);
result.push(await sink.Forward(fileIn.Description, fileOut));
const fileOut = await processor(fileIn, sink);
result.push(fileOut);
}

@@ -62,2 +62,18 @@ return new data_store_1.QuickDataSource(result);

}
function CreatePluginOAI2toOAIx() {
return CreatePerFilePlugin(async (config) => async (fileIn, sink) => {
const fileOut = await conversion_1.ConvertOAI2toOAI3(fileIn, sink);
return await sink.Forward(fileIn.Description, fileOut);
});
}
function CreatePluginTransformer() {
return CreatePerFilePlugin(async (config) => {
const isObject = config.GetEntry("is-object") === false ? false : true;
const manipulator = new manipulation_1.Manipulator(config);
return async (fileIn, sink) => {
const fileOut = await manipulator.Process(fileIn, sink, isObject, fileIn.Description);
return await sink.Forward(fileIn.Description, fileOut);
};
});
}
function CreatePluginTransformerImmediate() {

@@ -227,2 +243,3 @@ return async (config, input, sink) => {

"semantic-validator": CreatePluginIdentity(),
"openapi-document-converter": CreatePluginOAI2toOAIx(),
"commonmarker": CreateCommonmarkProcessor(),

@@ -229,0 +246,0 @@ "emitter": CreateArtifactEmitter(),

@@ -22,3 +22,4 @@ "use strict";

function isReferenceNode(node) {
return node.path[node.path.length - 1] === "$ref" && typeof node.node.value === "string";
const lastKey = node.path[node.path.length - 1];
return (lastKey === "$ref" || lastKey === "x-ms-odata") && typeof node.node.value === "string";
}

@@ -25,0 +26,0 @@ async function EnsureCompleteDefinitionIsPresent(config, inputScope, sink, visitedEntities, externalFiles, sourceFileUri, sourceDocObj, sourceDocMappings, currentFileUri, entityType, modelName) {

@@ -11,3 +11,3 @@ "use strict";

const handlers = jsonpath.handlers;
handlers.register("subscript-descendant-filter_expression", function (component, partial, count) {
const filterExpressionHandler = function (component, partial, count) {
var src = component.expression.value.slice(1);

@@ -23,3 +23,5 @@ var passable = function (key, value) {

return eval("this").traverse(partial, null, passable, count);
});
};
handlers.register("subscript-descendant-filter_expression", filterExpressionHandler);
handlers.register("subscript-child-filter_expression", filterExpressionHandler);
function parse(jsonPath) {

@@ -26,0 +28,0 @@ return jsonpath.parse(jsonPath).map(part => part.expression.value).slice(1);

@@ -37,2 +37,6 @@ import * as yamlAst from "yaml-ast-parser";

export declare function Clone<T>(object: T): T;
/**
* Normalizes the order of given object's keys (sorts recursively)
*/
export declare function Normalize<T>(object: T): T;
export declare function ToAst<T>(object: T): YAMLNode;

@@ -39,0 +43,0 @@ export declare function Parse<T>(rawYaml: string, onError?: (message: string, index: number) => void): T;

@@ -158,2 +158,26 @@ "use strict";

exports.Clone = Clone;
/**
* Normalizes the order of given object's keys (sorts recursively)
*/
function Normalize(object) {
const clone = Clone(object);
const norm = (o) => {
if (Array.isArray(o)) {
o.forEach(norm);
}
else if (o && typeof o == "object") {
const keys = Object.keys(o).sort();
const oo = Object.assign({}, o);
for (const k of keys) {
delete o[k];
}
for (const k of keys) {
norm(o[k] = oo[k]);
}
}
};
norm(clone);
return clone;
}
exports.Normalize = Normalize;
function ToAst(object) {

@@ -160,0 +184,0 @@ return ParseToAst(FastStringify(object));

@@ -1,924 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const fs = require("fs");
const patch_moduleloader_1 = inline_patchmoduleloader();
const static_filesystem_1 = inline_staticfilesystem();
const patch_filesystem_1 = inline_patchfilesystem();
const common_1 = inline_common();
const fs_1 = require("fs");
const child_process = require("child_process");
const Module = require("module");
if (require.main === module) {
const startpath = fs_1.realpathSync(module.filename);
for (let i = 0; i < process.argv.length; i++) {
if (fs_1.realpathSync(process.argv[i]) === startpath) {
process.argv.splice(i, 1);
while (i < process.argv.length && process.argv[i].startsWith("--load-module=")) {
const staticModule = process.argv[i].split("=")[1];
process.argv.splice(i, 1);
load(staticModule);
}
if (process.argv.length < 2) {
console.log("Missing module name to start.");
process.exit(1);
}
Module._load(process.argv[1], null, true);
process._tickCallback();
break;
}
}
}
const possibilities = [ "node", "node.exe", process.execPath, process.argv[0] ];
function isNode(path) {
return possibilities.indexOf(path) > -1 ? true : false;
}
function cmdlineToArray(text, result = [], matcher = /[^\s"]+|"([^"]*)"/gi, count = 0) {
text = text.replace(/\\"/g, "￾");
const match = matcher.exec(text);
return match ? cmdlineToArray(text, result, matcher, result.push(match[1] ? match[1].replace(/\ufffe/g, '\\"') : match[0].replace(/\ufffe/g, '\\"'))) : result;
}
function indexAfterStartsWith(command, text) {
return command.startsWith(text) ? text.length : -1;
}
function startsWithNode(command) {
if (command.charAt(0) == '"') {
for (const each of possibilities) {
const val = indexAfterStartsWith(command, `"${each}" `);
if (val > -1) {
return val;
}
}
} else {
for (const each of possibilities) {
const val = indexAfterStartsWith(command, `${each} `);
if (val > -1) {
return val;
}
}
}
return -1;
}
function getInsertedArgs(loadedFileSystems) {
return common_1.select(loadedFileSystems, (p, c) => `--load-module=${c}`);
}
function getInsertedArgString(loadedFileSystems) {
return `${getInsertedArgs(loadedFileSystems).map(a => `"${a}"`).join(" ")}`;
}
function padStart(str, targetLength, padString = " ") {
targetLength = targetLength >> 0;
padString = String(padString || " ");
if (str.length > targetLength) {
return String(str);
} else {
targetLength = targetLength - str.length;
if (targetLength > padString.length) {
padString += padString.repeat(targetLength / padString.length);
}
return padString.slice(0, targetLength) + String(str);
}
}
function padEnd(str, targetLength, padString = " ") {
targetLength = targetLength >> 0;
padString = String(padString || " ");
if (str.length > targetLength) {
return String(str);
} else {
targetLength = targetLength - str.length;
if (targetLength > padString.length) {
padString += padString.repeat(targetLength / padString.length);
}
return String(str) + padString.slice(0, targetLength);
}
}
function list(staticModule) {
const svs = new static_filesystem_1.StaticFilesystem();
svs.load(staticModule);
const dir = new Array();
const files = {};
for (const each of svs.entries) {
const st = svs.statSync(each);
if (!st.isFile()) {
dir.push(`${padStart("<dir>", 12)} ${each}`);
} else {
files[each] = `${padStart(`${st.size}`, 12)} ${each}`;
}
}
for (const each of dir.sort()) {
console.log(each);
}
for (const each of Object.keys(files).sort()) {
console.log(files[each]);
}
svs.shutdown();
}
exports.list = list;
function existsInFs(svs, filePath) {
try {
return svs.statSync(filePath) ? true : false;
} catch (_a) {}
return false;
}
function load(staticModule) {
if (!global.staticloader) {
global.staticloader = {};
const svs = new static_filesystem_1.StaticFilesystem();
const undo_loader = patch_moduleloader_1.patchModuleLoader(svs);
const fsRFS = fs.readFileSync;
const undo_fs = patch_filesystem_1.patchFilesystem({
readFileSync: (path, options) => {
try {
if (svs.statSync(path)) {
return svs.readFileSync(path, options);
}
} catch (_a) {}
return fsRFS(path, options);
}
});
global.staticloader.undo = (() => {
undo_fs();
undo_loader();
});
global.staticloader.staticfilesystem = svs;
const process_exit = process.exit;
process.exit = (n => {
svs.shutdown();
global.staticloader.undo();
return process_exit(n);
});
const fork = child_process.fork;
const spawn = child_process.spawn;
const exec = child_process.exec;
const spawnSync = child_process.spawnSync;
const execSync = child_process.execSync;
child_process.fork = ((modulePath, args, options) => {
if (args && existsInFs(svs, modulePath)) {
return fork(__filename, [ ...getInsertedArgs(svs.loadedFileSystems), modulePath, ...Array.isArray(args) ? args : [ args ] ], options);
} else {
return fork(modulePath, args, options);
}
});
child_process.spawn = ((command, args, options) => {
if (args && (Array.isArray(args) || typeof args !== "object") && isNode(command) && existsInFs(svs, args[0])) {
return spawn(command, [ __filename, ...getInsertedArgs(svs.loadedFileSystems), ...Array.isArray(args) ? args : [ args ] ], options);
}
return spawn(command, args, options);
});
child_process.spawnSync = ((command, args, options) => {
if (args && (Array.isArray(args) || typeof args !== "object") && isNode(command) && existsInFs(svs, args[0])) {
return spawnSync(command, [ __filename, ...getInsertedArgs(svs.loadedFileSystems), ...Array.isArray(args) ? args : [ args ] ], options);
}
return spawnSync(command, args, options);
});
child_process.exec = ((command, options, callback) => {
const pos = startsWithNode(command);
if (pos > -1) {
if (existsInFs(svs, cmdlineToArray(command)[1])) {
return exec(`${command.substring(0, pos)} "${__filename}" ${getInsertedArgString(svs.loadedFileSystems)} ${command.substring(pos)}`, options, callback);
}
}
return exec(command, options, callback);
});
child_process.execSync = ((command, options) => {
const pos = startsWithNode(command);
if (pos > -1) {
if (existsInFs(svs, cmdlineToArray(command)[1])) {
return execSync(`${command.substring(0, pos)} "${__filename}" ${getInsertedArgString(svs.loadedFileSystems)} ${command.substring(pos)}`, options);
}
}
return execSync(command, options);
});
}
global.staticloader.staticfilesystem.load(staticModule);
}
exports.load = load;
function unload(staticModule) {
if (global.staticloader.undo) {
const svs = global.staticloader.staticfilesystem;
svs.unload(staticModule);
}
}
exports.unload = unload;
function inline_patchfilesystem() {
var exports = {};
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const fs = require("fs");
const original_fs = Object.assign({}, fs);
var MemberType;
(function(MemberType) {
MemberType[MemberType["Constructor"] = 0] = "Constructor";
MemberType[MemberType["Method"] = 1] = "Method";
MemberType[MemberType["Property"] = 2] = "Property";
})(MemberType || (MemberType = {}));
const metadata = {
StatWatcher: MemberType.Constructor,
FSWatcher: MemberType.Constructor,
ReadStream: MemberType.Constructor,
WriteStream: MemberType.Constructor,
ReadFileStream: MemberType.Constructor,
WriteFileStream: MemberType.Constructor,
Stats: MemberType.Constructor,
constants: MemberType.Property,
F_OK: MemberType.Property,
R_OK: MemberType.Property,
W_OK: MemberType.Property,
X_OK: MemberType.Property
};
function patchFilesystem(volume, original = fs) {
const backup = Object.assign({}, original);
for (const member of Object.getOwnPropertyNames(original)) {
if (typeof volume[member] !== typeof original[member]) {
continue;
}
switch (metadata[member]) {
case MemberType.Constructor:
original[member] = volume[member].bind(null, volume);
break;
case MemberType.Property:
original[member] = volume[member];
break;
default:
original[member] = volume[member].bind(volume);
break;
}
}
return () => patchFilesystem(fs, backup);
}
exports.patchFilesystem = patchFilesystem;
return exports;
}
function inline_staticfilesystem() {
var exports = {};
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const path_1 = require("path");
const os_1 = require("os");
const filesystem = require("fs");
const fs = Object.assign({}, filesystem);
const common_1 = inline_common();
class StaticVolumeFile {
constructor(sourcePath) {
this.sourcePath = sourcePath;
this.intBuffer = Buffer.alloc(common_1.INTSIZE);
this.buf = Buffer.alloc(1024 * 16);
this.index = {};
this.statData = Object.assign({}, fs.statSync(sourcePath), {
isDirectory: () => false,
isSymbolicLink: () => false,
isBlockDevice: () => false,
isCharacterDevice: () => false,
isFile: () => false,
isFIFO: () => false,
isSocket: () => false,
size: 0
});
this.fd = fs.openSync(sourcePath, "r");
let dataOffset = this.readInt();
let hashSize = this.readInt();
if (hashSize > this.buf.length) {
this.buf = Buffer.alloc(hashSize);
}
this.readBuffer(this.buf, hashSize);
this.hash = this.buf.toString("utf8", 0, hashSize);
do {
const nameSz = this.readInt();
if (nameSz == 0) {
break;
}
const dataSz = this.readInt();
if (nameSz > this.buf.length) {
this.buf = Buffer.alloc(nameSz);
}
this.readBuffer(this.buf, nameSz);
const name = this.buf.toString("utf8", 0, nameSz);
this.index[name] = Object.assign({}, this.statData, {
ino: dataOffset,
size: dataSz,
blocks: 1,
blksize: dataSz,
isFile: () => true
});
this.addParentFolders(name);
dataOffset += dataSz;
} while (true);
}
readBuffer(buffer, length) {
return fs.readSync(this.fd, buffer, 0, length || buffer.length, null);
}
readInt() {
fs.readSync(this.fd, this.intBuffer, 0, common_1.INTSIZE, null);
return this.intBuffer.readIntBE(0, 6);
}
shutdown() {
fs.closeSync(this.fd);
this.index = {};
}
addParentFolders(name) {
const parent = path_1.dirname(name);
if (parent && !this.index[parent]) {
this.index[parent] = Object.assign({}, this.statData, {
isDirectory: () => true
});
return this.addParentFolders(parent);
}
}
readFile(filepath, options) {
const item = this.index[filepath];
if (item && item.isFile()) {
const encoding = options ? typeof options === "string" ? options : typeof options === "object" ? options.encoding || "utf8" : "utf8" : "utf8";
if (this.buf.length < item.size) {
this.buf = Buffer.alloc(item.size);
}
fs.readSync(this.fd, this.buf, 0, item.size, item.ino);
return this.buf.toString(encoding, 0, item.size);
}
return undefined;
}
}
exports.StaticVolumeFile = StaticVolumeFile;
class StaticFilesystem {
constructor() {
this.fileSystems = [];
}
NewError(code, method, filepath) {
switch (code) {
case os_1.constants.errno.ENOENT:
return Object.assign({}, new Error(`ENOENT: no such file or directory, ${method} '${filepath}'`), {
code: "ENOENT",
path: filepath,
errno: os_1.constants.errno.ENOENT
});
case os_1.constants.errno.EISDIR:
return Object.assign({}, new Error(`EISDIR: illegal operation on a directory, ${method} '${filepath}'`), {
code: "EISDIR",
path: filepath,
errno: os_1.constants.errno.EISDIR
});
}
return Object.assign({}, new Error(`UNKNOWN: Error, ${method} '${filepath}'`), {
code: "UNKNOWN",
path: filepath,
errno: -1e4
});
}
shutdown() {
for (const fsystem of this.fileSystems) {
fsystem.shutdown();
}
}
get hashes() {
return common_1.select(this.fileSystems, (p, c, i, a) => c.hash);
}
load(sourcePath) {
sourcePath = path_1.resolve(sourcePath);
for (let i = 0; i < this.fileSystems.length; i++) {
if (this.fileSystems[i].sourcePath === sourcePath) {
return this;
}
}
this.fileSystems.push(new StaticVolumeFile(sourcePath));
return this;
}
get loadedFileSystems() {
return common_1.select(this.fileSystems, (p, c) => c.sourcePath);
}
unload(sourcePath) {
sourcePath = path_1.resolve(sourcePath);
for (let i = 0; i < this.fileSystems.length; i++) {
if (this.fileSystems[i].sourcePath === sourcePath) {
this.fileSystems[i].shutdown();
this.fileSystems.splice(i, 1);
}
}
return this;
}
get entries() {
return common_1.selectMany(this.fileSystems, (p, c) => Object.keys(c.index));
}
readFileSync(filepath, options) {
const targetPath = common_1.unixifyPath(filepath);
return common_1.first(this.fileSystems, fsystem => fsystem.readFile(targetPath, options), () => {
throw this.NewError(os_1.constants.errno.ENOENT, "readFileSync", filepath);
});
}
realpathSync(filepath) {
const targetPath = common_1.unixifyPath(filepath);
return common_1.first(this.fileSystems, fsystem => fsystem.index[targetPath] ? targetPath : undefined, () => {
throw this.NewError(os_1.constants.errno.ENOENT, "realpathSync", filepath);
});
}
statSync(filepath) {
const targetPath = common_1.unixifyPath(filepath);
return common_1.first(this.fileSystems, fsystem => fsystem.index[targetPath], () => {
throw this.NewError(os_1.constants.errno.ENOENT, "statSync", filepath);
});
}
}
exports.StaticFilesystem = StaticFilesystem;
return exports;
}
function inline_common() {
var exports = {};
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const crypto_1 = require("crypto");
exports.isWindows = process.platform === "win32";
const path_1 = require("path");
const child_process_1 = require("child_process");
const filesystem = require("fs");
const fs = Object.assign({}, filesystem);
function readdir(path) {
return new Promise((r, j) => fs.readdir(path, (err, files) => err ? j(err) : r(files)));
}
exports.readdir = readdir;
function stat(path) {
return new Promise((r, j) => fs.stat(path, (err, files) => err ? j(err) : r(files)));
}
exports.stat = stat;
function lstat(path) {
return new Promise((r, j) => fs.lstat(path, (err, files) => err ? j(err) : r(files)));
}
exports.lstat = lstat;
function open(path, flags, mode) {
return new Promise((r, j) => fs.open(path, flags, mode, (err, descrpitor) => err ? j(err) : r(descrpitor)));
}
exports.open = open;
function close(fd) {
return new Promise((r, j) => fs.close(fd, err => err ? j(err) : r()));
}
exports.close = close;
function write(fd, buffer, offset, length, position) {
return new Promise((r, j) => fs.write(fd, buffer, offset || 0, length || buffer.length, position || undefined, (err, written, buf) => err ? j(err) : r(written)));
}
exports.write = write;
function read(fd, buffer, offset, length, position) {
return new Promise((r, j) => fs.read(fd, buffer, offset, length, position || null, (err, bytes, buffer) => err ? j(err) : r(bytes)));
}
exports.read = read;
function readFile(path, options) {
return new Promise((r, j) => fs.readFile(path, options, (err, data) => err ? j(err) : r(data)));
}
exports.readFile = readFile;
function execute(command, cmdlineargs, options) {
return new Promise((r, j) => {
const cp = child_process_1.spawn(command, cmdlineargs, Object.assign({}, options, {
stdio: "pipe"
}));
let err = "";
let out = "";
cp.stderr.on("data", chunk => {
err += chunk;
process.stdout.write(".");
});
cp.stdout.on("data", chunk => {
out += chunk;
process.stdout.write(".");
});
cp.on("close", (code, signal) => r({
stdout: out,
stderr: err,
error: code ? new Error("Process Failed.") : null,
code: code
}));
});
}
exports.execute = execute;
function fs_mkdir(path) {
return new Promise((r, j) => fs.mkdir(path, err => err ? j(err) : r()));
}
function fs_unlink(path) {
return new Promise((r, j) => fs.unlink(path, err => err ? j(err) : r()));
}
function fs_rmdir(path) {
return new Promise((r, j) => fs.rmdir(path, err => err ? j(err) : r()));
}
function rename(oldPath, newPath) {
return new Promise((r, j) => fs.rename(oldPath, newPath, err => err ? j(err) : r()));
}
exports.rename = rename;
function writeFile(filename, content) {
return new Promise((r, j) => fs.writeFile(filename, content, err => err ? j(err) : r()));
}
exports.writeFile = writeFile;
async function copyFile(source, target) {
await mkdir(path_1.dirname(target));
return await new Promise((resolve, reject) => {
var rd = fs.createReadStream(source);
rd.on("error", rejectCleanup);
var wr = fs.createWriteStream(target);
wr.on("error", rejectCleanup);
function rejectCleanup(err) {
rd.destroy();
wr.end();
reject(err);
}
wr.on("finish", () => {
rd.close();
wr.close();
resolve();
});
rd.pipe(wr);
});
}
exports.copyFile = copyFile;
async function copyFolder(source, target, all) {
const waitAtEnd = all ? false : true;
all = all || new Array();
if (isDirectory(source)) {
for (const each of await readdir(source)) {
const sp = path_1.join(source, each);
const dp = path_1.join(target, each);
if (await isDirectory(sp)) {
copyFolder(sp, dp, all);
} else {
all.push(copyFile(sp, dp));
}
}
}
if (waitAtEnd) {
await Promise.all(all);
}
}
exports.copyFolder = copyFolder;
exports.exists = (path => new Promise((r, j) => fs.stat(path, (err, stats) => err ? r(false) : r(true))));
async function isDirectory(dirPath) {
try {
if (await exports.exists(dirPath)) {
return (await lstat(dirPath)).isDirectory();
}
} catch (e) {}
return false;
}
exports.isDirectory = isDirectory;
async function isFile(filePath) {
try {
if (await exports.exists(filePath)) {
return !(await lstat(filePath)).isDirectory();
}
} catch (e) {}
return false;
}
exports.isFile = isFile;
async function rmdir(dirPath) {
if (!await exports.exists(dirPath)) {
return;
}
if (!await isDirectory(dirPath)) {
throw new Error(dirPath);
}
if (process.cwd() === path_1.normalize(dirPath)) {
process.chdir(`${dirPath}/..`);
}
const files = await readdir(dirPath);
if (files.length) {
const awaiter = new Array();
try {
for (const file of files) {
try {
const p = path_1.join(dirPath, file);
if (await isDirectory(p)) {
awaiter.push(rmdir(p));
} else {
awaiter.push(fs_unlink(p).catch(() => {}));
}
} catch (e) {}
}
} finally {
await Promise.all(awaiter);
}
}
try {
await fs_rmdir(dirPath);
} catch (e) {
if (await isDirectory(dirPath)) {
throw new Error(`UnableToRemoveException ${dirPath}`);
}
}
}
exports.rmdir = rmdir;
async function rmFile(filePath) {
if (!exports.exists(filePath)) {
return;
}
if (await isDirectory(filePath)) {
throw new Error(`PathIsNotFileException : ${filePath}`);
}
try {
await fs_unlink(filePath);
} catch (e) {
if (await exports.exists(filePath)) {
throw new Error(`UnableToRemoveException : filePath`);
}
}
}
exports.rmFile = rmFile;
async function mkdir(dirPath) {
if (!await isDirectory(dirPath)) {
const p = path_1.normalize(dirPath + "/");
const parent = path_1.dirname(dirPath);
if (!await isDirectory(parent)) {
if (p != parent) {
await mkdir(parent);
}
}
try {
await fs_mkdir(p);
} catch (e) {
if (!await isDirectory(p)) {
throw new Error(e);
}
}
}
}
exports.mkdir = mkdir;
exports.INTSIZE = 6;
function _unixifyPath(filepath) {
if (filepath && typeof filepath === "string") {
return filepath.replace(/^\\\\\?\\(.):\\/, "$1:\\").replace(/[\\\/]+/g, "/").replace(/^([a-zA-Z]+:|\.\/)/, "").replace(/(.+?)\/$/, "$1");
}
return filepath;
}
function _isWindowsPath(filepath) {
if (filepath && filepath.length >= 3) {
if (filepath.charCodeAt(0) === 92 && filepath.charCodeAt(1) === 92) {
return true;
}
if (filepath.charCodeAt(1) == 58 && filepath.charCodeAt(2) === 92) {
var code = filepath.charCodeAt(0);
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
}
}
return false;
}
exports.unixifyPath = exports.isWindows ? _unixifyPath : p => p;
exports.isWindowsPath = exports.isWindows ? _isWindowsPath : p => p;
function calculateHash(content) {
return crypto_1.createHash("sha256").update(JSON.stringify(content)).digest("base64");
}
exports.calculateHash = calculateHash;
function select(array, callbackfn) {
return array.reduce((p, c, i, a) => {
p.push(callbackfn(p, c, i, a));
return p;
}, new Array());
}
exports.select = select;
function selectMany(array, callbackfn) {
return array.reduce((p, c, i, a) => {
p.push(...callbackfn(p, c, i, a));
return p;
}, new Array());
}
exports.selectMany = selectMany;
function first(array, selector, onError = (() => undefined)) {
for (const each of array) {
const result = selector(each);
if (result != undefined) {
return result;
}
}
return onError();
}
exports.first = first;
async function backup(filename) {
if (!await isFile(filename)) {
return async () => {
await rmFile(filename);
};
}
const backupFile = path_1.join(path_1.dirname(filename), `${path_1.basename(filename)}.${Math.random() * 1e4}${path_1.extname(filename)}`);
await rename(filename, backupFile);
await copyFile(backupFile, filename);
return async () => {
await rmFile(filename);
await rename(backupFile, filename);
};
}
exports.backup = backup;
return exports;
}
function inline_patchmoduleloader() {
var exports = {};
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const fs_1 = require("fs");
const common_1 = inline_common();
const path_1 = require("path");
const makeLong = require("path")._makeLong || path_1.resolve;
function stripBOM(content) {
return content && content.charCodeAt(0) === 65279 ? content.slice(1) : content;
}
function unixifyVolume(volume) {
return common_1.isWindows ? {
readFileSync: (path, options) => volume.readFileSync(common_1.unixifyPath(path), options),
realpathSync: (path, options) => volume.realpathSync(common_1.unixifyPath(path)),
statSync: path => volume.statSync(common_1.unixifyPath(path))
} : volume;
}
function patchModuleLoader(volume, enablePathNormalization = false, enableFallback = true, Module = require("module")) {
const backup = Object.assign({}, Module);
const preserveSymlinks = false;
const statcache = {};
const packageMainCache = {};
Module._fallback = enableFallback;
if (enablePathNormalization) {
volume = unixifyVolume(volume);
}
function internalModuleReadFile(path) {
try {
return volume.readFileSync(path, "utf8");
} catch (_a) {}
return undefined;
}
function internalModuleStat(filename) {
try {
return volume.statSync(filename).isDirectory() ? 1 : 0;
} catch (_a) {}
return -2;
}
function stat(filename) {
filename = makeLong(filename);
const result = statcache[filename];
return result !== undefined ? result : statcache[filename] = internalModuleStat(filename);
}
function readPackage(requestPath) {
const entry = packageMainCache[requestPath];
if (entry) {
return entry;
}
const jsonPath = path_1.resolve(requestPath, "package.json");
const json = internalModuleReadFile(makeLong(jsonPath));
if (json === undefined) {
return false;
}
let pkg;
try {
pkg = packageMainCache[requestPath] = JSON.parse(json).main;
} catch (e) {
e.path = jsonPath;
e.message = "Error parsing " + jsonPath + ": " + e.message;
throw e;
}
return pkg;
}
function tryFile(requestPath, isMain) {
if (preserveSymlinks && !isMain) {
return stat(requestPath) === 0 ? path_1.resolve(requestPath) : undefined;
}
return stat(requestPath) === 0 ? volume.realpathSync(requestPath) : undefined;
}
function tryExtensions(p, exts, isMain) {
for (let i = 0; i < exts.length; i++) {
const filename = tryFile(p + exts[i], isMain);
if (filename) {
return filename;
}
}
return undefined;
}
function tryPackage(requestPath, exts, isMain) {
let pkg = readPackage(requestPath);
if (pkg) {
let filename = path_1.resolve(requestPath, pkg);
return tryFile(filename, isMain) || tryExtensions(filename, exts, isMain) || tryExtensions(path_1.resolve(filename, "index"), exts, isMain);
}
return undefined;
}
Module._extensions[".js"] = ((module, filename) => {
if (stat(filename) == 0) {
module._compile(stripBOM(volume.readFileSync(filename, "utf8")), filename);
} else if (Module._fallback) {
module._compile(stripBOM(fs_1.readFileSync(filename, "utf8")), filename);
}
});
Module._extensions[".json"] = ((module, filename) => {
if (stat(filename) == 0) {
try {
module.exports = JSON.parse(stripBOM(volume.readFileSync(filename, "utf8")));
} catch (err) {
throw Object.assign({}, err, {
message: filename + ": " + err.message
});
}
} else if (Module._fallback) {
try {
module.exports = JSON.parse(stripBOM(fs_1.readFileSync(filename, "utf8")));
} catch (err) {
throw Object.assign({}, err, {
message: filename + ": " + err.message
});
}
}
});
Module._originalFindPath = Module._findPath;
Module._findPath = ((request, paths, isMain) => {
const result = Module._alternateFindPath(request, paths, isMain);
return !result && Module._fallback ? Module._originalFindPath(request, paths, isMain) : result;
});
Module._alternateFindPath = ((request, paths, isMain) => {
if (!request) {
return false;
}
if (path_1.isAbsolute(request)) {
paths = [ "" ];
} else if (!paths || paths.length === 0) {
return false;
}
const cacheKey = request + "\0" + (paths.length === 1 ? paths[0] : paths.join("\0"));
const entry = Module._pathCache[cacheKey];
if (entry) {
return entry;
}
const trailingSlash = request.charCodeAt(request.length - 1) === 47;
for (const curPath of paths) {
if (curPath && stat(curPath) < 1) {
continue;
}
let basePath = path_1.resolve(curPath, request);
let rc = stat(basePath);
if (rc < 0 && common_1.isWindowsPath(basePath)) {
let correctedPath = common_1.unixifyPath(basePath);
rc = stat(correctedPath);
if (rc >= 0) {
basePath = correctedPath;
}
}
let filename;
const exts = Object.keys(Module._extensions);
if (!trailingSlash) {
switch (rc) {
case 0:
filename = preserveSymlinks && !isMain ? path_1.resolve(basePath) : volume.realpathSync(basePath);
break;
case 1:
filename = tryPackage(basePath, exts, isMain);
break;
}
if (!filename) {
filename = tryExtensions(basePath, exts, isMain);
}
}
if (!filename && rc === 1) {
filename = tryPackage(basePath, exts, isMain) || tryExtensions(path_1.resolve(basePath, "index"), exts, isMain);
}
if (filename) {
Module._pathCache[cacheKey] = filename;
return filename;
}
}
return false;
});
return () => {
Module._extensions[".js"] = backup._extensions[".js"];
Module._extensions[".json"] = backup._extensions[".json"];
Module._findPath = backup._findPath;
};
}
exports.patchModuleLoader = patchModuleLoader;
return exports;
}
"use strict";function isNode(path){return possibilities.indexOf(path)>-1}function cmdlineToArray(text,result=[],matcher=/[^\s"]+|"([^"]*)"/gi,count=0){text=text.replace(/\\"/g,"￾");const match=matcher.exec(text);return match?cmdlineToArray(text,result,matcher,result.push(match[1]?match[1].replace(/\ufffe/g,'\\"'):match[0].replace(/\ufffe/g,'\\"'))):result}function indexAfterStartsWith(command,text){return command.startsWith(text)?text.length:-1}function startsWithNode(command){if('"'==command.charAt(0))for(const each of possibilities){const val=indexAfterStartsWith(command,`"${each}" `);if(val>-1)return val}else for(const each of possibilities){const val=indexAfterStartsWith(command,`${each} `);if(val>-1)return val}return-1}function getInsertedArgs(loadedFileSystems){return common_1.select(loadedFileSystems,(p,c)=>`--load-module=${c}`)}function getInsertedArgString(loadedFileSystems){return`${getInsertedArgs(loadedFileSystems).map(a=>`"${a}"`).join(" ")}`}function padStart(str,targetLength,padString=" "){return targetLength>>=0,padString=String(padString||" "),str.length>targetLength?String(str):((targetLength-=str.length)>padString.length&&(padString+=padString.repeat(targetLength/padString.length)),padString.slice(0,targetLength)+String(str))}function padEnd(str,targetLength,padString=" "){return targetLength>>=0,padString=String(padString||" "),str.length>targetLength?String(str):((targetLength-=str.length)>padString.length&&(padString+=padString.repeat(targetLength/padString.length)),String(str)+padString.slice(0,targetLength))}function list(staticModule){const svs=new static_filesystem_1.StaticFilesystem;svs.load(staticModule);const dir=new Array,files={};for(const each of svs.entries){const st=svs.statSync(each);st.isFile()?files[each]=`${padStart(`${st.size}`,12)} ${each}`:dir.push(`${padStart("<dir>",12)} ${each}`)}for(const each of dir.sort())console.log(each);for(const each of Object.keys(files).sort())console.log(files[each]);svs.shutdown()}function existsInFs(svs,filePath){try{return!!svs.statSync(filePath)}catch(_a){}return!1}function load(staticModule){if(!global.staticloader){global.staticloader={};const svs=new static_filesystem_1.StaticFilesystem,undo_loader=patch_moduleloader_1.patchModuleLoader(svs),fsRFS=fs.readFileSync,undo_fs=patch_filesystem_1.patchFilesystem({readFileSync:(path,options)=>{try{if(svs.statSync(path))return svs.readFileSync(path,options)}catch(_a){}return fsRFS(path,options)}});global.staticloader.undo=(()=>{undo_fs(),undo_loader()}),global.staticloader.staticfilesystem=svs;const process_exit=process.exit;process.exit=(n=>(svs.shutdown(),global.staticloader.undo(),process_exit(n)));const fork=child_process.fork,spawn=child_process.spawn,exec=child_process.exec,spawnSync=child_process.spawnSync,execSync=child_process.execSync;child_process.fork=((modulePath,args,options)=>args&&existsInFs(svs,modulePath)?fork(__filename,[...getInsertedArgs(svs.loadedFileSystems),modulePath,...Array.isArray(args)?args:[args]],options):fork(modulePath,args,options)),child_process.spawn=((command,args,options)=>args&&(Array.isArray(args)||"object"!=typeof args)&&isNode(command)&&existsInFs(svs,args[0])?spawn(command,[__filename,...getInsertedArgs(svs.loadedFileSystems),...Array.isArray(args)?args:[args]],options):spawn(command,args,options)),child_process.spawnSync=((command,args,options)=>args&&(Array.isArray(args)||"object"!=typeof args)&&isNode(command)&&existsInFs(svs,args[0])?spawnSync(command,[__filename,...getInsertedArgs(svs.loadedFileSystems),...Array.isArray(args)?args:[args]],options):spawnSync(command,args,options)),child_process.exec=((command,options,callback)=>{const pos=startsWithNode(command);return pos>-1&&existsInFs(svs,cmdlineToArray(command)[1])?exec(`${command.substring(0,pos)} "${__filename}" ${getInsertedArgString(svs.loadedFileSystems)} ${command.substring(pos)}`,options,callback):exec(command,options,callback)}),child_process.execSync=((command,options)=>{const pos=startsWithNode(command);return pos>-1&&existsInFs(svs,cmdlineToArray(command)[1])?execSync(`${command.substring(0,pos)} "${__filename}" ${getInsertedArgString(svs.loadedFileSystems)} ${command.substring(pos)}`,options):execSync(command,options)})}global.staticloader.staticfilesystem.load(staticModule)}function unload(staticModule){global.staticloader.undo&&global.staticloader.staticfilesystem.unload(staticModule)}function inline_patchfilesystem(){function patchFilesystem(volume,original=fs){const backup=Object.assign({},original);for(const member of Object.getOwnPropertyNames(original))if(volume[member]&&"SyncWriteStream"!==member&&typeof volume[member]==typeof original[member])switch(metadata[member]){case MemberType.Constructor:original[member]=volume[member].bind(null,volume);break;case MemberType.Property:original[member]=volume[member];break;default:original[member]=volume[member].bind(volume)}return()=>patchFilesystem(fs,backup)}var exports={};Object.defineProperty(exports,"__esModule",{value:!0});const fs=require("fs");Object.assign({},fs);var MemberType;!function(MemberType){MemberType[MemberType.Constructor=0]="Constructor",MemberType[MemberType.Method=1]="Method",MemberType[MemberType.Property=2]="Property"}(MemberType||(MemberType={}));const metadata={StatWatcher:MemberType.Constructor,FSWatcher:MemberType.Constructor,ReadStream:MemberType.Constructor,WriteStream:MemberType.Constructor,ReadFileStream:MemberType.Constructor,WriteFileStream:MemberType.Constructor,Stats:MemberType.Constructor,constants:MemberType.Property,F_OK:MemberType.Property,R_OK:MemberType.Property,W_OK:MemberType.Property,X_OK:MemberType.Property};return exports.patchFilesystem=patchFilesystem,exports}function inline_staticfilesystem(){var exports={};Object.defineProperty(exports,"__esModule",{value:!0});const path_1=require("path"),os_1=require("os"),filesystem=require("fs"),fs=Object.assign({},filesystem),common_1=inline_common();class StaticVolumeFile{constructor(sourcePath){this.sourcePath=sourcePath,this.intBuffer=Buffer.alloc(common_1.INTSIZE),this.buf=Buffer.alloc(16384),this.index={},this.statData=Object.assign({},fs.statSync(sourcePath),{isDirectory:()=>!1,isSymbolicLink:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isFile:()=>!1,isFIFO:()=>!1,isSocket:()=>!1,size:0}),this.fd=fs.openSync(sourcePath,"r");let dataOffset=this.readInt(),hashSize=this.readInt();for(hashSize>this.buf.length&&(this.buf=Buffer.alloc(hashSize)),this.readBuffer(this.buf,hashSize),this.hash=this.buf.toString("utf8",0,hashSize);;){const nameSz=this.readInt();if(0==nameSz)break;const dataSz=this.readInt();nameSz>this.buf.length&&(this.buf=Buffer.alloc(nameSz)),this.readBuffer(this.buf,nameSz);const name=this.buf.toString("utf8",0,nameSz);this.index[name]=Object.assign({},this.statData,{ino:dataOffset,size:dataSz,blocks:1,blksize:dataSz,isFile:()=>!0}),this.addParentFolders(name),dataOffset+=dataSz}}readBuffer(buffer,length){return fs.readSync(this.fd,buffer,0,length||buffer.length,null)}readInt(){return fs.readSync(this.fd,this.intBuffer,0,common_1.INTSIZE,null),this.intBuffer.readIntBE(0,6)}shutdown(){fs.closeSync(this.fd),this.index={}}addParentFolders(name){const parent=path_1.dirname(name);if(parent&&!this.index[parent])return this.index[parent]=Object.assign({},this.statData,{isDirectory:()=>!0}),this.addParentFolders(parent)}readFile(filepath,options){const item=this.index[filepath];if(item&&item.isFile()){const encoding=options?"string"==typeof options?options:"object"==typeof options?options.encoding||"utf8":"utf8":"utf8";return this.buf.length<item.size&&(this.buf=Buffer.alloc(item.size)),fs.readSync(this.fd,this.buf,0,item.size,item.ino),this.buf.toString(encoding,0,item.size)}}}exports.StaticVolumeFile=StaticVolumeFile;class StaticFilesystem{constructor(){this.fileSystems=[]}NewError(code,method,filepath){switch(code){case os_1.constants.errno.ENOENT:return Object.assign({},new Error(`ENOENT: no such file or directory, ${method} '${filepath}'`),{code:"ENOENT",path:filepath,errno:os_1.constants.errno.ENOENT});case os_1.constants.errno.EISDIR:return Object.assign({},new Error(`EISDIR: illegal operation on a directory, ${method} '${filepath}'`),{code:"EISDIR",path:filepath,errno:os_1.constants.errno.EISDIR})}return Object.assign({},new Error(`UNKNOWN: Error, ${method} '${filepath}'`),{code:"UNKNOWN",path:filepath,errno:-1e4})}shutdown(){for(const fsystem of this.fileSystems)fsystem.shutdown()}get hashes(){return common_1.select(this.fileSystems,(p,c,i,a)=>c.hash)}load(sourcePath){sourcePath=path_1.resolve(sourcePath);for(let i=0;i<this.fileSystems.length;i++)if(this.fileSystems[i].sourcePath===sourcePath)return this;return this.fileSystems.push(new StaticVolumeFile(sourcePath)),this}get loadedFileSystems(){return common_1.select(this.fileSystems,(p,c)=>c.sourcePath)}unload(sourcePath){sourcePath=path_1.resolve(sourcePath);for(let i=0;i<this.fileSystems.length;i++)this.fileSystems[i].sourcePath===sourcePath&&(this.fileSystems[i].shutdown(),this.fileSystems.splice(i,1));return this}get entries(){return common_1.selectMany(this.fileSystems,(p,c)=>Object.keys(c.index))}readFileSync(filepath,options){const targetPath=common_1.unixifyPath(filepath);return common_1.first(this.fileSystems,fsystem=>fsystem.readFile(targetPath,options),()=>{throw this.NewError(os_1.constants.errno.ENOENT,"readFileSync",filepath)})}realpathSync(filepath){const targetPath=common_1.unixifyPath(filepath);return common_1.first(this.fileSystems,fsystem=>fsystem.index[targetPath]?targetPath:void 0,()=>{throw this.NewError(os_1.constants.errno.ENOENT,"realpathSync",filepath)})}statSync(filepath){const targetPath=common_1.unixifyPath(filepath);return common_1.first(this.fileSystems,fsystem=>fsystem.index[targetPath],()=>{throw this.NewError(os_1.constants.errno.ENOENT,"statSync",filepath)})}}return exports.StaticFilesystem=StaticFilesystem,exports}function inline_common(){function readdir(path){return new Promise((r,j)=>fs.readdir(path,(err,files)=>err?j(err):r(files)))}function lstat(path){return new Promise((r,j)=>fs.lstat(path,(err,files)=>err?j(err):r(files)))}function fs_mkdir(path){return new Promise((r,j)=>fs.mkdir(path,err=>err?j(err):r()))}function fs_unlink(path){return new Promise((r,j)=>fs.unlink(path,err=>err?j(err):r()))}function fs_rmdir(path){return new Promise((r,j)=>fs.rmdir(path,err=>err?j(err):r()))}function rename(oldPath,newPath){return new Promise((r,j)=>fs.rename(oldPath,newPath,err=>err?j(err):r()))}async function copyFile(source,target){return await mkdir(path_1.dirname(target)),await new Promise((resolve,reject)=>{function rejectCleanup(err){rd.destroy(),wr.end(),reject(err)}var rd=fs.createReadStream(source);rd.on("error",rejectCleanup);var wr=fs.createWriteStream(target);wr.on("error",rejectCleanup),wr.on("finish",()=>{rd.close(),wr.close(),resolve()}),rd.pipe(wr)})}async function copyFolder(source,target,all){const waitAtEnd=!all;if(all=all||new Array,isDirectory(source))for(const each of await readdir(source)){const sp=path_1.join(source,each),dp=path_1.join(target,each);await isDirectory(sp)?copyFolder(sp,dp,all):all.push(copyFile(sp,dp))}waitAtEnd&&await Promise.all(all)}async function isDirectory(dirPath){try{if(await exports.exists(dirPath))return(await lstat(dirPath)).isDirectory()}catch(e){}return!1}async function isFile(filePath){try{if(await exports.exists(filePath))return!(await lstat(filePath)).isDirectory()}catch(e){}return!1}async function rmdir(dirPath){if(!await exports.exists(dirPath))return;if(!await isDirectory(dirPath))throw new Error(dirPath);process.cwd()===path_1.normalize(dirPath)&&process.chdir(`${dirPath}/..`);const files=await readdir(dirPath);if(files.length){const awaiter=new Array;try{for(const file of files)try{const p=path_1.join(dirPath,file);await isDirectory(p)?awaiter.push(rmdir(p)):awaiter.push(fs_unlink(p).catch(()=>{}))}catch(e){}}finally{await Promise.all(awaiter)}}try{await fs_rmdir(dirPath)}catch(e){if(await isDirectory(dirPath))throw new Error(`UnableToRemoveException ${dirPath}`)}}async function rmFile(filePath){if(exports.exists(filePath)){if(await isDirectory(filePath))throw new Error(`PathIsNotFileException : ${filePath}`);try{await fs_unlink(filePath)}catch(e){if(await exports.exists(filePath))throw new Error(`UnableToRemoveException : filePath`)}}}async function mkdir(dirPath){if(!await isDirectory(dirPath)){const p=path_1.normalize(dirPath+"/"),parent=path_1.dirname(dirPath);await isDirectory(parent)||p!=parent&&await mkdir(parent);try{await fs_mkdir(p)}catch(e){if(!await isDirectory(p))throw new Error(e)}}}var exports={};Object.defineProperty(exports,"__esModule",{value:!0});const crypto_1=require("crypto");exports.isWindows="win32"===process.platform;const path_1=require("path"),child_process_1=require("child_process"),filesystem=require("fs"),fs=Object.assign({},filesystem);return exports.readdir=readdir,exports.stat=function(path){return new Promise((r,j)=>fs.stat(path,(err,files)=>err?j(err):r(files)))},exports.lstat=lstat,exports.open=function(path,flags,mode){return new Promise((r,j)=>fs.open(path,flags,mode,(err,descrpitor)=>err?j(err):r(descrpitor)))},exports.close=function(fd){return new Promise((r,j)=>fs.close(fd,err=>err?j(err):r()))},exports.write=function(fd,buffer,offset,length,position){return new Promise((r,j)=>fs.write(fd,buffer,offset||0,length||buffer.length,position||void 0,(err,written,buf)=>err?j(err):r(written)))},exports.read=function(fd,buffer,offset,length,position){return new Promise((r,j)=>fs.read(fd,buffer,offset,length,position||null,(err,bytes,buffer)=>err?j(err):r(bytes)))},exports.readFile=function(path,options){return new Promise((r,j)=>fs.readFile(path,options,(err,data)=>err?j(err):r(data)))},exports.execute=function(command,cmdlineargs,options){return new Promise((r,j)=>{const cp=child_process_1.spawn(command,cmdlineargs,Object.assign({},options,{stdio:"pipe"}));let err="",out="";cp.stderr.on("data",chunk=>{err+=chunk,process.stdout.write(".")}),cp.stdout.on("data",chunk=>{out+=chunk,process.stdout.write(".")}),cp.on("close",(code,signal)=>r({stdout:out,stderr:err,error:code?new Error("Process Failed."):null,code:code}))})},exports.rename=rename,exports.writeFile=function(filename,content){return new Promise((r,j)=>fs.writeFile(filename,content,err=>err?j(err):r()))},exports.copyFile=copyFile,exports.copyFolder=copyFolder,exports.exists=(path=>new Promise((r,j)=>fs.stat(path,(err,stats)=>r(err?!1:!0)))),exports.isDirectory=isDirectory,exports.isFile=isFile,exports.rmdir=rmdir,exports.rmFile=rmFile,exports.mkdir=mkdir,exports.INTSIZE=6,exports.unixifyPath=exports.isWindows?function(filepath){return filepath&&"string"==typeof filepath?filepath.replace(/^\\\\\?\\(.):\\/,"$1:\\").replace(/[\\\/]+/g,"/").replace(/^([a-zA-Z]+:|\.\/)/,"").replace(/(.+?)\/$/,"$1"):filepath}:p=>p,exports.isWindowsPath=exports.isWindows?function(filepath){if(filepath&&filepath.length>=3){if(92===filepath.charCodeAt(0)&&92===filepath.charCodeAt(1))return!0;if(58==filepath.charCodeAt(1)&&92===filepath.charCodeAt(2)){var code=filepath.charCodeAt(0);return code>=65&&code<=90||code>=97&&code<=122}}return!1}:p=>p,exports.calculateHash=function(content){return crypto_1.createHash("sha256").update(JSON.stringify(content)).digest("base64")},exports.select=function(array,callbackfn){return array.reduce((p,c,i,a)=>(p.push(callbackfn(p,c,i,a)),p),new Array)},exports.selectMany=function(array,callbackfn){return array.reduce((p,c,i,a)=>(p.push(...callbackfn(p,c,i,a)),p),new Array)},exports.first=function(array,selector,onError=(()=>void 0)){for(const each of array){const result=selector(each);if(void 0!=result)return result}return onError()},exports.backup=async function(filename){if(!await isFile(filename))return async()=>{await rmFile(filename)};const backupFile=path_1.join(path_1.dirname(filename),`${path_1.basename(filename)}.${1e4*Math.random()}${path_1.extname(filename)}`);return await rename(filename,backupFile),await copyFile(backupFile,filename),async()=>{await rmFile(filename),await rename(backupFile,filename)}},exports}function inline_patchmoduleloader(){function stripBOM(content){return content&&65279===content.charCodeAt(0)?content.slice(1):content}function unixifyVolume(volume){return common_1.isWindows?{readFileSync:(path,options)=>volume.readFileSync(common_1.unixifyPath(path),options),realpathSync:(path,options)=>volume.realpathSync(common_1.unixifyPath(path)),statSync:path=>volume.statSync(common_1.unixifyPath(path))}:volume}var exports={};Object.defineProperty(exports,"__esModule",{value:!0});const fs_1=require("fs"),common_1=inline_common(),path_1=require("path"),makeLong=require("path")._makeLong||path_1.resolve;return exports.patchModuleLoader=function(volume,enablePathNormalization=!1,enableFallback=!0,Module=require("module")){function internalModuleReadFile(path){try{return volume.readFileSync(path,"utf8")}catch(_a){}}function internalModuleStat(filename){try{return volume.statSync(filename).isDirectory()?1:0}catch(_a){}return-2}function stat(filename){filename=makeLong(filename);const result=statcache[filename];return void 0!==result?result:statcache[filename]=internalModuleStat(filename)}function readPackage(requestPath){const entry=packageMainCache[requestPath];if(entry)return entry;const jsonPath=path_1.resolve(requestPath,"package.json"),json=internalModuleReadFile(makeLong(jsonPath));if(void 0===json)return!1;let pkg;try{pkg=packageMainCache[requestPath]=JSON.parse(json).main}catch(e){throw e.path=jsonPath,e.message="Error parsing "+jsonPath+": "+e.message,e}return pkg}function tryFile(requestPath,isMain){return preserveSymlinks&&!isMain?0===stat(requestPath)?path_1.resolve(requestPath):void 0:0===stat(requestPath)?volume.realpathSync(requestPath):void 0}function tryExtensions(p,exts,isMain){for(let i=0;i<exts.length;i++){const filename=tryFile(p+exts[i],isMain);if(filename)return filename}}function tryPackage(requestPath,exts,isMain){let pkg=readPackage(requestPath);if(pkg){let filename=path_1.resolve(requestPath,pkg);return tryFile(filename,isMain)||tryExtensions(filename,exts,isMain)||tryExtensions(path_1.resolve(filename,"index"),exts,isMain)}}const backup=Object.assign({},Module),preserveSymlinks=!1,statcache={},packageMainCache={};return Module._fallback=enableFallback,enablePathNormalization&&(volume=unixifyVolume(volume)),Module._extensions[".js"]=((module,filename)=>{0==stat(filename)?module._compile(stripBOM(volume.readFileSync(filename,"utf8")),filename):Module._fallback&&module._compile(stripBOM(fs_1.readFileSync(filename,"utf8")),filename)}),Module._extensions[".json"]=((module,filename)=>{if(0==stat(filename))try{module.exports=JSON.parse(stripBOM(volume.readFileSync(filename,"utf8")))}catch(err){throw Object.assign({},err,{message:filename+": "+err.message})}else if(Module._fallback)try{module.exports=JSON.parse(stripBOM(fs_1.readFileSync(filename,"utf8")))}catch(err){throw Object.assign({},err,{message:filename+": "+err.message})}}),Module._originalFindPath=Module._findPath,Module._findPath=((request,paths,isMain)=>{const result=Module._alternateFindPath(request,paths,isMain);return!result&&Module._fallback?Module._originalFindPath(request,paths,isMain):result}),Module._alternateFindPath=((request,paths,isMain)=>{if(!request)return!1;if(path_1.isAbsolute(request))paths=[""];else if(!paths||0===paths.length)return!1;const cacheKey=request+"\0"+(1===paths.length?paths[0]:paths.join("\0")),entry=Module._pathCache[cacheKey];if(entry)return entry;const trailingSlash=47===request.charCodeAt(request.length-1);for(const curPath of paths){if(curPath&&stat(curPath)<1)continue;let basePath=path_1.resolve(curPath,request),rc=stat(basePath);if(rc<0&&common_1.isWindowsPath(basePath)){let correctedPath=common_1.unixifyPath(basePath);(rc=stat(correctedPath))>=0&&(basePath=correctedPath)}let filename;const exts=Object.keys(Module._extensions);if(!trailingSlash){switch(rc){case 0:filename=preserveSymlinks&&!isMain?path_1.resolve(basePath):volume.realpathSync(basePath);break;case 1:filename=tryPackage(basePath,exts,isMain)}filename||(filename=tryExtensions(basePath,exts,isMain))}if(filename||1!==rc||(filename=tryPackage(basePath,exts,isMain)||tryExtensions(path_1.resolve(basePath,"index"),exts,isMain)),filename)return Module._pathCache[cacheKey]=filename,filename}return!1}),()=>{Module._extensions[".js"]=backup._extensions[".js"],Module._extensions[".json"]=backup._extensions[".json"],Module._findPath=backup._findPath}},exports}Object.defineProperty(exports,"__esModule",{value:!0});const fs=require("fs"),patch_moduleloader_1=inline_patchmoduleloader(),static_filesystem_1=inline_staticfilesystem(),patch_filesystem_1=inline_patchfilesystem(),common_1=inline_common(),fs_1=require("fs"),child_process=require("child_process"),Module=require("module");if(require.main===module){const startpath=fs_1.realpathSync(module.filename);for(let i=0;i<process.argv.length;i++)if(fs_1.realpathSync(process.argv[i])===startpath){for(process.argv.splice(i,1);i<process.argv.length&&process.argv[i].startsWith("--load-module=");){const staticModule=process.argv[i].split("=")[1];process.argv.splice(i,1),load(staticModule)}process.argv.length<2&&(console.log("Missing module name to start."),process.exit(1)),Module._load(process.argv[1],null,!0),process._tickCallback();break}}const possibilities=["node","node.exe",process.execPath,process.argv[0]];exports.list=list,exports.load=load,exports.unload=unload;
{
"name": "@microsoft.azure/autorest-core",
"version": "2.0.4184",
"version": "2.0.4186",
"description": "AutoRest core module",

@@ -56,3 +56,3 @@ "engines": {

"get-uri": "^2.0.0",
"jsonpath": "^0.2.11",
"jsonpath": "1.0.0",
"linq-es2015": "^2.4.25",

@@ -63,2 +63,3 @@ "pify": "^3.0.0",

"strip-bom": "^3.0.0",
"swagger2openapi": "olydis/swagger2openapi#autorest-flavor",
"untildify": "^3.0.2",

@@ -65,0 +66,0 @@ "urijs": "^1.18.10",

@@ -150,4 +150,14 @@ # Default Configuration

swagger-document/emitter:
input: transform
input: identity
scope: scope-swagger-document/emitter
# OpenAPI
openapi-document/openapi-document-converter:
input: swagger-document/identity
output-artifact: openapi-document
openapi-document/identity:
input: openapi-document-converter
output-artifact: openapi-document
openapi-document/emitter:
input: identity
scope: scope-openapi-document/emitter

@@ -162,2 +172,10 @@ scope-swagger-document/emitter:

$config["input-file"][0].split('/').reverse()[0].split('\\').reverse()[0].replace(/\.json$/, "")
scope-openapi-document/emitter:
input-artifact: openapi-document
is-object: true
# rethink that output-file part
output-uri-expr: |
$config["output-file"] ||
($config.namespace ? $config.namespace.replace(/:/g,'_') : undefined) ||
$config["input-file"][0].split('/').reverse()[0].split('\\').reverse()[0].replace(/\.json$/, "")
scope-cm/emitter:

@@ -164,0 +182,0 @@ input-artifact: code-model-v1

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc