Skip to content

Commit

Permalink
feat: 🔙 Revert live tunneler #66
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofugaro committed Apr 23, 2020
1 parent 19d0a58 commit f6a6e6a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 353 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Then you just `cd project-name`, run `yarn start` and start creating awesome stu
#### Commands
These are the available commands once you created a project:
- `yarn start` starts a server locally, accessible both from your browser and from another machine using your same wi-fi
- `yarn start --exposed` starts a server locally and exposes it to the internet, accessible from everyone having the link, kinda like ngrok, but works only if you have an accurat ssh key. The link created looks like `{branch}.{repo}.internal.accurat.io` if you're in a branch, or `{repo}.internal.accurat.io` if you're on master. It uses a server with an instance of [SSH-Tuna](https://github.com/accurat/ssh-tuna) to achieve this.
- `yarn build` builds the project for production, ready to be deployed from the `build/` folder
- `yarn test` runs [jest](https://jestjs.io/en/). By default (if you're not in a CI) it runs in watch mode, but you can disable watch mode by passing `--watch=false`. You can also pass any other argument you would pass to jest, for example `yarn test --updateSnapshot` updates your snapshots.
- `yarn lint` lints with eslint the `src/` folder. You can pass any [eslint options](https://eslint.org/docs/user-guide/command-line-interface#options) to the lint command, for example if you want to use eslint's fix option, you do it like this:
Expand Down Expand Up @@ -251,8 +250,6 @@ render() {

- **WATCH_NODE_MODULES** - Set this to true if you want to recompile when any of the used `node_modules` changes (default `false`)

- **TUNNEL_DOMAIN** - The domain that the command `yarn start --exposed` will use as a request tunnel, it must be the domain of a server with an instance of [SSH-Tuna](https://github.com/accurat/ssh-tuna) on it (default `internal.accurat.io`)

## Available Env Variables
These are the Env Variables that Accurapp provides you, you cannot modify them directly:
- **NODE_ENV** - It is equal to `'development'` in the `yarn start` command and `'production'` in the `yarn build` command
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lint": "node node_modules/eslint/bin/eslint.js packages",
"test": "./test/e2e.sh",
"create-test-app": "./test/create-test-app.sh",
"create-test-app-start": "(yarn create-test-app && cd test-app/ && BROWSER=false yarn start --exposed)",
"create-test-app-start": "(yarn create-test-app && cd test-app/ && BROWSER=false yarn start)",
"create-test-app-build": "(yarn create-test-app && cd test-app/ && yarn build)",
"create-test-app-test": "(yarn create-test-app && cd test-app/ && yarn test --watch=false)",
"publish": "is-git-status-clean && lerna publish --conventional-commits --message 'chore: 🚀 Publish'"
Expand Down Expand Up @@ -36,4 +36,4 @@
"is-git-status-clean": "1.0.0",
"lerna": "3.20.2"
}
}
}
3 changes: 1 addition & 2 deletions packages/accurapp-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"react-dev-utils": "10.2.1",
"resolve": "1.16.1",
"semver": "7.3.2",
"ssh-tuna": "1.0.3",
"webpack": "4.42.1",
"webpack-dev-server": "3.10.3"
}
}
}
23 changes: 0 additions & 23 deletions packages/accurapp-scripts/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const detect = require('detect-port')
const WebpackDevServer = require('webpack-dev-server')
const openOrRefreshBrowser = require('react-dev-utils/openBrowser')
const { prepareUrls } = require('react-dev-utils/WebpackDevServerUtils')
const { tunnelPort } = require('ssh-tuna')
const { log, coloredBanner } = require('../utils/logging-utils')
const { generateSubdomain } = require('../utils/tunnel-utils')
const { createWebpackCompiler, readWebpackConfig } = require('../utils/webpack-utils')
const { verifyTypeScriptSetup } = require('../utils/verifyTypeScriptSetup')
const {
Expand All @@ -29,9 +27,6 @@ process.env.LATEST_TAG = extractLatestTag()
const HOST = process.env.HOST || '0.0.0.0'
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 8000
const PROTOCOL = process.env.HTTPS === 'true' ? 'https' : 'http'
const TUNNEL_DOMAIN = process.env.TUNNEL_DOMAIN || 'internal.accurat.io'
const TUNNEL_SSH_PORT = process.env.TUNNEL_SSH_PORT || 2222
const EXPOSED = process.argv.includes('--exposed')

const appDir = process.cwd()
verifyTypeScriptSetup(appDir)
Expand All @@ -41,24 +36,6 @@ function runDevServer(port) {
const compiler = createWebpackCompiler(() => {
log.info(`The app is running at: ${chalk.cyan(urls.localUrlForTerminal)}`)
log.info(`Or on your network at: ${chalk.cyan(urls.lanUrlForTerminal)}`)

if (EXPOSED) {
const subdomain = generateSubdomain()
tunnelPort(port, subdomain, TUNNEL_DOMAIN, TUNNEL_SSH_PORT)
.then(() => {
const url = `https://${subdomain}.${TUNNEL_DOMAIN}`
log.info(`Even from far away at: ${chalk.cyan(url)}`)
})
.catch((err) => {
const message = err.message || err
if (message.includes('authentication methods failed')) {
err =
'Could not authenticate to the tunneling server, please make sure you can access the server via ssh.'
}

log.err(`Could not expose the local port: ${err}`)
})
}
})

const devServerConfig = {
Expand Down
25 changes: 0 additions & 25 deletions packages/accurapp-scripts/utils/git-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,6 @@ function extractLatestTag() {
}
}

function extractCurrentBranch() {
try {
return cp.execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
} catch (e) {
// Probably git is not available, return an empty string instead
return ''
}
}

function extractRepoName() {
try {
return cp
.execSync('basename -s .git `git config --get remote.origin.url`', {
stdio: ['pipe', 'pipe', 'ignore'],
})
.toString()
.trim()
} catch (e) {
// Probably git is not available, return an empty string instead
return ''
}
}

function isInGitRepository() {
try {
cp.execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' })
Expand All @@ -73,7 +50,5 @@ module.exports = {
extractLatestCommitHash,
extractLatestCommitTimestamp,
extractLatestTag,
extractCurrentBranch,
extractRepoName,
isInGitRepository,
}
12 changes: 0 additions & 12 deletions packages/accurapp-scripts/utils/tunnel-utils.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ yarn create-test-app
cd test-app/

# Test the start of the application
BROWSER=false yarn start --exposed &
BROWSER=false yarn start &
PID=$!
sleep 20s
kill $PID
Expand All @@ -32,7 +32,7 @@ mv ./src/components/App.test.js ./src/components/App.test.ts
cp -r ../.fixtures/test-app-ts/src .

# Test the start with typescript
BROWSER=false yarn start --exposed &
BROWSER=false yarn start &
PID=$!
sleep 30s
kill $PID
Expand Down
Loading

0 comments on commit f6a6e6a

Please sign in to comment.