From 5ec494391c1e660481882fea3e6a7bcf395d2e84 Mon Sep 17 00:00:00 2001 From: marshmallow Date: Tue, 7 May 2024 11:03:29 +1000 Subject: [PATCH] add prettier alongisde .editorconfig (#19) * chore: add prettier * feat: add checks * chore: update flake lock --- .github/workflows/check.yml | 38 +++++++++++++++++++ flake.lock | 31 ++++------------ nix/packages/website/default.nix | 2 +- package-lock.json | 63 +++++++++++++++++++++++++++++++- package.json | 8 +++- prettier.config.mjs | 12 ++++++ 6 files changed, 126 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/check.yml create mode 100644 prettier.config.mjs diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..817c06e --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,38 @@ +name: Check + +on: + pull_request: + push: + branches: + - main + +jobs: + prettier: + name: Check Code Format + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install NPM dependencies + run: npm ci + + - name: Check Prettier + run: npm run prettier:check:ci + nix: + name: Nix Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: cachix/install-nix-action@v25 + + - name: Check Nix Build + run: nix build + + - name: Check Nix Flake + run: nix flake check + diff --git a/flake.lock b/flake.lock index 3327f15..4595cd7 100644 --- a/flake.lock +++ b/flake.lock @@ -54,16 +54,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1714272655, - "narHash": "sha256-3/ghIWCve93ngkx5eNPdHIKJP/pMzSr5Wc4rNKE1wOc=", - "owner": "nixos", + "lastModified": 1715023704, + "narHash": "sha256-nf72zOUuXkqN4arcQsngR19KkaQa3cDPtaSJLT8XUWY=", + "owner": "auxolotl", "repo": "nixpkgs", - "rev": "12430e43bd9b81a6b4e79e64f87c624ade701eaf", + "rev": "b0fec4b7a197c6d553d353fbe4a1b6105689187c", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-23.11", + "owner": "auxolotl", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } @@ -71,8 +71,7 @@ "root": { "inputs": { "nixpkgs": "nixpkgs", - "snowfall-lib": "snowfall-lib", - "unstable": "unstable" + "snowfall-lib": "snowfall-lib" } }, "snowfall-lib": { @@ -111,22 +110,6 @@ "repo": "default", "type": "github" } - }, - "unstable": { - "locked": { - "lastModified": 1714253743, - "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } } }, "root": "root", diff --git a/nix/packages/website/default.nix b/nix/packages/website/default.nix index a332a97..303ba82 100644 --- a/nix/packages/website/default.nix +++ b/nix/packages/website/default.nix @@ -12,7 +12,7 @@ in src = lib.snowfall.fs.get-file "/"; - npmDepsHash = "sha256-ze98HddbmkSAgDxJIw1l2YH3EcJ8NKx6Gz++xbcxBM4="; + npmDepsHash = "sha256-nNeFo6MF1Bn7Lypgtr/hgpm1lEbdmLR+6/krWH+8zCU="; npmFlags = ["--ignore-scripts"]; diff --git a/package-lock.json b/package-lock.json index 5631d81..be8b580 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,9 @@ "typescript": "^5.4.5" }, "devDependencies": { - "@tailwindcss/typography": "^0.5.13" + "@tailwindcss/typography": "^0.5.13", + "prettier": "^3.2.5", + "prettier-plugin-astro": "^0.13.0" } }, "node_modules/@alloc/quick-lru": { @@ -5257,6 +5259,41 @@ "node": ">=8.15" } }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "devOptional": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-astro": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-astro/-/prettier-plugin-astro-0.13.0.tgz", + "integrity": "sha512-5HrJNnPmZqTUNoA97zn4gNQv9BgVhv+et03314WpQ9H9N8m2L9OSV798olwmG2YLXPl1iSstlJCR1zB3x5xG4g==", + "devOptional": true, + "dependencies": { + "@astrojs/compiler": "^1.5.5", + "prettier": "^3.0.0", + "sass-formatter": "^0.7.6" + }, + "engines": { + "node": "^14.15.0 || >=16.0.0" + } + }, + "node_modules/prettier-plugin-astro/node_modules/@astrojs/compiler": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-1.8.2.tgz", + "integrity": "sha512-o/ObKgtMzl8SlpIdzaxFnt7SATKPxu4oIP/1NL+HDJRzxfJcAkOTAb/ZKMRyULbz4q+1t2/DAebs2Z1QairkZw==", + "devOptional": true + }, "node_modules/prismjs": { "version": "1.29.0", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", @@ -5989,6 +6026,21 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/s.color": { + "version": "0.0.15", + "resolved": "https://registry.npmjs.org/s.color/-/s.color-0.0.15.tgz", + "integrity": "sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==", + "devOptional": true + }, + "node_modules/sass-formatter": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/sass-formatter/-/sass-formatter-0.7.9.tgz", + "integrity": "sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==", + "devOptional": true, + "dependencies": { + "suf-log": "^2.5.3" + } + }, "node_modules/scheduler": { "version": "0.23.2", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", @@ -6313,6 +6365,15 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/suf-log": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/suf-log/-/suf-log-2.5.3.tgz", + "integrity": "sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==", + "devOptional": true, + "dependencies": { + "s.color": "0.0.15" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", diff --git a/package.json b/package.json index a044f25..dcceb68 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "start": "astro dev", "build": "astro check && astro build", "preview": "astro preview", - "astro": "astro" + "astro": "astro", + "prettier:check:ci": "prettier . --check", + "prettier:format": "prettier . --write" }, "dependencies": { "@astrojs/check": "^0.5.10", @@ -23,6 +25,8 @@ }, "license": "GPL-3.0-or-later", "devDependencies": { - "@tailwindcss/typography": "^0.5.13" + "@tailwindcss/typography": "^0.5.13", + "prettier": "^3.2.5", + "prettier-plugin-astro": "^0.13.0" } } diff --git a/prettier.config.mjs b/prettier.config.mjs new file mode 100644 index 0000000..a4e8871 --- /dev/null +++ b/prettier.config.mjs @@ -0,0 +1,12 @@ +/** @type {import("prettier").Config} */ +export default { + plugins: ["prettier-plugin-astro"], + overrides: [ + { + files: "*.astro", + options: { + parser: "astro", + }, + }, + ], +};