From 5196109e0cbd21c1f6073a8a5acd226f3864585e Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 18 Feb 2018 10:42:27 -0800 Subject: [PATCH] more work on testing --- .gitignore | 1 + bin/setup-mastodon.js | 33 ++++++++++++++++++++ mastodon/.env | 12 -------- mastodon/docker-compose.yml | 61 ------------------------------------- package-lock.json | 31 +++++++++++++++++++ package.json | 5 +-- 6 files changed, 68 insertions(+), 75 deletions(-) create mode 100644 bin/setup-mastodon.js delete mode 100644 mastodon/.env delete mode 100644 mastodon/docker-compose.yml diff --git a/.gitignore b/.gitignore index 5cc50695..23dddd59 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ yarn.lock cypress/screenshots templates/.* assets/*.css +/mastodon \ No newline at end of file diff --git a/bin/setup-mastodon.js b/bin/setup-mastodon.js new file mode 100644 index 00000000..ba1e2e66 --- /dev/null +++ b/bin/setup-mastodon.js @@ -0,0 +1,33 @@ +const pify = require('pify') +const exec = require('child-process-promise').exec; +const dir = __dirname +const path = require('path') +const fs = require('fs') +const exists = pify(fs.exists.bind(fs)) +const writeFile = pify(fs.writeFile.bind(fs)) + +const envFile = ` +PAPERCLIP_SECRET=foo +SECRET_KEY_BASE=bar +OTP_SECRET=foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar +` + +async function main() { + let mastodonDir = path.join(dir, '../mastodon') + if (!(await exists(mastodonDir))) { + await exec(`git clone https://github.com/tootsuite/mastodon "${mastodonDir}"`) + await exec(`git checkout v2.2.0`, {cwd: mastodonDir}) + await writeFile(path.join(dir, '../mastodon/.env'), envFile, 'utf8') + } + + await exec(`gem install bundler`, {cwd: mastodonDir}) + await exec(`gem install foreman`, {cwd: mastodonDir}) + await exec(`bundle install`, {cwd: mastodonDir}) + await exec(`yarn --pure-lockfile`, {cwd: mastodonDir}) + await exec(`foreman start`, {cwd: mastodonDir}) +} + +main().catch(err => { + console.error(err) + process.exit(1) +}) diff --git a/mastodon/.env b/mastodon/.env deleted file mode 100644 index 7467f780..00000000 --- a/mastodon/.env +++ /dev/null @@ -1,12 +0,0 @@ -PAPERCLIP_SECRET=foo -SECRET_KEY_BASE=bar -OTP_SECRET=foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar - -#REDIS_HOST=localhost -#REDIS_PORT=6379 - -DB_HOST=127.0.0.1 -DB_NAME=mastodon_dev -DB_USER=mastodon_dev -DB_PASS=mastodon_dev -DB_PORT=5432 diff --git a/mastodon/docker-compose.yml b/mastodon/docker-compose.yml deleted file mode 100644 index 259de3ed..00000000 --- a/mastodon/docker-compose.yml +++ /dev/null @@ -1,61 +0,0 @@ -version: '3' -services: - - db: - restart: always - image: postgres:9.6-alpine - environment: - POSTGRES_USER: mastodon_dev - POSTGRES_PASSWORD: mastodon_dev - POSTGRES_DB: mastodon_dev -### Uncomment to enable DB persistance -# volumes: -# - ./postgres:/var/lib/postgresql/data - - redis: - restart: always - image: redis:4.0-alpine -### Uncomment to enable REDIS persistance -# volumes: -# - ./redis:/data - - web: - #build: . - image: gargron/mastodon:v2.2.0 - restart: always - env_file: .env - command: bundle exec rails s -p 3000 -b '0.0.0.0' - ports: - - "3000:3000" - depends_on: - - db - - redis - volumes: - - ./public/assets:/mastodon/public/assets - - ./public/packs:/mastodon/public/packs - - ./public/system:/mastodon/public/system - - streaming: - #build: . - image: gargron/mastodon:v2.2.0 - restart: always - env_file: .env - command: npm run start - ports: - - "4000:4000" - depends_on: - - db - - redis - - sidekiq: - #build: . - image: gargron/mastodon:v2.2.0 - restart: always - env_file: .env - command: bundle exec sidekiq -q default -q mailers -q pull -q push - depends_on: - - db - - redis - volumes: - - ./public/packs:/mastodon/public/packs - - ./public/system:/mastodon/public/system diff --git a/package-lock.json b/package-lock.json index 1e3110a6..701bb93d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -726,6 +726,27 @@ "parse5": "3.0.3" } }, + "child-process-promise": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/child-process-promise/-/child-process-promise-2.2.1.tgz", + "integrity": "sha1-RzChHvYQ+tRQuPIjx50x172tgHQ=", + "requires": { + "cross-spawn": "4.0.2", + "node-version": "1.1.0", + "promise-polyfill": "6.1.0" + }, + "dependencies": { + "cross-spawn": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz", + "integrity": "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=", + "requires": { + "lru-cache": "4.1.1", + "which": "1.3.0" + } + } + } + }, "chokidar": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.0.tgz", @@ -5085,6 +5106,11 @@ } } }, + "node-version": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/node-version/-/node-version-1.1.0.tgz", + "integrity": "sha512-t1V2RFiaTavaW3jtQO0A2nok6k7/Gghuvx2rjvICuT0B0dYaObBQ4U0xHL+ZTPFZodt1LMYG2Vi2nypfz4/AJg==" + }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -6349,6 +6375,11 @@ "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" }, + "promise-polyfill": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-6.1.0.tgz", + "integrity": "sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc=" + }, "proxy-addr": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", diff --git a/package.json b/package.json index 21b42f2f..c7b0f204 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,14 @@ "cy:open": "cypress open", "test": "run-p --race dev cy:run", "globalize-css": "node ./bin/globalize-css.js", - "deglobalize-css": "node ./bin/globalize-css.js --reverse" + "deglobalize-css": "node ./bin/globalize-css.js --reverse", + "setup-mastodon": "node ./bin/setup-mastodon.js" }, "dependencies": { "@gamestdio/websocket": "^0.2.2", "a11y-dialog": "^4.0.1", "cheerio": "^1.0.0-rc.2", + "child-process-promise": "^2.2.1", "chokidar": "^2.0.0", "compression": "^1.7.1", "concurrently": "^3.5.1", @@ -44,7 +46,6 @@ "pify": "^3.0.0", "quick-lru": "^1.1.0", "requestidlecallback": "^0.3.0", - "rimraf": "^2.6.2", "sapper": "nolanlawson/sapper#fix-style-loader-built", "serve-static": "^1.13.1", "standard": "^10.0.3",