@sanity/pkg-utils 6.7.1 → 6.8.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/cli.cjs CHANGED
@@ -3,7 +3,7 @@ var cac = require("cac");
3
3
  function _interopDefaultCompat(e) {
4
4
  return e && typeof e == "object" && "default" in e ? e : { default: e };
5
5
  }
6
- var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "6.7.1";
6
+ var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "6.8.0";
7
7
  const cli = cac__default.default();
8
8
  cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
9
9
  const { checkAction } = await Promise.resolve().then(function() {
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { z, ZodError } from "zod";
8
8
  import chalk from "chalk";
9
9
  import fs, { writeFile, readFile, readdir, lstat } from "node:fs/promises";
10
10
  import browserslist from "browserslist";
11
- import config from "@sanity/browserslist-config";
11
+ import config$1 from "@sanity/browserslist-config";
12
12
  import ts from "typescript";
13
13
  import { errorMap } from "zod-validation-error";
14
14
  import { Observable, switchMap } from "rxjs";
@@ -81,7 +81,7 @@ async function loadConfig(options2) {
81
81
  function resolveConfigProperty(prop, initialValue) {
82
82
  return prop ? typeof prop == "function" ? prop(initialValue) : prop : initialValue;
83
83
  }
84
- const DEFAULT_BROWSERSLIST_QUERY = config;
84
+ const DEFAULT_BROWSERSLIST_QUERY = config$1;
85
85
  function isRecord(value) {
86
86
  return !!value && !Array.isArray(value) && typeof value == "object";
87
87
  }
@@ -356,7 +356,7 @@ function parseExports(options2) {
356
356
  "package.json: `types` must be declared for the npm listing to show as a TypeScript module."
357
357
  ), strict && !pkg.exports["./package.json"] && errors.push('package.json: `exports["./package.json"] must be declared.');
358
358
  for (const [exportPath, exportEntry] of Object.entries(pkg.exports))
359
- if (exportPath.endsWith(".json"))
359
+ if (exportPath.endsWith(".json") || typeof exportEntry == "string" && exportEntry.endsWith(".json"))
360
360
  exportPath === "./package.json" && exportEntry !== "./package.json" && errors.push('package.json: `exports["./package.json"] must be "./package.json".');
361
361
  else if (!(isRecord(exportEntry) && "svelte" in exportEntry))
362
362
  if (isRecord(exportEntry)) {
@@ -20939,7 +20939,34 @@ function printEsbuildMessage(log, msg) {
20939
20939
  async function isEmptyDirectory(dirPath) {
20940
20940
  return (await readdir(dirPath)).length === 0;
20941
20941
  }
20942
- const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i, defaultTemplate = async ({ cwd, logger, packagePath }) => {
20942
+ const overridableDefaults = {
20943
+ endOfLine: "lf",
20944
+ tabWidth: 2,
20945
+ useTabs: !1
20946
+ }, config = {
20947
+ ...overridableDefaults,
20948
+ printWidth: 100,
20949
+ semi: !1,
20950
+ singleQuote: !0,
20951
+ quoteProps: "consistent",
20952
+ bracketSpacing: !1,
20953
+ plugins: ["prettier-plugin-packagejson"],
20954
+ overrides: [
20955
+ {
20956
+ files: ["*.json5"],
20957
+ options: {
20958
+ quoteProps: "preserve",
20959
+ singleQuote: !1
20960
+ }
20961
+ },
20962
+ {
20963
+ files: ["*.yml"],
20964
+ options: {
20965
+ singleQuote: !1
20966
+ }
20967
+ }
20968
+ ]
20969
+ }, RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i, defaultTemplate = async ({ cwd, logger, packagePath }) => {
20943
20970
  const gitConfig = await parseGitConfig({ cwd, type: "global" });
20944
20971
  return {
20945
20972
  options: [
@@ -21021,23 +21048,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21021
21048
  }
21022
21049
  ],
21023
21050
  async getFiles(options2, features) {
21024
- const { pkgName, repo } = options2, { fullName: name } = pkgName, author = [options2.authorName, options2.authorEmail && `<${options2.authorEmail}>`].filter(Boolean).join(" ") ?? void 0, prettierConfig = features.prettier ? {
21025
- bracketSpacing: !1,
21026
- plugins: ["prettier-plugin-packagejson"],
21027
- printWidth: 100,
21028
- quoteProps: "consistent",
21029
- semi: !1,
21030
- singleQuote: !0,
21031
- tabWidth: 2,
21032
- overrides: [
21033
- {
21034
- files: ["*.yml"],
21035
- options: {
21036
- singleQuote: !1
21037
- }
21038
- }
21039
- ]
21040
- } : void 0, pkgJson = {
21051
+ const { pkgName, repo } = options2, { fullName: name } = pkgName, author = [options2.authorName, options2.authorEmail && `<${options2.authorEmail}>`].filter(Boolean).join(" ") ?? void 0, pkgJson = {
21041
21052
  name,
21042
21053
  version: "0.0.0",
21043
21054
  description: options2.description ?? void 0,
@@ -21074,7 +21085,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21074
21085
  "lint-staged": features.prettier ? {
21075
21086
  "*": ["prettier --write --cache --ignore-unknown"]
21076
21087
  } : void 0,
21077
- // prettier: prettierConfig,
21088
+ prettier: features.prettier ? "@sanity/prettier-config" : void 0,
21078
21089
  browserslist: "extends @sanity/browserslist-config",
21079
21090
  dependencies: {},
21080
21091
  devDependencies: {
@@ -21122,21 +21133,13 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21122
21133
  etc
21123
21134
  node_modules
21124
21135
  `
21125
- }), features.prettier && (files.push({
21136
+ }), features.prettier && files.push({
21126
21137
  name: ".prettierignore",
21127
21138
  contents: outdent`
21128
21139
  dist
21129
21140
  pnpm-lock.yaml
21130
21141
  `
21131
- }), files.push({
21132
- name: ".prettierrc",
21133
- contents: await format(
21134
- resolve(packagePath, ".prettierrc.json"),
21135
- JSON.stringify(prettierConfig, null, 2) + `
21136
- `,
21137
- prettierConfig
21138
- )
21139
- })), repo && (pkgJson.repository = {
21142
+ }), repo && (pkgJson.repository = {
21140
21143
  type: "git",
21141
21144
  url: `git+ssh://git@${repo.source}/${repo.owner}/${repo.name}.git`
21142
21145
  }, pkgJson.bugs = {
@@ -21238,7 +21241,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21238
21241
  /** @type import('eslint').Linter.Config */
21239
21242
  module.exports = ${JSON.stringify(eslintConfig, null, 2)}
21240
21243
  `,
21241
- prettierConfig
21244
+ config
21242
21245
  )
21243
21246
  });
21244
21247
  }
@@ -21278,7 +21281,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21278
21281
  }
21279
21282
  }
21280
21283
  `,
21281
- prettierConfig
21284
+ config
21282
21285
  )
21283
21286
  }), files.push({
21284
21287
  name: "tsconfig.dist.json",
@@ -21296,7 +21299,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21296
21299
  }
21297
21300
  }
21298
21301
  `,
21299
- prettierConfig
21302
+ config
21300
21303
  )
21301
21304
  }), files.push({
21302
21305
  name: "tsconfig.json",
@@ -21316,7 +21319,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21316
21319
  }
21317
21320
  }
21318
21321
  `,
21319
- prettierConfig
21322
+ config
21320
21323
  )
21321
21324
  })), features.typescript ? (files.push({
21322
21325
  name: "package.config.ts",
@@ -21331,7 +21334,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21331
21334
  tsconfig: 'tsconfig.dist.json',
21332
21335
  })
21333
21336
  `,
21334
- prettierConfig
21337
+ config
21335
21338
  )
21336
21339
  }), files.push({
21337
21340
  name: "src/index.ts",
@@ -21343,7 +21346,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21343
21346
  //
21344
21347
  }
21345
21348
  `,
21346
- prettierConfig
21349
+ config
21347
21350
  )
21348
21351
  })) : (files.push({
21349
21352
  name: "package.config.js",
@@ -21361,7 +21364,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21361
21364
  },
21362
21365
  })
21363
21366
  `,
21364
- prettierConfig
21367
+ config
21365
21368
  )
21366
21369
  }), files.push({
21367
21370
  name: "src/index.js",
@@ -21373,7 +21376,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21373
21376
  //
21374
21377
  }
21375
21378
  `,
21376
- prettierConfig
21379
+ config
21377
21380
  )
21378
21381
  }));
21379
21382
  try {
@@ -21391,7 +21394,7 @@ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/
21391
21394
  contents: await format(
21392
21395
  resolve(packagePath, "package.json"),
21393
21396
  JSON.stringify(pkgJson, null, 2),
21394
- prettierConfig
21397
+ config
21395
21398
  )
21396
21399
  }), files;
21397
21400
  }