@adobe/aio-commerce-lib-app 1.7.0 → 1.8.0-beta-20260714082406

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 (93) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/dist/cjs/actions/app-config/index.cjs +41 -38
  3. package/dist/cjs/actions/app-config/index.d.cts +1 -1
  4. package/dist/cjs/actions/association/index.cjs +85 -0
  5. package/dist/cjs/actions/{registration → association}/index.d.cts +9 -13
  6. package/dist/cjs/actions/config/index.cjs +21 -32
  7. package/dist/cjs/actions/installation/index.cjs +72 -51
  8. package/dist/cjs/actions/installation/index.d.cts +2 -2
  9. package/dist/cjs/actions/scope-tree/index.cjs +18 -17
  10. package/dist/{es/app-DrYHK-z1.d.mts → cjs/app-D3P-Z6uY.d.cts} +1085 -1035
  11. package/dist/cjs/association-repository-BAs3-VkW.cjs +69 -0
  12. package/dist/cjs/commands/index.cjs +512 -298
  13. package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
  14. package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
  15. package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
  16. package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  17. package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  18. package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  19. package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  20. package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
  21. package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
  22. package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
  23. package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
  24. package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
  25. package/dist/cjs/config/index.browser.cjs +18 -0
  26. package/dist/cjs/config/index.browser.d.cts +16 -0
  27. package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
  28. package/dist/cjs/config/{index.d.cts → index.node.d.cts} +954 -386
  29. package/dist/cjs/define-DBxAlJfN.d.cts +34 -0
  30. package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
  31. package/dist/cjs/environment-B7EnozSg.cjs +135 -0
  32. package/dist/cjs/{index-B5gJ-q4U.d.cts → index-CzReNwbF.d.cts} +17 -12
  33. package/dist/cjs/index.cjs +250 -0
  34. package/dist/cjs/index.d.cts +217 -0
  35. package/dist/cjs/{config-D-s0GSep.cjs → index.node-Dz4lV4qe.cjs} +119 -35
  36. package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
  37. package/dist/cjs/management/index.cjs +1 -1
  38. package/dist/cjs/management/index.d.cts +1 -1
  39. package/dist/cjs/{management-Dehz9qSJ.cjs → management-B9ItB80R.cjs} +385 -582
  40. package/dist/cjs/{openapi-Cux6K4ZD.cjs → openapi-CwytYdWl.cjs} +476 -600
  41. package/dist/cjs/{router-BOR7T6qR.cjs → router-hA_Y9gZ1.cjs} +42 -44
  42. package/dist/cjs/{schemas-FngDuIeo.cjs → schemas-mLxMh_ko.cjs} +2 -2
  43. package/dist/cjs/utils-DSCmZ_iJ.cjs +408 -0
  44. package/dist/cjs/{validate-oAOpyFyb.cjs → validate-BfxhZ5Wv.cjs} +20 -20
  45. package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-B5tb9NeF.cjs} +159 -151
  46. package/dist/es/actions/app-config/index.d.mts +1 -1
  47. package/dist/es/actions/app-config/index.mjs +39 -36
  48. package/dist/es/actions/{registration → association}/index.d.mts +9 -13
  49. package/dist/es/actions/association/index.mjs +82 -0
  50. package/dist/es/actions/config/index.mjs +17 -28
  51. package/dist/es/actions/installation/index.d.mts +2 -2
  52. package/dist/es/actions/installation/index.mjs +69 -48
  53. package/dist/es/actions/scope-tree/index.mjs +14 -13
  54. package/dist/{cjs/app-DrYHK-z1.d.cts → es/app-D3P-Z6uY.d.mts} +1085 -1035
  55. package/dist/es/association-repository-BbQv9WCl.mjs +52 -0
  56. package/dist/es/commands/index.mjs +544 -328
  57. package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
  58. package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
  59. package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
  60. package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  61. package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  62. package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  63. package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  64. package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
  65. package/dist/es/commands/templates/app-management/association.js.template +6 -0
  66. package/dist/es/commands/templates/app-management/installation.js.template +1 -13
  67. package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
  68. package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
  69. package/dist/es/config/index.browser.d.mts +16 -0
  70. package/dist/es/config/index.browser.mjs +17 -0
  71. package/dist/es/config/{index.d.mts → index.node.d.mts} +954 -386
  72. package/dist/es/config/{index.mjs → index.node.mjs} +5 -4
  73. package/dist/es/define-EoYRZbpe.d.mts +34 -0
  74. package/dist/es/define-Z_Glf1-_.mjs +35 -0
  75. package/dist/es/environment-C84BPRJZ.mjs +104 -0
  76. package/dist/es/{index-DLMbTtKS.d.mts → index-D52xglhZ.d.mts} +17 -12
  77. package/dist/es/index.d.mts +217 -0
  78. package/dist/es/index.mjs +242 -0
  79. package/dist/es/{config-3I4eLyyR.mjs → index.node-CDH5gwJE.mjs} +94 -30
  80. package/dist/es/management/index.d.mts +1 -1
  81. package/dist/es/management/index.mjs +1 -1
  82. package/dist/es/{management-BUX-w2Ji.mjs → management-B89ApQVY.mjs} +353 -550
  83. package/dist/es/{openapi-B6uP0SRn.mjs → openapi-CXonvevE.mjs} +476 -600
  84. package/dist/es/{router-D58JJHHA.mjs → router-B_h0cvjc.mjs} +40 -42
  85. package/dist/es/utils-_gj8L6eN.mjs +289 -0
  86. package/dist/es/{validate-Dfajrp99.mjs → validate-9cRZWGrA.mjs} +17 -17
  87. package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-BBPbY2mb.mjs} +150 -142
  88. package/package.json +40 -17
  89. package/dist/cjs/actions/registration/index.cjs +0 -50
  90. package/dist/cjs/admin-ui-sdk-EU915zlR.d.cts +0 -664
  91. package/dist/es/actions/registration/index.mjs +0 -49
  92. package/dist/es/admin-ui-sdk-BwnD0xjK.d.mts +0 -664
  93. /package/dist/cjs/{chunk-Cozy-1ZF.cjs → rolldown-runtime-Cozy-1ZF.cjs} +0 -0
@@ -0,0 +1,242 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+ import { n as getAssociationData } from "./association-repository-BbQv9WCl.mjs";
16
+ import { n as EVENTS_STORAGE_KEY } from "./utils-_gj8L6eN.mjs";
17
+ import { AdobeCommerceHttpClient } from "@adobe/aio-commerce-lib-api";
18
+ import { CommerceSdkErrorBase } from "@adobe/aio-commerce-lib-core/error";
19
+ import { getSystemConfigByKey } from "@adobe/aio-commerce-lib-config";
20
+
21
+ //#region source/errors/app-not-associated-error.ts
22
+ const DEFAULT_MESSAGE = "App is not associated with a Commerce instance. Re-associate the app to resolve this error.";
23
+ /**
24
+ * Thrown when a runtime action calls `getCommerceInstance` or `getCommerceClient`
25
+ * but the app has no stored association data — for example, when the app has
26
+ * never been associated, has been unassociated, or was associated by an older
27
+ * SDK that did not store this data.
28
+ *
29
+ * Re-associating the app resolves the error.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { getCommerceClient, AppNotAssociatedError } from "@adobe/aio-commerce-lib-app";
34
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
35
+ *
36
+ * try {
37
+ * const client = await getCommerceClient(resolveImsAuthParams(params));
38
+ * // ... use client
39
+ * } catch (error) {
40
+ * if (error instanceof AppNotAssociatedError) {
41
+ * // handle the unassociated case (e.g. return a 400 response)
42
+ * }
43
+ * throw error;
44
+ * }
45
+ * ```
46
+ */
47
+ var AppNotAssociatedError = class extends CommerceSdkErrorBase {
48
+ constructor(message = DEFAULT_MESSAGE, options) {
49
+ super(message, options);
50
+ }
51
+ };
52
+
53
+ //#endregion
54
+ //#region source/access/commerce-instance.ts
55
+ /**
56
+ * Returns the Commerce instance this app is currently associated with.
57
+ *
58
+ * @throws {AppNotAssociatedError} If the app is not associated, was
59
+ * unassociated, or was associated by an older SDK that did not store this
60
+ * data. Re-associating the app resolves the error.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * import { getCommerceInstance } from "@adobe/aio-commerce-lib-app";
65
+ *
66
+ * export async function main() {
67
+ * const instance = await getCommerceInstance();
68
+ *
69
+ * // instance.baseUrl — e.g. "https://my-store.example.com"
70
+ * // instance.env — "saas" | "paas"
71
+ * }
72
+ * ```
73
+ */
74
+ async function getCommerceInstance() {
75
+ const instance = await getAssociationData();
76
+ if (instance === null) throw new AppNotAssociatedError();
77
+ return instance;
78
+ }
79
+ /**
80
+ * Returns an initialised `AdobeCommerceHttpClient` for the Commerce instance
81
+ * this app is currently associated with.
82
+ *
83
+ * The base URL and flavor come from the stored association data
84
+ * ({@link getCommerceInstance}); the caller supplies the resolved IMS auth.
85
+ *
86
+ * @param auth - Resolved IMS auth params or an IMS auth provider.
87
+ * @param fetchOptions - Optional global fetch options forwarded to the
88
+ * underlying `AdobeCommerceHttpClient` (e.g. `headers`, `timeout`, `retry`).
89
+ * @throws {AppNotAssociatedError} If the app is not associated, was
90
+ * unassociated, or was associated by an older SDK that did not store this
91
+ * data. Re-associating the app resolves the error.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * import { getCommerceClient } from "@adobe/aio-commerce-lib-app";
96
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
97
+ *
98
+ * export async function main(params) {
99
+ * const client = await getCommerceClient(resolveImsAuthParams(params));
100
+ * const products = await client.get("products").json();
101
+ * }
102
+ * ```
103
+ */
104
+ async function getCommerceClient(auth, fetchOptions) {
105
+ const instance = await getCommerceInstance();
106
+ return new AdobeCommerceHttpClient({
107
+ auth,
108
+ config: {
109
+ baseUrl: instance.baseUrl,
110
+ flavor: instance.env
111
+ },
112
+ fetchOptions
113
+ });
114
+ }
115
+
116
+ //#endregion
117
+ //#region source/errors/publish-event-errors.ts
118
+ /**
119
+ * Base error thrown by {@link publishEvent} when event resolution or publishing fails.
120
+ * Catch this to handle all publish-event failures in a single clause.
121
+ */
122
+ var PublishEventError = class extends CommerceSdkErrorBase {};
123
+ /**
124
+ * Thrown when {@link publishEvent} cannot find the eventing installation data in system storage.
125
+ *
126
+ * This typically means the app installation has not run yet, or ran with an older SDK version
127
+ * that did not write event provider metadata to storage. Re-running the installation resolves it.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * try {
132
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
133
+ * } catch (error) {
134
+ * if (error instanceof EventsDataNotInitializedError) {
135
+ * // Prompt re-installation
136
+ * }
137
+ * }
138
+ * ```
139
+ */
140
+ var EventsDataNotInitializedError = class extends PublishEventError {
141
+ constructor() {
142
+ super("No eventing installation data found. Re-run the app installation to initialize event provider metadata.");
143
+ }
144
+ };
145
+ /**
146
+ * Thrown when the provider key passed to {@link publishEvent} does not match any provider
147
+ * declared in the app's eventing configuration.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * try {
152
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
153
+ * } catch (error) {
154
+ * if (error instanceof ProviderNotFoundError) {
155
+ * // "order-events" was not found — check app.commerce.config.ts
156
+ * }
157
+ * }
158
+ * ```
159
+ */
160
+ var ProviderNotFoundError = class extends PublishEventError {
161
+ constructor(providerKey) {
162
+ super(`No event provider with key '${providerKey}' found in the app eventing configuration.`);
163
+ }
164
+ };
165
+ /**
166
+ * Thrown when the event name passed to {@link publishEvent} does not match any event
167
+ * declared under the given provider in the app's eventing configuration.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * try {
172
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
173
+ * } catch (error) {
174
+ * if (error instanceof EventNotFoundError) {
175
+ * // "order.created" was not found under "order-events" — check app.commerce.config.ts
176
+ * }
177
+ * }
178
+ * ```
179
+ */
180
+ var EventNotFoundError = class extends PublishEventError {
181
+ constructor(eventName, providerKey) {
182
+ super(`No event named '${eventName}' found under provider '${providerKey}'.`);
183
+ }
184
+ };
185
+
186
+ //#endregion
187
+ //#region source/access/events.ts
188
+ /**
189
+ * Publishes an event declared in the app's eventing configuration.
190
+ *
191
+ * Resolves the provider key and event name to their respective I/O Events IDs from
192
+ * data written to system storage at installation time, then delegates the HTTP call
193
+ * to the given client. No management API round-trip is needed at runtime.
194
+ *
195
+ * @param params.client - An {@link AdobeIoEventsApiClient} configured with the correct IMS auth.
196
+ * @param params.provider - The `key` of an event provider declared in `app.commerce.config.ts`.
197
+ * @param params.event - The `name` of an event within that provider.
198
+ * @param params.payload - The event payload. Must be a JSON object.
199
+ *
200
+ * @throws {EventsDataNotInitializedError} If no eventing installation data is found in system storage.
201
+ * @throws {ProviderNotFoundError} If the provider key is not found in the stored data.
202
+ * @throws {EventNotFoundError} If the event name is not found under the given provider.
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * import { publishEvent } from "@adobe/aio-commerce-lib-app";
207
+ * import { createAdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events";
208
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
209
+ *
210
+ * export async function main(params) {
211
+ * const client = createAdobeIoEventsApiClient({
212
+ * auth: resolveImsAuthParams(params),
213
+ * config: { ingressBaseUrl: params.AIO_EVENTS_INGRESS_BASE_URL },
214
+ * });
215
+ *
216
+ * await publishEvent({
217
+ * client,
218
+ * provider: "order-events",
219
+ * event: "order.created",
220
+ * payload: { orderId: "100000123", total: 149.99 },
221
+ * });
222
+ * }
223
+ * ```
224
+ */
225
+ async function publishEvent(params) {
226
+ const { client, provider: providerKey, event: eventName, payload } = params;
227
+ const data = await getSystemConfigByKey(EVENTS_STORAGE_KEY);
228
+ if (!data) throw new EventsDataNotInitializedError();
229
+ const providerEntry = data.providers[providerKey];
230
+ if (!providerEntry) throw new ProviderNotFoundError(providerKey);
231
+ const eventEntry = providerEntry.events[eventName];
232
+ if (!eventEntry) throw new EventNotFoundError(eventName, providerKey);
233
+ await client.publishEvent({
234
+ eventCode: eventEntry.code,
235
+ isPhiData: eventEntry.isPhiData,
236
+ payload,
237
+ providerId: providerEntry.id
238
+ });
239
+ }
240
+
241
+ //#endregion
242
+ export { AppNotAssociatedError, EventNotFoundError, EventsDataNotInitializedError, ProviderNotFoundError, PublishEventError, getCommerceClient, getCommerceInstance, publishEvent };
@@ -13,33 +13,16 @@
13
13
  */
14
14
 
15
15
  import { t as stringifyError } from "./error-_RMwtrUA.mjs";
16
- import { t as validateCommerceAppConfig } from "./validate-Dfajrp99.mjs";
16
+ import { t as validateCommerceAppConfig } from "./validate-9cRZWGrA.mjs";
17
17
  import { dirname, join, parse } from "path";
18
18
  import { existsSync } from "fs";
19
19
  import { access, mkdir, readFile } from "fs/promises";
20
+ import NpmPackageJson from "@npmcli/package-json";
21
+ import { getPackageInfo } from "local-pkg";
20
22
  import { resolveCommand } from "package-manager-detector";
21
23
  import { detect, getUserAgent } from "package-manager-detector/detect";
24
+ import { satisfies, validRange } from "semver";
22
25
 
23
- //#region source/config/lib/define.ts
24
- /**
25
- * Helper to type-safely define the app config.
26
- * @param config - The app config to define.
27
- *
28
- * @example
29
- * ```typescript
30
- * import { defineConfig } from "@adobe/aio-commerce-lib-app";
31
- *
32
- * // In app.commerce.config.js
33
- * export default defineConfig({
34
- * // You get autocompletion and type-safety for the config object.
35
- * businessConfig: { ... }
36
- * });
37
- */
38
- function defineConfig(config) {
39
- return config;
40
- }
41
-
42
- //#endregion
43
26
  //#region ../../packages-private/scripting-utils/source/project.ts
44
27
  /**
45
28
  * This module exports shared project utilities for the AIO Commerce SDK.
@@ -57,7 +40,7 @@ async function findUp(name, options = {}) {
57
40
  const { root } = parse(cwd);
58
41
  const stopAt = options.stopAt || root;
59
42
  let currentDir = cwd;
60
- while (true) {
43
+ for (;;) {
61
44
  for (const fileName of names) {
62
45
  const filePath = join(currentDir, fileName);
63
46
  try {
@@ -88,6 +71,72 @@ async function readPackageJson(cwd = process.cwd()) {
88
71
  return JSON.parse(await readFile(packageJsonPath, "utf-8"));
89
72
  }
90
73
  /**
74
+ * Load the nearest package.json file with npmcli's package.json helper.
75
+ * @param cwd The current working directory
76
+ */
77
+ async function loadPackageJson(cwd = process.cwd()) {
78
+ const packageJsonPath = await findNearestPackageJson(cwd);
79
+ if (!packageJsonPath) return null;
80
+ return NpmPackageJson.load(dirname(packageJsonPath));
81
+ }
82
+ /**
83
+ * Convert package.json dependencies into a dependency map that can be written back.
84
+ * @param dependencies - Dependency map read from package.json.
85
+ */
86
+ function toWritablePackageJsonDependencies(dependencies) {
87
+ return Object.fromEntries(Object.entries(dependencies).filter((entry) => Boolean(entry[1])));
88
+ }
89
+ /**
90
+ * Resolve the installed package version from a project root.
91
+ * @param packageName - Package name to resolve.
92
+ * @param cwd - Project directory to resolve from.
93
+ */
94
+ async function getInstalledPackageVersion(packageName, cwd = process.cwd()) {
95
+ return (await getPackageInfo(packageName, { paths: [cwd] }))?.version ?? null;
96
+ }
97
+ /**
98
+ * Resolve which dependencies are missing or installed with incompatible versions.
99
+ *
100
+ * Installed package versions are compared with `semver.satisfies`. Declared
101
+ * package.json ranges are not used as compatibility proof because they can
102
+ * differ from what is actually installed.
103
+ *
104
+ * @param requiredDependencies - Dependencies that should exist.
105
+ * @param cwd - Project directory to resolve installed packages from.
106
+ */
107
+ async function getPackageDependencyInstallPlan(requiredDependencies, cwd = process.cwd()) {
108
+ const plan = {
109
+ incompatible: [],
110
+ missing: []
111
+ };
112
+ const installedVersions = await Promise.all(requiredDependencies.map((dependency) => getInstalledPackageVersion(dependency.name, cwd)));
113
+ requiredDependencies.forEach((dependency, index) => {
114
+ const installedVersion = installedVersions[index];
115
+ if (installedVersion === null) {
116
+ plan.missing.push(dependency);
117
+ return;
118
+ }
119
+ if (validRange(dependency.version) === null) return;
120
+ if (!satisfies(installedVersion, dependency.version, { includePrerelease: true })) plan.incompatible.push({
121
+ ...dependency,
122
+ installedVersion
123
+ });
124
+ });
125
+ return plan;
126
+ }
127
+ /**
128
+ * Merge required dependencies into a package.json dependency map when they are missing.
129
+ *
130
+ * @param dependencies - Dependency map to update.
131
+ * @param requiredDependencies - Dependencies that should exist.
132
+ * @param dependencyMaps - Package dependency maps to compare against.
133
+ */
134
+ function mergePackageJsonDependencies(dependencies, requiredDependencies, dependencyMaps = [dependencies]) {
135
+ const nextDependencies = toWritablePackageJsonDependencies(dependencies);
136
+ for (const { name, version } of requiredDependencies) if (!dependencyMaps.some((dependencyMap) => name in dependencyMap)) nextDependencies[name] = version;
137
+ return nextDependencies;
138
+ }
139
+ /**
91
140
  * Check if the current working directory is an ESM project.
92
141
  * @param cwd The current working directory
93
142
  */
@@ -120,6 +169,12 @@ const VALID_PACKAGE_MANAGERS = [
120
169
  "yarn",
121
170
  "bun"
122
171
  ];
172
+ const DEV_DEPENDENCY_INSTALL_FLAGS = {
173
+ bun: "--dev",
174
+ npm: "--save-dev",
175
+ pnpm: "--save-dev",
176
+ yarn: "--dev"
177
+ };
123
178
  /**
124
179
  * Type guard asserting that a value is a supported `PackageManager`.
125
180
  * @param value - The value to check
@@ -153,16 +208,25 @@ function getExecCommand(packageManager) {
153
208
  * manager (e.g. `pnpm add foo bar`, `npm i foo bar`).
154
209
  * @param packageManager - The detected package manager
155
210
  * @param packages - Package specifiers to install (e.g. `["foo@^1.0"]`)
211
+ * @param options - Install command options.
156
212
  */
157
- function getInstallCommand(packageManager, packages) {
158
- const resolved = resolveCommand(packageManager, "add", packages);
159
- if (!resolved) return {
160
- command: "npm",
161
- args: ["install", ...packages]
213
+ function getInstallCommand(packageManager, packages, options = {}) {
214
+ const installArgs = options.dev ? [DEV_DEPENDENCY_INSTALL_FLAGS[packageManager], ...packages] : packages;
215
+ const resolved = resolveCommand(packageManager, "add", installArgs);
216
+ return {
217
+ args: resolved?.args.filter(Boolean) ?? ["install", ...installArgs],
218
+ command: resolved?.command ?? "npm"
162
219
  };
220
+ }
221
+ /**
222
+ * Get the command that installs a project's declared dependencies.
223
+ * @param packageManager - The detected package manager
224
+ */
225
+ function getProjectInstallCommand(packageManager) {
226
+ const resolved = resolveCommand(packageManager, "install", []);
163
227
  return {
164
- args: resolved.args.filter((a) => Boolean(a)),
165
- command: resolved.command
228
+ args: resolved?.args.filter(Boolean) ?? ["install"],
229
+ command: resolved?.command ?? "npm"
166
230
  };
167
231
  }
168
232
 
@@ -242,4 +306,4 @@ async function parseCommerceAppConfig(cwd = process.cwd()) {
242
306
  }
243
307
 
244
308
  //#endregion
245
- export { getExecCommand as a, isESM as c, defineConfig as d, detectPackageManager as i, makeOutputDirFor as l, readCommerceAppConfig as n, getInstallCommand as o, resolveCommerceAppConfig as r, getProjectRootDirectory as s, parseCommerceAppConfig as t, readPackageJson as u };
309
+ export { getExecCommand as a, getProjectInstallCommand as c, loadPackageJson as d, makeOutputDirFor as f, detectPackageManager as i, getProjectRootDirectory as l, readPackageJson as m, readCommerceAppConfig as n, getInstallCommand as o, mergePackageJsonDependencies as p, resolveCommerceAppConfig as r, getPackageDependencyInstallPlan as s, parseCommerceAppConfig as t, isESM as u };
@@ -12,5 +12,5 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { $ as StepContextFactory, A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, G as BranchStep, H as isInProgressState, I as InstallationState, J as InferStepOutput, K as BranchStepOptions, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, Q as Step, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, W as AnyStep, X as LeafStep, Y as InstallationContext, Z as LeafStepOptions, _ as ValidationSummary, a as RunValidationOptions, at as ValidationIssueSeverity, b as ExecuteWorkflowOptions, c as runInstallation, ct as isBranchStep, d as CustomInstallationStepDefinition, et as StepMeta, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, it as ValidationIssue, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, lt as isLeafStep, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, nt as ValidationContext, o as createInitialInstallationState, ot as defineBranchStep, p as defineCustomInstallationStep, q as ExecutionContext, r as RunInstallationOptions, rt as ValidationExecutionContext, s as createInitialUninstallationState, st as defineLeafStep, t as CreateInitialInstallationStateOptions, tt as StepMetaInfo, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-DLMbTtKS.mjs";
15
+ import { $ as StepContextFactory, A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, G as BranchStep, H as isInProgressState, I as InstallationState, J as InferStepOutput, K as BranchStepOptions, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, Q as Step, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, W as AnyStep, X as LeafStep, Y as InstallationContext, Z as LeafStepOptions, _ as ValidationSummary, a as RunValidationOptions, at as ValidationIssueSeverity, b as ExecuteWorkflowOptions, c as runInstallation, ct as isBranchStep, d as CustomInstallationStepDefinition, et as StepMeta, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, it as ValidationIssue, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, lt as isLeafStep, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, nt as ValidationContext, o as createInitialInstallationState, ot as defineBranchStep, p as defineCustomInstallationStep, q as ExecutionContext, r as RunInstallationOptions, rt as ValidationExecutionContext, s as createInitialUninstallationState, st as defineLeafStep, t as CreateInitialInstallationStateOptions, tt as StepMetaInfo, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-D52xglhZ.mjs";
16
16
  export { type AnyStep, type BranchStep, type BranchStepOptions, type CreateInitialInstallationStateOptions, type CreateInitialStateOptions, type CreateInitialUninstallationStateOptions, type CustomInstallationStepDefinition, type CustomInstallationStepHandler, type ExecuteWorkflowOptions, type ExecutionContext, type ExecutionStatus, type FailedInstallationState, type InProgressInstallationState, type InferStepOutput, type InstallationContext, type InstallationData, type InstallationError, type InstallationHooks, type InstallationRetryMetadata, type InstallationState, type InstallationStatus, type LeafStep, type LeafStepOptions, type RunInstallationOptions, type RunUninstallationOptions, type RunValidationOptions, type Step, type StepContextFactory, type StepEvent, type StepFailedEvent, type StepMeta, type StepMetaInfo, type StepStartedEvent, type StepStatus, type StepSucceededEvent, type StepValidationResult, type SucceededInstallationState, type ValidateStepTreeOptions, type ValidationContext, type ValidationExecutionContext, type ValidationIssue, type ValidationIssueSeverity, type ValidationResult, type ValidationSummary, createInitialInstallationState, type createInitialState, createInitialUninstallationState, type createRetryState, type defineBranchStep, defineCustomInstallationStep, type defineLeafStep, type executeUninstallWorkflow, type executeWorkflow, type isBranchStep, isCompletedState, isFailedState, isInProgressState, type isLeafStep, isSucceededState, runInstallation, runUninstallation, runValidation, type validateStepTree };
@@ -12,6 +12,6 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, o as defineCustomInstallationStep, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../management-BUX-w2Ji.mjs";
15
+ import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, o as defineCustomInstallationStep, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../management-B89ApQVY.mjs";
16
16
 
17
17
  export { createInitialInstallationState, createInitialUninstallationState, defineCustomInstallationStep, isCompletedState, isFailedState, isInProgressState, isSucceededState, runInstallation, runUninstallation, runValidation };