From 6ffa9ca7773ec6735a5699942b4033f01f3ae597 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Sun, 25 Feb 2024 14:52:10 +0100 Subject: [PATCH] prototype of the deploys page using the inspect component --- .env.sample | 1 + .prettierrc | 9 +++ README.md | 12 +++- config.yaml | 11 ++- package.json | 2 + pnpm-lock.yaml | 10 +++ src/client/Deploy.jsx | 9 +++ src/client/Inspect.jsx | 41 +++++++++++ src/client/NewDeployForm.jsx | 131 +++++++++++++++++++++++++++++----- src/config.ts | 37 +++++++--- src/pages/deploys/index.astro | 31 ++------ src/styles/main.scss | 103 ++++++++++++++++++++++++-- src/utils.js | 5 ++ tsconfig.json | 3 +- 14 files changed, 342 insertions(+), 63 deletions(-) create mode 100644 .env.sample create mode 100644 .prettierrc create mode 100644 src/client/Deploy.jsx create mode 100644 src/client/Inspect.jsx 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 = () => { - +
- setRefType(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 ( <> - - - - + + + +