@sanity/plugin-kit 3.1.11 → 3.1.13-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/inject/semver-workflow/.github/workflows/main.yml +6 -6
- package/dist/_chunks-cjs/cli.js +135 -0
- package/dist/_chunks-cjs/cli.js.map +1 -0
- package/dist/_chunks-cjs/init.js +894 -0
- package/dist/_chunks-cjs/init.js.map +1 -0
- package/dist/_chunks-cjs/init2.js +83 -0
- package/dist/_chunks-cjs/init2.js.map +1 -0
- package/dist/_chunks-cjs/inject.js +54 -0
- package/dist/_chunks-cjs/inject.js.map +1 -0
- package/dist/_chunks-cjs/link-watch.js +84 -0
- package/dist/_chunks-cjs/link-watch.js.map +1 -0
- package/dist/_chunks-cjs/package.js +1808 -0
- package/dist/_chunks-cjs/package.js.map +1 -0
- package/dist/_chunks-cjs/package2.js +143 -0
- package/dist/_chunks-cjs/package2.js.map +1 -0
- package/dist/_chunks-cjs/ts.js +162 -0
- package/dist/_chunks-cjs/ts.js.map +1 -0
- package/dist/_chunks-cjs/verify-package.js +75 -0
- package/dist/_chunks-cjs/verify-package.js.map +1 -0
- package/dist/_chunks-cjs/verify-studio.js +57 -0
- package/dist/_chunks-cjs/verify-studio.js.map +1 -0
- package/dist/_chunks-cjs/version.js +51 -0
- package/dist/_chunks-cjs/version.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +4 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +57 -59
- package/src/actions/inject.ts +1 -1
- package/src/actions/verify/types.ts +0 -1
- package/src/actions/verify/validations.ts +13 -69
- package/src/actions/verify/verify-common.ts +0 -1
- package/src/actions/verify-package.ts +0 -2
- package/src/cli.ts +1 -0
- package/src/configs/forced-package-versions.ts +0 -1
- package/src/configs/pkg-config.ts +0 -1
- package/src/configs/tsconfig.ts +20 -21
- package/src/npm/package.ts +6 -17
- package/src/presets/ui.ts +0 -1
- package/dist/_chunks/cli-Wd1KIVDi.js +0 -168
- package/dist/_chunks/cli-Wd1KIVDi.js.map +0 -1
- package/dist/_chunks/init-5h0qT4Si.js +0 -966
- package/dist/_chunks/init-5h0qT4Si.js.map +0 -1
- package/dist/_chunks/init-7PO3ckQZ.js +0 -104
- package/dist/_chunks/init-7PO3ckQZ.js.map +0 -1
- package/dist/_chunks/inject-dEkit_VE.js +0 -49
- package/dist/_chunks/inject-dEkit_VE.js.map +0 -1
- package/dist/_chunks/link-watch-gjJZIMKf.js +0 -91
- package/dist/_chunks/link-watch-gjJZIMKf.js.map +0 -1
- package/dist/_chunks/package-esTAlA-W.js +0 -155
- package/dist/_chunks/package-esTAlA-W.js.map +0 -1
- package/dist/_chunks/package-yXL1pPXe.js +0 -2358
- package/dist/_chunks/package-yXL1pPXe.js.map +0 -1
- package/dist/_chunks/ts-DjETsLGv.js +0 -165
- package/dist/_chunks/ts-DjETsLGv.js.map +0 -1
- package/dist/_chunks/verify-package-8RX50rZW.js +0 -97
- package/dist/_chunks/verify-package-8RX50rZW.js.map +0 -1
- package/dist/_chunks/verify-studio-ybZTH8nM.js +0 -74
- package/dist/_chunks/verify-studio-ybZTH8nM.js.map +0 -1
- package/dist/_chunks/version-VsJ55gag.js +0 -54
- package/dist/_chunks/version-VsJ55gag.js.map +0 -1
|
@@ -1,2358 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20;
|
|
4
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
5
|
-
var fs = require('fs');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var util$1 = require('util');
|
|
8
|
-
var githubUrlToObject = require('github-url-to-object');
|
|
9
|
-
var validateNpmPackageName = require('validate-npm-package-name');
|
|
10
|
-
var _package = require('./package-esTAlA-W.js');
|
|
11
|
-
var pAny = require('p-any');
|
|
12
|
-
var crypto = require('crypto');
|
|
13
|
-
var url = require('url');
|
|
14
|
-
var inquirer = require('inquirer');
|
|
15
|
-
var cli = require('./cli-Wd1KIVDi.js');
|
|
16
|
-
var pProps = require('p-props');
|
|
17
|
-
var getLatestVersion = require('get-latest-version');
|
|
18
|
-
var outdent = require('outdent');
|
|
19
|
-
var chalk = require('chalk');
|
|
20
|
-
function _interopDefaultCompat(e) {
|
|
21
|
-
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
22
|
-
default: e
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
26
|
-
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
27
|
-
var util__default = /*#__PURE__*/_interopDefaultCompat(util$1);
|
|
28
|
-
var githubUrlToObject__default = /*#__PURE__*/_interopDefaultCompat(githubUrlToObject);
|
|
29
|
-
var validateNpmPackageName__default = /*#__PURE__*/_interopDefaultCompat(validateNpmPackageName);
|
|
30
|
-
var pAny__default = /*#__PURE__*/_interopDefaultCompat(pAny);
|
|
31
|
-
var crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
32
|
-
var inquirer__default = /*#__PURE__*/_interopDefaultCompat(inquirer);
|
|
33
|
-
var pProps__default = /*#__PURE__*/_interopDefaultCompat(pProps);
|
|
34
|
-
var getLatestVersion__default = /*#__PURE__*/_interopDefaultCompat(getLatestVersion);
|
|
35
|
-
var outdent__default = /*#__PURE__*/_interopDefaultCompat(outdent);
|
|
36
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
37
|
-
const buildExtensions = [".js", ".jsx", ".es6", ".es", ".mjs", ".ts", ".tsx"];
|
|
38
|
-
async function prompt(message, options) {
|
|
39
|
-
const type = options.choices ? "list" : options.type;
|
|
40
|
-
const result = await inquirer__default.default.prompt([{
|
|
41
|
-
...options,
|
|
42
|
-
type,
|
|
43
|
-
message,
|
|
44
|
-
name: "single"
|
|
45
|
-
}]);
|
|
46
|
-
return result && result.single;
|
|
47
|
-
}
|
|
48
|
-
prompt.separator = () => new inquirer__default.default.Separator();
|
|
49
|
-
function promptForPackageName(_ref, defaultVal) {
|
|
50
|
-
let {
|
|
51
|
-
basePath
|
|
52
|
-
} = _ref;
|
|
53
|
-
return prompt("Plugin name (sanity-plugin-...)", {
|
|
54
|
-
default: defaultVal || path__default.default.basename(basePath),
|
|
55
|
-
filter: name => {
|
|
56
|
-
const prefixless = name.trim().replace(/^sanity-plugin-/, "");
|
|
57
|
-
return name[0] === "@" ? name : "sanity-plugin-".concat(prefixless);
|
|
58
|
-
},
|
|
59
|
-
validate: name => {
|
|
60
|
-
const valid = validateNpmPackageName__default.default(name);
|
|
61
|
-
if (valid.errors) {
|
|
62
|
-
return valid.errors[0];
|
|
63
|
-
}
|
|
64
|
-
if (name[0] !== "@" && name.endsWith("plugin")) {
|
|
65
|
-
return "Name shouldn't include \"plugin\" multiple times (".concat(name, ")");
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function promptForRepoOrigin(options, defaultVal) {
|
|
72
|
-
return prompt("Git repository URL", {
|
|
73
|
-
default: defaultVal,
|
|
74
|
-
filter: raw => {
|
|
75
|
-
const url = (raw || "").trim();
|
|
76
|
-
const gh = githubUrlToObject__default.default(url);
|
|
77
|
-
return gh ? "git+ssh://git@github.com/".concat(gh.user, "/").concat(gh.repo, ".git") : url;
|
|
78
|
-
},
|
|
79
|
-
validate: url$1 => {
|
|
80
|
-
if (!url$1) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const parsed = new url.URL(url$1);
|
|
85
|
-
return parsed ? true : "Invalid URL";
|
|
86
|
-
} catch (err) {
|
|
87
|
-
return "Invalid URL";
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// This is a generated file. Do not edit.
|
|
94
|
-
var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
95
|
-
var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
|
|
96
|
-
var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
|
|
97
|
-
var unicode = {
|
|
98
|
-
Space_Separator: Space_Separator,
|
|
99
|
-
ID_Start: ID_Start,
|
|
100
|
-
ID_Continue: ID_Continue
|
|
101
|
-
};
|
|
102
|
-
var util = {
|
|
103
|
-
isSpaceSeparator(c) {
|
|
104
|
-
return typeof c === 'string' && unicode.Space_Separator.test(c);
|
|
105
|
-
},
|
|
106
|
-
isIdStartChar(c) {
|
|
107
|
-
return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c === '$' || c === '_' || unicode.ID_Start.test(c));
|
|
108
|
-
},
|
|
109
|
-
isIdContinueChar(c) {
|
|
110
|
-
return typeof c === 'string' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c === '$' || c === '_' || c === '\u200C' || c === '\u200D' || unicode.ID_Continue.test(c));
|
|
111
|
-
},
|
|
112
|
-
isDigit(c) {
|
|
113
|
-
return typeof c === 'string' && /[0-9]/.test(c);
|
|
114
|
-
},
|
|
115
|
-
isHexDigit(c) {
|
|
116
|
-
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
let source;
|
|
120
|
-
let parseState;
|
|
121
|
-
let stack;
|
|
122
|
-
let pos;
|
|
123
|
-
let line;
|
|
124
|
-
let column;
|
|
125
|
-
let token;
|
|
126
|
-
let key;
|
|
127
|
-
let root;
|
|
128
|
-
var parse = function parse(text, reviver) {
|
|
129
|
-
source = String(text);
|
|
130
|
-
parseState = 'start';
|
|
131
|
-
stack = [];
|
|
132
|
-
pos = 0;
|
|
133
|
-
line = 1;
|
|
134
|
-
column = 0;
|
|
135
|
-
token = undefined;
|
|
136
|
-
key = undefined;
|
|
137
|
-
root = undefined;
|
|
138
|
-
do {
|
|
139
|
-
token = lex();
|
|
140
|
-
|
|
141
|
-
// This code is unreachable.
|
|
142
|
-
// if (!parseStates[parseState]) {
|
|
143
|
-
// throw invalidParseState()
|
|
144
|
-
// }
|
|
145
|
-
|
|
146
|
-
parseStates[parseState]();
|
|
147
|
-
} while (token.type !== 'eof');
|
|
148
|
-
if (typeof reviver === 'function') {
|
|
149
|
-
return internalize({
|
|
150
|
-
'': root
|
|
151
|
-
}, '', reviver);
|
|
152
|
-
}
|
|
153
|
-
return root;
|
|
154
|
-
};
|
|
155
|
-
function internalize(holder, name, reviver) {
|
|
156
|
-
const value = holder[name];
|
|
157
|
-
if (value != null && typeof value === 'object') {
|
|
158
|
-
if (Array.isArray(value)) {
|
|
159
|
-
for (let i = 0; i < value.length; i++) {
|
|
160
|
-
const key = String(i);
|
|
161
|
-
const replacement = internalize(value, key, reviver);
|
|
162
|
-
if (replacement === undefined) {
|
|
163
|
-
delete value[key];
|
|
164
|
-
} else {
|
|
165
|
-
Object.defineProperty(value, key, {
|
|
166
|
-
value: replacement,
|
|
167
|
-
writable: true,
|
|
168
|
-
enumerable: true,
|
|
169
|
-
configurable: true
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
} else {
|
|
174
|
-
for (const key in value) {
|
|
175
|
-
const replacement = internalize(value, key, reviver);
|
|
176
|
-
if (replacement === undefined) {
|
|
177
|
-
delete value[key];
|
|
178
|
-
} else {
|
|
179
|
-
Object.defineProperty(value, key, {
|
|
180
|
-
value: replacement,
|
|
181
|
-
writable: true,
|
|
182
|
-
enumerable: true,
|
|
183
|
-
configurable: true
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return reviver.call(holder, name, value);
|
|
190
|
-
}
|
|
191
|
-
let lexState;
|
|
192
|
-
let buffer;
|
|
193
|
-
let doubleQuote;
|
|
194
|
-
let sign;
|
|
195
|
-
let c;
|
|
196
|
-
function lex() {
|
|
197
|
-
lexState = 'default';
|
|
198
|
-
buffer = '';
|
|
199
|
-
doubleQuote = false;
|
|
200
|
-
sign = 1;
|
|
201
|
-
for (;;) {
|
|
202
|
-
c = peek();
|
|
203
|
-
|
|
204
|
-
// This code is unreachable.
|
|
205
|
-
// if (!lexStates[lexState]) {
|
|
206
|
-
// throw invalidLexState(lexState)
|
|
207
|
-
// }
|
|
208
|
-
|
|
209
|
-
const token = lexStates[lexState]();
|
|
210
|
-
if (token) {
|
|
211
|
-
return token;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function peek() {
|
|
216
|
-
if (source[pos]) {
|
|
217
|
-
return String.fromCodePoint(source.codePointAt(pos));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function read() {
|
|
221
|
-
const c = peek();
|
|
222
|
-
if (c === '\n') {
|
|
223
|
-
line++;
|
|
224
|
-
column = 0;
|
|
225
|
-
} else if (c) {
|
|
226
|
-
column += c.length;
|
|
227
|
-
} else {
|
|
228
|
-
column++;
|
|
229
|
-
}
|
|
230
|
-
if (c) {
|
|
231
|
-
pos += c.length;
|
|
232
|
-
}
|
|
233
|
-
return c;
|
|
234
|
-
}
|
|
235
|
-
const lexStates = {
|
|
236
|
-
default() {
|
|
237
|
-
switch (c) {
|
|
238
|
-
case '\t':
|
|
239
|
-
case '\v':
|
|
240
|
-
case '\f':
|
|
241
|
-
case ' ':
|
|
242
|
-
case '\u00A0':
|
|
243
|
-
case '\uFEFF':
|
|
244
|
-
case '\n':
|
|
245
|
-
case '\r':
|
|
246
|
-
case '\u2028':
|
|
247
|
-
case '\u2029':
|
|
248
|
-
read();
|
|
249
|
-
return;
|
|
250
|
-
case '/':
|
|
251
|
-
read();
|
|
252
|
-
lexState = 'comment';
|
|
253
|
-
return;
|
|
254
|
-
case undefined:
|
|
255
|
-
read();
|
|
256
|
-
return newToken('eof');
|
|
257
|
-
}
|
|
258
|
-
if (util.isSpaceSeparator(c)) {
|
|
259
|
-
read();
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// This code is unreachable.
|
|
264
|
-
// if (!lexStates[parseState]) {
|
|
265
|
-
// throw invalidLexState(parseState)
|
|
266
|
-
// }
|
|
267
|
-
|
|
268
|
-
return lexStates[parseState]();
|
|
269
|
-
},
|
|
270
|
-
comment() {
|
|
271
|
-
switch (c) {
|
|
272
|
-
case '*':
|
|
273
|
-
read();
|
|
274
|
-
lexState = 'multiLineComment';
|
|
275
|
-
return;
|
|
276
|
-
case '/':
|
|
277
|
-
read();
|
|
278
|
-
lexState = 'singleLineComment';
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
throw invalidChar(read());
|
|
282
|
-
},
|
|
283
|
-
multiLineComment() {
|
|
284
|
-
switch (c) {
|
|
285
|
-
case '*':
|
|
286
|
-
read();
|
|
287
|
-
lexState = 'multiLineCommentAsterisk';
|
|
288
|
-
return;
|
|
289
|
-
case undefined:
|
|
290
|
-
throw invalidChar(read());
|
|
291
|
-
}
|
|
292
|
-
read();
|
|
293
|
-
},
|
|
294
|
-
multiLineCommentAsterisk() {
|
|
295
|
-
switch (c) {
|
|
296
|
-
case '*':
|
|
297
|
-
read();
|
|
298
|
-
return;
|
|
299
|
-
case '/':
|
|
300
|
-
read();
|
|
301
|
-
lexState = 'default';
|
|
302
|
-
return;
|
|
303
|
-
case undefined:
|
|
304
|
-
throw invalidChar(read());
|
|
305
|
-
}
|
|
306
|
-
read();
|
|
307
|
-
lexState = 'multiLineComment';
|
|
308
|
-
},
|
|
309
|
-
singleLineComment() {
|
|
310
|
-
switch (c) {
|
|
311
|
-
case '\n':
|
|
312
|
-
case '\r':
|
|
313
|
-
case '\u2028':
|
|
314
|
-
case '\u2029':
|
|
315
|
-
read();
|
|
316
|
-
lexState = 'default';
|
|
317
|
-
return;
|
|
318
|
-
case undefined:
|
|
319
|
-
read();
|
|
320
|
-
return newToken('eof');
|
|
321
|
-
}
|
|
322
|
-
read();
|
|
323
|
-
},
|
|
324
|
-
value() {
|
|
325
|
-
switch (c) {
|
|
326
|
-
case '{':
|
|
327
|
-
case '[':
|
|
328
|
-
return newToken('punctuator', read());
|
|
329
|
-
case 'n':
|
|
330
|
-
read();
|
|
331
|
-
literal('ull');
|
|
332
|
-
return newToken('null', null);
|
|
333
|
-
case 't':
|
|
334
|
-
read();
|
|
335
|
-
literal('rue');
|
|
336
|
-
return newToken('boolean', true);
|
|
337
|
-
case 'f':
|
|
338
|
-
read();
|
|
339
|
-
literal('alse');
|
|
340
|
-
return newToken('boolean', false);
|
|
341
|
-
case '-':
|
|
342
|
-
case '+':
|
|
343
|
-
if (read() === '-') {
|
|
344
|
-
sign = -1;
|
|
345
|
-
}
|
|
346
|
-
lexState = 'sign';
|
|
347
|
-
return;
|
|
348
|
-
case '.':
|
|
349
|
-
buffer = read();
|
|
350
|
-
lexState = 'decimalPointLeading';
|
|
351
|
-
return;
|
|
352
|
-
case '0':
|
|
353
|
-
buffer = read();
|
|
354
|
-
lexState = 'zero';
|
|
355
|
-
return;
|
|
356
|
-
case '1':
|
|
357
|
-
case '2':
|
|
358
|
-
case '3':
|
|
359
|
-
case '4':
|
|
360
|
-
case '5':
|
|
361
|
-
case '6':
|
|
362
|
-
case '7':
|
|
363
|
-
case '8':
|
|
364
|
-
case '9':
|
|
365
|
-
buffer = read();
|
|
366
|
-
lexState = 'decimalInteger';
|
|
367
|
-
return;
|
|
368
|
-
case 'I':
|
|
369
|
-
read();
|
|
370
|
-
literal('nfinity');
|
|
371
|
-
return newToken('numeric', Infinity);
|
|
372
|
-
case 'N':
|
|
373
|
-
read();
|
|
374
|
-
literal('aN');
|
|
375
|
-
return newToken('numeric', NaN);
|
|
376
|
-
case '"':
|
|
377
|
-
case "'":
|
|
378
|
-
doubleQuote = read() === '"';
|
|
379
|
-
buffer = '';
|
|
380
|
-
lexState = 'string';
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
throw invalidChar(read());
|
|
384
|
-
},
|
|
385
|
-
identifierNameStartEscape() {
|
|
386
|
-
if (c !== 'u') {
|
|
387
|
-
throw invalidChar(read());
|
|
388
|
-
}
|
|
389
|
-
read();
|
|
390
|
-
const u = unicodeEscape();
|
|
391
|
-
switch (u) {
|
|
392
|
-
case '$':
|
|
393
|
-
case '_':
|
|
394
|
-
break;
|
|
395
|
-
default:
|
|
396
|
-
if (!util.isIdStartChar(u)) {
|
|
397
|
-
throw invalidIdentifier();
|
|
398
|
-
}
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
buffer += u;
|
|
402
|
-
lexState = 'identifierName';
|
|
403
|
-
},
|
|
404
|
-
identifierName() {
|
|
405
|
-
switch (c) {
|
|
406
|
-
case '$':
|
|
407
|
-
case '_':
|
|
408
|
-
case '\u200C':
|
|
409
|
-
case '\u200D':
|
|
410
|
-
buffer += read();
|
|
411
|
-
return;
|
|
412
|
-
case '\\':
|
|
413
|
-
read();
|
|
414
|
-
lexState = 'identifierNameEscape';
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (util.isIdContinueChar(c)) {
|
|
418
|
-
buffer += read();
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
return newToken('identifier', buffer);
|
|
422
|
-
},
|
|
423
|
-
identifierNameEscape() {
|
|
424
|
-
if (c !== 'u') {
|
|
425
|
-
throw invalidChar(read());
|
|
426
|
-
}
|
|
427
|
-
read();
|
|
428
|
-
const u = unicodeEscape();
|
|
429
|
-
switch (u) {
|
|
430
|
-
case '$':
|
|
431
|
-
case '_':
|
|
432
|
-
case '\u200C':
|
|
433
|
-
case '\u200D':
|
|
434
|
-
break;
|
|
435
|
-
default:
|
|
436
|
-
if (!util.isIdContinueChar(u)) {
|
|
437
|
-
throw invalidIdentifier();
|
|
438
|
-
}
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
441
|
-
buffer += u;
|
|
442
|
-
lexState = 'identifierName';
|
|
443
|
-
},
|
|
444
|
-
sign() {
|
|
445
|
-
switch (c) {
|
|
446
|
-
case '.':
|
|
447
|
-
buffer = read();
|
|
448
|
-
lexState = 'decimalPointLeading';
|
|
449
|
-
return;
|
|
450
|
-
case '0':
|
|
451
|
-
buffer = read();
|
|
452
|
-
lexState = 'zero';
|
|
453
|
-
return;
|
|
454
|
-
case '1':
|
|
455
|
-
case '2':
|
|
456
|
-
case '3':
|
|
457
|
-
case '4':
|
|
458
|
-
case '5':
|
|
459
|
-
case '6':
|
|
460
|
-
case '7':
|
|
461
|
-
case '8':
|
|
462
|
-
case '9':
|
|
463
|
-
buffer = read();
|
|
464
|
-
lexState = 'decimalInteger';
|
|
465
|
-
return;
|
|
466
|
-
case 'I':
|
|
467
|
-
read();
|
|
468
|
-
literal('nfinity');
|
|
469
|
-
return newToken('numeric', sign * Infinity);
|
|
470
|
-
case 'N':
|
|
471
|
-
read();
|
|
472
|
-
literal('aN');
|
|
473
|
-
return newToken('numeric', NaN);
|
|
474
|
-
}
|
|
475
|
-
throw invalidChar(read());
|
|
476
|
-
},
|
|
477
|
-
zero() {
|
|
478
|
-
switch (c) {
|
|
479
|
-
case '.':
|
|
480
|
-
buffer += read();
|
|
481
|
-
lexState = 'decimalPoint';
|
|
482
|
-
return;
|
|
483
|
-
case 'e':
|
|
484
|
-
case 'E':
|
|
485
|
-
buffer += read();
|
|
486
|
-
lexState = 'decimalExponent';
|
|
487
|
-
return;
|
|
488
|
-
case 'x':
|
|
489
|
-
case 'X':
|
|
490
|
-
buffer += read();
|
|
491
|
-
lexState = 'hexadecimal';
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
return newToken('numeric', sign * 0);
|
|
495
|
-
},
|
|
496
|
-
decimalInteger() {
|
|
497
|
-
switch (c) {
|
|
498
|
-
case '.':
|
|
499
|
-
buffer += read();
|
|
500
|
-
lexState = 'decimalPoint';
|
|
501
|
-
return;
|
|
502
|
-
case 'e':
|
|
503
|
-
case 'E':
|
|
504
|
-
buffer += read();
|
|
505
|
-
lexState = 'decimalExponent';
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
if (util.isDigit(c)) {
|
|
509
|
-
buffer += read();
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
return newToken('numeric', sign * Number(buffer));
|
|
513
|
-
},
|
|
514
|
-
decimalPointLeading() {
|
|
515
|
-
if (util.isDigit(c)) {
|
|
516
|
-
buffer += read();
|
|
517
|
-
lexState = 'decimalFraction';
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
throw invalidChar(read());
|
|
521
|
-
},
|
|
522
|
-
decimalPoint() {
|
|
523
|
-
switch (c) {
|
|
524
|
-
case 'e':
|
|
525
|
-
case 'E':
|
|
526
|
-
buffer += read();
|
|
527
|
-
lexState = 'decimalExponent';
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
if (util.isDigit(c)) {
|
|
531
|
-
buffer += read();
|
|
532
|
-
lexState = 'decimalFraction';
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
return newToken('numeric', sign * Number(buffer));
|
|
536
|
-
},
|
|
537
|
-
decimalFraction() {
|
|
538
|
-
switch (c) {
|
|
539
|
-
case 'e':
|
|
540
|
-
case 'E':
|
|
541
|
-
buffer += read();
|
|
542
|
-
lexState = 'decimalExponent';
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
if (util.isDigit(c)) {
|
|
546
|
-
buffer += read();
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
return newToken('numeric', sign * Number(buffer));
|
|
550
|
-
},
|
|
551
|
-
decimalExponent() {
|
|
552
|
-
switch (c) {
|
|
553
|
-
case '+':
|
|
554
|
-
case '-':
|
|
555
|
-
buffer += read();
|
|
556
|
-
lexState = 'decimalExponentSign';
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
if (util.isDigit(c)) {
|
|
560
|
-
buffer += read();
|
|
561
|
-
lexState = 'decimalExponentInteger';
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
throw invalidChar(read());
|
|
565
|
-
},
|
|
566
|
-
decimalExponentSign() {
|
|
567
|
-
if (util.isDigit(c)) {
|
|
568
|
-
buffer += read();
|
|
569
|
-
lexState = 'decimalExponentInteger';
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
throw invalidChar(read());
|
|
573
|
-
},
|
|
574
|
-
decimalExponentInteger() {
|
|
575
|
-
if (util.isDigit(c)) {
|
|
576
|
-
buffer += read();
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
return newToken('numeric', sign * Number(buffer));
|
|
580
|
-
},
|
|
581
|
-
hexadecimal() {
|
|
582
|
-
if (util.isHexDigit(c)) {
|
|
583
|
-
buffer += read();
|
|
584
|
-
lexState = 'hexadecimalInteger';
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
throw invalidChar(read());
|
|
588
|
-
},
|
|
589
|
-
hexadecimalInteger() {
|
|
590
|
-
if (util.isHexDigit(c)) {
|
|
591
|
-
buffer += read();
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
return newToken('numeric', sign * Number(buffer));
|
|
595
|
-
},
|
|
596
|
-
string() {
|
|
597
|
-
switch (c) {
|
|
598
|
-
case '\\':
|
|
599
|
-
read();
|
|
600
|
-
buffer += escape();
|
|
601
|
-
return;
|
|
602
|
-
case '"':
|
|
603
|
-
if (doubleQuote) {
|
|
604
|
-
read();
|
|
605
|
-
return newToken('string', buffer);
|
|
606
|
-
}
|
|
607
|
-
buffer += read();
|
|
608
|
-
return;
|
|
609
|
-
case "'":
|
|
610
|
-
if (!doubleQuote) {
|
|
611
|
-
read();
|
|
612
|
-
return newToken('string', buffer);
|
|
613
|
-
}
|
|
614
|
-
buffer += read();
|
|
615
|
-
return;
|
|
616
|
-
case '\n':
|
|
617
|
-
case '\r':
|
|
618
|
-
throw invalidChar(read());
|
|
619
|
-
case '\u2028':
|
|
620
|
-
case '\u2029':
|
|
621
|
-
separatorChar(c);
|
|
622
|
-
break;
|
|
623
|
-
case undefined:
|
|
624
|
-
throw invalidChar(read());
|
|
625
|
-
}
|
|
626
|
-
buffer += read();
|
|
627
|
-
},
|
|
628
|
-
start() {
|
|
629
|
-
switch (c) {
|
|
630
|
-
case '{':
|
|
631
|
-
case '[':
|
|
632
|
-
return newToken('punctuator', read());
|
|
633
|
-
|
|
634
|
-
// This code is unreachable since the default lexState handles eof.
|
|
635
|
-
// case undefined:
|
|
636
|
-
// return newToken('eof')
|
|
637
|
-
}
|
|
638
|
-
lexState = 'value';
|
|
639
|
-
},
|
|
640
|
-
beforePropertyName() {
|
|
641
|
-
switch (c) {
|
|
642
|
-
case '$':
|
|
643
|
-
case '_':
|
|
644
|
-
buffer = read();
|
|
645
|
-
lexState = 'identifierName';
|
|
646
|
-
return;
|
|
647
|
-
case '\\':
|
|
648
|
-
read();
|
|
649
|
-
lexState = 'identifierNameStartEscape';
|
|
650
|
-
return;
|
|
651
|
-
case '}':
|
|
652
|
-
return newToken('punctuator', read());
|
|
653
|
-
case '"':
|
|
654
|
-
case "'":
|
|
655
|
-
doubleQuote = read() === '"';
|
|
656
|
-
lexState = 'string';
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
if (util.isIdStartChar(c)) {
|
|
660
|
-
buffer += read();
|
|
661
|
-
lexState = 'identifierName';
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
throw invalidChar(read());
|
|
665
|
-
},
|
|
666
|
-
afterPropertyName() {
|
|
667
|
-
if (c === ':') {
|
|
668
|
-
return newToken('punctuator', read());
|
|
669
|
-
}
|
|
670
|
-
throw invalidChar(read());
|
|
671
|
-
},
|
|
672
|
-
beforePropertyValue() {
|
|
673
|
-
lexState = 'value';
|
|
674
|
-
},
|
|
675
|
-
afterPropertyValue() {
|
|
676
|
-
switch (c) {
|
|
677
|
-
case ',':
|
|
678
|
-
case '}':
|
|
679
|
-
return newToken('punctuator', read());
|
|
680
|
-
}
|
|
681
|
-
throw invalidChar(read());
|
|
682
|
-
},
|
|
683
|
-
beforeArrayValue() {
|
|
684
|
-
if (c === ']') {
|
|
685
|
-
return newToken('punctuator', read());
|
|
686
|
-
}
|
|
687
|
-
lexState = 'value';
|
|
688
|
-
},
|
|
689
|
-
afterArrayValue() {
|
|
690
|
-
switch (c) {
|
|
691
|
-
case ',':
|
|
692
|
-
case ']':
|
|
693
|
-
return newToken('punctuator', read());
|
|
694
|
-
}
|
|
695
|
-
throw invalidChar(read());
|
|
696
|
-
},
|
|
697
|
-
end() {
|
|
698
|
-
// This code is unreachable since it's handled by the default lexState.
|
|
699
|
-
// if (c === undefined) {
|
|
700
|
-
// read()
|
|
701
|
-
// return newToken('eof')
|
|
702
|
-
// }
|
|
703
|
-
|
|
704
|
-
throw invalidChar(read());
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
function newToken(type, value) {
|
|
708
|
-
return {
|
|
709
|
-
type,
|
|
710
|
-
value,
|
|
711
|
-
line,
|
|
712
|
-
column
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
function literal(s) {
|
|
716
|
-
for (const c of s) {
|
|
717
|
-
const p = peek();
|
|
718
|
-
if (p !== c) {
|
|
719
|
-
throw invalidChar(read());
|
|
720
|
-
}
|
|
721
|
-
read();
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
function escape() {
|
|
725
|
-
const c = peek();
|
|
726
|
-
switch (c) {
|
|
727
|
-
case 'b':
|
|
728
|
-
read();
|
|
729
|
-
return '\b';
|
|
730
|
-
case 'f':
|
|
731
|
-
read();
|
|
732
|
-
return '\f';
|
|
733
|
-
case 'n':
|
|
734
|
-
read();
|
|
735
|
-
return '\n';
|
|
736
|
-
case 'r':
|
|
737
|
-
read();
|
|
738
|
-
return '\r';
|
|
739
|
-
case 't':
|
|
740
|
-
read();
|
|
741
|
-
return '\t';
|
|
742
|
-
case 'v':
|
|
743
|
-
read();
|
|
744
|
-
return '\v';
|
|
745
|
-
case '0':
|
|
746
|
-
read();
|
|
747
|
-
if (util.isDigit(peek())) {
|
|
748
|
-
throw invalidChar(read());
|
|
749
|
-
}
|
|
750
|
-
return '\0';
|
|
751
|
-
case 'x':
|
|
752
|
-
read();
|
|
753
|
-
return hexEscape();
|
|
754
|
-
case 'u':
|
|
755
|
-
read();
|
|
756
|
-
return unicodeEscape();
|
|
757
|
-
case '\n':
|
|
758
|
-
case '\u2028':
|
|
759
|
-
case '\u2029':
|
|
760
|
-
read();
|
|
761
|
-
return '';
|
|
762
|
-
case '\r':
|
|
763
|
-
read();
|
|
764
|
-
if (peek() === '\n') {
|
|
765
|
-
read();
|
|
766
|
-
}
|
|
767
|
-
return '';
|
|
768
|
-
case '1':
|
|
769
|
-
case '2':
|
|
770
|
-
case '3':
|
|
771
|
-
case '4':
|
|
772
|
-
case '5':
|
|
773
|
-
case '6':
|
|
774
|
-
case '7':
|
|
775
|
-
case '8':
|
|
776
|
-
case '9':
|
|
777
|
-
throw invalidChar(read());
|
|
778
|
-
case undefined:
|
|
779
|
-
throw invalidChar(read());
|
|
780
|
-
}
|
|
781
|
-
return read();
|
|
782
|
-
}
|
|
783
|
-
function hexEscape() {
|
|
784
|
-
let buffer = '';
|
|
785
|
-
let c = peek();
|
|
786
|
-
if (!util.isHexDigit(c)) {
|
|
787
|
-
throw invalidChar(read());
|
|
788
|
-
}
|
|
789
|
-
buffer += read();
|
|
790
|
-
c = peek();
|
|
791
|
-
if (!util.isHexDigit(c)) {
|
|
792
|
-
throw invalidChar(read());
|
|
793
|
-
}
|
|
794
|
-
buffer += read();
|
|
795
|
-
return String.fromCodePoint(parseInt(buffer, 16));
|
|
796
|
-
}
|
|
797
|
-
function unicodeEscape() {
|
|
798
|
-
let buffer = '';
|
|
799
|
-
let count = 4;
|
|
800
|
-
while (count-- > 0) {
|
|
801
|
-
const c = peek();
|
|
802
|
-
if (!util.isHexDigit(c)) {
|
|
803
|
-
throw invalidChar(read());
|
|
804
|
-
}
|
|
805
|
-
buffer += read();
|
|
806
|
-
}
|
|
807
|
-
return String.fromCodePoint(parseInt(buffer, 16));
|
|
808
|
-
}
|
|
809
|
-
const parseStates = {
|
|
810
|
-
start() {
|
|
811
|
-
if (token.type === 'eof') {
|
|
812
|
-
throw invalidEOF();
|
|
813
|
-
}
|
|
814
|
-
push();
|
|
815
|
-
},
|
|
816
|
-
beforePropertyName() {
|
|
817
|
-
switch (token.type) {
|
|
818
|
-
case 'identifier':
|
|
819
|
-
case 'string':
|
|
820
|
-
key = token.value;
|
|
821
|
-
parseState = 'afterPropertyName';
|
|
822
|
-
return;
|
|
823
|
-
case 'punctuator':
|
|
824
|
-
// This code is unreachable since it's handled by the lexState.
|
|
825
|
-
// if (token.value !== '}') {
|
|
826
|
-
// throw invalidToken()
|
|
827
|
-
// }
|
|
828
|
-
|
|
829
|
-
pop();
|
|
830
|
-
return;
|
|
831
|
-
case 'eof':
|
|
832
|
-
throw invalidEOF();
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
// This code is unreachable since it's handled by the lexState.
|
|
836
|
-
// throw invalidToken()
|
|
837
|
-
},
|
|
838
|
-
afterPropertyName() {
|
|
839
|
-
// This code is unreachable since it's handled by the lexState.
|
|
840
|
-
// if (token.type !== 'punctuator' || token.value !== ':') {
|
|
841
|
-
// throw invalidToken()
|
|
842
|
-
// }
|
|
843
|
-
|
|
844
|
-
if (token.type === 'eof') {
|
|
845
|
-
throw invalidEOF();
|
|
846
|
-
}
|
|
847
|
-
parseState = 'beforePropertyValue';
|
|
848
|
-
},
|
|
849
|
-
beforePropertyValue() {
|
|
850
|
-
if (token.type === 'eof') {
|
|
851
|
-
throw invalidEOF();
|
|
852
|
-
}
|
|
853
|
-
push();
|
|
854
|
-
},
|
|
855
|
-
beforeArrayValue() {
|
|
856
|
-
if (token.type === 'eof') {
|
|
857
|
-
throw invalidEOF();
|
|
858
|
-
}
|
|
859
|
-
if (token.type === 'punctuator' && token.value === ']') {
|
|
860
|
-
pop();
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
push();
|
|
864
|
-
},
|
|
865
|
-
afterPropertyValue() {
|
|
866
|
-
// This code is unreachable since it's handled by the lexState.
|
|
867
|
-
// if (token.type !== 'punctuator') {
|
|
868
|
-
// throw invalidToken()
|
|
869
|
-
// }
|
|
870
|
-
|
|
871
|
-
if (token.type === 'eof') {
|
|
872
|
-
throw invalidEOF();
|
|
873
|
-
}
|
|
874
|
-
switch (token.value) {
|
|
875
|
-
case ',':
|
|
876
|
-
parseState = 'beforePropertyName';
|
|
877
|
-
return;
|
|
878
|
-
case '}':
|
|
879
|
-
pop();
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
// This code is unreachable since it's handled by the lexState.
|
|
883
|
-
// throw invalidToken()
|
|
884
|
-
},
|
|
885
|
-
afterArrayValue() {
|
|
886
|
-
// This code is unreachable since it's handled by the lexState.
|
|
887
|
-
// if (token.type !== 'punctuator') {
|
|
888
|
-
// throw invalidToken()
|
|
889
|
-
// }
|
|
890
|
-
|
|
891
|
-
if (token.type === 'eof') {
|
|
892
|
-
throw invalidEOF();
|
|
893
|
-
}
|
|
894
|
-
switch (token.value) {
|
|
895
|
-
case ',':
|
|
896
|
-
parseState = 'beforeArrayValue';
|
|
897
|
-
return;
|
|
898
|
-
case ']':
|
|
899
|
-
pop();
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
// This code is unreachable since it's handled by the lexState.
|
|
903
|
-
// throw invalidToken()
|
|
904
|
-
},
|
|
905
|
-
end() {
|
|
906
|
-
// This code is unreachable since it's handled by the lexState.
|
|
907
|
-
// if (token.type !== 'eof') {
|
|
908
|
-
// throw invalidToken()
|
|
909
|
-
// }
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
function push() {
|
|
913
|
-
let value;
|
|
914
|
-
switch (token.type) {
|
|
915
|
-
case 'punctuator':
|
|
916
|
-
switch (token.value) {
|
|
917
|
-
case '{':
|
|
918
|
-
value = {};
|
|
919
|
-
break;
|
|
920
|
-
case '[':
|
|
921
|
-
value = [];
|
|
922
|
-
break;
|
|
923
|
-
}
|
|
924
|
-
break;
|
|
925
|
-
case 'null':
|
|
926
|
-
case 'boolean':
|
|
927
|
-
case 'numeric':
|
|
928
|
-
case 'string':
|
|
929
|
-
value = token.value;
|
|
930
|
-
break;
|
|
931
|
-
|
|
932
|
-
// This code is unreachable.
|
|
933
|
-
// default:
|
|
934
|
-
// throw invalidToken()
|
|
935
|
-
}
|
|
936
|
-
if (root === undefined) {
|
|
937
|
-
root = value;
|
|
938
|
-
} else {
|
|
939
|
-
const parent = stack[stack.length - 1];
|
|
940
|
-
if (Array.isArray(parent)) {
|
|
941
|
-
parent.push(value);
|
|
942
|
-
} else {
|
|
943
|
-
Object.defineProperty(parent, key, {
|
|
944
|
-
value,
|
|
945
|
-
writable: true,
|
|
946
|
-
enumerable: true,
|
|
947
|
-
configurable: true
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
if (value !== null && typeof value === 'object') {
|
|
952
|
-
stack.push(value);
|
|
953
|
-
if (Array.isArray(value)) {
|
|
954
|
-
parseState = 'beforeArrayValue';
|
|
955
|
-
} else {
|
|
956
|
-
parseState = 'beforePropertyName';
|
|
957
|
-
}
|
|
958
|
-
} else {
|
|
959
|
-
const current = stack[stack.length - 1];
|
|
960
|
-
if (current == null) {
|
|
961
|
-
parseState = 'end';
|
|
962
|
-
} else if (Array.isArray(current)) {
|
|
963
|
-
parseState = 'afterArrayValue';
|
|
964
|
-
} else {
|
|
965
|
-
parseState = 'afterPropertyValue';
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
function pop() {
|
|
970
|
-
stack.pop();
|
|
971
|
-
const current = stack[stack.length - 1];
|
|
972
|
-
if (current == null) {
|
|
973
|
-
parseState = 'end';
|
|
974
|
-
} else if (Array.isArray(current)) {
|
|
975
|
-
parseState = 'afterArrayValue';
|
|
976
|
-
} else {
|
|
977
|
-
parseState = 'afterPropertyValue';
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
// This code is unreachable.
|
|
982
|
-
// function invalidParseState () {
|
|
983
|
-
// return new Error(`JSON5: invalid parse state '${parseState}'`)
|
|
984
|
-
// }
|
|
985
|
-
|
|
986
|
-
// This code is unreachable.
|
|
987
|
-
// function invalidLexState (state) {
|
|
988
|
-
// return new Error(`JSON5: invalid lex state '${state}'`)
|
|
989
|
-
// }
|
|
990
|
-
|
|
991
|
-
function invalidChar(c) {
|
|
992
|
-
if (c === undefined) {
|
|
993
|
-
return syntaxError("JSON5: invalid end of input at ".concat(line, ":").concat(column));
|
|
994
|
-
}
|
|
995
|
-
return syntaxError("JSON5: invalid character '".concat(formatChar(c), "' at ").concat(line, ":").concat(column));
|
|
996
|
-
}
|
|
997
|
-
function invalidEOF() {
|
|
998
|
-
return syntaxError("JSON5: invalid end of input at ".concat(line, ":").concat(column));
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
// This code is unreachable.
|
|
1002
|
-
// function invalidToken () {
|
|
1003
|
-
// if (token.type === 'eof') {
|
|
1004
|
-
// return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
|
|
1005
|
-
// }
|
|
1006
|
-
|
|
1007
|
-
// const c = String.fromCodePoint(token.value.codePointAt(0))
|
|
1008
|
-
// return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
|
|
1009
|
-
// }
|
|
1010
|
-
|
|
1011
|
-
function invalidIdentifier() {
|
|
1012
|
-
column -= 5;
|
|
1013
|
-
return syntaxError("JSON5: invalid identifier character at ".concat(line, ":").concat(column));
|
|
1014
|
-
}
|
|
1015
|
-
function separatorChar(c) {
|
|
1016
|
-
console.warn("JSON5: '".concat(formatChar(c), "' in strings is not valid ECMAScript; consider escaping"));
|
|
1017
|
-
}
|
|
1018
|
-
function formatChar(c) {
|
|
1019
|
-
const replacements = {
|
|
1020
|
-
"'": "\\'",
|
|
1021
|
-
'"': '\\"',
|
|
1022
|
-
'\\': '\\\\',
|
|
1023
|
-
'\b': '\\b',
|
|
1024
|
-
'\f': '\\f',
|
|
1025
|
-
'\n': '\\n',
|
|
1026
|
-
'\r': '\\r',
|
|
1027
|
-
'\t': '\\t',
|
|
1028
|
-
'\v': '\\v',
|
|
1029
|
-
'\0': '\\0',
|
|
1030
|
-
'\u2028': '\\u2028',
|
|
1031
|
-
'\u2029': '\\u2029'
|
|
1032
|
-
};
|
|
1033
|
-
if (replacements[c]) {
|
|
1034
|
-
return replacements[c];
|
|
1035
|
-
}
|
|
1036
|
-
if (c < ' ') {
|
|
1037
|
-
const hexString = c.charCodeAt(0).toString(16);
|
|
1038
|
-
return '\\x' + ('00' + hexString).substring(hexString.length);
|
|
1039
|
-
}
|
|
1040
|
-
return c;
|
|
1041
|
-
}
|
|
1042
|
-
function syntaxError(message) {
|
|
1043
|
-
const err = new SyntaxError(message);
|
|
1044
|
-
err.lineNumber = line;
|
|
1045
|
-
err.columnNumber = column;
|
|
1046
|
-
return err;
|
|
1047
|
-
}
|
|
1048
|
-
var stringify = function stringify(value, replacer, space) {
|
|
1049
|
-
const stack = [];
|
|
1050
|
-
let indent = '';
|
|
1051
|
-
let propertyList;
|
|
1052
|
-
let replacerFunc;
|
|
1053
|
-
let gap = '';
|
|
1054
|
-
let quote;
|
|
1055
|
-
if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) {
|
|
1056
|
-
space = replacer.space;
|
|
1057
|
-
quote = replacer.quote;
|
|
1058
|
-
replacer = replacer.replacer;
|
|
1059
|
-
}
|
|
1060
|
-
if (typeof replacer === 'function') {
|
|
1061
|
-
replacerFunc = replacer;
|
|
1062
|
-
} else if (Array.isArray(replacer)) {
|
|
1063
|
-
propertyList = [];
|
|
1064
|
-
for (const v of replacer) {
|
|
1065
|
-
let item;
|
|
1066
|
-
if (typeof v === 'string') {
|
|
1067
|
-
item = v;
|
|
1068
|
-
} else if (typeof v === 'number' || v instanceof String || v instanceof Number) {
|
|
1069
|
-
item = String(v);
|
|
1070
|
-
}
|
|
1071
|
-
if (item !== undefined && propertyList.indexOf(item) < 0) {
|
|
1072
|
-
propertyList.push(item);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
if (space instanceof Number) {
|
|
1077
|
-
space = Number(space);
|
|
1078
|
-
} else if (space instanceof String) {
|
|
1079
|
-
space = String(space);
|
|
1080
|
-
}
|
|
1081
|
-
if (typeof space === 'number') {
|
|
1082
|
-
if (space > 0) {
|
|
1083
|
-
space = Math.min(10, Math.floor(space));
|
|
1084
|
-
gap = ' '.substr(0, space);
|
|
1085
|
-
}
|
|
1086
|
-
} else if (typeof space === 'string') {
|
|
1087
|
-
gap = space.substr(0, 10);
|
|
1088
|
-
}
|
|
1089
|
-
return serializeProperty('', {
|
|
1090
|
-
'': value
|
|
1091
|
-
});
|
|
1092
|
-
function serializeProperty(key, holder) {
|
|
1093
|
-
let value = holder[key];
|
|
1094
|
-
if (value != null) {
|
|
1095
|
-
if (typeof value.toJSON5 === 'function') {
|
|
1096
|
-
value = value.toJSON5(key);
|
|
1097
|
-
} else if (typeof value.toJSON === 'function') {
|
|
1098
|
-
value = value.toJSON(key);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
if (replacerFunc) {
|
|
1102
|
-
value = replacerFunc.call(holder, key, value);
|
|
1103
|
-
}
|
|
1104
|
-
if (value instanceof Number) {
|
|
1105
|
-
value = Number(value);
|
|
1106
|
-
} else if (value instanceof String) {
|
|
1107
|
-
value = String(value);
|
|
1108
|
-
} else if (value instanceof Boolean) {
|
|
1109
|
-
value = value.valueOf();
|
|
1110
|
-
}
|
|
1111
|
-
switch (value) {
|
|
1112
|
-
case null:
|
|
1113
|
-
return 'null';
|
|
1114
|
-
case true:
|
|
1115
|
-
return 'true';
|
|
1116
|
-
case false:
|
|
1117
|
-
return 'false';
|
|
1118
|
-
}
|
|
1119
|
-
if (typeof value === 'string') {
|
|
1120
|
-
return quoteString(value);
|
|
1121
|
-
}
|
|
1122
|
-
if (typeof value === 'number') {
|
|
1123
|
-
return String(value);
|
|
1124
|
-
}
|
|
1125
|
-
if (typeof value === 'object') {
|
|
1126
|
-
return Array.isArray(value) ? serializeArray(value) : serializeObject(value);
|
|
1127
|
-
}
|
|
1128
|
-
return undefined;
|
|
1129
|
-
}
|
|
1130
|
-
function quoteString(value) {
|
|
1131
|
-
const quotes = {
|
|
1132
|
-
"'": 0.1,
|
|
1133
|
-
'"': 0.2
|
|
1134
|
-
};
|
|
1135
|
-
const replacements = {
|
|
1136
|
-
"'": "\\'",
|
|
1137
|
-
'"': '\\"',
|
|
1138
|
-
'\\': '\\\\',
|
|
1139
|
-
'\b': '\\b',
|
|
1140
|
-
'\f': '\\f',
|
|
1141
|
-
'\n': '\\n',
|
|
1142
|
-
'\r': '\\r',
|
|
1143
|
-
'\t': '\\t',
|
|
1144
|
-
'\v': '\\v',
|
|
1145
|
-
'\0': '\\0',
|
|
1146
|
-
'\u2028': '\\u2028',
|
|
1147
|
-
'\u2029': '\\u2029'
|
|
1148
|
-
};
|
|
1149
|
-
let product = '';
|
|
1150
|
-
for (let i = 0; i < value.length; i++) {
|
|
1151
|
-
const c = value[i];
|
|
1152
|
-
switch (c) {
|
|
1153
|
-
case "'":
|
|
1154
|
-
case '"':
|
|
1155
|
-
quotes[c]++;
|
|
1156
|
-
product += c;
|
|
1157
|
-
continue;
|
|
1158
|
-
case '\0':
|
|
1159
|
-
if (util.isDigit(value[i + 1])) {
|
|
1160
|
-
product += '\\x00';
|
|
1161
|
-
continue;
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
if (replacements[c]) {
|
|
1165
|
-
product += replacements[c];
|
|
1166
|
-
continue;
|
|
1167
|
-
}
|
|
1168
|
-
if (c < ' ') {
|
|
1169
|
-
let hexString = c.charCodeAt(0).toString(16);
|
|
1170
|
-
product += '\\x' + ('00' + hexString).substring(hexString.length);
|
|
1171
|
-
continue;
|
|
1172
|
-
}
|
|
1173
|
-
product += c;
|
|
1174
|
-
}
|
|
1175
|
-
const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
|
|
1176
|
-
product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
|
|
1177
|
-
return quoteChar + product + quoteChar;
|
|
1178
|
-
}
|
|
1179
|
-
function serializeObject(value) {
|
|
1180
|
-
if (stack.indexOf(value) >= 0) {
|
|
1181
|
-
throw TypeError('Converting circular structure to JSON5');
|
|
1182
|
-
}
|
|
1183
|
-
stack.push(value);
|
|
1184
|
-
let stepback = indent;
|
|
1185
|
-
indent = indent + gap;
|
|
1186
|
-
let keys = propertyList || Object.keys(value);
|
|
1187
|
-
let partial = [];
|
|
1188
|
-
for (const key of keys) {
|
|
1189
|
-
const propertyString = serializeProperty(key, value);
|
|
1190
|
-
if (propertyString !== undefined) {
|
|
1191
|
-
let member = serializeKey(key) + ':';
|
|
1192
|
-
if (gap !== '') {
|
|
1193
|
-
member += ' ';
|
|
1194
|
-
}
|
|
1195
|
-
member += propertyString;
|
|
1196
|
-
partial.push(member);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
let final;
|
|
1200
|
-
if (partial.length === 0) {
|
|
1201
|
-
final = '{}';
|
|
1202
|
-
} else {
|
|
1203
|
-
let properties;
|
|
1204
|
-
if (gap === '') {
|
|
1205
|
-
properties = partial.join(',');
|
|
1206
|
-
final = '{' + properties + '}';
|
|
1207
|
-
} else {
|
|
1208
|
-
let separator = ',\n' + indent;
|
|
1209
|
-
properties = partial.join(separator);
|
|
1210
|
-
final = '{\n' + indent + properties + ',\n' + stepback + '}';
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
stack.pop();
|
|
1214
|
-
indent = stepback;
|
|
1215
|
-
return final;
|
|
1216
|
-
}
|
|
1217
|
-
function serializeKey(key) {
|
|
1218
|
-
if (key.length === 0) {
|
|
1219
|
-
return quoteString(key);
|
|
1220
|
-
}
|
|
1221
|
-
const firstChar = String.fromCodePoint(key.codePointAt(0));
|
|
1222
|
-
if (!util.isIdStartChar(firstChar)) {
|
|
1223
|
-
return quoteString(key);
|
|
1224
|
-
}
|
|
1225
|
-
for (let i = firstChar.length; i < key.length; i++) {
|
|
1226
|
-
if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
|
|
1227
|
-
return quoteString(key);
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
return key;
|
|
1231
|
-
}
|
|
1232
|
-
function serializeArray(value) {
|
|
1233
|
-
if (stack.indexOf(value) >= 0) {
|
|
1234
|
-
throw TypeError('Converting circular structure to JSON5');
|
|
1235
|
-
}
|
|
1236
|
-
stack.push(value);
|
|
1237
|
-
let stepback = indent;
|
|
1238
|
-
indent = indent + gap;
|
|
1239
|
-
let partial = [];
|
|
1240
|
-
for (let i = 0; i < value.length; i++) {
|
|
1241
|
-
const propertyString = serializeProperty(String(i), value);
|
|
1242
|
-
partial.push(propertyString !== undefined ? propertyString : 'null');
|
|
1243
|
-
}
|
|
1244
|
-
let final;
|
|
1245
|
-
if (partial.length === 0) {
|
|
1246
|
-
final = '[]';
|
|
1247
|
-
} else {
|
|
1248
|
-
if (gap === '') {
|
|
1249
|
-
let properties = partial.join(',');
|
|
1250
|
-
final = '[' + properties + ']';
|
|
1251
|
-
} else {
|
|
1252
|
-
let separator = ',\n' + indent;
|
|
1253
|
-
let properties = partial.join(separator);
|
|
1254
|
-
final = '[\n' + indent + properties + ',\n' + stepback + ']';
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
stack.pop();
|
|
1258
|
-
indent = stepback;
|
|
1259
|
-
return final;
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
const JSON5 = {
|
|
1263
|
-
parse,
|
|
1264
|
-
stringify
|
|
1265
|
-
};
|
|
1266
|
-
var lib = JSON5;
|
|
1267
|
-
const stat$1 = util__default.default.promisify(fs__default.default.stat);
|
|
1268
|
-
const mkdir = util__default.default.promisify(fs__default.default.mkdir);
|
|
1269
|
-
const readdir = util__default.default.promisify(fs__default.default.readdir);
|
|
1270
|
-
const copyFile = util__default.default.promisify(fs__default.default.copyFile);
|
|
1271
|
-
const readFile$2 = util__default.default.promisify(fs__default.default.readFile);
|
|
1272
|
-
const writeFile = util__default.default.promisify(fs__default.default.writeFile);
|
|
1273
|
-
function hasSourceEquivalent(compiledFile, paths) {
|
|
1274
|
-
if (!paths.source) {
|
|
1275
|
-
return fileExists(path__default.default.isAbsolute(compiledFile) ? compiledFile : path__default.default.resolve(paths.basePath, compiledFile));
|
|
1276
|
-
}
|
|
1277
|
-
const baseDir = path__default.default.dirname(compiledFile.replace(paths.compiled, paths.source));
|
|
1278
|
-
const baseName = path__default.default.basename(compiledFile, path__default.default.extname(compiledFile));
|
|
1279
|
-
const pathStub = path__default.default.join(baseDir, baseName);
|
|
1280
|
-
return buildCandidateExists(pathStub);
|
|
1281
|
-
}
|
|
1282
|
-
async function hasSourceFile(filePath, paths) {
|
|
1283
|
-
if (!(paths !== null && paths !== void 0 && paths.source)) {
|
|
1284
|
-
var _paths$basePath;
|
|
1285
|
-
return fileExists(path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve((_paths$basePath = paths === null || paths === void 0 ? void 0 : paths.basePath) !== null && _paths$basePath !== void 0 ? _paths$basePath : "", filePath));
|
|
1286
|
-
}
|
|
1287
|
-
const pathStub = path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve(paths.source, filePath);
|
|
1288
|
-
if (await fileExists(pathStub)) {
|
|
1289
|
-
return true;
|
|
1290
|
-
}
|
|
1291
|
-
return buildCandidateExists(pathStub);
|
|
1292
|
-
}
|
|
1293
|
-
function hasCompiledFile(filePath, paths) {
|
|
1294
|
-
if (!(paths !== null && paths !== void 0 && paths.compiled)) {
|
|
1295
|
-
var _paths$basePath2;
|
|
1296
|
-
return fileExists(path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve((_paths$basePath2 = paths === null || paths === void 0 ? void 0 : paths.basePath) !== null && _paths$basePath2 !== void 0 ? _paths$basePath2 : "", filePath));
|
|
1297
|
-
}
|
|
1298
|
-
const absPath = path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve(paths.compiled, filePath);
|
|
1299
|
-
const fileExt = path__default.default.extname(absPath);
|
|
1300
|
-
const withExt = fileExt === "" ? "".concat(absPath, ".js") : absPath;
|
|
1301
|
-
return fileExists(withExt);
|
|
1302
|
-
}
|
|
1303
|
-
function buildCandidateExists(pathStub) {
|
|
1304
|
-
const candidates = buildExtensions.map(extCandidate => "".concat(pathStub).concat(extCandidate));
|
|
1305
|
-
return pAny__default.default(candidates.map(candidate => stat$1(candidate))).then(() => true).catch(() => false);
|
|
1306
|
-
}
|
|
1307
|
-
function fileExists(filePath) {
|
|
1308
|
-
return stat$1(filePath).then(() => true).catch(() => false);
|
|
1309
|
-
}
|
|
1310
|
-
async function readJsonFile(filePath) {
|
|
1311
|
-
const content = await readFile$2(filePath, "utf8");
|
|
1312
|
-
return JSON.parse(content);
|
|
1313
|
-
}
|
|
1314
|
-
function writeJsonFile(filePath, content) {
|
|
1315
|
-
const data = JSON.stringify(content, null, 2) + "\n";
|
|
1316
|
-
return writeFile(filePath, data, {
|
|
1317
|
-
encoding: "utf8"
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
async function writeFileWithOverwritePrompt(filePath, content, options) {
|
|
1321
|
-
const {
|
|
1322
|
-
default: defaultVal,
|
|
1323
|
-
force = false,
|
|
1324
|
-
...writeOptions
|
|
1325
|
-
} = options;
|
|
1326
|
-
const withinCwd = filePath.startsWith(process.cwd());
|
|
1327
|
-
const printablePath = withinCwd ? path__default.default.relative(process.cwd(), filePath) : filePath;
|
|
1328
|
-
if (await fileEqualsData(filePath, content)) {
|
|
1329
|
-
return false;
|
|
1330
|
-
}
|
|
1331
|
-
if (!force && (await fileExists(filePath)) && !(await prompt("File \"".concat(printablePath, "\" already exists. Overwrite?"), {
|
|
1332
|
-
type: "confirm",
|
|
1333
|
-
default: defaultVal
|
|
1334
|
-
}))) {
|
|
1335
|
-
return false;
|
|
1336
|
-
}
|
|
1337
|
-
await writeFile(filePath, content, writeOptions);
|
|
1338
|
-
return true;
|
|
1339
|
-
}
|
|
1340
|
-
async function copyFileWithOverwritePrompt(from, to, flags) {
|
|
1341
|
-
const withinCwd = to.startsWith(process.cwd());
|
|
1342
|
-
const printablePath = withinCwd ? path__default.default.relative(process.cwd(), to) : to;
|
|
1343
|
-
if (await filesAreEqual(from, to)) {
|
|
1344
|
-
return false;
|
|
1345
|
-
}
|
|
1346
|
-
await ensureDirectoryExists(to);
|
|
1347
|
-
if (!flags.force && (await fileExists(to)) && !(await prompt("File \"".concat(printablePath, "\" already exists. Overwrite?"), {
|
|
1348
|
-
type: "confirm",
|
|
1349
|
-
default: false
|
|
1350
|
-
}))) {
|
|
1351
|
-
return false;
|
|
1352
|
-
}
|
|
1353
|
-
await copyFile(from, to);
|
|
1354
|
-
return true;
|
|
1355
|
-
}
|
|
1356
|
-
async function ensureDirectoryExists(filePath) {
|
|
1357
|
-
const dirname = path__default.default.dirname(filePath);
|
|
1358
|
-
if (await fileExists(dirname)) {
|
|
1359
|
-
return true;
|
|
1360
|
-
}
|
|
1361
|
-
await ensureDirectoryExists(dirname);
|
|
1362
|
-
await mkdir(dirname);
|
|
1363
|
-
}
|
|
1364
|
-
async function fileEqualsData(filePath, content) {
|
|
1365
|
-
const contentHash = crypto__default.default.createHash("sha1").update(content).digest("hex");
|
|
1366
|
-
const remoteHash = await getFileHash(filePath);
|
|
1367
|
-
return contentHash === remoteHash;
|
|
1368
|
-
}
|
|
1369
|
-
async function filesAreEqual(file1, file2) {
|
|
1370
|
-
const [hash1, hash2] = await Promise.all([getFileHash(file1, false), getFileHash(file2)]);
|
|
1371
|
-
return hash1 === hash2;
|
|
1372
|
-
}
|
|
1373
|
-
function getFileHash(filePath) {
|
|
1374
|
-
let allowMissing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1375
|
-
return new Promise((resolve, reject) => {
|
|
1376
|
-
const hash = crypto__default.default.createHash("sha1");
|
|
1377
|
-
const stream = fs__default.default.createReadStream(filePath);
|
|
1378
|
-
stream.on("error", err => {
|
|
1379
|
-
if (err.code === "ENOENT" && allowMissing) {
|
|
1380
|
-
resolve(null);
|
|
1381
|
-
} else {
|
|
1382
|
-
reject(err);
|
|
1383
|
-
}
|
|
1384
|
-
});
|
|
1385
|
-
stream.on("end", () => resolve(hash.digest("hex")));
|
|
1386
|
-
stream.on("data", chunk => hash.update(chunk));
|
|
1387
|
-
});
|
|
1388
|
-
}
|
|
1389
|
-
async function ensureDir(dirPath) {
|
|
1390
|
-
try {
|
|
1391
|
-
await mkdir(dirPath);
|
|
1392
|
-
} catch (err) {
|
|
1393
|
-
if (err.code !== "EEXIST") {
|
|
1394
|
-
throw err;
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
async function isEmptyish(dirPath) {
|
|
1399
|
-
const ignoredFiles = [".git", ".gitignore", "license", "readme.md"];
|
|
1400
|
-
const allFiles = await readdir(dirPath).catch(() => []);
|
|
1401
|
-
const files = allFiles.filter(file => !ignoredFiles.includes(file.toLowerCase()));
|
|
1402
|
-
return files.length === 0;
|
|
1403
|
-
}
|
|
1404
|
-
async function readFileContent(_ref2) {
|
|
1405
|
-
let {
|
|
1406
|
-
filename,
|
|
1407
|
-
basePath
|
|
1408
|
-
} = _ref2;
|
|
1409
|
-
const filepath = path__default.default.normalize(path__default.default.join(basePath, filename));
|
|
1410
|
-
try {
|
|
1411
|
-
return await readFile$2(filepath, "utf8");
|
|
1412
|
-
} catch (err) {
|
|
1413
|
-
if (err.code === "ENOENT") {
|
|
1414
|
-
cli.log.debug("No ".concat(filename, " file found."));
|
|
1415
|
-
return void 0;
|
|
1416
|
-
}
|
|
1417
|
-
throw new Error("Failed to read \"".concat(filepath, "\": ").concat(err.message));
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
async function readJson5File(_ref3) {
|
|
1421
|
-
let {
|
|
1422
|
-
filename,
|
|
1423
|
-
basePath
|
|
1424
|
-
} = _ref3;
|
|
1425
|
-
const content = await readFileContent({
|
|
1426
|
-
filename,
|
|
1427
|
-
basePath
|
|
1428
|
-
});
|
|
1429
|
-
if (!content) {
|
|
1430
|
-
return void 0;
|
|
1431
|
-
}
|
|
1432
|
-
return parseJson5(content, filename);
|
|
1433
|
-
}
|
|
1434
|
-
function parseJson5(content, errorKey) {
|
|
1435
|
-
try {
|
|
1436
|
-
return lib.parse(content);
|
|
1437
|
-
} catch (err) {
|
|
1438
|
-
throw new Error("Error parsing \"".concat(errorKey, "\": ").concat(err.message));
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
function errorToUndefined(err) {
|
|
1442
|
-
if (err instanceof TypeError) {
|
|
1443
|
-
throw err;
|
|
1444
|
-
}
|
|
1445
|
-
return void 0;
|
|
1446
|
-
}
|
|
1447
|
-
const stat = util__default.default.promisify(fs__default.default.stat);
|
|
1448
|
-
const readFile$1 = util__default.default.promisify(fs__default.default.readFile);
|
|
1449
|
-
const allowedPartProps = ["name", "implements", "path", "description"];
|
|
1450
|
-
const disallowedPluginProps = ["api", "project", "plugins", "env"];
|
|
1451
|
-
async function getPaths(options) {
|
|
1452
|
-
const {
|
|
1453
|
-
basePath
|
|
1454
|
-
} = options;
|
|
1455
|
-
const manifest = await readManifest(options);
|
|
1456
|
-
if (!manifest.paths) {
|
|
1457
|
-
return null;
|
|
1458
|
-
}
|
|
1459
|
-
return absolutifyPaths(manifest.paths, basePath);
|
|
1460
|
-
}
|
|
1461
|
-
function absolutifyPaths(paths, basePath) {
|
|
1462
|
-
const getPath = relative => relative ? path__default.default.resolve(path__default.default.join(basePath, relative)) : void 0;
|
|
1463
|
-
return paths ? {
|
|
1464
|
-
basePath,
|
|
1465
|
-
compiled: getPath(paths.compiled),
|
|
1466
|
-
source: getPath(paths.source)
|
|
1467
|
-
} : {
|
|
1468
|
-
basePath
|
|
1469
|
-
};
|
|
1470
|
-
}
|
|
1471
|
-
async function readManifest(options) {
|
|
1472
|
-
const {
|
|
1473
|
-
basePath,
|
|
1474
|
-
validate = true
|
|
1475
|
-
} = options;
|
|
1476
|
-
const manifestPath = path__default.default.normalize(path__default.default.join(basePath, "sanity.json"));
|
|
1477
|
-
let content;
|
|
1478
|
-
try {
|
|
1479
|
-
content = await readFile$1(manifestPath, "utf8");
|
|
1480
|
-
} catch (err) {
|
|
1481
|
-
if (err.code === "ENOENT") {
|
|
1482
|
-
throw new Error("No sanity.json found. sanity.json is required for plugins to function. Use `".concat(_package.pkg.binname, " init` for a new plugin, or create an empty `sanity.json` with an empty object (`{}`) for existing ones."));
|
|
1483
|
-
}
|
|
1484
|
-
throw new Error("Failed to read \"".concat(manifestPath, "\": ").concat(err.message));
|
|
1485
|
-
}
|
|
1486
|
-
let parsed;
|
|
1487
|
-
try {
|
|
1488
|
-
parsed = JSON.parse(content);
|
|
1489
|
-
} catch (err) {
|
|
1490
|
-
throw new Error("Error parsing \"".concat(manifestPath, "\": ").concat(err.message));
|
|
1491
|
-
}
|
|
1492
|
-
if (validate) {
|
|
1493
|
-
await validateManifest(parsed, options);
|
|
1494
|
-
}
|
|
1495
|
-
return parsed;
|
|
1496
|
-
}
|
|
1497
|
-
async function validateManifest(manifest, opts) {
|
|
1498
|
-
const options = {
|
|
1499
|
-
isPlugin: true,
|
|
1500
|
-
...opts
|
|
1501
|
-
};
|
|
1502
|
-
if (!isObject$1(manifest)) {
|
|
1503
|
-
throw new Error("Invalid sanity.json: Root must be an object");
|
|
1504
|
-
}
|
|
1505
|
-
if (options.isPlugin) {
|
|
1506
|
-
await validatePluginManifest(manifest, options);
|
|
1507
|
-
} else {
|
|
1508
|
-
await validateProjectManifest(manifest);
|
|
1509
|
-
}
|
|
1510
|
-
if ("root" in manifest && typeof manifest.root !== "boolean") {
|
|
1511
|
-
throw new Error("Invalid sanity.json: \"root\" property must be a boolean if declared");
|
|
1512
|
-
}
|
|
1513
|
-
await validateParts(manifest, {
|
|
1514
|
-
...options,
|
|
1515
|
-
paths: absolutifyPaths(manifest.paths, options.basePath)
|
|
1516
|
-
});
|
|
1517
|
-
}
|
|
1518
|
-
function validateProjectManifest(manifest) {
|
|
1519
|
-
if ("paths" in manifest) {
|
|
1520
|
-
throw new Error("Invalid sanity.json: \"paths\" property has no meaning in a project manifest");
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
async function validatePluginManifest(manifest, options) {
|
|
1524
|
-
const disallowed = Object.keys(manifest).filter(key => disallowedPluginProps.includes(key)).map(key => "\"".concat(key, "\""));
|
|
1525
|
-
if (disallowed.length > 0) {
|
|
1526
|
-
const plural = disallowed.length > 1 ? "s" : "";
|
|
1527
|
-
const joined = disallowed.join(", ");
|
|
1528
|
-
throw new Error("Invalid sanity.json: Key".concat(plural, " ").concat(joined, " ").concat(plural ? "are" : "is", " not allowed in a plugin manifest"));
|
|
1529
|
-
}
|
|
1530
|
-
if (manifest.root) {
|
|
1531
|
-
throw new Error("Invalid sanity.json: \"root\" cannot be truthy in a plugin manifest");
|
|
1532
|
-
}
|
|
1533
|
-
await validatePaths$1(manifest, options);
|
|
1534
|
-
}
|
|
1535
|
-
async function validatePaths$1(manifest, options) {
|
|
1536
|
-
var _srcStats;
|
|
1537
|
-
if (!("paths" in manifest)) {
|
|
1538
|
-
return;
|
|
1539
|
-
}
|
|
1540
|
-
if (!isObject$1(manifest.paths)) {
|
|
1541
|
-
throw new Error("Invalid sanity.json: \"paths\" must be an object if declared");
|
|
1542
|
-
}
|
|
1543
|
-
if (typeof manifest.paths.compiled !== "string") {
|
|
1544
|
-
throw new Error("Invalid sanity.json: \"paths\" must have a (string) \"compiled\" property if declared");
|
|
1545
|
-
}
|
|
1546
|
-
if (typeof manifest.paths.source !== "string") {
|
|
1547
|
-
throw new Error("Invalid sanity.json: \"paths\" must have a (string) \"source\" property if declared");
|
|
1548
|
-
}
|
|
1549
|
-
const sourcePath = path__default.default.resolve(options.basePath, manifest.paths.source);
|
|
1550
|
-
let srcStats;
|
|
1551
|
-
try {
|
|
1552
|
-
srcStats = await stat(sourcePath);
|
|
1553
|
-
} catch (err) {
|
|
1554
|
-
if (err.code === "ENOENT") {
|
|
1555
|
-
throw new Error("sanity.json references \"source\" path which does not exist: \"".concat(sourcePath, "\""));
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
if (!((_srcStats = srcStats) !== null && _srcStats !== void 0 && _srcStats.isDirectory())) {
|
|
1559
|
-
throw new Error("sanity.json references \"source\" path which is not a directory: \"".concat(sourcePath, "\""));
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
async function validateParts(manifest, options) {
|
|
1563
|
-
if (!("parts" in manifest)) {
|
|
1564
|
-
return;
|
|
1565
|
-
}
|
|
1566
|
-
if (!Array.isArray(manifest.parts)) {
|
|
1567
|
-
throw new Error("Invalid sanity.json: \"parts\" must be an array if declared");
|
|
1568
|
-
}
|
|
1569
|
-
let i = 0;
|
|
1570
|
-
for (const part of manifest.parts) {
|
|
1571
|
-
await validatePart(part, i, options);
|
|
1572
|
-
i++;
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
async function validatePart(part, index, options) {
|
|
1576
|
-
if (!isObject$1(part)) {
|
|
1577
|
-
throw new Error("Invalid sanity.json: \"parts[".concat(index, "]\" must be an object"));
|
|
1578
|
-
}
|
|
1579
|
-
validateAllowedPartKeys(part, index);
|
|
1580
|
-
validatePartStringValues(part, index);
|
|
1581
|
-
validatePartNames(part, index, options);
|
|
1582
|
-
await validatePartFiles(part, index, options);
|
|
1583
|
-
}
|
|
1584
|
-
async function validatePartFiles(part, index, options) {
|
|
1585
|
-
const {
|
|
1586
|
-
verifyCompiledParts,
|
|
1587
|
-
verifySourceParts,
|
|
1588
|
-
paths
|
|
1589
|
-
} = options;
|
|
1590
|
-
if (!(part !== null && part !== void 0 && part.path)) {
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
const ext = path__default.default.extname(part.path);
|
|
1594
|
-
if (paths !== null && paths !== void 0 && paths.source && ext && ext !== ".js" && buildExtensions.includes(ext)) {
|
|
1595
|
-
throw new Error("Invalid sanity.json: Part path has extension which is not applicable after compiling. ".concat(ext, " becomes .js after compiling. Specify filename without extension (").concat(path__default.default.basename(part.path), ") (parts[").concat(index, "])"));
|
|
1596
|
-
}
|
|
1597
|
-
if (!verifySourceParts && !verifyCompiledParts) {
|
|
1598
|
-
return;
|
|
1599
|
-
}
|
|
1600
|
-
const [srcExists, outDirExists] = await Promise.all([hasSourceFile(part.path, paths), verifyCompiledParts && hasCompiledFile(part.path, paths)]);
|
|
1601
|
-
if (!srcExists) {
|
|
1602
|
-
throw new Error("Invalid sanity.json: Part path references file that does not exist in source directory (".concat((paths === null || paths === void 0 ? void 0 : paths.source) || (paths === null || paths === void 0 ? void 0 : paths.basePath), ") (parts[").concat(index, "])"));
|
|
1603
|
-
}
|
|
1604
|
-
if (verifyCompiledParts && !outDirExists) {
|
|
1605
|
-
throw new Error("Invalid sanity.json: Part path references file (\"".concat(part.path, "\") that does not exist in compiled directory (").concat(paths === null || paths === void 0 ? void 0 : paths.compiled, ") (parts[").concat(index, "])"));
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
function validatePartNames(part, index, options) {
|
|
1609
|
-
var _part$name, _part$implements;
|
|
1610
|
-
const pluginName = options.pluginName ? options.pluginName.replace(/^sanity-plugin-/, "") : "";
|
|
1611
|
-
if (!(part !== null && part !== void 0 && part.name) || !(part !== null && part !== void 0 && (_part$name = part.name) !== null && _part$name !== void 0 && _part$name.startsWith("part:".concat(pluginName, "/")))) {
|
|
1612
|
-
throw new Error("Invalid sanity.json: \"name\" must be prefixed with \"part:".concat(pluginName, "/\" - got \"").concat(part === null || part === void 0 ? void 0 : part.name, "\" (parts[").concat(index, "])"));
|
|
1613
|
-
}
|
|
1614
|
-
if (!(part !== null && part !== void 0 && (_part$implements = part.implements) !== null && _part$implements !== void 0 && _part$implements.startsWith("part:"))) {
|
|
1615
|
-
throw new Error("Invalid sanity.json: \"implements\" must be prefixed with \"part:\" - got \"".concat(part === null || part === void 0 ? void 0 : part.implements, "\" (parts[").concat(index, "])"));
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
function validateAllowedPartKeys(part, index) {
|
|
1619
|
-
const disallowed = Object.keys(part).filter(key => !allowedPartProps.includes(key)).map(key => "\"".concat(key, "\""));
|
|
1620
|
-
if (disallowed.length > 0) {
|
|
1621
|
-
const plural = disallowed.length > 1 ? "s" : "";
|
|
1622
|
-
const joined = disallowed.join(", ");
|
|
1623
|
-
throw new Error("Invalid sanity.json: Key".concat(plural, " ").concat(joined, " ").concat(plural ? "are" : "is", " not allowed in a part declaration (parts[").concat(index, "])"));
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
function validatePartStringValues(part, index) {
|
|
1627
|
-
const nonStrings = Object.keys(part).filter(key => typeof part[key] !== "string").map(key => "\"".concat(key, "\""));
|
|
1628
|
-
if (nonStrings.length > 0) {
|
|
1629
|
-
const plural = nonStrings.length > 1 ? "s" : "";
|
|
1630
|
-
const joined = nonStrings.join(", ");
|
|
1631
|
-
throw new Error("Invalid sanity.json: Key".concat(plural, " ").concat(joined, " should be of type string (parts[").concat(index, "])"));
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
function isObject$1(obj) {
|
|
1635
|
-
return !Array.isArray(obj) && obj !== null && typeof obj === "object";
|
|
1636
|
-
}
|
|
1637
|
-
async function hasSanityJson(basePath) {
|
|
1638
|
-
const file = await readJsonFile(path__default.default.join(basePath, "sanity.json")).catch(errorToUndefined);
|
|
1639
|
-
return {
|
|
1640
|
-
exists: Boolean(file),
|
|
1641
|
-
isRoot: Boolean(file && file.root)
|
|
1642
|
-
};
|
|
1643
|
-
}
|
|
1644
|
-
async function findStudioV3Config(basePath) {
|
|
1645
|
-
const jsFile = "sanity.config.js";
|
|
1646
|
-
const jsExists = await fileExists(path__default.default.join(basePath, jsFile));
|
|
1647
|
-
if (jsExists) {
|
|
1648
|
-
return {
|
|
1649
|
-
v3ConfigFile: jsFile
|
|
1650
|
-
};
|
|
1651
|
-
}
|
|
1652
|
-
const tsFile = "sanity.config.ts";
|
|
1653
|
-
const tsExists = await fileExists(path__default.default.join(basePath, tsFile));
|
|
1654
|
-
return {
|
|
1655
|
-
v3ConfigFile: tsExists ? tsFile : void 0
|
|
1656
|
-
};
|
|
1657
|
-
}
|
|
1658
|
-
const lockedDependencies = {
|
|
1659
|
-
"styled-components": "^5.2"
|
|
1660
|
-
};
|
|
1661
|
-
function resolveLatestVersions(packages) {
|
|
1662
|
-
const versions = {};
|
|
1663
|
-
for (const pkgName of packages) {
|
|
1664
|
-
versions[pkgName] = pkgName in lockedDependencies ? lockedDependencies[pkgName] : "latest";
|
|
1665
|
-
}
|
|
1666
|
-
return pProps__default.default(versions, async (range, pkgName) => {
|
|
1667
|
-
const version = await getLatestVersion__default.default(pkgName, {
|
|
1668
|
-
range
|
|
1669
|
-
});
|
|
1670
|
-
if (!version) {
|
|
1671
|
-
throw new Error("Found no version for ".concat(pkgName));
|
|
1672
|
-
}
|
|
1673
|
-
return rangeify(version);
|
|
1674
|
-
}, {
|
|
1675
|
-
concurrency: 8
|
|
1676
|
-
});
|
|
1677
|
-
}
|
|
1678
|
-
function rangeify(version) {
|
|
1679
|
-
return "^".concat(version);
|
|
1680
|
-
}
|
|
1681
|
-
const mergedPackages = ["@sanity/base", "@sanity/core", "@sanity/types", "@sanity/data-aspects", "@sanity/default-layout", "@sanity/default-login", "@sanity/desk-tool", "@sanity/field", "@sanity/form-builder", "@sanity/initial-value-templates", "@sanity/language-filter", "@sanity/production-preview", "@sanity/react-hooks", "@sanity/resolver", "@sanity/state-router", "@sanity/structure", "@sanity/studio-hints"].sort();
|
|
1682
|
-
const deprecatedDevDeps = ["tsdx", "sanipack", "parcel", "@parcel/packager-ts", "@parcel/transformer-typescript-types"];
|
|
1683
|
-
const expectedScripts = {
|
|
1684
|
-
build: "run-s clean && plugin-kit verify-package --silent && pkg-utils build --strict && pkg-utils --strict",
|
|
1685
|
-
watch: "pkg-utils watch --strict",
|
|
1686
|
-
"link-watch": "plugin-kit link-watch",
|
|
1687
|
-
prepublishOnly: "run-s build"
|
|
1688
|
-
};
|
|
1689
|
-
const expectedModulesFields = ["source", "exports", "main", "module", "files"];
|
|
1690
|
-
function filesWithSuffixes(fileBases, suffixes) {
|
|
1691
|
-
return fileBases.flatMap(file => suffixes.map(suffix => "".concat(file, ".").concat(suffix)));
|
|
1692
|
-
}
|
|
1693
|
-
function validateNodeEngine(packageJson) {
|
|
1694
|
-
var _packageJson$engines;
|
|
1695
|
-
const nodeVersionRange = ">=14";
|
|
1696
|
-
if (!((_packageJson$engines = packageJson.engines) !== null && _packageJson$engines !== void 0 && (_packageJson$engines = _packageJson$engines.node) !== null && _packageJson$engines !== void 0 && _packageJson$engines.startsWith(nodeVersionRange))) {
|
|
1697
|
-
var _packageJson$engines2;
|
|
1698
|
-
return [outdent__default.default(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n Expected package.json to contain engines.node: \">=14\" to ensure Studio compatible builds,\n but it was: ", "\n\n Please add the following to package.json:\n\n \"engines\": {\n \"node\": \"", "\"\n }"])), (_packageJson$engines2 = packageJson.engines) === null || _packageJson$engines2 === void 0 ? void 0 : _packageJson$engines2.node, nodeVersionRange).trimStart()];
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
function validateModule(packageJson, options) {
|
|
1702
|
-
const {
|
|
1703
|
-
outDir
|
|
1704
|
-
} = options;
|
|
1705
|
-
const errors = [];
|
|
1706
|
-
const missingFields = expectedModulesFields.filter(field => !packageJson[field]);
|
|
1707
|
-
if (missingFields.length) {
|
|
1708
|
-
errors.push(outdent__default.default(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n Expected source, exports, main, module and files entries in package.json, but ", " where missing.\n\n Example:\n\n Given a plugin with entry-point in src/index.ts, using default @sanity/pkg-utils build command,\n package.json should contain the following entries to ensure that commonjs and esm outputs are built into ", ":\n\n \"source\": \"./src/index.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./", "/index.d.ts\",\n \"source\": \"./src/index.ts\",\n \"require\": \"./", "/index.js\",\n \"import\": \"./", "/index.esm.js\",\n \"default\": \"./", "/index.js\"\n }\n },\n \"main\": \"./", "/index.js\",\n \"module\": \"./", "/index.esm.js\",\n \"types\": \"./", "/index.d.ts\",\n \"files\": [\n \"", "\",\n \"src\"\n ],\n\n Refer to @sanity/pkg-utils for more: https://github.com/sanity-io/pkg-utils#sanitypkg-utils\n "])), missingFields.join(", "), outDir, outDir, outDir, outDir, outDir, outDir, outDir, outDir, outDir).trimStart());
|
|
1709
|
-
}
|
|
1710
|
-
if (packageJson.typings) {
|
|
1711
|
-
errors.push(outdent__default.default(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Found typings field in package.json. Use types instead."]))));
|
|
1712
|
-
}
|
|
1713
|
-
return errors;
|
|
1714
|
-
}
|
|
1715
|
-
function validateScripts(packageJson) {
|
|
1716
|
-
const errors = [];
|
|
1717
|
-
const divergentScripts = Object.entries(expectedScripts).filter(_ref4 => {
|
|
1718
|
-
var _packageJson$scripts;
|
|
1719
|
-
let [key, expectedCommand] = _ref4;
|
|
1720
|
-
const command = (_packageJson$scripts = packageJson.scripts) === null || _packageJson$scripts === void 0 ? void 0 : _packageJson$scripts[key];
|
|
1721
|
-
return !command || !command.includes(expectedCommand);
|
|
1722
|
-
});
|
|
1723
|
-
if (divergentScripts.length) {
|
|
1724
|
-
errors.push(outdent__default.default(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n The following script commands did not contain expected defaults: ", "\n\n This checks for that the commands-strings includes these terms.\n\n Please add the following to your package.json \"scripts\":\n\n ", "\n "])), divergentScripts.map(_ref5 => {
|
|
1725
|
-
let [key] = _ref5;
|
|
1726
|
-
return key;
|
|
1727
|
-
}).join(", "), divergentScripts.map(_ref6 => {
|
|
1728
|
-
let [key, value] = _ref6;
|
|
1729
|
-
return "\"".concat(key, "\": \"").concat(value, "\"");
|
|
1730
|
-
}).join(",\n")).trimStart());
|
|
1731
|
-
}
|
|
1732
|
-
return errors;
|
|
1733
|
-
}
|
|
1734
|
-
async function validateTsConfig(ts, options) {
|
|
1735
|
-
const {
|
|
1736
|
-
basePath,
|
|
1737
|
-
outDir,
|
|
1738
|
-
tsconfig
|
|
1739
|
-
} = options;
|
|
1740
|
-
const errors = [];
|
|
1741
|
-
const expectedCompilerOptions = {
|
|
1742
|
-
moduleResolution: "node",
|
|
1743
|
-
target: "esnext",
|
|
1744
|
-
module: "esnext",
|
|
1745
|
-
emitDeclarationOnly: true,
|
|
1746
|
-
esModuleInterop: true,
|
|
1747
|
-
skipLibCheck: true,
|
|
1748
|
-
isolatedModules: true,
|
|
1749
|
-
downlevelIteration: true,
|
|
1750
|
-
declaration: true,
|
|
1751
|
-
allowSyntheticDefaultImports: true,
|
|
1752
|
-
rootDir: ".",
|
|
1753
|
-
outDir
|
|
1754
|
-
};
|
|
1755
|
-
const wrongEntries = Object.entries(expectedCompilerOptions).filter(_ref7 => {
|
|
1756
|
-
var _option;
|
|
1757
|
-
let [key, value] = _ref7;
|
|
1758
|
-
let option = ts.options[key];
|
|
1759
|
-
if (key === "rootDir" && typeof option === "string") {
|
|
1760
|
-
option = path__default.default.relative(basePath, option) || ".";
|
|
1761
|
-
}
|
|
1762
|
-
if (key === "outDir" && typeof option === "string") {
|
|
1763
|
-
option = path__default.default.relative(basePath, option) || ".";
|
|
1764
|
-
}
|
|
1765
|
-
if (key === "moduleResolution" && option === 2) {
|
|
1766
|
-
option = "node";
|
|
1767
|
-
}
|
|
1768
|
-
if (key === "target" && option === 99) {
|
|
1769
|
-
option = "esnext";
|
|
1770
|
-
}
|
|
1771
|
-
if (key === "module" && option === 99) {
|
|
1772
|
-
option = "esnext";
|
|
1773
|
-
}
|
|
1774
|
-
return typeof value === "string" && typeof option === "string" ? value.toLowerCase() !== ((_option = option) === null || _option === void 0 ? void 0 : _option.toLowerCase()) : value !== option;
|
|
1775
|
-
});
|
|
1776
|
-
if (wrongEntries.length) {
|
|
1777
|
-
const expectedOutput = wrongEntries.map(_ref8 => {
|
|
1778
|
-
let [key, value] = _ref8;
|
|
1779
|
-
return "\"".concat(key, "\": ").concat(typeof value === "string" ? "\"".concat(value, "\"") : value, ",");
|
|
1780
|
-
}).join("\n");
|
|
1781
|
-
errors.push(outdent__default.default(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n Recommended ", " compilerOptions missing:\n\n The following fields had unexpected values: [", "]\n Expected to find these values:\n ", "\n\n Please update your ", " accordingly.\n "])), tsconfig, wrongEntries.map(_ref9 => {
|
|
1782
|
-
let [key] = _ref9;
|
|
1783
|
-
return key;
|
|
1784
|
-
}).join(", "), expectedOutput, tsconfig).trimStart());
|
|
1785
|
-
}
|
|
1786
|
-
return errors;
|
|
1787
|
-
}
|
|
1788
|
-
function validatePkgUtilsDependency(_ref10) {
|
|
1789
|
-
let {
|
|
1790
|
-
devDependencies
|
|
1791
|
-
} = _ref10;
|
|
1792
|
-
if (!(devDependencies !== null && devDependencies !== void 0 && devDependencies["@sanity/pkg-utils"])) {
|
|
1793
|
-
return [outdent__default.default(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n package.json does not list @sanity/pkg-utils as a devDependency.\n @sanity/pkg-utils replaced parcel as the recommended build tool in @sanity/plugin-kit 2.0.0\n\n Please add it by running 'npm install --save-dev @sanity/pkg-utils'.\n "]))).trimStart()];
|
|
1794
|
-
}
|
|
1795
|
-
return [];
|
|
1796
|
-
}
|
|
1797
|
-
function validateSanityDependencies(packageJson) {
|
|
1798
|
-
const {
|
|
1799
|
-
dependencies,
|
|
1800
|
-
devDependencies,
|
|
1801
|
-
peerDependencies
|
|
1802
|
-
} = packageJson;
|
|
1803
|
-
const allDependencies = {
|
|
1804
|
-
...dependencies,
|
|
1805
|
-
...devDependencies,
|
|
1806
|
-
...peerDependencies
|
|
1807
|
-
};
|
|
1808
|
-
const illegalDeps = Object.keys(allDependencies).filter(dep => mergedPackages.includes(dep));
|
|
1809
|
-
const deps = new Set(illegalDeps);
|
|
1810
|
-
const unique = [...deps.values()];
|
|
1811
|
-
if (unique.length) {
|
|
1812
|
-
return [outdent__default.default(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n package.json depends on \"@sanity/*\" packages that have moved into \"sanity\" package.\n\n The following dependencies should be replaced with \"sanity\":\n - ", "\n\n Refer to the reference docs to find replacement imports:\n ", "\n "])), unique.join("\n- "), cli.urls.refDocs).trimStart()];
|
|
1813
|
-
}
|
|
1814
|
-
return [];
|
|
1815
|
-
}
|
|
1816
|
-
function validateDeprecatedDependencies(packageJson) {
|
|
1817
|
-
const {
|
|
1818
|
-
dependencies,
|
|
1819
|
-
devDependencies,
|
|
1820
|
-
peerDependencies
|
|
1821
|
-
} = packageJson;
|
|
1822
|
-
const allDependencies = {
|
|
1823
|
-
...dependencies,
|
|
1824
|
-
...devDependencies,
|
|
1825
|
-
...peerDependencies
|
|
1826
|
-
};
|
|
1827
|
-
const illegalDeps = Object.keys(allDependencies).filter(dep => deprecatedDevDeps.includes(dep));
|
|
1828
|
-
const deps = new Set(illegalDeps);
|
|
1829
|
-
const unique = [...deps.values()];
|
|
1830
|
-
if (unique.length) {
|
|
1831
|
-
return [outdent__default.default(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n package.json contains deprecated dependencies that should be removed:\n - ", "\n "])), unique.join("\n- ")).trimStart()];
|
|
1832
|
-
}
|
|
1833
|
-
return [];
|
|
1834
|
-
}
|
|
1835
|
-
async function validateBabelConfig(_ref11) {
|
|
1836
|
-
let {
|
|
1837
|
-
basePath
|
|
1838
|
-
} = _ref11;
|
|
1839
|
-
const suffixes = ["json", "js", "cjs", "mjs"];
|
|
1840
|
-
const babelFileNames = [".babelrc", "babel.config"];
|
|
1841
|
-
const filenames = [".babelrc", ...filesWithSuffixes(babelFileNames, suffixes)];
|
|
1842
|
-
const babelFiles = [];
|
|
1843
|
-
for (const filename of filenames) {
|
|
1844
|
-
const filepath = path__default.default.normalize(path__default.default.join(basePath, filename));
|
|
1845
|
-
if (await fileExists(filepath)) {
|
|
1846
|
-
babelFiles.push(filename);
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
if (babelFiles.length) {
|
|
1850
|
-
return [outdent__default.default(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n Found babel-config file: [", "]. When using default @sanity/plugin-kit build command,\n this is probably not needed.\n\n Delete the file, or disable this check.\n "])), babelFiles.join(", ")).trimStart()];
|
|
1851
|
-
}
|
|
1852
|
-
return [];
|
|
1853
|
-
}
|
|
1854
|
-
async function validateStudioConfig(_ref12) {
|
|
1855
|
-
let {
|
|
1856
|
-
basePath
|
|
1857
|
-
} = _ref12;
|
|
1858
|
-
const suffixes = ["ts", "js", "tsx", "jsx"];
|
|
1859
|
-
const filenames = filesWithSuffixes(["sanity.config", "sanity.cli"], suffixes);
|
|
1860
|
-
const files = {};
|
|
1861
|
-
for (const filename of filenames) {
|
|
1862
|
-
const filepath = path__default.default.normalize(path__default.default.join(basePath, filename));
|
|
1863
|
-
files[filename] = await fileExists(filepath);
|
|
1864
|
-
}
|
|
1865
|
-
const sanityJson = await readJson5File({
|
|
1866
|
-
basePath,
|
|
1867
|
-
filename: "sanity.json"
|
|
1868
|
-
});
|
|
1869
|
-
const hasConfigFile = fileBase => filesWithSuffixes([fileBase], suffixes).some(filename => files[filename]);
|
|
1870
|
-
const hasCliConfig = hasConfigFile("sanity.cli");
|
|
1871
|
-
const hasStudioConfig = hasConfigFile("sanity.config");
|
|
1872
|
-
const errors = [];
|
|
1873
|
-
if (sanityJson) {
|
|
1874
|
-
var _sanityJson$plugins;
|
|
1875
|
-
const info = [outdent__default.default(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n Found sanity.json. This file is not used by Sanity Studio V3.\n\n Please consult the Studio V3 migration guide:\n ", "\n It will detail how to convert sanity.json to sanity.config.ts (or .js) and sanity.cli.ts (or .js) equivalents.\n "])), cli.urls.migrationGuideStudio).trimStart(), ((_sanityJson$plugins = sanityJson.plugins) === null || _sanityJson$plugins === void 0 ? void 0 : _sanityJson$plugins.length) && outdent__default.default(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n For V3 versions and alternatives to V2 plugins, please refer to the Sanity Exchange:\n ", "\n "])), cli.urls.sanityExchange).trimStart()].filter(s => !!s);
|
|
1876
|
-
errors.push(info.join("\n\n"));
|
|
1877
|
-
}
|
|
1878
|
-
if (!hasCliConfig) {
|
|
1879
|
-
var _sanityJson$api$proje, _sanityJson$api, _sanityJson$api$datas, _sanityJson$api2;
|
|
1880
|
-
errors.push(outdent__default.default(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n sanity.cli.(", ") missing. Please create a file named sanity.cli.ts with the following content:\n\n ", "\n\n Make sure to replace the projectId and dataset fields with your own.\n\n For more, see ", "\n "])), suffixes.join(" | "), chalk__default.default.green(outdent__default.default(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n import {createCliConfig} from 'sanity/cli'\n\n export default createCliConfig({\n api: {\n projectId: '", "',\n dataset: '", "',\n }\n })"])), (_sanityJson$api$proje = sanityJson === null || sanityJson === void 0 || (_sanityJson$api = sanityJson.api) === null || _sanityJson$api === void 0 ? void 0 : _sanityJson$api.projectId) !== null && _sanityJson$api$proje !== void 0 ? _sanityJson$api$proje : "project-id", (_sanityJson$api$datas = sanityJson === null || sanityJson === void 0 || (_sanityJson$api2 = sanityJson.api) === null || _sanityJson$api2 === void 0 ? void 0 : _sanityJson$api2.dataset) !== null && _sanityJson$api$datas !== void 0 ? _sanityJson$api$datas : "dataset")), cli.urls.migrationGuideStudio).trimStart());
|
|
1881
|
-
}
|
|
1882
|
-
if (!hasStudioConfig) {
|
|
1883
|
-
var _sanityJson$api$proje2, _sanityJson$api3, _sanityJson$api$datas2, _sanityJson$api4;
|
|
1884
|
-
errors.push(outdent__default.default(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n sanity.config.(", ") missing. At a minimum sanity.config.ts should contain:\n\n ", "\n\n Make sure to replace the projectId and dataset fields with your own.\n\n For more, see ", "\n "])), suffixes.join(" | "), chalk__default.default.green(outdent__default.default(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n import { defineConfig } from \"sanity\"\n import { deskTool } from \"sanity/desk\"\n\n export default defineConfig({\n name: \"default\",\n\n projectId: '", "',\n dataset: '", "',\n\n plugins: [\n deskTool(),\n ],\n\n schema: {\n types: [\n /* put your v2 schema-types here */\n ],\n },\n })"])), (_sanityJson$api$proje2 = sanityJson === null || sanityJson === void 0 || (_sanityJson$api3 = sanityJson.api) === null || _sanityJson$api3 === void 0 ? void 0 : _sanityJson$api3.projectId) !== null && _sanityJson$api$proje2 !== void 0 ? _sanityJson$api$proje2 : "project-id", (_sanityJson$api$datas2 = sanityJson === null || sanityJson === void 0 || (_sanityJson$api4 = sanityJson.api) === null || _sanityJson$api4 === void 0 ? void 0 : _sanityJson$api4.dataset) !== null && _sanityJson$api$datas2 !== void 0 ? _sanityJson$api$datas2 : "dataset")).trimStart(), cli.urls.migrationGuideStudio).trimStart());
|
|
1885
|
-
}
|
|
1886
|
-
return errors.length ? [errors.join("\n\n---\n\n")] : [];
|
|
1887
|
-
}
|
|
1888
|
-
async function validatePluginSanityJson(_ref13) {
|
|
1889
|
-
var _sanityJson$parts, _packageJson$dependen;
|
|
1890
|
-
let {
|
|
1891
|
-
basePath,
|
|
1892
|
-
packageJson
|
|
1893
|
-
} = _ref13;
|
|
1894
|
-
const sanityJson = await readJson5File({
|
|
1895
|
-
basePath,
|
|
1896
|
-
filename: "sanity.json"
|
|
1897
|
-
});
|
|
1898
|
-
const expectedDefaults = {
|
|
1899
|
-
parts: [{
|
|
1900
|
-
implements: "part:@sanity/base/sanity-root",
|
|
1901
|
-
path: "./v2-incompatible.js"
|
|
1902
|
-
}]
|
|
1903
|
-
};
|
|
1904
|
-
const hasSinglePart = sanityJson && Object.keys(sanityJson).length === 1 && (sanityJson === null || sanityJson === void 0 ? void 0 : sanityJson.parts) && sanityJson.parts.length === 1;
|
|
1905
|
-
const firstPart = hasSinglePart ? sanityJson === null || sanityJson === void 0 || (_sanityJson$parts = sanityJson.parts) === null || _sanityJson$parts === void 0 ? void 0 : _sanityJson$parts[0] : void 0;
|
|
1906
|
-
const correctImplements = (firstPart === null || firstPart === void 0 ? void 0 : firstPart.implements) === expectedDefaults.parts[0].implements;
|
|
1907
|
-
const pathExists = (firstPart === null || firstPart === void 0 ? void 0 : firstPart.path) && (await fileExists(path__default.default.normalize(path__default.default.join(basePath, firstPart.path))));
|
|
1908
|
-
const hasDependency = !!((_packageJson$dependen = packageJson.dependencies) !== null && _packageJson$dependen !== void 0 && _packageJson$dependen[cli.incompatiblePluginPackage]);
|
|
1909
|
-
const isValid = sanityJson && hasSinglePart && correctImplements && pathExists && hasDependency;
|
|
1910
|
-
if (!isValid) {
|
|
1911
|
-
const errors = [!sanityJson ? "sanity.json does not exist" : null, !hasSinglePart ? 'sanity.json should have exactly one entry in "parts", but did not.' : null, !correctImplements ? "The part should implement ".concat(expectedDefaults.parts[0].implements, ", but did not.") : null, firstPart !== null && firstPart !== void 0 && firstPart.path && !pathExists ? "The file in \"path\", ".concat(firstPart === null || firstPart === void 0 ? void 0 : firstPart.path, ", does not exist.") : null, !hasDependency ? outdent__default.default(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n package.json should have ", " as a dependency, but did not.\n Install it with: npm install --save ", "\n "])), cli.incompatiblePluginPackage, cli.incompatiblePluginPackage).trimStart() : null].filter(e => !!e);
|
|
1912
|
-
return [outdent__default.default(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n Invalid sanity.json. It is used for compatibility checking in V2 studios:\n\n - ", "\n\n sanity.json will only be used when incorrectly installing a v3 plugin in a v2 Studio.\n\n This check ensures that sanity.json conforms with the usage section of\n ", "\n "])), errors.join("\n- "), cli.urls.incompatiblePlugin).trimStart()];
|
|
1913
|
-
}
|
|
1914
|
-
return [];
|
|
1915
|
-
}
|
|
1916
|
-
function validatePackageName$1(packageJson) {
|
|
1917
|
-
var _packageJson$name, _packageJson$name2;
|
|
1918
|
-
const valid = validateNpmPackageName__default.default(packageJson.name);
|
|
1919
|
-
if (!valid.validForNewPackages) {
|
|
1920
|
-
return ["Invalid package.json: \"name\" is invalid: ".concat(valid.errors.join(", "))];
|
|
1921
|
-
}
|
|
1922
|
-
const isScoped = (_packageJson$name = packageJson.name) === null || _packageJson$name === void 0 ? void 0 : _packageJson$name.startsWith("@");
|
|
1923
|
-
if (!isScoped && !((_packageJson$name2 = packageJson.name) !== null && _packageJson$name2 !== void 0 && _packageJson$name2.startsWith("sanity-plugin-"))) {
|
|
1924
|
-
return ["Invalid package.json: \"name\" should be prefixed with \"sanity-plugin-\" (or scoped - @your-company/plugin-name)"];
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
async function validateSrcIndexFile(basePath) {
|
|
1928
|
-
const paths = ["index.js", "index.ts"].map(p => path__default.default.join("src", p));
|
|
1929
|
-
const allowedIndexFiles = paths.map(file => path__default.default.join(basePath, file));
|
|
1930
|
-
let hasIndex = false;
|
|
1931
|
-
for (const indexFile of allowedIndexFiles) {
|
|
1932
|
-
hasIndex = hasIndex || (await fileExists(indexFile));
|
|
1933
|
-
}
|
|
1934
|
-
if (!hasIndex) {
|
|
1935
|
-
return [outdent__default.default(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n Expected one of [", "] to exist.\n\n @sanity/pkg-utils expects a non-jsx file to be the source entry-point for the plugin.\n If you currently have JSX in your index file, extract it into a separate file and import it.\n "])), paths.join(", "))];
|
|
1936
|
-
}
|
|
1937
|
-
return [];
|
|
1938
|
-
}
|
|
1939
|
-
async function disallowDuplicateConfig(_ref14) {
|
|
1940
|
-
let {
|
|
1941
|
-
basePath,
|
|
1942
|
-
pkgJson,
|
|
1943
|
-
configKey,
|
|
1944
|
-
files
|
|
1945
|
-
} = _ref14;
|
|
1946
|
-
const found = [];
|
|
1947
|
-
for (const file of files) {
|
|
1948
|
-
const filePath = path__default.default.join(basePath, file);
|
|
1949
|
-
const exits = await fileExists(filePath);
|
|
1950
|
-
if (exits) {
|
|
1951
|
-
found.push(file);
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
if (found.length > 1) {
|
|
1955
|
-
return [outdent__default.default(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n Found multiple config files that serve the same purpose: [", "].\n\n There should be at most one of these files. Delete the rest.\n "])), found.join(", "))];
|
|
1956
|
-
}
|
|
1957
|
-
if (found.length && pkgJson[configKey]) {
|
|
1958
|
-
return [outdent__default.default(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n package.json contains ", ", but there also exists a config file that serves the same purpose.\n Config file: ", "]\n\n Either delete the file or remove ", " entry from package.json.\n "])), configKey, found.join(""), configKey)];
|
|
1959
|
-
}
|
|
1960
|
-
return [];
|
|
1961
|
-
}
|
|
1962
|
-
async function disallowDuplicateEslintConfig(basePath, pkgJson) {
|
|
1963
|
-
return disallowDuplicateConfig({
|
|
1964
|
-
basePath,
|
|
1965
|
-
pkgJson,
|
|
1966
|
-
configKey: "eslint",
|
|
1967
|
-
files: [".eslintrc", ".eslintrc.js", ".eslintrc.cjs", ".eslintrc.yaml", ".eslintrc.yml", ".eslintrc.json"]
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
|
-
async function disallowDuplicatePrettierConfig(basePath, pkgJson) {
|
|
1971
|
-
return disallowDuplicateConfig({
|
|
1972
|
-
basePath,
|
|
1973
|
-
pkgJson,
|
|
1974
|
-
configKey: "prettier",
|
|
1975
|
-
files: [".prettierrc", ".prettierrc.json5", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.js", ".prettierrc.cjs", ".prettier.config,js", ".prettier.config.cjs", ".prettierrc.toml"]
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
const forcedPackageVersions = {};
|
|
1979
|
-
const forcedDevPackageVersions = forcedPackageVersions;
|
|
1980
|
-
const forcedPeerPackageVersions = {
|
|
1981
|
-
react: "^18",
|
|
1982
|
-
"react-dom": "^18",
|
|
1983
|
-
"react-is": "^18",
|
|
1984
|
-
"@types/react": "^18",
|
|
1985
|
-
"@types/react-dom": "^18",
|
|
1986
|
-
sanity: "^3",
|
|
1987
|
-
"styled-components": "^5.2"
|
|
1988
|
-
};
|
|
1989
|
-
const defaultDependencies = [cli.incompatiblePluginPackage];
|
|
1990
|
-
const defaultDevDependencies = ["npm-run-all", "rimraf", "sanity",
|
|
1991
|
-
// peer dependencies of `sanity`
|
|
1992
|
-
"react", "react-dom", "styled-components",
|
|
1993
|
-
// peer dependencies of `styled-components`
|
|
1994
|
-
"react-is"];
|
|
1995
|
-
const defaultPeerDependencies = ["react", "sanity"];
|
|
1996
|
-
const readFile = util__default.default.promisify(fs__default.default.readFile);
|
|
1997
|
-
const pathKeys = ["main", "module", "browser", "types", "typings"];
|
|
1998
|
-
async function getPackage(opts) {
|
|
1999
|
-
const options = {
|
|
2000
|
-
flags: {},
|
|
2001
|
-
...opts
|
|
2002
|
-
};
|
|
2003
|
-
validateOptions(options);
|
|
2004
|
-
const {
|
|
2005
|
-
basePath,
|
|
2006
|
-
validate = true
|
|
2007
|
-
} = options;
|
|
2008
|
-
const manifestPath = path__default.default.normalize(path__default.default.join(basePath, "package.json"));
|
|
2009
|
-
let content;
|
|
2010
|
-
try {
|
|
2011
|
-
content = await readFile(manifestPath, "utf8");
|
|
2012
|
-
} catch (err) {
|
|
2013
|
-
if (err.code === "ENOENT") {
|
|
2014
|
-
throw new Error("No package.json found. package.json is required to publish to npm. Use `".concat(cli.cliName, " init` for a new plugin, or `npm init` for an existing one"));
|
|
2015
|
-
}
|
|
2016
|
-
throw new Error("Failed to read \"".concat(manifestPath, "\": ").concat(err.message));
|
|
2017
|
-
}
|
|
2018
|
-
let parsed;
|
|
2019
|
-
try {
|
|
2020
|
-
parsed = JSON.parse(content);
|
|
2021
|
-
} catch (err) {
|
|
2022
|
-
throw new Error("Error parsing \"".concat(manifestPath, "\": ").concat(err.message));
|
|
2023
|
-
}
|
|
2024
|
-
if (!isObject(parsed)) {
|
|
2025
|
-
throw new Error("Invalid package.json: Root must be an object");
|
|
2026
|
-
}
|
|
2027
|
-
if (validate) {
|
|
2028
|
-
await validatePackage(parsed, options);
|
|
2029
|
-
}
|
|
2030
|
-
return parsed;
|
|
2031
|
-
}
|
|
2032
|
-
async function validatePackage(manifest, opts) {
|
|
2033
|
-
validateOptions(opts);
|
|
2034
|
-
const options = {
|
|
2035
|
-
isPlugin: true,
|
|
2036
|
-
...opts
|
|
2037
|
-
};
|
|
2038
|
-
if (options.isPlugin) {
|
|
2039
|
-
await validatePluginPackage(manifest, options);
|
|
2040
|
-
}
|
|
2041
|
-
validateLockFiles(options);
|
|
2042
|
-
}
|
|
2043
|
-
function validateOptions(opts) {
|
|
2044
|
-
const options = opts || {};
|
|
2045
|
-
if (!isObject(options)) {
|
|
2046
|
-
throw new Error("Options must be an object");
|
|
2047
|
-
}
|
|
2048
|
-
if (typeof options.basePath !== "string") {
|
|
2049
|
-
throw new Error("\"options.basePath\" must be a string (path to plugin base path)");
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
async function validatePluginPackage(manifest, options) {
|
|
2053
|
-
validatePackageName(manifest);
|
|
2054
|
-
await validatePaths(manifest, options);
|
|
2055
|
-
}
|
|
2056
|
-
function validatePackageName(manifest) {
|
|
2057
|
-
if (typeof manifest.name !== "string") {
|
|
2058
|
-
throw new Error("Invalid package.json: \"name\" must be a string");
|
|
2059
|
-
}
|
|
2060
|
-
const valid = validateNpmPackageName__default.default(manifest.name);
|
|
2061
|
-
if (!valid.validForNewPackages) {
|
|
2062
|
-
throw new Error("Invalid package.json: \"name\" is invalid: ".concat(valid.errors.join(", ")));
|
|
2063
|
-
}
|
|
2064
|
-
const isScoped = manifest.name[0] === "@";
|
|
2065
|
-
if (!isScoped && !manifest.name.startsWith("sanity-plugin-")) {
|
|
2066
|
-
throw new Error("Invalid package.json: \"name\" should be prefixed with \"sanity-plugin-\" (or scoped - @your-company/plugin-name)");
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
async function validatePaths(manifest, options) {
|
|
2070
|
-
var _manifest$name;
|
|
2071
|
-
const paths = await getPaths({
|
|
2072
|
-
...options,
|
|
2073
|
-
pluginName: (_manifest$name = manifest.name) !== null && _manifest$name !== void 0 ? _manifest$name : "unknown",
|
|
2074
|
-
verifySourceParts: false,
|
|
2075
|
-
verifyCompiledParts: false
|
|
2076
|
-
});
|
|
2077
|
-
const abs = file => path__default.default.isAbsolute(file) ? file : path__default.default.resolve(path__default.default.join(options.basePath, file));
|
|
2078
|
-
const exists = file => fs__default.default.existsSync(abs(file));
|
|
2079
|
-
const willExist = file => paths && hasSourceEquivalent(abs(file), paths);
|
|
2080
|
-
const withinSourceDir = file => (paths === null || paths === void 0 ? void 0 : paths.source) && abs(file).startsWith(paths.source);
|
|
2081
|
-
const withinTargetDir = file => (paths === null || paths === void 0 ? void 0 : paths.compiled) && abs(file).startsWith(paths.compiled);
|
|
2082
|
-
for (const key of pathKeys) {
|
|
2083
|
-
var _options$flags;
|
|
2084
|
-
if (!(key in manifest)) {
|
|
2085
|
-
continue;
|
|
2086
|
-
}
|
|
2087
|
-
const manifestValue = manifest[key];
|
|
2088
|
-
if (typeof manifestValue !== "string") {
|
|
2089
|
-
throw new Error("Invalid package.json: \"".concat(key, "\" must be a string if defined"));
|
|
2090
|
-
}
|
|
2091
|
-
if (!(options !== null && options !== void 0 && (_options$flags = options.flags) !== null && _options$flags !== void 0 && _options$flags.allowSourceTarget) && paths && withinSourceDir(manifestValue)) {
|
|
2092
|
-
throw new Error("Invalid package.json: \"".concat(key, "\" points to file within source (uncompiled) directory. Use --allow-source-target if you really want to do this."));
|
|
2093
|
-
}
|
|
2094
|
-
const fileExists = exists(manifestValue);
|
|
2095
|
-
if (fileExists && paths && withinTargetDir(manifestValue) && !(await willExist(manifestValue))) {
|
|
2096
|
-
throw new Error("Invalid package.json: \"".concat(key, "\" points to file that will not exist after compiling"));
|
|
2097
|
-
}
|
|
2098
|
-
if (!exists(manifestValue) && !(await willExist(manifestValue))) {
|
|
2099
|
-
if (!paths) {
|
|
2100
|
-
throw new Error("Invalid package.json: \"".concat(key, "\" points to file that does not exist"));
|
|
2101
|
-
}
|
|
2102
|
-
const inOutDir = paths.compiled && !abs(manifestValue).startsWith(paths.compiled);
|
|
2103
|
-
throw new Error(inOutDir ? "Invalid package.json: \"".concat(key, "\" points to file that does not exist, and \"paths\" is not configured to compile to this location") : "Invalid package.json: \"".concat(key, "\" points to file that does not exist, and no equivalent is found in source directory"));
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
function isObject(obj) {
|
|
2108
|
-
return !Array.isArray(obj) && obj !== null && typeof obj === "object";
|
|
2109
|
-
}
|
|
2110
|
-
function validateLockFiles(options) {
|
|
2111
|
-
const npm = fs__default.default.existsSync(path__default.default.join(options.basePath, "package-lock.json"));
|
|
2112
|
-
const yarn = fs__default.default.existsSync(path__default.default.join(options.basePath, "yarn.lock"));
|
|
2113
|
-
if (npm && yarn) {
|
|
2114
|
-
throw new Error("Invalid plugin: contains both package-lock.json and yarn.lock");
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
async function writePackageJson(data, options) {
|
|
2118
|
-
var _prev$version, _prev$keywords;
|
|
2119
|
-
const {
|
|
2120
|
-
user,
|
|
2121
|
-
pluginName,
|
|
2122
|
-
license,
|
|
2123
|
-
description,
|
|
2124
|
-
pkg: prevPkg,
|
|
2125
|
-
gitOrigin
|
|
2126
|
-
} = data;
|
|
2127
|
-
const {
|
|
2128
|
-
outDir,
|
|
2129
|
-
peerDependencies: addPeers,
|
|
2130
|
-
dependencies: addDeps,
|
|
2131
|
-
devDependencies: addDevDeps
|
|
2132
|
-
} = options;
|
|
2133
|
-
const {
|
|
2134
|
-
flags
|
|
2135
|
-
} = options;
|
|
2136
|
-
const prev = prevPkg || {};
|
|
2137
|
-
const usePrettier = flags.prettier !== false;
|
|
2138
|
-
const useEslint = flags.eslint !== false;
|
|
2139
|
-
const useTypescript = flags.eslint !== false;
|
|
2140
|
-
const newDevDependencies = [cli.cliName, "@sanity/pkg-utils"];
|
|
2141
|
-
if (useTypescript) {
|
|
2142
|
-
cli.log.debug("Using TypeScript. Adding to dev dependencies.");
|
|
2143
|
-
newDevDependencies.push("@types/react", "typescript");
|
|
2144
|
-
}
|
|
2145
|
-
if (usePrettier) {
|
|
2146
|
-
cli.log.debug("Using prettier. Adding to dev dependencies.");
|
|
2147
|
-
newDevDependencies.push("prettier", "prettier-plugin-packagejson");
|
|
2148
|
-
}
|
|
2149
|
-
if (useEslint) {
|
|
2150
|
-
cli.log.debug("Using eslint. Adding to dev dependencies.");
|
|
2151
|
-
newDevDependencies.push("eslint", "eslint-config-sanity", "eslint-plugin-react", "eslint-plugin-react-hooks");
|
|
2152
|
-
if (usePrettier) {
|
|
2153
|
-
newDevDependencies.push("eslint-config-prettier", "eslint-plugin-prettier");
|
|
2154
|
-
}
|
|
2155
|
-
if (useTypescript) {
|
|
2156
|
-
newDevDependencies.push("@typescript-eslint/eslint-plugin", "@typescript-eslint/parser");
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
cli.log.debug("Resolving latest versions for %s", newDevDependencies.join(", "));
|
|
2160
|
-
const dependencies = forceDependencyVersions({
|
|
2161
|
-
...(prev.dependencies || {}),
|
|
2162
|
-
...(addDeps || {}),
|
|
2163
|
-
...(await resolveLatestVersions(defaultDependencies))
|
|
2164
|
-
}, forcedPackageVersions);
|
|
2165
|
-
const devDependencies = forceDependencyVersions({
|
|
2166
|
-
...(addDevDeps || {}),
|
|
2167
|
-
...(prev.devDependencies || {}),
|
|
2168
|
-
...(await resolveLatestVersions([...newDevDependencies, ...defaultDevDependencies]))
|
|
2169
|
-
}, forcedDevPackageVersions);
|
|
2170
|
-
const peerDependencies = forceDependencyVersions({
|
|
2171
|
-
...(prev.peerDependencies || {}),
|
|
2172
|
-
...(addPeers || {}),
|
|
2173
|
-
...(await resolveLatestVersions(defaultPeerDependencies))
|
|
2174
|
-
}, forcedPeerPackageVersions);
|
|
2175
|
-
const source = flags.typescript ? "./src/index.ts" : "./src/index.js";
|
|
2176
|
-
const files = [outDir, "sanity.json", "src", "v2-incompatible.js"];
|
|
2177
|
-
files.sort();
|
|
2178
|
-
const forcedOrder = {
|
|
2179
|
-
name: pluginName,
|
|
2180
|
-
version: (_prev$version = prev.version) !== null && _prev$version !== void 0 ? _prev$version : "1.0.0",
|
|
2181
|
-
description: description || "",
|
|
2182
|
-
keywords: (_prev$keywords = prev.keywords) !== null && _prev$keywords !== void 0 ? _prev$keywords : ["sanity", "sanity-plugin"],
|
|
2183
|
-
...urlsFromOrigin(gitOrigin),
|
|
2184
|
-
...repoFromOrigin(gitOrigin),
|
|
2185
|
-
license: license ? license.id : "UNLICENSED",
|
|
2186
|
-
author: user !== null && user !== void 0 && user.email ? "".concat(user.name, " <").concat(user.email, ">") : user === null || user === void 0 ? void 0 : user.name,
|
|
2187
|
-
exports: {
|
|
2188
|
-
".": {
|
|
2189
|
-
...(flags.typescript ? {
|
|
2190
|
-
types: "./".concat(outDir, "/index.d.ts")
|
|
2191
|
-
} : {}),
|
|
2192
|
-
source,
|
|
2193
|
-
import: "./".concat(outDir, "/index.esm.js"),
|
|
2194
|
-
require: "./".concat(outDir, "/index.js"),
|
|
2195
|
-
default: "./".concat(outDir, "/index.esm.js")
|
|
2196
|
-
},
|
|
2197
|
-
"./package.json": "./package.json"
|
|
2198
|
-
},
|
|
2199
|
-
main: "./".concat(outDir, "/index.js"),
|
|
2200
|
-
module: "./".concat(outDir, "/index.esm.js"),
|
|
2201
|
-
source,
|
|
2202
|
-
...(flags.typescript ? {
|
|
2203
|
-
types: "./".concat(outDir, "/index.d.ts")
|
|
2204
|
-
} : {}),
|
|
2205
|
-
files,
|
|
2206
|
-
scripts: {
|
|
2207
|
-
...prev.scripts
|
|
2208
|
-
},
|
|
2209
|
-
dependencies: sortKeys(dependencies),
|
|
2210
|
-
devDependencies: sortKeys(devDependencies),
|
|
2211
|
-
peerDependencies: sortKeys(peerDependencies),
|
|
2212
|
-
engines: {
|
|
2213
|
-
node: ">=14"
|
|
2214
|
-
}
|
|
2215
|
-
};
|
|
2216
|
-
const manifest = {
|
|
2217
|
-
...forcedOrder,
|
|
2218
|
-
// Use already configured values by default (if not otherwise specified)
|
|
2219
|
-
...(prev || {}),
|
|
2220
|
-
// We're de-declaring properties because of key order in package.json
|
|
2221
|
-
...forcedOrder
|
|
2222
|
-
};
|
|
2223
|
-
delete manifest.typings;
|
|
2224
|
-
const differs = JSON.stringify(prev) !== JSON.stringify(manifest);
|
|
2225
|
-
cli.log.debug("Does manifest differ? %s", differs ? "yes" : "no");
|
|
2226
|
-
if (differs) {
|
|
2227
|
-
await writePackageJsonDirect(manifest, options);
|
|
2228
|
-
}
|
|
2229
|
-
return differs ? manifest : prev;
|
|
2230
|
-
}
|
|
2231
|
-
function urlsFromOrigin(gitOrigin) {
|
|
2232
|
-
const details = githubUrlToObject__default.default(gitOrigin);
|
|
2233
|
-
if (!details) {
|
|
2234
|
-
return {};
|
|
2235
|
-
}
|
|
2236
|
-
return {
|
|
2237
|
-
homepage: "https://github.com/".concat(details.user, "/").concat(details.repo, "#readme"),
|
|
2238
|
-
bugs: {
|
|
2239
|
-
url: "https://github.com/".concat(details.user, "/").concat(details.repo, "/issues")
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
}
|
|
2243
|
-
function repoFromOrigin(gitOrigin) {
|
|
2244
|
-
console.log(gitOrigin);
|
|
2245
|
-
if (!gitOrigin) {
|
|
2246
|
-
return {};
|
|
2247
|
-
}
|
|
2248
|
-
return {
|
|
2249
|
-
repository: {
|
|
2250
|
-
type: "git",
|
|
2251
|
-
url: gitOrigin
|
|
2252
|
-
}
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2255
|
-
function addScript(cmd, existing) {
|
|
2256
|
-
if (existing && existing.includes(cmd)) {
|
|
2257
|
-
return existing;
|
|
2258
|
-
}
|
|
2259
|
-
return cmd;
|
|
2260
|
-
}
|
|
2261
|
-
async function addPackageJsonScripts(manifest, options, updateScripts) {
|
|
2262
|
-
const originalScripts = manifest.scripts || {};
|
|
2263
|
-
const scripts = updateScripts({
|
|
2264
|
-
...originalScripts
|
|
2265
|
-
});
|
|
2266
|
-
const differs = Object.keys(scripts).some(key => scripts[key] !== originalScripts[key]);
|
|
2267
|
-
if (differs) {
|
|
2268
|
-
await writePackageJsonDirect({
|
|
2269
|
-
...manifest,
|
|
2270
|
-
scripts
|
|
2271
|
-
}, options);
|
|
2272
|
-
}
|
|
2273
|
-
return differs;
|
|
2274
|
-
}
|
|
2275
|
-
async function writePackageJsonDirect(manifest, _ref15) {
|
|
2276
|
-
let {
|
|
2277
|
-
basePath
|
|
2278
|
-
} = _ref15;
|
|
2279
|
-
await writeJsonFile(path__default.default.join(basePath, "package.json"), manifest);
|
|
2280
|
-
}
|
|
2281
|
-
async function addBuildScripts(manifest, options) {
|
|
2282
|
-
const {
|
|
2283
|
-
outDir
|
|
2284
|
-
} = options;
|
|
2285
|
-
if (!options.flags.scripts) {
|
|
2286
|
-
return false;
|
|
2287
|
-
}
|
|
2288
|
-
return addPackageJsonScripts(manifest, options, scripts => {
|
|
2289
|
-
scripts.build = addScript(expectedScripts.build, scripts.build);
|
|
2290
|
-
scripts.clean = addScript("rimraf ".concat(outDir), scripts.clean);
|
|
2291
|
-
scripts.format = addScript("prettier --write --cache --ignore-unknown .", scripts.format);
|
|
2292
|
-
scripts["link-watch"] = addScript(expectedScripts["link-watch"], scripts["link-watch"]);
|
|
2293
|
-
scripts.lint = addScript("eslint .", scripts.lint);
|
|
2294
|
-
scripts.prepublishOnly = addScript(expectedScripts.prepublishOnly, scripts.prepublishOnly);
|
|
2295
|
-
scripts.watch = addScript(expectedScripts.watch, scripts.watch);
|
|
2296
|
-
return scripts;
|
|
2297
|
-
});
|
|
2298
|
-
}
|
|
2299
|
-
function sortKeys(unordered) {
|
|
2300
|
-
return Object.keys(unordered).sort().reduce((obj, key) => {
|
|
2301
|
-
obj[key] = unordered[key];
|
|
2302
|
-
return obj;
|
|
2303
|
-
}, {});
|
|
2304
|
-
}
|
|
2305
|
-
function forceDependencyVersions(deps) {
|
|
2306
|
-
let versions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : forcedPackageVersions;
|
|
2307
|
-
const entries = Object.entries(deps).map(entry => {
|
|
2308
|
-
const [pkg] = entry;
|
|
2309
|
-
const forceVersion = versions[pkg];
|
|
2310
|
-
if (forceVersion) {
|
|
2311
|
-
return [pkg, forceVersion];
|
|
2312
|
-
}
|
|
2313
|
-
return entry;
|
|
2314
|
-
});
|
|
2315
|
-
return Object.fromEntries(entries);
|
|
2316
|
-
}
|
|
2317
|
-
exports.addBuildScripts = addBuildScripts;
|
|
2318
|
-
exports.addPackageJsonScripts = addPackageJsonScripts;
|
|
2319
|
-
exports.addScript = addScript;
|
|
2320
|
-
exports.copyFileWithOverwritePrompt = copyFileWithOverwritePrompt;
|
|
2321
|
-
exports.disallowDuplicateEslintConfig = disallowDuplicateEslintConfig;
|
|
2322
|
-
exports.disallowDuplicatePrettierConfig = disallowDuplicatePrettierConfig;
|
|
2323
|
-
exports.ensureDir = ensureDir;
|
|
2324
|
-
exports.errorToUndefined = errorToUndefined;
|
|
2325
|
-
exports.fileExists = fileExists;
|
|
2326
|
-
exports.findStudioV3Config = findStudioV3Config;
|
|
2327
|
-
exports.forceDependencyVersions = forceDependencyVersions;
|
|
2328
|
-
exports.forcedDevPackageVersions = forcedDevPackageVersions;
|
|
2329
|
-
exports.forcedPackageVersions = forcedPackageVersions;
|
|
2330
|
-
exports.getPackage = getPackage;
|
|
2331
|
-
exports.hasSanityJson = hasSanityJson;
|
|
2332
|
-
exports.isEmptyish = isEmptyish;
|
|
2333
|
-
exports.mergedPackages = mergedPackages;
|
|
2334
|
-
exports.mkdir = mkdir;
|
|
2335
|
-
exports.prompt = prompt;
|
|
2336
|
-
exports.promptForPackageName = promptForPackageName;
|
|
2337
|
-
exports.promptForRepoOrigin = promptForRepoOrigin;
|
|
2338
|
-
exports.readFile = readFile$2;
|
|
2339
|
-
exports.readJsonFile = readJsonFile;
|
|
2340
|
-
exports.resolveLatestVersions = resolveLatestVersions;
|
|
2341
|
-
exports.sortKeys = sortKeys;
|
|
2342
|
-
exports.validateBabelConfig = validateBabelConfig;
|
|
2343
|
-
exports.validateDeprecatedDependencies = validateDeprecatedDependencies;
|
|
2344
|
-
exports.validateModule = validateModule;
|
|
2345
|
-
exports.validateNodeEngine = validateNodeEngine;
|
|
2346
|
-
exports.validatePackageName = validatePackageName$1;
|
|
2347
|
-
exports.validatePkgUtilsDependency = validatePkgUtilsDependency;
|
|
2348
|
-
exports.validatePluginSanityJson = validatePluginSanityJson;
|
|
2349
|
-
exports.validateSanityDependencies = validateSanityDependencies;
|
|
2350
|
-
exports.validateScripts = validateScripts;
|
|
2351
|
-
exports.validateSrcIndexFile = validateSrcIndexFile;
|
|
2352
|
-
exports.validateStudioConfig = validateStudioConfig;
|
|
2353
|
-
exports.validateTsConfig = validateTsConfig;
|
|
2354
|
-
exports.writeFile = writeFile;
|
|
2355
|
-
exports.writeFileWithOverwritePrompt = writeFileWithOverwritePrompt;
|
|
2356
|
-
exports.writePackageJson = writePackageJson;
|
|
2357
|
-
exports.writePackageJsonDirect = writePackageJsonDirect;
|
|
2358
|
-
//# sourceMappingURL=package-yXL1pPXe.js.map
|