UNPKG

@zauberware/weblate-create-components

Version:

You need `curl` to be installed. It is installed per default on each unix-like machine.

18 lines (14 loc) 631 B
const { join } = require('path') const { formatHeaders, getComponentData, getResponse } = require('./helpers.js') const createComponent = async (options) => { let obj = getComponentData({ ...options, }); const data = JSON.stringify(obj, null, 2); console.log('data', data) console.log('options', options) const url = join(options.apiUrl, '/projects', options.projectName, '/components/'); console.log(`[+] Creating component in project [${options.projectName}] with name [${obj.name}]`) return await getResponse(url, `-X POST -d '${data}'`, formatHeaders(options.headers)) } module.exports = createComponent