@adobe/aio-commerce-lib-app 0.3.2 → 1.0.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +1 -4
  3. package/bin/cli.mjs +24 -0
  4. package/dist/cjs/actions/app-config.cjs +27 -0
  5. package/dist/cjs/actions/app-config.d.cts +15 -0
  6. package/dist/cjs/actions/config.cjs +79 -0
  7. package/dist/cjs/actions/config.d.cts +15 -0
  8. package/dist/cjs/actions/installation.cjs +424 -0
  9. package/dist/cjs/actions/{index.d.cts → installation.d.cts} +4 -3
  10. package/dist/cjs/actions/scope-tree.cjs +97 -0
  11. package/dist/cjs/actions/scope-tree.d.cts +8 -0
  12. package/dist/{es/app-Cx1-6dn0.d.mts → cjs/app-DWX5-Hsf.d.cts} +14 -14
  13. package/dist/cjs/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
  14. package/dist/cjs/commands/generate/actions/templates/app-management/installation.js.template +1 -1
  15. package/dist/cjs/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
  16. package/dist/cjs/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
  17. package/dist/cjs/commands/index.cjs +91 -106
  18. package/dist/cjs/config/index.cjs +21 -19
  19. package/dist/cjs/config/index.d.cts +52 -352
  20. package/dist/cjs/error-DJ2UAPH2.cjs +24 -0
  21. package/dist/cjs/installation-CLbceU9F.cjs +243 -0
  22. package/dist/cjs/{logging-DYwr5WQk.cjs → logging-IDRQG0as.cjs} +2 -2
  23. package/dist/cjs/management/index.cjs +9 -8
  24. package/dist/cjs/management/index.d.cts +2 -2
  25. package/dist/cjs/parser-BPpg_9QB.cjs +267 -0
  26. package/dist/cjs/router-DCw7oEQ9.cjs +417 -0
  27. package/dist/{es/index-Bxr3zvCT.d.mts → cjs/runner-DemKouFJ.d.cts} +49 -95
  28. package/dist/cjs/{management-Dm5h0E6l.cjs → runner-NHMvoMO2.cjs} +24 -30
  29. package/dist/cjs/schemas-CZ6c8Id9.cjs +98 -0
  30. package/dist/cjs/validate-Btzn9ilZ.cjs +235 -0
  31. package/dist/es/actions/app-config.d.mts +15 -0
  32. package/dist/es/actions/app-config.mjs +25 -0
  33. package/dist/es/actions/config.d.mts +15 -0
  34. package/dist/es/actions/config.mjs +77 -0
  35. package/dist/es/actions/{index.d.mts → installation.d.mts} +4 -3
  36. package/dist/es/actions/{index.mjs → installation.mjs} +27 -427
  37. package/dist/es/actions/scope-tree.d.mts +8 -0
  38. package/dist/es/actions/scope-tree.mjs +95 -0
  39. package/dist/{cjs/app-Dx0ca6oL.d.cts → es/app-BAiyvNo2.d.mts} +14 -14
  40. package/dist/es/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
  41. package/dist/es/commands/generate/actions/templates/app-management/installation.js.template +1 -1
  42. package/dist/es/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
  43. package/dist/es/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
  44. package/dist/es/commands/index.mjs +68 -84
  45. package/dist/es/config/index.d.mts +52 -352
  46. package/dist/es/config/index.mjs +3 -2
  47. package/dist/es/error-CMV3IjBz.mjs +18 -0
  48. package/dist/es/{error-P7JgUTds.mjs → installation-BTL9X7iv.mjs} +78 -128
  49. package/dist/es/management/index.d.mts +2 -3
  50. package/dist/es/management/index.mjs +1 -1
  51. package/dist/es/parser-CQZTVG6i.mjs +201 -0
  52. package/dist/es/router-CJ4VWoCt.mjs +404 -0
  53. package/dist/{cjs/index-C5SutkJQ.d.cts → es/runner-BD-lItnK.d.mts} +49 -95
  54. package/dist/es/{management-Y7pwEbNI.mjs → runner-vwAhjD5r.mjs} +17 -24
  55. package/dist/es/schemas-B8yIv0_b.mjs +41 -0
  56. package/dist/es/validate-DKnju9-R.mjs +187 -0
  57. package/package.json +38 -24
  58. package/dist/cjs/actions/index.cjs +0 -824
  59. package/dist/cjs/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
  60. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
  61. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
  62. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
  63. package/dist/cjs/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
  64. package/dist/cjs/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
  65. package/dist/cjs/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
  66. package/dist/cjs/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
  67. package/dist/cjs/config-JQ_n-5Nk.cjs +0 -565
  68. package/dist/cjs/error-Byj1DVHZ.cjs +0 -344
  69. package/dist/es/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
  70. package/dist/es/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
  71. package/dist/es/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
  72. package/dist/es/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
  73. package/dist/es/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
  74. package/dist/es/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
  75. package/dist/es/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
  76. package/dist/es/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
  77. package/dist/es/config-BSGerqCG.mjs +0 -457
  78. /package/dist/es/{logging-VgerMhp6.mjs → logging-CzmXDzxI.mjs} +0 -0
@@ -1,39 +1,42 @@
1
1
  #!/usr/bin/env node
2
- const require_error = require('../error-Byj1DVHZ.cjs');
3
- const require_logging = require('../logging-DYwr5WQk.cjs');
4
- const require_config = require('../config-JQ_n-5Nk.cjs');
2
+ const require_schemas = require('../schemas-CZ6c8Id9.cjs');
3
+ const require_validate = require('../validate-Btzn9ilZ.cjs');
4
+ const require_installation = require('../installation-CLbceU9F.cjs');
5
+ const require_parser = require('../parser-BPpg_9QB.cjs');
6
+ const require_error = require('../error-DJ2UAPH2.cjs');
7
+ const require_logging = require('../logging-IDRQG0as.cjs');
5
8
  let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
6
9
  let path = require("path");
7
- path = require_error.__toESM(path);
10
+ path = require_schemas.__toESM(path);
8
11
  let fs = require("fs");
9
12
  let fs_promises = require("fs/promises");
10
13
  let consola = require("consola");
11
- consola = require_error.__toESM(consola);
14
+ consola = require_schemas.__toESM(consola);
12
15
  let url = require("url");
13
16
  let yaml = require("yaml");
14
17
  let consola_utils = require("consola/utils");
15
18
  let safe_stable_stringify = require("safe-stable-stringify");
16
19
  let child_process = require("child_process");
17
20
  let _adobe_aio_lib_core_config = require("@adobe/aio-lib-core-config");
18
- _adobe_aio_lib_core_config = require_error.__toESM(_adobe_aio_lib_core_config);
21
+ _adobe_aio_lib_core_config = require_schemas.__toESM(_adobe_aio_lib_core_config);
19
22
  let _adobe_aio_lib_ims = require("@adobe/aio-lib-ims");
20
- _adobe_aio_lib_ims = require_error.__toESM(_adobe_aio_lib_ims);
23
+ _adobe_aio_lib_ims = require_schemas.__toESM(_adobe_aio_lib_ims);
21
24
  let dotenv = require("dotenv");
22
- dotenv = require_error.__toESM(dotenv);
25
+ dotenv = require_schemas.__toESM(dotenv);
23
26
  let prettier = require("prettier");
24
- prettier = require_error.__toESM(prettier);
27
+ prettier = require_schemas.__toESM(prettier);
25
28
 
26
29
  //#region ../../packages-private/scripting-utils/source/yaml/helpers.ts
27
30
  /**
28
31
  * Read a YAML file and return a {@link Document}
29
32
  * @param path - The path to the YAML file
30
33
  */
31
- async function readYamlFile(path$2) {
34
+ async function readYamlFile(path$3) {
32
35
  let doc = new yaml.Document();
33
- if ((0, fs.existsSync)(path$2)) try {
34
- doc = (0, yaml.parseDocument)(await (0, fs_promises.readFile)(path$2, "utf-8"), { keepSourceTokens: true });
36
+ if ((0, fs.existsSync)(path$3)) try {
37
+ doc = (0, yaml.parseDocument)(await (0, fs_promises.readFile)(path$3, "utf-8"), { keepSourceTokens: true });
35
38
  } catch (_) {
36
- const file = (0, path.basename)(path$2);
39
+ const file = (0, path.basename)(path$3);
37
40
  throw new Error(`Failed to parse ${file}`);
38
41
  }
39
42
  if (doc.contents === null) doc.contents = new yaml.YAMLMap();
@@ -47,18 +50,18 @@ async function readYamlFile(path$2) {
47
50
  * @param typeConfig - Configuration for the node type
48
51
  * @returns The existing or newly created node
49
52
  */
50
- function getOrCreateNode(doc, path$2, options, typeConfig) {
51
- const node = doc.getIn(path$2);
53
+ function getOrCreateNode(doc, path$4, options, typeConfig) {
54
+ const node = doc.getIn(path$4);
52
55
  if (node) {
53
- if (!typeConfig.typeGuard(node)) throw new Error(`Expected ${typeConfig.typeName} at path "${path$2.join(".")}".`);
56
+ if (!typeConfig.typeGuard(node)) throw new Error(`Expected ${typeConfig.typeName} at path "${path$4.join(".")}".`);
54
57
  return node;
55
58
  }
56
- if (doc.hasIn(path$2)) doc.deleteIn(path$2);
57
- const pair = doc.createPair(path$2.at(-1), typeConfig.createNode());
59
+ if (doc.hasIn(path$4)) doc.deleteIn(path$4);
60
+ const pair = doc.createPair(path$4.at(-1), typeConfig.createNode());
58
61
  options.onBeforeCreate?.(pair);
59
- if (path$2.length === 1) doc.add(pair);
60
- else doc.addIn(path$2.slice(0, -1), pair);
61
- return doc.getIn(path$2);
62
+ if (path$4.length === 1) doc.add(pair);
63
+ else doc.addIn(path$4.slice(0, -1), pair);
64
+ return doc.getIn(path$4);
62
65
  }
63
66
  /**
64
67
  * Get or create a sequence at the given path
@@ -66,8 +69,8 @@ function getOrCreateNode(doc, path$2, options, typeConfig) {
66
69
  * @param path - The path to the sequence
67
70
  * @param options - The options for the sequence
68
71
  */
69
- function getOrCreateSeq(doc, path$2, options) {
70
- return getOrCreateNode(doc, path$2, options ?? {}, {
72
+ function getOrCreateSeq(doc, path$5, options) {
73
+ return getOrCreateNode(doc, path$5, options ?? {}, {
71
74
  typeGuard: yaml.isSeq,
72
75
  createNode: () => new yaml.YAMLSeq(),
73
76
  typeName: "sequence"
@@ -79,8 +82,8 @@ function getOrCreateSeq(doc, path$2, options) {
79
82
  * @param path - The path to the map
80
83
  * @param options - The options for the map
81
84
  */
82
- function getOrCreateMap(doc, path$2, options) {
83
- return getOrCreateNode(doc, path$2, options ?? {}, {
85
+ function getOrCreateMap(doc, path$6, options) {
86
+ return getOrCreateNode(doc, path$6, options ?? {}, {
84
87
  typeGuard: yaml.isMap,
85
88
  createNode: () => new yaml.YAMLMap(),
86
89
  typeName: "map"
@@ -95,15 +98,15 @@ function getOrCreateMap(doc, path$2, options) {
95
98
  * @param config - The config to build
96
99
  * @param doc - The document to modify (a new one is created if not provided)
97
100
  */
98
- async function createOrUpdateExtConfig(path$2, config$1, doc) {
101
+ async function createOrUpdateExtConfig(path, config, doc) {
99
102
  const extConfigDoc = doc ?? new yaml.Document({});
100
- config$1.hooks ??= {};
101
- config$1.operations ??= { workerProcess: [] };
102
- config$1.runtimeManifest ??= { packages: {} };
103
- await buildHooks(extConfigDoc, config$1.hooks);
104
- buildOperations(extConfigDoc, config$1.operations);
105
- buildRuntimeManifest(extConfigDoc, config$1.runtimeManifest);
106
- await writeExtConfig(path$2, extConfigDoc);
103
+ config.hooks ??= {};
104
+ config.operations ??= { workerProcess: [] };
105
+ config.runtimeManifest ??= { packages: {} };
106
+ await buildHooks(extConfigDoc, config.hooks);
107
+ buildOperations(extConfigDoc, config.operations);
108
+ buildRuntimeManifest(extConfigDoc, config.runtimeManifest);
109
+ await writeExtConfig(path, extConfigDoc);
107
110
  return extConfigDoc;
108
111
  }
109
112
  /**
@@ -198,9 +201,9 @@ async function buildHooks(extConfig, hooks) {
198
201
  pair.key.spaceBefore = true;
199
202
  pair.key.commentBefore = ` The ${generatedHooks} hooks are auto-generated. Do not remove or manually edit.`;
200
203
  } });
201
- const execCommand = require_config.getExecCommand(await require_config.detectPackageManager());
202
- for (const [name, command$1] of Object.entries(hooks)) {
203
- const fullCommand = `${command$1.replaceAll("$packageExec", execCommand)}`;
204
+ const execCommand = require_parser.getExecCommand(await require_parser.detectPackageManager());
205
+ for (const [name, command] of Object.entries(hooks)) {
206
+ const fullCommand = `${command.replaceAll("$packageExec", execCommand)}`;
204
207
  const prevValue = (hooksMap.get(name) ?? "").trim();
205
208
  if (prevValue.endsWith("js") || prevValue.endsWith("ts")) throw new Error(`Conflicting hook definition found. The "${name}" hook needs to be a command, not a script.`);
206
209
  if (prevValue !== "" && !prevValue.includes(fullCommand)) hooksMap.set(name, `${prevValue} && ${fullCommand}`);
@@ -255,7 +258,7 @@ function getExtensionPointFolderPath(extensionPointId) {
255
258
  //#region source/commands/utils.ts
256
259
  /** Load the app commerce config */
257
260
  async function loadAppManifest() {
258
- const appConfig = await require_config.parseCommerceAppConfig();
261
+ const appConfig = await require_parser.parseCommerceAppConfig();
259
262
  consola.default.debug("Loaded app commerce config");
260
263
  return appConfig;
261
264
  }
@@ -282,7 +285,7 @@ const CUSTOM_SCRIPTS_LOADER_PLACEHOLDER = "// {{CUSTOM_SCRIPTS_LOADER}}";
282
285
  * @param actionName - The name of the action.
283
286
  * @param options - Optional configuration options.
284
287
  */
285
- function createActionDefinition(actionName, config$1 = {}, options = {}) {
288
+ function createActionDefinition(actionName, config = {}, options = {}) {
286
289
  const def = {
287
290
  ...options,
288
291
  function: `${GENERATED_ACTIONS_PATH}/${actionName}.js`,
@@ -293,8 +296,7 @@ function createActionDefinition(actionName, config$1 = {}, options = {}) {
293
296
  final: true
294
297
  }
295
298
  };
296
- if (config$1.requiresSchema) def.include = [[`${GENERATED_PATH}/${CONFIG_SCHEMA_FILE_NAME}`, `${PACKAGE_NAME}/`]];
297
- if (config$1.requiresEncryptionKey) def.inputs = {
299
+ if (config.requiresEncryptionKey) def.inputs = {
298
300
  ...def.inputs,
299
301
  AIO_COMMERCE_CONFIG_ENCRYPTION_KEY: "$AIO_COMMERCE_CONFIG_ENCRYPTION_KEY"
300
302
  };
@@ -314,16 +316,18 @@ function getRuntimeActions(extConfig, dir) {
314
316
  * Builds the ext.config.yaml configuration for the extensibility extension.
315
317
  * @param features - The features that are enabled for the app.
316
318
  */
317
- function buildAppManagementExtConfig(features) {
319
+ function buildAppManagementExtConfig(appConfig) {
320
+ const features = require_validate.getConfigDomains(appConfig);
321
+ const hasPasswordFieldsInSchema = require_validate.hasBusinessConfigSchema(appConfig) && appConfig.businessConfig.schema.some((field) => field.type === "password");
318
322
  const extConfig = {
319
323
  hooks: { "pre-app-build": "EXTENSION=extensibility/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
320
324
  operations: { workerProcess: [{
321
325
  type: "action",
322
- impl: `${PACKAGE_NAME}/get-app-config`
326
+ impl: `${PACKAGE_NAME}/app-config`
323
327
  }] },
324
328
  runtimeManifest: { packages: { [PACKAGE_NAME]: {
325
329
  license: "Apache-2.0",
326
- actions: { "get-app-config": createActionDefinition("get-app-config") }
330
+ actions: { "app-config": createActionDefinition("app-config") }
327
331
  } } }
328
332
  };
329
333
  if ([
@@ -335,7 +339,7 @@ function buildAppManagementExtConfig(features) {
335
339
  type: "action",
336
340
  impl: `${PACKAGE_NAME}/installation`
337
341
  });
338
- extConfig.runtimeManifest.packages[PACKAGE_NAME].actions.installation = createActionDefinition("installation", {}, {
342
+ extConfig.runtimeManifest.packages[PACKAGE_NAME].actions.installation = createActionDefinition("installation", { requiresEncryptionKey: hasPasswordFieldsInSchema }, {
339
343
  inputs: {
340
344
  ...COMMERCE_ACTION_INPUTS,
341
345
  LOG_LEVEL: "$LOG_LEVEL"
@@ -347,40 +351,14 @@ function buildAppManagementExtConfig(features) {
347
351
  }
348
352
  /** Builds the ext.config.yaml configuration for the business configuration extension. */
349
353
  function buildBusinessConfigurationExtConfig() {
350
- const actions = [
351
- {
352
- name: "get-scope-tree",
353
- templateFile: "get-scope-tree.js.template"
354
- },
355
- {
356
- name: "get-config-schema",
357
- templateFile: "get-config-schema.js.template",
358
- requiresSchema: true
359
- },
360
- {
361
- name: "get-configuration",
362
- templateFile: "get-configuration.js.template",
363
- requiresSchema: true,
364
- requiresEncryptionKey: true
365
- },
366
- {
367
- name: "set-configuration",
368
- templateFile: "set-configuration.js.template",
369
- requiresEncryptionKey: true
370
- },
371
- {
372
- name: "set-custom-scope-tree",
373
- templateFile: "set-custom-scope-tree.js.template"
374
- },
375
- {
376
- name: "sync-commerce-scopes",
377
- templateFile: "sync-commerce-scopes.js.template"
378
- },
379
- {
380
- name: "unsync-commerce-scopes",
381
- templateFile: "unsync-commerce-scopes.js.template"
382
- }
383
- ];
354
+ const actions = [{
355
+ name: "config",
356
+ templateFile: "config.js.template",
357
+ requiresEncryptionKey: true
358
+ }, {
359
+ name: "scope-tree",
360
+ templateFile: "scope-tree.js.template"
361
+ }];
384
362
  return {
385
363
  hooks: { "pre-app-build": "EXTENSION=configuration/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
386
364
  operations: { workerProcess: actions.map((action) => ({
@@ -399,7 +377,7 @@ function buildBusinessConfigurationExtConfig() {
399
377
  const __dirname$1 = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
400
378
  async function run$4(appManifest) {
401
379
  await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, EXTENSIBILITY_EXTENSION_POINT_ID), "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID);
402
- if (require_config.hasBusinessConfigSchema(appManifest)) await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, CONFIGURATION_EXTENSION_POINT_ID), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID);
380
+ if (require_validate.hasBusinessConfigSchema(appManifest)) await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, CONFIGURATION_EXTENSION_POINT_ID), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID);
403
381
  }
404
382
  /** Run the generate actions command */
405
383
  async function exec$5() {
@@ -414,12 +392,12 @@ async function exec$5() {
414
392
  /** Update the ext.config.yaml file */
415
393
  async function updateExtConfig(appConfig, extensionPointId) {
416
394
  consola.consola.info(`Updating ext.config.yaml for ${extensionPointId}...`);
417
- const extConfigPath = (0, path.join)(await require_config.makeOutputDirFor(getExtensionPointFolderPath(extensionPointId)), "ext.config.yaml");
395
+ const extConfigPath = (0, path.join)(await require_parser.makeOutputDirFor(getExtensionPointFolderPath(extensionPointId)), "ext.config.yaml");
418
396
  const extConfigDoc = await readYamlFile(extConfigPath);
419
397
  let extConfig;
420
398
  switch (extensionPointId) {
421
399
  case EXTENSIBILITY_EXTENSION_POINT_ID:
422
- extConfig = buildAppManagementExtConfig(require_config.getConfigDomains(appConfig));
400
+ extConfig = buildAppManagementExtConfig(appConfig);
423
401
  break;
424
402
  case CONFIGURATION_EXTENSION_POINT_ID:
425
403
  extConfig = buildBusinessConfigurationExtConfig();
@@ -432,7 +410,7 @@ async function updateExtConfig(appConfig, extensionPointId) {
432
410
  /** Generate the action files */
433
411
  async function generateActionFiles(appManifest, actions, extensionPointId) {
434
412
  consola.consola.start("Generating runtime actions...");
435
- const outputDir = await require_config.makeOutputDirFor((0, path.join)(getExtensionPointFolderPath(extensionPointId), GENERATED_ACTIONS_PATH));
413
+ const outputDir = await require_parser.makeOutputDirFor((0, path.join)(getExtensionPointFolderPath(extensionPointId), GENERATED_ACTIONS_PATH));
436
414
  const outputFiles = [];
437
415
  const templatesDir = (0, path.join)(__dirname$1, "generate/actions/templates");
438
416
  for (const action of actions) {
@@ -462,8 +440,8 @@ function applyCustomScripts(installationTemplate, customScriptsTemplate) {
462
440
  * Generate the installation template with dynamic custom script imports
463
441
  */
464
442
  async function generateCustomScriptsTemplate(template, appManifest) {
465
- if (!require_error.hasCustomInstallationSteps(appManifest)) return null;
466
- const projectRoot = await require_config.getProjectRootDirectory();
443
+ if (!require_installation.hasCustomInstallationSteps(appManifest)) return null;
444
+ const projectRoot = await require_parser.getProjectRootDirectory();
467
445
  const installationActionDir = (0, path.join)(projectRoot, getExtensionPointFolderPath(EXTENSIBILITY_EXTENSION_POINT_ID), GENERATED_ACTIONS_PATH);
468
446
  const customSteps = appManifest.installation.customInstallationSteps;
469
447
  const importStatements = customSteps.map((step, index) => {
@@ -484,7 +462,7 @@ async function generateCustomScriptsTemplate(template, appManifest) {
484
462
  async function run$3(appConfig) {
485
463
  consola.consola.info("Generating app manifest...");
486
464
  const contents = (0, safe_stable_stringify.stringify)(appConfig, null, 2);
487
- await (0, fs_promises.writeFile)((0, path.join)(await require_config.makeOutputDirFor(`${getExtensionPointFolderPath(EXTENSIBILITY_EXTENSION_POINT_ID)}/.generated`), APP_MANIFEST_FILE), contents, "utf-8");
465
+ await (0, fs_promises.writeFile)((0, path.join)(await require_parser.makeOutputDirFor(`${getExtensionPointFolderPath(EXTENSIBILITY_EXTENSION_POINT_ID)}/.generated`), APP_MANIFEST_FILE), contents, "utf-8");
488
466
  consola.consola.success(`Generated ${APP_MANIFEST_FILE}`);
489
467
  }
490
468
  /** Run the generate manifest command */
@@ -502,13 +480,20 @@ async function exec$4() {
502
480
  //#region source/commands/generate/schema/main.ts
503
481
  async function run$2(appConfig) {
504
482
  consola.consola.info("Generating configuration schema...");
505
- if (!require_config.hasBusinessConfigSchema(appConfig)) {
483
+ if (!require_validate.hasBusinessConfigSchema(appConfig)) {
506
484
  consola.consola.warn("Business configuration schema not found");
507
485
  return;
508
486
  }
509
- (0, child_process.execSync)("aio-commerce-lib-config validate schema");
487
+ const projectDir = (0, path.dirname)(await require_parser.findNearestPackageJson() ?? process.cwd());
488
+ const envPath = (0, path.join)(projectDir, ".env");
489
+ process.loadEnvFile(envPath);
490
+ if (appConfig.businessConfig.schema.some((field) => field.type === "password")) {
491
+ const packageExec = require_parser.getExecCommand(await require_parser.detectPackageManager(projectDir));
492
+ 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`);
493
+ else (0, child_process.execSync)(`${packageExec} aio-commerce-lib-config encryption setup`);
494
+ }
510
495
  const contents = (0, safe_stable_stringify.stringify)(appConfig.businessConfig.schema, null, 2);
511
- await (0, fs_promises.writeFile)((0, path.join)(await require_config.makeOutputDirFor(`${getExtensionPointFolderPath(CONFIGURATION_EXTENSION_POINT_ID)}/.generated`), CONFIG_SCHEMA_FILE_NAME), contents, "utf-8");
496
+ await (0, fs_promises.writeFile)((0, path.join)(await require_parser.makeOutputDirFor(`${getExtensionPointFolderPath(CONFIGURATION_EXTENSION_POINT_ID)}/.generated`), CONFIG_SCHEMA_FILE_NAME), contents, "utf-8");
512
497
  consola.consola.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}`);
513
498
  }
514
499
  /** Run the generate manifest command */
@@ -753,7 +738,7 @@ async function promptForCommerceAppConfig() {
753
738
  }
754
739
  /** Create the default commerce app config file content */
755
740
  async function getDefaultCommerceAppConfig(cwd, { appName, configFormat, domains }) {
756
- const needsESM = await require_config.isESM(cwd) || configFormat === "ts";
741
+ const needsESM = await require_parser.isESM(cwd) || configFormat === "ts";
757
742
  const exportKeyword = needsESM ? "export default" : "module.exports =";
758
743
  const importStatement = needsESM ? "import { defineConfig } from \"@adobe/aio-commerce-lib-app/config\";" : "const { defineConfig } = require(\"@adobe/aio-commerce-lib-app/config\");";
759
744
  const defaultConfig = { metadata: {
@@ -848,16 +833,16 @@ async function addExtensionPointToInstallYaml(extensionPointId, rootDirectory, c
848
833
  //#region source/commands/init/lib.ts
849
834
  /** Ensure app.commerce.config file exists, allow creating if it doesn't */
850
835
  async function ensureCommerceAppConfig(cwd = process.cwd()) {
851
- let config$1 = null;
836
+ let config = null;
852
837
  try {
853
- config$1 = await require_config.readCommerceAppConfig(cwd);
838
+ config = await require_parser.readCommerceAppConfig(cwd);
854
839
  } catch (_) {}
855
- if (config$1) try {
856
- const validatedConfig = require_config.validateCommerceAppConfig(config$1);
840
+ if (config) try {
841
+ const validatedConfig = require_validate.validateCommerceAppConfig(config);
857
842
  consola.consola.success(`${COMMERCE_APP_CONFIG_FILE} found and is valid. Continuing...`);
858
843
  return {
859
844
  config: validatedConfig,
860
- domains: require_config.getConfigDomains(validatedConfig)
845
+ domains: require_validate.getConfigDomains(validatedConfig)
861
846
  };
862
847
  } catch (error) {
863
848
  throw new Error(`${COMMERCE_APP_CONFIG_FILE} is invalid`, { cause: error });
@@ -872,7 +857,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
872
857
  try {
873
858
  const configContent = await getDefaultCommerceAppConfig(cwd, answers);
874
859
  consola.consola.info(`Creating ${answers.configFile}...`);
875
- const path$2 = (0, path.join)(await require_config.getProjectRootDirectory(cwd), answers.configFile);
860
+ const path$2 = (0, path.join)(await require_parser.getProjectRootDirectory(cwd), answers.configFile);
876
861
  await (0, fs_promises.writeFile)(path$2, await prettier.format(configContent, {
877
862
  semi: true,
878
863
  quoteStyle: "double",
@@ -887,7 +872,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
887
872
  }), "utf-8");
888
873
  consola.consola.success(`Created ${answers.configFile}`);
889
874
  return {
890
- config: await require_config.parseCommerceAppConfig(cwd),
875
+ config: await require_parser.parseCommerceAppConfig(cwd),
891
876
  domains: answers.domains
892
877
  };
893
878
  } catch (error) {
@@ -896,7 +881,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
896
881
  }
897
882
  /** Ensure package.json has the postinstall script */
898
883
  async function ensurePackageJson(cwd = process.cwd()) {
899
- const packageJson = await require_config.readPackageJson(cwd);
884
+ const packageJson = await require_parser.readPackageJson(cwd);
900
885
  if (!packageJson) {
901
886
  consola.consola.warn("package.json not found. Creating one...");
902
887
  const packageJsonContent = {
@@ -913,8 +898,8 @@ async function ensurePackageJson(cwd = process.cwd()) {
913
898
  execCommand: "npx"
914
899
  };
915
900
  }
916
- const packageManager = await require_config.detectPackageManager();
917
- const execCommand = require_config.getExecCommand(packageManager);
901
+ const packageManager = await require_parser.detectPackageManager();
902
+ const execCommand = require_parser.getExecCommand(packageManager);
918
903
  const postinstallScript = `${execCommand} aio-commerce-lib-app hooks postinstall`;
919
904
  packageJson.scripts ??= {};
920
905
  if (packageJson.scripts.postinstall === postinstallScript || packageJson.scripts.postinstall?.includes(postinstallScript)) {
@@ -941,7 +926,7 @@ async function ensurePackageJson(cwd = process.cwd()) {
941
926
  }
942
927
  /** Ensure app.config.yaml has the extension reference */
943
928
  async function ensureAppConfig(domains, cwd = process.cwd()) {
944
- const rootDirectory = await require_config.getProjectRootDirectory(cwd);
929
+ const rootDirectory = await require_parser.getProjectRootDirectory(cwd);
945
930
  if (domains.has("businessConfig.schema")) await addExtensionPointToAppConfig(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
946
931
  await addExtensionPointToAppConfig(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
947
932
  }
@@ -983,7 +968,7 @@ async function runGeneration(appConfig, execCommand) {
983
968
  }
984
969
  /** Ensure install.yaml has the extension reference */
985
970
  async function ensureInstallYaml(domains, cwd = process.cwd()) {
986
- const rootDirectory = await require_config.getProjectRootDirectory(cwd);
971
+ const rootDirectory = await require_parser.getProjectRootDirectory(cwd);
987
972
  if (domains.has("businessConfig.schema")) await addExtensionPointToInstallYaml(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
988
973
  await addExtensionPointToInstallYaml(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
989
974
  }
@@ -997,12 +982,12 @@ async function exec() {
997
982
  consola.consola.start("Initializing app...");
998
983
  const { execCommand, packageManager } = await ensurePackageJson();
999
984
  runInstall(packageManager, REQUIRED_DEPENDENCIES);
1000
- const { config: config$1, domains } = await ensureCommerceAppConfig();
985
+ const { config, domains } = await ensureCommerceAppConfig();
1001
986
  installDependencies(packageManager, domains);
1002
- (0, child_process.execSync)(`npm pkg set name="${config$1.metadata.id}"`);
1003
- (0, child_process.execSync)(`npm pkg set version="${config$1.metadata.version}"`);
1004
- (0, child_process.execSync)(`npm pkg set description="${config$1.metadata.description}"`);
1005
- await runGeneration(config$1, execCommand);
987
+ (0, child_process.execSync)(`npm pkg set name="${config.metadata.id}"`);
988
+ (0, child_process.execSync)(`npm pkg set version="${config.metadata.version}"`);
989
+ (0, child_process.execSync)(`npm pkg set description="${config.metadata.description}"`);
990
+ await runGeneration(config, execCommand);
1006
991
  await ensureAppConfig(domains);
1007
992
  await ensureInstallYaml(domains);
1008
993
  consola.consola.success("Initialization complete!");
@@ -1,20 +1,22 @@
1
- const require_error = require('../error-Byj1DVHZ.cjs');
2
- const require_config = require('../config-JQ_n-5Nk.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_validate = require('../validate-Btzn9ilZ.cjs');
3
+ const require_installation = require('../installation-CLbceU9F.cjs');
4
+ const require_parser = require('../parser-BPpg_9QB.cjs');
3
5
 
4
- exports.CommerceAppConfigSchemas = require_config.CommerceAppConfigSchemas;
5
- exports.defineConfig = require_config.defineConfig;
6
- exports.getConfigDomains = require_config.getConfigDomains;
7
- exports.hasBusinessConfig = require_config.hasBusinessConfig;
8
- exports.hasBusinessConfigSchema = require_config.hasBusinessConfigSchema;
9
- exports.hasCommerceEvents = require_error.hasCommerceEvents;
10
- exports.hasConfigDomain = require_config.hasConfigDomain;
11
- exports.hasCustomInstallation = require_error.hasCustomInstallation;
12
- exports.hasCustomInstallationSteps = require_error.hasCustomInstallationSteps;
13
- exports.hasEventing = require_error.hasEventing;
14
- exports.hasExternalEvents = require_error.hasExternalEvents;
15
- exports.hasMetadata = require_config.hasMetadata;
16
- exports.parseCommerceAppConfig = require_config.parseCommerceAppConfig;
17
- exports.readCommerceAppConfig = require_config.readCommerceAppConfig;
18
- exports.resolveCommerceAppConfig = require_config.resolveCommerceAppConfig;
19
- exports.validateCommerceAppConfig = require_config.validateCommerceAppConfig;
20
- exports.validateCommerceAppConfigDomain = require_config.validateCommerceAppConfigDomain;
6
+ exports.CommerceAppConfigSchemas = require_validate.CommerceAppConfigSchemas;
7
+ exports.defineConfig = require_parser.defineConfig;
8
+ exports.getConfigDomains = require_validate.getConfigDomains;
9
+ exports.hasBusinessConfig = require_validate.hasBusinessConfig;
10
+ exports.hasBusinessConfigSchema = require_validate.hasBusinessConfigSchema;
11
+ exports.hasCommerceEvents = require_installation.hasCommerceEvents;
12
+ exports.hasConfigDomain = require_validate.hasConfigDomain;
13
+ exports.hasCustomInstallation = require_installation.hasCustomInstallation;
14
+ exports.hasCustomInstallationSteps = require_installation.hasCustomInstallationSteps;
15
+ exports.hasEventing = require_installation.hasEventing;
16
+ exports.hasExternalEvents = require_installation.hasExternalEvents;
17
+ exports.hasMetadata = require_validate.hasMetadata;
18
+ exports.parseCommerceAppConfig = require_parser.parseCommerceAppConfig;
19
+ exports.readCommerceAppConfig = require_parser.readCommerceAppConfig;
20
+ exports.resolveCommerceAppConfig = require_parser.resolveCommerceAppConfig;
21
+ exports.validateCommerceAppConfig = require_validate.validateCommerceAppConfig;
22
+ exports.validateCommerceAppConfigDomain = require_validate.validateCommerceAppConfigDomain;