@sanity/pkg-utils 7.2.7 → 7.2.8-canary.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/dist/_chunks-cjs/build.cjs +2 -2
- package/dist/_chunks-cjs/build.cjs.map +1 -1
- package/dist/_chunks-cjs/check.cjs.map +1 -1
- package/dist/_chunks-cjs/consoleSpy.cjs +73 -9
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/_chunks-cjs/handleError.cjs.map +1 -1
- package/dist/_chunks-cjs/index.cjs +36 -21
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/_chunks-cjs/init.cjs +12 -12
- package/dist/_chunks-cjs/init.cjs.map +1 -1
- package/dist/_chunks-cjs/logger.cjs +1 -71
- package/dist/_chunks-cjs/logger.cjs.map +1 -1
- package/dist/_chunks-cjs/watch.cjs +17 -2
- package/dist/_chunks-cjs/watch.cjs.map +1 -1
- package/dist/cli.cjs +2 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/index.d.cts +5 -8
- package/dist/index.d.ts +5 -8
- package/dist/index.js +39 -40
- package/dist/index.js.map +1 -1
- package/package.json +11 -14
- package/src/cli/handleError.ts +0 -2
- package/src/cli/index.ts +1 -2
- package/src/global.ts +0 -1
- package/src/node/build.ts +3 -4
- package/src/node/check.ts +0 -3
- package/src/node/consoleSpy.ts +0 -2
- package/src/node/core/config/findConfigFile.ts +0 -2
- package/src/node/core/config/index.ts +3 -3
- package/src/node/core/config/loadConfig.ts +0 -3
- package/src/node/core/config/types.ts +0 -4
- package/src/node/core/contexts/buildContext.ts +2 -3
- package/src/node/core/pkg/loadPkg.ts +0 -2
- package/src/node/core/pkg/loadPkgWithReporting.ts +0 -1
- package/src/node/core/pkg/parseExports.ts +1 -2
- package/src/node/core/pkg/validateExports.ts +1 -1
- package/src/node/core/pkg/validatePkg.ts +0 -1
- package/src/node/core/template/createFromTemplate.ts +0 -2
- package/src/node/core/template/types.ts +0 -3
- package/src/node/getFilesize.ts +0 -1
- package/src/node/globFiles.ts +0 -1
- package/src/node/index.ts +64 -8
- package/src/node/init.ts +1 -3
- package/src/node/logger.ts +1 -2
- package/src/node/printExtractMessages.ts +1 -3
- package/src/node/printPackageTree.ts +2 -5
- package/src/node/resolveBuildContext.ts +12 -23
- package/src/node/resolveBuildTasks.ts +4 -3
- package/src/node/resolveWatchTasks.ts +4 -3
- package/src/node/spinner.ts +1 -2
- package/src/node/strict.test-d.ts +0 -1
- package/src/node/tasks/dts/buildTypes.ts +0 -1
- package/src/node/tasks/dts/createApiExtractorConfig.ts +0 -1
- package/src/node/tasks/dts/createTSDocConfig.ts +0 -1
- package/src/node/tasks/dts/doExtract.ts +2 -4
- package/src/node/tasks/dts/dtsTask.ts +0 -1
- package/src/node/tasks/dts/dtsWatchTask.ts +1 -3
- package/src/node/tasks/dts/extractTypes.ts +3 -4
- package/src/node/tasks/dts/getExtractMessagesConfig.ts +1 -2
- package/src/node/tasks/dts/getTargetPaths.ts +2 -2
- package/src/node/tasks/dts/printDiagnostic.ts +0 -2
- package/src/node/tasks/index.ts +4 -2
- package/src/node/tasks/rollup/resolveRollupConfig.ts +10 -11
- package/src/node/tasks/rollup/rollupTask.ts +1 -4
- package/src/node/tasks/rollup/rollupWatchTask.ts +1 -3
- package/src/node/tasks/types.ts +3 -3
- package/src/node/templates/default/template.ts +20 -23
- package/src/node/watch.ts +2 -3
- package/src/node/watchConfigFiles.ts +0 -2
- package/src/node/watchFiles.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {PkgBundle, PkgExport} from '../../core/config/types'
|
|
2
|
+
import type {PackageJSON} from '../../core/pkg/types'
|
|
2
3
|
|
|
3
4
|
/** @internal */
|
|
4
5
|
export const fileEnding = /\.[mc]?js$/
|
|
@@ -66,7 +67,6 @@ export function getTargetPaths(
|
|
|
66
67
|
return Array.from(set)
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
70
|
function isPkgExport(exp: any): exp is PkgExport {
|
|
71
71
|
return exp?.browser || exp?.node || exp?.default
|
|
72
72
|
}
|
package/src/node/tasks/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {dtsTask
|
|
2
|
-
import {
|
|
1
|
+
import {dtsTask} from './dts/dtsTask'
|
|
2
|
+
import {dtsWatchTask} from './dts/dtsWatchTask'
|
|
3
|
+
import {rollupTask} from './rollup/rollupTask'
|
|
4
|
+
import {rollupWatchTask} from './rollup/rollupWatchTask'
|
|
3
5
|
import type {BuildTaskHandlers, WatchTaskHandlers} from './types'
|
|
4
6
|
|
|
5
7
|
export * from './dts'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import type {PluginItem} from '@babel/core'
|
|
4
3
|
import {optimizeLodashImports} from '@optimize-lodash/rollup-plugin'
|
|
5
4
|
import alias from '@rollup/plugin-alias'
|
|
@@ -11,9 +10,10 @@ import replace from '@rollup/plugin-replace'
|
|
|
11
10
|
import terser from '@rollup/plugin-terser'
|
|
12
11
|
import type {InputOptions, OutputOptions, Plugin} from 'rollup'
|
|
13
12
|
import esbuild from 'rollup-plugin-esbuild'
|
|
14
|
-
|
|
15
13
|
import {pkgExtMap as extMap} from '../../../node/core/pkg/pkgExt'
|
|
16
|
-
import {
|
|
14
|
+
import {resolveConfigProperty} from '../../core/config/resolveConfigProperty'
|
|
15
|
+
import type {BuildContext} from '../../core/contexts/buildContext'
|
|
16
|
+
import type {PackageJSON} from '../../core/pkg/types'
|
|
17
17
|
import type {RollupTask, RollupWatchTask} from '../types'
|
|
18
18
|
|
|
19
19
|
export interface RollupConfig {
|
|
@@ -59,8 +59,8 @@ export function resolveRollupConfig(
|
|
|
59
59
|
const defaultPlugins = [
|
|
60
60
|
replace({
|
|
61
61
|
preventAssignment: true,
|
|
62
|
-
values:
|
|
63
|
-
|
|
62
|
+
values:
|
|
63
|
+
pkg.name === '@sanity/pkg-utils'
|
|
64
64
|
? {...replacements}
|
|
65
65
|
: {
|
|
66
66
|
'process.env.PKG_FILE_PATH': (arg) => {
|
|
@@ -68,7 +68,6 @@ export function resolveRollupConfig(
|
|
|
68
68
|
const entry = entries.find((e) => e.source === sourcePath)
|
|
69
69
|
|
|
70
70
|
if (!entry) {
|
|
71
|
-
// eslint-disable-next-line no-console
|
|
72
71
|
console.error(`could not find source entry: ${sourcePath}`)
|
|
73
72
|
|
|
74
73
|
return 'null'
|
|
@@ -82,8 +81,7 @@ export function resolveRollupConfig(
|
|
|
82
81
|
'process.env.PKG_RUNTIME': JSON.stringify(runtime),
|
|
83
82
|
'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),
|
|
84
83
|
...replacements,
|
|
85
|
-
}
|
|
86
|
-
},
|
|
84
|
+
},
|
|
87
85
|
}),
|
|
88
86
|
alias({
|
|
89
87
|
entries: {...pathAliases},
|
|
@@ -220,9 +218,10 @@ export function resolveRollupConfig(
|
|
|
220
218
|
return false
|
|
221
219
|
},
|
|
222
220
|
|
|
223
|
-
input: entries.reduce<{[entryAlias: string]: string}>(
|
|
224
|
-
|
|
225
|
-
|
|
221
|
+
input: entries.reduce<{[entryAlias: string]: string}>(
|
|
222
|
+
(acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),
|
|
223
|
+
{},
|
|
224
|
+
),
|
|
226
225
|
|
|
227
226
|
watch: {
|
|
228
227
|
chokidar: {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import chalk from 'chalk'
|
|
4
3
|
import {rollup} from 'rollup'
|
|
5
4
|
import {Observable} from 'rxjs'
|
|
6
|
-
|
|
7
5
|
import {createConsoleSpy} from '../../consoleSpy'
|
|
8
|
-
import type {BuildContext} from '../../core'
|
|
6
|
+
import type {BuildContext} from '../../core/contexts/buildContext'
|
|
9
7
|
import type {RollupTask, TaskHandler} from '../types'
|
|
10
8
|
import {resolveRollupConfig} from './resolveRollupConfig'
|
|
11
9
|
|
|
@@ -66,7 +64,6 @@ export const rollupTask: TaskHandler<RollupTask> = {
|
|
|
66
64
|
//
|
|
67
65
|
},
|
|
68
66
|
error: (_ctx, _task, err) => {
|
|
69
|
-
// eslint-disable-next-line no-console
|
|
70
67
|
console.error(err)
|
|
71
68
|
},
|
|
72
69
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import chalk from 'chalk'
|
|
4
|
-
import {type RollupWatcherEvent, type RollupWatchOptions
|
|
3
|
+
import {watch as rollupWatch, type RollupWatcherEvent, type RollupWatchOptions} from 'rollup'
|
|
5
4
|
import {Observable} from 'rxjs'
|
|
6
|
-
|
|
7
5
|
import type {RollupWatchTask, TaskHandler} from '../types'
|
|
8
6
|
import {resolveRollupConfig} from './resolveRollupConfig'
|
|
9
7
|
|
package/src/node/tasks/types.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {RollupWatcherEvent} from 'rollup'
|
|
2
2
|
import type {Observable} from 'rxjs'
|
|
3
|
-
|
|
4
|
-
import type {BuildContext
|
|
5
|
-
import type {DtsResult, DtsTask, DtsWatchTask} from './dts'
|
|
3
|
+
import type {PkgRuntime} from '../core/config/types'
|
|
4
|
+
import type {BuildContext} from '../core/contexts/buildContext'
|
|
5
|
+
import type {DtsResult, DtsTask, DtsWatchTask} from './dts/types'
|
|
6
6
|
|
|
7
7
|
/** @internal */
|
|
8
8
|
export interface RollupTaskEntry {
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import {execSync} from 'node:child_process'
|
|
2
2
|
import {resolve} from 'node:path'
|
|
3
|
-
|
|
4
3
|
import prettierConfig from '@sanity/prettier-config'
|
|
5
4
|
import getLatestVersion from 'get-latest-version'
|
|
6
5
|
import gitUrlParse from 'git-url-parse'
|
|
7
6
|
import {outdent} from 'outdent'
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type PackageJSON,
|
|
14
|
-
type PkgTemplate,
|
|
15
|
-
type PkgTemplateFile,
|
|
16
|
-
} from '../../core'
|
|
7
|
+
import {format, type Config as PrettierConfig} from 'prettier'
|
|
8
|
+
import {isRecord} from '../../core/isRecord'
|
|
9
|
+
import type {PackageJSON} from '../../core/pkg/types'
|
|
10
|
+
import {defineTemplateOption} from '../../core/template/define'
|
|
11
|
+
import {type PkgTemplate, type PkgTemplateFile} from '../../core/template/types'
|
|
17
12
|
|
|
18
13
|
const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i
|
|
19
14
|
|
|
@@ -262,7 +257,6 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
262
257
|
}
|
|
263
258
|
|
|
264
259
|
if (features['eslint']) {
|
|
265
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
260
|
const eslintConfig: any = {
|
|
267
261
|
root: true,
|
|
268
262
|
env: {
|
|
@@ -324,7 +318,6 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
324
318
|
'@typescript-eslint/parser': '^7',
|
|
325
319
|
}
|
|
326
320
|
|
|
327
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
328
321
|
const eslintConfigOverride: any = {
|
|
329
322
|
files: ['**/*.ts', '**/*.tsx'],
|
|
330
323
|
parser: '@typescript-eslint/parser',
|
|
@@ -356,7 +349,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
356
349
|
|
|
357
350
|
files.push({
|
|
358
351
|
name: '.eslintrc.cjs',
|
|
359
|
-
contents: await
|
|
352
|
+
contents: await prettierFormat(
|
|
360
353
|
resolve(packagePath, '.eslintrc.cjs'),
|
|
361
354
|
outdent`
|
|
362
355
|
'use strict'
|
|
@@ -372,7 +365,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
372
365
|
if (features['typescript']) {
|
|
373
366
|
files.push({
|
|
374
367
|
name: 'tsconfig.settings.json',
|
|
375
|
-
contents: await
|
|
368
|
+
contents: await prettierFormat(
|
|
376
369
|
resolve(packagePath, 'tsconfig.settings.json'),
|
|
377
370
|
outdent`
|
|
378
371
|
{
|
|
@@ -389,7 +382,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
389
382
|
|
|
390
383
|
files.push({
|
|
391
384
|
name: 'tsconfig.dist.json',
|
|
392
|
-
contents: await
|
|
385
|
+
contents: await prettierFormat(
|
|
393
386
|
resolve(packagePath, 'tsconfig.dist.json'),
|
|
394
387
|
outdent`
|
|
395
388
|
{
|
|
@@ -404,7 +397,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
404
397
|
|
|
405
398
|
files.push({
|
|
406
399
|
name: 'tsconfig.json',
|
|
407
|
-
contents: await
|
|
400
|
+
contents: await prettierFormat(
|
|
408
401
|
resolve(packagePath, 'tsconfig.json'),
|
|
409
402
|
outdent`
|
|
410
403
|
{
|
|
@@ -422,7 +415,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
422
415
|
if (features['typescript']) {
|
|
423
416
|
files.push({
|
|
424
417
|
name: 'package.config.ts',
|
|
425
|
-
contents: await
|
|
418
|
+
contents: await prettierFormat(
|
|
426
419
|
resolve(packagePath, 'package.config.ts'),
|
|
427
420
|
outdent`
|
|
428
421
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
@@ -439,7 +432,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
439
432
|
|
|
440
433
|
files.push({
|
|
441
434
|
name: 'src/index.ts',
|
|
442
|
-
contents: await
|
|
435
|
+
contents: await prettierFormat(
|
|
443
436
|
resolve(packagePath, 'src/index.ts'),
|
|
444
437
|
outdent`
|
|
445
438
|
/** @public */
|
|
@@ -453,7 +446,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
453
446
|
} else {
|
|
454
447
|
files.push({
|
|
455
448
|
name: 'package.config.js',
|
|
456
|
-
contents: await
|
|
449
|
+
contents: await prettierFormat(
|
|
457
450
|
resolve(packagePath, 'package.config.js'),
|
|
458
451
|
outdent`
|
|
459
452
|
import {defineConfig} from '@sanity/pkg-utils'
|
|
@@ -473,7 +466,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
473
466
|
|
|
474
467
|
files.push({
|
|
475
468
|
name: 'src/index.js',
|
|
476
|
-
contents: await
|
|
469
|
+
contents: await prettierFormat(
|
|
477
470
|
resolve(packagePath, 'src/index.js'),
|
|
478
471
|
outdent`
|
|
479
472
|
/** @public */
|
|
@@ -502,7 +495,7 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
502
495
|
|
|
503
496
|
files.push({
|
|
504
497
|
name: 'package.json',
|
|
505
|
-
contents: await
|
|
498
|
+
contents: await prettierFormat(
|
|
506
499
|
resolve(packagePath, 'package.json'),
|
|
507
500
|
JSON.stringify(pkgJson, null, 2),
|
|
508
501
|
prettierConfig,
|
|
@@ -514,8 +507,12 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
514
507
|
}
|
|
515
508
|
}
|
|
516
509
|
|
|
517
|
-
function
|
|
518
|
-
|
|
510
|
+
function prettierFormat(
|
|
511
|
+
filepath: string,
|
|
512
|
+
input: string,
|
|
513
|
+
prettierOptions: PrettierConfig | undefined,
|
|
514
|
+
) {
|
|
515
|
+
return format(input, {...prettierOptions, plugins: [], filepath})
|
|
519
516
|
}
|
|
520
517
|
|
|
521
518
|
async function resolveLatestDeps(deps: Record<string, string | undefined>) {
|
package/src/node/watch.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import {switchMap} from 'rxjs'
|
|
4
|
-
|
|
5
3
|
import {loadConfig, loadPkgWithReporting} from './core'
|
|
6
4
|
import {createLogger} from './logger'
|
|
7
5
|
import {resolveBuildContext} from './resolveBuildContext'
|
|
8
6
|
import {resolveWatchTasks} from './resolveWatchTasks'
|
|
9
|
-
import {
|
|
7
|
+
import {watchTaskHandlers} from './tasks'
|
|
8
|
+
import {type TaskHandler, type WatchTask} from './tasks/types'
|
|
10
9
|
import {watchConfigFiles} from './watchConfigFiles'
|
|
11
10
|
|
|
12
11
|
/** @public */
|
package/src/node/watchFiles.ts
CHANGED