Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE(cli) remove watch command #100

Merged
merged 1 commit into from
Nov 15, 2019
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
4 changes: 0 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@
"devDependencies": {
"@oclif/dev-cli": "1.22.2",
"decompress": "4.2.0",
"fetch-mock": "5.11.0",
"jayson": "2.0.6",
"litdoc": "1.5.6",
"markdown-toc": "1.1.0",
"mock-fs": "4.10.0",
"ngrok": "2.2.10",
"nock": "10.0.6",
"node-watch": "0.5.4",
"stdout-stderr": "0.1.9",
"yamljs": "0.3.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ module.exports = {
logs: require('./logs'),
push: require('./push'),
register: require('./register'),
upload: require('./upload'),
watch: require('./watch')
upload: require('./upload')
};
161 changes: 0 additions & 161 deletions packages/cli/src/commands/watch.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/cli/src/oclif/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ Some notes to help an ongoing project

## hard

- [ ] build
- [x] build
- [ ] collaborate
- [ ] convert
- [ ] env
- [ ] invite
- [x] promote
- [ ] push
- [x] push
- [ ] scaffold
- [ ] upload
- [ ] watch - remove?
- [x] upload
- [x] watch - remove?
- [x] validate
66 changes: 1 addition & 65 deletions packages/cli/src/utils/local.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
const _ = require('lodash');
const colors = require('colors');
const path = require('path');

const { PLATFORM_PACKAGE } = require('../constants');

const { prettyJSONstringify } = require('./display');

const { promisify } = require('./promisify');

const nodeWatch = (...args) => require('node-watch')(...args);
const makeTunnelUrl = (...args) => promisify(require('ngrok').connect)(...args);

const getLocalAppHandler = ({ reload = false, baseEvent = {} } = {}) => {
const entryPath = `${process.cwd()}/index`;
const rootPath = path.dirname(require.resolve(entryPath));
Expand Down Expand Up @@ -58,63 +50,7 @@ const localAppCommand = event => {
});
};

// translate a JS Error into what would be returned from lambda
const createAWSError = error => {
const stackTrace = error.stack.split(/\n\s+at\s/).slice(1);

return {
errorMessage: error.message,
errorType: error.name,
stackTrace
};
};

// Stands up a local tunnel server for app commands.
const localAppTunnelServer = options => {
const jayson = require('jayson');

const server = jayson.server({
test: (args, callback) => {
callback(null, { results: 'Success!' });
},
invoke: (args, callback) => {
const [event] = args;
options.log();
options.log(colors.green('==Method'));
options.log(event.method);
options.log(colors.green('==Bundle'));
options.log(prettyJSONstringify(event.bundle));
options.handler(event, {}, (err, resp) => {
if (err) {
options.log(colors.red(colors.bold('==Error')));
options.log(err.stack);
options.log();
} else {
options.log(colors.red(colors.bold('==Results')));
options.log(prettyJSONstringify(resp.results));
options.log();
}
if (err) {
// match how AWS returns its errors
const awsError = createAWSError(err);
callback(null, awsError);
} else {
callback(err, resp);
}
});
}
});

server.httpServer = server.http();
server.httpServer.listen(options.port);

return server;
};

module.exports = {
getLocalAppHandler,
localAppCommand,
localAppTunnelServer,
makeTunnelUrl,
nodeWatch
localAppCommand
};
18 changes: 0 additions & 18 deletions packages/cli/src/utils/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,6 @@ const promiseDoWhile = (action, stop) => {
return loop();
};

/* Delay a promise, by just a bit. */
const promiseDelay = (delay = 1000) => {
return () =>
new Promise(resolve => {
setTimeout(() => resolve(), delay);
});
};

/* Never stop looping. */
const promiseForever = (action, delay = 1000) => {
const loop = () =>
action()
.then(promiseDelay(delay))
.then(loop);
return loop();
};

/* Return full path to entry point file as specified in package.json (ie "index.js") */
const entryPoint = dir => {
dir = dir || process.cwd();
Expand Down Expand Up @@ -233,7 +216,6 @@ module.exports = {
npmInstall,
printVersionInfo,
promiseDoWhile,
promiseForever,
runCommand,
snakeCase
};