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

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuharu authored Apr 1, 2024
0 parents commit b021af8
Show file tree
Hide file tree
Showing 40 changed files with 21,514 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "textlint for daigirin",
"build": {
"context": "..",
"dockerfile": "../Dockerfile"
},
"postCreateCommand": "apk update && apk add -U --no-cache openssh && apk add -U --no-cache git",
"customizations": {
"vscode": {
"extensions": [
"streetsidesoftware.code-spell-checker",
"taichi.vscode-textlint",
"github.vscode-pull-request-github"
]
}
}
}
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gitignore

# Node.js
node_modules
npm-debug.log
yarn-error.log
29 changes: 29 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docker Image CI

on:
push:
branches:
- main
workflow_dispatch: ~

env:
IMAGE: ghcr.io/yumemi/daigirin-template

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login
run: echo '${{ github.token }}' | docker login ghcr.io -u $ --password-stdin
- name: Build & Push
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ ENV.IMAGE }}:latest
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
### Generated by gibo (https://github.com/simonwhitaker/gibo)
### https://raw.github.com/github/gitignore/4488915eec0b3a45b5c63ead28f286819c0917de/Global/macOS.gitignore

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# book
book/output
book/.vivliostyle

# node.js
node_modules/
npm-debug.log
yarn-error.log
9 changes: 9 additions & 0 deletions .textlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore file

README.md

# Ignore by glob pattern

.vscode/**
theme/**
prh-rules/**
19 changes: 19 additions & 0 deletions .textlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"plugins": {
},
"filters": {
"comments": true
},
"rules": {
"preset-ja-spacing": {
"ja-space-between-half-and-full-width": {
"space": "always"
}
},
"preset-ja-technical-writing": true,
"spellcheck-tech-word": true,
"prh": {
"rulePaths" :["./prh-rules/media/techbooster.yml"]
}
}
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"ms-vscode-remote.remote-containers",
"streetsidesoftware.code-spell-checker",
"taichi.vscode-textlint"
],
}
31 changes: 31 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"editor.formatOnSave": true,
"cSpell.words": [
"baseservice",
"Bitrise",
"daigirin",
"docomo",
"foodpanda",
"hogehoge",
"Jetpack",
"kantoku",
"Keishin",
"nodenv",
"taichi",
"Qiita",
"STARPAY",
"SUNMI",
"Surile",
"techbook",
"techbooster",
"textlint",
"textlintignore",
"vivliostyle",
"WWDC",
"xcodebuild",
"xcresult",
"Xiaomi",
"Yokomaku",
"yumemi"
]
}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM node:20-alpine
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile && yarn cache clean
WORKDIR /workspaces/daigirin-template
5 changes: 5 additions & 0 deletions DockerfileForDockerCompose
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:20-alpine
WORKDIR /workspaces/daigirin-template

COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile && yarn cache clean
138 changes: 138 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Environment variable

MAKEFILE_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
MAKEFILE_PATH := $(MAKEFILE_DIR)/Makefile
DOCKER_COMPOSE_PATH := $(MAKEFILE_DIR)/docker-compose.yml
BOOK_DIR := $(MAKEFILE_DIR)/book
OUTPUT_DIR := $(BOOK_DIR)/output
BOOK_PATH := $(OUTPUT_DIR)/ebook.pdf

export TEXT_LINT_IMAGE_NAME=textlint
export TEXT_LINT_IMAGE_TAG=latest

## https://github.com/vivliostyle/vivliostyle-cli/pkgs/container/cli
VIVLIOSTYLE_CLI_IMAGE_NAME := ghcr.io/vivliostyle/cli
VIVLIOSTYLE_CLI_IMAGE_TAG := 8.9.1

ALL_DOCKER_IMAGES := $(TEXT_LINT_IMAGE_NAME) $(VIVLIOSTYLE_CLI_IMAGE_NAME)

DOCKER = \
@$(MAKE) prepare_docker; \
$(shell command -v docker)

DOCKER_COMPOSE = \
@$(MAKE) prepare_docker; \
$(shell command -v docker-compose -f $(DOCKER_COMPOSE_PATH))

VIVLIOSTYLE_CLI = $(DOCKER) run \
--rm \
-v $(BOOK_DIR):/local \
-w /local \
$(VIVLIOSTYLE_CLI_IMAGE_NAME):$(VIVLIOSTYLE_CLI_IMAGE_TAG) \

# Commands

default: help

.PHONY: help
help:
@## コマンド名とその直前のコメント行が出力されます。
@## @see https://stackoverflow.com/a/35730928
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t

.PHONY: run
## pdfを生成して開く
run: \
pdf \
open

.PHONY: lint
## textlintを実行
lint:
$(DOCKER_COMPOSE) run --rm lint

.PHONY: pdf
## pdfを生成
pdf:
$(VIVLIOSTYLE_CLI) build \
--no-sandbox

.PHONY: pdf_press
## プレス版のpdfを生成
pdf_press:
$(VIVLIOSTYLE_CLI) build \
--no-sandbox \
--press-ready \
--preflight-option gray-scale \
--style ./theme/theme-press.css \
--output ./output/press.pdf

.PHONY: open
## pdfを開く
open:
open $(BOOK_PATH)

.PHONY: clean
## 生成ファイルをすべて削除
clean: \
clean_pdf \
clean_docker

.PHONY: clean_pdf
## pdf関係の生成物を削除
clean_pdf:
rm -rf $(OUTPUT_DIR)

.PHONY: clean_docker
## Docker関係の生成物を削除
clean_docker:
rm -rf node_modules
@for IMAGE in $(ALL_DOCKER_IMAGES) ; do \
IMAGE_IDS=$$(docker images -q $$IMAGE); \
if [ ! -z "$$IMAGE_IDS" ]; then \
echo "Removing Docker image $$IMAGE"; \
docker rmi $$IMAGE_IDS; \
else \
echo "Docker image $$IMAGE does not exist"; \
fi; \
done

# Internal Commands

.PHONY: install_brew
install_brew:
@if ! command -v brew >/dev/null 2>&1; then \
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
fi

.PHONY: install_docker
install_docker:
@if ! command -v docker >/dev/null 2>&1; then \
brew install docker; \
fi

.PHONY: install_docker-compose
install_docker-compose:
@if ! command -v docker-compose >/dev/null 2>&1; then \
brew install docker-compose; \
fi

.PHONY: install_colima
install_colima:
@if ! command -v colima >/dev/null 2>&1; then \
brew install colima; \
fi

.PHONY: start_colima
start_colima:
@if [ $$(colima status 2>&1 | grep -c "not running") -eq 1 ]; then \
colima start; \
fi

.PHONY: prepare_docker
prepare_docker: \
install_brew \
install_docker \
install_docker-compose \
install_colima \
start_colima
Loading

0 comments on commit b021af8

Please sign in to comment.