mirror of
https://github.com/unraid/api.git
synced 2026-01-01 06:01:18 -06:00
fix: one-command dev & web env files (#1214)
- fixes `pnpm dev` - fixes `just setup` - Prevents env pollution in nuxt dev/build
This commit is contained in:
@@ -4,10 +4,6 @@ default:
|
|||||||
@just --list --justfile {{justfile()}} --list-heading $'\nAPI project recipes:\n'
|
@just --list --justfile {{justfile()}} --list-heading $'\nAPI project recipes:\n'
|
||||||
@just list-commands
|
@just list-commands
|
||||||
|
|
||||||
setup:
|
|
||||||
pnpm install
|
|
||||||
pnpm run container:build
|
|
||||||
|
|
||||||
# builds js files that can run on an unraid server
|
# builds js files that can run on an unraid server
|
||||||
@build:
|
@build:
|
||||||
pnpm run build
|
pnpm run build
|
||||||
|
|||||||
@@ -17,11 +17,13 @@
|
|||||||
"start": "node dist/main.js",
|
"start": "node dist/main.js",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"command": "pnpm run build && clear && ./dist/cli.js",
|
"command": "pnpm run build && clear && ./dist/cli.js",
|
||||||
"// Build": "",
|
"// Build and Deploy": "",
|
||||||
"build": "vite build --mode=production",
|
"build": "vite build --mode=production",
|
||||||
"postbuild": "chmod +x dist/main.js && chmod +x dist/cli.js",
|
"postbuild": "chmod +x dist/main.js && chmod +x dist/cli.js",
|
||||||
"build:docker": "./scripts/dc.sh run --rm builder",
|
"build:docker": "./scripts/dc.sh run --rm builder",
|
||||||
"build-and-pack": "tsx ./scripts/build.ts",
|
"build-and-pack": "tsx ./scripts/build.ts",
|
||||||
|
"preunraid:deploy": "pnpm build",
|
||||||
|
"unraid:deploy": "./scripts/deploy-dev.sh",
|
||||||
"// GraphQL Codegen": "",
|
"// GraphQL Codegen": "",
|
||||||
"codegen": "MOTHERSHIP_GRAPHQL_LINK='https://staging.mothership.unraid.net/ws' graphql-codegen --config codegen.ts -r dotenv/config './.env.staging'",
|
"codegen": "MOTHERSHIP_GRAPHQL_LINK='https://staging.mothership.unraid.net/ws' graphql-codegen --config codegen.ts -r dotenv/config './.env.staging'",
|
||||||
"codegen:watch": "DOTENV_CONFIG_PATH='./.env.staging' graphql-codegen --config codegen.ts --watch -r dotenv/config",
|
"codegen:watch": "DOTENV_CONFIG_PATH='./.env.staging' graphql-codegen --config codegen.ts --watch -r dotenv/config",
|
||||||
|
|||||||
6
justfile
6
justfile
@@ -12,9 +12,9 @@ setup:
|
|||||||
@just ignore .vscode/settings.json api/.vscode/settings.json web/.vscode/settings.json
|
@just ignore .vscode/settings.json api/.vscode/settings.json web/.vscode/settings.json
|
||||||
# ignore api local-state files
|
# ignore api local-state files
|
||||||
@just ignore api/dev/states/myservers.cfg api/dev/Unraid.net/myservers.cfg
|
@just ignore api/dev/states/myservers.cfg api/dev/Unraid.net/myservers.cfg
|
||||||
|
|
||||||
just api/setup
|
pnpm install
|
||||||
just web/setup
|
just unraid-ui/setup
|
||||||
|
|
||||||
# restore notification files under api/dev
|
# restore notification files under api/dev
|
||||||
restore-notifications:
|
restore-notifications:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm -r build",
|
"build": "pnpm -r build",
|
||||||
"dev": "pnpm -r dev",
|
"dev": "pnpm -r dev",
|
||||||
|
"unraid:deploy": "pnpm -r unraid:deploy",
|
||||||
"test": "pnpm -r test",
|
"test": "pnpm -r test",
|
||||||
"lint": "pnpm -r lint",
|
"lint": "pnpm -r lint",
|
||||||
"lint:fix": "pnpm -r lint:fix",
|
"lint:fix": "pnpm -r lint:fix",
|
||||||
|
|||||||
26
readme.md
26
readme.md
@@ -96,6 +96,7 @@ Make sure the following software is installed before proceeding.
|
|||||||
* Docker (for macOS folks, Orbstack works too)
|
* Docker (for macOS folks, Orbstack works too)
|
||||||
* [Node.js (v20)][Node-url]
|
* [Node.js (v20)][Node-url]
|
||||||
* [Just](https://github.com/casey/just)
|
* [Just](https://github.com/casey/just)
|
||||||
|
* libvirt (macOS folks can run `brew install libvirt`)
|
||||||
* An [Unraid][Unraid-url] server for development
|
* An [Unraid][Unraid-url] server for development
|
||||||
|
|
||||||
Next, create an SSH key if you haven't already.
|
Next, create an SSH key if you haven't already.
|
||||||
@@ -123,26 +124,27 @@ Once you have your key pair, add your public SSH key to your Unraid server:
|
|||||||
```
|
```
|
||||||
|
|
||||||
This will run installation scripts, container builds, and some git scripts to reduce noise (i.e. personal editor customizations, etc).
|
This will run installation scripts, container builds, and some git scripts to reduce noise (i.e. personal editor customizations, etc).
|
||||||
3. Run the API container
|
|
||||||
|
Alternatively, run `pnpm install` for a lighter, less opinionated setup.
|
||||||
|
3. Run dev servers
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd api
|
pnpm dev
|
||||||
npm run container:start
|
|
||||||
```
|
```
|
||||||
|
|
||||||
4. This should bring you inside the API container. There, run the following command to start the server:
|
This will run every dev server in the monorepo. By default, this means:
|
||||||
|
|
||||||
|
* The unraid-api will be available at localhost:3001
|
||||||
|
* The dev server for "rich" web components (like the User Profile Component) will be at localhost:4321 -- Note that shipping to unraid is preferred, as the dev environment is significantly different.
|
||||||
|
* The vite server for unraid-ui development will be at localhost:5173
|
||||||
|
|
||||||
|
4. Test on Unraid
|
||||||
|
|
||||||
```js
|
```js
|
||||||
npm run dev
|
pnpm unraid:deploy <SERVER_IP>
|
||||||
```
|
```
|
||||||
|
|
||||||
5. In another terminal, open the project and navigate to the web directory. Then, run the dev server:
|
This will ship a staging build of unraid-api, unraid-ui, and unraid-components to an Unraid server located at `<SERVER_IP>`.
|
||||||
|
|
||||||
```sh
|
|
||||||
cd web
|
|
||||||
npm install # just in case
|
|
||||||
npm run dev
|
|
||||||
```
|
|
||||||
|
|
||||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ list-commands:
|
|||||||
|
|
||||||
# Prepares the repo for development
|
# Prepares the repo for development
|
||||||
setup:
|
setup:
|
||||||
pnpm install
|
|
||||||
pnpm run build
|
pnpm run build
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -13,16 +13,22 @@
|
|||||||
"tailwind.config.ts"
|
"tailwind.config.ts"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"// Development": "",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
|
||||||
"build:wc": "REM_PLUGIN=true vite build -c vite.web-component.ts --mode production",
|
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"test:ui": "vitest --ui",
|
"test:ui": "vitest --ui",
|
||||||
"coverage": "vitest run --coverage",
|
"coverage": "vitest run --coverage",
|
||||||
"clean": "rm -rf dist",
|
"// Build": "",
|
||||||
"prebuild": "npm run clean",
|
"prebuild": "npm run clean",
|
||||||
|
"build": "vite build",
|
||||||
|
"build:wc": "REM_PLUGIN=true vite build -c vite.web-component.ts --mode production",
|
||||||
|
"clean": "rm -rf dist",
|
||||||
"typecheck": "vue-tsc --noEmit",
|
"typecheck": "vue-tsc --noEmit",
|
||||||
|
"// Deploy to Unraid Server": "",
|
||||||
|
"preunraid:deploy": "pnpm build:wc",
|
||||||
|
"unraid:deploy": "just deploy",
|
||||||
|
"// Storybook": "",
|
||||||
"storybook": "storybook dev -p 6006",
|
"storybook": "storybook dev -p 6006",
|
||||||
"build-storybook": "storybook build"
|
"build-storybook": "storybook build"
|
||||||
},
|
},
|
||||||
|
|||||||
6
web/.env.production
Normal file
6
web/.env.production
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
VITE_ACCOUNT=https://account.unraid.net
|
||||||
|
VITE_CONNECT=https://connect.myunraid.net
|
||||||
|
VITE_UNRAID_NET=https://unraid.net
|
||||||
|
VITE_CALLBACK_KEY=Uyv2o8e*FiQe8VeLekTqyX6Z*8XonB
|
||||||
|
# Keep console logs until components are stabilized
|
||||||
|
VITE_ALLOW_CONSOLE_LOGS=true
|
||||||
3
web/.gitignore
vendored
3
web/.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
!.env.staging
|
!.env.staging
|
||||||
|
!.env.production
|
||||||
@@ -4,11 +4,6 @@ default:
|
|||||||
@just --list --justfile {{justfile()}} --list-heading $'\nWeb project recipes:\n'
|
@just --list --justfile {{justfile()}} --list-heading $'\nWeb project recipes:\n'
|
||||||
@just list-commands
|
@just list-commands
|
||||||
|
|
||||||
setup:
|
|
||||||
just ../unraid-ui/setup
|
|
||||||
cp .env.example .env
|
|
||||||
npm install
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf .nuxt
|
rm -rf .nuxt
|
||||||
rm -rf node_modules
|
rm -rf node_modules
|
||||||
|
|||||||
@@ -5,16 +5,19 @@
|
|||||||
"license": "GPL-2.0-only",
|
"license": "GPL-2.0-only",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"// Development": "",
|
"// Development": "",
|
||||||
"dev": "[ -f .env ] && nuxt dev --dotenv .env || nuxt dev --dotenv .env.staging",
|
"predev": "pnpm --filter=@unraid/ui build",
|
||||||
|
"dev": "nuxt dev --dotenv .env.example",
|
||||||
"preview": "nuxt preview",
|
"preview": "nuxt preview",
|
||||||
"serve": "NODE_ENV=production PORT=${PORT:-4321} node .output/server/index.mjs",
|
"serve": "NODE_ENV=production PORT=${PORT:-4321} node .output/server/index.mjs",
|
||||||
"// Build": "",
|
"// Build": "",
|
||||||
|
"prebuild:dev": "pnpm predev",
|
||||||
"build:dev": "nuxi build --dotenv .env.staging && pnpm run manifest-ts && pnpm run deploy-to-unraid:dev",
|
"build:dev": "nuxi build --dotenv .env.staging && pnpm run manifest-ts && pnpm run deploy-to-unraid:dev",
|
||||||
"build:webgui": "pnpm run type-check && nuxi build --dotenv .env.production && pnpm run manifest-ts && pnpm run copy-to-webgui-repo",
|
"build:webgui": "pnpm run type-check && nuxi build --dotenv .env.production && pnpm run manifest-ts && pnpm run copy-to-webgui-repo",
|
||||||
"build": "NODE_ENV=production nuxi build --dotenv .env.production && pnpm run manifest-ts",
|
"build": "NODE_ENV=production nuxi build --dotenv .env.production && pnpm run manifest-ts",
|
||||||
"generate": "nuxt generate",
|
"generate": "nuxt generate",
|
||||||
"manifest-ts": "node ./scripts/add-timestamp-webcomponent-manifest.js",
|
"manifest-ts": "node ./scripts/add-timestamp-webcomponent-manifest.js",
|
||||||
"// Deployment": "",
|
"// Deployment": "",
|
||||||
|
"unraid:deploy": "pnpm build:dev",
|
||||||
"deploy-to-unraid:dev": "./scripts/deploy-dev.sh",
|
"deploy-to-unraid:dev": "./scripts/deploy-dev.sh",
|
||||||
"copy-to-webgui-repo": "./scripts/copy-to-webgui-repo.sh",
|
"copy-to-webgui-repo": "./scripts/copy-to-webgui-repo.sh",
|
||||||
"// Code Quality": "",
|
"// Code Quality": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user