-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jjurman
committed
Sep 10, 2017
1 parent
9d9d846
commit d8976fc
Showing
22 changed files
with
180 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
tram-one-example | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#! /usr/bin/env node | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const appTitle = process.argv[2] || 'tram-one-app' | ||
|
||
const processFile = (file, currentPath) => { | ||
const filePath = path.join(currentPath, file) | ||
const newFilePath = filePath | ||
.replace(path.join(__dirname, 'template'), path.join(process.cwd(), appTitle)) | ||
|
||
// copy a directory | ||
if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) { | ||
// make the directory | ||
if (fs.existsSync(newFilePath)) { | ||
console.warn(`Folder ${newFilePath} already exists`) | ||
} else { | ||
fs.mkdirSync(newFilePath) | ||
} | ||
|
||
// process all the files in the directory | ||
const files = fs.readdirSync(filePath) | ||
files.forEach((file) => processFile(file, filePath)) | ||
return | ||
} | ||
|
||
// copy a file | ||
const normalFile = fs.readFileSync(filePath) | ||
.toString() | ||
.replace('%TITLE%', appTitle) | ||
if (fs.existsSync(newFilePath)) { | ||
console.warn(`File ${newFilePath} already exists`) | ||
} else { | ||
fs.appendFileSync(newFilePath, normalFile) | ||
} | ||
} | ||
|
||
const filePath = path.join(__dirname, 'template') | ||
console.log(`${Creating} appTitle`) | ||
processFile('', filePath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
{ | ||
"name": "tram-one-express", | ||
"version": "1.0.7", | ||
"version": "2.0.0", | ||
"description": "Generator to build Tram-One applications quickly", | ||
"bin": "./prompts.js", | ||
"bin": "./generator.js", | ||
"files": [ | ||
"template", | ||
"generate.js", | ||
"prompts.js" | ||
"generator.js" | ||
], | ||
"main": "prompts.js", | ||
"main": "generator.js", | ||
"keywords": [ | ||
"tram-one", | ||
"generator" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf ./tram-one-example", | ||
"start": "node prompts.js", | ||
"start": "node generator tram-one-example", | ||
"poststart": "npm --prefix ./tram-one-example install ./tram-one-example", | ||
"example-start": "npm --prefix ./tram-one-example start", | ||
"example-test": "npm --prefix ./tram-one-example test" | ||
}, | ||
"author": "Jesse Jurman", | ||
"license": "MIT", | ||
"dependencies": { | ||
"inquirer": "^3.2.2" | ||
"inquirer": "^3.2.2", | ||
"mem-fs": "^1.1.3", | ||
"mem-fs-editor": "^3.0.2" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Distributable | ||
dist | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# %TITLE% | ||
|
||
## Developement Instructions | ||
1. In the root directory, run `npm install` to install all the project dependencies | ||
2. Run `npm start` to start the dev server | ||
3. Navigate to http://localhost:9966 (or the url provided after running `npm start`) | ||
|
||
## Developement Commands | ||
Below are a list of commands used for developement. The logic for all the commands are in the local `package.json` | ||
- `npm start` - starts a server hosting the webapp on localhost using budo; will live update with changes | ||
- `npm run build` - builds a final distributable using browserify | ||
- `npm run test-dev` - starts a server hosting test files on localhost; Test results are shown when you navigate to the webapp on a browser | ||
- `npm test` - runs tests against all browsers on the device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const Tram = require('tram-one') | ||
const html = Tram.html() | ||
|
||
module.exports = () => { | ||
return html` | ||
<h1> | ||
%TITLE% | ||
</h1> | ||
` | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
module.exports = (options) => ` | ||
const Tram = require('tram-one') | ||
const html = Tram.html() | ||
|
||
const app = new Tram() | ||
app.addRoute('/', require('./pages/home')) | ||
app.addRoute('/404', require('./pages/404')) | ||
app.start('.main') | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "%TITLE%", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"start": "budo main.js:bundle.js --pushstate --dir public --live", | ||
"prebuild": "cp -r public/ dist", | ||
"build": "browserify ./main.js -o ./dist/bundle.js -t [ babelify --presets [ env ] ]", | ||
"test-build": "browserify ./specs/specs.js -o ./specs/spec-bundle.js -t [ babelify --presets [ env ] ]", | ||
"test-dev": "testem -f ./specs/testem.yml", | ||
"test": "testem ci -f ./specs/testem.yml" | ||
}, | ||
"keywords": [ | ||
"%TITLE%", | ||
"tram-one" | ||
], | ||
"dependencies": { | ||
"babel-preset-env": "^1.6.0", | ||
"babelify": "^7.3.0", | ||
"browserify": "^14.4.0", | ||
"budo": "^10.0.4", | ||
"testem": "^1.16.2", | ||
"tram-one": "^1.4.1" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const Tram = require('tram-one') | ||
const html = Tram.html() | ||
|
||
module.exports = () => { | ||
return html` | ||
<div> | ||
<h1>404</h1> | ||
<code>No route ${window.location.pathname}</code><br> | ||
Check <code>%TITLE%/main.js</code> to see all the available routes. | ||
</div> | ||
` | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
module.exports = (options) => ` | ||
const Tram = require('tram-one') | ||
const html = Tram.html({ | ||
header: require('../elements/header') | ||
}) | ||
|
||
module.exports = (${options.extraParams ? 'state' : ''}) => { | ||
return html\` | ||
module.exports = () => { | ||
return html` | ||
<div> | ||
<header></header> | ||
<div> | ||
Thank you for using Tram-One!<br> | ||
To get started, edit <code>${options.name}/pages/home.js</code>. | ||
To get started, edit <code>%TITLE%/pages/home.js</code>. | ||
</div> | ||
</div> | ||
\` | ||
` | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<head> | ||
<title>%TITLE%</title> | ||
<link rel="icon" type="image/png" href="./favicon.png" /> | ||
</head> | ||
<body> | ||
<div class="main"></div> | ||
<script src="bundle.js"></script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
4 changes: 1 addition & 3 deletions
4
template/specs/header-spec.js.js → template/specs/header-spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
module.exports = (options) => ` | ||
const header = require('../elements/header') | ||
|
||
describe('header', () => { | ||
it('should have the title', () => { | ||
const page = header() | ||
expect(page.textContent).toEqual('${options.name}') | ||
expect(page.textContent).toMatch('%TITLE%') | ||
}) | ||
}) | ||
` |
Oops, something went wrong.