lightning-terminal: fixed building frontend and embedding it into backend (#418337)
This commit is contained in:
@@ -1,139 +0,0 @@
|
||||
{
|
||||
"name": "lightning-terminal",
|
||||
"version": "0.0.1",
|
||||
"description": "Lightning Terminal",
|
||||
"repository": "https://github.com/lightninglabs/lightning-terminal",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "BROWSER=none react-scripts start",
|
||||
"develop": "REACT_APP_USE_SAMPLE_DATA=true yarn start",
|
||||
"build": "react-scripts build",
|
||||
"postbuild": "git restore build/.gitkeep",
|
||||
"test": "react-scripts test --env=jest-environment-jsdom --transformIgnorePatterns \"node_modules/(?!d3)/\"",
|
||||
"test:ci": "cross-env CI=true yarn test --coverage",
|
||||
"eject": "react-scripts eject",
|
||||
"lint": "eslint --ext .ts,.tsx --ignore-path .eslintignore .",
|
||||
"tsc": "tsc --noEmit",
|
||||
"protos": "node ./scripts/build-protos.js",
|
||||
"storybook": "storybook dev -p 9009 -s public",
|
||||
"build-storybook": "storybook build -s public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "11.4.0",
|
||||
"@emotion/styled": "11.3.0",
|
||||
"@improbable-eng/grpc-web": "0.14.0",
|
||||
"@types/react-collapse": "^5.0.1",
|
||||
"big.js": "6.1.1",
|
||||
"bootstrap": "4.6.1",
|
||||
"buffer": "6.0.3",
|
||||
"copy-to-clipboard": "3.3.1",
|
||||
"d3": "7.8.5",
|
||||
"date-fns": "2.14.0",
|
||||
"debug": "4.3.1",
|
||||
"file-saver": "2.0.2",
|
||||
"http-proxy-middleware": "2.0.7",
|
||||
"i18next": "19.5.1",
|
||||
"i18next-browser-languagedetector": "5.0.0",
|
||||
"lodash": "4.17.21",
|
||||
"lottie-web": "5.7.0",
|
||||
"mobx": "6.3.2",
|
||||
"mobx-react-lite": "3.2.0",
|
||||
"mobx-utils": "6.0.4",
|
||||
"qrcode.react": "^3.1.0",
|
||||
"rc-dialog": "^8.9.0",
|
||||
"rc-select": "11.5.0",
|
||||
"rc-switch": "^4.0.0",
|
||||
"rc-tooltip": "4.2.1",
|
||||
"react": "17.0.2",
|
||||
"react-collapse": "^5.1.1",
|
||||
"react-dom": "17.0.2",
|
||||
"react-i18next": "13.5.0",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-toastify": "6.0.6",
|
||||
"react-virtualized": "9.21.2",
|
||||
"reactour": "1.18.0",
|
||||
"semver": "^7.5.2",
|
||||
"styled-components": "5.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/addon-actions": "7.5.3",
|
||||
"@storybook/addon-docs": "7.5.3",
|
||||
"@storybook/addon-links": "7.5.3",
|
||||
"@storybook/addons": "7.5.3",
|
||||
"@storybook/preset-create-react-app": "7.5.3",
|
||||
"@storybook/react": "7.5.3",
|
||||
"@storybook/react-webpack5": "7.5.3",
|
||||
"@testing-library/jest-dom": "5.11.5",
|
||||
"@testing-library/react": "11.1.1",
|
||||
"@testing-library/user-event": "12.2.0",
|
||||
"@types/big.js": "6.1.1",
|
||||
"@types/d3": "7.4.3",
|
||||
"@types/debug": "4.1.5",
|
||||
"@types/file-saver": "2.0.1",
|
||||
"@types/google-protobuf": "3.15.10",
|
||||
"@types/history": "4.7.6",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/lodash": "4.14.157",
|
||||
"@types/node": "14.0.14",
|
||||
"@types/react": "17.0.13",
|
||||
"@types/react-dom": "17.0.8",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@types/react-virtualized": "9.21.10",
|
||||
"@types/reactour": "1.17.1",
|
||||
"@types/semver": "^7.3.9",
|
||||
"@typescript-eslint/eslint-plugin": "5.17.0",
|
||||
"@typescript-eslint/parser": "5.17.0",
|
||||
"cross-env": "7.0.2",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-prettier": "4.0.0",
|
||||
"eslint-plugin-react": "7.29.4",
|
||||
"google-protobuf": "3.14.0",
|
||||
"jest-canvas-mock": "2.3.0",
|
||||
"jest-environment-jsdom": "27.5.1",
|
||||
"prettier": "2.1.2",
|
||||
"protoc-gen-js": "3.21.2",
|
||||
"react-scripts": "^5.0.1",
|
||||
"sass": "1.43.4",
|
||||
"storybook": "7.5.3",
|
||||
"ts-protoc-gen": "0.15.0",
|
||||
"typescript": "4.1.6",
|
||||
"webpack": "5.89.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"strip-ansi": "6.0.1",
|
||||
"jackspeak": "2.1.1",
|
||||
"wrap-ansi": "7.0.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app",
|
||||
"ignorePatterns": [
|
||||
"src/types/generated/**/*.js"
|
||||
]
|
||||
},
|
||||
"jest": {
|
||||
"globalSetup": "./src/setupTestsGlobal.ts",
|
||||
"resetMocks": false,
|
||||
"collectCoverageFrom": [
|
||||
"src/**/*.{js,jsx,ts,tsx}",
|
||||
"!src/**/*.d.ts",
|
||||
"!src/__(stories|mocks)__/**/*.{ts,tsx}",
|
||||
"!src/types/**/*.{js,ts}",
|
||||
"!src/i18n/**/*.{js,ts}",
|
||||
"!src/util/tests/**/*.{ts,tsx}",
|
||||
"!src/setupProxy.js",
|
||||
"!src/index.tsx"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
buildGoModule,
|
||||
fetchFromGitHub,
|
||||
mkYarnPackage,
|
||||
nodejs,
|
||||
yarn,
|
||||
yarnConfigHook,
|
||||
yarnBuildHook,
|
||||
fetchYarnDeps,
|
||||
go,
|
||||
versionCheckHook,
|
||||
testers,
|
||||
curl,
|
||||
lightning-terminal,
|
||||
}:
|
||||
|
||||
buildGoModule rec {
|
||||
@@ -30,6 +37,18 @@ buildGoModule rec {
|
||||
|
||||
vendorHash = "sha256-Gbx4uz6q9Ef4QNv6DpIoCACjhT66iZ7GPNpd/g9MgKQ=";
|
||||
|
||||
buildInputs = [ lightning-app ];
|
||||
postUnpack = ''
|
||||
echo "Copying app build output into app/build dir to embed into litd."
|
||||
cp -r ${lightning-app}/* source/app/build/
|
||||
|
||||
echo "Asserting that app/build/index.html exists."
|
||||
if [ ! -f source/app/build/index.html ]; then
|
||||
echo "ERROR: app/build/index.html not found!"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
@@ -75,24 +94,59 @@ buildGoModule rec {
|
||||
versionCheckHook
|
||||
];
|
||||
|
||||
lightning-app = mkYarnPackage {
|
||||
passthru.tests.litd-app = testers.runCommand {
|
||||
name = "test-litd-app";
|
||||
nativeBuildInputs = [
|
||||
curl
|
||||
lightning-terminal
|
||||
];
|
||||
script = ''
|
||||
litd \
|
||||
--uipassword=12345678 \
|
||||
--insecure-httplisten=127.0.0.1:8080 \
|
||||
--httpslisten= &
|
||||
sleep 2
|
||||
GETindexHTTPCode=$(curl -o /dev/null -w "%{http_code}" -Lvs 127.0.0.1:8080/index.html)
|
||||
if [ "$GETindexHTTPCode" = 200 ]; then
|
||||
touch $out
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
lightning-app = stdenv.mkDerivation {
|
||||
pname = "lightning-app";
|
||||
src = "${src}/app";
|
||||
version = "0.0.1";
|
||||
packageJSON = ./package.json;
|
||||
yarnLock = "${src}/app/yarn.lock";
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnOfflineCache = fetchYarnDeps {
|
||||
yarnLock = "${src}/app/yarn.lock";
|
||||
hash = "sha256-ulOgKQRLG4cRi1N1DajmbZ0L7d08g5cYDA9itXu+Esw=";
|
||||
};
|
||||
|
||||
# Remove this command from package.json. It requires Git and it is not
|
||||
# really needed.
|
||||
postPatch = ''
|
||||
substituteInPlace package.json \
|
||||
--replace '"postbuild": "git restore build/.gitkeep",' ' '
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs
|
||||
yarn
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
# Disable linter. It finds a lot of proposed substitutions and fails.
|
||||
export DISABLE_ESLINT_PLUGIN=true
|
||||
export CI=false
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r build/* $out/
|
||||
'';
|
||||
};
|
||||
outputs = [
|
||||
"out"
|
||||
"app"
|
||||
];
|
||||
postFixup = ''
|
||||
ln -s ${lightning-app} "$app"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "All-in-one Lightning node management tool that includes LND, Loop, Pool, Faraday, and Tapd";
|
||||
@@ -101,6 +155,5 @@ buildGoModule rec {
|
||||
changelog = "https://github.com/lightninglabs/lightning-terminal/releases/tag/v${version}";
|
||||
maintainers = with lib.maintainers; [ HannahMR ];
|
||||
mainProgram = "litcli";
|
||||
outputsToInstall = [ "out" ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user