Skip to content

Commit 6074936

Browse files
committed
Add application utilities
1 parent 405c925 commit 6074936

File tree

9 files changed

+42
-14
lines changed

9 files changed

+42
-14
lines changed

src/components/Generator/Generator.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use client';
22

3-
import { ReactElement } from 'react';
3+
import {ReactElement} from 'react';
44
import Window from '@/components/Window';
55

66
import styles from './generator.module.scss';
7-
import { useForm } from 'react-hook-form';
7+
import {useForm} from 'react-hook-form';
88
import Settings from './Settings';
99
import GeneratedTaskfile from './GeneredTaskfile';
1010
import Form from '@/components/Form';
11-
import { Font } from './GeneredTaskfile/buildHeader';
11+
import {Font} from './GeneredTaskfile/buildHeader';
1212

1313
export type GeneratorSettings = {
1414
project: string;
@@ -18,6 +18,7 @@ export type GeneratorSettings = {
1818
checkoutGitRequest: 'none' | 'github' | 'gitlab';
1919
configureGitHooks: boolean;
2020
fileUtilities: boolean;
21+
appUtilities: boolean;
2122
};
2223

2324
const Generator = (): ReactElement => {

src/components/Generator/GeneredTaskfile/addons/addons.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { GeneratorSettings } from '@/components/Generator';
2-
import { TaskfileAddons } from '@/components/Generator/GeneredTaskfile/taskfile';
1+
import {GeneratorSettings} from '@/components/Generator';
2+
import {TaskfileAddons} from '@/components/Generator/GeneredTaskfile/taskfile';
33

44
import runtime from './runtime';
55
import git from './git';
66
import fileUtilities from './fileUtilities';
7+
import appUtilities from "@/components/Generator/GeneredTaskfile/addons/appUtilities";
78

89
/**
910
* Render addons for the Taskfile based on the generator settings
@@ -15,6 +16,7 @@ const renderAddons = (settings: GeneratorSettings, addons: TaskfileAddons): void
1516
runtime(settings, addons);
1617
git(settings, addons);
1718
fileUtilities(settings, addons);
19+
appUtilities(settings, addons);
1820
};
1921

2022
export default renderAddons;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function app:ensure {
2+
if [ ! $(which "$1") ]; then
3+
echo "Missing required application ${RED}$1${RESET}. Install it before tying again."
4+
exit 1
5+
fi
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {GeneratorSettings} from '@/components/Generator';
2+
import {TaskfileAddons} from '@/components/Generator/GeneredTaskfile/taskfile';
3+
import loadTemplate from '@/helpers/loadTemplate';
4+
import appUtilitiesSh from './app-utilities.sh';
5+
6+
const appUtilities = (settings: GeneratorSettings, addon: TaskfileAddons): void => {
7+
if (settings.appUtilities) {
8+
addon.utilityFunctions.push(loadTemplate(appUtilitiesSh));
9+
}
10+
};
11+
12+
export default appUtilities;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './appUtilities';
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
function file:ensure { # Abort if the desired file is not found
22
if [ ! -f $1 ]; then
3-
echo -e "${RED}Missing required file: ${YELLOW}$1${RESET}"
3+
echo -e "Missing required file ${RED}$1${RESET}, make sure it is created."
44
exit 1
55
fi
66
}
77

88
function file:ensure-copy { # file:ensure-copy $COPY_TARGET $COPY_SOURCE
99
if [ ! -f $1 ]; then
1010
cp $2 $1;
11-
echo -e "Created copy of ${YELLOW}$2${RESET} to create ${GREEN}$1${RESET}.";
11+
echo -e "Created copy of ${YELLOW}$2${RESET} to create required file ${GREEN}$1${RESET}.";
1212
else
13-
echo "${GREEN}$1${RESET} is present.";
13+
echo "File ${GREEN}$1${RESET} is present.";
1414
fi
1515
}

src/components/Generator/GeneredTaskfile/taskfile-base.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function task:shorthand { ## Create CLI shorthand task instead of ./Taskfile
7272
banner
7373
if [[ ! "$(declare -F task:${@-help})" ]]; then
7474
title "Task not found"
75-
echo -e "Task ${YELLOW}$1${RESET} doesn't exist."
75+
echo -e "Task ${RED}$1${RESET} doesn't exist."
7676
task:help
7777
exit 1
7878
fi

src/components/Generator/Settings/Settings.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use client';
22

3-
import { ReactElement } from 'react';
3+
import {ReactElement} from 'react';
44

5-
import styles from './settings.module.css';
5+
import styles from './settings.module.scss';
66
import TextInput from '@/components/Form/Text';
77
import RadioInput from '@/components/Form/Radio';
8-
import { useFormContext } from 'react-hook-form';
9-
import { GeneratorSettings } from '@/components/Generator';
8+
import {useFormContext} from 'react-hook-form';
9+
import {GeneratorSettings} from '@/components/Generator';
1010
import Checkbox from '@/components/Form/Checkbox';
1111

1212
const Settings = (): ReactElement => {
@@ -80,7 +80,9 @@ const Settings = (): ReactElement => {
8080
]}
8181
/>
8282
<Checkbox name="configureGitHooks">Configure git hooks</Checkbox>
83-
<Checkbox name="fileUtilities">File utilities</Checkbox>
83+
<h2>Utilities</h2>
84+
<Checkbox name="fileUtilities">File checks</Checkbox>
85+
<Checkbox name="appUtilities">Application dependencies</Checkbox>
8486
</div>
8587
);
8688
};

src/components/Generator/Settings/settings.module.css renamed to src/components/Generator/Settings/settings.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
display: flex;
33
flex-direction: column;
44
gap: 1rem;
5+
6+
h2 {
7+
font-size: 1rem;
8+
}
59
}

0 commit comments

Comments
 (0)