@sanity/pkg-utils 1.3.0 → 1.4.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/README.md +8 -0
- package/dist/__printPackageTree-793a302b.cjs +75 -0
- package/dist/__printPackageTree-793a302b.cjs.map +1 -0
- package/dist/__resolveBuildContext-1b29cff2.cjs +336 -0
- package/dist/__resolveBuildContext-1b29cff2.cjs.map +1 -0
- package/dist/_build-08236974.cjs +169 -0
- package/dist/_build-08236974.cjs.map +1 -0
- package/dist/_buildAction-586dfb5f.cjs +43 -0
- package/dist/_buildAction-586dfb5f.cjs.map +1 -0
- package/dist/_check-9d180462.cjs +16 -0
- package/dist/_check-9d180462.cjs.map +1 -0
- package/dist/_index-c5bd1bc8.cjs +565 -0
- package/dist/_index-c5bd1bc8.cjs.map +1 -0
- package/dist/_statusAction-385b72dd.cjs +27 -0
- package/dist/_statusAction-385b72dd.cjs.map +1 -0
- package/dist/_watch-003a06b2.cjs +218 -0
- package/dist/_watch-003a06b2.cjs.map +1 -0
- package/dist/_watchAction-c7cf282d.cjs +42 -0
- package/dist/_watchAction-c7cf282d.cjs.map +1 -0
- package/dist/cli.cjs +14 -31
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +41 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +278 -152
- package/dist/index.js +946 -5195
- package/dist/index.js.map +1 -1
- package/package.json +25 -9
- package/src/cli/buildAction.ts +8 -0
- package/src/cli/index.ts +41 -0
- package/src/cli/statusAction.ts +8 -0
- package/src/cli/watchAction.ts +8 -0
- package/src/{core → node/_core}/_defaults.ts +1 -3
- package/src/{core → node/_core}/_isRecord.ts +1 -3
- package/src/{core → node/_core}/config/_loadConfig.ts +1 -3
- package/src/node/_core/config/_resolveConfigProperty.ts +15 -0
- package/src/{core → node/_core}/config/defineConfig.ts +1 -3
- package/src/{core → node/_core}/config/index.ts +0 -0
- package/src/node/_core/config/types.ts +69 -0
- package/src/node/_core/contexts/buildContext.ts +34 -0
- package/src/node/_core/contexts/index.ts +1 -0
- package/src/{core → node/_core}/index.ts +2 -0
- package/src/node/_core/pkg/_loadPkg.ts +54 -0
- package/src/node/_core/pkg/_loadPkgWithReporting.ts +29 -0
- package/src/node/_core/pkg/_parseExports.ts +45 -0
- package/src/{core → node/_core}/pkg/_types.ts +16 -5
- package/src/{core → node/_core}/pkg/index.ts +1 -0
- package/src/{build/tasks/dts → node/_core/ts}/_loadTSConfig.ts +1 -0
- package/src/node/_core/ts/index.ts +1 -0
- package/src/node/_getFilesize.ts +8 -0
- package/src/node/_globFiles.ts +5 -0
- package/src/node/_printExtractMessages.ts +56 -0
- package/src/node/_printPackageTree.ts +72 -0
- package/src/{build/_parseWebTarget.ts → node/_resolveBrowserTarget.ts} +2 -2
- package/src/{build/_parseBrowserslistVersions.ts → node/_resolveBrowserslistVersions.ts} +1 -1
- package/src/node/_resolveBuildContext.ts +104 -0
- package/src/node/_resolveBuildTasks.ts +129 -0
- package/src/{build/_parseNodeTarget.ts → node/_resolveNodeTarget.ts} +2 -2
- package/src/node/_resolveWatchTasks.ts +129 -0
- package/src/node/_spinner.ts +26 -0
- package/src/node/_tasks/_types.ts +57 -0
- package/src/node/_tasks/dts/_DtsError.ts +11 -0
- package/src/{build/tasks → node/_tasks}/dts/_buildTypes.ts +20 -16
- package/src/node/_tasks/dts/_createApiExtractorConfig.ts +41 -0
- package/src/{build/tasks → node/_tasks}/dts/_createTSDocConfig.ts +2 -6
- package/src/node/_tasks/dts/_doExtract.ts +46 -0
- package/src/node/_tasks/dts/_dtsTask.ts +38 -0
- package/src/node/_tasks/dts/_dtsWatchTask.ts +43 -0
- package/src/node/_tasks/dts/_extractTypes.ts +161 -0
- package/src/node/_tasks/dts/_types.ts +25 -0
- package/src/node/_tasks/dts/index.ts +3 -0
- package/src/node/_tasks/index.ts +19 -0
- package/src/node/_tasks/rollup/_resolveRollupConfig.ts +132 -0
- package/src/node/_tasks/rollup/_rollupTask.ts +71 -0
- package/src/node/_tasks/rollup/_rollupWatchTask.ts +78 -0
- package/src/node/_tasks/rollup/index.ts +2 -0
- package/src/node/_watchConfigFiles.ts +52 -0
- package/src/node/_watchFiles.ts +29 -0
- package/src/node/build.ts +47 -0
- package/src/node/check.ts +14 -0
- package/src/node/index.ts +6 -0
- package/src/node/watch.ts +56 -0
- package/dist/_build-f08e1020.cjs +0 -5544
- package/dist/_build-f08e1020.cjs.map +0 -1
- package/src/build/_parseTasks.ts +0 -87
- package/src/build/_types.ts +0 -26
- package/src/build/build.ts +0 -93
- package/src/build/index.ts +0 -2
- package/src/build/tasks/_types.ts +0 -8
- package/src/build/tasks/dts/_createApiExtractorConfig.ts +0 -88
- package/src/build/tasks/dts/_extractTypes.ts +0 -100
- package/src/build/tasks/dts/dts.ts +0 -59
- package/src/build/tasks/dts/index.ts +0 -1
- package/src/build/tasks/extract/_extractTask.ts +0 -49
- package/src/build/tasks/extract/index.ts +0 -1
- package/src/build/tasks/index.ts +0 -4
- package/src/build/tasks/rollup/_resolveRollupConfig.ts +0 -95
- package/src/build/tasks/rollup/index.ts +0 -1
- package/src/build/tasks/rollup/rollup.ts +0 -96
- package/src/cli.ts +0 -25
- package/src/core/config/_resolveConfigProperty.ts +0 -14
- package/src/core/config/types.ts +0 -52
- package/src/core/pkg/_loadPkg.ts +0 -13
- package/src/core/pkg/_parseExports.ts +0 -40
- package/src/index.ts +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,152 +1,278 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
export declare type
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*/
|
|
82
|
-
export declare interface
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
1
|
+
import {ExtractorMessage} from '@microsoft/api-extractor'
|
|
2
|
+
import {Observable} from 'rxjs'
|
|
3
|
+
import {RollupWatcherEvent} from 'rollup'
|
|
4
|
+
import ts from 'typescript'
|
|
5
|
+
|
|
6
|
+
/** @public */
|
|
7
|
+
export declare function build(options: {cwd: string; tsconfig?: string}): Promise<void>
|
|
8
|
+
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare interface _BuildContext {
|
|
11
|
+
config?: PkgConfigOptions
|
|
12
|
+
cwd: string
|
|
13
|
+
dist: string
|
|
14
|
+
exports: PkgExports | undefined
|
|
15
|
+
external: string[]
|
|
16
|
+
files: _BuildFile[]
|
|
17
|
+
logger: {
|
|
18
|
+
log: (...args: unknown[]) => void
|
|
19
|
+
info: (...args: unknown[]) => void
|
|
20
|
+
warn: (...args: unknown[]) => void
|
|
21
|
+
error: (...args: unknown[]) => void
|
|
22
|
+
success: (...args: unknown[]) => void
|
|
23
|
+
}
|
|
24
|
+
pkg: _PackageJSON
|
|
25
|
+
runtime: PkgRuntime
|
|
26
|
+
src: string
|
|
27
|
+
target: Record<PkgRuntime, string[]>
|
|
28
|
+
ts: {
|
|
29
|
+
config?: ts.ParsedCommandLine
|
|
30
|
+
configPath?: string
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @internal */
|
|
35
|
+
export declare interface _BuildFile {
|
|
36
|
+
type: 'asset' | 'chunk' | 'types'
|
|
37
|
+
path: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
export declare type _BuildTask = _DtsTask | _RollupTask
|
|
42
|
+
|
|
43
|
+
/** @internal */
|
|
44
|
+
export declare interface _BuildTaskHandlers {
|
|
45
|
+
'build:dts': _TaskHandler<_DtsTask, _DtsResult>
|
|
46
|
+
'build:js': _TaskHandler<_RollupTask>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @internal */
|
|
50
|
+
export declare const _buildTaskHandlers: _BuildTaskHandlers
|
|
51
|
+
|
|
52
|
+
/** @public */
|
|
53
|
+
export declare function check(options: {cwd: string; tsconfig?: string}): Promise<void>
|
|
54
|
+
|
|
55
|
+
/** @internal */
|
|
56
|
+
export declare const _DEFAULTS: {
|
|
57
|
+
browserslist: string[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @public */
|
|
61
|
+
export declare function defineConfig(configOptions: PkgConfigOptions): PkgConfigOptions
|
|
62
|
+
|
|
63
|
+
/** @internal */
|
|
64
|
+
export declare interface _DtsResult {
|
|
65
|
+
type: 'dts'
|
|
66
|
+
messages: ExtractorMessage[]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** @internal */
|
|
70
|
+
export declare interface _DtsTask {
|
|
71
|
+
type: 'build:dts'
|
|
72
|
+
exportPath: string
|
|
73
|
+
importId: string
|
|
74
|
+
source: string
|
|
75
|
+
output: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** @internal */
|
|
79
|
+
export declare const _dtsTask: _TaskHandler<_DtsTask, _DtsResult>
|
|
80
|
+
|
|
81
|
+
/** @internal */
|
|
82
|
+
export declare interface _DtsWatchTask {
|
|
83
|
+
type: 'watch:dts'
|
|
84
|
+
exportPath: string
|
|
85
|
+
importId: string
|
|
86
|
+
source: string
|
|
87
|
+
output: string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @internal */
|
|
91
|
+
export declare const _dtsWatchTask: _TaskHandler<_DtsWatchTask, _DtsResult>
|
|
92
|
+
|
|
93
|
+
/** @internal */
|
|
94
|
+
export declare function _isRecord(value: unknown): value is Record<string, unknown>
|
|
95
|
+
|
|
96
|
+
/** @internal */
|
|
97
|
+
export declare function _loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined>
|
|
98
|
+
|
|
99
|
+
/** @internal */
|
|
100
|
+
export declare function _loadPkg(options: {cwd: string}): Promise<_PackageJSON>
|
|
101
|
+
|
|
102
|
+
/** @internal */
|
|
103
|
+
export declare function _loadPkgWithReporting(options: {cwd: string}): Promise<_PackageJSON>
|
|
104
|
+
|
|
105
|
+
/** @internal */
|
|
106
|
+
export declare function _loadTSConfig(options: {
|
|
107
|
+
cwd: string
|
|
108
|
+
tsconfigPath: string
|
|
109
|
+
}): Promise<ts.ParsedCommandLine>
|
|
110
|
+
|
|
111
|
+
/** @internal */
|
|
112
|
+
export declare interface _PackageJSON {
|
|
113
|
+
type?: 'module'
|
|
114
|
+
version: string
|
|
115
|
+
private?: boolean
|
|
116
|
+
name: string
|
|
117
|
+
bin?: Record<string, string>
|
|
118
|
+
dependencies?: Record<string, string>
|
|
119
|
+
devDependencies?: Record<string, string>
|
|
120
|
+
peerDependencies?: Record<string, string>
|
|
121
|
+
exports?: Record<
|
|
122
|
+
string,
|
|
123
|
+
{
|
|
124
|
+
source: string
|
|
125
|
+
browser?: {
|
|
126
|
+
require?: string
|
|
127
|
+
import?: string
|
|
128
|
+
}
|
|
129
|
+
require?: string
|
|
130
|
+
import?: string
|
|
131
|
+
types?: string
|
|
132
|
+
}
|
|
133
|
+
>
|
|
134
|
+
main?: string
|
|
135
|
+
browser?: Record<string, string>
|
|
136
|
+
source: string
|
|
137
|
+
module?: string
|
|
138
|
+
types?: string
|
|
139
|
+
browserslist?: string[]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @internal */
|
|
143
|
+
export declare function _parseExports(options: {pkg: _PackageJSON}): (PkgExport & {
|
|
144
|
+
_path: string
|
|
145
|
+
})[]
|
|
146
|
+
|
|
147
|
+
/** @public */
|
|
148
|
+
export declare interface PkgConfigOptions {
|
|
149
|
+
/**
|
|
150
|
+
* Directory of distributed & bundled files.
|
|
151
|
+
*/
|
|
152
|
+
dist?: string
|
|
153
|
+
exports?: PkgConfigProperty<PkgExports>
|
|
154
|
+
extract?: {
|
|
155
|
+
rules?: {
|
|
156
|
+
'ae-forgotten-export'?: PkgRuleLevel
|
|
157
|
+
'ae-incompatible-release-tags'?: PkgRuleLevel
|
|
158
|
+
'ae-internal-missing-underscore'?: PkgRuleLevel
|
|
159
|
+
'ae-missing-release-tag'?: PkgRuleLevel
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Packages to exclude from the bundles.
|
|
164
|
+
*/
|
|
165
|
+
external?: PkgConfigProperty<string[]>
|
|
166
|
+
minify?: boolean
|
|
167
|
+
/**
|
|
168
|
+
* Default runtime of package exports
|
|
169
|
+
*/
|
|
170
|
+
runtime?: PkgRuntime
|
|
171
|
+
sourcemap?: boolean
|
|
172
|
+
/**
|
|
173
|
+
* Directory of source files.
|
|
174
|
+
*/
|
|
175
|
+
src?: string
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** @public */
|
|
179
|
+
export declare type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T
|
|
180
|
+
|
|
181
|
+
/** @public */
|
|
182
|
+
export declare type PkgConfigPropertyResolver<T> = (prev: T) => T
|
|
183
|
+
|
|
184
|
+
/** @public */
|
|
185
|
+
export declare interface PkgExport {
|
|
186
|
+
/** @internal */
|
|
187
|
+
_exported?: boolean
|
|
188
|
+
browser?: {
|
|
189
|
+
source?: string
|
|
190
|
+
import?: string
|
|
191
|
+
require?: string
|
|
192
|
+
}
|
|
193
|
+
import?: string
|
|
194
|
+
require?: string
|
|
195
|
+
source: string
|
|
196
|
+
types?: string
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** @public */
|
|
200
|
+
export declare interface PkgExports {
|
|
201
|
+
[path: string]: PkgExport
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** @public */
|
|
205
|
+
export declare type PkgFormat = 'commonjs' | 'esm'
|
|
206
|
+
|
|
207
|
+
/** @public */
|
|
208
|
+
export declare type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'
|
|
209
|
+
|
|
210
|
+
/** @public */
|
|
211
|
+
export declare type PkgRuntime = '*' | 'browser' | 'node'
|
|
212
|
+
|
|
213
|
+
/** @internal */
|
|
214
|
+
export declare function _resolveBuildTasks(ctx: _BuildContext): _BuildTask[]
|
|
215
|
+
|
|
216
|
+
/** @internal */
|
|
217
|
+
export declare function _resolveConfigProperty<T>(
|
|
218
|
+
prop: PkgConfigProperty<T> | undefined,
|
|
219
|
+
initialValue: T
|
|
220
|
+
): T
|
|
221
|
+
|
|
222
|
+
/** @internal */
|
|
223
|
+
export declare interface _RollupTask {
|
|
224
|
+
type: 'build:js'
|
|
225
|
+
buildId: string
|
|
226
|
+
entries: _RollupTaskEntry[]
|
|
227
|
+
runtime: PkgRuntime
|
|
228
|
+
format: 'commonjs' | 'esm'
|
|
229
|
+
target: string[]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** @internal */
|
|
233
|
+
export declare const _rollupTask: _TaskHandler<_RollupTask>
|
|
234
|
+
|
|
235
|
+
/** @internal */
|
|
236
|
+
export declare interface _RollupTaskEntry {
|
|
237
|
+
path: string
|
|
238
|
+
source: string
|
|
239
|
+
output: string
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** @internal */
|
|
243
|
+
export declare interface _RollupWatchTask {
|
|
244
|
+
type: 'watch:js'
|
|
245
|
+
buildId: string
|
|
246
|
+
entries: _RollupTaskEntry[]
|
|
247
|
+
runtime: PkgRuntime
|
|
248
|
+
format: 'commonjs' | 'esm'
|
|
249
|
+
target: string[]
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** @internal */
|
|
253
|
+
export declare const _rollupWatchTask: _TaskHandler<_RollupWatchTask, RollupWatcherEvent>
|
|
254
|
+
|
|
255
|
+
/** @internal */
|
|
256
|
+
export declare type _TaskHandler<Task, Result = void> = {
|
|
257
|
+
name: (ctx: _BuildContext, task: Task) => string
|
|
258
|
+
exec: (ctx: _BuildContext, task: Task) => Observable<Result>
|
|
259
|
+
complete: (ctx: _BuildContext, task: Task, result: Result) => void
|
|
260
|
+
error: (ctx: _BuildContext, task: Task, error: unknown) => void
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** @public */
|
|
264
|
+
export declare function watch(options: {cwd: string; tsconfig?: string}): Promise<void>
|
|
265
|
+
|
|
266
|
+
/** @internal */
|
|
267
|
+
export declare type _WatchTask = _DtsWatchTask | _RollupWatchTask
|
|
268
|
+
|
|
269
|
+
/** @internal */
|
|
270
|
+
export declare interface _WatchTaskHandlers {
|
|
271
|
+
'watch:dts': _TaskHandler<_DtsWatchTask, _DtsResult>
|
|
272
|
+
'watch:js': _TaskHandler<_RollupWatchTask, RollupWatcherEvent>
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** @internal */
|
|
276
|
+
export declare const _watchTaskHandlers: _WatchTaskHandlers
|
|
277
|
+
|
|
278
|
+
export {}
|