diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 110c11b0..fd162834 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -33,6 +33,11 @@ jobs: - name: Check Python formatting run: uvx ruff format --check . --config pyproject.toml + - name: Check Scenarios formatting + run: | + npm ci + npx prettier --check "scenarios/**/*.{toml,json,yaml}" + typos: runs-on: ubuntu-latest name: Check typos diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..511892dc --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "plugins": ["prettier-plugin-toml"] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cdc08661..91568d27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,3 +42,12 @@ manually back out the change. See [this comment][index-incorrect-snapshot] for an example. [index-incorrect-snapshot]: https://github.com/astral-sh/packse/pull/175#issuecomment-2056964089 + +## Formatting Scenarios + +This step requires NodeJS installed. + +``` +npm install +npx prettier --write "scenarios/**/*.{toml,json,yaml}" +``` diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..c40b05d4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,65 @@ +{ + "name": "packse", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "prettier": "^3.3.3", + "prettier-plugin-toml": "^2.0.1" + } + }, + "node_modules/@taplo/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@taplo/core/-/core-0.1.1.tgz", + "integrity": "sha512-BG/zLGf5wiNXGEVPvUAAX/4ilB3PwDUY2o0MV0y47mZbDZ9ad9UK/cIQsILat3bqbPJsALVbU6k3cskNZ3vAQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@taplo/lib": { + "version": "0.4.0-alpha.2", + "resolved": "https://registry.npmjs.org/@taplo/lib/-/lib-0.4.0-alpha.2.tgz", + "integrity": "sha512-DV/Re3DPVY+BhBtLZ3dmP4mP6YMLSsgq9qGLXwOV38lvNF/fBlgvQswzlXmzCEefL/3q2eMoefZpOI/+GLuCNA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@taplo/core": "^0.1.0" + } + }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-toml": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-toml/-/prettier-plugin-toml-2.0.1.tgz", + "integrity": "sha512-99z1YOkViECHtXQjGIigd3talI/ybUI1zB3yniAwUrlWBXupNXThB1hM6bwSMUEj2/+tomTlMtT98F5t4s8IWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@taplo/lib": "^0.4.0-alpha.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + }, + "peerDependencies": { + "prettier": "^3.0.3" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..521c394c --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "prettier": "^3.3.3", + "prettier-plugin-toml": "^2.0.1" + } +} diff --git a/scenarios/examples/example.json b/scenarios/examples/example.json index 67844d5e..56fc546b 100644 --- a/scenarios/examples/example.json +++ b/scenarios/examples/example.json @@ -1,39 +1,33 @@ { - "name": "example", - "description": "This is an example scenario, in which the user depends on a single package `a` which requires `b`.", - "expected": { - "satisfiable": true, - "packages": { - "a": "1.0.0", - "b": "2.0.0" - }, - "explanation": "The latest valid version of `b` should be installed. `b==3.0.0` is not valid because it requires `c` which does not exist." + "name": "example", + "description": "This is an example scenario, in which the user depends on a single package `a` which requires `b`.", + "expected": { + "satisfiable": true, + "packages": { + "a": "1.0.0", + "b": "2.0.0" }, - "root": { - "requires": [ - "a" - ] + "explanation": "The latest valid version of `b` should be installed. `b==3.0.0` is not valid because it requires `c` which does not exist." + }, + "root": { + "requires": ["a"] + }, + "packages": { + "a": { + "versions": { + "1.0.0": { + "requires": ["b>1.0.0"] + } + } }, - "packages": { - "a": { - "versions": { - "1.0.0": { - "requires": [ - "b>1.0.0" - ] - } - } - }, - "b": { - "versions": { - "1.0.0": {}, - "2.0.0": {}, - "3.0.0": { - "requires": [ - "c" - ] - } - } + "b": { + "versions": { + "1.0.0": {}, + "2.0.0": {}, + "3.0.0": { + "requires": ["c"] } + } } + } } diff --git a/scenarios/examples/example.toml b/scenarios/examples/example.toml index c813236f..576ff5cc 100644 --- a/scenarios/examples/example.toml +++ b/scenarios/examples/example.toml @@ -5,19 +5,19 @@ description = "This is an example scenario written in TOML, in which the user de satisfiable = true explanation = "The latest valid version of `b` should be installed. `b==3.0.0` is not valid because it requires `c` which does not exist." - [expected.packages] - a = "1.0.0" - b = "2.0.0" +[expected.packages] +a = "1.0.0" +b = "2.0.0" [root] -requires = [ "a" ] +requires = ["a"] [packages.a.versions."1.0.0"] -requires = [ "b>1.0.0" ] +requires = ["b>1.0.0"] [packages.b.versions] -"1.0.0" = { } -"2.0.0" = { } +"1.0.0" = {} +"2.0.0" = {} - [packages.b.versions."3.0.0"] - requires = [ "c" ] +[packages.b.versions."3.0.0"] +requires = ["c"] diff --git a/scenarios/examples/example.yaml b/scenarios/examples/example.yaml index f9a0aba3..a9279468 100644 --- a/scenarios/examples/example.yaml +++ b/scenarios/examples/example.yaml @@ -1,26 +1,28 @@ - name: example-yaml - description: This is an example scenario written in YAML, in which the user depends on a single - package `a` which requires `b`. + description: + This is an example scenario written in YAML, in which the user depends on a + single package `a` which requires `b`. expected: satisfiable: true packages: a: 1.0.0 b: 2.0.0 - explanation: The latest valid version of `b` should be installed. `b==3.0.0` is - not valid because it requires `c` which does not exist. + explanation: + The latest valid version of `b` should be installed. `b==3.0.0` is not + valid because it requires `c` which does not exist. root: requires: - - a + - a packages: a: versions: 1.0.0: requires: - - b>1.0.0 + - b>1.0.0 b: versions: 1.0.0: {} 2.0.0: {} 3.0.0: requires: - - c + - c