diff --git a/.husky/pre-push b/.husky/pre-push index 20d0d06..213bace 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -2,3 +2,4 @@ . "$(dirname "$0")/_/husky.sh" npm run lint +npx tsc diff --git a/lib/plugin.js b/lib/plugin.js index 43e51b9..e255803 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,6 +1,6 @@ "use strict"; -/** @type { import("prettier").Plugin<{ text: string }> } */ +/** @type {import("prettier").Plugin<{ text: string }>} */ module.exports = { languages: [ { @@ -27,10 +27,20 @@ module.exports = { printers: { "prisma-ast": { - print(path) { + print(path, options) { const { format } = require("@prisma/prisma-fmt-wasm"); const { text } = path.getValue(); - return format(text); + const params = JSON.stringify({ + textDocument: { + uri: new URL(`file://${options.filepath}`), + }, + options: { + tabSize: options.tabWidth, + insertSpaces: !options.useTabs, + }, + }); + + return format(text, params); }, }, }, diff --git a/package-lock.json b/package-lock.json index 37554d9..182e509 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,15 @@ "version": "3.7.0", "license": "MIT", "dependencies": { - "@prisma/prisma-fmt-wasm": "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f" + "@prisma/prisma-fmt-wasm": "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f" }, "devDependencies": { - "@types/jest": "27.0.3", + "@types/jest": "27.4.0", "@types/prettier": "2.4.2", "@umidbekk/configs": "0.1.0", "husky": "7.0.4", - "jest": "27.4.5", - "lint-staged": "12.1.4", + "jest": "27.4.7", + "lint-staged": "12.1.7", "np": "7.6.0", "prettier": "2.5.1", "prettier-plugin-packagejson": "2.2.15", @@ -892,9 +892,9 @@ } }, "node_modules/@prisma/prisma-fmt-wasm": { - "version": "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f", - "resolved": "https://registry.npmjs.org/@prisma/prisma-fmt-wasm/-/prisma-fmt-wasm-3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f.tgz", - "integrity": "sha512-hwd3R0CYseBPx9RM20tcIqukBfd0wffLtqXq+FHEv2HeDlH2y1bvnXDAbn9Z+8t8Wqsj1hBDwEYLeYkvh6d19g==" + "version": "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f", + "resolved": "https://registry.npmjs.org/@prisma/prisma-fmt-wasm/-/prisma-fmt-wasm-3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f.tgz", + "integrity": "sha512-r3eqcIkyLMLGXMAO5anxDUlDjkJQLJ9WfVyBzaPDQICNw+506MWx3J3jllGSPEqifch17NLNEckfb9ox5gn7tA==" }, "node_modules/@samverschueren/stream-to-observable": { "version": "0.3.1", @@ -1079,9 +1079,9 @@ } }, "node_modules/@types/jest": { - "version": "27.0.3", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.0.3.tgz", - "integrity": "sha512-cmmwv9t7gBYt7hNKH5Spu7Kuu/DotGa+Ff+JGRKZ4db5eh8PnKS4LuebJ3YLUoyOyIHraTGyULn23YtEAm0VSg==", + "version": "27.4.0", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.4.0.tgz", + "integrity": "sha512-gHl8XuC1RZ8H2j5sHv/JqsaxXkDDM9iDOgu0Wp8sjs4u/snb2PVehyWXJPr+ORA0RPpgw231mnutWI1+0hgjIQ==", "dev": true, "dependencies": { "jest-diff": "^27.0.0", @@ -3827,14 +3827,14 @@ } }, "node_modules/jest": { - "version": "27.4.5", - "resolved": "https://registry.npmjs.org/jest/-/jest-27.4.5.tgz", - "integrity": "sha512-uT5MiVN3Jppt314kidCk47MYIRilJjA/l2mxwiuzzxGUeJIvA8/pDaJOAX5KWvjAo7SCydcW0/4WEtgbLMiJkg==", + "version": "27.4.7", + "resolved": "https://registry.npmjs.org/jest/-/jest-27.4.7.tgz", + "integrity": "sha512-8heYvsx7nV/m8m24Vk26Y87g73Ba6ueUd0MWed/NXMhSZIm62U/llVbS0PJe1SHunbyXjJ/BqG1z9bFjGUIvTg==", "dev": true, "dependencies": { - "@jest/core": "^27.4.5", + "@jest/core": "^27.4.7", "import-local": "^3.0.2", - "jest-cli": "^27.4.5" + "jest-cli": "^27.4.7" }, "bin": { "jest": "bin/jest.js" @@ -4634,9 +4634,9 @@ "dev": true }, "node_modules/lint-staged": { - "version": "12.1.4", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.4.tgz", - "integrity": "sha512-RgDz9nsFsE0/5eL9Vat0AvCuk0+j5mEuzBIVfrRH5FRtt5wibYe8zTjZs2nuqLFrLAGQGYnj8+HJxolcj08i/A==", + "version": "12.1.7", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.7.tgz", + "integrity": "sha512-bltv/ejiLWtowExpjU+s5z8j1Byjg9AlmaAjMmqNbIicY69u6sYIwXGg0dCn0TlkrrY2CphtHIXAkbZ+1VoWQQ==", "dev": true, "dependencies": { "cli-truncate": "^3.1.0", @@ -8818,9 +8818,9 @@ } }, "@prisma/prisma-fmt-wasm": { - "version": "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f", - "resolved": "https://registry.npmjs.org/@prisma/prisma-fmt-wasm/-/prisma-fmt-wasm-3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f.tgz", - "integrity": "sha512-hwd3R0CYseBPx9RM20tcIqukBfd0wffLtqXq+FHEv2HeDlH2y1bvnXDAbn9Z+8t8Wqsj1hBDwEYLeYkvh6d19g==" + "version": "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f", + "resolved": "https://registry.npmjs.org/@prisma/prisma-fmt-wasm/-/prisma-fmt-wasm-3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f.tgz", + "integrity": "sha512-r3eqcIkyLMLGXMAO5anxDUlDjkJQLJ9WfVyBzaPDQICNw+506MWx3J3jllGSPEqifch17NLNEckfb9ox5gn7tA==" }, "@samverschueren/stream-to-observable": { "version": "0.3.1", @@ -8981,9 +8981,9 @@ } }, "@types/jest": { - "version": "27.0.3", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.0.3.tgz", - "integrity": "sha512-cmmwv9t7gBYt7hNKH5Spu7Kuu/DotGa+Ff+JGRKZ4db5eh8PnKS4LuebJ3YLUoyOyIHraTGyULn23YtEAm0VSg==", + "version": "27.4.0", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.4.0.tgz", + "integrity": "sha512-gHl8XuC1RZ8H2j5sHv/JqsaxXkDDM9iDOgu0Wp8sjs4u/snb2PVehyWXJPr+ORA0RPpgw231mnutWI1+0hgjIQ==", "dev": true, "requires": { "jest-diff": "^27.0.0", @@ -11066,14 +11066,14 @@ } }, "jest": { - "version": "27.4.5", - "resolved": "https://registry.npmjs.org/jest/-/jest-27.4.5.tgz", - "integrity": "sha512-uT5MiVN3Jppt314kidCk47MYIRilJjA/l2mxwiuzzxGUeJIvA8/pDaJOAX5KWvjAo7SCydcW0/4WEtgbLMiJkg==", + "version": "27.4.7", + "resolved": "https://registry.npmjs.org/jest/-/jest-27.4.7.tgz", + "integrity": "sha512-8heYvsx7nV/m8m24Vk26Y87g73Ba6ueUd0MWed/NXMhSZIm62U/llVbS0PJe1SHunbyXjJ/BqG1z9bFjGUIvTg==", "dev": true, "requires": { - "@jest/core": "^27.4.5", + "@jest/core": "^27.4.7", "import-local": "^3.0.2", - "jest-cli": "^27.4.5" + "jest-cli": "^27.4.7" } }, "jest-changed-files": { @@ -11691,9 +11691,9 @@ "dev": true }, "lint-staged": { - "version": "12.1.4", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.4.tgz", - "integrity": "sha512-RgDz9nsFsE0/5eL9Vat0AvCuk0+j5mEuzBIVfrRH5FRtt5wibYe8zTjZs2nuqLFrLAGQGYnj8+HJxolcj08i/A==", + "version": "12.1.7", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.7.tgz", + "integrity": "sha512-bltv/ejiLWtowExpjU+s5z8j1Byjg9AlmaAjMmqNbIicY69u6sYIwXGg0dCn0TlkrrY2CphtHIXAkbZ+1VoWQQ==", "dev": true, "requires": { "cli-truncate": "^3.1.0", diff --git a/package.json b/package.json index 0a8675f..6dbc70e 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "lint": "prettier . --check", "prepare": "husky install", - "prerelease": "npm i && npm run lint && npx tsc", + "prerelease": "npm ci && npm run lint && npx tsc", "release": "np --no-2fa", "tdd": "jest --watch", "test": "jest" @@ -25,15 +25,15 @@ "*": "prettier --write --ignore-unknown" }, "dependencies": { - "@prisma/prisma-fmt-wasm": "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f" + "@prisma/prisma-fmt-wasm": "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f" }, "devDependencies": { - "@types/jest": "27.0.3", + "@types/jest": "27.4.0", "@types/prettier": "2.4.2", "@umidbekk/configs": "0.1.0", "husky": "7.0.4", - "jest": "27.4.5", - "lint-staged": "12.1.4", + "jest": "27.4.7", + "lint-staged": "12.1.7", "np": "7.6.0", "prettier": "2.5.1", "prettier-plugin-packagejson": "2.2.15",