mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-11 00:21:29 -04:00
Integrate composerize (https://github.com/magicmark/composerize) into it-tools
This commit is contained in:
parent
f512d09227
commit
efb78da456
6 changed files with 135 additions and 16 deletions
4
src/tools/docker-to-docker-compose/composerize.d.ts
vendored
Normal file
4
src/tools/docker-to-docker-compose/composerize.d.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
declare module 'composerize' {
|
||||
const composerize: function;
|
||||
export default composerize;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<template>
|
||||
<n-card>
|
||||
<n-input
|
||||
v-model:value="dockerRun"
|
||||
style="font-family: monospace"
|
||||
type="textarea"
|
||||
placeholder="Your docker run command to convert..."
|
||||
rows="3"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<n-input
|
||||
style="font-family: monospace"
|
||||
:value="dockerCompose"
|
||||
type="textarea"
|
||||
placeholder="Converted to docker-compose file"
|
||||
:autosize="{ minRows: 1 }"
|
||||
readonly
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<br />
|
||||
<br />
|
||||
<n-space justify="center">
|
||||
<n-button secondary autofocus @click="copy"> Copy </n-button>
|
||||
<n-button :disabled="dockerCompose === ''" secondary @click="downloadFile()"> Download file </n-button>
|
||||
</n-space>
|
||||
</n-card>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||
import { textToBase64 } from '@/utils/base64';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import composerize from 'composerize';
|
||||
|
||||
const dockerRun = ref(
|
||||
'docker run -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --restart always --log-opt max-size=1g nginx',
|
||||
);
|
||||
const dockerCompose = ref('');
|
||||
const dockerComposeBase64 = computed(() => 'data:application/yaml;base64,' + textToBase64(dockerCompose.value));
|
||||
const { copy } = useCopy({ source: dockerCompose, text: 'docker-compose copied to the clipboard' });
|
||||
const { download } = useDownloadFileFromBase64({ source: dockerComposeBase64, filename: 'docker-compose.yml' });
|
||||
|
||||
function downloadFile() {
|
||||
if (dockerCompose.value === '') return;
|
||||
try {
|
||||
//dockerComposeBase64 = 'data:application/yaml;base64,' + dockerComposeBase64.value;
|
||||
download();
|
||||
} catch (_) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
watch([dockerRun], convertToCompose, { immediate: true });
|
||||
|
||||
function convertToCompose() {
|
||||
dockerCompose.value = composerize(dockerRun.value);
|
||||
}
|
||||
</script>
|
11
src/tools/docker-to-docker-compose/index.ts
Normal file
11
src/tools/docker-to-docker-compose/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { BrandDocker } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Composerize',
|
||||
path: '/docker-to-docker-compose',
|
||||
description: 'Turns docker run commands into docker-compose files!',
|
||||
keywords: ['docker', 'to', 'docker', 'compose'],
|
||||
component: () => import('./docker-to-docker-compose.vue'),
|
||||
icon: BrandDocker,
|
||||
});
|
|
@ -1,6 +1,7 @@
|
|||
import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as dockerToDockerCompose } from './docker-to-docker-compose';
|
||||
import { tool as htmlWysiwygEditor } from './html-wysiwyg-editor';
|
||||
import { tool as rsaKeyPairGenerator } from './rsa-key-pair-generator';
|
||||
import { tool as textToNatoAlphabet } from './text-to-nato-alphabet';
|
||||
|
@ -84,7 +85,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||
},
|
||||
{
|
||||
name: 'Development',
|
||||
components: [gitMemo, randomPortGenerator, crontabGenerator, jsonViewer, jsonMinify, sqlPrettify, chmodCalculator],
|
||||
components: [gitMemo, randomPortGenerator, crontabGenerator, jsonViewer, jsonMinify, sqlPrettify, chmodCalculator, dockerToDockerCompose],
|
||||
},
|
||||
{
|
||||
name: 'Math',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue