Skip to content

Commit 5c44039

Browse files
authored
Add ability to let addons generate taskfile sections (#6)
* Add ability to let addons generate taskfile sections * Add first part of the docker compose addon generation * Use template parser for cleaner imports of shells scripts * Finish docker compose rendering * Add checkbox example for adding the development proxy * Add contirubtor avatars to the readme * Finalize development proxy setup * Add Taskfile git addon * Update readme to point more to the online generator * Fix linting * Add typescript types check to linting * Fix linting task names and descriptions * Update site icon * Fix some string coversion issues * Fix linting issues
1 parent 41727dd commit 5c44039

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1068
-695
lines changed

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/preview.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ jobs:
2121
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
2222
- name: Deploy Project Artifacts to Vercel
2323
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
24-

README.md

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
1-
# Taskfile
1+
# Taskfile ([TaskfileGenerator.com](https://taskfilegenerator.com))
22

3-
A `./Taskfile` is a task runner in plain and easy [Bash](https://nl.wikipedia.org/wiki/Bash). It
4-
adds a list of available tasks to your project.
3+
A `./Taskfile` is a task runner in plain and easy [Bash](https://nl.wikipedia.org/wiki/Bash). It adds a list of
4+
available tasks to your project.
55

6-
![CLI Taskfile preview](./images/cli-preview.gif)
6+
Generate your own Taskfile at [TaskfileGenerator.com](https://taskfilegenerator.com).
77

8-
## Why
9-
10-
- Works on any OS (any bash terminal)
11-
- A uniform way to run your projects
12-
- Very easy to use
13-
- Automate your most common tasks (updating, starting, building, etc...)
14-
- Easy to understand and maintain
15-
16-
# Create your own taskfile
17-
18-
This project gives you a `Taskfile` base, and gives you a collection of usefull tasks to help out on
19-
your project.
8+
[![CLI Taskfile preview](./images/cli-preview.gif)](https://taskfilegenerator.com)
209

21-
- [The Taskfile base](./taskfile-base.md)
22-
23-
We strongly recommend that your project uses a project section containing a `init` and a `update`
24-
task. Check out our example:
25-
26-
- [Project section](./section/project.md)
27-
28-
## Usefull tasks
10+
## Why
2911

30-
Check out the following sections for tasks that could be helpfull for your project's Taskfile:
12+
- Works on any OS (any bash terminal)
13+
- A uniform way to run your projects
14+
- Very easy to use
15+
- Automate your most common tasks (updating, starting, building, etc...)
16+
- Easy to understand and maintain
17+
- Automatically generated list of available task
3118

32-
- [Docker](./section/docker.md)
33-
- [GitHub](./section/github.md)
34-
- [GitLab](./section/gitlab.md)
19+
## Credits
3520

36-
# Credits
21+
This Taskfile setup is based on [Adrian Cooney's Taskfile](https://github.com/adriancooney/Taskfile) and is widely
22+
adopted by [Enrise](https://enrise.com) in our modified flavour.
3723

38-
This Taskfile setup is based on
39-
[Adrian Cooney's Taskfile](https://github.com/adriancooney/Taskfile).
24+
## Contributors
4025

41-
# Contribute
26+
A big thanks to all the contributors of Taskfile!
4227

43-
Feel free to add your own Taskfile tasks via a PR. The more usefull tasks, the easier we make the
44-
life of other developers.
28+
![contirubtor avatars](https://contrib.rocks/image?repo=enrise/taskfile)

Taskfile

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function banner {
1919
# =========================================================
2020

2121
function task:init { ## Set up the project for local development
22+
project:git-config
2223
task:update
2324
task:help
2425
}
@@ -50,11 +51,10 @@ function project:install-dependencies {
5051
npm install
5152
}
5253

53-
function task:prettify { ## Prettify all files
54-
title "Cleaning codestyle"
55-
echo "Prettifying files..."
56-
prettier --write --list-different .
57-
echo "Done."
54+
function project:git-config {
55+
title "Setting git configuration"
56+
git config --local core.hooksPath dev/git-hooks
57+
echo -e "Git hooks directory is set to ${YELLOW}./dev/git-hooks${RESET}."
5858
}
5959

6060
# =========================================================
@@ -74,12 +74,35 @@ function task:production { ## Build and run production output
7474
docker run --rm --publish 3089:80 --name tasksite --volume ./out:/var/www nstapelbroek/static-webserver:5
7575
}
7676

77+
function task:prettier { ## Prettify all files
78+
title "Running prettier"
79+
echo "Prettifying files..."
80+
prettier --config dev/linting/.prettierrc.json --ignore-path dev/linting/.prettierignore --write --list-different . \
81+
&& echo -e "All ${GREEN}good${RESET}."
82+
}
83+
84+
function task:eslint { ## Check typescript logic
85+
title "ESLint"
86+
echo "Checking typescript logic..."
87+
eslint --config dev/linting/eslint.config.mjs . \
88+
&& echo -e "All ${GREEN}good${RESET}."
89+
}
90+
91+
function task:typescript { ## Check typescript types
92+
title "Typescript type check"
93+
echo "Checking typescript types..."
94+
tsc --noEmit --project . --pretty \
95+
&& echo -e "All ${GREEN}good${RESET}."
96+
}
97+
7798
# =========================================================
7899
## Automation
79100
# =========================================================
80101

81102
function task:pre-commit { ## Clean up code before committing
82-
task:prettify
103+
task:prettier
104+
task:eslint
105+
task:typescript
83106
title "Comitting"
84107
}
85108

@@ -123,6 +146,11 @@ function task:shorthand { ## Create CLI shorthand task instead of ./Taskfile
123146
echo -e "${BLUE}You can now use:${RESET} task ${YELLOW}<task>${RESET} <args>"
124147
}
125148

126-
# Execute tasks
127149
banner
128-
if [[ "$(declare -fF task:${@-help})" ]]; then task:${@-help}; else task:help; exit 1; fi
150+
if [[ ! "$(declare -F task:${@-help})" ]]; then
151+
title "Task not found"
152+
echo -e "Task ${YELLOW}$1${RESET} doesn't exist."
153+
task:help
154+
exit 1
155+
fi
156+
task:${@-help}

dev/git-hooks/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
# Make the shell script user-interactive
4+
exec < /dev/tty
5+
6+
# Run pre-commit action from the Taskfile
7+
./Taskfile pre-commit

dev/linting/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.idea/
2+
.next/
3+
.github/
4+
*.yml
5+
out/
File renamed without changes.

dev/linting/eslint.config.mjs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import reactPlugin from 'eslint-plugin-react';
2+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
3+
4+
import nextPlugin from '@next/eslint-plugin-next';
5+
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
6+
import typescriptParser from '@typescript-eslint/parser';
7+
8+
const projectRules = {
9+
'@next/next/no-img-element': 'off',
10+
'linebreak-style': ['error', 'unix'],
11+
'react/jsx-pascal-case': ['error'],
12+
'react/button-has-type': ['error'],
13+
'@typescript-eslint/no-unused-vars': [
14+
'error',
15+
{
16+
argsIgnorePattern: '^_',
17+
caughtErrorsIgnorePattern: '^_',
18+
varsIgnorePattern: '^_',
19+
},
20+
],
21+
};
22+
23+
export default [
24+
{
25+
plugins: {
26+
'@typescript-eslint': typescriptPlugin,
27+
},
28+
languageOptions: {
29+
parser: typescriptParser,
30+
parserOptions: {
31+
warnOnUnsupportedTypeScriptVersion: false,
32+
},
33+
},
34+
rules: {
35+
...typescriptPlugin.configs.recommended.rules,
36+
'@typescript-eslint/explicit-module-boundary-types': 'off',
37+
'@typescript-eslint/explicit-function-return-type': [
38+
'warn',
39+
{
40+
allowedNames: ['Page', 'generateMetadata', 'Layout'],
41+
},
42+
],
43+
},
44+
},
45+
{
46+
files: ['**/*.{ts,tsx}'],
47+
plugins: {
48+
react: reactPlugin,
49+
'react-hooks': reactHooksPlugin,
50+
'@next/next': nextPlugin,
51+
},
52+
rules: {
53+
...reactPlugin.configs['jsx-runtime'].rules,
54+
// ...hooksPlugin.configs.recommended.rules,
55+
...nextPlugin.configs.recommended.rules,
56+
...nextPlugin.configs['core-web-vitals'].rules,
57+
...projectRules,
58+
},
59+
settings: {
60+
react: {
61+
version: 'detect',
62+
},
63+
},
64+
},
65+
{
66+
ignores: ['.next/', 'out/'],
67+
},
68+
];

dev/linting/lint-staged.config.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2+
3+
const prettier =
4+
'prettier --config dev/linting/.prettierrc.json --ignore-path dev/linting/.prettierignore --write --list-different';
5+
6+
const config = {
7+
// ==============================
8+
// Frontend specific
9+
// ==============================
10+
'*.{ts,tsx}': [
11+
// tsc runs for all files instead of only the edited ones
12+
() => 'tsc --noEmit --project . --pretty',
13+
'eslint --config dev/linting/eslint.config.mjs',
14+
prettier,
15+
],
16+
17+
// ==============================
18+
// Global files
19+
// ==============================
20+
'*.{json,css,md,html}': [prettier],
21+
};
22+
23+
export default config;

next.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import type { NextConfig } from "next";
1+
import type { NextConfig } from 'next';
22

33
const nextConfig: NextConfig = {
44
output: 'export',
55
webpack: (config) => {
66
config.module.rules.push({
7-
test: /\.txt$/i,
7+
test: /\.(txt|sh)$/i,
88
use: 'raw-loader',
99
});
1010

1111
return config;
12-
}
12+
},
1313
};
1414

1515
export default nextConfig;

0 commit comments

Comments
 (0)