Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fileignoreconfig:
ignore_detectors:
- filecontent
- filename: package-lock.json
checksum: 3b95f4f64329f55ad5364b0468ca2d7d7337cfbb97b42db4929c894d7bd44a27
checksum: 29476e419f64cdf5cb6a41033148dae3eaacde840e0da8fdcf3690cf59b31899
- filename: src/entry-editable.ts
checksum: 3ba7af9ed1c1adef2e2bd5610099716562bebb8ba750d4b41ddda99fc9eaf115
- filename: .husky/pre-commit
Expand All @@ -14,3 +14,9 @@ fileignoreconfig:
checksum: d455330cc4f9306889fb299171364a37ad2c3bafe1fbd334033edc94f21694a6
- filename: package.json
checksum: 033eb21070795be5b426183f52d784347110fcb724bc9f8d63f94898ac5f0086
- filename: src/Models/metadata-model.ts
checksum: a101e109db1ec6ee0cb16a116f9b099e547c3104881e4fa1eaef2849e2d0aaf0
- filename: src/json-to-html.ts
checksum: a843710fc9f54bf4c7996f39561dc66491d62a9d9eeca50fa2c7c37bd6141f53
- filename: src/render-embedded-objects.ts
checksum: 35d56d4f7b625611fef18414fccdbff014c1d90d02e17eb0efa4d6166b73e23b
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [1.7.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.7.0)
- Added option in addTags to disable lowercasing of locale

## [1.6.3](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.6.3)
- Refactor: Simplified endpoints.ts to use compile-time JSON import instead of runtime file loading
- Build: Updated build process to download regions.json to src/assets directory
Expand Down
120 changes: 120 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Contributing to Contentstack Utils JavaScript

Thank you for your interest in contributing to Contentstack Utils JavaScript. This document provides guidelines and instructions for contributing.

## Pull Request Target Branch

**All pull requests must be raised against the `development` branch.**

Do not open PRs against `master` or `staging`. Create your feature or fix branch from `development`, and open your PR to merge into `development`. Maintainers will handle promotion to other branches after review.

## Getting Started

### Prerequisites

- **Node.js** 10 or later
- **npm** (comes with Node.js)
- **Git**

### Development Setup

1. **Fork the repository** on GitHub and clone your fork locally:

```bash
git clone https://github.com/YOUR_USERNAME/contentstack-utils-javascript.git
cd contentstack-utils-javascript
```

2. **Add the upstream remote** (optional, for syncing with the main repo):

```bash
git remote add upstream https://github.com/contentstack/contentstack-utils-javascript.git
```

3. **Create a branch from `development`** for your work:

```bash
git fetch upstream
git checkout development
git pull upstream development
git checkout -b your-feature-or-fix-name
```

4. **Install dependencies:**

```bash
npm install
```

5. **Build the project:**

```bash
npm run build
```

## Development Workflow

### Running Tests

- Run the full test suite: `npm test`
- Run tests in watch mode (for development): `npm run test:debug`

All tests must pass before submitting a PR. New features and bug fixes should include or update tests as appropriate.

### Code Style

- **ESLint:** The project uses ESLint. Fix auto-fixable issues with your editor or by running the linter.
- **Prettier:** Code is formatted with Prettier. Use `npm run format` to format `src/**/*.ts`.

Ensure your code adheres to the existing style so that CI and pre-commit checks pass.

### Commit Messages

This project uses [Conventional Commits](https://www.conventionalcommits.org/) enforced by Commitlint.

- Use a **type** and a **short subject** (e.g. `feat: add jsonToHTML option`, `fix: handle empty nodes`).
- Allowed types include: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`, `sample`.
- Subject should be lowercase, imperative, and not end with a period.
- Add a blank line and a longer body when the change needs more explanation.

Husky runs a commit-msg hook to validate commit messages. Invalid messages will be rejected.

### Pre-commit Hooks

Husky is used for Git hooks. Before each commit, the pre-commit hook runs. Ensure your working tree is clean and that tests and lint pass locally to avoid failed commits.

## Submitting Changes

1. **Keep your branch up to date** with `development`:

```bash
git fetch upstream
git rebase upstream/development
```

2. **Open a Pull Request** against the **`development`** branch (not `master` or `staging`).

3. **Fill out the PR template** (if one exists) and provide:
- A clear title and description of the change
- Link to any related issue
- Summary of testing done

4. **Address review feedback** promptly. Maintainers may request changes before merging.

5. **Do not force-push** after review has started unless the maintainer asks you to; use new commits for updates when possible so review history is preserved.

## Reporting Issues

- Use the GitHub issue tracker for bugs and feature requests.
- Search existing issues first to avoid duplicates.
- Include steps to reproduce for bugs, and your environment (Node version, OS).
- For security issues, see [SECURITY.md](SECURITY.md).

## Additional Resources

- [README](README.md) – Project overview and usage
- [CHANGELOG](CHANGELOG.md) – Version history and changes
- [SECURITY](SECURITY.md) – Security and vulnerability reporting
- [CODEOWNERS](CODEOWNERS) – Code ownership and review expectations

Thank you for contributing.
13 changes: 6 additions & 7 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
The MIT License (MIT)
MIT License


Copyright (c) 2016-2025 Contentstack
Copyright (c) 2016-2026 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -10,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions __test__/entry-editable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,4 +519,45 @@ describe('Entry editable test', () => {
})
})

describe('useLowerCaseLocale option', () => {
it('should preserve locale casing when useLowerCaseLocale is false', done => {
const entry = {
"uid": "test_uid",
"locale": "en-US",
"title": "Test Entry"
}

addTags(entry, 'test_content_type', false, 'en-US', { useLowerCaseLocale: false })

expect((entry as any)['$']['title']).toEqual('data-cslp=test_content_type.test_uid.en-US.title')
done()
})

it('should lowercase locale when useLowerCaseLocale is explicitly true', done => {
const entry = {
"uid": "test_uid",
"locale": "en-US",
"title": "Test Entry"
}

addTags(entry, 'test_content_type', false, 'en-US', { useLowerCaseLocale: true })

expect((entry as any)['$']['title']).toEqual('data-cslp=test_content_type.test_uid.en-us.title')
done()
})

it('should lowercase locale by default when options is not provided', done => {
const entry = {
"uid": "test_uid",
"locale": "en-US",
"title": "Test Entry"
}

addTags(entry, 'test_content_type', false, 'en-US')

expect((entry as any)['$']['title']).toEqual('data-cslp=test_content_type.test_uid.en-us.title')
done()
})
})

})
Loading
Loading