This command will clone a complete Form.io Project, including forms, submissions, revisions, etc. between environments.
Download the ZIP of this Gist, then run the following inside of the extracted folder.
npm install
var EMAIL = ''; | |
var PROJECTID = ''; | |
db.projects.find({name: 'formio'}).forEach(function(project) { | |
db.forms.find({name: 'user', project: project._id}).forEach(function(userForm) { | |
print("User Form: " + userForm._id); | |
db.submissions.find({'data.email': EMAIL, form: userForm._id}).forEach(function(user) { | |
if (user) { | |
print("User: " + user._id); | |
db.projects.find({_id: ObjectId(PROJECTID)}).forEach(function(changeProject) { | |
if (changeProject) { |
db.forms.find({'settings.pdf.src': {$ne: null}}).forEach(function(form) { | |
db.forms.update({_id: form._id}, {$set: {'settings.pdf.src': form.settings.pdf.src.replace(/https\:\/\/files\.form\.io|/, 'https://yourdeployment.com/pdf')}}) | |
}); |
const fetch = require('@formio/node-fetch-http-proxy'); | |
const shell = require('@travist/async-shell'); | |
const fs = require('fs'); | |
const config = require('./migrate.json'); | |
async function migrateForm(src, project) { | |
let resp; | |
let originalForm; | |
try { | |
resp = await fetch(src, { | |
rejectUnauthorized: false |
FROM alpine:latest | |
MAINTAINER Form.io <[email protected]> | |
ENV USERNAME=formiouser | |
ENV UID=5000 | |
ENV GROUP=${USERNAME} | |
ENV GID=${UID} | |
RUN adduser -u ${UID} -g ${GROUP} -D ${USERNAME} &&\ |
docker exec pdf-server node --eval="\ | |
const puppeteer = require('puppeteer');\ | |
(async () => {\ | |
const translateProxy = function(proxy) {\ | |
return proxy.replace(/http[s]?:\/\//g, '').split(',').join(';');\ | |
};\ | |
const puppeteerArgs = [\ | |
'--no-sandbox',\ | |
'--disable-setuid-sandbox',\ | |
'--disable-dev-shm-usage',\ |
const fetch = require('node-fetch'); | |
const FormData = require('form-data'); | |
// Refer to https://apidocs.form.io/#0e4214b1-4e35-f22c-3a0c-0a5e01c62126 to get the right url here. | |
fetch('https://api.form.io/project/[PROJECT_ID]/form/[FORM_ID]/submission/[SUBMISSION_ID]/download?token=[DOWNLOAD_TOKEN]', { | |
method: 'GET' | |
}).then((response) => { | |
const form = new FormData(); | |
form.append('file', response.body, { filename : 'submission.pdf' }); | |
fetch('https://httpbin.org/post', { | |
method: 'POST', |
version: '3.7' | |
services: | |
mongo: | |
image: mongo:4.2 | |
restart: always | |
volumes: | |
- mdb-data:/data/db | |
networks: | |
formio: | |
aliases: |
node -e ' | |
var config = require("dotenv").config(); | |
var packageJson = require("./package.json"); | |
console.log("docker run -itd \\"); | |
for (let i in config.parsed) { | |
switch (i) { | |
case "MONGO": | |
config.parsed[i] = config.parsed[i].replace("localhost", "mongo"); | |
break; | |
case "FORMIO_S3_SERVER": |
'use strict'; | |
const config = { | |
projectUrl: 'http://localhost:3000', | |
apiKey: '23423423lkj234ljk234lkj234lkj23' | |
}; | |
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const methodOverride = require('method-override'); | |
const fetch = require('node-fetch'); |