@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
@@ -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-381b636b.cjs.dev.js');
32
+ var createPostcssConfig = require('./create-postcss-config-78879a12.cjs.dev.js');
33
33
  var hasJsxRuntime = require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
34
34
  var optimizations = require('./optimizations-7789145e.cjs.dev.js');
35
35
  var paths = require('./paths-b76fc753.cjs.dev.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,
@@ -17,6 +17,11 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
17
17
  var os__default = /*#__PURE__*/_interopDefault(os);
18
18
  var path__default = /*#__PURE__*/_interopDefault(path);
19
19
 
20
+ /**
21
+ * Environment variable name for providing a token directly (useful for CI).
22
+ * When set, this token will be used instead of the stored credentials.
23
+ */
24
+ const MC_ACCESS_TOKEN_ENV_VAR = 'MC_ACCESS_TOKEN';
20
25
  let CredentialsStorage = /*#__PURE__*/function () {
21
26
  function CredentialsStorage() {
22
27
  _classCallCheck(this, CredentialsStorage);
@@ -25,8 +30,8 @@ let CredentialsStorage = /*#__PURE__*/function () {
25
30
  const credentialsFolderPath = path__default["default"].join(homedir, `.commercetools`);
26
31
  this.credentialsFilePath = path__default["default"].join(credentialsFolderPath, 'mc-credentials.json');
27
32
 
28
- // Ensure the credentials file is present
29
- if (!doesFileExist.doesFileExist(this.credentialsFilePath)) {
33
+ // Ensure the credentials file is present (skip if using env var token)
34
+ if (!process.env[MC_ACCESS_TOKEN_ENV_VAR] && !doesFileExist.doesFileExist(this.credentialsFilePath)) {
30
35
  fs__default["default"].mkdirSync(credentialsFolderPath, {
31
36
  recursive: true
32
37
  });
@@ -52,6 +57,11 @@ let CredentialsStorage = /*#__PURE__*/function () {
52
57
  }, {
53
58
  key: "getToken",
54
59
  value: function getToken(environmentKey) {
60
+ // Check for environment variable token first (useful for CI)
61
+ const envToken = process.env[MC_ACCESS_TOKEN_ENV_VAR];
62
+ if (envToken) {
63
+ return envToken;
64
+ }
55
65
  const allCredentials = this._loadCredentials();
56
66
  if (!this.isSessionValid(environmentKey)) {
57
67
  return null;
@@ -61,6 +71,10 @@ let CredentialsStorage = /*#__PURE__*/function () {
61
71
  }, {
62
72
  key: "setToken",
63
73
  value: function setToken(environmentKey, credentials) {
74
+ // Don't write credentials if using env var token
75
+ if (process.env[MC_ACCESS_TOKEN_ENV_VAR]) {
76
+ return;
77
+ }
64
78
  const allCredentials = this._loadCredentials();
65
79
  allCredentials[environmentKey] = credentials;
66
80
  this._writeCredentials(allCredentials);
@@ -68,6 +82,10 @@ let CredentialsStorage = /*#__PURE__*/function () {
68
82
  }, {
69
83
  key: "isSessionValid",
70
84
  value: function isSessionValid(environmentKey) {
85
+ // If using environment variable token, assume it's valid
86
+ if (process.env[MC_ACCESS_TOKEN_ENV_VAR]) {
87
+ return true;
88
+ }
71
89
  const allCredentials = this._loadCredentials();
72
90
  const credentials = allCredentials[environmentKey];
73
91
  if (!credentials) {
@@ -17,6 +17,11 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
17
17
  var os__default = /*#__PURE__*/_interopDefault(os);
18
18
  var path__default = /*#__PURE__*/_interopDefault(path);
19
19
 
20
+ /**
21
+ * Environment variable name for providing a token directly (useful for CI).
22
+ * When set, this token will be used instead of the stored credentials.
23
+ */
24
+ const MC_ACCESS_TOKEN_ENV_VAR = 'MC_ACCESS_TOKEN';
20
25
  let CredentialsStorage = /*#__PURE__*/function () {
21
26
  function CredentialsStorage() {
22
27
  _classCallCheck(this, CredentialsStorage);
@@ -25,8 +30,8 @@ let CredentialsStorage = /*#__PURE__*/function () {
25
30
  const credentialsFolderPath = path__default["default"].join(homedir, `.commercetools`);
26
31
  this.credentialsFilePath = path__default["default"].join(credentialsFolderPath, 'mc-credentials.json');
27
32
 
28
- // Ensure the credentials file is present
29
- if (!doesFileExist.doesFileExist(this.credentialsFilePath)) {
33
+ // Ensure the credentials file is present (skip if using env var token)
34
+ if (!process.env[MC_ACCESS_TOKEN_ENV_VAR] && !doesFileExist.doesFileExist(this.credentialsFilePath)) {
30
35
  fs__default["default"].mkdirSync(credentialsFolderPath, {
31
36
  recursive: true
32
37
  });
@@ -52,6 +57,11 @@ let CredentialsStorage = /*#__PURE__*/function () {
52
57
  }, {
53
58
  key: "getToken",
54
59
  value: function getToken(environmentKey) {
60
+ // Check for environment variable token first (useful for CI)
61
+ const envToken = process.env[MC_ACCESS_TOKEN_ENV_VAR];
62
+ if (envToken) {
63
+ return envToken;
64
+ }
55
65
  const allCredentials = this._loadCredentials();
56
66
  if (!this.isSessionValid(environmentKey)) {
57
67
  return null;
@@ -61,6 +71,10 @@ let CredentialsStorage = /*#__PURE__*/function () {
61
71
  }, {
62
72
  key: "setToken",
63
73
  value: function setToken(environmentKey, credentials) {
74
+ // Don't write credentials if using env var token
75
+ if (process.env[MC_ACCESS_TOKEN_ENV_VAR]) {
76
+ return;
77
+ }
64
78
  const allCredentials = this._loadCredentials();
65
79
  allCredentials[environmentKey] = credentials;
66
80
  this._writeCredentials(allCredentials);
@@ -68,6 +82,10 @@ let CredentialsStorage = /*#__PURE__*/function () {
68
82
  }, {
69
83
  key: "isSessionValid",
70
84
  value: function isSessionValid(environmentKey) {
85
+ // If using environment variable token, assume it's valid
86
+ if (process.env[MC_ACCESS_TOKEN_ENV_VAR]) {
87
+ return true;
88
+ }
71
89
  const allCredentials = this._loadCredentials();
72
90
  const credentials = allCredentials[environmentKey];
73
91
  if (!credentials) {
@@ -7,6 +7,11 @@ import os from 'node:os';
7
7
  import path from 'node:path';
8
8
  import { d as doesFileExist } from './does-file-exist-32618334.esm.js';
9
9
 
10
+ /**
11
+ * Environment variable name for providing a token directly (useful for CI).
12
+ * When set, this token will be used instead of the stored credentials.
13
+ */
14
+ const MC_ACCESS_TOKEN_ENV_VAR = 'MC_ACCESS_TOKEN';
10
15
  let CredentialsStorage = /*#__PURE__*/function () {
11
16
  function CredentialsStorage() {
12
17
  _classCallCheck(this, CredentialsStorage);
@@ -15,8 +20,8 @@ let CredentialsStorage = /*#__PURE__*/function () {
15
20
  const credentialsFolderPath = path.join(homedir, `.commercetools`);
16
21
  this.credentialsFilePath = path.join(credentialsFolderPath, 'mc-credentials.json');
17
22
 
18
- // Ensure the credentials file is present
19
- if (!doesFileExist(this.credentialsFilePath)) {
23
+ // Ensure the credentials file is present (skip if using env var token)
24
+ if (!process.env[MC_ACCESS_TOKEN_ENV_VAR] && !doesFileExist(this.credentialsFilePath)) {
20
25
  fs.mkdirSync(credentialsFolderPath, {
21
26
  recursive: true
22
27
  });
@@ -42,6 +47,11 @@ let CredentialsStorage = /*#__PURE__*/function () {
42
47
  }, {
43
48
  key: "getToken",
44
49
  value: function getToken(environmentKey) {
50
+ // Check for environment variable token first (useful for CI)
51
+ const envToken = process.env[MC_ACCESS_TOKEN_ENV_VAR];
52
+ if (envToken) {
53
+ return envToken;
54
+ }
45
55
  const allCredentials = this._loadCredentials();
46
56
  if (!this.isSessionValid(environmentKey)) {
47
57
  return null;
@@ -51,6 +61,10 @@ let CredentialsStorage = /*#__PURE__*/function () {
51
61
  }, {
52
62
  key: "setToken",
53
63
  value: function setToken(environmentKey, credentials) {
64
+ // Don't write credentials if using env var token
65
+ if (process.env[MC_ACCESS_TOKEN_ENV_VAR]) {
66
+ return;
67
+ }
54
68
  const allCredentials = this._loadCredentials();
55
69
  allCredentials[environmentKey] = credentials;
56
70
  this._writeCredentials(allCredentials);
@@ -58,6 +72,10 @@ let CredentialsStorage = /*#__PURE__*/function () {
58
72
  }, {
59
73
  key: "isSessionValid",
60
74
  value: function isSessionValid(environmentKey) {
75
+ // If using environment variable token, assume it's valid
76
+ if (process.env[MC_ACCESS_TOKEN_ENV_VAR]) {
77
+ return true;
78
+ }
61
79
  const allCredentials = this._loadCredentials();
62
80
  const credentials = allCredentials[environmentKey];
63
81
  if (!credentials) {
@@ -11,11 +11,15 @@ export type TCliCommandCompileHtmlOptions = {
11
11
  export type TCliCommandConfigSyncOptions = {
12
12
  dryRun: boolean;
13
13
  };
14
+ export type TCliCommandConfigSyncCIOptions = {
15
+ dryRun: boolean;
16
+ };
14
17
  export type TCliCommandLoginOptions = {
15
18
  mcApiUrl?: string;
16
19
  projectKey?: string;
17
20
  oauthScope?: string[];
18
21
  force?: boolean;
22
+ headless?: boolean;
19
23
  };
20
24
  export type TCliCommandSetDeploymentPreviewOptions = {
21
25
  alias?: string;
@@ -5,8 +5,8 @@ import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instanc
5
5
  import chalk from 'chalk';
6
6
  import prompts from 'prompts';
7
7
  import { processConfig } from '@commercetools-frontend/application-config';
8
- import { C as CredentialsStorage } from './credentials-storage-4464313c.esm.js';
9
- import { f as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-14074b2b.esm.js';
8
+ import { C as CredentialsStorage } from './credentials-storage-fcc77fb6.esm.js';
9
+ import { d as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-d2fa2ca7.esm.js';
10
10
  import '@babel/runtime-corejs3/helpers/classCallCheck';
11
11
  import '@babel/runtime-corejs3/helpers/createClass';
12
12
  import '@babel/runtime-corejs3/core-js-stable/json/stringify';
@@ -28,7 +28,7 @@ import 'graphql';
28
28
  import 'graphql-request';
29
29
  import '@commercetools-frontend/constants';
30
30
  import '@commercetools/http-user-agent';
31
- import './package-a34835d9.esm.js';
31
+ import './package-9e6910b8.esm.js';
32
32
 
33
33
  const credentialsStorage = new CredentialsStorage();
34
34
  const validateUrl = function () {
@@ -7,8 +7,8 @@ var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/insta
7
7
  var chalk = require('chalk');
8
8
  var prompts = require('prompts');
9
9
  var applicationConfig = require('@commercetools-frontend/application-config');
10
- var credentialsStorage$1 = require('./credentials-storage-cbb5c559.cjs.dev.js');
11
- var graphqlRequests = require('./graphql-requests-23f7ddb1.cjs.dev.js');
10
+ var credentialsStorage$1 = require('./credentials-storage-c4c5980e.cjs.dev.js');
11
+ var graphqlRequests = require('./graphql-requests-da194989.cjs.dev.js');
12
12
  require('@babel/runtime-corejs3/helpers/classCallCheck');
13
13
  require('@babel/runtime-corejs3/helpers/createClass');
14
14
  require('@babel/runtime-corejs3/core-js-stable/json/stringify');
@@ -30,7 +30,7 @@ require('graphql');
30
30
  require('graphql-request');
31
31
  require('@commercetools-frontend/constants');
32
32
  require('@commercetools/http-user-agent');
33
- require('./package-d8b1f4c0.cjs.dev.js');
33
+ require('./package-0eebca1b.cjs.dev.js');
34
34
 
35
35
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
36
36
 
@@ -7,8 +7,8 @@ var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/insta
7
7
  var chalk = require('chalk');
8
8
  var prompts = require('prompts');
9
9
  var applicationConfig = require('@commercetools-frontend/application-config');
10
- var credentialsStorage$1 = require('./credentials-storage-0b89aa0e.cjs.prod.js');
11
- var graphqlRequests = require('./graphql-requests-0a6eeb3a.cjs.prod.js');
10
+ var credentialsStorage$1 = require('./credentials-storage-6d592cd6.cjs.prod.js');
11
+ var graphqlRequests = require('./graphql-requests-b57fca4c.cjs.prod.js');
12
12
  require('@babel/runtime-corejs3/helpers/classCallCheck');
13
13
  require('@babel/runtime-corejs3/helpers/createClass');
14
14
  require('@babel/runtime-corejs3/core-js-stable/json/stringify');
@@ -30,7 +30,7 @@ require('graphql');
30
30
  require('graphql-request');
31
31
  require('@commercetools-frontend/constants');
32
32
  require('@commercetools/http-user-agent');
33
- require('./package-e1f7242c.cjs.prod.js');
33
+ require('./package-b9298ce3.cjs.prod.js');
34
34
 
35
35
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
36
36
 
@@ -14,9 +14,9 @@ var chalk = require('chalk');
14
14
  var graphql = require('graphql');
15
15
  var graphqlRequest = require('graphql-request');
16
16
  var constants = require('@commercetools-frontend/constants');
17
- var credentialsStorage$1 = require('./credentials-storage-0b89aa0e.cjs.prod.js');
17
+ var credentialsStorage$1 = require('./credentials-storage-6d592cd6.cjs.prod.js');
18
18
  var createHttpUserAgent = require('@commercetools/http-user-agent');
19
- var _package = require('./package-e1f7242c.cjs.prod.js');
19
+ var _package = require('./package-b9298ce3.cjs.prod.js');
20
20
 
21
21
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
22
22
 
@@ -12,9 +12,9 @@ import chalk from 'chalk';
12
12
  import { print } from 'graphql';
13
13
  import { GraphQLClient, ClientError } from 'graphql-request';
14
14
  import { GRAPHQL_TARGETS, SUPPORTED_HEADERS } from '@commercetools-frontend/constants';
15
- import { C as CredentialsStorage } from './credentials-storage-4464313c.esm.js';
15
+ import { C as CredentialsStorage } from './credentials-storage-fcc77fb6.esm.js';
16
16
  import createHttpUserAgent from '@commercetools/http-user-agent';
17
- import { p as pkgJson } from './package-a34835d9.esm.js';
17
+ import { p as pkgJson } from './package-9e6910b8.esm.js';
18
18
 
19
19
  const userAgent = createHttpUserAgent({
20
20
  name: 'graphql-request',
@@ -252,4 +252,4 @@ const updateCustomApplicationDeploymentPreview = async _ref9 => {
252
252
  return updatedDeploymentPreviewResult.updateCustomApplicationDeploymentPreview;
253
253
  };
254
254
 
255
- export { fetchUserOrganizations as a, fetchCustomView as b, createCustomApplication as c, createCustomView as d, updateCustomView as e, fetchCustomApplication as f, updateCustomApplicationDeploymentPreview as g, createCustomApplicationDeploymentPreview as h, updateCustomApplication as u };
255
+ export { createCustomView as a, updateCustomView as b, createCustomApplication as c, fetchCustomApplication as d, fetchCustomView as e, fetchUserOrganizations as f, updateCustomApplicationDeploymentPreview as g, createCustomApplicationDeploymentPreview as h, updateCustomApplication as u };
@@ -14,9 +14,9 @@ var chalk = require('chalk');
14
14
  var graphql = require('graphql');
15
15
  var graphqlRequest = require('graphql-request');
16
16
  var constants = require('@commercetools-frontend/constants');
17
- var credentialsStorage$1 = require('./credentials-storage-cbb5c559.cjs.dev.js');
17
+ var credentialsStorage$1 = require('./credentials-storage-c4c5980e.cjs.dev.js');
18
18
  var createHttpUserAgent = require('@commercetools/http-user-agent');
19
- var _package = require('./package-d8b1f4c0.cjs.dev.js');
19
+ var _package = require('./package-0eebca1b.cjs.dev.js');
20
20
 
21
21
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
22
22
 
@@ -6,21 +6,22 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
6
6
  var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
7
7
  var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
8
8
  var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
9
+ var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
10
+ var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
11
+ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
9
12
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
10
13
  var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
11
14
  var crypto = require('node:crypto');
12
15
  var process = require('node:process');
13
16
  var chalk = require('chalk');
14
17
  var applicationConfig = require('@commercetools-frontend/application-config');
15
- var _package = require('./package-e1f7242c.cjs.prod.js');
16
- var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
18
+ var _package = require('./package-b9298ce3.cjs.prod.js');
17
19
  var http = require('node:http');
18
20
  var jwtDecode = require('jwt-decode');
19
- var credentialsStorage$1 = require('./credentials-storage-0b89aa0e.cjs.prod.js');
21
+ var credentialsStorage$1 = require('./credentials-storage-6d592cd6.cjs.prod.js');
20
22
  require('@babel/runtime-corejs3/helpers/classCallCheck');
21
23
  require('@babel/runtime-corejs3/helpers/createClass');
22
24
  require('@babel/runtime-corejs3/core-js-stable/json/stringify');
23
- require('@babel/runtime-corejs3/core-js-stable/date/now');
24
25
  require('node:fs');
25
26
  require('node:os');
26
27
  require('node:path');
@@ -52,12 +53,14 @@ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsW
52
53
  var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
53
54
  var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
54
55
  var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
56
+ var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
57
+ var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
58
+ var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
55
59
  var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
56
60
  var _URL__default = /*#__PURE__*/_interopDefault(_URL);
57
61
  var crypto__default = /*#__PURE__*/_interopDefault(crypto);
58
62
  var process__default = /*#__PURE__*/_interopDefault(process);
59
63
  var chalk__default = /*#__PURE__*/_interopDefault(chalk);
60
- var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
61
64
  var http__default = /*#__PURE__*/_interopDefault(http);
62
65
  var jwtDecode__default = /*#__PURE__*/_interopDefault(jwtDecode);
63
66
 
@@ -205,6 +208,116 @@ const generateRandomHash = function () {
205
208
  let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
206
209
  return crypto__default["default"].randomBytes(length).toString('hex');
207
210
  };
211
+
212
+ /**
213
+ * Performs headless login using Puppeteer.
214
+ * Requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables.
215
+ */
216
+ async function runHeadlessLogin(authUrl) {
217
+ const email = process__default["default"].env.IDENTITY_EMAIL;
218
+ const password = process__default["default"].env.IDENTITY_PASSWORD;
219
+ if (!email || !password) {
220
+ throw new Error('Headless login requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables');
221
+ }
222
+ let puppeteer;
223
+ try {
224
+ puppeteer = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('puppeteer')); });
225
+ } catch {
226
+ throw new Error('Puppeteer is required for headless login. Install it with: npm install puppeteer');
227
+ }
228
+ const browser = await puppeteer.default.launch({
229
+ headless: 'new',
230
+ args: ['--no-sandbox', '--disable-setuid-sandbox']
231
+ });
232
+ try {
233
+ const page = await browser.newPage();
234
+ await page.goto(authUrl.toString(), {
235
+ waitUntil: 'networkidle2'
236
+ });
237
+
238
+ // Wait for the login page to load
239
+ await page.waitForSelector('input[name="identifier"]', {
240
+ timeout: 30000
241
+ });
242
+
243
+ // Dismiss cookie banner if present
244
+ // Note: Using string-based evaluate to avoid bundler transforming Array.from
245
+ try {
246
+ await page.evaluate(`
247
+ (function() {
248
+ var buttons = Array.from(document.querySelectorAll('button'));
249
+ var acceptBtn = buttons.find(function(btn) {
250
+ return btn.textContent && btn.textContent.includes('Accept all cookies');
251
+ });
252
+ if (acceptBtn) acceptBtn.click();
253
+ })()
254
+ `);
255
+ await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
256
+ } catch {
257
+ // Cookie banner not found or already dismissed
258
+ }
259
+
260
+ // Fill in email
261
+ await page.type('input[name="identifier"]', email);
262
+ await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
263
+
264
+ // Click "Next" button
265
+ await page.evaluate(`
266
+ (function() {
267
+ var buttons = Array.from(document.querySelectorAll('button'));
268
+ var nextBtn = buttons.find(function(btn) {
269
+ return btn.textContent && btn.textContent.toLowerCase().includes('next');
270
+ });
271
+ if (nextBtn) nextBtn.click();
272
+ })()
273
+ `);
274
+
275
+ // Wait for password field
276
+ await page.waitForSelector('input[name="password"]', {
277
+ visible: true,
278
+ timeout: 30000
279
+ });
280
+
281
+ // Fill in password
282
+ await page.type('input[name="password"]', password);
283
+ await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
284
+
285
+ // Click "Submit" button
286
+ await page.evaluate(`
287
+ (function() {
288
+ var buttons = Array.from(document.querySelectorAll('button'));
289
+ var submitBtn = buttons.find(function(btn) {
290
+ return btn.textContent && btn.textContent.toLowerCase().includes('submit');
291
+ });
292
+ if (submitBtn) submitBtn.click();
293
+ })()
294
+ `);
295
+
296
+ // Wait for the callback to be processed (the server will close and exit)
297
+ // We just need to keep the browser alive until the redirect happens
298
+ const startTime = _Date$now__default["default"]();
299
+ const timeout = 60000;
300
+ while (_Date$now__default["default"]() - startTime < timeout) {
301
+ await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
302
+ const currentUrl = page.url();
303
+ if (_includesInstanceProperty__default["default"](currentUrl).call(currentUrl, 'sessionToken=')) {
304
+ // Token was captured by the callback server, we can exit
305
+ break;
306
+ }
307
+ const pageContent = await page.content();
308
+ if (_includesInstanceProperty__default["default"](pageContent).call(pageContent, 'Invalid credentials') || _includesInstanceProperty__default["default"](pageContent).call(pageContent, 'invalid_grant')) {
309
+ throw new Error('Invalid credentials');
310
+ }
311
+
312
+ // Check if page shows success (callback server response)
313
+ if (_includesInstanceProperty__default["default"](pageContent).call(pageContent, 'Success!')) {
314
+ break;
315
+ }
316
+ }
317
+ } finally {
318
+ await browser.close();
319
+ }
320
+ }
208
321
  async function run(options) {
209
322
  const mcApiUrl = await resolveMcApiUrl(options);
210
323
  if (!mcApiUrl) {
@@ -246,12 +359,18 @@ async function run(options) {
246
359
  }
247
360
  });
248
361
  await startServer(server);
249
- console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
250
- console.log(` ${authUrl}`);
251
- console.log();
252
- const open = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('open')); });
253
- await open.default(authUrl.toString());
254
- console.log('Waiting for the OIDC authentication to complete...');
362
+ if (options.headless) {
363
+ console.log(`Initiating headless authentication flow using Puppeteer...`);
364
+ console.log();
365
+ await runHeadlessLogin(authUrl);
366
+ } else {
367
+ console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
368
+ console.log(` ${authUrl}`);
369
+ console.log();
370
+ const open = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('open')); });
371
+ await open.default(authUrl.toString());
372
+ console.log('Waiting for the OIDC authentication to complete...');
373
+ }
255
374
  }
256
375
 
257
376
  exports["default"] = run;