Adds publish command to register all domains

This commit is contained in:
Akshay Nair committed 2020-10-05 14:45:46 +05:30
1 parent a9ba56908d
commit e1ea243243
2 files changed
+9 -6

No files matched your search

+2 -1
View File
@@ -3,7 +3,8 @@
"version": "1.0.0", "version": "1.0.0",
"description": "Register *.is-a.dev domains for free", "description": "Register *.is-a.dev domains for free",
"scripts": { "scripts": {
"test": "jest" "test": "jest",
"publish-records": "yarn test && node ./scripts/register-domains.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
+7 -5
View File
@@ -1,7 +1,7 @@
const R = require('ramda'); const R = require('ramda');
const { VALID_RECORD_TYPES, TTL } = require('../utils/constants'); const { VALID_RECORD_TYPES, TTL } = require('../utils/constants');
const { domainService: domain } = require('../utils/domain-service'); const { domainService: dc } = require('../utils/domain-service');
const { getDomains } = require('../utils/domain'); const { getDomains: gd } = require('../utils/domain');
const getRecords = R.compose(R.toPairs, R.pick(VALID_RECORD_TYPES)); const getRecords = R.compose(R.toPairs, R.pick(VALID_RECORD_TYPES));
@@ -21,11 +21,13 @@ const toHostList = R.chain(data => {
const registerDomains = async ({ domainService, getDomains }) => { const registerDomains = async ({ domainService, getDomains }) => {
const domains = await getDomains().then(toHostList); const domains = await getDomains().then(toHostList);
await domainService.updateHosts(domains); return domainService.updateHosts(domains);
}; };
const main = () => { const main = async () => {
console.log('Running cli'); console.log('Registering domains...');
const result = await registerDomains({ domainService: dc, getDomains: gd });
console.log(result);
}; };
if (require.main === module) { if (require.main === module) {