@adobe/aio-commerce-lib-app 1.7.0 → 1.8.0-alpha-20260722091448
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.
- package/CHANGELOG.md +92 -0
- package/dist/cjs/actions/app-config/index.cjs +41 -38
- package/dist/cjs/actions/app-config/index.d.cts +1 -1
- package/dist/cjs/actions/association/index.cjs +85 -0
- package/dist/cjs/actions/{registration → association}/index.d.cts +9 -13
- package/dist/cjs/actions/config/index.cjs +21 -32
- package/dist/cjs/actions/installation/index.cjs +72 -51
- package/dist/cjs/actions/installation/index.d.cts +2 -2
- package/dist/cjs/actions/scope-tree/index.cjs +18 -17
- package/dist/{es/app-DrYHK-z1.d.mts → cjs/app-BwehWeu1.d.cts} +1237 -1031
- package/dist/cjs/commands/index.cjs +523 -301
- package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +12 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +16 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
- package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
- package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
- package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
- package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
- package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
- package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
- package/dist/cjs/config/index.browser.cjs +18 -0
- package/dist/cjs/config/index.browser.d.cts +16 -0
- package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
- package/dist/{es/config/index.d.mts → cjs/config/index.node.d.cts} +1065 -394
- package/dist/cjs/define-DOqVyexT.d.cts +34 -0
- package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
- package/dist/cjs/environment-B7EnozSg.cjs +135 -0
- package/dist/cjs/{index-B5gJ-q4U.d.cts → index-B3ISkC54.d.cts} +17 -12
- package/dist/cjs/index.cjs +268 -0
- package/dist/cjs/index.d.cts +230 -0
- package/dist/cjs/{config-D-s0GSep.cjs → index.node-BWZuZLgs.cjs} +144 -44
- package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +1 -1
- package/dist/cjs/{management-Dehz9qSJ.cjs → management-DEsRVP2L.cjs} +385 -582
- package/dist/cjs/{openapi-Cux6K4ZD.cjs → openapi-CwytYdWl.cjs} +476 -600
- package/dist/cjs/repository-CbceYZqc.cjs +69 -0
- package/dist/cjs/{router-BOR7T6qR.cjs → router-hA_Y9gZ1.cjs} +42 -44
- package/dist/cjs/{schemas-FngDuIeo.cjs → schemas-mLxMh_ko.cjs} +2 -2
- package/dist/cjs/utils-DSCmZ_iJ.cjs +408 -0
- package/dist/cjs/{validate-oAOpyFyb.cjs → validate-C_eCKp21.cjs} +21 -21
- package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-L4DWHSOl.cjs} +159 -151
- package/dist/es/actions/app-config/index.d.mts +1 -1
- package/dist/es/actions/app-config/index.mjs +39 -36
- package/dist/es/actions/{registration → association}/index.d.mts +9 -13
- package/dist/es/actions/association/index.mjs +82 -0
- package/dist/es/actions/config/index.mjs +17 -28
- package/dist/es/actions/installation/index.d.mts +2 -2
- package/dist/es/actions/installation/index.mjs +69 -48
- package/dist/es/actions/scope-tree/index.mjs +14 -13
- package/dist/{cjs/app-DrYHK-z1.d.cts → es/app-BwehWeu1.d.mts} +1237 -1031
- package/dist/es/commands/index.mjs +556 -332
- package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
- package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
- package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +12 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +16 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
- package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
- package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
- package/dist/es/commands/templates/app-management/association.js.template +6 -0
- package/dist/es/commands/templates/app-management/installation.js.template +1 -13
- package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
- package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
- package/dist/es/config/index.browser.d.mts +16 -0
- package/dist/es/config/index.browser.mjs +17 -0
- package/dist/{cjs/config/index.d.cts → es/config/index.node.d.mts} +1066 -393
- package/dist/es/config/{index.mjs → index.node.mjs} +5 -4
- package/dist/es/define-DxH1BFia.d.mts +34 -0
- package/dist/es/define-Z_Glf1-_.mjs +35 -0
- package/dist/es/environment-C84BPRJZ.mjs +104 -0
- package/dist/es/{index-DLMbTtKS.d.mts → index-DSk-RmwM.d.mts} +17 -12
- package/dist/es/index.d.mts +230 -0
- package/dist/es/index.mjs +259 -0
- package/dist/es/{config-3I4eLyyR.mjs → index.node-DuvW9Sha.mjs} +113 -39
- package/dist/es/management/index.d.mts +1 -1
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-BUX-w2Ji.mjs → management-D5pmBBec.mjs} +353 -550
- package/dist/es/{openapi-B6uP0SRn.mjs → openapi-CXonvevE.mjs} +476 -600
- package/dist/es/repository-BGmy0YeZ.mjs +52 -0
- package/dist/es/{router-D58JJHHA.mjs → router-B_h0cvjc.mjs} +40 -42
- package/dist/es/utils-_gj8L6eN.mjs +289 -0
- package/dist/es/{validate-Dfajrp99.mjs → validate-t0T0F2MF.mjs} +18 -18
- package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-D7DExIDM.mjs} +150 -142
- package/package.json +40 -17
- package/dist/cjs/actions/registration/index.cjs +0 -50
- package/dist/cjs/admin-ui-sdk-EU915zlR.d.cts +0 -664
- package/dist/es/actions/registration/index.mjs +0 -49
- package/dist/es/admin-ui-sdk-BwnD0xjK.d.mts +0 -664
- /package/dist/cjs/{chunk-Cozy-1ZF.cjs → rolldown-runtime-Cozy-1ZF.cjs} +0 -0
|
@@ -13,37 +13,34 @@
|
|
|
13
13
|
* governing permissions and limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const require_rolldown_runtime = require('../rolldown-runtime-Cozy-1ZF.cjs');
|
|
17
17
|
const require_error = require('../error-D-N0PKSl.cjs');
|
|
18
|
-
const
|
|
19
|
-
const require_webhooks = require('../webhooks-
|
|
20
|
-
const require_validate = require('../validate-
|
|
21
|
-
const require_logging = require('../logging-
|
|
18
|
+
const require_index_node = require('../index.node-BWZuZLgs.cjs');
|
|
19
|
+
const require_webhooks = require('../webhooks-L4DWHSOl.cjs');
|
|
20
|
+
const require_validate = require('../validate-C_eCKp21.cjs');
|
|
21
|
+
const require_logging = require('../logging-udPuAJPt.cjs');
|
|
22
|
+
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
22
23
|
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
23
24
|
let consola = require("consola");
|
|
24
|
-
consola =
|
|
25
|
+
consola = require_rolldown_runtime.__toESM(consola, 1);
|
|
26
|
+
let child_process = require("child_process");
|
|
25
27
|
let path = require("path");
|
|
26
|
-
path =
|
|
27
|
-
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
28
|
-
let prettier = require("prettier");
|
|
29
|
-
prettier = require_chunk.__toESM(prettier, 1);
|
|
28
|
+
path = require_rolldown_runtime.__toESM(path, 1);
|
|
30
29
|
let fs = require("fs");
|
|
31
30
|
let fs_promises = require("fs/promises");
|
|
31
|
+
let prettier = require("prettier");
|
|
32
|
+
prettier = require_rolldown_runtime.__toESM(prettier, 1);
|
|
32
33
|
let url = require("url");
|
|
33
34
|
let yaml = require("yaml");
|
|
34
|
-
let _npmcli_package_json = require("@npmcli/package-json");
|
|
35
|
-
_npmcli_package_json = require_chunk.__toESM(_npmcli_package_json, 1);
|
|
36
35
|
let consola_utils = require("consola/utils");
|
|
37
36
|
let esbuild = require("esbuild");
|
|
38
37
|
let safe_stable_stringify = require("safe-stable-stringify");
|
|
39
|
-
safe_stable_stringify = require_chunk.__toESM(safe_stable_stringify, 1);
|
|
40
|
-
let child_process = require("child_process");
|
|
41
38
|
let _adobe_aio_lib_core_config = require("@adobe/aio-lib-core-config");
|
|
42
|
-
_adobe_aio_lib_core_config =
|
|
39
|
+
_adobe_aio_lib_core_config = require_rolldown_runtime.__toESM(_adobe_aio_lib_core_config, 1);
|
|
43
40
|
let _adobe_aio_lib_ims = require("@adobe/aio-lib-ims");
|
|
44
|
-
_adobe_aio_lib_ims =
|
|
41
|
+
_adobe_aio_lib_ims = require_rolldown_runtime.__toESM(_adobe_aio_lib_ims, 1);
|
|
45
42
|
let dotenv = require("dotenv");
|
|
46
|
-
dotenv =
|
|
43
|
+
dotenv = require_rolldown_runtime.__toESM(dotenv, 1);
|
|
47
44
|
|
|
48
45
|
//#region source/commands/constants.ts
|
|
49
46
|
/** The name of the package containing all the generated runtime actions */
|
|
@@ -58,12 +55,8 @@ const GENERATED_ACTIONS_PATH = `${GENERATED_PATH}/${ACTIONS_FOLDER}`;
|
|
|
58
55
|
const EXTENSIBILITY_EXTENSION_POINT_ID = "commerce/extensibility/1";
|
|
59
56
|
/** The name of the extension point for configuration. */
|
|
60
57
|
const CONFIGURATION_EXTENSION_POINT_ID = "commerce/configuration/1";
|
|
61
|
-
/** The name of the extension point for Admin UI
|
|
62
|
-
const
|
|
63
|
-
/** The name of the package containing the admin UI SDK generated actions */
|
|
64
|
-
const ADMIN_UI_SDK_PACKAGE_NAME = "admin-ui-sdk";
|
|
65
|
-
/** The path to the directory containing the generated Admin UI SDK actions. */
|
|
66
|
-
const ADMIN_UI_SDK_ACTIONS_PATH = `${GENERATED_PATH}/actions/registration`;
|
|
58
|
+
/** The name of the extension point for Admin UI. */
|
|
59
|
+
const BACKEND_UI_V2_EXTENSION_POINT_ID = "commerce/backend-ui/2";
|
|
67
60
|
/** The name of the configuration schema file */
|
|
68
61
|
const APP_MANIFEST_FILE = "app.commerce.manifest.json";
|
|
69
62
|
/** The name of the generated runtime-safe app config module (dynamic schemas only). */
|
|
@@ -90,25 +83,63 @@ function getExtensionPointFolderPath(extensionPointId) {
|
|
|
90
83
|
/** Format file content using prettier, inferring the parser from the file path. */
|
|
91
84
|
function prettierFormat(content, filepath) {
|
|
92
85
|
return prettier.format(content, {
|
|
93
|
-
semi: true,
|
|
94
|
-
quoteStyle: "double",
|
|
95
86
|
arrowParens: "always",
|
|
96
87
|
bracketSameLine: true,
|
|
97
88
|
bracketSpacing: true,
|
|
98
|
-
|
|
99
|
-
tabWidth: 2,
|
|
100
|
-
useTabs: false,
|
|
89
|
+
filepath,
|
|
101
90
|
printWidth: 80,
|
|
102
|
-
|
|
91
|
+
quoteStyle: "double",
|
|
92
|
+
semi: true,
|
|
93
|
+
tabWidth: 2,
|
|
94
|
+
trailingComma: "all",
|
|
95
|
+
useTabs: false
|
|
103
96
|
});
|
|
104
97
|
}
|
|
105
98
|
/** Load the app commerce config */
|
|
106
99
|
async function loadAppManifest() {
|
|
107
|
-
const appConfig = await
|
|
100
|
+
const appConfig = await require_index_node.parseCommerceAppConfig();
|
|
108
101
|
consola.default.debug("Loaded app commerce config");
|
|
109
102
|
return appConfig;
|
|
110
103
|
}
|
|
111
104
|
/**
|
|
105
|
+
* Install the given dependencies.
|
|
106
|
+
* @param packageManager - The detected package manager.
|
|
107
|
+
* @param dependencies - Package specifiers to install; no-op when empty.
|
|
108
|
+
* @param cwd - Working directory for the install command.
|
|
109
|
+
* @param options - Install command options.
|
|
110
|
+
*/
|
|
111
|
+
function runInstall(packageManager, dependencies, cwd = process.cwd(), options = {}) {
|
|
112
|
+
if (dependencies.length === 0) return;
|
|
113
|
+
const dependencyListString = dependencies.map((dependency) => ` - ${dependency}`).join("\n");
|
|
114
|
+
consola.default.start([`Installing the following dependencies with ${packageManager}:\n${dependencyListString}\n`, "This may take a few seconds...\n"].join("\n"));
|
|
115
|
+
const { command, args } = require_index_node.getInstallCommand(packageManager, dependencies, options);
|
|
116
|
+
const displayCommand = [command, ...args].join(" ");
|
|
117
|
+
const result = (0, child_process.spawnSync)(command, args, {
|
|
118
|
+
cwd,
|
|
119
|
+
stdio: "inherit"
|
|
120
|
+
});
|
|
121
|
+
if (result.error || result.status !== 0) throw new Error(`Failed to install dependencies automatically. Please install manually: ${displayCommand}`, { cause: result.error ?? /* @__PURE__ */ new Error(`Install exited with code ${result.status}`) });
|
|
122
|
+
consola.default.log("");
|
|
123
|
+
consola.default.success("Dependencies installed successfully");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Install dependencies declared in package.json.
|
|
127
|
+
* @param packageManager - The detected package manager.
|
|
128
|
+
* @param cwd - Working directory for the install command.
|
|
129
|
+
*/
|
|
130
|
+
function runProjectInstall(packageManager, cwd = process.cwd()) {
|
|
131
|
+
consola.default.start([`Installing project dependencies with ${packageManager}...`, "This may take a few seconds...\n"].join("\n"));
|
|
132
|
+
const { command, args } = require_index_node.getProjectInstallCommand(packageManager);
|
|
133
|
+
const displayCommand = [command, ...args].join(" ");
|
|
134
|
+
const result = (0, child_process.spawnSync)(command, args, {
|
|
135
|
+
cwd,
|
|
136
|
+
stdio: "inherit"
|
|
137
|
+
});
|
|
138
|
+
if (result.error || result.status !== 0) throw new Error(`Failed to install dependencies automatically. Please install manually: ${displayCommand}`, { cause: result.error ?? /* @__PURE__ */ new Error(`Install exited with code ${result.status}`) });
|
|
139
|
+
consola.default.log("");
|
|
140
|
+
consola.default.success("Dependencies installed successfully");
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
112
143
|
* Whether the app config contains anything that can't be JSON-serialized as-is
|
|
113
144
|
* and therefore requires generating a runtime-safe ESM config module.
|
|
114
145
|
*/
|
|
@@ -116,6 +147,10 @@ function hasDynamicAppConfig(appConfig) {
|
|
|
116
147
|
const schema = appConfig.businessConfig?.schema;
|
|
117
148
|
return Array.isArray(schema) && (0, _adobe_aio_commerce_lib_config.hasDynamicSchema)(schema);
|
|
118
149
|
}
|
|
150
|
+
/** Whether preserving the app config requires generating a JavaScript module. */
|
|
151
|
+
async function requiresJavaScriptAppConfig(appConfig) {
|
|
152
|
+
return hasDynamicAppConfig(appConfig) || await require_index_node.hasNamedCommerceAppConfigExports();
|
|
153
|
+
}
|
|
119
154
|
/**
|
|
120
155
|
* Path to an extension point's `.generated` directory, relative to the project root.
|
|
121
156
|
* @param extensionPointId - The extension point ID, e.g. "commerce/extensibility/1"
|
|
@@ -145,20 +180,6 @@ function getActionPath(extensionPointId, actionName) {
|
|
|
145
180
|
function getExtConfigPath(extensionPointId) {
|
|
146
181
|
return (0, path.join)(getExtensionPointFolderPath(extensionPointId), "ext.config.yaml");
|
|
147
182
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Path to an Admin UI SDK generated actions directory, relative to the project root.
|
|
150
|
-
* @param extensionPointId - The extension point ID, e.g. "commerce/backend-ui/1"
|
|
151
|
-
*/
|
|
152
|
-
function getAdminUiSdkActionsDir(extensionPointId) {
|
|
153
|
-
return (0, path.join)(getExtensionPointFolderPath(extensionPointId), ADMIN_UI_SDK_ACTIONS_PATH);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Path to the generated Admin UI SDK registration action file, relative to the project root.
|
|
157
|
-
* @param extensionPointId - The extension point ID, e.g. "commerce/backend-ui/1"
|
|
158
|
-
*/
|
|
159
|
-
function getAdminUiSdkRegistrationActionPath(extensionPointId) {
|
|
160
|
-
return (0, path.join)(getAdminUiSdkActionsDir(extensionPointId), "index.js");
|
|
161
|
-
}
|
|
162
183
|
/** Path to the generated app manifest JSON file, relative to the project root. */
|
|
163
184
|
function getManifestPath() {
|
|
164
185
|
return (0, path.join)(getGeneratedDir(EXTENSIBILITY_EXTENSION_POINT_ID), APP_MANIFEST_FILE);
|
|
@@ -176,8 +197,11 @@ function getSchemaPath() {
|
|
|
176
197
|
}
|
|
177
198
|
|
|
178
199
|
//#endregion
|
|
179
|
-
//#region source/commands/generate/actions/
|
|
180
|
-
|
|
200
|
+
//#region source/commands/generate/actions/constants.ts
|
|
201
|
+
const __dirname$1 = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
202
|
+
/** The path to the action templates directory, sibling to this file. */
|
|
203
|
+
const TEMPLATES_DIR = (0, path.join)(__dirname$1, "templates");
|
|
204
|
+
/** The list of Commerce variables that are required for the runtime actions. */
|
|
181
205
|
const COMMERCE_VARIABLES = [
|
|
182
206
|
"AIO_COMMERCE_AUTH_IMS_CLIENT_ID",
|
|
183
207
|
"AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS",
|
|
@@ -186,27 +210,104 @@ const COMMERCE_VARIABLES = [
|
|
|
186
210
|
"AIO_COMMERCE_AUTH_IMS_ORG_ID",
|
|
187
211
|
"AIO_COMMERCE_AUTH_IMS_SCOPES"
|
|
188
212
|
];
|
|
189
|
-
/** The inputs for the generated runtime actions */
|
|
213
|
+
/** The inputs for the generated runtime actions. */
|
|
190
214
|
const COMMERCE_ACTION_INPUTS = Object.fromEntries(COMMERCE_VARIABLES.map((variable) => [variable, `$${variable}`]));
|
|
191
215
|
const CUSTOM_IMPORTS_PLACEHOLDER = "// {{CUSTOM_SCRIPTS_IMPORTS}}";
|
|
192
216
|
const CUSTOM_SCRIPTS_MAP_PLACEHOLDER = "// {{CUSTOM_SCRIPTS_MAP}}";
|
|
193
217
|
const CUSTOM_SCRIPTS_LOADER_PLACEHOLDER = "// {{CUSTOM_SCRIPTS_LOADER}}";
|
|
194
|
-
|
|
218
|
+
/** File extensions that require bundling or TypeScript web-src templates. */
|
|
219
|
+
const TYPESCRIPT_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
220
|
+
".ts",
|
|
221
|
+
".mts",
|
|
222
|
+
".cts"
|
|
223
|
+
]);
|
|
224
|
+
const JSX_FILE_EXTENSION = ".jsx";
|
|
225
|
+
const TSX_FILE_EXTENSION = ".tsx";
|
|
226
|
+
const APP_TITLE_PLACEHOLDER = "APP_TITLE";
|
|
227
|
+
const WEB_SOURCE_ENTRYPOINT_FILE = "index.html";
|
|
228
|
+
const WEB_SOURCE_IMPORT_ALIAS = "#web/*";
|
|
229
|
+
/** Runtime dependencies required by the generated web-src app. */
|
|
230
|
+
const WEB_SOURCE_DEPENDENCIES = [
|
|
231
|
+
{
|
|
232
|
+
name: "@adobe/aio-commerce-lib-admin-ui",
|
|
233
|
+
version: "^0.2.0-alpha-20260722091448"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "react",
|
|
237
|
+
version: "^19.2.7"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "react-dom",
|
|
241
|
+
version: "^19.2.7"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "@react-spectrum/s2",
|
|
245
|
+
version: "^1.5.1"
|
|
246
|
+
}
|
|
247
|
+
];
|
|
248
|
+
/** Development dependencies required by the generated web-src app. */
|
|
249
|
+
const WEB_SOURCE_DEV_DEPENDENCIES = [{
|
|
250
|
+
name: "@types/react",
|
|
251
|
+
version: "^19.2.17"
|
|
252
|
+
}, {
|
|
253
|
+
name: "@types/react-dom",
|
|
254
|
+
version: "^19.2.3"
|
|
255
|
+
}];
|
|
256
|
+
/** Development dependencies required only by TypeScript web-src scaffolds. */
|
|
257
|
+
const WEB_SOURCE_TS_DEV_DEPENDENCIES = [{
|
|
258
|
+
name: "@tsconfig/bases",
|
|
259
|
+
version: "latest"
|
|
260
|
+
}, {
|
|
261
|
+
name: "typescript",
|
|
262
|
+
version: "latest"
|
|
263
|
+
}];
|
|
264
|
+
/** tsconfig.json generated for TypeScript web-src scaffolds. */
|
|
265
|
+
const WEB_SOURCE_TSCONFIG_FILE = "tsconfig.json";
|
|
266
|
+
const WEB_SOURCE_TSCONFIG = {
|
|
267
|
+
compilerOptions: {
|
|
268
|
+
allowImportingTsExtensions: true,
|
|
269
|
+
allowJs: true,
|
|
270
|
+
checkJs: true,
|
|
271
|
+
jsx: "react-jsx",
|
|
272
|
+
jsxImportSource: "react",
|
|
273
|
+
module: "esnext",
|
|
274
|
+
moduleResolution: "bundler",
|
|
275
|
+
noEmit: true,
|
|
276
|
+
rewriteRelativeImportExtensions: false
|
|
277
|
+
},
|
|
278
|
+
extends: ["@tsconfig/bases/recommended"],
|
|
279
|
+
include: [
|
|
280
|
+
"src/**/*.js",
|
|
281
|
+
"src/**/*.ts",
|
|
282
|
+
"src/**/*.tsx",
|
|
283
|
+
"src/**/*.jsx"
|
|
284
|
+
]
|
|
285
|
+
};
|
|
286
|
+
/** Parcel shared bundle config required by Spectrum S2 styles. */
|
|
287
|
+
const WEB_SOURCE_SHARED_BUNDLES = [{
|
|
288
|
+
assets: ["**/@react-spectrum/s2/**", "src/commerce-backend-ui-2/web-src/*.{js,jsx,ts,tsx}"],
|
|
289
|
+
name: "s2-styles",
|
|
290
|
+
types: ["css"]
|
|
291
|
+
}];
|
|
292
|
+
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region source/commands/generate/actions/config.ts
|
|
195
295
|
/**
|
|
196
296
|
* Creates a runtime action configuration.
|
|
197
297
|
* @param actionName - The name of the action.
|
|
298
|
+
* @param config - Action generation options.
|
|
198
299
|
* @param options - Optional configuration options.
|
|
199
300
|
*/
|
|
200
301
|
function createActionDefinition(actionName, config = {}, options = {}) {
|
|
201
302
|
const def = {
|
|
202
303
|
...options,
|
|
304
|
+
annotations: {
|
|
305
|
+
final: true,
|
|
306
|
+
"require-adobe-auth": true
|
|
307
|
+
},
|
|
203
308
|
function: `${GENERATED_ACTIONS_PATH}/${actionName}.js`,
|
|
204
|
-
web: options.web ?? "yes",
|
|
205
309
|
runtime: "nodejs:24",
|
|
206
|
-
|
|
207
|
-
"require-adobe-auth": true,
|
|
208
|
-
final: true
|
|
209
|
-
}
|
|
310
|
+
web: options.web ?? "yes"
|
|
210
311
|
};
|
|
211
312
|
if (config.requiresEncryptionKey) def.inputs = {
|
|
212
313
|
...def.inputs,
|
|
@@ -217,6 +318,7 @@ function createActionDefinition(actionName, config = {}, options = {}) {
|
|
|
217
318
|
/**
|
|
218
319
|
* Gets the runtime actions to be generated from the ext.config.yaml configuration.
|
|
219
320
|
* @param extConfig - The ext.config.yaml configuration.
|
|
321
|
+
* @param dir - Directory containing the runtime action templates.
|
|
220
322
|
*/
|
|
221
323
|
function getRuntimeActions(extConfig, dir) {
|
|
222
324
|
return Object.entries(extConfig.runtimeManifest?.packages?.["app-management"]?.actions ?? {}).map(([name, _]) => ({
|
|
@@ -226,26 +328,32 @@ function getRuntimeActions(extConfig, dir) {
|
|
|
226
328
|
}
|
|
227
329
|
/**
|
|
228
330
|
* Builds the ext.config.yaml configuration for the extensibility extension.
|
|
229
|
-
* @param
|
|
331
|
+
* @param appConfig - Parsed app configuration.
|
|
230
332
|
*/
|
|
231
333
|
function buildAppManagementExtConfig(appConfig) {
|
|
232
334
|
const extConfig = {
|
|
233
335
|
hooks: { "pre-app-build": "EXTENSION=extensibility/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
|
|
234
336
|
operations: { workerProcess: [{
|
|
235
|
-
|
|
236
|
-
|
|
337
|
+
impl: `${PACKAGE_NAME}/app-config`,
|
|
338
|
+
type: "action"
|
|
339
|
+
}, {
|
|
340
|
+
impl: `${PACKAGE_NAME}/association`,
|
|
341
|
+
type: "action"
|
|
237
342
|
}] },
|
|
238
343
|
runtimeManifest: { packages: { [PACKAGE_NAME]: {
|
|
239
|
-
|
|
240
|
-
|
|
344
|
+
actions: {
|
|
345
|
+
"app-config": createActionDefinition("app-config"),
|
|
346
|
+
association: createActionDefinition("association")
|
|
347
|
+
},
|
|
348
|
+
license: "Apache-2.0"
|
|
241
349
|
} } }
|
|
242
350
|
};
|
|
243
351
|
const needsInstallAction = require_validate.requiresInstallation(appConfig);
|
|
244
352
|
const hasPasswordFieldsInSchema = require_validate.hasBusinessConfigSchema(appConfig) && appConfig.businessConfig.schema.some((field) => field.type === "password");
|
|
245
353
|
if (needsInstallAction) {
|
|
246
354
|
extConfig.operations.workerProcess.push({
|
|
247
|
-
|
|
248
|
-
|
|
355
|
+
impl: `${PACKAGE_NAME}/installation`,
|
|
356
|
+
type: "action"
|
|
249
357
|
});
|
|
250
358
|
extConfig.runtimeManifest.packages[PACKAGE_NAME].actions.installation = createActionDefinition("installation", { requiresEncryptionKey: hasPasswordFieldsInSchema }, {
|
|
251
359
|
inputs: {
|
|
@@ -261,8 +369,8 @@ function buildAppManagementExtConfig(appConfig) {
|
|
|
261
369
|
function buildBusinessConfigurationExtConfig() {
|
|
262
370
|
const actions = [{
|
|
263
371
|
name: "config",
|
|
264
|
-
|
|
265
|
-
|
|
372
|
+
requiresEncryptionKey: true,
|
|
373
|
+
templateFile: "config.js.template"
|
|
266
374
|
}, {
|
|
267
375
|
name: "scope-tree",
|
|
268
376
|
templateFile: "scope-tree.js.template"
|
|
@@ -270,38 +378,64 @@ function buildBusinessConfigurationExtConfig() {
|
|
|
270
378
|
return {
|
|
271
379
|
hooks: { "pre-app-build": "EXTENSION=configuration/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
|
|
272
380
|
operations: { workerProcess: actions.map((action) => ({
|
|
273
|
-
|
|
274
|
-
|
|
381
|
+
impl: `${PACKAGE_NAME}/${action.name}`,
|
|
382
|
+
type: "action"
|
|
275
383
|
})) },
|
|
276
384
|
runtimeManifest: { packages: { [PACKAGE_NAME]: {
|
|
277
|
-
|
|
278
|
-
|
|
385
|
+
actions: Object.fromEntries(actions.map((action) => [action.name, createActionDefinition(action.name, action)])),
|
|
386
|
+
license: "Apache-2.0"
|
|
279
387
|
} } }
|
|
280
388
|
};
|
|
281
389
|
}
|
|
390
|
+
/** Collects unique `runtimeAction` strings from all worker entries in an `adminUi` config. */
|
|
391
|
+
function collectUniqueRuntimeActions(adminUi) {
|
|
392
|
+
const entities = [
|
|
393
|
+
"order",
|
|
394
|
+
"product",
|
|
395
|
+
"customer"
|
|
396
|
+
].map((key) => adminUi?.[key]);
|
|
397
|
+
const gridRuntimeActions = entities.map((entity) => entity?.gridColumns?.runtimeAction).filter((action) => action !== void 0);
|
|
398
|
+
const massActionRuntimeActions = entities.flatMap((entity) => entity?.massActions ?? []).filter((action) => action.type === "worker").map((action) => action.runtimeAction);
|
|
399
|
+
const viewButtonRuntimeActions = (adminUi?.order?.viewButtons ?? []).filter((button) => button.type === "worker").map((button) => button.runtimeAction);
|
|
400
|
+
return [.../* @__PURE__ */ new Set([
|
|
401
|
+
...gridRuntimeActions,
|
|
402
|
+
...massActionRuntimeActions,
|
|
403
|
+
...viewButtonRuntimeActions
|
|
404
|
+
])];
|
|
405
|
+
}
|
|
406
|
+
/** Returns true if the `adminUi` config requires a `view` operation and `web` source in ext.config.yaml. */
|
|
407
|
+
function requiresWebSource(adminUi) {
|
|
408
|
+
if (adminUi?.menu !== void 0) return true;
|
|
409
|
+
if ((adminUi?.order?.viewButtons ?? []).some((button) => button.type === "view")) return true;
|
|
410
|
+
return [
|
|
411
|
+
"order",
|
|
412
|
+
"product",
|
|
413
|
+
"customer"
|
|
414
|
+
].map((key) => adminUi?.[key]).flatMap((entity) => entity?.massActions ?? []).some((action) => action.type === "view");
|
|
415
|
+
}
|
|
282
416
|
/**
|
|
283
|
-
* Builds the ext.config.yaml
|
|
417
|
+
* Builds the ext.config.yaml for the Admin UI v2 extension (`commerce/backend-ui/2`).
|
|
418
|
+
* Derives `workerProcess` and `view` operation declarations from `adminUi` config.
|
|
419
|
+
* Adds a `view` operation and `web` source when view-type entries or `adminUi.menu` is configured.
|
|
420
|
+
* @param appConfig - Parsed app configuration.
|
|
284
421
|
*/
|
|
285
|
-
function
|
|
422
|
+
function buildAdminUiV2ExtConfig(appConfig) {
|
|
423
|
+
const { adminUi } = appConfig;
|
|
424
|
+
const runtimeActions = collectUniqueRuntimeActions(adminUi);
|
|
425
|
+
const requiresWeb = requiresWebSource(adminUi);
|
|
286
426
|
return {
|
|
287
|
-
hooks: { "pre-app-build": "EXTENSION=backend-ui/
|
|
288
|
-
operations: {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
annotations: {
|
|
300
|
-
"require-adobe-auth": true,
|
|
301
|
-
final: true
|
|
302
|
-
}
|
|
303
|
-
} }
|
|
304
|
-
} } }
|
|
427
|
+
hooks: { "pre-app-build": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-build" },
|
|
428
|
+
operations: {
|
|
429
|
+
...requiresWeb && { view: [{
|
|
430
|
+
impl: "index.html",
|
|
431
|
+
type: "web"
|
|
432
|
+
}] },
|
|
433
|
+
...runtimeActions.length > 0 && { workerProcess: runtimeActions.map((impl) => ({
|
|
434
|
+
impl,
|
|
435
|
+
type: "action"
|
|
436
|
+
})) }
|
|
437
|
+
},
|
|
438
|
+
...requiresWeb && { web: "web-src" }
|
|
305
439
|
};
|
|
306
440
|
}
|
|
307
441
|
|
|
@@ -315,9 +449,9 @@ async function readYamlFile(path$5) {
|
|
|
315
449
|
let doc = new yaml.Document();
|
|
316
450
|
if ((0, fs.existsSync)(path$5)) try {
|
|
317
451
|
doc = (0, yaml.parseDocument)(await (0, fs_promises.readFile)(path$5, "utf-8"), { keepSourceTokens: true });
|
|
318
|
-
} catch {
|
|
452
|
+
} catch (err) {
|
|
319
453
|
const file = (0, path.basename)(path$5);
|
|
320
|
-
throw new Error(`Failed to parse ${file}
|
|
454
|
+
throw new Error(`Failed to parse ${file}`, { cause: err });
|
|
321
455
|
}
|
|
322
456
|
if (doc.contents === null) doc.contents = new yaml.YAMLMap();
|
|
323
457
|
return doc;
|
|
@@ -351,8 +485,8 @@ function getOrCreateNode(doc, path$6, options, typeConfig) {
|
|
|
351
485
|
*/
|
|
352
486
|
function getOrCreateSeq(doc, path$7, options) {
|
|
353
487
|
return getOrCreateNode(doc, path$7, options ?? {}, {
|
|
354
|
-
typeGuard: yaml.isSeq,
|
|
355
488
|
createNode: () => new yaml.YAMLSeq(),
|
|
489
|
+
typeGuard: yaml.isSeq,
|
|
356
490
|
typeName: "sequence"
|
|
357
491
|
});
|
|
358
492
|
}
|
|
@@ -364,8 +498,8 @@ function getOrCreateSeq(doc, path$7, options) {
|
|
|
364
498
|
*/
|
|
365
499
|
function getOrCreateMap(doc, path$8, options) {
|
|
366
500
|
return getOrCreateNode(doc, path$8, options ?? {}, {
|
|
367
|
-
typeGuard: yaml.isMap,
|
|
368
501
|
createNode: () => new yaml.YAMLMap(),
|
|
502
|
+
typeGuard: yaml.isMap,
|
|
369
503
|
typeName: "map"
|
|
370
504
|
});
|
|
371
505
|
}
|
|
@@ -409,10 +543,9 @@ async function createOrUpdateExtConfig(path, config, doc) {
|
|
|
409
543
|
const extConfigDoc = doc ?? new yaml.Document({});
|
|
410
544
|
if (config.web !== void 0) buildWeb(extConfigDoc, config.web);
|
|
411
545
|
config.hooks ??= {};
|
|
412
|
-
config.runtimeManifest ??= { packages: {} };
|
|
413
546
|
await buildHooks(extConfigDoc, config.hooks);
|
|
414
547
|
if (config.operations !== void 0) buildOperations(extConfigDoc, config.operations);
|
|
415
|
-
buildRuntimeManifest(extConfigDoc, config.runtimeManifest);
|
|
548
|
+
if (config.runtimeManifest !== void 0) buildRuntimeManifest(extConfigDoc, config.runtimeManifest);
|
|
416
549
|
await writeExtConfig(path, extConfigDoc);
|
|
417
550
|
return extConfigDoc;
|
|
418
551
|
}
|
|
@@ -451,8 +584,8 @@ function buildActionDefinition(action, existingAction) {
|
|
|
451
584
|
...action.inputs ?? {}
|
|
452
585
|
});
|
|
453
586
|
actionDef.set("annotations", { ...action.annotations ?? {
|
|
454
|
-
|
|
455
|
-
|
|
587
|
+
final: true,
|
|
588
|
+
"require-adobe-auth": true
|
|
456
589
|
} });
|
|
457
590
|
const includes = action.include ?? [];
|
|
458
591
|
if (includes.length > 0) {
|
|
@@ -509,10 +642,11 @@ function buildOperations(extConfig, operations) {
|
|
|
509
642
|
* @param packages - The packages to build
|
|
510
643
|
*/
|
|
511
644
|
function buildRuntimeManifest(extConfig, manifest) {
|
|
645
|
+
const packages = manifest.packages ?? {};
|
|
646
|
+
if (Object.keys(packages).length === 0) return;
|
|
512
647
|
getOrCreateMap(extConfig, ["runtimeManifest"], { onBeforeCreate: (pair) => {
|
|
513
648
|
pair.key.spaceBefore = true;
|
|
514
649
|
} });
|
|
515
|
-
const packages = manifest.packages ?? {};
|
|
516
650
|
getOrCreateMap(extConfig, ["runtimeManifest", "packages"]);
|
|
517
651
|
for (const [name, pkg] of Object.entries(packages)) {
|
|
518
652
|
const packageDef = getOrCreateMap(extConfig, [
|
|
@@ -544,7 +678,7 @@ async function buildHooks(extConfig, hooks) {
|
|
|
544
678
|
pair.key.spaceBefore = true;
|
|
545
679
|
pair.key.commentBefore = ` The ${generatedHooks} hooks are auto-generated. Do not remove or manually edit.`;
|
|
546
680
|
} });
|
|
547
|
-
const execCommand =
|
|
681
|
+
const execCommand = require_index_node.getExecCommand(await require_index_node.detectPackageManager());
|
|
548
682
|
for (const [name, command] of Object.entries(hooks)) {
|
|
549
683
|
const fullCommand = `${command.replaceAll("$packageExec", execCommand)}`;
|
|
550
684
|
const prevValue = (hooksMap.get(name) ?? "").trim();
|
|
@@ -560,26 +694,15 @@ async function buildHooks(extConfig, hooks) {
|
|
|
560
694
|
*/
|
|
561
695
|
async function writeExtConfig(configPath, doc) {
|
|
562
696
|
await (0, fs_promises.writeFile)(configPath, doc.toString({
|
|
697
|
+
defaultStringType: "PLAIN",
|
|
563
698
|
indent: 2,
|
|
564
|
-
lineWidth: 0
|
|
565
|
-
defaultStringType: "PLAIN"
|
|
699
|
+
lineWidth: 0
|
|
566
700
|
}), "utf-8");
|
|
567
701
|
}
|
|
568
702
|
|
|
569
703
|
//#endregion
|
|
570
704
|
//#region source/commands/generate/actions/lib.ts
|
|
571
|
-
const __dirname$1 = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
572
|
-
/** The path to the action templates directory, sibling to this file. */
|
|
573
|
-
const TEMPLATES_DIR = (0, path.join)(__dirname$1, "templates");
|
|
574
|
-
const TYPESCRIPT_CONFIG_EXTENSIONS = new Set([
|
|
575
|
-
".ts",
|
|
576
|
-
".mts",
|
|
577
|
-
".cts"
|
|
578
|
-
]);
|
|
579
705
|
const LEADING_DOT_SLASH_PATTERN = /^\.\//u;
|
|
580
|
-
const DYNAMIC_APP_CONFIG_IMPORT = `import appConfig from "${APP_CONFIG_IMPORT_ALIAS}";`;
|
|
581
|
-
const STATIC_APP_MANIFEST_IMPORT = "import appConfig from \"../../app.commerce.manifest.json\" with { type: \"json\" };";
|
|
582
|
-
const STATIC_CONFIG_SCHEMA_IMPORT = "import configSchema from \"../../configuration-schema.json\" with { type: \"json\" };";
|
|
583
706
|
/** Normalize a path for use as an ESM import specifier. */
|
|
584
707
|
function normalizeImportPath(path$3) {
|
|
585
708
|
const normalizedPath = path$3.split(path.sep).join("/");
|
|
@@ -591,7 +714,8 @@ function normalizePackageJsonPath(path$4) {
|
|
|
591
714
|
}
|
|
592
715
|
/** Add or update the package import alias used by dynamic generated actions. */
|
|
593
716
|
async function updateAppConfigImportAlias(projectRoot, runtimeConfigPath) {
|
|
594
|
-
const pkg = await
|
|
717
|
+
const pkg = await require_index_node.loadPackageJson(projectRoot);
|
|
718
|
+
if (pkg === null) throw new Error("Could not find package.json.");
|
|
595
719
|
const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
|
|
596
720
|
pkg.update({ imports: {
|
|
597
721
|
...existingImports,
|
|
@@ -599,91 +723,84 @@ async function updateAppConfigImportAlias(projectRoot, runtimeConfigPath) {
|
|
|
599
723
|
} });
|
|
600
724
|
await pkg.save();
|
|
601
725
|
}
|
|
602
|
-
/**
|
|
603
|
-
async function deleteAppConfigImportAlias(projectRoot) {
|
|
604
|
-
const pkg = await _npmcli_package_json.default.load(projectRoot);
|
|
605
|
-
const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
|
|
606
|
-
if (!("#app.commerce.config" in existingImports)) return;
|
|
607
|
-
const imports = { ...existingImports };
|
|
608
|
-
delete imports[APP_CONFIG_IMPORT_ALIAS];
|
|
609
|
-
if (Object.keys(imports).length > 0) pkg.update({ imports });
|
|
610
|
-
else pkg.content.imports = void 0;
|
|
611
|
-
await pkg.save();
|
|
612
|
-
}
|
|
613
|
-
/** Write an ESM passthrough module for JavaScript app config files. */
|
|
726
|
+
/** Write an ESM passthrough module that re-exports an app config file. */
|
|
614
727
|
async function writeJavaScriptAppConfigModule(configFilePath, outputPath) {
|
|
728
|
+
const configImportPath = normalizeImportPath((0, path.relative)((0, path.dirname)(outputPath), configFilePath));
|
|
729
|
+
const isJson = (0, path.extname)(configFilePath) === ".json";
|
|
615
730
|
await (0, fs_promises.writeFile)(outputPath, [
|
|
616
731
|
"// This file has been auto-generated by `@adobe/aio-commerce-lib-app`",
|
|
617
732
|
"// Do not modify this file directly",
|
|
618
733
|
"",
|
|
619
|
-
`import appConfig from "${
|
|
734
|
+
`import appConfig from "${configImportPath}"${isJson ? " with { type: \"json\" }" : ""};`,
|
|
620
735
|
"",
|
|
736
|
+
isJson ? null : `export * from "${configImportPath}";`,
|
|
621
737
|
"export default appConfig;",
|
|
622
738
|
""
|
|
623
|
-
].join("\n"), "utf-8");
|
|
739
|
+
].filter((item) => item !== null).join("\n"), "utf-8");
|
|
624
740
|
}
|
|
625
741
|
/** Bundle a TypeScript app config file into runtime-safe ESM. */
|
|
626
742
|
async function bundleTypeScriptAppConfigModule(configFilePath, outputPath) {
|
|
627
743
|
await (0, esbuild.build)({
|
|
628
|
-
entryPoints: [configFilePath],
|
|
629
|
-
outfile: outputPath,
|
|
630
744
|
bundle: true,
|
|
745
|
+
entryPoints: [configFilePath],
|
|
631
746
|
format: "esm",
|
|
632
|
-
|
|
633
|
-
|
|
747
|
+
logLevel: "silent",
|
|
748
|
+
outfile: outputPath,
|
|
634
749
|
packages: "external",
|
|
635
|
-
|
|
750
|
+
platform: "node",
|
|
751
|
+
target: "node22"
|
|
636
752
|
});
|
|
637
753
|
}
|
|
638
754
|
/** Generate the runtime-safe app config module used by generated runtime actions. */
|
|
639
755
|
async function generateRuntimeAppConfigModule() {
|
|
640
|
-
const projectRoot = await
|
|
756
|
+
const projectRoot = await require_index_node.getProjectRootDirectory();
|
|
641
757
|
const runtimeConfigPath = getRuntimeAppConfigPath();
|
|
642
|
-
await
|
|
758
|
+
await require_index_node.makeOutputDirFor((0, path.dirname)(runtimeConfigPath));
|
|
643
759
|
const outputPath = (0, path.join)(projectRoot, runtimeConfigPath);
|
|
644
|
-
const configFilePath = await
|
|
645
|
-
if (!configFilePath) throw new Error("
|
|
760
|
+
const configFilePath = await require_index_node.resolveCommerceAppConfig(projectRoot);
|
|
761
|
+
if (!configFilePath) throw new Error("Generating a JavaScript app config module requires an app.commerce.config.* file.");
|
|
646
762
|
consola.consola.info("Generating JS config module...");
|
|
647
763
|
if (TYPESCRIPT_CONFIG_EXTENSIONS.has((0, path.extname)(configFilePath))) await bundleTypeScriptAppConfigModule(configFilePath, outputPath);
|
|
648
764
|
else await writeJavaScriptAppConfigModule(configFilePath, outputPath);
|
|
649
765
|
await updateAppConfigImportAlias(projectRoot, runtimeConfigPath);
|
|
650
766
|
consola.consola.success(`Generated JS config module: ${(0, path.relative)(process.cwd(), outputPath)}`);
|
|
651
767
|
}
|
|
652
|
-
/**
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
768
|
+
/**
|
|
769
|
+
* Write an ESM module that re-exports the static app manifest JSON so generated
|
|
770
|
+
* actions can import it via the alias without needing a JSON import attribute.
|
|
771
|
+
*/
|
|
772
|
+
async function prepareStaticAppConfigImportAlias() {
|
|
773
|
+
const projectRoot = await require_index_node.getProjectRootDirectory();
|
|
774
|
+
const runtimeConfigPath = getRuntimeAppConfigPath();
|
|
775
|
+
const outputPath = (0, path.join)(projectRoot, runtimeConfigPath);
|
|
776
|
+
await require_index_node.makeOutputDirFor((0, path.dirname)(runtimeConfigPath));
|
|
777
|
+
await writeJavaScriptAppConfigModule((0, path.join)(projectRoot, getManifestPath()), outputPath);
|
|
778
|
+
await updateAppConfigImportAlias(projectRoot, runtimeConfigPath);
|
|
657
779
|
}
|
|
658
780
|
/**
|
|
659
781
|
* Prepare runtime-side config artifacts consumed by generated actions: the
|
|
660
782
|
* bundled ESM module and its `#app.commerce.config` package import alias.
|
|
661
783
|
*
|
|
662
|
-
*
|
|
784
|
+
* Configs that require JavaScript use the source config file, while serializable
|
|
785
|
+
* default-only configs use the generated JSON manifest.
|
|
663
786
|
*/
|
|
664
787
|
async function prepareRuntimeAppConfigModule(appManifest) {
|
|
665
|
-
if (
|
|
788
|
+
if (await requiresJavaScriptAppConfig(appManifest)) {
|
|
666
789
|
await generateRuntimeAppConfigModule();
|
|
667
790
|
return;
|
|
668
791
|
}
|
|
669
|
-
await
|
|
670
|
-
}
|
|
671
|
-
/** Switch static JSON imports to the generated runtime config module for dynamic schemas. */
|
|
672
|
-
function applyRuntimeAppConfigImport(template, actionName) {
|
|
673
|
-
if (actionName === "app-config" || actionName === "installation") return template.replace(STATIC_APP_MANIFEST_IMPORT, DYNAMIC_APP_CONFIG_IMPORT);
|
|
674
|
-
if (actionName === "config") return template.replace(STATIC_CONFIG_SCHEMA_IMPORT, DYNAMIC_APP_CONFIG_IMPORT).replace("const args = { configSchema };", "const args = { configSchema: appConfig.businessConfig.schema };");
|
|
675
|
-
return template;
|
|
792
|
+
await prepareStaticAppConfigImportAlias();
|
|
676
793
|
}
|
|
677
794
|
/**
|
|
678
795
|
* Read an extension point's ext.config.yaml file and return it as a JS object.
|
|
679
796
|
* @param extensionPointId - The extension point ID to read the config for.
|
|
680
797
|
*/
|
|
681
798
|
async function readExtConfig(extensionPointId) {
|
|
682
|
-
const extConfigPath = (0, path.join)(await
|
|
799
|
+
const extConfigPath = (0, path.join)(await require_index_node.getProjectRootDirectory(), getExtConfigPath(extensionPointId));
|
|
683
800
|
try {
|
|
684
801
|
return {
|
|
685
|
-
|
|
686
|
-
|
|
802
|
+
doc: await readYamlFile(extConfigPath),
|
|
803
|
+
path: extConfigPath
|
|
687
804
|
};
|
|
688
805
|
} catch (error) {
|
|
689
806
|
const reason = error instanceof Error ? error.message : "Unexpected error while reading the file.";
|
|
@@ -691,13 +808,13 @@ async function readExtConfig(extensionPointId) {
|
|
|
691
808
|
`Could not read ext.config.yaml for ${extensionPointId} at ${extConfigPath}.`,
|
|
692
809
|
`Make sure the file exists and is valid YAML. You can regenerate it with "aio-commerce-lib-app generate actions".`,
|
|
693
810
|
`Reason: ${reason}`
|
|
694
|
-
].join("\n"));
|
|
811
|
+
].join("\n"), { cause: error });
|
|
695
812
|
}
|
|
696
813
|
}
|
|
697
814
|
/** Update the ext.config.yaml file */
|
|
698
815
|
async function updateExtConfig(appConfig, extensionPointId) {
|
|
699
816
|
consola.consola.info(`Updating ext.config.yaml for ${extensionPointId}...`);
|
|
700
|
-
await
|
|
817
|
+
await require_index_node.makeOutputDirFor(getExtensionPointFolderPath(extensionPointId));
|
|
701
818
|
const { path: extConfigPath, doc: extConfigDoc } = await readExtConfig(extensionPointId);
|
|
702
819
|
let extConfig;
|
|
703
820
|
switch (extensionPointId) {
|
|
@@ -707,31 +824,162 @@ async function updateExtConfig(appConfig, extensionPointId) {
|
|
|
707
824
|
case CONFIGURATION_EXTENSION_POINT_ID:
|
|
708
825
|
extConfig = buildBusinessConfigurationExtConfig();
|
|
709
826
|
break;
|
|
710
|
-
case
|
|
711
|
-
extConfig =
|
|
827
|
+
case BACKEND_UI_V2_EXTENSION_POINT_ID:
|
|
828
|
+
extConfig = buildAdminUiV2ExtConfig(appConfig);
|
|
712
829
|
break;
|
|
713
830
|
}
|
|
714
831
|
await createOrUpdateExtConfig(extConfigPath, extConfig, extConfigDoc);
|
|
715
832
|
return extConfig;
|
|
716
833
|
}
|
|
834
|
+
/**
|
|
835
|
+
* Resolve the generated web-src entrypoint path from an extension config.
|
|
836
|
+
* @param extConfig - Extension config containing the view operation.
|
|
837
|
+
* @param extensionPointId - Extension point that owns the web source folder.
|
|
838
|
+
*/
|
|
839
|
+
function getWebSourceEntrypoint(extConfig, extensionPointId) {
|
|
840
|
+
const viewEntrypoint = extConfig.operations?.view?.[0]?.impl;
|
|
841
|
+
if (viewEntrypoint === void 0) return null;
|
|
842
|
+
return (0, path.join)(getExtensionPointFolderPath(extensionPointId), extConfig.web ?? "web-src", viewEntrypoint);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Ensure package.json has the dependencies and Parcel config needed by web-src.
|
|
846
|
+
* @param projectRoot - Project root containing the package.json to update.
|
|
847
|
+
*/
|
|
848
|
+
async function prepareWebSourcePackage(projectRoot, extension) {
|
|
849
|
+
const pkg = await require_index_node.loadPackageJson(projectRoot);
|
|
850
|
+
if (pkg === null) throw new Error("Could not find package.json.");
|
|
851
|
+
const requiredDevDependencies = [...WEB_SOURCE_DEV_DEPENDENCIES, ...extension === "tsx" ? WEB_SOURCE_TS_DEV_DEPENDENCIES : []];
|
|
852
|
+
const installPlan = await require_index_node.getPackageDependencyInstallPlan([...WEB_SOURCE_DEPENDENCIES, ...requiredDevDependencies], projectRoot);
|
|
853
|
+
if (installPlan.incompatible.length > 0) {
|
|
854
|
+
const incompatibleDependencies = installPlan.incompatible.map(({ name, version, installedVersion }) => `${name}@${installedVersion} does not satisfy ${version}`).join("\n");
|
|
855
|
+
throw new Error(`Cannot scaffold web-src because installed dependencies are incompatible:\n${incompatibleDependencies}`);
|
|
856
|
+
}
|
|
857
|
+
const dependencies = pkg.content.dependencies ?? {};
|
|
858
|
+
const devDependencies = pkg.content.devDependencies ?? {};
|
|
859
|
+
const dependencyMaps = [dependencies, devDependencies];
|
|
860
|
+
const declaredDependencyNames = new Set(dependencyMaps.flatMap((depMap) => Object.keys(depMap)));
|
|
861
|
+
const dependenciesToDeclare = [...WEB_SOURCE_DEPENDENCIES, ...requiredDevDependencies].filter(({ name }) => !declaredDependencyNames.has(name));
|
|
862
|
+
if (dependenciesToDeclare.length > 0) {
|
|
863
|
+
consola.consola.info("Adding web-src dependencies in package.json:");
|
|
864
|
+
consola.consola.log.raw((0, consola_utils.formatTree)(dependenciesToDeclare.map(({ name, version }) => ` ${name}@${version}`)));
|
|
865
|
+
} else consola.consola.info("web-src dependencies are already declared in package.json.");
|
|
866
|
+
pkg.update({
|
|
867
|
+
"@parcel/bundler-default": {
|
|
868
|
+
...pkg.content["@parcel/bundler-default"],
|
|
869
|
+
manualSharedBundles: WEB_SOURCE_SHARED_BUNDLES
|
|
870
|
+
},
|
|
871
|
+
"@parcel/resolver-default": {
|
|
872
|
+
...pkg.content["@parcel/resolver-default"],
|
|
873
|
+
packageExports: true
|
|
874
|
+
},
|
|
875
|
+
dependencies: require_index_node.mergePackageJsonDependencies(dependencies, WEB_SOURCE_DEPENDENCIES, dependencyMaps),
|
|
876
|
+
devDependencies: require_index_node.mergePackageJsonDependencies(devDependencies, requiredDevDependencies, dependencyMaps)
|
|
877
|
+
});
|
|
878
|
+
await pkg.save();
|
|
879
|
+
if (installPlan.missing.length === 0) {
|
|
880
|
+
consola.consola.info("web-src dependencies are already installed.");
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
consola.consola.info("Installing missing web-src dependencies from package.json:");
|
|
884
|
+
consola.consola.log.raw((0, consola_utils.formatTree)(installPlan.missing.map(({ name, version }) => ` ${name}@${version}`)));
|
|
885
|
+
runProjectInstall(await require_index_node.detectPackageManager(projectRoot), projectRoot);
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Add the package import alias for an existing or generated web-src.
|
|
889
|
+
* @param extConfig - Extension config containing the view operation.
|
|
890
|
+
*/
|
|
891
|
+
async function prepareWebSourceImportAlias(extConfig) {
|
|
892
|
+
const entrypoint = getWebSourceEntrypoint(extConfig, BACKEND_UI_V2_EXTENSION_POINT_ID);
|
|
893
|
+
if (entrypoint === null) return;
|
|
894
|
+
const pkg = await require_index_node.loadPackageJson(await require_index_node.getProjectRootDirectory());
|
|
895
|
+
if (pkg === null) throw new Error("Could not find package.json.");
|
|
896
|
+
const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
|
|
897
|
+
const webSourceSrcPath = (0, path.join)((0, path.dirname)(entrypoint), "src");
|
|
898
|
+
pkg.update({ imports: {
|
|
899
|
+
...existingImports,
|
|
900
|
+
[WEB_SOURCE_IMPORT_ALIAS]: `${normalizePackageJsonPath(webSourceSrcPath)}/*`
|
|
901
|
+
} });
|
|
902
|
+
await pkg.save();
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Resolve the generated web-src file extension from the app config file type.
|
|
906
|
+
* @param projectRoot - Project root used to find the commerce app config file.
|
|
907
|
+
*/
|
|
908
|
+
async function resolveWebSourceExtension(projectRoot) {
|
|
909
|
+
const configFilePath = await require_index_node.resolveCommerceAppConfig(projectRoot);
|
|
910
|
+
return configFilePath !== null && TYPESCRIPT_CONFIG_EXTENSIONS.has((0, path.extname)(configFilePath)) ? "tsx" : "jsx";
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Resolve the destination path for a web-src template file.
|
|
914
|
+
* @param templatePath - Template file path relative to its source directory.
|
|
915
|
+
* @param extension - Web source extension to generate.
|
|
916
|
+
*/
|
|
917
|
+
function getWebSourceTemplateTargetPath(templatePath, extension) {
|
|
918
|
+
if (extension === "jsx" || !templatePath.endsWith(".jsx")) return templatePath;
|
|
919
|
+
return `${templatePath.slice(0, -JSX_FILE_EXTENSION.length)}${TSX_FILE_EXTENSION}`;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Copy web-src templates directly to the final file extension and entrypoint.
|
|
923
|
+
* @param sourceDir - Template web-src directory.
|
|
924
|
+
* @param targetDir - Generated web-src directory.
|
|
925
|
+
* @param extension - Web source extension to generate.
|
|
926
|
+
*/
|
|
927
|
+
async function copyWebSourceTemplates(sourceDir, targetDir, extension, appTitle) {
|
|
928
|
+
await (0, fs_promises.mkdir)(targetDir, { recursive: true });
|
|
929
|
+
const entries = await (0, fs_promises.readdir)(sourceDir, { withFileTypes: true });
|
|
930
|
+
return (await Promise.all(entries.map(async (entry) => {
|
|
931
|
+
const sourcePath = (0, path.join)(sourceDir, entry.name);
|
|
932
|
+
const targetPath = (0, path.join)(targetDir, getWebSourceTemplateTargetPath(entry.name, extension));
|
|
933
|
+
if (entry.isDirectory()) return await copyWebSourceTemplates(sourcePath, targetPath, extension, appTitle);
|
|
934
|
+
let content = await (0, fs_promises.readFile)(sourcePath, "utf-8");
|
|
935
|
+
if (extension === "tsx") content = content.replaceAll(`${JSX_FILE_EXTENSION}"`, `${TSX_FILE_EXTENSION}"`);
|
|
936
|
+
if (targetPath.endsWith("index.html")) content = content.replaceAll(APP_TITLE_PLACEHOLDER, appTitle);
|
|
937
|
+
await (0, fs_promises.writeFile)(targetPath, content, {
|
|
938
|
+
encoding: "utf-8",
|
|
939
|
+
flag: "wx"
|
|
940
|
+
});
|
|
941
|
+
return ` ${(0, path.relative)(process.cwd(), targetPath)}`;
|
|
942
|
+
}))).flat();
|
|
943
|
+
}
|
|
944
|
+
/** Generate the web source scaffold for iframe-based Admin UI extensions. */
|
|
945
|
+
async function generateWebSrc(extConfig, extensionPointId, appName, templatesDir = TEMPLATES_DIR) {
|
|
946
|
+
const entrypoint = getWebSourceEntrypoint(extConfig, extensionPointId);
|
|
947
|
+
if (entrypoint === null) return;
|
|
948
|
+
const projectRoot = await require_index_node.getProjectRootDirectory();
|
|
949
|
+
const entrypointPath = (0, path.join)(projectRoot, entrypoint);
|
|
950
|
+
if ((0, fs.existsSync)(entrypointPath)) {
|
|
951
|
+
consola.consola.info(`web-src entrypoint already exists, skipping scaffold: ${(0, path.relative)(process.cwd(), entrypointPath)}`);
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
consola.consola.start(`Scaffolding web-src for ${extensionPointId}...`);
|
|
955
|
+
const sourceDir = (0, path.join)(templatesDir, "admin-ui", "web-src");
|
|
956
|
+
const targetDir = (0, path.dirname)(entrypointPath);
|
|
957
|
+
const extension = await resolveWebSourceExtension(projectRoot);
|
|
958
|
+
const outputFiles = await copyWebSourceTemplates(sourceDir, targetDir, extension, appName);
|
|
959
|
+
if (extension === "tsx") {
|
|
960
|
+
const tsconfigPath = (0, path.join)(targetDir, WEB_SOURCE_TSCONFIG_FILE);
|
|
961
|
+
await (0, fs_promises.writeFile)(tsconfigPath, JSON.stringify(WEB_SOURCE_TSCONFIG, null, 2), "utf-8");
|
|
962
|
+
outputFiles.push(` ${(0, path.relative)(process.cwd(), tsconfigPath)}`);
|
|
963
|
+
}
|
|
964
|
+
await prepareWebSourcePackage(projectRoot, extension);
|
|
965
|
+
consola.consola.success(`Scaffolded ${(0, path.relative)(process.cwd(), targetDir)}`);
|
|
966
|
+
consola.consola.log.raw((0, consola_utils.formatTree)(outputFiles));
|
|
967
|
+
}
|
|
717
968
|
/** Generate the action files */
|
|
718
969
|
async function generateActionFiles(appManifest, actions, extensionPointId, templatesDir) {
|
|
719
970
|
consola.consola.start("Generating runtime actions...");
|
|
720
|
-
await
|
|
721
|
-
const projectRoot = await
|
|
722
|
-
const outputFiles =
|
|
723
|
-
const useDynamicImports = hasDynamicAppConfig(appManifest);
|
|
724
|
-
for (const action of actions) {
|
|
971
|
+
await require_index_node.makeOutputDirFor(getActionsDir(extensionPointId));
|
|
972
|
+
const projectRoot = await require_index_node.getProjectRootDirectory();
|
|
973
|
+
const outputFiles = await Promise.all(actions.map(async (action) => {
|
|
725
974
|
let template = await (0, fs_promises.readFile)((0, path.join)(templatesDir, action.templateFile), "utf-8");
|
|
726
|
-
if (useDynamicImports) template = applyRuntimeAppConfigImport(template, action.name);
|
|
727
975
|
if (action.name === "installation") {
|
|
728
976
|
const scriptsTemplate = await generateCustomScriptsTemplate(await (0, fs_promises.readFile)((0, path.join)(templatesDir, "app-management", "custom-scripts.js.template"), "utf-8"), appManifest);
|
|
729
977
|
template = applyCustomScripts(template, scriptsTemplate);
|
|
730
978
|
}
|
|
731
979
|
const actionPath = (0, path.join)(projectRoot, getActionPath(extensionPointId, action.name));
|
|
732
980
|
await (0, fs_promises.writeFile)(actionPath, template, "utf-8");
|
|
733
|
-
|
|
734
|
-
}
|
|
981
|
+
return ` ${(0, path.relative)(process.cwd(), actionPath)}`;
|
|
982
|
+
}));
|
|
735
983
|
consola.consola.success(`Generated ${actions.length} action(s)`);
|
|
736
984
|
consola.consola.log.raw((0, consola_utils.formatTree)(outputFiles));
|
|
737
985
|
}
|
|
@@ -750,11 +998,12 @@ function applyCustomScripts(installationTemplate, customScriptsTemplate) {
|
|
|
750
998
|
*/
|
|
751
999
|
async function generateCustomScriptsTemplate(template, appManifest) {
|
|
752
1000
|
if (!require_webhooks.hasCustomInstallationSteps(appManifest)) return null;
|
|
753
|
-
const projectRoot = await
|
|
1001
|
+
const projectRoot = await require_index_node.getProjectRootDirectory();
|
|
754
1002
|
const installationActionDir = (0, path.join)(projectRoot, getActionsDir(EXTENSIBILITY_EXTENSION_POINT_ID));
|
|
755
1003
|
const customSteps = appManifest.installation.customInstallationSteps;
|
|
756
1004
|
const importStatements = customSteps.map((step, index) => {
|
|
757
|
-
|
|
1005
|
+
const absoluteScriptPath = (0, path.join)(projectRoot, step.script);
|
|
1006
|
+
let relativeImportPath = (0, path.relative)(installationActionDir, absoluteScriptPath);
|
|
758
1007
|
if (!relativeImportPath.startsWith(".")) relativeImportPath = `./${relativeImportPath}`;
|
|
759
1008
|
relativeImportPath = relativeImportPath.replace(/\\/g, "/");
|
|
760
1009
|
return `import * as ${`customScript${index}`} from "${relativeImportPath}";`;
|
|
@@ -765,23 +1014,6 @@ async function generateCustomScriptsTemplate(template, appManifest) {
|
|
|
765
1014
|
}).join("\n");
|
|
766
1015
|
return template.replace(CUSTOM_IMPORTS_PLACEHOLDER, importStatements).replace(CUSTOM_SCRIPTS_MAP_PLACEHOLDER, scriptMap);
|
|
767
1016
|
}
|
|
768
|
-
/**
|
|
769
|
-
* Generates `registration/index.js` with the Admin UI SDK registration config
|
|
770
|
-
* inlined as a JS object literal.
|
|
771
|
-
* @param appManifest - The validated app config; must satisfy `hasAdminUiSdk`.
|
|
772
|
-
* @param extensionPointId - The extension point ID that owns the registration action.
|
|
773
|
-
* @param templatesDir - The root directory containing the action templates.
|
|
774
|
-
*/
|
|
775
|
-
async function generateRegistrationActionFile(appManifest, extensionPointId, templatesDir = TEMPLATES_DIR) {
|
|
776
|
-
consola.consola.start("Generating Admin UI SDK registration action...");
|
|
777
|
-
await require_config.makeOutputDirFor(getAdminUiSdkActionsDir(extensionPointId));
|
|
778
|
-
const projectRoot = await require_config.getProjectRootDirectory();
|
|
779
|
-
const template = await (0, fs_promises.readFile)((0, path.join)(templatesDir, "admin-ui-sdk", "registration.js.template"), "utf-8");
|
|
780
|
-
const { registration } = appManifest.adminUiSdk;
|
|
781
|
-
const actionPath = (0, path.join)(projectRoot, getAdminUiSdkRegistrationActionPath(extensionPointId));
|
|
782
|
-
await (0, fs_promises.writeFile)(actionPath, await prettierFormat(template.replace(REGISTRATION_JSON_PLACEHOLDER, `const registration = ${(0, safe_stable_stringify.default)(registration)};`), actionPath), "utf-8");
|
|
783
|
-
consola.consola.success(`Generated registration action at ${(0, path.relative)(process.cwd(), actionPath)}`);
|
|
784
|
-
}
|
|
785
1017
|
|
|
786
1018
|
//#endregion
|
|
787
1019
|
//#region source/commands/generate/actions/main.ts
|
|
@@ -794,9 +1026,12 @@ async function run$5(appManifest, templatesDir = TEMPLATES_DIR) {
|
|
|
794
1026
|
await prepareRuntimeAppConfigModule(appManifest);
|
|
795
1027
|
await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, EXTENSIBILITY_EXTENSION_POINT_ID), "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
|
|
796
1028
|
if (require_validate.hasBusinessConfigSchema(appManifest)) await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, CONFIGURATION_EXTENSION_POINT_ID), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
|
|
797
|
-
if (require_webhooks.
|
|
798
|
-
await updateExtConfig(appManifest,
|
|
799
|
-
|
|
1029
|
+
if (require_webhooks.hasAdminUi(appManifest)) {
|
|
1030
|
+
const extConfig = await updateExtConfig(appManifest, BACKEND_UI_V2_EXTENSION_POINT_ID);
|
|
1031
|
+
if (extConfig.operations?.view) {
|
|
1032
|
+
await prepareWebSourceImportAlias(extConfig);
|
|
1033
|
+
await generateWebSrc(extConfig, BACKEND_UI_V2_EXTENSION_POINT_ID, appManifest.metadata.displayName, templatesDir);
|
|
1034
|
+
}
|
|
800
1035
|
}
|
|
801
1036
|
}
|
|
802
1037
|
/** Run the generate actions command */
|
|
@@ -813,8 +1048,8 @@ async function exec$5() {
|
|
|
813
1048
|
//#endregion
|
|
814
1049
|
//#region source/commands/generate/manifest/main.ts
|
|
815
1050
|
async function run$4(appConfig) {
|
|
816
|
-
if (
|
|
817
|
-
const stalePath = (0, path.join)(await
|
|
1051
|
+
if (await requiresJavaScriptAppConfig(appConfig)) {
|
|
1052
|
+
const stalePath = (0, path.join)(await require_index_node.getProjectRootDirectory(), getManifestPath());
|
|
818
1053
|
if (await (0, fs_promises.access)(stalePath).then(() => true, () => false)) {
|
|
819
1054
|
await (0, fs_promises.rm)(stalePath, { force: true });
|
|
820
1055
|
consola.consola.success(`Removed stale ${APP_MANIFEST_FILE}`);
|
|
@@ -823,7 +1058,7 @@ async function run$4(appConfig) {
|
|
|
823
1058
|
}
|
|
824
1059
|
consola.consola.info("Generating app manifest...");
|
|
825
1060
|
const contents = (0, safe_stable_stringify.stringify)(appConfig, null, 2);
|
|
826
|
-
await (0, fs_promises.writeFile)((0, path.join)(await
|
|
1061
|
+
await (0, fs_promises.writeFile)((0, path.join)(await require_index_node.makeOutputDirFor(getGeneratedDir(EXTENSIBILITY_EXTENSION_POINT_ID)), APP_MANIFEST_FILE), contents, "utf-8");
|
|
827
1062
|
consola.consola.success(`Generated ${APP_MANIFEST_FILE}\n`);
|
|
828
1063
|
}
|
|
829
1064
|
/** Run the generate manifest command */
|
|
@@ -856,12 +1091,12 @@ async function run$3(appConfig) {
|
|
|
856
1091
|
consola.consola.debug("Business configuration schema not found in application configuration. Nothing to do.");
|
|
857
1092
|
return;
|
|
858
1093
|
}
|
|
859
|
-
const projectDir = await
|
|
1094
|
+
const projectDir = await require_index_node.getProjectRootDirectory();
|
|
860
1095
|
const envPath = (0, path.join)(projectDir, ".env");
|
|
861
1096
|
await touch(envPath);
|
|
862
1097
|
process.loadEnvFile(envPath);
|
|
863
1098
|
if (appConfig.businessConfig.schema.some((field) => field.type === "password")) {
|
|
864
|
-
const packageExec =
|
|
1099
|
+
const packageExec = require_index_node.getExecCommand(await require_index_node.detectPackageManager(projectDir));
|
|
865
1100
|
if ("AIO_COMMERCE_CONFIG_ENCRYPTION_KEY" in process.env && String(process.env.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY).trim().length > 0) (0, child_process.execSync)(`${packageExec} aio-commerce-lib-config encryption validate`);
|
|
866
1101
|
else (0, child_process.execSync)(`${packageExec} aio-commerce-lib-config encryption setup`);
|
|
867
1102
|
}
|
|
@@ -874,7 +1109,7 @@ async function run$3(appConfig) {
|
|
|
874
1109
|
return;
|
|
875
1110
|
}
|
|
876
1111
|
consola.consola.info("Generating configuration schema...");
|
|
877
|
-
const outputDir = await
|
|
1112
|
+
const outputDir = await require_index_node.makeOutputDirFor(getGeneratedDir(CONFIGURATION_EXTENSION_POINT_ID));
|
|
878
1113
|
const contents = (0, safe_stable_stringify.stringify)(appConfig.businessConfig.schema, null, 2);
|
|
879
1114
|
await (0, fs_promises.writeFile)((0, path.join)(outputDir, CONFIG_SCHEMA_FILE_NAME), contents, "utf-8");
|
|
880
1115
|
consola.consola.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}\n`);
|
|
@@ -919,10 +1154,10 @@ const { context } = _adobe_aio_lib_ims.default;
|
|
|
919
1154
|
const IMS_KEYS = {
|
|
920
1155
|
client_id: "AIO_COMMERCE_AUTH_IMS_CLIENT_ID",
|
|
921
1156
|
client_secrets: "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS",
|
|
922
|
-
|
|
923
|
-
technical_account_id: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID",
|
|
1157
|
+
ims_org_id: "AIO_COMMERCE_AUTH_IMS_ORG_ID",
|
|
924
1158
|
scopes: "AIO_COMMERCE_AUTH_IMS_SCOPES",
|
|
925
|
-
|
|
1159
|
+
technical_account_email: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL",
|
|
1160
|
+
technical_account_id: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID"
|
|
926
1161
|
};
|
|
927
1162
|
/**
|
|
928
1163
|
* Replaces or creates an environment variable in a .env file
|
|
@@ -954,7 +1189,7 @@ function resolveEnvPath() {
|
|
|
954
1189
|
}
|
|
955
1190
|
/** Resolves the IMS server to server context from the project workspace credentials. */
|
|
956
1191
|
function resolveImsS2SContext() {
|
|
957
|
-
const [credential] = (_adobe_aio_lib_core_config.default.get("project.workspace.details.credentials") ?? []).filter(({ integration_type }) => integration_type === "oauth_server_to_server").map(({ name }) => name)
|
|
1192
|
+
const [credential] = (_adobe_aio_lib_core_config.default.get("project.workspace.details.credentials") ?? []).filter(({ integration_type }) => integration_type === "oauth_server_to_server").map(({ name }) => name);
|
|
958
1193
|
if (!credential) return Promise.resolve(null);
|
|
959
1194
|
return context.get(credential);
|
|
960
1195
|
}
|
|
@@ -1007,8 +1242,14 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
|
|
|
1007
1242
|
await generateActionFiles(appManifest, getRuntimeActions(businessConfigExtConfig.toJS(), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
|
|
1008
1243
|
return;
|
|
1009
1244
|
}
|
|
1010
|
-
if (extension === "backend-ui/
|
|
1011
|
-
if (require_webhooks.
|
|
1245
|
+
if (extension === "backend-ui/2") {
|
|
1246
|
+
if (require_webhooks.hasAdminUi(appManifest)) {
|
|
1247
|
+
const extConfig = await updateExtConfig(appManifest, BACKEND_UI_V2_EXTENSION_POINT_ID);
|
|
1248
|
+
if (extConfig.operations?.view) {
|
|
1249
|
+
await prepareWebSourceImportAlias(extConfig);
|
|
1250
|
+
await generateWebSrc(extConfig, BACKEND_UI_V2_EXTENSION_POINT_ID, appManifest.metadata.displayName, templatesDir);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1012
1253
|
return;
|
|
1013
1254
|
}
|
|
1014
1255
|
throw new Error(`Unsupported extension: ${extension}`);
|
|
@@ -1016,10 +1257,10 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
|
|
|
1016
1257
|
/** Runs the pre-app-build hook */
|
|
1017
1258
|
async function exec$1() {
|
|
1018
1259
|
consola.default.debug("Running lib-app pre-app-build hook");
|
|
1019
|
-
const
|
|
1260
|
+
const rawExtension = process.env.EXTENSION;
|
|
1020
1261
|
try {
|
|
1021
|
-
if (!
|
|
1022
|
-
await run$1(
|
|
1262
|
+
if (!rawExtension) throw new Error("EXTENSION environment variable is not set");
|
|
1263
|
+
await run$1(rawExtension);
|
|
1023
1264
|
} catch (error) {
|
|
1024
1265
|
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.default.error(error.display());
|
|
1025
1266
|
else consola.default.error(error);
|
|
@@ -1032,77 +1273,77 @@ async function exec$1() {
|
|
|
1032
1273
|
/** The default values for the features of the commerce app config. */
|
|
1033
1274
|
const DOMAIN_DEFAULTS = {
|
|
1034
1275
|
businessConfig: { schema: [{
|
|
1035
|
-
type: "list",
|
|
1036
|
-
name: "sampleList",
|
|
1037
|
-
label: "Sample List",
|
|
1038
|
-
selectionMode: "multiple",
|
|
1039
1276
|
default: ["a"],
|
|
1277
|
+
label: "Sample List",
|
|
1278
|
+
name: "sampleList",
|
|
1040
1279
|
options: [{
|
|
1041
1280
|
label: "Option A",
|
|
1042
1281
|
value: "a"
|
|
1043
1282
|
}, {
|
|
1044
1283
|
label: "Option B",
|
|
1045
1284
|
value: "b"
|
|
1046
|
-
}]
|
|
1285
|
+
}],
|
|
1286
|
+
selectionMode: "multiple",
|
|
1287
|
+
type: "list"
|
|
1047
1288
|
}, {
|
|
1048
|
-
|
|
1049
|
-
name: "sampleText",
|
|
1289
|
+
default: "Hello, world!",
|
|
1050
1290
|
label: "Sample Text",
|
|
1051
|
-
|
|
1291
|
+
name: "sampleText",
|
|
1292
|
+
type: "text"
|
|
1052
1293
|
}] },
|
|
1053
1294
|
"eventing.commerce": [{
|
|
1054
|
-
provider: {
|
|
1055
|
-
label: "Commerce Events Provider",
|
|
1056
|
-
description: "A description for your Commerce Events provider."
|
|
1057
|
-
},
|
|
1058
1295
|
events: [{
|
|
1059
|
-
|
|
1296
|
+
description: "Use case description for the event.",
|
|
1060
1297
|
fields: [{ name: "*" }],
|
|
1061
1298
|
label: "Sample Event",
|
|
1062
|
-
|
|
1299
|
+
name: "plugin.sample_event",
|
|
1063
1300
|
runtimeActions: ["my-package/handle-sample-event"]
|
|
1064
|
-
}]
|
|
1301
|
+
}],
|
|
1302
|
+
provider: {
|
|
1303
|
+
description: "A description for your Commerce Events provider.",
|
|
1304
|
+
label: "Commerce Events Provider"
|
|
1305
|
+
}
|
|
1065
1306
|
}],
|
|
1066
1307
|
"eventing.external": [{
|
|
1067
|
-
provider: {
|
|
1068
|
-
label: "External Events Provider",
|
|
1069
|
-
description: "A description for your External Events provider."
|
|
1070
|
-
},
|
|
1071
1308
|
events: [{
|
|
1072
|
-
name: "be-observer.sample_event",
|
|
1073
|
-
label: "Sample Event",
|
|
1074
1309
|
description: "Use case description for the event.",
|
|
1310
|
+
label: "Sample Event",
|
|
1311
|
+
name: "be-observer.sample_event",
|
|
1075
1312
|
runtimeActions: ["my-package/handle-sample-event"]
|
|
1076
|
-
}]
|
|
1313
|
+
}],
|
|
1314
|
+
provider: {
|
|
1315
|
+
description: "A description for your External Events provider.",
|
|
1316
|
+
label: "External Events Provider"
|
|
1317
|
+
}
|
|
1077
1318
|
}],
|
|
1078
1319
|
"installation.customInstallationSteps": [{
|
|
1079
|
-
name: "sample-step",
|
|
1080
1320
|
description: "Use case description for the step.",
|
|
1321
|
+
name: "sample-step",
|
|
1081
1322
|
script: "./path/to/script.js"
|
|
1082
1323
|
}],
|
|
1083
1324
|
webhooks: [{
|
|
1084
|
-
|
|
1325
|
+
category: "modification",
|
|
1085
1326
|
description: "A sample Commerce Webhook handler.",
|
|
1327
|
+
label: "Sample Webhook",
|
|
1086
1328
|
runtimeAction: "my-package/handle-webhook",
|
|
1087
|
-
category: "modification",
|
|
1088
1329
|
webhook: {
|
|
1089
|
-
webhook_method: "plugin.sample.event",
|
|
1090
|
-
webhook_type: "after",
|
|
1091
1330
|
batch_name: "my_app",
|
|
1092
1331
|
hook_name: "sample_hook",
|
|
1093
|
-
method: "POST"
|
|
1332
|
+
method: "POST",
|
|
1333
|
+
webhook_method: "plugin.sample.event",
|
|
1334
|
+
webhook_type: "after"
|
|
1094
1335
|
}
|
|
1095
1336
|
}, {
|
|
1096
|
-
label: "Sample Webhook with URL",
|
|
1097
|
-
description: "A sample Commerce Webhook handler using an explicit URL.",
|
|
1098
1337
|
category: "modification",
|
|
1338
|
+
description: "A sample Commerce Webhook handler using an explicit URL.",
|
|
1339
|
+
label: "Sample Webhook with URL",
|
|
1099
1340
|
webhook: {
|
|
1100
|
-
webhook_method: "plugin.sample.event",
|
|
1101
|
-
webhook_type: "after",
|
|
1102
1341
|
batch_name: "my_app",
|
|
1103
1342
|
hook_name: "sample_hook_url",
|
|
1104
1343
|
method: "POST",
|
|
1105
|
-
url: "https://example.com/webhook"
|
|
1344
|
+
url: "https://example.com/webhook",
|
|
1345
|
+
webhook_method: "plugin.sample.event",
|
|
1346
|
+
webhook_type: "after"
|
|
1106
1347
|
}
|
|
1107
1348
|
}]
|
|
1108
1349
|
};
|
|
@@ -1125,30 +1366,28 @@ function initFlagsToScaffoldAppAnswers(flags) {
|
|
|
1125
1366
|
/** Prompt the user to scaffold a new Commerce App configuration. When options are provided, prompts are skipped. */
|
|
1126
1367
|
async function promptForCommerceAppConfig() {
|
|
1127
1368
|
const configFormat = await consola.default.prompt("What format do you want to use for the config file?", {
|
|
1128
|
-
|
|
1369
|
+
cancel: "reject",
|
|
1129
1370
|
default: "ts",
|
|
1130
1371
|
initial: "ts",
|
|
1131
|
-
cancel: "reject",
|
|
1132
1372
|
options: [{
|
|
1373
|
+
hint: "Recommended",
|
|
1133
1374
|
label: "TypeScript",
|
|
1134
|
-
value: "ts"
|
|
1135
|
-
hint: "Recommended"
|
|
1375
|
+
value: "ts"
|
|
1136
1376
|
}, {
|
|
1137
1377
|
label: "JavaScript",
|
|
1138
1378
|
value: "js"
|
|
1139
|
-
}]
|
|
1379
|
+
}],
|
|
1380
|
+
type: "select"
|
|
1140
1381
|
});
|
|
1141
1382
|
const appName = await consola.default.prompt("What is the name of your app?", {
|
|
1142
|
-
|
|
1143
|
-
placeholder: "Application Display Name",
|
|
1383
|
+
cancel: "reject",
|
|
1144
1384
|
default: "My Application",
|
|
1145
|
-
|
|
1385
|
+
placeholder: "Application Display Name",
|
|
1386
|
+
type: "text"
|
|
1146
1387
|
});
|
|
1147
1388
|
const featuresToAdd = await consola.default.prompt(`What features do you want to add to your app? ${(0, consola_utils.colorize)("gray", "Space to select/deselect, Enter to submit")}`, {
|
|
1148
|
-
type: "multiselect",
|
|
1149
|
-
initial: [],
|
|
1150
|
-
required: true,
|
|
1151
1389
|
cancel: "reject",
|
|
1390
|
+
initial: [],
|
|
1152
1391
|
options: [
|
|
1153
1392
|
{
|
|
1154
1393
|
label: "Business Configuration",
|
|
@@ -1170,7 +1409,9 @@ async function promptForCommerceAppConfig() {
|
|
|
1170
1409
|
label: "Custom Installation Steps",
|
|
1171
1410
|
value: "installation.customInstallationSteps"
|
|
1172
1411
|
}
|
|
1173
|
-
]
|
|
1412
|
+
],
|
|
1413
|
+
required: true,
|
|
1414
|
+
type: "multiselect"
|
|
1174
1415
|
});
|
|
1175
1416
|
const configFile = `${COMMERCE_APP_CONFIG_FILE}.${configFormat}`;
|
|
1176
1417
|
const domains = new Set(featuresToAdd);
|
|
@@ -1178,20 +1419,20 @@ async function promptForCommerceAppConfig() {
|
|
|
1178
1419
|
return {
|
|
1179
1420
|
appName,
|
|
1180
1421
|
configFile,
|
|
1181
|
-
|
|
1182
|
-
|
|
1422
|
+
configFormat,
|
|
1423
|
+
domains
|
|
1183
1424
|
};
|
|
1184
1425
|
}
|
|
1185
1426
|
/** Create the default commerce app config file content */
|
|
1186
1427
|
async function getDefaultCommerceAppConfig(cwd, { appName, configFormat, domains }) {
|
|
1187
|
-
const needsESM = await
|
|
1428
|
+
const needsESM = await require_index_node.isESM(cwd) || configFormat === "ts";
|
|
1188
1429
|
const exportKeyword = needsESM ? "export default" : "module.exports =";
|
|
1189
1430
|
const importStatement = needsESM ? "import { defineConfig } from \"@adobe/aio-commerce-lib-app/config\";" : "const { defineConfig } = require(\"@adobe/aio-commerce-lib-app/config\");";
|
|
1190
1431
|
const defaultConfig = { metadata: {
|
|
1191
|
-
|
|
1432
|
+
description: "A custom Adobe Commerce application. Fill description for your app.",
|
|
1192
1433
|
displayName: appName,
|
|
1193
|
-
|
|
1194
|
-
|
|
1434
|
+
id: appName.toLowerCase().replace(/ /g, "-"),
|
|
1435
|
+
version: "1.0.0"
|
|
1195
1436
|
} };
|
|
1196
1437
|
if (domains.has("businessConfig.schema")) defaultConfig.businessConfig = { schema: DOMAIN_DEFAULTS.businessConfig.schema };
|
|
1197
1438
|
if (domains.has("eventing.commerce")) defaultConfig.eventing = {
|
|
@@ -1281,7 +1522,7 @@ async function addExtensionPointToInstallYaml(extensionPointId, rootDirectory, c
|
|
|
1281
1522
|
async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true, flags) {
|
|
1282
1523
|
let config = null;
|
|
1283
1524
|
try {
|
|
1284
|
-
config = await
|
|
1525
|
+
config = await require_index_node.readCommerceAppConfig(cwd);
|
|
1285
1526
|
} catch {}
|
|
1286
1527
|
if (config) try {
|
|
1287
1528
|
const validatedConfig = require_validate.validateCommerceAppConfig(config);
|
|
@@ -1296,22 +1537,22 @@ async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true,
|
|
|
1296
1537
|
if (!flags) {
|
|
1297
1538
|
consola.consola.warn(`${COMMERCE_APP_CONFIG_FILE} not found.`);
|
|
1298
1539
|
if (!await consola.consola.prompt(`Do you want to create a ${"app.commerce.config"} file? (y/n)`, {
|
|
1299
|
-
|
|
1540
|
+
default: false,
|
|
1300
1541
|
initial: true,
|
|
1301
|
-
|
|
1542
|
+
type: "confirm"
|
|
1302
1543
|
})) throw new Error("Initialization cancelled.");
|
|
1303
1544
|
}
|
|
1304
1545
|
const answers = flags ? initFlagsToScaffoldAppAnswers(flags) : await promptForCommerceAppConfig();
|
|
1305
1546
|
try {
|
|
1306
1547
|
const configContent = await getDefaultCommerceAppConfig(cwd, answers);
|
|
1307
|
-
const path$2 = (0, path.join)(await
|
|
1548
|
+
const path$2 = (0, path.join)(await require_index_node.getProjectRootDirectory(cwd), answers.configFile);
|
|
1308
1549
|
consola.consola.info(`Creating ${answers.configFile}...`);
|
|
1309
1550
|
if (formatConfig) await (0, fs_promises.writeFile)(path$2, await prettierFormat(configContent, path$2), "utf-8");
|
|
1310
1551
|
else await (0, fs_promises.writeFile)(path$2, configContent, "utf-8");
|
|
1311
|
-
const
|
|
1552
|
+
const createdConfig = await require_index_node.parseCommerceAppConfig(cwd);
|
|
1312
1553
|
consola.consola.success(`Created ${answers.configFile}`);
|
|
1313
1554
|
return {
|
|
1314
|
-
config,
|
|
1555
|
+
config: createdConfig,
|
|
1315
1556
|
domains: answers.domains
|
|
1316
1557
|
};
|
|
1317
1558
|
} catch (error) {
|
|
@@ -1323,25 +1564,24 @@ async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true,
|
|
|
1323
1564
|
* @param cwd - Directory to check; defaults to `process.cwd()`
|
|
1324
1565
|
*/
|
|
1325
1566
|
async function ensurePackageJson(cwd = process.cwd()) {
|
|
1326
|
-
const existing = await
|
|
1567
|
+
const existing = await require_index_node.readPackageJson(cwd);
|
|
1327
1568
|
let packageJson;
|
|
1328
1569
|
if (existing) packageJson = existing;
|
|
1329
1570
|
else {
|
|
1330
1571
|
consola.consola.warn("package.json not found. Creating one...");
|
|
1331
1572
|
packageJson = {
|
|
1332
1573
|
name: "my-commerce-app",
|
|
1333
|
-
|
|
1334
|
-
|
|
1574
|
+
private: true,
|
|
1575
|
+
version: "1.0.0"
|
|
1335
1576
|
};
|
|
1336
1577
|
await (0, fs_promises.writeFile)((0, path.join)((0, path.resolve)(cwd), PACKAGE_JSON_FILE), JSON.stringify(packageJson, null, 2), "utf-8");
|
|
1337
1578
|
consola.consola.success("Wrote package.json");
|
|
1338
1579
|
}
|
|
1339
|
-
const packageManager = await
|
|
1340
|
-
const execCommand = require_config.getExecCommand(packageManager);
|
|
1580
|
+
const packageManager = await require_index_node.detectPackageManager(cwd);
|
|
1341
1581
|
return {
|
|
1582
|
+
execCommand: require_index_node.getExecCommand(packageManager),
|
|
1342
1583
|
packageJson,
|
|
1343
|
-
packageManager
|
|
1344
|
-
execCommand
|
|
1584
|
+
packageManager
|
|
1345
1585
|
};
|
|
1346
1586
|
}
|
|
1347
1587
|
/**
|
|
@@ -1351,7 +1591,8 @@ async function ensurePackageJson(cwd = process.cwd()) {
|
|
|
1351
1591
|
*/
|
|
1352
1592
|
async function writePostinstallHook(execCommand, cwd = process.cwd()) {
|
|
1353
1593
|
const postinstallScript = `${execCommand} aio-commerce-lib-app hooks postinstall`;
|
|
1354
|
-
const pkg = await
|
|
1594
|
+
const pkg = await require_index_node.loadPackageJson(cwd);
|
|
1595
|
+
if (pkg === null) throw new Error("Could not find package.json.");
|
|
1355
1596
|
const existing = pkg.content.scripts?.postinstall;
|
|
1356
1597
|
if (existing === postinstallScript || existing?.includes(postinstallScript)) {
|
|
1357
1598
|
consola.consola.success(`postinstall script already configured in ${PACKAGE_JSON_FILE}`);
|
|
@@ -1369,32 +1610,12 @@ async function writePostinstallHook(execCommand, cwd = process.cwd()) {
|
|
|
1369
1610
|
}
|
|
1370
1611
|
/** Ensure app.config.yaml has the extension reference */
|
|
1371
1612
|
async function ensureAppConfig(domains, cwd = process.cwd()) {
|
|
1372
|
-
const rootDirectory = await
|
|
1613
|
+
const rootDirectory = await require_index_node.getProjectRootDirectory(cwd);
|
|
1373
1614
|
if (domains.has("businessConfig.schema")) await addExtensionPointToAppConfig(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
|
|
1374
|
-
if (domains.has("
|
|
1615
|
+
if (domains.has("adminUi")) await addExtensionPointToAppConfig(BACKEND_UI_V2_EXTENSION_POINT_ID, rootDirectory, " This extension is required for Admin UI. Do not remove.");
|
|
1375
1616
|
await addExtensionPointToAppConfig(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
|
|
1376
1617
|
}
|
|
1377
1618
|
/**
|
|
1378
|
-
* Install the given dependencies.
|
|
1379
|
-
* @param packageManager - The detected package manager
|
|
1380
|
-
* @param dependencies - Package specifiers to install; no-op when empty
|
|
1381
|
-
* @param cwd - Working directory for the install command
|
|
1382
|
-
*/
|
|
1383
|
-
function runInstall(packageManager, dependencies, cwd = process.cwd()) {
|
|
1384
|
-
if (dependencies.length === 0) return;
|
|
1385
|
-
const dependencyListString = dependencies.map((dependency) => ` - ${dependency}`).join("\n");
|
|
1386
|
-
consola.consola.start([`Installing the following dependencies with ${packageManager}:\n${dependencyListString}\n`, "This may take a few seconds...\n"].join("\n"));
|
|
1387
|
-
const { command, args } = require_config.getInstallCommand(packageManager, dependencies);
|
|
1388
|
-
const displayCommand = [command, ...args].join(" ");
|
|
1389
|
-
const result = (0, child_process.spawnSync)(command, args, {
|
|
1390
|
-
cwd,
|
|
1391
|
-
stdio: "inherit"
|
|
1392
|
-
});
|
|
1393
|
-
if (result.error || result.status !== 0) throw new Error(`Failed to install dependencies automatically. Please install manually: ${displayCommand}`, { cause: result.error ?? /* @__PURE__ */ new Error(`Install exited with code ${result.status}`) });
|
|
1394
|
-
consola.consola.log("");
|
|
1395
|
-
consola.consola.success("Dependencies installed successfully");
|
|
1396
|
-
}
|
|
1397
|
-
/**
|
|
1398
1619
|
* Install the domain-specific dependencies derived from the selected domains.
|
|
1399
1620
|
* @param packageManager - The detected package manager
|
|
1400
1621
|
* @param domains - Domains enabled in the commerce app config
|
|
@@ -1402,7 +1623,7 @@ function runInstall(packageManager, dependencies, cwd = process.cwd()) {
|
|
|
1402
1623
|
*/
|
|
1403
1624
|
function installDependencies(packageManager, domains, cwd = process.cwd()) {
|
|
1404
1625
|
const packages = [];
|
|
1405
|
-
if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.
|
|
1626
|
+
if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.6.0-alpha-20260722091448`);
|
|
1406
1627
|
if (packages.length === 0) {
|
|
1407
1628
|
consola.consola.info("No additional domain dependencies to install.");
|
|
1408
1629
|
return;
|
|
@@ -1421,15 +1642,15 @@ async function runGeneration(appConfig, execCommand) {
|
|
|
1421
1642
|
}
|
|
1422
1643
|
/** Ensure install.yaml has the extension reference */
|
|
1423
1644
|
async function ensureInstallYaml(domains, cwd = process.cwd()) {
|
|
1424
|
-
const rootDirectory = await
|
|
1645
|
+
const rootDirectory = await require_index_node.getProjectRootDirectory(cwd);
|
|
1425
1646
|
if (domains.has("businessConfig.schema")) await addExtensionPointToInstallYaml(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
|
|
1426
|
-
if (domains.has("
|
|
1647
|
+
if (domains.has("adminUi")) await addExtensionPointToInstallYaml(BACKEND_UI_V2_EXTENSION_POINT_ID, rootDirectory, " This extension is required for Admin UI. Do not remove.");
|
|
1427
1648
|
await addExtensionPointToInstallYaml(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
|
|
1428
1649
|
}
|
|
1429
1650
|
|
|
1430
1651
|
//#endregion
|
|
1431
1652
|
//#region source/commands/init/main.ts
|
|
1432
|
-
const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.
|
|
1653
|
+
const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.8.0-alpha-20260722091448`];
|
|
1433
1654
|
/** Initialize the project */
|
|
1434
1655
|
async function run(flags, extraOptions) {
|
|
1435
1656
|
consola.consola.start("Initializing app...");
|
|
@@ -1437,11 +1658,12 @@ async function run(flags, extraOptions) {
|
|
|
1437
1658
|
runInstall(packageManager, REQUIRED_DEPENDENCIES);
|
|
1438
1659
|
const { config, domains } = await ensureCommerceAppConfig(process.cwd(), extraOptions?.formatConfig ?? true, flags);
|
|
1439
1660
|
installDependencies(packageManager, domains);
|
|
1440
|
-
const pkg = await
|
|
1661
|
+
const pkg = await require_index_node.loadPackageJson(process.cwd());
|
|
1662
|
+
if (pkg === null) throw new Error("Could not find package.json.");
|
|
1441
1663
|
pkg.update({
|
|
1664
|
+
description: config.metadata.description,
|
|
1442
1665
|
name: config.metadata.id,
|
|
1443
|
-
version: config.metadata.version
|
|
1444
|
-
description: config.metadata.description
|
|
1666
|
+
version: config.metadata.version
|
|
1445
1667
|
});
|
|
1446
1668
|
await pkg.save();
|
|
1447
1669
|
await runGeneration(config, execCommand);
|
|
@@ -1499,17 +1721,17 @@ async function generateAll() {
|
|
|
1499
1721
|
}
|
|
1500
1722
|
/** Command handlers registry mapping command names to their subcommand handlers */
|
|
1501
1723
|
const COMMANDS = {
|
|
1502
|
-
init: exec,
|
|
1503
|
-
hooks: {
|
|
1504
|
-
"pre-app-build": exec$1,
|
|
1505
|
-
postinstall: exec$2
|
|
1506
|
-
},
|
|
1507
1724
|
generate: {
|
|
1508
1725
|
actions: exec$5,
|
|
1726
|
+
all: generateAll,
|
|
1509
1727
|
manifest: exec$4,
|
|
1510
|
-
schema: exec$3
|
|
1511
|
-
|
|
1512
|
-
|
|
1728
|
+
schema: exec$3
|
|
1729
|
+
},
|
|
1730
|
+
hooks: {
|
|
1731
|
+
postinstall: exec$2,
|
|
1732
|
+
"pre-app-build": exec$1
|
|
1733
|
+
},
|
|
1734
|
+
init: exec
|
|
1513
1735
|
};
|
|
1514
1736
|
/**
|
|
1515
1737
|
* Generic command handler that dispatches to specific command implementations
|