From 79a6e5a28707638cd00621879de62626e6829dec Mon Sep 17 00:00:00 2001 From: sw-yx Date: Tue, 2 Apr 2019 14:35:04 -0400 Subject: [PATCH 1/2] add detector type field --- src/commands/dev/index.js | 11 ++++++----- src/detectors/README.md | 1 + src/detectors/cra.js | 1 + src/detectors/eleventy.js | 1 + src/detectors/gatsby.js | 1 + src/detectors/hugo.js | 1 + src/detectors/jekyll.js | 1 + src/detectors/react-static.js | 1 + src/detectors/vue.js | 1 + 9 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/commands/dev/index.js b/src/commands/dev/index.js index 0e59394..e2c0d15 100644 --- a/src/commands/dev/index.js +++ b/src/commands/dev/index.js @@ -94,12 +94,13 @@ function startDevServer(settings, log, error) { log('Server listening to', settings.proxyPort) }) return + } else { + log(`Starting netlify dev with ${settings.type}`) + const ps = execa(settings.command, settings.args, { env: settings.env, stdio: 'inherit', shell: true }) + ps.on('close', code => process.exit(code)) + ps.on('SIGINT', process.exit) + ps.on('SIGTERM', process.exit) } - - const ps = execa(settings.command, settings.args, { env: settings.env, stdio: 'inherit', shell: true }) - ps.on('close', code => process.exit(code)) - ps.on('SIGINT', process.exit) - ps.on('SIGTERM', process.exit) } class DevCommand extends Command { diff --git a/src/detectors/README.md b/src/detectors/README.md index 5e687a8..ee022b8 100644 --- a/src/detectors/README.md +++ b/src/detectors/README.md @@ -6,6 +6,7 @@ ```ts { + type: String, // e.g. gatsby, vue-cli command: String, // e.g. yarn, npm port: Number, // e.g. 8888 proxyPort: Number, // e.g. 3000 diff --git a/src/detectors/cra.js b/src/detectors/cra.js index 70d0bfa..d8bdd91 100644 --- a/src/detectors/cra.js +++ b/src/detectors/cra.js @@ -20,6 +20,7 @@ module.exports = function() { const yarnExists = existsSync('yarn.lock') return { + type: 'create-react-app', command: yarnExists ? 'yarn' : 'npm', port: 8888, proxyPort: 3000, diff --git a/src/detectors/eleventy.js b/src/detectors/eleventy.js index 1965da9..a75e964 100644 --- a/src/detectors/eleventy.js +++ b/src/detectors/eleventy.js @@ -6,6 +6,7 @@ module.exports = function() { } return { + type: 'eleventy', port: 8888, proxyPort: 8080, env: { ...process.env }, diff --git a/src/detectors/gatsby.js b/src/detectors/gatsby.js index e3e6b07..72b1e75 100644 --- a/src/detectors/gatsby.js +++ b/src/detectors/gatsby.js @@ -29,6 +29,7 @@ module.exports = function() { const yarnExists = existsSync('yarn.lock') return { + type: 'gatsby', command: yarnExists ? 'yarn' : 'npm', port: 8888, proxyPort: 8000, diff --git a/src/detectors/hugo.js b/src/detectors/hugo.js index c14671a..3e01190 100644 --- a/src/detectors/hugo.js +++ b/src/detectors/hugo.js @@ -6,6 +6,7 @@ module.exports = function() { } return { + type: 'hugo', port: 8888, proxyPort: 1313, env: { ...process.env }, diff --git a/src/detectors/jekyll.js b/src/detectors/jekyll.js index 2eef268..3d74f20 100644 --- a/src/detectors/jekyll.js +++ b/src/detectors/jekyll.js @@ -6,6 +6,7 @@ module.exports = function() { } return { + type: 'jekyll', port: 8888, proxyPort: 4000, env: { ...process.env }, diff --git a/src/detectors/react-static.js b/src/detectors/react-static.js index 82cde3d..db2b9f5 100644 --- a/src/detectors/react-static.js +++ b/src/detectors/react-static.js @@ -29,6 +29,7 @@ module.exports = function() { const yarnExists = existsSync('yarn.lock') return { + type: 'react-static', command: yarnExists ? 'yarn' : 'npm', port: 8888, proxyPort: 3000, diff --git a/src/detectors/vue.js b/src/detectors/vue.js index 479b763..5986cc6 100644 --- a/src/detectors/vue.js +++ b/src/detectors/vue.js @@ -20,6 +20,7 @@ module.exports = function() { const yarnExists = existsSync('yarn.lock') return { + type: 'vue-cli', command: yarnExists ? 'yarn' : 'npm', port: 8888, proxyPort: 8080, From 6e314356f8356a15b30b90511b966a5421ed1c28 Mon Sep 17 00:00:00 2001 From: DavidWells Date: Tue, 2 Apr 2019 14:10:59 -0700 Subject: [PATCH 2/2] send through project type --- src/commands/dev/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/dev/index.js b/src/commands/dev/index.js index e2c0d15..36be791 100644 --- a/src/commands/dev/index.js +++ b/src/commands/dev/index.js @@ -152,9 +152,11 @@ class DevCommand extends Command { } const url = await startProxy(settings, addonUrls) + // Todo hoist this telemetry `command` to CLI hook track('command', { - command: 'dev' + command: 'dev', + projectType: settings.type || 'custom' }) const banner = chalk.bold(`Netlify dev server is now ready on ${url}`)