Skip to content

Commit

Permalink
Fix json imports (#57)
Browse files Browse the repository at this point in the history
* Use exported version from Alfa

* Add changeset

* Fix importing package name and version

* Typo
  • Loading branch information
Jym77 authored Jul 25, 2024
1 parent b67ea3b commit 3a1dcd7
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-crews-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-cli": patch
---

**Changed:** Fix importing of package name and version
6 changes: 6 additions & 0 deletions .changeset/thick-parrots-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@siteimprove/alfa-formatter-sarif": patch
"@siteimprove/alfa-formatter-earl": patch
---

**Changed:** Alfa version is now read from the exported value in `alfa-rules`.
11 changes: 11 additions & 0 deletions packages/alfa-cli/get-pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# This script relies on npm package.json variables and thus must be called
# through npm, yarn or the like to correctly set them.

set -eux

echo "// Generated by yarn alfa-postversion
export const name = \"$(node -e "console.log(process.env.npm_package_name)")\";
export const version = \"$(node -e "console.log(process.env.npm_package_version)")\";
"
11 changes: 11 additions & 0 deletions packages/alfa-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
"bin/**/*.js",
"bin/**/*.d.ts"
],
"//": [
"For scripts:",
"We need to update the version number after creating a new one.",
"We also need to update the documentation, which includes the version number; updating the documentation from a CI tool requires CI=false to allow changes.",
"Finally we need to stage the changed files that will be commited later in the release process."
],
"scripts": {
"alfa-postversion": "./get-pkg.sh > src/pkg.ts && yarn self-extract && git add src/pkg.ts ../../docs/review/api/alfa-cli.api.md",
"self-extract": "CI=false yarn run --top-level extract packages/alfa-cli",
"packages/alfa-cli": "echo workaround https://github.com/webpro-nl/knip/issues/739"
},
"dependencies": {
"@siteimprove/alfa-act": "^0.88.0",
"@siteimprove/alfa-command": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-cli/src/alfa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Command, Flag } from "@siteimprove/alfa-command";
import { None } from "@siteimprove/alfa-option";
import { Err } from "@siteimprove/alfa-result";

import pkg from "../package.json";
import * as pkg from "./pkg.js";

import audit from "./alfa/command/audit.js";
import scrape from "./alfa/command/scrape.js";
Expand Down
4 changes: 4 additions & 0 deletions packages/alfa-cli/src/pkg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Generated by yarn alfa-postversion
export const name = "@siteimprove/alfa-cli";
export const version = "0.68.3";

3 changes: 2 additions & 1 deletion packages/alfa-cli/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"alfa/command/scrape/arguments.ts",
"alfa/command/scrape/flags.ts",
"alfa/command/scrape/run.ts",
"alfa/profiler.ts"
"alfa/profiler.ts",
"pkg.ts"
],
"references": [
{ "path": "../../alfa-command" },
Expand Down
1 change: 1 addition & 0 deletions packages/alfa-formatter-earl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@siteimprove/alfa-formatter": "workspace:^",
"@siteimprove/alfa-future": "^0.88.0",
"@siteimprove/alfa-hash": "^0.88.0",
"@siteimprove/alfa-rules": "^0.88.0",
"jsonld": "^8.3.2"
},
"peerDependencies": {
Expand Down
7 changes: 1 addition & 6 deletions packages/alfa-formatter-earl/src/earl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ import { Serializable } from "@siteimprove/alfa-earl";
import type { Formatter } from "@siteimprove/alfa-formatter";
import { Future } from "@siteimprove/alfa-future";
import type { Hashable } from "@siteimprove/alfa-hash";
import { alfaVersion as version } from "@siteimprove/alfa-rules";

import * as jsonld from "jsonld";

// This should be the alfa-rules version, but alfa-rules is not
// imported here. Anyway, checker version should probably be included
// in outcomes serialization rather than hacked here.
import pkg from "@siteimprove/alfa-act/package.json";
const version = pkg.version

const { stringify } = JSON;

/**
Expand Down
1 change: 1 addition & 0 deletions packages/alfa-formatter-sarif/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@siteimprove/alfa-act": "^0.88.0",
"@siteimprove/alfa-formatter": "workspace:^",
"@siteimprove/alfa-hash": "^0.88.0",
"@siteimprove/alfa-rules": "^0.88.0",
"@siteimprove/alfa-sarif": "^0.88.0"
},
"publishConfig": {
Expand Down
7 changes: 1 addition & 6 deletions packages/alfa-formatter-sarif/src/sarif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import type { Hashable } from "@siteimprove/alfa-hash";
import type { Log } from "@siteimprove/alfa-sarif";
import { Serializable } from "@siteimprove/alfa-sarif";
import type { Formatter } from "@siteimprove/alfa-formatter";

// This should be the alfa-rules version, but alfa-rules is not
// imported here. Anyway, checker version should probably be included
// in outcomes serialization rather than hacked here.
import pkg from "@siteimprove/alfa-act/package.json";
const version = pkg.version;
import { alfaVersion as version } from "@siteimprove/alfa-rules";

const { stringify } = JSON;

Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,7 @@ __metadata:
"@siteimprove/alfa-formatter": "workspace:^"
"@siteimprove/alfa-future": ^0.88.0
"@siteimprove/alfa-hash": ^0.88.0
"@siteimprove/alfa-rules": ^0.88.0
"@types/jsonld": ^1.5.14
jsonld: ^8.3.2
peerDependencies:
Expand Down Expand Up @@ -2284,6 +2285,7 @@ __metadata:
"@siteimprove/alfa-act": ^0.88.0
"@siteimprove/alfa-formatter": "workspace:^"
"@siteimprove/alfa-hash": ^0.88.0
"@siteimprove/alfa-rules": ^0.88.0
"@siteimprove/alfa-sarif": ^0.88.0
languageName: unknown
linkType: soft
Expand Down

0 comments on commit 3a1dcd7

Please sign in to comment.