Skip to content

Commit

Permalink
replaced localhost by development
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledoux committed Jul 23, 2017
1 parent e34ce89 commit fd39d27
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docs/frontend_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Here are some additional informations about frontend templates architecture. As
| +-- static
+-- bin
| +-- bundle.sh
| +-- localhost_bundle.sh
| +-- development_bundle.sh
+-- bundler
| +-- <REPLACE>config.js
| +-- <REPLACE>webpackDevServer.js
Expand Down
2 changes: 1 addition & 1 deletion docs/teleport_ontology.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ and also sets other dynamic variables.

## type
A type is the object that defines a certain environment for deployment.
It is typically sets of parameters specific to a localhost, or a staging or a
It is typically sets of parameters specific to a development, or a staging or a
production use (like the host, port values). You can ask Teleport to do something
for a particular type with the --type option.

Expand Down
2 changes: 1 addition & 1 deletion platforms/teleport-docker/.teleport.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}
},
"typesByName": {
"localhost": {
"development": {
},
"production": {
"subDomain": "",
Expand Down
2 changes: 1 addition & 1 deletion platforms/teleport-heroku/.teleport.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"iconUrl": "https://raw.githubusercontent.com/snipsco/teleport/master/platforms/teleport-heroku/teleport-heroku.png",
"isPlatform": true,
"typesByName": {
"localhost": {
"development": {
},
"production": {
"abbreviation": "prod",
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ class Teleport {
if (typeof project.config === 'undefined') {
project.config = {
typesByName: {
localhost: {}
development: {}
}
}
}
// if there is no deployment platform template, then we should escape if we want
// to do a build, push, run, deploy
const types = Object.keys(project.config.typesByName)
if (Object.keys(types).length === 1 &&
types[0] === 'localhost' &&
types[0] === 'development' &&
(program.build || program.push || program.run || program.deploy)) {
this.consoleError('You want to do a deploy task or sub-tasks, but you did not specified a platform template in this project')
process.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions src/methods/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import path from 'path'

export function build () {
const { project, program } = this
// type is localhost by default, but here we want to deploy
// type is development by default, but here we want to deploy
// so we set actually the default to staging here
if (program.type === 'localhost') {
if (program.type === 'development') {
program.type = 'staging'
}
this.setTypeEnvironment()
Expand Down
2 changes: 1 addition & 1 deletion src/methods/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// bundle is the task that will bundle your project locally.
// - it goes to each server and execute their scripts/$TYPE_bundle.sh
// script.
// - if $TYPE is localhost, it runs the server of assets and scripts that you may have if you have a frontend
// - if $TYPE is development, it runs the server of assets and scripts that you may have if you have a frontend
// bundler like webpack, otherwise it triggers a bundle prod

import childProcess from 'child_process'
Expand Down
4 changes: 2 additions & 2 deletions src/methods/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export function configureProjectConfig () {
})
)

// add a default localhost type if there was not a platform template
// add a default development type if there was not a platform template
// that did taht already
if (typeof project.config.typesByName === 'undefined') {
project.config.typesByName = {
localhost: {}
development: {}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/methods/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// DEPLOY TASK
// deploy is the last task that to call when you want to push a project
// outside of your localhost environment, given a certain typed context.
// outside of your development environment, given a certain typed context.
// (Usually type can be "staging" or "production")
// - it first checks if we need to bundle the frontend part.
// - it then calls, for each server, the deploy method that will execute their scripts/<type>_deploy.sh
Expand All @@ -12,7 +12,7 @@ import path from 'path'

export function deploy () {
const { project, program } = this
// type is localhost by default, but here we want to deploy
// type is development by default, but here we want to deploy
// so we set actually the default to staging here
if (program.type === 'development') {
program.type = 'staging'
Expand Down
4 changes: 2 additions & 2 deletions src/methods/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ export function installServers () {
program.image = undefined
program.method = 'installServer'
program.methods = null
program.type = 'localhost'
program.type = 'development'
this.setTypeEnvironment()
this.mapInServers()
}

export function installServer () {
const { app, program, server } = this
const commands = []
let fileName = `localhost_install.sh`
let fileName = `development_install.sh`
let fileDir = path.join(server.dir, 'scripts', fileName)
if (!fs.existsSync(fileDir)) {
fileName = 'install.sh'
Expand Down
4 changes: 2 additions & 2 deletions src/methods/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

export function push () {
const { program } = this
// type is localhost by default, but here we want to deploy
// type is development by default, but here we want to deploy
// so we set actually the default to staging here
if (program.type === 'localhost') {
if (program.type === 'development') {
program.type = 'staging'
}
this.setTypeEnvironment()
Expand Down
30 changes: 15 additions & 15 deletions src/methods/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// In these files all the $[] instances are replaced with values from this teleport object.
// You can check more precisely how the formatString function works in the ../utils/functions.js.
// Note also that the replace method will for each <REPLACE_FOR_EACH_TYPE>_<file_name> placeholder file
// create one file per type (localhost, staging and production in the common case).
// Meaning that you will have localhost_<file_name>, staging_<file_name>,
// create one file per type (development, staging and production in the common case).
// Meaning that you will have development_<file_name>, staging_<file_name>,
// production_<file_name> created.
// - replace goes to your bundler folder and does the same thing

Expand All @@ -32,7 +32,7 @@ const dockerPlaceholderfiles = [
'start.sh'
]

const notLocalhostPlaceholderFiles = [
const notDevelopmentPlaceholderFiles = [
/.*push.sh$/,
/.*controller.sh$/,
/.*build.sh$/,
Expand Down Expand Up @@ -67,7 +67,7 @@ export function replaceServerPlaceholderFiles () {
welcome = this.welcome
}
// connect if no port was set here
if (type.name !== 'localhost' && typeof run.port === 'undefined') {
if (type.name !== 'development' && typeof run.port === 'undefined') {
this.connect()
}
// add types
Expand Down Expand Up @@ -114,28 +114,28 @@ export function replaceServerPlaceholderFiles () {
const templatePathDir = dirChunks.slice(0, -1).join('/')
let installedFileName = dirChunks.slice(-1)[0]
.replace(templatePrefix, '')
if (type.name === 'localhost') {
if (type.name === 'development') {
// we know that there are some script and config files dedicated to the deploy step
// so we don't have actually to write them for the localhost type case
if (notLocalhostPlaceholderFiles.some(notLocalhostPlaceholderFile => {
return notLocalhostPlaceholderFile.test(installedFileName)
// so we don't have actually to write them for the development type case
if (notDevelopmentPlaceholderFiles.some(notDevelopmentPlaceholderFile => {
return notDevelopmentPlaceholderFile.test(installedFileName)
})) {
return
}
// no need also to replace and write when actually there is already the
// locahost placeholder file
const localhostTemplateDir = `${templatePathDir}/<REPLACE>localhost_${installedFileName}`
if (fs.existsSync(localhostTemplateDir)) {
// development placeholder file
const developmentTemplateDir = `${templatePathDir}/<REPLACE>development_${installedFileName}`
if (fs.existsSync(developmentTemplateDir)) {
return
}
} else if (installedFileName.split('_')[0] === 'localhost') {
// also we have some specific placeholder files dedicated to localhost
// so if we are not to the localhost case we have to leave
} else if (installedFileName.split('_')[0] === 'development') {
// also we have some specific placeholder files dedicated to development
// so if we are not to the development case we have to leave
return
}
// if we are not in the case of a deploy file
// we can escape
if (type.name !== 'localhost' && typeof backend.helpersByName.docker === 'undefined' &&
if (type.name !== 'development' && typeof backend.helpersByName.docker === 'undefined' &&
dockerPlaceholderfiles.includes(installedFileName)) {
return
}
Expand Down
4 changes: 2 additions & 2 deletions src/methods/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

export function run () {
const { program } = this
// type is localhost by default, but here we want to deploy
// type is development by default, but here we want to deploy
// so we set actually the default to staging here
if (program.type === 'localhost') {
if (program.type === 'development') {
program.type = 'staging'
}
this.setTypeEnvironment()
Expand Down
8 changes: 4 additions & 4 deletions src/methods/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function setTypeEnvironment () {
if (typesByName) {
const type = this.type = Object.assign({}, typesByName[program.type])
type.name = program.type
type.pip = type.name === 'localhost'
type.pip = type.name === 'development'
? pip
: 'pip'
}
Expand Down Expand Up @@ -247,7 +247,7 @@ export function setRunEnvironment () {
// that are done here
server.runsByTypeName[type.name] = run
// set the docker image
if (run.name !== 'localhost') {
if (run.name !== 'development') {
if (backend.helpersByName && backend.helpersByName.kubernetes) {
run.nodeName = `${run.infraName}.${backend.helpersByName.kubernetes.nodeDomain}`
// special case where we give to the host just the name of the dockerHost
Expand All @@ -263,12 +263,12 @@ export function setRunEnvironment () {
: `${type.abbreviation.toUpperCase()}_`
run.virtualName = `${virtualNamePrefix}${backend.capitalUnderscoreSiteName}_${server.abbreviation.toUpperCase()}_SERVICE_HOST`
} else {
run.tag = `localhost-${server.tag}`
run.tag = `development-${server.tag}`
}
// set the url
run.url = run.host
? `http://${run.host}`
: (run.name === 'localhost' ? 'http://localhost' : `https://${backend.siteName}.${backend.domain}`)
: (run.name === 'development' ? 'http://localhost' : `https://${backend.siteName}.${backend.domain}`)
if (run.port) {
run.url += ':' + run.port
}
Expand Down
4 changes: 2 additions & 2 deletions src/methods/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// start is the task that will run your project locally.
// - it goes to each server and execute their scripts/$TYPE_start.sh
// script.
// - if $TYPE is localhost, it runs the server of assets and scripts that you may have if you have a frontend
// - if $TYPE is development, it runs the server of assets and scripts that you may have if you have a frontend
// bundler like webpack, otherwise it triggers a bundle prod


Expand Down Expand Up @@ -102,7 +102,7 @@ export function startServer () {
export function getStartServerCommand () {
const { app, program, server, type } = this
const commands = []
const fileName = 'localhost_start.sh'
const fileName = 'development_start.sh'
commands.push(`export TYPE=${type.name}`)
commands.push(`cd ${server.dir}`)
commands.push(`sh scripts/${fileName}`)
Expand Down
4 changes: 2 additions & 2 deletions tests/test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const TEST_TEMPLATES = [
'teleport-heroku'
].join(',')
const TAGS = [
`localhost-${TEST_APP_NAME}-wbr`,
`localhost-${TEST_APP_NAME}-wbs`,
`development-${TEST_APP_NAME}-wbr`,
`development-${TEST_APP_NAME}-wbs`,
`${TEST_APP_NAME}-wbr`,
`${TEST_APP_NAME}-wbs`,
`stg-${TEST_APP_NAME}-wbr`,
Expand Down

0 comments on commit fd39d27

Please sign in to comment.