Convert project into a one package.json file structure

This commit is contained in:
Igor Gassmann 2017-11-28 21:29:59 -03:00
parent 1d9a5d90cf
commit 683f3e9f07
20 changed files with 6716 additions and 8912 deletions

View file

@ -3,7 +3,7 @@ current_version = 0.18.2
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+)(?P<candidate>\d+))?
serialize =
serialize =
{major}.{minor}.{patch}{release}{candidate}
{major}.{minor}.{patch}
@ -12,15 +12,11 @@ first_value = 1
[bumpversion:part:release]
optional_value = production
values =
values =
rc
production
[bumpversion:file:src/main/package.json]
search = "version": "{current_version}"
replace = "version": "{new_version}"
[bumpversion:file:src/renderer/package.json]
[bumpversion:file:package.json]
search = "version": "{current_version}"
replace = "version": "{new_version}"

View file

@ -2,7 +2,7 @@
host = https://www.transifex.com
[lbry-app.app-strings]
file_filter = src/main/dist/locales/<lang>.json
source_file = src/main/dist/locales/en.json
file_filter = dist/locales/<lang>.json
source_file = dist/locales/en.json
source_lang = en
type = KEYVALUEJSON
type = KEYVALUEJSON

View file

@ -29,11 +29,10 @@ This will download and install the LBRY app and its dependencies, including [the
### Running
Run `./node_modules/.bin/electron src/main`
Run `./node_modules/.bin/electron .`
### Ongoing Development
1. `cd src/renderer`
2. `./watch.sh`
`./watch.sh`
This will set up a monitor that will automatically compile any changes to JS or CSS folders inside of the `src/renderer` folder. This allows you to make changes and see them immediately by reloading the app.
@ -65,35 +64,21 @@ exit
python -m pip install -r build\requirements.txt
npm install -g yarn
yarn install
```
3. Change directory to `src\main` and run the following:
```
yarn install
node_modules\.bin\electron-rebuild
node_modules\.bin\electron-rebuild
cd ..\..
```
4. Change directory to `src\renderer` and run the following:
```
yarn install
npm rebuild node-sass
node node_modules\node-sass\bin\node-sass --output dist\css --sourcemap=none scss\
node_modules\.bin\webpack --config webpack.dev.config.js
xcopy /E dist ..\main\dist
cd ..\..
node_modules\.bin\node-sass --output dist\css --sourcemap=none src\renderer\scss\
node_modules\.bin\webpack --config src\renderer\webpack.prod.js
xcopy /E src\renderer\dist dist
```
4. Download the lbry daemon and cli [binaries](https://github.com/lbryio/lbry/releases) and place them in `src\main\dist\`
3. Download the lbry daemon and cli [binaries](https://github.com/lbryio/lbry/releases) and place them in `dist\`
### Building lbry-app
1. run `node_modules\.bin\build -p never` from the root of the project.
Run `node_modules\.bin\build -p never` from the root of the project.
### Running the electron app
1. Run `node_modules\.bin\electron src\main`
Run `node_modules\.bin\electron .`
### Ongoing Development
1. `cd src\renderer`
2. `watch.bat`
Run `watch.bat`
This will set up a monitor that will automatically compile any changes to JS or CSS folders inside of the `src\renderer` folder. This allows you to make changes and see them immediately by reloading the app.

View file

@ -5,41 +5,35 @@ Install-Product node $env:nodejs_version
npm install -g yarn
yarn install
# do app
cd src\main
yarn install
# necessary to ensure native Node modules (e.g. keytar) are built against the correct version of Node)
# yes, it needs to be run twice. it fails the first time, not sure why
node_modules\.bin\electron-rebuild
node_modules\.bin\electron-rebuild
cd ..\..
# clean dist\
if (Test-Path -Path dist\) {
Remove-Item -Recurse -Force dist\
}
New-Item -ItemType directory -Path dist\
# build ui
cd src\renderer
yarn install
npm rebuild node-sass
node_modules\.bin\node-sass --output dist\css --sourcemap=none scss\
node_modules\.bin\webpack --config webpack.prod.js
Copy-Item dist ..\main\ -recurse
cd ..\..
node src\renderer\extractLocals.js
node_modules\.bin\node-sass --output dist\css --sourcemap=none src\renderer\scss\
node_modules\.bin\webpack --config src\renderer\webpack.prod.js
Copy-Item src\renderer\dist dist -recurse
# get daemon and cli executable
$package_settings = (Get-Content src\main\package.json -Raw | ConvertFrom-Json).lbrySettings
$package_settings = (Get-Content package.json -Raw | ConvertFrom-Json).lbrySettings
$daemon_ver = $package_settings.lbrynetDaemonVersion
$daemon_url_template = $package_settings.lbrynetDaemonUrlTemplate
$daemon_url = $daemon_url_template.Replace('OSNAME', 'windows').Replace('DAEMONVER', $daemon_ver)
Invoke-WebRequest -Uri $daemon_url -OutFile daemon.zip
Expand-Archive daemon.zip -DestinationPath src\main\dist\
dir src\main\dist\ # verify that daemon binary is there
Expand-Archive daemon.zip -DestinationPath dist\
dir dist\ # verify that daemon binary is there
rm daemon.zip
# build electron app
node_modules\.bin\build -p never
$binary_name = Get-ChildItem -Path dist -Filter '*.exe' -Name
$binary_name = Get-ChildItem -Path dist -Filter 'LBRY Setup*.exe' -Name
$new_name = $binary_name -replace '^LBRY Setup (.*)\.exe$', 'LBRY_$1.exe'
Rename-Item -Path "dist\$binary_name" -NewName $new_name
dir dist # verify that binary was built/named correctly

View file

@ -41,8 +41,6 @@ fi
[ -d "$ROOT/dist" ] && rm -rf "$ROOT/dist"
mkdir -p "$ROOT/dist"
[ -d "$ROOT/src/main/dist" ] && rm -rf "$ROOT/src/main/dist"
mkdir -p "$ROOT/src/main/dist"
yarn install
@ -53,13 +51,11 @@ yarn install
############
echo -e "\033[0;32mCompiling UI\x1b[m"
(
cd "$ROOT/src/renderer"
yarn install
npm rebuild node-sass
node extractLocals.js
node_modules/.bin/node-sass --output dist/css --sourcemap=none scss/
node_modules/.bin/webpack --config webpack.prod.js
cp -r dist/* "$ROOT/src/main/dist/"
node src/renderer/extractLocals.js
node_modules/.bin/node-sass --output dist/css --sourcemap=none src/renderer/scss/
node_modules/.bin/webpack --config src/renderer/webpack.prod.js
cp -r src/renderer/dist/* "$ROOT/dist/"
)
@ -73,14 +69,14 @@ if $OSX; then
else
OSNAME="linux"
fi
DAEMON_VER=$(node -e "console.log(require(\"$ROOT/src/main/package.json\").lbrySettings.lbrynetDaemonVersion)")
DAEMON_URL_TEMPLATE=$(node -e "console.log(require(\"$ROOT/src/main/package.json\").lbrySettings.lbrynetDaemonUrlTemplate)")
DAEMON_VER=$(node -e "console.log(require(\"$ROOT/package.json\").lbrySettings.lbrynetDaemonVersion)")
DAEMON_URL_TEMPLATE=$(node -e "console.log(require(\"$ROOT/package.json\").lbrySettings.lbrynetDaemonUrlTemplate)")
DAEMON_URL=$(echo ${DAEMON_URL_TEMPLATE//DAEMONVER/$DAEMON_VER} | sed "s/OSNAME/$OSNAME/g")
DAEMON_VER_PATH="$BUILD_DIR/daemon.ver"
echo "$DAEMON_VER_PATH"
if [[ ! -f $DAEMON_VER_PATH || ! -f $ROOT/src/main/dist/lbrynet-daemon || "$(< "$DAEMON_VER_PATH")" != "$DAEMON_VER" ]]; then
if [[ ! -f $DAEMON_VER_PATH || ! -f $ROOT/dist/lbrynet-daemon || "$(< "$DAEMON_VER_PATH")" != "$DAEMON_VER" ]]; then
curl -sL -o "$BUILD_DIR/daemon.zip" "$DAEMON_URL"
unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/src/main/dist/"
unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/dist/"
rm "$BUILD_DIR/daemon.zip"
echo "$DAEMON_VER" > "$DAEMON_VER_PATH"
else
@ -93,20 +89,6 @@ fi
###################
# Build the app #
###################
echo -e '\033[0;32mBuilding Lbry-app\x1b[m'
(
cd "$ROOT/src/main"
yarn install
# necessary to ensure native Node modules (e.g. keytar) are built against the correct version of Node)
# yes, it needs to be run twice. it fails the first time, not sure why
set +e
# DEBUG=electron-rebuild node_modules/.bin/electron-rebuild .
node_modules/.bin/electron-rebuild "$ROOT/src/main"
set -e
node_modules/.bin/electron-rebuild "$ROOT/src/main"
)
if [ "$FULL_BUILD" == "true" ]; then
if $OSX; then
security unlock-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain
@ -133,5 +115,5 @@ if [ "$FULL_BUILD" == "true" ]; then
echo -e '\033[0;32mBuild and packaging complete.\x1b[m'
else
echo -e 'Build complete. Run \033[1;31m./node_modules/.bin/electron src/main\x1b[m to launch the app'
echo -e 'Build complete. Run \033[1;31m./node_modules/.bin/electron .\x1b[m to launch the app'
fi

View file

@ -17,7 +17,7 @@ import github
import changelog
ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
APP_PACKAGE_JSON_FILE = os.path.join(ROOT, 'src', 'main', 'package.json')
APP_PACKAGE_JSON_FILE = os.path.join(ROOT, 'package.json')
def main():

View file

@ -1,9 +1,33 @@
{
"postinstall": "install-app-deps",
"name": "LBRY",
"version": "0.18.2",
"description": "A browser for the LBRY network, a digital marketplace controlled by its users.",
"author": {
"name": "LBRY Inc.",
"email": "hello@lbry.io"
},
"homepage": "https://lbry.io/",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack-dev-server --devtool eval --progress --colors --inline",
"precommit": "lint-staged",
"prettier": "prettier --trailing-comma es5 --write js/**/*.{js,jsx}",
"extract-langs": "node extractLocals.js"
},
"main": "src/main/main.js",
"repository": {
"type": "git",
"url": "https://github.com/lbryio/lbry-app"
},
"bugs": {
"url": "https://github.com/lbryio/lbry-app/issues"
},
"keywords": [
"lbry"
],
"build": {
"asar": false,
"directories": {
"app": "src/main"
"app": "."
},
"appId": "io.lbry.LBRY",
"mac": {
@ -66,12 +90,82 @@
"perMachine": true
}
},
"dependencies": {
"electron-dl": "^1.6.0",
"install": "^0.8.7",
"jayson": "^2.0.2",
"keytar": "^4.0.3",
"npm": "^4.2.0",
"semver": "^5.3.0",
"tree-kill": "^1.1.0",
"from2": "^2.3.0",
"jshashes": "^1.0.7",
"localforage": "^1.5.0",
"node-sass": "^4.5.3",
"rc-progress": "^2.0.6",
"react": "^15.4.0",
"react-dom": "^15.4.0",
"react-markdown": "^2.5.0",
"react-modal": "^1.5.2",
"react-paginate": "^4.4.3",
"react-redux": "^5.0.3",
"react-simplemde-editor": "^3.6.11",
"redux": "^3.6.0",
"redux-action-buffer": "^1.1.0",
"redux-logger": "^3.0.1",
"redux-persist": "^4.8.0",
"redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.10",
"redux-thunk": "^2.2.0",
"render-media": "^2.10.0",
"reselect": "^3.0.0",
"y18n": "^3.2.1"
},
"devDependencies": {
"devtron": "^1.4.0",
"electron": "^1.7.9",
"electron-builder": "^11.7.0",
"electron-debug": "^1.4.0",
"electron-devtools-installer": "^2.2.1"
"electron-devtools-installer": "^2.2.1",
"babel": "^6.5.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.18.2",
"babel-loader": "^7.1.1",
"babel-plugin-react-require": "^3.0.0",
"babel-polyfill": "^6.20.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.18.0",
"css-loader": "^0.28.4",
"eslint": "^3.10.2",
"eslint-config-airbnb": "^13.0.0",
"eslint-loader": "^1.6.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.7.1",
"husky": "^0.13.4",
"i18n-extract": "^0.4.4",
"json-loader": "^0.5.4",
"lint-staged": "^3.6.0",
"node-loader": "^0.6.0",
"prettier": "^1.4.2",
"style-loader": "^0.18.2",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.4.4",
"webpack-merge": "^4.1.1",
"webpack-notifier": "^1.5.0",
"webpack-target-electron-renderer": "^0.4.0"
},
"license": "MIT"
"postinstall": "install-app-deps",
"license": "MIT",
"lint-staged": {
"src/renderer/js/**/*.{jsx,js}": [
"prettier --trailing-comma es5 --write",
"git add"
]
},
"lbrySettings": {
"lbrynetDaemonVersion": "0.18.0",
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip"
}
}

0
src/common/.gitkeep Normal file
View file

View file

@ -39,7 +39,7 @@ if (isDebug) {
// Misc constants
const LATEST_RELEASE_API_URL = 'https://api.github.com/repos/lbryio/lbry-app/releases/latest';
const DAEMON_PATH = process.env.LBRY_DAEMON || path.join(__dirname, 'dist', 'lbrynet-daemon');
const DAEMON_PATH = process.env.LBRY_DAEMON || path.join(app.getAppPath(), 'dist', 'lbrynet-daemon');
let client = jayson.client.http({
host: 'localhost',
@ -178,7 +178,7 @@ function createWindow () {
if (isDebug) {
win.webContents.openDevTools();
}
win.loadURL(`file://${__dirname}/dist/index.html`)
win.loadURL(`file://${app.getAppPath()}/dist/index.html`)
if (openUri) { // We stored and received a URI that an external app requested before we had a window object
win.webContents.on('did-finish-load', () => {
win.webContents.send('open-uri-requested', openUri);
@ -240,7 +240,7 @@ function createTray () {
if (process.platform === 'darwin') {
// Using @2x for mac retina screens so the icon isn't blurry
// file name needs to include "Template" at the end for dark menu bar
iconPath = path.join(app.getAppPath(), "/dist/img/fav/macTemplate@2x.png");
iconPath = path.join(app.getAppPath(), "/dist/img/fav/macTemplate@2x.png");
} else {
iconPath = path.join(app.getAppPath(), "/dist/img/fav/32x32.png");
}
@ -315,7 +315,7 @@ function handleDaemonSubprocessExited() {
// TODO: maybe it would be better to restart the daemon?
if (win) {
console.log('Did not request daemon stop, so quitting in 5 seconds.');
win.loadURL(`file://${__dirname}/dist/warning.html`);
win.loadURL(`file://${app.getAppPath()}/dist/warning.html`);
setTimeout(quitNow, 5000);
} else {
console.log('Did not request daemon stop, so quitting.');
@ -507,7 +507,7 @@ function upgrade(event, installerPath) {
});
if (win) {
win.loadURL(`file://${__dirname}/dist/upgrade.html`);
win.loadURL(`file://${app.getAppPath()}/dist/upgrade.html`);
}
shutdownDaemonAndQuit(true);
@ -554,4 +554,4 @@ ipcMain.on('get-auth-token', (event) => {
ipcMain.on('set-auth-token', (event, token) => {
keytar.setPassword("LBRY", "auth_token", token ? token.toString().trim() : null);
});
});

View file

@ -1,28 +0,0 @@
{
"name": "LBRY",
"version": "0.18.2",
"main": "main.js",
"description": "A browser for the LBRY network, a digital marketplace controlled by its users.",
"homepage": "https://github.com/lbryio/lbry-app",
"author": {
"name": "LBRY Inc.",
"email": "hello@lbry.io"
},
"dependencies": {
"electron-dl": "^1.6.0",
"install": "^0.8.7",
"jayson": "^2.0.2",
"keytar": "^4.0.3",
"npm": "^4.2.0",
"semver": "^5.3.0",
"tree-kill": "^1.1.0"
},
"devDependencies": {
"electron-rebuild": "^1.5.11"
},
"lbrySettings": {
"lbrynetDaemonVersion": "0.18.0",
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip"
},
"license": "MIT"
}

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
var extract = require("i18n-extract");
const fs = require("fs");
var dir = __dirname + "/../main/dist/locales";
var dir = __dirname + "/../../dist/locales";
var path = dir + "/en.json";
if (!fs.existsSync(dir)) {

View file

@ -20,7 +20,7 @@ const { remote, ipcRenderer, shell } = require("electron");
const path = require("path");
const { download } = remote.require("electron-dl");
const fs = remote.require("fs");
const { lbrySettings: config } = require("../../../../main/package.json");
const { lbrySettings: config } = require("../../../../../package.json");
const CHECK_UPGRADE_INTERVAL = 10 * 60 * 1000;
export function doOpenModal(modal, modalProps = {}) {

View file

@ -1,86 +0,0 @@
{
"name": "lbry-web-ui",
"version": "0.18.2",
"description": "LBRY UI",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack-dev-server --devtool eval --progress --colors --inline",
"precommit": "lint-staged",
"prettier": "prettier --trailing-comma es5 --write js/**/*.{js,jsx}",
"extract-langs": "node extractLocals.js"
},
"keywords": [
"lbry"
],
"author": {
"name": "LBRY Inc.",
"email": "hello@lbry.io"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/lbryio/lbry-app/issues"
},
"homepage": "https://github.com/lbryio/lbry-app",
"dependencies": {
"from2": "^2.3.0",
"jshashes": "^1.0.7",
"localforage": "^1.5.0",
"node-sass": "^4.5.3",
"rc-progress": "^2.0.6",
"react": "^15.4.0",
"react-dom": "^15.4.0",
"react-markdown": "^2.5.0",
"react-modal": "^1.5.2",
"react-paginate": "^4.4.3",
"react-redux": "^5.0.3",
"react-simplemde-editor": "^3.6.11",
"redux": "^3.6.0",
"redux-action-buffer": "^1.1.0",
"redux-logger": "^3.0.1",
"redux-persist": "^4.8.0",
"redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.10",
"redux-thunk": "^2.2.0",
"render-media": "^2.10.0",
"reselect": "^3.0.0",
"y18n": "^3.2.1"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.18.2",
"babel-loader": "^7.1.1",
"babel-plugin-react-require": "^3.0.0",
"babel-polyfill": "^6.20.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.18.0",
"css-loader": "^0.28.4",
"electron-rebuild": "^1.5.11",
"eslint": "^3.10.2",
"eslint-config-airbnb": "^13.0.0",
"eslint-loader": "^1.6.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.7.1",
"husky": "^0.13.4",
"i18n-extract": "^0.4.4",
"json-loader": "^0.5.4",
"lint-staged": "^3.6.0",
"node-loader": "^0.6.0",
"prettier": "^1.4.2",
"style-loader": "^0.18.2",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.4.4",
"webpack-merge": "^4.1.1",
"webpack-notifier": "^1.5.0",
"webpack-target-electron-renderer": "^0.4.0"
},
"lint-staged": {
"gitDir": "../..",
"src/renderer/js/**/*.{jsx,js}": [
"prettier --trailing-comma es5 --write",
"git add"
]
}
}

View file

@ -1,11 +0,0 @@
@echo off
set found=
for %%F in (
"%~dp0\node_modules\node-sass\bin\node-sass"
"%~dp0\node_modules\.bin\webpack"
) do if exist %%F (set found=1)
if not defined found EXIT
node %~dp0\node_modules\node-sass\bin\node-sass --output %~dp0\..\main\dist\css --sourcemap=none %~dp0\scss
%~dp0\node_modules\.bin\webpack --config %~dp0\webpack.dev.js --progress --colors --watch

View file

@ -10,7 +10,7 @@ const PATHS = {
};
module.exports = {
entry: ["babel-polyfill", "./js/main.js"],
entry: ["babel-polyfill", "./src/renderer/js/main.js"],
output: {
path: path.join(PATHS.dist, "js"),
publicPath: "/js/",

File diff suppressed because it is too large Load diff

11
watch.bat Normal file
View file

@ -0,0 +1,11 @@
@echo off
set found=
for %%F in (
"%~dp0\node_modules\node-sass\bin\node-sass"
"%~dp0\node_modules\.bin\webpack"
) do if exist %%F (set found=1)
if not defined found EXIT
node %~dp0\node_modules\node-sass\bin\node-sass --output %~dp0\dist\css --sourcemap=none %~dp0\src\renderer\scss
%~dp0\node_modules\.bin\webpack --config %~dp0\src\renderer\webpack.dev.js --progress --colors --watch

View file

@ -18,8 +18,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
# run sass once without --watch to force update. then run with --watch to keep watching
node_modules/.bin/node-sass --output $DIR/../main/dist/css --sourcemap=none $DIR/scss/
node_modules/.bin/node-sass --output $DIR/../main/dist/css --sourcemap=none --watch $DIR/scss/ &
node_modules/.bin/node-sass --output $DIR/dist/css --sourcemap=none $DIR/src/renderer/scss/
node_modules/.bin/node-sass --output $DIR/dist/css --sourcemap=none --watch $DIR/src/renderer/scss/ &
node_modules/.bin/webpack --config webpack.dev.js --progress --colors --watch
)
node_modules/.bin/webpack --config $DIR/src/renderer/webpack.dev.js --progress --colors --watch
)

6613
yarn.lock

File diff suppressed because it is too large Load diff