Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

[MAJOR] json format only outputs valid json #260

Merged
merged 7 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,820 changes: 777 additions & 1,043 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"minimatch": "3.0.3",
"node-fetch": "1.7.1",
"normalize-path": "2.0.1",
"ora": "2.1.0",
"prettier": "1.9.1",
"read": "1.0.7",
"readable-stream": "2.2.2",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/_access.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ const makeAccess = (command, recordType) => {
app.title
}".\n`
);
utils.printStarting(`Removing ${email}`);
utils.startSpinner(`Removing ${email}`);
return utils.callAPI(url, { method: 'DELETE' });
} else {
context.line(
`Preparing to add ${recordType} ${email} to your app "${
app.title
}${msgExtra}".\n`
);
utils.printStarting(`Adding ${email}`);
utils.startSpinner(`Adding ${email}`);
return utils.callAPI(url, { method: 'POST' });
}
})
.then(() => {
utils.printDone();
utils.endSpinner();
context.line(
`\n${_.capitalize(
recordTypePlural
Expand Down
4 changes: 2 additions & 2 deletions src/commands/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const convert = (context, appid, location) => {
constants.BASE_ENDPOINT
}/api/developer/v1/apps/${appid}/dump`;

utils.printStarting('Downloading app from Zapier');
utils.startSpinner('Downloading app from Zapier');
return utils
.callAPI(null, { url })
.then(legacyApp => {
Expand All @@ -31,7 +31,7 @@ const convert = (context, appid, location) => {
return legacyApp;
})
.then(legacyApp => {
utils.printDone();
utils.endSpinner();
return legacyApp;
})
.then(legacyApp => utils.convertApp(legacyApp, tempAppDir));
Expand Down
6 changes: 3 additions & 3 deletions src/commands/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const deleteApp = (context, app) => {
context.line(
`Preparing to delete all versions of your app "${app.title}".\n`
);
utils.printStarting('Deleting app');
utils.startSpinner('Deleting app');
return utils.callAPI(`/apps/${app.id}`, {
method: 'DELETE'
});
Expand All @@ -14,7 +14,7 @@ const deleteVersion = (context, app, version) => {
context.line(
`Preparing to delete version ${version} of your app "${app.title}".\n`
);
utils.printStarting(`Deleting version ${version}`);
utils.startSpinner(`Deleting version ${version}`);
return utils.callAPI(`/apps/${app.id}/versions/${version}`, {
method: 'DELETE'
});
Expand All @@ -36,7 +36,7 @@ const _delete = (context, appOrVersion, version) => {
: deleteApp(context, app)
)
.then(() => {
utils.printDone();
utils.endSpinner();
context.line(' Deletion successful!\n');
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/commands/deprecate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const deprecate = (context, version, deprecationDate) => {
`Preparing to deprecate version ${version} your app "${app.title}".\n`
);
const url = '/apps/' + app.id + '/versions/' + version + '/deprecate';
utils.printStarting(`Deprecating ${version}`);
utils.startSpinner(`Deprecating ${version}`);
return utils.callAPI(url, {
method: 'PUT',
body: {
Expand All @@ -23,7 +23,7 @@ const deprecate = (context, version, deprecationDate) => {
});
})
.then(() => {
utils.printDone();
utils.endSpinner();
context.line(' Deprecation successful!\n');
context.line(
`We'll let users know that this version is no longer recommended and will cease to work on ${deprecationDate}.`
Expand Down
4 changes: 2 additions & 2 deletions src/commands/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const env = (context, version, key, value) => {
const startMsg = isRemove
? `Deleting ${key}`
: `Setting ${key} to "${value}"`;
utils.printStarting(startMsg);
utils.startSpinner(startMsg);

const method = isRemove ? 'DELETE' : 'PUT';
return utils.callAPI(url, {
Expand All @@ -31,7 +31,7 @@ const env = (context, version, key, value) => {
});
})
.then(() => {
utils.printDone();
utils.endSpinner();
context.line();
context.line(
`Environment updated! Try viewing it with \`zapier env ${version}\`.`
Expand Down
4 changes: 2 additions & 2 deletions src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const init = (context, location) => {

const template = global.argOpts.template || 'minimal';
const createApp = tempAppDir => {
utils.printStarting(
utils.startSpinner(
`Downloading zapier/zapier-platform-example-app-${template} starter app`
);
return exampleApps
.downloadAndUnzipTo(template, tempAppDir)
.then(() => exampleApps.removeReadme(tempAppDir))
.then(() => utils.printDone());
.then(() => utils.endSpinner());
};

return utils.initApp(context, location, createApp).then(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ const link = context => {
if (hasCancelled(answer)) {
throw new Error('Cancelled link operation.');
} else {
utils.printStarting(`Selecting existing app "${appMap[answer].title}"`);
utils.startSpinner(`Selecting existing app "${appMap[answer].title}"`);
return appMap[answer];
}
})
.then(app => {
utils.printDone();
utils.printStarting(`Setting up \`${constants.CURRENT_APP_FILE}\` file`);
utils.endSpinner();
utils.startSpinner(`Setting up \`${constants.CURRENT_APP_FILE}\` file`);
return utils.writeLinkedAppConfig(app);
})
.then(() => {
utils.printDone();
utils.endSpinner();
context.line(
'\nFinished! You can `zapier push` now to build & upload a version!'
);
Expand Down
8 changes: 4 additions & 4 deletions src/commands/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const logout = context => {

return Promise.resolve()
.then(() => {
utils.printStarting('Deactivating personal deploy keys');
utils.startSpinner('Deactivating personal deploy keys');
return utils
.callAPI('/keys', {
method: 'DELETE'
Expand All @@ -18,12 +18,12 @@ const logout = context => {
.catch(() => true);
})
.then(() => {
utils.printDone();
utils.printStarting(`Destroying \`${constants.AUTH_LOCATION_RAW}\``);
utils.endSpinner();
utils.startSpinner(`Destroying \`${constants.AUTH_LOCATION_RAW}\``);
return utils.deleteFile(constants.AUTH_LOCATION);
})
.then(() => {
utils.printDone();
utils.endSpinner();
context.line();
context.line(
'All personal deploy keys deactivated - now try `zapier login` to login again.'
Expand Down
4 changes: 2 additions & 2 deletions src/commands/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const colors = require('colors/safe');
const logs = context => {
context.line('The logs of your app listed below.\n');

utils.startSpinner();
utils.startSpinner('Loading your logs');
return utils.listLogs(global.argOpts).then(data => {
utils.endSpinner('');
utils.endSpinner();

let columns;
const type = global.argOpts.type || logs.argOptsSpec.type.default;
Expand Down
6 changes: 3 additions & 3 deletions src/commands/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const migrate = (context, fromVersion, toVersion, optionalPercent = '100%') => {
app.title
}" from ${fromVersion} to ${toVersion}.\n`
);
utils.printStarting(
utils.startSpinner(
`Starting migration from ${fromVersion} to ${toVersion} for ${user}`
);
} else {
Expand All @@ -39,7 +39,7 @@ const migrate = (context, fromVersion, toVersion, optionalPercent = '100%') => {
app.title
}" from ${fromVersion} to ${toVersion}.\n`
);
utils.printStarting(
utils.startSpinner(
`Starting migration from ${fromVersion} to ${toVersion} for ${optionalPercent}%`
);
}
Expand All @@ -53,7 +53,7 @@ const migrate = (context, fromVersion, toVersion, optionalPercent = '100%') => {
);
})
.then(() => {
utils.printDone();
utils.endSpinner();
context.line(
'\nMigration successfully queued, please check `zapier history` to track the status. Migrations usually take between 5-10 minutes.'
);
Expand Down
8 changes: 4 additions & 4 deletions src/commands/promote.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const promote = (context, version) => {
return utils.promiseDoWhile(action, stop);
})
.then(answer => {
context.line();
if (hasCancelled(answer)) {
throw new Error('Cancelled promote.');
}
Expand All @@ -75,19 +76,18 @@ const promote = (context, version) => {
body.changelog = changelog;
}

utils.printStarting(`Verifying and promoting ${version}`);
utils.startSpinner(`Verifying and promoting ${version}`);
return utils.callAPI(
url,
{
method: 'PUT',
body
},
false,
true
);
})
.then(() => {
utils.printDone();
utils.endSpinner();
context.line(' Promotion successful!\n');
context.line(
'Optionally, run the `zapier migrate` command to move users to this version.'
Expand All @@ -97,7 +97,7 @@ const promote = (context, version) => {
// we probalby have a raw response, might have a thrown error
// The server 403s when the app hasn't been approved yet
if (_.get(response, 'json.activationInfo')) {
utils.printDone();
utils.endSpinner();
context.line(
'\nGood news! Your app passes validation and has the required number of testers and active Zaps.\n'
);
Expand Down
9 changes: 4 additions & 5 deletions src/commands/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const register = (context, title, { printWhenDone = true } = {}) => {
return utils
.checkCredentials()
.then(() => {
utils.printDone();
utils.printStarting(`Confirming registation of app "${title}"`);
utils.startSpinner(`Confirming registation of app "${title}"`);
return utils.callAPI('/apps', {
method: 'POST',
body: {
Expand All @@ -20,16 +19,16 @@ const register = (context, title, { printWhenDone = true } = {}) => {
});
})
.then(app => {
utils.printDone();
utils.printStarting(
utils.endSpinner();
utils.startSpinner(
`Linking app to current directory with \`${
constants.CURRENT_APP_FILE
}\``
);
return utils.writeLinkedAppConfig(app, appDir);
})
.then(() => {
utils.printDone();
utils.endSpinner();
if (printWhenDone) {
context.line(
'\nFinished! Now that your app is registered with Zapier, you can `zapier push` a version!'
Expand Down
10 changes: 5 additions & 5 deletions src/commands/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const writeTemplateFile = (templatePath, templateContext, dest) => {
_.template(template, { interpolate: /<%=([\s\S]+?)%>/g })(templateContext)
)
.then(rendered => {
utils.printStarting(`Writing new ${dest}.js`);
utils.startSpinner(`Writing new ${dest}.js`);
return utils
.ensureDir(path.dirname(destPath))
.then(() => utils.writeFile(destPath, rendered));
})
.then(() => utils.printDone());
.then(() => utils.endSpinner());
};

const scaffold = (context, type, name) => {
Expand Down Expand Up @@ -83,7 +83,7 @@ const scaffold = (context, type, name) => {
.then(() => utils.readFile(entryFile))
.then(entryBuf => entryBuf.toString())
.then(entryJs => {
utils.printStarting(`Rewriting your ${entry}`);
utils.startSpinner(`Rewriting your ${entry}`);
let lines = entryJs.split('\n');

// this is very dumb and will definitely break, it inserts lines of code
Expand All @@ -101,7 +101,7 @@ const scaffold = (context, type, name) => {
_.endsWith(line, injectAfter)
);
if (linesDefIndex === -1) {
utils.printDone(false);
utils.endSpinner(false);
context.line();
context.line(
colors.bold(`Oops, we could not reliably rewrite your ${entry}.`) +
Expand All @@ -116,7 +116,7 @@ const scaffold = (context, type, name) => {
lines.splice(linesDefIndex + 1, 0, ' ' + injectorLine);
return utils
.writeFile(entryFile, lines.join('\n'))
.then(() => utils.printDone());
.then(() => utils.endSpinner());
}
})
.then(() =>
Expand Down
14 changes: 7 additions & 7 deletions src/commands/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ const watch = context => {
if (fileName.startsWith('.git')) {
return;
}
utils.printStarting(`Reloading for ${fileName}`);
utils.startSpinner(`Reloading for ${fileName}`);
resetHandler()
.then(reloadDefinition)
.then(pingZapierForTunnel)
.then(() => utils.printDone())
.then(() => utils.endSpinner())
.catch(err => {
utils.printDone(false);
utils.endSpinner(false);
context.line(err);
// don't print err.stack until we use require('syntax-error') or similar
});
Expand All @@ -94,16 +94,16 @@ const watch = context => {
.checkCredentials()
.then(() => utils.getLinkedApp())
.then(app => {
utils.printStarting('Starting local server on port ' + options.port);
utils.startSpinner('Starting local server on port ' + options.port);
return Promise.all([app, utils.localAppTunnelServer(options)]);
})
.then(([app, server]) => {
utils.printDone();
utils.printStarting('Starting local tunnel for port ' + options.port);
utils.endSpinner();
utils.startSpinner('Starting local tunnel for port ' + options.port);
return Promise.all([app, server, utils.makeTunnelUrl(options.port)]);
})
.then(([app, server, _proxyUrl]) => {
utils.printDone();
utils.endSpinner();

localAppId = app.id;
localProxyUrl = _proxyUrl;
Expand Down
Loading