Skip to content

Commit

Permalink
Generate restaurant data files from a script
Browse files Browse the repository at this point in the history
  • Loading branch information
camjackson committed Jul 1, 2018
1 parent 643176e commit d1587ea
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 88 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
content/restaurants*
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ node_js:
before_install:
- pip install --upgrade --user awscli

install: "echo 'This is static content - nothing to install!'"
script:
- mkdir build
- mv images build
- mv style.css build
- yarn build

deploy:
provider: s3
bucket: content.demo.microfrontends.com
local_dir: build
local_dir: content
skip_cleanup: true

after_deploy:
Expand Down
93 changes: 93 additions & 0 deletions buildData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const fs = require('fs');

const restaurants = [
{
id: '1',
name: "Becky's Burgers",
priceRange: '$$',
imageSrc: '/images/1-burger.jpg',
imageDescription: 'A photo of a burger with fries',
description: 'Juicy burgers, crunchy fries, and creamy shakes',
},
{
id: '2',
name: 'Chicken Nice',
priceRange: '$',
imageSrc: '/images/2-chicken-rice.jpg',
imageDescription: 'A photo of Hainanese chicken rice',
description: "The world's best Hainanese Chicken Rice",
},
{
id: '3',
name: "Nonna's pizza and pasta",
priceRange: '$$',
imageSrc: '/images/3-pizza.jpg',
imageDescription: 'A photo of a margherita pizza',
description: 'Classic pizza and pasta just like Nonna used to make',
},
{
id: '4',
name: 'Super satay skewers',
priceRange: '$$',
imageSrc: '/images/4-satay.jpg',
imageDescription: 'A photo of some satay skewers with sauce',
description: "Satay so good it'll save the world",
},
{
id: '5',
name: 'Curry delights',
priceRange: '$$$',
imageSrc: '/images/5-curry.jpg',
imageDescription: 'A photo of Indian curries',
description: 'The best Indian curries from the freshest ingredients',
},
{
id: '6',
name: 'Sliced',
priceRange: '$',
imageSrc: '/images/6-sandwich.jpg',
imageDescription: 'A photo of a sandwich',
description: 'Fresh sandwhiches at great prices',
},
{
id: '7',
name: 'Taste of Iberia',
priceRange: '$$$$',
imageSrc: '/images/7-paella.jpg',
imageDescription: 'A photo of Spanish Paella',
description: 'Paella, tapas, and imported Spanish wines',
},
{
id: '8',
name: 'Crunchy Crunch',
priceRange: '$$',
imageSrc: '/images/8-fried-chicken.jpg',
imageDescription: 'A photo of crispy fried chicken',
description: "The city's best Southern-style fried chicken",
},
{
id: '9',
name: "Japan's finest",
priceRange: '$$$',
imageSrc: '/images/9-sushi.jpg',
imageDescription: 'A photo of sushi and sashimi',
description: 'Only the freshest fish and tastiest katsu',
},
{
id: '10',
name: "Chippo's",
priceRange: '$',
imageSrc: '/images/10-fish-n-chips.jpg',
imageDescription: 'A photo of deep-fried fish with thick-cut hot chips',
description: 'Authentic Aussie-style fish n chips',
},
];

fs.writeFileSync('./content/restaurants.json', JSON.stringify(restaurants));
fs.mkdirSync('./content/restaurants');
restaurants.forEach(restaurant => {
fs.writeFileSync(
`./content/restaurants/${restaurant.id}.json`,
JSON.stringify(restaurant),
);
});
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
"author": "Cam Jackson <camjackson89@gmail.com>",
"license": "MIT",
"scripts": {
"start": "serve --port 5000 --cors"
"build": "node buildData.js",
"start": "serve --port 5000 --cors content"
},
"devDependencies": {
"prettier": "^1.13.7",
"serve": "^6.5.2"
},
"prettier": {
"singleQuote": true,
"trailingComma": "all"
}
}
82 changes: 0 additions & 82 deletions restaurants.json

This file was deleted.

4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ prepend-http@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"

prettier@^1.13.7:
version "1.13.7"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.7.tgz#850f3b8af784a49a6ea2d2eaa7ed1428a34b7281"

pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
Expand Down

0 comments on commit d1587ea

Please sign in to comment.