@commercetools-frontend/mc-scripts 25.1.0 → 25.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +20 -7
  2. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +20 -7
  3. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +20 -7
  4. package/dist/{build-ec10df64.cjs.prod.js → build-182a099c.cjs.prod.js} +3 -3
  5. package/dist/{build-dbcd0936.esm.js → build-220a1658.esm.js} +3 -3
  6. package/dist/{build-0a5986d1.cjs.dev.js → build-519d246d.cjs.dev.js} +3 -3
  7. package/dist/{build-vite-16b1a575.cjs.dev.js → build-vite-837e7c94.cjs.dev.js} +56 -34
  8. package/dist/{build-vite-59e1f185.esm.js → build-vite-8cae71a0.esm.js} +53 -15
  9. package/dist/{build-vite-5d317720.cjs.prod.js → build-vite-b007241b.cjs.prod.js} +56 -34
  10. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
  11. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
  12. package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
  13. package/dist/config-sync-0b96d430.esm.js +255 -0
  14. package/dist/config-sync-b3072939.cjs.prod.js +265 -0
  15. package/dist/config-sync-ci-4a09aa00.cjs.prod.js +305 -0
  16. package/dist/config-sync-ci-85e3fec2.esm.js +294 -0
  17. package/dist/config-sync-ci-eadb8bfc.cjs.dev.js +305 -0
  18. package/dist/config-sync-f8fca39f.cjs.dev.js +265 -0
  19. package/dist/{config-sync-ce05c66c.cjs.prod.js → config-sync-helpers-11fc328f.cjs.prod.js} +162 -287
  20. package/dist/{config-sync-dbb43993.cjs.dev.js → config-sync-helpers-dab59ed9.cjs.dev.js} +162 -287
  21. package/dist/{config-sync-e7f53a98.esm.js → config-sync-helpers-fe6ea729.esm.js} +154 -283
  22. package/dist/{create-postcss-config-91c09596.cjs.prod.js → create-postcss-config-56b74a34.cjs.prod.js} +1 -1
  23. package/dist/{create-postcss-config-381b636b.cjs.dev.js → create-postcss-config-78879a12.cjs.dev.js} +1 -1
  24. package/dist/{create-postcss-config-0a86560d.esm.js → create-postcss-config-95f9bf62.esm.js} +1 -1
  25. package/dist/{create-webpack-config-for-development-37677a49.cjs.prod.js → create-webpack-config-for-development-3eb1b365.cjs.prod.js} +2 -2
  26. package/dist/{create-webpack-config-for-development-488742b2.cjs.dev.js → create-webpack-config-for-development-62b89920.cjs.dev.js} +2 -2
  27. package/dist/{create-webpack-config-for-development-df3f7f7f.esm.js → create-webpack-config-for-development-a28736fa.esm.js} +2 -2
  28. package/dist/{create-webpack-config-for-production-e22f78d2.esm.js → create-webpack-config-for-production-21ea561f.esm.js} +2 -2
  29. package/dist/{create-webpack-config-for-production-aad64e2a.cjs.prod.js → create-webpack-config-for-production-3b6599db.cjs.prod.js} +2 -2
  30. package/dist/{create-webpack-config-for-production-46d817cc.cjs.dev.js → create-webpack-config-for-production-e5ed8805.cjs.dev.js} +2 -2
  31. package/dist/{credentials-storage-0b89aa0e.cjs.prod.js → credentials-storage-6d592cd6.cjs.prod.js} +20 -2
  32. package/dist/{credentials-storage-cbb5c559.cjs.dev.js → credentials-storage-c4c5980e.cjs.dev.js} +20 -2
  33. package/dist/{credentials-storage-4464313c.esm.js → credentials-storage-fcc77fb6.esm.js} +20 -2
  34. package/dist/declarations/src/types.d.ts +4 -0
  35. package/dist/{deployment-previews-set-bbef95d2.esm.js → deployment-previews-set-7d49e7df.esm.js} +3 -3
  36. package/dist/{deployment-previews-set-4edd48db.cjs.dev.js → deployment-previews-set-8d6a1e99.cjs.dev.js} +3 -3
  37. package/dist/{deployment-previews-set-636fb1a3.cjs.prod.js → deployment-previews-set-f8ce3db7.cjs.prod.js} +3 -3
  38. package/dist/{graphql-requests-0a6eeb3a.cjs.prod.js → graphql-requests-b57fca4c.cjs.prod.js} +2 -2
  39. package/dist/{graphql-requests-14074b2b.esm.js → graphql-requests-d2fa2ca7.esm.js} +3 -3
  40. package/dist/{graphql-requests-23f7ddb1.cjs.dev.js → graphql-requests-da194989.cjs.dev.js} +2 -2
  41. package/dist/{login-54ebae96.cjs.prod.js → login-9774c9cc.cjs.prod.js} +130 -11
  42. package/dist/{login-1b222f33.esm.js → login-abb38213.esm.js} +127 -10
  43. package/dist/{login-a6fd5fbf.cjs.dev.js → login-f4550251.cjs.dev.js} +130 -11
  44. package/dist/{package-e1f7242c.cjs.prod.js → package-0eebca1b.cjs.dev.js} +20 -10
  45. package/dist/{package-a34835d9.esm.js → package-9e6910b8.esm.js} +20 -10
  46. package/dist/{package-d8b1f4c0.cjs.dev.js → package-b9298ce3.cjs.prod.js} +20 -10
  47. package/dist/{start-890895df.esm.js → start-109f9462.esm.js} +3 -3
  48. package/dist/{start-37ec4a7e.cjs.dev.js → start-7765f44c.cjs.dev.js} +3 -3
  49. package/dist/{start-0be8a294.cjs.prod.js → start-e014127c.cjs.prod.js} +3 -3
  50. package/package.json +20 -10
  51. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
  52. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
  53. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
  54. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +4 -4
  55. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
  56. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
@@ -1,13 +1,6 @@
1
- import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
2
- import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
3
- import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
4
- import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
5
1
  import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
6
2
  import chalk from 'chalk';
7
3
  import omit from 'lodash/omit';
8
- import prompts from 'prompts';
9
- import { sanitizeSvg, processConfig } from '@commercetools-frontend/application-config';
10
- import { C as CredentialsStorage } from './credentials-storage-4464313c.esm.js';
11
4
  import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
12
5
  import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
13
6
  import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
@@ -19,21 +12,11 @@ import _Set from '@babel/runtime-corejs3/core-js-stable/set';
19
12
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
20
13
  import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
21
14
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
15
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
22
16
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
23
- import { f as fetchCustomApplication, a as fetchUserOrganizations, c as createCustomApplication, u as updateCustomApplication, b as fetchCustomView, d as createCustomView, e as updateCustomView } from './graphql-requests-14074b2b.esm.js';
24
- import '@babel/runtime-corejs3/helpers/classCallCheck';
25
- import '@babel/runtime-corejs3/helpers/createClass';
26
- import '@babel/runtime-corejs3/core-js-stable/date/now';
27
- import 'node:fs';
28
- import 'node:os';
29
- import 'node:path';
30
- import './does-file-exist-32618334.esm.js';
31
- import '@babel/runtime-corejs3/core-js-stable/instance/some';
32
- import 'graphql';
33
- import 'graphql-request';
34
- import '@commercetools-frontend/constants';
35
- import '@commercetools/http-user-agent';
36
- import './package-a34835d9.esm.js';
17
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
18
+ import { sanitizeSvg } from '@commercetools-frontend/application-config';
19
+ import { c as createCustomApplication, u as updateCustomApplication, a as createCustomView, b as updateCustomView, d as fetchCustomApplication, e as fetchCustomView } from './graphql-requests-d2fa2ca7.esm.js';
37
20
 
38
21
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
39
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context9, _context0; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context9 = ownKeys(Object(t), !0)).call(_context9, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context0 = ownKeys(Object(t))).call(_context0, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -515,7 +498,6 @@ const getCustomViewConfigDiff = (oldConfig, newConfig) => {
515
498
  return diff.join('\n');
516
499
  };
517
500
 
518
- const credentialsStorage = new CredentialsStorage();
519
501
  const getMcUrlLink = _ref => {
520
502
  let mcApiUrl = _ref.mcApiUrl,
521
503
  organizationId = _ref.organizationId,
@@ -526,307 +508,196 @@ const getMcUrlLink = _ref => {
526
508
  return customEntityLink;
527
509
  };
528
510
  const isCustomViewData = data => data.entryPointUriPath === undefined;
529
- async function createOrUpdateCustomApplication(_ref2) {
530
- var _context3;
511
+ async function performCreateCustomApplication(_ref2) {
531
512
  let mcApiUrl = _ref2.mcApiUrl,
513
+ organizationId = _ref2.organizationId,
514
+ organizationName = _ref2.organizationName,
532
515
  localCustomEntityData = _ref2.localCustomEntityData,
533
516
  applicationIdentifier = _ref2.applicationIdentifier,
534
- options = _ref2.options;
535
- const fetchedCustomApplication = await fetchCustomApplication({
517
+ dryRun = _ref2.dryRun;
518
+ console.log(`Creating Custom Application in organization "${chalk.green(organizationName)}"...`);
519
+ const data = omit(localCustomEntityData, ['id']);
520
+ if (dryRun) {
521
+ console.log();
522
+ console.log('Dry run - would create Custom Application with:');
523
+ console.log(chalk.gray(_JSON$stringify(data, null, 2)));
524
+ return null;
525
+ }
526
+ const createdCustomApplication = await createCustomApplication({
536
527
  mcApiUrl,
537
- entryPointUriPath: localCustomEntityData.entryPointUriPath,
528
+ organizationId,
529
+ data,
538
530
  applicationIdentifier
539
531
  });
540
- if (!fetchedCustomApplication) {
541
- var _context2;
542
- const userOrganizations = await fetchUserOrganizations({
543
- mcApiUrl,
544
- applicationIdentifier
545
- });
546
- let organizationId, organizationName;
547
- if (userOrganizations.total === 0) {
548
- throw new Error(`It seems you are not an admin of any Organization. Please make sure to be part of the Administrators team of the Organization you want the Custom Application to be configured to.`);
549
- }
550
- if (userOrganizations.total === 1) {
551
- const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
552
- organization = _userOrganizations$re[0];
553
- organizationId = organization.id;
554
- organizationName = organization.name;
555
- } else {
556
- var _context;
557
- const organizationChoices = _mapInstanceProperty(_context = userOrganizations.results).call(_context, organization => ({
558
- title: organization.name,
559
- value: organization.id
560
- }));
561
- const _await$prompts = await prompts({
562
- type: 'select',
563
- name: 'organizationId',
564
- message: 'Select an Organization',
565
- choices: organizationChoices,
566
- initial: 0
567
- }),
568
- selectedOrganizationId = _await$prompts.organizationId;
569
- if (!selectedOrganizationId) {
570
- throw new Error(`No Organization selected, aborting.`);
571
- }
572
- organizationId = selectedOrganizationId;
573
- organizationName = _findInstanceProperty(organizationChoices).call(organizationChoices, _ref3 => {
574
- let value = _ref3.value;
575
- return value === organizationId;
576
- }).title;
577
- }
578
- const _await$prompts2 = await prompts({
579
- type: 'text',
580
- name: 'confirmation',
581
- message: _filterInstanceProperty(_context2 = [`You are about to create a new Custom Application in the "${chalk.green(organizationName)}" organization. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be created.')]).call(_context2, Boolean).join('\n'),
582
- initial: 'yes'
583
- }),
584
- confirmation = _await$prompts2.confirmation;
585
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
586
- console.log(chalk.red('Aborted.'));
587
- return;
588
- }
589
- const data = omit(localCustomEntityData, ['id']);
590
- if (options.dryRun) {
591
- console.log();
592
- console.log(`The following payload would be used to create a new Custom Application.`);
593
- console.log();
594
- console.log(chalk.gray(_JSON$stringify(data, null, 2)));
595
- return;
596
- }
597
- const createdCustomApplication = await createCustomApplication({
598
- mcApiUrl,
599
- organizationId,
600
- data,
601
- applicationIdentifier
602
- });
603
-
604
- // This check is technically not necessary, as the `graphql-request` client
605
- // throws an error in case of GraphQL errors.
606
- // However, the generated TypeScript data related to the GraphQL query has the
607
- // field typed as optional, thus having an extra check for type correctness.
608
- if (!createdCustomApplication) {
609
- throw new Error('Failed to create the Custom Application.');
610
- }
611
- const customAppLink = getMcUrlLink({
612
- mcApiUrl,
613
- organizationId,
614
- customEntityId: createdCustomApplication.id
615
- });
616
- console.log(chalk.green(`Custom Application created.\nPlease update the "env.production.applicationId" field in your local Custom Application config file with the following value: "${chalk.green(createdCustomApplication.id)}".`));
617
- console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk.gray(customAppLink)}".`);
618
- return;
532
+ if (!createdCustomApplication) {
533
+ throw new Error('Failed to create the Custom Application.');
619
534
  }
620
535
  const customAppLink = getMcUrlLink({
621
536
  mcApiUrl,
622
- organizationId: fetchedCustomApplication.organizationId,
623
- customEntityId: fetchedCustomApplication.application.id
624
- });
625
- const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
626
- if (!configDiff) {
627
- console.log(chalk.green(`Custom Application up-to-date.`));
628
- console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk.gray(customAppLink)}".`);
629
- return;
630
- }
631
- console.log('Changes detected:');
632
- console.log(configDiff);
633
- console.log();
634
- const _await$prompts3 = await prompts({
635
- type: 'text',
636
- name: 'confirmation',
637
- message: _filterInstanceProperty(_context3 = [`You are about to update the Custom Application "${chalk.green(localCustomEntityData.entryPointUriPath)}" with the changes above. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be updated.')]).call(_context3, Boolean).join('\n'),
638
- initial: 'yes'
639
- }),
640
- confirmation = _await$prompts3.confirmation;
641
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
642
- console.log(chalk.red('Aborted.'));
643
- return;
644
- }
537
+ organizationId,
538
+ customEntityId: createdCustomApplication.id
539
+ });
540
+ console.log(chalk.green('Custom Application created successfully.'));
541
+ console.log(`ID: ${chalk.cyan(createdCustomApplication.id)}`);
542
+ console.log(`Please update the "env.production.applicationId" field in your local Custom Application config file with the ID above.`);
543
+ console.log(`URL: ${chalk.gray(customAppLink)}`);
544
+ return createdCustomApplication.id;
545
+ }
546
+ async function performUpdateCustomApplication(_ref3) {
547
+ let mcApiUrl = _ref3.mcApiUrl,
548
+ organizationId = _ref3.organizationId,
549
+ applicationId = _ref3.applicationId,
550
+ localCustomEntityData = _ref3.localCustomEntityData,
551
+ applicationIdentifier = _ref3.applicationIdentifier,
552
+ dryRun = _ref3.dryRun;
645
553
  const data = omit(localCustomEntityData, ['id']);
646
- if (options.dryRun) {
647
- console.log();
648
- console.log(`The following payload would be used to update the Custom Application "${chalk.green(data.entryPointUriPath)}".`);
554
+ if (dryRun) {
649
555
  console.log();
556
+ console.log(`Dry run - would update Custom Application "${chalk.green(data.entryPointUriPath)}" with:`);
650
557
  console.log(chalk.gray(_JSON$stringify(data, null, 2)));
651
558
  return;
652
559
  }
560
+ console.log('Updating Custom Application...');
653
561
  await updateCustomApplication({
654
562
  mcApiUrl,
655
- organizationId: fetchedCustomApplication.organizationId,
656
- data: omit(localCustomEntityData, ['id']),
657
- applicationId: fetchedCustomApplication.application.id,
563
+ organizationId,
564
+ data,
565
+ applicationId,
658
566
  applicationIdentifier
659
567
  });
660
- console.log(chalk.green(`Custom Application updated.`));
661
- console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk.gray(customAppLink)}".`);
568
+ const customAppLink = getMcUrlLink({
569
+ mcApiUrl,
570
+ organizationId,
571
+ customEntityId: applicationId
572
+ });
573
+ console.log(chalk.green('Custom Application updated successfully.'));
574
+ console.log(`URL: ${chalk.gray(customAppLink)}`);
662
575
  }
663
- async function createOrUpdateCustomView(_ref4) {
664
- var _context6;
576
+ async function performCreateCustomView(_ref4) {
665
577
  let mcApiUrl = _ref4.mcApiUrl,
578
+ organizationId = _ref4.organizationId,
579
+ organizationName = _ref4.organizationName,
666
580
  localCustomEntityData = _ref4.localCustomEntityData,
667
- customViewId = _ref4.customViewId,
668
- options = _ref4.options,
669
- applicationIdentifier = _ref4.applicationIdentifier;
670
- const fetchedCustomView = await fetchCustomView({
581
+ applicationIdentifier = _ref4.applicationIdentifier,
582
+ dryRun = _ref4.dryRun;
583
+ console.log(`Creating Custom View in organization "${chalk.green(organizationName)}"...`);
584
+ const data = omit(localCustomEntityData, ['id']);
585
+ if (dryRun) {
586
+ console.log();
587
+ console.log('Dry run - would create Custom View with:');
588
+ console.log(chalk.gray(_JSON$stringify(data, null, 2)));
589
+ return null;
590
+ }
591
+ const createdCustomView = await createCustomView({
671
592
  mcApiUrl,
672
- customViewId,
593
+ organizationId,
594
+ data,
673
595
  applicationIdentifier
674
596
  });
675
- if (!fetchedCustomView) {
676
- var _context5;
677
- const userOrganizations = await fetchUserOrganizations({
678
- mcApiUrl,
679
- customViewId,
680
- applicationIdentifier
681
- });
682
- let organizationId, organizationName;
683
- if (userOrganizations.total === 0) {
684
- throw new Error(`It seems you are not an admin of any Organization. Please make sure to be part of the Administrators team of the Organization you want the Custom View to be configured to.`);
685
- }
686
- if (userOrganizations.total === 1) {
687
- const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
688
- organization = _userOrganizations$re2[0];
689
- organizationId = organization.id;
690
- organizationName = organization.name;
691
- } else {
692
- var _context4;
693
- const organizationChoices = _mapInstanceProperty(_context4 = userOrganizations.results).call(_context4, organization => ({
694
- title: organization.name,
695
- value: organization.id
696
- }));
697
- const _await$prompts4 = await prompts({
698
- type: 'select',
699
- name: 'organizationId',
700
- message: 'Select an Organization',
701
- choices: organizationChoices,
702
- initial: 0
703
- }),
704
- selectedOrganizationId = _await$prompts4.organizationId;
705
- if (!selectedOrganizationId) {
706
- throw new Error(`No Organization selected, aborting.`);
707
- }
708
- organizationId = selectedOrganizationId;
709
- organizationName = _findInstanceProperty(organizationChoices).call(organizationChoices, _ref5 => {
710
- let value = _ref5.value;
711
- return value === organizationId;
712
- }).title;
713
- }
714
- const _await$prompts5 = await prompts({
715
- type: 'text',
716
- name: 'confirmation',
717
- message: _filterInstanceProperty(_context5 = [`You are about to create a new Custom View in the "${chalk.green(organizationName)}" organization. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be created.')]).call(_context5, Boolean).join('\n'),
718
- initial: 'yes'
719
- }),
720
- confirmation = _await$prompts5.confirmation;
721
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
722
- console.log(chalk.red('Aborted.'));
723
- return;
724
- }
725
- const data = omit(localCustomEntityData, ['id']);
726
- if (options.dryRun) {
727
- console.log();
728
- console.log(`The following payload would be used to create a new Custom View.`);
729
- console.log();
730
- console.log(chalk.gray(_JSON$stringify(data, null, 2)));
731
- return;
732
- }
733
- const createdCustomView = await createCustomView({
734
- mcApiUrl,
735
- organizationId,
736
- data,
737
- applicationIdentifier
738
- });
739
-
740
- // This check is technically not necessary, as the `graphql-request` client
741
- // throws an error in case of GraphQL errors.
742
- // However, the generated TypeScript data related to the GraphQL query has the
743
- // field typed as optional, thus having an extra check for type correctness.
744
- if (!createdCustomView) {
745
- throw new Error('Failed to create the Custom View.');
746
- }
747
- const customViewLink = getMcUrlLink({
748
- mcApiUrl,
749
- organizationId,
750
- customEntityId: createdCustomView.id,
751
- isCustomView: true
752
- });
753
- console.log(chalk.green(`Custom View created.\nPlease update the "env.production.customViewId" field in your local Custom View config file with the following value: "${chalk.green(createdCustomView.id)}".`));
754
- console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk.gray(customViewLink)}".`);
755
- return;
597
+ if (!createdCustomView) {
598
+ throw new Error('Failed to create the Custom View.');
756
599
  }
757
600
  const customViewLink = getMcUrlLink({
758
601
  mcApiUrl,
759
- organizationId: fetchedCustomView.organizationId,
760
- customEntityId: fetchedCustomView?.customView?.id || '',
602
+ organizationId,
603
+ customEntityId: createdCustomView.id,
761
604
  isCustomView: true
762
605
  });
763
- const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
764
- if (!configDiff) {
765
- console.log(chalk.green(`Custom View up-to-date.`));
766
- console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk.gray(customViewLink)}".`);
767
- return;
768
- }
769
- console.log('Changes detected:');
770
- console.log(configDiff);
771
- console.log();
772
- const _await$prompts6 = await prompts({
773
- type: 'text',
774
- name: 'confirmation',
775
- message: _filterInstanceProperty(_context6 = [`You are about to update the Custom View "${chalk.green(localCustomEntityData.defaultLabel)}" with the changes above. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be updated.')]).call(_context6, Boolean).join('\n'),
776
- initial: 'yes'
777
- }),
778
- confirmation = _await$prompts6.confirmation;
779
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
780
- console.log(chalk.red('Aborted.'));
781
- return;
782
- }
606
+ console.log(chalk.green('Custom View created successfully.'));
607
+ console.log(`ID: ${chalk.cyan(createdCustomView.id)}`);
608
+ console.log(`Please update the "env.production.customViewId" field in your local Custom View config file with the ID above.`);
609
+ console.log(`URL: ${chalk.gray(customViewLink)}`);
610
+ return createdCustomView.id;
611
+ }
612
+ async function performUpdateCustomView(_ref5) {
613
+ let mcApiUrl = _ref5.mcApiUrl,
614
+ organizationId = _ref5.organizationId,
615
+ customViewId = _ref5.customViewId,
616
+ localCustomEntityData = _ref5.localCustomEntityData,
617
+ applicationIdentifier = _ref5.applicationIdentifier,
618
+ dryRun = _ref5.dryRun;
783
619
  const data = omit(localCustomEntityData, ['id']);
784
- if (options.dryRun) {
785
- console.log();
786
- console.log(`The following payload would be used to update the Custom View "${chalk.green(data.defaultLabel)}".`);
620
+ if (dryRun) {
787
621
  console.log();
622
+ console.log(`Dry run - would update Custom View "${chalk.green(data.defaultLabel)}" with:`);
788
623
  console.log(chalk.gray(_JSON$stringify(data, null, 2)));
789
624
  return;
790
625
  }
626
+ console.log('Updating Custom View...');
791
627
  await updateCustomView({
792
628
  mcApiUrl,
793
- organizationId: fetchedCustomView.organizationId,
794
- data: omit(localCustomEntityData, ['id']),
795
- customViewId: fetchedCustomView?.customView?.id || '',
629
+ organizationId,
630
+ data,
631
+ customViewId,
796
632
  applicationIdentifier
797
633
  });
798
- console.log(chalk.green(`Custom View updated.`));
799
- console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk.gray(customViewLink)}".`);
634
+ const customViewLink = getMcUrlLink({
635
+ mcApiUrl,
636
+ organizationId,
637
+ customEntityId: customViewId,
638
+ isCustomView: true
639
+ });
640
+ console.log(chalk.green('Custom View updated successfully.'));
641
+ console.log(`URL: ${chalk.gray(customViewLink)}`);
800
642
  }
801
- async function run(options) {
802
- const applicationConfig = await processConfig();
803
- const localCustomEntityData = applicationConfig.data;
804
- const _applicationConfig$en = applicationConfig.env,
805
- mcApiUrl = _applicationConfig$en.mcApiUrl,
806
- applicationIdentifier = _applicationConfig$en.applicationIdentifier,
807
- customViewId = _applicationConfig$en.customViewId;
808
- console.log(`Using Merchant Center environment "${chalk.green(mcApiUrl)}".`);
809
- console.log();
810
- const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
811
- if (!isSessionValid) {
812
- throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
643
+ async function checkCustomApplicationStatus(_ref6) {
644
+ let mcApiUrl = _ref6.mcApiUrl,
645
+ entryPointUriPath = _ref6.entryPointUriPath,
646
+ applicationIdentifier = _ref6.applicationIdentifier,
647
+ localCustomEntityData = _ref6.localCustomEntityData;
648
+ const fetchedCustomApplication = await fetchCustomApplication({
649
+ mcApiUrl,
650
+ entryPointUriPath,
651
+ applicationIdentifier
652
+ });
653
+ if (!fetchedCustomApplication) {
654
+ return {
655
+ exists: false
656
+ };
813
657
  }
814
- if (isCustomViewData(localCustomEntityData)) {
815
- createOrUpdateCustomView({
816
- mcApiUrl,
817
- localCustomEntityData,
818
- applicationIdentifier,
819
- customViewId: customViewId || localCustomEntityData.id,
820
- options
821
- });
822
- } else {
823
- createOrUpdateCustomApplication({
824
- mcApiUrl,
825
- localCustomEntityData,
826
- applicationIdentifier,
827
- options
828
- });
658
+ const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
659
+ const customAppLink = getMcUrlLink({
660
+ mcApiUrl,
661
+ organizationId: fetchedCustomApplication.organizationId,
662
+ customEntityId: fetchedCustomApplication.application.id
663
+ });
664
+ return {
665
+ exists: true,
666
+ organizationId: fetchedCustomApplication.organizationId,
667
+ applicationId: fetchedCustomApplication.application.id,
668
+ configDiff,
669
+ link: customAppLink
670
+ };
671
+ }
672
+ async function checkCustomViewStatus(_ref7) {
673
+ let mcApiUrl = _ref7.mcApiUrl,
674
+ customViewId = _ref7.customViewId,
675
+ applicationIdentifier = _ref7.applicationIdentifier,
676
+ localCustomEntityData = _ref7.localCustomEntityData;
677
+ const fetchedCustomView = await fetchCustomView({
678
+ mcApiUrl,
679
+ customViewId,
680
+ applicationIdentifier
681
+ });
682
+ if (!fetchedCustomView) {
683
+ return {
684
+ exists: false
685
+ };
829
686
  }
687
+ const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
688
+ const customViewLink = getMcUrlLink({
689
+ mcApiUrl,
690
+ organizationId: fetchedCustomView.organizationId,
691
+ customEntityId: fetchedCustomView?.customView?.id || '',
692
+ isCustomView: true
693
+ });
694
+ return {
695
+ exists: true,
696
+ organizationId: fetchedCustomView.organizationId,
697
+ customViewId: fetchedCustomView?.customView?.id || '',
698
+ configDiff,
699
+ link: customViewLink
700
+ };
830
701
  }
831
702
 
832
- export { run as default };
703
+ export { performUpdateCustomApplication as a, checkCustomViewStatus as b, checkCustomApplicationStatus as c, performCreateCustomView as d, performUpdateCustomView as e, isCustomViewData as i, performCreateCustomApplication as p };
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
4
4
  var path = require('path');
5
- var _package = require('./package-e1f7242c.cjs.prod.js');
5
+ var _package = require('./package-b9298ce3.cjs.prod.js');
6
6
 
7
7
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
4
4
  var path = require('path');
5
- var _package = require('./package-d8b1f4c0.cjs.dev.js');
5
+ var _package = require('./package-0eebca1b.cjs.dev.js');
6
6
 
7
7
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
8
8
 
@@ -1,6 +1,6 @@
1
1
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
2
2
  import path from 'path';
3
- import { p as pkgJson } from './package-a34835d9.esm.js';
3
+ import { p as pkgJson } from './package-9e6910b8.esm.js';
4
4
 
5
5
  // This function aims to return the same result as `require.resolve`.
6
6
  // However, resolving a path to a `.css` file does not return the real
@@ -25,7 +25,7 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
25
25
  var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
26
26
  var applicationConfig = require('@commercetools-frontend/application-config');
27
27
  var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
28
- var createPostcssConfig = require('./create-postcss-config-91c09596.cjs.prod.js');
28
+ var createPostcssConfig = require('./create-postcss-config-56b74a34.cjs.prod.js');
29
29
  var hasJsxRuntime = require('./has-jsx-runtime-c3202df5.cjs.prod.js');
30
30
  var optimizations = require('./optimizations-fb93514f.cjs.prod.js');
31
31
  var paths = require('./paths-7768b440.cjs.prod.js');
@@ -90,7 +90,7 @@ let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
90
90
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
91
91
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
92
92
  // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
93
- const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
93
+ const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-gb", "en-au", "en-ca", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
94
94
  const defaultToggleFlags = {
95
95
  generateIndexHtml: true,
96
96
  disableCoreJs: false
@@ -25,7 +25,7 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
25
25
  var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
26
26
  var applicationConfig = require('@commercetools-frontend/application-config');
27
27
  var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
28
- var createPostcssConfig = require('./create-postcss-config-381b636b.cjs.dev.js');
28
+ var createPostcssConfig = require('./create-postcss-config-78879a12.cjs.dev.js');
29
29
  var hasJsxRuntime = require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
30
30
  var optimizations = require('./optimizations-7789145e.cjs.dev.js');
31
31
  var paths = require('./paths-b76fc753.cjs.dev.js');
@@ -90,7 +90,7 @@ let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
90
90
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
91
91
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
92
92
  // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
93
- const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
93
+ const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-gb", "en-au", "en-ca", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
94
94
  const defaultToggleFlags = {
95
95
  generateIndexHtml: true,
96
96
  disableCoreJs: false
@@ -23,7 +23,7 @@ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
23
23
  import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
24
24
  import { processConfig } from '@commercetools-frontend/application-config';
25
25
  import { replaceHtmlPlaceholders } from '@commercetools-frontend/mc-html-template';
26
- import { c as createPostcssConfig } from './create-postcss-config-0a86560d.esm.js';
26
+ import { c as createPostcssConfig } from './create-postcss-config-95f9bf62.esm.js';
27
27
  import { h as hasJsxRuntime } from './has-jsx-runtime-e3ecb09b.esm.js';
28
28
  import { g as getWepbackCacheGroups } from './optimizations-bf991634.esm.js';
29
29
  import { p as paths } from './paths-39f22b8b.esm.js';
@@ -65,7 +65,7 @@ let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
65
65
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
66
66
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
67
67
  // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
68
- const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
68
+ const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-gb", "en-au", "en-ca", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
69
69
  const defaultToggleFlags = {
70
70
  generateIndexHtml: true,
71
71
  disableCoreJs: false
@@ -27,7 +27,7 @@ import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/insta
27
27
  import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
28
28
  import fs from 'fs';
29
29
  import path from 'path';
30
- import { c as createPostcssConfig } from './create-postcss-config-0a86560d.esm.js';
30
+ import { c as createPostcssConfig } from './create-postcss-config-95f9bf62.esm.js';
31
31
  import { h as hasJsxRuntime } from './has-jsx-runtime-e3ecb09b.esm.js';
32
32
  import { g as getWepbackCacheGroups } from './optimizations-bf991634.esm.js';
33
33
  import { p as paths } from './paths-39f22b8b.esm.js';
@@ -88,7 +88,7 @@ let FinalStatsWriterPlugin = /*#__PURE__*/function () {
88
88
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
89
89
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
90
90
  // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
91
- const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
91
+ const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-gb", "en-au", "en-ca", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
92
92
  const defaultToggleFlags = {
93
93
  // Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
94
94
  enableExtractCss: true,
@@ -29,7 +29,7 @@ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
29
29
  var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
30
30
  var fs = require('fs');
31
31
  var path = require('path');
32
- var createPostcssConfig = require('./create-postcss-config-91c09596.cjs.prod.js');
32
+ var createPostcssConfig = require('./create-postcss-config-56b74a34.cjs.prod.js');
33
33
  var hasJsxRuntime = require('./has-jsx-runtime-c3202df5.cjs.prod.js');
34
34
  var optimizations = require('./optimizations-fb93514f.cjs.prod.js');
35
35
  var paths = require('./paths-7768b440.cjs.prod.js');
@@ -118,7 +118,7 @@ let FinalStatsWriterPlugin = /*#__PURE__*/function () {
118
118
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
119
119
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
120
120
  // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
121
- const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
121
+ const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-gb", "en-au", "en-ca", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
122
122
  const defaultToggleFlags = {
123
123
  // Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
124
124
  enableExtractCss: true,