Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
add files
Browse files Browse the repository at this point in the history
  • Loading branch information
marihachi committed Jul 19, 2024
1 parent c32acd9 commit b08087e
Show file tree
Hide file tree
Showing 29 changed files with 1,643 additions and 0 deletions.
1 change: 1 addition & 0 deletions .devcontainer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/post_create_custom.sh
27 changes: 27 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# +----------------------------------------------------------------------------------------+ #
# | _____ _ _ | #
# | | __ \ | | (_) | #
# | | | | | ___ __ __ ___ ___ _ __ | |_ __ _ _ _ __ ___ _ __ | #
# | | | | | / _ \ \ \ / / / __| / _ \ | '_ \ | __| / _` | | | | '_ \ / _ \ | '__| | #
# | | |__| | | __/ \ V / | (__ | (_) | | | | | \ |_ | (_| | | | | | | | | __/ | | | #
# | |_____/ \___| \_/ \___| \___/ |_| |_| \__| \__,_| |_| |_| |_| \___| |_| | #
# | | #
# +----------------------------------------------------------------------------------------+ #

# Node.js 20 image on Debian 12 (bookworm)
FROM node:20-bookworm AS devcontainer
ARG USERNAME=node

RUN apt-get update

# Install sudo
RUN apt-get install -y sudo
RUN echo "node ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/node

# Install pnpm
RUN corepack enable pnpm

# Switch user
# この操作により権限が一般ユーザーになります。
USER $USERNAME
WORKDIR /home/$USERNAME/
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Development",
"dockerComposeFile": "../compose.development.yaml",
"service": "devcontainer",
"workspaceFolder": "/workspaces",
"postCreateCommand": "/workspaces/.devcontainer/post_create.sh",
"remoteUser": "node",
"shutdownAction": "none",
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/node/.ssh,readonly,type=bind"
],
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Configure tool-specific properties.
// "customizations": {},
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"github.vscode-github-actions",
"timonwong.shellcheck",
"ms-azuretools.vscode-docker",
"ms-vscode-remote.remote-containers",
"editorconfig.editorconfig",
"bierner.markdown-mermaid"
]
}
}
}
36 changes: 36 additions & 0 deletions .devcontainer/post_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

# +----------------------------------------------------------------------------------------+ #
# | _____ _ _ | #
# | | __ \ | | (_) | #
# | | | | | ___ __ __ ___ ___ _ __ | |_ __ _ _ _ __ ___ _ __ | #
# | | | | | / _ \ \ \ / / / __| / _ \ | '_ \ | __| / _` | | | | '_ \ / _ \ | '__| | #
# | | |__| | | __/ \ V / | (__ | (_) | | | | | \ |_ | (_| | | | | | | | | __/ | | | #
# | |_____/ \___| \_/ \___| \___/ |_| |_| \__| \__,_| |_| |_| |_| \___| |_| | #
# | | #
# +----------------------------------------------------------------------------------------+ #

# Bash Strict Mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/)
set -euo pipefail
IFS=$'\n\t'

# Constants
WORKSPACE_PATH=/workspaces
BACKEND_PACKAGE_PATH="${WORKSPACE_PATH}/backend"
FRONTEND_PACKAGE_PATH="${WORKSPACE_PATH}/frontend"
CUSTOM_POST_CREATE_SCRIPT_PATH="${WORKSPACE_PATH}/.devcontainer/post_create_custom.sh"

# 各パッケージの package.json を参照して pnpm と依存関係をインストールする
echo "Install backend dependencies..."
cd "$BACKEND_PACKAGE_PATH"
corepack pnpm install --frozen-lockfile

echo "Install frontend dependencies..."
cd "$FRONTEND_PACKAGE_PATH"
corepack pnpm install --frozen-lockfile

# Run custom post create script
if [ -f "$CUSTOM_POST_CREATE_SCRIPT_PATH" ]; then
echo "Run custom post create script ($CUSTOM_POST_CREATE_SCRIPT_PATH)..."
eval "$CUSTOM_POST_CREATE_SCRIPT_PATH"
fi
15 changes: 15 additions & 0 deletions .devcontainer/post_create_custom.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# Bash Strict Mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/)
set -euo pipefail
IFS=$'\n\t'

# Install Vim
sudo apt-get install vim --yes

# [README]
# Dev Containerのコンテナー作成後にお好きな処理 (お気に入りのエディターのインストールなど)をコンテナーで実行させたい場合は
# このファイルと同じディレクトリーに post_create_custom.sh という名前のファイルを作り
# このファイルのようにシェルスクリプトを記述してください。
#
# 実行権を付与 (chmod +x)する必要があることに注意してください。(このファイルをコピーするとよいでしょう)
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
27 changes: 27 additions & 0 deletions .github/workflows/front-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ESLint CI

on:
push:
paths:
- "frontend/src/**"
- ".github/workflows/front-lint.yml"

jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: "latest"
- uses: actions/setup-node@v4
with:
node-version: "latest"
cache: "pnpm"
cache-dependency-path: ./frontend/pnpm-lock.yaml
- run: pnpm i
- run: pnpm lint
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"[typescript][typescriptreact][javascript][javascriptreact][html][scss][json][jsonc][markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# snow-spec
A human-friendly, language for describing your API spec that generates OpenAPI file.

## License
MIT
22 changes: 22 additions & 0 deletions compose.development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# +----------------------------------------------------------------------------------------+ #
# | _____ _ _ | #
# | | __ \ | | (_) | #
# | | | | | ___ __ __ ___ ___ _ __ | |_ __ _ _ _ __ ___ _ __ | #
# | | | | | / _ \ \ \ / / / __| / _ \ | '_ \ | __| / _` | | | | '_ \ / _ \ | '__| | #
# | | |__| | | __/ \ V / | (__ | (_) | | | | | \ |_ | (_| | | | | | | | | __/ | | | #
# | |_____/ \___| \_/ \___| \___/ |_| |_| \__| \__,_| |_| |_| |_| \___| |_| | #
# | | #
# +----------------------------------------------------------------------------------------+ #

name: snow-development

services:
devcontainer:
build:
context: .
dockerfile: ./.devcontainer/Dockerfile
target: devcontainer
volumes:
- .:/workspaces:cached
working_dir: /workspaces
command: sleep infinity
60 changes: 60 additions & 0 deletions docs/1.0/example/main.snow
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
syntax = "snow-spec-1.0";

//
// common
//

type UUID = string {
pattern "([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})";
caseSensitive false;
};

type Name = string {
pattern "[A-Za-z0-9-]*";
minLength 1;
};

//
// users
//

type DisplayName = string {
minLength 1;
};

type User = object {
field userId: UUID;
field name: Name;
field displayName: DisplayName;
};

POST /api/users {
body: object {
field name: Name;
field displayName: DisplayName;
};
response: User;
}

GET /api/users/:id {
parameter id: UUID;
response: User;
}

DELETE /api/users/:id {
parameter id: UUID;
}

//
// account
//

type Account = object {
field accountId: UUID;
field name: Name;
field users: User[];
};

GET /api/me {
response: Account;
}
Loading

0 comments on commit b08087e

Please sign in to comment.