@sanity/pkg-utils 3.2.0 → 3.2.2
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-JUK_GqHH.cjs} +80 -49
- package/dist/_chunks/init-JUK_GqHH.cjs.map +1 -0
- package/dist/_chunks/{initAction-bz-ok0LO.cjs → initAction-Xi2rF6yS.cjs} +2 -2
- package/dist/_chunks/{initAction-bz-ok0LO.cjs.map → initAction-Xi2rF6yS.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 +27 -62
- 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 +141 -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.2",
|
|
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",
|
|
@@ -115,7 +68,7 @@
|
|
|
115
68
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
116
69
|
"@rollup/plugin-json": "^6.0.1",
|
|
117
70
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
118
|
-
"@rollup/plugin-replace": "^5.0.
|
|
71
|
+
"@rollup/plugin-replace": "^5.0.5",
|
|
119
72
|
"@rollup/plugin-terser": "^0.4.4",
|
|
120
73
|
"browserslist": "^4.22.1",
|
|
121
74
|
"cac": "^6.7.14",
|
|
@@ -137,7 +90,7 @@
|
|
|
137
90
|
"pretty-bytes": "^5.6.0",
|
|
138
91
|
"prompts": "^2.4.2",
|
|
139
92
|
"rimraf": "^4.4.1",
|
|
140
|
-
"rollup": "^4.1.
|
|
93
|
+
"rollup": "^4.1.5",
|
|
141
94
|
"rollup-plugin-esbuild": "^6.1.0",
|
|
142
95
|
"rxjs": "^7.8.1",
|
|
143
96
|
"treeify": "^1.1.0",
|
|
@@ -145,9 +98,8 @@
|
|
|
145
98
|
"zod": "^3.22.4"
|
|
146
99
|
},
|
|
147
100
|
"devDependencies": {
|
|
148
|
-
"@commitlint/cli": "^18.
|
|
149
|
-
"@commitlint/config-conventional": "^18.
|
|
150
|
-
"@sanity/pkg-utils": "workspace:*",
|
|
101
|
+
"@commitlint/cli": "^18.2.0",
|
|
102
|
+
"@commitlint/config-conventional": "^18.1.0",
|
|
151
103
|
"@types/babel__core": "^7.20.3",
|
|
152
104
|
"@types/cpx": "^1.5.4",
|
|
153
105
|
"@types/find-config": "^1.0.3",
|
|
@@ -158,8 +110,8 @@
|
|
|
158
110
|
"@types/rimraf": "^3.0.2",
|
|
159
111
|
"@types/treeify": "^1.0.2",
|
|
160
112
|
"@types/uuid": "^9.0.6",
|
|
161
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
162
|
-
"@typescript-eslint/parser": "^6.
|
|
113
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
114
|
+
"@typescript-eslint/parser": "^6.9.0",
|
|
163
115
|
"commitizen": "^4.3.0",
|
|
164
116
|
"cpx": "^1.5.0",
|
|
165
117
|
"cz-conventional-changelog": "^3.3.0",
|
|
@@ -177,21 +129,34 @@
|
|
|
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.2"
|
|
181
134
|
},
|
|
182
135
|
"peerDependencies": {
|
|
183
136
|
"typescript": "^4.7 || ^5"
|
|
184
137
|
},
|
|
185
|
-
"packageManager": "pnpm@8.
|
|
138
|
+
"packageManager": "pnpm@8.10.0",
|
|
186
139
|
"engines": {
|
|
187
140
|
"node": ">=16.0.0"
|
|
188
141
|
},
|
|
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,34 @@ 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
|
+
'simple-import-sort/exports': 'warn',
|
|
325
|
+
'simple-import-sort/imports': 'warn',
|
|
326
|
+
'strict': ['warn', 'global'],
|
|
282
327
|
},
|
|
283
328
|
}
|
|
284
329
|
|
|
285
330
|
files.push({
|
|
286
331
|
name: '.eslintignore',
|
|
287
332
|
contents: outdent`
|
|
288
|
-
|
|
333
|
+
dist
|
|
289
334
|
`,
|
|
290
335
|
})
|
|
291
336
|
|
|
@@ -298,10 +343,11 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
298
343
|
|
|
299
344
|
pkgJson.devDependencies = {
|
|
300
345
|
...pkgJson.devDependencies,
|
|
301
|
-
eslint: '*',
|
|
302
|
-
'eslint-config-prettier': '*',
|
|
346
|
+
'eslint': '*',
|
|
347
|
+
'eslint-config-prettier': features.prettier ? '*' : undefined,
|
|
348
|
+
'eslint-plugin-simple-import-sort': '*',
|
|
303
349
|
'eslint-plugin-import': '*',
|
|
304
|
-
'eslint-plugin-prettier': '*',
|
|
350
|
+
'eslint-plugin-prettier': features.prettier ? '*' : undefined,
|
|
305
351
|
}
|
|
306
352
|
|
|
307
353
|
if (features.typescript) {
|
|
@@ -320,11 +366,16 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
320
366
|
},
|
|
321
367
|
extends: [
|
|
322
368
|
'eslint:recommended',
|
|
323
|
-
'plugin:prettier/recommended',
|
|
369
|
+
features.prettier ? 'plugin:prettier/recommended' : undefined,
|
|
324
370
|
'plugin:@typescript-eslint/eslint-recommended',
|
|
325
371
|
'plugin:@typescript-eslint/recommended',
|
|
326
372
|
].filter(Boolean),
|
|
327
|
-
plugins: [
|
|
373
|
+
plugins: [
|
|
374
|
+
'import',
|
|
375
|
+
'@typescript-eslint',
|
|
376
|
+
'simple-import-sort',
|
|
377
|
+
features.prettier ? 'prettier' : undefined,
|
|
378
|
+
].filter(Boolean),
|
|
328
379
|
rules: {
|
|
329
380
|
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
330
381
|
'@typescript-eslint/interface-name-prefix': 'off',
|
|
@@ -359,32 +410,32 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
359
410
|
outdent`
|
|
360
411
|
{
|
|
361
412
|
"compilerOptions": {
|
|
362
|
-
|
|
413
|
+
// Completeness
|
|
414
|
+
"skipLibCheck": true,
|
|
415
|
+
|
|
416
|
+
// Interop constraints
|
|
417
|
+
"allowSyntheticDefaultImports": true,
|
|
418
|
+
"esModuleInterop": true,
|
|
419
|
+
|
|
420
|
+
// Language and environment
|
|
363
421
|
"target": "ES2020",
|
|
364
|
-
"declaration": true,
|
|
365
|
-
"declarationMap": true,
|
|
366
|
-
"sourceMap": true,
|
|
367
422
|
|
|
368
|
-
//
|
|
369
|
-
"
|
|
423
|
+
// Modules
|
|
424
|
+
"module": "ES2020",
|
|
425
|
+
"moduleResolution": "Node",
|
|
426
|
+
|
|
427
|
+
// Type checking
|
|
428
|
+
"alwaysStrict": true,
|
|
429
|
+
"noFallthroughCasesInSwitch": true,
|
|
370
430
|
"noImplicitAny": true,
|
|
371
|
-
"
|
|
372
|
-
"strictFunctionTypes": true,
|
|
373
|
-
"strictPropertyInitialization": true,
|
|
431
|
+
"noImplicitReturns": true,
|
|
374
432
|
"noImplicitThis": true,
|
|
375
|
-
"alwaysStrict": true,
|
|
376
|
-
|
|
377
|
-
// Additional checks
|
|
378
433
|
"noUnusedLocals": true,
|
|
379
434
|
"noUnusedParameters": true,
|
|
380
|
-
"
|
|
381
|
-
"
|
|
382
|
-
"
|
|
383
|
-
|
|
384
|
-
// Module resolution
|
|
385
|
-
"moduleResolution": "node",
|
|
386
|
-
"allowSyntheticDefaultImports": true,
|
|
387
|
-
"esModuleInterop": true
|
|
435
|
+
"strict": true,
|
|
436
|
+
"strictFunctionTypes": true,
|
|
437
|
+
"strictNullChecks": true,
|
|
438
|
+
"strictPropertyInitialization": true
|
|
388
439
|
}
|
|
389
440
|
}
|
|
390
441
|
`,
|
|
@@ -400,10 +451,10 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
400
451
|
{
|
|
401
452
|
"extends": "./tsconfig.settings",
|
|
402
453
|
"include": ["./src"],
|
|
454
|
+
"exclude": ["./src/**/*.test.ts"],
|
|
403
455
|
"compilerOptions": {
|
|
404
456
|
"rootDir": ".",
|
|
405
457
|
"outDir": "./dist",
|
|
406
|
-
"emitDeclarationOnly": true,
|
|
407
458
|
"resolveJsonModule": true
|
|
408
459
|
}
|
|
409
460
|
}
|
|
@@ -419,7 +470,8 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
419
470
|
outdent`
|
|
420
471
|
{
|
|
421
472
|
"extends": "./tsconfig.settings",
|
|
422
|
-
"include": ["
|
|
473
|
+
"include": ["./**/*.cjs", "./**/*.ts", "./**/*.tsx"],
|
|
474
|
+
"exclude": ["./node_modules"],
|
|
423
475
|
"compilerOptions": {
|
|
424
476
|
"rootDir": ".",
|
|
425
477
|
"outDir": "./dist",
|
|
@@ -443,14 +495,8 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
443
495
|
outdent`
|
|
444
496
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
445
497
|
|
|
498
|
+
// https://github.com/sanity-io/pkg-utils#configuration
|
|
446
499
|
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
500
|
// the path to the tsconfig file for distributed builds
|
|
455
501
|
tsconfig: 'tsconfig.dist.json',
|
|
456
502
|
})
|
|
@@ -536,19 +582,22 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
536
582
|
}
|
|
537
583
|
}
|
|
538
584
|
|
|
539
|
-
function format(filepath: string, input: string, prettierOptions: PrettierConfig) {
|
|
540
|
-
return prettier.format(input, {...prettierOptions, filepath})
|
|
585
|
+
function format(filepath: string, input: string, prettierOptions: PrettierConfig | undefined) {
|
|
586
|
+
return prettier.format(input, {...prettierOptions, plugins: [], filepath})
|
|
541
587
|
}
|
|
542
588
|
|
|
543
|
-
async function resolveLatestDeps(deps: Record<string, string>) {
|
|
589
|
+
async function resolveLatestDeps(deps: Record<string, string | undefined>) {
|
|
544
590
|
const depsEntries = Object.entries(deps)
|
|
545
591
|
const latestDeps: Record<string, string> = {}
|
|
546
592
|
|
|
547
593
|
for (const entry of depsEntries) {
|
|
548
594
|
const [name, version] = entry
|
|
549
|
-
const latestVersion = await getLatestVersion(name, version)
|
|
550
595
|
|
|
551
|
-
|
|
596
|
+
if (version) {
|
|
597
|
+
const latestVersion = await getLatestVersion(name, version)
|
|
598
|
+
|
|
599
|
+
latestDeps[name] = latestVersion ? `^${latestVersion}` : version
|
|
600
|
+
}
|
|
552
601
|
}
|
|
553
602
|
|
|
554
603
|
return latestDeps
|