From 53d0bd8b6054f7f3d5badecce46252448d27b04e Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sat, 15 Feb 2025 19:02:30 +0100 Subject: [PATCH] Test config Workflow --- .github/workflows/changelog.yml | 30 -------- .github/workflows/docs.yml | 47 ------------- .github/workflows/lualsgen.yml | 36 ---------- .github/workflows/release.yml | 58 ---------------- .gitignore | 3 +- installer.lua | 98 ++++++++++++++++++++++++++ minify.yml | 118 -------------------------------- tools/generate-config.lua | 27 ++++++++ 8 files changed, 127 insertions(+), 290 deletions(-) delete mode 100644 .github/workflows/changelog.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/lualsgen.yml delete mode 100644 .github/workflows/release.yml create mode 100644 installer.lua delete mode 100644 minify.yml create mode 100644 tools/generate-config.lua diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml deleted file mode 100644 index c10d7a7..0000000 --- a/.github/workflows/changelog.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Generate Changelog - -on: - push: - paths: - - 'src/**' - branches: - - main - -jobs: - changelog: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Generate changelog - id: changelog - uses: heinrichreimer/github-changelog-generator-action@v2.3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Commit updated changelog - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add CHANGELOG.md - git commit -m "Update changelog" || true - git push diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 357b938..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build Docs -on: - pull_request: - branches: - - main - paths: - - 'src/**' - push: - branches: - - main - paths: - - 'src/**' -jobs: - build: - name: Build docs - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Lua - uses: leafo/gh-actions-lua@v8 - with: - luaVersion: 5.4 - - name: Checkout existing docs - uses: actions/checkout@v3 - with: - ref: gh-pages - path: build_docs - - name: Prepare references directory - run: | - mkdir -p build_docs/docs - rm -rf build_docs/docs/references - mkdir -p build_docs/docs/references - - name: Process markdown files - run: | - find src -type f -name "*.lua" | while read file; do - filename=$(basename "$file") - if [ "$filename" != "LuaLS.lua" ]; then - lua tools/markdown.lua "$file" "build_docs/docs/references/${filename%.lua}.md" - fi - done - - name: Deploy - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build_docs \ No newline at end of file diff --git a/.github/workflows/lualsgen.yml b/.github/workflows/lualsgen.yml deleted file mode 100644 index 6c573e5..0000000 --- a/.github/workflows/lualsgen.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Generate LuaLS Definitions -on: - push: - paths: - - 'src/elements/**' - branches: - - main - pull_request: - paths: - - 'src/elements/**' - branches: - - main - -jobs: - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Setup Lua - uses: leafo/gh-actions-lua@v8 - with: - luaVersion: "5.4" - - - name: Generate LuaLS definitions - run: | - lua tools/annotationParser.lua src/elements src/LuaLS.lua - - - name: Commit changes - if: github.event_name == 'push' - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add src/LuaLS.lua - git commit -m "Update LuaLS definitions" || true - git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index f43437d..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Create Release - -on: - workflow_run: - workflows: ["Minify Lua Code"] - types: - - completed - branches: - - main - -jobs: - release: - if: | - github.event.workflow_run.conclusion == 'success' && - contains(github.event.workflow_run.head_commit.modified, 'version') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Get Version - id: version - run: echo "version=$(cat version)" >> $GITHUB_OUTPUT - - - name: Check if version file changed - run: | - git fetch origin ${{ github.event.workflow_run.head_branch }} - if ! git diff --quiet origin/${{ github.event.workflow_run.head_branch }}^1 origin/${{ github.event.workflow_run.head_branch }} -- version; then - echo "Version file was changed" - else - echo "Version file was not changed" - exit 1 - - # Add version check - - name: Check if version exists - run: | - if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then - echo "::error::Version v${{ steps.version.outputs.version }} already exists" - exit 1 - fi - - - name: Generate changelog - id: changelog - uses: heinrichreimer/github-changelog-generator-action@v2.3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ steps.version.outputs.version }} - body_path: CHANGELOG.md - files: | - CHANGELOG.md - release/basalt.lua - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 672fe6c..e46fc93 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ test2.lua lua-ls-cc-tweaked-main test.xml ascii.lua -tests \ No newline at end of file +tests +workflows \ No newline at end of file diff --git a/installer.lua b/installer.lua new file mode 100644 index 0000000..c42d1c3 --- /dev/null +++ b/installer.lua @@ -0,0 +1,98 @@ +local basalt = require("basalt") +local REPO_URL = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/master/src" + +-- Basis-Komponenten die immer installiert werden müssen +local REQUIRED_FILES = { + "init.lua", + "render.lua", + "elementManager.lua", + "propertySystem.lua", + "elements/BaseElement.lua", + "elements/VisualElement.lua", + "elements/Container.lua", + "elements/BaseFrame.lua" +} + +-- Optionale Komponenten +local OPTIONAL_ELEMENTS = { + "Button", + "Input", + "Label", + "List", + "Menu", + "Table", + "Tree", + "Dropdown" +} + +local OPTIONAL_PLUGINS = { + "animation", + "theme", + "xml", + "state" +} + +local main = basalt.createFrame() + :setBackground(colors.lightGray) + +-- Header +main:addLabel() + :setText("Basalt2 Installer") + :setPosition(2,2) + :setForeground(colors.black) + +-- Element Selection +local elementList = main:addList() + :setPosition(2,4) + :setSize(20,8) + :setBackground(colors.white) + :setForeground(colors.black) + +for _, element in ipairs(OPTIONAL_ELEMENTS) do + elementList:addItem({ + text = element, + selected = true + }) +end + +-- Plugin Selection +local pluginList = main:addList() + :setPosition(24,4) + :setSize(20,8) + :setBackground(colors.white) + :setForeground(colors.black) + +for _, plugin in ipairs(OPTIONAL_PLUGINS) do + pluginList:addItem({ + text = plugin, + selected = true + }) +end + +-- Labels +main:addLabel() + :setText("Elements:") + :setPosition(2,3) + :setForeground(colors.black) + +main:addLabel() + :setText("Plugins:") + :setPosition(24,3) + :setForeground(colors.black) + +-- Install Button +main:addButton() + :setText("Install") + :setPosition(2,13) + :setSize(42,1) + :onClick(function() + -- Installation Logic hier + local selectedElements = {} + local selectedPlugins = {} + + -- Sammle ausgewählte Items + -- Download Files + -- Erstelle Ordnerstruktur + end) + +basalt.autoUpdate() diff --git a/minify.yml b/minify.yml deleted file mode 100644 index 2d242e6..0000000 --- a/minify.yml +++ /dev/null @@ -1,118 +0,0 @@ -name: Minify Lua Code - -on: - push: - branches: - - main - paths: - - 'src/**' - pull_request: - branches: - - main - paths: - - 'src/**' - -jobs: - minify: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Lua - run: | - sudo apt-get update - sudo apt-get install -y lua5.3 - - - name: Minify Lua files - run: | - mkdir -p release - - echo "Creating minification script..." - cat > minify_script.lua << 'EOL' - local minify = loadfile("tools/minify.lua")() - local lfs = require("lfs") - - local files = {} - - local function scanDir(dir, baseDir) - baseDir = baseDir or "" - for file in lfs.dir(dir) do - if file ~= "." and file ~= ".." then - local fullPath = dir .. "/" .. file - local attr = lfs.attributes(fullPath) - if attr.mode == "directory" then - scanDir(fullPath, baseDir .. file .. "/") - elseif file:match("%.lua$") and file ~= "LuaLS.lua" then - table.insert(files, { - path = baseDir .. file, - fullPath = fullPath - }) - end - end - end - end - - scanDir("src") - - local output = { - 'local minified = true\n', - 'local project = {}\n', - 'local baseRequire = require\n', - 'require = function(path) return project[path] or baseRequire(path) end\n' - } - - for _, file in ipairs(files) do - local f = io.open(file.fullPath, "r") - local content = f:read("*all") - f:close() - - local success, minified = minify(content) - if not success then - print("Failed to minify " .. file.path) - print(minified) - os.exit(1) - end - - table.insert(output, string.format( - 'project["%s"] = function(...) %s end\n', - file.path, minified - )) - end - - table.insert(output, 'return project["main.lua"]') - - local out = io.open("release/basalt.lua", "w") - out:write(table.concat(output)) - out:close() - EOL - - echo "Installing LuaFileSystem..." - sudo apt-get install -y lua-filesystem - - echo "Running minification..." - if lua minify_script.lua; then - echo "Minification successful" - echo "Files processed:" - find src -name "*.lua" | sed 's|^src/||' - else - echo "Minification failed" - exit 1 - fi - - - name: Commit minified Lua file - if: success() - run: | - if [ -s release/basalt.lua ]; then - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add release/basalt.lua - git commit -m 'Minify all Lua files into project bundle' - git push - else - echo "Error: basalt.lua is empty or doesn't exist" - exit 1 - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/tools/generate-config.lua b/tools/generate-config.lua new file mode 100644 index 0000000..d06d31e --- /dev/null +++ b/tools/generate-config.lua @@ -0,0 +1,27 @@ +local function scanDir(dir) + local files = {} + for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do + local name = file:match("([^/]+)%.lua$") + if name then + files[file] = { + name = name, + path = file:gsub("^src", ""), + } + end + end + return files +end + +local config = { + repo = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/master", + required = { + ["src/init.lua"] = "/init.lua", + ["src/render.lua"] = "/render.lua", + }, + elements = scanDir("src/elements"), + plugins = scanDir("src/plugins") +} + +local f = io.open("config.lua", "w") +f:write("return " .. textutils.serialize(config)) +f:close()