diff --git a/.env.sample b/.env.sample
new file mode 100644
index 0000000..064bccc
--- /dev/null
+++ b/.env.sample
@@ -0,0 +1 @@
+CONFIG_PATH=config.yaml
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..304c469
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,9 @@
+{
+ "printWidth": 100,
+ "singleQuote": true,
+ "quoteProps": "consistent",
+ "tabWidth": 4,
+ "semi": false,
+ "arrowParens": "avoid",
+ "proseWrap": "always"
+}
diff --git a/README.md b/README.md
index 8e072b0..0fda2d5 100644
--- a/README.md
+++ b/README.md
@@ -23,11 +23,19 @@ deploys:
branch: main
type: dockerfile
options:
- path: ./Dockerfile
+ ports:
+ - 80:8080
+ volumes:
+ - /var/www/html:/var/www/html
- name: project2
url: ssh://example.org/username/project2.git
commit: 04c540647a
type: docker-compose
options:
- path: ./docker-compose.yml
+ path: ./docker-compose.yml # already the default
+ - name: project3
+ url: https://github.com/username/project3
+ type: shell
+ options:
+ path: ./deploy.sh # already the default
```
\ No newline at end of file
diff --git a/config.yaml b/config.yaml
index 2caf196..af19a4d 100644
--- a/config.yaml
+++ b/config.yaml
@@ -2,9 +2,18 @@ deploys:
- name: project1
url: https://github.com/username/project1
branch: main
+ type: docker
+ options:
+ ports:
+ - 80:8080
+ volumes:
+ - /var/www/html:/var/www/html
+ - name: project2
+ url: https://github.com/username/project2
type: dockerfile
options:
- port: 80:8080
+ ports:
+ - 9000:8080
volumes:
- /var/www/html:/var/www/html
- name: project2
diff --git a/package.json b/package.json
index 1589f12..46823b6 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"async-mutex": "^0.4.1",
"dockerode": "^4.0.2",
"js-yaml": "^4.1.0",
+ "lodash": "^4.17.21",
"nodegit": "^0.27.0",
"preact": "^10.19.4",
"typescript": "^5.3.3"
@@ -27,6 +28,7 @@
"devDependencies": {
"@types/dockerode": "^3.3.23",
"@types/js-yaml": "^4.0.9",
+ "@types/lodash": "^4.14.202",
"sass": "^1.70.0"
}
}
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9d31c33..8a1d24b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -35,6 +35,9 @@ dependencies:
js-yaml:
specifier: ^4.1.0
version: 4.1.0
+ lodash:
+ specifier: ^4.17.21
+ version: 4.17.21
nodegit:
specifier: ^0.27.0
version: 0.27.0
@@ -52,6 +55,9 @@ devDependencies:
'@types/js-yaml':
specifier: ^4.0.9
version: 4.0.9
+ '@types/lodash':
+ specifier: ^4.14.202
+ version: 4.14.202
sass:
specifier: ^1.70.0
version: 1.70.0
@@ -1000,6 +1006,10 @@ packages:
'@types/node': 20.11.17
dev: false
+ /@types/lodash@4.14.202:
+ resolution: {integrity: sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==}
+ dev: true
+
/@types/mdast@4.0.3:
resolution: {integrity: sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==}
dependencies:
diff --git a/src/client/Deploy.jsx b/src/client/Deploy.jsx
new file mode 100644
index 0000000..44ed1af
--- /dev/null
+++ b/src/client/Deploy.jsx
@@ -0,0 +1,9 @@
+import { Value } from './Inspect.jsx'
+
+export const Deploy = ({ deploy }) => {
+ return (
+
+
+
+ )
+}
diff --git a/src/client/Inspect.jsx b/src/client/Inspect.jsx
new file mode 100644
index 0000000..843ab15
--- /dev/null
+++ b/src/client/Inspect.jsx
@@ -0,0 +1,41 @@
+import _ from 'lodash'
+import { clsx } from '../utils.js'
+
+export const Value = ({ value, borderless }) => {
+ return Array.isArray(value) ? (
+
+ ) : typeof value === 'object' ? (
+
+ ) : (
+ value
+ )
+}
+
+export const ValueArray = ({ value, borderless }) => {
+ return (
+
+ {value.map(item => (
+
+
+
+ ))}
+
+ )
+}
+
+export const ValueObject = ({ value, borderless }) => {
+ return (
+
+ {Object.entries(value).map(([k, v]) => (
+ <>
+
+ {_.startCase(k)}
+
+
+
+
+ >
+ ))}
+
+ )
+}
diff --git a/src/client/NewDeployForm.jsx b/src/client/NewDeployForm.jsx
index 9b051e6..ca6a44a 100644
--- a/src/client/NewDeployForm.jsx
+++ b/src/client/NewDeployForm.jsx
@@ -10,27 +10,50 @@ export const NewDeployForm = () => {
-
+
-
- setDeployType(e.target.value)}>
+ setDeployType(e.target.value)}
+ >
-
+
+
@@ -44,12 +67,14 @@ export const NewDeployForm = () => {
export const DeployOptions = ({ type }) => {
switch (type) {
- case 'shell':
- return
- case 'dockerfile':
+ case 'docker':
return
+ case 'dockerfile':
+ return
case 'docker-compose':
return
+ case 'shell':
+ return
default:
return null
}
@@ -58,20 +83,75 @@ export const DeployOptions = ({ type }) => {
const DockerDeploy = () => {
return (
<>
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
+
+const DockerfileDeploy = () => {
+ return (
+ <>
+
+
-
+
-
+
-
+
>
)
}
@@ -80,10 +160,20 @@ const ShellDeploy = () => {
return (
<>
-
+
-
+
>
)
}
@@ -92,7 +182,12 @@ const DockerComposeDeploy = () => {
return (
<>
-
+
>
)
}
diff --git a/src/config.ts b/src/config.ts
index 80443a1..9c6e740 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -3,46 +3,61 @@ import yaml from 'js-yaml'
import { readFile, writeFile } from 'fs/promises'
import { Mutex } from 'async-mutex'
-type GitRef = { commit: string } | { branch: string } | { tag: string }
+export type GitRef = { type: 'default' } | { type: 'branch' | 'tag' | 'commit'; value: string }
-type BaseDeploy = {
- name: string
+export type BaseDeploy = { name: string }
+
+export type BaseGitDeploy = BaseDeploy & {
url: string
-} & GitRef
+ ref: GitRef
+}
-type DockerDeploy = BaseDeploy & {
+export type DockerDeploy = BaseDeploy & {
type: 'docker'
options: {
- path?: string
image: string
+ name?: string
volumes?: string[]
ports?: string[]
env?: Record
}
}
-type DockerComposeDeploy = BaseDeploy & {
+export type DockerfileDeploy = BaseGitDeploy & {
+ type: 'dockerfile'
+ options: {
+ path?: string
+
+ name?: string
+ volumes?: string[]
+ ports?: string[]
+ env?: Record
+ }
+}
+
+export type DockerComposeDeploy = BaseGitDeploy & {
type: 'docker-compose'
options: {
path?: string
}
}
-type ShellDeploy = BaseDeploy & {
+export type ShellDeploy = BaseGitDeploy & {
type: 'shell'
options: {
path?: string
+ env?: Record
}
}
-type Deploy = DockerDeploy | DockerComposeDeploy | ShellDeploy
+export type Deploy = DockerDeploy | DockerfileDeploy | DockerComposeDeploy | ShellDeploy
-type Config = {
+export type Config = {
deploys: Deploy[]
}
export const refToString = (ref: GitRef) => {
- return 'commit' in ref ? ref.commit : 'branch' in ref ? ref.branch : 'tag' in ref ? ref.tag : ''
+ return ref.type === 'default' ? '' : ref.value
}
const mutex = new Mutex()
diff --git a/src/pages/deploys/index.astro b/src/pages/deploys/index.astro
index 27c91dc..1f6c1b3 100644
--- a/src/pages/deploys/index.astro
+++ b/src/pages/deploys/index.astro
@@ -1,36 +1,15 @@
---
+import { Deploy } from '../../client/Deploy'
import { loadConfig, refToString } from '../../config'
import Layout from '../../layouts/Layout.astro'
const { deploys } = await loadConfig()
---
-
+
Deploys
New Deploy
-
- {
- deploys.map(deploy => (
- -
- Name:
- {deploy.name}
- URL:
- {deploy.url.startsWith('http') ? (
-
- {deploy.url}
-
- ) : (
- deploy.url
- )}
-
- Ref:
- {refToString(deploy)}
- Type:
- {deploy.type}
- Path:
- {deploy.options.path}
-
- ))
- }
-
+
+ {deploys.map(deploy => )}
+
diff --git a/src/styles/main.scss b/src/styles/main.scss
index 40b2fce..8391350 100644
--- a/src/styles/main.scss
+++ b/src/styles/main.scss
@@ -104,7 +104,7 @@ textarea {
width: auto;
&:not(textarea) {
- height: 32px;
+ height: 2rem;
}
font-size: 18px;
@@ -116,7 +116,7 @@ textarea {
border: 1px solid #ddd;
border-radius: 6px;
- padding: 5px 0.25rem;
+ padding: 0 0.25rem;
display: flex;
align-items: center;
@@ -132,6 +132,11 @@ textarea {
}
}
+textarea {
+ min-height: 2rem;
+ padding: 7px 0.25rem;
+}
+
form {
width: 100%;
@@ -144,7 +149,7 @@ form {
border: 1px solid #ddd;
grid-template-columns: minmax(7rem, auto) 1fr;
- gap: 0.75rem 1rem;
+ gap: 0.5rem;
align-items: start;
@@ -180,9 +185,99 @@ form {
display: flex;
align-items: center;
- height: 32px;
+ height: 2rem;
+ font-weight: 700;
+ }
+}
+
+.object {
+ display: grid;
+ grid-template-columns: auto 1fr;
+
+ border: 1px solid #ddd;
+
+ width: 100%;
+
+ & > .key {
font-weight: 700;
+
+ display: flex;
+ align-items: center;
+
+ min-height: 2rem;
+
+ padding: 0 1rem 0 0.25rem;
+ }
+
+ & > .value {
+ min-height: 2rem;
+ padding: 0.25rem;
+
+ display: flex;
+ align-items: center;
+
+ border-left: 1px solid #ddd;
+ }
+
+ & > .key,
+ & > .value {
+ border-top: 1px solid #ddd;
}
+
+ & > .key:nth-child(1) {
+ border-top: none;
+ }
+ & > .value:nth-child(2) {
+ border-top: none;
+ }
+}
+
+.array {
+ display: grid;
+
+ border: 1px solid #ddd;
+
+ width: 100%;
+
+ & > .item {
+ display: flex;
+ align-items: center;
+
+ min-height: 2rem;
+ padding: 0.25rem;
+ }
+
+ & > .item {
+ border-top: 1px solid #ddd;
+ }
+
+ & > .item:nth-child(1) {
+ border-top: none;
+ }
+}
+
+.compound-value {
+ border-radius: 4px;
+
+ &.borderless {
+ border: none;
+ }
+}
+
+.deploys {
+ width: 100%;
+
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+}
+
+.deploy {
+ width: 100%;
+
+ background: #fff;
+ padding: 1rem;
+ border-radius: 1rem;
}
//
diff --git a/src/utils.js b/src/utils.js
index e69de29..98e9ba9 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -0,0 +1,5 @@
+export const clsx = (...args) =>
+ args
+ .filter(Boolean)
+ .flatMap(s => (typeof s === 'string' ? s.split(' ') : [s]))
+ .join(' ')
diff --git a/tsconfig.json b/tsconfig.json
index 560c357..11f6093 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,6 +2,7 @@
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"jsx": "react-jsx",
- "jsxImportSource": "preact"
+ "jsxImportSource": "preact",
+ "exactOptionalPropertyTypes": true
}
}