@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "6.7.1",
3
+ "version": "6.8.0",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -31,8 +31,11 @@
31
31
  "default": "./dist/index.js"
32
32
  },
33
33
  "./tsconfig/recommended.json": "./tsconfig/recommended.json",
34
+ "./tsconfig/recommended": "./tsconfig/recommended.json",
34
35
  "./tsconfig/strict.json": "./tsconfig/strict.json",
36
+ "./tsconfig/strict": "./tsconfig/strict.json",
35
37
  "./tsconfig/strictest.json": "./tsconfig/strictest.json",
38
+ "./tsconfig": "./tsconfig/strictest.json",
36
39
  "./package.json": "./package.json"
37
40
  },
38
41
  "main": "./dist/index.cjs",
@@ -62,6 +65,7 @@
62
65
  ]
63
66
  },
64
67
  "browserslist": "extends @sanity/browserslist-config",
68
+ "prettier": "@sanity/prettier-config",
65
69
  "dependencies": {
66
70
  "@babel/core": "^7.24.4",
67
71
  "@babel/types": "^7.24.0",
@@ -92,7 +96,6 @@
92
96
  "parse-git-config": "^3.0.0",
93
97
  "pkg-up": "^3.1.0",
94
98
  "prettier": "^3.2.5",
95
- "prettier-plugin-packagejson": "^2.5.0",
96
99
  "pretty-bytes": "^5.6.0",
97
100
  "prompts": "^2.4.2",
98
101
  "rimraf": "^4.4.1",
@@ -107,6 +110,7 @@
107
110
  "devDependencies": {
108
111
  "@commitlint/cli": "^19.2.2",
109
112
  "@commitlint/config-conventional": "^19.2.2",
113
+ "@sanity/prettier-config": "^1.0.0",
110
114
  "@types/babel__core": "^7.20.5",
111
115
  "@types/cpx": "^1.5.5",
112
116
  "@types/find-config": "^1.0.4",
@@ -140,7 +144,7 @@
140
144
  "typescript": "5.4.5",
141
145
  "vitest": "^1.5.0",
142
146
  "vitest-github-actions-reporter": "^0.11.1",
143
- "@sanity/pkg-utils": "6.7.1"
147
+ "@sanity/pkg-utils": "6.8.0"
144
148
  },
145
149
  "peerDependencies": {
146
150
  "typescript": "5.4.x"
@@ -163,7 +163,10 @@ export function parseExports(options: {
163
163
  }
164
164
 
165
165
  for (const [exportPath, exportEntry] of Object.entries(pkg.exports)) {
166
- if (exportPath.endsWith('.json')) {
166
+ if (
167
+ exportPath.endsWith('.json') ||
168
+ (typeof exportEntry === 'string' && exportEntry.endsWith('.json'))
169
+ ) {
167
170
  if (exportPath === './package.json') {
168
171
  if (exportEntry !== './package.json') {
169
172
  errors.push('package.json: `exports["./package.json"] must be "./package.json".')
@@ -1,5 +1,6 @@
1
1
  import {resolve} from 'node:path'
2
2
 
3
+ import prettierConfig from '@sanity/prettier-config'
3
4
  import getLatestVersion from 'get-latest-version'
4
5
  import gitUrlParse from 'git-url-parse'
5
6
  import {outdent} from 'outdent'
@@ -133,28 +134,8 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
133
134
  .filter(Boolean)
134
135
  .join(' ') ?? undefined
135
136
 
136
- const prettierConfig: PrettierConfig | undefined = features['prettier']
137
- ? {
138
- bracketSpacing: false,
139
- plugins: ['prettier-plugin-packagejson'],
140
- printWidth: 100,
141
- quoteProps: 'consistent',
142
- semi: false,
143
- singleQuote: true,
144
- tabWidth: 2,
145
- overrides: [
146
- {
147
- files: ['*.yml'],
148
- options: {
149
- singleQuote: false,
150
- },
151
- },
152
- ],
153
- }
154
- : undefined
155
-
156
137
  const pkgJson: PackageJSON & {
157
- prettier?: PrettierConfig
138
+ prettier?: '@sanity/prettier-config'
158
139
  ['lint-staged']?: Record<string, string[]>
159
140
  } = {
160
141
  name,
@@ -197,7 +178,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
197
178
  '*': ['prettier --write --cache --ignore-unknown'],
198
179
  }
199
180
  : undefined,
200
- // prettier: prettierConfig,
181
+ 'prettier': features['prettier'] ? '@sanity/prettier-config' : undefined,
201
182
  'browserslist': 'extends @sanity/browserslist-config',
202
183
  'dependencies': {},
203
184
  'devDependencies': {
@@ -262,15 +243,6 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
262
243
  pnpm-lock.yaml
263
244
  `,
264
245
  })
265
-
266
- files.push({
267
- name: '.prettierrc',
268
- contents: await format(
269
- resolve(packagePath, '.prettierrc.json'),
270
- JSON.stringify(prettierConfig, null, 2) + '\n',
271
- prettierConfig,
272
- ),
273
- })
274
246
  }
275
247
 
276
248
  if (repo) {