@sanity/pkg-utils 2.3.4 → 2.3.6
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-61901816.cjs → build-010eef33.cjs} +2 -2
- package/dist/_chunks/build-010eef33.cjs.map +1 -0
- package/dist/_chunks/{buildAction-2e2ae058.cjs → buildAction-82c8ffda.cjs} +2 -2
- package/dist/_chunks/{buildAction-2e2ae058.cjs.map → buildAction-82c8ffda.cjs.map} +1 -1
- package/dist/_chunks/check-0665cb35.cjs.map +1 -1
- package/dist/_chunks/consoleSpy-d738cb9f.cjs.map +1 -1
- package/dist/_chunks/{index-07125387.cjs → index-04fb159f.cjs} +2 -2
- package/dist/_chunks/index-04fb159f.cjs.map +1 -0
- package/dist/_chunks/{init-ab36343b.cjs → init-2377e6e5.cjs} +10 -10
- package/dist/_chunks/init-2377e6e5.cjs.map +1 -0
- package/dist/_chunks/{initAction-d18cf4f2.cjs → initAction-2abd8576.cjs} +2 -2
- package/dist/_chunks/{initAction-d18cf4f2.cjs.map → initAction-2abd8576.cjs.map} +1 -1
- package/dist/_chunks/logger-c593f06b.cjs.map +1 -1
- package/dist/_chunks/{watch-8c2aec77.cjs → watch-fdd55720.cjs} +2 -2
- package/dist/_chunks/watch-fdd55720.cjs.map +1 -0
- package/dist/_chunks/{watchAction-994967c6.cjs → watchAction-52b8ded3.cjs} +2 -2
- package/dist/_chunks/{watchAction-994967c6.cjs.map → watchAction-52b8ded3.cjs.map} +1 -1
- package/dist/cli.cjs +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/src/node/check.ts +2 -2
- package/src/node/core/config/resolveConfigProperty.ts +1 -1
- package/src/node/core/pkg/loadPkgWithReporting.ts +4 -4
- package/src/node/core/pkg/parseExports.ts +4 -4
- package/src/node/core/pkg/validateExports.ts +3 -3
- package/src/node/core/pkg/validatePkg.ts +4 -4
- package/src/node/core/template/createFromTemplate.ts +2 -2
- package/src/node/core/template/types.ts +1 -1
- package/src/node/printExtractMessages.ts +2 -2
- package/src/node/printPackageTree.ts +2 -2
- package/src/node/resolveBuildContext.ts +1 -1
- package/src/node/resolveBuildTasks.ts +4 -4
- package/src/node/resolveWatchTasks.ts +4 -4
- package/src/node/tasks/dts/createTSDocConfig.ts +2 -2
- package/src/node/tasks/dts/doExtract.ts +2 -2
- package/src/node/tasks/dts/dtsTask.ts +1 -1
- package/src/node/tasks/dts/dtsWatchTask.ts +1 -1
- package/src/node/tasks/dts/extractTypes.ts +2 -2
- package/src/node/tasks/dts/getExtractMessagesConfig.ts +1 -1
- package/src/node/tasks/node/reexportCjsTask.ts +1 -1
- package/src/node/tasks/rollup/resolveRollupConfig.ts +6 -6
- package/src/node/tasks/rollup/rollupTask.ts +2 -2
- package/src/node/tasks/rollup/rollupWatchTask.ts +1 -1
- package/src/node/templates/default/template.ts +18 -18
- package/src/node/watch.ts +1 -1
- package/src/node/watchConfigFiles.ts +2 -2
- package/src/node/watchFiles.ts +1 -1
- package/dist/_chunks/build-61901816.cjs.map +0 -1
- package/dist/_chunks/index-07125387.cjs.map +0 -1
- package/dist/_chunks/init-ab36343b.cjs.map +0 -1
- package/dist/_chunks/watch-8c2aec77.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.6",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"outdent": "^0.8.0",
|
|
148
148
|
"parse-git-config": "^3.0.0",
|
|
149
149
|
"pkg-up": "^3.1.0",
|
|
150
|
-
"prettier": "^
|
|
150
|
+
"prettier": "^3.0.0",
|
|
151
151
|
"prettier-plugin-packagejson": "^2.4.3",
|
|
152
152
|
"pretty-bytes": "^5.6.0",
|
|
153
153
|
"prompts": "^2.4.2",
|
|
@@ -164,14 +164,13 @@
|
|
|
164
164
|
"@commitlint/cli": "^17.6.5",
|
|
165
165
|
"@commitlint/config-conventional": "^17.6.5",
|
|
166
166
|
"@sanity/pkg-utils": "workspace:*",
|
|
167
|
-
"@sanity/semantic-release-preset": "4.1.
|
|
167
|
+
"@sanity/semantic-release-preset": "4.1.2",
|
|
168
168
|
"@types/babel__core": "^7.20.1",
|
|
169
169
|
"@types/cpx": "^1.5.2",
|
|
170
170
|
"@types/find-config": "^1.0.1",
|
|
171
171
|
"@types/git-url-parse": "^9.0.1",
|
|
172
172
|
"@types/node": "^20.2.5",
|
|
173
173
|
"@types/parse-git-config": "^3.0.1",
|
|
174
|
-
"@types/prettier": "^2.7.3",
|
|
175
174
|
"@types/prompts": "^2.4.4",
|
|
176
175
|
"@types/rimraf": "^3.0.2",
|
|
177
176
|
"@types/treeify": "^1.0.0",
|
|
@@ -184,7 +183,7 @@
|
|
|
184
183
|
"eslint": "^8.42.0",
|
|
185
184
|
"eslint-config-prettier": "^8.8.0",
|
|
186
185
|
"eslint-plugin-import": "^2.27.5",
|
|
187
|
-
"eslint-plugin-prettier": "^
|
|
186
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
188
187
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
189
188
|
"husky": "^8.0.3",
|
|
190
189
|
"lint-staged": "^13.2.2",
|
|
@@ -199,7 +198,7 @@
|
|
|
199
198
|
"peerDependencies": {
|
|
200
199
|
"typescript": "^4.7 || ^5"
|
|
201
200
|
},
|
|
202
|
-
"packageManager": "pnpm@8.6.
|
|
201
|
+
"packageManager": "pnpm@8.6.10",
|
|
203
202
|
"engines": {
|
|
204
203
|
"node": ">=16.0.0"
|
|
205
204
|
},
|
package/src/node/check.ts
CHANGED
|
@@ -85,7 +85,7 @@ export async function check(options: {
|
|
|
85
85
|
|
|
86
86
|
async function checkExports(
|
|
87
87
|
exportPaths: string[],
|
|
88
|
-
options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger}
|
|
88
|
+
options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},
|
|
89
89
|
) {
|
|
90
90
|
const {cwd, external, format, logger} = options
|
|
91
91
|
|
|
@@ -148,7 +148,7 @@ function printEsbuildMessage(log: (...args: unknown[]) => void, msg: esbuild.Mes
|
|
|
148
148
|
`${msg.detail || msg.text}\n`,
|
|
149
149
|
`${msg.location.line} | ${msg.location.lineText}\n`,
|
|
150
150
|
`in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,
|
|
151
|
-
].join('')
|
|
151
|
+
].join(''),
|
|
152
152
|
)
|
|
153
153
|
} else {
|
|
154
154
|
log(msg.detail || msg.text)
|
|
@@ -33,19 +33,19 @@ export async function loadPkgWithReporting(options: {
|
|
|
33
33
|
|
|
34
34
|
if (!assertOrder('require', 'import', keys)) {
|
|
35
35
|
logger.warn(
|
|
36
|
-
`exports["${expPath}"]: the \`require\` property should come before the \`import\` property
|
|
36
|
+
`exports["${expPath}"]: the \`require\` property should come before the \`import\` property`,
|
|
37
37
|
)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (!assertOrder('require', 'node', keys)) {
|
|
41
41
|
logger.warn(
|
|
42
|
-
`exports["${expPath}"]: the \`require\` property should come before the \`node\` property
|
|
42
|
+
`exports["${expPath}"]: the \`require\` property should come before the \`node\` property`,
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (!assertOrder('node', 'import', keys)) {
|
|
47
47
|
logger.warn(
|
|
48
|
-
`exports["${expPath}"]: the \`node\` property should come before \`import\` property
|
|
48
|
+
`exports["${expPath}"]: the \`node\` property should come before \`import\` property`,
|
|
49
49
|
)
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -65,7 +65,7 @@ export async function loadPkgWithReporting(options: {
|
|
|
65
65
|
`\`${formatPath(issue.path)}\` `,
|
|
66
66
|
`in \`./package.json\` must be of type ${chalk.magenta(issue.expected)} `,
|
|
67
67
|
`(received ${chalk.magenta(issue.received)})`,
|
|
68
|
-
].join('')
|
|
68
|
+
].join(''),
|
|
69
69
|
)
|
|
70
70
|
continue
|
|
71
71
|
}
|
|
@@ -51,25 +51,25 @@ export function parseExports(options: {
|
|
|
51
51
|
exportEntry.require !== rootExport.require
|
|
52
52
|
) {
|
|
53
53
|
errors.push(
|
|
54
|
-
'package.json: mismatch between "main" and "exports.require". These must be equal.'
|
|
54
|
+
'package.json: mismatch between "main" and "exports.require". These must be equal.',
|
|
55
55
|
)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (exportEntry.import && rootExport.import && exportEntry.import !== rootExport.import) {
|
|
59
59
|
errors.push(
|
|
60
|
-
'package.json: mismatch between "module" and "exports.import" These must be equal.'
|
|
60
|
+
'package.json: mismatch between "module" and "exports.import" These must be equal.',
|
|
61
61
|
)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (exportEntry.types && rootExport.types && exportEntry.types !== rootExport.types) {
|
|
65
65
|
errors.push(
|
|
66
|
-
'package.json: mismatch between "types" and "exports.types". These must be equal.'
|
|
66
|
+
'package.json: mismatch between "types" and "exports.types". These must be equal.',
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (exportEntry.source && rootExport.source && exportEntry.source !== rootExport.source) {
|
|
71
71
|
errors.push(
|
|
72
|
-
'package.json: mismatch between "source" and "exports.source". These must be equal.'
|
|
72
|
+
'package.json: mismatch between "source" and "exports.source". These must be equal.',
|
|
73
73
|
)
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -4,7 +4,7 @@ import {PackageJSON} from './types'
|
|
|
4
4
|
|
|
5
5
|
export function validateExports(
|
|
6
6
|
_exports: (PkgExport & {_path: string})[],
|
|
7
|
-
options: {extMap: PkgExtMap; pkg: PackageJSON}
|
|
7
|
+
options: {extMap: PkgExtMap; pkg: PackageJSON},
|
|
8
8
|
): string[] {
|
|
9
9
|
const {extMap, pkg} = options
|
|
10
10
|
const ext = extMap[pkg.type || 'commonjs']
|
|
@@ -14,13 +14,13 @@ export function validateExports(
|
|
|
14
14
|
for (const exp of _exports) {
|
|
15
15
|
if (exp.require && !exp.require.endsWith(ext.commonjs)) {
|
|
16
16
|
errors.push(
|
|
17
|
-
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].require\` must end with "${ext.commonjs}"
|
|
17
|
+
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].require\` must end with "${ext.commonjs}"`,
|
|
18
18
|
)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
if (exp.import && !exp.import.endsWith(ext.esm)) {
|
|
22
22
|
errors.push(
|
|
23
|
-
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].import\` must end with "${ext.esm}"
|
|
23
|
+
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].import\` must end with "${ext.esm}"`,
|
|
24
24
|
)
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -29,20 +29,20 @@ const pkgSchema = z.object({
|
|
|
29
29
|
source: z.string(),
|
|
30
30
|
require: z.optional(z.string()),
|
|
31
31
|
import: z.optional(z.string()),
|
|
32
|
-
})
|
|
32
|
+
}),
|
|
33
33
|
),
|
|
34
34
|
node: z.optional(
|
|
35
35
|
z.object({
|
|
36
36
|
source: z.optional(z.string()),
|
|
37
37
|
require: z.optional(z.string()),
|
|
38
38
|
import: z.optional(z.string()),
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
40
|
),
|
|
41
41
|
import: z.optional(z.string()),
|
|
42
42
|
default: z.string(),
|
|
43
43
|
}),
|
|
44
|
-
])
|
|
45
|
-
)
|
|
44
|
+
]),
|
|
45
|
+
),
|
|
46
46
|
),
|
|
47
47
|
browserslist: z.optional(z.array(z.string())),
|
|
48
48
|
})
|
|
@@ -42,7 +42,7 @@ export async function createFromTemplate(options: {
|
|
|
42
42
|
? templateOption.initial(templateOptions)
|
|
43
43
|
: templateOption.initial,
|
|
44
44
|
},
|
|
45
|
-
{onCancel: () => process.exit(0)}
|
|
45
|
+
{onCancel: () => process.exit(0)},
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
templateOptions[templateOption.name] = templateOption.parse
|
|
@@ -61,7 +61,7 @@ export async function createFromTemplate(options: {
|
|
|
61
61
|
message: `use ${templateFeature.name}?`,
|
|
62
62
|
initial: templateFeature.initial,
|
|
63
63
|
},
|
|
64
|
-
{onCancel: () => process.exit(0)}
|
|
64
|
+
{onCancel: () => process.exit(0)},
|
|
65
65
|
)
|
|
66
66
|
: undefined
|
|
67
67
|
|
|
@@ -30,7 +30,7 @@ export function printExtractMessages(ctx: BuildContext, messages: ExtractorMessa
|
|
|
30
30
|
` - ${chalk.yellow('warning')} ${chalk.gray(msg.messageId)}\n`,
|
|
31
31
|
msg.text,
|
|
32
32
|
'\n',
|
|
33
|
-
].join('')
|
|
33
|
+
].join(''),
|
|
34
34
|
)
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -50,7 +50,7 @@ export function printExtractMessages(ctx: BuildContext, messages: ExtractorMessa
|
|
|
50
50
|
` - ${chalk.red('error')} ${chalk.gray(msg.messageId)}\n`,
|
|
51
51
|
msg.text,
|
|
52
52
|
'\n',
|
|
53
|
-
].join('')
|
|
53
|
+
].join(''),
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -30,7 +30,7 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
30
30
|
|
|
31
31
|
if (pkg.bin) {
|
|
32
32
|
tree.bin = Object.fromEntries(
|
|
33
|
-
Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)])
|
|
33
|
+
Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),
|
|
34
34
|
)
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -96,7 +96,7 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
return [chalk.cyan(path.join(pkg.name, exportPath)), exp]
|
|
99
|
-
})
|
|
99
|
+
}),
|
|
100
100
|
)
|
|
101
101
|
|
|
102
102
|
logger.log(treeify.asTree(tree as Record<string, any>, true, true))
|
|
@@ -93,7 +93,7 @@ export async function resolveBuildContext(options: {
|
|
|
93
93
|
|
|
94
94
|
if (commonDistPath === cwd) {
|
|
95
95
|
throw new Error(
|
|
96
|
-
'all output files must share a common parent directory which is not the root package directory'
|
|
96
|
+
'all output files must share a common parent directory which is not the root package directory',
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -13,7 +13,7 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
|
|
|
13
13
|
const tasks: BuildTask[] = []
|
|
14
14
|
|
|
15
15
|
const exports = Object.entries(ctx.exports || {}).map(
|
|
16
|
-
([_path, exp]) => ({_path, ...exp} as PkgExport & {_path: string}
|
|
16
|
+
([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
const dtsTask: DtsTask = {
|
|
@@ -140,15 +140,15 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
|
|
|
140
140
|
if (exp._exported && exp._path !== '.') {
|
|
141
141
|
const relativeTargetPath = (exp.browser?.import || exp.import || '').replace(
|
|
142
142
|
/\.[^/.]+$/,
|
|
143
|
-
''
|
|
143
|
+
'',
|
|
144
144
|
)
|
|
145
145
|
|
|
146
146
|
if (relativeTargetPath) {
|
|
147
147
|
fs.writeFileSync(
|
|
148
148
|
path.resolve(cwd, `${exp._path}.js`),
|
|
149
149
|
[`// AUTO-GENERATED – DO NOT EDIT`, `export * from '${relativeTargetPath}'`, ``].join(
|
|
150
|
-
'\n'
|
|
151
|
-
)
|
|
150
|
+
'\n',
|
|
151
|
+
),
|
|
152
152
|
)
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -10,7 +10,7 @@ export function resolveWatchTasks(ctx: BuildContext): WatchTask[] {
|
|
|
10
10
|
const tasks: WatchTask[] = []
|
|
11
11
|
|
|
12
12
|
const exports = Object.entries(ctx.exports || {}).map(
|
|
13
|
-
([_path, exp]) => ({_path, ...exp} as PkgExport & {_path: string}
|
|
13
|
+
([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
const dtsTask: DtsWatchTask = {
|
|
@@ -115,15 +115,15 @@ export function resolveWatchTasks(ctx: BuildContext): WatchTask[] {
|
|
|
115
115
|
if (exp._exported && exp._path !== '.') {
|
|
116
116
|
const relativeTargetPath = (exp.browser?.import || exp.import || '').replace(
|
|
117
117
|
/\.[^/.]+$/,
|
|
118
|
-
''
|
|
118
|
+
'',
|
|
119
119
|
)
|
|
120
120
|
|
|
121
121
|
if (relativeTargetPath) {
|
|
122
122
|
fs.writeFileSync(
|
|
123
123
|
path.resolve(cwd, `${exp._path}.js`),
|
|
124
124
|
[`// AUTO-GENERATED – DO NOT EDIT`, `export * from '${relativeTargetPath}'`, ``].join(
|
|
125
|
-
'\n'
|
|
126
|
-
)
|
|
125
|
+
'\n',
|
|
126
|
+
),
|
|
127
127
|
)
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -20,7 +20,7 @@ export async function createTSDocConfig(opts: {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const tsDocBaseBuf = await readFile(
|
|
23
|
-
require.resolve('@microsoft/api-extractor/extends/tsdoc-base.json')
|
|
23
|
+
require.resolve('@microsoft/api-extractor/extends/tsdoc-base.json'),
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
// Include the definitions that are required for API Extractor
|
|
@@ -33,7 +33,7 @@ export async function createTSDocConfig(opts: {
|
|
|
33
33
|
tagName: `@${t.name}`,
|
|
34
34
|
syntaxKind: t.syntaxKind,
|
|
35
35
|
allowMultiple: t.allowMultiple,
|
|
36
|
-
}))
|
|
36
|
+
})),
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
// Indicate that custom tags are supported by your tooling.
|
|
@@ -15,7 +15,7 @@ import {DtsResult, DtsTask, DtsWatchTask} from './types'
|
|
|
15
15
|
*/
|
|
16
16
|
export async function doExtract(
|
|
17
17
|
ctx: BuildContext,
|
|
18
|
-
task: DtsTask | DtsWatchTask
|
|
18
|
+
task: DtsTask | DtsWatchTask,
|
|
19
19
|
): Promise<DtsResult> {
|
|
20
20
|
const {config, cwd, files, logger, strict, ts} = ctx
|
|
21
21
|
|
|
@@ -41,7 +41,7 @@ export async function doExtract(
|
|
|
41
41
|
|
|
42
42
|
const sourceTypesPath = path.resolve(
|
|
43
43
|
tmpPath,
|
|
44
|
-
path.relative(rootDir, path.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, '.d.ts')
|
|
44
|
+
path.relative(rootDir, path.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, '.d.ts'),
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
const targetPath = path.resolve(cwd, entry.targetPath)
|
|
@@ -17,7 +17,7 @@ export const dtsTask: TaskHandler<DtsTask, DtsResult> = {
|
|
|
17
17
|
[
|
|
18
18
|
` - ${chalk.cyan(entry.importId)}: `,
|
|
19
19
|
`${chalk.yellow(entry.sourcePath)} ${chalk.gray('→')} ${chalk.yellow(entry.targetPath)}`,
|
|
20
|
-
].join('')
|
|
20
|
+
].join(''),
|
|
21
21
|
),
|
|
22
22
|
].join('\n'),
|
|
23
23
|
exec: (ctx, task) => {
|
|
@@ -14,7 +14,7 @@ export const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult> = {
|
|
|
14
14
|
`build type definitions`,
|
|
15
15
|
...task.entries.map(
|
|
16
16
|
(entry) =>
|
|
17
|
-
` ${chalk.blue(entry.importId)}: ${entry.sourcePath} -> ${entry.targetPath}
|
|
17
|
+
` ${chalk.blue(entry.importId)}: ${entry.sourcePath} -> ${entry.targetPath}`,
|
|
18
18
|
),
|
|
19
19
|
].join('\n'),
|
|
20
20
|
exec: (ctx, task) => {
|
|
@@ -17,7 +17,7 @@ export function getExtractMessagesConfig(options: {
|
|
|
17
17
|
|
|
18
18
|
function ruleToLogLevel(
|
|
19
19
|
key: keyof NonNullable<NonNullable<PkgConfigOptions['extract']>['rules']>,
|
|
20
|
-
defaultLevel?: ExtractorLogLevel
|
|
20
|
+
defaultLevel?: ExtractorLogLevel,
|
|
21
21
|
) {
|
|
22
22
|
const r = rules?.[key]
|
|
23
23
|
|
|
@@ -17,7 +17,7 @@ export const nodeReexportCjsTask: TaskHandler<NodeReExportFromCJSTask> = {
|
|
|
17
17
|
[
|
|
18
18
|
` - ${chalk.cyan(entry.importId)}: `,
|
|
19
19
|
`${chalk.yellow(entry.require)} ${chalk.gray('→')} ${chalk.yellow(entry.import)}`,
|
|
20
|
-
].join('')
|
|
20
|
+
].join(''),
|
|
21
21
|
),
|
|
22
22
|
].join('\n'),
|
|
23
23
|
exec: (ctx, task) => {
|
|
@@ -20,7 +20,7 @@ export interface RollupConfig {
|
|
|
20
20
|
/** @internal */
|
|
21
21
|
export function resolveRollupConfig(
|
|
22
22
|
ctx: BuildContext,
|
|
23
|
-
buildTask: RollupTask | RollupWatchTask
|
|
23
|
+
buildTask: RollupTask | RollupWatchTask,
|
|
24
24
|
): RollupConfig {
|
|
25
25
|
const {format, runtime, target} = buildTask
|
|
26
26
|
const {config, cwd, exports: _exports, extMap, external, distPath, logger, pkg, ts} = ctx
|
|
@@ -31,7 +31,7 @@ export function resolveRollupConfig(
|
|
|
31
31
|
const pathAliases = Object.fromEntries(
|
|
32
32
|
Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {
|
|
33
33
|
return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0])]
|
|
34
|
-
})
|
|
34
|
+
}),
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
const entries = buildTask.entries.map((entry) => {
|
|
@@ -47,7 +47,7 @@ export function resolveRollupConfig(
|
|
|
47
47
|
const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))
|
|
48
48
|
|
|
49
49
|
const replacements = Object.fromEntries(
|
|
50
|
-
Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)])
|
|
50
|
+
Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
const defaultPlugins = [
|
|
@@ -69,7 +69,7 @@ export function resolveRollupConfig(
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return JSON.stringify(
|
|
72
|
-
path.relative(cwd, path.resolve(outDir, entry.name + outputExt))
|
|
72
|
+
path.relative(cwd, path.resolve(outDir, entry.name + outputExt)),
|
|
73
73
|
)
|
|
74
74
|
},
|
|
75
75
|
'process.env.PKG_FORMAT': JSON.stringify(format),
|
|
@@ -156,8 +156,8 @@ export function resolveRollupConfig(
|
|
|
156
156
|
logger.warn(
|
|
157
157
|
`detected self-referencing import – treating as external: ${path.relative(
|
|
158
158
|
cwd,
|
|
159
|
-
idPath
|
|
160
|
-
)}
|
|
159
|
+
idPath,
|
|
160
|
+
)}`,
|
|
161
161
|
)
|
|
162
162
|
|
|
163
163
|
return true
|
|
@@ -25,7 +25,7 @@ export const rollupTask: TaskHandler<RollupTask> = {
|
|
|
25
25
|
[
|
|
26
26
|
` - `,
|
|
27
27
|
`${chalk.yellow(e.source)} ${chalk.gray('→')} ${chalk.yellow(e.output)}`,
|
|
28
|
-
].join('')
|
|
28
|
+
].join(''),
|
|
29
29
|
),
|
|
30
30
|
]
|
|
31
31
|
: []
|
|
@@ -38,7 +38,7 @@ export const rollupTask: TaskHandler<RollupTask> = {
|
|
|
38
38
|
` - `,
|
|
39
39
|
`${chalk.cyan(path.join(ctx.pkg.name, e.path))}: `,
|
|
40
40
|
`${chalk.yellow(e.source)} ${chalk.gray('→')} ${chalk.yellow(e.output)}`,
|
|
41
|
-
].join('')
|
|
41
|
+
].join(''),
|
|
42
42
|
),
|
|
43
43
|
]
|
|
44
44
|
: []
|
|
@@ -43,7 +43,7 @@ export const rollupWatchTask: TaskHandler<RollupWatchTask, RollupWatcherEvent> =
|
|
|
43
43
|
task.format
|
|
44
44
|
})\n ${task.entries
|
|
45
45
|
.map((e) => `${chalk.blue(path.join(ctx.pkg.name, e.path))}: ${e.source} -> ${e.output}`)
|
|
46
|
-
.join('\n ')}
|
|
46
|
+
.join('\n ')}`,
|
|
47
47
|
)
|
|
48
48
|
logger.log('')
|
|
49
49
|
|
|
@@ -336,7 +336,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
336
336
|
|
|
337
337
|
files.push({
|
|
338
338
|
name: '.eslintrc.cjs',
|
|
339
|
-
contents: format(
|
|
339
|
+
contents: await format(
|
|
340
340
|
resolve(packagePath, '.eslintrc.cjs'),
|
|
341
341
|
outdent`
|
|
342
342
|
'use strict'
|
|
@@ -344,7 +344,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
344
344
|
/** @type import('eslint').Linter.Config */
|
|
345
345
|
module.exports = ${JSON.stringify(eslintConfig, null, 2)}
|
|
346
346
|
`,
|
|
347
|
-
prettierConfig
|
|
347
|
+
prettierConfig,
|
|
348
348
|
),
|
|
349
349
|
})
|
|
350
350
|
}
|
|
@@ -352,7 +352,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
352
352
|
if (features.typescript) {
|
|
353
353
|
files.push({
|
|
354
354
|
name: 'tsconfig.settings.json',
|
|
355
|
-
contents: format(
|
|
355
|
+
contents: await format(
|
|
356
356
|
resolve(packagePath, 'tsconfig.settings.json'),
|
|
357
357
|
outdent`
|
|
358
358
|
{
|
|
@@ -386,13 +386,13 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
`,
|
|
389
|
-
prettierConfig
|
|
389
|
+
prettierConfig,
|
|
390
390
|
),
|
|
391
391
|
})
|
|
392
392
|
|
|
393
393
|
files.push({
|
|
394
394
|
name: 'tsconfig.dist.json',
|
|
395
|
-
contents: format(
|
|
395
|
+
contents: await format(
|
|
396
396
|
resolve(packagePath, 'tsconfig.dist.json'),
|
|
397
397
|
outdent`
|
|
398
398
|
{
|
|
@@ -406,13 +406,13 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
`,
|
|
409
|
-
prettierConfig
|
|
409
|
+
prettierConfig,
|
|
410
410
|
),
|
|
411
411
|
})
|
|
412
412
|
|
|
413
413
|
files.push({
|
|
414
414
|
name: 'tsconfig.json',
|
|
415
|
-
contents: format(
|
|
415
|
+
contents: await format(
|
|
416
416
|
resolve(packagePath, 'tsconfig.json'),
|
|
417
417
|
outdent`
|
|
418
418
|
{
|
|
@@ -427,7 +427,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
`,
|
|
430
|
-
prettierConfig
|
|
430
|
+
prettierConfig,
|
|
431
431
|
),
|
|
432
432
|
})
|
|
433
433
|
}
|
|
@@ -436,7 +436,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
436
436
|
if (features.typescript) {
|
|
437
437
|
files.push({
|
|
438
438
|
name: 'package.config.ts',
|
|
439
|
-
contents: format(
|
|
439
|
+
contents: await format(
|
|
440
440
|
resolve(packagePath, 'package.config.ts'),
|
|
441
441
|
outdent`
|
|
442
442
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
@@ -453,13 +453,13 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
453
453
|
tsconfig: 'tsconfig.dist.json',
|
|
454
454
|
})
|
|
455
455
|
`,
|
|
456
|
-
prettierConfig
|
|
456
|
+
prettierConfig,
|
|
457
457
|
),
|
|
458
458
|
})
|
|
459
459
|
|
|
460
460
|
files.push({
|
|
461
461
|
name: 'src/index.ts',
|
|
462
|
-
contents: format(
|
|
462
|
+
contents: await format(
|
|
463
463
|
resolve(packagePath, 'src/index.ts'),
|
|
464
464
|
outdent`
|
|
465
465
|
/** @public */
|
|
@@ -467,13 +467,13 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
467
467
|
//
|
|
468
468
|
}
|
|
469
469
|
`,
|
|
470
|
-
prettierConfig
|
|
470
|
+
prettierConfig,
|
|
471
471
|
),
|
|
472
472
|
})
|
|
473
473
|
} else {
|
|
474
474
|
files.push({
|
|
475
475
|
name: 'package.config.js',
|
|
476
|
-
contents: format(
|
|
476
|
+
contents: await format(
|
|
477
477
|
resolve(packagePath, 'package.config.js'),
|
|
478
478
|
outdent`
|
|
479
479
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
@@ -487,13 +487,13 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
487
487
|
},
|
|
488
488
|
})
|
|
489
489
|
`,
|
|
490
|
-
prettierConfig
|
|
490
|
+
prettierConfig,
|
|
491
491
|
),
|
|
492
492
|
})
|
|
493
493
|
|
|
494
494
|
files.push({
|
|
495
495
|
name: 'src/index.js',
|
|
496
|
-
contents: format(
|
|
496
|
+
contents: await format(
|
|
497
497
|
resolve(packagePath, 'src/index.js'),
|
|
498
498
|
outdent`
|
|
499
499
|
/** @public */
|
|
@@ -501,7 +501,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
501
501
|
//
|
|
502
502
|
}
|
|
503
503
|
`,
|
|
504
|
-
prettierConfig
|
|
504
|
+
prettierConfig,
|
|
505
505
|
),
|
|
506
506
|
})
|
|
507
507
|
}
|
|
@@ -522,10 +522,10 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
522
522
|
|
|
523
523
|
files.push({
|
|
524
524
|
name: 'package.json',
|
|
525
|
-
contents: format(
|
|
525
|
+
contents: await format(
|
|
526
526
|
resolve(packagePath, 'package.json'),
|
|
527
527
|
JSON.stringify(pkgJson, null, 2),
|
|
528
|
-
prettierConfig
|
|
528
|
+
prettierConfig,
|
|
529
529
|
),
|
|
530
530
|
})
|
|
531
531
|
|
package/src/node/watch.ts
CHANGED