update scripts
This commit is contained in:
parent
9872f6073e
commit
5c38554a38
|
@ -1,8 +1,8 @@
|
||||||
const times = require('lodash/times')
|
import times from 'lodash/times'
|
||||||
|
|
||||||
export const actions = times(30, i => ({
|
export const actions = times(30, i => ({
|
||||||
post: {
|
post: {
|
||||||
text: (i + 1)
|
text: '' + (i + 1)
|
||||||
},
|
},
|
||||||
user: 'admin'
|
user: 'admin'
|
||||||
})).concat([
|
})).concat([
|
||||||
|
@ -95,6 +95,14 @@ export const actions = times(30, i => ({
|
||||||
user: 'quux',
|
user: 'quux',
|
||||||
follow: 'foobar'
|
follow: 'foobar'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
user: 'admin',
|
||||||
|
follow: 'quux'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
user: 'foobar',
|
||||||
|
follow: 'quux'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
user: 'admin',
|
user: 'admin',
|
||||||
post: {
|
post: {
|
||||||
|
@ -139,10 +147,6 @@ export const actions = times(30, i => ({
|
||||||
privacy: 'private'
|
privacy: 'private'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
user: 'admin',
|
|
||||||
boost: 2
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
user: 'admin',
|
user: 'admin',
|
||||||
favorite: 2
|
favorite: 2
|
||||||
|
@ -180,10 +184,6 @@ export const actions = times(30, i => ({
|
||||||
user: 'quux',
|
user: 'quux',
|
||||||
pin: 6
|
pin: 6
|
||||||
},
|
},
|
||||||
{
|
|
||||||
user: 'admin',
|
|
||||||
boost: 5
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
user: 'admin',
|
user: 'admin',
|
||||||
favorite: 5
|
favorite: 5
|
||||||
|
|
|
@ -5,16 +5,20 @@ import { uploadMedia } from '../routes/_api/media'
|
||||||
import { followAccount } from '../routes/_api/follow'
|
import { followAccount } from '../routes/_api/follow'
|
||||||
import { favoriteStatus } from '../routes/_api/favorite'
|
import { favoriteStatus } from '../routes/_api/favorite'
|
||||||
import { reblogStatus } from '../routes/_api/reblog'
|
import { reblogStatus } from '../routes/_api/reblog'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
|
import FileApi from 'file-api'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
global.File = require('file-api').File
|
|
||||||
global.FormData = require('file-api').FormData
|
|
||||||
global.fetch = require('node-fetch')
|
|
||||||
|
|
||||||
async function restoreMastodonData () {
|
global.File = FileApi.File
|
||||||
|
global.FormData = FileApi.FormData
|
||||||
|
global.fetch = fetch
|
||||||
|
|
||||||
|
export async function restoreMastodonData () {
|
||||||
|
debugger
|
||||||
console.log('Restoring mastodon data...')
|
console.log('Restoring mastodon data...')
|
||||||
let internalIdsToIds = {}
|
let internalIdsToIds = {}
|
||||||
for (let action of actions) {
|
for (let action of actions) {
|
||||||
|
console.log(JSON.stringify(action))
|
||||||
let accessToken = users[action.user].accessToken
|
let accessToken = users[action.user].accessToken
|
||||||
if (action.post) {
|
if (action.post) {
|
||||||
let { text, media, sensitive, spoiler, privacy, inReplyTo, internalId } = action.post
|
let { text, media, sensitive, spoiler, privacy, inReplyTo, internalId } = action.post
|
||||||
|
@ -32,13 +36,16 @@ async function restoreMastodonData () {
|
||||||
internalIdsToIds[internalId] = status.id
|
internalIdsToIds[internalId] = status.id
|
||||||
}
|
}
|
||||||
} else if (action.follow) {
|
} else if (action.follow) {
|
||||||
await followAccount('localhost:3000', accessToken, action.follow)
|
await followAccount('localhost:3000', accessToken, users[action.follow].id)
|
||||||
} else if (action.favorite) {
|
} else if (action.favorite) {
|
||||||
await favoriteStatus('localhost:3000', accessToken, internalIdsToIds[action.favorite])
|
await favoriteStatus('localhost:3000', accessToken, internalIdsToIds[action.favorite])
|
||||||
} else if (action.boost) {
|
} else if (action.boost) {
|
||||||
await reblogStatus('localhost:3000', accessToken, internalIdsToIds[action.favorite])
|
await reblogStatus('localhost:3000', accessToken, internalIdsToIds[action.boost])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = restoreMastodonData
|
restoreMastodonData().catch(err => {
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
|
@ -1,14 +1,16 @@
|
||||||
const restoreMastodonData = require('./restore-mastodon-data')
|
import { restoreMastodonData } from './restore-mastodon-data'
|
||||||
const pify = require('pify')
|
import pify from 'pify'
|
||||||
const exec = require('child-process-promise').exec
|
import childProcessPromise from 'child-process-promise'
|
||||||
const spawn = require('child-process-promise').spawn
|
import path from 'path'
|
||||||
const dir = __dirname
|
import fs from 'fs'
|
||||||
const path = require('path')
|
import { waitForMastodonToStart } from './wait-for-mastodon-to-start'
|
||||||
const fs = require('fs')
|
|
||||||
|
const exec = childProcessPromise.exec
|
||||||
|
const spawn = childProcessPromise.spawn
|
||||||
|
const mkdirp = pify(mkdirpCB)
|
||||||
const stat = pify(fs.stat.bind(fs))
|
const stat = pify(fs.stat.bind(fs))
|
||||||
const writeFile = pify(fs.writeFile.bind(fs))
|
const writeFile = pify(fs.writeFile.bind(fs))
|
||||||
const mkdirp = pify(require('mkdirp'))
|
const dir = __dirname
|
||||||
const waitForMastodonToStart = require('./wait-for-mastodon-to-start')
|
|
||||||
|
|
||||||
const envFile = `
|
const envFile = `
|
||||||
PAPERCLIP_SECRET=foo
|
PAPERCLIP_SECRET=foo
|
||||||
|
@ -71,9 +73,9 @@ async function runMastodon () {
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
await cloneMastodon()
|
await cloneMastodon()
|
||||||
//await setupMastodonDatabase()
|
await setupMastodonDatabase()
|
||||||
await runMastodon()
|
await runMastodon()
|
||||||
//await restoreMastodonData()
|
await restoreMastodonData()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('SIGINT', function () {
|
process.on('SIGINT', function () {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const fetch = require('node-fetch')
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
async function waitForMastodonToStart () {
|
export async function waitForMastodonToStart () {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
|
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
|
||||||
|
@ -16,8 +16,6 @@ async function waitForMastodonToStart () {
|
||||||
console.log('Mastodon started up')
|
console.log('Mastodon started up')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = waitForMastodonToStart
|
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
waitForMastodonToStart().catch(err => {
|
waitForMastodonToStart().catch(err => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
|
|
@ -109,6 +109,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"@std/esm": {
|
"@std/esm": {
|
||||||
"mode": "js"
|
"mode": "js",
|
||||||
|
"cjs": "vars"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,25 @@ export const users = {
|
||||||
admin: {
|
admin: {
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password: 'mastodonadmin',
|
password: 'mastodonadmin',
|
||||||
accessToken: '1a62cc93aa6ccdad5a1048bd37b627c9df72f68c7f4b87d2daaeb83010ff44ab'
|
accessToken: '1a62cc93aa6ccdad5a1048bd37b627c9df72f68c7f4b87d2daaeb83010ff44ab',
|
||||||
|
id: 1
|
||||||
},
|
},
|
||||||
foobar: {
|
foobar: {
|
||||||
username: 'foobar',
|
username: 'foobar',
|
||||||
password: 'foobarfoobar',
|
password: 'foobarfoobar',
|
||||||
accessToken: '67868cd5b1f1279697ffffdb44c144b0ae427d74f4540717b67bf4a9c5c5c346'
|
accessToken: '67868cd5b1f1279697ffffdb44c144b0ae427d74f4540717b67bf4a9c5c5c346',
|
||||||
|
id: 2
|
||||||
},
|
},
|
||||||
quux: {
|
quux: {
|
||||||
username: 'quux',
|
username: 'quux',
|
||||||
password: 'quuxquuxquux',
|
password: 'quuxquuxquux',
|
||||||
accessToken: 'd100083c1749392da7e1c12e63a6fba75f15ea1fbce93361d722889abf418464'
|
accessToken: 'd100083c1749392da7e1c12e63a6fba75f15ea1fbce93361d722889abf418464',
|
||||||
|
id: 3
|
||||||
},
|
},
|
||||||
ExternalLinks: {
|
ExternalLinks: {
|
||||||
username: 'ExternalLinks',
|
username: 'ExternalLinks',
|
||||||
password: 'ExternalLinksExternalLink',
|
password: 'ExternalLinksExternalLink',
|
||||||
accessToken: 'e9a463ba1729ae0049a97a312af702cb3d08d84de1cc8d6da3fad90af068117b'
|
accessToken: 'e9a463ba1729ae0049a97a312af702cb3d08d84de1cc8d6da3fad90af068117b',
|
||||||
|
id: 4
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue