Skip to content

Commit

Permalink
Merge pull request #133 from chaitin/fix-docker-run
Browse files Browse the repository at this point in the history
fix: the old docker trans package is bad,use the other
  • Loading branch information
phxa1 authored Feb 5, 2024
2 parents c6b70e8 + 0b27600 commit ea4ba13
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 132 deletions.
3 changes: 3 additions & 0 deletions declare.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ declare module 'clean-css' {
export type Options = any;
export default any;
}
declare module 'composerize' {
export default any;
}
declare module 'figlet/importable-fonts/Standard.js';
declare module 'figlet/importable-fonts/1Row.js';
declare module 'figlet/importable-fonts/3D-ASCII';
Expand Down
194 changes: 66 additions & 128 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"big-integer": "^1.6.52",
"change-case": "^5.3.0",
"clean-css": "^5.3.3",
"composerize-ts": "^0.6.2",
"composerize": "^1.6.6",
"compressorjs": "^1.2.1",
"crypto-js": "^4.2.0",
"css2less": "^0.1.4",
Expand Down
22 changes: 19 additions & 3 deletions src/pages/docker_run_to_docker_compose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import MainContent from '@/components/MainContent';
import TextFieldWithClean from '@/components/TextFieldWithClean';
import { ToolsForm } from '@/components/Tools';
import { saveFile } from '@/utils/download';
import { Button, Stack, TextField } from '@mui/material';
import { composerize } from 'composerize-ts';
import { Button, MenuItem, Select, Stack, TextField } from '@mui/material';
import Composerize from 'composerize';

import React, { useState } from 'react';

const DockerRunToDockerCompose: React.FC = () => {
const [dockerRun, setDockerRun] = useState<string>(
'docker run -p 8080:80 -d --name myapp nginx'
);
const [version, setVersion] = useState<'v2x' | 'v3x'>('v2x');
const [dockerCompose, setDockerCompose] = useState<string>('');
const conversionResult = () => {
const res = composerize(dockerRun.trim()).yaml;
if (!dockerRun.trim()) return;
const res = Composerize(dockerRun.trim(), null, version);
setDockerCompose(res);
};
const handleSaveFile = () => {
Expand Down Expand Up @@ -64,6 +67,19 @@ const DockerRunToDockerCompose: React.FC = () => {
>
导出 YAML
</Button>
<Select
sx={{ width: '100px', flexGrow: '0!important' }}
value={version}
label='Version'
onChange={(v) => setVersion(v.target.value as 'v2x' | 'v3x')}
>
<MenuItem key='v2x' value='v2x'>
v2x
</MenuItem>
<MenuItem key='v3x' value='v3x'>
v3x
</MenuItem>
</Select>
</Stack>
<TextField multiline variant='filled' value={dockerCompose} />
</ToolsForm>
Expand Down
Loading

0 comments on commit ea4ba13

Please sign in to comment.