Skip to content
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

feat: bump app-script & add add-locations script [EXT-6267] #9586

Merged
merged 4 commits into from
Mar 20, 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
3 changes: 2 additions & 1 deletion examples/app-parameters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
"build": "tsc && vite build",
"test": "vitest",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN",
"setup": "ts-node scripts/setup.ts"
},
"devDependencies": {
"@contentful/app-scripts": "1.19.1",
"@contentful/app-scripts": "^2.3.0",
"@testing-library/react": "^16.2.0",
"@types/node": "^16.18.124",
"@types/react": "18.3.1",
Expand Down
3 changes: 2 additions & 1 deletion examples/asset-upload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@contentful/app-scripts": "^1.30.1",
"@contentful/app-scripts": "^2.3.0",
"@contentful/app-sdk": "4.22.0",
"@contentful/f36-components": "4.45.0",
"@contentful/f36-tokens": "4.0.2",
Expand All @@ -18,6 +18,7 @@
"start": "vite",
"build": "tsc && vite build",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
Expand Down
9 changes: 7 additions & 2 deletions examples/autotagger/functions/INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ npx create-contentful-app@latest --example function-appevent-handler

### Creating an app

You can create an app using CLI using `npm run create-app-definition`. This will prompt you to enter details for your new app and organization details. You can also create an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the "Create App" button on the top right.
You can create an app using the CLI command `npm run create-app-definition`. This will prompt you to enter details for your new app and organization details. You can also create an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the "Create App" button on the top right.

### Using environment variables

Expand All @@ -22,8 +22,13 @@ You will need to set the following environment variables as listed below:

It as simple using the CLI command `npm run upload-ci`. This will perform two actions: upload the code, linking it to the app, and then finally activating the code ready for usage in both

### Adding locations to an app

You can add locations to an existing app using the CLI command `npm run add-locations`. This will launch an interactive prompt, allowing you to select locations to add to your app.
You can also add locations to an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the **"Edit"** flyout button for your app and selecting locations on the **"General"** tab.

## Utilizing app event handler functions

When you create an app that utilizes [app events](https://www.contentful.com/developers/docs/extensibility/app-framework/app-events/), you can define the entities and topics for these events. However, you may also want to do some additional handling when these events occur. For example, you may want to send a copy of the event to an external service for logging or monitoring purposes.

Once you have built and uploaded your functions to Contentful, link them to your app event subscription using the [CMA](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/app-event-subscriptions/app-event-subscription/update-or-subscribe-to-events/console/js-plain) or the [Events](https://app.contentful.com/deeplink?link=app-definition&tab=events) tab on the App details page.
Once you have built and uploaded your functions to Contentful, link them to your app event subscription using the [CMA](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/app-event-subscriptions/app-event-subscription/update-or-subscribe-to-events/console/js-plain) or the [Events](https://app.contentful.com/deeplink?link=app-definition&tab=events) tab on the App details page.
3 changes: 2 additions & 1 deletion examples/autotagger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"build:functions": "contentful-app-scripts build-functions --ci",
"test": "vitest run --passWithNoTests",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./build",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./build --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
Expand All @@ -38,7 +39,7 @@
]
},
"devDependencies": {
"@contentful/app-scripts": "2.1.2",
"@contentful/app-scripts": "^2.3.0",
"@contentful/node-apps-toolkit": "^3.11.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
Expand Down
3 changes: 2 additions & 1 deletion examples/blog-post-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"build": "vite build",
"preview": "vite preview",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
"devDependencies": {
"@contentful/app-scripts": "1.10.2",
"@contentful/app-scripts": "^2.3.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
"@tsconfig/create-react-app": "2.0.0",
Expand Down
4 changes: 3 additions & 1 deletion examples/commercelayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.5.89",
"private": true,
"devDependencies": {
"@contentful/app-scripts": "1.15.0",
"@contentful/app-scripts": "^2.3.0",
"cross-env": "7.0.3",
"vite": "^5.0.0",
"@vitejs/plugin-react": "^4.0.3"
Expand All @@ -20,6 +20,8 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
Expand Down
3 changes: 2 additions & 1 deletion examples/compare-entries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"react-dom": "^16.14.0"
},
"devDependencies": {
"@contentful/app-scripts": "1.10.2",
"@contentful/app-scripts": "^2.3.0",
"@tsconfig/create-react-app": "2.0.0",
"@vitejs/plugin-react": "^4.0.3",
"cross-env": "7.0.3",
Expand All @@ -29,6 +29,7 @@
"build": "vite build",
"preview": "vite preview",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
Expand Down
4 changes: 3 additions & 1 deletion examples/custom-validation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"scripts": {
"start": "vite",
"build": "tsc --noEmit && vite build",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
"dependencies": {
"@contentful/app-scripts": "1.10.2",
"@contentful/app-scripts": "^2.3.0",
"@contentful/app-sdk": "4.22.0",
"@contentful/f36-components": "4.45.0",
"@contentful/react-apps-toolkit": "1.2.16",
Expand Down
4 changes: 3 additions & 1 deletion examples/dam-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react-dom": "17.0.2"
},
"devDependencies": {
"@contentful/app-scripts": "1.15.0",
"@contentful/app-scripts": "^2.3.0",
"cross-env": "7.0.3",
"vite": "^5.0.0",
"@vitejs/plugin-react": "^4.0.3"
Expand All @@ -19,6 +19,8 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
Expand Down
4 changes: 3 additions & 1 deletion examples/ecommerce-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react-dom": "17.0.2"
},
"devDependencies": {
"@contentful/app-scripts": "1.15.0",
"@contentful/app-scripts": "^2.3.0",
"cross-env": "7.0.3",
"vite": "^5.0.0",
"@vitejs/plugin-react": "^4.0.3"
Expand All @@ -19,6 +19,8 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
Expand Down
3 changes: 2 additions & 1 deletion examples/editor-assignment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"vitest": "^3.0.7"
},
"devDependencies": {
"@contentful/app-scripts": "1.10.2",
"@contentful/app-scripts": "^2.3.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
"@tsconfig/create-react-app": "2.0.0",
Expand All @@ -37,6 +37,7 @@
"test": "vitest",
"preview": "vite preview",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./dist",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./dist --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN"
},
Expand Down
5 changes: 5 additions & 0 deletions examples/function-appaction/INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ npm run upload

The interactive CLI will prompt you to provide additional details, such as a CMA endpoint URL. Select **Yes** when prompted if you’d like to activate the bundle after upload.

### Adding locations to an app

You can add locations to an existing app using the CLI command `npm run add-locations`. This will launch an interactive prompt, allowing you to select locations to add to your app.
You can also add locations to an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the **"Edit"** flyout button for your app and selecting locations on the **"General"** tab.

### Create an App Action

You can create an app action by navigating to the app definition in the Contentful web UI and following [these instructions](https://www.contentful.com/developers/docs/extensibility/app-framework/app-actions/#create-an-app-action), ensuring that you select `function-invocation` for the type and choosing your uploaded function.
Expand Down
3 changes: 2 additions & 1 deletion examples/function-appaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build": "vite build && npm run build:functions",
"test": "vitest",
"create-app-definition": "contentful-app-scripts create-app-definition",
"add-locations": "contentful-app-scripts add-locations",
"upload": "contentful-app-scripts upload --bundle-dir ./build",
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./build --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN",
"build:functions": "contentful-app-scripts build-functions --ci",
Expand All @@ -43,7 +44,7 @@
]
},
"devDependencies": {
"@contentful/app-scripts": "^2.1.2",
"@contentful/app-scripts": "^2.3.0",
"@contentful/node-apps-toolkit": "^3.11.1",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ npx create-contentful-app@latest --example function-appevent-filter --javascript

### Creating an app

You can create an app using CLI using `npm run create-app-definition`. This will prompt you to enter details for your new app and organization details. You can also create an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the "Create App" button on the top right.
You can create an app using the CLI command `npm run create-app-definition`. This will prompt you to enter details for your new app and organization details. You can also create an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the "Create App" button on the top right.

### Using environment variables

Expand All @@ -22,8 +22,13 @@ You will need to set the following environment variables as listed below:

It as simple using the CLI command `npm run upload-ci`. This will perform two actions: upload the code, linking it to the app, and then finally activating the code ready for usage in both

### Adding locations to an app

You can add locations to an existing app using the CLI command `npm run add-locations`. This will launch an interactive prompt, allowing you to select locations to add to your app.
You can also add locations to an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the **"Edit"** flyout button for your app and selecting locations on the **"General"** tab.

## Utilizing app event filter functions

When you create an app that utilizes [app events](https://www.contentful.com/developers/docs/extensibility/app-framework/app-events/), you can define the entities and topics for these events. However, you may also want to do some additional filtering for these app events. For example, you might want to filter Entry events so that they are only sent for certain content types. App event filter functions are a flexible way of making app events even more powerful for your apps.

Once you have built and uploaded your functions to Contentful, link them to your app event subscription using the [CMA](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/app-event-subscriptions/app-event-subscription/update-or-subscribe-to-events/console/js-plain) or the [Events](https://app.contentful.com/deeplink?link=app-definition&tab=events) tab on the App details page.
Once you have built and uploaded your functions to Contentful, link them to your app event subscription using the [CMA](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/app-event-subscriptions/app-event-subscription/update-or-subscribe-to-events/console/js-plain) or the [Events](https://app.contentful.com/deeplink?link=app-definition&tab=events) tab on the App details page.
2 changes: 1 addition & 1 deletion examples/function-appevent-filter/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"build": "contentful-app-scripts build-functions --ci"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided not to add script as I believe the intent with these is that they are merged with another template that has the script

},
"devDependencies": {
"@contentful/app-scripts": "^2.1.2",
"@contentful/app-scripts": "^2.3.0",
"sentiment": "^5.0.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ npx create-contentful-app@latest --example function-appevent-filter

### Creating an app

You can create an app using CLI using `npm run create-app-definition`. This will prompt you to enter details for your new app and organization details. You can also create an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the "Create App" button on the top right.
You can create an app using the CLI command `npm run create-app-definition`. This will prompt you to enter details for your new app and organization details. You can also create an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the "Create App" button on the top right.

### Using environment variables

Expand All @@ -22,8 +22,13 @@ You will need to set the following environment variables as listed below:

It as simple using the CLI command `npm run upload-ci`. This will perform two actions: upload the code, linking it to the app, and then finally activating the code ready for usage in both

### Adding locations to an app

You can add locations to an existing app using the CLI command `npm run add-locations`. This will launch an interactive prompt, allowing you to select locations to add to your app.
You can also add locations to an app definition by [visiting the apps section](https://app.contentful.com/deeplink?link=app-definition-list) under your organization settings in the Contentful web UI and clicking on the **"Edit"** flyout button for your app and selecting locations on the **"General"** tab.

## Utilizing app event filter functions

When you create an app that utilizes [app events](https://www.contentful.com/developers/docs/extensibility/app-framework/app-events/), you can define the entities and topics for these events. However, you may also want to do some additional filtering for these app events. For example, you might want to filter Entry events so that they are only sent for certain content types. App event filter functions are a flexible way of making app events even more powerful for your apps.

Once you have built and uploaded your functions to Contentful, link them to your app event subscription using the [CMA](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/app-event-subscriptions/app-event-subscription/update-or-subscribe-to-events/console/js-plain) or the [Events](https://app.contentful.com/deeplink?link=app-definition&tab=events) tab on the App details page.
Once you have built and uploaded your functions to Contentful, link them to your app event subscription using the [CMA](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/app-event-subscriptions/app-event-subscription/update-or-subscribe-to-events/console/js-plain) or the [Events](https://app.contentful.com/deeplink?link=app-definition&tab=events) tab on the App details page.
2 changes: 1 addition & 1 deletion examples/function-appevent-filter/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"build": "contentful-app-scripts build-functions --ci"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided not to add script as I believe the intent with these is that they are merged with another template that has the script

},
"devDependencies": {
"@contentful/app-scripts": "^2.1.2",
"@contentful/app-scripts": "^2.3.0",
"@contentful/node-apps-toolkit": "^3.11.1",
"@tsconfig/recommended": "1.0.8",
"@types/sentiment": "^5.0.4",
Expand Down
Loading