Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1 @@
export declare const parse: (code: string) => Object;

View File

@@ -0,0 +1,530 @@
/*
* Generated by PEG.js 0.10.0.
*
* http://pegjs.org/
*/
"use strict";
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function peg$SyntaxError(message, expected, found, location) {
this.message = message;
this.expected = expected;
this.found = found;
this.location = location;
this.name = "SyntaxError";
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, peg$SyntaxError);
}
}
peg$subclass(peg$SyntaxError, Error);
peg$SyntaxError.buildMessage = function(expected, found) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function(expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
"class": function(expectation) {
var escapedParts = "",
i;
for (i = 0; i < expectation.parts.length; i++) {
escapedParts += expectation.parts[i] instanceof Array
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
: classEscape(expectation.parts[i]);
}
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
},
any: function(expectation) {
return "any character";
},
end: function(expectation) {
return "end of input";
},
other: function(expectation) {
return expectation.description;
}
};
function hex(ch) {
return ch.charCodeAt(0).toString(16).toUpperCase();
}
function literalEscape(s) {
return s
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\0/g, '\\0')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
}
function classEscape(s) {
return s
.replace(/\\/g, '\\\\')
.replace(/\]/g, '\\]')
.replace(/\^/g, '\\^')
.replace(/-/g, '\\-')
.replace(/\0/g, '\\0')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
}
function describeExpectation(expectation) {
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
}
function describeExpected(expected) {
var descriptions = new Array(expected.length),
i, j;
for (i = 0; i < expected.length; i++) {
descriptions[i] = describeExpectation(expected[i]);
}
descriptions.sort();
if (descriptions.length > 0) {
for (i = 1, j = 1; i < descriptions.length; i++) {
if (descriptions[i - 1] !== descriptions[i]) {
descriptions[j] = descriptions[i];
j++;
}
}
descriptions.length = j;
}
switch (descriptions.length) {
case 1:
return descriptions[0];
case 2:
return descriptions[0] + " or " + descriptions[1];
default:
return descriptions.slice(0, -1).join(", ")
+ ", or "
+ descriptions[descriptions.length - 1];
}
}
function describeFound(found) {
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
}
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
};
function peg$parse(input, options) {
options = options !== void 0 ? options : {};
var peg$FAILED = {},
peg$startRuleFunctions = { resolution: peg$parseresolution },
peg$startRuleFunction = peg$parseresolution,
peg$c0 = "/",
peg$c1 = peg$literalExpectation("/", false),
peg$c2 = function(from, descriptor) { return { from, descriptor } },
peg$c3 = function(descriptor) { return { descriptor } },
peg$c4 = "@",
peg$c5 = peg$literalExpectation("@", false),
peg$c6 = function(fullName, description) { return { fullName, description } },
peg$c7 = function(fullName) { return { fullName } },
peg$c8 = function() { return text() },
peg$c9 = /^[^\/@]/,
peg$c10 = peg$classExpectation(["/", "@"], true, false),
peg$c11 = /^[^\/]/,
peg$c12 = peg$classExpectation(["/"], true, false),
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{ line: 1, column: 1 }],
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$savedPos, peg$currPos);
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
input.substring(peg$savedPos, peg$currPos),
location
);
}
function error(message, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
throw peg$buildSimpleError(message, location);
}
function peg$literalExpectation(text, ignoreCase) {
return { type: "literal", text: text, ignoreCase: ignoreCase };
}
function peg$classExpectation(parts, inverted, ignoreCase) {
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
}
function peg$anyExpectation() {
return { type: "any" };
}
function peg$endExpectation() {
return { type: "end" };
}
function peg$otherExpectation(description) {
return { type: "other", description: description };
}
function peg$computePosDetails(pos) {
var details = peg$posDetailsCache[pos], p;
if (details) {
return details;
} else {
p = pos - 1;
while (!peg$posDetailsCache[p]) {
p--;
}
details = peg$posDetailsCache[p];
details = {
line: details.line,
column: details.column
};
while (p < pos) {
if (input.charCodeAt(p) === 10) {
details.line++;
details.column = 1;
} else {
details.column++;
}
p++;
}
peg$posDetailsCache[pos] = details;
return details;
}
}
function peg$computeLocation(startPos, endPos) {
var startPosDetails = peg$computePosDetails(startPos),
endPosDetails = peg$computePosDetails(endPos);
return {
start: {
offset: startPos,
line: startPosDetails.line,
column: startPosDetails.column
},
end: {
offset: endPos,
line: endPosDetails.line,
column: endPosDetails.column
}
};
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildSimpleError(message, location) {
return new peg$SyntaxError(message, null, null, location);
}
function peg$buildStructuredError(expected, found, location) {
return new peg$SyntaxError(
peg$SyntaxError.buildMessage(expected, found),
expected,
found,
location
);
}
function peg$parseresolution() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parsespecifier();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 47) {
s2 = peg$c0;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
if (s2 !== peg$FAILED) {
s3 = peg$parsespecifier();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c2(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsespecifier();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c3(s1);
}
s0 = s1;
}
return s0;
}
function peg$parsespecifier() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parsefullName();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 64) {
s2 = peg$c4;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s2 !== peg$FAILED) {
s3 = peg$parsedescription();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c6(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsefullName();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c7(s1);
}
s0 = s1;
}
return s0;
}
function peg$parsefullName() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 64) {
s1 = peg$c4;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parseident();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 47) {
s3 = peg$c0;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parseident();
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseident();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
}
s0 = s1;
}
return s0;
}
function peg$parseident() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = [];
if (peg$c9.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c9.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
}
s0 = s1;
return s0;
}
function peg$parsedescription() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = [];
if (peg$c11.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c12); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c11.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c12); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
}
s0 = s1;
return s0;
}
peg$result = peg$startRuleFunction();
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
return peg$result;
} else {
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
peg$fail(peg$endExpectation());
}
throw peg$buildStructuredError(
peg$maxFailExpected,
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
peg$maxFailPos < input.length
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
);
}
}
module.exports = {
SyntaxError: peg$SyntaxError,
parse: peg$parse
};

View File

@@ -0,0 +1,17 @@
resolution =
from:specifier "/" descriptor:specifier { return { from, descriptor } }
/ descriptor:specifier { return { descriptor } }
specifier =
fullName:fullName "@" description:description { return { fullName, description } }
/ fullName:fullName { return { fullName } }
fullName =
"@" ident "/" ident { return text() }
/ ident { return text() }
ident =
[^/@]+ { return text() }
description =
[^/]+ { return text() }

92
node_modules/@yarnpkg/parsers/lib/grammars/shell.d.ts generated vendored Normal file
View File

@@ -0,0 +1,92 @@
// From the top to the bottom:
//
// - A shell line is composed of multiple command lines, first separated by ";" and then chained by "&&" / "||"
// - A command line is composed of multiple commands chained by "|" / "|&"
// - A command is composed of multiple arguments separated by spaces
// - An argument can be a value argument (sent to the underlying program), or a redirection
// - A value argument is a combination of argument segments
export type ArgumentSegment =
| {type: `text`, text: string}
| {type: `glob`, pattern: string}
| {type: `shell`, shell: ShellLine, quoted: boolean}
| {type: `variable`, name: string, defaultValue?: Array<ValueArgument>, alternativeValue?: Array<ValueArgument>, quoted: boolean}
| {type: `arithmetic`, arithmetic: ArithmeticExpression};
export type Argument =
| RedirectArgument
| ValueArgument;
export type RedirectArgument = {
type: `redirection`;
subtype: `>` | `<` | '>&' | '<&' | `>>` | `<<<`;
fd: number | null;
args: Array<ValueArgument>;
};
export type ValueArgument =
| {type: `argument`, segments: Array<ArgumentSegment>};
export type EnvSegment = {
name: string;
args: [] | [ValueArgument];
};
export type Command = {
type: `command`;
args: Array<Argument>;
envs: Array<EnvSegment>;
} | {
type: `subshell`;
subshell: ShellLine;
args: Array<RedirectArgument>;
} | {
type: `group`;
group: ShellLine;
args: Array<RedirectArgument>;
} | {
type: `envs`;
envs: Array<EnvSegment>;
};
export type CommandChain = Command & {
then?: CommandChainThen;
};
export type CommandChainThen = {
type: `|&` | `|`;
chain: CommandChain;
};
export type CommandLine = {
chain: CommandChain;
then?: CommandLineThen;
};
export type CommandLineThen = {
type: `&&` | `||`;
line: CommandLine;
};
export type ShellLine = Array<{
type: ';' | '&';
command: CommandLine;
}>;
export type ArithmeticPrimary = {
type: `number`;
value: number;
} | {
type: `variable`;
name: string;
};
export type ArithmeticOperatorExpression = {
type: `multiplication` | `division` | `addition` | `subtraction`;
left: ArithmeticExpression;
right: ArithmeticExpression;
};
export type ArithmeticExpression = ArithmeticPrimary | ArithmeticOperatorExpression;
export declare const parse: (code: string, options: {isGlobPattern: (arg: string) => boolean}) => ShellLine;

3653
node_modules/@yarnpkg/parsers/lib/grammars/shell.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

189
node_modules/@yarnpkg/parsers/lib/grammars/shell.pegjs generated vendored Normal file
View File

@@ -0,0 +1,189 @@
Start
= S* line:ShellLine? { return line ? line : [] }
ShellLine
= command:CommandLine S* type:ShellLineType then:ShellLineThen? { return [ { command, type } ].concat(then || []) }
/ command:CommandLine S* type:ShellLineType? { return [ { command, type: type || ';' } ] }
ShellLineThen
= S* then:ShellLine S* { return then }
ShellLineType
= ';'
/ '&'
CommandLine
= chain:CommandChain then:CommandLineThen? { return then ? { chain, then } : { chain } }
CommandLineThen
= S* type:CommandLineType S* then:CommandLine S* { return { type, line: then } }
CommandLineType
= '&&'
/ '||'
CommandChain
= main:Command then:CommandChainThen? { return then ? { ...main, then } : main }
CommandChainThen
= S* type:CommandChainType S* then:CommandChain S* { return { type, chain: then } }
CommandChainType
= '|&'
/ '|'
VariableAssignment
= name:EnvVariable '=' arg:StrictValueArgument S* { return { name, args: [arg] } }
/ name:EnvVariable '=' S* { return { name, args: [] } }
Command
= S* "(" S* subshell:ShellLine S* ")" S* args:RedirectArgument* S* { return { type: `subshell`, subshell, args } }
/ S* "{" S* group:ShellLine S* "}" S* args:RedirectArgument* S* { return { type: `group`, group, args } }
/ S* envs:VariableAssignment* S* args:Argument+ S* { return { type: `command`, args, envs } }
/ S* envs:VariableAssignment+ S* { return { type: `envs`, envs } }
CommandString
= S* args:ValueArgument+ S* { return args }
Argument
= S* arg:RedirectArgument { return arg }
/ S* arg:ValueArgument { return arg }
RedirectArgument
= S* fd:[0-9]? redirect:RedirectType arg:ValueArgument { return { type: `redirection`, subtype: redirect, fd: fd !== null ? parseInt(fd) : null, args: [arg] } }
RedirectType
= '>>'
/ '>&'
/ '>'
/ '<<<'
/ '<&'
/ '<'
ValueArgument
= S* arg:StrictValueArgument { return arg }
StrictValueArgument
= segments:ArgumentSegment+ { return { type: `argument`, segments: [].concat(... segments) } }
ArgumentSegment
= string:CQuoteString { return string }
/ string:SglQuoteString { return string }
/ string:DblQuoteString { return string }
/ string:PlainString { return string }
CQuoteString
= "$'" text:CQuoteStringText "'" { return [ { type: `text`, text } ] }
SglQuoteString
= "'" text:SglQuoteStringText "'" { return [ { type: `text`, text } ] }
DblQuoteString
= '""' { return { type: `text`, text: `` } } / '"' segments:DblQuoteStringSegment* '"' { return segments }
PlainString
= segments:PlainStringSegment+ { return segments }
DblQuoteStringSegment
= arithmetic:Arithmetic { return { type: `arithmetic`, arithmetic, quoted: true} }
/ shell:Subshell { return { type: `shell`, shell, quoted: true } }
/ variable:Variable { return { type: `variable`, ...variable, quoted: true } }
/ text:DblQuoteStringText { return { type: `text`, text } }
PlainStringSegment
= arithmetic:Arithmetic { return { type: `arithmetic`, arithmetic, quoted: false} }
/ shell:Subshell { return { type: `shell`, shell, quoted: false } }
/ variable:Variable { return { type: `variable`, ...variable, quoted: false } }
/ pattern:Glob { return { type: `glob`, pattern } }
/ text:PlainStringText { return { type: `text`, text } }
SglQuoteStringText
= chars:[^']* { return chars.join(``) }
DblQuoteStringText
= chars:( DblQuoteEscapedChar / [^$"])+ { return chars.join(``) }
DblQuoteEscapedChar
= '\\\n' { return `` }
/ '\\' c:[\\$"`] { return c }
CQuoteStringText
= chars:(CQuoteEscapedChar / [^'])* { return chars.join(``) }
CQuoteEscapedChar
= '\\a' { return '\a' }
/ '\\b' { return '\b' }
/ '\\' [Ee] { return '\x1b' }
/ '\\f' { return '\f' }
/ '\\n' { return '\n' }
/ '\\r' { return '\r' }
/ '\\t' { return '\t' }
/ '\\v' { return '\v' }
/ '\\' c:[\\'"?] { return c }
/ HexCodeString
HexCodeString
= '\\' c:HexCodeChar0 { return String.fromCharCode(parseInt(c, 16)) }
/ char:('\\x' c:$(HexCodeChar0 HexCodeChar / HexCodeChar0) { return String.fromCharCode(parseInt(c, 16)) })
/ utf8:('\\u' c:$(HexCodeChar HexCodeChar HexCodeChar HexCodeChar) { return String.fromCharCode(parseInt(c, 16)) })
/ utf16:('\\U' c:$(HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar) { return String.fromCodePoint(parseInt(c, 16)) })
HexCodeChar0
= [0-7]
HexCodeChar
= [0-9a-fA-f]
PlainStringText
= chars:('\\' c:. { return c } / '{}' { return '{}' } / !SpecialShellChars c:. { return c })+ { return chars.join(``) }
ArithmeticPrimary
= sign:('-' / '+')? left:[0-9]+ '.' right:[0-9]+ { return { type: `number`, value: (sign === '-' ? -1 : 1) * parseFloat(left.join(``) + `.` + right.join(``)) } }
/ sign:('-' / '+')? value:[0-9]+ { return { type: `number`, value: (sign === '-' ? -1 : 1) * parseInt(value.join(``)) } }
/ variable:Variable { return { type: `variable`, ...variable } }
/ name:Identifier { return { type: `variable`, name } }
/ '(' S* value:ArithmeticExpression S* ')' { return value }
ArithmeticTimesExpression
= left:ArithmeticPrimary rest:(S* op:('*' / '/') S* right:ArithmeticPrimary { return { type: op === `*` ? `multiplication` : `division`, right } })* {
return rest.reduce((left, right) => ({ left, ...right }), left)
}
ArithmeticExpression
= left:ArithmeticTimesExpression rest:(S* op:('+' / '-') S* right:ArithmeticTimesExpression { return { type: op === `+` ? `addition` : `subtraction`, right } })* {
return rest.reduce((left, right) => ({ left, ...right }), left)
}
Arithmetic
= '$((' S* arithmetic:ArithmeticExpression S* '))' { return arithmetic }
Subshell
= '$(' command:ShellLine ')' { return command }
Variable
= '${' name:Identifier ':-' arg:CommandString '}' { return { name, defaultValue: arg } }
/ '${' name:Identifier ':-}' { return { name, defaultValue: [] } }
/ '${' name:Identifier ':+' arg:CommandString '}' { return { name, alternativeValue: arg } }
/ '${' name:Identifier ':+}' { return { name, alternativeValue: [] } }
/ '${' name:Identifier '}' { return { name } }
/ '$' name:Identifier { return { name } }
Glob
= pattern:GlobText & { return options.isGlobPattern(pattern) } { return pattern }
GlobText
= chars:(!GlobSpecialShellChars c:. { return c })+ { return chars.join(``) }
EnvVariable
= [a-zA-Z0-9_]+ { return text() }
Identifier
= [$@*?#a-zA-Z0-9_-]+ { return text() }
SpecialShellChars
= [()}<>$|&; \t"']
GlobSpecialShellChars
= [<>&; \t"']
S = [ \t]+

1
node_modules/@yarnpkg/parsers/lib/grammars/syml.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare const parse: (code: string) => {[key: string]: any};

1911
node_modules/@yarnpkg/parsers/lib/grammars/syml.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

125
node_modules/@yarnpkg/parsers/lib/grammars/syml.pegjs generated vendored Normal file
View File

@@ -0,0 +1,125 @@
{
const INDENT_STEP = 2;
let indentLevel = 0;
}
Start
= PropertyStatements
ItemStatements
= statements:ItemStatement* { return [].concat(... statements) }
ItemStatement
= Samedent "-" B value:Expression { return value }
PropertyStatements
= statements:PropertyStatement* { return Object.assign({}, ... statements) }
PropertyStatement
= B? ("#" (!EOL .)+)? EOL_ANY+ { return {} }
/ Samedent property:Name B? ":" B? value:Expression { return {[property]: value} }
// Compatibility with the old lockfile format (key-values without a ":")
/ Samedent property:LegacyName B? ":" B? value:Expression { return {[property]: value} }
// Compatibility with the old lockfile format (key-values without a ":")
/ Samedent property:LegacyName B value:LegacyLiteral EOL_ANY+ { return {[property]: value} }
// Compatibility with the old lockfile format (multiple keys for a same value)
/ Samedent property:LegacyName others:(B? "," B? other:LegacyName { return other })+ B? ":" B? value:Expression { return Object.assign({}, ... [property].concat(others).map(property => ({[property]: value}))) }
Expression
= &(EOL Extradent "-" B) EOL_ANY Indent statements:ItemStatements Dedent { return statements }
/ EOL Indent statements:PropertyStatements Dedent { return statements }
/ expression:Literal EOL_ANY+ { return expression }
Samedent "correct indentation"
= spaces:" "* &{ return spaces.length === indentLevel * INDENT_STEP }
Extradent
= spaces:" "* &{ return spaces.length === (indentLevel + 1) * INDENT_STEP }
Indent
= &{ indentLevel++; return true }
Dedent
= &{ indentLevel--; return true }
Name
= string
/ pseudostring
LegacyName
= string
/ pseudostringLegacy+ { return text() }
Literal
= null
/ boolean
/ string
/ pseudostring
LegacyLiteral
= null
/ string
/ pseudostringLegacy
/**
*/
pseudostring "pseudostring"
= [^\r\n\t ?:,\][{}#&*!|>'"%@`-] (B? [^\r\n\t ,\][{}:#"'])* { return text().replace(/^ *| *$/g, '') }
pseudostringLegacy
= "--"? [a-zA-Z\/0-9] [^\r\n\t :,]* { return text().replace(/^ *| *$/g, '') }
/**
* String parsing
*/
null
= "null" { return null }
boolean
= "true" { return true }
/ "false" { return false }
string "string"
= '"' '"' { return "" }
/ '"' chars:chars '"' { return chars }
chars
= chars:char+ { return chars.join(``) }
char
= [^"\\\0-\x1F\x7f]
/ '\\"' { return `"` }
/ "\\\\" { return `\\` }
/ "\\/" { return `/` }
/ "\\b" { return `\b` }
/ "\\f" { return `\f` }
/ "\\n" { return `\n` }
/ "\\r" { return `\r` }
/ "\\t" { return `\t` }
/ "\\u" h1:hexDigit h2:hexDigit h3:hexDigit h4:hexDigit {
return String.fromCharCode(parseInt(`0x${h1}${h2}${h3}${h4}`));
}
hexDigit
= [0-9a-fA-F]
/**
* Spaces
*/
B "blank space"
= [ \t]+
S "white space"
= [ \t\n\r]+
EOL_ANY
= EOL (B? EOL)*
EOL
= "\r\n"
/ "\n"
/ "\r"

6
node_modules/@yarnpkg/parsers/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export type { ArgumentSegment, Argument, CommandChain, CommandLine, EnvSegment, ShellLine } from './grammars/shell';
export type { ArithmeticExpression, ArithmeticPrimary } from './grammars/shell';
export { parseShell, stringifyShell, stringifyArgument, stringifyArgumentSegment, stringifyArithmeticExpression, stringifyCommand, stringifyCommandChain, stringifyCommandChainThen, stringifyCommandLine, stringifyCommandLineThen, stringifyEnvSegment, stringifyRedirectArgument, stringifyShellLine, stringifyValueArgument, } from './shell';
export { parseResolution, stringifyResolution } from './resolution';
export type { Resolution } from './resolution';
export { parseSyml, stringifySyml } from './syml';

24
node_modules/@yarnpkg/parsers/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringifySyml = exports.parseSyml = exports.stringifyResolution = exports.parseResolution = exports.stringifyValueArgument = exports.stringifyShellLine = exports.stringifyRedirectArgument = exports.stringifyEnvSegment = exports.stringifyCommandLineThen = exports.stringifyCommandLine = exports.stringifyCommandChainThen = exports.stringifyCommandChain = exports.stringifyCommand = exports.stringifyArithmeticExpression = exports.stringifyArgumentSegment = exports.stringifyArgument = exports.stringifyShell = exports.parseShell = void 0;
var shell_1 = require("./shell");
Object.defineProperty(exports, "parseShell", { enumerable: true, get: function () { return shell_1.parseShell; } });
Object.defineProperty(exports, "stringifyShell", { enumerable: true, get: function () { return shell_1.stringifyShell; } });
Object.defineProperty(exports, "stringifyArgument", { enumerable: true, get: function () { return shell_1.stringifyArgument; } });
Object.defineProperty(exports, "stringifyArgumentSegment", { enumerable: true, get: function () { return shell_1.stringifyArgumentSegment; } });
Object.defineProperty(exports, "stringifyArithmeticExpression", { enumerable: true, get: function () { return shell_1.stringifyArithmeticExpression; } });
Object.defineProperty(exports, "stringifyCommand", { enumerable: true, get: function () { return shell_1.stringifyCommand; } });
Object.defineProperty(exports, "stringifyCommandChain", { enumerable: true, get: function () { return shell_1.stringifyCommandChain; } });
Object.defineProperty(exports, "stringifyCommandChainThen", { enumerable: true, get: function () { return shell_1.stringifyCommandChainThen; } });
Object.defineProperty(exports, "stringifyCommandLine", { enumerable: true, get: function () { return shell_1.stringifyCommandLine; } });
Object.defineProperty(exports, "stringifyCommandLineThen", { enumerable: true, get: function () { return shell_1.stringifyCommandLineThen; } });
Object.defineProperty(exports, "stringifyEnvSegment", { enumerable: true, get: function () { return shell_1.stringifyEnvSegment; } });
Object.defineProperty(exports, "stringifyRedirectArgument", { enumerable: true, get: function () { return shell_1.stringifyRedirectArgument; } });
Object.defineProperty(exports, "stringifyShellLine", { enumerable: true, get: function () { return shell_1.stringifyShellLine; } });
Object.defineProperty(exports, "stringifyValueArgument", { enumerable: true, get: function () { return shell_1.stringifyValueArgument; } });
var resolution_1 = require("./resolution");
Object.defineProperty(exports, "parseResolution", { enumerable: true, get: function () { return resolution_1.parseResolution; } });
Object.defineProperty(exports, "stringifyResolution", { enumerable: true, get: function () { return resolution_1.stringifyResolution; } });
var syml_1 = require("./syml");
Object.defineProperty(exports, "parseSyml", { enumerable: true, get: function () { return syml_1.parseSyml; } });
Object.defineProperty(exports, "stringifySyml", { enumerable: true, get: function () { return syml_1.stringifySyml; } });

12
node_modules/@yarnpkg/parsers/lib/resolution.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
export type Resolution = {
from?: {
fullName: string;
description?: string;
};
descriptor: {
fullName: string;
description?: string;
};
};
export declare function parseResolution(source: string): Resolution;
export declare function stringifyResolution(resolution: Resolution): string;

31
node_modules/@yarnpkg/parsers/lib/resolution.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseResolution = parseResolution;
exports.stringifyResolution = stringifyResolution;
const resolution_1 = require("./grammars/resolution");
function parseResolution(source) {
const legacyResolution = source.match(/^\*{1,2}\/(.*)/);
if (legacyResolution)
throw new Error(`The override for '${source}' includes a glob pattern. Glob patterns have been removed since their behaviours don't match what you'd expect. Set the override to '${legacyResolution[1]}' instead.`);
try {
return (0, resolution_1.parse)(source);
}
catch (error) {
if (error.location)
error.message = error.message.replace(/(\.)?$/, ` (line ${error.location.start.line}, column ${error.location.start.column})$1`);
throw error;
}
}
function stringifyResolution(resolution) {
let str = ``;
if (resolution.from) {
str += resolution.from.fullName;
if (resolution.from.description)
str += `@${resolution.from.description}`;
str += `/`;
}
str += resolution.descriptor.fullName;
if (resolution.descriptor.description)
str += `@${resolution.descriptor.description}`;
return str;
}

19
node_modules/@yarnpkg/parsers/lib/shell.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import { Argument, ArgumentSegment, ArithmeticExpression, Command, CommandChain, CommandChainThen, CommandLine, CommandLineThen, EnvSegment, RedirectArgument, ShellLine, ValueArgument } from './grammars/shell';
export declare function parseShell(source: string, options?: {
isGlobPattern: (arg: string) => boolean;
}): ShellLine;
export declare function stringifyShellLine(shellLine: ShellLine, { endSemicolon }?: {
endSemicolon?: boolean;
}): string;
export declare function stringifyCommandLine(commandLine: CommandLine): string;
export declare function stringifyCommandLineThen(commandLineThen: CommandLineThen): string;
export declare function stringifyCommandChain(commandChain: CommandChain): string;
export declare function stringifyCommandChainThen(commandChainThen: CommandChainThen): string;
export declare function stringifyCommand(command: Command): string;
export declare function stringifyEnvSegment(envSegment: EnvSegment): string;
export declare function stringifyArgument(argument: Argument): string;
export declare function stringifyRedirectArgument(argument: RedirectArgument): string;
export declare function stringifyValueArgument(argument: ValueArgument): string;
export declare function stringifyArgumentSegment(argumentSegment: ArgumentSegment): string;
export declare function stringifyArithmeticExpression(argument: ArithmeticExpression): string;
export { stringifyShellLine as stringifyShell };

171
node_modules/@yarnpkg/parsers/lib/shell.js generated vendored Normal file
View File

@@ -0,0 +1,171 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringifyShell = void 0;
exports.parseShell = parseShell;
exports.stringifyShellLine = stringifyShellLine;
exports.stringifyShell = stringifyShellLine;
exports.stringifyCommandLine = stringifyCommandLine;
exports.stringifyCommandLineThen = stringifyCommandLineThen;
exports.stringifyCommandChain = stringifyCommandChain;
exports.stringifyCommandChainThen = stringifyCommandChainThen;
exports.stringifyCommand = stringifyCommand;
exports.stringifyEnvSegment = stringifyEnvSegment;
exports.stringifyArgument = stringifyArgument;
exports.stringifyRedirectArgument = stringifyRedirectArgument;
exports.stringifyValueArgument = stringifyValueArgument;
exports.stringifyArgumentSegment = stringifyArgumentSegment;
exports.stringifyArithmeticExpression = stringifyArithmeticExpression;
const shell_1 = require("./grammars/shell");
function parseShell(source, options = { isGlobPattern: () => false }) {
try {
return (0, shell_1.parse)(source, options);
}
catch (error) {
if (error.location)
error.message = error.message.replace(/(\.)?$/, ` (line ${error.location.start.line}, column ${error.location.start.column})$1`);
throw error;
}
}
function stringifyShellLine(shellLine, { endSemicolon = false } = {}) {
return shellLine
.map(({ command, type }, index) => `${stringifyCommandLine(command)}${type === `;`
? (index !== shellLine.length - 1 || endSemicolon ? `;` : ``)
: ` &`}`)
.join(` `);
}
function stringifyCommandLine(commandLine) {
return `${stringifyCommandChain(commandLine.chain)}${commandLine.then ? ` ${stringifyCommandLineThen(commandLine.then)}` : ``}`;
}
function stringifyCommandLineThen(commandLineThen) {
return `${commandLineThen.type} ${stringifyCommandLine(commandLineThen.line)}`;
}
function stringifyCommandChain(commandChain) {
return `${stringifyCommand(commandChain)}${commandChain.then ? ` ${stringifyCommandChainThen(commandChain.then)}` : ``}`;
}
function stringifyCommandChainThen(commandChainThen) {
return `${commandChainThen.type} ${stringifyCommandChain(commandChainThen.chain)}`;
}
function stringifyCommand(command) {
switch (command.type) {
case `command`:
return `${command.envs.length > 0 ? `${command.envs.map(env => stringifyEnvSegment(env)).join(` `)} ` : ``}${command.args.map(argument => stringifyArgument(argument)).join(` `)}`;
case `subshell`:
return `(${stringifyShellLine(command.subshell)})${command.args.length > 0 ? ` ${command.args.map(argument => stringifyRedirectArgument(argument)).join(` `)}` : ``}`;
case `group`:
return `{ ${stringifyShellLine(command.group, { /* Bash compat */ endSemicolon: true })} }${command.args.length > 0 ? ` ${command.args.map(argument => stringifyRedirectArgument(argument)).join(` `)}` : ``}`;
case `envs`:
return command.envs.map(env => stringifyEnvSegment(env)).join(` `);
default:
throw new Error(`Unsupported command type: "${command.type}"`);
}
}
function stringifyEnvSegment(envSegment) {
return `${envSegment.name}=${envSegment.args[0] ? stringifyValueArgument(envSegment.args[0]) : ``}`;
}
function stringifyArgument(argument) {
switch (argument.type) {
case `redirection`:
return stringifyRedirectArgument(argument);
case `argument`:
return stringifyValueArgument(argument);
default:
throw new Error(`Unsupported argument type: "${argument.type}"`);
}
}
function stringifyRedirectArgument(argument) {
return `${argument.subtype} ${argument.args.map(argument => stringifyValueArgument(argument)).join(` `)}`;
}
function stringifyValueArgument(argument) {
return argument.segments.map(segment => stringifyArgumentSegment(segment)).join(``);
}
const ESCAPED_CONTROL_CHARS = new Map([
[`\f`, `\\f`],
[`\n`, `\\n`],
[`\r`, `\\r`],
[`\t`, `\\t`],
[`\v`, `\\v`],
[`\0`, `\\0`],
]);
const ESCAPED_DBL_CHARS = new Map([
[`\\`, `\\\\`],
[`$`, `\\$`],
[`"`, `\\"`],
...Array.from(ESCAPED_CONTROL_CHARS, ([c, replacement]) => {
return [c, `"$'${replacement}'"`];
}),
]);
const getEscapedControlChar = (c) => {
return ESCAPED_CONTROL_CHARS.get(c) ?? `\\x${c.charCodeAt(0).toString(16).padStart(2, `0`)}`;
};
const getEscapedDblChar = (match) => {
return ESCAPED_DBL_CHARS.get(match) ?? `"$'${getEscapedControlChar(match)}'"`;
};
function stringifyArgumentSegment(argumentSegment) {
const doubleQuoteIfRequested = (string, quote) => quote
? `"${string}"`
: string;
const quoteIfNeeded = (text) => {
if (text === ``)
return `''`;
if (!text.match(/[()}<>$|&;"'\n\t ]/))
return text;
if (!text.match(/['\t\p{C}]/u))
return `'${text}'`;
if (!text.match(/'/)) {
return `$'${text.replace(/[\t\p{C}]/u, getEscapedControlChar)}'`;
}
else {
return `"${text.replace(/["$\t\p{C}]/u, getEscapedDblChar)}"`;
}
};
switch (argumentSegment.type) {
case `text`:
return quoteIfNeeded(argumentSegment.text);
case `glob`:
return argumentSegment.pattern;
case `shell`:
return doubleQuoteIfRequested(`$(${stringifyShellLine(argumentSegment.shell)})`, argumentSegment.quoted);
case `variable`:
return doubleQuoteIfRequested(typeof argumentSegment.defaultValue === `undefined`
? typeof argumentSegment.alternativeValue === `undefined`
? `\${${argumentSegment.name}}`
: argumentSegment.alternativeValue.length === 0
? `\${${argumentSegment.name}:+}`
: `\${${argumentSegment.name}:+${argumentSegment.alternativeValue.map(argument => stringifyValueArgument(argument)).join(` `)}}`
: argumentSegment.defaultValue.length === 0
? `\${${argumentSegment.name}:-}`
: `\${${argumentSegment.name}:-${argumentSegment.defaultValue.map(argument => stringifyValueArgument(argument)).join(` `)}}`, argumentSegment.quoted);
case `arithmetic`:
return `$(( ${stringifyArithmeticExpression(argumentSegment.arithmetic)} ))`;
default:
throw new Error(`Unsupported argument segment type: "${argumentSegment.type}"`);
}
}
function stringifyArithmeticExpression(argument) {
const getOperator = (type) => {
switch (type) {
case `addition`:
return `+`;
case `subtraction`:
return `-`;
case `multiplication`:
return `*`;
case `division`:
return `/`;
default:
throw new Error(`Can't extract operator from arithmetic expression of type "${type}"`);
}
};
const parenthesizeIfRequested = (string, parenthesize) => parenthesize ? `( ${string} )` : string;
const stringifyAndParenthesizeIfNeeded = (expression) =>
// Right now we parenthesize all arithmetic operator expressions because it's easier
parenthesizeIfRequested(stringifyArithmeticExpression(expression), ![`number`, `variable`].includes(expression.type));
switch (argument.type) {
case `number`:
return String(argument.value);
case `variable`:
return argument.name;
default:
return `${stringifyAndParenthesizeIfNeeded(argument.left)} ${getOperator(argument.type)} ${stringifyAndParenthesizeIfNeeded(argument.right)}`;
}
}

11
node_modules/@yarnpkg/parsers/lib/syml.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export declare class PreserveOrdering {
readonly data: any;
constructor(data: any);
}
export declare function stringifySyml(value: any): string;
export declare namespace stringifySyml {
var PreserveOrdering: typeof import("./syml").PreserveOrdering;
}
export declare function parseSyml(source: string): {
[key: string]: any;
};

132
node_modules/@yarnpkg/parsers/lib/syml.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreserveOrdering = void 0;
exports.stringifySyml = stringifySyml;
exports.parseSyml = parseSyml;
const js_yaml_1 = require("js-yaml");
const syml_1 = require("./grammars/syml");
const simpleStringPattern = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
// The following keys will always be stored at the top of the object, in the
// specified order. It's not fair but life isn't fair either.
const specialObjectKeys = [`__metadata`, `version`, `resolution`, `dependencies`, `peerDependencies`, `dependenciesMeta`, `peerDependenciesMeta`, `binaries`];
class PreserveOrdering {
constructor(data) {
this.data = data;
}
}
exports.PreserveOrdering = PreserveOrdering;
function stringifyString(value) {
if (value.match(simpleStringPattern)) {
return value;
}
else {
return JSON.stringify(value);
}
}
function isRemovableField(value) {
if (typeof value === `undefined`)
return true;
if (typeof value === `object` && value !== null && !Array.isArray(value))
return Object.keys(value).every(key => isRemovableField(value[key]));
return false;
}
function stringifyValue(value, indentLevel, newLineIfObject) {
if (value === null)
return `null\n`;
if (typeof value === `number` || typeof value === `boolean`)
return `${value.toString()}\n`;
if (typeof value === `string`)
return `${stringifyString(value)}\n`;
if (Array.isArray(value)) {
if (value.length === 0)
return `[]\n`;
const indent = ` `.repeat(indentLevel);
const serialized = value.map(sub => {
return `${indent}- ${stringifyValue(sub, indentLevel + 1, false)}`;
}).join(``);
return `\n${serialized}`;
}
if (typeof value === `object` && value) {
const [data, sort] = value instanceof PreserveOrdering
? [value.data, false]
: [value, true];
const indent = ` `.repeat(indentLevel);
const keys = Object.keys(data);
if (sort) {
keys.sort((a, b) => {
const aIndex = specialObjectKeys.indexOf(a);
const bIndex = specialObjectKeys.indexOf(b);
if (aIndex === -1 && bIndex === -1)
return a < b ? -1 : a > b ? +1 : 0;
if (aIndex !== -1 && bIndex === -1)
return -1;
if (aIndex === -1 && bIndex !== -1)
return +1;
return aIndex - bIndex;
});
}
const fields = keys.filter(key => {
return !isRemovableField(data[key]);
}).map((key, index) => {
const value = data[key];
const stringifiedKey = stringifyString(key);
const stringifiedValue = stringifyValue(value, indentLevel + 1, true);
const recordIndentation = index > 0 || newLineIfObject
? indent
: ``;
// Yaml 1.2 spec says that keys over 1024 characters need to be prefixed with ? and the : goes in a new line
const keyPart = stringifiedKey.length > 1024
? `? ${stringifiedKey}\n${recordIndentation}:`
: `${stringifiedKey}:`;
const valuePart = stringifiedValue.startsWith(`\n`)
? stringifiedValue
: ` ${stringifiedValue}`;
return `${recordIndentation}${keyPart}${valuePart}`;
}).join(indentLevel === 0 ? `\n` : ``) || `\n`;
if (!newLineIfObject) {
return `${fields}`;
}
else {
return `\n${fields}`;
}
}
throw new Error(`Unsupported value type (${value})`);
}
function stringifySyml(value) {
try {
const stringified = stringifyValue(value, 0, false);
return stringified !== `\n` ? stringified : ``;
}
catch (error) {
if (error.location)
error.message = error.message.replace(/(\.)?$/, ` (line ${error.location.start.line}, column ${error.location.start.column})$1`);
throw error;
}
}
stringifySyml.PreserveOrdering = PreserveOrdering;
function parseViaPeg(source) {
if (!source.endsWith(`\n`))
source += `\n`;
return (0, syml_1.parse)(source);
}
const LEGACY_REGEXP = /^(#.*(\r?\n))*?#\s+yarn\s+lockfile\s+v1\r?\n/i;
function parseViaJsYaml(source) {
if (LEGACY_REGEXP.test(source))
return parseViaPeg(source);
const value = (0, js_yaml_1.safeLoad)(source, {
schema: js_yaml_1.FAILSAFE_SCHEMA,
json: true,
});
// Empty files are parsed as `undefined` instead of an empty object
// Empty files with 2 newlines or more are `null` instead
if (value === undefined || value === null)
return {};
if (typeof value !== `object`)
throw new Error(`Expected an indexed object, got a ${typeof value} instead. Does your file follow Yaml's rules?`);
if (Array.isArray(value))
throw new Error(`Expected an indexed object, got an array instead. Does your file follow Yaml's rules?`);
return value;
}
function parseSyml(source) {
return parseViaJsYaml(source);
}