Skip to content

Commit

Permalink
Add ability to let addons generate taskfile sections (#6)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rick-nu authored Nov 14, 2024
1 parent 41727dd commit 5c44039
Show file tree
Hide file tree
Showing 59 changed files with 1,068 additions and 695 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ jobs:
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}

52 changes: 18 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
# Taskfile
# Taskfile ([TaskfileGenerator.com](https://taskfilegenerator.com))

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

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

## Why

- Works on any OS (any bash terminal)
- A uniform way to run your projects
- Very easy to use
- Automate your most common tasks (updating, starting, building, etc...)
- Easy to understand and maintain

# Create your own taskfile

This project gives you a `Taskfile` base, and gives you a collection of usefull tasks to help out on
your project.
[![CLI Taskfile preview](./images/cli-preview.gif)](https://taskfilegenerator.com)

- [The Taskfile base](./taskfile-base.md)

We strongly recommend that your project uses a project section containing a `init` and a `update`
task. Check out our example:

- [Project section](./section/project.md)

## Usefull tasks
## Why

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

- [Docker](./section/docker.md)
- [GitHub](./section/github.md)
- [GitLab](./section/gitlab.md)
## Credits

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

This Taskfile setup is based on
[Adrian Cooney's Taskfile](https://github.com/adriancooney/Taskfile).
## Contributors

# Contribute
A big thanks to all the contributors of Taskfile!

Feel free to add your own Taskfile tasks via a PR. The more usefull tasks, the easier we make the
life of other developers.
![contirubtor avatars](https://contrib.rocks/image?repo=enrise/taskfile)
44 changes: 36 additions & 8 deletions Taskfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function banner {
# =========================================================

function task:init { ## Set up the project for local development
project:git-config
task:update
task:help
}
Expand Down Expand Up @@ -50,11 +51,10 @@ function project:install-dependencies {
npm install
}

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

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

function task:prettier { ## Prettify all files
title "Running prettier"
echo "Prettifying files..."
prettier --config dev/linting/.prettierrc.json --ignore-path dev/linting/.prettierignore --write --list-different . \
&& echo -e "All ${GREEN}good${RESET}."
}

function task:eslint { ## Check typescript logic
title "ESLint"
echo "Checking typescript logic..."
eslint --config dev/linting/eslint.config.mjs . \
&& echo -e "All ${GREEN}good${RESET}."
}

function task:typescript { ## Check typescript types
title "Typescript type check"
echo "Checking typescript types..."
tsc --noEmit --project . --pretty \
&& echo -e "All ${GREEN}good${RESET}."
}

# =========================================================
## Automation
# =========================================================

function task:pre-commit { ## Clean up code before committing
task:prettify
task:prettier
task:eslint
task:typescript
title "Comitting"
}

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

# Execute tasks
banner
if [[ "$(declare -fF task:${@-help})" ]]; then task:${@-help}; else task:help; exit 1; fi
if [[ ! "$(declare -F task:${@-help})" ]]; then
title "Task not found"
echo -e "Task ${YELLOW}$1${RESET} doesn't exist."
task:help
exit 1
fi
task:${@-help}
7 changes: 7 additions & 0 deletions dev/git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# Make the shell script user-interactive
exec < /dev/tty

# Run pre-commit action from the Taskfile
./Taskfile pre-commit
5 changes: 5 additions & 0 deletions dev/linting/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
.next/
.github/
*.yml
out/
File renamed without changes.
68 changes: 68 additions & 0 deletions dev/linting/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';

import nextPlugin from '@next/eslint-plugin-next';
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';

const projectRules = {
'@next/next/no-img-element': 'off',
'linebreak-style': ['error', 'unix'],
'react/jsx-pascal-case': ['error'],
'react/button-has-type': ['error'],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
};

export default [
{
plugins: {
'@typescript-eslint': typescriptPlugin,
},
languageOptions: {
parser: typescriptParser,
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
rules: {
...typescriptPlugin.configs.recommended.rules,
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-function-return-type': [
'warn',
{
allowedNames: ['Page', 'generateMetadata', 'Layout'],
},
],
},
},
{
files: ['**/*.{ts,tsx}'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'@next/next': nextPlugin,
},
rules: {
...reactPlugin.configs['jsx-runtime'].rules,
// ...hooksPlugin.configs.recommended.rules,
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
...projectRules,
},
settings: {
react: {
version: 'detect',
},
},
},
{
ignores: ['.next/', 'out/'],
},
];
23 changes: 23 additions & 0 deletions dev/linting/lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */

const prettier =
'prettier --config dev/linting/.prettierrc.json --ignore-path dev/linting/.prettierignore --write --list-different';

const config = {
// ==============================
// Frontend specific
// ==============================
'*.{ts,tsx}': [
// tsc runs for all files instead of only the edited ones
() => 'tsc --noEmit --project . --pretty',
'eslint --config dev/linting/eslint.config.mjs',
prettier,
],

// ==============================
// Global files
// ==============================
'*.{json,css,md,html}': [prettier],
};

export default config;
6 changes: 3 additions & 3 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { NextConfig } from "next";
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
output: 'export',
webpack: (config) => {
config.module.rules.push({
test: /\.txt$/i,
test: /\.(txt|sh)$/i,
use: 'raw-loader',
});

return config;
}
},
};

export default nextConfig;
Loading

0 comments on commit 5c44039

Please sign in to comment.