Skip to content

Commit c215a10

Browse files
authored
Merge pull request #3 from contentstack/v2-dev
Modularised repo changes v2
2 parents d72fcce + 48983ac commit c215a10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+12715
-11668
lines changed

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* @contentstack/devex-pr-reviewers
2+
.github/workflows/sca-scan.yml @contentstack/security-admin
3+
.github/workflows/issues-jira.yml @contentstack/security-admin
4+
.github/workflows/policy-scan.yml @contentstack/security-admin
5+
**/.snyk @contentstack/security-admin

.github/config/release.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"releaseAll": true,
3+
"plugins": {
4+
"export": false,
5+
"import": false,
6+
"clone": false,
7+
"export-to-csv": false,
8+
"migration": false,
9+
"seed": false,
10+
"bootstrap": false,
11+
"branches": false
12+
}
13+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
pull_request:
16+
# The branches below must be a subset of the branches above
17+
branches: '*'
18+
19+
jobs:
20+
analyze:
21+
name: Analyze
22+
runs-on: ubuntu-latest
23+
permissions:
24+
actions: read
25+
contents: read
26+
security-events: write
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
language: [ 'javascript' ]
32+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
33+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v3.5.3
38+
39+
# Initializes the CodeQL tools for scanning.
40+
- name: Initialize CodeQL
41+
uses: github/codeql-action/init@v2
42+
with:
43+
languages: ${{ matrix.language }}
44+
# If you wish to specify custom queries, you can do so here or in a config file.
45+
# By default, queries listed here will override any specified in a config file.
46+
# Prefix the list here with "+" to use these queries and those in the config file.
47+
48+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
49+
# queries: security-extended,security-and-quality
50+
51+
52+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
53+
# If this step fails, then you should remove it and run the build manually (see below)
54+
- name: Autobuild
55+
uses: github/codeql-action/autobuild@v2
56+
57+
# ℹ️ Command-line programs to run using the OS shell.
58+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
59+
60+
# If the Autobuild fails above, remove it and uncomment the following three lines.
61+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
62+
63+
# - run: |
64+
# echo "Run, Build Application using script"
65+
# ./location_of_script_within_repo/buildscript.sh
66+
67+
- name: Perform CodeQL Analysis
68+
uses: github/codeql-action/analyze@v2

.github/workflows/issues-jira.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Create Jira Ticket for Github Issue
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
jobs:
8+
issue-jira:
9+
runs-on: ubuntu-latest
10+
steps:
11+
12+
- name: Login to Jira
13+
uses: atlassian/gajira-login@master
14+
env:
15+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
16+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
17+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
18+
19+
- name: Create Jira Issue
20+
id: create_jira
21+
uses: atlassian/gajira-create@master
22+
with:
23+
project: ${{ secrets.JIRA_PROJECT }}
24+
issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
25+
summary: Github | Issue | ${{ github.event.repository.name }} | ${{ github.event.issue.title }}
26+
description: |
27+
*GitHub Issue:* ${{ github.event.issue.html_url }}
28+
29+
*Description:*
30+
${{ github.event.issue.body }}
31+
fields: "${{ secrets.ISSUES_JIRA_FIELDS }}"

.github/workflows/policy-scan.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Checks the security policy and configurations
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
jobs:
6+
security-policy:
7+
if: github.event.repository.visibility == 'public'
8+
runs-on: ubuntu-latest
9+
defaults:
10+
run:
11+
shell: bash
12+
steps:
13+
- uses: actions/checkout@master
14+
- name: Checks for SECURITY.md policy file
15+
run: |
16+
if ! [[ -f "SECURITY.md" || -f ".github/SECURITY.md" ]]; then exit 1; fi
17+
security-license:
18+
if: github.event.repository.visibility == 'public'
19+
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
shell: bash
23+
steps:
24+
- uses: actions/checkout@master
25+
- name: Checks for License file
26+
run: |
27+
expected_license_files=("LICENSE" "LICENSE.txt" "LICENSE.md" "License.txt")
28+
license_file_found=false
29+
current_year=$(date +"%Y")
30+
31+
for license_file in "${expected_license_files[@]}"; do
32+
if [ -f "$license_file" ]; then
33+
license_file_found=true
34+
# check the license file for the current year, if not exists, exit with error
35+
if ! grep -q "$current_year" "$license_file"; then
36+
echo "License file $license_file does not contain the current year."
37+
exit 2
38+
fi
39+
break
40+
fi
41+
done
42+
43+
if [ "$license_file_found" = false ]; then
44+
echo "No license file found. Please add a license file to the repository."
45+
exit 1
46+
fi
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Release CLI Plugins (v2 Beta)
2+
3+
on:
4+
push:
5+
branches: [v2-beta]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: pnpm/action-setup@v4
13+
with:
14+
version: 10.28.0
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: '22.x'
18+
19+
- name: Enable Corepack
20+
run: corepack enable
21+
22+
- name: Install pnpm
23+
run: corepack prepare pnpm@10.28.0 --activate
24+
25+
- name: Clean the repository
26+
run: pnpm run clean:all
27+
28+
- name: Install root dependencies
29+
run: pnpm install --frozen-lockfile
30+
31+
- name: Build all plugins
32+
run: pnpm -r --sort run build
33+
34+
- name: Reading Configuration
35+
id: release_config
36+
uses: rgarcia-phi/json-to-variables@v1.1.0
37+
with:
38+
filename: .github/config/release.json
39+
prefix: release
40+
41+
# Variants
42+
- name: Publishing variants (Beta)
43+
uses: JS-DevTools/npm-publish@v3
44+
with:
45+
token: ${{ secrets.NPM_TOKEN }}
46+
package: ./packages/contentstack-variants/package.json
47+
tag: beta
48+
49+
# Export
50+
- name: Publishing export (Beta)
51+
uses: JS-DevTools/npm-publish@v3
52+
with:
53+
token: ${{ secrets.NPM_TOKEN }}
54+
package: ./packages/contentstack-export/package.json
55+
tag: beta
56+
57+
# Audit
58+
- name: Publishing audit (Beta)
59+
uses: JS-DevTools/npm-publish@v3
60+
with:
61+
token: ${{ secrets.NPM_TOKEN }}
62+
package: ./packages/contentstack-audit/package.json
63+
tag: beta
64+
65+
# Import
66+
- name: Publishing import (Beta)
67+
uses: JS-DevTools/npm-publish@v3
68+
with:
69+
token: ${{ secrets.NPM_TOKEN }}
70+
package: ./packages/contentstack-import/package.json
71+
tag: beta
72+
73+
# Clone
74+
- name: Publishing clone (Beta)
75+
uses: JS-DevTools/npm-publish@v3
76+
with:
77+
token: ${{ secrets.NPM_TOKEN }}
78+
package: ./packages/contentstack-clone/package.json
79+
tag: beta
80+
81+
# Import Setup
82+
- name: Publishing import-setup (Beta)
83+
uses: JS-DevTools/npm-publish@v3
84+
with:
85+
token: ${{ secrets.NPM_TOKEN }}
86+
package: ./packages/contentstack-import-setup/package.json
87+
tag: beta
88+
89+
# Export to CSV
90+
- name: Publishing export to csv (Beta)
91+
uses: JS-DevTools/npm-publish@v3
92+
with:
93+
token: ${{ secrets.NPM_TOKEN }}
94+
package: ./packages/contentstack-export-to-csv/package.json
95+
tag: beta
96+
97+
# Migration
98+
- name: Publishing migration (Beta)
99+
uses: JS-DevTools/npm-publish@v3
100+
with:
101+
token: ${{ secrets.NPM_TOKEN }}
102+
package: ./packages/contentstack-migration/package.json
103+
tag: beta
104+
105+
# Seed
106+
- name: Publishing seed (Beta)
107+
uses: JS-DevTools/npm-publish@v3
108+
with:
109+
token: ${{ secrets.NPM_TOKEN }}
110+
package: ./packages/contentstack-seed/package.json
111+
tag: beta
112+
113+
# Bootstrap
114+
- name: Publishing bootstrap (Beta)
115+
uses: JS-DevTools/npm-publish@v3
116+
with:
117+
token: ${{ secrets.NPM_TOKEN }}
118+
package: ./packages/contentstack-bootstrap/package.json
119+
tag: beta
120+
121+
# Branches
122+
- name: Publishing branches (Beta)
123+
uses: JS-DevTools/npm-publish@v3
124+
with:
125+
token: ${{ secrets.NPM_TOKEN }}
126+
package: ./packages/contentstack-branches/package.json
127+
tag: beta
128+
129+
- name: Create Beta Release
130+
id: create_release
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.PKG_TOKEN }}
133+
VERSION: ${{ steps.publish-core.outputs.version }}
134+
run: |
135+
# Get the previous beta release for comparison
136+
PREVIOUS_BETA=$(gh release list --limit 10 | grep 'beta' | head -1 | cut -f1)
137+
138+
if [ -n "$PREVIOUS_BETA" ]; then
139+
gh release create v"$VERSION" --title "Beta Release $VERSION" --notes-from-tag "$PREVIOUS_BETA" --prerelease
140+
else
141+
gh release create v"$VERSION" --title "Beta Release $VERSION" --generate-notes --prerelease
142+
fi

.github/workflows/sca-scan.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Source Composition Analysis Scan
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
jobs:
6+
security-sca:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@master
10+
- name: Run Snyk to check for vulnerabilities
11+
uses: snyk/actions/node@master
12+
env:
13+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
14+
with:
15+
args: --all-projects --fail-on=all
16+
json: true
17+
continue-on-error: true
18+
- uses: contentstack/sca-policy@main

.github/workflows/unit-test.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Run Unit Tests
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
run-tests:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup pnpm
15+
uses: pnpm/action-setup@v4
16+
with:
17+
version: 10.28.0 # or your local pnpm version
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '22.x'
23+
cache: 'pnpm' # optional but recommended
24+
25+
- name: Install Dependencies
26+
run: pnpm install --frozen-lockfile
27+
28+
- name: Build all plugins
29+
run: |
30+
NODE_ENV=PREPACK_MODE pnpm -r --sort run build
31+
32+
- name: Run tests for Contentstack Import Plugin
33+
working-directory: ./packages/contentstack-import
34+
run: npm run test:unit
35+
36+
- name: Run tests for Contentstack Export Plugin
37+
working-directory: ./packages/contentstack-export
38+
run: npm run test:unit
39+
40+
- name: Run tests for Audit plugin
41+
working-directory: ./packages/contentstack-audit
42+
run: npm run test:unit
43+
44+
- name: Run tests for Contentstack Migration
45+
working-directory: ./packages/contentstack-migration
46+
run: npm run test
47+
48+
- name: Run tests for Contentstack Export To CSV
49+
working-directory: ./packages/contentstack-export-to-csv
50+
run: npm run test:unit
51+
52+
- name: Run tests for Contentstack Bootstrap
53+
working-directory: ./packages/contentstack-bootstrap
54+
run: npm run test
55+
56+
# - name: Run tests for Contentstack Import Setup
57+
# working-directory: ./packages/contentstack-import-setup
58+
# run: npm run test:unit
59+
60+
- name: Run tests for Contentstack Branches
61+
working-directory: ./packages/contentstack-branches
62+
run: npm run test:unit

0 commit comments

Comments
 (0)