Skip to content

Commit

Permalink
fix: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
iib0011 committed Feb 23, 2025
1 parent 70ad843 commit 97b940a
Show file tree
Hide file tree
Showing 13 changed files with 281 additions and 150 deletions.
44 changes: 29 additions & 15 deletions .idea/workspace.xml

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

52 changes: 37 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# OmniTools
<p align="center"><img src="src/assets/logo.png" width="80"></p>
<h1 align="center">OmniTools</h1>

Welcome to **OmniTools**, a self-hosted alternative to PineTools.com.
[//]: # ([![Docker Pulls]&#40;https://img.shields.io/docker/pulls/iib0011/omni-tools&#41;]&#40;https://hub.docker.com/r/iib0011/omni-tools&#41;)

This project offers a variety of online tools to help with everyday tasks,
all available for free and open for community contributions. Whether you are manipulating images, crunching numbers, or coding, OmniTools has you covered. Please don't forget to star the
[![Discord](https://img.shields.io/discord/1342971141823664179?label=Discord)](https://discord.gg/SDbbn3hT4b)

Welcome to OmniTools, a self-hosted platform offering a variety of online tools to simplify everyday tasks.
Whether you are manipulating images, crunching numbers, or
coding, OmniTools has you covered. Please don't forget to star the
repo to support us.
Here is the [demo](https://omnitools.netlify.app/) website.

Expand All @@ -19,27 +23,43 @@ Here is the [demo](https://omnitools.netlify.app/) website.

## Features

OmniTools includes a variety of tools, such as:
We strive to offer a variety of tools, including:

## **Image/Video/Binary Tools**

1. **Image/Video/Binary tools**
- Image Resizer
- Image Converter
- Video Trimmer
- Video Reverser
- And more...

- Image Resizer, Image converter, Video trimmer, video reverser, etc.
## **String/List Tools**

2. **Math tools**
- Case Converters
- List Shuffler
- Text Formatters
- And more...

- Generate prime numbers, generate perfect numbers etc.
## **Date and Time Tools**

3. **String/List Tools**
- Date Calculators
- Time Zone Converters
- And more...

- Case converters, shuffle list, text formatters, etc.
## **Math Tools**

4. **Date and Time Tools**
- Generate Prime Numbers
- Generate Perfect Numbers
- And more...

- Date calculators, time zone converters, etc.
## **Miscellaneous Tools**

5. **Miscellaneous Tools**
- JSON Tools
- XML Tools
- CSV Tools
- And more...

- JSON, XML tools, CSV tools etc.
Stay tuned as we continue to expand and improve our collection!

## Self-host/Run

Expand All @@ -49,6 +69,8 @@ docker run -d --name omni-tools --restart unless-stopped -p 8080:80 iib0011/omni

## Contribute

This is a React Project with Typescript Material UI.

### Project setup

```bash
Expand Down
16 changes: 16 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@hugeicons/core-free-icons": "^1.0.10",
"@hugeicons/react": "^1.0.3",
"@mui/icons-material": "^5.15.20",
"@mui/material": "^5.15.20",
"@playwright/test": "^1.45.0",
Expand Down
106 changes: 62 additions & 44 deletions scripts/create-tool.mjs
Original file line number Diff line number Diff line change
@@ -1,59 +1,75 @@
import { readFile, writeFile } from 'fs/promises'
import fs from 'fs'
import { dirname, join, sep } from 'path'
import { fileURLToPath } from 'url'

const currentDirname = dirname(fileURLToPath(import.meta.url))

const toolName = process.argv[2]
const folder = process.argv[3]

const toolsDir = join(currentDirname, '..', 'src', 'pages', folder ?? '')
import { readFile, writeFile } from 'fs/promises';
import fs from 'fs';
import { dirname, join, sep } from 'path';
import { fileURLToPath } from 'url';

const currentDirname = dirname(fileURLToPath(import.meta.url));

const toolName = process.argv[2];
const folder = process.argv[3];

const toolsDir = join(
currentDirname,
'..',
'src',
'pages',
'tools',
folder ?? ''
);
if (!toolName) {
throw new Error('Please specify a toolname.')
throw new Error('Please specify a toolname.');
}

function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1)
return string.charAt(0).toUpperCase() + string.slice(1);
}

function createFolderStructure(basePath, foldersToCreateIndexCount) {
const folderArray = basePath.split(sep)
const folderArray = basePath.split(sep);

function recursiveCreate(currentBase, index) {
if (index >= folderArray.length) {
return
return;
}
const currentPath = join(currentBase, folderArray[index])
const currentPath = join(currentBase, folderArray[index]);
if (!fs.existsSync(currentPath)) {
fs.mkdirSync(currentPath, { recursive: true })
fs.mkdirSync(currentPath, { recursive: true });
}
const indexPath = join(currentPath, 'index.ts')
if (!fs.existsSync(indexPath) && index < folderArray.length - 1 && index >= folderArray.length - 1 - foldersToCreateIndexCount) {
fs.writeFileSync(indexPath, `export const ${currentPath.split(sep)[currentPath.split(sep).length - 1]}Tools = [];\n`)
console.log(`File created: ${indexPath}`)
const indexPath = join(currentPath, 'index.ts');
if (
!fs.existsSync(indexPath) &&
index < folderArray.length - 1 &&
index >= folderArray.length - 1 - foldersToCreateIndexCount
) {
fs.writeFileSync(
indexPath,
`export const ${
currentPath.split(sep)[currentPath.split(sep).length - 1]
}Tools = [];\n`
);
console.log(`File created: ${indexPath}`);
}
// Recursively create the next folder
recursiveCreate(currentPath, index + 1)
recursiveCreate(currentPath, index + 1);
}

// Start the recursive folder creation
recursiveCreate('.', 0)
recursiveCreate('.', 0);
}

const toolNameCamelCase = toolName.replace(/-./g, (x) => x[1].toUpperCase())
const toolNameCamelCase = toolName.replace(/-./g, (x) => x[1].toUpperCase());
const toolNameTitleCase =
toolName[0].toUpperCase() + toolName.slice(1).replace(/-/g, ' ')
const toolDir = join(toolsDir, toolName)
const type = folder.split(sep)[folder.split(sep).length - 1]
await createFolderStructure(toolDir, folder.split(sep).length)
console.log(`Directory created: ${toolDir}`)
toolName[0].toUpperCase() + toolName.slice(1).replace(/-/g, ' ');
const toolDir = join(toolsDir, toolName);
const type = folder.split(sep)[folder.split(sep).length - 1];
await createFolderStructure(toolDir, folder.split(sep).length);
console.log(`Directory created: ${toolDir}`);

const createToolFile = async (name, content) => {
const filePath = join(toolDir, name)
await writeFile(filePath, content.trim())
console.log(`File created: ${filePath}`)
}
const filePath = join(toolDir, name);
await writeFile(filePath, content.trim());
console.log(`File created: ${filePath}`);
};

createToolFile(
`index.tsx`,
Expand All @@ -70,7 +86,7 @@ export default function ${capitalizeFirstLetter(toolNameCamelCase)}() {
return <Box>Lorem ipsum</Box>;
}
`
)
);
createToolFile(
`meta.ts`,
`
Expand All @@ -84,13 +100,13 @@ export const tool = defineTool('${type}', {
// image,
description: '',
shortDescription: '',
keywords: ['${toolName.split('-').join('\', \'')}'],
keywords: ['${toolName.split('-').join("', '")}'],
component: lazy(() => import('./index'))
});
`
)
);

createToolFile(`service.ts`, ``)
createToolFile(`service.ts`, ``);
createToolFile(
`${toolName}.service.test.ts`,
`
Expand All @@ -101,7 +117,7 @@ import { expect, describe, it } from 'vitest';
//
// })
`
)
);

// createToolFile(
// `${toolName}.e2e.spec.ts`,
Expand All @@ -125,15 +141,17 @@ import { expect, describe, it } from 'vitest';
// `
// )

const toolsIndex = join(toolsDir, 'index.ts')
const toolsIndex = join(toolsDir, 'index.ts');
const indexContent = await readFile(toolsIndex, { encoding: 'utf-8' }).then(
(r) => r.split('\n')
)
);

indexContent.splice(
0,
0,
`import { tool as ${type}${capitalizeFirstLetter(toolNameCamelCase)} } from './${toolName}/meta';`
)
writeFile(toolsIndex, indexContent.join('\n'))
console.log(`Added import in: ${toolsIndex}`)
`import { tool as ${type}${capitalizeFirstLetter(
toolNameCamelCase
)} } from './${toolName}/meta';`
);
writeFile(toolsIndex, indexContent.join('\n'));
console.log(`Added import in: ${toolsIndex}`);
Binary file added src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 97b940a

Please sign in to comment.