├── .dockerignore ├── .gitignore ├── .travis.yml ├── Dockerfile ├── LICENSE ├── README-NOW.md ├── README.md ├── app.json ├── package.json └── server.js /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | .next 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .DS_Store 4 | .env 5 | .next 6 | now.json 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | matrix: 4 | include: 5 | - node_js: "8" 6 | 7 | notifications: 8 | email: false -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:8 2 | # Create directory 3 | RUN mkdir -p /usr/src/app 4 | WORKDIR /usr/src/app 5 | # Install dependencies 6 | COPY package.json /usr/src/app/ 7 | RUN npm install 8 | # Copy files 9 | COPY . /usr/src/app 10 | # RUN npm run start 11 | EXPOSE 3000 12 | CMD [ "npm", "start" ] 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 OpenComponents community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README-NOW.md: -------------------------------------------------------------------------------- 1 | # Starter Kit 2 | 3 | Get up and running with OpenComponents in 3 simple steps. 4 | 5 | Before starting make sure you have: 6 | - An account on [Now](https://zeit.co/now) and its [CLI installed](https://zeit.co/download#command-line) 7 | - An [S3](https://aws.amazon.com/s3) bucket on AWS 8 | 9 | ## #1 - Deploy the OpenComponents Registry to Now 10 | 11 | Clone this repository locally: 12 | 13 | ``` 14 | $ git clone https://github.com/opencomponents/starter-kit && cd starter-kit 15 | ``` 16 | 17 | Add the needed secrets environment variables with the now CLI: 18 | 19 | - `s3-key` 20 | - `s3-secret` 21 | - `s3-region` 22 | - `s3-bucket` 23 | - `publish-username` 24 | - `publish-password` 25 | 26 | ``` 27 | $ now secret s3-key yourvaluehere 28 | ... 29 | ``` 30 | 31 | and make them available as environment variables: 32 | 33 | ``` 34 | $ now -e S3_KEY=@s3-key -e S3_SECRET=@s3-secret -e S3_REGION=@s3-region -e S3_BUCKET=@s3-bucket -e PUBLISH_USERNAME=@publish-username -e PUBLISH_PASSWORD=@publish-password 35 | ``` 36 | 37 | For further help with the now CLI, please refere to their [docs](https://zeit.co/docs/features/now-cli) 38 | 39 | You are now ready to deploy, simply type: 40 | 41 | ``` 42 | $ now 43 | ``` 44 | 45 | If prompted, choose the Dockerfile deploy 46 | 47 | 48 | ## #2 - Build your first component 49 | 50 | Install the OpenComponents CLI 51 | 52 | ``` 53 | $ npm install -g oc 54 | ``` 55 | 56 | Create your first component: 57 | 58 | ``` 59 | $ oc init my-first-component 60 | ``` 61 | 62 | Develop/Test locally by starting a local dev registry 63 | 64 | ``` 65 | $ oc dev . 3030 66 | ``` 67 | 68 | Your component will be available at: 69 | 70 | - endpoint: [http://localhost:3030/my-first-component](http://localhost:3030/my-first-component) 71 | 72 | - info: [http://localhost:3030/my-first-component/~info](http://localhost:3030/my-first-component/~info) 73 | 74 | - fullPreview: [http://localhost:3030/my-first-component/~preview](http://localhost:3030/my-first-component/~preview) 75 | 76 | ## #3 Publish the component to the registry 77 | 78 | Add the registry to the CLI: 79 | 80 | ``` 81 | $ oc registry add http://my-registryurl.on.now.sh/ 82 | ``` 83 | 84 | Publish your component 85 | 86 | ``` 87 | $ oc publish my-first-component --username=YOURVALUEHERE --password=YOURVALUEHERE 88 | ``` 89 | 90 | Your component is now published 🎉 🎉 🎉 ! 91 | 92 | You can consume it here: `http://my-registryurl.on.now.sh/my-first-component` 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Starter Kit 2 | 3 | [![Greenkeeper badge](https://badges.greenkeeper.io/opencomponents/get-started.svg)](https://greenkeeper.io/) 4 | 5 | Get up and running with OpenComponents in 3 simple steps. 6 |
💁 This guide relies on Heroku for its deploy, if you wish to rely on [Now](https://zeit.co/now) instead, [click here](README-NOW.md). 7 | 8 | 9 | Before starting make sure you have: 10 | - An account on [Heroku](https://signup.heroku.com/) 11 | - An [S3](https://aws.amazon.com/s3) bucket on AWS 12 | 13 | ## #1 - Deploy the OpenComponents registry to Heroku 14 | 15 | Click the button below and follow the instructions. 16 | 17 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/opencomponents/starter-kit) 18 | 19 | ## #2 - Build your first component 20 | 21 | Install the OpenComponents CLI 22 | 23 | ``` 24 | $ npm install -g oc 25 | ``` 26 | 27 | Create your first component: 28 | 29 | ``` 30 | $ oc init my-first-component 31 | ``` 32 | 33 | Develop/Test locally by starting a local dev registry 34 | 35 | ``` 36 | $ oc dev . 3030 37 | ``` 38 | 39 | Your component will be available at: 40 | 41 | - endpoint: [http://localhost:3030/my-first-component](http://localhost:3030/my-first-component) 42 | 43 | - info: [http://localhost:3030/my-first-component/~info](http://localhost:3030/my-first-component/~info) 44 | 45 | - fullPreview: [http://localhost:3030/my-first-component/~preview](http://localhost:3030/my-first-component/~preview) 46 | 47 | ## #3 Publish the component to the registry 48 | 49 | Add the registry using the CLI: 50 | 51 | ``` 52 | $ oc registry add http://my-registry.on.herokuapp.com/ 53 | ``` 54 | 55 | Publish your component 56 | 57 | ``` 58 | $ oc publish my-first-component --username=YOURVALUEHERE --password=YOURVALUEHERE 59 | ``` 60 | 61 | Your component is now published 🎉 🎉 🎉 ! 62 | 63 | You can consume it here: `http://my-registry.on.herokuapp.com/my-first-component` 64 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oc-registry", 3 | "description": "A barebone OpenComponents registry", 4 | "repository": "https://github.com/opencomponents/starter-kit", 5 | "logo": "https://avatars2.githubusercontent.com/u/28356951?v=4&s=200", 6 | "keywords": [ 7 | "opencomponents", 8 | "registry", 9 | "microfrontends", 10 | "node" 11 | ], 12 | "env": { 13 | "BASEURL": { 14 | "description": "The base url of the registry, ie: https://your-app-name.herokuapp.com", 15 | "value": "" 16 | }, 17 | "S3_KEY": { 18 | "description": "Your AWS S3 Key", 19 | "value": "" 20 | }, 21 | "S3_SECRET": { 22 | "description": "Your AWS S3 Secret", 23 | "value": "" 24 | }, 25 | "S3_REGION": { 26 | "description": "Your AWS S3 Region", 27 | "value": "" 28 | }, 29 | "S3_BUCKET": { 30 | "description": "Your AWS Bucket Name", 31 | "value": "" 32 | }, 33 | "PUBLISH_USERNAME": { 34 | "description": "The username needed to publish to the registry", 35 | "value": "" 36 | }, 37 | "PUBLISH_PASSWORD": { 38 | "description": "The password needed to publish to the registry", 39 | "value": "" 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "opencomponents-starter-kit", 3 | "version": "1.0.0", 4 | "description": "Get up and running with OpenComponents in 3 simple steps", 5 | "scripts": { 6 | "test": "true" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/opencomponents/get-started.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/opencomponents/get-started/issues" 14 | }, 15 | "homepage": "https://github.com/opencomponents/get-started#readme", 16 | "author": { 17 | "name": "Nick Balestra", 18 | "email": "nick@balestra.ch" 19 | }, 20 | "license": "MIT", 21 | "dependencies": { 22 | "dotenv": "^6.0.0", 23 | "oc": "^0.44.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Store ENV variables in .env to set up your local development 4 | // https://github.com/motdotla/dotenv#usage 5 | require('dotenv').config(); 6 | const Registry = require('oc').Registry; 7 | 8 | // Minimal configuration for the registry 9 | // For advanced configuration check the documantion: 10 | // https://github.com/opentable/oc/wiki/Registry 11 | const configuration = { 12 | baseUrl: process.env.NOW_URL || process.env.BASEURL, 13 | port: process.env.PORT || 3000, 14 | publishAuth: { 15 | type: 'basic', 16 | username: process.env.PUBLISH_USERNAME, 17 | password: process.env.PUBLISH_PASSWORD 18 | }, 19 | s3: { 20 | key: process.env.S3_KEY, 21 | secret: process.env.S3_SECRET, 22 | bucket: process.env.S3_BUCKET, 23 | region: process.env.S3_REGION, 24 | path: `//s3.${process.env.S3_REGION}.amazonaws.com/${process.env.S3_BUCKET}/`, 25 | componentsDir: 'components' 26 | }, 27 | dependencies: [] 28 | }; 29 | 30 | // Instantiate the registry 31 | // An express.js app is exposed as registry.app 32 | const registry = new Registry(configuration); 33 | registry.start(function (err, app) { 34 | if (err) { 35 | console.log('Registry not started: ', err); 36 | process.exit(1); 37 | } 38 | }); 39 | --------------------------------------------------------------------------------