Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Thumbs.db

# hyf
.hyf/score.json
.hyf/test-output.txt

# Editor and IDE settings
.vscode/
Expand Down Expand Up @@ -155,4 +156,3 @@ dist
# Vite logs files
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

6 changes: 6 additions & 0 deletions .hyf/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions .hyf/score.example.json

This file was deleted.

17 changes: 7 additions & 10 deletions .hyf/test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

# Run your test scripts here.
# Auto grade tool will execute this file within the .hyf working directory.
# The result should be stored in score.json file with the format shown below.
cat << EOF > score.json
{
"score": 0,
"pass": true,
"passingScore": 0
}
EOF
pushd ..
/usr/bin/env npm install
npx vitest run --reporter=json --outputFile=.hyf/report.json
popd || exit
} >/dev/null

PASSING_SCORE=50 /usr/bin/env node tester.js
55 changes: 55 additions & 0 deletions .hyf/tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import fs from 'fs/promises';
import path from 'path';

const __dirname = import.meta.dirname;
const reportPath = path.join(__dirname, 'report.json');

try {
const reportContent = await fs.readFile(reportPath, 'utf-8');
await fs.unlink(reportPath);

const { testResults } = JSON.parse(reportContent);
let maxPoints = 0;
let earnedPoints = 0;
let passedCount = 0;
let failedCount = 0;

console.log('Vitest unit test results:\n');

const passingScore = Number(process.env.PASSING_SCORE || 50);

for (const result of testResults) {
for (const { title, status } of result.assertionResults) {
const match = title.match(/^\[(\d+)]/);
const points = match ? Number(match[1]) || 1 : 1;
maxPoints += points;
let icon;
if (status === 'passed') {
icon = '✅';
passedCount += 1;
earnedPoints += points;
} else {
icon = '❌';
failedCount += 1;
}
console.log(`${icon} ${title}`);
}
}

console.log(`\nTotal passed: ${passedCount}`);
console.log(`Total failed: ${failedCount}`);

const totalScore = Math.round((earnedPoints / maxPoints) * 100);

const results = {
score: totalScore,
pass: totalScore >= passingScore,
passingScore: passingScore,
};

await fs.writeFile('score.json', JSON.stringify(results, null, 2));
process.exit(0);
} catch (error) {
console.error('Error parsing report JSON:', error);
process.exit(1);
}
132 changes: 132 additions & 0 deletions examples/margarita.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Cocktail Recipes

## Margarita

![Margarita](https://www.thecocktaildb.com/images/media/drink/5noda61589575158.jpg/medium)

**Category**: Ordinary Drink

**Alcoholic**: Yes

### Ingredients

- 1 1/2 oz Tequila
- 1/2 oz Triple sec
- 1 oz Lime juice
- Salt

### Instructions

Rub the rim of the glass with the lime slice to make the salt stick to it. Take care to moisten only the outer rim and sprinkle the salt on it. The salt should present to the lips of the imbiber and never mix into the cocktail. Shake the other ingredients with ice, then carefully pour into the glass.

Serve in: Cocktail glass

## Blue Margarita

![Blue Margarita](https://www.thecocktaildb.com/images/media/drink/bry4qh1582751040.jpg/medium)

**Category**: Ordinary Drink

**Alcoholic**: Yes

### Ingredients

- 1 1/2 oz Tequila
- 1 oz Blue Curacao
- 1 oz Lime juice
- Coarse Salt

### Instructions

Rub rim of cocktail glass with lime juice. Dip rim in coarse salt. Shake tequila, blue curacao, and lime juice with ice, strain into the salt-rimmed glass, and serve.

Serve in: Cocktail glass

## Tommy's Margarita

![Tommy's Margarita](https://www.thecocktaildb.com/images/media/drink/loezxn1504373874.jpg/medium)

**Category**: Ordinary Drink

**Alcoholic**: Yes

### Ingredients

- 4.5 cl Tequila
- 1.5 cl Lime Juice
- 2 spoons Agave syrup

### Instructions

Shake and strain into a chilled cocktail glass.

Serve in: Old-Fashioned glass

## Whitecap Margarita

![Whitecap Margarita](https://www.thecocktaildb.com/images/media/drink/srpxxp1441209622.jpg/medium)

**Category**: Other / Unknown

**Alcoholic**: Yes

### Ingredients

- 1 cup Ice
- 2 oz Tequila
- 1/4 cup Cream of coconut
- 3 tblsp fresh Lime juice

### Instructions

Place all ingredients in a blender and blend until smooth. This makes one drink.

Serve in: Margarita/Coupette glass

## Strawberry Margarita

![Strawberry Margarita](https://www.thecocktaildb.com/images/media/drink/tqyrpw1439905311.jpg/medium)

**Category**: Ordinary Drink

**Alcoholic**: Yes

### Ingredients

- 1/2 oz Strawberry schnapps
- 1 oz Tequila
- 1/2 oz Triple sec
- 1 oz Lemon juice
- 1 oz Strawberries
- Salt

### Instructions

Rub rim of cocktail glass with lemon juice and dip rim in salt. Shake schnapps, tequila, triple sec, lemon juice, and strawberries with ice, strain into the salt-rimmed glass, and serve.

Serve in: Cocktail glass

## Smashed Watermelon Margarita

![Smashed Watermelon Margarita](https://www.thecocktaildb.com/images/media/drink/dztcv51598717861.jpg/medium)

**Category**: Cocktail

**Alcoholic**: Yes

### Ingredients

- 1/2 cup Watermelon
- 5 Mint
- 1/3 Cup Grapefruit Juice
- Juice of 1/2 Lime
- 1 shot Tequila
- Garnish with Watermelon
- Garnish with Mint

### Instructions

In a mason jar muddle the watermelon and 5 mint leaves together into a puree and strain. Next add the grapefruit juice, juice of half a lime and the tequila as well as some ice. Put a lid on the jar and shake. Pour into a glass and add more ice. Garnish with fresh mint and a small slice of watermelon.

Serve in: Collins glass

Loading