Mainnet-laconic stack fixes for laconicd2 #904

Merged
dboreham merged 7 commits from dboreham/mainnet-laconic-v2-fixes into main 2024-07-31 13:51:29 +00:00
12 changed files with 69 additions and 39 deletions
Showing only changes of commit 0fa6e9f649 - Show all commits

View File

@ -51,7 +51,7 @@ $ laconic-so build-npms --include <package-name>
```
e.g.
```
$ laconic-so build-npms --include laconic-sdk
$ laconic-so build-npms --include registry-sdk
```
Build the packages for a stack:
```

View File

@ -56,7 +56,7 @@ laconic-so --stack fixturenet-laconicd build-npms
Navigate to the Gitea console and switch to the `cerc-io` user then find the `Packages` tab to confirm that these two npm packages have been published:
- `@cerc-io/laconic-registry-cli`
- `@cerc-io/laconic-sdk`
- `@cerc-io/registry-sdk`
### Build and deploy fixturenet containers

View File

@ -68,5 +68,5 @@ ENV PATH="${PATH}:/scripts"
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
# Placeholder CMD : generally this will be overridden at run time like :
# docker run -it -v /home/builder/cerc/laconic-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
# docker run -it -v /home/builder/cerc/registry-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
CMD node --version

View File

@ -98,39 +98,67 @@ try {
console.log(envMap);
EOF
CONFIG_LINES=$(wc -l ${NEXT_CONFIG_JS} | awk '{ print $1 }')
ENV_LINE=$(grep -n 'env:' ${NEXT_CONFIG_JS} | cut -d':' -f1)
WEBPACK_CONF_LINE=$(egrep -n 'webpack:\s+\([^,]+,' ${NEXT_CONFIG_JS} | cut -d':' -f1)
NEXT_SECTION_ADJUSTMENT=0
grep 'withPWA' ${NEXT_CONFIG_JS} >/dev/null && HAS_WITHPWA=true || HAS_WITHPWA=false
if [ -n "$WEBPACK_CONF_LINE" ]; then
WEBPACK_CONF_VAR=$(egrep -n 'webpack:\s+\([^,]+,' ${NEXT_CONFIG_JS} | cut -d',' -f1 | cut -d'(' -f2)
head -$(( ${WEBPACK_CONF_LINE} )) ${NEXT_CONFIG_JS} > ${NEXT_CONFIG_JS}.2
cat > ${NEXT_CONFIG_JS}.3 <<EOF
$WEBPACK_CONF_VAR.plugins.push(new webpack.DefinePlugin(envMap));
EOF
NEXT_SECTION_LINE=$((WEBPACK_CONF_LINE))
elif [ -n "$ENV_LINE" ]; then
head -$(( ${ENV_LINE} - 1 )) ${NEXT_CONFIG_JS} > ${NEXT_CONFIG_JS}.2
cat > ${NEXT_CONFIG_JS}.3 <<EOF
webpack: (config) => {
if [ "$HAS_WITHPWA" == "true" ]; then
if [ "$IMPORT_OR_REQUIRE" == "import" ]; then
cat > ${NEXT_CONFIG_JS}.2 <<EOF
const __xPWA__ = (p) => {
const realPWA = withPWA(p);
return (nextConfig) => {
const modConfig = {...nextConfig};
modConfig.webpack = (config) => {
config.plugins.push(new webpack.DefinePlugin(envMap));
return config;
},
return nextConfig.webpack ? nextConfig.webpack(config) : config;
};
return realPWA(modConfig);
};
};
EOF
NEXT_SECTION_ADJUSTMENT=1
NEXT_SECTION_LINE=$ENV_LINE
else
cat > ${NEXT_CONFIG_JS}.3 <<EOF
const __xPWA__ = (nextConfig) => {
const modConfig = {...nextConfig};
modConfig.webpack = (config) => {
config.plugins.push(new webpack.DefinePlugin(envMap));
return nextConfig.webpack ? nextConfig.webpack(config) : config;
};
return withPWA(modConfig);
};
EOF
fi
cat ${NEXT_CONFIG_JS} | js-beautify | sed 's/withPWA(/__xPWA__(/g' > ${NEXT_CONFIG_JS}.4
else
echo "WARNING: Cannot find location to insert environment variable map in ${NEXT_CONFIG_JS}" 1>&2
rm -f ${NEXT_CONFIG_JS}.*
NEXT_SECTION_LINE=0
cat > ${NEXT_CONFIG_JS}.3 <<EOF
const __xCfg__ = (nextConfig) => {
const modConfig = {...nextConfig};
modConfig.webpack = (config) => {
config.plugins.push(new webpack.DefinePlugin(envMap));
return nextConfig.webpack ? nextConfig.webpack(config) : config;
};
return modConfig;
};
EOF
if [ "$IMPORT_OR_REQUIRE" == "import" ]; then
cat ${NEXT_CONFIG_JS} | js-beautify | sed 's/export\s\+default\s\+/const __orig_cfg__ = /g' > ${NEXT_CONFIG_JS}.4
echo "export default __xCfg__(__orig_cfg__);" > ${NEXT_CONFIG_JS}.5
else
cat ${NEXT_CONFIG_JS} | js-beautify | sed 's/module.exports\s\+=\s\+/const __orig_cfg__ = /g' > ${NEXT_CONFIG_JS}.4
echo "module.exports = __xCfg__(__orig_cfg__);" > ${NEXT_CONFIG_JS}.5
fi
fi
tail -$(( ${CONFIG_LINES} - ${NEXT_SECTION_LINE} + ${NEXT_SECTION_ADJUSTMENT} )) ${NEXT_CONFIG_JS} > ${NEXT_CONFIG_JS}.4
rm -f ${NEXT_CONFIG_JS}
for ((i=0; i <=5; i++)); do
if [ -f "${NEXT_CONFIG_JS}.${i}" ]; then
for ((i=0; i <= 10; i++)); do
if [ -s "${NEXT_CONFIG_JS}.${i}" ]; then
if [ $i -le 2 ] ; then
cat ${NEXT_CONFIG_JS}.${i} >> ${NEXT_CONFIG_JS}
else
@ -139,6 +167,8 @@ for ((i=0; i <=5; i++)); do
fi
done
rm ${NEXT_CONFIG_JS}.*
cat ${NEXT_CONFIG_JS} | js-beautify > ${NEXT_CONFIG_JS}.pretty
mv ${NEXT_CONFIG_JS}.pretty ${NEXT_CONFIG_JS}
"${SCRIPT_DIR}/find-env.sh" "$(pwd)" > .env-list.json

View File

@ -1,4 +1,4 @@
laconic-sdk
registry-sdk
laconic-registry-cli
laconic-console
debug

View File

@ -7,7 +7,7 @@ github.com/cerc-io/ipld-eth-db-validator
github.com/cerc-io/ipld-eth-beacon-indexer
github.com/cerc-io/ipld-eth-beacon-db
github.com/cerc-io/laconicd
github.com/cerc-io/laconic-sdk
github.com/cerc-io/registry-sdk
github.com/cerc-io/laconic-registry-cli
github.com/cerc-io/laconic-console
github.com/cerc-io/mobymask-watcher-ts

View File

@ -58,5 +58,5 @@ Now npm packages can be built:
Ensure that `CERC_NPM_AUTH_TOKEN` is set with the token printed above when the package-registry stack was deployed (the actual token value will be different than shown in this example):
```
$ export CERC_NPM_AUTH_TOKEN=84fe66a73698bf11edbdccd0a338236b7d1d5c45
$ laconic-so build-npms --include laconic-sdk,laconic-registry-cli
$ laconic-so build-npms --include registry-sdk,laconic-registry-cli
```

View File

@ -7,11 +7,11 @@ repos:
- github.com/lirewine/crypto
- github.com/lirewine/gem
- github.com/lirewine/sdk
- git.vdb.to/cerc-io/laconic-sdk
- git.vdb.to/cerc-io/registry-sdk
- git.vdb.to/cerc-io/laconic-registry-cli
- git.vdb.to/cerc-io/laconic-console
npms:
- laconic-sdk
- registry-sdk
- laconic-registry-cli
- debug
- crypto

View File

@ -3,10 +3,10 @@ name: fixturenet-laconicd
description: "A laconicd fixturenet"
repos:
- git.vdb.to/cerc-io/laconicd
- git.vdb.to/cerc-io/laconic-sdk
- git.vdb.to/cerc-io/registry-sdk
- git.vdb.to/cerc-io/laconic-registry-cli
npms:
- laconic-sdk
- registry-sdk
- laconic-registry-cli
containers:
- cerc/laconicd

View File

@ -7,12 +7,12 @@ repos:
- github.com/lirewine/crypto
- github.com/lirewine/gem
- github.com/lirewine/sdk
- git.vdb.to/cerc-io/laconic-sdk
- git.vdb.to/cerc-io/registry-sdk
- git.vdb.to/cerc-io/laconic-registry-cli
- git.vdb.to/cerc-io/laconic-console
- github.com/ping-pub/explorer
npms:
- laconic-sdk
- registry-sdk
- laconic-registry-cli
- debug
- crypto

View File

@ -109,7 +109,7 @@ Setup a test chain:
```bash
export CERC_NPM_REGISTRY_URL=https://git.vdb.to/api/packages/cerc-io/npm/
laconic-so --stack fixturenet-laconic-loaded setup-repositories --include git.vdb.to/cerc-io/laconicd,git.vdb.to/cerc-io/laconic-sdk,git.vdb.to/cerc-io/laconic-registry-cli,git.vdb.to/cerc-io/laconic-console
laconic-so --stack fixturenet-laconic-loaded setup-repositories --include git.vdb.to/cerc-io/laconicd,git.vdb.to/cerc-io/registry-sdk,git.vdb.to/cerc-io/laconic-registry-cli,git.vdb.to/cerc-io/laconic-console
laconic-so --stack fixturenet-laconic-loaded build-containers

View File

@ -20,7 +20,7 @@ echo "Cloning repositories into: $CERC_REPO_BASE_DIR"
rm -rf $CERC_REPO_BASE_DIR
mkdir -p $CERC_REPO_BASE_DIR
# Pull an example small public repo to test we can pull a repo
$TEST_TARGET_SO setup-repositories --include cerc-io/laconic-sdk
$TEST_TARGET_SO setup-repositories --include cerc-io/registry-sdk
# Test pulling a stack
$TEST_TARGET_SO --stack test setup-repositories
# Test building the a stack container