@sanity/pkg-utils 1.7.2 → 1.7.3
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/{__resolveBuildContext-9b0aa9f9.cjs → __resolveBuildContext-56b6b816.cjs} +2 -2
- package/dist/__resolveBuildContext-56b6b816.cjs.map +1 -0
- package/dist/{_build-6e7deb31.cjs → _build-49dd667f.cjs} +20 -17
- package/dist/_build-49dd667f.cjs.map +1 -0
- package/dist/{_buildAction-d8841b41.cjs → _buildAction-b58e3a4b.cjs} +4 -8
- package/dist/{_buildAction-d8841b41.cjs.map → _buildAction-b58e3a4b.cjs.map} +1 -1
- package/dist/{_check-04a1f749.cjs → _check-0871d90f.cjs} +2 -2
- package/dist/{_check-04a1f749.cjs.map → _check-0871d90f.cjs.map} +1 -1
- package/dist/{_checkAction-09426a13.cjs → _checkAction-0510605b.cjs} +3 -3
- package/dist/{_checkAction-09426a13.cjs.map → _checkAction-0510605b.cjs.map} +1 -1
- package/dist/{_index-46cab21c.cjs → _index-e3dda92a.cjs} +53 -56
- package/dist/_index-e3dda92a.cjs.map +1 -0
- package/dist/{_watch-cf9c717f.cjs → _watch-e1c86797.cjs} +21 -18
- package/dist/_watch-e1c86797.cjs.map +1 -0
- package/dist/{_watchAction-5941527f.cjs → _watchAction-cfe36cbc.cjs} +4 -8
- package/dist/{_watchAction-5941527f.cjs.map → _watchAction-cfe36cbc.cjs.map} +1 -1
- package/dist/cli.cjs +4 -4
- package/dist/index.cjs +5 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +87 -80
- package/dist/index.js.map +1 -1
- package/dist/types/src/cli/buildAction.d.ts +4 -0
- package/dist/types/src/cli/buildAction.d.ts.map +1 -0
- package/dist/types/src/cli/checkAction.d.ts +5 -0
- package/dist/types/src/cli/checkAction.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/watchAction.d.ts +4 -0
- package/dist/types/src/cli/watchAction.d.ts.map +1 -0
- package/dist/types/src/node/_core/_defaults.d.ts +5 -0
- package/dist/types/src/node/_core/_defaults.d.ts.map +1 -0
- package/dist/types/src/node/_core/_isRecord.d.ts +3 -0
- package/dist/types/src/node/_core/_isRecord.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/_loadConfig.d.ts +6 -0
- package/dist/types/src/node/_core/config/_loadConfig.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/_resolveConfigProperty.d.ts +4 -0
- package/dist/types/src/node/_core/config/_resolveConfigProperty.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/defineConfig.d.ts +4 -0
- package/dist/types/src/node/_core/config/defineConfig.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/index.d.ts +5 -0
- package/dist/types/src/node/_core/config/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/types.d.ts +76 -0
- package/dist/types/src/node/_core/config/types.d.ts.map +1 -0
- package/dist/types/src/node/_core/contexts/buildContext.d.ts +33 -0
- package/dist/types/src/node/_core/contexts/buildContext.d.ts.map +1 -0
- package/dist/types/src/node/_core/contexts/index.d.ts +2 -0
- package/dist/types/src/node/_core/contexts/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/index.d.ts +7 -0
- package/dist/types/src/node/_core/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_loadPkg.d.ts +6 -0
- package/dist/types/src/node/_core/pkg/_loadPkg.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_loadPkgWithReporting.d.ts +6 -0
- package/dist/types/src/node/_core/pkg/_loadPkgWithReporting.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_parseExports.d.ts +9 -0
- package/dist/types/src/node/_core/pkg/_parseExports.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_types.d.ts +29 -0
- package/dist/types/src/node/_core/pkg/_types.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/index.d.ts +5 -0
- package/dist/types/src/node/_core/pkg/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/ts/_loadTSConfig.d.ts +7 -0
- package/dist/types/src/node/_core/ts/_loadTSConfig.d.ts.map +1 -0
- package/dist/types/src/node/_core/ts/index.d.ts +2 -0
- package/dist/types/src/node/_core/ts/index.d.ts.map +1 -0
- package/dist/types/src/node/_getFilesize.d.ts +2 -0
- package/dist/types/src/node/_getFilesize.d.ts.map +1 -0
- package/dist/types/src/node/_globFiles.d.ts +2 -0
- package/dist/types/src/node/_globFiles.d.ts.map +1 -0
- package/dist/types/src/node/_printExtractMessages.d.ts +4 -0
- package/dist/types/src/node/_printExtractMessages.d.ts.map +1 -0
- package/dist/types/src/node/_printPackageTree.d.ts +4 -0
- package/dist/types/src/node/_printPackageTree.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBrowserTarget.d.ts +3 -0
- package/dist/types/src/node/_resolveBrowserTarget.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBrowserslistVersions.d.ts +11 -0
- package/dist/types/src/node/_resolveBrowserslistVersions.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBuildContext.d.ts +8 -0
- package/dist/types/src/node/_resolveBuildContext.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBuildTasks.d.ts +5 -0
- package/dist/types/src/node/_resolveBuildTasks.d.ts.map +1 -0
- package/dist/types/src/node/_resolveNodeTarget.d.ts +3 -0
- package/dist/types/src/node/_resolveNodeTarget.d.ts.map +1 -0
- package/dist/types/src/node/_resolveWatchTasks.d.ts +5 -0
- package/dist/types/src/node/_resolveWatchTasks.d.ts.map +1 -0
- package/dist/types/src/node/_spinner.d.ts +5 -0
- package/dist/types/src/node/_spinner.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/_types.d.ts +50 -0
- package/dist/types/src/node/_tasks/_types.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_DtsError.d.ts +7 -0
- package/dist/types/src/node/_tasks/dts/_DtsError.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_buildTypes.d.ts +9 -0
- package/dist/types/src/node/_tasks/dts/_buildTypes.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_createApiExtractorConfig.d.ts +11 -0
- package/dist/types/src/node/_tasks/dts/_createApiExtractorConfig.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_createTSDocConfig.d.ts +12 -0
- package/dist/types/src/node/_tasks/dts/_createTSDocConfig.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_doExtract.d.ts +4 -0
- package/dist/types/src/node/_tasks/dts/_doExtract.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_dtsTask.d.ts +5 -0
- package/dist/types/src/node/_tasks/dts/_dtsTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_dtsWatchTask.d.ts +5 -0
- package/dist/types/src/node/_tasks/dts/_dtsWatchTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_extractTypes.d.ts +17 -0
- package/dist/types/src/node/_tasks/dts/_extractTypes.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_types.d.ts +27 -0
- package/dist/types/src/node/_tasks/dts/_types.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/index.d.ts +4 -0
- package/dist/types/src/node/_tasks/dts/index.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/index.d.ts +9 -0
- package/dist/types/src/node/_tasks/index.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/_resolveRollupConfig.d.ts +10 -0
- package/dist/types/src/node/_tasks/rollup/_resolveRollupConfig.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/_rollupTask.d.ts +4 -0
- package/dist/types/src/node/_tasks/rollup/_rollupTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/_rollupWatchTask.d.ts +5 -0
- package/dist/types/src/node/_tasks/rollup/_rollupWatchTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/index.d.ts +3 -0
- package/dist/types/src/node/_tasks/rollup/index.d.ts.map +1 -0
- package/dist/types/src/node/_watchConfigFiles.d.ts +5 -0
- package/dist/types/src/node/_watchConfigFiles.d.ts.map +1 -0
- package/dist/types/src/node/_watchFiles.d.ts +7 -0
- package/dist/types/src/node/_watchFiles.d.ts.map +1 -0
- package/dist/types/src/node/build.d.ts +6 -0
- package/dist/types/src/node/build.d.ts.map +1 -0
- package/dist/types/src/node/check.d.ts +7 -0
- package/dist/types/src/node/check.d.ts.map +1 -0
- package/dist/{index.d.ts → types/src/node/index.d.ts} +12 -8
- package/dist/types/src/node/index.d.ts.map +1 -0
- package/dist/types/src/node/watch.d.ts +6 -0
- package/dist/types/src/node/watch.d.ts.map +1 -0
- package/package.json +7 -6
- package/src/node/_core/pkg/_loadPkgWithReporting.ts +1 -1
- package/src/node/_resolveBuildTasks.ts +18 -14
- package/src/node/_resolveWatchTasks.ts +19 -15
- package/src/node/_tasks/dts/_buildTypes.ts +2 -25
- package/src/node/_tasks/dts/_doExtract.ts +32 -31
- package/src/node/_tasks/dts/_dtsTask.ts +4 -1
- package/src/node/_tasks/dts/_dtsWatchTask.ts +4 -1
- package/src/node/_tasks/dts/_types.ts +12 -8
- package/src/node/_tasks/rollup/_resolveRollupConfig.ts +30 -3
- package/dist/__resolveBuildContext-9b0aa9f9.cjs.map +0 -1
- package/dist/_build-6e7deb31.cjs.map +0 -1
- package/dist/_index-46cab21c.cjs.map +0 -1
- package/dist/_watch-cf9c717f.cjs.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExtractorMessage, ExtractorResult } from '@microsoft/api-extractor';
|
|
2
|
+
import { PkgConfigOptions, _BuildFile } from '../../_core';
|
|
3
|
+
export declare function _extractTypes(options: {
|
|
4
|
+
cwd: string;
|
|
5
|
+
distPath: string;
|
|
6
|
+
exportPath: string;
|
|
7
|
+
filePath: string;
|
|
8
|
+
files: _BuildFile[];
|
|
9
|
+
projectPath: string;
|
|
10
|
+
rules?: NonNullable<PkgConfigOptions['extract']>['rules'];
|
|
11
|
+
sourcePath: string;
|
|
12
|
+
tsconfigPath: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
extractorResult: ExtractorResult;
|
|
15
|
+
messages: ExtractorMessage[];
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=_extractTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_extractTypes.d.ts","sourceRoot":"","sources":["../../../../../../src/node/_tasks/dts/_extractTypes.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,gBAAgB,EAChB,eAAe,EAEhB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAe,gBAAgB,EAAE,UAAU,EAAC,MAAM,aAAa,CAAA;AAWtE,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IACzD,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC;IAAC,eAAe,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAAC,CAAC,CAkI5E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ExtractorMessage } from '@microsoft/api-extractor';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export interface _DtsWatchTask {
|
|
4
|
+
type: 'watch:dts';
|
|
5
|
+
entries: {
|
|
6
|
+
exportPath: string;
|
|
7
|
+
importId: string;
|
|
8
|
+
sourcePath: string;
|
|
9
|
+
targetPath: string;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
/** @internal */
|
|
13
|
+
export interface _DtsTask {
|
|
14
|
+
type: 'build:dts';
|
|
15
|
+
entries: {
|
|
16
|
+
exportPath: string;
|
|
17
|
+
importId: string;
|
|
18
|
+
sourcePath: string;
|
|
19
|
+
targetPath: string;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
export interface _DtsResult {
|
|
24
|
+
type: 'dts';
|
|
25
|
+
messages: ExtractorMessage[];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/node/_tasks/dts/_types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAA;AAEzD,gBAAgB;AAChB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAA;IACjB,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;KACnB,EAAE,CAAA;CACJ;AAED,gBAAgB;AAChB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;KACnB,EAAE,CAAA;CACJ;AAED,gBAAgB;AAChB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,KAAK,CAAA;IACX,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/node/_tasks/dts/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { _BuildTaskHandlers, _WatchTaskHandlers } from './_types';
|
|
2
|
+
export * from './_types';
|
|
3
|
+
export * from './dts';
|
|
4
|
+
export * from './rollup';
|
|
5
|
+
/** @internal */
|
|
6
|
+
export declare const _buildTaskHandlers: _BuildTaskHandlers;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare const _watchTaskHandlers: _WatchTaskHandlers;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/node/_tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,UAAU,CAAA;AAI/D,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AAExB,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,EAAE,kBAGhC,CAAA;AAED,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,EAAE,kBAGhC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InputOptions, OutputOptions } from 'rollup';
|
|
2
|
+
import { _BuildContext } from '../../_core';
|
|
3
|
+
import { _RollupTask, _RollupWatchTask } from '../_types';
|
|
4
|
+
export interface _RollupConfig {
|
|
5
|
+
inputOptions: InputOptions;
|
|
6
|
+
outputOptions: OutputOptions;
|
|
7
|
+
}
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare function _resolveRollupConfig(ctx: _BuildContext, buildTask: _RollupTask | _RollupWatchTask): _RollupConfig;
|
|
10
|
+
//# sourceMappingURL=_resolveRollupConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_resolveRollupConfig.d.ts","sourceRoot":"","sources":["../../../../../../src/node/_tasks/rollup/_resolveRollupConfig.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,QAAQ,CAAA;AAGlD,OAAO,EAAC,aAAa,EAAY,MAAM,aAAa,CAAA;AACpD,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,WAAW,CAAA;AAEvD,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED,gBAAgB;AAChB,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,WAAW,GAAG,gBAAgB,GACxC,aAAa,CAgKf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupTask.d.ts","sourceRoot":"","sources":["../../../../../../src/node/_tasks/rollup/_rollupTask.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AAGnD,gBAAgB;AAChB,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,WAAW,CAyBjD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupWatchTask.d.ts","sourceRoot":"","sources":["../../../../../../src/node/_tasks/rollup/_rollupWatchTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAA2C,MAAM,QAAQ,CAAA;AAEnF,OAAO,EAAC,gBAAgB,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AAGxD,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,gBAAgB,EAAE,kBAAkB,CAqE/E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/node/_tasks/rollup/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_watchConfigFiles.d.ts","sourceRoot":"","sources":["../../../../src/node/_watchConfigFiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAA;AAK/B,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CA4C7F"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
export interface _FileEvent {
|
|
3
|
+
type: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir';
|
|
4
|
+
file: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function _watchFiles(patterns: string[]): Observable<_FileEvent>;
|
|
7
|
+
//# sourceMappingURL=_watchFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_watchFiles.d.ts","sourceRoot":"","sources":["../../../../src/node/_watchFiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAA;AAE/B,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAA;IAC1D,IAAI,EAAE,MAAM,CAAA;CACb;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC,CAoBtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/node/build.ts"],"names":[],"mappings":"AAMA,cAAc;AACd,wBAAsB,KAAK,CAAC,OAAO,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../../src/node/check.ts"],"names":[],"mappings":"AASA,cAAc;AACd,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyHhB"}
|
|
@@ -73,10 +73,12 @@ export declare interface _DtsResult {
|
|
|
73
73
|
/** @internal */
|
|
74
74
|
export declare interface _DtsTask {
|
|
75
75
|
type: 'build:dts'
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
entries: {
|
|
77
|
+
exportPath: string
|
|
78
|
+
importId: string
|
|
79
|
+
sourcePath: string
|
|
80
|
+
targetPath: string
|
|
81
|
+
}[]
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
/** @internal */
|
|
@@ -85,10 +87,12 @@ export declare const _dtsTask: _TaskHandler<_DtsTask, _DtsResult>
|
|
|
85
87
|
/** @internal */
|
|
86
88
|
export declare interface _DtsWatchTask {
|
|
87
89
|
type: 'watch:dts'
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
entries: {
|
|
91
|
+
exportPath: string
|
|
92
|
+
importId: string
|
|
93
|
+
sourcePath: string
|
|
94
|
+
targetPath: string
|
|
95
|
+
}[]
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/** @internal */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../../src/node/watch.ts"],"names":[],"mappings":"AAQA,cAAc;AACd,wBAAsB,KAAK,CAAC,OAAO,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CpF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"author": "Sanity.io <hello@sanity.io>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Simple utilities for modern npm packages.",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"source": "./src/node/index.ts",
|
|
17
17
|
"main": "./dist/index.cjs",
|
|
18
18
|
"module": "./dist/index.js",
|
|
19
|
-
"types": "./dist/index.d.ts",
|
|
19
|
+
"types": "./dist/types/src/node/index.d.ts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
22
|
+
"types": "./dist/types/src/node/index.d.ts",
|
|
23
23
|
"source": "./src/node/index.ts",
|
|
24
24
|
"import": "./dist/index.js",
|
|
25
25
|
"require": "./dist/index.cjs",
|
|
@@ -36,13 +36,14 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
|
-
"build": "node -r esbuild-register scripts/build
|
|
39
|
+
"build": "node -r esbuild-register scripts/build",
|
|
40
40
|
"check:package": "node -r esbuild-register scripts/check",
|
|
41
41
|
"clean": "rimraf dist test/env/__tmp__",
|
|
42
42
|
"commit": "cz",
|
|
43
43
|
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
44
44
|
"format": "prettier --write --cache --ignore-unknown .",
|
|
45
45
|
"lint": "eslint . --ext .cjs,.js,.ts",
|
|
46
|
+
"postbuild": "pnpm run check:package",
|
|
46
47
|
"prebuild": "pnpm run clean",
|
|
47
48
|
"prepublishOnly": "pnpm run build",
|
|
48
49
|
"release": "semantic-release",
|
|
@@ -75,7 +76,6 @@
|
|
|
75
76
|
"pkg-up": "^3.1.0",
|
|
76
77
|
"prettier": "^2.7.1",
|
|
77
78
|
"pretty-bytes": "^5.6.0",
|
|
78
|
-
"rimraf": "^3.0.2",
|
|
79
79
|
"rollup": "^2.78.1",
|
|
80
80
|
"rollup-plugin-esbuild": "^4.9.3",
|
|
81
81
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
"@commitlint/cli": "^17.0.3",
|
|
89
89
|
"@commitlint/config-conventional": "^17.0.3",
|
|
90
90
|
"@sanity/semantic-release-preset": "^2.0.0",
|
|
91
|
+
"@types/babel__core": "^7.1.19",
|
|
91
92
|
"@types/cpx": "^1.5.2",
|
|
92
93
|
"@types/find-config": "^1.0.1",
|
|
93
|
-
"@types/globby": "^9.1.0",
|
|
94
94
|
"@types/mkdirp": "^1.0.2",
|
|
95
95
|
"@types/node": "^18.7.13",
|
|
96
96
|
"@types/prettier": "^2.7.0",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"eslint-plugin-prettier": "^4.2.1",
|
|
109
109
|
"husky": "^8.0.1",
|
|
110
110
|
"lint-staged": "^12.5.0",
|
|
111
|
+
"rimraf": "^3.0.2",
|
|
111
112
|
"semantic-release": "^19.0.5",
|
|
112
113
|
"ts-node": "^10.9.1",
|
|
113
114
|
"typescript": "^4.7.4",
|
|
@@ -15,7 +15,7 @@ export async function _loadPkgWithReporting(options: {cwd: string}): Promise<_Pa
|
|
|
15
15
|
if (issue.code === 'invalid_type') {
|
|
16
16
|
console.log(
|
|
17
17
|
`${chalk.red('invalid type')} in ./package.json at ${chalk.magenta(
|
|
18
|
-
`\`${issue.path.join('')}\``
|
|
18
|
+
`\`${issue.path.join('.')}\``
|
|
19
19
|
)} (expected ${issue.expected}, received ${issue.received})`
|
|
20
20
|
)
|
|
21
21
|
}
|
|
@@ -13,13 +13,19 @@ export function _resolveBuildTasks(ctx: _BuildContext): _BuildTask[] {
|
|
|
13
13
|
([_path, exp]) => ({_path, ...exp} as PkgExport & {_path: string})
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const dtsTask: _DtsTask = {
|
|
17
|
+
type: 'build:dts',
|
|
18
|
+
entries: [],
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
const rollupTasks: Record<string, _RollupTask> = {}
|
|
18
22
|
|
|
19
23
|
function _addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: _RollupTaskEntry) {
|
|
20
24
|
const buildId = `${format}:${runtime}`
|
|
21
25
|
|
|
22
|
-
if (
|
|
26
|
+
if (rollupTasks[buildId]) {
|
|
27
|
+
rollupTasks[buildId].entries.push(entry)
|
|
28
|
+
} else {
|
|
23
29
|
rollupTasks[buildId] = {
|
|
24
30
|
type: 'build:js',
|
|
25
31
|
buildId,
|
|
@@ -28,8 +34,6 @@ export function _resolveBuildTasks(ctx: _BuildContext): _BuildTask[] {
|
|
|
28
34
|
format,
|
|
29
35
|
target: target[runtime],
|
|
30
36
|
}
|
|
31
|
-
} else {
|
|
32
|
-
rollupTasks[buildId].entries.push(entry)
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -38,15 +42,12 @@ export function _resolveBuildTasks(ctx: _BuildContext): _BuildTask[] {
|
|
|
38
42
|
const importId = path.join(pkg.name, exp._path)
|
|
39
43
|
|
|
40
44
|
if (exp.types) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
targetPath: exp.types,
|
|
48
|
-
}
|
|
49
|
-
}
|
|
45
|
+
dtsTask.entries.push({
|
|
46
|
+
importId,
|
|
47
|
+
exportPath: exp._path,
|
|
48
|
+
sourcePath: exp.source,
|
|
49
|
+
targetPath: exp.types,
|
|
50
|
+
})
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -102,7 +103,10 @@ export function _resolveBuildTasks(ctx: _BuildContext): _BuildTask[] {
|
|
|
102
103
|
})
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
if (dtsTask.entries.length) {
|
|
107
|
+
tasks.push(dtsTask)
|
|
108
|
+
}
|
|
109
|
+
|
|
106
110
|
tasks.push(...Object.values(rollupTasks))
|
|
107
111
|
|
|
108
112
|
// Parse rollup:esm:browser tasks
|
|
@@ -12,13 +12,19 @@ export function _resolveWatchTasks(ctx: _BuildContext): _WatchTask[] {
|
|
|
12
12
|
([_path, exp]) => ({_path, ...exp} as PkgExport & {_path: string})
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const dtsTask: _DtsWatchTask = {
|
|
16
|
+
type: 'watch:dts',
|
|
17
|
+
entries: [],
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
const rollupTasks: Record<string, _RollupWatchTask> = {}
|
|
17
21
|
|
|
18
22
|
function _addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: _RollupTaskEntry) {
|
|
19
23
|
const buildId = `${format}:${runtime}`
|
|
20
24
|
|
|
21
|
-
if (
|
|
25
|
+
if (rollupTasks[buildId]) {
|
|
26
|
+
rollupTasks[buildId].entries.push(entry)
|
|
27
|
+
} else {
|
|
22
28
|
rollupTasks[buildId] = {
|
|
23
29
|
type: 'watch:js',
|
|
24
30
|
buildId,
|
|
@@ -27,8 +33,6 @@ export function _resolveWatchTasks(ctx: _BuildContext): _WatchTask[] {
|
|
|
27
33
|
format,
|
|
28
34
|
target: target[runtime],
|
|
29
35
|
}
|
|
30
|
-
} else {
|
|
31
|
-
rollupTasks[buildId].entries.push(entry)
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -37,15 +41,12 @@ export function _resolveWatchTasks(ctx: _BuildContext): _WatchTask[] {
|
|
|
37
41
|
const importId = path.join(pkg.name, exp._path)
|
|
38
42
|
|
|
39
43
|
if (exp.types) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
targetPath: exp.types,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
44
|
+
dtsTask.entries.push({
|
|
45
|
+
importId,
|
|
46
|
+
exportPath: exp._path,
|
|
47
|
+
sourcePath: exp.source,
|
|
48
|
+
targetPath: exp.types,
|
|
49
|
+
})
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -101,7 +102,10 @@ export function _resolveWatchTasks(ctx: _BuildContext): _WatchTask[] {
|
|
|
101
102
|
})
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
if (dtsTask.entries.length) {
|
|
106
|
+
tasks.push(dtsTask)
|
|
107
|
+
}
|
|
108
|
+
|
|
105
109
|
tasks.push(...Object.values(rollupTasks))
|
|
106
110
|
|
|
107
111
|
// Parse rollup:esm:browser tasks
|
|
@@ -115,7 +119,7 @@ export function _resolveWatchTasks(ctx: _BuildContext): _WatchTask[] {
|
|
|
115
119
|
[
|
|
116
120
|
`// AUTO-GENERATED – DO NOT EDIT`,
|
|
117
121
|
``,
|
|
118
|
-
`export {default} from '${relativeTargetPath}'`,
|
|
122
|
+
// `export {default} from '${relativeTargetPath}'`,
|
|
119
123
|
`export * from '${relativeTargetPath}'`,
|
|
120
124
|
``,
|
|
121
125
|
].join('\n')
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
|
-
import path from 'path'
|
|
4
3
|
import ts from 'typescript'
|
|
5
4
|
|
|
6
5
|
export const formatHost: ts.FormatDiagnosticsHost = {
|
|
@@ -13,10 +12,9 @@ export const formatHost: ts.FormatDiagnosticsHost = {
|
|
|
13
12
|
export async function _buildTypes(options: {
|
|
14
13
|
cwd: string
|
|
15
14
|
outDir: string
|
|
16
|
-
sourcePath: string
|
|
17
15
|
tsconfig: ts.ParsedCommandLine
|
|
18
|
-
}): Promise<
|
|
19
|
-
const {
|
|
16
|
+
}): Promise<void> {
|
|
17
|
+
const {outDir, tsconfig} = options
|
|
20
18
|
|
|
21
19
|
const compilerOptions: ts.CompilerOptions = {
|
|
22
20
|
...tsconfig.options,
|
|
@@ -27,23 +25,8 @@ export async function _buildTypes(options: {
|
|
|
27
25
|
outDir,
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
const rootDir =
|
|
31
|
-
path.relative(
|
|
32
|
-
cwd,
|
|
33
|
-
compilerOptions.rootDir
|
|
34
|
-
? path.resolve(cwd, compilerOptions.rootDir)
|
|
35
|
-
: path.dirname(path.resolve(cwd, sourcePath))
|
|
36
|
-
) || '.'
|
|
37
|
-
|
|
38
28
|
const program = ts.createProgram(tsconfig.fileNames, compilerOptions)
|
|
39
29
|
|
|
40
|
-
const sourceFiles = program.getSourceFiles()
|
|
41
|
-
const sourceFile = sourceFiles.find((f) => f.fileName === path.resolve(cwd, sourcePath))
|
|
42
|
-
|
|
43
|
-
if (!sourceFile) {
|
|
44
|
-
throw new Error(`source file not found: ${sourcePath}`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
30
|
const emitResult = program.emit()
|
|
48
31
|
|
|
49
32
|
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)
|
|
@@ -68,10 +51,4 @@ export async function _buildTypes(options: {
|
|
|
68
51
|
throw new Error('failed to compile')
|
|
69
52
|
}
|
|
70
53
|
}
|
|
71
|
-
|
|
72
|
-
const typesPath = path
|
|
73
|
-
.resolve(outDir, path.relative(rootDir, path.resolve(cwd, sourcePath)))
|
|
74
|
-
.replace(/\.[jt]sx?$/, '.d.ts')
|
|
75
|
-
|
|
76
|
-
return {path: typesPath}
|
|
77
54
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
|
-
import {
|
|
3
|
-
import rimrafCallback from 'rimraf'
|
|
2
|
+
import {ExtractorMessage} from '@microsoft/api-extractor'
|
|
4
3
|
import {_BuildContext} from '../../_core'
|
|
5
4
|
import {_buildTypes} from './_buildTypes'
|
|
6
5
|
import {_DtsError} from './_DtsError'
|
|
7
6
|
import {_extractTypes} from './_extractTypes'
|
|
8
7
|
import {_DtsResult, _DtsTask, _DtsWatchTask} from './_types'
|
|
9
8
|
|
|
10
|
-
const rimraf = promisify(rimrafCallback)
|
|
11
|
-
|
|
12
9
|
export async function _doExtract(
|
|
13
10
|
ctx: _BuildContext,
|
|
14
11
|
task: _DtsTask | _DtsWatchTask
|
|
@@ -17,40 +14,44 @@ export async function _doExtract(
|
|
|
17
14
|
|
|
18
15
|
if (!ts.config || !ts.configPath) return {type: 'dts', messages: []}
|
|
19
16
|
|
|
20
|
-
const sourcePath = task.sourcePath
|
|
21
|
-
const exportPath = task.exportPath === '.' ? './index' : task.exportPath
|
|
22
17
|
const distPath = path.resolve(cwd, dist)
|
|
23
|
-
const filePath = path.relative(distPath, path.resolve(cwd, task.targetPath))
|
|
24
18
|
|
|
25
|
-
const
|
|
26
|
-
const tmpDir = {
|
|
27
|
-
path: tmpDirPath,
|
|
28
|
-
removeCallback: () => rimraf(tmpDirPath),
|
|
29
|
-
}
|
|
19
|
+
const {outDir = distPath, rootDir = cwd} = ts.config.options
|
|
30
20
|
|
|
31
|
-
|
|
21
|
+
await _buildTypes({
|
|
32
22
|
cwd,
|
|
33
|
-
outDir:
|
|
34
|
-
sourcePath,
|
|
23
|
+
outDir: outDir,
|
|
35
24
|
tsconfig: ts.config,
|
|
36
25
|
})
|
|
37
26
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
const messages: ExtractorMessage[] = []
|
|
28
|
+
|
|
29
|
+
for (const entry of task.entries) {
|
|
30
|
+
const exportPath = entry.exportPath === '.' ? './index' : entry.exportPath
|
|
31
|
+
|
|
32
|
+
const filePath = path.relative(distPath, path.resolve(cwd, entry.targetPath))
|
|
33
|
+
|
|
34
|
+
const result = await _extractTypes({
|
|
35
|
+
cwd,
|
|
36
|
+
exportPath,
|
|
37
|
+
files,
|
|
38
|
+
filePath,
|
|
39
|
+
projectPath: cwd,
|
|
40
|
+
rules: config?.extract?.rules,
|
|
41
|
+
sourcePath: path.resolve(
|
|
42
|
+
outDir,
|
|
43
|
+
path.relative(cwd, rootDir),
|
|
44
|
+
entry.sourcePath.replace(/\.ts$/, '.d.ts')
|
|
45
|
+
),
|
|
46
|
+
tsconfigPath: path.resolve(cwd, ts.configPath),
|
|
47
|
+
distPath,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
messages.push(...result.messages)
|
|
51
|
+
|
|
52
|
+
if (result.messages.some((msg) => msg.logLevel === 'error')) {
|
|
53
|
+
throw new _DtsError('encountered errors when extracting types', result.messages)
|
|
54
|
+
}
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
return {type: 'dts', messages}
|
|
@@ -11,7 +11,10 @@ export const _dtsTask: _TaskHandler<_DtsTask, _DtsResult> = {
|
|
|
11
11
|
name: (_ctx, task) =>
|
|
12
12
|
[
|
|
13
13
|
`build type definitions`,
|
|
14
|
-
|
|
14
|
+
...task.entries.map(
|
|
15
|
+
(entry) =>
|
|
16
|
+
` ${chalk.blue(entry.importId)}: ${entry.sourcePath} -> ${entry.targetPath}`
|
|
17
|
+
),
|
|
15
18
|
].join('\n'),
|
|
16
19
|
exec: (ctx, task) => {
|
|
17
20
|
return new Observable((observer) => {
|
|
@@ -11,7 +11,10 @@ export const _dtsWatchTask: _TaskHandler<_DtsWatchTask, _DtsResult> = {
|
|
|
11
11
|
name: (_ctx, task) =>
|
|
12
12
|
[
|
|
13
13
|
`build type definitions`,
|
|
14
|
-
|
|
14
|
+
...task.entries.map(
|
|
15
|
+
(entry) =>
|
|
16
|
+
` ${chalk.blue(entry.importId)}: ${entry.sourcePath} -> ${entry.targetPath}`
|
|
17
|
+
),
|
|
15
18
|
].join('\n'),
|
|
16
19
|
exec: (ctx, task) => {
|
|
17
20
|
return new Observable((observer) => {
|
|
@@ -3,19 +3,23 @@ import {ExtractorMessage} from '@microsoft/api-extractor'
|
|
|
3
3
|
/** @internal */
|
|
4
4
|
export interface _DtsWatchTask {
|
|
5
5
|
type: 'watch:dts'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
entries: {
|
|
7
|
+
exportPath: string
|
|
8
|
+
importId: string
|
|
9
|
+
sourcePath: string
|
|
10
|
+
targetPath: string
|
|
11
|
+
}[]
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
/** @internal */
|
|
13
15
|
export interface _DtsTask {
|
|
14
16
|
type: 'build:dts'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
entries: {
|
|
18
|
+
exportPath: string
|
|
19
|
+
importId: string
|
|
20
|
+
sourcePath: string
|
|
21
|
+
targetPath: string
|
|
22
|
+
}[]
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/** @internal */
|