@aligent/nx-appbuilder 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +203 -0
  2. package/generators.json +18 -0
  3. package/package.json +20 -0
  4. package/src/generators/app/files/base/.editorconfig.template +18 -0
  5. package/src/generators/app/files/base/.gitignore.template +9 -0
  6. package/src/generators/app/files/base/.nvmrc.template +1 -0
  7. package/src/generators/app/files/base/README.md.template +44 -0
  8. package/src/generators/app/files/base/app.config.yaml.template +77 -0
  9. package/src/generators/app/files/base/babel.actions.config.js.template +6 -0
  10. package/src/generators/app/files/base/eslint.config.mjs.template +8 -0
  11. package/src/generators/app/files/base/global-types/@adobe/ADOBE_TYPES.md.template +10 -0
  12. package/src/generators/app/files/base/global-types/@adobe/aio-sdk/aio-core-logging.d.ts.template +15 -0
  13. package/src/generators/app/files/base/global-types/@adobe/aio-sdk/aio-lib-core-config.d.ts.template +43 -0
  14. package/src/generators/app/files/base/hooks/check-action-types.sh.template +13 -0
  15. package/src/generators/app/files/base/prettier.config.mjs.template +3 -0
  16. package/src/generators/app/files/base/src/actions/tsconfig.json.template +8 -0
  17. package/src/generators/app/files/base/tests/tsconfig.json.template +13 -0
  18. package/src/generators/app/files/base/tsconfig.base.json.template +14 -0
  19. package/src/generators/app/files/base/tsconfig.json.template +3 -0
  20. package/src/generators/app/files/base/vitest.config.ts.template +19 -0
  21. package/src/generators/app/files/commerce-backend-ui/extension-manifest.json.template +8 -0
  22. package/src/generators/app/files/commerce-backend-ui/hooks/check-web-types.sh.template +11 -0
  23. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/registration/index.ts.template +32 -0
  24. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/tsconfig.json.template +8 -0
  25. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/utils/http.ts.template +18 -0
  26. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/utils/runtime.ts.template +47 -0
  27. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/utils/utils.ts.template +187 -0
  28. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/ext.config.yaml.template +20 -0
  29. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/.gitignore.template +2 -0
  30. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/index.html.template +15 -0
  31. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/components/App.tsx.template +37 -0
  32. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/components/ExtensionRegistration.tsx.template +15 -0
  33. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/config.json.d.ts.template +4 -0
  34. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/constants/extension.ts.template +1 -0
  35. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/context/AdobeRuntimeContextProvider.tsx.template +65 -0
  36. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/context/PageContextProvider.tsx.template +78 -0
  37. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/hooks/useAppBuilderAction.ts.template +41 -0
  38. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/hooks/useLazyAppBuilderAction.ts.template +116 -0
  39. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/index.css.template +4 -0
  40. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/index.tsx.template +20 -0
  41. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/types/ActionName.ts.template +9 -0
  42. package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/tsconfig.json.template +14 -0
  43. package/src/generators/app/files/commerce-config/src/commerce-configuration-1/ext.config.yaml.template +37 -0
  44. package/src/generators/app/files/commerce-config/src/commerce-configuration-1/my-webpack-config.cjs.template +24 -0
  45. package/src/generators/app/files/commerce-extensibility/app.commerce.config.ts.template +138 -0
  46. package/src/generators/app/files/commerce-extensibility/install.yaml.template +17 -0
  47. package/src/generators/app/files/commerce-extensibility/src/commerce-extensibility-1/ext.config.yaml.template +25 -0
  48. package/src/generators/app/files/commerce-extensibility/src/commerce-extensibility-1/my-webpack-config.cjs.template +24 -0
  49. package/src/generators/app/files/events/global-types/@adobe/aio-sdk/aio-lib-events.d.ts.template +7 -0
  50. package/src/generators/app/files/events/src/actions/handle-sample-event.ts.template +35 -0
  51. package/src/generators/app/files/install-steps/scripts/install/sample-step.js.template +14 -0
  52. package/src/generators/app/files/rest-actions/src/actions/rest-sample.ts.template +30 -0
  53. package/src/generators/app/files/scheduled/src/actions/cron-sample.ts.template +23 -0
  54. package/src/generators/app/generator.d.ts +3 -0
  55. package/src/generators/app/generator.js +38 -0
  56. package/src/generators/app/lib/apply-feature-files.d.ts +9 -0
  57. package/src/generators/app/lib/apply-feature-files.js +76 -0
  58. package/src/generators/app/lib/compose-package-json.d.ts +3 -0
  59. package/src/generators/app/lib/compose-package-json.js +164 -0
  60. package/src/generators/app/lib/normalize-options.d.ts +3 -0
  61. package/src/generators/app/lib/normalize-options.js +67 -0
  62. package/src/generators/app/lib/template-package/package.json +31 -0
  63. package/src/generators/app/lib/update-root-package.d.ts +6 -0
  64. package/src/generators/app/lib/update-root-package.js +23 -0
  65. package/src/generators/app/lib/update-root-tsconfig.d.ts +8 -0
  66. package/src/generators/app/lib/update-root-tsconfig.js +24 -0
  67. package/src/generators/app/schema.d.ts +32 -0
  68. package/src/generators/app/schema.json +73 -0
  69. package/src/generators/preset/files/.gitignore.template +30 -0
  70. package/src/generators/preset/files/.npmrc.template +2 -0
  71. package/src/generators/preset/files/.nvmrc.template +1 -0
  72. package/src/generators/preset/files/README.md.template +38 -0
  73. package/src/generators/preset/files/tsconfig.json.template +6 -0
  74. package/src/generators/preset/nx-json.d.ts +4 -0
  75. package/src/generators/preset/nx-json.js +36 -0
  76. package/src/generators/preset/preset.d.ts +13 -0
  77. package/src/generators/preset/preset.js +113 -0
  78. package/src/generators/preset/schema.d.ts +4 -0
  79. package/src/generators/preset/schema.json +25 -0
  80. package/src/index.d.ts +2 -0
  81. package/src/index.js +19 -0
  82. package/tsconfig.lib.tsbuildinfo +1 -0
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # Nx App Builder
2
+
3
+ The `@aligent/nx-appbuilder` package provides Nx generators for Adobe App Builder development. It scaffolds a workspace shell and individual App Builder apps inside an Nx monorepo, wired up against Aligent's `@adobe/aio-sdk` / `@adobe/aio-commerce-lib-*` conventions.
4
+
5
+ ## Generators
6
+
7
+ ### Preset Generator
8
+
9
+ The preset generator initialises a new App Builder monorepo. It is invoked indirectly via either `@aligent/create-workspace` (the Aligent-flavoured wrapper) or vanilla `create-nx-workspace`, and produces the workspace shell only — apps are added afterwards with the `app` generator.
10
+
11
+ #### Usage
12
+
13
+ ```bash
14
+ # Recommended: the Aligent wrapper. Requires corepack to be enabled.
15
+ npx @aligent/create-workspace@latest --preset=@aligent/nx-appbuilder
16
+
17
+ # Or directly via create-nx-workspace (will prompt for nodeVersion if omitted):
18
+ npx create-nx-workspace@latest --preset=@aligent/nx-appbuilder
19
+ ```
20
+
21
+ > The `@aligent/create-workspace` wrapper calls `create-nx-workspace` under the hood, prompts for the preset's options (workspace name, target Node.js version), and removes the npm-bootstrap artefacts (`package-lock.json`, `node_modules`, `.nx`) afterwards so the workspace is ready for `yarn install`.
22
+
23
+ #### Options
24
+
25
+ | Option | Type | Required | Default | Description |
26
+ |--------|--------|----------|---------|---------------------------------------------------------------------------------------------------------------|
27
+ | `name` | string | Yes | - | Workspace name (kebab-case). Used as the `@aligent/<name>` npm package name and the workspace directory name. |
28
+
29
+ #### Post-generation setup
30
+
31
+ After running the preset generator, configure the npm registry token before the first `npm install`:
32
+
33
+ - **`NPM_TOKEN`** — the generated `.npmrc` points `@aligent` at `https://npm.corp.aligent.consulting/` and reads `${NPM_TOKEN}` for auth. Generate a token by signing in to the registry with your GitHub account, then export it in your shell:
34
+
35
+ ```bash
36
+ export NPM_TOKEN=<your-token>
37
+ ```
38
+
39
+ #### What it creates
40
+
41
+ The preset generator scaffolds:
42
+
43
+ - **Root configuration files**:
44
+ - `package.json` - Workspace manifest with `lint` / `check-types` / `test` / `build` scripts (affected + run-many variants)
45
+ - `nx.json` - Nx workspace configuration with cached `lint` / `check-types` / `test` / `build` target defaults
46
+ - `.npmrc` - Aligent private registry configuration
47
+ - `.nvmrc` - Pinned Node.js version (v22)
48
+ - `.gitignore` - Standard ignores for Node, Nx, Parcel and Adobe AppBuilder
49
+ - `README.md` - Workspace-level usage guide
50
+
51
+ The preset does **not** scaffold any apps — see the `app` generator below.
52
+
53
+ ### App Generator
54
+
55
+ The app generator creates a new Adobe App Builder app inside an existing workspace. The generator drives a series of prompts (or accepts CLI flags) that toggle which feature subtrees are rendered into the new app's directory.
56
+
57
+ #### Usage
58
+
59
+ ```bash
60
+ npx nx g @aligent/nx-appbuilder:app <app-name>
61
+ ```
62
+
63
+ Pass any of the feature flags below to skip the corresponding prompt, e.g.:
64
+
65
+ ```bash
66
+ npx nx g @aligent/nx-appbuilder:app my-app \
67
+ --hasAdminUI=true \
68
+ --sidebarCategory=sales \
69
+ --hasCommerceWebhooks=true
70
+ ```
71
+
72
+ #### Options
73
+
74
+ | Option | Type | Required | Default | Description |
75
+ |-------------------------|---------|----------|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
76
+ | `name` | string | Yes | - | App name (kebab-case). Used as the directory name and the suffix of the `@aligent/<name>` package name. |
77
+ | `description` | string | No | `''` | Short description of the app, used in `package.json` and the generated README. |
78
+ | `displayName` | string | No | Title-cased `name` | Human-readable display name used in `app.commerce.config.ts` and the generated README. |
79
+ | `hasAdminUI` | boolean | No | `false` | Generates the Commerce backend UI extension (`commerce/backend-ui/1`) — custom admin pages and sidebar menu items. |
80
+ | `sidebarCategory` | enum | No | `none` | Sidebar category for the admin menu item. One of `catalog`, `sales`, `customers`, `content`, `none`. Only used when `hasAdminUI=true`; prompted if omitted. |
81
+ | `hasBusinessConfig` | boolean | No | `false` | Generates the Commerce configuration extension (`commerce/configuration/1`) — merchant-facing fields under Stores → Configuration. |
82
+ | `hasCommerceWebhooks` | boolean | No | `false` | Adds a `webhooks` section to `app.commerce.config.ts` for binding Commerce extensibility hooks to runtime actions. |
83
+ | `hasEvents` | boolean | No | `false` | Generates a sample event handler under `src/actions/` and an `eventing` block in `app.commerce.config.ts` for Commerce + external event subscriptions. |
84
+ | `hasRestActions` | boolean | No | `false` | Generates a sample REST action under `src/actions/` and registers it in the runtime manifest. |
85
+ | `hasScheduledActions` | boolean | No | `false` | Generates a sample cron-triggered action under `src/actions/` along with the `triggers` and `rules` entries that fire it. |
86
+ | `hasCustomInstallSteps` | boolean | No | `false` | Generates an `installation` block in `app.commerce.config.ts` and a sample step under `scripts/install/`. |
87
+
88
+ > Setting `hasAdminUI`, `hasBusinessConfig`, or `hasCommerceWebhooks` automatically pulls in the `commerce-extensibility` subtree and the `@adobe/aio-commerce-lib-*` dependencies.
89
+
90
+ #### What it creates
91
+
92
+ The app generator always renders a **base** subtree into `<app-name>/`:
93
+
94
+ - **App-level files**:
95
+ - `app.config.yaml` - App Builder manifest with the runtime package, action declarations, triggers and rules (composed from the selected flags)
96
+ - `package.json` - Pinned dependencies and `lint` / `lint:fix` / `check-types` / `test` scripts (per-target variants for actions, web and tests)
97
+ - `package.json` `nx.targets` block - declares the custom `check-types` and `deploy` targets; `lint` and `test` are inferred by the `@nx/eslint/plugin` and `@nx/vitest` plugins from `eslint.config.mjs` and `vitest.config.ts`
98
+ - `tsconfig.json` / `tsconfig.base.json` - TypeScript project config
99
+ - `babel.actions.config.js` - Babel preset for App Builder actions
100
+ - `eslint.config.mjs` / `prettier.config.mjs` - Lint and formatter config (`@aligent/ts-code-standards`)
101
+ - `vitest.config.ts` - Vitest config
102
+ - `.editorconfig`, `.nvmrc`, `.gitignore`, `README.md`
103
+
104
+ - **Action and test scaffolding**:
105
+ - `src/actions/tsconfig.json` - TypeScript config for the App Builder actions
106
+ - `tests/tsconfig.json` - TypeScript config for the test suite
107
+ - `hooks/check-action-types.sh` - `pre-app-build` hook that type-checks actions before deploy
108
+ - `global-types/@adobe/aio-sdk/*.d.ts` - Local type augmentations for the Adobe AIO SDK
109
+
110
+ - **Root updates**:
111
+ - Adds `<app-name>` to the root `package.json` workspaces array
112
+
113
+ Additional subtrees are layered on top depending on the selected flags:
114
+
115
+ | Flag | Subtree rendered | Notable additions |
116
+ |-----------------------------------------------------------------|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
117
+ | any of `hasAdminUI`, `hasBusinessConfig`, `hasCommerceWebhooks` | `commerce-extensibility/` | `app.commerce.config.ts`, `install.yaml`, `commerce/extensibility/1` extension config; pulls in `@adobe/aio-commerce-lib-app` / `-config`. |
118
+ | `hasAdminUI` | `commerce-backend-ui/` | React 19 + Spectrum admin UI under `src/commerce-backend-ui-1/`, `web-src/` entry point, action utils, registration, `pre-app-build` web type-check hook. |
119
+ | `hasBusinessConfig` | `commerce-config/` | `commerce/configuration/1` extension config wired into `app.commerce.config.ts`; adds a `businessConfig.schema` block to `app.commerce.config.ts`. |
120
+ | `hasCommerceWebhooks` | none (modifies `commerce-extensibility/`) | Adds a `webhooks` section to `app.commerce.config.ts` for binding Commerce extensibility hooks to runtime actions or external URLs. No new files; relies on the `commerce-extensibility/` subtree being rendered. |
121
+ | `hasRestActions` | `rest-actions/` | `src/actions/rest-sample.ts` registered as a web action in `app.config.yaml`. |
122
+ | `hasEvents` | `events/` | `src/actions/handle-sample-event.ts`, sample Commerce + external event subscriptions, `aio-lib-events` global types. |
123
+ | `hasScheduledActions` | `scheduled/` | `src/actions/cron-sample.ts` plus the `triggers`/`rules` entries that fire it on a cron schedule. |
124
+ | `hasCustomInstallSteps` | `install-steps/` | `scripts/install/sample-step.js` and an `installation.customInstallationSteps` entry in `app.commerce.config.ts`. |
125
+
126
+ #### Example
127
+
128
+ ```bash
129
+ # Standalone backend integration with REST actions and scheduled jobs
130
+ npx nx g @aligent/nx-appbuilder:app order-sync \
131
+ --hasRestActions=true \
132
+ --hasScheduledActions=true
133
+
134
+ # Commerce admin UI with business configuration and webhook bindings
135
+ npx nx g @aligent/nx-appbuilder:app loyalty-rules \
136
+ --hasAdminUI=true \
137
+ --sidebarCategory=customers \
138
+ --hasBusinessConfig=true \
139
+ --hasCommerceWebhooks=true
140
+ ```
141
+
142
+ ## Project Structure
143
+
144
+ After running the preset generator and adding one or more apps, your workspace will look like:
145
+
146
+ ```
147
+ my-workspace/
148
+ ├── my-app/
149
+ │ ├── src/
150
+ │ │ ├── actions/
151
+ │ │ │ ├── tsconfig.json
152
+ │ │ │ └── ... # rest / event / cron action samples (per flag)
153
+ │ │ ├── commerce-backend-ui-1/ # only if hasAdminUI
154
+ │ │ ├── commerce-configuration-1/ # only if hasBusinessConfig
155
+ │ │ └── commerce-extensibility-1/ # only if any commerce-lib flag
156
+ │ ├── tests/
157
+ │ ├── hooks/
158
+ │ ├── global-types/
159
+ │ ├── scripts/install/ # only if hasCustomInstallSteps
160
+ │ ├── app.config.yaml
161
+ │ ├── app.commerce.config.ts # only if any commerce-lib flag
162
+ │ ├── install.yaml # only if any commerce-lib flag
163
+ │ ├── package.json # includes nx.targets for check-types and deploy
164
+ │ └── ...
165
+ ├── nx.json
166
+ ├── package.json
167
+ ├── .npmrc
168
+ └── .nvmrc
169
+ ```
170
+
171
+ ## Development
172
+
173
+ ### Building
174
+
175
+ ```bash
176
+ npx nx build nx-appbuilder
177
+ ```
178
+
179
+ The `@nx/js:tsc` build executor compiles `src/**/*.ts` to `dist/src/` and copies the templates under `src/generators/<gen>/files/` verbatim. Template files use the `.template` suffix (e.g. `app.commerce.config.ts.template`) so they aren't picked up by lint or `tsc`; `@nx/devkit`'s `generateFiles` strips the suffix at generation time.
180
+
181
+ ### Running tests / lint / type-check
182
+
183
+ ```bash
184
+ npx nx test nx-appbuilder
185
+ npx nx lint nx-appbuilder
186
+ npx nx typecheck nx-appbuilder
187
+ ```
188
+
189
+ ### Local testing
190
+
191
+ To try the generator locally against a sibling workspace without publishing:
192
+
193
+ ```bash
194
+ # In the consumer workspace:
195
+ npm install --save-dev /absolute/path/to/packages/nx-appbuilder
196
+ npx nx g @aligent/nx-appbuilder:app my-app
197
+ ```
198
+
199
+ Or use the local Verdaccio registry — see the root `CLAUDE.md` for the `nx start-local-registry` workflow.
200
+
201
+ ## License
202
+
203
+ MIT
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "name": "@aligent/nx-appbuilder",
4
+ "version": "0.1.0",
5
+ "generators": {
6
+ "preset": {
7
+ "factory": "./src/generators/preset/preset",
8
+ "schema": "./src/generators/preset/schema.json",
9
+ "description": "Scaffold a new Aligent AppBuilder monorepo (used by create-nx-workspace).",
10
+ "x-use-standalone-layout": true
11
+ },
12
+ "app": {
13
+ "factory": "./src/generators/app/generator",
14
+ "schema": "./src/generators/app/schema.json",
15
+ "description": "Scaffold a new Adobe App Builder app inside an existing workspace."
16
+ }
17
+ }
18
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@aligent/nx-appbuilder",
3
+ "version": "0.2.0",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "typings": "./src/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/aligent/microservice-development-utilities.git",
10
+ "directory": "packages/nx-appbuilder"
11
+ },
12
+ "dependencies": {
13
+ "@nx/devkit": "22.4.2",
14
+ "enquirer": "^2.3.6"
15
+ },
16
+ "generators": "./generators.json",
17
+ "author": "Aligent",
18
+ "license": "MIT",
19
+ "types": "./src/index.d.ts"
20
+ }
@@ -0,0 +1,18 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_size = 4
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+ max_line_length = 100
11
+
12
+
13
+ [{package.json,*.yml,*.md}]
14
+ indent_size = 2
15
+ indent_style = space
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
@@ -0,0 +1,9 @@
1
+ # NodeJS packages
2
+ node_modules
3
+
4
+ # AppBuilder/aio CLI outputs
5
+ dist
6
+ .parcel-cache
7
+ .env
8
+ .aio
9
+ .aws.tmp*
@@ -0,0 +1 @@
1
+ v<%= nodeVersion %>
@@ -0,0 +1,44 @@
1
+ # <%= displayName %>
2
+
3
+ <%= description %>
4
+
5
+ ## Development
6
+
7
+ Run any of these from the monorepo root. Replace `npm install` with
8
+ `yarn install` / `pnpm install` if that's your preferred package manager —
9
+ the workspace works the same either way.
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ npm install
14
+
15
+ # Lint
16
+ npx nx lint <%= name %>
17
+
18
+ # Type-check
19
+ npx nx run <%= name %>:check-types
20
+
21
+ # Test
22
+ npx nx test <%= name %>
23
+
24
+ # Deploy
25
+ npx nx run <%= name %>:deploy
26
+ ```
27
+
28
+ ## Structure
29
+
30
+ <%_ const usesCommerceLib = hasAdminUI || hasBusinessConfig || hasCommerceWebhooks; _%>
31
+ <%_ if (usesCommerceLib) { _%>
32
+ This app integrates with Adobe Commerce via App Management
33
+ (`@adobe/aio-commerce-lib-app`). The merchant-facing config, eventing, webhook
34
+ subscriptions, and custom install steps are all declared in
35
+ `app.commerce.config.ts`; the lib provisions them at install time.
36
+ <%_ if (hasAdminUI) { _%>
37
+
38
+ The admin UI lives under `src/commerce-backend-ui-1/`. Add pages and
39
+ components inside `web-src/src/components/`.
40
+ <%_ } _%>
41
+ <%_ } else { _%>
42
+ This is a standalone Adobe App Builder integration. Backend actions live under
43
+ `src/actions/`. There is no Commerce admin UI and no business configuration.
44
+ <%_ } _%>
@@ -0,0 +1,77 @@
1
+ <%_
2
+ const usesCommerceExtensions = hasAdminUI || hasBusinessConfig || hasCommerceWebhooks;
3
+ const hasAnyAction = hasRestActions || hasEvents || hasScheduledActions;
4
+ const preBuildSteps = ['./hooks/check-action-types.sh'];
5
+ if (hasAdminUI) preBuildSteps.push('./hooks/check-web-types.sh');
6
+ const preAppBuild = preBuildSteps.join(' && ');
7
+ _%>
8
+ application:
9
+ hooks:
10
+ pre-app-build: <%- preAppBuild %>
11
+ actions: src/actions
12
+ runtimeManifest:
13
+ packages:
14
+ <%= runtimePackageName %>:
15
+ license: Apache-2.0
16
+ <%_ if (!hasAnyAction) { _%>
17
+ actions: {}
18
+ <%_ } else { _%>
19
+ actions:
20
+ <%_ if (hasRestActions) { _%>
21
+ rest-sample:
22
+ function: src/actions/rest-sample.ts
23
+ web: 'yes'
24
+ runtime: nodejs:<%= nodeMajor %>
25
+ inputs:
26
+ LOG_LEVEL: debug
27
+ annotations:
28
+ require-adobe-auth: true
29
+ final: true
30
+ <%_ } _%>
31
+ <%_ if (hasEvents) { _%>
32
+ handle-sample-event:
33
+ function: src/actions/handle-sample-event.ts
34
+ web: 'yes'
35
+ runtime: nodejs:<%= nodeMajor %>
36
+ inputs:
37
+ LOG_LEVEL: debug
38
+ annotations:
39
+ require-adobe-auth: true
40
+ final: true
41
+ <%_ } _%>
42
+ <%_ if (hasScheduledActions) { _%>
43
+ cron-sample:
44
+ function: src/actions/cron-sample.ts
45
+ web: 'no'
46
+ runtime: nodejs:<%= nodeMajor %>
47
+ inputs:
48
+ LOG_LEVEL: debug
49
+ annotations:
50
+ final: true
51
+ <%_ } _%>
52
+ <%_ } _%>
53
+ <%_ if (hasScheduledActions) { _%>
54
+ triggers:
55
+ cron-sample-trigger:
56
+ feed: /whisk.system/alarms/alarm
57
+ inputs:
58
+ cron: '0 * * * *'
59
+ rules:
60
+ cron-sample-rule:
61
+ trigger: cron-sample-trigger
62
+ action: cron-sample
63
+ <%_ } _%>
64
+ <%_ if (usesCommerceExtensions) { _%>
65
+
66
+ extensions:
67
+ <%_ if (hasAdminUI) { _%>
68
+ commerce/backend-ui/1:
69
+ $include: src/commerce-backend-ui-1/ext.config.yaml
70
+ <%_ } _%>
71
+ <%_ if (hasBusinessConfig) { _%>
72
+ commerce/configuration/1:
73
+ $include: src/commerce-configuration-1/ext.config.yaml
74
+ <%_ } _%>
75
+ commerce/extensibility/1:
76
+ $include: src/commerce-extensibility-1/ext.config.yaml
77
+ <%_ } _%>
@@ -0,0 +1,6 @@
1
+ // Babel configuration allowing compilation of typescript files in both
2
+ // test and src/action folders
3
+ module.exports = {
4
+ presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
5
+ ignore: ['**/src/web/**', '**/node_modules/**'],
6
+ };
@@ -0,0 +1,8 @@
1
+ import { eslintConfigs } from '@aligent/ts-code-standards';
2
+
3
+ export default [
4
+ ...eslintConfigs.react,
5
+ {
6
+ ignores: ['**/*.js', '**/*.cjs', '**/*.mjs', '**/coverage'],
7
+ },
8
+ ];
@@ -0,0 +1,10 @@
1
+ # Type declarations for @adobe/aio-sdk
2
+
3
+ Although some of the modules contained within the sdk have type definitions, they are not exported by the sdk itself.
4
+ This folder declares a minimal module for the sdk.
5
+
6
+ ## Currently supported
7
+
8
+ - Core.Logger (from @adobe/aio-lib-core-logging)
9
+ - Core.Config (from @adobe/aio-lib-core-config)
10
+ - Events (from @adobe/aio-lib-events)
@@ -0,0 +1,15 @@
1
+ import Logger, { AioLoggerConfig } from '@adobe/aio-lib-core-logging';
2
+
3
+ /**
4
+ * In the official `AioLoggerConfig` type, `level` is defined as `string`, but the values accepted are:
5
+ * 'error', 'warn', 'info', 'verbose', 'debug', and 'silly'. See [Adobe Developer
6
+ * Doc](https://developer.adobe.com/commerce/extensibility/app-development/best-practices/logging-troubleshooting/#set-the-log-level)
7
+ * for reference.
8
+ */
9
+ type LogLevel = 'error' | 'warn' | 'info' | 'verbose' | 'debug' | 'silly';
10
+
11
+ declare module '@adobe/aio-sdk' {
12
+ export namespace Core {
13
+ export { Logger, AioLoggerConfig, LogLevel };
14
+ }
15
+ }
@@ -0,0 +1,43 @@
1
+ //
2
+ declare module '@adobe/aio-sdk' {
3
+ namespace Core {
4
+ // The types declared in @adobe/aio-lib-core-config are inaccurate, providing our own declaration here
5
+ class ConfigAPI {
6
+ /**
7
+ * Gets the value for a key in the Config.
8
+ * If no parameters are specified, it will return all keys and values of the consolidated Config.
9
+ * @param [key = ''] - the key to get the value from
10
+ * @param [source] - 'global', 'local', or 'env'. Defaults to searching the consolidated config.
11
+ */
12
+ get(key?: string, source?: string): string | Record<string, string>;
13
+ /**
14
+ * Set the value for a key in the Config.
15
+ * @param key - the key to set the value to
16
+ * @param value - the value to save for the key
17
+ * @param [local = false] - Set to true to save the value in the local config. Defaults to false (save to global config).
18
+ */
19
+ set(key: string, value: string, local?: boolean): ConfigAPI;
20
+ /**
21
+ * Delete a key and its value in the Config.
22
+ * @param key - the key to delete the value from
23
+ * @param [local = false] - Set to true to delete the value in the local config. Defaults to false (save to global config).
24
+ */
25
+ delete(key: string, local?: boolean): ConfigAPI;
26
+ /**
27
+ * Reload the Config from all the config file(s)
28
+ */
29
+ reload(): ConfigAPI;
30
+ /**
31
+ * Pipe data from stdin.
32
+ */
33
+ getPipedData(): Promise<string>;
34
+ /**
35
+ * Hoists variables in the ./.env file to process.env
36
+ * @param force - force the loading of the .env file
37
+ */
38
+ dotenv(force?: boolean): void;
39
+ }
40
+
41
+ const Config: ConfigAPI;
42
+ }
43
+ }
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo -e "\n⏩ Checking action types before build... 🔍\n"
4
+
5
+ if npx tsc --noEmit --project src/actions/tsconfig.json; then
6
+ echo -e "\n⏩ Action type checking completed successfully! ✅\n"
7
+ # Exiting with 0 allows the build to continue
8
+ exit 0
9
+ else
10
+ echo -e "\n⏩ Action type checking failed: ❌\n"
11
+ # Exiting with non-zero will cause the build to be skipped/failed
12
+ exit 1
13
+ fi
@@ -0,0 +1,3 @@
1
+ import { prettierConfig } from '@aligent/ts-code-standards';
2
+
3
+ export default prettierConfig;
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "sourceMap": true
5
+ },
6
+ "include": ["**/*.ts", "../../global-types"],
7
+ "exclude": []
8
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "allowImportingTsExtensions": true,
6
+ "baseUrl": "..",
7
+ "paths": {
8
+ "@/*": ["src/*"]
9
+ }
10
+ },
11
+ "include": ["**/*.test.ts", "../global-types"],
12
+ "exclude": []
13
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "@aligent/ts-code-standards/tsconfigs-base",
3
+ "compileOnSave": false,
4
+ "compilerOptions": {
5
+ "noEmit": true,
6
+ "allowImportingTsExtensions": true,
7
+ "baseUrl": "./src",
8
+ "paths": {
9
+ "@/*": ["*"]
10
+ }
11
+ },
12
+ "exclude": ["tests", "**/*.mjs", "**/*.cjs", "node_modules"],
13
+ "include": ["global-types"]
14
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./tsconfig.base.json"
3
+ }
@@ -0,0 +1,19 @@
1
+ import path from 'node:path';
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ environment: 'node',
7
+ include: [
8
+ 'tests/**/*.test.ts',
9
+ 'tests/**/*.test.tsx',
10
+ 'src/**/*.test.ts',
11
+ 'src/**/*.test.tsx',
12
+ ],
13
+ },
14
+ resolve: {
15
+ alias: {
16
+ '@': path.resolve(__dirname, 'src'),
17
+ },
18
+ },
19
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "displayName": "<%= displayName %>",
4
+ "description": "<%= description %>",
5
+ "platform": "web",
6
+ "id": "<%= extensionId %>",
7
+ "version": "1.0.0"
8
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo -e "\n⏩ Checking web types before build... 🔍\n"
4
+
5
+ if npx tsc --noEmit --project src/commerce-backend-ui-1/web-src/tsconfig.json; then
6
+ echo -e "\n⏩ Web type checking completed successfully! ✅\n"
7
+ exit 0
8
+ else
9
+ echo -e "\n⏩ Web type checking failed: ❌\n"
10
+ exit 1
11
+ fi
@@ -0,0 +1,32 @@
1
+ <%_ if (sidebarCategory !== 'none') { _%>
2
+ import { EXTENSION_ID } from '../../web-src/src/constants/extension.ts';
3
+
4
+ <%_ } _%>
5
+ export function main() {
6
+ return {
7
+ statusCode: 200,
8
+ body: {
9
+ registration: {
10
+ <%_ if (sidebarCategory !== 'none') { _%>
11
+ menuItems: [
12
+ {
13
+ id: `${EXTENSION_ID}::<%= appSlug %>`,
14
+ title: '<%= displayName %>',
15
+ parent: 'aligentApps::<%= sidebarCategory %>',
16
+ sortOrder: 10,
17
+ },
18
+ {
19
+ id: 'aligentApps::<%= sidebarCategory %>',
20
+ title: '<%= sidebarCategoryTitle %>',
21
+ isSection: true,
22
+ sortOrder: 20,
23
+ },
24
+ ],
25
+ <%_ } _%>
26
+ page: {
27
+ title: '<%= displayName %>',
28
+ },
29
+ },
30
+ },
31
+ };
32
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "sourceMap": true
5
+ },
6
+ "include": ["**/*.ts", "../../../global-types"],
7
+ "exclude": []
8
+ }