Skip to content

Monorepo sync #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .github/workflows/sync-monorepo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { syncfromGithubAction } from 'monorepo-sync';

syncfromGithubAction()
.then(() => {
console.log('Sync completed successfully');
process.exit(0);
})
.catch((error) => {
console.error('Error during sync:', error);
process.exit(1);
});
49 changes: 49 additions & 0 deletions .github/workflows/sync-pr-to-monorepo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Sync Merged PR to Monorepo

on:
pull_request:
types: [closed]
branches:
- main
- master

jobs:
sync-to-monorepo:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.MONOREPO_SYNC_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
SOURCE_REPO_NAME: ${{ github.event.repository.name }}
MONOREPO_PACKAGE_LOCATION: packages/${{ github.event.repository.name }}
MONOREPO_PATH: ${{ github.workspace }}/monorepo

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
# Install project dependencies (including dev dependencies)
run: npm install
- name: Install zx
run: npm install zx

- name: Install monorepo-sync package
run: npm install git+https://github.com/formio/monorepo-sync.git
- name: Clone Monorepo
run: |
gh repo clone formio/formio-monorepo monorepo -- --depth=1

- name: Sync to Monorepo
run: |
echo "Syncing PR #${PR_NUMBER}: ${PR_TITLE}"
node .github/workflows/sync-monorepo.mjs
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"jest-transform-css": "^6.0.1",
"jsdom": "^22.1.0",
"prettier": "3.2.4",
"monorepo-sync": "git+https://github.com/johnformio/monorepo-sync.git",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"ts-jest": "^29.1.2",
Expand Down
13 changes: 8 additions & 5 deletions src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
onNextPage?: (page: number, submission: Submission) => void;
onCancelSubmit?: () => void;
onCancelComponent?: (component: Component) => void;
onChange?: (value: any, flags: any, modified: boolean) => void;

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onCustomEvent?: (event: {
type: string;
component: Component;
Expand All @@ -69,17 +69,17 @@
onComponentChange?: (changed: {
instance: Webform;
component: Component;
value: any;

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
flags: any;

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
}) => void;
onSubmit?: (submission: Submission, saved?: boolean) => void;
onSubmitDone?: (submission: Submission) => void;
onSubmitError?: (error: EventError) => void;
onFormLoad?: (form: JSON) => void;
onError?: (error: EventError | false) => void;
onRender?: (param: any) => void;

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onAttach?: (param: any) => void;

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onBuild?: (param: any) => void;

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onFocus?: (instance: Webform) => void;
onBlur?: (instance: Webform) => void;
onInitialized?: () => void;
Expand All @@ -91,7 +91,7 @@
onSubmissionDeleted?: (submission: Submission) => void;
onRequestDone?: () => void;
otherEvents?: {
[event: string]: (...args: any[]) => void;

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
};
};

Expand All @@ -114,7 +114,7 @@
| 'formioform'
| 'Formio'
>,
...args: [string, ...any[]]

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
) => {
const [event, ...outputArgs] = args;
if (event.startsWith('formio.')) {
Expand Down Expand Up @@ -252,7 +252,8 @@
export const Form = (props: FormProps) => {
const renderElement = useRef<HTMLDivElement | null>(null);
const currentFormJson = useRef<FormType | null>(null);
const { formConstructor, formSource, formReadyCallback } = getEffectiveProps(props);
const { formConstructor, formSource, formReadyCallback } =
getEffectiveProps(props);
const {
src,
form,
Expand Down Expand Up @@ -295,9 +296,10 @@
console.warn('Form source not found');
return;
}
currentFormJson.current = formSource && typeof formSource !== 'string'
? structuredClone(formSource)
: null;
currentFormJson.current =
formSource && typeof formSource !== 'string'
? structuredClone(formSource)
: null;
const instance = await createWebformInstance(
formConstructor,
currentFormJson.current || formSource,
Expand Down Expand Up @@ -338,7 +340,8 @@
useEffect(() => {
let onAnyHandler = null;
if (formInstance && Object.keys(handlers).length > 0) {
onAnyHandler = (...args: [string, ...any[]]) => onAnyEvent(handlers, ...args);
onAnyHandler = (...args: [string, ...any[]]) =>

Check warning on line 343 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 343 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 343 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onAnyEvent(handlers, ...args);
formInstance.onAny(onAnyHandler);
}

Expand Down
24 changes: 13 additions & 11 deletions src/components/Report.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ export const Report = (props) => {
// eslint-disable-next-line no-undef
if (report && !_isEqual(report, jsonReport.current)) {
jsonReport.current = cloneDeep(report);
createReportInstance(report).then(() => {
if (formio) {
formio.form = { components: [], report };
return formio;
}
}).catch((err) => {
console.error(err);
if (formio?.form?.report ) {
formio.form.report = {};
}
});
createReportInstance(report)
.then(() => {
if (formio) {
formio.form = { components: [], report };
return formio;
}
})
.catch((err) => {
console.error(err);
if (formio?.form?.report) {
formio.form.report = {};
}
});
initializeFormio();
}
}, [props.report]);
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3908,6 +3908,12 @@ moment@^2.29.4:
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==

"monorepo-sync@git+https://github.com/johnformio/monorepo-sync.git":
version "1.0.0"
resolved "git+https://github.com/johnformio/monorepo-sync.git#7865350762a51f65be5a7c10314a18d0a1905f1e"
dependencies:
zx "^8.5.4"

ms@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
Expand Down Expand Up @@ -5310,3 +5316,8 @@ yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zx@^8.5.4:
version "8.5.4"
resolved "https://registry.yarnpkg.com/zx/-/zx-8.5.4.tgz#1f5cc658ad69cf093aca1c5cfa943393e8db85f3"
integrity sha512-44oKea9Sa8ZnOkTnS6fRJpg3quzgnbB43nLrVfYnqE86J4sxgZMUDLezzKET/FdOAVkF4X+Alm9Bume+W+RW9Q==
Loading