@sanity/pkg-utils 3.1.1 → 3.2.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": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -46,6 +46,24 @@
46
46
  "!dist/stats.html",
47
47
  "src"
48
48
  ],
49
+ "scripts": {
50
+ "build": "run-s clean build:pkg check:pkg",
51
+ "build:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/build",
52
+ "check:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/check",
53
+ "check:types": "tsc --build",
54
+ "clean": "rimraf dist",
55
+ "commit": "cz",
56
+ "extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
57
+ "format": "prettier --write --cache --ignore-unknown . && eslint . --ext .cjs,.js,.ts,.tsx --fix --quiet",
58
+ "lint": "eslint . --ext .cjs,.js,.ts,.tsx",
59
+ "playground:build": "pnpm --filter './playground/**' build",
60
+ "playground:clean": "pnpm --filter './playground/**' --silent clean",
61
+ "prepublishOnly": "pnpm run build",
62
+ "test": "run-s playground:clean test:clean vitest:run",
63
+ "test:clean": "rimraf test/env/__tmp__",
64
+ "vitest:run": "vitest run",
65
+ "watch": "node --loader esbuild-register/loader -r esbuild-register scripts/watch"
66
+ },
49
67
  "commitlint": {
50
68
  "extends": [
51
69
  "@commitlint/config-conventional"
@@ -107,7 +125,7 @@
107
125
  "esbuild-register": "^3.5.0",
108
126
  "find-config": "^1.0.0",
109
127
  "get-latest-version": "^5.1.0",
110
- "git-url-parse": "^13.1.0",
128
+ "git-url-parse": "^13.1.1",
111
129
  "globby": "^11.1.0",
112
130
  "jsonc-parser": "^3.2.0",
113
131
  "mkdirp": "^3.0.1",
@@ -127,8 +145,9 @@
127
145
  "zod": "^3.22.4"
128
146
  },
129
147
  "devDependencies": {
130
- "@commitlint/cli": "^17.8.0",
131
- "@commitlint/config-conventional": "^17.8.0",
148
+ "@commitlint/cli": "^18.0.0",
149
+ "@commitlint/config-conventional": "^18.0.0",
150
+ "@sanity/pkg-utils": "workspace:*",
132
151
  "@types/babel__core": "^7.20.3",
133
152
  "@types/cpx": "^1.5.4",
134
153
  "@types/find-config": "^1.0.3",
@@ -138,19 +157,19 @@
138
157
  "@types/prompts": "^2.4.7",
139
158
  "@types/rimraf": "^3.0.2",
140
159
  "@types/treeify": "^1.0.2",
141
- "@types/uuid": "^9.0.5",
160
+ "@types/uuid": "^9.0.6",
142
161
  "@typescript-eslint/eslint-plugin": "^6.8.0",
143
162
  "@typescript-eslint/parser": "^6.8.0",
144
163
  "commitizen": "^4.3.0",
145
164
  "cpx": "^1.5.0",
146
165
  "cz-conventional-changelog": "^3.3.0",
147
- "eslint": "^8.51.0",
166
+ "eslint": "^8.52.0",
148
167
  "eslint-config-prettier": "^9.0.0",
149
- "eslint-plugin-import": "^2.28.1",
168
+ "eslint-plugin-import": "^2.29.0",
150
169
  "eslint-plugin-prettier": "^5.0.1",
151
170
  "eslint-plugin-simple-import-sort": "10.0.0",
152
171
  "husky": "^8.0.3",
153
- "lint-staged": "^15.0.1",
172
+ "lint-staged": "^15.0.2",
154
173
  "npm-run-all": "^4.1.5",
155
174
  "outdent": "^0.8.0",
156
175
  "recast": "^0.23.4",
@@ -158,8 +177,7 @@
158
177
  "ts-node": "^10.9.1",
159
178
  "typescript": "^5.2.2",
160
179
  "vitest": "^0.34.6",
161
- "vitest-github-actions-reporter": "^0.10.0",
162
- "@sanity/pkg-utils": "3.1.1"
180
+ "vitest-github-actions-reporter": "^0.10.0"
163
181
  },
164
182
  "peerDependencies": {
165
183
  "typescript": "^4.7 || ^5"
@@ -171,21 +189,9 @@
171
189
  "publishConfig": {
172
190
  "access": "public"
173
191
  },
174
- "scripts": {
175
- "build": "run-s clean build:pkg check:pkg",
176
- "build:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/build",
177
- "check:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/check",
178
- "check:types": "tsc --build",
179
- "clean": "rimraf dist",
180
- "commit": "cz",
181
- "extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
182
- "format": "prettier --write --cache --ignore-unknown . && eslint . --ext .cjs,.js,.ts,.tsx --fix --quiet",
183
- "lint": "eslint . --ext .cjs,.js,.ts,.tsx",
184
- "playground:build": "pnpm --filter './playground/**' build",
185
- "playground:clean": "pnpm --filter './playground/**' --silent clean",
186
- "test": "run-s playground:clean test:clean vitest:run",
187
- "test:clean": "rimraf test/env/__tmp__",
188
- "vitest:run": "vitest run",
189
- "watch": "node --loader esbuild-register/loader -r esbuild-register scripts/watch"
192
+ "pnpm": {
193
+ "overrides": {
194
+ "@sanity/pkg-utils": "workspace:*"
195
+ }
190
196
  }
191
- }
197
+ }
@@ -79,6 +79,7 @@ export interface PkgConfigOptions {
79
79
  dist?: string
80
80
  exports?: PkgConfigProperty<PkgExports>
81
81
  extract?: {
82
+ bundledPackages?: string[]
82
83
  customTags?: TSDocCustomTag[]
83
84
  rules?: {
84
85
  'ae-forgotten-export'?: PkgRuleLevel
@@ -2,6 +2,7 @@ import {IConfigFile, IExtractorMessagesConfig} from '@microsoft/api-extractor'
2
2
  import path from 'path'
3
3
 
4
4
  export function createApiExtractorConfig(options: {
5
+ bundledPackages?: string[]
5
6
  distPath: string
6
7
  exportPath: string
7
8
  filePath: string
@@ -11,6 +12,7 @@ export function createApiExtractorConfig(options: {
11
12
  tsconfigPath: string
12
13
  }): IConfigFile {
13
14
  const {
15
+ bundledPackages,
14
16
  distPath,
15
17
  exportPath,
16
18
  filePath,
@@ -25,7 +27,7 @@ export function createApiExtractorConfig(options: {
25
27
  enabled: false,
26
28
  reportFileName: '<unscopedPackageName>.api.md',
27
29
  },
28
- // bundledPackages: [],
30
+ bundledPackages,
29
31
  compiler: {
30
32
  tsconfigFilePath: tsconfigPath,
31
33
  },
@@ -47,6 +47,7 @@ export async function doExtract(
47
47
  const targetPath = path.resolve(cwd, entry.targetPath)
48
48
  const filePath = path.relative(outDir, targetPath)
49
49
  const result = await extractTypes({
50
+ bundledPackages: config?.extract?.bundledPackages || [],
50
51
  customTags: config?.extract?.customTags,
51
52
  cwd,
52
53
  distPath: outDir,
@@ -63,6 +64,7 @@ export async function doExtract(
63
64
  messages.push(...result.messages)
64
65
 
65
66
  const errors = result.messages.filter((msg) => msg.logLevel === 'error')
67
+
66
68
  if (errors.length > 0) {
67
69
  await rimraf(tmpPath)
68
70
  throw new DtsError(`encountered ${errors.length} errors when extracting types`, errors)
@@ -16,6 +16,7 @@ import {extractModuleBlocksFromTypes} from './extractModuleBlocks'
16
16
  import {getExtractMessagesConfig} from './getExtractMessagesConfig'
17
17
 
18
18
  export async function extractTypes(options: {
19
+ bundledPackages?: string[]
19
20
  customTags: NonNullable<PkgConfigOptions['extract']>['customTags']
20
21
  cwd: string
21
22
  distPath: string
@@ -29,6 +30,7 @@ export async function extractTypes(options: {
29
30
  tsconfigPath: string
30
31
  }): Promise<{extractorResult: ExtractorResult; messages: ExtractorMessage[]}> {
31
32
  const {
33
+ bundledPackages,
32
34
  customTags,
33
35
  distPath,
34
36
  exportPath,
@@ -47,6 +49,7 @@ export async function extractTypes(options: {
47
49
 
48
50
  const extractorConfig: ExtractorConfig = ExtractorConfig.prepare({
49
51
  configObject: createApiExtractorConfig({
52
+ bundledPackages,
50
53
  distPath,
51
54
  exportPath,
52
55
  filePath,