Skip to content

Commit a0522ba

Browse files
authored
Initialize FORMS-17541-Validation
0 parents  commit a0522ba

File tree

400 files changed

+51665
-0
lines changed

Some content is hidden

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

400 files changed

+51665
-0
lines changed

.circleci/config.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
version: 2.1
2+
orbs:
3+
node: circleci/node@5
4+
browser-tools: circleci/[email protected]
5+
jobs:
6+
lint:
7+
executor: node/default
8+
steps:
9+
- checkout
10+
- node/install-packages:
11+
pkg-manager: npm
12+
- run:
13+
name: Run lint
14+
command: npm run lint
15+
unit-tests:
16+
# Install node dependencies and run tests
17+
executor: node/default
18+
steps:
19+
- checkout
20+
- node/install-packages:
21+
pkg-manager: npm
22+
- run:
23+
name: Print node install help instructions
24+
command: |-
25+
echo "One cause for node package install failure is if you have private repositories that it can't reach
26+
One way to fix this for private npm packages:
27+
1. Use the npm CLI's \"login\" command to create a token (usually saved in your user's \"~/.npmrc\" file)
28+
For more info, see https://circleci.com/blog/publishing-npm-packages-using-circleci-2-0/#:~:text=set%20the%20%24npm_token%20environment%20variable%20in%20circleci
29+
2. Add a NPM_TOKEN to an org context
30+
For info on how to use contexts, see https://circleci.com/docs/contexts/
31+
3. Add a .circleci/config.yml to your repository or use this config.yml as a starting template
32+
4. Configure the jobs to use the context that includes NPM_TOKEN
33+
5. Add a step to inject your NPM_TOKEN environment variable into npm before \"install-packages\"
34+
For an example, see https://circleci.com/blog/publishing-npm-packages-using-circleci-2-0/#:~:text=the%20deploy%20job%20has%20several%20steps%20that%20run%20to%20authenticate%20with%20and%20publish%20to"
35+
when: on_fail
36+
- run:
37+
name: Run unit tests
38+
command: npm run test:unit --passWithNoTests
39+
e2e-tests:
40+
docker:
41+
- image: mcr.microsoft.com/playwright:v1.40.0-jammy
42+
steps:
43+
- checkout
44+
- run:
45+
name: Install Playwright
46+
command: |
47+
npm i -D @playwright/test
48+
npx playwright install
49+
- run:
50+
name: Install browsers
51+
command: npx playwright install chrome
52+
- run:
53+
name: Run end-to-end
54+
command: npm run test:e2e
55+
- store_artifacts:
56+
path: test/e2e/reports
57+
destination: test-results
58+
- store_artifacts:
59+
path: ./videos
60+
destination: videos
61+
- store_artifacts:
62+
path: ./error-screenshot.png
63+
destination: screenshots
64+
check-coverage:
65+
executor: node/default
66+
steps:
67+
- checkout
68+
- node/install-packages:
69+
pkg-manager: npm
70+
- run:
71+
name: Install Dependencies
72+
command: npm i
73+
- run:
74+
name : check coverage
75+
command: npm run coverage
76+
- store_artifacts:
77+
path: coverage
78+
workflows:
79+
lint:
80+
jobs:
81+
- lint
82+
build-and-test:
83+
jobs:
84+
- unit-tests
85+
- e2e-tests
86+
check-coverage:
87+
jobs:
88+
- check-coverage

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
helix-importer-ui
2+
rollup/*
3+
blocks/form/rules/formula/*
4+
blocks/form/rules/model/*
5+
scripts/editor-support.js
6+
scripts/editor-support-rte.js

.eslintrc.cjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
root: true,
3+
extends: 'airbnb-base',
4+
env: {
5+
browser: true,
6+
},
7+
parser: '@babel/eslint-parser',
8+
parserOptions: {
9+
allowImportExportEverywhere: true,
10+
sourceType: 'module',
11+
requireConfigFile: false,
12+
},
13+
rules: {
14+
// allow reassigning param
15+
'no-param-reassign': [2, { props: false }],
16+
'linebreak-style': ['error', 'unix'],
17+
'import/extensions': ['error', {
18+
js: 'always',
19+
}],
20+
'import/no-extraneous-dependencies': ['error', {'devDependencies': ['test/**/**.js', '**/*.config.js']}]
21+
},
22+
};

.github/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Please always provide the [GitHub issue(s)](../issues) your PR is for, as well as test URLs where your change can be observed (before and after):
2+
3+
Fix #<gh-issue-id>
4+
5+
Test URLs:
6+
- Before: https://main--aem-boilerplate-forms--adobe-rnd.hlx.live/
7+
- After: https://{branch}--aem-boilerplate-forms--adobe-rnd.hlx.live/
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This workflow will run upon repository creation and clean up
2+
# all files that are not strictly required to build an AEM Live project
3+
# but that we use to develop the project template. This includes this
4+
# particular workflow file.
5+
on:
6+
push:
7+
branches:
8+
- main
9+
workflow_dispatch:
10+
jobs:
11+
cleanup:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
actions: write
16+
# only run if commit message is "Initial commit" on main branch
17+
if: ${{ github.event_name == 'workflow_dispatch' || ((github.ref == 'refs/heads/main') && (github.event.head_commit.message == 'Initial commit'))}}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Use Node.js 20
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
- name: Remove Helper Files
26+
run: |
27+
rm -rf \
28+
.github/workflows/cleanup-on-create.yaml \
29+
CHANGELOG.md
30+
31+
- name: Remove Form Developement Files
32+
run: |
33+
rm -rf \
34+
.circleci .npmrc test rollup playwright.config.js
35+
36+
- name: Update .eslintignore
37+
run: |
38+
sed -i '/^rollup/d' .eslintignore
39+
sed -i '/^helix-importer-ui/d' .eslintignore
40+
41+
- name: Update Package.json
42+
run: |
43+
rm -rf package.json package-lock.json
44+
mv package-prod.json package.json
45+
mv package-prod-lock.json package-lock.json
46+
47+
- name: Initialize README
48+
# replace {repo} and {owner} with the actual values
49+
run: |
50+
sed -i.bak "s/{repo}/$(basename ${{ github.repository }})/g" README.md
51+
sed -i.bak "s/{owner}/$(dirname ${{ github.repository }})/g" README.md
52+
- name: Initialize Pull Request Template
53+
run: |
54+
sed -i.bak "s/aem-boilerplate-forms/$(basename ${{ github.repository }})/g" .github/pull_request_template.md
55+
sed -i.bak "s/adobe-rnd/$(dirname ${{ github.repository }})/g" .github/pull_request_template.md
56+
57+
# commit back to the repository
58+
- name: Commit changes
59+
run: |
60+
git config --local user.email "[email protected]"
61+
git config --local user.name "AEM Bot"
62+
git add .
63+
git commit -m "chore: cleanup repository template"
64+
git push

.github/workflows/main.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Build
2+
on: [push]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- name: Use Node.js 20
10+
uses: actions/setup-node@v4
11+
with:
12+
node-version: 20
13+
- run: npm ci
14+
- run: npm run lint
15+

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.hlx/*
2+
coverage/*
3+
logs/*
4+
node_modules/*
5+
6+
helix-importer-ui
7+
.DS_Store
8+
*.bak
9+
.idea
10+
.nyc_output
11+
12+
.env*
13+
.vscode
14+
/test-results/
15+
/playwright-report/
16+
/blob-report/
17+
/playwright/.cache/
18+
test/e2e/reports/
19+
LoginAuth.json

.hlxignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.*
2+
*.md
3+
karma.config.js
4+
LICENSE
5+
package.json
6+
package-lock.json
7+
test/*
8+
_*

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node .husky/pre-commit.mjs

.husky/pre-commit.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { exec } from "node:child_process";
2+
import fs from 'fs/promises';
3+
4+
const run = (cmd) => new Promise((resolve, reject) => exec(
5+
cmd,
6+
(error, stdout, stderr) => {
7+
if (error) reject();
8+
if (stderr) reject(stderr);
9+
resolve(stdout);
10+
}
11+
));
12+
13+
const sortComponentDefinition = async (sortKey) => {
14+
const filePath = './component-definition.json';
15+
try {
16+
const data = await fs.readFile(filePath, 'utf8');
17+
if(!data) throw new Error('No data found in file, expected JSON file.');
18+
const jsonContent = JSON.parse(data);
19+
20+
const formGeneralGroup = jsonContent.groups.find(group => group.id === 'form-general');
21+
if (formGeneralGroup) {
22+
formGeneralGroup.components.sort((a, b) => {
23+
if (a.title < b.title) return -1;
24+
if (a.title > b.title) return 1;
25+
return 0;
26+
});
27+
}
28+
29+
await fs.writeFile(filePath, JSON.stringify(jsonContent, null, 2), 'utf8');
30+
console.log(`File ${filePath} has been sorted by ${sortKey}`);
31+
} catch (error) {
32+
console.error(`Error processing file ${filePath}:`, error);
33+
}
34+
};
35+
36+
const changeset = await run('git diff --cached --name-only --diff-filter=ACMR');
37+
const modifiedFiles = changeset.split('\n').filter(Boolean);
38+
39+
const modifiedPartials = modifiedFiles.filter((file) => file.match(/(^|\/)_.*.json/));
40+
if (modifiedPartials.length > 0) {
41+
const output = await run('npm run build:json --silent');
42+
await sortComponentDefinition('title');
43+
console.log(output);
44+
await run('git add .');
45+
}

0 commit comments

Comments
 (0)