1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/distbin_ynh.git synced 2024-09-03 18:26:10 +02:00

Merge pull request #13 from YunoHost-Apps/testing

Cleanup and improvements
This commit is contained in:
yalh76 2019-02-03 11:04:03 +01:00 committed by GitHub
commit c6ebcb3849
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 99 deletions

View file

@ -1,68 +0,0 @@
{
"name": "distbin",
"version": "1.0.0",
"description": "Post bin with distributed social features.",
"main": "src",
"directories": {
"test": "test"
},
"dependencies": {
"@types/accepts": "^1.3.5",
"@types/dompurify": "0.0.31",
"@types/jsdom": "^11.0.5",
"@types/lodash": "^4.14.85",
"@types/marked": "^0.3.0",
"@types/morgan": "^1.7.35",
"@types/node-uuid": "0.0.28",
"@types/parse-link-header": "^1.0.0",
"@types/winston": "^2.3.7",
"accepts": "^1.3.3",
"dompurify": "^0.8.4",
"hoek": "^4.2.1",
"jsdom": "^9.9.1",
"jsonld": "^0.4.11",
"jsonld-rdfa-parser": "^1.5.1",
"lodash": "^4.17.4",
"marked": "^0.3.19",
"morgan": "^1.9.1",
"node-fetch": "^1.6.3",
"node-uuid": "^1.4.7",
"parse-link-header": "^0.4.1",
"portfinder": "^1.0.13",
"uuid": "^3.1.0",
"winston": "^2.4.0"
},
"devDependencies": {
"@types/node": "^8.10.19",
"@types/node-fetch": "^2.1.1",
"copyfiles": "^1.2.0",
"eslint": "^3.7.1",
"eslint-config-standard": "^6.2.0",
"eslint-plugin-no-only-tests": "^2.0.0",
"eslint-plugin-promise": "^3.0.0",
"eslint-plugin-standard": "^2.0.1",
"ts-node": "^6.2.0",
"tsc-watch": "^1.0.22",
"tslint": "^5.10.0",
"typescript": "^2.9.2",
"typescript-eslint-parser": "^8.0.1"
},
"peerDependencies": {
"hoek": "^4.2.1"
},
"config": {
"port": __PORT__
},
"scripts": {
"lint": "tslint -c tslint.json 'src/**/*.ts' 'test/**/*.ts' 'bin/**/*.ts'",
"lint-fix": "tslint --fix -c tslint.json 'src/**/*.ts' 'test/**/*.ts' 'bin/**/*.ts'",
"test": "ts-node test",
"start": "node ./dist/bin/server",
"start-dev": "tsc-watch --onSuccess 'npm start'",
"tsc": "tsc",
"build": "tsc && npm run build.copyfiles",
"build.copyfiles": "copyfiles './src/**/*.json' dist/"
},
"author": "",
"license": "ISC"
}

View file

@ -8,6 +8,8 @@ User=__APP__
Group=__APP__
Environment="PATH=__NODEJS_PATH__"
Environment="PORT=__PORT__"
Environment="DB_DIR=__FINALPATH__/db"
Environment="NODE_ENV=production"
WorkingDirectory=__FINALPATH__/
ExecStart=/bin/sh -c '__FINALPATH__/node_modules/.bin/ts-node --project __FINALPATH__/tsconfig.json __FINALPATH__/bin/server.ts >> /var/log/__APP__/__APP__.log 2>&1'

View file

@ -6,7 +6,7 @@
"en": "Distributed pastebin with ActivityPub.",
"fr": "Pastebin distribué utilisant le protocole ActivityPub."
},
"version": "1.0~ynh1",
"version": "1.0~ynh2",
"url": "https://example.com",
"license": "Apache-2.0",
"maintainer": {

View file

@ -16,6 +16,7 @@ source /usr/share/yunohost/helpers
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
read -p "Press any key..."
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
@ -97,10 +98,10 @@ ynh_app_setting_set $app port $port
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
#ynh_install_app_dependencies deb1 deb2
ynh_install_nodejs 8
#ynh_install_app_dependencies
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
@ -174,18 +175,23 @@ ynh_system_user_create "$app" "$final_path"
mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app"
#=================================================
# CREATE DB FOLDER
#=================================================
mkdir -p "$final_path/db"
#=================================================
# MAKE SETUP
#=================================================
chown -R "$app":"$app" "$final_path"
pushd $final_path
ynh_use_nodejs
sudo -u $app env PATH=$PATH:$nodejs_path npm install hoek@^4.2.1 --save
sudo -u $app env PATH=$PATH:$nodejs_path npm install typescript@>=2.0 --save
sudo -u $app env PATH=$PATH:$nodejs_path npm install ts-node
sudo -u $app env PATH=$PATH:$nodejs_path npm install
sudo -u $app env PATH=$PATH:$nodejs_path npm audit fix
ynh_use_nodejs
sudo -u $app env PATH=$PATH:$nodejs_path npm add hoek@^4.2.1 --save --production
sudo -u $app env PATH=$PATH:$nodejs_path npm install ts-node
sudo -u $app env PATH=$PATH:$nodejs_path npm install --production
sudo -u $app env PATH=$PATH:$nodejs_path npm audit fix
popd
#=================================================

View file

@ -46,9 +46,9 @@ ynh_remove_systemd_config
#=================================================
# Remove metapackage and its dependencies
#ynh_remove_app_dependencies
ynh_use_nodejs
ynh_remove_nodejs
ynh_remove_app_dependencies
#=================================================
# REMOVE THE MYSQL DATABASE
@ -61,10 +61,6 @@ ynh_remove_nodejs
# REMOVE APP MAIN DIR
#=================================================
# remove tmp files
sudo -u $app rm -rf /tmp/*
ynh_secure_remove "/var/tmp/*"
# Remove the app directory securely
ynh_secure_remove "$final_path"
@ -105,9 +101,6 @@ fi
# REMOVE THE CRON FILE
#=================================================
#npm uninstall -g ts-node
#npm uninstall -g typescript
# Remove a cron file
#ynh_secure_remove "/etc/cron.d/$app"

View file

@ -92,11 +92,10 @@ chown -R $app:$app /var/log/$app
# REINSTALL DEPENDENCIES
#=================================================
# Define and install dependencies
#ynh_install_app_dependencies deb1 deb2
ynh_install_nodejs 8
#ynh_install_app_dependencies
#=================================================
# RESTORE SYSTEMD
#=================================================

View file

@ -85,7 +85,10 @@ path_url=$(ynh_normalize_url_path $path_url)
# Download, check integrity, uncompress and patch the source from app.src#
#ynh_setup_source "$final_path"
(cd $final_path && git pull)
pushd $final_path
git pull
popd
#=================================================
# NGINX CONFIGURATION
@ -98,10 +101,10 @@ ynh_add_nginx_config
# UPGRADE DEPENDENCIES
#=================================================
#ynh_install_app_dependencies deb1 deb2
ynh_install_nodejs 8
#ynh_install_app_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -119,18 +122,23 @@ ynh_system_user_create "$app" "$final_path"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
# CREATE DB FOLDER
#=================================================
mkdir -p "$final_path/db"
#=================================================
# MAKE INSTALL
#=================================================
chown -R "$app":"$app" "$final_path"
pushd $final_path
ynh_use_nodejs
sudo -u $app env PATH=$PATH:$nodejs_path npm install hoek@^4.2.1 --save
sudo -u $app env PATH=$PATH:$nodejs_path npm install typescript@>=2.0 --save
sudo -u $app env PATH=$PATH:$nodejs_path npm install ts-node
sudo -u $app env PATH=$PATH:$nodejs_path npm install
sudo -u $app env PATH=$PATH:$nodejs_path npm audit fix
ynh_use_nodejs
sudo -u $app env PATH=$PATH:$nodejs_path npm update --production
sudo -u $app env PATH=$PATH:$nodejs_path npm install --production
sudo -u $app env PATH=$PATH:$nodejs_path npm audit fix
popd
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.