@commercetools-frontend/mc-scripts 21.7.0 → 21.9.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.
- package/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +345 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-5357ad26.cjs.prod.js +224 -0
- package/dist/build-9b6d7eee.cjs.dev.js +224 -0
- package/dist/build-c483e87f.esm.js +209 -0
- package/dist/build-vite-3b82522e.cjs.dev.js +151 -0
- package/dist/build-vite-93abdc95.esm.js +139 -0
- package/dist/build-vite-b7cd993a.cjs.prod.js +151 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-4361a0b3.esm.js +77 -0
- package/dist/compile-html-d6331c35.cjs.prod.js +87 -0
- package/dist/compile-html-d9e731aa.cjs.dev.js +87 -0
- package/dist/config-sync-6b31d972.esm.js +840 -0
- package/dist/config-sync-a478bc0f.cjs.dev.js +864 -0
- package/dist/config-sync-f07734e4.cjs.prod.js +859 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-04243dea.esm.js} +27 -25
- package/dist/create-postcss-config-760e2dc5.cjs.dev.js +90 -0
- package/dist/create-postcss-config-ddc3abee.cjs.prod.js +90 -0
- package/dist/create-webpack-config-for-development-76fdab59.cjs.prod.js +419 -0
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-d93ae4b2.esm.js} +94 -57
- package/dist/create-webpack-config-for-development-dfd1c174.cjs.dev.js +419 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-9290479a.esm.js} +120 -54
- package/dist/create-webpack-config-for-production-bc8c1f37.cjs.dev.js +469 -0
- package/dist/create-webpack-config-for-production-d652ad1a.cjs.prod.js +469 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/moment-locales.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2485 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-custom-application.d.ts +4 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
- package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-7b7ae27e.esm.js +155 -0
- package/dist/login-b13f26e7.cjs.dev.js +165 -0
- package/dist/login-c11fb977.cjs.prod.js +165 -0
- package/dist/package-4b4fcf02.cjs.prod.js +139 -0
- package/dist/package-4c3e3fb7.cjs.dev.js +139 -0
- package/dist/package-8e6305bd.esm.js +137 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-1b7dad90.cjs.prod.js +209 -0
- package/dist/start-45ca01f2.cjs.dev.js +209 -0
- package/dist/start-600d06a3.esm.js +194 -0
- package/dist/start-vite-22de08dc.cjs.dev.js +151 -0
- package/dist/start-vite-dc046cba.esm.js +138 -0
- package/dist/start-vite-fe13330b.cjs.prod.js +151 -0
- package/dist/user-agent-5f8ec93d.cjs.prod.js +106 -0
- package/dist/user-agent-ca628320.esm.js +94 -0
- package/dist/user-agent-ee57c98a.cjs.dev.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +110 -0
- package/dist/vite-plugin-svgr-eb8524fa.esm.js +85 -0
- package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +110 -0
- package/package.json +56 -50
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -264
- package/build/commands/build-vite.js +0 -91
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -176
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -138
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -69
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -36
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/get-config-diff.js +0 -308
- package/build/utils/get-config-diff.spec.js +0 -285
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
4
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
5
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
6
|
+
var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
7
|
+
var fs = require('fs');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
var os = require('os');
|
|
10
|
+
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
11
|
+
var _package = require('./package-4b4fcf02.cjs.prod.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
16
|
+
var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
|
|
17
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
18
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
19
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
20
|
+
var createHttpUserAgent__default = /*#__PURE__*/_interopDefault(createHttpUserAgent);
|
|
21
|
+
|
|
22
|
+
var homedir = os__default["default"].homedir();
|
|
23
|
+
var credentialsFolderPath = path__default["default"].join(homedir, ".commercetools");
|
|
24
|
+
var credentialsFilePath = path__default["default"].join(credentialsFolderPath, 'mc-credentials.json');
|
|
25
|
+
|
|
26
|
+
var CredentialsStorage = /*#__PURE__*/function () {
|
|
27
|
+
function CredentialsStorage() {
|
|
28
|
+
_classCallCheck(this, CredentialsStorage);
|
|
29
|
+
|
|
30
|
+
// Ensure the credentials file is present
|
|
31
|
+
if (!fs__default["default"].existsSync(credentialsFilePath)) {
|
|
32
|
+
fs__default["default"].mkdirSync(credentialsFolderPath, {
|
|
33
|
+
recursive: true
|
|
34
|
+
}); // Initialize with an empty object
|
|
35
|
+
|
|
36
|
+
this._writeCredentials();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_createClass(CredentialsStorage, [{
|
|
41
|
+
key: "_writeCredentials",
|
|
42
|
+
value: function _writeCredentials(credentials) {
|
|
43
|
+
fs__default["default"].writeFileSync(credentialsFilePath, _JSON$stringify__default["default"](credentials || {}, null, 2), {
|
|
44
|
+
encoding: 'utf8'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "_loadCredentials",
|
|
49
|
+
value: function _loadCredentials() {
|
|
50
|
+
var data = fs__default["default"].readFileSync(credentialsFilePath, {
|
|
51
|
+
encoding: 'utf8'
|
|
52
|
+
});
|
|
53
|
+
return JSON.parse(data);
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "getToken",
|
|
57
|
+
value: function getToken(environmentKey) {
|
|
58
|
+
var allCredentials = this._loadCredentials();
|
|
59
|
+
|
|
60
|
+
if (!this.isSessionValid(environmentKey)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return allCredentials[environmentKey].token;
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "setToken",
|
|
68
|
+
value: function setToken(environmentKey, credentials) {
|
|
69
|
+
var allCredentials = this._loadCredentials();
|
|
70
|
+
|
|
71
|
+
allCredentials[environmentKey] = credentials;
|
|
72
|
+
|
|
73
|
+
this._writeCredentials(allCredentials);
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "isSessionValid",
|
|
77
|
+
value: function isSessionValid(environmentKey) {
|
|
78
|
+
var allCredentials = this._loadCredentials();
|
|
79
|
+
|
|
80
|
+
var credentials = allCredentials[environmentKey];
|
|
81
|
+
|
|
82
|
+
if (!credentials) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var now = Math.floor(_Date$now__default["default"]() / 1000);
|
|
87
|
+
return now < credentials.expiresAt;
|
|
88
|
+
}
|
|
89
|
+
}]);
|
|
90
|
+
|
|
91
|
+
return CredentialsStorage;
|
|
92
|
+
}();
|
|
93
|
+
|
|
94
|
+
CredentialsStorage.location = credentialsFilePath;
|
|
95
|
+
|
|
96
|
+
var userAgent = createHttpUserAgent__default["default"]({
|
|
97
|
+
name: 'graphql-request',
|
|
98
|
+
libraryName: 'mc-scripts',
|
|
99
|
+
libraryVersion: _package.pkgJson.version,
|
|
100
|
+
contactUrl: 'https://git.io/fjuyC',
|
|
101
|
+
// points to the appkit repo issues
|
|
102
|
+
contactEmail: 'support@commercetools.com'
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
exports.CredentialsStorage = CredentialsStorage;
|
|
106
|
+
exports.userAgent = userAgent;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
2
|
+
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
3
|
+
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
4
|
+
import _Date$now from '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import createHttpUserAgent from '@commercetools/http-user-agent';
|
|
9
|
+
import { p as pkgJson } from './package-8e6305bd.esm.js';
|
|
10
|
+
|
|
11
|
+
var homedir = os.homedir();
|
|
12
|
+
var credentialsFolderPath = path.join(homedir, ".commercetools");
|
|
13
|
+
var credentialsFilePath = path.join(credentialsFolderPath, 'mc-credentials.json');
|
|
14
|
+
|
|
15
|
+
var CredentialsStorage = /*#__PURE__*/function () {
|
|
16
|
+
function CredentialsStorage() {
|
|
17
|
+
_classCallCheck(this, CredentialsStorage);
|
|
18
|
+
|
|
19
|
+
// Ensure the credentials file is present
|
|
20
|
+
if (!fs.existsSync(credentialsFilePath)) {
|
|
21
|
+
fs.mkdirSync(credentialsFolderPath, {
|
|
22
|
+
recursive: true
|
|
23
|
+
}); // Initialize with an empty object
|
|
24
|
+
|
|
25
|
+
this._writeCredentials();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_createClass(CredentialsStorage, [{
|
|
30
|
+
key: "_writeCredentials",
|
|
31
|
+
value: function _writeCredentials(credentials) {
|
|
32
|
+
fs.writeFileSync(credentialsFilePath, _JSON$stringify(credentials || {}, null, 2), {
|
|
33
|
+
encoding: 'utf8'
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "_loadCredentials",
|
|
38
|
+
value: function _loadCredentials() {
|
|
39
|
+
var data = fs.readFileSync(credentialsFilePath, {
|
|
40
|
+
encoding: 'utf8'
|
|
41
|
+
});
|
|
42
|
+
return JSON.parse(data);
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "getToken",
|
|
46
|
+
value: function getToken(environmentKey) {
|
|
47
|
+
var allCredentials = this._loadCredentials();
|
|
48
|
+
|
|
49
|
+
if (!this.isSessionValid(environmentKey)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return allCredentials[environmentKey].token;
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "setToken",
|
|
57
|
+
value: function setToken(environmentKey, credentials) {
|
|
58
|
+
var allCredentials = this._loadCredentials();
|
|
59
|
+
|
|
60
|
+
allCredentials[environmentKey] = credentials;
|
|
61
|
+
|
|
62
|
+
this._writeCredentials(allCredentials);
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "isSessionValid",
|
|
66
|
+
value: function isSessionValid(environmentKey) {
|
|
67
|
+
var allCredentials = this._loadCredentials();
|
|
68
|
+
|
|
69
|
+
var credentials = allCredentials[environmentKey];
|
|
70
|
+
|
|
71
|
+
if (!credentials) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var now = Math.floor(_Date$now() / 1000);
|
|
76
|
+
return now < credentials.expiresAt;
|
|
77
|
+
}
|
|
78
|
+
}]);
|
|
79
|
+
|
|
80
|
+
return CredentialsStorage;
|
|
81
|
+
}();
|
|
82
|
+
|
|
83
|
+
CredentialsStorage.location = credentialsFilePath;
|
|
84
|
+
|
|
85
|
+
var userAgent = createHttpUserAgent({
|
|
86
|
+
name: 'graphql-request',
|
|
87
|
+
libraryName: 'mc-scripts',
|
|
88
|
+
libraryVersion: pkgJson.version,
|
|
89
|
+
contactUrl: 'https://git.io/fjuyC',
|
|
90
|
+
// points to the appkit repo issues
|
|
91
|
+
contactEmail: 'support@commercetools.com'
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export { CredentialsStorage as C, userAgent as u };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
4
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
5
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
6
|
+
var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
7
|
+
var fs = require('fs');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
var os = require('os');
|
|
10
|
+
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
11
|
+
var _package = require('./package-4c3e3fb7.cjs.dev.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
16
|
+
var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
|
|
17
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
18
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
19
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
20
|
+
var createHttpUserAgent__default = /*#__PURE__*/_interopDefault(createHttpUserAgent);
|
|
21
|
+
|
|
22
|
+
var homedir = os__default["default"].homedir();
|
|
23
|
+
var credentialsFolderPath = path__default["default"].join(homedir, ".commercetools");
|
|
24
|
+
var credentialsFilePath = path__default["default"].join(credentialsFolderPath, 'mc-credentials.json');
|
|
25
|
+
|
|
26
|
+
var CredentialsStorage = /*#__PURE__*/function () {
|
|
27
|
+
function CredentialsStorage() {
|
|
28
|
+
_classCallCheck(this, CredentialsStorage);
|
|
29
|
+
|
|
30
|
+
// Ensure the credentials file is present
|
|
31
|
+
if (!fs__default["default"].existsSync(credentialsFilePath)) {
|
|
32
|
+
fs__default["default"].mkdirSync(credentialsFolderPath, {
|
|
33
|
+
recursive: true
|
|
34
|
+
}); // Initialize with an empty object
|
|
35
|
+
|
|
36
|
+
this._writeCredentials();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_createClass(CredentialsStorage, [{
|
|
41
|
+
key: "_writeCredentials",
|
|
42
|
+
value: function _writeCredentials(credentials) {
|
|
43
|
+
fs__default["default"].writeFileSync(credentialsFilePath, _JSON$stringify__default["default"](credentials || {}, null, 2), {
|
|
44
|
+
encoding: 'utf8'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "_loadCredentials",
|
|
49
|
+
value: function _loadCredentials() {
|
|
50
|
+
var data = fs__default["default"].readFileSync(credentialsFilePath, {
|
|
51
|
+
encoding: 'utf8'
|
|
52
|
+
});
|
|
53
|
+
return JSON.parse(data);
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "getToken",
|
|
57
|
+
value: function getToken(environmentKey) {
|
|
58
|
+
var allCredentials = this._loadCredentials();
|
|
59
|
+
|
|
60
|
+
if (!this.isSessionValid(environmentKey)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return allCredentials[environmentKey].token;
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "setToken",
|
|
68
|
+
value: function setToken(environmentKey, credentials) {
|
|
69
|
+
var allCredentials = this._loadCredentials();
|
|
70
|
+
|
|
71
|
+
allCredentials[environmentKey] = credentials;
|
|
72
|
+
|
|
73
|
+
this._writeCredentials(allCredentials);
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "isSessionValid",
|
|
77
|
+
value: function isSessionValid(environmentKey) {
|
|
78
|
+
var allCredentials = this._loadCredentials();
|
|
79
|
+
|
|
80
|
+
var credentials = allCredentials[environmentKey];
|
|
81
|
+
|
|
82
|
+
if (!credentials) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var now = Math.floor(_Date$now__default["default"]() / 1000);
|
|
87
|
+
return now < credentials.expiresAt;
|
|
88
|
+
}
|
|
89
|
+
}]);
|
|
90
|
+
|
|
91
|
+
return CredentialsStorage;
|
|
92
|
+
}();
|
|
93
|
+
|
|
94
|
+
CredentialsStorage.location = credentialsFilePath;
|
|
95
|
+
|
|
96
|
+
var userAgent = createHttpUserAgent__default["default"]({
|
|
97
|
+
name: 'graphql-request',
|
|
98
|
+
libraryName: 'mc-scripts',
|
|
99
|
+
libraryVersion: _package.pkgJson.version,
|
|
100
|
+
contactUrl: 'https://git.io/fjuyC',
|
|
101
|
+
// points to the appkit repo issues
|
|
102
|
+
contactEmail: 'support@commercetools.com'
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
exports.CredentialsStorage = CredentialsStorage;
|
|
106
|
+
exports.userAgent = userAgent;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var vite = require('vite');
|
|
7
|
+
var pluginutils = require('@rollup/pluginutils');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n["default"] = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
30
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
31
|
+
|
|
32
|
+
function vitePluginSvgr() {
|
|
33
|
+
var filter = pluginutils.createFilter('**/*.react.svg');
|
|
34
|
+
return {
|
|
35
|
+
name: 'vite-plugin-svgr',
|
|
36
|
+
transform: function transform(_code, id) {
|
|
37
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
38
|
+
var _yield$import, transform, svgCode, componentCode, res;
|
|
39
|
+
|
|
40
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
41
|
+
while (1) {
|
|
42
|
+
switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
if (!filter(id)) {
|
|
45
|
+
_context.next = 15;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_context.next = 3;
|
|
50
|
+
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@svgr/core')); });
|
|
51
|
+
|
|
52
|
+
case 3:
|
|
53
|
+
_yield$import = _context.sent;
|
|
54
|
+
transform = _yield$import.transform;
|
|
55
|
+
_context.next = 7;
|
|
56
|
+
return fs__default["default"].promises.readFile(id, 'utf8');
|
|
57
|
+
|
|
58
|
+
case 7:
|
|
59
|
+
svgCode = _context.sent;
|
|
60
|
+
_context.next = 10;
|
|
61
|
+
return transform(svgCode, {
|
|
62
|
+
icon: false,
|
|
63
|
+
svgoConfig: {
|
|
64
|
+
plugins: [{
|
|
65
|
+
// https://github.com/svg/svgo#default-preset
|
|
66
|
+
name: 'preset-default',
|
|
67
|
+
params: {
|
|
68
|
+
overrides: {
|
|
69
|
+
removeViewBox: false
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}]
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
filePath: id,
|
|
76
|
+
caller: {
|
|
77
|
+
previousExport: null
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
case 10:
|
|
82
|
+
componentCode = _context.sent;
|
|
83
|
+
_context.next = 13;
|
|
84
|
+
return vite.transformWithEsbuild(componentCode, id, {
|
|
85
|
+
loader: 'jsx'
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
case 13:
|
|
89
|
+
res = _context.sent;
|
|
90
|
+
return _context.abrupt("return", {
|
|
91
|
+
code: res.code,
|
|
92
|
+
map: null // TODO:
|
|
93
|
+
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
case 15:
|
|
97
|
+
return _context.abrupt("return", null);
|
|
98
|
+
|
|
99
|
+
case 16:
|
|
100
|
+
case "end":
|
|
101
|
+
return _context.stop();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, _callee);
|
|
105
|
+
}))();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
exports.vitePluginSvgr = vitePluginSvgr;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
|
|
2
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { transformWithEsbuild } from 'vite';
|
|
5
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
6
|
+
|
|
7
|
+
function vitePluginSvgr() {
|
|
8
|
+
var filter = createFilter('**/*.react.svg');
|
|
9
|
+
return {
|
|
10
|
+
name: 'vite-plugin-svgr',
|
|
11
|
+
transform: function transform(_code, id) {
|
|
12
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
13
|
+
var _yield$import, transform, svgCode, componentCode, res;
|
|
14
|
+
|
|
15
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
16
|
+
while (1) {
|
|
17
|
+
switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
if (!filter(id)) {
|
|
20
|
+
_context.next = 15;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_context.next = 3;
|
|
25
|
+
return import('@svgr/core');
|
|
26
|
+
|
|
27
|
+
case 3:
|
|
28
|
+
_yield$import = _context.sent;
|
|
29
|
+
transform = _yield$import.transform;
|
|
30
|
+
_context.next = 7;
|
|
31
|
+
return fs.promises.readFile(id, 'utf8');
|
|
32
|
+
|
|
33
|
+
case 7:
|
|
34
|
+
svgCode = _context.sent;
|
|
35
|
+
_context.next = 10;
|
|
36
|
+
return transform(svgCode, {
|
|
37
|
+
icon: false,
|
|
38
|
+
svgoConfig: {
|
|
39
|
+
plugins: [{
|
|
40
|
+
// https://github.com/svg/svgo#default-preset
|
|
41
|
+
name: 'preset-default',
|
|
42
|
+
params: {
|
|
43
|
+
overrides: {
|
|
44
|
+
removeViewBox: false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}]
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
filePath: id,
|
|
51
|
+
caller: {
|
|
52
|
+
previousExport: null
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
case 10:
|
|
57
|
+
componentCode = _context.sent;
|
|
58
|
+
_context.next = 13;
|
|
59
|
+
return transformWithEsbuild(componentCode, id, {
|
|
60
|
+
loader: 'jsx'
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
case 13:
|
|
64
|
+
res = _context.sent;
|
|
65
|
+
return _context.abrupt("return", {
|
|
66
|
+
code: res.code,
|
|
67
|
+
map: null // TODO:
|
|
68
|
+
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
case 15:
|
|
72
|
+
return _context.abrupt("return", null);
|
|
73
|
+
|
|
74
|
+
case 16:
|
|
75
|
+
case "end":
|
|
76
|
+
return _context.stop();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, _callee);
|
|
80
|
+
}))();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { vitePluginSvgr as v };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var vite = require('vite');
|
|
7
|
+
var pluginutils = require('@rollup/pluginutils');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n["default"] = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
30
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
31
|
+
|
|
32
|
+
function vitePluginSvgr() {
|
|
33
|
+
var filter = pluginutils.createFilter('**/*.react.svg');
|
|
34
|
+
return {
|
|
35
|
+
name: 'vite-plugin-svgr',
|
|
36
|
+
transform: function transform(_code, id) {
|
|
37
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
38
|
+
var _yield$import, transform, svgCode, componentCode, res;
|
|
39
|
+
|
|
40
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
41
|
+
while (1) {
|
|
42
|
+
switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
if (!filter(id)) {
|
|
45
|
+
_context.next = 15;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_context.next = 3;
|
|
50
|
+
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@svgr/core')); });
|
|
51
|
+
|
|
52
|
+
case 3:
|
|
53
|
+
_yield$import = _context.sent;
|
|
54
|
+
transform = _yield$import.transform;
|
|
55
|
+
_context.next = 7;
|
|
56
|
+
return fs__default["default"].promises.readFile(id, 'utf8');
|
|
57
|
+
|
|
58
|
+
case 7:
|
|
59
|
+
svgCode = _context.sent;
|
|
60
|
+
_context.next = 10;
|
|
61
|
+
return transform(svgCode, {
|
|
62
|
+
icon: false,
|
|
63
|
+
svgoConfig: {
|
|
64
|
+
plugins: [{
|
|
65
|
+
// https://github.com/svg/svgo#default-preset
|
|
66
|
+
name: 'preset-default',
|
|
67
|
+
params: {
|
|
68
|
+
overrides: {
|
|
69
|
+
removeViewBox: false
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}]
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
filePath: id,
|
|
76
|
+
caller: {
|
|
77
|
+
previousExport: null
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
case 10:
|
|
82
|
+
componentCode = _context.sent;
|
|
83
|
+
_context.next = 13;
|
|
84
|
+
return vite.transformWithEsbuild(componentCode, id, {
|
|
85
|
+
loader: 'jsx'
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
case 13:
|
|
89
|
+
res = _context.sent;
|
|
90
|
+
return _context.abrupt("return", {
|
|
91
|
+
code: res.code,
|
|
92
|
+
map: null // TODO:
|
|
93
|
+
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
case 15:
|
|
97
|
+
return _context.abrupt("return", null);
|
|
98
|
+
|
|
99
|
+
case 16:
|
|
100
|
+
case "end":
|
|
101
|
+
return _context.stop();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, _callee);
|
|
105
|
+
}))();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
exports.vitePluginSvgr = vitePluginSvgr;
|