@sanity/pkg-utils 7.7.1-canary.3 → 7.7.2-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/dist/_chunks-cjs/index.cjs +29 -41
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/_chunks-cjs/resolveRolldownConfig.cjs.map +1 -1
- package/dist/_chunks-es/consoleSpy.js +15 -26
- package/dist/_chunks-es/consoleSpy.js.map +1 -1
- package/dist/_chunks-es/index.js +1 -0
- package/dist/_chunks-es/index.js.map +1 -1
- package/dist/_chunks-es/init.js +12 -15
- package/dist/_chunks-es/init.js.map +1 -1
- package/dist/_chunks-es/resolveRolldownConfig.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -49
- package/dist/index.d.ts +17 -49
- package/dist/index.js +1 -3
- package/package.json +3 -3
- package/tsconfig/isolated-declarations.json +3 -1
- package/tsconfig/recommended.json +3 -0
|
@@ -18,7 +18,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
18
18
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
19
19
|
mod
|
|
20
20
|
));
|
|
21
|
-
var path = require("node:path"), rimraf = require("rimraf"), node_module = require("node:module"), node = require("esbuild-register/dist/node"), pkgUp = require("pkg-up"), findConfig = require("find-config"), node_fs = require("node:fs"), chalk = require("chalk"), zod = require("zod"), fs = require("node:fs/promises"),
|
|
21
|
+
var path = require("node:path"), rimraf = require("rimraf"), node_module = require("node:module"), node = require("esbuild-register/dist/node"), pkgUp = require("pkg-up"), findConfig = require("find-config"), node_fs = require("node:fs"), chalk = require("chalk"), zod = require("zod"), fs = require("node:fs/promises"), browserslist = require("browserslist"), config$1 = require("@sanity/browserslist-config"), ts = require("typescript"), zodValidationError = require("zod-validation-error"), rxjs = require("rxjs"), apiExtractor = require("@microsoft/api-extractor"), mkdirp = require("mkdirp"), prettier = require("prettier"), tsdocConfig = require("@microsoft/tsdoc-config"), jsoncParser = require("jsonc-parser"), recast = require("recast"), typeScriptParser = require("recast/parsers/typescript.js"), rollup = require("rollup"), rollupPlugin = require("@optimize-lodash/rollup-plugin"), alias = require("@rollup/plugin-alias"), pluginBabel = require("@rollup/plugin-babel"), commonjs = require("@rollup/plugin-commonjs"), json = require("@rollup/plugin-json"), pluginNodeResolve = require("@rollup/plugin-node-resolve"), replace = require("@rollup/plugin-replace"), terser = require("@rollup/plugin-terser"), esbuild = require("rollup-plugin-esbuild"), treeify = require("treeify"), prettyBytes = require("pretty-bytes"), prompts = require("prompts"), node_child_process = require("node:child_process"), getLatestVersion = require("get-latest-version"), gitUrlParse = require("git-url-parse"), outdent = require("outdent"), operators = require("rxjs/operators"), globby = require("globby"), chokidar = require("chokidar"), _documentCurrentScript = typeof document < "u" ? document.currentScript : null;
|
|
22
22
|
function _interopDefaultCompat(e) {
|
|
23
23
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
24
24
|
}
|
|
@@ -37,7 +37,7 @@ function _interopNamespaceCompat(e) {
|
|
|
37
37
|
}
|
|
38
38
|
}), n.default = e, Object.freeze(n);
|
|
39
39
|
}
|
|
40
|
-
var path__default = /* @__PURE__ */ _interopDefaultCompat(path), rimraf__namespace = /* @__PURE__ */ _interopNamespaceCompat(rimraf), pkgUp__default = /* @__PURE__ */ _interopDefaultCompat(pkgUp), findConfig__default = /* @__PURE__ */ _interopDefaultCompat(findConfig), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), fs__default = /* @__PURE__ */ _interopDefaultCompat(fs),
|
|
40
|
+
var path__default = /* @__PURE__ */ _interopDefaultCompat(path), rimraf__namespace = /* @__PURE__ */ _interopNamespaceCompat(rimraf), pkgUp__default = /* @__PURE__ */ _interopDefaultCompat(pkgUp), findConfig__default = /* @__PURE__ */ _interopDefaultCompat(findConfig), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), fs__default = /* @__PURE__ */ _interopDefaultCompat(fs), browserslist__default = /* @__PURE__ */ _interopDefaultCompat(browserslist), config__default = /* @__PURE__ */ _interopDefaultCompat(config$1), ts__default = /* @__PURE__ */ _interopDefaultCompat(ts), prettier__namespace = /* @__PURE__ */ _interopNamespaceCompat(prettier), typeScriptParser__default = /* @__PURE__ */ _interopDefaultCompat(typeScriptParser), alias__default = /* @__PURE__ */ _interopDefaultCompat(alias), commonjs__default = /* @__PURE__ */ _interopDefaultCompat(commonjs), json__default = /* @__PURE__ */ _interopDefaultCompat(json), replace__default = /* @__PURE__ */ _interopDefaultCompat(replace), terser__default = /* @__PURE__ */ _interopDefaultCompat(terser), esbuild__default = /* @__PURE__ */ _interopDefaultCompat(esbuild), treeify__default = /* @__PURE__ */ _interopDefaultCompat(treeify), prettyBytes__default = /* @__PURE__ */ _interopDefaultCompat(prettyBytes), prompts__default = /* @__PURE__ */ _interopDefaultCompat(prompts), getLatestVersion__default = /* @__PURE__ */ _interopDefaultCompat(getLatestVersion), gitUrlParse__default = /* @__PURE__ */ _interopDefaultCompat(gitUrlParse), globby__default = /* @__PURE__ */ _interopDefaultCompat(globby), chokidar__namespace = /* @__PURE__ */ _interopNamespaceCompat(chokidar);
|
|
41
41
|
function fileExists(filePath) {
|
|
42
42
|
try {
|
|
43
43
|
return node_fs.statSync(filePath), !0;
|
|
@@ -342,7 +342,7 @@ function parseExports(options) {
|
|
|
342
342
|
pkg.module && pkg.browser?.[pkg.module] ? browserConditions.push(
|
|
343
343
|
` "import": ${JSON.stringify(pkg.browser[pkg.module].replace(fileEnding, extMap.esm))}`
|
|
344
344
|
) : pkg.browser?.[pkg.main] && browserConditions.push(
|
|
345
|
-
` "import": ${JSON.stringify(pkg.browser
|
|
345
|
+
` "import": ${JSON.stringify(pkg.browser[pkg.main].replace(fileEnding, extMap.esm))}`
|
|
346
346
|
), pkg.browser?.[pkg.main] && browserConditions.push(
|
|
347
347
|
` "require": ${JSON.stringify(pkg.browser[pkg.main].replace(fileEnding, extMap.commonjs))}`
|
|
348
348
|
), browserConditions.length && maybeBrowserCondition.push(
|
|
@@ -454,7 +454,8 @@ const toggle = zod.z.union([zod.z.literal("error"), zod.z.literal("warn"), zod.z
|
|
|
454
454
|
noImplicitBrowsersList: toggle.default("warn"),
|
|
455
455
|
alwaysPackageJsonTypes: toggle.default("error"),
|
|
456
456
|
alwaysPackageJsonMain: toggle.default("error"),
|
|
457
|
-
alwaysPackageJsonFiles: toggle.default("error")
|
|
457
|
+
alwaysPackageJsonFiles: toggle.default("error"),
|
|
458
|
+
noCheckTypes: toggle.default("warn")
|
|
458
459
|
}).strict(), validationSchema = zod.z.object({
|
|
459
460
|
strictOptions: strictOptions.default({})
|
|
460
461
|
});
|
|
@@ -471,26 +472,17 @@ async function resolveBuildContext(options) {
|
|
|
471
472
|
strict,
|
|
472
473
|
tsconfig: tsconfigPath
|
|
473
474
|
} = options, tsconfig = await loadTSConfig({ cwd, tsconfigPath }), strictOptions2 = parseStrictOptions(config2?.strictOptions ?? {});
|
|
475
|
+
if (strictOptions2.noCheckTypes !== "off" && tsconfig?.options && config2?.dts !== "rolldown" && tsconfig.options.noCheck !== !1 && !tsconfig.options.noCheck) {
|
|
476
|
+
if (strictOptions2.noCheckTypes === "error")
|
|
477
|
+
throw new Error(
|
|
478
|
+
"`noCheck` is not set to `true` in the tsconfig.json file used by `package.config.ts`. This makes generating dts files slower than it needs to be, as it will perform type checking on the dts files while at it."
|
|
479
|
+
);
|
|
480
|
+
logger.warn(
|
|
481
|
+
"`noCheck` is not set to `true` in the tsconfig.json file used by `package.config.ts`. This makes generating dts files slower than it needs to be, as it will perform type checking on the dts files while at it."
|
|
482
|
+
);
|
|
483
|
+
}
|
|
474
484
|
let browserslist2 = pkg.browserslist;
|
|
475
|
-
if (browserslist2) {
|
|
476
|
-
if (browserslist2 === "extends @sanity/browserslist-config" && strictOptions2.noImplicitBrowsersList !== "off")
|
|
477
|
-
try {
|
|
478
|
-
const { findPackageJSON } = await import("node:module"), browsersListPath = findPackageJSON(
|
|
479
|
-
"@sanity/browserslist-config",
|
|
480
|
-
path__default.default.resolve(cwd, "package.json")
|
|
481
|
-
);
|
|
482
|
-
assert__default.default.ok(browsersListPath, "browserslist-config is not installed");
|
|
483
|
-
} catch (error) {
|
|
484
|
-
if (strictOptions2.noImplicitBrowsersList === "error")
|
|
485
|
-
throw new Error(
|
|
486
|
-
'\n- package.json: "browserslist" references "@sanity/browserslist-config" but it\'s not installed. Run `pnpm add -D @sanity/browserslist-config` to install it.',
|
|
487
|
-
{ cause: error }
|
|
488
|
-
);
|
|
489
|
-
logger.warn(
|
|
490
|
-
'package.json: "browserslist" references "@sanity/browserslist-config" but it\'s not installed. Run `pnpm add -D @sanity/browserslist-config` to install it.'
|
|
491
|
-
);
|
|
492
|
-
}
|
|
493
|
-
} else {
|
|
485
|
+
if (!browserslist2) {
|
|
494
486
|
if (strict && strictOptions2.noImplicitBrowsersList !== "off") {
|
|
495
487
|
if (strictOptions2.noImplicitBrowsersList === "error")
|
|
496
488
|
throw new Error(
|
|
@@ -579,7 +571,7 @@ function transformPackageName(packageName) {
|
|
|
579
571
|
return packageName;
|
|
580
572
|
if (packageName.startsWith("@")) {
|
|
581
573
|
const [scope, name] = packageName.split("/");
|
|
582
|
-
return `@types/${scope
|
|
574
|
+
return `@types/${scope?.slice(1)}__${name}`;
|
|
583
575
|
} else
|
|
584
576
|
return `@types/${packageName}`;
|
|
585
577
|
}
|
|
@@ -757,6 +749,7 @@ async function buildTypes(options) {
|
|
|
757
749
|
emitDeclarationOnly: !0,
|
|
758
750
|
noEmit: !1,
|
|
759
751
|
noEmitOnError: strict ? !0 : tsconfig.options.noEmitOnError ?? !0,
|
|
752
|
+
noCheck: tsconfig.options.noCheck ?? tsconfig.options.isolatedDeclarations,
|
|
760
753
|
outDir
|
|
761
754
|
}, program = ts__default.default.createProgram(tsconfig.fileNames, compilerOptions), emitResult = program.emit(), allDiagnostics = ts__default.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
762
755
|
for (const diagnostic of allDiagnostics)
|
|
@@ -1809,6 +1802,17 @@ const overridableDefaults = {
|
|
|
1809
1802
|
endOfLine: "lf",
|
|
1810
1803
|
tabWidth: 2,
|
|
1811
1804
|
useTabs: !1
|
|
1805
|
+
}, json5 = {
|
|
1806
|
+
files: ["*.json5"],
|
|
1807
|
+
options: {
|
|
1808
|
+
quoteProps: "preserve",
|
|
1809
|
+
singleQuote: !1
|
|
1810
|
+
}
|
|
1811
|
+
}, yaml = {
|
|
1812
|
+
files: ["*.yml"],
|
|
1813
|
+
options: {
|
|
1814
|
+
singleQuote: !1
|
|
1815
|
+
}
|
|
1812
1816
|
}, config = {
|
|
1813
1817
|
...overridableDefaults,
|
|
1814
1818
|
printWidth: 100,
|
|
@@ -1817,21 +1821,7 @@ const overridableDefaults = {
|
|
|
1817
1821
|
quoteProps: "consistent",
|
|
1818
1822
|
bracketSpacing: !1,
|
|
1819
1823
|
plugins: ["prettier-plugin-packagejson"],
|
|
1820
|
-
overrides: [
|
|
1821
|
-
{
|
|
1822
|
-
files: ["*.json5"],
|
|
1823
|
-
options: {
|
|
1824
|
-
quoteProps: "preserve",
|
|
1825
|
-
singleQuote: !1
|
|
1826
|
-
}
|
|
1827
|
-
},
|
|
1828
|
-
{
|
|
1829
|
-
files: ["*.yml"],
|
|
1830
|
-
options: {
|
|
1831
|
-
singleQuote: !1
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
]
|
|
1824
|
+
overrides: [json5, yaml]
|
|
1835
1825
|
}, RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i, defaultTemplate = async ({ cwd, logger, packagePath }) => {
|
|
1836
1826
|
const gitConfig = getGitUserConfig(cwd);
|
|
1837
1827
|
return {
|
|
@@ -2414,7 +2404,5 @@ exports.loadPkgWithReporting = loadPkgWithReporting;
|
|
|
2414
2404
|
exports.parseExports = parseExports;
|
|
2415
2405
|
exports.parseStrictOptions = parseStrictOptions;
|
|
2416
2406
|
exports.pkgExtMap = pkgExtMap;
|
|
2417
|
-
exports.strictOptions = strictOptions;
|
|
2418
|
-
exports.toggle = toggle;
|
|
2419
2407
|
exports.watch = watch;
|
|
2420
2408
|
//# sourceMappingURL=index.cjs.map
|