-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
37b99e4
commit 6b0d387
Showing
137 changed files
with
2,777 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.10.1 |
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,113 @@ | ||
name: my_app CI | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
pull_request: | ||
branches: "*" | ||
|
||
jobs: | ||
check-format: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
crystal_version: | ||
- 1.10.1 | ||
experimental: | ||
- false | ||
runs-on: ubuntu-latest | ||
continue-on-error: ${{ matrix.experimental }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Crystal | ||
uses: crystal-lang/install-crystal@v1 | ||
with: | ||
crystal: ${{ matrix.crystal_version }} | ||
- name: Format | ||
run: crystal tool format --check | ||
|
||
specs: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
crystal_version: | ||
- 1.10.1 | ||
experimental: | ||
- false | ||
runs-on: ubuntu-latest | ||
env: | ||
LUCKY_ENV: test | ||
DB_HOST: localhost | ||
continue-on-error: ${{ matrix.experimental }} | ||
services: | ||
postgres: | ||
image: postgres:14-alpine | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Crystal | ||
uses: crystal-lang/install-crystal@v1 | ||
with: | ||
crystal: ${{ matrix.crystal_version }} | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- name: Set up Yarn cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Set up Node cache | ||
uses: actions/cache@v4 | ||
id: node-cache # use this to check for `cache-hit` (`steps.node-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Set up Crystal cache | ||
uses: actions/cache@v4 | ||
id: crystal-cache | ||
with: | ||
path: | | ||
~/.cache/crystal | ||
lib | ||
key: ${{ runner.os }}-crystal-${{ hashFiles('**/shard.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-crystal- | ||
- name: Install shards | ||
if: steps.crystal-cache.outputs.cache-hit != 'true' | ||
run: shards check || shards install | ||
|
||
- name: Install yarn packages | ||
if: steps.node-cache.outputs.cache-hit != 'true' | ||
run: yarn install --frozen-lockfile --no-progress | ||
- name: Compiling assets | ||
run: yarn prod | ||
- name: Build lucky_tasks | ||
run: crystal build tasks.cr -o ./lucky_tasks | ||
|
||
- name: Prepare database | ||
run: | | ||
./lucky_tasks db.create | ||
./lucky_tasks db.migrate | ||
./lucky_tasks db.seed.required_data | ||
- name: Run tests | ||
run: crystal spec |
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,14 @@ | ||
/docs/ | ||
/lib/ | ||
/bin/ | ||
/.shards/ | ||
*.dwarf | ||
start_server | ||
*.dwarf | ||
*.local.cr | ||
.env | ||
/tmp/public/js | ||
/public/css | ||
/public/mix-manifest.json | ||
/node_modules | ||
yarn-error.log |
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,2 @@ | ||
web: bin/app | ||
release: lucky db.migrate |
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,3 @@ | ||
system_check: script/system_check && sleep 100000 | ||
web: lucky watch --reload-browser | ||
assets: yarn watch |
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,23 @@ | ||
# my_app | ||
|
||
This is a project written using [Lucky](https://luckyframework.org). Enjoy! | ||
|
||
### Setting up the project | ||
|
||
1. [Install required dependencies](https://luckyframework.org/guides/getting-started/installing#install-required-dependencies) | ||
1. Update database settings in `config/database.cr` | ||
1. Run `script/setup` | ||
1. Run `lucky dev` to start the app | ||
|
||
### Using Docker for development | ||
|
||
1. [Install Docker](https://docs.docker.com/engine/install/) | ||
1. Run `docker compose up` | ||
|
||
The Docker container will boot all of the necessary components needed to run your Lucky application. | ||
To configure the container, update the `docker-compose.yml` file, and the `docker/development.dockerfile` file. | ||
|
||
|
||
### Learning Lucky | ||
|
||
Lucky uses the [Crystal](https://crystal-lang.org) programming language. You can learn about Lucky from the [Lucky Guides](https://luckyframework.org/guides/getting-started/why-lucky). |
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,26 @@ | ||
/* | ||
| Browser-sync config file | ||
| | ||
| For up-to-date information about the options: | ||
| http://www.browsersync.io/docs/options/ | ||
| | ||
*/ | ||
|
||
module.exports = { | ||
snippetOptions: { | ||
rule: { | ||
match: /<\/head>/i, | ||
fn: function (snippet, match) { | ||
return snippet + match; | ||
} | ||
} | ||
}, | ||
files: ["public/css/**/*.css", "public/js/**/*.js"], | ||
watchEvents: ["change"], | ||
open: false, | ||
browser: "default", | ||
ghostMode: false, | ||
ui: false, | ||
online: false, | ||
logConnections: false | ||
}; |
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 @@ | ||
# This file may be used for custom Application configurations. | ||
# It will be loaded before other config files. | ||
# | ||
# Read more on configuration: | ||
# https://luckyframework.org/guides/getting-started/configuration#configuring-your-own-code | ||
|
||
# Use this code as an example: | ||
# | ||
# ``` | ||
# module Application | ||
# Habitat.create do | ||
# setting support_email : String | ||
# setting lock_with_basic_auth : Bool | ||
# end | ||
# end | ||
# | ||
# Application.configure do |settings| | ||
# settings.support_email = "[email protected]" | ||
# settings.lock_with_basic_auth = LuckyEnv.staging? | ||
# end | ||
# | ||
# # In your application, call | ||
# # `Application.settings.support_email` anywhere you need it. | ||
# ``` |
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,11 @@ | ||
require "./server" | ||
|
||
Authentic.configure do |settings| | ||
settings.secret_key = Lucky::Server.settings.secret_key_base | ||
|
||
unless LuckyEnv.production? | ||
# This value can be between 4 and 31 | ||
fastest_encryption_possible = 4 | ||
settings.encryption_cost = fastest_encryption_possible | ||
end | ||
end |
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,4 @@ | ||
# This enables the color output when in development or test | ||
# Check out the Colorize docs for more information | ||
# https://crystal-lang.org/api/Colorize.html | ||
Colorize.enabled = LuckyEnv.development? || LuckyEnv.test? |
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,25 @@ | ||
require "./server" | ||
|
||
Lucky::Session.configure do |settings| | ||
settings.key = "_my_app_session" | ||
end | ||
|
||
Lucky::CookieJar.configure do |settings| | ||
settings.on_set = ->(cookie : HTTP::Cookie) { | ||
# If ForceSSLHandler is enabled, only send cookies over HTTPS | ||
cookie.secure(Lucky::ForceSSLHandler.settings.enabled) | ||
|
||
# By default, don't allow reading cookies with JavaScript | ||
cookie.http_only(true) | ||
|
||
# Restrict cookies to a first-party or same-site context | ||
cookie.samesite(:lax) | ||
|
||
# Set all cookies to the root path by default | ||
cookie.path("/") | ||
|
||
# You can set other defaults for cookies here. For example: | ||
# | ||
# cookie.expires(1.year.from_now).domain("mydomain.com") | ||
} | ||
end |
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,29 @@ | ||
database_name = "my_app_#{LuckyEnv.environment}" | ||
|
||
AppDatabase.configure do |settings| | ||
if LuckyEnv.production? | ||
settings.credentials = Avram::Credentials.parse(ENV["DATABASE_URL"]) | ||
else | ||
settings.credentials = Avram::Credentials.parse?(ENV["DATABASE_URL"]?) || Avram::Credentials.new( | ||
database: database_name, | ||
hostname: ENV["DB_HOST"]? || "localhost", | ||
port: ENV["DB_PORT"]?.try(&.to_i) || 5432, | ||
# Some common usernames are "postgres", "root", or your system username (run 'whoami') | ||
username: ENV["DB_USERNAME"]? || "postgres", | ||
# Some Postgres installations require no password. Use "" if that is the case. | ||
password: ENV["DB_PASSWORD"]? || "postgres" | ||
) | ||
end | ||
end | ||
|
||
Avram.configure do |settings| | ||
settings.database_to_migrate = AppDatabase | ||
|
||
# In production, allow lazy loading (N+1). | ||
# In development and test, raise an error if you forget to preload associations | ||
settings.lazy_load_enabled = LuckyEnv.production? | ||
|
||
# Always parse `Time` values with these specific formats. | ||
# Used for both database values, and datetime input fields. | ||
# settings.time_formats << "%F" | ||
end |
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,26 @@ | ||
require "carbon_sendgrid_adapter" | ||
|
||
BaseEmail.configure do |settings| | ||
if LuckyEnv.production? | ||
# If you don't need to send emails, set the adapter to DevAdapter instead: | ||
# | ||
# settings.adapter = Carbon::DevAdapter.new | ||
# | ||
# If you do need emails, get a key from SendGrid and set an ENV variable | ||
send_grid_key = send_grid_key_from_env | ||
settings.adapter = Carbon::SendGridAdapter.new(api_key: send_grid_key) | ||
elsif LuckyEnv.development? | ||
settings.adapter = Carbon::DevAdapter.new(print_emails: true) | ||
else | ||
settings.adapter = Carbon::DevAdapter.new | ||
end | ||
end | ||
|
||
private def send_grid_key_from_env | ||
ENV["SEND_GRID_KEY"]? || raise_missing_key_message | ||
end | ||
|
||
private def raise_missing_key_message | ||
puts "Missing SEND_GRID_KEY. Set the SEND_GRID_KEY env variable to 'unused' if not sending emails, or set the SEND_GRID_KEY ENV var.".colorize.red | ||
exit(1) | ||
end |
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,33 @@ | ||
# Environments are managed using `LuckyEnv`. By default, development, production | ||
# and test are supported. See | ||
# https://luckyframework.org/guides/getting-started/configuration for details. | ||
# | ||
# The default environment is development unless the environment variable | ||
# LUCKY_ENV is set. | ||
# | ||
# Example: | ||
# ``` | ||
# LuckyEnv.environment # => "development" | ||
# LuckyEnv.development? # => true | ||
# LuckyEnv.production? # => false | ||
# LuckyEnv.test? # => false | ||
# ``` | ||
# | ||
# New environments can be added using the `LuckyEnv.add_env` macro. | ||
# | ||
# Example: | ||
# ``` | ||
# LuckyEnv.add_env :staging | ||
# LuckyEnv.staging? # => false | ||
# ``` | ||
# | ||
# To determine whether or not a `LuckyTask` is currently running, you can use | ||
# the `LuckyEnv.task?` predicate. | ||
# | ||
# Example: | ||
# ``` | ||
# LuckyEnv.task? # => false | ||
# ``` | ||
|
||
# Add a staging environment. | ||
# LuckyEnv.add_env :staging |
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,3 @@ | ||
Lucky::ErrorHandler.configure do |settings| | ||
settings.show_debug_output = !LuckyEnv.production? | ||
end |
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,3 @@ | ||
Lucky::HTMLPage.configure do |settings| | ||
settings.render_component_comments = !LuckyEnv.production? | ||
end |
Oops, something went wrong.