Skip to content

Commit

Permalink
move
Browse files Browse the repository at this point in the history
  • Loading branch information
lancejpollard committed Jan 14, 2024
1 parent 79762fc commit 96b42a1
Show file tree
Hide file tree
Showing 199 changed files with 51 additions and 48 deletions.
29 changes: 18 additions & 11 deletions code/browser/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,24 @@ export async function decompressArchive(compressed: Uint8Array) {
// unzipper.push(zipChunk2);
// unzipper.push(zipChunk3, true);

// zip(
// { f1: aMassiveFile, 'f2.txt': anotherMassiveFile },
// {
// // The options object is still optional, you can still do just
// // zip(archive, callback)
// level: 6,
// },
// (err, data) => {
// // Save the ZIP file
// },
// )
export async function createZip({ tree }) {
return new Promise((res, rej) => {
fflate.zip(
{},
// tree,{ f1: aMassiveFile, 'f2.txt': anotherMassiveFile }
{
level: 6,
},
(err, data) => {
// Save the ZIP file
if (err) {
return rej(err)
}
res(data)
},
)
})
}

// unzip(aMassiveZIPFile, (err, unzipped) => {
// // If the archive has data.xml, log it here
Expand Down
12 changes: 0 additions & 12 deletions code/shared/code.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
import { getCommand } from './command.js'
import {
BuildCommandToCompileC,
BuildCommandToCompileCModel,
BuildCommandToCompileCpp,
BuildCommandToCompileCppModel,
BuildCommandToCompileSwift,
BuildCommandToCompileSwiftModel,
BuildCommandToFormatAssembly,
BuildCommandToFormatAssemblyModel,
BuildCommandToFormatC,
BuildCommandToFormatCModel,
BuildCommandToFormatCodeWithClangModel,
BuildCommandToFormatCpp,
BuildCommandToFormatCppModel,
BuildCommandToFormatJava,
BuildCommandToFormatJavaModel,
BuildCommandToFormatKotlin,
BuildCommandToFormatKotlinModel,
BuildCommandToFormatPython,
BuildCommandToFormatPythonModel,
BuildCommandToFormatRuby,
BuildCommandToFormatRubyModel,
BuildCommandToFormatRust,
BuildCommandToFormatRustModel,
BuildCommandToFormatSwift,
BuildCommandToFormatSwiftModel,
} from './type/index.js'

Expand Down
6 changes: 1 addition & 5 deletions code/shared/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import { parse, Options } from 'csv-parse/browser/esm/sync'
import typeOf from 'type-detect'
import escapeSqlString from 'sql-escape-string'
import {
unflattenObject,
flattenObject,
flattenObjectSafe,
} from './object'
import { unflattenObject, flattenObjectSafe } from './object'
import _ from 'lodash'
import sortKeys from 'json-keys-sort'

Expand Down
22 changes: 5 additions & 17 deletions code/shared/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import path from 'path'
import { ChildProcessError, exec } from '../node/process.js'
import { YYYY_MM_DD_HH_MM_SS, toDayJs } from './date.js'
import {
BuildCommandToExtractMetadataFromImage,
BuildCommandToExtractMetadataFromImageModel,
BuildCommandToProcessImage,
BuildCommandToProcessImageModel,
BuildCommandToReplaceImageColorWithImageMagick,
BuildCommandToReplaceImageColorWithImageMagickModel,
BuildCommandToResizeImageWithImageMagick,
BuildCommandToResizeImageWithImageMagickModel,
IMAGE_MAGICK_COLOR_SPACE_CONTENT,
IMAGE_MAGICK_COMPRESSION_CONTENT,
Expand Down Expand Up @@ -135,17 +131,13 @@ export function buildCommandToProcessImage(source) {
return cmd
}

export function buildCommandToExtractMetadataFromImage(
source: BuildCommandToExtractMetadataFromImage,
) {
export function buildCommandToExtractMetadataFromImage(source) {
const { inputPath } =
BuildCommandToExtractMetadataFromImageModel.parse(source)
return ['exiftool', `"${inputPath}"`]
}

export function buildCommandToWriteMetadataToImage(
source: BuildCommandToExtractMetadataFromImage,
) {
export function buildCommandToWriteMetadataToImage(source) {
const {
inputPath,
copyright,
Expand Down Expand Up @@ -224,17 +216,15 @@ export function buildCommandToWriteMetadataToImage(
return cmd
}

export function buildCommandToRemoveImageMetadata(
source: BuildCommandToExtractMetadataFromImage,
) {
export function buildCommandToRemoveImageMetadata(source) {
const { inputPath } =
BuildCommandToExtractMetadataFromImageModel.parse(source)
const cmd = [`exiftool`, `-all=`, `"${inputPath}"`]
return cmd
}

export async function buildCommandToReplaceImageColorWithImageMagick(
source: BuildCommandToReplaceImageColorWithImageMagick,
source,
) {
const { inputPath, outputPath, startColor, endColor, fuzz } =
BuildCommandToReplaceImageColorWithImageMagickModel.parse(source)
Expand All @@ -249,9 +239,7 @@ export async function buildCommandToReplaceImageColorWithImageMagick(
return cmd
}

export async function buildCommandToResizeImageWithImageMagick(
source: BuildCommandToResizeImageWithImageMagick,
) {
export async function buildCommandToResizeImageWithImageMagick(source) {
const { inputPath, outputPath, width, height, stretch, gravity } =
BuildCommandToResizeImageWithImageMagickModel.parse(source)

Expand Down
22 changes: 22 additions & 0 deletions code/shared/type/source/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,25 @@ export const build_command_to_create_rar: Form = {
},
},
}

// https://github.com/ashang/unar/blob/master/README.md
export const unarchiver_format = {
form: 'hash',
bond: {
head: { like: 'string' },
},
hash: {
zip: { head: 'Zip' },
rar: { head: 'RAR' },
'7z': { head: '7z' },
tar: { head: 'Tar' },
gzip: { head: 'Gzip' },
bzip2: { head: 'Bzip2' },
lzma: { head: 'LZMA' },
cab: { head: 'CAB' },
msi: { head: 'MSI' },
nsis: { head: 'NSIS' },
exe: { head: 'EXE' },
iso: { head: 'ISO' },
},
}
Binary file removed test/data/image/favicon.ico
Binary file not shown.
3 changes: 0 additions & 3 deletions test/data/video/buck.320x180.mp4

This file was deleted.

Loading

0 comments on commit 96b42a1

Please sign in to comment.