Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: components-first-release #7

Merged
merged 37 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
af8e810
feat: building .jar
Felipe-gsilva Sep 9, 2024
7781d6f
doc: enhance installation process
Felipe-gsilva Sep 9, 2024
657cd4b
feat: creating node library (unfinished)
Felipe-gsilva Sep 11, 2024
15826a9
fix: node-lib building config
Felipe-gsilva Sep 12, 2024
84ff0fa
doc: code rabbit snippets
Felipe-gsilva Sep 12, 2024
aefd082
fix: glob, rimraf and cliui deps
Felipe-gsilva Sep 12, 2024
207a668
fix: adds prop test unit (back)
Felipe-gsilva Sep 12, 2024
73ab5c5
feat: mockingbird as npm-module
Felipe-gsilva Sep 12, 2024
5c550a6
fix: comma on package.json
Felipe-gsilva Sep 12, 2024
9b58fd2
feat: adds webpack config
Felipe-gsilva Sep 17, 2024
cccbe1a
chore: webpack and npm module config
Felipe-gsilva Sep 18, 2024
7cd6fed
feat: build jar back and gh releases
Felipe-gsilva Sep 18, 2024
f8100cc
fix: minor issues
Felipe-gsilva Sep 18, 2024
33477ad
fix: testing compiling options
Felipe-gsilva Sep 20, 2024
8edc81c
test: exporting fn button
Felipe-gsilva Sep 23, 2024
ee3a393
feat: diff prod and dev on webpack bundle
J0sueTM Sep 23, 2024
e48e40a
Update webpack.config.js
avelino Sep 23, 2024
99e1d8c
feat: submit button
Felipe-gsilva Sep 24, 2024
8baba22
feat: loading prop and fixes on example page
Felipe-gsilva Sep 24, 2024
cbd05c4
doc: updates README.md for clojar and new usage
Felipe-gsilva Sep 25, 2024
eb13794
docs: improves text cohesion
Felipe-gsilva Sep 25, 2024
c72bf5a
feat: enhance on navbar
Felipe-gsilva Sep 25, 2024
f5ff6b6
feat: better compiling on css and component enhancement
Felipe-gsilva Sep 25, 2024
f541320
feat: copy the css file from .jar (on build hook)
Felipe-gsilva Sep 27, 2024
c6d97bf
fix: css build hook
Felipe-gsilva Sep 28, 2024
dfc1798
fix: unit test for props
Felipe-gsilva Sep 28, 2024
935f48b
feat: copy target.css on any project to a specified path
Felipe-gsilva Sep 30, 2024
7dc6e58
fix: formatting
Felipe-gsilva Sep 30, 2024
2f3e319
fix: gray-50 color error
Felipe-gsilva Oct 1, 2024
ca98734
fix: button, input and props fix
Felipe-gsilva Oct 1, 2024
0c84712
fix: props test
Felipe-gsilva Oct 1, 2024
1987956
fix: component style enhance
Felipe-gsilva Oct 2, 2024
efd5257
fix: ci workflow
Felipe-gsilva Oct 3, 2024
46df98a
fix: npm install
Felipe-gsilva Oct 3, 2024
4dc125b
docs: improve reading flow
Felipe-gsilva Oct 4, 2024
bf83370
doc: adds more context on README.md
Felipe-gsilva Oct 4, 2024
ff9a234
feat: export tag for shadow npm compiling
Felipe-gsilva Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
java-version: '11'

- name: Install clojure cli
uses: DeLaGuardo/setup-clojure@master
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: 1.11.1.1113

Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
push:
tags:
- 'v*'
workflow_dispatch:
Comment on lines +1 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! The workflow name and triggers are well-defined.

The workflow name "Release" is clear and descriptive. The triggers are appropriate for a release workflow, allowing for both automated releases on version tags and manual triggering.

Consider adding a brief description comment at the beginning of the file to provide more context:

# Workflow for releasing the project to Clojars
# Triggered on pushing tags starting with 'v' or manually
name: Release
🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 5-5: wrong indentation: expected 8 but found 6

(indentation)


[error] 6-6: wrong indentation: expected 10 but found 8

(indentation)


jobs:
clojars:
runs-on: ubuntu-latest
environment: release
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: "DeLaGuardo/[email protected]"
with:
cli: "1.11.1.1139"
- name: release
env:
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }}
run: |
clojure -T:dev:build clean && \
clojure -T:dev:build jar && \
clojure -T:dev:build install && \
clojure -X:deploy-clojars

Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ pom.xml.asc
/.shadow-cljs/
/resources/public/index.html
/resources/public/assets
/resources/public/css/site.css
/resources/public/css/
/resources/test/

/resources/node/
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,42 @@ Prerequisites

Before you begin, ensure you have the following installed:
- Clojure: Follow the [Clojure Installation guide](https://clojure.org/guides/install_clojure) to set up your environment.
- Node.js: Required for managing dependencies and building your project. Download it from [here](https://www.npmjs.com/package/downloads).
- [Node.js](https://nodejs.org/en/download/prebuilt-installer/current).
- [npm](https://www.npmjs.com/package/downloads).

# Installation

- Set up your project: Start by creating a new ClojureScript project, or use an existing one.
We distribute our software via Clojars, so you are can just plug and play!

- Install node dependencies with a simple command:
``` clj

``` sh
npm i
```
;; TODO

- configure your shadow cljs:
```

> for better understanding, follow the offcial [guide](https://github.com/thheller/shadow-cljs)


# Usage

;; TODO

# Testing

# Testing Locally

And you are now done, you can clone and build this repo in order to see some examples of good usage of our dear Mockingbird. You can read more [here](docs/test.md).
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved

- Set up your project: Start by creating a new ClojureScript project, or use an existing one.

- Install node dependencies with a simple command:

``` sh
npm i
```
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved

- configure your shadow cljs

> for better understanding, follow the offcial [guide](https://github.com/thheller/shadow-cljs)

# Contributing

Mockingbird is open-source, and contributions are welcome! If you have ideas for new features, improvements, or bug fixes, feel free to open an issue or submit a pull request.
35 changes: 35 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(ns build
(:require [clojure.tools.build.api :as b]))

(def lib 'com.github.moclojer/mockingbird)
(def version "0.0.1")
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
Comment on lines +5 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Consider Centralizing the Version Number

The version number "0.0.1" is hardcoded in multiple files (build.clj, package.json, and package-lock.json). To enhance maintainability and ensure consistency across the project, consider implementing a centralized version management system for future releases.

🔗 Analysis chain

LGTM: Project metadata definitions are correct

The project metadata definitions look good for a first release. However, for future releases, consider implementing a more flexible version management system.

To ensure consistency across the project, let's verify if the version is used elsewhere:


To accurately verify if the version number "0.0.1" is used elsewhere in the codebase, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other occurrences of the version number
rg --type-add 'json:*.json' --type-add 'edn:*.edn' --type json,edn,clojure '"0.0.1"'

Length of output: 127


Script:

# 
#!/bin/bash
# Description: Check for other occurrences of the version number
rg -tjson -tedn -tclojure '"0.0.1"'

Length of output: 470


(defn clean [_]
(b/delete
{:path "target"}))

(defn jar [_]
(b/write-pom
{:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir
{:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar
{:class-dir class-dir
:jar-file jar-file}))

(defn install [_]
(b/install
{:basis basis
:lib lib
:version version
:jar-file jar-file
:class-dir class-dir}))

12 changes: 11 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20220803"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more recent version of the Closure Compiler.

Adding the Closure Compiler dependency is a great choice for optimizing the JavaScript output. However, the specified version v20220803 is quite dated. Consider using a more recent version to ensure you have access to the latest optimizations and bug fixes.

com.fbeyer/refx {:mvn/version "0.0.49"}
lilactown/helix {:mvn/version "0.1.9"}
funcool/promesa {:mvn/version "9.0.494"}
Expand All @@ -15,4 +17,12 @@
:clojure-lsp {:replace-deps {com.github.clojure-lsp/clojure-lsp-standalone {:mvn/version "2024.08.05_18.16.00-1"}}
:main-opts ["-m" "clojure-lsp.main"]}
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.4"}}
:ns-default build}}}
:ns-default build}
;; env CLOJARS_USERNAME=username CLOJARS_PASSWORD=clojars-token
;; clj -X:deploy-clojars
:deploy-clojars {:extra-deps {slipset/deps-deploy {:mvn/version (build/version)}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote
:sign-releases? false
:pom-file "target/classes/META-INF/maven/com.moclojer/mockingbird/pom.xml"
:artifact "target/com.moclojer.mockingbird.jar"}}}}
1 change: 1 addition & 0 deletions docs/Roadmap.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Roadmap

- distribuition
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
- layout
- components
- themes (mockingbird, nightjar, kiwi)
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
"ci:tests": "npm run ci:karma-make && npx shadow-cljs compile ci-tests && npx karma start --single-run",
"postcss:build": "npx cross-env TAILWIND_MODE=build postcss src/mockingbird/css/tailwind.css -o ./resources/public/assets/css/output.css --verbose",
"postcss:watch": "npx cross-env TAILWIND_MODE=watch postcss src/mockingbird/css/tailwind.css -o ./resources/public/assets/css/output.css --verbose -w",
"app:watch": "npx shadow-cljs watch app",
"watch": "run-p -l *:watch",
"repl": "npx shadow-cljs clj-repl"
"watch": "npx shadow-cljs watch app",
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
"repl": "npx shadow-cljs clj-repl",
"release": "run-s shadow:release",
"shadow:release": "npx shadow-cljs release app",
"lib": "npx shadow-cljs compile node-lib "
},
"dependencies": {
"@codemirror/language": "^6.6.0",
Expand Down
82 changes: 54 additions & 28 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -1,40 +1,66 @@
{:deps {:aliases [:dev]}
:nrepl {:port 9000}
:builds {:app {:target :browser
:output-dir "resources/public/assets/js"
:asset-path "/assets/js"
:devtools {:reload-strategy :full
:http-port 8101
:http-root "resources/public"}
:builds {:app {:target :browser
:output-dir "resources/public/assets/js"
:asset-path "/assets/js"
:devtools {:reload-strategy :full
:http-port 8101
:http-root "resources/public"}
:build-hooks [(dev.shadow.hooks/hash-files
["./resources/public/assets/css/output.css"
"./resources/public/assets/js/core.js"])
(dev.shadow.hooks/replace-hashed-files
"./resources/index.src.html"
"./resources/public/index.html")]
:dev {:modules {:core {:init-fn dev.core/init}}
:compiler-options {:warning-as-errors true}
:build-hooks [(dev.shadow.hooks/build-css
true
"./src/mockingbird/css/tailwind.css"
"./resources/public/assets/css/output.css")]}
:release {:modules {:core {:init-fn mockingbird.core/init}}
:compiler-options {:optimizations :advanced
:infer-externs :auto
:source-map true
:warnings-as-errors true}
:build-options {:manifest-name "manifest.json"}
:build-hooks [(dev.shadow.hooks/build-css
false
"./src/mockingbird/css/tailwind.css"
"./resources/public/assets/css/output.css")]}}
:tests {:target :browser-test
:test-dir "resources/test"
:ns-regexp "-test$"
:devtools {:http-port 8102
:http-root "resources/test"}}
:dev {:modules {:core {:init-fn dev.core/init}}
:compiler-options {:warning-as-errors true}
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
:build-hooks [(dev.shadow.hooks/build-css
true
"./src/mockingbird/css/tailwind.css"
"./resources/public/assets/css/output.css")]}
:release {:modules {:core {:init-fn mockingbird.core/init}}
:compiler-options {:optimizations :advanced
:infer-externs :auto
:source-map true
:warnings-as-errors true}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Reconsider :warnings-as-errors in the :release configuration

Including :warnings-as-errors true in the production build may cause the build process to fail due to minor warnings, potentially delaying releases. It's common practice to relax this setting in production to ensure smoother deployments.

:build-options {:manifest-name "manifest.json"}
:build-hooks [(dev.shadow.hooks/build-css
false
"./src/mockingbird/css/tailwind.css"
"./resources/public/assets/css/output.css")]}}
:tests {:target :browser-test
:test-dir "resources/test"
:ns-regexp "-test$"
:devtools {:http-port 8102
:http-root "resources/test"}}

:ci-tests {:target :karma
:output-to "resources/test/ci.js"
:ns-regexp "-test$"
:compiler-options {:static-fns false}}}}
:compiler-options {:static-fns false}}
:node-lib {:target :node-library
:output-dir "resources/node/"
:output-to "resources/node/mockingbird-lib.js"
:exports-fn mockingbird.node/generate-exports
:build-hooks [(dev.shadow.hooks/hash-files
["./resources/public/assets/css/output.css"
"./resources/public/assets/js/core.js"])
(dev.shadow.hooks/replace-hashed-files
"./resources/index.src.html"
"./resources/public/index.html")]
:dev {:modules {:core {:init-fn dev.core/init}}
:compiler-options {:warning-as-errors true}
:build-hooks [(dev.shadow.hooks/build-css
true
"./src/mockingbird/css/tailwind.css"
"./resources/public/assets/css/output.css")]}
:release {:modules {:core {:init-fn mockingbird.core/init}}
:compiler-options {:optimizations :advanced
:infer-externs :auto
:source-map true
:warnings-as-errors true}
:build-options {:manifest-name "manifest.json"}
:build-hooks [(dev.shadow.hooks/build-css
false
"./src/mockingbird/css/tailwind.css"
"./resources/public/assets/css/output.css")]}}}}
1 change: 0 additions & 1 deletion src/dev/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require
[mockingbird.core :as m]))

;; TODO
(defn ^:export init
[]
(try
Expand Down
42 changes: 15 additions & 27 deletions src/mockingbird/components/aside.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,23 @@
[refx.alpha :as refx]
[reitit.frontend.easy :as rfe]))

#_(defnc mock []
(let [aside (refx/use-sub [:app.dashboard/aside])
aside-open? (:open? aside)
current-user (refx/use-sub [:app.auth/current-user])
menu-open? (refx/use-sub [:app.dashboard/is-menu-open?])
mocks-raw (refx/use-sub [:app.dashboard/mocks-raw])]

(hooks/use-effect
[mocks-raw]
(when (nil? mocks-raw)
(refx/dispatch-sync [:app.dashboard/get-mocks current-user])))

;; TODO add mock content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Address the TODO: Add mock content

The TODO comment indicates that mock content needs to be added to the mock component. Would you like assistance in implementing this content, or should we open a GitHub issue to track this task?

(defnc mock [{:keys [aside aside-open?
current-user menu-open?
mocks-raw when-mock-raw
children]
:or {aside "" aside-open? false
current-user "" menu-open? false
mocks-raw false when-mock-raw ""}}]
(d/li
(d/div
{:class "flex flex-row"}
(d/button
{:on-click #(rfe/push-state :app.core/mocks)
:class (str "flex items-center p-2 w-full text-base font-normal text-gray-900 rounded-lg "
"transition duration-75 group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700 ")
:aria-controls "dropdown-mocks"
:aria-expanded aside-open?
:data-collapse-toggle "dropdown-mocks"}
(d/span {:class (str "flex ml-3 text-left whitespace-nowrap "
(when-not aside-open?
"lg:absolute lg:hidden"))} "Mocks"))
(d/button
{:class (str "px-2 rounded-lg fill-gray-200 bg-transparent hover:bg-gray-200 hover:fill-gray-400 "
(if aside-open? "block " "hidden "))
:on-click #(refx/dispatch-sync [:app.dashboard/toggle-menu])})))))
children)))

(defnc aside
[{:keys [id class type theme
aria-label position]
aria-label position
children]
Comment on lines +27 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Ensure proper handling of children in the aside component

The aside component now accepts children as a prop. If children can be nil, ensure that the component gracefully handles this case without causing runtime errors.

:or {id ""
class ""
theme :mockingbird
Expand Down Expand Up @@ -92,3 +76,7 @@
#_(when aside-open?
(d/span {:class "ml-3"}
"Logout"))))))))


;; TODO aside specific components
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Address the TODO: Add aside-specific components

The TODO comment suggests adding specific components for the aside. Would you like assistance in developing these components, or should we open a GitHub issue to track this task?

(defnc aside-componet [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Typo in function name aside-componet

The function name aside-componet appears to be misspelled. It should likely be aside-component.

Apply this diff to correct the typo:

-defnc aside-componet []
+defnc aside-component []
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(defnc aside-componet [])
(defnc aside-component [])

2 changes: 1 addition & 1 deletion src/mockingbird/components/icon.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;; TODO

(def styles
{})
{:mockingbird {}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! Consider adding a clarifying comment and addressing the TODO.

The change to the styles variable is approved as it provides a structure for potential theme-specific styling.

  1. As suggested in a previous review, consider adding a comment to clarify the purpose of the styles variable:
;; Styles map for theme-specific customization
(def styles
  {:mockingbird {}})
  1. There's a TODO comment above this definition. Please address it or provide context on what needs to be done.


(defnc icon
[{:keys [class theme label href
Expand Down
Loading
Loading