Skip to content

Commit

Permalink
Merge branch 'biome'
Browse files Browse the repository at this point in the history
  • Loading branch information
idevat committed Feb 5, 2025
2 parents 7fed93e + c146d37 commit 5325da3
Show file tree
Hide file tree
Showing 654 changed files with 2,670 additions and 28,906 deletions.
4 changes: 2 additions & 2 deletions .bin/bump-version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require("fs");
const fs = require("node:fs");

if (process.argv.length !== 3) {
throw Error(`Usage: ${process.argv[0]} ${process.argv[1]} <version>`);
throw new Error(`Usage: ${process.argv[0]} ${process.argv[1]} <version>`);
}

const version = process.argv[2];
Expand Down
22 changes: 0 additions & 22 deletions .bin/lint.sh

This file was deleted.

53 changes: 53 additions & 0 deletions .bin/pre-commit/check-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh

# Check definition. Multiline string, every line is for one check.
# Format of line is:
# `Check title ./path/relative/to/this/script/check-script.sh`.
# The last space separates title from script path.
check_list="
BIOME LINT CHECK ./check-lint.sh
BIOME FORMAT CHECK ./check-format.sh
MAKEFILE FILE LISTING CHECK ./check-makefile-file-listing.sh
"

extract_title() {
echo "$1" | awk '{$NF=""; print $0}'
}

extract_command() {
realpath "$(dirname "$0")"/"$(echo "$1" | awk '{print $NF}')"
}

err_report=""
while IFS= read -r line; do
[ -n "$line" ] || continue

check=$(extract_command "$line")

if ! output=$("$check" 2>&1); then
err_report="${err_report}$(extract_title "$line") ($check)\n$output\n\n"
fi
done << EOF
$check_list
EOF

if [ -z "$err_report" ]; then
exit 0
fi

echo "Warning: some check failed"
printf "%b" "$err_report"

printf "Checks failed. Continue with commit? (c)Continue (a)Abort: " > /dev/tty
IFS= read -r resolution < /dev/tty

case "$resolution" in
c | C) exit 0 ;;
a | A)
echo "Commit aborted."
exit 1
;;
esac

echo "Unknown resolution '$resolution', aborting commit..."
exit 1
5 changes: 5 additions & 0 deletions .bin/pre-commit/check-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

root_dir="$(realpath "$(dirname "$0")"/../../)"

npx @biomejs/biome format "$root_dir"
5 changes: 5 additions & 0 deletions .bin/pre-commit/check-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

root_dir="$(realpath "$(dirname "$0")"/../../)"

npx @biomejs/biome lint --error-on-warnings "$root_dir"
44 changes: 44 additions & 0 deletions .bin/pre-commit/check-makefile-file-listing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

makefile_list="\
Makefile.am
packages/app/Makefile.am
packages/test/Makefile.am
"

get_mentioned_files() {
for makefile in $1; do
[ -n "$makefile" ] || continue
"$(dirname "$0")"/extract-extra-dist.sh "$makefile"
done
}

get_unlisted_files() {
makefiles=$1
added_files=$2

mentioned_files=$(get_mentioned_files "$makefiles")

for file in $added_files; do
if ! echo "$mentioned_files" |
grep --quiet --fixed-strings --line-regexp "$file" 2> /dev/null; then
echo "$file"
fi
done
}

git_added="$(git diff --cached --name-only --diff-filter=A)"

if [ -z "$git_added" ]; then
exit 0
fi

unlisted_files="$(get_unlisted_files "$makefile_list" "$git_added")"

if [ -z "$unlisted_files" ]; then
exit 0
fi

echo "Warning: The following files are not listed in any Makefile.am:"
echo "$unlisted_files"
exit 1
30 changes: 30 additions & 0 deletions .bin/pre-commit/extract-extra-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

makefile="$1"
inside_extra_dist=0
files=""

while IFS= read -r line; do
case "$line" in
*EXTRA_DIST[[:space:]]*=*)
inside_extra_dist=1
files="${line#*=}"
files="${files%\\}"
;;
*\\)
[ $inside_extra_dist -eq 1 ] && files="$files ${line%\\}"
;;
*) # the last line in EXTRA_DIST
[ $inside_extra_dist -eq 1 ] && files="$files $line" && break
;;
esac
done < "$makefile"

# no globing
set -f
# split to arguments
# shellcheck disable=2086
set -- $files
for file in "$@"; do
printf "%s\n" "${makefile%Makefile.am}$file"
done
4 changes: 4 additions & 0 deletions .bin/pre-commit/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

./.bin/pre-commit/remove-nexus.sh
./.bin/pre-commit/check-all.sh
12 changes: 0 additions & 12 deletions .bin/pre-commit.sh → .bin/pre-commit/remove-nexus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,3 @@ for lockDir in \

fix_lock "$lockDir"/package-lock.json
done

# Deal with reduced packages (for building process).
app=packages/app
package_build="$app"/.bin/package-build

packages_build="$app"/$("$package_build"/fname.sh)
packages_build_lock="$app"/$("$package_build"/fname.sh -l)

"$package_build"/generate.sh "$app"
git add "$packages_build" "$packages_build_lock"

fix_lock "$packages_build_lock"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ yarn-error.log*
pcs-web-ui-*
pcs-web-ui.spec
.npmrc
.eslintcache

stamps*

Expand Down
8 changes: 0 additions & 8 deletions .prettierrc.js

This file was deleted.

23 changes: 11 additions & 12 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ EXTRA_DIST = \
.bin/check-no-nexus.sh \
.bin/init_nexus.sh \
.bin/init.sh \
.bin/lint.sh \
.bin/npm_install.sh \
.bin/pre-commit/extract-extra-dist.sh \
.bin/pre-commit/check-all.sh \
.bin/pre-commit/check-format.sh \
.bin/pre-commit/check-lint.sh \
.bin/pre-commit/check-makefile-file-listing.sh \
.bin/pre-commit/remove-nexus.sh \
.bin/pre-commit.sh \
.bin/render-spec.sh \
.browserslistrc \
Expand Down Expand Up @@ -71,8 +76,8 @@ app:
build:
if [ "${abs_top_builddir}" != "${abs_top_srcdir}" ]; then \
mkdir -p $(APP_BUILD); \
cp $(APP_SRC)/package-build.json $(APP_BUILD)/package.json; \
cp $(APP_SRC)/package-build-lock.json $(APP_BUILD)/package-lock.json; \
cp $(APP_SRC)/package.json $(APP_BUILD)/package.json; \
cp $(APP_SRC)/package-lock.json $(APP_BUILD)/package-lock.json; \
fi

if [ ! -d $(APP_BUILD)/node_modules ]; then \
Expand Down Expand Up @@ -121,21 +126,19 @@ check_sources:
@.bin/check-no-nexus.sh

lint:
@.bin/lint.sh ./packages
@npx biome lint --error-on-warnings ./

fmt:
npx prettier "packages/app/src/" --write
packages/app/node_modules/.bin/eslint --fix --ext .js,.ts,.tsx packages/app/src/
npx biome format --write ./

.PHONY: bump-version
bump-version:
@node .bin/bump-version.js $(version)
@packages/app/.bin/package-build/generate.sh packages/app
@git commit -a -m "bump new version ($(version))"
@git tag -a -m "$(version) release" $(version) HEAD

dist-hook:
$(abs_top_srcdir)/packages/app/.bin/package-build/fetch-and-pack.sh \
$(abs_top_srcdir)/packages/app/.bin/fetch-and-pack-node-modules.sh \
$(APP_SRC) \
packages/app \
$(PACKAGE_NAME)-node-modules-$(VERSION).tar.xz
Expand Down Expand Up @@ -169,10 +172,6 @@ clean-local:
rm -f ${abs_top_builddir}/.version; \
fi

generate-package-build:
@packages/app/.bin/package-build/generate.sh packages/app


npm_install:
@.bin/npm_install.sh ./packages

Expand Down
Loading

0 comments on commit 5325da3

Please sign in to comment.