@sanity/pkg-utils 7.2.8 → 7.2.9-canary.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/dist/index.d.cts CHANGED
@@ -1,10 +1,8 @@
1
1
  import type {PluginItem} from '@babel/core'
2
- import type {ExtractorMessage, IExtractorMessagesConfig} from '@microsoft/api-extractor'
2
+ import type {IExtractorMessagesConfig} from '@microsoft/api-extractor'
3
3
  import type {OptimizeLodashOptions} from '@optimize-lodash/rollup-plugin'
4
4
  import type {NormalizedOutputOptions, TreeshakingOptions} from 'rollup'
5
- import {Plugin as RollupPlugin, RollupWatcherEvent} from 'rollup'
6
- import type {Observable} from 'rxjs'
7
- import ts from 'typescript'
5
+ import {Plugin as RollupPlugin} from 'rollup'
8
6
  import {z} from 'zod'
9
7
 
10
8
  /**
@@ -34,45 +32,6 @@ export declare function build(options: {
34
32
  clean?: boolean
35
33
  }): Promise<void>
36
34
 
37
- /** @internal */
38
- export declare interface BuildContext {
39
- config?: PkgConfigOptions
40
- cwd: string
41
- distPath: string
42
- emitDeclarationOnly: boolean
43
- exports: PkgExports | undefined
44
- external: string[]
45
- bundledPackages: string[]
46
- files: BuildFile[]
47
- logger: Logger
48
- pkg: PackageJSON
49
- runtime: PkgRuntime
50
- strict: boolean
51
- target: Record<PkgRuntime, string[]>
52
- ts: {
53
- config?: ts.ParsedCommandLine
54
- configPath?: string
55
- }
56
- }
57
-
58
- /** @internal */
59
- export declare interface BuildFile {
60
- type: 'asset' | 'chunk' | 'types'
61
- path: string
62
- }
63
-
64
- /** @internal */
65
- export declare type BuildTask = DtsTask | RollupTask
66
-
67
- /** @internal */
68
- export declare interface BuildTaskHandlers {
69
- 'build:dts': TaskHandler<DtsTask, DtsResult>
70
- 'build:js': TaskHandler<RollupTask>
71
- }
72
-
73
- /** @internal */
74
- export declare const buildTaskHandlers: BuildTaskHandlers
75
-
76
35
  /** @public */
77
36
  export declare function check(options: {
78
37
  cwd: string
@@ -80,15 +39,7 @@ export declare function check(options: {
80
39
  tsconfig?: string
81
40
  }): Promise<void>
82
41
 
83
- /** @internal */
84
- export declare function createFromTemplate(options: {
85
- cwd: string
86
- logger: Logger
87
- packagePath: string
88
- template: PkgTemplate
89
- }): Promise<void>
90
-
91
- /** @internal */
42
+ /** @alpha */
92
43
  export declare function createLogger(): Logger
93
44
 
94
45
  /** @public */
@@ -100,45 +51,7 @@ export declare function defineConfig<const T extends PkgConfigOptions>(configOpt
100
51
  /** @public */
101
52
  export declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>
102
53
 
103
- /** @internal */
104
- export declare interface DtsResult {
105
- type: 'dts'
106
- messages: ExtractorMessage[]
107
- results: {
108
- sourcePath: string
109
- filePaths: string[]
110
- }[]
111
- }
112
-
113
- /** @internal */
114
- export declare interface DtsTask {
115
- type: 'build:dts'
116
- entries: {
117
- exportPath: string
118
- importId: string
119
- sourcePath: string
120
- targetPaths: string[]
121
- }[]
122
- }
123
-
124
- /** @internal */
125
- export declare const dtsTask: TaskHandler<DtsTask, DtsResult>
126
-
127
- /** @internal */
128
- export declare interface DtsWatchTask {
129
- type: 'watch:dts'
130
- entries: {
131
- exportPath: string
132
- importId: string
133
- sourcePath: string
134
- targetPaths: string[]
135
- }[]
136
- }
137
-
138
- /** @internal */
139
- export declare const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult>
140
-
141
- /** @internal */
54
+ /** @alpha */
142
55
  export declare function getExtractMessagesConfig(options: {
143
56
  rules: NonNullable<PkgConfigOptions['extract']>['rules']
144
57
  }): IExtractorMessagesConfig
@@ -151,30 +64,21 @@ export declare type InferredStrictOptions = z.infer<typeof strictOptions>
151
64
  /** @public */
152
65
  export declare function init(options: {cwd: string; path: string}): Promise<void>
153
66
 
154
- /** @internal */
155
- export declare function isRecord(value: unknown): value is Record<string, unknown>
156
-
157
- /** @internal */
67
+ /** @alpha */
158
68
  export declare function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined>
159
69
 
160
70
  /** @internal */
161
71
  export declare function loadPkg(options: {cwd: string}): Promise<PackageJSON>
162
72
 
163
- /** @internal */
73
+ /** @alpha */
164
74
  export declare function loadPkgWithReporting(options: {
165
75
  cwd: string
166
76
  logger: Logger
167
77
  strict: boolean
168
78
  }): Promise<PackageJSON>
169
79
 
170
- /** @internal */
171
- export declare function loadTSConfig(options: {
172
- cwd: string
173
- tsconfigPath: string
174
- }): Promise<ts.ParsedCommandLine | undefined>
175
-
176
- /** @internal */
177
- export declare interface Logger {
80
+ /** @alpha */
81
+ declare interface Logger {
178
82
  log: (...args: unknown[]) => void
179
83
  info: (...args: unknown[]) => void
180
84
  warn: (...args: unknown[]) => void
@@ -182,7 +86,7 @@ export declare interface Logger {
182
86
  success: (...args: unknown[]) => void
183
87
  }
184
88
 
185
- /** @internal */
89
+ /** @alpha */
186
90
  export declare interface PackageJSON {
187
91
  type?: 'commonjs' | 'module'
188
92
  version: string
@@ -259,7 +163,7 @@ export declare interface PackageJSON {
259
163
  license?: string
260
164
  }
261
165
 
262
- /** @internal */
166
+ /** @alpha */
263
167
  export declare function parseExports(options: {
264
168
  cwd: string
265
169
  pkg: PackageJSON
@@ -270,7 +174,7 @@ export declare function parseExports(options: {
270
174
  _path: string
271
175
  })[]
272
176
 
273
- /** @internal */
177
+ /** @alpha */
274
178
  export declare function parseStrictOptions(input: unknown): InferredStrictOptions
275
179
 
276
180
  /** @public */
@@ -455,30 +359,6 @@ export declare interface PkgExports {
455
359
  [path: string]: PkgExport
456
360
  }
457
361
 
458
- /** @internal */
459
- export declare interface PkgExtMap {
460
- commonjs: {
461
- commonjs: string
462
- esm: string
463
- }
464
- module: {
465
- commonjs: string
466
- esm: string
467
- }
468
- }
469
-
470
- /** @internal */
471
- export declare const pkgExtMap: {
472
- commonjs: {
473
- commonjs: '.js'
474
- esm: '.mjs'
475
- }
476
- module: {
477
- commonjs: '.cjs'
478
- esm: '.js'
479
- }
480
- }
481
-
482
362
  /** @public */
483
363
  export declare type PkgFormat = 'commonjs' | 'esm'
484
364
 
@@ -609,50 +489,8 @@ export declare interface ReactCompilerOptions {
609
489
  target: '17' | '18' | '19'
610
490
  }
611
491
 
612
- /** @internal */
613
- export declare function resolveBuildTasks(ctx: BuildContext): BuildTask[]
614
-
615
- /** @internal */
616
- export declare function resolveConfigProperty<T>(
617
- prop: PkgConfigProperty<T> | undefined,
618
- initialValue: T,
619
- ): T
620
-
621
492
  export {RollupPlugin}
622
493
 
623
- /** @internal */
624
- export declare interface RollupTask {
625
- type: 'build:js'
626
- buildId: string
627
- entries: RollupTaskEntry[]
628
- runtime: PkgRuntime
629
- format: 'commonjs' | 'esm'
630
- target: string[]
631
- }
632
-
633
- /** @internal */
634
- export declare const rollupTask: TaskHandler<RollupTask>
635
-
636
- /** @internal */
637
- export declare interface RollupTaskEntry {
638
- path: string
639
- source: string
640
- output: string
641
- }
642
-
643
- /** @internal */
644
- export declare interface RollupWatchTask {
645
- type: 'watch:js'
646
- buildId: string
647
- entries: RollupTaskEntry[]
648
- runtime: PkgRuntime
649
- format: 'commonjs' | 'esm'
650
- target: string[]
651
- }
652
-
653
- /** @internal */
654
- export declare const rollupWatchTask: TaskHandler<RollupWatchTask, RollupWatcherEvent>
655
-
656
494
  /**
657
495
  * @public
658
496
  */
@@ -737,14 +575,6 @@ export declare const strictOptions: z.ZodObject<
737
575
  }
738
576
  >
739
577
 
740
- /** @internal */
741
- export declare type TaskHandler<Task, Result = void> = {
742
- name: (ctx: BuildContext, task: Task) => string
743
- exec: (ctx: BuildContext, task: Task) => Observable<Result>
744
- complete: (ctx: BuildContext, task: Task, result: Result) => void
745
- error: (ctx: BuildContext, task: Task, error: unknown) => void
746
- }
747
-
748
578
  /**
749
579
  * @public
750
580
  */
@@ -771,16 +601,4 @@ export declare function watch(options: {
771
601
  tsconfig?: string
772
602
  }): Promise<void>
773
603
 
774
- /** @internal */
775
- export declare type WatchTask = DtsWatchTask | RollupWatchTask
776
-
777
- /** @internal */
778
- export declare interface WatchTaskHandlers {
779
- 'watch:dts': TaskHandler<DtsWatchTask, DtsResult>
780
- 'watch:js': TaskHandler<RollupWatchTask, RollupWatcherEvent>
781
- }
782
-
783
- /** @internal */
784
- export declare const watchTaskHandlers: WatchTaskHandlers
785
-
786
604
  export {}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import type {PluginItem} from '@babel/core'
2
- import type {ExtractorMessage, IExtractorMessagesConfig} from '@microsoft/api-extractor'
2
+ import type {IExtractorMessagesConfig} from '@microsoft/api-extractor'
3
3
  import type {OptimizeLodashOptions} from '@optimize-lodash/rollup-plugin'
4
4
  import type {NormalizedOutputOptions, TreeshakingOptions} from 'rollup'
5
- import {Plugin as RollupPlugin, RollupWatcherEvent} from 'rollup'
6
- import type {Observable} from 'rxjs'
7
- import ts from 'typescript'
5
+ import {Plugin as RollupPlugin} from 'rollup'
8
6
  import {z} from 'zod'
9
7
 
10
8
  /**
@@ -34,45 +32,6 @@ export declare function build(options: {
34
32
  clean?: boolean
35
33
  }): Promise<void>
36
34
 
37
- /** @internal */
38
- export declare interface BuildContext {
39
- config?: PkgConfigOptions
40
- cwd: string
41
- distPath: string
42
- emitDeclarationOnly: boolean
43
- exports: PkgExports | undefined
44
- external: string[]
45
- bundledPackages: string[]
46
- files: BuildFile[]
47
- logger: Logger
48
- pkg: PackageJSON
49
- runtime: PkgRuntime
50
- strict: boolean
51
- target: Record<PkgRuntime, string[]>
52
- ts: {
53
- config?: ts.ParsedCommandLine
54
- configPath?: string
55
- }
56
- }
57
-
58
- /** @internal */
59
- export declare interface BuildFile {
60
- type: 'asset' | 'chunk' | 'types'
61
- path: string
62
- }
63
-
64
- /** @internal */
65
- export declare type BuildTask = DtsTask | RollupTask
66
-
67
- /** @internal */
68
- export declare interface BuildTaskHandlers {
69
- 'build:dts': TaskHandler<DtsTask, DtsResult>
70
- 'build:js': TaskHandler<RollupTask>
71
- }
72
-
73
- /** @internal */
74
- export declare const buildTaskHandlers: BuildTaskHandlers
75
-
76
35
  /** @public */
77
36
  export declare function check(options: {
78
37
  cwd: string
@@ -80,15 +39,7 @@ export declare function check(options: {
80
39
  tsconfig?: string
81
40
  }): Promise<void>
82
41
 
83
- /** @internal */
84
- export declare function createFromTemplate(options: {
85
- cwd: string
86
- logger: Logger
87
- packagePath: string
88
- template: PkgTemplate
89
- }): Promise<void>
90
-
91
- /** @internal */
42
+ /** @alpha */
92
43
  export declare function createLogger(): Logger
93
44
 
94
45
  /** @public */
@@ -100,45 +51,7 @@ export declare function defineConfig<const T extends PkgConfigOptions>(configOpt
100
51
  /** @public */
101
52
  export declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>
102
53
 
103
- /** @internal */
104
- export declare interface DtsResult {
105
- type: 'dts'
106
- messages: ExtractorMessage[]
107
- results: {
108
- sourcePath: string
109
- filePaths: string[]
110
- }[]
111
- }
112
-
113
- /** @internal */
114
- export declare interface DtsTask {
115
- type: 'build:dts'
116
- entries: {
117
- exportPath: string
118
- importId: string
119
- sourcePath: string
120
- targetPaths: string[]
121
- }[]
122
- }
123
-
124
- /** @internal */
125
- export declare const dtsTask: TaskHandler<DtsTask, DtsResult>
126
-
127
- /** @internal */
128
- export declare interface DtsWatchTask {
129
- type: 'watch:dts'
130
- entries: {
131
- exportPath: string
132
- importId: string
133
- sourcePath: string
134
- targetPaths: string[]
135
- }[]
136
- }
137
-
138
- /** @internal */
139
- export declare const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult>
140
-
141
- /** @internal */
54
+ /** @alpha */
142
55
  export declare function getExtractMessagesConfig(options: {
143
56
  rules: NonNullable<PkgConfigOptions['extract']>['rules']
144
57
  }): IExtractorMessagesConfig
@@ -151,30 +64,21 @@ export declare type InferredStrictOptions = z.infer<typeof strictOptions>
151
64
  /** @public */
152
65
  export declare function init(options: {cwd: string; path: string}): Promise<void>
153
66
 
154
- /** @internal */
155
- export declare function isRecord(value: unknown): value is Record<string, unknown>
156
-
157
- /** @internal */
67
+ /** @alpha */
158
68
  export declare function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined>
159
69
 
160
70
  /** @internal */
161
71
  export declare function loadPkg(options: {cwd: string}): Promise<PackageJSON>
162
72
 
163
- /** @internal */
73
+ /** @alpha */
164
74
  export declare function loadPkgWithReporting(options: {
165
75
  cwd: string
166
76
  logger: Logger
167
77
  strict: boolean
168
78
  }): Promise<PackageJSON>
169
79
 
170
- /** @internal */
171
- export declare function loadTSConfig(options: {
172
- cwd: string
173
- tsconfigPath: string
174
- }): Promise<ts.ParsedCommandLine | undefined>
175
-
176
- /** @internal */
177
- export declare interface Logger {
80
+ /** @alpha */
81
+ declare interface Logger {
178
82
  log: (...args: unknown[]) => void
179
83
  info: (...args: unknown[]) => void
180
84
  warn: (...args: unknown[]) => void
@@ -182,7 +86,7 @@ export declare interface Logger {
182
86
  success: (...args: unknown[]) => void
183
87
  }
184
88
 
185
- /** @internal */
89
+ /** @alpha */
186
90
  export declare interface PackageJSON {
187
91
  type?: 'commonjs' | 'module'
188
92
  version: string
@@ -259,7 +163,7 @@ export declare interface PackageJSON {
259
163
  license?: string
260
164
  }
261
165
 
262
- /** @internal */
166
+ /** @alpha */
263
167
  export declare function parseExports(options: {
264
168
  cwd: string
265
169
  pkg: PackageJSON
@@ -270,7 +174,7 @@ export declare function parseExports(options: {
270
174
  _path: string
271
175
  })[]
272
176
 
273
- /** @internal */
177
+ /** @alpha */
274
178
  export declare function parseStrictOptions(input: unknown): InferredStrictOptions
275
179
 
276
180
  /** @public */
@@ -455,30 +359,6 @@ export declare interface PkgExports {
455
359
  [path: string]: PkgExport
456
360
  }
457
361
 
458
- /** @internal */
459
- export declare interface PkgExtMap {
460
- commonjs: {
461
- commonjs: string
462
- esm: string
463
- }
464
- module: {
465
- commonjs: string
466
- esm: string
467
- }
468
- }
469
-
470
- /** @internal */
471
- export declare const pkgExtMap: {
472
- commonjs: {
473
- commonjs: '.js'
474
- esm: '.mjs'
475
- }
476
- module: {
477
- commonjs: '.cjs'
478
- esm: '.js'
479
- }
480
- }
481
-
482
362
  /** @public */
483
363
  export declare type PkgFormat = 'commonjs' | 'esm'
484
364
 
@@ -609,50 +489,8 @@ export declare interface ReactCompilerOptions {
609
489
  target: '17' | '18' | '19'
610
490
  }
611
491
 
612
- /** @internal */
613
- export declare function resolveBuildTasks(ctx: BuildContext): BuildTask[]
614
-
615
- /** @internal */
616
- export declare function resolveConfigProperty<T>(
617
- prop: PkgConfigProperty<T> | undefined,
618
- initialValue: T,
619
- ): T
620
-
621
492
  export {RollupPlugin}
622
493
 
623
- /** @internal */
624
- export declare interface RollupTask {
625
- type: 'build:js'
626
- buildId: string
627
- entries: RollupTaskEntry[]
628
- runtime: PkgRuntime
629
- format: 'commonjs' | 'esm'
630
- target: string[]
631
- }
632
-
633
- /** @internal */
634
- export declare const rollupTask: TaskHandler<RollupTask>
635
-
636
- /** @internal */
637
- export declare interface RollupTaskEntry {
638
- path: string
639
- source: string
640
- output: string
641
- }
642
-
643
- /** @internal */
644
- export declare interface RollupWatchTask {
645
- type: 'watch:js'
646
- buildId: string
647
- entries: RollupTaskEntry[]
648
- runtime: PkgRuntime
649
- format: 'commonjs' | 'esm'
650
- target: string[]
651
- }
652
-
653
- /** @internal */
654
- export declare const rollupWatchTask: TaskHandler<RollupWatchTask, RollupWatcherEvent>
655
-
656
494
  /**
657
495
  * @public
658
496
  */
@@ -737,14 +575,6 @@ export declare const strictOptions: z.ZodObject<
737
575
  }
738
576
  >
739
577
 
740
- /** @internal */
741
- export declare type TaskHandler<Task, Result = void> = {
742
- name: (ctx: BuildContext, task: Task) => string
743
- exec: (ctx: BuildContext, task: Task) => Observable<Result>
744
- complete: (ctx: BuildContext, task: Task, result: Result) => void
745
- error: (ctx: BuildContext, task: Task, error: unknown) => void
746
- }
747
-
748
578
  /**
749
579
  * @public
750
580
  */
@@ -771,16 +601,4 @@ export declare function watch(options: {
771
601
  tsconfig?: string
772
602
  }): Promise<void>
773
603
 
774
- /** @internal */
775
- export declare type WatchTask = DtsWatchTask | RollupWatchTask
776
-
777
- /** @internal */
778
- export declare interface WatchTaskHandlers {
779
- 'watch:dts': TaskHandler<DtsWatchTask, DtsResult>
780
- 'watch:js': TaskHandler<RollupWatchTask, RollupWatcherEvent>
781
- }
782
-
783
- /** @internal */
784
- export declare const watchTaskHandlers: WatchTaskHandlers
785
-
786
604
  export {}
package/dist/index.js CHANGED
@@ -1548,6 +1548,9 @@ function isEsbuildMessage(msg) {
1548
1548
  function defineConfig(configOptions) {
1549
1549
  return configOptions;
1550
1550
  }
1551
+ function defineTemplateOption(option) {
1552
+ return option;
1553
+ }
1551
1554
  const promptsTypes = {
1552
1555
  string: "text"
1553
1556
  };
@@ -1589,9 +1592,6 @@ async function createFromTemplate(options) {
1589
1592
  `), logger.success(`wrote ${relative(cwd, filePath)}`);
1590
1593
  }
1591
1594
  }
1592
- function defineTemplateOption(option) {
1593
- return option;
1594
- }
1595
1595
  async function isEmptyDirectory(dirPath) {
1596
1596
  return (await readdir(dirPath)).length === 0;
1597
1597
  }
@@ -2193,31 +2193,19 @@ async function watch(options) {
2193
2193
  export {
2194
2194
  DEFAULT_BROWSERSLIST_QUERY,
2195
2195
  build,
2196
- buildTaskHandlers,
2197
2196
  check,
2198
- createFromTemplate,
2199
2197
  createLogger,
2200
2198
  defineConfig,
2201
2199
  defineTemplateOption,
2202
- dtsTask,
2203
- dtsWatchTask,
2204
2200
  getExtractMessagesConfig,
2205
2201
  init,
2206
- isRecord,
2207
2202
  loadConfig,
2208
2203
  loadPkg,
2209
2204
  loadPkgWithReporting,
2210
- loadTSConfig,
2211
2205
  parseExports,
2212
2206
  parseStrictOptions,
2213
- pkgExtMap,
2214
- resolveBuildTasks,
2215
- resolveConfigProperty,
2216
- rollupTask,
2217
- rollupWatchTask,
2218
2207
  strictOptions,
2219
2208
  toggle,
2220
- watch,
2221
- watchTaskHandlers
2209
+ watch
2222
2210
  };
2223
2211
  //# sourceMappingURL=index.js.map