Skip to content

Commit 7e6d60a

Browse files
Merge pull request #53 from contentstack/development
Staging 30-06-2025 | Release
2 parents ab4d64e + 961d84f commit 7e6d60a

File tree

12 files changed

+1005
-2615
lines changed

12 files changed

+1005
-2615
lines changed

.github/workflows/jira.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
pull_request:
44
types: [opened]
55
jobs:
6-
security:
6+
security-jira:
77
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-')}}
88
runs-on: ubuntu-latest
99
steps:
@@ -21,8 +21,13 @@ jobs:
2121
project: ${{ secrets.JIRA_PROJECT }}
2222
issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
2323
summary: |
24-
${{ github.event.pull_request.title }}
24+
Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }}
2525
description: |
2626
PR: ${{ github.event.pull_request.html_url }}
2727
2828
fields: "${{ secrets.JIRA_FIELDS }}"
29+
- name: Transition issue
30+
uses: atlassian/gajira-transition@v3
31+
with:
32+
issue: ${{ steps.create.outputs.issue }}
33+
transition: ${{ secrets.JIRA_TRANSITION }}

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
12-
- uses: actions/setup-node@v1
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
1313
with:
14-
node-version: "18.x"
14+
node-version: "22.x"
1515
- run: npm install
1616

1717
- name: get-package-details
@@ -28,7 +28,7 @@ jobs:
2828
tag_prefix: "v"
2929
- name: Create Release
3030
if: steps.update_tag.outputs.tagname
31-
uses: actions/create-release@v1
31+
uses: actions/create-release@v4
3232
id: create_release
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
@@ -40,7 +40,7 @@ jobs:
4040
- name: Upload Release Asset
4141
if: steps.update_tag.outputs.tagname
4242
id: upload-release-asset
43-
uses: actions/upload-release-asset@v1
43+
uses: actions/upload-release-asset@v4
4444
env:
4545
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4646
with:

.github/workflows/sast-scan.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: SAST Scan
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
jobs:
6+
security-sast:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Semgrep Scan
11+
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto

.github/workflows/sca-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
pull_request:
44
types: [opened, synchronize, reopened]
55
jobs:
6-
security:
6+
security-sca:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@master

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @contentstack/security-admin
1+
* @contentstack/security-admin

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Contentstack
3+
Copyright (c) 2025 Contentstack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This boilerplate is a code skeleton that will help you get up and running with C
1010

1111
### Prerequisite
1212

13-
- Node.js 8 or above
13+
- Node.js 20 or above
1414
- ngrok for running it on the local system
1515
- A webhook already set up as follows:
1616
- Make your contentstack-webhook-listener server available publicly (For local environment, use ngrok)

clean.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// scripts/clean.js
2+
const fs = require("fs");
3+
const path = require("path");
4+
const rimraf = require("rimraf");
5+
const config = require("./config/all");
6+
const { merge } = require("lodash");
7+
8+
// Set application's environment
9+
const env = process.env.NODE_ENV || config.environment || "development";
10+
11+
let envConfig;
12+
if (fs.existsSync(path.join(__dirname, "config", env + ".js"))) {
13+
envConfig = require(path.join(__dirname, "config", env));
14+
} else {
15+
envConfig = require(path.join(__dirname, "config", "development"));
16+
}
17+
18+
const appConfig = merge(config, envConfig);
19+
20+
const pathsToDelete = [".ledger", ".token", "unprocessible"];
21+
22+
// Preserve .checkpoint only if explicitly set in the configuration
23+
if (!appConfig.checkpoint?.preserve) {
24+
pathsToDelete.push(".checkpoint");
25+
}
26+
27+
pathsToDelete.forEach((fileOrDir) => {
28+
const fullPath = path.join(__dirname, fileOrDir);
29+
if (fs.existsSync(fullPath)) {
30+
rimraf.sync(fullPath);
31+
console.log("Deleted:", fileOrDir);
32+
} else {
33+
console.log("Not found (skipped):", fileOrDir);
34+
}
35+
});

config/all.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const config = {
1212
//(For NA Region) host: 'cdn.contentstack.io',
1313
//(For EU Region) host: 'eu-cdn.contentstack.com',
1414
//(For AZURE NA Region) host: 'azure-na-cdn.contentstack.com',
15+
//(For GCP NA Region) host: 'gcp-na-cdn.contentstack.com',
1516
host:'',
1617
},
1718
plugins: [
@@ -68,6 +69,11 @@ const config = {
6869
},
6970
},
7071
],
72+
checkpoint: {
73+
enabled: false, // Set to true if you want to enable checkpoint
74+
filePath: ".checkpoint",
75+
preserve: false // Set to true if you want to preserve the checkpoint file during clean operation
76+
},
7177
}
7278

7379
module.exports = config

index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ if (fs.existsSync(path.join(__dirname, "config", env + ".js"))) {
3232

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

35+
// Optional checkpoint reading
36+
if (appConfig.checkpoint?.enabled) {
37+
const checkpointPath = path.join(__dirname, appConfig.checkpoint.filePath || ".checkpoint");
38+
const checkPoint = readHiddenFile(checkpointPath);
39+
if (checkPoint) {
40+
console.log("Found sync token in checkpoint file:", checkPoint);
41+
appConfig.contentstack.sync_token = checkPoint.token;
42+
console.log("Using sync token:", appConfig.contentstack.sync_token);
43+
}
44+
}
45+
3546
datasyncManager.setConfig(appConfig);
3647
datasyncManager.setAssetStore(assetStore);
3748
datasyncManager.setContentStore(contentStore);
@@ -45,3 +56,16 @@ datasyncManager
4556
.catch((error) => {
4657
console.error(error);
4758
});
59+
60+
function readHiddenFile(filePath) {
61+
try {
62+
if (!fs.existsSync(filePath)) {
63+
console.error("File does not exist:", filePath);
64+
return;
65+
}
66+
const data = fs.readFileSync(filePath, "utf8");
67+
return JSON.parse(data);
68+
} catch (err) {
69+
console.error("Error reading file:", err?.message);
70+
}
71+
}

0 commit comments

Comments
 (0)