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.4198 to 2.0.4199

dist/help.d.ts

104

dist/app.js

@@ -9,5 +9,27 @@ #!/usr/bin/env node

*--------------------------------------------------------------------------------------------*/
// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd
if (!String.prototype.padEnd) {
String.prototype.padEnd = function padEnd(targetLength, padString) {
targetLength = targetLength >> 0; //floor if number or convert non-number to 0;
padString = String(padString || ' ');
if (this.length > targetLength) {
return String(this);
}
else {
targetLength = targetLength - this.length;
if (targetLength > padString.length) {
padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
}
return String(this) + padString.slice(0, targetLength);
}
};
}
require('events').EventEmitter.defaultMaxListeners = 100;
process.env['ELECTRON_RUN_AS_NODE'] = "1";
delete process.env['ELECTRON_NO_ATTACH_CONSOLE'];
process.on("exit", () => {
autorest_core_1.Shutdown();
});
const color = global.color ? global.color : p => p;
const configuration_1 = require("./lib/configuration");

@@ -40,10 +62,10 @@ const yaml_1 = require("./lib/ref/yaml");

catch (e) {
console.error("Error: You have provided legacy command line arguments (single-dash syntax) that seem broken.");
console.error(color("!Error: You have provided legacy command line arguments (single-dash syntax) that seem broken."));
console.error("");
console.error("While AutoRest keeps on supporting the old CLI by converting it over to the new one internally, " +
"it does not have crazy logic determining *what* is wrong with arguments, should conversion fail. " +
"Please try fixing your arguments or consider moving to the new CLI. " +
"Visit https://github.com/Azure/autorest/blob/master/docs/user/cli.md for information about the new CLI.");
console.error(color("> While AutoRest keeps on supporting the old CLI by converting it over to the new one internally, \n" +
"> it does not have crazy logic determining *what* is wrong with arguments, should conversion fail. \n" +
"> Please try fixing your arguments or consider moving to the new CLI. \n" +
"> isit https://github.com/Azure/autorest/blob/master/docs/user/cli.md for information about the new CLI."));
console.error("");
console.error("Internal error: " + e);
console.error(color("!Internal error: " + e));
return 1;

@@ -146,6 +168,6 @@ }

case message_1.Channel.Information:
console.log(m.FormattedMessage || m.Text);
console.log(color(m.FormattedMessage || m.Text));
break;
case message_1.Channel.Warning:
console.warn(m.FormattedMessage || m.Text);
console.log(color(m.FormattedMessage || m.Text));
break;

@@ -155,3 +177,3 @@ case message_1.Channel.Error:

errorCounter();
console.error(m.FormattedMessage || m.Text);
console.error(color(m.FormattedMessage || m.Text));
break;

@@ -245,11 +267,47 @@ }

}
// perform file system operations.
for (const folder of clearFolders) {
try {
await uri_1.ClearFolder(folder);
if (config.HelpRequested) {
// no fs operations on --help! Instead, format and print artifacts to console.
// - print boilerplate help
console.log("");
console.log("");
console.log(color("**Usage**: autorest `[configuration-file.md] [...options]`"));
console.log("");
console.log(color(" See: https://aka.ms/autorest/cli for additional documentation"));
// - sort artifacts by name (then content, just for stability)
const helpArtifacts = artifacts.sort((a, b) => a.uri === b.uri ? (a.content > b.content ? 1 : -1) : (a.uri > b.uri ? 1 : -1));
// - format and print
for (const helpArtifact of helpArtifacts) {
const help = yaml_1.Parse(helpArtifact.content, (message, index) => console.error(color(`!Parsing error at **${helpArtifact.uri}**:__${index}: ${message}__`)));
if (!help) {
continue;
}
const activatedBySuffix = help.activationScope ? ` (activated by --${help.activationScope})` : "";
console.log("");
console.log(color(`### ${help.categoryFriendlyName}${activatedBySuffix}`));
if (help.description) {
console.log(color(help.description));
}
console.log("");
for (const settingHelp of help.settings) {
const keyPart = `--${settingHelp.key}`;
const typePart = settingHelp.type ? `=<${settingHelp.type}>` : ` `; //`[=<boolean>]`;
let settingPart = `${keyPart}\`${typePart}\``;
// if (!settingHelp.required) {
// settingPart = `[${settingPart}]`;
// }
console.log(color(` ${settingPart.padEnd(30)} **${settingHelp.description}**`));
}
}
catch (e) { }
}
for (const artifact of artifacts) {
await uri_1.WriteString(artifact.uri, artifact.content);
else {
// perform file system operations.
for (const folder of clearFolders) {
try {
await uri_1.ClearFolder(folder);
}
catch (e) { }
}
for (const artifact of artifacts) {
await uri_1.WriteString(artifact.uri, artifact.content);
}
}

@@ -265,3 +323,3 @@ // return the exit code to the caller.

/* if (existing[key]) {
Console.Log(`> Warning: ${key} is overwritten.`);
Console.Log(color(`> Warning: ${key} is overwritten.`));
} */

@@ -304,3 +362,3 @@ existing[key] = value;

exitcode++;
console.error(`File ${path} is not a OpenAPI file.`);
console.error(color(`!File ${path} is not a OpenAPI file.`));
continue;

@@ -384,7 +442,2 @@ }

autorestArgs = process.argv.slice(2);
// temporary: --help displays legacy AutoRest's -Help message
if (autorestArgs.indexOf("--help") !== -1) {
await legacyMain(["-Help"]);
return;
}
if (legacyCli_1.isLegacy(autorestArgs)) {

@@ -396,2 +449,3 @@ exitcode = await legacyMain(autorestArgs);

}
await autorest_core_1.Shutdown();
process.exit(exitcode);

@@ -409,7 +463,9 @@ }

}
await autorest_core_1.Shutdown();
process.exit(e.exitCode);
}
if (e !== false) {
console.error(e);
console.error(color(`!${e}`));
}
await autorest_core_1.Shutdown();
process.exit(1);

@@ -416,0 +472,0 @@ }

@@ -90,8 +90,5 @@ "use strict";

};
if (earlyCancel) {
this.Finished.Dispatch(false);
return false;
}
if (view.InputFileUris.length === 0) {
if (view.GetEntry("allow-no-input")) {
this.Finished.Dispatch(true);
return true;

@@ -103,2 +100,6 @@ }

}
if (earlyCancel) {
this.Finished.Dispatch(false);
return false;
}
await Promise.race([

@@ -105,0 +106,0 @@ pipeline_1.RunPipeline(view, this.fileSystem),

@@ -58,3 +58,2 @@ import { Artifact } from './artifact';

readonly suppress: Iterable<string>;
readonly set: Iterable<string>;
readonly transform: Iterable<string>;

@@ -105,2 +104,3 @@ readonly test: Iterable<string>;

readonly VerboseMode: boolean;
readonly HelpRequested: boolean;
GetNestedConfiguration(pluginName: string): Iterable<ConfigurationView>;

@@ -107,0 +107,0 @@ GetNestedConfigurationImmediate(...scope: any[]): ConfigurationView;

@@ -78,5 +78,2 @@ "use strict";

}
get set() {
return ValuesOf(this.directive["set"]);
}
get transform() {

@@ -270,7 +267,10 @@ return ValuesOf(this.directive["transform"]);

get DebugMode() {
return this.config["debug"];
return !!this.config["debug"];
}
get VerboseMode() {
return this.config["verbose"];
return !!this.config["verbose"];
}
get HelpRequested() {
return !!this.config["help"];
}
*GetNestedConfiguration(pluginName) {

@@ -492,2 +492,3 @@ for (const section of ValuesOf(this.config[pluginName])) {

static async shutdown() {
plugin_endpoint_1.AutoRestExtension.killAll();
for (const each in loadedExtensions) {

@@ -584,3 +585,3 @@ const ext = loadedExtensions[each];

Channel: message_1.Channel.Information,
Text: `Loading local AutoRest extension '${additionalExtension.name}' (${localPath})`
Text: `> Loading local AutoRest extension '${additionalExtension.name}' (${localPath})`
});

@@ -601,3 +602,3 @@ const pack = await extMgr.findPackage(additionalExtension.name, localPath);

Channel: message_1.Channel.Information,
Text: `Loading AutoRest extension '${additionalExtension.name}' (${additionalExtension.source})`
Text: `> Loading AutoRest extension '${additionalExtension.name}' (${additionalExtension.source})`
});

@@ -615,3 +616,3 @@ // start extension

Channel: message_1.Channel.Information,
Text: `Installing AutoRest extension '${additionalExtension.name}' (${additionalExtension.source})`
Text: `> Installing AutoRest extension '${additionalExtension.name}' (${additionalExtension.source})`
});

@@ -618,0 +619,0 @@ const extension = await extMgr.installPackage(pack, false, 5 * 60 * 1000, (progressInit) => progressInit.Message.Subscribe((s, m) => tmpView.Message({ Text: m, Channel: message_1.Channel.Verbose })));

@@ -10,3 +10,13 @@ "use strict";

const merging_1 = require("../source-map/merging");
function IsDocumentationField(path) {
function IsDocumentationField(node) {
if (!node || !node.node.value || !node.node.value.value || typeof node.node.value.value !== "string") {
return false;
}
const path = node.path;
if (path.length < 2) {
return false;
}
if (path[path.length - 2] === "x-ms-examples") {
return false;
}
const last = path[path.length - 1];

@@ -53,3 +63,3 @@ return last === "Description" || last === "Summary";

for (const d of yaml_1.Descendants(ast, [], true)) {
if (d.node.kind === yaml_1.Kind.MAPPING && IsDocumentationField(d.path)) {
if (d.node.kind === yaml_1.Kind.MAPPING && IsDocumentationField(d)) {
const node = d.node;

@@ -56,0 +66,0 @@ const rawMarkdown = node.value.value;

@@ -21,7 +21,8 @@ "use strict";

const conversion_1 = require("../openapi/conversion");
const help_1 = require("./help");
;
function CreatePluginIdentity() {
function GetPlugin_Identity() {
return async (config, input) => input;
}
function CreatePluginLoader() {
function GetPlugin_Loader() {
return async (config, input, sink) => {

@@ -37,3 +38,3 @@ let inputs = config.InputFileUris;

}
function CreatePluginMdOverrideLoader() {
function GetPlugin_MdOverrideLoader() {
return async (config, input, sink) => {

@@ -62,3 +63,3 @@ let inputs = config.InputFileUris;

}
function CreatePluginOAI2toOAIx() {
function GetPlugin_OAI2toOAIx() {
return CreatePerFilePlugin(async (config) => async (fileIn, sink) => {

@@ -69,3 +70,3 @@ const fileOut = await conversion_1.ConvertOAI2toOAI3(fileIn, sink);

}
function CreatePluginYaml2Jsonx() {
function GetPlugin_Yaml2Jsonx() {
return CreatePerFilePlugin(async (config) => async (fileIn, sink) => {

@@ -77,3 +78,3 @@ let ast = fileIn.ReadYamlAst();

}
function CreatePluginJsonx2Yaml() {
function GetPlugin_Jsonx2Yaml() {
return CreatePerFilePlugin(async (config) => async (fileIn, sink) => {

@@ -85,3 +86,3 @@ let ast = fileIn.ReadYamlAst();

}
function CreatePluginTransformer() {
function GetPlugin_Transformer() {
return CreatePerFilePlugin(async (config) => {

@@ -96,3 +97,3 @@ const isObject = config.GetEntry("is-object") === false ? false : true;

}
function CreatePluginTransformerImmediate() {
function GetPlugin_TransformerImmediate() {
return async (config, input, sink) => {

@@ -109,3 +110,3 @@ const isObject = config.GetEntry("is-object") === false ? false : true;

}
function CreatePluginComposer() {
function GetPlugin_Composer() {
return async (config, input, sink) => {

@@ -120,3 +121,3 @@ const swaggers = await Promise.all((await input.Enum()).map(x => input.ReadStrict(x)));

}
function CreatePluginExternal(host, pluginName) {
function GetPlugin_External(host, pluginName) {
return async (config, input, sink) => {

@@ -136,3 +137,3 @@ const plugin = await host;

}
function CreateCommonmarkProcessor() {
function GetPlugin_CommonmarkProcessor() {
return async (config, input, sink) => {

@@ -150,3 +151,3 @@ const files = await input.Enum();

}
function CreateArtifactEmitter(inputOverride) {
function GetPlugin_ArtifactEmitter(inputOverride) {
return async (config, input, sink) => {

@@ -160,3 +161,3 @@ if (inputOverride) {

}
await artifact_emitter_1.EmitArtifacts(config, config.GetEntry("input-artifact"), key => uri_1.ResolveUri(config.OutputFolderUri, safe_eval_1.safeEval(config.GetEntry("output-uri-expr"), { $key: key, $config: config.Raw })), input, config.GetEntry("is-object"));
await artifact_emitter_1.EmitArtifacts(config, config.GetEntry("input-artifact") || null, key => uri_1.ResolveUri(config.OutputFolderUri, safe_eval_1.safeEval(config.GetEntry("output-uri-expr") || "$key", { $key: key, $config: config.Raw })), input, config.GetEntry("is-object"));
return new data_store_1.QuickDataSource([]);

@@ -258,17 +259,19 @@ };

const plugins = {
"identity": CreatePluginIdentity(),
"loader": CreatePluginLoader(),
"md-override-loader": CreatePluginMdOverrideLoader(),
"transform": CreatePluginTransformer(),
"transform-immediate": CreatePluginTransformerImmediate(),
"compose": CreatePluginComposer(),
"help-autorest": help_1.GetPlugin_HelpAutoRest(),
"help-autorest-core": help_1.GetPlugin_HelpAutoRestCore(),
"identity": GetPlugin_Identity(),
"loader": GetPlugin_Loader(),
"md-override-loader": GetPlugin_MdOverrideLoader(),
"transform": GetPlugin_Transformer(),
"transform-immediate": GetPlugin_TransformerImmediate(),
"compose": GetPlugin_Composer(),
// TODO: replace with OAV again
"semantic-validator": CreatePluginIdentity(),
"openapi-document-converter": CreatePluginOAI2toOAIx(),
"yaml2jsonx": CreatePluginYaml2Jsonx(),
"jsonx2yaml": CreatePluginJsonx2Yaml(),
"commonmarker": CreateCommonmarkProcessor(),
"emitter": CreateArtifactEmitter(),
"pipeline-emitter": CreateArtifactEmitter(async () => new data_store_1.QuickDataSource([await configView.DataStore.getDataSink().WriteObject("pipeline", pipeline.pipeline)])),
"configuration-emitter": CreateArtifactEmitter(async () => new data_store_1.QuickDataSource([await configView.DataStore.getDataSink().WriteObject("configuration", configView.Raw)]))
"semantic-validator": GetPlugin_Identity(),
"openapi-document-converter": GetPlugin_OAI2toOAIx(),
"yaml2jsonx": GetPlugin_Yaml2Jsonx(),
"jsonx2yaml": GetPlugin_Jsonx2Yaml(),
"commonmarker": GetPlugin_CommonmarkProcessor(),
"emitter": GetPlugin_ArtifactEmitter(),
"pipeline-emitter": GetPlugin_ArtifactEmitter(async () => new data_store_1.QuickDataSource([await configView.DataStore.getDataSink().WriteObject("pipeline", pipeline.pipeline)])),
"configuration-emitter": GetPlugin_ArtifactEmitter(async () => new data_store_1.QuickDataSource([await configView.DataStore.getDataSink().WriteObject("configuration", configView.Raw)]))
};

@@ -281,3 +284,3 @@ // dynamically loaded, auto-discovered plugins

if (!plugins[plugin]) {
plugins[plugin] = CreatePluginExternal(extension, plugin);
plugins[plugin] = GetPlugin_External(extension, plugin);
__extensionExtension[plugin] = extension;

@@ -284,0 +287,0 @@ }

@@ -13,3 +13,5 @@ /// <reference types="node" />

private static CreateSessionId();
private static processes;
kill(): void;
static killAll(): void;
static FromModule(modulePath: string): Promise<AutoRestExtension>;

@@ -16,0 +18,0 @@ static FromChildProcess(extensionName: string, childProc: ChildProcess): Promise<AutoRestExtension>;

@@ -85,2 +85,8 @@ "use strict";

}
static killAll() {
for (const each of AutoRestExtension.processes) {
each.kill("SIGKILL");
}
AutoRestExtension.processes.length = 0;
}
static async FromModule(modulePath) {

@@ -93,2 +99,3 @@ const childProc = child_process_1.fork(modulePath, [], { silent: true });

childProc.stderr.pipe(process.stderr);
AutoRestExtension.processes.push(childProc);
// poke the extension to detect trivial issues like process startup failure or protocol violations, ...

@@ -182,3 +189,4 @@ if (!Array.isArray(await plugin.GetPluginNames(cancellation_1.CancellationToken.None))) {

AutoRestExtension.lastSessionId = 0;
AutoRestExtension.processes = new Array();
exports.AutoRestExtension = AutoRestExtension;
//# sourceMappingURL=plugin-endpoint.js.map

@@ -47,6 +47,7 @@ "use strict";

const references = [];
var currentDoc = externalFiles[currentFileUri].ReadYamlAst();
const currentDoc = externalFiles[currentFileUri];
const currentDocAst = currentDoc.ReadYamlAst();
if (entityType == null || modelName == null) {
// external references
for (const node of yaml_2.Descendants(currentDoc)) {
for (const node of yaml_2.Descendants(currentDocAst)) {
if (isReferenceNode(node)) {

@@ -61,3 +62,3 @@ if (!node.node.value.startsWith("#")) {

// references within external file
const model = yaml_1.ResolveRelativeNode(currentDoc, currentDoc, [entityType, modelName]);
const model = yaml_1.ResolveRelativeNode(currentDocAst, currentDocAst, [entityType, modelName]);
for (const node of yaml_2.Descendants(model, [entityType, modelName])) {

@@ -71,3 +72,3 @@ if (isReferenceNode(node)) {

for (const { node, path } of references) {
const complaintLocation = { document: currentFileUri, Position: { path: path } };
const complaintLocation = { document: currentDoc.key, Position: { path: path } };
const refPath = node.value;

@@ -132,3 +133,3 @@ if (refPath.indexOf("#") === -1) {

const dependentRefs = [];
for (const node of yaml_2.Descendants(currentDoc)) {
for (const node of yaml_2.Descendants(currentDocAst)) {
const path = node.path;

@@ -135,0 +136,0 @@ if (path.length > 3 && path[path.length - 3] === "allOf" && isReferenceNode(node) && node.node.value.indexOf(reference) !== -1) {

{
"name": "@microsoft.azure/autorest-core",
"version": "2.0.4198",
"version": "2.0.4199",
"description": "AutoRest core module",

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

"mocha-typescript": "^1.1.7",
"static-link": "^0.2.2",
"static-link": "^0.2.3",
"vscode-jsonrpc": "^3.3.1"

@@ -53,4 +53,4 @@ },

"dependencies": {
"@microsoft.azure/async-io": "~1.0.22",
"@microsoft.azure/extension": "~1.2.12",
"@microsoft.azure/async-io": "~2.0.7",
"@microsoft.azure/extension": "^2.0.4",
"vscode-languageserver": "3.4.3",

@@ -70,7 +70,6 @@ "commonmark": "^0.27.0",

"vscode-jsonrpc": "^3.3.1",
"yaml-ast-parser": "https://github.com/olydis/yaml-ast-parser/releases/download/0.0.34/yaml-ast-parser-0.0.34.tgz",
"yargs": "^8.0.2"
"yaml-ast-parser": "https://github.com/olydis/yaml-ast-parser/releases/download/0.0.34/yaml-ast-parser-0.0.34.tgz"
},
"patch": "const fs = require(`fs`); let txt = fs.readFileSync('./node_modules/npm/lib/install/action/extract.js','utf8').replace(`const ENABLE_WORKERS = process.platform === 'darwin'`, `const ENABLE_WORKERS = false;`); fs.writeFileSync('./node_modules/npm/lib/install/action/extract.js', txt ); txt = fs.readFileSync(`./node_modules/npm/lib/npm.js`,`utf8`).replace(`var j = parseJSON(fs.readFileSync(`, `var j = require(path.join(__dirname, '../package.json'));` ).replace(`path.join(__dirname, '../package.json')) + '')`,``); fs.writeFileSync(`./node_modules/npm/lib/npm.js`, txt ); "
"patch": "const fs = require(`fs`); let txt = fs.readFileSync('./node_modules/npm/lib/install/action/extract.js','utf8').replace(`const ENABLE_WORKERS = process.platform === 'darwin'`, `const ENABLE_WORKERS = false;`); fs.writeFileSync('./node_modules/npm/lib/install/action/extract.js', txt ); txt = fs.readFileSync(`./node_modules/npm/lib/npm.js`,`utf8`).replace(`var j = parseJSON(fs.readFileSync(`, `var j = require(path.join(__dirname, '../package.json'));` ).replace(`path.join(__dirname, '../package.json')) + '')`,``); fs.writeFileSync(`./node_modules/npm/lib/npm.js`, txt ); txt = fs.readFileSync('./node_modules/npm/lib/pack.js','utf8').replace(`require.main.filename`, `require.resolve('../bin/npm-cli.js')`); fs.writeFileSync('./node_modules/npm/lib/pack.js', txt );"
}
}

@@ -110,12 +110,35 @@ # Default Configuration

#### Help
``` yaml $(help)
input-file: dummy # trick "no input file" checks... may wanna refactor at some point
```
``` yaml
pipeline:
help/help-autorest:
scope: help
help/help-autorest-core:
scope: help
output-artifact:
- null # so emitted help doesn't necessarily have to say its output-artifact
- help
```
Note: We don't load anything if `--help` is specified.
``` yaml !$(help)
perform-load: true # kick off loading
```
#### Loading
Note: We don't load anything if `--help` appears to be specified.
Markdown documentation overrides:
``` yaml !$(help)
``` yaml
pipeline:
swagger-document-override/md-override-loader:
output-artifact: immediate-config
scope: perform-load
```

@@ -125,3 +148,3 @@

``` yaml !$(help)
``` yaml
pipeline:

@@ -131,2 +154,3 @@ swagger-document/loader:

output-artifact: swagger-document
scope: perform-load
swagger-document/individual/transform:

@@ -185,3 +209,3 @@ input: loader

$config["input-file"][0].split('/').reverse()[0].split('\\').reverse()[0].replace(/\.json$/, "")
scope-cm/emitter:
scope-cm/emitter: # can remove once every generator depends on recent modeler
input-artifact: code-model-v1

@@ -188,0 +212,0 @@ is-object: true

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