Skip to content

Commit

Permalink
begin reffactoring folder structure so i can see whats happening
Browse files Browse the repository at this point in the history
  • Loading branch information
lancejpollard committed Jan 19, 2024
1 parent 28bc35a commit 7670fae
Show file tree
Hide file tree
Showing 95 changed files with 2,677 additions and 2,743 deletions.
6 changes: 3 additions & 3 deletions code/cli/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
convert_font_with_font_forge,
convert_image_with_image_magick,
convert_video_with_ffmpeg,
} from '../shared/type/source/index.js'
} from '../shared/source/index.js'
import { Form } from '@termsurf/form'
import {
FormatRustModel,
Expand All @@ -43,7 +43,7 @@ import {
useConvertFontWithFontForge,
useConvertImageWithImageMagick,
useConvertVideoWithFfmpeg,
} from '../node/call/convert.js'
} from '../node/action/convert.js'
import {
logOutput,
logOutputError,
Expand All @@ -58,7 +58,7 @@ import {
} from './parse.js'
import { formatRust } from '../node/code.js'
import { inspectSystem } from '../node/system.js'
import { compile, compileInternal } from '../node/call/compile.js'
import { compile, compileInternal } from '../node/action/compile.js'

export const CONVERT_KEY: Record<string, Link> = {
i: { line: ['input', 'file', 'path'] },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion code/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export * from './archive.js'
export * from './font.js'
export * from './net.js'

export * from './call/convert.js'
export * from './action/convert.js'
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
6 changes: 3 additions & 3 deletions code/shared/archive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getCommand } from '../shared/index.js'
import {
ArchiveWithRar,
CompressWithZip,
ArchiveWithZip,
ConvertArchive,
DecompressWith7Z,
DecompressWithUnarchiver,
Expand Down Expand Up @@ -34,11 +34,11 @@ export function buildCommandToConvertArchive(input: ConvertArchive) {
}
return [
...buildCommandToDecompressWithUnarchiver(decompressInput),
...buildCommandToCompressWithZip(compressInput),
...buildCommandToArchiveWithZip(compressInput),
]
}

export function buildCommandToCompressWithZip(input: CompressWithZip) {
export function buildCommandToArchiveWithZip(input: ArchiveWithZip) {
const cmd = getCommand(`zip`)
cmd.list.push('-r', input.output.file.path, input.input.path)
return [cmd]
Expand Down
6 changes: 2 additions & 4 deletions code/shared/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import {
ConvertDocumentWithPandoc,
SanitizeHtmlFromContentModel,
ConvertLatexToPdfWithPdfLatex,
CheckIfPdfIsValidWithData,
ValidatePdfWithData,
SlicePdfWithData,
} from './type/index.js'
import { getCommand } from './command.js'

export async function checkIfPdfIsValidWithData(
input: CheckIfPdfIsValidWithData,
) {
export async function validatePdfWithData(input: ValidatePdfWithData) {
try {
await PDFDocument.load(input.input.file.data as ArrayBuffer)
return true
Expand Down
11 changes: 4 additions & 7 deletions code/shared/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {
IMAGE_MAGICK_COLOR_SPACE_CONTENT,
IMAGE_MAGICK_COMPRESSION_CONTENT,
ConvertImageWithImageMagick,
ExtractMetadataFromImage,
InspectMetadataFromImage,
WriteMetadataToImage,
RemoveImageMetadata,
GenerateGifWithGifsicle,
} from './type/index.js'
import { getCommand } from './command.js'
import _ from 'lodash'
Expand Down Expand Up @@ -99,8 +98,8 @@ export function buildCommandToConvertImageWithImageMagick(
return [cmd]
}

export function buildCommandToExtractMetadataFromImage(
input: ExtractMetadataFromImage,
export function buildCommandToInspectMetadataFromImage(
input: InspectMetadataFromImage,
) {
const cmd = getCommand('exiftool')
cmd.list.push(`"${input.input.file.path}"`)
Expand Down Expand Up @@ -239,9 +238,7 @@ export function buildCommandToRemoveImageMetadata(
// return [cmd]
// }

export function buildCommandToGenerateGifWithGifsicle(
input: GenerateGifWithGifsicle,
) {
export function buildCommandToGenerateGifWithGifsicle(input) {
const cmd = getCommand('gifsicle')

if (input.unoptimize) {
Expand Down
40 changes: 40 additions & 0 deletions code/shared/source/action/archive/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Form } from '@termsurf/form'

export const archive_with_rar: Form = {
form: 'form',
link: {
input: {
link: {
format: { like: 'string', name: { mark: 'I' } },
path: { like: 'string' },
},
},
output: {
link: {
format: { like: 'string', name: { mark: 'O' } },
file: {
link: { path: { like: 'string' } },
},
},
},
},
}

export const archive_with_zip: Form = {
form: 'form',
link: {
input: {
link: {
path: { like: 'string', name: { mark: 'i' } },
},
},
output: {
link: {
format: { like: 'string', name: { mark: 'O' } },
file: {
link: { path: { like: 'string', name: { mark: 'o' } } },
},
},
},
},
}
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions code/shared/source/action/convert/archive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Form } from '@termsurf/form'

export const convert_archive: Form = {
form: 'form',
link: {
temporary: {
link: {
directory: {
link: {
path: { like: 'string', name: { mark: 'm' } },
},
},
},
},
input: {
link: {
format: { like: 'unarchiver_format', name: { mark: 'I' } },
file: {
link: { path: { like: 'string' } },
},
},
},
output: {
link: {
format: { like: 'string', name: { mark: 'O' } },
file: {
link: { path: { like: 'string' } },
},
},
},
},
}
212 changes: 212 additions & 0 deletions code/shared/source/action/convert/document/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
import { Form } from '@termsurf/form'

export const convert_document_with_jupyter: Form = {
form: 'form',
link: {
input: {
link: {
format: { like: 'string', name: { mark: 'I' } },
file: {
link: {
path: { like: 'string' },
},
},
},
},
output: {
link: {
format: { like: 'string', name: { mark: 'O' } },
file: {
link: {
format: { like: 'string' },
},
},
},
},
},
}

export const convert_document_with_libre_office: Form = {
form: 'form',
link: {
input: {
link: {
format: {
like: 'libre_office_input_format',
name: { mark: 'I' },
},
file: {
link: {
path: { like: 'string', name: { mark: 'i' } },
},
},
},
},
output: {
link: {
format: {
like: 'libre_office_output_format',
name: { mark: 'O' },
},
directory: {
link: {
path: { like: 'string', name: { mark: 'b' } },
},
},
},
},
},
}

export const convert_latex_to_pdf_with_pdf_latex: Form = {
form: 'form',
link: {
input: {
link: {
format: { like: 'string', name: { mark: 'I' } },
file: {
link: {
path: { like: 'string' },
},
},
},
},
output: {
link: {
directory: {
link: {
path: { like: 'string' },
},
},
file: {
link: {
name: { like: 'string' },
},
},
},
},
},
}

export const convert_document_with_calibre: Form = {
form: 'form',
link: {
input: {
link: {
format: { like: 'calibre_input_format', name: { mark: 'I' } },
file: {
link: {
path: { like: 'string', name: { mark: 'i' } },
},
},
},
},
output: {
link: {
format: { like: 'calibre_output_format', name: { mark: 'O' } },
file: {
link: {
path: { like: 'string', name: { mark: 'o' } },
},
},
},
},
},
}

export const convert_html_to_pdf_with_puppeteer: Form = {
form: 'form',
link: {
input: {
link: {
format: { like: 'string', name: { mark: 'I' } },
file: {
link: {
path: { like: 'string' },
},
},
},
},
output: {
link: {
format: { like: 'string', name: { mark: 'O' } },
file: {
link: {
path: { like: 'string' },
},
},
},
},
viewport: {
link: {
width: { like: 'natural_number', need: false },
height: { like: 'natural_number', need: false },
},
},
proxy: { like: 'string', need: false },
waitUntil: { like: 'puppeteer_life_cycle_event', need: false },
},
}

export const convert_html_to_png_with_puppeteer: Form = {
form: 'form',
link: {
input: {
link: {
format: { like: 'string', name: { mark: 'I' } },
file: {
link: {
path: { like: 'string' },
},
},
},
},
output: {
link: {
format: { like: 'string', name: { mark: 'O' } },
file: {
link: {
path: { like: 'string' },
},
},
},
},
viewport: {
link: {
width: { like: 'natural_number', need: false },
height: { like: 'natural_number', need: false },
},
},
proxy: { like: 'string', need: false },
waitUntil: { like: 'puppeteer_life_cycle_event', need: false },
},
}

export const convert_document_with_pandoc: Form = {
form: 'form',
link: {
input: {
link: {
format: { like: 'pandoc_input_format', name: { mark: 'I' } },
file: {
link: {
path: { like: 'string', name: { mark: 'i' } },
},
},
},
},
output: {
link: {
file: {
link: {
path: { like: 'string', name: { mark: 'o' } },
},
},
format: {
like: 'pandoc_output_format',
name: { mark: 'O' },
},
},
},
},
}
Loading

0 comments on commit 7670fae

Please sign in to comment.