diff --git a/package-lock.json b/package-lock.json index 26dda2c2..44c17fa1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,6 +63,7 @@ "json5": "^2.2.1", "lint-staged": "^13.0.3", "prettier": "^2.7.1", + "prettier-plugin-packagejson": "^2.3.0", "readdirp": "^3.6.0", "rimraf": "^3.0.2", "sanity": "3.0.0-rc.0", @@ -7125,6 +7126,15 @@ "node": ">=8" } }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/detect-node-es": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", @@ -8983,6 +8993,15 @@ "node": ">=0.10.0" } }, + "node_modules/git-hooks-list": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/git-hooks-list/-/git-hooks-list-1.0.3.tgz", + "integrity": "sha512-Y7wLWcrLUXwk2noSka166byGCvhMtDRpgHdzCno1UQv/n/Hegp++a2xBWJL1lJarnKD3SWaljD+0z1ztqxuKyQ==", + "dev": true, + "funding": { + "url": "https://github.com/fisker/git-hooks-list?sponsor=1" + } + }, "node_modules/git-log-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/git-log-parser/-/git-log-parser-1.2.0.tgz", @@ -15310,6 +15329,23 @@ "node": ">=6.0.0" } }, + "node_modules/prettier-plugin-packagejson": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.3.0.tgz", + "integrity": "sha512-2SAPMMk1UDkqsB7DifWKcwCm6VC52JXMrzLHfbcQHJRWhRCj9zziOy+s+2XOyPBeyqFqS+A/1IKzOrxKFTo6pw==", + "dev": true, + "dependencies": { + "sort-package-json": "1.57.0" + }, + "peerDependencies": { + "prettier": ">= 1.16.0" + }, + "peerDependenciesMeta": { + "prettier": { + "optional": true + } + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", @@ -16916,6 +16952,57 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/sort-object-keys": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sort-object-keys/-/sort-object-keys-1.1.3.tgz", + "integrity": "sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg==", + "dev": true + }, + "node_modules/sort-package-json": { + "version": "1.57.0", + "resolved": "https://registry.npmjs.org/sort-package-json/-/sort-package-json-1.57.0.tgz", + "integrity": "sha512-FYsjYn2dHTRb41wqnv+uEqCUvBpK3jZcTp9rbz2qDTmel7Pmdtf+i2rLaaPMRZeSVM60V3Se31GyWFpmKs4Q5Q==", + "dev": true, + "dependencies": { + "detect-indent": "^6.0.0", + "detect-newline": "3.1.0", + "git-hooks-list": "1.0.3", + "globby": "10.0.0", + "is-plain-obj": "2.1.0", + "sort-object-keys": "^1.1.3" + }, + "bin": { + "sort-package-json": "cli.js" + } + }, + "node_modules/sort-package-json/node_modules/globby": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-10.0.0.tgz", + "integrity": "sha512-3LifW9M4joGZasyYPz2A1U74zbC/45fvpXUvO/9KbSa+VV0aGZarWkfdgKyR9sExNP0t0x0ss/UMJpNpcaTspw==", + "dev": true, + "dependencies": { + "@types/glob": "^7.1.1", + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.0.3", + "glob": "^7.1.3", + "ignore": "^5.1.1", + "merge2": "^1.2.3", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sort-package-json/node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -26188,6 +26275,12 @@ "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", "integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==" }, + "detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true + }, "detect-node-es": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", @@ -27498,6 +27591,12 @@ "homedir-polyfill": "^1.0.0" } }, + "git-hooks-list": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/git-hooks-list/-/git-hooks-list-1.0.3.tgz", + "integrity": "sha512-Y7wLWcrLUXwk2noSka166byGCvhMtDRpgHdzCno1UQv/n/Hegp++a2xBWJL1lJarnKD3SWaljD+0z1ztqxuKyQ==", + "dev": true + }, "git-log-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/git-log-parser/-/git-log-parser-1.2.0.tgz", @@ -32114,6 +32213,15 @@ "fast-diff": "^1.1.2" } }, + "prettier-plugin-packagejson": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.3.0.tgz", + "integrity": "sha512-2SAPMMk1UDkqsB7DifWKcwCm6VC52JXMrzLHfbcQHJRWhRCj9zziOy+s+2XOyPBeyqFqS+A/1IKzOrxKFTo6pw==", + "dev": true, + "requires": { + "sort-package-json": "1.57.0" + } + }, "pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", @@ -33383,6 +33491,50 @@ } } }, + "sort-object-keys": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sort-object-keys/-/sort-object-keys-1.1.3.tgz", + "integrity": "sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg==", + "dev": true + }, + "sort-package-json": { + "version": "1.57.0", + "resolved": "https://registry.npmjs.org/sort-package-json/-/sort-package-json-1.57.0.tgz", + "integrity": "sha512-FYsjYn2dHTRb41wqnv+uEqCUvBpK3jZcTp9rbz2qDTmel7Pmdtf+i2rLaaPMRZeSVM60V3Se31GyWFpmKs4Q5Q==", + "dev": true, + "requires": { + "detect-indent": "^6.0.0", + "detect-newline": "3.1.0", + "git-hooks-list": "1.0.3", + "globby": "10.0.0", + "is-plain-obj": "2.1.0", + "sort-object-keys": "^1.1.3" + }, + "dependencies": { + "globby": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-10.0.0.tgz", + "integrity": "sha512-3LifW9M4joGZasyYPz2A1U74zbC/45fvpXUvO/9KbSa+VV0aGZarWkfdgKyR9sExNP0t0x0ss/UMJpNpcaTspw==", + "dev": true, + "requires": { + "@types/glob": "^7.1.1", + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.0.3", + "glob": "^7.1.3", + "ignore": "^5.1.1", + "merge2": "^1.2.3", + "slash": "^3.0.0" + } + }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true + } + } + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", diff --git a/package.json b/package.json index b329644e..96bd749a 100644 --- a/package.json +++ b/package.json @@ -2,38 +2,6 @@ "name": "@sanity/plugin-kit", "version": "2.0.9", "description": "Enhanced Sanity.io plugin development experience", - "scripts": { - "clean": "rimraf lib", - "prebuild": "npm run clean", - "build": "tsc", - "postbuild": "node executable-index.js", - "watch": "tsc --watch", - "test": "tap", - "prepare": "husky install", - "commit": "git-cz", - "lint": "eslint .", - "compile": "tsc --noEmit", - "format": "prettier src -w", - "prepublishOnly": "npm run build" - }, - "binname": "sanity-plugin", - "source": "./src/index.ts", - "types": "./lib/src/index.d.ts", - "bin": "lib/src/index.js", - "main": "./lib/src/index.js", - "files": [ - "v2-incompatible.js", - "src", - "lib", - "assets" - ], - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/sanity-io/plugin-kit.git" - }, - "engines": { - "node": ">=14.0.0" - }, "keywords": [ "sanity-io", "sanity", @@ -43,12 +11,52 @@ "typescript", "bootstrap" ], - "author": "Sanity.io ", - "license": "MIT", + "homepage": "https://github.com/sanity-io/plugin-kit#readme", "bugs": { "url": "https://github.com/sanity-io/plugin-kit/issues" }, - "homepage": "https://github.com/sanity-io/plugin-kit#readme", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/sanity-io/plugin-kit.git" + }, + "license": "MIT", + "author": "Sanity.io ", + "main": "./lib/src/index.js", + "source": "./src/index.ts", + "types": "./lib/src/index.d.ts", + "bin": "lib/src/index.js", + "files": [ + "v2-incompatible.js", + "src", + "lib", + "assets" + ], + "scripts": { + "prebuild": "npm run clean", + "build": "tsc", + "postbuild": "node executable-index.js", + "clean": "rimraf lib", + "commit": "git-cz", + "compile": "tsc --noEmit", + "format": "prettier src -w", + "lint": "eslint .", + "prepare": "husky install", + "prepublishOnly": "npm run build", + "test": "tap", + "watch": "tsc --watch" + }, + "tap": { + "browser": false, + "check-coverage": false, + "coverage-report": [ + "html" + ], + "jobs": 2, + "reporter": "spec", + "test-ignore": "^lib/.*|.*ignore.*|.*run-test-command.*|.*fixture.utils.*", + "timeout": 120, + "ts": true + }, "dependencies": { "@rexxars/choosealicense-list": "^1.1.2", "chalk": "^4.1.2", @@ -78,9 +86,6 @@ "xdg-basedir": "^4.0.0", "yalc": "^1.0.0-pre.53" }, - "peerDependencies": { - "eslint": ">=8.0.0" - }, "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", @@ -104,6 +109,7 @@ "json5": "^2.2.1", "lint-staged": "^13.0.3", "prettier": "^2.7.1", + "prettier-plugin-packagejson": "^2.3.0", "readdirp": "^3.6.0", "rimraf": "^3.0.2", "sanity": "3.0.0-rc.0", @@ -112,16 +118,11 @@ "ts-node": "^10.9.1", "typescript": "^4.8.4" }, - "tap": { - "jobs": 2, - "browser": false, - "timeout": 120, - "reporter": "spec", - "check-coverage": false, - "coverage-report": [ - "html" - ], - "test-ignore": "^lib/.*|.*ignore.*|.*run-test-command.*|.*fixture.utils.*", - "ts": true - } + "peerDependencies": { + "eslint": ">=8.0.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "binname": "sanity-plugin" } diff --git a/tap-snapshots/test/verify-package.test.ts.test.cjs b/tap-snapshots/test/verify-package.test.ts.test.cjs index d876c679..4ac18679 100644 --- a/tap-snapshots/test/verify-package.test.ts.test.cjs +++ b/tap-snapshots/test/verify-package.test.ts.test.cjs @@ -5,7 +5,9 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/verify-package.test.ts TAP plugin-kit verify-package in ok package > stdout should match snapshot 1`] = ` +exports[ + `test/verify-package.test.ts TAP plugin-kit verify-package in ok package > stdout should match snapshot 1` +] = ` [success] No outstanding upgrade issues detected. Suggested next steps: @@ -14,7 +16,9 @@ Suggested next steps: - Test the plugin using the link-watch command ` -exports[`test/verify-package.test.ts TAP plugin-kit verify-package in package with all checks failing > stderr should match snapshot 1`] = ` +exports[ + `test/verify-package.test.ts TAP plugin-kit verify-package in package with all checks failing > stderr should match snapshot 1` +] = ` [error] Invalid package.json: "name" should be prefixed with "sanity-plugin-" (or scoped - @your-company/plugin-name) @@ -256,7 +260,9 @@ To fail-fast on first detected issue run: npx @sanity/plugin-kit verify-package' --single ` -exports[`test/verify-package.test.ts TAP plugin-kit verify-package in package with invalid eslint config > stderr should match snapshot 1`] = ` +exports[ + `test/verify-package.test.ts TAP plugin-kit verify-package in package with invalid eslint config > stderr should match snapshot 1` +] = ` [error] Failed to run eslint check Error: Failed to load config "this-does-not-exist" to extend from. Referenced from: root/.eslintrc at configInvalidError root/node_modules/@eslint/eslintrc/lib/config-array-factory.js:299:9) @@ -310,7 +316,9 @@ To fail-fast on first detected issue run: npx @sanity/plugin-kit verify-package' --single ` -exports[`test/verify-package.test.ts TAP plugin-kit verify-studio in fresh v2 studio > stderr should match snapshot 1`] = ` +exports[ + `test/verify-package.test.ts TAP plugin-kit verify-studio in fresh v2 studio > stderr should match snapshot 1` +] = ` [error] Found sanity.json. This file is not used by Sanity Studio V3. diff --git a/test/fixtures/build/folder-sanity-json/package.json b/test/fixtures/build/folder-sanity-json/package.json index 45a05214..7af75e21 100644 --- a/test/fixtures/build/folder-sanity-json/package.json +++ b/test/fixtures/build/folder-sanity-json/package.json @@ -3,14 +3,14 @@ "version": "1.0.0", "private": true, "description": "Just an invalid thing", - "main": "./src/one.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, "keywords": [ "sanity", "sanity-plugin" ], + "license": "MIT", "author": "Some person", - "license": "MIT" + "main": "./src/one.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } } diff --git a/test/fixtures/build/plain/package.json b/test/fixtures/build/plain/package.json index 342f41dc..e6436fa6 100644 --- a/test/fixtures/build/plain/package.json +++ b/test/fixtures/build/plain/package.json @@ -3,11 +3,11 @@ "version": "1.0.0", "private": true, "description": "Just a fixture", - "main": "./src/schemaType.js", "keywords": [ "sanity", "sanity-plugin" ], + "license": "MIT", "author": "Some person", - "license": "MIT" + "main": "./src/schemaType.js" } diff --git a/test/fixtures/build/ts/package.json b/test/fixtures/build/ts/package.json index 33d4be8d..edad6cef 100644 --- a/test/fixtures/build/ts/package.json +++ b/test/fixtures/build/ts/package.json @@ -3,19 +3,19 @@ "version": "1.0.0", "private": true, "description": "Just a valid typescript Sanity plugin fixture. Do not publish.", - "main": "./lib/one.js", - "types": "types.d.ts", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, "keywords": [ "sanity", "sanity-plugin" ], + "license": "MIT", + "author": "Some person", + "main": "./lib/one.js", + "types": "types.d.ts", "files": [ "lib", ".eslintignore" ], - "author": "Some person", - "license": "MIT" + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } } diff --git a/test/fixtures/build/valid-js/package.json b/test/fixtures/build/valid-js/package.json index 574e8204..a2297c47 100644 --- a/test/fixtures/build/valid-js/package.json +++ b/test/fixtures/build/valid-js/package.json @@ -3,7 +3,12 @@ "version": "1.0.0", "private": true, "description": "Just a valid Sanity plugin fixture. Do not publish.", - "source": "./src/index.js", + "keywords": [ + "sanity", + "sanity-plugin" + ], + "license": "MIT", + "author": "Some person", "exports": { ".": { "require": "./lib/cjs/index.js", @@ -12,6 +17,7 @@ }, "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", + "source": "./src/index.js", "files": [ "src", "lib" @@ -19,13 +25,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "keywords": [ - "sanity", - "sanity-plugin" - ], "peerDependencies": { "react": "^16.2.0 || ^18.0.0" - }, - "author": "Some person", - "license": "MIT" + } } diff --git a/test/fixtures/inject/valid/package.json b/test/fixtures/inject/valid/package.json index 49f42a8f..2539ca83 100644 --- a/test/fixtures/inject/valid/package.json +++ b/test/fixtures/inject/valid/package.json @@ -2,12 +2,16 @@ "name": "sanity-plugin-test-plugin", "version": "1.0.0", "description": "", - "author": "Test Person ", + "homepage": "https://github.com/sanity-io/sanity#readme", + "bugs": { + "url": "https://github.com/sanity-io/sanity/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/sanity-io/sanity" + }, "license": "MIT", - "source": "./src/index.ts", - "main": "./lib/index.js", - "module": "./lib/index.esm.js", - "types": "./lib/src/index.d.ts", + "author": "Test Person ", "exports": { ".": { "types": "./lib/src/index.d.ts", @@ -17,40 +21,32 @@ "default": "./lib/index.js" } }, + "main": "./lib/index.js", + "module": "./lib/index.esm.js", + "source": "./src/index.ts", + "types": "./lib/src/index.d.ts", "files": [ "src", "lib", "v2-incompatible.js", "sanity.json" ], - "sanityPlugin": { - "verifyPackage": { - "tsc": false - } - }, "scripts": { - "clean": "rimraf lib", - "lint": "eslint .", "prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils", "build": "pkg-utils build --no-cache", - "watch": "pkg-utils watch", + "clean": "rimraf lib", "link-watch": "plugin-kit link-watch", - "prepublishOnly": "npm run build" - }, - "repository": { - "type": "git", - "url": "https://github.com/sanity-io/sanity" - }, - "engines": { - "node": ">=14.0.0" + "lint": "eslint .", + "prepublishOnly": "npm run build", + "watch": "pkg-utils watch" }, "dependencies": { "@sanity/incompatible-plugin": "^0.0.1-studio-v3.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.27.1", "@sanity/pkg-utils": "^1.16.0", "@sanity/plugin-kit": "^0.0.1-studio-v3.1", + "@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/parser": "^5.27.1", "eslint": "^8.17.0", "eslint-config-prettier": "^8.5.0", @@ -59,6 +55,7 @@ "eslint-plugin-react": "^7.30.0", "eslint-plugin-react-hooks": "^4.5.0", "prettier": "^2.6.2", + "prettier-plugin-packagejson": "^2.3.0", "react": "^18.0.0", "rimraf": "^3.0.2", "sanity": "dev-preview || 3.0.0-rc.0", @@ -68,8 +65,12 @@ "react": "^17.0.0 || ^18.0.0", "sanity": "dev-preview || 3.0.0-rc.0" }, - "bugs": { - "url": "https://github.com/sanity-io/sanity/issues" + "engines": { + "node": ">=14.0.0" }, - "homepage": "https://github.com/sanity-io/sanity#readme" + "sanityPlugin": { + "verifyPackage": { + "tsc": false + } + } } diff --git a/test/fixtures/verify-package/every-failure-possible/package.json b/test/fixtures/verify-package/every-failure-possible/package.json index 8a3877b1..2102b892 100644 --- a/test/fixtures/verify-package/every-failure-possible/package.json +++ b/test/fixtures/verify-package/every-failure-possible/package.json @@ -10,19 +10,19 @@ ], "dependencies": {}, "devDependencies": { + "@sanity/base": "^2.30.1", "eslint": "^8.17.0", "eslint-config-prettier": "^8.5.0", "eslint-config-sanity": "^6.0.0", "eslint-plugin-react": "^7.30.0", "eslint-plugin-react-hooks": "^4.5.0", + "parcel": "^2.7.0", "react": "^17.0.0 || ^18.0.0", "rimraf": "^3.0.2", - "@sanity/base": "^2.30.1", - "parcel": "^2.7.0", "typescript": "^4.7.3" }, "peerDependencies": { - "react": "^17.0.0 || ^18.0.0", - "@sanity/base": "^2.30.1" + "@sanity/base": "^2.30.1", + "react": "^17.0.0 || ^18.0.0" } } diff --git a/test/fixtures/verify-package/fresh-v2-movie-studio/package.json b/test/fixtures/verify-package/fresh-v2-movie-studio/package.json index 5bf7a832..550da524 100644 --- a/test/fixtures/verify-package/fresh-v2-movie-studio/package.json +++ b/test/fixtures/verify-package/fresh-v2-movie-studio/package.json @@ -1,17 +1,17 @@ { "name": "throwaway", - "private": true, "version": "1.0.0", + "private": true, "description": "", - "main": "package.json", - "license": "UNLICENSED", - "scripts": { - "start": "sanity start", - "build": "sanity build" - }, "keywords": [ "sanity" ], + "license": "UNLICENSED", + "main": "package.json", + "scripts": { + "build": "sanity build", + "start": "sanity start" + }, "dependencies": { "@sanity/base": "^2.30.1", "@sanity/core": "^2.30.1", diff --git a/test/fixtures/verify-package/invalid-eslint/package.json b/test/fixtures/verify-package/invalid-eslint/package.json index d5e302e6..20e2874d 100644 --- a/test/fixtures/verify-package/invalid-eslint/package.json +++ b/test/fixtures/verify-package/invalid-eslint/package.json @@ -2,63 +2,47 @@ "name": "sanity-plugin-test-plugin", "version": "1.0.0", "description": "", - "author": "Test Person ", + "homepage": "https://github.com/sanity-io/sanity#readme", + "bugs": { + "url": "https://github.com/sanity-io/sanity/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/sanity-io/sanity" + }, "license": "MIT", - "source": "./src/index.ts", - "main": "./lib/cjs/index.js", - "module": "./lib/esm/index.js", - "types": "./lib/types/index.d.ts", + "author": "Test Person ", "exports": { ".": { "require": "./lib/cjs/index.js", "default": "./lib/esm/index.js" } }, + "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", + "source": "./src/index.ts", + "types": "./lib/types/index.d.ts", "files": [ "src", "lib", "v2-incompatible.js", "sanity.json" ], - "sanityPlugin": { - "verifyPackage": { - "eslintImports": true, - "tsc": false, - "packageName": false, - "module": false, - "tsconfig": false, - "dependencies": false, - "rollupConfig": false, - "babelConfig": false, - "sanityV2Json": false, - "scripts": false, - "pkg-utils": false, - "nodeEngine": false, - "studioConfig": false - } - }, "scripts": { - "clean": "rimraf lib", - "lint": "eslint .", "prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils", "build": "pkg-utils build", - "watch": "pkg-utils watch", + "clean": "rimraf lib", "link-watch": "plugin-kit link-watch", - "prepublishOnly": "npm run build" - }, - "repository": { - "type": "git", - "url": "https://github.com/sanity-io/sanity" - }, - "engines": { - "node": ">=14.0.0" + "lint": "eslint .", + "prepublishOnly": "npm run build", + "watch": "pkg-utils watch" }, "dependencies": { "@sanity/incompatible-plugin": "^0.0.1-studio-v3.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.27.1", "@sanity/plugin-kit": "^0.0.1-studio-v3.1", + "@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/parser": "^5.27.1", "eslint": "^8.17.0", "eslint-config-prettier": "^8.5.0", @@ -67,6 +51,7 @@ "eslint-plugin-react": "^7.30.0", "eslint-plugin-react-hooks": "^4.5.0", "prettier": "^2.6.2", + "prettier-plugin-packagejson": "^2.3.0", "react": "^17.0.0 || ^18.0.0", "rimraf": "^3.0.2", "sanity": "2.29.5-purple-unicorn.856", @@ -76,8 +61,24 @@ "react": "^17.0.0 || ^18.0.0", "sanity": "purple-unicorn" }, - "bugs": { - "url": "https://github.com/sanity-io/sanity/issues" + "engines": { + "node": ">=14.0.0" }, - "homepage": "https://github.com/sanity-io/sanity#readme" + "sanityPlugin": { + "verifyPackage": { + "eslintImports": true, + "tsc": false, + "packageName": false, + "module": false, + "tsconfig": false, + "dependencies": false, + "rollupConfig": false, + "babelConfig": false, + "sanityV2Json": false, + "scripts": false, + "pkg-utils": false, + "nodeEngine": false, + "studioConfig": false + } + } } diff --git a/test/fixtures/verify-package/valid/package.json b/test/fixtures/verify-package/valid/package.json index 0ebe68db..2806d4ab 100644 --- a/test/fixtures/verify-package/valid/package.json +++ b/test/fixtures/verify-package/valid/package.json @@ -2,52 +2,48 @@ "name": "sanity-plugin-test-plugin", "version": "1.0.0", "description": "", - "author": "Test Person ", + "homepage": "https://github.com/sanity-io/sanity#readme", + "bugs": { + "url": "https://github.com/sanity-io/sanity/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/sanity-io/sanity" + }, "license": "MIT", - "source": "./src/index.ts", - "main": "./lib/cjs/index.js", - "module": "./lib/esm/index.js", - "types": "./lib/types/index.d.ts", + "author": "Test Person ", "exports": { ".": { "require": "./lib/cjs/index.js", "default": "./lib/esm/index.js" } }, + "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", + "source": "./src/index.ts", + "types": "./lib/types/index.d.ts", "files": [ "src", "lib", "v2-incompatible.js", "sanity.json" ], - "sanityPlugin": { - "verifyPackage": { - "tsc": false - } - }, "scripts": { - "clean": "rimraf lib", - "lint": "eslint .", "prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils", "build": "pkg-utils build --no-cache", - "watch": "pkg-utils watch", + "clean": "rimraf lib", "link-watch": "plugin-kit link-watch", - "prepublishOnly": "npm run build" - }, - "repository": { - "type": "git", - "url": "https://github.com/sanity-io/sanity" - }, - "engines": { - "node": ">=14.0.0" + "lint": "eslint .", + "prepublishOnly": "npm run build", + "watch": "pkg-utils watch" }, "dependencies": { "@sanity/incompatible-plugin": "^0.0.1-studio-v3.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.27.1", "@sanity/pkg-utils": "^1.16.1", "@sanity/plugin-kit": "^0.0.1-studio-v3.1", + "@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/parser": "^5.27.1", "eslint": "^8.17.0", "eslint-config-prettier": "^8.5.0", @@ -56,6 +52,7 @@ "eslint-plugin-react": "^7.30.0", "eslint-plugin-react-hooks": "^4.5.0", "prettier": "^2.6.2", + "prettier-plugin-packagejson": "^2.3.0", "react": "^17.0.0 || ^18.0.0", "rimraf": "^3.0.2", "sanity": "2.29.5-purple-unicorn.856", @@ -65,8 +62,12 @@ "react": "^17.0.0 || ^18.0.0", "sanity": "purple-unicorn" }, - "bugs": { - "url": "https://github.com/sanity-io/sanity/issues" + "engines": { + "node": ">=14.0.0" }, - "homepage": "https://github.com/sanity-io/sanity#readme" + "sanityPlugin": { + "verifyPackage": { + "tsc": false + } + } } diff --git a/test/init.test.ts b/test/init.test.ts index eec8dfa4..160906a1 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -25,6 +25,7 @@ const defaultDevDependencies = [ 'eslint-plugin-react', 'eslint-plugin-react-hooks', 'prettier', + 'prettier-plugin-packagejson', 'react', 'rimraf', 'sanity',