@sanity/pkg-utils 2.2.16 → 2.3.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/README.md +16 -7
- package/dist/_chunks/{build-ba8f4eab.cjs → build-0aed2000.cjs} +11 -8
- package/dist/_chunks/build-0aed2000.cjs.map +1 -0
- package/dist/_chunks/{buildAction-f35f5fe0.cjs → buildAction-196fba7b.cjs} +2 -2
- package/dist/_chunks/{buildAction-f35f5fe0.cjs.map → buildAction-196fba7b.cjs.map} +1 -1
- package/dist/_chunks/{check-c18ac13f.cjs → check-2deafe2a.cjs} +25 -31
- package/dist/_chunks/check-2deafe2a.cjs.map +1 -0
- package/dist/_chunks/{checkAction-be47c642.cjs → checkAction-7ac5a05e.cjs} +2 -2
- package/dist/_chunks/{checkAction-be47c642.cjs.map → checkAction-7ac5a05e.cjs.map} +1 -1
- package/dist/_chunks/{index-b295a336.cjs → index-984e18d1.cjs} +6 -3
- package/dist/_chunks/index-984e18d1.cjs.map +1 -0
- package/dist/_chunks/init-ab36343b.cjs +469 -0
- package/dist/_chunks/init-ab36343b.cjs.map +1 -0
- package/dist/_chunks/initAction-d18cf4f2.cjs +16 -0
- package/dist/_chunks/initAction-d18cf4f2.cjs.map +1 -0
- package/dist/_chunks/logger-c593f06b.cjs +97 -0
- package/dist/_chunks/logger-c593f06b.cjs.map +1 -0
- package/dist/_chunks/{resolveBuildContext-2239fc5e.cjs → resolveBuildContext-5ef90110.cjs} +13 -92
- package/dist/_chunks/resolveBuildContext-5ef90110.cjs.map +1 -0
- package/dist/_chunks/{watch-5bfb8b28.cjs → watch-63a93eb0.cjs} +10 -7
- package/dist/_chunks/watch-63a93eb0.cjs.map +1 -0
- package/dist/_chunks/{watchAction-788563ea.cjs → watchAction-95c0b481.cjs} +2 -2
- package/dist/_chunks/{watchAction-788563ea.cjs.map → watchAction-95c0b481.cjs.map} +1 -1
- package/dist/cli.cjs +17 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +12 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +87 -0
- package/dist/index.js +465 -32
- package/dist/index.js.map +1 -1
- package/package.json +93 -79
- package/src/cli/index.ts +12 -3
- package/src/cli/initAction.ts +13 -0
- package/src/node/build.ts +1 -1
- package/src/node/check.ts +4 -2
- package/src/node/core/config/findConfigFile.ts +6 -14
- package/src/node/core/config/index.ts +1 -1
- package/src/node/core/config/loadConfig.ts +2 -1
- package/src/node/core/contexts/buildContext.ts +2 -1
- package/src/node/core/findCommonPath.test.ts +1 -0
- package/src/node/core/index.ts +3 -2
- package/src/node/core/pkg/loadPkg.ts +1 -0
- package/src/node/core/pkg/loadPkgWithReporting.ts +1 -0
- package/src/node/core/pkg/types.ts +13 -0
- package/src/node/core/pkg/validatePkg.ts +1 -0
- package/src/node/core/template/createFromTemplate.ts +85 -0
- package/src/node/core/template/define.ts +6 -0
- package/src/node/core/template/index.ts +3 -0
- package/src/node/core/template/types.ts +45 -0
- package/src/node/fileExists.ts +12 -0
- package/src/node/globFiles.ts +1 -1
- package/src/node/index.ts +1 -0
- package/src/node/init.ts +55 -0
- package/src/node/isEmptyDirectory.ts +5 -0
- package/src/node/printExtractMessages.ts +2 -1
- package/src/node/printPackageTree.ts +4 -13
- package/src/node/resolveBuildContext.ts +5 -4
- package/src/node/resolveBuildTasks.ts +2 -1
- package/src/node/resolveWatchTasks.ts +3 -2
- package/src/node/tasks/dts/buildTypes.ts +1 -0
- package/src/node/tasks/dts/createApiExtractorConfig.ts +1 -1
- package/src/node/tasks/dts/createTSDocConfig.ts +1 -1
- package/src/node/tasks/dts/doExtract.ts +2 -1
- package/src/node/tasks/dts/dtsTask.ts +1 -0
- package/src/node/tasks/dts/dtsWatchTask.ts +1 -0
- package/src/node/tasks/dts/extractTypes.ts +4 -3
- package/src/node/tasks/dts/getExtractMessagesConfig.ts +2 -1
- package/src/node/tasks/dts/printDiagnostic.ts +2 -1
- package/src/node/tasks/index.ts +1 -1
- package/src/node/tasks/node/reexportCjsTask.ts +3 -2
- package/src/node/tasks/rollup/resolveRollupConfig.ts +2 -1
- package/src/node/tasks/rollup/rollupTask.ts +2 -1
- package/src/node/tasks/rollup/rollupWatchTask.ts +2 -1
- package/src/node/tasks/types.ts +2 -1
- package/src/node/templates/default/index.ts +1 -0
- package/src/node/templates/default/template.ts +553 -0
- package/src/node/templates/index.ts +1 -0
- package/src/node/watch.ts +2 -1
- package/src/node/watchConfigFiles.ts +1 -0
- package/dist/_chunks/build-ba8f4eab.cjs.map +0 -1
- package/dist/_chunks/check-c18ac13f.cjs.map +0 -1
- package/dist/_chunks/index-b295a336.cjs.map +0 -1
- package/dist/_chunks/resolveBuildContext-2239fc5e.cjs.map +0 -1
- package/dist/_chunks/watch-5bfb8b28.cjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,14 @@ export declare function check(options: {
|
|
|
79
79
|
tsconfig?: string
|
|
80
80
|
}): Promise<void>
|
|
81
81
|
|
|
82
|
+
/** @internal */
|
|
83
|
+
export declare function createFromTemplate(options: {
|
|
84
|
+
cwd: string
|
|
85
|
+
logger: Logger
|
|
86
|
+
packagePath: string
|
|
87
|
+
template: PkgTemplate
|
|
88
|
+
}): Promise<void>
|
|
89
|
+
|
|
82
90
|
/** @internal */
|
|
83
91
|
export declare function createLogger(): Logger
|
|
84
92
|
|
|
@@ -91,6 +99,9 @@ export declare const DEFAULT_PKG_EXT_MAP: PkgExtMap
|
|
|
91
99
|
/** @public */
|
|
92
100
|
export declare function defineConfig(configOptions: PkgConfigOptions): PkgConfigOptions
|
|
93
101
|
|
|
102
|
+
/** @public */
|
|
103
|
+
export declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>
|
|
104
|
+
|
|
94
105
|
/** @internal */
|
|
95
106
|
export declare interface DtsResult {
|
|
96
107
|
type: 'dts'
|
|
@@ -137,6 +148,9 @@ export declare function getExtractMessagesConfig(options: {
|
|
|
137
148
|
/** @internal */
|
|
138
149
|
export declare function getPkgExtMap(options: {legacyExports: boolean}): PkgExtMap
|
|
139
150
|
|
|
151
|
+
/** @public */
|
|
152
|
+
export declare function init(options: {cwd: string; path: string}): Promise<void>
|
|
153
|
+
|
|
140
154
|
/** @internal */
|
|
141
155
|
export declare function isRecord(value: unknown): value is Record<string, unknown>
|
|
142
156
|
|
|
@@ -182,7 +196,16 @@ export declare interface PackageJSON {
|
|
|
182
196
|
type?: 'commonjs' | 'module'
|
|
183
197
|
version: string
|
|
184
198
|
private?: boolean
|
|
199
|
+
author?:
|
|
200
|
+
| string
|
|
201
|
+
| {
|
|
202
|
+
name: string
|
|
203
|
+
email?: string
|
|
204
|
+
url?: string
|
|
205
|
+
}
|
|
185
206
|
name: string
|
|
207
|
+
description?: string
|
|
208
|
+
keywords?: string[]
|
|
186
209
|
bin?: Record<string, string>
|
|
187
210
|
dependencies?: Record<string, string>
|
|
188
211
|
devDependencies?: Record<string, string>
|
|
@@ -213,7 +236,27 @@ export declare interface PackageJSON {
|
|
|
213
236
|
source?: string
|
|
214
237
|
module?: string
|
|
215
238
|
types?: string
|
|
239
|
+
files?: string[]
|
|
240
|
+
scripts?: Record<string, string>
|
|
216
241
|
browserslist?: string[]
|
|
242
|
+
engines?: {
|
|
243
|
+
node?: string
|
|
244
|
+
npm?: string
|
|
245
|
+
}
|
|
246
|
+
repository?:
|
|
247
|
+
| string
|
|
248
|
+
| {
|
|
249
|
+
type: 'git'
|
|
250
|
+
url: string
|
|
251
|
+
}
|
|
252
|
+
bugs?:
|
|
253
|
+
| string
|
|
254
|
+
| {
|
|
255
|
+
url: string
|
|
256
|
+
email?: string
|
|
257
|
+
}
|
|
258
|
+
homepage?: string
|
|
259
|
+
license?: string
|
|
217
260
|
}
|
|
218
261
|
|
|
219
262
|
/** @internal */
|
|
@@ -353,6 +396,50 @@ export declare type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'
|
|
|
353
396
|
/** @public */
|
|
354
397
|
export declare type PkgRuntime = '*' | 'browser' | 'node'
|
|
355
398
|
|
|
399
|
+
/** @public */
|
|
400
|
+
export declare type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver
|
|
401
|
+
|
|
402
|
+
/** @public */
|
|
403
|
+
export declare interface PkgTemplateDefinition {
|
|
404
|
+
options: PkgTemplateStringOption<any>[]
|
|
405
|
+
features: {
|
|
406
|
+
name: string
|
|
407
|
+
optional: boolean
|
|
408
|
+
initial: boolean
|
|
409
|
+
}[]
|
|
410
|
+
getFiles: (
|
|
411
|
+
options: Record<string, any>,
|
|
412
|
+
features: Record<string, boolean>
|
|
413
|
+
) => Promise<PkgTemplateFile[]>
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** @public */
|
|
417
|
+
export declare interface PkgTemplateFile {
|
|
418
|
+
name: string
|
|
419
|
+
contents: string
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** @public */
|
|
423
|
+
export declare type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
|
|
424
|
+
|
|
425
|
+
/** @public */
|
|
426
|
+
export declare type PkgTemplateResolver = (options: {
|
|
427
|
+
cwd: string
|
|
428
|
+
/** @internal */
|
|
429
|
+
logger: Logger
|
|
430
|
+
packagePath: string
|
|
431
|
+
}) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>
|
|
432
|
+
|
|
433
|
+
/** @public */
|
|
434
|
+
export declare interface PkgTemplateStringOption<T = string> {
|
|
435
|
+
name: string
|
|
436
|
+
type: 'string'
|
|
437
|
+
description: string
|
|
438
|
+
initial?: T | ((options: Record<string, any>) => T)
|
|
439
|
+
parse?: (v: string) => T | null
|
|
440
|
+
validate?: (v: string) => string | true
|
|
441
|
+
}
|
|
442
|
+
|
|
356
443
|
/** @internal */
|
|
357
444
|
export declare function resolveBuildTasks(ctx: BuildContext): BuildTask[]
|
|
358
445
|
|