@sanity/pkg-utils 6.2.1 → 6.4.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/_chunks-cjs/build.cjs +14 -4
- package/dist/_chunks-cjs/build.cjs.map +1 -1
- package/dist/_chunks-cjs/buildAction.cjs +2 -1
- package/dist/_chunks-cjs/buildAction.cjs.map +1 -1
- package/dist/cli.cjs +12 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/cli/buildAction.ts +2 -0
- package/src/cli/index.ts +13 -1
- package/src/node/build.ts +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"typescript": "5.4.5",
|
|
136
136
|
"vitest": "^1.4.0",
|
|
137
137
|
"vitest-github-actions-reporter": "^0.11.1",
|
|
138
|
-
"@sanity/pkg-utils": "6.
|
|
138
|
+
"@sanity/pkg-utils": "6.4.0"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
141
|
"typescript": "5.4.x"
|
package/src/cli/buildAction.ts
CHANGED
|
@@ -5,6 +5,7 @@ export async function buildAction(options: {
|
|
|
5
5
|
emitDeclarationOnly?: boolean
|
|
6
6
|
strict?: boolean
|
|
7
7
|
tsconfig?: string
|
|
8
|
+
clean?: boolean
|
|
8
9
|
}): Promise<void> {
|
|
9
10
|
try {
|
|
10
11
|
await build({
|
|
@@ -12,6 +13,7 @@ export async function buildAction(options: {
|
|
|
12
13
|
emitDeclarationOnly: options.emitDeclarationOnly,
|
|
13
14
|
strict: options.strict,
|
|
14
15
|
tsconfig: options.tsconfig,
|
|
16
|
+
clean: options.clean,
|
|
15
17
|
})
|
|
16
18
|
} catch (err) {
|
|
17
19
|
handleError(err)
|
package/src/cli/index.ts
CHANGED
|
@@ -20,10 +20,22 @@ cli
|
|
|
20
20
|
.option('--emitDeclarationOnly', 'Emit d.ts only')
|
|
21
21
|
.option('--strict', 'Strict mode')
|
|
22
22
|
.option('--tsconfig [tsconfig]', '[string] tsconfig.json')
|
|
23
|
+
.option('--check', 'Run the check command after build (same as running `pkg build && pkg check`)')
|
|
24
|
+
.option('--clean', 'Clean the dist directory before building')
|
|
23
25
|
.action(async (options) => {
|
|
26
|
+
const {check = false, ...buildOptions} = options
|
|
24
27
|
const {buildAction} = await import('./buildAction')
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
await buildAction(buildOptions)
|
|
30
|
+
|
|
31
|
+
if (check) {
|
|
32
|
+
const {checkAction} = await import('./checkAction')
|
|
33
|
+
|
|
34
|
+
await checkAction({
|
|
35
|
+
strict: options.strict,
|
|
36
|
+
tsconfig: options.tsconfig,
|
|
37
|
+
})
|
|
38
|
+
}
|
|
27
39
|
})
|
|
28
40
|
|
|
29
41
|
cli.command('init [path]', 'Initialize package').action(async (p) => {
|
package/src/node/build.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
import rimraf from 'rimraf'
|
|
4
|
+
|
|
1
5
|
import {loadConfig, loadPkgWithReporting} from './core'
|
|
2
6
|
import {createLogger} from './logger'
|
|
3
7
|
import {resolveBuildContext} from './resolveBuildContext'
|
|
@@ -29,11 +33,19 @@ export async function build(options: {
|
|
|
29
33
|
emitDeclarationOnly?: boolean
|
|
30
34
|
strict?: boolean
|
|
31
35
|
tsconfig?: string
|
|
36
|
+
clean?: boolean
|
|
32
37
|
}): Promise<void> {
|
|
33
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
cwd,
|
|
40
|
+
emitDeclarationOnly,
|
|
41
|
+
strict = false,
|
|
42
|
+
tsconfig: tsconfigOption,
|
|
43
|
+
clean = false,
|
|
44
|
+
} = options
|
|
34
45
|
const logger = createLogger()
|
|
35
46
|
|
|
36
47
|
const config = await loadConfig({cwd})
|
|
48
|
+
|
|
37
49
|
const legacyExports = config?.legacyExports ?? false
|
|
38
50
|
const pkg = await loadPkgWithReporting({cwd, logger, strict, legacyExports})
|
|
39
51
|
|
|
@@ -49,6 +61,13 @@ export async function build(options: {
|
|
|
49
61
|
tsconfig,
|
|
50
62
|
})
|
|
51
63
|
|
|
64
|
+
if (clean) {
|
|
65
|
+
logger.log(
|
|
66
|
+
`Cleaning the contents of the \`dist\` folder: './${path.relative(cwd, ctx.distPath)}'`,
|
|
67
|
+
)
|
|
68
|
+
await rimraf(ctx.distPath)
|
|
69
|
+
}
|
|
70
|
+
|
|
52
71
|
const buildTasks = resolveBuildTasks(ctx)
|
|
53
72
|
|
|
54
73
|
for (const task of buildTasks) {
|