cm-utilities-cjs
v2.0.0
Published
Internal utilities for CM projects created with npm
Downloads
176
Maintainers
Readme
CM Utilities
Internal utilities for CM projects created with npm using ESM and CJS modules.
You can check the npm page for ESM modules library and the npm page for CJS modules library.
| Type | Package | |-------------|------------------------------------------------------------------------------------------------------------| | ESM modules | | | CJS modules | |
Installation
npm install --save-dev cm-utilities
or npm install --save-dev cm-utilities-cjs
Usage
First, import the functions from ESM modules you will need:
import {end, readBranch, readCommitSHA1, readVersion} from 'cm-utilities';
Or, import the functions from CJS modules you will need:
const {end, readBranch, readCommitSHA1, readVersion} = require('cm-utilities');
Then, use them in your different scripts according to the needs of your project.
Functions
These are the different functions that you can use from this library:
| Method | Description |
|-----------------------|---------------------------------------------------------------------------------------------------------------------|
| bytesToHuman | Allows bytes to be displayed in a human readable form |
| calculateNextVersion | Allows you to calculate the next semantic version |
| calculateSHA1 | Allows you to calculate the SHA-1 value of a file |
| end | Allows you to calculate the time spent receiving the start |
| generateTimestamp | Allows you to generate a timestamp from the current date |
| generateVersionCode | It allows you to generate the version code (consecutive integer) for an Android application |
| generateVersionName | Allows you to generate the version name (version text) for an Android application |
| isoToUnixTime | Allows you to convert a date in ISO format to unix time |
| joinUnix | Allows you to convert the folder separator according to the operating system |
| localHour | Allows you to get the local time in [hh:mm:ss.sss]
format if you are not in a Cloudflare Pages or Vercel pipeline |
| log | Allows printing in console |
| parseUnixPath | Allows you to convert path separators to Unix format |
| printFilesize | Prints the size of a file in a human readable form |
| printJSON | Formats a JSON text string in a more readable way |
| printJSONObject | Formats a JSON object in a more readable way |
| readAppChanges | Allows you to read the application changes from the environment variables that correspond to each language |
| readBranch | Allows you to read the current branch in which this method is being executed |
| readRevision | Allows you to read the SHA1 of the current commit in which this method is being executed |
| readVersion | Allows reading the VERSION file in the root of the project |
| readVersionWithSuffix | Allows you to read the VERSION file in the root of the project by adding the suffix according to the current branch |
| sendBackup | Allows you to register a new backup in CM Control |
| sendDeployment | Allows you to register a new deployment in CM Control |
| sendPOST | Allows you to make a POST type HTTP request |
| unixTime | Allows you to obtain the current unix time |
| validateFile | Allows you to validate if a file exists and is readable |
| writeVersion | Allows writing to the VERSION file in the root of the project |
Release history & changelog
See the Releases page for a list of all releases, including changes.
Help / Support
If you run into any issues, please email me at [email protected], or you can use the contact form in my page.
For bug reports, please open an issue on GitHub.
Contributing
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature
). - Commit your changes (
git commit -am 'Added some feature'
). - Push to the branch (
git push origin my-new-feature
). - Create a new pull request to develop branch.