@sanity/pkg-utils 7.2.6 → 7.2.8-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/bin/pkg-utils.cjs +1 -0
- package/dist/_chunks-cjs/build.cjs +2 -2
- package/dist/_chunks-cjs/build.cjs.map +1 -1
- package/dist/_chunks-cjs/check.cjs.map +1 -1
- package/dist/_chunks-cjs/consoleSpy.cjs +2 -7
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/_chunks-cjs/handleError.cjs.map +1 -1
- package/dist/_chunks-cjs/index.cjs +36 -20
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/_chunks-cjs/init.cjs +12 -12
- package/dist/_chunks-cjs/init.cjs.map +1 -1
- package/dist/_chunks-cjs/logger.cjs +0 -2
- package/dist/_chunks-cjs/logger.cjs.map +1 -1
- package/dist/_chunks-cjs/watch.cjs +17 -2
- package/dist/_chunks-cjs/watch.cjs.map +1 -1
- package/dist/cli.cjs +2 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/index.d.cts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +36 -40
- package/dist/index.js.map +1 -1
- package/package.json +16 -19
- package/src/cli/handleError.ts +0 -2
- package/src/cli/index.ts +1 -2
- package/src/global.ts +0 -1
- package/src/node/build.ts +2 -4
- package/src/node/check.ts +0 -1
- package/src/node/consoleSpy.ts +0 -2
- package/src/node/core/config/loadConfig.ts +0 -1
- package/src/node/core/template/types.ts +0 -3
- package/src/node/logger.ts +1 -2
- package/src/node/printPackageTree.ts +0 -2
- package/src/node/resolveBuildContext.ts +6 -14
- package/src/node/spinner.ts +1 -2
- package/src/node/tasks/dts/doExtract.ts +1 -3
- package/src/node/tasks/dts/dtsWatchTask.ts +1 -3
- package/src/node/tasks/dts/extractTypes.ts +1 -3
- package/src/node/tasks/dts/getTargetPaths.ts +0 -1
- package/src/node/tasks/rollup/resolveRollupConfig.ts +8 -11
- package/src/node/tasks/rollup/rollupTask.ts +0 -1
- package/src/node/templates/default/template.ts +16 -16
- package/src/node/watchFiles.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.8-canary.0",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -59,13 +59,15 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"lint-staged": {
|
|
62
|
+
"*.{js,jsx,ts,tsx,mjs,cjs}": [
|
|
63
|
+
"prettier --cache --write",
|
|
64
|
+
"oxlint --fix --quiet"
|
|
65
|
+
],
|
|
62
66
|
"*": [
|
|
63
|
-
"prettier --write --cache --ignore-unknown"
|
|
64
|
-
"eslint --ext .cjs,.js,.ts,.tsx --fix"
|
|
67
|
+
"prettier --write --cache --ignore-unknown"
|
|
65
68
|
]
|
|
66
69
|
},
|
|
67
70
|
"browserslist": "extends @sanity/browserslist-config",
|
|
68
|
-
"prettier": "@sanity/prettier-config",
|
|
69
71
|
"dependencies": {
|
|
70
72
|
"@babel/core": "^7.27.4",
|
|
71
73
|
"@babel/preset-typescript": "^7.27.1",
|
|
@@ -75,7 +77,7 @@
|
|
|
75
77
|
"@optimize-lodash/rollup-plugin": "5.0.2",
|
|
76
78
|
"@rollup/plugin-alias": "^5.1.1",
|
|
77
79
|
"@rollup/plugin-babel": "^6.0.4",
|
|
78
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
80
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
79
81
|
"@rollup/plugin-json": "^6.1.0",
|
|
80
82
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
81
83
|
"@rollup/plugin-replace": "^6.0.2",
|
|
@@ -105,13 +107,14 @@
|
|
|
105
107
|
"rxjs": "^7.8.2",
|
|
106
108
|
"treeify": "^1.1.0",
|
|
107
109
|
"uuid": "^11.1.0",
|
|
108
|
-
"zod": "3.25.
|
|
109
|
-
"zod-validation-error": "3.5.
|
|
110
|
+
"zod": "3.25.67",
|
|
111
|
+
"zod-validation-error": "3.5.2"
|
|
110
112
|
},
|
|
111
113
|
"devDependencies": {
|
|
112
114
|
"@commitlint/cli": "^19.8.1",
|
|
113
115
|
"@commitlint/config-conventional": "^19.8.1",
|
|
114
|
-
"@
|
|
116
|
+
"@ianvs/prettier-plugin-sort-imports": "^4.4.2",
|
|
117
|
+
"@sanity/prettier-config": "^1.0.4",
|
|
115
118
|
"@types/babel__core": "^7.20.5",
|
|
116
119
|
"@types/cpx": "^1.5.5",
|
|
117
120
|
"@types/find-config": "^1.0.4",
|
|
@@ -122,27 +125,21 @@
|
|
|
122
125
|
"@types/semver": "^7.5.8",
|
|
123
126
|
"@types/treeify": "^1.0.3",
|
|
124
127
|
"@types/uuid": "^10.0.0",
|
|
125
|
-
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
126
|
-
"@typescript-eslint/parser": "^8.34.0",
|
|
127
128
|
"browserslist-to-esbuild": "2.1.1",
|
|
128
129
|
"commitizen": "^4.3.1",
|
|
129
130
|
"cpx": "^1.5.0",
|
|
130
131
|
"cz-conventional-changelog": "^3.3.0",
|
|
131
|
-
"eslint": "^8.57.1",
|
|
132
|
-
"eslint-config-prettier": "^10.1.5",
|
|
133
|
-
"eslint-plugin-import": "^2.31.0",
|
|
134
|
-
"eslint-plugin-prettier": "^5.4.1",
|
|
135
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
136
132
|
"husky": "^8.0.3",
|
|
137
133
|
"lint-staged": "^15.0.2",
|
|
138
134
|
"npm-run-all2": "^8.0.4",
|
|
139
135
|
"outdent": "^0.8.0",
|
|
136
|
+
"oxlint": "^1.1.0",
|
|
140
137
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
141
138
|
"semver": "^7.6.0",
|
|
142
139
|
"ts-node": "^10.9.2",
|
|
143
140
|
"typescript": "5.8.3",
|
|
144
|
-
"vitest": "^3.2.
|
|
145
|
-
"@sanity/pkg-utils": "7.2.
|
|
141
|
+
"vitest": "^3.2.4",
|
|
142
|
+
"@sanity/pkg-utils": "7.2.8-canary.0"
|
|
146
143
|
},
|
|
147
144
|
"peerDependencies": {
|
|
148
145
|
"babel-plugin-react-compiler": "*",
|
|
@@ -167,8 +164,8 @@
|
|
|
167
164
|
"clean": "rimraf dist test/env/__tmp__",
|
|
168
165
|
"commit": "cz",
|
|
169
166
|
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
170
|
-
"format": "prettier --write --cache --ignore-unknown . &&
|
|
171
|
-
"lint": "
|
|
167
|
+
"format": "prettier --write --cache --ignore-unknown . && oxlint --fix --quiet",
|
|
168
|
+
"lint": "oxlint",
|
|
172
169
|
"playground:build": "pnpm --filter './playground/**' build",
|
|
173
170
|
"playground:clean": "pnpm --filter './playground/**' --silent clean",
|
|
174
171
|
"pretest": "run-s playground:clean",
|
package/src/cli/handleError.ts
CHANGED
package/src/cli/index.ts
CHANGED
package/src/global.ts
CHANGED
package/src/node/build.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import rimraf from 'rimraf'
|
|
4
|
-
|
|
2
|
+
import {rimraf} from 'rimraf'
|
|
5
3
|
import {loadConfig, loadPkgWithReporting} from './core'
|
|
6
4
|
import {createLogger} from './logger'
|
|
7
5
|
import {resolveBuildContext} from './resolveBuildContext'
|
|
8
6
|
import {resolveBuildTasks} from './resolveBuildTasks'
|
|
9
7
|
import {createSpinner} from './spinner'
|
|
10
|
-
import {type BuildTask,
|
|
8
|
+
import {buildTaskHandlers, type BuildTask, type TaskHandler} from './tasks'
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Build the distribution files of a npm package.
|
package/src/node/check.ts
CHANGED
|
@@ -120,7 +120,6 @@ async function checkExports(
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
const esbuildWarnings = esbuildResult.warnings.filter((msg) => {
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
124
123
|
!(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)
|
|
125
124
|
})
|
|
126
125
|
|
package/src/node/consoleSpy.ts
CHANGED
|
@@ -31,7 +31,6 @@ export async function loadConfig(options: {cwd: string}): Promise<PkgConfigOptio
|
|
|
31
31
|
|
|
32
32
|
const {unregister} = globalThis.__DEV__ ? {unregister: () => undefined} : register(esbuildOptions)
|
|
33
33
|
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
35
34
|
const mod = require(configFile)
|
|
36
35
|
|
|
37
36
|
unregister()
|
|
@@ -11,7 +11,6 @@ export interface PkgTemplateStringOption<T = string> {
|
|
|
11
11
|
name: string
|
|
12
12
|
type: 'string'
|
|
13
13
|
description: string
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
14
|
initial?: T | ((options: Record<string, any>) => T)
|
|
16
15
|
parse?: (v: string) => T | null
|
|
17
16
|
validate?: (v: string) => string | true
|
|
@@ -22,7 +21,6 @@ export type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
|
|
|
22
21
|
|
|
23
22
|
/** @public */
|
|
24
23
|
export interface PkgTemplateDefinition {
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
24
|
options: PkgTemplateStringOption<any>[]
|
|
27
25
|
features: {
|
|
28
26
|
name: string
|
|
@@ -30,7 +28,6 @@ export interface PkgTemplateDefinition {
|
|
|
30
28
|
initial: boolean
|
|
31
29
|
}[]
|
|
32
30
|
getFiles: (
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
31
|
options: Record<string, any>,
|
|
35
32
|
features: Record<string, boolean>,
|
|
36
33
|
) => Promise<PkgTemplateFile[]>
|
package/src/node/logger.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// oxlint-disable no-console
|
|
1
2
|
import chalk from 'chalk'
|
|
2
3
|
|
|
3
4
|
/** @internal */
|
|
@@ -12,7 +13,6 @@ export interface Logger {
|
|
|
12
13
|
/** @internal */
|
|
13
14
|
export function createLogger(): Logger {
|
|
14
15
|
return {
|
|
15
|
-
/* eslint-disable no-console */
|
|
16
16
|
log: (...args) => {
|
|
17
17
|
console.log(...args)
|
|
18
18
|
},
|
|
@@ -28,6 +28,5 @@ export function createLogger(): Logger {
|
|
|
28
28
|
success: (...args) => {
|
|
29
29
|
console.log(chalk.green('[success]'), ...args)
|
|
30
30
|
},
|
|
31
|
-
/* eslint-enable no-console */
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -22,7 +22,6 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
22
22
|
|
|
23
23
|
logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)
|
|
24
24
|
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
25
|
const tree: Record<string, unknown> = {}
|
|
27
26
|
|
|
28
27
|
if (pkg.type) {
|
|
@@ -93,6 +92,5 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
93
92
|
}),
|
|
94
93
|
)
|
|
95
94
|
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
95
|
logger.log(treeify.asTree(tree as Record<string, any>, true, true))
|
|
98
96
|
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import browserslistToEsbuild from 'browserslist-to-esbuild'
|
|
4
|
-
|
|
5
3
|
import {
|
|
6
|
-
type BuildContext,
|
|
7
4
|
DEFAULT_BROWSERSLIST_QUERY,
|
|
8
5
|
loadTSConfig,
|
|
9
|
-
type PackageJSON,
|
|
10
6
|
parseExports,
|
|
7
|
+
resolveConfigProperty,
|
|
8
|
+
type BuildContext,
|
|
9
|
+
type PackageJSON,
|
|
11
10
|
type PkgConfigOptions,
|
|
12
11
|
type PkgExports,
|
|
13
12
|
type PkgRuntime,
|
|
14
|
-
resolveConfigProperty,
|
|
15
13
|
} from './core'
|
|
16
14
|
import {findCommonDirPath, pathContains} from './core/findCommonPath'
|
|
17
15
|
import type {Logger} from './logger'
|
|
@@ -40,7 +38,6 @@ export async function resolveBuildContext(options: {
|
|
|
40
38
|
const tsconfig = await loadTSConfig({cwd, tsconfigPath})
|
|
41
39
|
const strictOptions = parseStrictOptions(config?.strictOptions ?? {})
|
|
42
40
|
|
|
43
|
-
/* eslint-disable padding-line-between-statements */
|
|
44
41
|
let browserslist = pkg.browserslist
|
|
45
42
|
if (!browserslist) {
|
|
46
43
|
if (strict && strictOptions.noImplicitBrowsersList !== 'off') {
|
|
@@ -58,7 +55,6 @@ export async function resolveBuildContext(options: {
|
|
|
58
55
|
browserslist = DEFAULT_BROWSERSLIST_QUERY
|
|
59
56
|
}
|
|
60
57
|
const targetVersions = browserslistToEsbuild(browserslist)
|
|
61
|
-
/* eslint-enable padding-line-between-statements */
|
|
62
58
|
|
|
63
59
|
if (
|
|
64
60
|
strict &&
|
|
@@ -98,10 +94,8 @@ export async function resolveBuildContext(options: {
|
|
|
98
94
|
strict,
|
|
99
95
|
strictOptions,
|
|
100
96
|
logger,
|
|
101
|
-
}).reduce<PkgExports>((acc,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return {...acc, [exportPath]: exportEntry}
|
|
97
|
+
}).reduce<PkgExports>((acc, {_path: exportPath, ...exportEntry}) => {
|
|
98
|
+
return Object.assign(acc, {[exportPath]: exportEntry})
|
|
105
99
|
}, {})
|
|
106
100
|
|
|
107
101
|
const exports = resolveConfigProperty(config?.exports, parsedExports)
|
|
@@ -118,9 +112,7 @@ export async function resolveBuildContext(options: {
|
|
|
118
112
|
: resolveConfigProperty(config?.external, parsedExternal)
|
|
119
113
|
// Merge bundledPackages with dev deps, replace if it's a function
|
|
120
114
|
const externalWithTypes = new Set([pkg.name, ...external, ...external.map(transformPackageName)])
|
|
121
|
-
const bundledDependencies = [
|
|
122
|
-
...(pkg.devDependencies ? Object.keys(pkg.devDependencies) : []),
|
|
123
|
-
].filter(
|
|
115
|
+
const bundledDependencies = (pkg.devDependencies ? Object.keys(pkg.devDependencies) : []).filter(
|
|
124
116
|
// Do not bundle anything that is marked as external
|
|
125
117
|
(_) => !externalWithTypes.has(_),
|
|
126
118
|
)
|
package/src/node/spinner.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import type {ExtractorMessage} from '@microsoft/api-extractor'
|
|
4
|
-
import rimraf from 'rimraf'
|
|
5
|
-
|
|
3
|
+
import {rimraf} from 'rimraf'
|
|
6
4
|
import type {BuildContext} from '../../core'
|
|
7
5
|
import {buildTypes} from './buildTypes'
|
|
8
6
|
import {DtsError} from './DtsError'
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import type {ExtractorMessage} from '@microsoft/api-extractor'
|
|
4
3
|
import chalk from 'chalk'
|
|
5
|
-
import rimraf from 'rimraf'
|
|
4
|
+
import * as rimraf from 'rimraf'
|
|
6
5
|
import {Observable} from 'rxjs'
|
|
7
6
|
import ts from 'typescript'
|
|
8
|
-
|
|
9
7
|
import {printExtractMessages} from '../../printExtractMessages'
|
|
10
8
|
import type {TaskHandler} from '../types'
|
|
11
9
|
import {buildTypes} from './buildTypes'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
|
|
4
3
|
import {
|
|
5
4
|
Extractor,
|
|
6
5
|
ExtractorConfig,
|
|
@@ -8,9 +7,8 @@ import {
|
|
|
8
7
|
type ExtractorResult,
|
|
9
8
|
} from '@microsoft/api-extractor'
|
|
10
9
|
import {mkdirp} from 'mkdirp'
|
|
11
|
-
import prettier from 'prettier'
|
|
10
|
+
import * as prettier from 'prettier'
|
|
12
11
|
import type ts from 'typescript'
|
|
13
|
-
|
|
14
12
|
import type {BuildFile, PkgConfigOptions} from '../../core'
|
|
15
13
|
import {createApiExtractorConfig} from './createApiExtractorConfig'
|
|
16
14
|
import {createTSDocConfig} from './createTSDocConfig'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import type {PluginItem} from '@babel/core'
|
|
4
3
|
import {optimizeLodashImports} from '@optimize-lodash/rollup-plugin'
|
|
5
4
|
import alias from '@rollup/plugin-alias'
|
|
@@ -11,9 +10,8 @@ import replace from '@rollup/plugin-replace'
|
|
|
11
10
|
import terser from '@rollup/plugin-terser'
|
|
12
11
|
import type {InputOptions, OutputOptions, Plugin} from 'rollup'
|
|
13
12
|
import esbuild from 'rollup-plugin-esbuild'
|
|
14
|
-
|
|
15
13
|
import {pkgExtMap as extMap} from '../../../node/core/pkg/pkgExt'
|
|
16
|
-
import {type BuildContext, type PackageJSON
|
|
14
|
+
import {resolveConfigProperty, type BuildContext, type PackageJSON} from '../../core'
|
|
17
15
|
import type {RollupTask, RollupWatchTask} from '../types'
|
|
18
16
|
|
|
19
17
|
export interface RollupConfig {
|
|
@@ -59,8 +57,8 @@ export function resolveRollupConfig(
|
|
|
59
57
|
const defaultPlugins = [
|
|
60
58
|
replace({
|
|
61
59
|
preventAssignment: true,
|
|
62
|
-
values:
|
|
63
|
-
|
|
60
|
+
values:
|
|
61
|
+
pkg.name === '@sanity/pkg-utils'
|
|
64
62
|
? {...replacements}
|
|
65
63
|
: {
|
|
66
64
|
'process.env.PKG_FILE_PATH': (arg) => {
|
|
@@ -68,7 +66,6 @@ export function resolveRollupConfig(
|
|
|
68
66
|
const entry = entries.find((e) => e.source === sourcePath)
|
|
69
67
|
|
|
70
68
|
if (!entry) {
|
|
71
|
-
// eslint-disable-next-line no-console
|
|
72
69
|
console.error(`could not find source entry: ${sourcePath}`)
|
|
73
70
|
|
|
74
71
|
return 'null'
|
|
@@ -82,8 +79,7 @@ export function resolveRollupConfig(
|
|
|
82
79
|
'process.env.PKG_RUNTIME': JSON.stringify(runtime),
|
|
83
80
|
'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),
|
|
84
81
|
...replacements,
|
|
85
|
-
}
|
|
86
|
-
},
|
|
82
|
+
},
|
|
87
83
|
}),
|
|
88
84
|
alias({
|
|
89
85
|
entries: {...pathAliases},
|
|
@@ -220,9 +216,10 @@ export function resolveRollupConfig(
|
|
|
220
216
|
return false
|
|
221
217
|
},
|
|
222
218
|
|
|
223
|
-
input: entries.reduce<{[entryAlias: string]: string}>(
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
input: entries.reduce<{[entryAlias: string]: string}>(
|
|
220
|
+
(acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),
|
|
221
|
+
{},
|
|
222
|
+
),
|
|
226
223
|
|
|
227
224
|
watch: {
|
|
228
225
|
chokidar: {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import {execSync} from 'node:child_process'
|
|
2
2
|
import {resolve} from 'node:path'
|
|
3
|
-
|
|
4
3
|
import prettierConfig from '@sanity/prettier-config'
|
|
5
4
|
import getLatestVersion from 'get-latest-version'
|
|
6
5
|
import gitUrlParse from 'git-url-parse'
|
|
7
6
|
import {outdent} from 'outdent'
|
|
8
|
-
import
|
|
9
|
-
|
|
7
|
+
import {format, type Config as PrettierConfig} from 'prettier'
|
|
10
8
|
import {
|
|
11
9
|
defineTemplateOption,
|
|
12
10
|
isRecord,
|
|
@@ -262,7 +260,6 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
262
260
|
}
|
|
263
261
|
|
|
264
262
|
if (features['eslint']) {
|
|
265
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
263
|
const eslintConfig: any = {
|
|
267
264
|
root: true,
|
|
268
265
|
env: {
|
|
@@ -324,7 +321,6 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
324
321
|
'@typescript-eslint/parser': '^7',
|
|
325
322
|
}
|
|
326
323
|
|
|
327
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
328
324
|
const eslintConfigOverride: any = {
|
|
329
325
|
files: ['**/*.ts', '**/*.tsx'],
|
|
330
326
|
parser: '@typescript-eslint/parser',
|
|
@@ -356,7 +352,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
356
352
|
|
|
357
353
|
files.push({
|
|
358
354
|
name: '.eslintrc.cjs',
|
|
359
|
-
contents: await
|
|
355
|
+
contents: await prettierFormat(
|
|
360
356
|
resolve(packagePath, '.eslintrc.cjs'),
|
|
361
357
|
outdent`
|
|
362
358
|
'use strict'
|
|
@@ -372,7 +368,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
372
368
|
if (features['typescript']) {
|
|
373
369
|
files.push({
|
|
374
370
|
name: 'tsconfig.settings.json',
|
|
375
|
-
contents: await
|
|
371
|
+
contents: await prettierFormat(
|
|
376
372
|
resolve(packagePath, 'tsconfig.settings.json'),
|
|
377
373
|
outdent`
|
|
378
374
|
{
|
|
@@ -389,7 +385,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
389
385
|
|
|
390
386
|
files.push({
|
|
391
387
|
name: 'tsconfig.dist.json',
|
|
392
|
-
contents: await
|
|
388
|
+
contents: await prettierFormat(
|
|
393
389
|
resolve(packagePath, 'tsconfig.dist.json'),
|
|
394
390
|
outdent`
|
|
395
391
|
{
|
|
@@ -404,7 +400,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
404
400
|
|
|
405
401
|
files.push({
|
|
406
402
|
name: 'tsconfig.json',
|
|
407
|
-
contents: await
|
|
403
|
+
contents: await prettierFormat(
|
|
408
404
|
resolve(packagePath, 'tsconfig.json'),
|
|
409
405
|
outdent`
|
|
410
406
|
{
|
|
@@ -422,7 +418,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
422
418
|
if (features['typescript']) {
|
|
423
419
|
files.push({
|
|
424
420
|
name: 'package.config.ts',
|
|
425
|
-
contents: await
|
|
421
|
+
contents: await prettierFormat(
|
|
426
422
|
resolve(packagePath, 'package.config.ts'),
|
|
427
423
|
outdent`
|
|
428
424
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
@@ -439,7 +435,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
439
435
|
|
|
440
436
|
files.push({
|
|
441
437
|
name: 'src/index.ts',
|
|
442
|
-
contents: await
|
|
438
|
+
contents: await prettierFormat(
|
|
443
439
|
resolve(packagePath, 'src/index.ts'),
|
|
444
440
|
outdent`
|
|
445
441
|
/** @public */
|
|
@@ -453,7 +449,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
453
449
|
} else {
|
|
454
450
|
files.push({
|
|
455
451
|
name: 'package.config.js',
|
|
456
|
-
contents: await
|
|
452
|
+
contents: await prettierFormat(
|
|
457
453
|
resolve(packagePath, 'package.config.js'),
|
|
458
454
|
outdent`
|
|
459
455
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
@@ -473,7 +469,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
473
469
|
|
|
474
470
|
files.push({
|
|
475
471
|
name: 'src/index.js',
|
|
476
|
-
contents: await
|
|
472
|
+
contents: await prettierFormat(
|
|
477
473
|
resolve(packagePath, 'src/index.js'),
|
|
478
474
|
outdent`
|
|
479
475
|
/** @public */
|
|
@@ -502,7 +498,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
502
498
|
|
|
503
499
|
files.push({
|
|
504
500
|
name: 'package.json',
|
|
505
|
-
contents: await
|
|
501
|
+
contents: await prettierFormat(
|
|
506
502
|
resolve(packagePath, 'package.json'),
|
|
507
503
|
JSON.stringify(pkgJson, null, 2),
|
|
508
504
|
prettierConfig,
|
|
@@ -514,8 +510,12 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
514
510
|
}
|
|
515
511
|
}
|
|
516
512
|
|
|
517
|
-
function
|
|
518
|
-
|
|
513
|
+
function prettierFormat(
|
|
514
|
+
filepath: string,
|
|
515
|
+
input: string,
|
|
516
|
+
prettierOptions: PrettierConfig | undefined,
|
|
517
|
+
) {
|
|
518
|
+
return format(input, {...prettierOptions, plugins: [], filepath})
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
async function resolveLatestDeps(deps: Record<string, string | undefined>) {
|
package/src/node/watchFiles.ts
CHANGED