More MJS fixes.
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 40s
Smoke Test / Run basic test suite (pull_request) Successful in 4m14s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m43s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m0s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 7m51s
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 40s
Smoke Test / Run basic test suite (pull_request) Successful in 4m14s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m43s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m0s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 7m51s
This commit is contained in:
parent
48c726b67c
commit
e3b0d244f1
@ -3,11 +3,13 @@
|
|||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
set -x
|
|
||||||
|
|
||||||
CERC_MIN_NEXTVER=13.4.2
|
CERC_MIN_NEXTVER=13.4.2
|
||||||
|
CERC_DEFAULT_WEBPACK_VER="5.93.0"
|
||||||
|
|
||||||
CERC_NEXT_VERSION="${CERC_NEXT_VERSION:-keep}"
|
CERC_NEXT_VERSION="${CERC_NEXT_VERSION:-keep}"
|
||||||
|
CERC_WEBPACK_VERSION="${CERC_WEBPACK_VERSION:-keep}"
|
||||||
|
|
||||||
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
||||||
if [ -z "$CERC_BUILD_TOOL" ]; then
|
if [ -z "$CERC_BUILD_TOOL" ]; then
|
||||||
if [ -f "pnpm-lock.yaml" ]; then
|
if [ -f "pnpm-lock.yaml" ]; then
|
||||||
@ -28,8 +30,10 @@ cd "${WORK_DIR}" || exit 1
|
|||||||
|
|
||||||
if [ -f "next.config.mjs" ]; then
|
if [ -f "next.config.mjs" ]; then
|
||||||
NEXT_CONFIG_JS="next.config.mjs"
|
NEXT_CONFIG_JS="next.config.mjs"
|
||||||
|
IMPORT_OR_REQUIRE="import"
|
||||||
else
|
else
|
||||||
NEXT_CONFIG_JS="next.config.js"
|
NEXT_CONFIG_JS="next.config.js"
|
||||||
|
IMPORT_OR_REQUIRE="require"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If this file doesn't exist at all, we'll get errors below.
|
# If this file doesn't exist at all, we'll get errors below.
|
||||||
@ -50,11 +54,27 @@ fi
|
|||||||
js-beautify next.config.dist > ${NEXT_CONFIG_JS}
|
js-beautify next.config.dist > ${NEXT_CONFIG_JS}
|
||||||
echo "" >> ${NEXT_CONFIG_JS}
|
echo "" >> ${NEXT_CONFIG_JS}
|
||||||
|
|
||||||
WEBPACK_REQ_LINE=$(grep -n "require([\'\"]webpack[\'\"])" ${NEXT_CONFIG_JS} | cut -d':' -f1)
|
if [ "${IMPORT_OR_REQUIRE}" == "require" ]; then
|
||||||
if [ -z "$WEBPACK_REQ_LINE" ]; then
|
WEBPACK_REQ_LINE=$(grep -n "require([\'\"]webpack[\'\"])" ${NEXT_CONFIG_JS} | cut -d':' -f1)
|
||||||
cat > ${NEXT_CONFIG_JS}.0 <<EOF
|
if [ -z "$WEBPACK_REQ_LINE" ]; then
|
||||||
|
cat > ${NEXT_CONFIG_JS}.0 <<EOF
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
WEBPACK_IMPORT_LINE=$(grep -n "^import .*[\'\"]webpack[\'\"];?$" ${NEXT_CONFIG_JS} | cut -d':' -f1)
|
||||||
|
if [ -z "$WEBPACK_IMPORT_LINE" ]; then
|
||||||
|
cat > ${NEXT_CONFIG_JS}.0 <<EOF
|
||||||
|
import webpack from 'webpack';
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
CREATE_REQUIRE_LINE=$(grep -n "require = createRequire" ${NEXT_CONFIG_JS} | cut -d':' -f1)
|
||||||
|
if [ -z "$CREATE_REQUIRE_LINE" ]; then
|
||||||
|
cat >> ${NEXT_CONFIG_JS}.0 <<EOF
|
||||||
|
import { createRequire } from "module";
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > ${NEXT_CONFIG_JS}.1 <<EOF
|
cat > ${NEXT_CONFIG_JS}.1 <<EOF
|
||||||
@ -65,7 +85,8 @@ try {
|
|||||||
a[v] = \`"CERC_RUNTIME_ENV_\${v.split(/\./).pop()}"\`;
|
a[v] = \`"CERC_RUNTIME_ENV_\${v.split(/\./).pop()}"\`;
|
||||||
return a;
|
return a;
|
||||||
}, {});
|
}, {});
|
||||||
} catch {
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
// If .env-list.json cannot be loaded, we are probably running in dev mode, so use process.env instead.
|
// If .env-list.json cannot be loaded, we are probably running in dev mode, so use process.env instead.
|
||||||
envMap = Object.keys(process.env).reduce((a, v) => {
|
envMap = Object.keys(process.env).reduce((a, v) => {
|
||||||
if (v.startsWith('CERC_')) {
|
if (v.startsWith('CERC_')) {
|
||||||
@ -74,6 +95,7 @@ try {
|
|||||||
return a;
|
return a;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
console.log(envMap);
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
CONFIG_LINES=$(wc -l ${NEXT_CONFIG_JS} | awk '{ print $1 }')
|
CONFIG_LINES=$(wc -l ${NEXT_CONFIG_JS} | awk '{ print $1 }')
|
||||||
@ -104,9 +126,10 @@ else
|
|||||||
NEXT_SECTION_LINE=0
|
NEXT_SECTION_LINE=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tail -$(( ${CONFIG_LINES} - ${NEXT_SECTION_LINE} + ${NEXT_SECTION_ADJUSTMENT} )) ${NEXT_CONFIG_JS} > ${NEXT_CONFIG_JS}.5
|
tail -$(( ${CONFIG_LINES} - ${NEXT_SECTION_LINE} + ${NEXT_SECTION_ADJUSTMENT} )) ${NEXT_CONFIG_JS} > ${NEXT_CONFIG_JS}.4
|
||||||
|
|
||||||
cat ${NEXT_CONFIG_JS}.* | sed 's/^ *//g' | js-beautify | grep -v 'process\.\env\.' | js-beautify > ${NEXT_CONFIG_JS}
|
cat ${NEXT_CONFIG_JS}.{0,1,2} > ${NEXT_CONFIG_JS}
|
||||||
|
cat ${NEXT_CONFIG_JS}.{3,4} | sed 's/^ *//g' | js-beautify | grep -v 'process\.\env\.' | js-beautify >> ${NEXT_CONFIG_JS}
|
||||||
rm ${NEXT_CONFIG_JS}.*
|
rm ${NEXT_CONFIG_JS}.*
|
||||||
|
|
||||||
"${SCRIPT_DIR}/find-env.sh" "$(pwd)" > .env-list.json
|
"${SCRIPT_DIR}/find-env.sh" "$(pwd)" > .env-list.json
|
||||||
@ -123,6 +146,16 @@ if [ "$CERC_NEXT_VERSION" != "keep" ] && [ "$CUR_NEXT_VERSION" != "$CERC_NEXT_VE
|
|||||||
mv package.json.$$ package.json
|
mv package.json.$$ package.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CUR_WEBPACK_VERSION="`jq -r '.dependencies.webpack' package.json`"
|
||||||
|
if [ "${CERC_WEBPACK_VERSION}" != "keep" ] || [ "${CUR_WEBPACK_VERSION}" == "null" ]; then
|
||||||
|
if [ -z "$CERC_WEBPACK_VERSION" ] || [ "$CERC_WEBPACK_VERSION" == "keep" ]; then
|
||||||
|
CERC_WEBPACK_VERSION="${CERC_DEFAULT_WEBPACK_VER}"
|
||||||
|
fi
|
||||||
|
echo "Webpack is required. Adding to webpack@$CERC_WEBPACK_VERSION to dependencies..." 1>&2
|
||||||
|
cat package.json | jq ".dependencies.webpack = \"$CERC_WEBPACK_VERSION\"" > package.json.$$
|
||||||
|
mv package.json.$$ package.json
|
||||||
|
fi
|
||||||
|
|
||||||
time $CERC_BUILD_TOOL install || exit 1
|
time $CERC_BUILD_TOOL install || exit 1
|
||||||
|
|
||||||
CUR_NEXT_VERSION=`jq -r '.version' node_modules/next/package.json`
|
CUR_NEXT_VERSION=`jq -r '.version' node_modules/next/package.json`
|
||||||
|
Loading…
Reference in New Issue
Block a user