# codepolish

> Beautify your code, Elevate your projects

Latest version **1.0.15** (published 2024-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install codepolish
pnpm add codepolish
yarn add codepolish
bun add codepolish
```

Provides the command `beautifyJSON`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2024-03-08 |
| First published | 2024-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 674.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ankit Guria |
| Maintainers | ankitguria142 |
| Keywords | beautify, HTML, Javascript, JSON, Python, YAML, cli, front-end, coloredcli, CLI, command line, linters, jslint, terminal, shell, log, console, backend |

## Links

- npm: https://www.npmjs.com/package/codepolish
- Repository: https://github.com/ankit142/CodePolish
- Homepage: https://github.com/ankit142/CodePolish#readme
- Issues: https://github.com/ankit142/CodePolish/issues
- Funding: https://github.com/sponsors/ankit142
- npm.io page: https://npm.io/package/codepolish

## Dependencies (3)

- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [require](https://npm.io/package/require.md) ^2.4.20
- [codepolish](https://npm.io/package/codepolish.md) ^1.0.12

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.15 (latest) — 2024-03-08
- 1.0.14 — 2024-03-07
- 1.0.13 — 2024-03-07
- 1.0.12 — 2024-03-07
- 1.0.11 — 2024-03-07
- 1.0.10 — 2024-03-07
- 1.0.9 — 2024-03-07
- 1.0.8 — 2024-03-07
- 1.0.7 — 2024-03-07
- 1.0.6 — 2024-03-07
- 1.0.5 — 2024-03-07
- 1.0.4 — 2024-03-07
- 1.0.3 — 2024-03-07
- 1.0.2 — 2024-03-07
- 1.0.1 — 2024-03-07
- … 1 more at https://npm.io/package/codepolish/versions

## README

<h1 align="center">
	<br>
	<br>
	<img width="320" src="https://github.com/ankit142/CodePolish/blob/main/media/CodePolishLogo.png" alt="CodePolish">
	<br>
	<br>
	<br>
</h1>

# CodePolish.js

<h3 align = "center">
Beautify your code, Elevate your projects
</h3>
A npm package written on node to beautify your code be it any tech specific, be it JSON, JS, YAML, Python or JAVA extension files.

# Installation
You can install CodePolish using:

`npm i codepolish`

or

`npm install codepolish`

# Usage

# Basic Usage 

Now, let's say we have a file: sample.js

```javascript
// sample.js
function greet(name) {
return `Hello, ${name}!`;
}console.log(greet('Ankit Guria'));
```

Some dependencies maybe required, like:

`npm install yaml`

As the package also supports .yaml files.
Now just head to the directory of this file and run this command on the console:

`node -e "require('codepolish').beautifyJS('sample.js')"`

Similarly, a sample.json

```JSON
// sample.json
{"name":"Ankit Guria","age":25,"city":"India"}
```
Now just head to the console:

`node -e "require('codepolish').beautifyJSON('sample.json')"`

And the below screenshot can be seen as it is on the console:

![consoleprompt](https://github.com/ankit142/CodePolish/blob/main/media/consoleprompt.png)

# (Examples)

# Test1: Playing with Python files, beautifying .py

![OutputImage1](https://github.com/ankit142/CodePolish/blob/main/media/earlierPY.png)


`node -e "require('codepolish').beautifyPython('sample.py')"`

# Output:

![OutputImage12](https://github.com/ankit142/CodePolish/blob/main/media/formattedPY.png)

# Test2: Playing with JS files, beautifying .js

![OutputImage1](https://github.com/ankit142/CodePolish/blob/main/media/earlierJS.png)

`node -e "require('codepolish').beautifyJS('sample.js')"`

# Output:

![OutputImage12](https://github.com/ankit142/CodePolish/blob/main/media/formattedJS.png)

# Test3: Playing with JAVA files, beautifying .java

![OutputImage1](https://github.com/ankit142/CodePolish/blob/main/media/earlierJAVA.png)

`node -e "require('codepolish').beautifyJava('sample.java')"`

# Output:

![OutputImage12](https://github.com/ankit142/CodePolish/blob/main/media/formattedJAVA.png)

# Test4: Playing with JSONs, beautifying JSON Linters

![OutputImage1](https://github.com/ankit142/CodePolish/blob/main/media/earlierJSON.png)

`node -e "require('codepolish').beautifyJSON('sample.json')"`

# Output:

![OutputImage12](https://github.com/ankit142/CodePolish/blob/main/media/formattedJSON.png)


# Dependencies

`npm install require `
and 
`npm install js-yaml `

# Steps for a layman(Playground)
1. Create a new project: 

`npm init`

This command will create a package.json dependencies for your test file.

```json
// package.json
{
  "name": "codepolish",
  "version": "1.0.2",
  "description": "Beautify your code, Elevate your projects",
  "main": "index.cjs",
  "type": "commonjs",
  "directories": {
    "lib": "lib"
  },
  "scripts": {
    "test": "node --experimental-modules test.cjs  "
  },
  "funding": {
    "type": "individual",
    "url": "https://github.com/sponsors/ankit142"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/ankit142/CodePolish.git"
  },
  "bugs": {
    "url": "https://github.com/ankit142/CodePolish/issues"
  },
  "homepage": "https://github.com/ankit142/CodePolish#readme",
  "author": "Ankit Guria",
  "license": "MIT",
  "dependencies": {
    "js-yaml": "^4.1.0",
    "require": "^2.4.20"
  }
}

```

2. A new file like - "test.cjs" to be created. 
Here is the sample code:
```javascript
// test.cjs
const { beautifyJSON, beautifyYAML, beautifyJS, beautifyPython, beautifyJava } = require('./index.cjs');


// Paths to the unformatted example files
const filePathJSON = './test/example.json';
const filePathYAML = './test/example.yaml';
const filePathJS = './test/example.js';
const filePathPython = './test/example.py';
const filePathJava = './test/example.java';

// Test beautify functions
beautifyJSON(filePathJSON);
beautifyYAML(filePathYAML);
beautifyJS(filePathJS);
beautifyPython(filePathPython);
beautifyJava(filePathJava);

console.log('Beautification completed successfully!');

```
3. Now run this file, and here you go.
`node --experimental-modules test.cjs`

4. Play and enjoy more with custom console log statements or something else.
The output should be something like this: 

![OutputImage13](https://github.com/ankit142/CodePolish/blob/main/media/output.png)
# Contributing
Feel free to contribute by opening issues or submitting pull requests on [GitHub](https://github.com/ankit142/CodePolish).

# License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/ankit142/CodePolish/blob/main/LICENSE) file for details.

---
_Source: https://npm.io/package/codepolish · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
