Skip to content

Commit f60d96a

Browse files
committed
#0: MVP event adding commands
1 parent 314aa04 commit f60d96a

File tree

9 files changed

+316
-22
lines changed

9 files changed

+316
-22
lines changed

.lando.yml

+4
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ tooling:
5252
blog:
5353
service: cli
5454
cmd: yarn dev:blog
55+
description: Launch the blog
5556
docs:
5657
service: cli
5758
cmd: yarn dev:docs
59+
description: Launch the documentation site
5860
events:
5961
service: cli
6062
cmd: yarn dev:events
63+
description: Launch the events listing
6164
node:
6265
service: cli
6366
platform:
@@ -67,6 +70,7 @@ tooling:
6770
site:
6871
service: cli
6972
cmd: yarn dev:site
73+
description: Launch the marketing site
7074
vuepress:
7175
service: cli
7276
yarn:

api/data/events.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
- name: MidCamp 2020
22
id: wahtever
3-
date: 3-18-2020
4-
url: https://www.midcamp.org/
3+
date: '2020-03-18'
4+
url: 'https://www.midcamp.org/'
55
location: DePaul University
66
presenter: Mike Pirog
77
type: camp
8-
presenterPic: https://www.gravatar.com/avatar/dc1322b3ddd0ef682862d7f281c821bb
9-
presenterLink: https://twitter.com/pirogcommamike
8+
presenterPic: 'https://www.gravatar.com/avatar/dc1322b3ddd0ef682862d7f281c821bb'
9+
presenterLink: 'https://twitter.com/pirogcommamike'
1010
summary: >-
11-
Come hang out with Lando project lead Mike Pirog and hear what we've got in store for you in 2020! There isn't a session but we will buy you a beer!
11+
Come hang out with Lando project lead Mike Pirog and hear what we've got in
12+
store for you in 2020! There isn't a session but we will buy you a beer!
1213
- name: BadCamp 2017
1314
id: wahtever2
14-
date: 10-18-2017
15-
url: https://2017.badcamp.net/session/coding-development/intermediate/future-dev-now
15+
date: '2017-10-18'
16+
url: >-
17+
https://2017.badcamp.net/session/coding-development/intermediate/future-dev-now
1618
location: UC Berkeley
1719
presenter: Mike Pirog
1820
type: camp
19-
presenterPic: https://www.gravatar.com/avatar/dc1322b3ddd0ef682862d7f281c821bb
20-
presenterLink: https://twitter.com/pirogcommamike
21+
presenterPic: 'https://www.gravatar.com/avatar/dc1322b3ddd0ef682862d7f281c821bb'
22+
presenterLink: 'https://twitter.com/pirogcommamike'
2123
summary: >-
22-
Come see (and then use!) the future of local development tools: Lando, a free, open source and cross platform devops tool that is also the most advanced, powerful and easy local development environment in the galaxy.
24+
Come see (and then use!) the future of local development tools: Lando, a
25+
free, open source and cross platform devops tool that is also the most
26+
advanced, powerful and easy local development environment in the galaxy.

plugins/lando-alliance/lib/api.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ module.exports = class LandoApiClient {
2323
/*
2424
* Create a data source
2525
*/
26-
create(source, data = {}) {
27-
const database = this.read(source);
26+
create(source, data = {}, sort = []) {
27+
let database = this.read(source);
2828
database.push(_.merge({}, data, {id: hasher(data)}));
29+
// Sort if we have to
30+
if (!_.isEmpty(sort)) database = _.orderBy(database, ...sort);
31+
// Dump results
2932
this.yaml.dump(path.resolve(this.base, `${source}.yml`), _.uniqBy(database, 'id'));
3033
return this.read(source, {id: hasher(data)});
3134
};
@@ -52,7 +55,7 @@ module.exports = class LandoApiClient {
5255
/*
5356
* Alias of create
5457
*/
55-
update(source, data = {}) {
56-
return this.create(source, data);
58+
update(source, data = {}, sort = []) {
59+
return this.create(source, data, sort);
5760
};
5861
};

plugins/lando-alliance/lib/event.js

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
'use strict';
2+
3+
// Modules
4+
const _ = require('lodash');
5+
const dayjs = require('dayjs');
6+
7+
// Things the contributor helps with
8+
const eventTypes = [
9+
{name: 'Conference, National, 500+ people', value: 'conference'},
10+
{name: 'Camp, Regional, 100+ people', value: 'camp'},
11+
{name: 'Meetup, Local, 10+ people', value: 'meetup'},
12+
{name: 'Other', value: 'other'},
13+
];
14+
15+
// Options for adding a contrib
16+
exports.addOptions = authors => ({
17+
name: {
18+
describe: 'Event name',
19+
string: true,
20+
interactive: {
21+
type: 'input',
22+
message: 'Event name?',
23+
default: 'My Event',
24+
},
25+
},
26+
presenter: {
27+
describe: 'Event presenter',
28+
string: true,
29+
choices: authors,
30+
interactive: {
31+
type: 'list',
32+
message: 'Featuring?',
33+
default: 'Team Lando',
34+
choices: authors,
35+
},
36+
},
37+
date: {
38+
describe: 'Event date',
39+
string: true,
40+
interactive: {
41+
type: 'input',
42+
message: 'Event date (use format YYYY-MM-DD)',
43+
default: dayjs().format('YYYY-MM-DD'),
44+
filter: input => dayjs(input).format('YYYY-MM-DD'),
45+
validate: input => {
46+
return (dayjs(input).isValid()) ? true : 'Enter a valid date';
47+
},
48+
},
49+
},
50+
summary: {
51+
describe: 'Event summary',
52+
string: true,
53+
interactive: {
54+
type: 'input',
55+
default: 'A longer and SEO dense summary',
56+
message: 'Event summary?',
57+
validate: input => {
58+
if (_.size(input) > 280) return 'Must be 280 characters or less!';
59+
return true;
60+
},
61+
},
62+
},
63+
type: {
64+
describe: 'Event Type',
65+
array: true,
66+
alias: ['t'],
67+
choices: eventTypes,
68+
interactive: {
69+
type: 'list',
70+
default: 'meetup',
71+
message: 'Event type or size',
72+
choices: eventTypes,
73+
},
74+
},
75+
location: {
76+
describe: 'Event location',
77+
string: true,
78+
interactive: {
79+
type: 'input',
80+
message: 'Location? (examples: San Francisco, MIT)',
81+
},
82+
},
83+
url: {
84+
describe: 'Event details URL',
85+
string: true,
86+
interactive: {
87+
type: 'input',
88+
message: 'URL of event details?',
89+
},
90+
},
91+
});
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
'use strict';
2+
3+
// Modules
4+
const _ = require('lodash');
5+
const crypto = require('crypto');
6+
const event = require('./../lib/event');
7+
const LandoApiClient = require('./../lib/api');
8+
9+
module.exports = lando => {
10+
// Get the API
11+
const api = new LandoApiClient(lando.log);
12+
// Get the authors
13+
const authors = _.map(api.read('contributors'), author => ({name: author.name, value: author.id}));
14+
authors.unshift({name: 'Team Lando', value: 'Team Lando'});
15+
16+
return {
17+
command: 'event:add',
18+
level: 'tasks',
19+
describe: 'Adds a new Lando event',
20+
options: event.addOptions(authors),
21+
run: options => {
22+
// Build The basic data
23+
const seed = `${options.url}${options.name}${options.presenter}${options.date}`;
24+
const data = _.merge({}, {
25+
id: `${crypto.createHash('md5').update(seed).digest('hex')}`,
26+
presenter: 'Team Lando',
27+
presenterPic: 'https://gravatar.com/avatar/c335f31e62b453f747f39a84240b3bbd',
28+
presenterLink: 'https://twitter.com/devwithlando',
29+
}, _.omitBy(_.omit(options, ['_', '_app', '$0', 'verbose', 'v']), _.isEmpty));
30+
31+
// Replace author data if we have it
32+
if (data.presenter !== 'Team Lando') {
33+
const presenter = _.first(api.read('contributors', {id: data.presenter}));
34+
data.presenter = presenter.name;
35+
data.presenterPic = presenter.pic;
36+
data.presenterLink = presenter.twitter
37+
? `https://twitter.com/${presenter.twitter}` : `https://github.com/${presenter.github}`;
38+
}
39+
40+
// Add to the events
41+
console.log('Added the following event');
42+
console.log(lando.cli.formatData(api.update('events', data, [['date'], ['desc']]), {format: 'table'}));
43+
},
44+
};
45+
};
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
// Modules
4+
const LandoApiClient = require('./../lib/api');
5+
6+
module.exports = lando => ({
7+
command: 'event:list',
8+
level: 'tasks',
9+
describe: 'List Lando events',
10+
options: lando.cli.formatOptions(),
11+
run: options => {
12+
const api = new LandoApiClient(lando.log);
13+
console.log(lando.cli.formatData(api.read('events'), options));
14+
},
15+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
// Modules
4+
const _ = require('lodash');
5+
const LandoApiClient = require('./../lib/api');
6+
7+
module.exports = lando => {
8+
// Get the API client
9+
const api = new LandoApiClient(lando.log);
10+
// Return the task
11+
return {
12+
command: 'event:remove',
13+
level: 'tasks',
14+
describe: 'Removes a Lando event',
15+
options: {
16+
id: {
17+
describe: 'The resource id to remove',
18+
alias: ['i'],
19+
string: true,
20+
interactive: {
21+
type: 'list',
22+
message: 'Which event do you want to remove?',
23+
choices: _(api.read('events'))
24+
.map(event => ({name: event.name, value: event.id}))
25+
.value(),
26+
},
27+
},
28+
yes: lando.cli.confirm('Are you sure?'),
29+
},
30+
run: options => {
31+
const id = api.delete('events', options.id);
32+
console.log(`Removed event with id ${id}`);
33+
},
34+
};
35+
};

plugins/lando-alliance/tasks/guide-generate.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ module.exports = lando => {
9494
run: options => {
9595
// Build The basic data
9696
const data = _.merge({}, {
97-
date: new Date().toISOString(),
98-
filePath: path.join(guidesPath, `${_.kebabCase(options.title)}.md`),
99-
url: `https://docs.lndo.site/guides/${_.kebabCase(options.title)}.html`,
100-
author: 'Team Lando',
101-
pic: 'https://gravatar.com/avatar/c335f31e62b453f747f39a84240b3bbd',
102-
link: 'https://twitter.com/devwithlando',
103-
}, options);
97+
date: new Date().toISOString(),
98+
filePath: path.join(guidesPath, `${_.kebabCase(options.title)}.md`),
99+
url: `https://docs.lndo.site/guides/${_.kebabCase(options.title)}.html`,
100+
author: 'Team Lando',
101+
pic: 'https://gravatar.com/avatar/c335f31e62b453f747f39a84240b3bbd',
102+
link: 'https://twitter.com/devwithlando',
103+
}, options);
104104

105105
// if file already exists then throw error
106-
// if (fs.existsSync(data.filePath)) throw Error(`Guide already exists at ${data.filePath}!`);
106+
if (fs.existsSync(data.filePath)) throw Error(`Guide already exists at ${data.filePath}!`);
107107

108108
// Add new guide to selected category and update categories file
109109
const section = _.find(guidesData, {title: data.category});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: <%= title %>
3+
metaTitle: <%= title %> | Lando
4+
description: <%= description %>
5+
date: <%= date %>
6+
original: <%= original %>
7+
repo: <%= original %>
8+
9+
author:
10+
name: <%= author %>
11+
pic: <%= pic %>
12+
link: <%= link %>
13+
14+
feed:
15+
enable: true
16+
author:
17+
- name: <%= author %>
18+
19+
link: <%= link %>
20+
contributor:
21+
- name: <%= author %>
22+
23+
link: <%= link %>
24+
---
25+
26+
# <%= title %>
27+
28+
<GuideHeader name="<%= author %>" pic="<%= pic %>" link="<%= link %>" />
29+
30+
Here is some demo content to help get you started. We are using it primarily to...
31+
32+
* Give you a decent starting structure for your guide
33+
* Showcase some helpful markdown elements you can use
34+
* Showcase the _kinds_ of things guides should have
35+
36+
Feel free to use none, some or all of this!
37+
38+
::: warning THIS IS DEMO CONTENT!
39+
Note that the below is DEMO CONTENT and exists only to illustrate a possible way to structure a guide as well as the markdown components that can be used, including this warning dialog!
40+
:::
41+
42+
## Proxying the SOLR 7 admin interface
43+
44+
By default Lando does not expose the solr admin interface to the outside world however you can tell Lando to expose it and even give it a nice `*.lndo.site` URL.
45+
46+
::: danger ONLY FOR RECENT VERSIONS OF SOLR
47+
The solr web UI works differently for earlier versions of solr so this _may_ or _may not_ work for those earlier versions.
48+
:::
49+
50+
### Exposing the UI
51+
52+
The key setting to activate is the `portforward` option which comes with our `solr` service. This will tell Lando to both expose the service to the outside world AND to assign a `localhost` address to it.
53+
54+
```yaml
55+
name: lando-solr
56+
services:
57+
index:
58+
type: solr:7
59+
portforward: true
60+
```
61+
62+
Make sure you rebuild your app so the new config will take.
63+
64+
```bash
65+
lando rebuild -y
66+
```
67+
68+
You should see the `localhost` URL when the rebuild completes. :100: :guitar:
69+
70+
71+
### Assigning a proxy route
72+
73+
```yaml
74+
name: lando-solr
75+
proxy:
76+
index:
77+
- admin-solr.lndo.site:8983
78+
services:
79+
index:
80+
type: solr:7
81+
portforward: true
82+
```
83+
84+
::: tip CUSTOM PROXY PORT
85+
Note the `8983` at the end of `admin-solr.lndo.site`. This is needed when the web service is not running on the default `80` or `443` ports. **It does not mean that the service is accessible at `https://admin-solr.lndo.site:8983`.** It means that `https://admin-solr.lndo.site` routes to port `8983` on the `index` service.
86+
:::
87+
88+
Again make sure you rebuild your app so the new config will take.
89+
90+
```bash
91+
lando rebuild -y
92+
```
93+
94+
You should see the `localhost` _and_ proxy URLs when the rebuild completes. :star:
95+
96+
<GuideFooter original="<%= original %>" repo="<%= repo %>"/>
97+
<Newsletter />

0 commit comments

Comments
 (0)