@adobe/aio-commerce-lib-app 1.10.0 → 1.10.1
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 +14 -0
- package/dist/cjs/actions/app-config/index.cjs +2 -2
- package/dist/cjs/commands/index.cjs +107 -40
- package/dist/cjs/{openapi-C_y_Y5YX.cjs → openapi-4EYZryTG.cjs} +1 -1
- package/dist/es/actions/app-config/index.mjs +2 -2
- package/dist/es/commands/index.mjs +107 -40
- package/dist/es/{openapi-Brn9plmt.mjs → openapi-B_fZbtfP.mjs} +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-app
|
|
2
2
|
|
|
3
|
+
## 1.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#635](https://github.com/adobe/aio-commerce-sdk/pull/635) [`71bf666`](https://github.com/adobe/aio-commerce-sdk/commit/71bf66656ef1fc6dd272a0821e8b00aab5dc197e) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - The app build hooks now set `NODE_ENV` in the project `.env` so the web bundler builds for the correct environment (production on build, development on dev and run).
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`71bf666`](https://github.com/adobe/aio-commerce-sdk/commit/71bf66656ef1fc6dd272a0821e8b00aab5dc197e), [`71bf666`](https://github.com/adobe/aio-commerce-sdk/commit/71bf66656ef1fc6dd272a0821e8b00aab5dc197e)]:
|
|
10
|
+
- @adobe/aio-commerce-lib-admin-ui@1.0.1
|
|
11
|
+
- @adobe/aio-commerce-lib-auth@1.1.3
|
|
12
|
+
- @adobe/aio-commerce-lib-api@1.3.1
|
|
13
|
+
- @adobe/aio-commerce-lib-config@1.6.1
|
|
14
|
+
- @adobe/aio-commerce-lib-events@1.3.1
|
|
15
|
+
- @adobe/aio-commerce-lib-webhooks@1.2.1
|
|
16
|
+
|
|
3
17
|
## 1.10.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -29,7 +29,7 @@ let crypto = require("crypto");
|
|
|
29
29
|
* Loads the committed OpenAPI spec via dynamic import so it
|
|
30
30
|
* lands in its own chunk and is not parsed on every cold start.
|
|
31
31
|
*/
|
|
32
|
-
const importOpenApi = () => Promise.resolve().then(() => require("../../openapi-
|
|
32
|
+
const importOpenApi = () => Promise.resolve().then(() => require("../../openapi-4EYZryTG.cjs"));
|
|
33
33
|
/** Matches component schema `$ref` strings, capturing the schema name. */
|
|
34
34
|
const SCHEMA_REF_PATTERN = /"#\/components\/schemas\/(\w+)"/g;
|
|
35
35
|
/**
|
|
@@ -80,7 +80,7 @@ function pruneUnusedTags(spec) {
|
|
|
80
80
|
* @param domains - The active config domains.
|
|
81
81
|
*/
|
|
82
82
|
function getOpenApiCacheKey(domains) {
|
|
83
|
-
const input = `1.10.
|
|
83
|
+
const input = `1.10.1:${[...domains].sort().join(",")}:2.0.0`;
|
|
84
84
|
return (0, crypto.createHash)("sha256").update(input).digest("hex").slice(0, 8);
|
|
85
85
|
}
|
|
86
86
|
/** Returns the server URL to be set in the OpenAPI spec, based on the current namespace. */
|
|
@@ -357,7 +357,7 @@ const LEADING_DOT_SLASH_PATTERN$1 = /^\.\//u;
|
|
|
357
357
|
const WEB_SOURCE_DEPENDENCIES = [
|
|
358
358
|
{
|
|
359
359
|
name: "@adobe/aio-commerce-lib-admin-ui",
|
|
360
|
-
version: "^1.0.
|
|
360
|
+
version: "^1.0.1"
|
|
361
361
|
},
|
|
362
362
|
{
|
|
363
363
|
name: "react",
|
|
@@ -683,7 +683,11 @@ function buildAdminUiV2ExtConfig(appConfig) {
|
|
|
683
683
|
const runtimeActions = collectUniqueRuntimeActions(adminUi);
|
|
684
684
|
const requiresWeb = requiresWebSource(adminUi);
|
|
685
685
|
return {
|
|
686
|
-
hooks: {
|
|
686
|
+
hooks: {
|
|
687
|
+
"pre-app-build": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-build",
|
|
688
|
+
"pre-app-dev": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-dev",
|
|
689
|
+
"pre-app-run": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-run"
|
|
690
|
+
},
|
|
687
691
|
operations: {
|
|
688
692
|
...requiresWeb && { view: [{
|
|
689
693
|
impl: "index.html",
|
|
@@ -1152,7 +1156,7 @@ async function generateCustomScriptsTemplate(template, appManifest) {
|
|
|
1152
1156
|
* @param appManifest - The app manifest, used to determine which actions to generate and their content.
|
|
1153
1157
|
* @param templatesDir - The directory to load templates from, for testing purposes. Defaults to the generated actions template root.
|
|
1154
1158
|
*/
|
|
1155
|
-
async function run$
|
|
1159
|
+
async function run$7(appManifest, templatesDir = TEMPLATES_DIR) {
|
|
1156
1160
|
await prepareRuntimeAppConfigModule(appManifest);
|
|
1157
1161
|
const appManagementExtConfig = await updateExtConfig(appManifest, EXTENSIBILITY_EXTENSION_POINT_ID);
|
|
1158
1162
|
await generateActionFiles(appManifest, getRuntimeActions(appManagementExtConfig, "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
|
|
@@ -1169,9 +1173,9 @@ async function run$5(appManifest, templatesDir = TEMPLATES_DIR) {
|
|
|
1169
1173
|
}
|
|
1170
1174
|
}
|
|
1171
1175
|
/** Run the generate actions command */
|
|
1172
|
-
async function exec$
|
|
1176
|
+
async function exec$7() {
|
|
1173
1177
|
try {
|
|
1174
|
-
await run$
|
|
1178
|
+
await run$7(await loadAppManifest());
|
|
1175
1179
|
} catch (error) {
|
|
1176
1180
|
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.consola.error(error.display());
|
|
1177
1181
|
else consola.consola.error(error);
|
|
@@ -1181,7 +1185,7 @@ async function exec$5() {
|
|
|
1181
1185
|
|
|
1182
1186
|
//#endregion
|
|
1183
1187
|
//#region source/commands/generate/manifest/main.ts
|
|
1184
|
-
async function run$
|
|
1188
|
+
async function run$6(appConfig) {
|
|
1185
1189
|
if (await requiresJavaScriptAppConfig(appConfig)) {
|
|
1186
1190
|
const stalePath = (0, path.join)(await require_index_node.getProjectRootDirectory(), getManifestPath());
|
|
1187
1191
|
if (await (0, fs_promises.access)(stalePath).then(() => true, () => false)) {
|
|
@@ -1198,9 +1202,9 @@ async function run$4(appConfig) {
|
|
|
1198
1202
|
consola.consola.success(`Generated ${APP_MANIFEST_FILE}\n`);
|
|
1199
1203
|
}
|
|
1200
1204
|
/** Run the generate manifest command */
|
|
1201
|
-
async function exec$
|
|
1205
|
+
async function exec$6() {
|
|
1202
1206
|
try {
|
|
1203
|
-
await run$
|
|
1207
|
+
await run$6(await loadAppManifest());
|
|
1204
1208
|
} catch (error) {
|
|
1205
1209
|
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.consola.error(error.display());
|
|
1206
1210
|
else consola.consola.error(error);
|
|
@@ -1222,7 +1226,7 @@ async function touch(filePath) {
|
|
|
1222
1226
|
|
|
1223
1227
|
//#endregion
|
|
1224
1228
|
//#region source/commands/generate/schema/main.ts
|
|
1225
|
-
async function run$
|
|
1229
|
+
async function run$5(appConfig) {
|
|
1226
1230
|
if (!require_validate.hasBusinessConfigSchema(appConfig)) {
|
|
1227
1231
|
consola.consola.debug("Business configuration schema not found in application configuration. Nothing to do.");
|
|
1228
1232
|
return;
|
|
@@ -1252,9 +1256,9 @@ async function run$3(appConfig) {
|
|
|
1252
1256
|
consola.consola.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}\n`);
|
|
1253
1257
|
}
|
|
1254
1258
|
/** Run the generate schema command */
|
|
1255
|
-
async function exec$
|
|
1259
|
+
async function exec$5() {
|
|
1256
1260
|
try {
|
|
1257
|
-
await run$
|
|
1261
|
+
await run$5(await loadAppManifest());
|
|
1258
1262
|
} catch (error) {
|
|
1259
1263
|
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.consola.error(error.display());
|
|
1260
1264
|
else consola.consola.error(error);
|
|
@@ -1264,16 +1268,16 @@ async function exec$3() {
|
|
|
1264
1268
|
|
|
1265
1269
|
//#endregion
|
|
1266
1270
|
//#region source/commands/hooks/postinstall.ts
|
|
1267
|
-
async function run$
|
|
1268
|
-
await run$
|
|
1269
|
-
await run$
|
|
1270
|
-
await run$
|
|
1271
|
+
async function run$4(appManifest, templatesDir) {
|
|
1272
|
+
await run$7(appManifest, templatesDir);
|
|
1273
|
+
await run$6(appManifest);
|
|
1274
|
+
await run$5(appManifest);
|
|
1271
1275
|
}
|
|
1272
1276
|
/** Runs the postinstall hook */
|
|
1273
|
-
async function exec$
|
|
1277
|
+
async function exec$4() {
|
|
1274
1278
|
consola.default.debug("Running lib-app postinstall hook");
|
|
1275
1279
|
try {
|
|
1276
|
-
await run$
|
|
1280
|
+
await run$4(await loadAppManifest());
|
|
1277
1281
|
} catch (error) {
|
|
1278
1282
|
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.default.error(error.display());
|
|
1279
1283
|
else consola.default.error(error);
|
|
@@ -1319,10 +1323,26 @@ function replaceEnvVar(filePath, key, value) {
|
|
|
1319
1323
|
if (!keyExists) updatedLines.push(`${key}=${formattedValue}`);
|
|
1320
1324
|
(0, fs.writeFileSync)(envPath, updatedLines.join("\n"), "utf8");
|
|
1321
1325
|
}
|
|
1322
|
-
/**
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
+
/**
|
|
1327
|
+
* Returns the path to the project's `.env` file, resolved from the project root
|
|
1328
|
+
* (the nearest `package.json` walking up from `cwd`), so it is found regardless
|
|
1329
|
+
* of which subdirectory a command is invoked from.
|
|
1330
|
+
* @param cwd - A directory within the project. Defaults to the current working directory.
|
|
1331
|
+
*/
|
|
1332
|
+
async function resolveEnvPath(cwd = process.cwd()) {
|
|
1333
|
+
const projectRoot = await require_index_node.getProjectRootDirectory(cwd);
|
|
1334
|
+
return path.default.join(projectRoot, ".env");
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Sets the `NODE_ENV` environment variable in the app `.env` file, so the web
|
|
1338
|
+
* bundler (Parcel) ships the matching React build. Creates the `.env` if absent.
|
|
1339
|
+
* @param mode - The environment mode to write into `NODE_ENV`.
|
|
1340
|
+
* @param cwd - A directory within the project. Defaults to the current working directory.
|
|
1341
|
+
*/
|
|
1342
|
+
async function setNodeEnv(mode, cwd = process.cwd()) {
|
|
1343
|
+
const envPath = await resolveEnvPath(cwd);
|
|
1344
|
+
if (!(0, fs.existsSync)(envPath)) (0, fs.writeFileSync)(envPath, "", "utf8");
|
|
1345
|
+
replaceEnvVar(envPath, "NODE_ENV", mode);
|
|
1326
1346
|
}
|
|
1327
1347
|
/** Resolves the IMS server to server context from the project workspace credentials. */
|
|
1328
1348
|
function resolveImsS2SContext() {
|
|
@@ -1333,9 +1353,10 @@ function resolveImsS2SContext() {
|
|
|
1333
1353
|
/**
|
|
1334
1354
|
* Syncs the IMS credentials environment variables from the configured IMS context in
|
|
1335
1355
|
* the .env file, in a way that is compatible with `@adobe/aio-commerce-lib-auth`.
|
|
1356
|
+
* @param cwd - A directory within the project. Defaults to the current working directory.
|
|
1336
1357
|
*/
|
|
1337
|
-
async function syncImsCredentials() {
|
|
1338
|
-
const envPath = resolveEnvPath();
|
|
1358
|
+
async function syncImsCredentials(cwd = process.cwd()) {
|
|
1359
|
+
const envPath = await resolveEnvPath(cwd);
|
|
1339
1360
|
if (!(0, fs.existsSync)(envPath)) return {
|
|
1340
1361
|
ok: false,
|
|
1341
1362
|
reason: "missing-env"
|
|
@@ -1360,22 +1381,23 @@ async function syncImsCredentials() {
|
|
|
1360
1381
|
/**
|
|
1361
1382
|
* Runs the pre-app-build hook for the given extension.
|
|
1362
1383
|
* @param extension - The extension to run the hook for.
|
|
1384
|
+
* @param cwd - The project directory. Defaults to the current working directory.
|
|
1363
1385
|
* @param templatesDir - The directory to load templates from, for testing purposes. Defaults to the generated actions template root.
|
|
1364
1386
|
*/
|
|
1365
|
-
async function run$
|
|
1387
|
+
async function run$3(extension, cwd = process.cwd(), templatesDir = TEMPLATES_DIR) {
|
|
1366
1388
|
const appManifest = await loadAppManifest();
|
|
1367
1389
|
await prepareRuntimeAppConfigModule(appManifest);
|
|
1368
1390
|
if (extension === "extensibility/1") {
|
|
1369
1391
|
const { doc: extensibilityExtConfig } = await readExtConfig(EXTENSIBILITY_EXTENSION_POINT_ID);
|
|
1370
|
-
await run$
|
|
1392
|
+
await run$6(appManifest);
|
|
1371
1393
|
await generateActionFiles(appManifest, getRuntimeActions(extensibilityExtConfig.toJS(), "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
|
|
1372
1394
|
consola.default.info("Syncing IMS credentials...");
|
|
1373
|
-
await syncImsCredentials();
|
|
1395
|
+
await syncImsCredentials(cwd);
|
|
1374
1396
|
return;
|
|
1375
1397
|
}
|
|
1376
1398
|
if (extension === "configuration/1") {
|
|
1377
1399
|
const { doc: businessConfigExtConfig } = await readExtConfig(CONFIGURATION_EXTENSION_POINT_ID);
|
|
1378
|
-
await run$
|
|
1400
|
+
await run$5(appManifest);
|
|
1379
1401
|
await generateActionFiles(appManifest, getRuntimeActions(businessConfigExtConfig.toJS(), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
|
|
1380
1402
|
return;
|
|
1381
1403
|
}
|
|
@@ -1385,6 +1407,7 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
|
|
|
1385
1407
|
if (extConfig.operations?.view) {
|
|
1386
1408
|
await prepareWebSourceImportAlias(extConfig);
|
|
1387
1409
|
await generateWebSrc(extConfig, appManifest.metadata.displayName, templatesDir);
|
|
1410
|
+
await setNodeEnv("production", cwd);
|
|
1388
1411
|
}
|
|
1389
1412
|
}
|
|
1390
1413
|
return;
|
|
@@ -1392,12 +1415,54 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
|
|
|
1392
1415
|
throw new Error(`Unsupported extension: ${extension}`);
|
|
1393
1416
|
}
|
|
1394
1417
|
/** Runs the pre-app-build hook */
|
|
1395
|
-
async function exec$
|
|
1418
|
+
async function exec$3() {
|
|
1396
1419
|
consola.default.debug("Running lib-app pre-app-build hook");
|
|
1397
1420
|
const rawExtension = process.env.EXTENSION;
|
|
1398
1421
|
try {
|
|
1399
1422
|
if (!rawExtension) throw new Error("EXTENSION environment variable is not set");
|
|
1400
|
-
await run$
|
|
1423
|
+
await run$3(rawExtension);
|
|
1424
|
+
} catch (error) {
|
|
1425
|
+
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.default.error(error.display());
|
|
1426
|
+
else consola.default.error(error);
|
|
1427
|
+
process.exit(1);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
//#endregion
|
|
1432
|
+
//#region source/commands/hooks/pre-app-dev.ts
|
|
1433
|
+
/**
|
|
1434
|
+
* Resets the web build back to development by writing `NODE_ENV` to the project `.env`.
|
|
1435
|
+
* @param cwd - The project directory. Defaults to the current working directory.
|
|
1436
|
+
*/
|
|
1437
|
+
async function run$2(cwd = process.cwd()) {
|
|
1438
|
+
await setNodeEnv("development", cwd);
|
|
1439
|
+
}
|
|
1440
|
+
/** Runs the pre-app-dev hook. */
|
|
1441
|
+
async function exec$2() {
|
|
1442
|
+
consola.default.debug("Running lib-app pre-app-dev hook");
|
|
1443
|
+
try {
|
|
1444
|
+
await run$2();
|
|
1445
|
+
} catch (error) {
|
|
1446
|
+
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.default.error(error.display());
|
|
1447
|
+
else consola.default.error(error);
|
|
1448
|
+
process.exit(1);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
//#endregion
|
|
1453
|
+
//#region source/commands/hooks/pre-app-run.ts
|
|
1454
|
+
/**
|
|
1455
|
+
* Resets the web build back to development by writing `NODE_ENV` to the project `.env`.
|
|
1456
|
+
* @param cwd - The project directory. Defaults to the current working directory.
|
|
1457
|
+
*/
|
|
1458
|
+
async function run$1(cwd = process.cwd()) {
|
|
1459
|
+
await setNodeEnv("development", cwd);
|
|
1460
|
+
}
|
|
1461
|
+
/** Runs the pre-app-run hook. */
|
|
1462
|
+
async function exec$1() {
|
|
1463
|
+
consola.default.debug("Running lib-app pre-app-run hook");
|
|
1464
|
+
try {
|
|
1465
|
+
await run$1();
|
|
1401
1466
|
} catch (error) {
|
|
1402
1467
|
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.default.error(error.display());
|
|
1403
1468
|
else consola.default.error(error);
|
|
@@ -1762,7 +1827,7 @@ async function ensureAppConfig(domains, cwd = process.cwd()) {
|
|
|
1762
1827
|
*/
|
|
1763
1828
|
function installDependencies(packageManager, domains, cwd = process.cwd()) {
|
|
1764
1829
|
const packages = [];
|
|
1765
|
-
if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.6.
|
|
1830
|
+
if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.6.1`);
|
|
1766
1831
|
if (packages.length === 0) {
|
|
1767
1832
|
consola.consola.info("No additional domain dependencies to install.");
|
|
1768
1833
|
return;
|
|
@@ -1772,9 +1837,9 @@ function installDependencies(packageManager, domains, cwd = process.cwd()) {
|
|
|
1772
1837
|
/** Run the generation command */
|
|
1773
1838
|
async function runGeneration(appConfig, execCommand) {
|
|
1774
1839
|
try {
|
|
1840
|
+
await run$7(appConfig);
|
|
1841
|
+
await run$6(appConfig);
|
|
1775
1842
|
await run$5(appConfig);
|
|
1776
|
-
await run$4(appConfig);
|
|
1777
|
-
await run$3(appConfig);
|
|
1778
1843
|
} catch (error) {
|
|
1779
1844
|
throw new Error(`Failed to run generation command. Please run manually: ${execCommand} aio-commerce-lib-app generate all`, { cause: error });
|
|
1780
1845
|
}
|
|
@@ -1789,7 +1854,7 @@ async function ensureInstallYaml(domains, cwd = process.cwd()) {
|
|
|
1789
1854
|
|
|
1790
1855
|
//#endregion
|
|
1791
1856
|
//#region source/commands/init/main.ts
|
|
1792
|
-
const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.10.
|
|
1857
|
+
const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.10.1`];
|
|
1793
1858
|
/** Initialize the project */
|
|
1794
1859
|
async function run(flags, extraOptions) {
|
|
1795
1860
|
consola.consola.start("Initializing app...");
|
|
@@ -1857,21 +1922,23 @@ Examples:
|
|
|
1857
1922
|
`;
|
|
1858
1923
|
/** Run all generate targets in sequence */
|
|
1859
1924
|
async function generateAll() {
|
|
1925
|
+
await exec$7();
|
|
1926
|
+
await exec$6();
|
|
1860
1927
|
await exec$5();
|
|
1861
|
-
await exec$4();
|
|
1862
|
-
await exec$3();
|
|
1863
1928
|
}
|
|
1864
1929
|
/** Command handlers registry mapping command names to their subcommand handlers */
|
|
1865
1930
|
const COMMANDS = {
|
|
1866
1931
|
generate: {
|
|
1867
|
-
actions: exec$
|
|
1932
|
+
actions: exec$7,
|
|
1868
1933
|
all: generateAll,
|
|
1869
|
-
manifest: exec$
|
|
1870
|
-
schema: exec$
|
|
1934
|
+
manifest: exec$6,
|
|
1935
|
+
schema: exec$5
|
|
1871
1936
|
},
|
|
1872
1937
|
hooks: {
|
|
1873
|
-
postinstall: exec$
|
|
1874
|
-
"pre-app-build": exec$
|
|
1938
|
+
postinstall: exec$4,
|
|
1939
|
+
"pre-app-build": exec$3,
|
|
1940
|
+
"pre-app-dev": exec$2,
|
|
1941
|
+
"pre-app-run": exec$1
|
|
1875
1942
|
},
|
|
1876
1943
|
init: exec
|
|
1877
1944
|
};
|
|
@@ -26,7 +26,7 @@ import { createHash } from "crypto";
|
|
|
26
26
|
* Loads the committed OpenAPI spec via dynamic import so it
|
|
27
27
|
* lands in its own chunk and is not parsed on every cold start.
|
|
28
28
|
*/
|
|
29
|
-
const importOpenApi = () => import("../../openapi-
|
|
29
|
+
const importOpenApi = () => import("../../openapi-B_fZbtfP.mjs");
|
|
30
30
|
/** Matches component schema `$ref` strings, capturing the schema name. */
|
|
31
31
|
const SCHEMA_REF_PATTERN = /"#\/components\/schemas\/(\w+)"/g;
|
|
32
32
|
/**
|
|
@@ -77,7 +77,7 @@ function pruneUnusedTags(spec) {
|
|
|
77
77
|
* @param domains - The active config domains.
|
|
78
78
|
*/
|
|
79
79
|
function getOpenApiCacheKey(domains) {
|
|
80
|
-
const input = `1.10.
|
|
80
|
+
const input = `1.10.1:${[...domains].sort().join(",")}:2.0.0`;
|
|
81
81
|
return createHash("sha256").update(input).digest("hex").slice(0, 8);
|
|
82
82
|
}
|
|
83
83
|
/** Returns the server URL to be set in the OpenAPI spec, based on the current namespace. */
|
|
@@ -350,7 +350,7 @@ const LEADING_DOT_SLASH_PATTERN$1 = /^\.\//u;
|
|
|
350
350
|
const WEB_SOURCE_DEPENDENCIES = [
|
|
351
351
|
{
|
|
352
352
|
name: "@adobe/aio-commerce-lib-admin-ui",
|
|
353
|
-
version: "^1.0.
|
|
353
|
+
version: "^1.0.1"
|
|
354
354
|
},
|
|
355
355
|
{
|
|
356
356
|
name: "react",
|
|
@@ -676,7 +676,11 @@ function buildAdminUiV2ExtConfig(appConfig) {
|
|
|
676
676
|
const runtimeActions = collectUniqueRuntimeActions(adminUi);
|
|
677
677
|
const requiresWeb = requiresWebSource(adminUi);
|
|
678
678
|
return {
|
|
679
|
-
hooks: {
|
|
679
|
+
hooks: {
|
|
680
|
+
"pre-app-build": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-build",
|
|
681
|
+
"pre-app-dev": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-dev",
|
|
682
|
+
"pre-app-run": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-run"
|
|
683
|
+
},
|
|
680
684
|
operations: {
|
|
681
685
|
...requiresWeb && { view: [{
|
|
682
686
|
impl: "index.html",
|
|
@@ -1145,7 +1149,7 @@ async function generateCustomScriptsTemplate(template, appManifest) {
|
|
|
1145
1149
|
* @param appManifest - The app manifest, used to determine which actions to generate and their content.
|
|
1146
1150
|
* @param templatesDir - The directory to load templates from, for testing purposes. Defaults to the generated actions template root.
|
|
1147
1151
|
*/
|
|
1148
|
-
async function run$
|
|
1152
|
+
async function run$7(appManifest, templatesDir = TEMPLATES_DIR) {
|
|
1149
1153
|
await prepareRuntimeAppConfigModule(appManifest);
|
|
1150
1154
|
const appManagementExtConfig = await updateExtConfig(appManifest, EXTENSIBILITY_EXTENSION_POINT_ID);
|
|
1151
1155
|
await generateActionFiles(appManifest, getRuntimeActions(appManagementExtConfig, "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
|
|
@@ -1162,9 +1166,9 @@ async function run$5(appManifest, templatesDir = TEMPLATES_DIR) {
|
|
|
1162
1166
|
}
|
|
1163
1167
|
}
|
|
1164
1168
|
/** Run the generate actions command */
|
|
1165
|
-
async function exec$
|
|
1169
|
+
async function exec$7() {
|
|
1166
1170
|
try {
|
|
1167
|
-
await run$
|
|
1171
|
+
await run$7(await loadAppManifest());
|
|
1168
1172
|
} catch (error) {
|
|
1169
1173
|
if (error instanceof CommerceSdkValidationError) consola.error(error.display());
|
|
1170
1174
|
else consola.error(error);
|
|
@@ -1174,7 +1178,7 @@ async function exec$5() {
|
|
|
1174
1178
|
|
|
1175
1179
|
//#endregion
|
|
1176
1180
|
//#region source/commands/generate/manifest/main.ts
|
|
1177
|
-
async function run$
|
|
1181
|
+
async function run$6(appConfig) {
|
|
1178
1182
|
if (await requiresJavaScriptAppConfig(appConfig)) {
|
|
1179
1183
|
const stalePath = join(await getProjectRootDirectory(), getManifestPath());
|
|
1180
1184
|
if (await access(stalePath).then(() => true, () => false)) {
|
|
@@ -1191,9 +1195,9 @@ async function run$4(appConfig) {
|
|
|
1191
1195
|
consola.success(`Generated ${APP_MANIFEST_FILE}\n`);
|
|
1192
1196
|
}
|
|
1193
1197
|
/** Run the generate manifest command */
|
|
1194
|
-
async function exec$
|
|
1198
|
+
async function exec$6() {
|
|
1195
1199
|
try {
|
|
1196
|
-
await run$
|
|
1200
|
+
await run$6(await loadAppManifest());
|
|
1197
1201
|
} catch (error) {
|
|
1198
1202
|
if (error instanceof CommerceSdkValidationError) consola.error(error.display());
|
|
1199
1203
|
else consola.error(error);
|
|
@@ -1215,7 +1219,7 @@ async function touch(filePath) {
|
|
|
1215
1219
|
|
|
1216
1220
|
//#endregion
|
|
1217
1221
|
//#region source/commands/generate/schema/main.ts
|
|
1218
|
-
async function run$
|
|
1222
|
+
async function run$5(appConfig) {
|
|
1219
1223
|
if (!hasBusinessConfigSchema(appConfig)) {
|
|
1220
1224
|
consola.debug("Business configuration schema not found in application configuration. Nothing to do.");
|
|
1221
1225
|
return;
|
|
@@ -1245,9 +1249,9 @@ async function run$3(appConfig) {
|
|
|
1245
1249
|
consola.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}\n`);
|
|
1246
1250
|
}
|
|
1247
1251
|
/** Run the generate schema command */
|
|
1248
|
-
async function exec$
|
|
1252
|
+
async function exec$5() {
|
|
1249
1253
|
try {
|
|
1250
|
-
await run$
|
|
1254
|
+
await run$5(await loadAppManifest());
|
|
1251
1255
|
} catch (error) {
|
|
1252
1256
|
if (error instanceof CommerceSdkValidationError) consola.error(error.display());
|
|
1253
1257
|
else consola.error(error);
|
|
@@ -1257,16 +1261,16 @@ async function exec$3() {
|
|
|
1257
1261
|
|
|
1258
1262
|
//#endregion
|
|
1259
1263
|
//#region source/commands/hooks/postinstall.ts
|
|
1260
|
-
async function run$
|
|
1261
|
-
await run$
|
|
1262
|
-
await run$
|
|
1263
|
-
await run$
|
|
1264
|
+
async function run$4(appManifest, templatesDir) {
|
|
1265
|
+
await run$7(appManifest, templatesDir);
|
|
1266
|
+
await run$6(appManifest);
|
|
1267
|
+
await run$5(appManifest);
|
|
1264
1268
|
}
|
|
1265
1269
|
/** Runs the postinstall hook */
|
|
1266
|
-
async function exec$
|
|
1270
|
+
async function exec$4() {
|
|
1267
1271
|
consola$1.debug("Running lib-app postinstall hook");
|
|
1268
1272
|
try {
|
|
1269
|
-
await run$
|
|
1273
|
+
await run$4(await loadAppManifest());
|
|
1270
1274
|
} catch (error) {
|
|
1271
1275
|
if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
|
|
1272
1276
|
else consola$1.error(error);
|
|
@@ -1312,10 +1316,26 @@ function replaceEnvVar(filePath, key, value) {
|
|
|
1312
1316
|
if (!keyExists) updatedLines.push(`${key}=${formattedValue}`);
|
|
1313
1317
|
writeFileSync(envPath, updatedLines.join("\n"), "utf8");
|
|
1314
1318
|
}
|
|
1315
|
-
/**
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
+
/**
|
|
1320
|
+
* Returns the path to the project's `.env` file, resolved from the project root
|
|
1321
|
+
* (the nearest `package.json` walking up from `cwd`), so it is found regardless
|
|
1322
|
+
* of which subdirectory a command is invoked from.
|
|
1323
|
+
* @param cwd - A directory within the project. Defaults to the current working directory.
|
|
1324
|
+
*/
|
|
1325
|
+
async function resolveEnvPath(cwd = process.cwd()) {
|
|
1326
|
+
const projectRoot = await getProjectRootDirectory(cwd);
|
|
1327
|
+
return path.join(projectRoot, ".env");
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Sets the `NODE_ENV` environment variable in the app `.env` file, so the web
|
|
1331
|
+
* bundler (Parcel) ships the matching React build. Creates the `.env` if absent.
|
|
1332
|
+
* @param mode - The environment mode to write into `NODE_ENV`.
|
|
1333
|
+
* @param cwd - A directory within the project. Defaults to the current working directory.
|
|
1334
|
+
*/
|
|
1335
|
+
async function setNodeEnv(mode, cwd = process.cwd()) {
|
|
1336
|
+
const envPath = await resolveEnvPath(cwd);
|
|
1337
|
+
if (!existsSync(envPath)) writeFileSync(envPath, "", "utf8");
|
|
1338
|
+
replaceEnvVar(envPath, "NODE_ENV", mode);
|
|
1319
1339
|
}
|
|
1320
1340
|
/** Resolves the IMS server to server context from the project workspace credentials. */
|
|
1321
1341
|
function resolveImsS2SContext() {
|
|
@@ -1326,9 +1346,10 @@ function resolveImsS2SContext() {
|
|
|
1326
1346
|
/**
|
|
1327
1347
|
* Syncs the IMS credentials environment variables from the configured IMS context in
|
|
1328
1348
|
* the .env file, in a way that is compatible with `@adobe/aio-commerce-lib-auth`.
|
|
1349
|
+
* @param cwd - A directory within the project. Defaults to the current working directory.
|
|
1329
1350
|
*/
|
|
1330
|
-
async function syncImsCredentials() {
|
|
1331
|
-
const envPath = resolveEnvPath();
|
|
1351
|
+
async function syncImsCredentials(cwd = process.cwd()) {
|
|
1352
|
+
const envPath = await resolveEnvPath(cwd);
|
|
1332
1353
|
if (!existsSync(envPath)) return {
|
|
1333
1354
|
ok: false,
|
|
1334
1355
|
reason: "missing-env"
|
|
@@ -1353,22 +1374,23 @@ async function syncImsCredentials() {
|
|
|
1353
1374
|
/**
|
|
1354
1375
|
* Runs the pre-app-build hook for the given extension.
|
|
1355
1376
|
* @param extension - The extension to run the hook for.
|
|
1377
|
+
* @param cwd - The project directory. Defaults to the current working directory.
|
|
1356
1378
|
* @param templatesDir - The directory to load templates from, for testing purposes. Defaults to the generated actions template root.
|
|
1357
1379
|
*/
|
|
1358
|
-
async function run$
|
|
1380
|
+
async function run$3(extension, cwd = process.cwd(), templatesDir = TEMPLATES_DIR) {
|
|
1359
1381
|
const appManifest = await loadAppManifest();
|
|
1360
1382
|
await prepareRuntimeAppConfigModule(appManifest);
|
|
1361
1383
|
if (extension === "extensibility/1") {
|
|
1362
1384
|
const { doc: extensibilityExtConfig } = await readExtConfig(EXTENSIBILITY_EXTENSION_POINT_ID);
|
|
1363
|
-
await run$
|
|
1385
|
+
await run$6(appManifest);
|
|
1364
1386
|
await generateActionFiles(appManifest, getRuntimeActions(extensibilityExtConfig.toJS(), "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
|
|
1365
1387
|
consola$1.info("Syncing IMS credentials...");
|
|
1366
|
-
await syncImsCredentials();
|
|
1388
|
+
await syncImsCredentials(cwd);
|
|
1367
1389
|
return;
|
|
1368
1390
|
}
|
|
1369
1391
|
if (extension === "configuration/1") {
|
|
1370
1392
|
const { doc: businessConfigExtConfig } = await readExtConfig(CONFIGURATION_EXTENSION_POINT_ID);
|
|
1371
|
-
await run$
|
|
1393
|
+
await run$5(appManifest);
|
|
1372
1394
|
await generateActionFiles(appManifest, getRuntimeActions(businessConfigExtConfig.toJS(), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
|
|
1373
1395
|
return;
|
|
1374
1396
|
}
|
|
@@ -1378,6 +1400,7 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
|
|
|
1378
1400
|
if (extConfig.operations?.view) {
|
|
1379
1401
|
await prepareWebSourceImportAlias(extConfig);
|
|
1380
1402
|
await generateWebSrc(extConfig, appManifest.metadata.displayName, templatesDir);
|
|
1403
|
+
await setNodeEnv("production", cwd);
|
|
1381
1404
|
}
|
|
1382
1405
|
}
|
|
1383
1406
|
return;
|
|
@@ -1385,12 +1408,54 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
|
|
|
1385
1408
|
throw new Error(`Unsupported extension: ${extension}`);
|
|
1386
1409
|
}
|
|
1387
1410
|
/** Runs the pre-app-build hook */
|
|
1388
|
-
async function exec$
|
|
1411
|
+
async function exec$3() {
|
|
1389
1412
|
consola$1.debug("Running lib-app pre-app-build hook");
|
|
1390
1413
|
const rawExtension = process.env.EXTENSION;
|
|
1391
1414
|
try {
|
|
1392
1415
|
if (!rawExtension) throw new Error("EXTENSION environment variable is not set");
|
|
1393
|
-
await run$
|
|
1416
|
+
await run$3(rawExtension);
|
|
1417
|
+
} catch (error) {
|
|
1418
|
+
if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
|
|
1419
|
+
else consola$1.error(error);
|
|
1420
|
+
process.exit(1);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
//#endregion
|
|
1425
|
+
//#region source/commands/hooks/pre-app-dev.ts
|
|
1426
|
+
/**
|
|
1427
|
+
* Resets the web build back to development by writing `NODE_ENV` to the project `.env`.
|
|
1428
|
+
* @param cwd - The project directory. Defaults to the current working directory.
|
|
1429
|
+
*/
|
|
1430
|
+
async function run$2(cwd = process.cwd()) {
|
|
1431
|
+
await setNodeEnv("development", cwd);
|
|
1432
|
+
}
|
|
1433
|
+
/** Runs the pre-app-dev hook. */
|
|
1434
|
+
async function exec$2() {
|
|
1435
|
+
consola$1.debug("Running lib-app pre-app-dev hook");
|
|
1436
|
+
try {
|
|
1437
|
+
await run$2();
|
|
1438
|
+
} catch (error) {
|
|
1439
|
+
if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
|
|
1440
|
+
else consola$1.error(error);
|
|
1441
|
+
process.exit(1);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
//#endregion
|
|
1446
|
+
//#region source/commands/hooks/pre-app-run.ts
|
|
1447
|
+
/**
|
|
1448
|
+
* Resets the web build back to development by writing `NODE_ENV` to the project `.env`.
|
|
1449
|
+
* @param cwd - The project directory. Defaults to the current working directory.
|
|
1450
|
+
*/
|
|
1451
|
+
async function run$1(cwd = process.cwd()) {
|
|
1452
|
+
await setNodeEnv("development", cwd);
|
|
1453
|
+
}
|
|
1454
|
+
/** Runs the pre-app-run hook. */
|
|
1455
|
+
async function exec$1() {
|
|
1456
|
+
consola$1.debug("Running lib-app pre-app-run hook");
|
|
1457
|
+
try {
|
|
1458
|
+
await run$1();
|
|
1394
1459
|
} catch (error) {
|
|
1395
1460
|
if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
|
|
1396
1461
|
else consola$1.error(error);
|
|
@@ -1755,7 +1820,7 @@ async function ensureAppConfig(domains, cwd = process.cwd()) {
|
|
|
1755
1820
|
*/
|
|
1756
1821
|
function installDependencies(packageManager, domains, cwd = process.cwd()) {
|
|
1757
1822
|
const packages = [];
|
|
1758
|
-
if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.6.
|
|
1823
|
+
if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.6.1`);
|
|
1759
1824
|
if (packages.length === 0) {
|
|
1760
1825
|
consola.info("No additional domain dependencies to install.");
|
|
1761
1826
|
return;
|
|
@@ -1765,9 +1830,9 @@ function installDependencies(packageManager, domains, cwd = process.cwd()) {
|
|
|
1765
1830
|
/** Run the generation command */
|
|
1766
1831
|
async function runGeneration(appConfig, execCommand) {
|
|
1767
1832
|
try {
|
|
1833
|
+
await run$7(appConfig);
|
|
1834
|
+
await run$6(appConfig);
|
|
1768
1835
|
await run$5(appConfig);
|
|
1769
|
-
await run$4(appConfig);
|
|
1770
|
-
await run$3(appConfig);
|
|
1771
1836
|
} catch (error) {
|
|
1772
1837
|
throw new Error(`Failed to run generation command. Please run manually: ${execCommand} aio-commerce-lib-app generate all`, { cause: error });
|
|
1773
1838
|
}
|
|
@@ -1782,7 +1847,7 @@ async function ensureInstallYaml(domains, cwd = process.cwd()) {
|
|
|
1782
1847
|
|
|
1783
1848
|
//#endregion
|
|
1784
1849
|
//#region source/commands/init/main.ts
|
|
1785
|
-
const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.10.
|
|
1850
|
+
const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.10.1`];
|
|
1786
1851
|
/** Initialize the project */
|
|
1787
1852
|
async function run(flags, extraOptions) {
|
|
1788
1853
|
consola.start("Initializing app...");
|
|
@@ -1850,21 +1915,23 @@ Examples:
|
|
|
1850
1915
|
`;
|
|
1851
1916
|
/** Run all generate targets in sequence */
|
|
1852
1917
|
async function generateAll() {
|
|
1918
|
+
await exec$7();
|
|
1919
|
+
await exec$6();
|
|
1853
1920
|
await exec$5();
|
|
1854
|
-
await exec$4();
|
|
1855
|
-
await exec$3();
|
|
1856
1921
|
}
|
|
1857
1922
|
/** Command handlers registry mapping command names to their subcommand handlers */
|
|
1858
1923
|
const COMMANDS = {
|
|
1859
1924
|
generate: {
|
|
1860
|
-
actions: exec$
|
|
1925
|
+
actions: exec$7,
|
|
1861
1926
|
all: generateAll,
|
|
1862
|
-
manifest: exec$
|
|
1863
|
-
schema: exec$
|
|
1927
|
+
manifest: exec$6,
|
|
1928
|
+
schema: exec$5
|
|
1864
1929
|
},
|
|
1865
1930
|
hooks: {
|
|
1866
|
-
postinstall: exec$
|
|
1867
|
-
"pre-app-build": exec$
|
|
1931
|
+
postinstall: exec$4,
|
|
1932
|
+
"pre-app-build": exec$3,
|
|
1933
|
+
"pre-app-dev": exec$2,
|
|
1934
|
+
"pre-app-run": exec$1
|
|
1868
1935
|
},
|
|
1869
1936
|
init: exec
|
|
1870
1937
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@adobe/aio-commerce-lib-app",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Adobe Inc.",
|
|
5
|
-
"version": "1.10.
|
|
5
|
+
"version": "1.10.1",
|
|
6
6
|
"private": false,
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22 <=24"
|
|
@@ -120,13 +120,13 @@
|
|
|
120
120
|
"type-fest": "^5.0.0",
|
|
121
121
|
"valibot": "^1.1.0",
|
|
122
122
|
"yaml": "^2.8.1",
|
|
123
|
-
"@adobe/aio-commerce-lib-admin-ui": "1.0.
|
|
124
|
-
"@adobe/aio-commerce-lib-api": "1.3.
|
|
125
|
-
"@adobe/aio-commerce-lib-
|
|
126
|
-
"@adobe/aio-commerce-lib-
|
|
123
|
+
"@adobe/aio-commerce-lib-admin-ui": "1.0.1",
|
|
124
|
+
"@adobe/aio-commerce-lib-api": "1.3.1",
|
|
125
|
+
"@adobe/aio-commerce-lib-auth": "1.1.3",
|
|
126
|
+
"@adobe/aio-commerce-lib-config": "1.6.1",
|
|
127
127
|
"@adobe/aio-commerce-lib-core": "1.2.0",
|
|
128
|
-
"@adobe/aio-commerce-lib-events": "1.3.
|
|
129
|
-
"@adobe/aio-commerce-lib-webhooks": "1.2.
|
|
128
|
+
"@adobe/aio-commerce-lib-events": "1.3.1",
|
|
129
|
+
"@adobe/aio-commerce-lib-webhooks": "1.2.1"
|
|
130
130
|
},
|
|
131
131
|
"peerDependencies": {
|
|
132
132
|
"@tsconfig/bases": "^1.0.26",
|
|
@@ -156,9 +156,9 @@
|
|
|
156
156
|
"@aio-commerce-sdk/common-utils": "0.2.6",
|
|
157
157
|
"@aio-commerce-sdk/config-tsdown": "1.0.1",
|
|
158
158
|
"@aio-commerce-sdk/config-typedoc": "1.0.0",
|
|
159
|
-
"@aio-commerce-sdk/config-vitest": "1.0.0",
|
|
160
|
-
"@aio-commerce-sdk/scripting-utils": "0.3.4",
|
|
161
159
|
"@aio-commerce-sdk/config-typescript": "1.0.0",
|
|
160
|
+
"@aio-commerce-sdk/config-vitest": "1.0.0",
|
|
161
|
+
"@aio-commerce-sdk/scripting-utils": "0.3.5",
|
|
162
162
|
"@aio-commerce-sdk/scripts": "0.1.1"
|
|
163
163
|
},
|
|
164
164
|
"sideEffects": false,
|