Skip to content

Commit e1a3974

Browse files
Simplify template for faster project setup
Remove sample actions from the deployable codebase and save them as reference documentation in docs/examples/ so developers can copy what they need without shipping demo code in production. Replace the standalone frontend (src/web) with a Commerce Admin panel extension (commerce-backend-ui-1) that includes IMS authentication, Experience Cloud Shell integration, and a minimal starter page. Add a pre-build hook that automatically creates webpack configs for commerce extensions with auto-generated code, so developers do not need to set up webpack manually after running aio generate. Other changes: - Add .env.sample with all available environment variables - Make the telemetry service name configurable via environment variable - Rename telemetry config to newrelic-otel-config for clarity - Update all dependencies to their latest stable versions - Remove unused packages (cloudevents, uuid, ts-loader) - Consolidate shared TypeScript settings into the base config - Set minimum Node version to 22 to match the runtime target - Update README with current architecture and setup instructions
1 parent 8597d82 commit e1a3974

55 files changed

Lines changed: 2445 additions & 6695 deletions

Some content is hidden

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

.env.sample

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Adobe I/O Runtime credentials (generated by `aio app use`)
2+
# AIO_RUNTIME_AUTH=
3+
# AIO_RUNTIME_NAMESPACE=
4+
5+
# Telemetry
6+
# Service name used in New Relic APM dashboards
7+
TELEMETRY_SERVICE_NAME=my-app
8+
# Obtain from https://one.newrelic.com/launcher/api-keys-ui.api-keys-launcher (Ingest - License key)
9+
NEW_RELIC_LICENSE_KEY=

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# OS
2+
.DS_Store
3+
14
# NodeJS packages
25
node_modules
36

@@ -7,3 +10,15 @@ dist
710
.env
811
.aio
912
.aws.tmp*
13+
install.yaml
14+
15+
# Generated extension scaffolding
16+
src/commerce-configuration-1/
17+
src/commerce-extensibility-1/
18+
src/commerce-backend-ui-1/web-src/src/config.json
19+
20+
# AI Context Files
21+
GEMINI.md
22+
CLAUDE.md
23+
.claude
24+
.mcp.json

README.md

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Aligent Typescript Template for Adobe AppBuilder
22

3-
This repository contains a ready-to-build application including two actions and a simple frontend.
4-
Frontend and action code is fully typed, actions are bundled with sourcemaps using `ts-loader` for step-through debugging.
3+
This repository contains a ready-to-build application template for Adobe App Builder.
4+
Action code is fully typed, bundled with sourcemaps using Babel for step-through debugging.
55

6-
# Setup
6+
## Setup
77

8-
## Prerequisites
8+
### Prerequisites
99

1010
- Access to the [Adobe Developer Console](https://developer.adobe.com/developer-console/)
1111
- Access to an existing AppBuilder project.
1212
- If you're making a new project, follow the steps [here](https://developer.adobe.com/app-builder/docs/get_started/app_builder_get_started/first-app) to create an App project in the Adobe Developer Console.
1313
- Up-to-date global installation of the [Adobe aio CLI](https://developer.adobe.com/runtime/docs/guides/tools/cli_install/)
1414

15-
## Set up the repository
15+
### Set up the repository
1616

1717
```bash
1818
npm ci # Install dependencies
@@ -27,12 +27,7 @@ aio console workspace select
2727

2828
Then run `aio app use` to build your `.aio` and `.env` files.
2929

30-
31-
Add the `BASE_URL` environment variable required for the api-sample action to your `.env` file
32-
33-
```bash
34-
BASE_URL=https://pokeapi.co/api/v2/pokemon/
35-
```
30+
Copy [`.env.sample`](.env.sample) to `.env` and fill in your values.
3631

3732
## Development
3833

@@ -48,8 +43,8 @@ manta host add [app_name] [port_number] -k -s
4843
`port_number` is likely to be 9080, but if that's not the case, run `aio app dev` to see what the port number is. After this step, you'll be able to access your local development app at `https://[app_name].aligent.dev`. You'll also need to add `SERVER_HOST=0.0.0.0` to your `.env` file.
4944

5045
#### Commands
51-
- `aio app dev` will serve **both** actions and frontend locally
52-
- `aio app run` will **deploy** actions to the AppBuilder platform and serve the frontend locally
46+
- `aio app dev` will serve actions locally
47+
- `aio app run` will **deploy** actions to the AppBuilder platform
5348

5449
### Debugging in VS Code
5550

@@ -75,7 +70,6 @@ aio rt activation logs [activation_id_of_your_action]
7570

7671
to see the error logs.
7772

78-
7973
### Test & Coverage
8074

8175
- Run `aio app test` to run the testing suite
@@ -86,23 +80,32 @@ to see the error logs.
8680
- `aio app deploy` to build and deploy all actions on Runtime and static files to CDN
8781
- `aio app undeploy` to undeploy the app
8882

83+
## Examples
84+
85+
Example actions with full code, config, and tests are available in [`docs/examples/`](docs/examples/):
86+
87+
- [`api-sample`](docs/examples/api-sample/) — Calling an external API
88+
- [`publish-event-sample`](docs/examples/publish-event-sample/) — Publishing events to Adobe I/O Events
89+
- [`telemetry-example`](docs/examples/telemetry-example/) — OpenTelemetry instrumentation
90+
8991
## Telemetry (OpenTelemetry)
9092

9193
This project includes OpenTelemetry instrumentation via [`@adobe/aio-lib-telemetry`](https://github.com/adobe/aio-lib-telemetry), with traces, metrics, and logs exported to New Relic.
9294

93-
See [`src/actions/telemetry-example/index.ts`](src/actions/telemetry-example/index.ts) for a working example that demonstrates all of the features below.
95+
See [`docs/examples/telemetry-example/`](docs/examples/telemetry-example/) for a working example that demonstrates all of the features below.
9496

9597
### Setup
9698

9799
1. Obtain an **Ingest - License** key from [New Relic API Keys](https://one.newrelic.com/launcher/api-keys-ui.api-keys-launcher).
98100

99-
2. Add it to your `.env` file:
101+
2. Add the following to your `.env` file (see [`.env.sample`](.env.sample)):
100102

101103
```bash
104+
TELEMETRY_SERVICE_NAME=my-app
102105
NEW_RELIC_LICENSE_KEY=your_license_key_here
103106
```
104107

105-
3. Pass it as an input to each instrumented action in `app.config.yaml`:
108+
3. Pass them as inputs to each instrumented action in `app.config.yaml`:
106109

107110
```yaml
108111
my-action:
@@ -112,6 +115,7 @@ See [`src/actions/telemetry-example/index.ts`](src/actions/telemetry-example/ind
112115
inputs:
113116
LOG_LEVEL: debug
114117
ENABLE_TELEMETRY: true
118+
TELEMETRY_SERVICE_NAME: $TELEMETRY_SERVICE_NAME
115119
NEW_RELIC_LICENSE_KEY: $NEW_RELIC_LICENSE_KEY
116120
```
117121

@@ -241,9 +245,8 @@ The library automatically deserializes context from `params.__telemetryContext`
241245
```yaml
242246
application:
243247
hooks:
244-
pre-app-build: ./hooks/check-action-types.sh && ./hooks/check-web-types.sh
245-
actions: actions
246-
web: web-src
248+
pre-app-build: ./hooks/generate-webpack-configs.sh && ./hooks/check-action-types.sh
249+
actions: src/actions
247250
runtimeManifest:
248251
packages:
249252
appbuilder:
@@ -260,14 +263,7 @@ application:
260263
- Makes secrets and environment variables available at build time
261264
- Documentation: https://developer.adobe.com/app-builder/docs/guides/configuration/#env
262265
263-
```bash
264-
# AIO_RUNTIME_AUTH=
265-
# AIO_RUNTIME_NAMESPACE=
266-
267-
# BASE_URL=
268-
269-
# NEW_RELIC_LICENSE_KEY=
270-
```
266+
See [`.env.sample`](.env.sample) for all available variables. Copy it to `.env` and fill in your values.
271267
272268
### `.aio`
273269
@@ -280,27 +276,19 @@ application:
280276
- Configuration for Developer Console
281277
- Documentation: https://developer.adobe.com/app-builder/docs/guides/configuration/#aio
282278
283-
### `*webpack-config.js`
279+
### `*webpack-config.cjs`
284280
285281
- Used by `aio cli` for bundling typescript code
286282
- Adds inline source maps to support runtime debugging breakpoints in Typescript files
283+
- A `pre-app-build` hook automatically generates webpack configs for commerce extensions with `.generated` folders
287284
288285
## General pain points in this repository
289286
290287
This setup is brittle and confusing in a few areas. Some of that is because of the aio CLI's opinionated behaviour, some may be because the Typescript and package settings aren't quite right.
291288
292289
- `aio app test` (jest) and `aio app build` (webpack for actions) require a babel setup for typescript support
293-
- Parcel will detect a standard `babel.config.js` file and warn about it
294-
- Babel and parcel do not typecheck, so hooks are used to check types before building actions/web folders
295-
- AppBuilder doesn't support ESM syntax for `*webpack-config.js`, so the whole package has to be commonjs. For consistency only the standard aligent config files (prettier, eslint) are kept as `.mjs`
296-
- Jest doesn't understand the transpiled `.js` imports, requiring `moduleNameMapper` configuration in `jest.config.js`
290+
- Babel does not typecheck, so hooks are used to check types before building
291+
- AppBuilder doesn't support ESM syntax for `*webpack-config.cjs`, so the whole package has to be commonjs. For consistency only the standard aligent config files (prettier, eslint) are kept as `.mjs`
292+
- Commerce extensions auto-generate ESM `.js` files in `.generated/` folders that need Babel transpilation — this is handled automatically by the `generate-webpack-configs.sh` hook
293+
- Jest doesn't understand the transpiled `.js` imports, requiring `moduleNameMapper` configuration in `jest.config.cjs`
297294
- `babel-jest` hoists mock declarations to the top of the files which can make it very tricky to mock nested functions from `@adobe/aio-sdk`; the `jest` import is not available at the time mocks are initialised
298-
299-
## Under development
300-
301-
- [ ] Deployment pipeline
302-
- [ ] Pre-commit hooks
303-
- [x] Front End calling deployed actions
304-
- [ ] Front End extension point example
305-
- [x] Cleaner tsconfig setup separating tests, actions, web code
306-
- [x] Use Babel instead of ts-loader for action compiling

app.config.yaml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,6 @@
11
application:
22
hooks:
3-
pre-app-build: ./hooks/check-action-types.sh && ./hooks/check-web-types.sh
3+
pre-app-build: ./hooks/check-action-types.sh
44
actions: src/actions
5-
web: src/web
65
runtimeManifest:
7-
packages:
8-
appbuilder:
9-
license: Apache-2.0
10-
actions:
11-
api-sample:
12-
function: src/actions/api-sample/index.ts
13-
web: 'yes'
14-
runtime: nodejs:22
15-
inputs:
16-
LOG_LEVEL: debug
17-
BASE_URL: $BASE_URL
18-
annotations:
19-
require-adobe-auth: true
20-
final: true
21-
publish-event-sample:
22-
function: src/actions/publish-event-sample/index.ts
23-
web: 'yes'
24-
runtime: nodejs:22
25-
inputs:
26-
LOG_LEVEL: debug
27-
apiKey: $SERVICE_API_KEY
28-
annotations:
29-
require-adobe-auth: true
30-
final: true
31-
telemetry-example:
32-
function: src/actions/telemetry-example/index.ts
33-
web: 'yes'
34-
runtime: nodejs:22
35-
inputs:
36-
LOG_LEVEL: debug
37-
ENABLE_TELEMETRY: true
38-
NEW_RELIC_LICENSE_KEY: $NEW_RELIC_LICENSE_KEY
39-
annotations:
40-
require-adobe-auth: false
41-
final: true
6+
packages: {}

app.config.yaml.extentions

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extensions:
2+
commerce/backend-ui/1:
3+
$include: src/commerce-backend-ui-1/ext.config.yaml
4+
5+
# # This extension is required for business configuration. Do not remove.
6+
# commerce/configuration/1:
7+
# $include: src/commerce-configuration-1/ext.config.yaml
8+
9+
# # This extension is required for app management. Do not remove.
10+
# commerce/extensibility/1:
11+
# $include: src/commerce-extensibility-1/ext.config.yaml
12+

0 commit comments

Comments
 (0)