Skip to content

Commit

Permalink
fix corner case of comma in folding vectors; upgrade workflow; alpha …
Browse files Browse the repository at this point in the history
…release
  • Loading branch information
tiye committed Mar 28, 2020
1 parent d50301f commit 3aa4fba
Show file tree
Hide file tree
Showing 18 changed files with 348 additions and 222 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

name: Deploy package

on:
release:
types: [created]

jobs:
deploy:
name: Deploy

runs-on: ubuntu-latest

steps:
- run: curl -O https://download.clojure.org/install/linux-install-1.10.1.507.sh && chmod +x linux-install-1.10.1.507.sh && sudo ./linux-install-1.10.1.507.sh

- uses: actions/checkout@v2

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
name: Cache node modules of yarn
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache Clojars
uses: actions/cache@v1
env:
cache-name: cache-clojars
with:
path: ~/.m2/repository
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('shadow-cljs.edn') }}
restore-keys: |
${{ runner.os }}-clojars
- name: run tests
run: 'yarn && yarn shadow-cljs compile test && node target/test.js'

- run: echo Working on ${{ github.ref }}

- name: deploy to clojars
run: env CLOJARS_USERNAME=jiyinyiyong CLOJARS_PASSWORD=${{ secrets.CLOJARS_PASSWORD }} clojure -A:release
55 changes: 55 additions & 0 deletions .github/workflows/upload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

name: Upload Assets

on:
pull_request: {}
push:
branches:
- master

jobs:
upload-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker://timbru31/java-node:latest

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
name: Cache node modules of yarn
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache Clojars
uses: actions/cache@v1
env:
cache-name: cache-clojars
with:
path: ~/.m2/repository
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('shadow-cljs.edn') }}
restore-keys: |
${{ runner.os }}-clojars
- run: yarn && yarn build
name: Build web assets

- name: Deploy to server
id: deploy
uses: Pendect/action-rsyncer@v1.1.0
env:
DEPLOY_KEY: ${{secrets.rsync_private_key}}
with:
flags: '-avzr --progress'
options: ''
ssh_options: ''
src: 'dist/*'
dest: 'rsync-user@tiye.me:/web-assets/repo/${{ github.repository }}'

- name: Display status from deploy
run: echo "${{ steps.deploy.outputs.status }}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Demo http://repo.cirru.org/writer.clj/
[![Clojars Project](https://img.shields.io/clojars/v/cirru/writer.svg)](https://clojars.org/cirru/writer)

```clojure
[cirru/writer "0.1.6"]
[cirru/writer "0.1.7-a1"]
```

```clojure
Expand Down
222 changes: 190 additions & 32 deletions calcit.cirru

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

{
:paths ["src"]
:aliases {
:release {
:extra-deps {
appliedscience/deps-library {:mvn/version "0.3.4"}
}
:main-opts ["-m" "deps-library.release"]
}
}
}
1 change: 1 addition & 0 deletions examples/ast/fold-vectors.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[["a" [[] "b"] "e" "f" "g" "h"]]
4 changes: 4 additions & 0 deletions examples/cirru/fold-vectors.cirru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

a
() b
, e f g h
3 changes: 2 additions & 1 deletion examples/cirru/unfolding.cirru
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

set (add 1 $)
, x y (add 5 $)
, x y
add 5 $
add 2
9 changes: 0 additions & 9 deletions meyvn.edn

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"shortid": "^2.2.15"
},
"devDependencies": {
"http-server": "^0.12.0",
"shadow-cljs": "^2.8.83"
}
}
6 changes: 6 additions & 0 deletions release.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{:version "0.1.7-a1"
:group-id "cirru"
:artifact-id "writer"
:skip-tag true
:description "Cirru Writer"
:scm-url "https://github.com/Cirru/writer.clj"}
18 changes: 7 additions & 11 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
:dependencies [
[mvc-works/hsl "0.1.2"]
[mvc-works/shell-page "0.1.10"]
[respo/ui "0.3.13"]
[respo/reel "0.3.5"]
[cirru/parser "0.2.0"]
[respo/value "0.2.5"]
[respo "0.11.5"]
[respo/reel "0.3.5"]
[respo/ui "0.3.14"]
[respo/reel "0.4.0"]
[cirru/parser "0.2.5"]
[respo/value "0.3.0"]
[respo "0.12.1"]
[respo/reel "0.4.0"]
[cumulo/util "0.1.10"]
[medley "1.2.0"]
[medley "1.3.0"]
[org.clojure/core.incubator "0.1.4"]
]
:repositories {
"central" {:url "https://maven.aliyun.com/nexus/content/groups/public/"}
"clojars" {:url "https://mirrors.ustc.edu.cn/clojars/"}
}
:open-file-command [
"subl"
["%s:%s:%s" :file :line :column]
Expand Down
2 changes: 1 addition & 1 deletion src/cirru_writer/comp/container.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
(=< 8 nil)
(button
{:style (merge ui/button {:vertical-align :middle}),
:on-click (fn [e d! m!]
:on-click (fn [e d!]
(try
(let [started-time (.now js/Date)
result (generate-statements (read-string (:content store)) {:inline? true})]
Expand Down
9 changes: 7 additions & 2 deletions src/cirru_writer/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

(def char-space " ")

(defn generate-leaf [leaf] (if (every? char-allowed? leaf) leaf (pr-str leaf)))
(defn generate-leaf [leaf]
(if (= leaf []) "()" (if (every? char-allowed? leaf) leaf (pr-str leaf))))

(defn generate-inline-expr [expr]
(str
Expand Down Expand Up @@ -54,6 +55,7 @@
(let [cursor (first exprs)
kind (cond
(string? cursor) :leaf
(= cursor []) :leaf
(simple? cursor) :simple-expr
(boxed? cursor) :boxed-expr
:else :expr)
Expand Down Expand Up @@ -104,7 +106,10 @@
(->> exprs
(transform-comma)
(transform-dollar)
(map (fn [xs] (str "\n" (generate-tree xs true options 0) "\n")))
(map
(fn [xs]
(comment println "gen" (pr-str xs))
(str "\n" (generate-tree xs true options 0) "\n")))
(string/join "")))

(defn write-code
Expand Down
6 changes: 4 additions & 2 deletions src/cirru_writer/list.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
(loop [acc [], chunk [], nodes xs, prev-kind nil]
(if (empty? nodes)
(if (empty? chunk) acc (conj acc (vec-add [","] chunk)))
(let [cursor (first nodes), kind (if (string? cursor) :leaf :expr)]
(if (and (= kind :leaf) (= prev-kind :expr))
(let [cursor (first nodes), kind (if (or (string? cursor) (= cursor [])) :leaf :expr)]
(comment println "loop" acc chunk nodes (pr-str cursor) kind prev-kind)
(if (or (and (= kind :leaf) (= prev-kind :expr))
(and (= kind :leaf) (not (empty? chunk))))
(recur acc (conj chunk cursor) (rest nodes) kind)
(let [checked-acc (if (empty? chunk) acc (conj acc (vec-add [","] chunk)))]
(recur
Expand Down
9 changes: 9 additions & 0 deletions src/cirru_writer/test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
(is (= (parse expected) data))
(is (= (write-code data) expected)))))

(deftest
fold-vectors-test
(let [data (read-string (slurp "examples/ast/fold-vectors.edn"))
expected (slurp "examples/cirru/fold-vectors.cirru")]
(testing
"writing case for fold-vectors"
(is (= (parse expected) data))
(is (= (write-code data {:inline? true}) expected)))))

(deftest
folding-test
(let [data (read-string (slurp "examples/ast/folding.edn"))
Expand Down
4 changes: 2 additions & 2 deletions src/cirru_writer/updater.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

(ns cirru-writer.updater (:require [respo.cursor :refer [mutate]]))
(ns cirru-writer.updater (:require [respo.cursor :refer [update-states]]))

(defn updater [store op op-data]
(case op
:states (update store :states (mutate op-data))
:states (update-states store op-data)
:content (assoc store :content op-data)
:generate (merge store op-data {:error nil})
:error (assoc store :error op-data)
Expand Down

0 comments on commit 3aa4fba

Please sign in to comment.