Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mugendi committed Sep 29, 2024
0 parents commit 89013ad
Show file tree
Hide file tree
Showing 40 changed files with 4,917 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
node_modules

# Output
.output
.vercel
/.svelte-kit
/build

# OS
.DS_Store
Thumbs.db

# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"hide-files.files": []
}
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
39 changes: 39 additions & 0 deletions bash/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) 2024 Anthony Mugendi
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT

# Function to check if a container exists
container_exists() {
docker ps -a --format '{{.Names}}' | grep -q "^$1$"
}

# Function to check if a container is running
container_running() {
docker ps --format '{{.Names}}' | grep -q "^$1$"
}

# Function to stop a container if it exists and is running
stop_container() {
if container_exists "$1"; then
if docker ps -q -f name="$1" | grep -q .; then
echo "Stopping $1 container..."
docker stop "$1"
else
echo "$1 container is not running."
fi
else
echo "$1 container does not exist."
fi
}

# Function to stop and remove a container if it exists
stop_and_remove() {
if container_exists "$1"; then
echo "Stopping and removing $1 container..."
docker stop "$1" 2>/dev/null
docker rm "$1"
else
echo "$1 container does not exist."
fi
}
53 changes: 53 additions & 0 deletions bash/typesense.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$0")")

# load methodss we need...
. "$SCRIPT_DIR/docker.sh"
. "$SCRIPT_DIR/../.env"


if [ -z "$API_KEY" ]; then
echo "Error: API KEY is required." >&2
return 1
fi

if [ -z "$API_PORT" ]; then
echo "Error: API PORT is required." >&2
return 1
fi



DATA_DIR="$HOME/typesense-data"
CONTAINER_NAME='typesense'

if [ -n "$RECREATE" ]; then
stop_and_remove "$CONTAINER_NAME"
fi

echo "DATA_DIR: $DATA_DIR\nCONTAINER_NAME: $CONTAINER_NAME\nAPI KEY: $API_KEY\nAPI PORT:$API_PORT\nRECREATE: $RECREATE\n"


# Start Tor container
if ! container_exists "$CONTAINER_NAME"; then
echo "Creating and starting $CONTAINER_NAME container..."

mkdir -p "$DATA_DIR"

docker run -d --restart unless-stopped \
--name typesense \
-p "$API_PORT":8108 \
-v "$DATA_DIR":/data \
typesense/typesense:27.1 \
--data-dir /data \
--api-key=$API_KEY \
--enable-cors

elif ! container_running "$CONTAINER_NAME"; then
echo "Starting existing $CONTAINER_NAME container..."
docker start "$CONTAINER_NAME"
else
echo "$CONTAINER_NAME container is already running."
fi

#
32 changes: 32 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import eslint from '@eslint/js';
import prettier from 'eslint-config-prettier';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: tseslint.parser
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
);
59 changes: 59 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "app",
"version": "0.0.1",
"scripts": {
"setup": "sh ./bash/typesense.sh",
"env": "node -r dotenv/config",
"dev": "vite dev",
"prod":"node -r dotenv/config build",
"build": "vite build",
"preview": "run-p setup vite preview",
"test": "npm run test:integration && npm run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
"test:unit": "vitest"
},
"devDependencies": {
"@fontsource/fira-mono": "^5.0.0",
"@neoconfetti/svelte": "^2.0.0",
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-node": "^5.2.5",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^9.6.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"sass-embedded": "^1.79.4",
"svelte": "^4.2.7",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0",
"vite": "^5.0.3",
"vitest": "^2.0.0"
},
"type": "module",
"dependencies": {
"bytes": "^3.1.2",
"detect-file-encoding-and-language": "^2.4.0",
"dotenv": "^16.4.5",
"globby": "^14.0.2",
"isutf8": "^4.0.1",
"language-detect": "^1.1.0",
"lodash": "^4.17.21",
"mime-types": "^2.1.35",
"npm-run-all": "^4.1.5",
"open": "^10.1.0",
"printline": "^1.0.0",
"read-chunk": "^5.0.0",
"shorthash": "^0.0.2",
"typesense": "^1.8.2"
}
}
12 changes: 12 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/
};

export default config;
Loading

0 comments on commit 89013ad

Please sign in to comment.