diff --git a/dist/index.cjs b/dist/index.cjs index 96691a2..4db0dd0 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -22712,168 +22712,827 @@ var require_github = __commonJS((exports2) => { exports2.getOctokit = getOctokit; }); -// node_modules/jsonc-parser/lib/umd/main.js -var require_main2 = __commonJS((exports2, module2) => { - (function(factory) { - if (typeof module2 === "object" && typeof module2.exports === "object") { - var v = factory(require, exports2); - if (v !== undefined) - module2.exports = v; - } else if (typeof define === "function" && define.amd) { - define(["require", "exports", "./impl/format", "./impl/edit", "./impl/scanner", "./impl/parser"], factory); - } - })(function(require2, exports3) { - Object.defineProperty(exports3, "__esModule", { value: true }); - exports3.applyEdits = exports3.modify = exports3.format = exports3.printParseErrorCode = exports3.ParseErrorCode = exports3.stripComments = exports3.visit = exports3.getNodeValue = exports3.getNodePath = exports3.findNodeAtOffset = exports3.findNodeAtLocation = exports3.parseTree = exports3.parse = exports3.getLocation = exports3.SyntaxKind = exports3.ScanError = exports3.createScanner = undefined; - const formatter = require2("./impl/format"); - const edit = require2("./impl/edit"); - const scanner = require2("./impl/scanner"); - const parser = require2("./impl/parser"); - exports3.createScanner = scanner.createScanner; - var ScanError; - (function(ScanError2) { - ScanError2[ScanError2["None"] = 0] = "None"; - ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment"; - ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString"; - ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber"; - ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode"; - ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter"; - ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter"; - })(ScanError || (exports3.ScanError = ScanError = {})); - var SyntaxKind; - (function(SyntaxKind2) { - SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken"; - SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken"; - SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken"; - SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken"; - SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken"; - SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken"; - SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword"; - SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword"; - SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword"; - SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral"; - SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral"; - SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia"; - SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia"; - SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia"; - SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia"; - SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown"; - SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF"; - })(SyntaxKind || (exports3.SyntaxKind = SyntaxKind = {})); - exports3.getLocation = parser.getLocation; - exports3.parse = parser.parse; - exports3.parseTree = parser.parseTree; - exports3.findNodeAtLocation = parser.findNodeAtLocation; - exports3.findNodeAtOffset = parser.findNodeAtOffset; - exports3.getNodePath = parser.getNodePath; - exports3.getNodeValue = parser.getNodeValue; - exports3.visit = parser.visit; - exports3.stripComments = parser.stripComments; - var ParseErrorCode; - (function(ParseErrorCode2) { - ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol"; - ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat"; - ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected"; - ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected"; - ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected"; - ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected"; - ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected"; - ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected"; - ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected"; - ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken"; - ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment"; - ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString"; - ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber"; - ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode"; - ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter"; - ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter"; - })(ParseErrorCode || (exports3.ParseErrorCode = ParseErrorCode = {})); - function printParseErrorCode(code) { - switch (code) { - case 1: - return "InvalidSymbol"; - case 2: - return "InvalidNumberFormat"; - case 3: - return "PropertyNameExpected"; +// src/main.ts +var core9 = __toESM(require_core(), 1); + +// src/deploy.ts +var import_node_fs3 = require("node:fs"); +var core6 = __toESM(require_core(), 1); +var github2 = __toESM(require_github(), 1); + +// src/cloudflare.ts +var core2 = __toESM(require_core(), 1); + +// src/config.ts +var import_node_fs = require("node:fs"); + +// node_modules/jsonc-parser/lib/esm/impl/scanner.js +function createScanner(text, ignoreTrivia = false) { + const len = text.length; + let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0; + function scanHexDigits(count, exact) { + let digits = 0; + let value2 = 0; + while (digits < count || !exact) { + let ch = text.charCodeAt(pos); + if (ch >= 48 && ch <= 57) { + value2 = value2 * 16 + ch - 48; + } else if (ch >= 65 && ch <= 70) { + value2 = value2 * 16 + ch - 65 + 10; + } else if (ch >= 97 && ch <= 102) { + value2 = value2 * 16 + ch - 97 + 10; + } else { + break; + } + pos++; + digits++; + } + if (digits < count) { + value2 = -1; + } + return value2; + } + function setPosition(newPosition) { + pos = newPosition; + value = ""; + tokenOffset = 0; + token = 16; + scanError = 0; + } + function scanNumber() { + let start = pos; + if (text.charCodeAt(pos) === 48) { + pos++; + } else { + pos++; + while (pos < text.length && isDigit(text.charCodeAt(pos))) { + pos++; + } + } + if (pos < text.length && text.charCodeAt(pos) === 46) { + pos++; + if (pos < text.length && isDigit(text.charCodeAt(pos))) { + pos++; + while (pos < text.length && isDigit(text.charCodeAt(pos))) { + pos++; + } + } else { + scanError = 3; + return text.substring(start, pos); + } + } + let end = pos; + if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) { + pos++; + if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) { + pos++; + } + if (pos < text.length && isDigit(text.charCodeAt(pos))) { + pos++; + while (pos < text.length && isDigit(text.charCodeAt(pos))) { + pos++; + } + end = pos; + } else { + scanError = 3; + } + } + return text.substring(start, end); + } + function scanString() { + let result = "", start = pos; + while (true) { + if (pos >= len) { + result += text.substring(start, pos); + scanError = 2; + break; + } + const ch = text.charCodeAt(pos); + if (ch === 34) { + result += text.substring(start, pos); + pos++; + break; + } + if (ch === 92) { + result += text.substring(start, pos); + pos++; + if (pos >= len) { + scanError = 2; + break; + } + const ch2 = text.charCodeAt(pos++); + switch (ch2) { + case 34: + result += '"'; + break; + case 92: + result += "\\"; + break; + case 47: + result += "/"; + break; + case 98: + result += "\b"; + break; + case 102: + result += "\f"; + break; + case 110: + result += ` +`; + break; + case 114: + result += "\r"; + break; + case 116: + result += "\t"; + break; + case 117: + const ch3 = scanHexDigits(4, true); + if (ch3 >= 0) { + result += String.fromCharCode(ch3); + } else { + scanError = 4; + } + break; + default: + scanError = 5; + } + start = pos; + continue; + } + if (ch >= 0 && ch <= 31) { + if (isLineBreak(ch)) { + result += text.substring(start, pos); + scanError = 2; + break; + } else { + scanError = 6; + } + } + pos++; + } + return result; + } + function scanNext() { + value = ""; + scanError = 0; + tokenOffset = pos; + lineStartOffset = lineNumber; + prevTokenLineStartOffset = tokenLineStartOffset; + if (pos >= len) { + tokenOffset = len; + return token = 17; + } + let code = text.charCodeAt(pos); + if (isWhiteSpace(code)) { + do { + pos++; + value += String.fromCharCode(code); + code = text.charCodeAt(pos); + } while (isWhiteSpace(code)); + return token = 15; + } + if (isLineBreak(code)) { + pos++; + value += String.fromCharCode(code); + if (code === 13 && text.charCodeAt(pos) === 10) { + pos++; + value += ` +`; + } + lineNumber++; + tokenLineStartOffset = pos; + return token = 14; + } + switch (code) { + case 123: + pos++; + return token = 1; + case 125: + pos++; + return token = 2; + case 91: + pos++; + return token = 3; + case 93: + pos++; + return token = 4; + case 58: + pos++; + return token = 6; + case 44: + pos++; + return token = 5; + case 34: + pos++; + value = scanString(); + return token = 10; + case 47: + const start = pos - 1; + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < len) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + value = text.substring(start, pos); + return token = 12; + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + const safeLength = len - 1; + let commentClosed = false; + while (pos < safeLength) { + const ch = text.charCodeAt(pos); + if (ch === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + commentClosed = true; + break; + } + pos++; + if (isLineBreak(ch)) { + if (ch === 13 && text.charCodeAt(pos) === 10) { + pos++; + } + lineNumber++; + tokenLineStartOffset = pos; + } + } + if (!commentClosed) { + pos++; + scanError = 1; + } + value = text.substring(start, pos); + return token = 13; + } + value += String.fromCharCode(code); + pos++; + return token = 16; + case 45: + value += String.fromCharCode(code); + pos++; + if (pos === len || !isDigit(text.charCodeAt(pos))) { + return token = 16; + } + case 48: + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + value += scanNumber(); + return token = 11; + default: + while (pos < len && isUnknownContentCharacter(code)) { + pos++; + code = text.charCodeAt(pos); + } + if (tokenOffset !== pos) { + value = text.substring(tokenOffset, pos); + switch (value) { + case "true": + return token = 8; + case "false": + return token = 9; + case "null": + return token = 7; + } + return token = 16; + } + value += String.fromCharCode(code); + pos++; + return token = 16; + } + } + function isUnknownContentCharacter(code) { + if (isWhiteSpace(code) || isLineBreak(code)) { + return false; + } + switch (code) { + case 125: + case 93: + case 123: + case 91: + case 34: + case 58: + case 44: + case 47: + return false; + } + return true; + } + function scanNextNonTrivia() { + let result; + do { + result = scanNext(); + } while (result >= 12 && result <= 15); + return result; + } + return { + setPosition, + getPosition: () => pos, + scan: ignoreTrivia ? scanNextNonTrivia : scanNext, + getToken: () => token, + getTokenValue: () => value, + getTokenOffset: () => tokenOffset, + getTokenLength: () => pos - tokenOffset, + getTokenStartLine: () => lineStartOffset, + getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset, + getTokenError: () => scanError + }; +} +function isWhiteSpace(ch) { + return ch === 32 || ch === 9; +} +function isLineBreak(ch) { + return ch === 10 || ch === 13; +} +function isDigit(ch) { + return ch >= 48 && ch <= 57; +} +var CharacterCodes; +(function(CharacterCodes2) { + CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed"; + CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes2[CharacterCodes2["space"] = 32] = "space"; + CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0"; + CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1"; + CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2"; + CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3"; + CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4"; + CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5"; + CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6"; + CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7"; + CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8"; + CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9"; + CharacterCodes2[CharacterCodes2["a"] = 97] = "a"; + CharacterCodes2[CharacterCodes2["b"] = 98] = "b"; + CharacterCodes2[CharacterCodes2["c"] = 99] = "c"; + CharacterCodes2[CharacterCodes2["d"] = 100] = "d"; + CharacterCodes2[CharacterCodes2["e"] = 101] = "e"; + CharacterCodes2[CharacterCodes2["f"] = 102] = "f"; + CharacterCodes2[CharacterCodes2["g"] = 103] = "g"; + CharacterCodes2[CharacterCodes2["h"] = 104] = "h"; + CharacterCodes2[CharacterCodes2["i"] = 105] = "i"; + CharacterCodes2[CharacterCodes2["j"] = 106] = "j"; + CharacterCodes2[CharacterCodes2["k"] = 107] = "k"; + CharacterCodes2[CharacterCodes2["l"] = 108] = "l"; + CharacterCodes2[CharacterCodes2["m"] = 109] = "m"; + CharacterCodes2[CharacterCodes2["n"] = 110] = "n"; + CharacterCodes2[CharacterCodes2["o"] = 111] = "o"; + CharacterCodes2[CharacterCodes2["p"] = 112] = "p"; + CharacterCodes2[CharacterCodes2["q"] = 113] = "q"; + CharacterCodes2[CharacterCodes2["r"] = 114] = "r"; + CharacterCodes2[CharacterCodes2["s"] = 115] = "s"; + CharacterCodes2[CharacterCodes2["t"] = 116] = "t"; + CharacterCodes2[CharacterCodes2["u"] = 117] = "u"; + CharacterCodes2[CharacterCodes2["v"] = 118] = "v"; + CharacterCodes2[CharacterCodes2["w"] = 119] = "w"; + CharacterCodes2[CharacterCodes2["x"] = 120] = "x"; + CharacterCodes2[CharacterCodes2["y"] = 121] = "y"; + CharacterCodes2[CharacterCodes2["z"] = 122] = "z"; + CharacterCodes2[CharacterCodes2["A"] = 65] = "A"; + CharacterCodes2[CharacterCodes2["B"] = 66] = "B"; + CharacterCodes2[CharacterCodes2["C"] = 67] = "C"; + CharacterCodes2[CharacterCodes2["D"] = 68] = "D"; + CharacterCodes2[CharacterCodes2["E"] = 69] = "E"; + CharacterCodes2[CharacterCodes2["F"] = 70] = "F"; + CharacterCodes2[CharacterCodes2["G"] = 71] = "G"; + CharacterCodes2[CharacterCodes2["H"] = 72] = "H"; + CharacterCodes2[CharacterCodes2["I"] = 73] = "I"; + CharacterCodes2[CharacterCodes2["J"] = 74] = "J"; + CharacterCodes2[CharacterCodes2["K"] = 75] = "K"; + CharacterCodes2[CharacterCodes2["L"] = 76] = "L"; + CharacterCodes2[CharacterCodes2["M"] = 77] = "M"; + CharacterCodes2[CharacterCodes2["N"] = 78] = "N"; + CharacterCodes2[CharacterCodes2["O"] = 79] = "O"; + CharacterCodes2[CharacterCodes2["P"] = 80] = "P"; + CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q"; + CharacterCodes2[CharacterCodes2["R"] = 82] = "R"; + CharacterCodes2[CharacterCodes2["S"] = 83] = "S"; + CharacterCodes2[CharacterCodes2["T"] = 84] = "T"; + CharacterCodes2[CharacterCodes2["U"] = 85] = "U"; + CharacterCodes2[CharacterCodes2["V"] = 86] = "V"; + CharacterCodes2[CharacterCodes2["W"] = 87] = "W"; + CharacterCodes2[CharacterCodes2["X"] = 88] = "X"; + CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y"; + CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z"; + CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk"; + CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash"; + CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace"; + CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket"; + CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon"; + CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma"; + CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot"; + CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus"; + CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace"; + CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket"; + CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus"; + CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash"; + CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed"; + CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab"; +})(CharacterCodes || (CharacterCodes = {})); + +// node_modules/jsonc-parser/lib/esm/impl/string-intern.js +var cachedSpaces = new Array(20).fill(0).map((_, index) => { + return " ".repeat(index); +}); +var maxCachedValues = 200; +var cachedBreakLinesWithSpaces = { + " ": { + "\n": new Array(maxCachedValues).fill(0).map((_, index) => { + return ` +` + " ".repeat(index); + }), + "\r": new Array(maxCachedValues).fill(0).map((_, index) => { + return "\r" + " ".repeat(index); + }), + "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => { + return `\r +` + " ".repeat(index); + }) + }, + "\t": { + "\n": new Array(maxCachedValues).fill(0).map((_, index) => { + return ` +` + "\t".repeat(index); + }), + "\r": new Array(maxCachedValues).fill(0).map((_, index) => { + return "\r" + "\t".repeat(index); + }), + "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => { + return `\r +` + "\t".repeat(index); + }) + } +}; + +// node_modules/jsonc-parser/lib/esm/impl/parser.js +var ParseOptions; +(function(ParseOptions2) { + ParseOptions2.DEFAULT = { + allowTrailingComma: false + }; +})(ParseOptions || (ParseOptions = {})); +function parse(text, errors = [], options = ParseOptions.DEFAULT) { + let currentProperty = null; + let currentParent = []; + const previousParents = []; + function onValue(value) { + if (Array.isArray(currentParent)) { + currentParent.push(value); + } else if (currentProperty !== null) { + currentParent[currentProperty] = value; + } + } + const visitor = { + onObjectBegin: () => { + const object = {}; + onValue(object); + previousParents.push(currentParent); + currentParent = object; + currentProperty = null; + }, + onObjectProperty: (name) => { + currentProperty = name; + }, + onObjectEnd: () => { + currentParent = previousParents.pop(); + }, + onArrayBegin: () => { + const array = []; + onValue(array); + previousParents.push(currentParent); + currentParent = array; + currentProperty = null; + }, + onArrayEnd: () => { + currentParent = previousParents.pop(); + }, + onLiteralValue: onValue, + onError: (error, offset, length) => { + errors.push({ error, offset, length }); + } + }; + visit(text, visitor, options); + return currentParent[0]; +} +function visit(text, visitor, options = ParseOptions.DEFAULT) { + const _scanner = createScanner(text, false); + const _jsonPath = []; + let suppressedCallbacks = 0; + function toNoArgVisit(visitFunction) { + return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true; + } + function toOneArgVisit(visitFunction) { + return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true; + } + function toOneArgVisitWithPath(visitFunction) { + return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true; + } + function toBeginVisit(visitFunction) { + return visitFunction ? () => { + if (suppressedCallbacks > 0) { + suppressedCallbacks++; + } else { + let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()); + if (cbReturn === false) { + suppressedCallbacks = 1; + } + } + } : () => true; + } + function toEndVisit(visitFunction) { + return visitFunction ? () => { + if (suppressedCallbacks > 0) { + suppressedCallbacks--; + } + if (suppressedCallbacks === 0) { + visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()); + } + } : () => true; + } + const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError); + const disallowComments = options && options.disallowComments; + const allowTrailingComma = options && options.allowTrailingComma; + function scanNext() { + while (true) { + const token = _scanner.scan(); + switch (_scanner.getTokenError()) { case 4: - return "ValueExpected"; + handleError(14); + break; case 5: - return "ColonExpected"; + handleError(15); + break; + case 3: + handleError(13); + break; + case 1: + if (!disallowComments) { + handleError(11); + } + break; + case 2: + handleError(12); + break; case 6: - return "CommaExpected"; - case 7: - return "CloseBraceExpected"; - case 8: - return "CloseBracketExpected"; - case 9: - return "EndOfFileExpected"; - case 10: - return "InvalidCommentToken"; - case 11: - return "UnexpectedEndOfComment"; + handleError(16); + break; + } + switch (token) { case 12: - return "UnexpectedEndOfString"; case 13: - return "UnexpectedEndOfNumber"; - case 14: - return "InvalidUnicode"; - case 15: - return "InvalidEscapeCharacter"; + if (disallowComments) { + handleError(10); + } else { + onComment(); + } + break; case 16: - return "InvalidCharacter"; + handleError(1); + break; + case 15: + case 14: + break; + default: + return token; } - return ""; } - exports3.printParseErrorCode = printParseErrorCode; - function format(documentText, range, options) { - return formatter.format(documentText, range, options); + } + function handleError(error, skipUntilAfter = [], skipUntil = []) { + onError(error); + if (skipUntilAfter.length + skipUntil.length > 0) { + let token = _scanner.getToken(); + while (token !== 17) { + if (skipUntilAfter.indexOf(token) !== -1) { + scanNext(); + break; + } else if (skipUntil.indexOf(token) !== -1) { + break; + } + token = scanNext(); + } } - exports3.format = format; - function modify(text, path, value, options) { - return edit.setProperty(text, path, value, options); + } + function parseString(isValue) { + const value = _scanner.getTokenValue(); + if (isValue) { + onLiteralValue(value); + } else { + onObjectProperty(value); + _jsonPath.push(value); } - exports3.modify = modify; - function applyEdits(text, edits) { - let sortedEdits = edits.slice(0).sort((a, b) => { - const diff = a.offset - b.offset; - if (diff === 0) { - return a.length - b.length; + scanNext(); + return true; + } + function parseLiteral() { + switch (_scanner.getToken()) { + case 11: + const tokenValue = _scanner.getTokenValue(); + let value = Number(tokenValue); + if (isNaN(value)) { + handleError(2); + value = 0; } - return diff; - }); - let lastModifiedOffset = text.length; - for (let i = sortedEdits.length - 1;i >= 0; i--) { - let e = sortedEdits[i]; - if (e.offset + e.length <= lastModifiedOffset) { - text = edit.applyEdit(text, e); - } else { - throw new Error("Overlapping edit"); + onLiteralValue(value); + break; + case 7: + onLiteralValue(null); + break; + case 8: + onLiteralValue(true); + break; + case 9: + onLiteralValue(false); + break; + default: + return false; + } + scanNext(); + return true; + } + function parseProperty() { + if (_scanner.getToken() !== 10) { + handleError(3, [], [2, 5]); + return false; + } + parseString(false); + if (_scanner.getToken() === 6) { + onSeparator(":"); + scanNext(); + if (!parseValue()) { + handleError(4, [], [2, 5]); + } + } else { + handleError(5, [], [2, 5]); + } + _jsonPath.pop(); + return true; + } + function parseObject() { + onObjectBegin(); + scanNext(); + let needsComma = false; + while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) { + if (_scanner.getToken() === 5) { + if (!needsComma) { + handleError(4, [], []); + } + onSeparator(","); + scanNext(); + if (_scanner.getToken() === 2 && allowTrailingComma) { + break; } - lastModifiedOffset = e.offset; + } else if (needsComma) { + handleError(6, [], []); + } + if (!parseProperty()) { + handleError(4, [], [2, 5]); } - return text; + needsComma = true; } - exports3.applyEdits = applyEdits; - }); -}); - -// src/main.ts -var core9 = __toESM(require_core(), 1); - -// src/deploy.ts -var import_node_fs3 = require("node:fs"); -var core6 = __toESM(require_core(), 1); -var github2 = __toESM(require_github(), 1); + onObjectEnd(); + if (_scanner.getToken() !== 2) { + handleError(7, [2], []); + } else { + scanNext(); + } + return true; + } + function parseArray() { + onArrayBegin(); + scanNext(); + let isFirstElement = true; + let needsComma = false; + while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) { + if (_scanner.getToken() === 5) { + if (!needsComma) { + handleError(4, [], []); + } + onSeparator(","); + scanNext(); + if (_scanner.getToken() === 4 && allowTrailingComma) { + break; + } + } else if (needsComma) { + handleError(6, [], []); + } + if (isFirstElement) { + _jsonPath.push(0); + isFirstElement = false; + } else { + _jsonPath[_jsonPath.length - 1]++; + } + if (!parseValue()) { + handleError(4, [], [4, 5]); + } + needsComma = true; + } + onArrayEnd(); + if (!isFirstElement) { + _jsonPath.pop(); + } + if (_scanner.getToken() !== 4) { + handleError(8, [4], []); + } else { + scanNext(); + } + return true; + } + function parseValue() { + switch (_scanner.getToken()) { + case 3: + return parseArray(); + case 1: + return parseObject(); + case 10: + return parseString(true); + default: + return parseLiteral(); + } + } + scanNext(); + if (_scanner.getToken() === 17) { + if (options.allowEmptyContent) { + return true; + } + handleError(4, [], []); + return false; + } + if (!parseValue()) { + handleError(4, [], []); + return false; + } + if (_scanner.getToken() !== 17) { + handleError(9, [], []); + } + return true; +} -// src/cloudflare.ts -var core2 = __toESM(require_core(), 1); +// node_modules/jsonc-parser/lib/esm/main.js +var ScanError; +(function(ScanError2) { + ScanError2[ScanError2["None"] = 0] = "None"; + ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment"; + ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString"; + ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber"; + ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode"; + ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter"; + ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter"; +})(ScanError || (ScanError = {})); +var SyntaxKind; +(function(SyntaxKind2) { + SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken"; + SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken"; + SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken"; + SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken"; + SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken"; + SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken"; + SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword"; + SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword"; + SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword"; + SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral"; + SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral"; + SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia"; + SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia"; + SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia"; + SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia"; + SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown"; + SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF"; +})(SyntaxKind || (SyntaxKind = {})); +var parse2 = parse; +var ParseErrorCode; +(function(ParseErrorCode2) { + ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol"; + ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat"; + ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected"; + ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected"; + ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected"; + ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected"; + ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected"; + ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected"; + ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected"; + ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken"; + ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment"; + ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString"; + ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber"; + ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode"; + ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter"; + ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter"; +})(ParseErrorCode || (ParseErrorCode = {})); // src/config.ts -var import_node_fs = require("node:fs"); -var import_jsonc_parser = __toESM(require_main2(), 1); function parseJsonc(text) { - return import_jsonc_parser.parse(text, [], { allowTrailingComma: true }); + return parse2(text, [], { allowTrailingComma: true }); } function readConfig(path) { return parseJsonc(import_node_fs.readFileSync(path, "utf8")); diff --git a/src/config.ts b/src/config.ts index dcaa24c..2a19c59 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ import { readFileSync } from 'node:fs' -import { parse } from 'jsonc-parser' +import { parse } from 'jsonc-parser/lib/esm/main.js' export function parseJsonc(text: string): any { return parse(text, [], { allowTrailingComma: true })