Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
11c486c
Merge pull request #39 from contentstack/staging
aman19K Dec 18, 2023
ec216c8
added comment for the gcp-na cdn url
cs-raj Jan 10, 2024
8caf28a
Merge pull request #41 from contentstack/feat/CS-43274
cs-raj Jan 10, 2024
adc1b87
sca-scan.yml
aravindbuilt May 17, 2024
f2901a2
jira.yml
aravindbuilt May 17, 2024
c688f85
sast-scan.yml
aravindbuilt May 17, 2024
6f5018a
codeql-analysis.yml
aravindbuilt May 17, 2024
cfef3d5
sca-scan.yml
aravindbuilt Jan 20, 2025
589fa7d
jira.yml
aravindbuilt Jan 20, 2025
7d9f166
sast-scan.yml
aravindbuilt Jan 20, 2025
2474526
codeql-analysis.yml
aravindbuilt Jan 20, 2025
a5a1501
Updated codeowners
aravindbuilt Jan 20, 2025
8f33336
fix: update GitHub Actions to latest versions and update to node v22
harshithad0703 Feb 13, 2025
64ead70
chore: update datasync dependencies to latest versions
harshithad0703 Feb 14, 2025
e34bb2f
Merge pull request #45 from contentstack/fix/dx-2138-node-v22
harshithad0703 Feb 14, 2025
2ba666b
Merge branch 'master' into development
harshithad0703 Feb 14, 2025
e2b16f6
docs: update Node.js version requirement in README
harshithad0703 Feb 17, 2025
621f128
Merge pull request #47 from contentstack/fix/dx-2139-readme-update
harshithad0703 Feb 17, 2025
ecf0ca5
chore: update license year and bump version to 1.2.10
harshithad0703 Mar 4, 2025
9aeacd0
Merge pull request #48 from contentstack/fix/version-bump
harshithad0703 Mar 4, 2025
9ffcedb
feat: Added preserve and enabled checkpoint in the configuration to i…
aman19K Jun 26, 2025
00286f9
updated @contentstack/datasync-asset-store-filesystem version
aman19K Jun 26, 2025
93e7fad
fix: directory issue
aman19K Jun 26, 2025
fdc5e41
Merge pull request #51 from contentstack/feat/DX-3202
aman19K Jun 26, 2025
b75485b
fix: lock file
aman19K Jun 26, 2025
961d84f
Merge pull request #52 from contentstack/fix/lock-file
aman19K Jun 26, 2025
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
9 changes: 7 additions & 2 deletions .github/workflows/jira.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
types: [opened]
jobs:
security:
security-jira:
if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}}
runs-on: ubuntu-latest
steps:
Expand All @@ -21,8 +21,13 @@ jobs:
project: ${{ secrets.JIRA_PROJECT }}
issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
summary: |
${{ github.event.pull_request.title }}
Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }}
description: |
PR: ${{ github.event.pull_request.html_url }}

fields: "${{ secrets.JIRA_FIELDS }}"
- name: Transition issue
uses: atlassian/gajira-transition@v3
with:
issue: ${{ steps.create.outputs.issue }}
transition: ${{ secrets.JIRA_TRANSITION }}
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18.x"
node-version: "22.x"
- run: npm install

- name: get-package-details
Expand All @@ -28,7 +28,7 @@ jobs:
tag_prefix: "v"
- name: Create Release
if: steps.update_tag.outputs.tagname
uses: actions/create-release@v1
uses: actions/create-release@v4
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Upload Release Asset
if: steps.update_tag.outputs.tagname
id: upload-release-asset
uses: actions/upload-release-asset@v1
uses: actions/upload-release-asset@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/sast-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: SAST Scan
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
security-sast:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Semgrep Scan
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto
2 changes: 1 addition & 1 deletion .github/workflows/sca-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
security:
security-sca:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @contentstack/security-admin
* @contentstack/security-admin
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Contentstack
Copyright (c) 2025 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 Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This boilerplate is a code skeleton that will help you get up and running with C

### Prerequisite

- Node.js 8 or above
- Node.js 20 or above
- ngrok for running it on the local system
- A webhook already set up as follows:
- Make your contentstack-webhook-listener server available publicly (For local environment, use ngrok)
Expand Down
35 changes: 35 additions & 0 deletions clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// scripts/clean.js
const fs = require("fs");
const path = require("path");
const rimraf = require("rimraf");
const config = require("./config/all");
const { merge } = require("lodash");

// Set application's environment
const env = process.env.NODE_ENV || config.environment || "development";

let envConfig;
if (fs.existsSync(path.join(__dirname, "config", env + ".js"))) {
envConfig = require(path.join(__dirname, "config", env));
} else {
envConfig = require(path.join(__dirname, "config", "development"));
}

const appConfig = merge(config, envConfig);

const pathsToDelete = [".ledger", ".token", "unprocessible"];

// Preserve .checkpoint only if explicitly set in the configuration
if (!appConfig.checkpoint?.preserve) {
pathsToDelete.push(".checkpoint");
}

pathsToDelete.forEach((fileOrDir) => {
const fullPath = path.join(__dirname, fileOrDir);
if (fs.existsSync(fullPath)) {
rimraf.sync(fullPath);
console.log("Deleted:", fileOrDir);
} else {
console.log("Not found (skipped):", fileOrDir);
}
});
6 changes: 6 additions & 0 deletions config/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const config = {
//(For NA Region) host: 'cdn.contentstack.io',
//(For EU Region) host: 'eu-cdn.contentstack.com',
//(For AZURE NA Region) host: 'azure-na-cdn.contentstack.com',
//(For GCP NA Region) host: 'gcp-na-cdn.contentstack.com',
host:'',
},
plugins: [
Expand Down Expand Up @@ -68,6 +69,11 @@ const config = {
},
},
],
checkpoint: {
enabled: false, // Set to true if you want to enable checkpoint
filePath: ".checkpoint",
preserve: false // Set to true if you want to preserve the checkpoint file during clean operation
},
}

module.exports = config
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ if (fs.existsSync(path.join(__dirname, "config", env + ".js"))) {

const appConfig = _.merge(config, envConfig);

// Optional checkpoint reading
if (appConfig.checkpoint?.enabled) {
const checkpointPath = path.join(__dirname, appConfig.checkpoint.filePath || ".checkpoint");
const checkPoint = readHiddenFile(checkpointPath);
if (checkPoint) {
console.log("Found sync token in checkpoint file:", checkPoint);
appConfig.contentstack.sync_token = checkPoint.token;
console.log("Using sync token:", appConfig.contentstack.sync_token);
}
}

datasyncManager.setConfig(appConfig);
datasyncManager.setAssetStore(assetStore);
datasyncManager.setContentStore(contentStore);
Expand All @@ -45,3 +56,16 @@ datasyncManager
.catch((error) => {
console.error(error);
});

function readHiddenFile(filePath) {
try {
if (!fs.existsSync(filePath)) {
console.error("File does not exist:", filePath);
return;
}
const data = fs.readFileSync(filePath, "utf8");
return JSON.parse(data);
} catch (err) {
console.error("Error reading file:", err?.message);
}
}
Loading
Loading