{"id":17609615,"url":"https://github.com/vitaly-t/pg-minify","last_synced_at":"2025-05-16T11:05:11.529Z","repository":{"id":57322599,"uuid":"49945459","full_name":"vitaly-t/pg-minify","owner":"vitaly-t","description":"Minifies PostgreSQL scripts.","archived":false,"fork":false,"pushed_at":"2025-03-09T22:22:47.000Z","size":117,"stargazers_count":53,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T02:09:48.368Z","etag":null,"topics":["comment","minify","postgresql","sql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitaly-t.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-19T10:34:39.000Z","updated_at":"2025-05-06T12:01:26.000Z","dependencies_parsed_at":"2024-06-18T15:29:22.313Z","dependency_job_id":"785dc225-cbe0-49e0-941c-e8ab776f85b8","html_url":"https://github.com/vitaly-t/pg-minify","commit_stats":{"total_commits":134,"total_committers":5,"mean_commits":26.8,"dds":"0.19402985074626866","last_synced_commit":"1c9ae2c61263c09fac5ad50e05b51691f88d7634"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fpg-minify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fpg-minify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fpg-minify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fpg-minify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitaly-t","download_url":"https://codeload.github.com/vitaly-t/pg-minify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comment","minify","postgresql","sql"],"created_at":"2024-10-22T17:09:20.651Z","updated_at":"2025-05-16T11:05:06.519Z","avatar_url":"https://github.com/vitaly-t.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"pg-minify\n=========\n\n[![Build Status](https://github.com/vitaly-t/pg-minify/actions/workflows/ci.yml/badge.svg)](https://github.com/vitaly-t/pg-minify/actions/workflows/ci.yml)\n[![Node Version](https://img.shields.io/badge/nodejs-14%20--%2022-green.svg?logo=node.js\u0026style=flat)](https://nodejs.org)\n\nMinifies PostgreSQL scripts, reducing the IO usage.\n\n**Features:**\n\n* Removes `/*multi-line*/` (including nested) and `--single-line` comments\n* Preserves special/copyright multi-line comments that start with `/*!`\n* Concatenates multi-line strings into a single line with `\\n`\n* Fixes multi-line text, prefixing it with `E` where needed\n* Removes redundant line gaps: line breaks, tabs and spaces\n* Provides basic parsing and error detection for invalid SQL\n* Flattens the resulting script into a single line\n* Optionally, compresses SQL for minimum space \n\n## Installing\n\n```\n$ npm install pg-minify\n```\n\n## Usage\n\n```js\nconst minify = require('pg-minify');\n\nconst sql = 'SELECT 1; -- comments';\n\nminify(sql); //=\u003e SELECT 1;\n```\n\nwith compression (removes all unnecessary spaces):\n\n```js\nconst sql = 'SELECT * FROM \"table\" WHERE col = 123; -- comments';\n\nminify(sql, {compress: true});\n//=\u003e SELECT*FROM\"table\"WHERE col=123;\n```\n\nThe library's distribution includes [TypeScript] declarations.\n\n## Error Handling\n\n[SQLParsingError] is thrown on failed SQL parsing:\n\n```js\ntry {\n    minify('SELECT \\'1');\n} catch (error) {\n    // error is minify.SQLParsingError instance\n    // error.message:\n    // Error parsing SQL at {line:1,col:8}: Unclosed text block.\n}\n```\n\n## API\n\n### minify(sql, [options]) ⇒ String\n\nMinifies SQL into a single line, according to the `options`.\n\n##### options.compress ⇒ Boolean\n\nCompresses / uglifies the SQL to its bare minimum, by removing all unnecessary spaces.\n\n* `false (default)` - keeps minimum spaces, for easier read\n* `true` - removes all unnecessary spaces \n\nSee also: [SQL Compression].\n\n##### options.removeAll ⇒ Boolean\n\nRemoves everything, i.e. special/copyright multi-line comments that start with `/*!` will be removed as well.\n\n## Limitations\n\nDouble-dollar `$$` string escaping, which avoids escaping single quotes, is not supported.\nSee [#12](https://github.com/vitaly-t/pg-minify/issues/12).\n\n## License\n\nCopyright © 2025 [Vitaly Tomilov](https://github.com/vitaly-t);\nReleased under the MIT license.\n\n[SQLParsingError]:https://github.com/vitaly-t/pg-minify/blob/master/lib/error.js#L22\n[TypeScript]:https://github.com/vitaly-t/pg-minify/tree/master/typescript\n[SQL Compression]:https://github.com/vitaly-t/pg-minify/wiki/SQL-Compression\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitaly-t%2Fpg-minify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitaly-t%2Fpg-minify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitaly-t%2Fpg-minify/lists"}