babel build

This commit is contained in:
Evert Prants 2018-10-18 18:34:47 +03:00
parent 051f95fee7
commit 16def1ccab
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
8 changed files with 24 additions and 17 deletions

View File

@ -1,13 +1,14 @@
{
"presets": [
"env",
"react",
"stage-0"
],
"plugins": [
"transform-class-properties",
"transform-decorators",
"transform-react-constant-elements",
"transform-react-inline-elements"
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
]
}

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
*.db
*.bak
tmp.*
values.json
/node_modules/
/dist/
/package-lock.json

View File

@ -3,16 +3,23 @@
"version": "1.0.0",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src -d dist",
"start": "node dist/server.js",
"download": "node dist/download.js",
"populate": "node dist/dbpopulate.js"
},
"private": true,
"dependencies": {
"babel-core": "^6.26.3",
"babel-env": "^2.4.1",
"bluebird": "^3.5.2",
"express": "^4.16.3",
"express-async-errors": "^3.0.0",
"fs-extra": "^7.0.0",
"sqlite": "^3.0.0"
"sqlite": "^3.0.0",
"babel-plugin-transform-runtime": "^6.23.0"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-env": "^2.4.1"
}
}

View File

@ -56,7 +56,7 @@ function getVideoInfo (arg) {
function fetchVideo (data) {
return new Promise((resolve, reject) => {
if (data.acodec !== 'mp3' || data.vcodec !== 'none') {
let tempName = path.join(__dirname, `/tmp.yt.${data.id}.mp3`)
let tempName = path.join(process.cwd(), `/tmp.yt.${data.id}.mp3`)
let ffmpeg = spawn('ffmpeg', ['-hide_banner', '-i', data.url, '-codec:a', 'libmp3lame', '-q:a', 2, '-joint_stereo', 1, '-y', tempName])
ffmpeg.stdout.pipe(process.stderr)

5
dbpopulate.js → src/dbpopulate.js Executable file → Normal file
View File

@ -1,4 +1,3 @@
#!/usr/bin/env babel-node
import fs from 'fs-extra'
import path from 'path'
import sqlite from 'sqlite'
@ -8,11 +7,11 @@ import readline from 'readline'
import asn from './common/async'
import dl from './common/download'
const values = require(path.join(__dirname, 'values.json'))
const values = require(path.join(process.cwd(), 'values.json'))
const musicdir = path.resolve(values.directory)
const dbPromise = Promise.resolve()
.then(() => sqlite.open(path.join(__dirname, values.database), { Promise, cache: true }))
.then(() => sqlite.open(path.join(process.cwd(), values.database), { Promise, cache: true }))
.then(db => db.migrate())
// ffprobe -i <file> -show_entries format=duration -v quiet -of csv="p=0"

3
download.js → src/download.js Executable file → Normal file
View File

@ -1,4 +1,3 @@
#!/usr/bin/env babel-node
'use strict'
import fs from 'fs-extra'
@ -8,7 +7,7 @@ import path from 'path'
import asn from './common/async'
import dl from './common/download'
const values = require(path.join(__dirname, 'values.json'))
const values = require(path.join(process.cwd(), 'values.json'))
const musicdir = path.resolve(values.directory)
const rl = readline.createInterface({

7
server.js → src/server.js Executable file → Normal file
View File

@ -1,4 +1,3 @@
#!/usr/bin/env babel-node
import path from 'path'
import sqlite from 'sqlite'
import Promise from 'bluebird'
@ -6,11 +5,11 @@ import express from 'express'
require('express-async-errors')
const values = require(path.join(__dirname, 'values.json'))
const values = require(path.join(process.cwd(), 'values.json'))
const tracksPerPage = 100
const dbPromise = Promise.resolve()
.then(() => sqlite.open(path.join(__dirname, values.database), { Promise, cache: true }))
.then(() => sqlite.open(path.join(process.cwd(), values.database), { Promise, cache: true }))
.then(db => db.migrate())
const app = express()
@ -151,7 +150,7 @@ router.use((err, req, res, next) => {
app.use('/api', router)
app.use('/file/track', express.static(path.resolve(values.directory)))
app.use('/', express.static(path.join(__dirname, 'public')))
app.use('/', express.static(path.join(process.cwd(), 'public')))
app.listen(port, '127.0.0.1', function () {
console.log(`app running on port ${port}`)