@commercetools-frontend/mc-scripts 20.10.3 → 20.12.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.
|
File without changes
|
package/build/bin/cli.js
CHANGED
|
@@ -41,6 +41,7 @@ Commands:
|
|
|
41
41
|
compile-html Compiles "index.html.template" file into a "index.html" with all the required runtime configuration. Outputs a "public" folder. Additionally, the security headers are also compiled and printed to stdout, unless you use a "transformer".
|
|
42
42
|
More info at https://docs.commercetools.com/custom-applications/deployment/compiling-a-custom-application.
|
|
43
43
|
--transformer <path> (optional) The path to a JS module that can be used to generate a configuration for a specific cloud provider (e.g. Netlify, Vercel, Firebase).
|
|
44
|
+
--inline-csp (optional) If defined, the CSP config is inlined in the HTML head as a meta tag. This might be useful to keep using a static config for a hosting provider without the dynamically generated Content-Security-Policy header.
|
|
44
45
|
|
|
45
46
|
start Starts the application in development mode using Webpack Dev Server.
|
|
46
47
|
|
|
@@ -78,7 +79,7 @@ const applicationDirectory = fs.realpathSync(process.cwd());
|
|
|
78
79
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
79
80
|
process.env.NODE_ENV = 'production'; // Get specific flag for this command.
|
|
80
81
|
|
|
81
|
-
const commandArgs = getArgsForCommand(['transformer']);
|
|
82
|
+
const commandArgs = getArgsForCommand(['transformer', 'inline-csp']);
|
|
82
83
|
proxyCommand({
|
|
83
84
|
commandArgs
|
|
84
85
|
});
|
|
@@ -17,7 +17,9 @@ const {
|
|
|
17
17
|
compileHtml
|
|
18
18
|
} = require('@commercetools-frontend/mc-html-template');
|
|
19
19
|
|
|
20
|
-
const flags = mri(process.argv.slice(2)
|
|
20
|
+
const flags = mri(process.argv.slice(2), {
|
|
21
|
+
boolean: ['inline-csp']
|
|
22
|
+
});
|
|
21
23
|
const appDirectory = fs.realpathSync(process.cwd());
|
|
22
24
|
|
|
23
25
|
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
|
@@ -60,21 +62,25 @@ try {
|
|
|
60
62
|
shelljs.cp('-R', path.join(assetsFrom, '/*'), publicAssetsPath);
|
|
61
63
|
|
|
62
64
|
const generateStatic = async () => {
|
|
63
|
-
const compiled = await compileHtml(paths.indexHtmlTemplatePath
|
|
65
|
+
const compiled = await compileHtml(paths.indexHtmlTemplatePath, {
|
|
66
|
+
inlineCsp: flags['inline-csp']
|
|
67
|
+
});
|
|
64
68
|
fs.writeFileSync(paths.indexHtmlPath, compiled.indexHtmlContent, {
|
|
65
69
|
encoding: 'utf8'
|
|
66
70
|
});
|
|
67
71
|
|
|
68
72
|
if (flags.transformer) {
|
|
69
73
|
try {
|
|
70
|
-
require.resolve(flags.transformer
|
|
74
|
+
const transformerPath = require.resolve(flags.transformer, {
|
|
75
|
+
paths: [appDirectory]
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const transformerFn = require(transformerPath);
|
|
79
|
+
|
|
80
|
+
transformerFn(compiled);
|
|
71
81
|
} catch (error) {
|
|
72
82
|
throw new Error(`Could not load transformer module "${flags.transformer}"\n${error.stack}`);
|
|
73
83
|
}
|
|
74
|
-
|
|
75
|
-
const transformerFn = require(flags.transformer);
|
|
76
|
-
|
|
77
|
-
transformerFn(compiled);
|
|
78
84
|
} else {
|
|
79
85
|
console.log(JSON.stringify(compiled.headers));
|
|
80
86
|
}
|
|
@@ -64,7 +64,7 @@ module.exports = ({
|
|
|
64
64
|
onBeforeSetupMiddleware({
|
|
65
65
|
app
|
|
66
66
|
}) {
|
|
67
|
-
var _applicationConfig$en;
|
|
67
|
+
var _applicationConfig$en, _applicationConfig$en2;
|
|
68
68
|
|
|
69
69
|
app.set('views', devAuthentication.views);
|
|
70
70
|
app.set('view engine', devAuthentication.config.viewEngine); // This lets us open files from the runtime error overlay.
|
|
@@ -79,12 +79,13 @@ module.exports = ({
|
|
|
79
79
|
data: null,
|
|
80
80
|
error: fakeApolloError
|
|
81
81
|
}));
|
|
82
|
-
});
|
|
82
|
+
});
|
|
83
83
|
|
|
84
|
-
if ((_applicationConfig$en = applicationConfig.env.__DEVELOPMENT__
|
|
85
|
-
var _applicationConfig$
|
|
84
|
+
if ((_applicationConfig$en = applicationConfig.env.__DEVELOPMENT__) !== null && _applicationConfig$en !== void 0 && (_applicationConfig$en2 = _applicationConfig$en.oidc) !== null && _applicationConfig$en2 !== void 0 && _applicationConfig$en2.authorizeUrl) {
|
|
85
|
+
var _applicationConfig$en3, _applicationConfig$en4;
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
88
|
+
if ((_applicationConfig$en3 = applicationConfig.env.__DEVELOPMENT__) !== null && _applicationConfig$en3 !== void 0 && (_applicationConfig$en4 = _applicationConfig$en3.oidc) !== null && _applicationConfig$en4 !== void 0 && _applicationConfig$en4.authorizeUrl.startsWith('http://localhost')) {
|
|
88
89
|
app.use('/login/authorize', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env));
|
|
89
90
|
}
|
|
90
91
|
} else {
|
|
@@ -25,7 +25,9 @@ class LocalHtmlWebpackPlugin {
|
|
|
25
25
|
apply(compiler) {
|
|
26
26
|
compiler.hooks.compilation.tap('LocalHtmlWebpackPlugin', compilation => {
|
|
27
27
|
HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync('LocalHtmlWebpackPlugin', (data, cb) => {
|
|
28
|
-
data.html = replaceHtmlPlaceholders(data.html,
|
|
28
|
+
data.html = replaceHtmlPlaceholders(data.html, {
|
|
29
|
+
env: enhancedLocalEnv
|
|
30
|
+
});
|
|
29
31
|
cb(null, data);
|
|
30
32
|
});
|
|
31
33
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/mc-scripts",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.12.0",
|
|
4
4
|
"description": "Configuration and scripts for developing a MC application",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -11,72 +11,69 @@
|
|
|
11
11
|
"homepage": "https://docs.commercetools.com/custom-applications",
|
|
12
12
|
"keywords": ["javascript", "frontend", "react", "toolkit"],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"private": false,
|
|
15
14
|
"publishConfig": {
|
|
16
15
|
"access": "public"
|
|
17
16
|
},
|
|
18
17
|
"main": "./build/index.js",
|
|
19
18
|
"files": ["build", "config", "package.json", "LICENSE", "README.md"],
|
|
20
|
-
"bin":
|
|
21
|
-
"mc-scripts": "./bin/mc-scripts.js"
|
|
22
|
-
},
|
|
19
|
+
"bin": "./bin/cli.js",
|
|
23
20
|
"browserslist": {
|
|
24
21
|
"production": [">1%", "not op_mini all", "not dead"],
|
|
25
22
|
"development": ["last 2 firefox versions", "last 2 chrome versions"]
|
|
26
23
|
},
|
|
27
24
|
"scripts": {
|
|
28
|
-
"
|
|
29
|
-
"build": "babel src --out-dir build",
|
|
25
|
+
"build": "rimraf build && babel src --out-dir build",
|
|
30
26
|
"build:bundles:watch": "yarn build -w"
|
|
31
27
|
},
|
|
32
28
|
"dependencies": {
|
|
33
29
|
"@babel/runtime": "7.15.4",
|
|
34
30
|
"@babel/runtime-corejs3": "7.15.4",
|
|
35
|
-
"@commercetools-frontend/application-config": "20.
|
|
36
|
-
"@commercetools-frontend/assets": "20.
|
|
37
|
-
"@commercetools-frontend/babel-preset-mc-app": "20.10.
|
|
38
|
-
"@commercetools-frontend/mc-dev-authentication": "20.10.
|
|
39
|
-
"@commercetools-frontend/mc-html-template": "20.
|
|
31
|
+
"@commercetools-frontend/application-config": "20.12.0",
|
|
32
|
+
"@commercetools-frontend/assets": "20.12.0",
|
|
33
|
+
"@commercetools-frontend/babel-preset-mc-app": "20.10.6",
|
|
34
|
+
"@commercetools-frontend/mc-dev-authentication": "20.10.6",
|
|
35
|
+
"@commercetools-frontend/mc-html-template": "20.12.0",
|
|
40
36
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.1",
|
|
41
37
|
"@svgr/webpack": "5.5.0",
|
|
42
38
|
"autoprefixer": "10.3.7",
|
|
43
|
-
"babel-loader": "8.2.
|
|
44
|
-
"browserslist": "4.17.
|
|
45
|
-
"core-js": "3.
|
|
39
|
+
"babel-loader": "8.2.3",
|
|
40
|
+
"browserslist": "4.17.5",
|
|
41
|
+
"core-js": "3.19.0",
|
|
46
42
|
"css-loader": "5.2.7",
|
|
47
43
|
"css-minimizer-webpack-plugin": "3.1.1",
|
|
48
44
|
"dotenv": "10.0.0",
|
|
49
45
|
"dotenv-expand": "5.1.0",
|
|
50
46
|
"fs-extra": "10.0.0",
|
|
51
47
|
"graphql-tag": "^2.11.0",
|
|
52
|
-
"html-webpack-plugin": "5.
|
|
48
|
+
"html-webpack-plugin": "5.5.0",
|
|
53
49
|
"json-loader": "0.5.7",
|
|
54
50
|
"mini-css-extract-plugin": "1.6.2",
|
|
55
51
|
"moment-locales-webpack-plugin": "1.2.0",
|
|
56
52
|
"mri": "1.2.0",
|
|
57
|
-
"postcss": "8.3.
|
|
53
|
+
"postcss": "8.3.11",
|
|
58
54
|
"postcss-color-mod-function": "3.0.3",
|
|
59
55
|
"postcss-custom-media": "8.0.0",
|
|
60
56
|
"postcss-custom-properties": "11.0.0",
|
|
61
57
|
"postcss-import": "14.0.2",
|
|
62
|
-
"postcss-loader": "6.
|
|
63
|
-
"postcss-reporter": "7.0.
|
|
58
|
+
"postcss-loader": "6.2.0",
|
|
59
|
+
"postcss-reporter": "7.0.4",
|
|
64
60
|
"react-dev-utils": "11.0.4",
|
|
65
61
|
"react-refresh": "0.10.0",
|
|
66
62
|
"serve-handler": "6.1.3",
|
|
67
63
|
"shelljs": "0.8.4",
|
|
68
|
-
"style-loader": "3.3.
|
|
64
|
+
"style-loader": "3.3.1",
|
|
69
65
|
"svg-url-loader": "7.1.1",
|
|
70
66
|
"terser-webpack-plugin": "5.2.4",
|
|
71
67
|
"thread-loader": "3.0.4",
|
|
72
|
-
"webpack": "5.
|
|
73
|
-
"webpack-bundle-analyzer": "4.
|
|
68
|
+
"webpack": "5.60.0",
|
|
69
|
+
"webpack-bundle-analyzer": "4.5.0",
|
|
74
70
|
"webpack-dev-server": "4.3.1",
|
|
75
71
|
"webpackbar": "5.0.0-3"
|
|
76
72
|
},
|
|
77
73
|
"devDependencies": {
|
|
78
74
|
"@babel/plugin-transform-runtime": "7.15.8",
|
|
79
|
-
"@babel/preset-env": "7.15.8"
|
|
75
|
+
"@babel/preset-env": "7.15.8",
|
|
76
|
+
"rimraf": "3.0.2"
|
|
80
77
|
},
|
|
81
78
|
"engines": {
|
|
82
79
|
"node": ">=12 || >=14"
|