@sanity/plugin-kit 3.1.9 → 3.1.11
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/_chunks/{cli-a67211d1.js → cli-Wd1KIVDi.js} +7 -7
- package/dist/_chunks/{cli-a67211d1.js.map → cli-Wd1KIVDi.js.map} +1 -1
- package/dist/_chunks/{init-50b074f7.js → init-5h0qT4Si.js} +29 -31
- package/dist/_chunks/init-5h0qT4Si.js.map +1 -0
- package/dist/_chunks/{init-2d09de2c.js → init-7PO3ckQZ.js} +4 -4
- package/dist/_chunks/{init-2d09de2c.js.map → init-7PO3ckQZ.js.map} +1 -1
- package/dist/_chunks/{inject-ef0110b8.js → inject-dEkit_VE.js} +6 -6
- package/dist/_chunks/{inject-ef0110b8.js.map → inject-dEkit_VE.js.map} +1 -1
- package/dist/_chunks/{link-watch-2e480365.js → link-watch-gjJZIMKf.js} +9 -11
- package/dist/_chunks/{link-watch-2e480365.js.map → link-watch-gjJZIMKf.js.map} +1 -1
- package/dist/_chunks/{package-9cfb2864.js → package-esTAlA-W.js} +19 -20
- package/dist/_chunks/{package-9cfb2864.js.map → package-esTAlA-W.js.map} +1 -1
- package/dist/_chunks/{package-f7519d2d.js → package-yXL1pPXe.js} +79 -81
- package/dist/_chunks/{package-f7519d2d.js.map → package-yXL1pPXe.js.map} +1 -1
- package/dist/_chunks/{ts-e380acbd.js → ts-DjETsLGv.js} +4 -4
- package/dist/_chunks/{ts-e380acbd.js.map → ts-DjETsLGv.js.map} +1 -1
- package/dist/_chunks/{verify-package-6a34ec23.js → verify-package-8RX50rZW.js} +10 -11
- package/dist/_chunks/{verify-package-6a34ec23.js.map → verify-package-8RX50rZW.js.map} +1 -1
- package/dist/_chunks/{verify-studio-34a9971f.js → verify-studio-ybZTH8nM.js} +9 -10
- package/dist/_chunks/{verify-studio-34a9971f.js.map → verify-studio-ybZTH8nM.js.map} +1 -1
- package/dist/_chunks/{version-d009c876.js → version-VsJ55gag.js} +3 -3
- package/dist/_chunks/{version-d009c876.js.map → version-VsJ55gag.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/package.json +18 -19
- package/src/npm/package.ts +1 -1
- package/src/presets/semver-workflow.ts +2 -3
- package/dist/_chunks/init-50b074f7.js.map +0 -1
|
@@ -7,12 +7,12 @@ var path = require('path');
|
|
|
7
7
|
var util$1 = require('util');
|
|
8
8
|
var githubUrlToObject = require('github-url-to-object');
|
|
9
9
|
var validateNpmPackageName = require('validate-npm-package-name');
|
|
10
|
-
var _package = require('./package-
|
|
10
|
+
var _package = require('./package-esTAlA-W.js');
|
|
11
11
|
var pAny = require('p-any');
|
|
12
12
|
var crypto = require('crypto');
|
|
13
13
|
var url = require('url');
|
|
14
14
|
var inquirer = require('inquirer');
|
|
15
|
-
var cli = require('./cli-
|
|
15
|
+
var cli = require('./cli-Wd1KIVDi.js');
|
|
16
16
|
var pProps = require('p-props');
|
|
17
17
|
var getLatestVersion = require('get-latest-version');
|
|
18
18
|
var outdent = require('outdent');
|
|
@@ -635,7 +635,6 @@ const lexStates = {
|
|
|
635
635
|
// case undefined:
|
|
636
636
|
// return newToken('eof')
|
|
637
637
|
}
|
|
638
|
-
|
|
639
638
|
lexState = 'value';
|
|
640
639
|
},
|
|
641
640
|
beforePropertyName() {
|
|
@@ -836,7 +835,6 @@ const parseStates = {
|
|
|
836
835
|
// This code is unreachable since it's handled by the lexState.
|
|
837
836
|
// throw invalidToken()
|
|
838
837
|
},
|
|
839
|
-
|
|
840
838
|
afterPropertyName() {
|
|
841
839
|
// This code is unreachable since it's handled by the lexState.
|
|
842
840
|
// if (token.type !== 'punctuator' || token.value !== ':') {
|
|
@@ -884,7 +882,6 @@ const parseStates = {
|
|
|
884
882
|
// This code is unreachable since it's handled by the lexState.
|
|
885
883
|
// throw invalidToken()
|
|
886
884
|
},
|
|
887
|
-
|
|
888
885
|
afterArrayValue() {
|
|
889
886
|
// This code is unreachable since it's handled by the lexState.
|
|
890
887
|
// if (token.type !== 'punctuator') {
|
|
@@ -905,7 +902,6 @@ const parseStates = {
|
|
|
905
902
|
// This code is unreachable since it's handled by the lexState.
|
|
906
903
|
// throw invalidToken()
|
|
907
904
|
},
|
|
908
|
-
|
|
909
905
|
end() {
|
|
910
906
|
// This code is unreachable since it's handled by the lexState.
|
|
911
907
|
// if (token.type !== 'eof') {
|
|
@@ -937,7 +933,6 @@ function push() {
|
|
|
937
933
|
// default:
|
|
938
934
|
// throw invalidToken()
|
|
939
935
|
}
|
|
940
|
-
|
|
941
936
|
if (root === undefined) {
|
|
942
937
|
root = value;
|
|
943
938
|
} else {
|
|
@@ -1285,9 +1280,9 @@ function hasSourceEquivalent(compiledFile, paths) {
|
|
|
1285
1280
|
return buildCandidateExists(pathStub);
|
|
1286
1281
|
}
|
|
1287
1282
|
async function hasSourceFile(filePath, paths) {
|
|
1288
|
-
if (!(paths
|
|
1289
|
-
var
|
|
1290
|
-
return fileExists(path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve((
|
|
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));
|
|
1291
1286
|
}
|
|
1292
1287
|
const pathStub = path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve(paths.source, filePath);
|
|
1293
1288
|
if (await fileExists(pathStub)) {
|
|
@@ -1296,9 +1291,9 @@ async function hasSourceFile(filePath, paths) {
|
|
|
1296
1291
|
return buildCandidateExists(pathStub);
|
|
1297
1292
|
}
|
|
1298
1293
|
function hasCompiledFile(filePath, paths) {
|
|
1299
|
-
if (!(paths
|
|
1300
|
-
var
|
|
1301
|
-
return fileExists(path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve((
|
|
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));
|
|
1302
1297
|
}
|
|
1303
1298
|
const absPath = path__default.default.isAbsolute(filePath) ? filePath : path__default.default.resolve(paths.compiled, filePath);
|
|
1304
1299
|
const fileExt = path__default.default.extname(absPath);
|
|
@@ -1406,11 +1401,11 @@ async function isEmptyish(dirPath) {
|
|
|
1406
1401
|
const files = allFiles.filter(file => !ignoredFiles.includes(file.toLowerCase()));
|
|
1407
1402
|
return files.length === 0;
|
|
1408
1403
|
}
|
|
1409
|
-
async function readFileContent(
|
|
1404
|
+
async function readFileContent(_ref2) {
|
|
1410
1405
|
let {
|
|
1411
1406
|
filename,
|
|
1412
1407
|
basePath
|
|
1413
|
-
} =
|
|
1408
|
+
} = _ref2;
|
|
1414
1409
|
const filepath = path__default.default.normalize(path__default.default.join(basePath, filename));
|
|
1415
1410
|
try {
|
|
1416
1411
|
return await readFile$2(filepath, "utf8");
|
|
@@ -1422,11 +1417,11 @@ async function readFileContent(_ref4) {
|
|
|
1422
1417
|
throw new Error("Failed to read \"".concat(filepath, "\": ").concat(err.message));
|
|
1423
1418
|
}
|
|
1424
1419
|
}
|
|
1425
|
-
async function readJson5File(
|
|
1420
|
+
async function readJson5File(_ref3) {
|
|
1426
1421
|
let {
|
|
1427
1422
|
filename,
|
|
1428
1423
|
basePath
|
|
1429
|
-
} =
|
|
1424
|
+
} = _ref3;
|
|
1430
1425
|
const content = await readFileContent({
|
|
1431
1426
|
filename,
|
|
1432
1427
|
basePath
|
|
@@ -1538,6 +1533,7 @@ async function validatePluginManifest(manifest, options) {
|
|
|
1538
1533
|
await validatePaths$1(manifest, options);
|
|
1539
1534
|
}
|
|
1540
1535
|
async function validatePaths$1(manifest, options) {
|
|
1536
|
+
var _srcStats;
|
|
1541
1537
|
if (!("paths" in manifest)) {
|
|
1542
1538
|
return;
|
|
1543
1539
|
}
|
|
@@ -1559,7 +1555,7 @@ async function validatePaths$1(manifest, options) {
|
|
|
1559
1555
|
throw new Error("sanity.json references \"source\" path which does not exist: \"".concat(sourcePath, "\""));
|
|
1560
1556
|
}
|
|
1561
1557
|
}
|
|
1562
|
-
if (!(srcStats
|
|
1558
|
+
if (!((_srcStats = srcStats) !== null && _srcStats !== void 0 && _srcStats.isDirectory())) {
|
|
1563
1559
|
throw new Error("sanity.json references \"source\" path which is not a directory: \"".concat(sourcePath, "\""));
|
|
1564
1560
|
}
|
|
1565
1561
|
}
|
|
@@ -1591,11 +1587,11 @@ async function validatePartFiles(part, index, options) {
|
|
|
1591
1587
|
verifySourceParts,
|
|
1592
1588
|
paths
|
|
1593
1589
|
} = options;
|
|
1594
|
-
if (!(part
|
|
1590
|
+
if (!(part !== null && part !== void 0 && part.path)) {
|
|
1595
1591
|
return;
|
|
1596
1592
|
}
|
|
1597
1593
|
const ext = path__default.default.extname(part.path);
|
|
1598
|
-
if (
|
|
1594
|
+
if (paths !== null && paths !== void 0 && paths.source && ext && ext !== ".js" && buildExtensions.includes(ext)) {
|
|
1599
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, "])"));
|
|
1600
1596
|
}
|
|
1601
1597
|
if (!verifySourceParts && !verifyCompiledParts) {
|
|
@@ -1603,20 +1599,20 @@ async function validatePartFiles(part, index, options) {
|
|
|
1603
1599
|
}
|
|
1604
1600
|
const [srcExists, outDirExists] = await Promise.all([hasSourceFile(part.path, paths), verifyCompiledParts && hasCompiledFile(part.path, paths)]);
|
|
1605
1601
|
if (!srcExists) {
|
|
1606
|
-
throw new Error("Invalid sanity.json: Part path references file that does not exist in source directory (".concat((paths
|
|
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, "])"));
|
|
1607
1603
|
}
|
|
1608
1604
|
if (verifyCompiledParts && !outDirExists) {
|
|
1609
|
-
throw new Error("Invalid sanity.json: Part path references file (\"".concat(part.path, "\") that does not exist in compiled directory (").concat(paths
|
|
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, "])"));
|
|
1610
1606
|
}
|
|
1611
1607
|
}
|
|
1612
1608
|
function validatePartNames(part, index, options) {
|
|
1613
|
-
var
|
|
1609
|
+
var _part$name, _part$implements;
|
|
1614
1610
|
const pluginName = options.pluginName ? options.pluginName.replace(/^sanity-plugin-/, "") : "";
|
|
1615
|
-
if (!(part
|
|
1616
|
-
throw new Error("Invalid sanity.json: \"name\" must be prefixed with \"part:".concat(pluginName, "/\" - got \"").concat(part
|
|
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, "])"));
|
|
1617
1613
|
}
|
|
1618
|
-
if (!(
|
|
1619
|
-
throw new Error("Invalid sanity.json: \"implements\" must be prefixed with \"part:\" - got \"".concat(part
|
|
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, "])"));
|
|
1620
1616
|
}
|
|
1621
1617
|
}
|
|
1622
1618
|
function validateAllowedPartKeys(part, index) {
|
|
@@ -1695,10 +1691,11 @@ function filesWithSuffixes(fileBases, suffixes) {
|
|
|
1695
1691
|
return fileBases.flatMap(file => suffixes.map(suffix => "".concat(file, ".").concat(suffix)));
|
|
1696
1692
|
}
|
|
1697
1693
|
function validateNodeEngine(packageJson) {
|
|
1698
|
-
var
|
|
1694
|
+
var _packageJson$engines;
|
|
1699
1695
|
const nodeVersionRange = ">=14";
|
|
1700
|
-
if (!((
|
|
1701
|
-
|
|
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()];
|
|
1702
1699
|
}
|
|
1703
1700
|
}
|
|
1704
1701
|
function validateModule(packageJson, options) {
|
|
@@ -1717,18 +1714,18 @@ function validateModule(packageJson, options) {
|
|
|
1717
1714
|
}
|
|
1718
1715
|
function validateScripts(packageJson) {
|
|
1719
1716
|
const errors = [];
|
|
1720
|
-
const divergentScripts = Object.entries(expectedScripts).filter(
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
const command = (
|
|
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];
|
|
1724
1721
|
return !command || !command.includes(expectedCommand);
|
|
1725
1722
|
});
|
|
1726
1723
|
if (divergentScripts.length) {
|
|
1727
|
-
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(
|
|
1728
|
-
let [key] =
|
|
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;
|
|
1729
1726
|
return key;
|
|
1730
|
-
}).join(", "), divergentScripts.map(
|
|
1731
|
-
let [key, value] =
|
|
1727
|
+
}).join(", "), divergentScripts.map(_ref6 => {
|
|
1728
|
+
let [key, value] = _ref6;
|
|
1732
1729
|
return "\"".concat(key, "\": \"").concat(value, "\"");
|
|
1733
1730
|
}).join(",\n")).trimStart());
|
|
1734
1731
|
}
|
|
@@ -1755,8 +1752,9 @@ async function validateTsConfig(ts, options) {
|
|
|
1755
1752
|
rootDir: ".",
|
|
1756
1753
|
outDir
|
|
1757
1754
|
};
|
|
1758
|
-
const wrongEntries = Object.entries(expectedCompilerOptions).filter(
|
|
1759
|
-
|
|
1755
|
+
const wrongEntries = Object.entries(expectedCompilerOptions).filter(_ref7 => {
|
|
1756
|
+
var _option;
|
|
1757
|
+
let [key, value] = _ref7;
|
|
1760
1758
|
let option = ts.options[key];
|
|
1761
1759
|
if (key === "rootDir" && typeof option === "string") {
|
|
1762
1760
|
option = path__default.default.relative(basePath, option) || ".";
|
|
@@ -1773,25 +1771,25 @@ async function validateTsConfig(ts, options) {
|
|
|
1773
1771
|
if (key === "module" && option === 99) {
|
|
1774
1772
|
option = "esnext";
|
|
1775
1773
|
}
|
|
1776
|
-
return typeof value === "string" && typeof option === "string" ? value.toLowerCase() !== (option
|
|
1774
|
+
return typeof value === "string" && typeof option === "string" ? value.toLowerCase() !== ((_option = option) === null || _option === void 0 ? void 0 : _option.toLowerCase()) : value !== option;
|
|
1777
1775
|
});
|
|
1778
1776
|
if (wrongEntries.length) {
|
|
1779
|
-
const expectedOutput = wrongEntries.map(
|
|
1780
|
-
let [key, value] =
|
|
1777
|
+
const expectedOutput = wrongEntries.map(_ref8 => {
|
|
1778
|
+
let [key, value] = _ref8;
|
|
1781
1779
|
return "\"".concat(key, "\": ").concat(typeof value === "string" ? "\"".concat(value, "\"") : value, ",");
|
|
1782
1780
|
}).join("\n");
|
|
1783
|
-
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(
|
|
1784
|
-
let [key] =
|
|
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;
|
|
1785
1783
|
return key;
|
|
1786
1784
|
}).join(", "), expectedOutput, tsconfig).trimStart());
|
|
1787
1785
|
}
|
|
1788
1786
|
return errors;
|
|
1789
1787
|
}
|
|
1790
|
-
function validatePkgUtilsDependency(
|
|
1788
|
+
function validatePkgUtilsDependency(_ref10) {
|
|
1791
1789
|
let {
|
|
1792
1790
|
devDependencies
|
|
1793
|
-
} =
|
|
1794
|
-
if (!(devDependencies
|
|
1791
|
+
} = _ref10;
|
|
1792
|
+
if (!(devDependencies !== null && devDependencies !== void 0 && devDependencies["@sanity/pkg-utils"])) {
|
|
1795
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()];
|
|
1796
1794
|
}
|
|
1797
1795
|
return [];
|
|
@@ -1834,10 +1832,10 @@ function validateDeprecatedDependencies(packageJson) {
|
|
|
1834
1832
|
}
|
|
1835
1833
|
return [];
|
|
1836
1834
|
}
|
|
1837
|
-
async function validateBabelConfig(
|
|
1835
|
+
async function validateBabelConfig(_ref11) {
|
|
1838
1836
|
let {
|
|
1839
1837
|
basePath
|
|
1840
|
-
} =
|
|
1838
|
+
} = _ref11;
|
|
1841
1839
|
const suffixes = ["json", "js", "cjs", "mjs"];
|
|
1842
1840
|
const babelFileNames = [".babelrc", "babel.config"];
|
|
1843
1841
|
const filenames = [".babelrc", ...filesWithSuffixes(babelFileNames, suffixes)];
|
|
@@ -1853,11 +1851,10 @@ async function validateBabelConfig(_ref13) {
|
|
|
1853
1851
|
}
|
|
1854
1852
|
return [];
|
|
1855
1853
|
}
|
|
1856
|
-
async function validateStudioConfig(
|
|
1854
|
+
async function validateStudioConfig(_ref12) {
|
|
1857
1855
|
let {
|
|
1858
1856
|
basePath
|
|
1859
|
-
} =
|
|
1860
|
-
var _a, _b, _c, _d, _e;
|
|
1857
|
+
} = _ref12;
|
|
1861
1858
|
const suffixes = ["ts", "js", "tsx", "jsx"];
|
|
1862
1859
|
const filenames = filesWithSuffixes(["sanity.config", "sanity.cli"], suffixes);
|
|
1863
1860
|
const files = {};
|
|
@@ -1874,25 +1871,26 @@ async function validateStudioConfig(_ref14) {
|
|
|
1874
1871
|
const hasStudioConfig = hasConfigFile("sanity.config");
|
|
1875
1872
|
const errors = [];
|
|
1876
1873
|
if (sanityJson) {
|
|
1877
|
-
|
|
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);
|
|
1878
1876
|
errors.push(info.join("\n\n"));
|
|
1879
1877
|
}
|
|
1880
1878
|
if (!hasCliConfig) {
|
|
1881
|
-
var
|
|
1882
|
-
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 })"])), (
|
|
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());
|
|
1883
1881
|
}
|
|
1884
1882
|
if (!hasStudioConfig) {
|
|
1885
|
-
var
|
|
1886
|
-
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 })"])), (
|
|
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());
|
|
1887
1885
|
}
|
|
1888
1886
|
return errors.length ? [errors.join("\n\n---\n\n")] : [];
|
|
1889
1887
|
}
|
|
1890
|
-
async function validatePluginSanityJson(
|
|
1888
|
+
async function validatePluginSanityJson(_ref13) {
|
|
1889
|
+
var _sanityJson$parts, _packageJson$dependen;
|
|
1891
1890
|
let {
|
|
1892
1891
|
basePath,
|
|
1893
1892
|
packageJson
|
|
1894
|
-
} =
|
|
1895
|
-
var _a, _b;
|
|
1893
|
+
} = _ref13;
|
|
1896
1894
|
const sanityJson = await readJson5File({
|
|
1897
1895
|
basePath,
|
|
1898
1896
|
filename: "sanity.json"
|
|
@@ -1903,26 +1901,26 @@ async function validatePluginSanityJson(_ref19) {
|
|
|
1903
1901
|
path: "./v2-incompatible.js"
|
|
1904
1902
|
}]
|
|
1905
1903
|
};
|
|
1906
|
-
const hasSinglePart = sanityJson && Object.keys(sanityJson).length === 1 && (sanityJson
|
|
1907
|
-
const firstPart = hasSinglePart ?
|
|
1908
|
-
const correctImplements = (firstPart
|
|
1909
|
-
const pathExists = (firstPart
|
|
1910
|
-
const hasDependency = !!((
|
|
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]);
|
|
1911
1909
|
const isValid = sanityJson && hasSinglePart && correctImplements && pathExists && hasDependency;
|
|
1912
1910
|
if (!isValid) {
|
|
1913
|
-
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,
|
|
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);
|
|
1914
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()];
|
|
1915
1913
|
}
|
|
1916
1914
|
return [];
|
|
1917
1915
|
}
|
|
1918
1916
|
function validatePackageName$1(packageJson) {
|
|
1919
|
-
var
|
|
1917
|
+
var _packageJson$name, _packageJson$name2;
|
|
1920
1918
|
const valid = validateNpmPackageName__default.default(packageJson.name);
|
|
1921
1919
|
if (!valid.validForNewPackages) {
|
|
1922
1920
|
return ["Invalid package.json: \"name\" is invalid: ".concat(valid.errors.join(", "))];
|
|
1923
1921
|
}
|
|
1924
|
-
const isScoped = (
|
|
1925
|
-
if (!isScoped && !((
|
|
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-"))) {
|
|
1926
1924
|
return ["Invalid package.json: \"name\" should be prefixed with \"sanity-plugin-\" (or scoped - @your-company/plugin-name)"];
|
|
1927
1925
|
}
|
|
1928
1926
|
}
|
|
@@ -1938,13 +1936,13 @@ async function validateSrcIndexFile(basePath) {
|
|
|
1938
1936
|
}
|
|
1939
1937
|
return [];
|
|
1940
1938
|
}
|
|
1941
|
-
async function disallowDuplicateConfig(
|
|
1939
|
+
async function disallowDuplicateConfig(_ref14) {
|
|
1942
1940
|
let {
|
|
1943
1941
|
basePath,
|
|
1944
1942
|
pkgJson,
|
|
1945
1943
|
configKey,
|
|
1946
1944
|
files
|
|
1947
|
-
} =
|
|
1945
|
+
} = _ref14;
|
|
1948
1946
|
const found = [];
|
|
1949
1947
|
for (const file of files) {
|
|
1950
1948
|
const filePath = path__default.default.join(basePath, file);
|
|
@@ -2070,7 +2068,6 @@ function validatePackageName(manifest) {
|
|
|
2070
2068
|
}
|
|
2071
2069
|
async function validatePaths(manifest, options) {
|
|
2072
2070
|
var _manifest$name;
|
|
2073
|
-
var _a;
|
|
2074
2071
|
const paths = await getPaths({
|
|
2075
2072
|
...options,
|
|
2076
2073
|
pluginName: (_manifest$name = manifest.name) !== null && _manifest$name !== void 0 ? _manifest$name : "unknown",
|
|
@@ -2080,9 +2077,10 @@ async function validatePaths(manifest, options) {
|
|
|
2080
2077
|
const abs = file => path__default.default.isAbsolute(file) ? file : path__default.default.resolve(path__default.default.join(options.basePath, file));
|
|
2081
2078
|
const exists = file => fs__default.default.existsSync(abs(file));
|
|
2082
2079
|
const willExist = file => paths && hasSourceEquivalent(abs(file), paths);
|
|
2083
|
-
const withinSourceDir = file => (paths
|
|
2084
|
-
const withinTargetDir = 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);
|
|
2085
2082
|
for (const key of pathKeys) {
|
|
2083
|
+
var _options$flags;
|
|
2086
2084
|
if (!(key in manifest)) {
|
|
2087
2085
|
continue;
|
|
2088
2086
|
}
|
|
@@ -2090,7 +2088,7 @@ async function validatePaths(manifest, options) {
|
|
|
2090
2088
|
if (typeof manifestValue !== "string") {
|
|
2091
2089
|
throw new Error("Invalid package.json: \"".concat(key, "\" must be a string if defined"));
|
|
2092
2090
|
}
|
|
2093
|
-
if (!(
|
|
2091
|
+
if (!(options !== null && options !== void 0 && (_options$flags = options.flags) !== null && _options$flags !== void 0 && _options$flags.allowSourceTarget) && paths && withinSourceDir(manifestValue)) {
|
|
2094
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."));
|
|
2095
2093
|
}
|
|
2096
2094
|
const fileExists = exists(manifestValue);
|
|
@@ -2185,15 +2183,15 @@ async function writePackageJson(data, options) {
|
|
|
2185
2183
|
...urlsFromOrigin(gitOrigin),
|
|
2186
2184
|
...repoFromOrigin(gitOrigin),
|
|
2187
2185
|
license: license ? license.id : "UNLICENSED",
|
|
2188
|
-
author:
|
|
2186
|
+
author: user !== null && user !== void 0 && user.email ? "".concat(user.name, " <").concat(user.email, ">") : user === null || user === void 0 ? void 0 : user.name,
|
|
2189
2187
|
exports: {
|
|
2190
2188
|
".": {
|
|
2191
2189
|
...(flags.typescript ? {
|
|
2192
2190
|
types: "./".concat(outDir, "/index.d.ts")
|
|
2193
2191
|
} : {}),
|
|
2194
2192
|
source,
|
|
2195
|
-
require: "./".concat(outDir, "/index.js"),
|
|
2196
2193
|
import: "./".concat(outDir, "/index.esm.js"),
|
|
2194
|
+
require: "./".concat(outDir, "/index.js"),
|
|
2197
2195
|
default: "./".concat(outDir, "/index.esm.js")
|
|
2198
2196
|
},
|
|
2199
2197
|
"./package.json": "./package.json"
|
|
@@ -2274,10 +2272,10 @@ async function addPackageJsonScripts(manifest, options, updateScripts) {
|
|
|
2274
2272
|
}
|
|
2275
2273
|
return differs;
|
|
2276
2274
|
}
|
|
2277
|
-
async function writePackageJsonDirect(manifest,
|
|
2275
|
+
async function writePackageJsonDirect(manifest, _ref15) {
|
|
2278
2276
|
let {
|
|
2279
2277
|
basePath
|
|
2280
|
-
} =
|
|
2278
|
+
} = _ref15;
|
|
2281
2279
|
await writeJsonFile(path__default.default.join(basePath, "package.json"), manifest);
|
|
2282
2280
|
}
|
|
2283
2281
|
async function addBuildScripts(manifest, options) {
|
|
@@ -2357,4 +2355,4 @@ exports.writeFile = writeFile;
|
|
|
2357
2355
|
exports.writeFileWithOverwritePrompt = writeFileWithOverwritePrompt;
|
|
2358
2356
|
exports.writePackageJson = writePackageJson;
|
|
2359
2357
|
exports.writePackageJsonDirect = writePackageJsonDirect;
|
|
2360
|
-
//# sourceMappingURL=package-
|
|
2358
|
+
//# sourceMappingURL=package-yXL1pPXe.js.map
|