2020-11-23 21:45:01 +01:00
|
|
|
import { promisify } from 'util'
|
|
|
|
import childProcessPromise from 'child-process-promise'
|
|
|
|
import path from 'path'
|
|
|
|
import fs from 'fs'
|
2021-07-05 05:19:04 +02:00
|
|
|
import { envFile, RUBY_VERSION } from './mastodon-config.js'
|
|
|
|
import esMain from 'es-main'
|
2020-11-23 21:45:01 +01:00
|
|
|
|
|
|
|
const exec = childProcessPromise.exec
|
|
|
|
const stat = promisify(fs.stat)
|
|
|
|
const writeFile = promisify(fs.writeFile)
|
2021-07-05 05:19:04 +02:00
|
|
|
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
2020-11-23 21:45:01 +01:00
|
|
|
const dir = __dirname
|
|
|
|
|
2021-06-06 22:16:25 +02:00
|
|
|
const GIT_URL = 'https://github.com/tootsuite/mastodon.git'
|
2022-04-30 23:38:37 +02:00
|
|
|
const GIT_TAG = 'v3.5.1'
|
2020-11-23 21:45:01 +01:00
|
|
|
|
|
|
|
const mastodonDir = path.join(dir, '../mastodon')
|
|
|
|
|
|
|
|
export default async function cloneMastodon () {
|
|
|
|
try {
|
|
|
|
await stat(mastodonDir)
|
|
|
|
} catch (e) {
|
|
|
|
console.log('Cloning mastodon...')
|
2020-11-24 01:29:03 +01:00
|
|
|
await exec(`git clone --single-branch --branch ${GIT_TAG} ${GIT_URL} "${mastodonDir}"`)
|
2020-11-23 21:45:01 +01:00
|
|
|
await writeFile(path.join(dir, '../mastodon/.env'), envFile, 'utf8')
|
2021-01-25 03:26:40 +01:00
|
|
|
await writeFile(path.join(dir, '../mastodon/.ruby-version'), RUBY_VERSION, 'utf8')
|
2020-11-23 21:45:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-05 05:19:04 +02:00
|
|
|
if (esMain(import.meta)) {
|
2020-11-23 21:45:01 +01:00
|
|
|
cloneMastodon().catch(err => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
|
|
|
}
|