Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit 61a1117

Browse files
Merge pull request #17 from livestorm/liv-5386-review-command
feat: improving the way we deal with metadata, liv-5386
2 parents a4912b5 + 4eee698 commit 61a1117

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

src/cmds/create.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const prompts = require('prompts')
44
const path = require('path')
55
const rimraf = require('rimraf')
66

7+
const defaultMetadata = require('../helpers/defaultMetadata')
8+
79
const questions = [
810
{
911
type: 'text',
@@ -63,6 +65,7 @@ module.exports = () => {
6365
const environments = require(`${pathForPlugin(answers.name)}/environments.json`)
6466
environments.development.name = answers.name
6567
environments.development.apiToken = answers.apiToken || ''
68+
environments.development.metadata = defaultMetadata(answers)
6669
fs.writeFileSync(
6770
`./livestorm-plugin-${answers.name}/environments.json`,
6871
JSON.stringify(environments, null, 2)
@@ -71,7 +74,7 @@ module.exports = () => {
7174
execSync(`cd ${pathForPlugin(answers.name)} && git init && git add --a && git commit -m "First commit"`)
7275

7376
console.log('All done 🙌')
74-
console.log(`If you need to change any of the pre-given answers feel free to edit ./${directoryNameFor(answers.name)}/package.json`)
77+
console.log(`If you need to change any of the pre-given answers feel free to edit ./${directoryNameFor(answers.name)}/environments.json`)
7578
console.log(`You can start coding by opening ./${directoryNameFor(answers.name)}/index.ts`)
7679
console.log(`Visit https://github.com/livestorm/livestorm-plugin for documentation`)
7780
} catch(err) {

src/cmds/review.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { execSync } = require('child_process')
99
const uploadFileOrDirectory = require('../helpers/uploadFileOrDirectory')
1010
const getLivestormPluginInformation = require('../helpers/getLivestormPluginInformation')
1111
const livestormDomain = require('../helpers/livestormDomain')
12+
const validateMetadata = require('../helpers/validateMetadata')
1213

1314
const questions = [
1415
{
@@ -76,6 +77,7 @@ module.exports = async function review() {
7677
console.log('Syncing plugin code...')
7778
execSync('livestorm publish production')
7879
answers.metadata = config.metadata
80+
validateMetadata(config.metadata)
7981
}
8082

8183
const zipUrl = await uploadZip(createZip())

src/helpers/defaultMetadata.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
module.exports = function defaultMetadata(answers) {
3+
return {
4+
logo: "https://uploads-ssl.webflow.com/60ad0f9314e628baa6971a76/60ec0b72f45280483f7957cf_Icon-Livestorm-Primary.svg",
5+
translations: {
6+
title: {
7+
en: answers.name.charAt(0).toUpperCase() + answers.name.slice(1)
8+
},
9+
description: {
10+
en: "This is your plugin description, you can change it by editing the metadata of your plugin's environment."
11+
}
12+
}
13+
}
14+
}

src/helpers/validateMetadata.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
function validateMetadata(json) {
3+
try {
4+
if (!json) throw 'Your environment is missing the "metadata" property.'
5+
if (!json.logo) throw 'No logo provided in the "metadata" property.'
6+
7+
if (!json.translations) throw 'Your "metadata" must include a translations object to display your plugin in the marketplace.'
8+
if (!json.translations.title) throw 'You must provide a title in the translations object.'
9+
if (!json.translations.title.en) throw 'Your title does not contain english translations.'
10+
11+
if (!json.translations.description) throw 'You must provide a translated description in the translations object.'
12+
if (!json.translations.description.en) throw 'Your description does not contain english translations.'
13+
} catch(err) {
14+
console.log(err)
15+
console.log('Make sure your environment\'s "metadata" property follows the correct pattern: https://developers.livestorm.co/docs/review-marketplace#submit-your-plugin-to-the-marketplace')
16+
process.exit(1)
17+
}
18+
}
19+
20+
module.exports = validateMetadata

0 commit comments

Comments
 (0)