Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat community templates #68

Merged
merged 6 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for community templates (action)
  • Loading branch information
lowlighter committed Jan 19, 2021
commit 6635944103fe450166dd265aa8bda42ad7f0c117
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ inputs:
description: SVG optimization
default: yes

# Setup additional templates from remote repositories (like forks)
# Format is : user/repo@branch:template
# To use a community template, set "template" option to "@template" (where template is the template name)
setup_community_templates:
description: Additional community templates to setup
default: ""

# Timezone used by metrics
# See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# Some plugins will use it to calibrate dates
Expand Down
8 changes: 7 additions & 1 deletion source/app/action/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@
}
}

//Pre-Setup
const community = {
templates:input.array("setup_community_templates")
}
info("Setup - community templates", community.templates)

//Load configuration
const {conf, Plugins, Templates} = await setup({log:false, nosettings:true})
const {conf, Plugins, Templates} = await setup({log:false, nosettings:true, community})
info("Setup", "complete")
info("Version", conf.package.version)

Expand Down
2 changes: 1 addition & 1 deletion source/app/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
logger(`metrics/setup > load package.json > success`)

//Load community template
if (Array.isArray(conf.settings.community.templates)) {
if ((Array.isArray(conf.settings.community.templates))&&(conf.settings.community.templates.length)) {
//Clean remote repository
logger(`metrics/setup > ${conf.settings.community.templates.length} community templates to install`)
await fs.promises.rmdir(path.join(__templates, ".community"), {recursive:true})
Expand Down
15 changes: 14 additions & 1 deletion tests/metrics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,17 @@
...input
})).toBe(true), 60*1e3)
})
)
)

describe("Additional options", () => {
test("Community templates", async () => expect(await action.run({
token:"MOCKED_TOKEN",
plugin_pagespeed_token:"MOCKED_TOKEN",
plugin_tweets_token:"MOCKED_TOKEN",
plugin_music_token:"MOCKED_CLIENT_ID, MOCKED_CLIENT_SECRET, MOCKED_REFRESH_TOKEN",
template:"@classic", base:"",
config_timezone:"Europe/Paris",
plugins_errors_fatal:true, dryrun:true, use_mocked_data:true, verify:true,
setup_community_templates:"lowlighter/metrics@master:classic",
})).toBe(true), 60*1e3)
})