@sanity/pkg-utils 3.2.0 → 3.2.1
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/{build-zIodsGMj.cjs → build-5-t0rNQ5.cjs} +3 -3
- package/dist/_chunks/{build-zIodsGMj.cjs.map → build-5-t0rNQ5.cjs.map} +1 -1
- package/dist/_chunks/{buildAction-F25hbZcX.cjs → buildAction-XzgSYD6h.cjs} +2 -2
- package/dist/_chunks/{buildAction-F25hbZcX.cjs.map → buildAction-XzgSYD6h.cjs.map} +1 -1
- package/dist/_chunks/{check-X8xKPDnl.cjs → check-K-76aP0H.cjs} +2 -2
- package/dist/_chunks/{check-X8xKPDnl.cjs.map → check-K-76aP0H.cjs.map} +1 -1
- package/dist/_chunks/{checkAction-uQWLDlBA.cjs → checkAction-ovZpdoTW.cjs} +2 -2
- package/dist/_chunks/{checkAction-uQWLDlBA.cjs.map → checkAction-ovZpdoTW.cjs.map} +1 -1
- package/dist/_chunks/{consoleSpy--ReK-_gE.cjs → consoleSpy-Njnvw7-i.cjs} +4 -4
- package/dist/_chunks/consoleSpy-Njnvw7-i.cjs.map +1 -0
- package/dist/_chunks/{index-qV4Iq6pv.cjs → index-jKQCY5H6.cjs} +3 -3
- package/dist/_chunks/{index-qV4Iq6pv.cjs.map → index-jKQCY5H6.cjs.map} +1 -1
- package/dist/_chunks/{init-gkPbG69g.cjs → init-F_vsNarH.cjs} +78 -49
- package/dist/_chunks/init-F_vsNarH.cjs.map +1 -0
- package/dist/_chunks/{initAction-bz-ok0LO.cjs → initAction-dKWPRJL7.cjs} +2 -2
- package/dist/_chunks/{initAction-bz-ok0LO.cjs.map → initAction-dKWPRJL7.cjs.map} +1 -1
- package/dist/_chunks/{watch-4Yq69TUG.cjs → watch-8dkaWImB.cjs} +3 -3
- package/dist/_chunks/{watch-4Yq69TUG.cjs.map → watch-8dkaWImB.cjs.map} +1 -1
- package/dist/_chunks/{watchAction-HseKdhoO.cjs → watchAction-MPezXdut.cjs} +2 -2
- package/dist/_chunks/{watchAction-HseKdhoO.cjs.map → watchAction-MPezXdut.cjs.map} +1 -1
- package/dist/cli.cjs +5 -5
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +20 -55
- package/src/node/core/pkg/types.ts +4 -4
- package/src/node/core/ts/loadTSConfig.ts +2 -2
- package/src/node/resolveBuildContext.ts +2 -2
- package/src/node/tasks/dts/getExtractMessagesConfig.ts +2 -2
- package/src/node/templates/default/template.ts +139 -92
- package/dist/_chunks/consoleSpy--ReK-_gE.cjs.map +0 -1
- package/dist/_chunks/init-gkPbG69g.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -46,24 +46,6 @@
|
|
|
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
|
-
},
|
|
67
49
|
"commitlint": {
|
|
68
50
|
"extends": [
|
|
69
51
|
"@commitlint/config-conventional"
|
|
@@ -75,35 +57,6 @@
|
|
|
75
57
|
"eslint --ext .cjs,.js,.ts,.tsx --fix"
|
|
76
58
|
]
|
|
77
59
|
},
|
|
78
|
-
"prettier": {
|
|
79
|
-
"bracketSpacing": false,
|
|
80
|
-
"plugins": [
|
|
81
|
-
"prettier-plugin-packagejson"
|
|
82
|
-
],
|
|
83
|
-
"printWidth": 100,
|
|
84
|
-
"semi": false,
|
|
85
|
-
"singleQuote": true,
|
|
86
|
-
"tabWidth": 2,
|
|
87
|
-
"overrides": [
|
|
88
|
-
{
|
|
89
|
-
"files": [
|
|
90
|
-
"*.json5"
|
|
91
|
-
],
|
|
92
|
-
"options": {
|
|
93
|
-
"quoteProps": "preserve",
|
|
94
|
-
"singleQuote": false
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"files": [
|
|
99
|
-
"*.yml"
|
|
100
|
-
],
|
|
101
|
-
"options": {
|
|
102
|
-
"singleQuote": false
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
60
|
"dependencies": {
|
|
108
61
|
"@babel/core": "^7.23.2",
|
|
109
62
|
"@babel/preset-env": "^7.23.2",
|
|
@@ -147,7 +100,6 @@
|
|
|
147
100
|
"devDependencies": {
|
|
148
101
|
"@commitlint/cli": "^18.0.0",
|
|
149
102
|
"@commitlint/config-conventional": "^18.0.0",
|
|
150
|
-
"@sanity/pkg-utils": "workspace:*",
|
|
151
103
|
"@types/babel__core": "^7.20.3",
|
|
152
104
|
"@types/cpx": "^1.5.4",
|
|
153
105
|
"@types/find-config": "^1.0.3",
|
|
@@ -177,7 +129,8 @@
|
|
|
177
129
|
"ts-node": "^10.9.1",
|
|
178
130
|
"typescript": "^5.2.2",
|
|
179
131
|
"vitest": "^0.34.6",
|
|
180
|
-
"vitest-github-actions-reporter": "^0.10.0"
|
|
132
|
+
"vitest-github-actions-reporter": "^0.10.0",
|
|
133
|
+
"@sanity/pkg-utils": "3.2.1"
|
|
181
134
|
},
|
|
182
135
|
"peerDependencies": {
|
|
183
136
|
"typescript": "^4.7 || ^5"
|
|
@@ -189,9 +142,21 @@
|
|
|
189
142
|
"publishConfig": {
|
|
190
143
|
"access": "public"
|
|
191
144
|
},
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
|
|
195
|
-
|
|
145
|
+
"scripts": {
|
|
146
|
+
"build": "run-s clean build:pkg check:pkg",
|
|
147
|
+
"build:pkg": "node -r esbuild-register scripts/build",
|
|
148
|
+
"check:pkg": "node -r esbuild-register scripts/check",
|
|
149
|
+
"check:types": "tsc --build",
|
|
150
|
+
"clean": "rimraf dist test/env/__tmp__",
|
|
151
|
+
"commit": "cz",
|
|
152
|
+
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
153
|
+
"format": "prettier --write --cache --ignore-unknown . && eslint . --ext .cjs,.js,.ts,.tsx --fix --quiet",
|
|
154
|
+
"lint": "eslint . --ext .cjs,.js,.ts,.tsx",
|
|
155
|
+
"playground:build": "pnpm --filter './playground/**' build",
|
|
156
|
+
"playground:clean": "pnpm --filter './playground/**' --silent clean",
|
|
157
|
+
"test": "run-s playground:clean test:clean vitest:run",
|
|
158
|
+
"test:clean": "rimraf test/env/__tmp__",
|
|
159
|
+
"vitest:run": "vitest run",
|
|
160
|
+
"watch": "node -r esbuild-register scripts/watch"
|
|
196
161
|
}
|
|
197
|
-
}
|
|
162
|
+
}
|
|
@@ -8,9 +8,9 @@ export interface PackageJSON {
|
|
|
8
8
|
description?: string
|
|
9
9
|
keywords?: string[]
|
|
10
10
|
bin?: Record<string, string>
|
|
11
|
-
dependencies?: Record<string, string>
|
|
12
|
-
devDependencies?: Record<string, string>
|
|
13
|
-
peerDependencies?: Record<string, string>
|
|
11
|
+
dependencies?: Record<string, string | undefined>
|
|
12
|
+
devDependencies?: Record<string, string | undefined>
|
|
13
|
+
peerDependencies?: Record<string, string | undefined>
|
|
14
14
|
exports?: Record<
|
|
15
15
|
string,
|
|
16
16
|
| `./${string}.json`
|
|
@@ -40,7 +40,7 @@ export interface PackageJSON {
|
|
|
40
40
|
module?: string
|
|
41
41
|
types?: string
|
|
42
42
|
files?: string[]
|
|
43
|
-
scripts?: Record<string, string>
|
|
43
|
+
scripts?: Record<string, string | undefined>
|
|
44
44
|
browserslist?: string[]
|
|
45
45
|
engines?: {
|
|
46
46
|
node?: string
|
|
@@ -4,13 +4,13 @@ import ts from 'typescript'
|
|
|
4
4
|
export async function loadTSConfig(options: {
|
|
5
5
|
cwd: string
|
|
6
6
|
tsconfigPath: string
|
|
7
|
-
}): Promise<ts.ParsedCommandLine> {
|
|
7
|
+
}): Promise<ts.ParsedCommandLine | undefined> {
|
|
8
8
|
const {cwd, tsconfigPath} = options
|
|
9
9
|
|
|
10
10
|
const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, tsconfigPath)
|
|
11
11
|
|
|
12
12
|
if (!configPath) {
|
|
13
|
-
|
|
13
|
+
return undefined
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const configFile = ts.readConfigFile(configPath, ts.sys.readFile)
|
|
@@ -53,8 +53,8 @@ export async function resolveBuildContext(options: {
|
|
|
53
53
|
|
|
54
54
|
const target: Record<PkgRuntime, string[]> = {
|
|
55
55
|
'*': webTarget.concat(nodeTarget),
|
|
56
|
-
browser: webTarget,
|
|
57
|
-
node: nodeTarget,
|
|
56
|
+
'browser': webTarget,
|
|
57
|
+
'node': nodeTarget,
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const parsedExports = parseExports({extMap, pkg, strict}).reduce<PkgExports>((acc, x) => {
|
|
@@ -32,7 +32,7 @@ export function getExtractMessagesConfig(options: {
|
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
extractorMessageReporting: {
|
|
35
|
-
default: {
|
|
35
|
+
'default': {
|
|
36
36
|
logLevel: 'warning' as ExtractorLogLevel,
|
|
37
37
|
addToApiReportFile: false,
|
|
38
38
|
},
|
|
@@ -64,7 +64,7 @@ export function getExtractMessagesConfig(options: {
|
|
|
64
64
|
},
|
|
65
65
|
|
|
66
66
|
tsdocMessageReporting: {
|
|
67
|
-
default: {
|
|
67
|
+
'default': {
|
|
68
68
|
logLevel: 'warning' as ExtractorLogLevel,
|
|
69
69
|
addToApiReportFile: false,
|
|
70
70
|
},
|
|
@@ -105,6 +105,11 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
105
105
|
optional: true,
|
|
106
106
|
initial: true,
|
|
107
107
|
},
|
|
108
|
+
{
|
|
109
|
+
name: 'prettier',
|
|
110
|
+
optional: true,
|
|
111
|
+
initial: true,
|
|
112
|
+
},
|
|
108
113
|
{
|
|
109
114
|
name: 'typescript',
|
|
110
115
|
optional: true,
|
|
@@ -121,69 +126,86 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
121
126
|
.filter(Boolean)
|
|
122
127
|
.join(' ') ?? undefined
|
|
123
128
|
|
|
124
|
-
const prettierConfig: PrettierConfig =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
const prettierConfig: PrettierConfig | undefined = features.prettier
|
|
130
|
+
? {
|
|
131
|
+
bracketSpacing: false,
|
|
132
|
+
plugins: ['prettier-plugin-packagejson'],
|
|
133
|
+
printWidth: 100,
|
|
134
|
+
quoteProps: 'consistent',
|
|
135
|
+
semi: false,
|
|
136
|
+
singleQuote: true,
|
|
137
|
+
tabWidth: 2,
|
|
138
|
+
overrides: [
|
|
139
|
+
{
|
|
140
|
+
files: ['*.yml'],
|
|
141
|
+
options: {
|
|
142
|
+
singleQuote: false,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
}
|
|
147
|
+
: undefined
|
|
140
148
|
|
|
141
149
|
const pkgJson: PackageJSON & {
|
|
142
150
|
prettier?: PrettierConfig
|
|
143
151
|
['lint-staged']?: Record<string, string[]>
|
|
144
152
|
} = {
|
|
145
153
|
name,
|
|
146
|
-
version: '0.0.0',
|
|
147
|
-
description: options.description ?? undefined,
|
|
148
|
-
keywords: [],
|
|
149
|
-
|
|
154
|
+
'version': '0.0.0',
|
|
155
|
+
'description': options.description ?? undefined,
|
|
156
|
+
'keywords': [],
|
|
157
|
+
'homepage': undefined,
|
|
158
|
+
'bugs': undefined,
|
|
159
|
+
'repository': undefined,
|
|
160
|
+
'license': options.license,
|
|
150
161
|
author,
|
|
151
|
-
type: 'module',
|
|
152
|
-
exports: {
|
|
162
|
+
'type': 'module',
|
|
163
|
+
'exports': {
|
|
153
164
|
'.': {
|
|
154
165
|
types: undefined,
|
|
155
166
|
source: features.typescript ? './src/index.ts' : './src/index.js',
|
|
156
|
-
require: './dist/index.cjs',
|
|
157
167
|
import: './dist/index.js',
|
|
168
|
+
require: './dist/index.cjs',
|
|
158
169
|
default: './dist/index.js',
|
|
159
170
|
},
|
|
160
171
|
'./package.json': './package.json',
|
|
161
172
|
},
|
|
162
|
-
main: './dist/index.cjs',
|
|
163
|
-
module: './dist/index.js',
|
|
164
|
-
source: features.typescript ? './src/index.ts' : './src/index.js',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
'main': './dist/index.cjs',
|
|
174
|
+
'module': './dist/index.js',
|
|
175
|
+
'source': features.typescript ? './src/index.ts' : './src/index.js',
|
|
176
|
+
'types': undefined,
|
|
177
|
+
'files': ['dist', 'src'],
|
|
178
|
+
'scripts': {
|
|
179
|
+
'build': 'run-s clean pkg:build pkg:check',
|
|
180
|
+
'clean': 'rimraf dist',
|
|
181
|
+
'format': features.prettier ? 'prettier --write --cache --ignore-unknown .' : undefined,
|
|
170
182
|
'pkg:build': 'pkg build --strict',
|
|
171
183
|
'pkg:check': 'pkg check --strict',
|
|
172
184
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
'lint-staged': features.prettier
|
|
186
|
+
? {
|
|
187
|
+
'*': ['prettier --write --cache --ignore-unknown'],
|
|
188
|
+
}
|
|
189
|
+
: undefined,
|
|
190
|
+
// prettier: prettierConfig,
|
|
191
|
+
'dependencies': {},
|
|
192
|
+
'devDependencies': {
|
|
179
193
|
'@sanity/pkg-utils': '*',
|
|
194
|
+
'@typescript-eslint/eslint-plugin': undefined,
|
|
195
|
+
'@typescript-eslint/parser': undefined,
|
|
196
|
+
'eslint': undefined,
|
|
197
|
+
'eslint-config-prettier': undefined,
|
|
198
|
+
'eslint-plugin-import': undefined,
|
|
199
|
+
'eslint-plugin-prettier': undefined,
|
|
200
|
+
'eslint-plugin-simple-import-sort': undefined,
|
|
180
201
|
'lint-staged': '*',
|
|
181
202
|
'npm-run-all': '*',
|
|
182
|
-
prettier: '*',
|
|
183
|
-
'prettier-plugin-packagejson': '*',
|
|
184
|
-
rimraf: '*',
|
|
203
|
+
'prettier': features.prettier ? '*' : undefined,
|
|
204
|
+
'prettier-plugin-packagejson': features.prettier ? '*' : undefined,
|
|
205
|
+
'rimraf': '*',
|
|
206
|
+
'typescript': undefined,
|
|
185
207
|
},
|
|
186
|
-
engines: {
|
|
208
|
+
'engines': {
|
|
187
209
|
node: '>=18.0.0',
|
|
188
210
|
},
|
|
189
211
|
}
|
|
@@ -212,21 +234,33 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
212
234
|
contents: outdent`
|
|
213
235
|
*.local
|
|
214
236
|
*.log
|
|
237
|
+
*.tgz
|
|
215
238
|
|
|
216
239
|
.DS_Store
|
|
217
|
-
etc
|
|
218
240
|
dist
|
|
241
|
+
etc
|
|
219
242
|
node_modules
|
|
220
243
|
`,
|
|
221
244
|
})
|
|
222
245
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
246
|
+
if (features.prettier) {
|
|
247
|
+
files.push({
|
|
248
|
+
name: '.prettierignore',
|
|
249
|
+
contents: outdent`
|
|
250
|
+
dist
|
|
251
|
+
pnpm-lock.yaml
|
|
252
|
+
`,
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
files.push({
|
|
256
|
+
name: '.prettierrc',
|
|
257
|
+
contents: await format(
|
|
258
|
+
resolve(packagePath, '.prettierrc.json'),
|
|
259
|
+
JSON.stringify(prettierConfig, null, 2) + '\n',
|
|
260
|
+
prettierConfig,
|
|
261
|
+
),
|
|
262
|
+
})
|
|
263
|
+
}
|
|
230
264
|
|
|
231
265
|
if (repo) {
|
|
232
266
|
pkgJson.repository = {
|
|
@@ -250,7 +284,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
250
284
|
|
|
251
285
|
pkgJson.scripts = {
|
|
252
286
|
...pkgJson.scripts,
|
|
253
|
-
['
|
|
287
|
+
['ts:check']: 'tsc --build',
|
|
254
288
|
}
|
|
255
289
|
|
|
256
290
|
const devDependencies = pkgJson.devDependencies
|
|
@@ -269,23 +303,32 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
269
303
|
es6: true,
|
|
270
304
|
node: true,
|
|
271
305
|
},
|
|
272
|
-
extends: [
|
|
306
|
+
extends: [
|
|
307
|
+
'eslint:recommended',
|
|
308
|
+
features.prettier ? 'plugin:prettier/recommended' : undefined,
|
|
309
|
+
].filter(Boolean),
|
|
273
310
|
parserOptions: {
|
|
274
311
|
ecmaVersion: 2020,
|
|
275
312
|
sourceType: 'module',
|
|
276
313
|
},
|
|
277
|
-
plugins: [
|
|
314
|
+
plugins: [
|
|
315
|
+
'import',
|
|
316
|
+
'simple-import-sort',
|
|
317
|
+
features.prettier ? 'prettier' : undefined,
|
|
318
|
+
].filter(Boolean),
|
|
278
319
|
rules: {
|
|
279
320
|
'no-console': 'error',
|
|
280
321
|
'no-shadow': 'error',
|
|
281
322
|
'no-warning-comments': ['warn', {location: 'start', terms: ['todo', 'fixme']}],
|
|
323
|
+
'quote-props': ['warn', 'consistent-as-needed'],
|
|
324
|
+
'strict': ['warn', 'global'],
|
|
282
325
|
},
|
|
283
326
|
}
|
|
284
327
|
|
|
285
328
|
files.push({
|
|
286
329
|
name: '.eslintignore',
|
|
287
330
|
contents: outdent`
|
|
288
|
-
|
|
331
|
+
dist
|
|
289
332
|
`,
|
|
290
333
|
})
|
|
291
334
|
|
|
@@ -298,10 +341,11 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
298
341
|
|
|
299
342
|
pkgJson.devDependencies = {
|
|
300
343
|
...pkgJson.devDependencies,
|
|
301
|
-
eslint: '*',
|
|
302
|
-
'eslint-config-prettier': '*',
|
|
344
|
+
'eslint': '*',
|
|
345
|
+
'eslint-config-prettier': features.prettier ? '*' : undefined,
|
|
346
|
+
'eslint-plugin-simple-import-sort': '*',
|
|
303
347
|
'eslint-plugin-import': '*',
|
|
304
|
-
'eslint-plugin-prettier': '*',
|
|
348
|
+
'eslint-plugin-prettier': features.prettier ? '*' : undefined,
|
|
305
349
|
}
|
|
306
350
|
|
|
307
351
|
if (features.typescript) {
|
|
@@ -320,11 +364,16 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
320
364
|
},
|
|
321
365
|
extends: [
|
|
322
366
|
'eslint:recommended',
|
|
323
|
-
'plugin:prettier/recommended',
|
|
367
|
+
features.prettier ? 'plugin:prettier/recommended' : undefined,
|
|
324
368
|
'plugin:@typescript-eslint/eslint-recommended',
|
|
325
369
|
'plugin:@typescript-eslint/recommended',
|
|
326
370
|
].filter(Boolean),
|
|
327
|
-
plugins: [
|
|
371
|
+
plugins: [
|
|
372
|
+
'import',
|
|
373
|
+
'@typescript-eslint',
|
|
374
|
+
'simple-import-sort',
|
|
375
|
+
features.prettier ? 'prettier' : undefined,
|
|
376
|
+
].filter(Boolean),
|
|
328
377
|
rules: {
|
|
329
378
|
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
330
379
|
'@typescript-eslint/interface-name-prefix': 'off',
|
|
@@ -359,32 +408,32 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
359
408
|
outdent`
|
|
360
409
|
{
|
|
361
410
|
"compilerOptions": {
|
|
362
|
-
|
|
411
|
+
// Completeness
|
|
412
|
+
"skipLibCheck": true,
|
|
413
|
+
|
|
414
|
+
// Interop constraints
|
|
415
|
+
"allowSyntheticDefaultImports": true,
|
|
416
|
+
"esModuleInterop": true,
|
|
417
|
+
|
|
418
|
+
// Language and environment
|
|
363
419
|
"target": "ES2020",
|
|
364
|
-
"declaration": true,
|
|
365
|
-
"declarationMap": true,
|
|
366
|
-
"sourceMap": true,
|
|
367
420
|
|
|
368
|
-
//
|
|
369
|
-
"
|
|
421
|
+
// Modules
|
|
422
|
+
"module": "ES2020",
|
|
423
|
+
"moduleResolution": "Node",
|
|
424
|
+
|
|
425
|
+
// Type checking
|
|
426
|
+
"alwaysStrict": true,
|
|
427
|
+
"noFallthroughCasesInSwitch": true,
|
|
370
428
|
"noImplicitAny": true,
|
|
371
|
-
"
|
|
372
|
-
"strictFunctionTypes": true,
|
|
373
|
-
"strictPropertyInitialization": true,
|
|
429
|
+
"noImplicitReturns": true,
|
|
374
430
|
"noImplicitThis": true,
|
|
375
|
-
"alwaysStrict": true,
|
|
376
|
-
|
|
377
|
-
// Additional checks
|
|
378
431
|
"noUnusedLocals": true,
|
|
379
432
|
"noUnusedParameters": true,
|
|
380
|
-
"
|
|
381
|
-
"
|
|
382
|
-
"
|
|
383
|
-
|
|
384
|
-
// Module resolution
|
|
385
|
-
"moduleResolution": "node",
|
|
386
|
-
"allowSyntheticDefaultImports": true,
|
|
387
|
-
"esModuleInterop": true
|
|
433
|
+
"strict": true,
|
|
434
|
+
"strictFunctionTypes": true,
|
|
435
|
+
"strictNullChecks": true,
|
|
436
|
+
"strictPropertyInitialization": true
|
|
388
437
|
}
|
|
389
438
|
}
|
|
390
439
|
`,
|
|
@@ -400,10 +449,10 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
400
449
|
{
|
|
401
450
|
"extends": "./tsconfig.settings",
|
|
402
451
|
"include": ["./src"],
|
|
452
|
+
"exclude": ["./src/**/*.test.ts"],
|
|
403
453
|
"compilerOptions": {
|
|
404
454
|
"rootDir": ".",
|
|
405
455
|
"outDir": "./dist",
|
|
406
|
-
"emitDeclarationOnly": true,
|
|
407
456
|
"resolveJsonModule": true
|
|
408
457
|
}
|
|
409
458
|
}
|
|
@@ -419,7 +468,8 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
419
468
|
outdent`
|
|
420
469
|
{
|
|
421
470
|
"extends": "./tsconfig.settings",
|
|
422
|
-
"include": ["
|
|
471
|
+
"include": ["./**/*.cjs", "./**/*.ts", "./**/*.tsx"],
|
|
472
|
+
"exclude": ["./node_modules"],
|
|
423
473
|
"compilerOptions": {
|
|
424
474
|
"rootDir": ".",
|
|
425
475
|
"outDir": "./dist",
|
|
@@ -443,14 +493,8 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
443
493
|
outdent`
|
|
444
494
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
445
495
|
|
|
496
|
+
// https://github.com/sanity-io/pkg-utils#configuration
|
|
446
497
|
export default defineConfig({
|
|
447
|
-
extract: {
|
|
448
|
-
rules: {
|
|
449
|
-
// do not require internal members to be prefixed with \`_\`
|
|
450
|
-
'ae-internal-missing-underscore': 'off',
|
|
451
|
-
},
|
|
452
|
-
},
|
|
453
|
-
|
|
454
498
|
// the path to the tsconfig file for distributed builds
|
|
455
499
|
tsconfig: 'tsconfig.dist.json',
|
|
456
500
|
})
|
|
@@ -536,19 +580,22 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
536
580
|
}
|
|
537
581
|
}
|
|
538
582
|
|
|
539
|
-
function format(filepath: string, input: string, prettierOptions: PrettierConfig) {
|
|
540
|
-
return prettier.format(input, {...prettierOptions, filepath})
|
|
583
|
+
function format(filepath: string, input: string, prettierOptions: PrettierConfig | undefined) {
|
|
584
|
+
return prettier.format(input, {...prettierOptions, plugins: [], filepath})
|
|
541
585
|
}
|
|
542
586
|
|
|
543
|
-
async function resolveLatestDeps(deps: Record<string, string>) {
|
|
587
|
+
async function resolveLatestDeps(deps: Record<string, string | undefined>) {
|
|
544
588
|
const depsEntries = Object.entries(deps)
|
|
545
589
|
const latestDeps: Record<string, string> = {}
|
|
546
590
|
|
|
547
591
|
for (const entry of depsEntries) {
|
|
548
592
|
const [name, version] = entry
|
|
549
|
-
const latestVersion = await getLatestVersion(name, version)
|
|
550
593
|
|
|
551
|
-
|
|
594
|
+
if (version) {
|
|
595
|
+
const latestVersion = await getLatestVersion(name, version)
|
|
596
|
+
|
|
597
|
+
latestDeps[name] = latestVersion ? `^${latestVersion}` : version
|
|
598
|
+
}
|
|
552
599
|
}
|
|
553
600
|
|
|
554
601
|
return latestDeps
|