-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
970db3a
commit 6fd4da1
Showing
25 changed files
with
2,118 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
# syntax = docker/dockerfile:1.4 | ||
FROM nixos/nix:2.21.1@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9 AS builder | ||
|
||
WORKDIR /tmp/build | ||
RUN mkdir /tmp/nix-store-closure | ||
|
||
# ignore SC2046 because the output of nix-store -qR will never have spaces - this is safe here | ||
# hadolint ignore=SC2046 | ||
RUN --mount=type=cache,target=/nix,from=nixos/nix:2.21.1,source=/nix \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,target=/tmp/build \ | ||
<<EOF | ||
nix \ | ||
--extra-experimental-features "nix-command flakes" \ | ||
--option filter-syscalls false \ | ||
--extra-trusted-substituters "https://cache.iog.io" \ | ||
--extra-trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \ | ||
--show-trace \ | ||
--log-format raw \ | ||
build . --out-link /tmp/output/result | ||
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure | ||
EOF | ||
|
||
FROM scratch | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /tmp/nix-store-closure /nix/store | ||
COPY --from=builder /tmp/output/ /app/ | ||
|
||
ENTRYPOINT ["/app/result/bin/entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(ns build | ||
(:require [clojure.tools.build.api :as b])) | ||
|
||
(def class-dir "target/classes") | ||
(def basis (b/create-basis {:project "deps.edn"})) | ||
|
||
(defn compile-java [_] | ||
(b/delete {:path "target"}) | ||
(b/javac {:src-dirs ["src/java"] | ||
:class-dir class-dir | ||
:basis basis | ||
:javac-opts ["-source" "8" "-target" "8"]})) | ||
|
||
(defn uber [_] | ||
(compile-java nil) ; Compile Java first | ||
(b/copy-dir {:src-dirs ["src/clojure" "resources"] | ||
:target-dir class-dir}) | ||
(b/compile-clj {:basis basis ; compile clojure code | ||
:src-dirs ["src/clojure"] | ||
:class-dir class-dir}) | ||
(b/uber {:class-dir class-dir | ||
:uber-file "target/my-project.jar" | ||
:basis basis | ||
:main 'docker.ts})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
|
||
sitter "github.com/smacker/go-tree-sitter" | ||
"github.com/smacker/go-tree-sitter/python" | ||
"github.com/smacker/go-tree-sitter/yaml" | ||
"github.com/smacker/go-tree-sitter/sql" | ||
"github.com/smacker/go-tree-sitter/bash" | ||
"github.com/smacker/go-tree-sitter/html" | ||
"github.com/smacker/go-tree-sitter/dockerfile" | ||
) | ||
|
||
func main() { | ||
// Check if both language and query string are provided as arguments | ||
if len(os.Args) < 3 { | ||
fmt.Println("Usage: ./program <language> <query_string>") | ||
return | ||
} | ||
language := os.Args[1] | ||
queryString := os.Args[2] | ||
|
||
// Create a parser | ||
parser := sitter.NewParser() | ||
|
||
// Set the language based on the first argument | ||
switch language { | ||
case "python": | ||
parser.SetLanguage(python.GetLanguage()) | ||
case "yaml": | ||
parser.SetLanguage(yaml.GetLanguage()) | ||
case "sql": | ||
parser.SetLanguage(sql.GetLanguage()) | ||
case "bash": | ||
parser.SetLanguage(bash.GetLanguage()) | ||
case "html": | ||
parser.SetLanguage(html.GetLanguage()) | ||
case "dockerfile": | ||
parser.SetLanguage(dockerfile.GetLanguage()) | ||
default: | ||
fmt.Printf("Unsupported language: %s\n", language) | ||
return | ||
} | ||
|
||
// Read source code from stdin | ||
sourceCode, err := ioutil.ReadAll(os.Stdin) | ||
if err != nil { | ||
fmt.Println("Error reading from stdin:", err) | ||
return | ||
} | ||
|
||
// Parse the source code | ||
tree := parser.Parse(nil, sourceCode) | ||
defer tree.Close() | ||
|
||
// Create a query | ||
query, err := sitter.NewQuery([]byte(queryString), python.GetLanguage()) | ||
if err != nil { | ||
fmt.Println("Error creating query:", err) | ||
return | ||
} | ||
defer query.Close() | ||
|
||
// Execute the query | ||
qc := sitter.NewQueryCursor() | ||
defer qc.Close() | ||
|
||
qc.Exec(query, tree.RootNode()) | ||
|
||
// Iterate over the query results | ||
for { | ||
match, ok := qc.NextMatch() | ||
if !ok { | ||
break | ||
} | ||
|
||
for _, capture := range match.Captures { | ||
captureName := query.CaptureNameForId(capture.Index) | ||
nodeText := capture.Node.Content(sourceCode) | ||
fmt.Printf("Capture: %s, Node: %s\n", captureName, nodeText) | ||
} | ||
} | ||
} |
Oops, something went wrong.