diff --git a/README-source.md b/README-source.md
index e7efdbe..c1f1105 100644
--- a/README-source.md
+++ b/README-source.md
@@ -1256,6 +1256,7 @@ While not always required, it's also recommended you use the same `zapier-platfo
- `npm install` for getting started
- `npm run build` for updating `./lib` from `./src`
- `npm test` for running tests (also runs `npm run build`)
+- `npm run test-convert` for running integration tests for the `zapier convert` command
- `npm run docs` for updating docs
- `npm run gen-completions` for updating the auto complete scripts
diff --git a/README.md b/README.md
index c66dd16..3c54293 100644
--- a/README.md
+++ b/README.md
@@ -2022,6 +2022,7 @@ While not always required, it's also recommended you use the same `zapier-platfo
- `npm install` for getting started
- `npm run build` for updating `./lib` from `./src`
- `npm test` for running tests (also runs `npm run build`)
+- `npm run test-convert` for running integration tests for the `zapier convert` command
- `npm run docs` for updating docs
- `npm run gen-completions` for updating the auto complete scripts
diff --git a/docs/index.html b/docs/index.html
index 57c286d..99e30a4 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -3645,6 +3645,7 @@
Development of the CLI
npm install
for getting started
npm run build
for updating ./lib
from ./src
npm test
for running tests (also runs npm run build
)
+npm run test-convert
for running integration tests for the zapier convert
command
npm run docs
for updating docs
npm run gen-completions
for updating the auto complete scripts
diff --git a/package.json b/package.json
index 60455d4..3f975e0 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,8 @@
"zapier": "zapier.js",
"validate-templates": "./scripts/validate-app-templates.js",
"set-template-versions": "./scripts/set-app-template-versions.js",
- "gen-completions": "./scripts/gen-zsh-completions.js > ./goodies/zsh/_zapier && ./scripts/gen-bash-completions.js > ./goodies/bash/_zapier"
+ "gen-completions": "./scripts/gen-zsh-completions.js > ./goodies/zsh/_zapier && ./scripts/gen-bash-completions.js > ./goodies/bash/_zapier",
+ "test-convert": "./scripts/test-convert.js"
},
"dependencies": {
"adm-zip": "0.4.7",
diff --git a/scripts/test-convert.js b/scripts/test-convert.js
new file mode 100755
index 0000000..687dc78
--- /dev/null
+++ b/scripts/test-convert.js
@@ -0,0 +1,66 @@
+#!/usr/bin/env node
+
+const _ = require('lodash');
+const path = require('path');
+const tmp = require('tmp');
+const utils = require('../lib/utils');
+
+const fse = require('fs-extra');
+const childProcess = utils.promisifyAll(require('child_process'));
+
+const appsToConvert = [
+ {id: 80082, name: 'simple-basic-auth'},
+ // TODO: Add more apps that require scripting and different auths, once zapier-platform-legacy-scripting-runner is live
+];
+
+const testConvertedApp = (appToConvert, rootTmpDir) => {
+ const zapierCmd = path.resolve(__dirname, '../zapier.js');
+ // Prepare all env variables the apps might need
+ const exportCmd = 'export CLIENT_ID=1234 CLIENT_SECRET=asdf USERNAME=user PASSWORD=passwd API_KEY=anything-goes ACCESS_TOKEN=a_token REFRESH_TOKEN=a_refresh_token';
+
+ const logFile = path.resolve(__dirname, '..', `${appToConvert.name}.log`);
+ const logStream = fse.createWriteStream(logFile);
+
+ console.log(`Converting and testing ${appToConvert.name}, writing logs to ${logFile}`);
+ return fse.ensureFile(logFile)
+ .then(() => {
+ return new Promise((resolve, reject) => {
+ const cmd = `${zapierCmd} convert ${appToConvert.id} ${appToConvert.name} --debug && cd ${appToConvert.name} && npm install && ${zapierCmd} validate && ${exportCmd} && ${zapierCmd} test --timeout=10000`;
+ const child = childProcess.exec(cmd, {cwd: rootTmpDir}, err => {
+ if (err) {
+ console.log('error starting child process:', err);
+ reject(err);
+ }
+ resolve();
+ });
+ child.stdout.pipe(logStream);
+ child.stderr.pipe(logStream);
+ });
+ })
+ .then(() => {
+ console.log(`${appToConvert.name} converted successfully`);
+ return null;
+ })
+ .catch(() => {
+ console.error(`${appToConvert.name} conversion failed. See ${logFile}.`);
+ return appToConvert.name;
+ });
+};
+
+global.argOpts = {};
+
+const rootTmpDir = tmp.tmpNameSync();
+fse.removeSync(rootTmpDir);
+fse.ensureDirSync(rootTmpDir);
+
+const tasks = _.map(appsToConvert, template => testConvertedApp(template, rootTmpDir));
+
+Promise.all(tasks)
+ .then(results => {
+ const failures = _.filter(results, result => result !== null);
+ if (failures.length) {
+ console.error('these apps failed conversion:', failures.join(', '));
+ } else {
+ console.log('apps converted successfully');
+ }
+ });