@sanity/pkg-utils 7.1.0 → 7.1.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/init.cjs +13 -5
- package/dist/_chunks-cjs/init.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
- package/src/node/templates/default/template.ts +18 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -94,14 +94,13 @@
|
|
|
94
94
|
"jsonc-parser": "^3.3.1",
|
|
95
95
|
"mkdirp": "^3.0.1",
|
|
96
96
|
"outdent": "^0.8.0",
|
|
97
|
-
"parse-git-config": "^3.0.0",
|
|
98
97
|
"pkg-up": "^3.1.0",
|
|
99
98
|
"prettier": "^3.5.3",
|
|
100
99
|
"pretty-bytes": "^5.6.0",
|
|
101
100
|
"prompts": "^2.4.2",
|
|
102
101
|
"recast": "0.23.11",
|
|
103
102
|
"rimraf": "^4.4.1",
|
|
104
|
-
"rollup": "^4.
|
|
103
|
+
"rollup": "^4.36.0",
|
|
105
104
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
106
105
|
"rxjs": "^7.8.2",
|
|
107
106
|
"treeify": "^1.1.0",
|
|
@@ -118,7 +117,6 @@
|
|
|
118
117
|
"@types/find-config": "^1.0.4",
|
|
119
118
|
"@types/git-url-parse": "^9.0.3",
|
|
120
119
|
"@types/node": "^20.8.7",
|
|
121
|
-
"@types/parse-git-config": "^3.0.4",
|
|
122
120
|
"@types/prompts": "^2.4.9",
|
|
123
121
|
"@types/rimraf": "^3.0.2",
|
|
124
122
|
"@types/semver": "^7.5.8",
|
|
@@ -144,7 +142,7 @@
|
|
|
144
142
|
"ts-node": "^10.9.2",
|
|
145
143
|
"typescript": "5.8.2",
|
|
146
144
|
"vitest": "^3.0.8",
|
|
147
|
-
"@sanity/pkg-utils": "7.1.
|
|
145
|
+
"@sanity/pkg-utils": "7.1.1"
|
|
148
146
|
},
|
|
149
147
|
"peerDependencies": {
|
|
150
148
|
"babel-plugin-react-compiler": "*",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {execSync} from 'node:child_process'
|
|
1
2
|
import {resolve} from 'node:path'
|
|
2
3
|
|
|
3
4
|
import prettierConfig from '@sanity/prettier-config'
|
|
4
5
|
import getLatestVersion from 'get-latest-version'
|
|
5
6
|
import gitUrlParse from 'git-url-parse'
|
|
6
7
|
import {outdent} from 'outdent'
|
|
7
|
-
import parseGitConfig from 'parse-git-config'
|
|
8
8
|
import prettier, {type Config as PrettierConfig} from 'prettier'
|
|
9
9
|
|
|
10
10
|
import {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i
|
|
19
19
|
|
|
20
20
|
export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) => {
|
|
21
|
-
const gitConfig =
|
|
21
|
+
const gitConfig = getGitUserConfig(cwd)
|
|
22
22
|
|
|
23
23
|
return {
|
|
24
24
|
options: [
|
|
@@ -86,13 +86,13 @@ export const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) =
|
|
|
86
86
|
name: 'authorName',
|
|
87
87
|
type: 'string',
|
|
88
88
|
description: 'package author name',
|
|
89
|
-
initial: gitConfig
|
|
89
|
+
initial: gitConfig.user,
|
|
90
90
|
}),
|
|
91
91
|
defineTemplateOption({
|
|
92
92
|
name: 'authorEmail',
|
|
93
93
|
type: 'string',
|
|
94
94
|
description: 'package author email',
|
|
95
|
-
initial: gitConfig
|
|
95
|
+
initial: gitConfig.email,
|
|
96
96
|
}),
|
|
97
97
|
defineTemplateOption({
|
|
98
98
|
name: 'license',
|
|
@@ -534,3 +534,17 @@ async function resolveLatestDeps(deps: Record<string, string | undefined>) {
|
|
|
534
534
|
|
|
535
535
|
return latestDeps
|
|
536
536
|
}
|
|
537
|
+
|
|
538
|
+
function getGitUserConfig(cwd: string): {user?: string; email?: string} {
|
|
539
|
+
let user: string | undefined
|
|
540
|
+
let email: string | undefined
|
|
541
|
+
|
|
542
|
+
try {
|
|
543
|
+
user = execSync('git config user.name', {encoding: 'utf8', cwd}).trim() || undefined
|
|
544
|
+
email = execSync('git config user.email', {encoding: 'utf8', cwd}).trim() || undefined
|
|
545
|
+
} catch {
|
|
546
|
+
/* ignore */
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return {user, email}
|
|
550
|
+
}
|