Skip to content

Commit 2144fa9

Browse files
Piyush Singh GaurPiyush Singh Gaur
authored andcommitted
feat(core): CSP-1 add cli tool for csp injection
1 parent c597388 commit 2144fa9

Some content is hidden

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

49 files changed

+22013
-2
lines changed

.cz-config.cjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module.exports = {
2+
types: [
3+
{value: 'feat', name: 'feat: A new feature'},
4+
{value: 'fix', name: 'fix: A bug fix'},
5+
{value: 'docs', name: 'docs: Documentation only changes'},
6+
{
7+
value: 'style',
8+
name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)',
9+
},
10+
{
11+
value: 'refactor',
12+
name: 'refactor: A code change that neither fixes a bug nor adds a feature',
13+
},
14+
{
15+
value: 'perf',
16+
name: 'perf: A code change that improves performance',
17+
},
18+
{value: 'test', name: 'test: Adding missing tests'},
19+
{
20+
value: 'chore',
21+
name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation',
22+
},
23+
{value: 'revert', name: 'revert: Revert to a commit'},
24+
{value: 'WIP', name: 'WIP: Work in progress'},
25+
],
26+
27+
scopes: [{name: 'core'}],
28+
29+
allowTicketNumber: true,
30+
isTicketNumberRequired: false,
31+
ticketNumberPrefix: 'CSP-',
32+
ticketNumberRegExp: '\\d{1,5}',
33+
34+
// override the messages, defaults are as follows
35+
messages: {
36+
type: "Select the type of change that you're committing:",
37+
scope: 'Denote the SCOPE of this change:',
38+
// used if allowCustomScopes is true
39+
customScope: 'Denote the SCOPE of this change:',
40+
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
41+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
42+
footer: 'Any tags (optional): ',
43+
breaking: 'List any BREAKING CHANGES (optional):\n',
44+
confirmCommit: 'Are you sure you want to proceed with the commit above?',
45+
},
46+
47+
allowCustomScopes: false,
48+
allowBreakingChanges: ['feat', 'fix'],
49+
50+
// limit subject length
51+
subjectLimit: 100,
52+
breaklineChar: '|', // It is supported for fields body and footer.
53+
footerPrefix: '',
54+
askForBreakingChangeFirst: true, // default is false
55+
subjectCase: null, // Allow any case for subject
56+
};

.eslintrc.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaVersion: 2020,
6+
sourceType: 'module',
7+
project: './tsconfig.eslint.json',
8+
tsconfigRootDir: __dirname,
9+
},
10+
plugins: ['@typescript-eslint', 'jest'],
11+
extends: ['eslint:recommended', 'prettier'],
12+
env: {
13+
node: true,
14+
es2020: true,
15+
jest: true,
16+
},
17+
ignorePatterns: ['commitlint.config.cjs', 'node_modules/', 'dist/', 'coverage/', '*.d.ts'],
18+
rules: {
19+
// TypeScript specific rules
20+
'@typescript-eslint/no-unused-vars': [
21+
'error',
22+
{
23+
argsIgnorePattern: '^_',
24+
varsIgnorePattern: '^_',
25+
caughtErrorsIgnorePattern: '^_',
26+
},
27+
],
28+
'@typescript-eslint/no-explicit-any': 'warn',
29+
'@typescript-eslint/explicit-function-return-type': 'error',
30+
'@typescript-eslint/no-inferrable-types': 'off',
31+
'@typescript-eslint/prefer-readonly': 'error',
32+
33+
// Code quality rules
34+
complexity: ['error', { max: 15 }],
35+
'max-depth': ['error', { max: 4 }],
36+
'max-lines': ['error', { max: 300, skipBlankLines: true, skipComments: true }],
37+
'max-lines-per-function': ['error', { max: 80, skipBlankLines: true, skipComments: true }],
38+
'max-params': ['error', { max: 5 }],
39+
'max-statements': ['error', { max: 25 }],
40+
'no-console': 'warn',
41+
'no-debugger': 'error',
42+
'no-alert': 'error',
43+
'no-duplicate-imports': 'error',
44+
'no-unused-expressions': 'error',
45+
'prefer-const': 'error',
46+
'no-var': 'error',
47+
'object-shorthand': 'error',
48+
'prefer-arrow-callback': 'error',
49+
'prefer-template': 'error',
50+
'no-nested-ternary': 'error',
51+
'no-unneeded-ternary': 'error',
52+
'no-else-return': 'error',
53+
'consistent-return': 'error',
54+
55+
// Security rules
56+
'no-eval': 'error',
57+
'no-implied-eval': 'error',
58+
'no-new-func': 'error',
59+
60+
// Jest specific rules
61+
'jest/expect-expect': 'error',
62+
'jest/no-disabled-tests': 'warn',
63+
'jest/no-focused-tests': 'error',
64+
'jest/no-identical-title': 'error',
65+
'jest/valid-expect': 'error',
66+
},
67+
overrides: [
68+
{
69+
files: ['test/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
70+
rules: {
71+
'@typescript-eslint/no-explicit-any': 'off',
72+
'@typescript-eslint/explicit-function-return-type': 'off',
73+
'max-lines': 'off', // Test files can be longer
74+
'max-lines-per-function': 'off',
75+
'max-statements': 'off',
76+
'no-console': 'off',
77+
},
78+
},
79+
{
80+
files: ['src/cli.ts', 'src/CSPInjector.ts'],
81+
rules: {
82+
'no-console': 'off', // CLI and main injector need console output
83+
'max-lines': 'off', // Legacy large files - gradually refactor
84+
'max-lines-per-function': ['error', { max: 150 }],
85+
complexity: ['error', { max: 25 }],
86+
'max-statements': ['error', { max: 50 }],
87+
'no-unused-expressions': 'off', // Some CLI expressions are intentional
88+
},
89+
},
90+
{
91+
files: ['test/helpers/*.ts'],
92+
rules: {
93+
'@typescript-eslint/prefer-readonly': 'off', // Test helpers may need mutable properties
94+
},
95+
},
96+
],
97+
};

.github/CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at support@sourcefuse.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Additional context**
27+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Description
2+
3+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4+
5+
Fixes # (issue)
6+
7+
## Type of change
8+
9+
Please delete options that are not relevant.
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] Intermediate change (work in progress)
15+
16+
## How Has This Been Tested?
17+
18+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
19+
20+
- [ ] Test A
21+
- [ ] Test B
22+
23+
## Checklist:
24+
25+
- [ ] Performed a self-review of my own code
26+
- [ ] npm test passes on your machine
27+
- [ ] New tests added or existing tests modified to cover all changes
28+
- [ ] Code conforms with the style guide
29+
- [ ] API Documentation in code was updated
30+
- [ ] Any dependent changes have been merged and published in downstream modules

.github/workflows/main.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
npm_audit:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- uses: actions/setup-node@v3
17+
with:
18+
node-version: '18.x'
19+
20+
- run: node --version
21+
- run: npm --version
22+
23+
- name: Install Dependencies
24+
run: npm ci
25+
26+
- name: Run Test Cases
27+
run: npm run test
28+
29+
- name: Run Lint Checks
30+
run: npm run lint

.github/workflows/pre_release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Pre-Release Check [Manual]
2+
on:
3+
workflow_dispatch:
4+
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
pre-release-check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '20.x'
20+
21+
- name: Configure Git
22+
run: |
23+
git config --global user.name $CONFIG_USERNAME
24+
git config --global user.email $CONFIG_EMAIL
25+
env:
26+
CONFIG_USERNAME: ${{ vars.RELEASE_COMMIT_USERNAME }}
27+
CONFIG_EMAIL: ${{ vars.RELEASE_COMMIT_EMAIL }}
28+
29+
- name: Set Git Remote with Auth Token
30+
run: |
31+
git remote set-url origin https://${RELEASE_COMMIT_USERNAME}:${GITHUB_PAT}@github.com/sourcefuse/arc-spa-csp
32+
env:
33+
GITHUB_PAT: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
34+
RELEASE_COMMIT_USERNAME: ${{ vars.RELEASE_COMMIT_USERNAME }}
35+
36+
- name: Install Dependencies
37+
run: npm ci
38+
39+
- name: Run Tests
40+
run: npm run test
41+
42+
- name: Run Semantic Release in Dry Run Mode
43+
run: npx semantic-release --dry-run
44+
env:
45+
GH_TOKEN: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
46+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)