Skip to content
Snippets Groups Projects
Verified Commit ba4ce5b9 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: move from devenv to flake.nix (wip)

parent f67212aa
No related branches found
No related tags found
No related merge requests found
Showing
with 6446 additions and 4700 deletions
  ;8t 
 . . . . %t%8;8S8t;888 8 .. . . . .
 . %X 8;  .S;.%;%@X%%88 8t8.: 
   8S.t%X@S%XX@X@8X8t8888SX. . . 
 . .88@t88X8SX@SSXXXSX888888888.@.% . 
 .;S.X888XXXS@t@SX@SS888X88888888X%8. 
 88;8X88@@SSX%%8XX8S88@S8888888888StX 
 :S@8@88@XSXSX8X8XXX88:X@8@888888888%8% 
:S;88@@8X@SS8888@8@8:X8XSS.X888888888:S:
X%%88@XX@@:%@X@@88S8@888S8::8888888888.8
8 8@@X88XS;8 %@8XX8S:88:@8@:8888888@88t8
:.888@@S@St@@X8@X@88@t8@X8X8S888888888;%
;%88@8@X8S;St:88 88@t.%X t88SX8@888888.@
8.888@8@@S8XS8S@ @88@;8..@888@8888888888
: @888888@%X:88 Xtt88X 8SX8888888@8888 @
t @88888@@8S8XS@SS88@8888888@88888888SX%
;;:88888888@8@@XX8888X8888S.@8888888@XX%
.X %8888888@@X@8888@8888%8:;S8888@888.8 
 .@8X8888888888@@88888X88X8888888888  
 8@8888888SS88XXXS%@:S @ 888888888X% 
 .SX 88888888888888:X8X8;8888888;88: .
 :.X 888888888@8888@8@888@888. %. 
 . t;;SX:S888@88888888@888 .. t.. . 
 .%:X8St%. 8@@8;.XS8:%.. . .
{pkgs'}:
with pkgs'; [
alejandra
blackbox
blackbox-terminal
coreutils-full
corepack_21
dialog
drill
fd
feh
gcc12
gdlv
git
gitty
glab
gnugrep
gnumake
gnused
go
graphviz
gum
jq
libffi
logrotate
meld
nodejs_21
node2nix
plantuml
ranger
unixtools.xxd
unzip
util-linux
vhs
wget
zlib
]
{
pkgs,
commonScript,
system,
...
}:
# derivation is a function that takes a set of attributes and returns a set of attributes.
# https://nixos.org/manual/nix/stable/language/derivations.html
derivation {
name = "monster";
builder = "${pkgs.bash}/bin/bash";
args = let
script = pkgs.callPackage ../scripts/build.nix {inherit commonScript;};
in ["${script}/bin/build"];
buildInputs = with pkgs; [];
system = system;
}
{
pkgs,
commonScript,
...
}: let
in
pkgs.writeShellScriptBin "build-and-publish" ''
source ${commonScript}
echo_section "build and publish"
echo_hint "This script will run the tests for the project, build the tarball and publish it to the repository."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
echo_step "Update the monster file"
if ! ${pkgs.nodejs_21}/bin/node ./development/scripts/buildMonsterFile.mjs
then
echo_fail "script buildMonsterFile.mjs failed, check your JS!"
exit 1
fi
echo_ok "Monster file updated."
echo_section "run tests"
TEST_PATH="./test"
TEST_CASES_PATH="''${TEST_PATH}/cases/"
if ! ${pkgs.nodePackages.mocha}/bin/mocha --colors --jobs 1 --bail --recursive $TEST_CASES_PATH
then
echo_fail "Tests failed, check your JS!"
exit 1
fi
echo_ok "Tests passed."
tempDir=$(${pkgs.coreutils}/bin/mktemp -d)
if ! nix build --no-link --json .#monster > $tempDir/build_result.json
then
${pkgs.coreutils}/bin/rm -rf $tempDir
echo_fail "Failed to build the project."
echo_hint "You can test the build by running ' nix build .#monster --print-build-logs'."
exit 1
fi
echo_step "Check if git is clean"
if [[ -n "$(git status --porcelain)" ]]; then
echo_fail "Git is not clean. Exiting."
echo_hint "You must commit all changes before you can publish a new version."
echo_hint "You can stash your changes with 'git stash' and apply them later with 'git stash pop'."
exit 1
fi
cd $tempDir
result=$(${pkgs.jq}/bin/jq -r '.[].outputs.out' < $tempDir/build_result.json)
${pkgs.coreutils}/bin/rm build_result.json
tarArchive=$(${pkgs.findutils}/bin/find $result -name "*.tgz")
if [ -z "$tarArchive" ]
then
echo_fail "Failed to find the tarball."
cd -
${pkgs.coreutils}/bin/rm -rf $tempDir
exit 1
fi
## npm instead of pnpm because of https://github.com/pnpm/pnpm/issues/7950
if ! publishingResult=$(${pkgs.nodejs_21}/bin/npm publish "$tarArchive" --json --dry-run --no-git-checks --access public)
then
cd -
${pkgs.coreutils}/bin/rm -rf $tempDir
echo_fail "Failed to publish the project."
exit 1
fi
cd -
${pkgs.coreutils}/bin/rm -rf $tempDir
echo_hint "ID: $(echo $publishingResult | jq .id)"
echo_hint "Name: $(echo $publishingResult | jq .name)"
echo_hint "Version $(echo $publishingResult | jq .version)"
echo_hint "SHA Sum: $(echo $publishingResult | jq .shasum)"
echo_hint "Files: $(echo $publishingResult | jq .entryCount)"
echo_ok "Build and publish successful."
''
{
pkgs,
lib,
commonScript,
...
}: let
in
pkgs.writeShellScriptBin "build-stylesheets" ''
source ${commonScript}
echo_section "Building stylesheets"
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
sourcePath="$(pwd)/source"
function build() {
source ${commonScript}
local prefix="''${sourcePath}/"
echo_step "build stylesheet ''${1#$prefix}"
${pkgs.nodejs_21}/bin/node ./development/scripts/buildStylesheets.mjs "$1"
}
export -f build
if ! ${pkgs.fd}/bin/fd --absolute-path --full-path "$sourcePath" --type file --extension pcss -0 | xargs -0 -I {} bash -c 'build "$@"' _ {}; then
echo_fail "Stylesheet build failed. Exiting."
exit 1
fi
echo_step "Formatting JS code"
if ! ${pkgs.biome}/bin/biome format --write ./source/
then
echo_fail "biome format failed"
exit 1
else
echo_ok "JS code formatted"
fi
echo_ok "Stylesheet build successful"
''
{
pkgs,
commonScript,
...
}: let
packageData = builtins.fromJSON (builtins.readFile ../../package.json);
version = packageData.version;
lib = pkgs.lib;
root = ../..;
gitignore = ../../.gitignore;
source = ../../source;
test = ../../test;
releasedPackageJson = {
description = packageData.description;
name = packageData.name;
version = version;
dependencies = packageData.dependencies;
keywords = packageData.keywords;
license = packageData.license;
repository = packageData.repository;
author = packageData.author;
homepage = packageData.homepage;
type = "module";
main = "source/monster.mjs";
module = "source/monster.mjs";
};
in
pkgs.writeShellScriptBin "build" ''
source ${commonScript}
export PATH=${lib.makeBinPath [pkgs.gzip pkgs.gnutar]}
export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME
${pkgs.coreutils}/bin/mkdir -p $out
if ! ${pkgs.rsync}/bin/rsync -a --exclude-from="${gitignore}" "${source}/." "./source/"
then
echo_fail "Failed to copy source files. Exiting."
exit 1
fi
if ! ${pkgs.rsync}/bin/rsync -a --exclude-from="${gitignore}" "${test}/." "./test/"
then
echo_fail "Failed to copy test files. Exiting."
exit 1
fi
if ! ${pkgs.coreutils}/bin/cp ${root}/README.md "./"
then
echo_fail "Failed to copy README.md. Exiting."
exit 1
fi
if ! ${pkgs.coreutils}/bin/cp ${root}/LICENSE "./"
then
echo_fail "Failed to copy LICENSE. Exiting."
exit 1
fi
if ! ${pkgs.coreutils}/bin/cp ${root}/CHANGELOG.md "./"
then
echo_fail "Failed to copy CHANGELOG.md. Exiting."
exit 1
fi
if ! echo '${builtins.toJSON releasedPackageJson}' > package.json
then
echo_fail "Failed to write package.json. Exiting."
exit 1
fi
if ! ${pkgs.gnutar}/bin/tar -czvf $out/monster-${version}.tgz .
then
echo_fail "Failed to create tarball. Exiting."
exit 1
fi
echo_ok "Tarball created successfully."
''
{
pkgs,
commonScript,
...
}:
pkgs.writeShellScriptBin "clean-up" ''
${commonScript}
echo_header "Cleaning up"
echo_step "Removing credentials"
${pkgs.git}/bin/git config --global --unset credential.helper
if [ -f /root/.docker/config.json ]; then rm /root/.docker/config.json; fi
echo_ok "Cleaned up"
''
{
pkgs,
commonScript,
versionBin,
updateChangelogScript,
...
}:
pkgs.writeShellScriptBin "deploy" ''
${commonScript}
echo_header "Deploying"
setup_go_env
if [ -z "''$CI_JOB_TOKEN" ]; then
echo_fail "Error: CI_JOB_TOKEN variable is not set."
exit 1
fi
if [ -z "''${CI_REPOSITORY_URL}" ]; then
echo_fail "Error: CI_REPOSITORY_URL environment variable is not set."
exit 1
fi
if [ -z "''${CI_PROJECT_DIR}" ]; then
echo_fail "Error: CI_PROJECT_DIR environment variable is not set."
exit 1
fi
cd ''${CI_PROJECT_DIR} || exit 1
${pkgs.git}/bin/git config --global user.email "''${GITLAB_USER_EMAIL}"
${pkgs.git}/bin/git config --global user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}"
${pkgs.git}/bin/git config --global credential.helper '!f() { echo "username=gitlab-ci-token"; echo "password=''${CI_JOB_TOKEN}"; }; f'
${pkgs.git}/bin/git config --global pull.rebase true
${pkgs.git}/bin/git config --global http.sslVerify "false"
${pkgs.git}/bin/git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@}
${pkgs.git}/bin/git fetch --all --tags --unshallow
${pkgs.git}/bin/git reset --hard origin/master
${pkgs.git}/bin/git clean -fd
${pkgs.git}/bin/git checkout $CI_COMMIT_REF_NAME
${pkgs.git}/bin/git pull origin $CI_COMMIT_REF_NAME
if ! ${pkgs.git}/bin/git --no-pager log --decorate=short --pretty=oneline -n 30
then
echo_fail "Error: Could not get git log."
exit 1
fi
${pkgs.git}/bin/git fetch --prune --prune-tags
echo_step "Bumping version"
gitVersion=$(${versionBin} predict --exit-code-if-no-bump)
if [ -z "$gitVersion" ]; then
echo_ok "There is no version bump."
echo_ok "done"
exit 0
fi
gitVersion="v$gitVersion"
echo "{\"version\": \"$gitVersion\", \"release\": \"''${CI_COMMIT_SHA}\"}" > release.json
${pkgs.git}/bin/git add release.json
${pkgs.nodejs}/bin/npm version $gitVersion --no-git-tag-version
${pkgs.git}/bin/git add package.json package-lock.json
${updateChangelogScript}
${pkgs.git}/bin/git add CHANGELOG.md
${pkgs.git}/bin/git commit -m "chore: update release.json"
${pkgs.git}/bin/git tag -a $gitVersion -m"chore: bump version to $gitVersion"
${pkgs.git}/bin/git --no-pager log --decorate=short --pretty=oneline -n 5
${pkgs.git}/bin/git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags
echo_ok "done"
''
{
pkgs,
commonScript,
versionBin,
}: let
script-update-project = pkgs.callPackage ./update-project.nix {inherit commonScript versionBin;};
script-update-changelog = pkgs.callPackage ./update-changelog.nix {inherit commonScript versionBin;};
script-init-project = pkgs.callPackage ./init-project.nix {inherit commonScript versionBin;};
script-build-stylesheets = pkgs.callPackage ./build-stylesheets.nix {inherit commonScript versionBin;};
script-build-and-publish = pkgs.callPackage ./build-and-publish.nix {inherit commonScript versionBin;};
script-run-tests = pkgs.callPackage ./run-tests.nix {inherit commonScript versionBin;};
taskfile = pkgs.writeTextFile {
name = "taskfile.yml";
text = ''
version: '3'
tasks:
default:
cmds:
- task --list
silent: true
git-commit:
desc: Commit changes.
aliases:
- gc
cmds:
- check-code
- cd "{{.USER_WORKING_DIR}}" && cd $(${pkgs.git}/bin/git rev-parse --show-toplevel) && nix run git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes#git-commit --no-write-lock-file
silent: true
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
update-project:
desc: Check code style, linting, and formatting.
aliases:
- up
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- ${script-update-project}/bin/update-project
silent: true
init-project:
desc: Initialize the project and install dependencies
aliases:
- ip
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- ${script-init-project}/bin/init-project
silent: true
build-stylesheets:
silent: true
aliases:
- bs
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
desc: Build the stylesheets javascript files
cmds:
- ${script-build-stylesheets}/bin/build-stylesheets
run-tests:
silent: true
aliases:
- rt
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
desc: Run the tests
cmds:
- ${script-run-tests}/bin/run-tests
build-and-publish:
silent: true
aliases:
- bp
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
desc: Build and publish the npm package
cmds:
- ${script-build-and-publish}/bin/build-and-publish
update-changelog:
silent: true
aliases:
- uc
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
desc: Update the changelog
cmds:
- ${script-update-changelog}/bin/update-changelog
'';
};
in
pkgs.writeShellScriptBin "task" ''
${pkgs.go-task}/bin/task -t "${taskfile}" "$@"
''
{
pkgs,
lib,
commonScript,
versionBin,
...
}: let
in
pkgs.writeShellScriptBin "init-project" ''
source ${commonScript}
echo_section "Initializing project"
echo_hint "This script initializes the project."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
echo_step "Installing dependencies"
if ! ${pkgs.findutils}/bin/find . -type d -name node_modules -prune -o -type f -name package.json -print | ${pkgs.findutils}/bin/xargs -I {} sh -c "cd $(dirname {}); ${pkgs.corepack}/bin/pnpm install"
then
echo_error "Failed to install dependencies"
echo_hint "Check the error message and try again"
exit 1
fi
echo_ok "Project initialized"
''
{
pkgs,
commonScript,
...
}: let
in
pkgs.writeShellScriptBin "prepare-release" ''
source ${commonScript}
echo_section "prepare-release"
echo_hint "This script will update changelog and increment version if necessary."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
echo_step "calculate new version"
if ! ${pkgs.nodejs_21}/bin/node ./development/scripts/buildMonsterFile.mjs
then
echo_fail "script buildMonsterFile.mjs failed, check your JS!"
exit 1
fi
echo_ok "Monster file updated."
echo_section "run tests"
TEST_PATH="./test"
TEST_CASES_PATH="''${TEST_PATH}/cases/"
if ! ${pkgs.nodePackages.mocha}/bin/mocha --colors --jobs 1 --bail --recursive $TEST_CASES_PATH
then
echo_fail "Tests failed, check your JS!"
exit 1
fi
echo_ok "Tests passed."
tempDir=$(${pkgs.coreutils}/bin/mktemp -d)
if ! nix build --no-link --json .#monster > $tempDir/build_result.json
then
${pkgs.coreutils}/bin/rm -rf $tempDir
echo_fail "Failed to build the project."
echo_hint "You can test the build by running ' nix build .#monster --print-build-logs'."
exit 1
fi
echo_step "Check if git is clean"
if [[ -n "$(git status --porcelain)" ]]; then
echo_fail "Git is not clean. Exiting."
echo_hint "You must commit all changes before you can publish a new version."
echo_hint "You can stash your changes with 'git stash' and apply them later with 'git stash pop'."
exit 1
fi
cd $tempDir
result=$(${pkgs.jq}/bin/jq -r '.[].outputs.out' < $tempDir/build_result.json)
${pkgs.coreutils}/bin/rm build_result.json
tarArchive=$(${pkgs.findutils}/bin/find $result -name "*.tgz")
if [ -z "$tarArchive" ]
then
echo_fail "Failed to find the tarball."
cd -
${pkgs.coreutils}/bin/rm -rf $tempDir
exit 1
fi
## npm instead of pnpm because of https://github.com/pnpm/pnpm/issues/7950
if ! publishingResult=$(${pkgs.nodejs_21}/bin/npm publish "$tarArchive" --json --dry-run --no-git-checks --access public)
then
cd -
${pkgs.coreutils}/bin/rm -rf $tempDir
echo_fail "Failed to publish the project."
exit 1
fi
cd -
${pkgs.coreutils}/bin/rm -rf $tempDir
echo_hint "ID: $(echo $publishingResult | jq .id)"
echo_hint "Name: $(echo $publishingResult | jq .name)"
echo_hint "Version $(echo $publishingResult | jq .version)"
echo_hint "SHA Sum: $(echo $publishingResult | jq .shasum)"
echo_hint "Files: $(echo $publishingResult | jq .entryCount)"
echo_ok "Build and publish successful."
''
{
pkgs,
lib,
commonScript,
...
}: let
in
pkgs.writeShellScriptBin "run-tests" ''
source ${commonScript}
echo_section "run tests"
echo_hint "This script will run tests in the current working directory."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
TEST_PATH="./test"
TEST_CASES_PATH="''${TEST_PATH}/cases/"
echo_section "choose the test option"
selection=$(${pkgs.gum}/bin/gum choose "run specific test" "run all tests" "Cancel")
if [[ "$selection" == "Cancel" ]]; then
echo_ok "You cancelled the operation."
exit 0
fi
if [[ "$selection" == "run all tests" ]]; then
echo_step "run specific tests"
if ! ${pkgs.nodePackages.mocha}/bin/mocha --colors --jobs 1 --bail --recursive $TEST_CASES_PATH
then
echo_fail "Tests failed, check your JS!"
exit 1
fi
exit 0
fi
escaped_test_cases_path=$(${pkgs.coreutils}/bin/printf '%s\n' "$TEST_CASES_PATH" | ${pkgs.gnused}/bin/sed 's:[\\/&]:\\&:g;$!s/$/\\/')
echo_step "run all tests"
files=$(${pkgs.findutils}/bin/find $TEST_CASES_PATH -type f -name "*.mjs")
relative_files=$(echo "$files" | ${pkgs.gnused}/bin/sed "s|''${escaped_test_cases_path}||g")
selected=$(echo "$relative_files" | ${pkgs.gum}/bin/gum filter --no-limit --header="Select the test case to run" --placeholder="Select test case to run, use tab to select multiple files")
if [[ -z "$selected" ]]; then
echo_ok "No test case selected, exiting."
exit 0
fi
full_paths=$(echo "$selected" | ${pkgs.gnused}/bin/sed "s|^|''${escaped_test_cases_path}|")
if ! ${pkgs.nodePackages.mocha}/bin/mocha --colors --jobs 1 --bail --recursive $full_paths
then
echo_fail "Tests failed, check your JS!"
exit 1
fi
''
{
pkgs,
lib,
commonScript,
versionBin,
...
}: let
in
pkgs.writeShellScriptBin "update-changelog" ''
source ${commonScript}
echo_section "Update Changelog"
echo_hint "This script will update the changelog."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
## update changelog
echo_step "Updating changelog"
CHANGELOG_PATH="./CHANGELOG.md"
latestDocumentedVersion=$(${pkgs.gnugrep}/bin/grep -Po '## \[\K[\d\.]+' $CHANGELOG_PATH | head -1)
if [ -z "$latestDocumentedVersion" ]; then
echo_fail "Could not find latest documented version in changelog"
echo_hint "Please add a version entry in the file $CHANGELOG_PATH"
exit 1
fi
currentVersion=$(${versionBin} print -g)
if [ "$latestDocumentedVersion" = "$currentVersion" ]; then
echo_ok "changelog already up to date"
else
tags=$(${pkgs.git}/bin/git tag --sort=creatordate)
tags_array=($tags)
position=$(${pkgs.coreutils}/bin/printf "%s\n" "''${tags_array[@]}" | ${pkgs.gnugrep}/bin/grep -n "^$latestDocumentedVersion$" | ${pkgs.coreutils}/bin/cut -d: -f1)
if [ -z "$position" ]; then
echo_fail "Could not find latest documented version in git tags"
echo_hint "Please check the git tags"
exit 1
fi
next_position=$((position + 1))
if [ $next_position -le ''${#tags_array[@]} ]; then
next_tag=''${tags_array[''$next_position - 1]}
else
echo_fail "Could not find next tag"
echo_hint "Please check the git tags"
exit 1
fi
echo_step "Generating changelog"
tmpChangelog=$(${pkgs.mktemp}/bin/mktemp)
if ! ${pkgs.git-chglog}/bin/git-chglog --config ./.config/chglog/config.yml -o $tmpChangelog $next_tag..
then
echo_fail "git-chglog failed"
${pkgs.coreutils}/bin/rm $tmpChangelog
exit 1
fi
newChanges=$(${pkgs.coreutils}/bin/cat $tmpChangelog)
${pkgs.coreutils}/bin/rm $tmpChangelog
if [ -n "$newChanges" ]; then
${pkgs.gnused}/bin/sed -i '1,/^# Changelog/d' $CHANGELOG_PATH
echo -e "# Changelog\n\ņ" > $CHANGELOG_PATH
echo "$newChanges" >> $CHANGELOG_PATH
${pkgs.coreutils}/bin/cat "$CHANGELOG_PATH" >> $CHANGELOG_PATH
echo_ok "changelog updated"
fi
fi
echo_ok "Code checked"
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
importJSScript = pkgs.writeTextFile {
name = "import.mjs";
text = ''
// THIS FILE IS AUTOGENERATED. DO NOT EDIT THIS FILE DIRECTLY.
export const projectRoot = "${config.devenv.root}";
export const sourcePath = "${config.devenv.root}/source";
export const developmentPath = "${config.devenv.root}/development";
export const pnpxBin = "${pkgs.nodePackages.pnpm}/bin/pnpx";
export const nodeBin = "${pkgs.nodejs_21}/bin/node";
export const license = "/**" + "\n" +
" * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved." + "\n" +
" * Node module: @schukai/monster" + "\n" +
" *" + "\n" +
" * This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3)." + "\n" +
" * The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html" + "\n" +
" *" + "\n" +
" * For those who do not wish to adhere to the AGPLv3, a commercial license is available." + "\n" +
" * Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms." + "\n" +
" * For more information about purchasing a commercial license, please contact schukai GmbH." + "\n" +
" */" + "\n\n" ;
;
// THIS FILE IS AUTOGENERATED. DO NOT EDIT THIS FILE DIRECTLY.
'';
};
in
pkgs.writeShellScriptBin "update-files" ''
${common}
echo_section "Update files"
create_symlink() {
if ${pkgs.coreutils}/bin/ln -s "$1" "$2" 2>/dev/null; then
echo_ok "$2 created"
else
echo_fail "$2 already exists"
fi
}
update_symlink() {
echo_section "Update $1"
local source_path="$1"
local target_path="$2"
local file_name="$(basename "$target_path")"
local source_dir="$(dirname "$source_path")"
${pkgs.coreutils}/bin/mkdir -p "$source_dir" || true
if [[ ! -d "$source_dir" ]]; then
echo_fail "$source_dir is not a directory. Please remove it manually and run the script again."
exit 1
fi
if [[ -L "$source_path" ]]; then
if [[ "$(readlink "$source_path")" != "$target_path" ]]; then
echo_step "Remove old symlink $file_name"
${pkgs.coreutils}/bin/rm "$source_path"
echo_step "Create new symlink $file_name"
create_symlink "$target_path" "$source_path"
echo_ok "$source_path updated$RESET"
else
echo_ok "$source_path is up to date$RESET"
fi
elif [[ -e "$source_path" ]]; then
echo_fail "$source_path already exists and is not a symlink. Please remove it manually and run the script again."
exit 1
else
create_symlink "$target_path" "$source_path"
echo_ok "$source_path created$RESET"
fi
}
update_symlink "${config.devenv.root}/development/scripts/import.mjs" "${importJSScript}"
''
{
pkgs,
lib,
commonScript,
versionBin,
...
}: let
in
pkgs.writeShellScriptBin "update-project" ''
source ${commonScript}
echo_section "Checking code"
echo_hint "This script will check the code for formatting and linting issues"
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
echo_step "Checking direnv configuration"
## exclude node_modules
nix_files=$(${pkgs.findutils}/bin/find . -type d \( -path '*/node_modules/*' -o -name 'node_modules' \) -prune -o -type f -name "*.nix" -print | tr '\n' ' ')
watch_line="watch_file $nix_files"
{
echo "$watch_line"
echo "use flake"
} > .envrc.new
if ! ${pkgs.diffutils}/bin/diff .envrc .envrc.new
then
${pkgs.coreutils}/bin/mv .envrc.new .envrc
echo_ok "direnv configuration updated"
fi
if [ -f .envrc.new ]; then
${pkgs.coreutils}/bin/rm .envrc.new
fi
echo_step "Checking nix code"
if ! ${pkgs.alejandra}/bin/alejandra flake.nix ./nix/scripts/*.nix ./nix/config/*.nix ./nix/packages/*nix
then
echo_fail "alejandra formatting failed"
exit 1
else
echo_ok "nix code formatted"
fi
echo_step "Installing dependencies (node)"
if ! ${pkgs.findutils}/bin/find . -type d -name node_modules -prune -o -type f -name package.json -print | ${pkgs.findutils}/bin/xargs -I {} sh -c "cd $(dirname {}); ${pkgs.corepack}/bin/pnpm install"
then
echo_error "Failed to install dependencies"
echo_hint "Check the error message and try again"
exit 1
fi
##format javascript code
echo_step "Formatting JS code"
if ! ${pkgs.biome}/bin/biome format --write ./source/
then
echo_fail "biome format failed"
exit 1
else
echo_ok "JS code formatted"
fi
## lint javascript code
echo_step "Linting JS code"
if ! ${pkgs.biome}/bin/biome lint ./source/
then
echo_fail "biome lint failed"
# exit 1 # to many errors, therefore not exiting
echo_hint "we do not exit the script here, because the linting still results in too many issues that need to be fixed bit by bit."
echo_hint "check one or two places and reduce the number, please. ♥"
fi
echo_ok "Code checked"
''
{
"name": "@schukai/monster",
"version": "3.64.1",
"version": "3.65.0",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [
"framework",
......@@ -40,10 +40,8 @@
"author": "schukai GmbH",
"license": "AGPL 3.0",
"dependencies": {
"@floating-ui/dom": "^1.6.3",
"@popperjs/core": "^2.11.8",
"estraverse": "^5.3.0",
"vite-plugin-directory-index": "^3.0.1"
"@floating-ui/dom": "^1.6.5",
"@popperjs/core": "^2.11.8"
},
"devDependencies": {
"@biomejs/biome": "1.3.3",
......@@ -56,28 +54,21 @@
"c8": "^8.0.1",
"chai": "^4.4.1",
"chai-dom": "^1.12.0",
"clean-jsdoc-theme": "^4.2.18",
"create-polyfill-service-url": "^2.3.0",
"crypt": "^0.0.2",
"cssnano": "^6.1.2",
"dom-storage": "^2.1.0",
"element-internals-polyfill": "^1.3.10",
"element-internals-polyfill": "^1.3.11",
"esbuild": "^0.19.12",
"esdoc": "^1.1.0",
"esdoc-standard-plugin": "^1.0.0",
"espree": "^10.0.1",
"estraverse": "^5.3.0",
"flow-bin": "^0.221.0",
"fs": "0.0.1-security",
"glob": "^10.3.12",
"glob": "^10.3.14",
"graphviz": "^0.0.9",
"jsdoc": "^4.0.2",
"jsdoc-external-example": "github:volker-schukai/jsdoc-external-example",
"jsdoc-mermaid": "^1.0.0",
"jsdoc-plantuml": "^1.0.3",
"jsdom": "^22.1.0",
"jsdom-global": "^3.0.2",
"mocha": "^10.4.0",
"node-plantuml": "^0.9.0",
"postcss": "^8.4.38",
"postcss-fluid": "^1.4.2",
"postcss-for": "^2.1.1",
......@@ -85,23 +76,24 @@
"postcss-load-config": "^4.0.2",
"postcss-mixins": "^9.0.4",
"postcss-nested": "^6.0.1",
"postcss-nesting": "^12.1.1",
"postcss-nesting": "^12.1.3",
"postcss-normalize": "^10.0.1",
"postcss-responsive-type": "^1.0.0",
"postcss-rtlcss": "^4.0.9",
"postcss-strip-units": "^2.0.1",
"puppeteer": "^21.11.0",
"sinon": "^17.0.1",
"sinon": "^17.0.2",
"turbowatch": "^2.29.4",
"url": "^0.11.3",
"url-exist": "3.0.1",
"util": "^0.12.5",
"vite": "5.2.7",
"vite-plugin-banner": "^0.7.1",
"vite-plugin-directory-index": "^3.0.1",
"vite-plugin-list-directory-contents": "^1.4.5",
"vite-plugin-minify": "^1.5.2",
"vite-plugin-mock": "^3.0.1",
"vite-plugin-mock": "^3.0.2",
"vite-plugin-terminal": "^1.2.0",
"ws": "^8.16.0"
"ws": "^8.17.0"
}
}
This diff is collapsed.
......@@ -16,7 +16,7 @@
"dependencies": {
"@floating-ui/dom": "^1.6.3",
"@popperjs/core": "^2.11.8",
"@schukai/monster": "^3.64.1",
"@schukai/monster": "^3.65.0",
"highlight.js": "^11.9.0"
},
"devDependencies": {
......@@ -27,7 +27,7 @@
"c8": "^8.0.1",
"create-polyfill-service-url": "^2.3.0",
"cssnano": "^6.1.2",
"element-internals-polyfill": "^1.3.10",
"element-internals-polyfill": "^1.3.11",
"esbuild": "^0.19.12",
"flow-bin": "^0.221.0",
"fs": "0.0.1-security",
......
This diff is collapsed.
......@@ -14,17 +14,20 @@
</head>
<body>
<div class="deco-line"></div>
<monster-panel>
<monster-split-panel data-monster-option-splittype="vertical" data-monster-option-dimension-initial="0%"
<monster-split-panel data-monster-option-splittype="vertical" data-monster-option-dimension-initial="300px"
data-monster-option-dimension-min="0%" data-monster-option-dimension-max="100%">
<monster-panel slot="start">
<monster-reload data-monster-url="./navigation.html"></monster-reload>
</monster-panel>
<monster-panel slot="end">
<main class="container">
<div class="deco"></div>
<div class="to-overview">
<a href="/" class="back-link">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
......@@ -36,7 +39,7 @@
</a>
</div>
<h1>Popper</h1>
<h1 id="class-name">Popper</h1>
<p>A beautiful popper that can make your life easier and also looks good.</p>
<div class="info-grid">
......@@ -62,7 +65,7 @@
<div><a target="_blank" href="https://npmjs.com/package/@schukai/monster">@schukai/monster</a></div>
<div>Since</div>
<div></div>
<div>1.66.0</div>
<div>1.65.0</div>
</div>
<div class="show-it"><monster-popper>
<div slot="button"
......@@ -75,7 +78,7 @@
<div data-monster-button-label="Overview"
class="active"
data-monster-button-icon="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='m8 2.42-.717-.737c-1.13-1.161-3.243-.777-4.01.72-.35.685-.451 1.707.236 3.062C4.16 6.753 5.52 8.32 8 10.042c2.479-1.723 3.839-3.29 4.491-4.577.687-1.355.587-2.377.236-3.061-.767-1.498-2.88-1.882-4.01-.721zm-.49 8.5c-10.78-7.44-3-13.155.359-10.063q.068.062.132.129.065-.067.132-.129c3.36-3.092 11.137 2.624.357 10.063l.235.468a.25.25 0 1 1-.448.224l-.008-.017c.008.11.02.202.037.29.054.27.161.488.419 1.003.288.578.235 1.15.076 1.629-.157.469-.422.867-.588 1.115l-.004.007a.25.25 0 1 1-.416-.278c.168-.252.4-.6.533-1.003.133-.396.163-.824-.049-1.246l-.013-.028c-.24-.48-.38-.758-.448-1.102a3 3 0 0 1-.052-.45l-.04.08a.25.25 0 1 1-.447-.224l.235-.468ZM6.013 2.06c-.649-.18-1.483.083-1.85.798-.131.258-.245.689-.08 1.335.063.244.414.198.487-.043.21-.697.627-1.447 1.359-1.692.217-.073.304-.337.084-.398'/%3E%3C/svg%3E">
<h2>Introduction</h2>
<monster-table-of-content><h2>Introduction</h2>
<p>
This is the Monster Popper component. It is a versatile and customizable control element
to an interactive and engaging user experience that integrates seamlessly into various web applications.
......@@ -117,7 +120,7 @@
your existing tools and libraries. Whether you are working on a small project or a large
application, Monster Popper's modular design guarantees easy integration that streamlines
your development process and increases your productivity.
</p>
</p></monster-table-of-content>
</div>
<div data-monster-button-label="Usage"
data-monster-button-icon="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M9.752 6.193c.599.6 1.73.437 2.528-.362s.96-1.932.362-2.531c-.599-.6-1.73-.438-2.528.361-.798.8-.96 1.933-.362 2.532'/%3E%3Cpath d='M15.811 3.312c-.363 1.534-1.334 3.626-3.64 6.218l-.24 2.408a2.56 2.56 0 0 1-.732 1.526L8.817 15.85a.51.51 0 0 1-.867-.434l.27-1.899c.04-.28-.013-.593-.131-.956a9 9 0 0 0-.249-.657l-.082-.202c-.815-.197-1.578-.662-2.191-1.277-.614-.615-1.079-1.379-1.275-2.195l-.203-.083a10 10 0 0 0-.655-.248c-.363-.119-.675-.172-.955-.132l-1.896.27A.51.51 0 0 1 .15 7.17l2.382-2.386c.41-.41.947-.67 1.524-.734h.006l2.4-.238C9.005 1.55 11.087.582 12.623.208c.89-.217 1.59-.232 2.08-.188.244.023.435.06.57.093q.1.026.16.045c.184.06.279.13.351.295l.029.073a3.5 3.5 0 0 1 .157.721c.055.485.051 1.178-.159 2.065m-4.828 7.475.04-.04-.107 1.081a1.54 1.54 0 0 1-.44.913l-1.298 1.3.054-.38c.072-.506-.034-.993-.172-1.418a9 9 0 0 0-.164-.45c.738-.065 1.462-.38 2.087-1.006M5.205 5c-.625.626-.94 1.351-1.004 2.09a9 9 0 0 0-.45-.164c-.424-.138-.91-.244-1.416-.172l-.38.054 1.3-1.3c.245-.246.566-.401.91-.44l1.08-.107zm9.406-3.961c-.38-.034-.967-.027-1.746.163-1.558.38-3.917 1.496-6.937 4.521-.62.62-.799 1.34-.687 2.051.107.676.483 1.362 1.048 1.928.564.565 1.25.941 1.924 1.049.71.112 1.429-.067 2.048-.688 3.079-3.083 4.192-5.444 4.556-6.987.183-.771.18-1.345.138-1.713a3 3 0 0 0-.045-.283 3 3 0 0 0-.3-.041Z'/%3E%3Cpath d='M7.009 12.139a7.6 7.6 0 0 1-1.804-1.352A7.6 7.6 0 0 1 3.794 8.86c-1.102.992-1.965 5.054-1.839 5.18.125.126 3.936-.896 5.054-1.902Z'/%3E%3C/svg%3E">
......@@ -218,28 +221,29 @@
</div>
<div data-monster-button-label="API"
data-monster-button-icon="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M6 0a.5.5 0 0 1 .5.5V3h3V.5a.5.5 0 0 1 1 0V3h1a.5.5 0 0 1 .5.5v3A3.5 3.5 0 0 1 8.5 10c-.002.434-.01.845-.04 1.22-.041.514-.126 1.003-.317 1.424a2.08 2.08 0 0 1-.97 1.028C6.725 13.9 6.169 14 5.5 14c-.998 0-1.61.33-1.974.718A1.92 1.92 0 0 0 3 16H2c0-.616.232-1.367.797-1.968C3.374 13.42 4.261 13 5.5 13c.581 0 .962-.088 1.218-.219.241-.123.4-.3.514-.55.121-.266.193-.621.23-1.09.027-.34.035-.718.037-1.141A3.5 3.5 0 0 1 4 6.5v-3a.5.5 0 0 1 .5-.5h1V.5A.5.5 0 0 1 6 0M5 4v2.5A2.5 2.5 0 0 0 7.5 9h1A2.5 2.5 0 0 0 11 6.5V4z'/%3E%3C/svg%3E">
<monster-table-of-content>
<h2>HTML Structure</h2>
<pre><code class="language-html">&lt;monster-popper&gt;&lt;/monster-popper&gt;</code></pre>
<h2>JavaScript Initialization</h2>
<pre><code class="language-js">const element = document.createElement('monster-popper');
document.body.appendChild(element);</code></pre>
<h2>Exported</h2>
<pre><code class="language-js">Popper</code></pre>
<h2>Options</h2>
<div class="option-grid">
<div class="option-headline">Option</div>
<div class="option-headline">Type</div>
<div class="option-headline">Default</div>
<div class="option-headline">Description</div>
<div>templates</div><div>object</div><div></div><div>templates The templates for the control.</div>
<div>templates.main</div><div>string</div><div></div><div>templates.main The main template.</div>
<div>mode</div><div>string</div><div></div><div>mode The mode of the popper. Possible values are `click`, `enter`, `manual`, `focus`, "auto" or a combination of them.</div>
<div>content</div><div>string</div><div></div><div>content The content of the popper.</div>
<div>popper</div><div>object</div><div></div><div>popper The popper options.</div>
<div>popper.placement</div><div>string</div><div></div><div>popper.placement The placement of the popper. Possible values are `top`, `bottom`, `left` and `right`.</div>
<div>popper.middleware</div><div>function[]</div><div></div><div>popper.middleware The middleware functions of the popper.</div>
<div>popper.middlewareInit</div><div>function[]</div><div></div><div>popper.middlewareInit The middleware init functions of the popper.</div>
<div>features</div><div>object</div><div></div><div>features The features of the popper.</div>
<div>features.preventPropagateOpenEvents</div><div>boolean</div><div></div><div>features.preventPropagateOpenEvents Prevents the open event from being sent.</div>
<div>templates</div><div>object</div><div></div><div>The templates for the control.</div>
<div>templates.main</div><div>string</div><div>undefined</div><div>The main template.</div>
<div>mode</div><div>string</div><div>auto focus</div><div>The mode of the popper. Possible values are `click`, `enter`, `manual`, `focus`, "auto" or a combination of them.</div>
<div>content</div><div>string</div><div>&lt;slot&gt;&lt;/slot&gt;</div><div>The content of the popper.</div>
<div>popper</div><div>object</div><div></div><div>The popper options.</div>
<div>popper.placement</div><div>string</div><div>top</div><div>The placement of the popper. Possible values are `top`, `bottom`, `left` and `right`.</div>
<div>popper.middleware</div><div>function[]</div><div>autoPlacement, offset:10, arrow</div><div>The middleware functions of the popper.</div>
<div>features</div><div>object</div><div></div><div>The features of the popper.</div>
<div>features.preventOpenEventSent</div><div>boolean</div><div>false</div><div>Prevents the open event from being sent.</div>
</div><br>
<h2>Properties and Attributes</h2>
<ul>
......@@ -251,29 +255,42 @@ document.body.appendChild(element);</code></pre>
</li>
</ul>
<h2>Methods</h2>
<h3>Other methods</h3><div class="method-grid"><div class='method-signature'><code class='language-javascript'>assembleMethodSymbol()</code></div><div><strong>Returns</strong><ul><li>{Popper}</li></ul> </div><div class='method-description'>
<h3>Behavioral methods</h3><div class="method-grid"><div class='method-signature'><code class='language-javascript'>hideDialog()</code></div><div><strong>Returns</strong><ul><li>{Popper}</li></ul> </div><div class='method-description'>
With this method you can hide the popper.
</div>
<div class='method-signature'><code class='language-javascript'>showDialog()</code></div><div><strong>Returns</strong><ul><li>{Popper}</li></ul> </div><div class='method-description'>
With this method you can show the popper.
</div>
<div class='method-signature'><code class='language-javascript'>toggleDialog()</code></div><div><strong>Returns</strong><ul><li>{Popper}</li></ul> </div><div class='method-description'>
With this method you can toggle the popper.
</div></div><h3>Static methods</h3><div class="method-grid"><div class='method-signature'><code class='language-javascript'>getCSSStyleSheet()</code></div><div><strong>Returns</strong><ul><li>{CSSStyleSheet[]}</li></ul> </div><div class='method-description'>
This method returns the css styles of the element.
</div>
<div class='method-signature'><code class='language-javascript'>getTag()</code></div><div><strong>Returns</strong><ul><li>{string}</li></ul> </div><div class='method-description'>
This method returns the tag name of the element.
</div>
<div class='method-signature'><code class='language-javascript'>connectedCallback()</code></div><div><strong>Returns</strong><ul><li>{void}</li></ul> </div><div class='method-description'> </div>
<div class='method-signature'><code class='language-javascript'>disconnectedCallback()</code></div><div><strong>Returns</strong><ul><li>{void}</li></ul> </div><div class='method-description'> </div>
<div class='method-signature'><code class='language-javascript'>getCSSStyleSheet()</code></div><div><strong>Returns</strong><ul><li>{Array<CSSStyleSheet>}</li></ul> </div><div class='method-description'> </div>
<div class='method-signature'><code class='language-javascript'>getTag()</code></div><div><strong>Returns</strong><ul><li>{string}</li></ul> </div><div class='method-description'> </div>
<div class='method-signature'><code class='language-javascript'>hideDialog()</code></div><div><strong>Returns</strong><ul><li>{Popper}</li></ul> </div><div class='method-description'> </div>
<div class='method-signature'><code class='language-javascript'>instanceSymbol()</code></div><div> </div><div class='method-description'>
This method is called by the <code>instanceof</code> operator. </div>
<div class='method-signature'><code class='language-javascript'>showDialog()</code></div><div><strong>Returns</strong><ul><li>{Popper}</li></ul> </div><div class='method-description'> </div>
<div class='method-signature'><code class='language-javascript'>toggleDialog()</code></div><div><strong>Returns</strong><ul><li>{Popper}</li></ul> </div><div class='method-description'> </div></div><br>
This method is called by the <code>instanceof</code> operator. </div></div><h3>Lifecycle methods</h3><div class="method-grid"><div class='method-signature'><code class='language-javascript'>assembleMethodSymbol()</code></div><div><strong>Returns</strong><ul><li>{Void}</li></ul> </div><div class='method-description'>
This method is called by the <code>connectedCallback</code> method on the first call.
</div>
<div class='method-signature'><code class='language-javascript'>connectedCallback()</code></div><div><strong>Returns</strong><ul><li>{void}</li></ul> </div><div class='method-description'>
This method is called when the element is connected to the dom.
</div>
<div class='method-signature'><code class='language-javascript'>disconnectedCallback()</code></div><div><strong>Returns</strong><ul><li>{void}</li></ul> </div><div class='method-description'>
This method is called when the element is disconnected from the dom.
</div></div><br>
<h2>Events</h2>
<p>The component emits the following events:</p><ul><li><code>monster-popper-hide</code> fired when the popper is hide.</li>
<li><code>monster-popper-hidden</code> fired when the popper is hidden.</li>
<li><code>monster-popper-open</code> fired when the popper is open.</li>
<li><code>monster-popper-opened</code> fired when the popper is opened.</li></ul><p>For more information on how to handle events, see the <a target='_blank' href="https://developer.mozilla.org/en-US/docs/Web/Events">mdn documentation</a>.</p>
</monster-table-of-content>
</div>
</monster-tabs>
</main>
<footer>
<p>© 2024 Powered by schukai GmbH - All rights reserved.</p>
<p>© 2024 Powered by schukai GmbH All rights reserved.</p>
<p>Code and documentation licensed by <a target="_blank"
href="https://www.gnu.org/licenses/agpl-3.0.en.html">AGPLv3
License</a> or commercial license.</p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment