@sanity/plugin-kit 4.0.20 → 5.0.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/assets/inject/semver-workflow/.github/workflows/main.yml +3 -3
- package/assets/inject/semver-workflow/.husky/commit-msg +0 -0
- package/assets/inject/semver-workflow/.husky/pre-commit +0 -0
- package/assets/inject/ui-workshop/src/__workshop__/props.tsx +2 -1
- package/bin/plugin-kit.js +3 -1
- package/dist/{_chunks-cjs/cli.js → _chunks-es/index.js} +53 -63
- package/dist/_chunks-es/index.js.map +1 -0
- package/dist/{_chunks-cjs/init2.js → _chunks-es/init.js} +25 -23
- package/dist/_chunks-es/init.js.map +1 -0
- package/dist/_chunks-es/init2.js +140 -0
- package/dist/_chunks-es/init2.js.map +1 -0
- package/{src/cmds/inject.ts → dist/_chunks-es/inject.js} +18 -32
- package/dist/{_chunks-cjs → _chunks-es}/inject.js.map +1 -1
- package/dist/_chunks-es/link-watch.js +91 -0
- package/dist/_chunks-es/link-watch.js.map +1 -0
- package/dist/_chunks-es/load-package-config.js +22 -0
- package/dist/_chunks-es/load-package-config.js.map +1 -0
- package/dist/_chunks-es/package.js +1759 -0
- package/dist/_chunks-es/package.js.map +1 -0
- package/dist/_chunks-es/package2.js +9 -0
- package/dist/{_chunks-cjs → _chunks-es}/package2.js.map +1 -1
- package/dist/_chunks-es/ts.js +171 -0
- package/dist/_chunks-es/ts.js.map +1 -0
- package/dist/_chunks-es/verify-package.js +92 -0
- package/dist/_chunks-es/verify-package.js.map +1 -0
- package/dist/_chunks-es/verify-studio.js +61 -0
- package/dist/_chunks-es/verify-studio.js.map +1 -0
- package/dist/_chunks-es/version.js +50 -0
- package/dist/_chunks-es/version.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +58 -116
- package/LICENSE +0 -21
- package/dist/_chunks-cjs/cli.js.map +0 -1
- package/dist/_chunks-cjs/init.js +0 -892
- package/dist/_chunks-cjs/init.js.map +0 -1
- package/dist/_chunks-cjs/init2.js.map +0 -1
- package/dist/_chunks-cjs/inject.js +0 -54
- package/dist/_chunks-cjs/link-watch.js +0 -84
- package/dist/_chunks-cjs/link-watch.js.map +0 -1
- package/dist/_chunks-cjs/package.js +0 -1809
- package/dist/_chunks-cjs/package.js.map +0 -1
- package/dist/_chunks-cjs/package2.js +0 -8
- package/dist/_chunks-cjs/ts.js +0 -160732
- package/dist/_chunks-cjs/ts.js.map +0 -1
- package/dist/_chunks-cjs/verify-package.js +0 -75
- package/dist/_chunks-cjs/verify-package.js.map +0 -1
- package/dist/_chunks-cjs/verify-studio.js +0 -57
- package/dist/_chunks-cjs/verify-studio.js.map +0 -1
- package/dist/_chunks-cjs/version.js +0 -51
- package/dist/_chunks-cjs/version.js.map +0 -1
- package/dist/cli.d.ts +0 -4
- package/dist/cli.js +0 -6
- package/dist/cli.js.map +0 -1
- package/src/actions/init.ts +0 -95
- package/src/actions/inject.ts +0 -399
- package/src/actions/link-watch.ts +0 -98
- package/src/actions/verify/types.ts +0 -56
- package/src/actions/verify/validations.ts +0 -505
- package/src/actions/verify/verify-common.ts +0 -93
- package/src/actions/verify-package.ts +0 -103
- package/src/actions/verify-studio.ts +0 -58
- package/src/cli.ts +0 -77
- package/src/cmds/index.ts +0 -20
- package/src/cmds/init.ts +0 -90
- package/src/cmds/link-watch.ts +0 -50
- package/src/cmds/verify-package.ts +0 -36
- package/src/cmds/verify-studio.ts +0 -36
- package/src/cmds/version.ts +0 -67
- package/src/configs/banned-packages.ts +0 -27
- package/src/configs/buildExtensions.ts +0 -1
- package/src/configs/default-source.ts +0 -64
- package/src/configs/eslint.ts +0 -51
- package/src/configs/forced-package-versions.ts +0 -12
- package/src/configs/git.ts +0 -68
- package/src/configs/pkg-config.ts +0 -30
- package/src/configs/prettier.ts +0 -11
- package/src/configs/tsconfig.ts +0 -78
- package/src/configs/uselessFiles.ts +0 -29
- package/src/constants.ts +0 -15
- package/src/dependencies/find.ts +0 -193
- package/src/dependencies/import-linter.ts +0 -95
- package/src/index.ts +0 -1
- package/src/npm/manager.ts +0 -44
- package/src/npm/package.ts +0 -427
- package/src/npm/publish.ts +0 -9
- package/src/npm/resolveLatestVersions.ts +0 -31
- package/src/presets/presets.ts +0 -54
- package/src/presets/renovatebot.ts +0 -21
- package/src/presets/semver-workflow.ts +0 -186
- package/src/presets/ui-workshop.ts +0 -97
- package/src/presets/ui.ts +0 -67
- package/src/sanity/manifest.ts +0 -340
- package/src/sharedFlags.ts +0 -14
- package/src/util/command-parser.ts +0 -36
- package/src/util/errorToUndefined.ts +0 -7
- package/src/util/files.ts +0 -260
- package/src/util/log.ts +0 -44
- package/src/util/prompt.ts +0 -70
- package/src/util/readme.ts +0 -88
- package/src/util/request.ts +0 -11
- package/src/util/ts.ts +0 -19
- package/src/util/user.ts +0 -129
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {loadConfig as loadPackageConfig} from '@sanity/pkg-utils'
|
|
2
|
-
import {getPackage} from '../npm/package'
|
|
3
|
-
import log from '../util/log'
|
|
4
|
-
import {cliName, urls} from '../constants'
|
|
5
|
-
import {validateImports} from '../dependencies/import-linter'
|
|
6
|
-
import outdent from 'outdent'
|
|
7
|
-
import chalk from 'chalk'
|
|
8
|
-
import {
|
|
9
|
-
createValidator,
|
|
10
|
-
runTscMaybe,
|
|
11
|
-
VerifyFlags,
|
|
12
|
-
VerifyPackageConfig,
|
|
13
|
-
} from './verify/verify-common'
|
|
14
|
-
import {PackageJson} from './verify/types'
|
|
15
|
-
import {validateSanityDependencies, validateStudioConfig} from './verify/validations'
|
|
16
|
-
import {readTSConfig} from '../util/ts'
|
|
17
|
-
|
|
18
|
-
export async function verifyStudio({basePath, flags}: {basePath: string; flags: VerifyFlags}) {
|
|
19
|
-
let errors: string[] = []
|
|
20
|
-
|
|
21
|
-
const packageJson: PackageJson = await getPackage({basePath, validate: false})
|
|
22
|
-
const verifyConfig: VerifyPackageConfig = packageJson.sanityPlugin?.verifyPackage || {}
|
|
23
|
-
const packageConfig = await loadPackageConfig({cwd: basePath})
|
|
24
|
-
const tsconfig = packageConfig?.tsconfig ?? 'tsconfig.json'
|
|
25
|
-
|
|
26
|
-
const validation = createValidator(verifyConfig, flags, errors)
|
|
27
|
-
|
|
28
|
-
const ts = await readTSConfig({basePath, filename: tsconfig})
|
|
29
|
-
|
|
30
|
-
await validation('studioConfig', async () => validateStudioConfig({basePath}))
|
|
31
|
-
await validation('dependencies', async () => validateSanityDependencies(packageJson))
|
|
32
|
-
await validation('eslintImports', async () => validateImports({basePath}))
|
|
33
|
-
|
|
34
|
-
if (errors.length) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
outdent`
|
|
37
|
-
Detected validation issues!
|
|
38
|
-
This Sanity Studio is not completely V3 ready. Fix the issues starting from the top, or disable any checks you deem unnecessary.
|
|
39
|
-
|
|
40
|
-
More information is available here:
|
|
41
|
-
- Migration guide: ${urls.migrationGuideStudio}
|
|
42
|
-
- Reference documentation: ${urls.refDocs}
|
|
43
|
-
|
|
44
|
-
${chalk.grey(
|
|
45
|
-
`To fail-fast on first detected issue run:\nnpx ${cliName} verify-studio --single`,
|
|
46
|
-
)}
|
|
47
|
-
`.trimStart(),
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
await runTscMaybe(verifyConfig, ts)
|
|
52
|
-
|
|
53
|
-
log.success(
|
|
54
|
-
outdent`
|
|
55
|
-
No outstanding upgrade issues detected. Studio is V3 ready!
|
|
56
|
-
`.trim(),
|
|
57
|
-
)
|
|
58
|
-
}
|
package/src/cli.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import meow from 'meow'
|
|
2
|
-
import log from './util/log'
|
|
3
|
-
import commands from './cmds'
|
|
4
|
-
import sharedFlags from './sharedFlags'
|
|
5
|
-
import {cliName} from './constants'
|
|
6
|
-
|
|
7
|
-
/** @public */
|
|
8
|
-
export async function cliEntry(argv = process.argv, autoExit = true) {
|
|
9
|
-
const cli = meow(
|
|
10
|
-
`
|
|
11
|
-
Usage
|
|
12
|
-
$ ${cliName} [--help] [--debug] <command> [<args>]
|
|
13
|
-
|
|
14
|
-
These are common commands used in various situations:
|
|
15
|
-
|
|
16
|
-
init Create a new Sanity plugin
|
|
17
|
-
inject Inject config into an existing Sanity v3 plugin
|
|
18
|
-
verify-package Check that a Sanity plugin package follows V3 conventions. Prints upgrade steps.
|
|
19
|
-
verify-studio Check that a Sanity Studio follows V3 conventions. Prints upgrade steps.
|
|
20
|
-
link-watch Recompiles plugin automatically on changes and runs yalc push --publish
|
|
21
|
-
version Show the version of ${cliName} currently installed
|
|
22
|
-
|
|
23
|
-
Options
|
|
24
|
-
--silent Do not print info and warning messages
|
|
25
|
-
--verbose Log everything. This option conflicts with --silent
|
|
26
|
-
--debug Print stack trace on errors
|
|
27
|
-
--version Output the version number
|
|
28
|
-
--help Output usage information
|
|
29
|
-
|
|
30
|
-
Examples
|
|
31
|
-
# Init a new plugin in current directory
|
|
32
|
-
$ ${cliName} init
|
|
33
|
-
|
|
34
|
-
# Init a new plugin in my-sanity-plugin directory
|
|
35
|
-
$ ${cliName} init my-sanity-plugin
|
|
36
|
-
|
|
37
|
-
# Check that a Sanity plugin package in current directory follows V3 conventions
|
|
38
|
-
$ ${cliName} verify-package
|
|
39
|
-
|
|
40
|
-
# Check that a Sanity Studio in current directory follows V3 conventions
|
|
41
|
-
$ ${cliName} verify-studio
|
|
42
|
-
`,
|
|
43
|
-
{
|
|
44
|
-
autoHelp: false,
|
|
45
|
-
flags: sharedFlags,
|
|
46
|
-
argv: argv.slice(2),
|
|
47
|
-
},
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
const commandName = cli.input[0]
|
|
51
|
-
if (!commandName) {
|
|
52
|
-
cli.showHelp() // Exits
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!(commandName in commands)) {
|
|
56
|
-
console.error(`Unknown command "${commandName}"`)
|
|
57
|
-
cli.showHelp() // Exits
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (cli.flags.silent && cli.flags.verbose) {
|
|
61
|
-
log.error(`--silent and --verbose are mutually exclusive`)
|
|
62
|
-
cli.showHelp() // Exits
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Lazy-load command
|
|
66
|
-
const cmd = commands[commandName as keyof typeof commands]
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
log.setVerbosity(cli.flags)
|
|
70
|
-
await cmd({argv: argv.slice(3)})
|
|
71
|
-
} catch (err: any) {
|
|
72
|
-
log.error(err instanceof TypeError || cli.flags.debug ? err.stack : err.message)
|
|
73
|
-
|
|
74
|
-
// eslint-disable-next-line no-process-exit
|
|
75
|
-
process.exit(1)
|
|
76
|
-
}
|
|
77
|
-
}
|
package/src/cmds/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
init: async (options: {argv: string[]}) => {
|
|
3
|
-
await (await import('./init')).default(options)
|
|
4
|
-
},
|
|
5
|
-
inject: async (options: {argv: string[]}) => {
|
|
6
|
-
await (await import('./inject')).default(options)
|
|
7
|
-
},
|
|
8
|
-
'link-watch': async (options: {argv: string[]}) => {
|
|
9
|
-
await (await import('./link-watch')).default(options)
|
|
10
|
-
},
|
|
11
|
-
'verify-package': async (options: {argv: string[]}) => {
|
|
12
|
-
await (await import('./verify-package')).default(options)
|
|
13
|
-
},
|
|
14
|
-
'verify-studio': async (options: {argv: string[]}) => {
|
|
15
|
-
await (await import('./verify-studio')).default(options)
|
|
16
|
-
},
|
|
17
|
-
version: async (options: {argv: string[]}) => {
|
|
18
|
-
await (await import('./version')).default(options)
|
|
19
|
-
},
|
|
20
|
-
}
|
package/src/cmds/init.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import meow from 'meow'
|
|
3
|
-
import log from '../util/log'
|
|
4
|
-
import {init, initFlags} from '../actions/init'
|
|
5
|
-
import {isEmptyish, ensureDir} from '../util/files'
|
|
6
|
-
import {installDependencies, promptForPackageManager} from '../npm/manager'
|
|
7
|
-
import {findStudioV3Config, hasSanityJson} from '../sanity/manifest'
|
|
8
|
-
import {prompt} from '../util/prompt'
|
|
9
|
-
import {cliName} from '../constants'
|
|
10
|
-
import {presetHelpList} from '../presets/presets'
|
|
11
|
-
|
|
12
|
-
const description = `Initialize a new Sanity plugin`
|
|
13
|
-
|
|
14
|
-
const help = `
|
|
15
|
-
Usage
|
|
16
|
-
$ ${cliName} init [dir] [<args>]
|
|
17
|
-
|
|
18
|
-
Options
|
|
19
|
-
--no-eslint Disables ESLint config and dependencies from being added
|
|
20
|
-
--no-prettier Disables prettier config and dependencies from being added
|
|
21
|
-
--no-typescript Disables typescript config and dependencies from being added
|
|
22
|
-
--no-license Disables LICENSE + package.json license field from being added
|
|
23
|
-
--no-editorconfig Disables .editorconfig from being added
|
|
24
|
-
--no-gitignore Disables .gitignore from being added
|
|
25
|
-
--no-scripts Disables scripts from being added to package.json
|
|
26
|
-
--no-install Disables automatically running package manager install
|
|
27
|
-
|
|
28
|
-
--name [package-name] Use the provided package-name
|
|
29
|
-
--author [name] Use the provided author
|
|
30
|
-
--repo [url] Use the provided repo url
|
|
31
|
-
--license [spdx] Use the license with the given SPDX identifier
|
|
32
|
-
--force No promt when overwriting files
|
|
33
|
-
|
|
34
|
-
--preset [preset-name] Adds config and files from a named preset. --preset can be supplied multiple times.
|
|
35
|
-
The following presets are available:
|
|
36
|
-
${presetHelpList(30)}
|
|
37
|
-
|
|
38
|
-
Examples
|
|
39
|
-
# Initialize a new plugin in the current directory
|
|
40
|
-
$ ${cliName} init
|
|
41
|
-
|
|
42
|
-
# Initialize a plugin in the directory ~/my-plugin
|
|
43
|
-
$ ${cliName} init ~/my-plugin
|
|
44
|
-
|
|
45
|
-
# Don't add eslint or prettier
|
|
46
|
-
$ ${cliName} init --no-eslint --no-prettier
|
|
47
|
-
`
|
|
48
|
-
|
|
49
|
-
async function run({argv}: {argv: string[]}) {
|
|
50
|
-
const cli = meow(help, {flags: initFlags, argv, description})
|
|
51
|
-
const basePath = path.resolve(cli.input[0] || process.cwd())
|
|
52
|
-
|
|
53
|
-
const {exists, isRoot} = await hasSanityJson(basePath)
|
|
54
|
-
if (exists && isRoot) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`sanity.json has a "root" property set to true - are you trying to init into a studio instead of a plugin?`,
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const {v3ConfigFile} = await findStudioV3Config(basePath)
|
|
61
|
-
if (v3ConfigFile) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
`${v3ConfigFile} exsists - are you trying to init into a studio instead of a plugin?`,
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
log.info('Initializing new plugin in "%s"', basePath)
|
|
68
|
-
if (
|
|
69
|
-
!cli.flags.force &&
|
|
70
|
-
!(await isEmptyish(basePath)) &&
|
|
71
|
-
!(await prompt('Directory is not empty, proceed?', {type: 'confirm', default: false}))
|
|
72
|
-
) {
|
|
73
|
-
log.error('Directory is not empty. Cancelled.')
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
await ensureDir(basePath)
|
|
78
|
-
await init({basePath, flags: cli.flags})
|
|
79
|
-
if (cli.flags.install) {
|
|
80
|
-
if (await installDependencies(await promptForPackageManager(), {cwd: basePath})) {
|
|
81
|
-
log.info('Done!')
|
|
82
|
-
} else {
|
|
83
|
-
log.error('Failed to install dependencies, try manually running `npm install`')
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
log.info('Dependency installation skipped.')
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default run
|
package/src/cmds/link-watch.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import meow from 'meow'
|
|
3
|
-
import pkg from '../../package.json'
|
|
4
|
-
import sharedFlags from '../sharedFlags'
|
|
5
|
-
import {linkWatch} from '../actions/link-watch'
|
|
6
|
-
|
|
7
|
-
const description = `Run the watch command and pushes any changes to yalc`
|
|
8
|
-
|
|
9
|
-
const help = `
|
|
10
|
-
Usage
|
|
11
|
-
$ ${pkg.binname} link-watch [<args>]
|
|
12
|
-
|
|
13
|
-
Options
|
|
14
|
-
--silent Do not print info and warning messages
|
|
15
|
-
--verbose Log everything. This option conflicts with --silent
|
|
16
|
-
--version Output the version number
|
|
17
|
-
--help Output usage information
|
|
18
|
-
|
|
19
|
-
Configuration
|
|
20
|
-
To override the default watch command configuration, provide an override in package.json under sanityPlugin:
|
|
21
|
-
{
|
|
22
|
-
"sanityPlugin": {
|
|
23
|
-
"watchCommand": "microbundle watch --format modern,esm,cjs --jsx React.createElement --jsxImportSource react --css inline",
|
|
24
|
-
"linkWatch": {
|
|
25
|
-
"command": "npm run watch",
|
|
26
|
-
"extensions": "js,png,svg,gif,jpeg,css"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
Examples
|
|
32
|
-
# Run the watch command and pushes any changes to yalc
|
|
33
|
-
$ ${pkg.binname} link-watch
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
const flags = {
|
|
37
|
-
...sharedFlags,
|
|
38
|
-
watch: {
|
|
39
|
-
type: 'boolean',
|
|
40
|
-
default: false,
|
|
41
|
-
},
|
|
42
|
-
} as const
|
|
43
|
-
|
|
44
|
-
function run({argv}: {argv: string[]}) {
|
|
45
|
-
const cli = meow(help, {flags, argv, description})
|
|
46
|
-
const basePath = path.resolve(cli.input[0] || process.cwd())
|
|
47
|
-
return linkWatch({basePath})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default run
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import meow from 'meow'
|
|
3
|
-
import {verifyPackage} from '../actions/verify-package'
|
|
4
|
-
import {cliName} from '../constants'
|
|
5
|
-
import {verifyFlags} from '../actions/verify/verify-common'
|
|
6
|
-
|
|
7
|
-
const description = `Verify that a Sanity plugin package is v3 compatible, and print upgrade steps if not.`
|
|
8
|
-
|
|
9
|
-
const help = `
|
|
10
|
-
Usage
|
|
11
|
-
$ ${cliName} verify-package [dir] [<args>]
|
|
12
|
-
|
|
13
|
-
Options
|
|
14
|
-
--single Enables fail-fast mode: Will only output the first validation that fails.
|
|
15
|
-
--silent Do not print info and warning messages
|
|
16
|
-
--verbose Log everything. This option conflicts with --silent
|
|
17
|
-
--version Output the version number
|
|
18
|
-
--help Output usage information
|
|
19
|
-
|
|
20
|
-
Each check will describe how they can be individually disabled.
|
|
21
|
-
|
|
22
|
-
Examples
|
|
23
|
-
# Verify Sanity plugin package in current directory
|
|
24
|
-
$ ${cliName} verify-package
|
|
25
|
-
|
|
26
|
-
# Verify Sanity plugin package in my-plugin directory in silent mode
|
|
27
|
-
$ ${cliName} verify-package my-plugin-directory --silent
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
function run({argv}: {argv: string[]}) {
|
|
31
|
-
const cli = meow(help, {flags: verifyFlags, argv, description})
|
|
32
|
-
const basePath = path.resolve(cli.input[0] || process.cwd())
|
|
33
|
-
return verifyPackage({basePath, flags: cli.flags})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default run
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import meow from 'meow'
|
|
3
|
-
import {cliName} from '../constants'
|
|
4
|
-
import {verifyFlags} from '../actions/verify/verify-common'
|
|
5
|
-
import {verifyStudio} from '../actions/verify-studio'
|
|
6
|
-
|
|
7
|
-
const description = `Verify that a Sanity Studio is configured correctly for v3, and print upgrade steps if not.`
|
|
8
|
-
|
|
9
|
-
const help = `
|
|
10
|
-
Usage
|
|
11
|
-
$ ${cliName} verify-studio [dir] [<args>]
|
|
12
|
-
|
|
13
|
-
Options
|
|
14
|
-
--single Enables fail-fast mode: Will only output the first validation that fails.
|
|
15
|
-
--silent Do not print info and warning messages
|
|
16
|
-
--verbose Log everything. This option conflicts with --silent
|
|
17
|
-
--version Output the version number
|
|
18
|
-
--help Output usage information
|
|
19
|
-
|
|
20
|
-
Each check will describe how they can be individually disabled.
|
|
21
|
-
|
|
22
|
-
Examples
|
|
23
|
-
# Verify Sanity Studio in current directory
|
|
24
|
-
$ ${cliName} verify-studio
|
|
25
|
-
|
|
26
|
-
# Verify Sanity Studio in my-sanity-studio directory in silent mode
|
|
27
|
-
$ ${cliName} verify-studio my-sanity-studio --silent
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
function run({argv}: {argv: string[]}) {
|
|
31
|
-
const cli = meow(help, {flags: verifyFlags, argv, description})
|
|
32
|
-
const basePath = path.resolve(cli.input[0] || process.cwd())
|
|
33
|
-
return verifyStudio({basePath, flags: cli.flags})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default run
|
package/src/cmds/version.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import meow from 'meow'
|
|
2
|
-
import pkg from '../../package.json'
|
|
3
|
-
import log from '../util/log'
|
|
4
|
-
import sharedFlags from '../sharedFlags'
|
|
5
|
-
|
|
6
|
-
const description = `Show the installed version of ${pkg.name}`
|
|
7
|
-
|
|
8
|
-
const help = `
|
|
9
|
-
Usage
|
|
10
|
-
$ ${pkg.binname} version
|
|
11
|
-
|
|
12
|
-
Options
|
|
13
|
-
--major Show only the major version
|
|
14
|
-
--minor Show only the minor version
|
|
15
|
-
--patch Show only the patch version
|
|
16
|
-
|
|
17
|
-
Examples
|
|
18
|
-
$ ${pkg.binname} version
|
|
19
|
-
${pkg.name} version ${pkg.version}
|
|
20
|
-
|
|
21
|
-
$ ${pkg.binname} version --major
|
|
22
|
-
${pkg.version.split('.')[0]}
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
const flags = {
|
|
26
|
-
...sharedFlags,
|
|
27
|
-
|
|
28
|
-
major: {
|
|
29
|
-
type: 'boolean',
|
|
30
|
-
default: false,
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
minor: {
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
default: false,
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
patch: {
|
|
39
|
-
type: 'boolean',
|
|
40
|
-
default: false,
|
|
41
|
-
},
|
|
42
|
-
} as const
|
|
43
|
-
|
|
44
|
-
function run({argv}: {argv: string[]}) {
|
|
45
|
-
const cli = meow(help, {flags, argv, description})
|
|
46
|
-
const versionParts = pkg.version.split('.')
|
|
47
|
-
const versionNames = ['major', 'minor', 'patch']
|
|
48
|
-
const versionFlags = versionNames.filter((flagName) => cli.flags[flagName])
|
|
49
|
-
const versionFlag = versionFlags[0]
|
|
50
|
-
const numVersionFlags = versionFlags.length
|
|
51
|
-
|
|
52
|
-
if (numVersionFlags === 0) {
|
|
53
|
-
log.msg(`${pkg.name} version ${pkg.version}`)
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (numVersionFlags > 1) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`--major, --minor and --patch are mutually exclusive - only one can be used at a time`,
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const partIndex = versionNames.indexOf(versionFlag)
|
|
64
|
-
log.msg(versionParts[partIndex])
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default run
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const mergedPackages = [
|
|
2
|
-
'@sanity/base',
|
|
3
|
-
'@sanity/core',
|
|
4
|
-
'@sanity/types',
|
|
5
|
-
'@sanity/data-aspects',
|
|
6
|
-
'@sanity/default-layout',
|
|
7
|
-
'@sanity/default-login',
|
|
8
|
-
'@sanity/desk-tool',
|
|
9
|
-
'@sanity/field',
|
|
10
|
-
'@sanity/form-builder',
|
|
11
|
-
'@sanity/initial-value-templates',
|
|
12
|
-
'@sanity/language-filter',
|
|
13
|
-
'@sanity/production-preview',
|
|
14
|
-
'@sanity/react-hooks',
|
|
15
|
-
'@sanity/resolver',
|
|
16
|
-
'@sanity/state-router',
|
|
17
|
-
'@sanity/structure',
|
|
18
|
-
'@sanity/studio-hints',
|
|
19
|
-
].sort()
|
|
20
|
-
|
|
21
|
-
export const deprecatedDevDeps = [
|
|
22
|
-
'tsdx',
|
|
23
|
-
'sanipack',
|
|
24
|
-
'parcel',
|
|
25
|
-
'@parcel/packager-ts',
|
|
26
|
-
'@parcel/transformer-typescript-types',
|
|
27
|
-
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const buildExtensions = ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx']
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import outdent from 'outdent'
|
|
2
|
-
import {PackageJson} from '../actions/verify/types'
|
|
3
|
-
|
|
4
|
-
export function defaultSourceJs(pkg: PackageJson) {
|
|
5
|
-
return (
|
|
6
|
-
outdent`
|
|
7
|
-
import {definePlugin} from 'sanity'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Usage in sanity.config.js (or .ts)
|
|
11
|
-
*
|
|
12
|
-
* \`\`\`js
|
|
13
|
-
* import {defineConfig} from 'sanity'
|
|
14
|
-
* import {myPlugin} from '${pkg.name}'
|
|
15
|
-
*
|
|
16
|
-
* export default defineConfig({
|
|
17
|
-
* // ...
|
|
18
|
-
* plugins: [myPlugin({})],
|
|
19
|
-
* })
|
|
20
|
-
* \`\`\`
|
|
21
|
-
*/
|
|
22
|
-
export const myPlugin = definePlugin((config = {}) => {
|
|
23
|
-
// eslint-disable-next-line no-console
|
|
24
|
-
console.log(\`hello from ${pkg.name}\`)
|
|
25
|
-
return {
|
|
26
|
-
name: '${pkg.name}',
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
`.trimStart() + '\n'
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function defaultSourceTs(pkg: PackageJson) {
|
|
34
|
-
return (
|
|
35
|
-
outdent`
|
|
36
|
-
import {definePlugin} from 'sanity'
|
|
37
|
-
|
|
38
|
-
interface MyPluginConfig {
|
|
39
|
-
/* nothing here yet */
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Usage in \`sanity.config.ts\` (or .js)
|
|
44
|
-
*
|
|
45
|
-
* \`\`\`ts
|
|
46
|
-
* import {defineConfig} from 'sanity'
|
|
47
|
-
* import {myPlugin} from '${pkg.name}'
|
|
48
|
-
*
|
|
49
|
-
* export default defineConfig({
|
|
50
|
-
* // ...
|
|
51
|
-
* plugins: [myPlugin()],
|
|
52
|
-
* })
|
|
53
|
-
* \`\`\`
|
|
54
|
-
*/
|
|
55
|
-
export const myPlugin = definePlugin<MyPluginConfig | void>((config = {}) => {
|
|
56
|
-
// eslint-disable-next-line no-console
|
|
57
|
-
console.log('hello from ${pkg.name}')
|
|
58
|
-
return {
|
|
59
|
-
name: '${pkg.name}',
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
`.trimStart() + '\n'
|
|
63
|
-
)
|
|
64
|
-
}
|
package/src/configs/eslint.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {InjectTemplate} from '../actions/inject'
|
|
2
|
-
import {InitFlags} from '../actions/init'
|
|
3
|
-
|
|
4
|
-
export function eslintrcTemplate(options: {flags: InitFlags}): InjectTemplate {
|
|
5
|
-
const {flags} = options
|
|
6
|
-
|
|
7
|
-
const eslintConfig = {
|
|
8
|
-
root: true,
|
|
9
|
-
env: {
|
|
10
|
-
node: true,
|
|
11
|
-
browser: true,
|
|
12
|
-
},
|
|
13
|
-
extends: [
|
|
14
|
-
'sanity',
|
|
15
|
-
flags.typescript && 'sanity/typescript',
|
|
16
|
-
'sanity/react',
|
|
17
|
-
'plugin:react-hooks/recommended',
|
|
18
|
-
flags.prettier && 'plugin:prettier/recommended',
|
|
19
|
-
'plugin:react/jsx-runtime',
|
|
20
|
-
].filter(Boolean),
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
type: 'template',
|
|
25
|
-
force: flags.force,
|
|
26
|
-
to: '.eslintrc',
|
|
27
|
-
value: JSON.stringify(eslintConfig, null, 2),
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function eslintignoreTemplate(options: {flags: InitFlags; outDir: string}): InjectTemplate {
|
|
32
|
-
const {flags, outDir} = options
|
|
33
|
-
|
|
34
|
-
const patterns = [
|
|
35
|
-
'.eslintrc.js',
|
|
36
|
-
'commitlint.config.js',
|
|
37
|
-
outDir,
|
|
38
|
-
'lint-staged.config.js',
|
|
39
|
-
flags.typescript ? 'package.config.ts' : 'package.config.js',
|
|
40
|
-
flags.typescript ? '*.js' : '',
|
|
41
|
-
].filter(Boolean)
|
|
42
|
-
|
|
43
|
-
patterns.sort()
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
type: 'template',
|
|
47
|
-
force: flags.force,
|
|
48
|
-
to: '.eslintignore',
|
|
49
|
-
value: patterns.join('\n'),
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const forcedPackageVersions = {}
|
|
2
|
-
|
|
3
|
-
export const forcedDevPackageVersions = forcedPackageVersions
|
|
4
|
-
|
|
5
|
-
export const forcedPeerPackageVersions = {
|
|
6
|
-
react: '^18',
|
|
7
|
-
'react-dom': '^18',
|
|
8
|
-
'@types/react': '^18',
|
|
9
|
-
'@types/react-dom': '^18',
|
|
10
|
-
sanity: '^3',
|
|
11
|
-
'styled-components': '^5.2',
|
|
12
|
-
}
|
package/src/configs/git.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {outdent} from 'outdent'
|
|
2
|
-
import {InjectTemplate} from '../actions/inject'
|
|
3
|
-
|
|
4
|
-
export function gitignoreTemplate(): InjectTemplate {
|
|
5
|
-
return {
|
|
6
|
-
type: 'template',
|
|
7
|
-
to: '.gitignore',
|
|
8
|
-
value: outdent`
|
|
9
|
-
# Logs
|
|
10
|
-
logs
|
|
11
|
-
*.log
|
|
12
|
-
npm-debug.log*
|
|
13
|
-
|
|
14
|
-
# Runtime data
|
|
15
|
-
pids
|
|
16
|
-
*.pid
|
|
17
|
-
*.seed
|
|
18
|
-
|
|
19
|
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
20
|
-
lib-cov
|
|
21
|
-
|
|
22
|
-
# Coverage directory used by tools like istanbul
|
|
23
|
-
coverage
|
|
24
|
-
|
|
25
|
-
# nyc test coverage
|
|
26
|
-
.nyc_output
|
|
27
|
-
|
|
28
|
-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
|
29
|
-
.grunt
|
|
30
|
-
|
|
31
|
-
# node-waf configuration
|
|
32
|
-
.lock-wscript
|
|
33
|
-
|
|
34
|
-
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
|
35
|
-
build/Release
|
|
36
|
-
|
|
37
|
-
# Dependency directories
|
|
38
|
-
node_modules
|
|
39
|
-
jspm_packages
|
|
40
|
-
|
|
41
|
-
# Optional npm cache directory
|
|
42
|
-
.npm
|
|
43
|
-
|
|
44
|
-
# Optional REPL history
|
|
45
|
-
.node_repl_history
|
|
46
|
-
|
|
47
|
-
# macOS finder cache file
|
|
48
|
-
.DS_Store
|
|
49
|
-
|
|
50
|
-
# VS Code settings
|
|
51
|
-
.vscode
|
|
52
|
-
|
|
53
|
-
# IntelliJ
|
|
54
|
-
.idea
|
|
55
|
-
*.iml
|
|
56
|
-
|
|
57
|
-
# Cache
|
|
58
|
-
.cache
|
|
59
|
-
|
|
60
|
-
# Yalc
|
|
61
|
-
.yalc
|
|
62
|
-
yalc.lock
|
|
63
|
-
|
|
64
|
-
# npm package zips
|
|
65
|
-
*.tgz
|
|
66
|
-
`,
|
|
67
|
-
}
|
|
68
|
-
}
|