code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
getReadmeTemplate = async templatePath => {
const spinner = ora('Loading README template').start()
try {
const template = await promisify(fs.readFile)(templatePath, 'utf8')
spinner.succeed('README template loaded')
return template
} catch (err) {
spinner.fail('README template loading fail')
t... | Get README template content from the given templatePath
@param {string} templatePath | getReadmeTemplate | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
buildReadmeContent = async (context, templatePath) => {
const currentYear = getYear(new Date())
const template = await getReadmeTemplate(templatePath)
return ejs.render(template, {
filename: templatePath,
currentYear,
...context
})
} | Build README content with the given context and templatePath
@param {Object} context
@param {string} templatePath | buildReadmeContent | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
buildReadmeContent = async (context, templatePath) => {
const currentYear = getYear(new Date())
const template = await getReadmeTemplate(templatePath)
return ejs.render(template, {
filename: templatePath,
currentYear,
...context
})
} | Build README content with the given context and templatePath
@param {Object} context
@param {string} templatePath | buildReadmeContent | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
validateReadmeTemplatePath = templatePath => {
const spinner = ora('Resolving README template path').start()
try {
fs.lstatSync(templatePath).isFile()
} catch (err) {
spinner.fail(`The template path '${templatePath}' is not valid.`)
throw err
}
spinner.succeed('README template path resolved')
} | Validate template path
@param {string} templatePath | validateReadmeTemplatePath | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
validateReadmeTemplatePath = templatePath => {
const spinner = ora('Resolving README template path').start()
try {
fs.lstatSync(templatePath).isFile()
} catch (err) {
spinner.fail(`The template path '${templatePath}' is not valid.`)
throw err
}
spinner.succeed('README template path resolved')
} | Validate template path
@param {string} templatePath | validateReadmeTemplatePath | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
getReadmeTemplatePath = async (customTemplate, useDefaultAnswers) => {
const templatePath = isNil(customTemplate)
? await chooseTemplate(useDefaultAnswers)
: customTemplate
validateReadmeTemplatePath(templatePath)
return templatePath
} | Get readme template path
(either a custom template, or a template that user will choose from prompt)
@param {String} customTemplate | getReadmeTemplatePath | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
getReadmeTemplatePath = async (customTemplate, useDefaultAnswers) => {
const templatePath = isNil(customTemplate)
? await chooseTemplate(useDefaultAnswers)
: customTemplate
validateReadmeTemplatePath(templatePath)
return templatePath
} | Get readme template path
(either a custom template, or a template that user will choose from prompt)
@param {String} customTemplate | getReadmeTemplatePath | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
checkOverwriteReadme = () =>
!fs.existsSync(README_PATH) || askOverwriteReadme() | Check if readme generator can overwrite the existed readme | checkOverwriteReadme | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
checkOverwriteReadme = () =>
!fs.existsSync(README_PATH) || askOverwriteReadme() | Check if readme generator can overwrite the existed readme | checkOverwriteReadme | javascript | kefranabg/readme-md-generator | src/readme.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js | MIT |
getGitRepositoryName = cwd => {
try {
return getReposName.sync({ cwd })
// eslint-disable-next-line no-empty
} catch (err) {
return undefined
}
} | Get git repository name
@param {String} cwd | getGitRepositoryName | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getGitRepositoryName = cwd => {
try {
return getReposName.sync({ cwd })
// eslint-disable-next-line no-empty
} catch (err) {
return undefined
}
} | Get git repository name
@param {String} cwd | getGitRepositoryName | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getDefaultAnswer = async (question, answersContext) => {
if (question.when && !question.when(answersContext)) return undefined
switch (question.type) {
case 'input':
return typeof question.default === 'function'
? question.default(answersContext)
: question.default || ''
case 'checkbo... | Get the default answer depending on the question type
@param {Object} question | getDefaultAnswer | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getDefaultAnswer = async (question, answersContext) => {
if (question.when && !question.when(answersContext)) return undefined
switch (question.type) {
case 'input':
return typeof question.default === 'function'
? question.default(answersContext)
: question.default || ''
case 'checkbo... | Get the default answer depending on the question type
@param {Object} question | getDefaultAnswer | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
isProjectAvailableOnNpm = projectName => {
try {
execSync(`npm view ${projectName}`, { stdio: 'ignore' })
return true
} catch (err) {
return false
}
} | Return true if the project is available on NPM, return false otherwise.
@param projectName
@returns boolean | isProjectAvailableOnNpm | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
isProjectAvailableOnNpm = projectName => {
try {
execSync(`npm view ${projectName}`, { stdio: 'ignore' })
return true
} catch (err) {
return false
}
} | Return true if the project is available on NPM, return false otherwise.
@param projectName
@returns boolean | isProjectAvailableOnNpm | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getDefaultAnswers = questions =>
questions.reduce(async (answersContextProm, question) => {
const answersContext = await answersContextProm
return {
...answersContext,
[question.name]: await getDefaultAnswer(question, answersContext)
}
}, Promise.resolve({})) | Get default question's answers
@param {Array} questions | getDefaultAnswers | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getDefaultAnswers = questions =>
questions.reduce(async (answersContextProm, question) => {
const answersContext = await answersContextProm
return {
...answersContext,
[question.name]: await getDefaultAnswer(question, answersContext)
}
}, Promise.resolve({})) | Get default question's answers
@param {Array} questions | getDefaultAnswers | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getAuthorWebsiteFromGithubAPI = async githubUsername => {
try {
const userData = await fetch(
`${GITHUB_API_URL}/users/${githubUsername}`
).then(res => res.json())
const authorWebsite = userData.blog
return isNil(authorWebsite) || isEmpty(authorWebsite)
? undefined
: authorWebsite
... | Get author's website from Github API
@param {string} githubUsername
@returns {string} authorWebsite | getAuthorWebsiteFromGithubAPI | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getAuthorWebsiteFromGithubAPI = async githubUsername => {
try {
const userData = await fetch(
`${GITHUB_API_URL}/users/${githubUsername}`
).then(res => res.json())
const authorWebsite = userData.blog
return isNil(authorWebsite) || isEmpty(authorWebsite)
? undefined
: authorWebsite
... | Get author's website from Github API
@param {string} githubUsername
@returns {string} authorWebsite | getAuthorWebsiteFromGithubAPI | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
doesFileExist = filepath => {
try {
return fs.existsSync(filepath)
} catch (err) {
return false
}
} | Returns a boolean whether a file exists or not
@param {String} filepath
@returns {Boolean} | doesFileExist | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
doesFileExist = filepath => {
try {
return fs.existsSync(filepath)
} catch (err) {
return false
}
} | Returns a boolean whether a file exists or not
@param {String} filepath
@returns {Boolean} | doesFileExist | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getPackageManagerFromLockFile = () => {
const packageLockExists = doesFileExist('package-lock.json')
const yarnLockExists = doesFileExist('yarn.lock')
if (packageLockExists && yarnLockExists) return undefined
if (packageLockExists) return 'npm'
if (yarnLockExists) return 'yarn'
return undefined
} | Returns the package manager from the lock file
@returns {String} packageManger or undefined | getPackageManagerFromLockFile | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
getPackageManagerFromLockFile = () => {
const packageLockExists = doesFileExist('package-lock.json')
const yarnLockExists = doesFileExist('yarn.lock')
if (packageLockExists && yarnLockExists) return undefined
if (packageLockExists) return 'npm'
if (yarnLockExists) return 'yarn'
return undefined
} | Returns the package manager from the lock file
@returns {String} packageManger or undefined | getPackageManagerFromLockFile | javascript | kefranabg/readme-md-generator | src/utils.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/utils.js | MIT |
buildFormattedChoices = engines =>
isNil(engines)
? null
: Object.keys(engines).map(key => ({
name: `${key} ${engines[key]}`,
value: {
name: key,
value: engines[key]
},
checked: true
})) | Return engines as formatted choices
@param {Object} engines | buildFormattedChoices | javascript | kefranabg/readme-md-generator | src/questions/project-prerequisites.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/questions/project-prerequisites.js | MIT |
buildFormattedChoices = engines =>
isNil(engines)
? null
: Object.keys(engines).map(key => ({
name: `${key} ${engines[key]}`,
value: {
name: key,
value: engines[key]
},
checked: true
})) | Return engines as formatted choices
@param {Object} engines | buildFormattedChoices | javascript | kefranabg/readme-md-generator | src/questions/project-prerequisites.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/questions/project-prerequisites.js | MIT |
hasProjectInfosEngines = projectInfos =>
!isNil(projectInfos.engines) && !isEmpty(projectInfos.engines) | Check if projectInfos has engines properties
@param {Object} projectInfos | hasProjectInfosEngines | javascript | kefranabg/readme-md-generator | src/questions/project-prerequisites.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/questions/project-prerequisites.js | MIT |
hasProjectInfosEngines = projectInfos =>
!isNil(projectInfos.engines) && !isEmpty(projectInfos.engines) | Check if projectInfos has engines properties
@param {Object} projectInfos | hasProjectInfosEngines | javascript | kefranabg/readme-md-generator | src/questions/project-prerequisites.js | https://github.com/kefranabg/readme-md-generator/blob/master/src/questions/project-prerequisites.js | MIT |
async function saveVueggProject (project, owner, repo, token) {
try {
return await axios.post('/api/project', { project, owner, repo, token })
} catch (e) {
console.error(e)
return false
}
} | Saves the current vuegg project definition in the specify repository
@param {object} project : Project definition to be saved in the repository (as vue.gg)
@param {string} owner : Repository owner
@param {string} repo : Repository where to save the project definition
@param {string} token : Authentication token
@r... | saveVueggProject | javascript | alxpez/vuegg | client/src/api/index.js | https://github.com/alxpez/vuegg/blob/master/client/src/api/index.js | MIT |
async function getVueggProject (owner, repo, token) {
try {
return await axios.get('/api/project', { params: { owner, repo, token } })
} catch (e) {
console.error(e)
return false
}
} | Retrieves the base64 vue.gg project definition from the especified repository.
@param {string} owner : owner of the repository
@param {string} repo : repository to get the vue.gg project definition from
@param {string} [token] : oauth2 token (for access private repos) [unused for now]
@return {string} : base64 stri... | getVueggProject | javascript | alxpez/vuegg | client/src/api/index.js | https://github.com/alxpez/vuegg/blob/master/client/src/api/index.js | MIT |
async function generateVueSources (project) {
try {
return await axios.post('/api/generate', project, {responseType: 'blob'})
} catch (e) {
console.error(e)
return false
}
} | Generated vuejs sources from a vuegg project definition
@param {object} project : current project
@return {blob} : A zip file containing the vuejs sources of the passed project | generateVueSources | javascript | alxpez/vuegg | client/src/api/index.js | https://github.com/alxpez/vuegg/blob/master/client/src/api/index.js | MIT |
async function authorizeUser () {
const oauthOpen = promisify(open)
const STATE = shortid.generate()
const authUrl = 'https://github.com/login/oauth/authorize'
.concat('?client_id=').concat(CLIENT_ID)
.concat('&redirect_uri=').concat(REDIRECT_URL)
.concat('&state=').concat(STATE)
.concat('&scope=... | Displays the login with GitHub screen to the user (as a popup or new tab),
if everything ok, closes the login screen and retrieves an authentication token for the logged user.
If something goes wrong in the process returns false.
@return {string|false} : Returns the authentication token or false if something goes wro... | authorizeUser | javascript | alxpez/vuegg | client/src/auth/index.js | https://github.com/alxpez/vuegg/blob/master/client/src/auth/index.js | MIT |
async function _getAccessToken (code) {
try {
let resp = await axios.post('/api/get-access-token', { code: code })
return resp.data
} catch (e) {
console.error(e)
return false
}
} | Displays the login with GitHub screen to the user (as a popup or new tab),
if everything ok, closes the login screen and retrieves an authentication token for the logged user.
If something goes wrong in the process returns false.
@return {string|false} : Returns the authentication token or false if something goes wro... | _getAccessToken | javascript | alxpez/vuegg | client/src/auth/index.js | https://github.com/alxpez/vuegg/blob/master/client/src/auth/index.js | MIT |
async function getAuthenticatedUser (token) {
try {
let resp = await axios.get('https://api.github.com/user', {
headers: {
'Authorization': 'bearer '.concat(token)
}
})
return resp.data
} catch (e) {
console.error(e)
return false
}
} | Retrieves the current authenticated user info
@param {string} token : Authentication token for the logged user
@return {object} Authenticated user | getAuthenticatedUser | javascript | alxpez/vuegg | client/src/auth/index.js | https://github.com/alxpez/vuegg/blob/master/client/src/auth/index.js | MIT |
function compInst (component) {
return {
global: true,
name: component.name,
top: component.top,
left: component.left,
bottom: component.bottom,
right: component.right,
componegg: component.componegg,
egglement: component.egglement,
containegg: component.containegg
}
} | Returns the component instance from the base component provided
@param {object} component : base component to generate the instance
@return {object} : Component instance
@see {@link [types.registerElement]}
@see {@link [types.duplicatePage]} | compInst | javascript | alxpez/vuegg | client/src/factories/componentFactory.js | https://github.com/alxpez/vuegg/blob/master/client/src/factories/componentFactory.js | MIT |
function compRef (component) {
return {
usageCount: 1,
name: component.name,
height: component.height,
width: component.width,
type: component.type,
text: component.text,
attrs: component.attrs,
styles: component.styles,
classes: component.classes,
children: component.children,... | Returns the component reference from the base component provided
@param {object} component : base component to generate the instance
@return {object} : Component reference
@see {@link [types.registerElement]}
@see {@link [types.duplicatePage]} | compRef | javascript | alxpez/vuegg | client/src/factories/componentFactory.js | https://github.com/alxpez/vuegg/blob/master/client/src/factories/componentFactory.js | MIT |
function fixElementToParentBounds (element, parent) {
const parentH = getComputedProp('height', parent)
const parentW = getComputedProp('width', parent)
let height = getComputedProp('height', element, parent)
let width = getComputedProp('width', element, parent)
let top = element.top
let left = element.lef... | Fixes the properties (top, left, height, width) of an element,
based on the parent container
@param {object} element : The element to which fix its props
@param {object} parent : Parent element of the 'element'
@return {object} : Object with clean/fixed top, left, height, width properties for the element | fixElementToParentBounds | javascript | alxpez/vuegg | client/src/helpers/positionDimension.js | https://github.com/alxpez/vuegg/blob/master/client/src/helpers/positionDimension.js | MIT |
function getComputedProp (prop, element, parent) {
if (prop === 'left' || prop === 'right' || prop === 'top' || prop === 'bottom') {
return parseInt(window.getComputedStyle(document.getElementById(element.id).parentNode)[prop])
} else {
return (
(!parent)
? parseInt(window.getComputedStyle(doc... | Calculates the computed prop of an element,
based on its own props and the parent props.
(Specially created to deal with percentage dimensions)
@param {object} element : The element to get the dimension for
@param {object} parent : The parent element of the 'element'
@param {string} prop : Property for which to extra... | getComputedProp | javascript | alxpez/vuegg | client/src/helpers/positionDimension.js | https://github.com/alxpez/vuegg/blob/master/client/src/helpers/positionDimension.js | MIT |
function setElId (el, parentId) {
let elId = shortid.generate()
if (parentId) elId = parentId.concat('.', elId)
let newElement = {...el, id: elId, children: []}
if (el.children && el.children.length > 0) {
for (let childEl of el.children) {
newElement.children.push(setElId(childEl, elId))
}
}
... | Assigns a new id to the element preceded by the parentId and a dot '.'
@param {object} el : Element to register
@param {string} [parentId] : Id of the parent element
@return {object} : New element (cloned from egglement) with newly assigned ids | setElId | javascript | alxpez/vuegg | client/src/helpers/recursiveMethods.js | https://github.com/alxpez/vuegg/blob/master/client/src/helpers/recursiveMethods.js | MIT |
function getExtGlobComps (el, compList) {
if (!compList) compList = []
if (el.global || el.external) compList.push(el)
if (el.children && el.children.length > 0) {
for (let childEl of el.children) {
compList = getExtGlobComps(childEl, compList)
}
}
return compList
} | Creates an array containing all the global/external components inside.
@param {object} el : Current reviewing element
@return {object} : An array with the global/external components found inside. | getExtGlobComps | javascript | alxpez/vuegg | client/src/helpers/recursiveMethods.js | https://github.com/alxpez/vuegg/blob/master/client/src/helpers/recursiveMethods.js | MIT |
function getChildNode (currentNode, targetId) {
if (currentNode.id === targetId) return currentNode
for (let child of currentNode.children) {
if (targetId.indexOf(child.id) !== -1) {
return getChildNode(child, targetId)
}
}
} | Returns the element identified by targetId, which could be the
currentNode itself, one of its children... (and down to any depth)
@param {object} currentNode : The element being inspected
@param {string} targetId : The id of the element expected
@return {object} : The element identified by targetId | getChildNode | javascript | alxpez/vuegg | client/src/helpers/recursiveMethods.js | https://github.com/alxpez/vuegg/blob/master/client/src/helpers/recursiveMethods.js | MIT |
function calcRelativePoint (currentNode, targetId, currentX, currentY) {
if (currentNode.id === targetId) return {left: currentX, top: currentY}
if (currentNode.left && currentNode.top) {
currentX -= currentNode.left
currentY -= currentNode.top
}
for (let child of currentNode.children) {
if (target... | Returns the element --identified by targetId-- relative position,
based on its parent (and full family depth) position
and the current mouse left/top position.
This method gives positioning support for elements changing "family".
@param {object} currentNode : The element being inspected
@param {string} targetId : The... | calcRelativePoint | javascript | alxpez/vuegg | client/src/helpers/recursiveMethods.js | https://github.com/alxpez/vuegg/blob/master/client/src/helpers/recursiveMethods.js | MIT |
canUndo () {
// There should always be at least one state (initializeState)
return this.done.length > 1
} | Vue Mixin to control the State history and undo/redo functionality
@type {Vue.mixin}
@see {@link https://vuejs.org/v2/guide/mixins.html|Vue Mixins} | canUndo | javascript | alxpez/vuegg | client/src/mixins/redoundo.js | https://github.com/alxpez/vuegg/blob/master/client/src/mixins/redoundo.js | MIT |
canRedo () {
return this.undone.length > 0
} | Vue Mixin to control the State history and undo/redo functionality
@type {Vue.mixin}
@see {@link https://vuejs.org/v2/guide/mixins.html|Vue Mixins} | canRedo | javascript | alxpez/vuegg | client/src/mixins/redoundo.js | https://github.com/alxpez/vuegg/blob/master/client/src/mixins/redoundo.js | MIT |
undo () {
if (this.canUndo) {
this.undone.push(this.done.pop())
let undoState = this.done[this.done.length - 1]
this.$store.replaceState(cloneDeep(undoState))
this.$root.$emit('rebaseState')
this.updateCanRedoUndo()
}
} | Vue Mixin to control the State history and undo/redo functionality
@type {Vue.mixin}
@see {@link https://vuejs.org/v2/guide/mixins.html|Vue Mixins} | undo | javascript | alxpez/vuegg | client/src/mixins/redoundo.js | https://github.com/alxpez/vuegg/blob/master/client/src/mixins/redoundo.js | MIT |
redo () {
if (this.canRedo) {
let redoState = this.undone.pop()
this.done.push(redoState)
this.$store.replaceState(cloneDeep(redoState))
this.$root.$emit('rebaseState')
this.updateCanRedoUndo()
}
} | Vue Mixin to control the State history and undo/redo functionality
@type {Vue.mixin}
@see {@link https://vuejs.org/v2/guide/mixins.html|Vue Mixins} | redo | javascript | alxpez/vuegg | client/src/mixins/redoundo.js | https://github.com/alxpez/vuegg/blob/master/client/src/mixins/redoundo.js | MIT |
updateCanRedoUndo () {
this.$store.commit(_toggleCanUndo, this.canUndo)
this.$store.commit(_toggleCanRedo, this.canRedo)
} | Vue Mixin to control the State history and undo/redo functionality
@type {Vue.mixin}
@see {@link https://vuejs.org/v2/guide/mixins.html|Vue Mixins} | updateCanRedoUndo | javascript | alxpez/vuegg | client/src/mixins/redoundo.js | https://github.com/alxpez/vuegg/blob/master/client/src/mixins/redoundo.js | MIT |
function elementsFromPoint (x, y) {
return (document.elementsFromPoint) ? document.elementsFromPoint(x, y) : elementsFromPointPolyfill(x, y)
} | Returns an array of HTML elements located under the point specified by x, y.
If the native elementsFromPoint function does not exist, a polyfill will be used.
@param {number} x : X position
@param {number} y : Y position
@return {array} : Array of the elements under the point (x, y) | elementsFromPoint | javascript | alxpez/vuegg | client/src/polyfills/elementsFromPoint.js | https://github.com/alxpez/vuegg/blob/master/client/src/polyfills/elementsFromPoint.js | MIT |
function elementsFromPointPolyfill (x, y) {
var parents = []
var parent = void 0
do {
if (parent !== document.elementFromPoint(x, y)) {
parent = document.elementFromPoint(x, y)
parents.push(parent)
parent.style.pointerEvents = 'none'
} else {
parent = false
}
} while (parent)... | Polyfill that covers the functionality of the native document.elementsFromPoint
function, in case that the browser does not support it.
@param {number} x : X position
@param {number} y : Y position
@return {array} : Array of the elements under the point (x, y) | elementsFromPointPolyfill | javascript | alxpez/vuegg | client/src/polyfills/elementsFromPoint.js | https://github.com/alxpez/vuegg/blob/master/client/src/polyfills/elementsFromPoint.js | MIT |
async function getAccessToken (ctx) {
try {
let resp = await auth.getAccessToken(ctx.request.body)
ctx.response.status = 200
ctx.response.type = 'text/plain'
ctx.response.body = resp
} catch (e) {
console.error('\n> Could not obtain token\n' + e)
process.exit(1)
}
} | [getAccessToken description]
@param {[type]} ctx [description]
@return {[type]} [description] | getAccessToken | javascript | alxpez/vuegg | server/server.js | https://github.com/alxpez/vuegg/blob/master/server/server.js | MIT |
async function saveVueggProject (ctx) {
try {
let resp = await github.saveVueggProject(ctx.request.body)
if (resp) {
ctx.response.status = 200
ctx.response.body = resp
ctx.response.type = 'text/plain'
}
} catch (e) {
console.error('\n> Could not save the project definition\n' + e)
... | Saves a vuegg project file in Github
@param {object} ctx : KoaContext object
@param {object} ctx.request.body : Body of the POST request
@see {@link http://koajs.com/#context|Koa Context} | saveVueggProject | javascript | alxpez/vuegg | server/server.js | https://github.com/alxpez/vuegg/blob/master/server/server.js | MIT |
async function getVueggProject (ctx) {
let params = ctx.request.query
try {
let resp = await github.getContent(params.owner, params.repo, 'vue.gg', params.token)
if (resp) {
ctx.response.status = 200
ctx.response.body = resp
ctx.response.type = 'application/json'
}
} catch (e) {
... | Retrieves a vuegg project file from Github
@param {object} ctx : KoaContext object
@param {object} ctx.request.body : Body of the POST request
@see {@link http://koajs.com/#context|Koa Context} | getVueggProject | javascript | alxpez/vuegg | server/server.js | https://github.com/alxpez/vuegg/blob/master/server/server.js | MIT |
async function generate (ctx) {
try {
let zipFile = await generator(ctx.request.body, ROOT_DIR)
if (zipFile) {
console.log('> Download -> ' + zipFile)
ctx.response.status = 200
ctx.response.type = 'zip'
ctx.response.body = fs.createReadStream(zipFile)
}
} catch (e) {
console.... | Generates a full vue application from a scaffold project,
plus the app definition sent in the ctx.request.body
@param {object} ctx : KoaContext object
@param {object} ctx.request.body : Body of the POST request
@return {zipFile} : A zip file with the generated application should be served
@see {@link http://koajs.co... | generate | javascript | alxpez/vuegg | server/server.js | https://github.com/alxpez/vuegg/blob/master/server/server.js | MIT |
async function _generator (content, rootDir) {
const spinner = ora({spinner: 'circleHalves'})
let targetDir = path.resolve(rootDir, 'tmp', content.id)
let zippedProject = path.resolve(rootDir, 'tmp', content.id + '.zip')
try {
spinner.start('> Getting environment ready')
targetDir = await prepare(conte... | Index of the project generator libraries.
@constructor
@param {object} content : Definition of the project to be generated
@param {string} rootDir : The root folder of vuegg-server | _generator | javascript | alxpez/vuegg | server/api/generator/index.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/index.js | MIT |
function _cssBuilder (el, isRoot) {
if ((!isRoot || !el.egglement) && (!el.styles || Object.keys(el.styles).length === 0)) return ''
const selector = isRoot ? '#' : '.'
const className = el.id.substr(el.id.lastIndexOf(".") + 1)
let styleDef = ''
let fullStyle = {}
if (isRoot) {
fullStyle = buildRoot(... | Given an element definition, extracts the css/styles from that element
and its children (by recursive calling) and contatenates them on a sigle String object.
If the el is a componegg, its children won't be parsed.
@constructor
@param {object} el : Element from which the style definitions will be gathered
@return {st... | _cssBuilder | javascript | alxpez/vuegg | server/api/generator/builder/css.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/css.js | MIT |
function buildRoot (el) {
let rootCSS = el.styles
if (typeof el.width !== 'undefined' && el.width !== null) {
rootCSS = {...rootCSS, width: isNaN(el.width) ? el.width : (el.width + 'px')}
}
if (typeof el.height !== 'undefined' && el.height !== null) {
rootCSS = {...rootCSS, height: isNaN(el.height) ? e... | Creates the CSS for the root element | buildRoot | javascript | alxpez/vuegg | server/api/generator/builder/css.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/css.js | MIT |
function buildNested (el) {
let nestedCSS = el.egglement ? {...el.styles, position: 'absolute'} : el.styles
if (typeof el.width !== 'undefined' && el.width !== null && el.width !== 'auto') {
nestedCSS = {...nestedCSS, width: isNaN(el.width) ? el.width : (el.width + 'px')}
}
if (typeof el.height !== 'undefi... | Creates the CSS definition for a nested element | buildNested | javascript | alxpez/vuegg | server/api/generator/builder/css.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/css.js | MIT |
function _htmlBuilder (el, level) {
const className = el.id.substr(el.id.lastIndexOf(".") + 1)
let elDef = ""
let elTag = el.type
let elProps = {'class': S(className).replaceAll('.', '-').s + parseBooleanPropsToString(el.classes)}
if (el.global) {
elTag = S(el.name).humanize().slugify().s
} else {
... | Given an egglement definition, creates a single String with the element as
a HTML-tag, its properties and nested children (by recursive calling).
If the egglement is a componegg, its props and children won't be parsed.
@constructor
@param {object} el : Element from which tag/props will be gathered
@param {number} leve... | _htmlBuilder | javascript | alxpez/vuegg | server/api/generator/builder/html.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/html.js | MIT |
function parseBooleanPropsToString (propList) {
let parsedString = ''
for (prop in propList) {
if (propList[prop] === true) parsedString += ' ' + prop
}
return parsedString
} | Given an egglement definition, creates a single String with the element as
a HTML-tag, its properties and nested children (by recursive calling).
If the egglement is a componegg, its props and children won't be parsed.
@constructor
@param {object} el : Element from which tag/props will be gathered
@param {number} leve... | parseBooleanPropsToString | javascript | alxpez/vuegg | server/api/generator/builder/html.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/html.js | MIT |
function isSelfClosing (tag) {
return SCT.includes(tag)
} | Given an egglement definition, creates a single String with the element as
a HTML-tag, its properties and nested children (by recursive calling).
If the egglement is a componegg, its props and children won't be parsed.
@constructor
@param {object} el : Element from which tag/props will be gathered
@param {number} leve... | isSelfClosing | javascript | alxpez/vuegg | server/api/generator/builder/html.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/html.js | MIT |
async function _routerBuilder (content, targetDir) {
const templateFile = path.resolve(targetDir,'templates','router','index.js')
const targetFile = path.resolve(targetDir,'src','router','index.js')
try {
await shell.cp(templateFile, targetFile)
} catch (e) {
log.error('\n > Could not copy ' + targetFi... | Given the project's content definition, copies the router file template,
and replaces the placeholders with the information of the project's pages.
@constructor
@param {object} content : Definition of the project to be generated
@param {string} targetDir : Folder to host the generated project for the given content | _routerBuilder | javascript | alxpez/vuegg | server/api/generator/builder/router.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/router.js | MIT |
async function _vueBuilder (file, componentRefs, targetDir) {
const fileName = S(file.name).stripPunctuation().camelize().titleCase().s
const fileType = file.componegg ? 'components' : 'pages'
const templateFile = path.resolve(targetDir,'templates','vue','default.vue')
const targetFile = path.resolve(targetDir... | Given a file definition (page or component), copies the vue file template,
and replaces the placeholders with the information of the file.
Generates nested components by recursive calls to the constructor function.
@constructor
@param {object} file : Definition of vue file to be generated
@param {object} componentRef... | _vueBuilder | javascript | alxpez/vuegg | server/api/generator/builder/vue.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/vue.js | MIT |
function getAllGlobalComponents (file, collection) {
if (file.children && file.children.length > 0) {
for (let el of file.children) {
if (el.componegg && el.global && (collection.indexOf(comp => comp.name === el.name) === -1)) {
collection.push(el)
}
collection = getAllGlobalComponents (... | Given a file definition (page or component), copies the vue file template,
and replaces the placeholders with the information of the file.
Generates nested components by recursive calls to the constructor function.
@constructor
@param {object} file : Definition of vue file to be generated
@param {object} componentRef... | getAllGlobalComponents | javascript | alxpez/vuegg | server/api/generator/builder/vue.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/vue.js | MIT |
function getComponentRef (components, componentName) {
return components[components.findIndex(comp => comp.name === componentName)]
} | Given a file definition (page or component), copies the vue file template,
and replaces the placeholders with the information of the file.
Generates nested components by recursive calls to the constructor function.
@constructor
@param {object} file : Definition of vue file to be generated
@param {object} componentRef... | getComponentRef | javascript | alxpez/vuegg | server/api/generator/builder/vue.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/vue.js | MIT |
function getFormattedAttrs (attrs) {
let formattedAttrs = ''
if (attrs) {
for (attr in attrs) {
if ((typeof attrs[attr] !== 'boolean')) {
formattedAttrs += ' ' + attr + '="' + attrs[attr] + '"'
} else if ((typeof attrs[attr] === 'boolean') && (attrs[attr] === true)) {
formattedAttrs ... | Given a file definition (page or component), copies the vue file template,
and replaces the placeholders with the information of the file.
Generates nested components by recursive calls to the constructor function.
@constructor
@param {object} file : Definition of vue file to be generated
@param {object} componentRef... | getFormattedAttrs | javascript | alxpez/vuegg | server/api/generator/builder/vue.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/builder/vue.js | MIT |
async function _cleanup (targetDir) {
try {
await shell.rm('-rf', targetDir)
} catch (e) {
log.error('\n > Could not remove ' + targetDir)
}
} | Remove the target folder for the generated project after this is been archived
@constructor
@param {string} targetDir : Folder that hosts the generated project (to remove) | _cleanup | javascript | alxpez/vuegg | server/api/generator/environment/cleanup.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/environment/cleanup.js | MIT |
async function _prepare (content, rootDir) {
const tmpDir = path.resolve(rootDir, 'tmp')
const targetDir = path.resolve(tmpDir, content.id)
try {
if (!shell.test('-e', tmpDir)) {
await shell.mkdir('-p', tmpDir)
}
if (shell.test('-e', targetDir)) {
await shell.rm('-rf', targetDir)
}
... | Prepares the environment and clones the scaffold-project for the generation tasks.
Checks if the /tmp folder exists on vuegg-server root (creates it if not),
adds a new folder for the project that will be generated (based on the content)
clones a scaffold project inside the targetDir and returns its full location.
@con... | _prepare | javascript | alxpez/vuegg | server/api/generator/environment/prepare.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/environment/prepare.js | MIT |
async function _archive (content, targetDir) {
const output = fs.createWriteStream(path.resolve(targetDir, '..', content.id + '.zip'))
const archive = archiver('zip', { zlib: { level: 9 } })
// output eventHandlers
output.on('close', () => console.log('> Archived: ' + archive.pointer() + ' total bytes'))
out... | Archives the contens of the project located at
targetDir into a zip-file (writeStream)
@constructor
@param {object} content : Definition of the project generated
@param {string} targetDir : Folder that hosts the generated project | _archive | javascript | alxpez/vuegg | server/api/generator/project/archive.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/project/archive.js | MIT |
async function _refactor (content, targetDir) {
const readmeFile = path.resolve(targetDir, 'README.md')
const indexFile = path.resolve(targetDir, 'index.html')
const packageFile = path.resolve(targetDir, 'package.json')
const mainFile = path.resolve(targetDir, 'src', 'main.js')
shell.sed('-i', '{{PROJECT_TIT... | Finishes the replacement of the project title in README.md, package.json, index.html
and removes the /templates folder from the generated project folder.
@constructor
@param {object} content : Definition of the project generated
@param {string} targetDir : Folder that hosts the generated project for the given content | _refactor | javascript | alxpez/vuegg | server/api/generator/project/refactor.js | https://github.com/alxpez/vuegg/blob/master/server/api/generator/project/refactor.js | MIT |
async function saveVueggProject ({project, owner, repo, token}) {
let existingRepo = await getRepo(owner, repo, token)
if (!existingRepo) { await createRepo(repo, token) }
return await saveFile(project, owner, repo, 'vue.gg', token)
} | Saves the current vuegg project definition in the specify repository
@param {object} project : Project definition to be saved in the repository (as vue.gg)
@param {string} owner : Repository owner
@param {string} repo : Repository where to save the project definition
@param {string} token : Authentication token
@r... | saveVueggProject | javascript | alxpez/vuegg | server/api/github/index.js | https://github.com/alxpez/vuegg/blob/master/server/api/github/index.js | MIT |
async function getRepo (owner, repo, token) {
// octokit.authenticate({type: 'oauth', token})
try {
return await octokit.repos.get({owner, repo})
} catch (e) {
console.log('(REPO) - ' + owner + '/' + repo + ' does not exist')
return false
}
} | [getRepo description]
@param {[type]} owner [description]
@param {[type]} repo [description]
@param {[type]} [token] [description]
@return {[type]} [description] | getRepo | javascript | alxpez/vuegg | server/api/github/index.js | https://github.com/alxpez/vuegg/blob/master/server/api/github/index.js | MIT |
async function createRepo (name, token) {
octokit.authenticate({type: 'oauth', token})
try {
return await octokit.repos.create({name, license_template: 'mit'})
} catch (e) {
console.error('(REPO) - Failed to create: ' + owner + '/' + name)
console.error(e)
return false
}
} | [createRepo description]
@param {[type]} name [description]
@param {[type]} token [description]
@return {[type]} [description] | createRepo | javascript | alxpez/vuegg | server/api/github/index.js | https://github.com/alxpez/vuegg/blob/master/server/api/github/index.js | MIT |
async function getContent (owner, repo, path, token) {
// octokit.authenticate({type: 'oauth', token})
try {
return await octokit.repos.getContent({owner, repo, path})
} catch (e) {
console.error('(FILE) - ' + owner + '/' + repo + '/' + path + ' does not exist')
return false
}
} | [getContent description]
@param {[type]} owner [description]
@param {[type]} repo [description]
@param {[type]} path [description]
@param {[type]} [token] [description]
@return {[type]} [description] | getContent | javascript | alxpez/vuegg | server/api/github/index.js | https://github.com/alxpez/vuegg/blob/master/server/api/github/index.js | MIT |
async function saveFile (content, owner, repo, path, token) {
let existentFile = await getContent(owner, repo, path, token)
let ghData = {
owner, repo, path,
content: Buffer.from(JSON.stringify(content)).toString('base64'),
committer: {name: 'vuegger', email: '35027416+vuegger@users.noreply.github.com'... | [saveFile description]
@param {[type]} content [description]
@param {[type]} owner [description]
@param {[type]} repo [description]
@param {[type]} token [description]
@return {[type]} [description] | saveFile | javascript | alxpez/vuegg | server/api/github/index.js | https://github.com/alxpez/vuegg/blob/master/server/api/github/index.js | MIT |
async function getAccessToken ({code, state}) {
const options = {
method: 'POST',
uri: 'https://github.com/login/oauth/access_token',
form: {
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,
code: code
}
}
try {
let resp = await rp(options)
ret... | [getAccessToken description]
@param {[type]} code [description]
@return {[type]} [description] | getAccessToken | javascript | alxpez/vuegg | server/auth/index.js | https://github.com/alxpez/vuegg/blob/master/server/auth/index.js | MIT |
addEntry(file: string): MochaWebpack {
this.entries = [
...this.entries,
file,
];
return this;
} | Add file run test against
@public
@param {string} file file or glob
@return {MochaWebpack} | addEntry | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
addInclude(file: string): MochaWebpack {
this.includes = [
...this.includes,
file,
];
return this;
} | Add file to include into the test bundle
@public
@param {string} file absolute path to module
@return {MochaWebpack} | addInclude | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
cwd(cwd: string): MochaWebpack {
this.options = {
...this.options,
cwd,
};
return this;
} | Sets the current working directory
@public
@param {string} cwd absolute working directory path
@return {MochaWebpack} | cwd | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
webpackConfig(config: {} = {}): MochaWebpack {
this.options = {
...this.options,
webpackConfig: config,
};
return this;
} | Sets the webpack config
@public
@param {Object} config webpack config
@return {MochaWebpack} | webpackConfig | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
bail(bail: boolean = false): MochaWebpack {
this.options = {
...this.options,
bail,
};
return this;
} | Enable or disable bailing on the first failure.
@public
@param {boolean} [bail]
@return {MochaWebpack} | bail | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
reporter(reporter: string | () => void, reporterOptions: {}): MochaWebpack {
this.options = {
...this.options,
reporter,
reporterOptions,
};
return this;
} | Set reporter to `reporter`, defaults to "spec".
@param {string|Function} reporter name or constructor
@param {Object} reporterOptions optional options
@return {MochaWebpack} | reporter | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
ui(ui: string): MochaWebpack {
this.options = {
...this.options,
ui,
};
return this;
} | Set test UI, defaults to "bdd".
@public
@param {string} ui bdd/tdd
@return {MochaWebpack} | ui | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
fgrep(str: string): MochaWebpack {
this.options = {
...this.options,
fgrep: str,
};
return this;
} | Only run tests containing <string>
@public
@param {string} str
@return {MochaWebpack} | fgrep | javascript | zinserjan/mocha-webpack | src/MochaWebpack.js | https://github.com/zinserjan/mocha-webpack/blob/master/src/MochaWebpack.js | MIT |
constructor(options, answers) {
super();
this.options = utils.merge({}, options);
this.answers = { ...answers };
} | Create an instance of `Enquirer`.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
```
@name Enquirer
@param {Object} `options` (optional) Options to use with all prompts.
@param {Object} `answers` (optional) Answers object to initialize with.
@api public | constructor | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
register(type, fn) {
if (utils.isObject(type)) {
for (let key of Object.keys(type)) this.register(key, type[key]);
return this;
}
assert.equal(typeof fn, 'function', 'expected a function');
const name = type.toLowerCase();
if (fn.prototype instanceof this.Prompt) {
this.prompts[n... | Register a custom prompt type.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
enquirer.register('customType', require('./custom-prompt'));
```
@name register()
@param {String} `type`
@param {Function|Prompt} `fn` `Prompt` class, or a function that returns a `Prompt` class.
@return {Object... | register | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
async prompt(questions = []) {
for (let question of [].concat(questions)) {
try {
if (typeof question === 'function') question = await question.call(this);
await this.ask(utils.merge({}, this.options, question));
} catch (err) {
return Promise.reject(err);
}
}
retur... | Prompt function that takes a "question" object or array of question objects,
and returns an object with responses from the user.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const response = await enquirer.prompt({
type: 'input',
name: 'username',
message: 'What is your username?... | prompt | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
async ask(question) {
if (typeof question === 'function') {
question = await question.call(this);
}
let opts = utils.merge({}, this.options, question);
let { type, name } = question;
let { set, get } = utils;
if (typeof type === 'function') {
type = await type.call(this, question, ... | Prompt function that takes a "question" object or array of question objects,
and returns an object with responses from the user.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const response = await enquirer.prompt({
type: 'input',
name: 'username',
message: 'What is your username?... | ask | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
use(plugin) {
plugin.call(this, this);
return this;
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | use | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
set Prompt(value) {
this._Prompt = value;
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | Prompt | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
get Prompt() {
return this._Prompt || this.constructor.Prompt;
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | Prompt | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
get prompts() {
return this.constructor.prompts;
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | prompts | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
static set Prompt(value) {
this._Prompt = value;
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | Prompt | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
static get Prompt() {
return this._Prompt || require('./lib/prompt');
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | Prompt | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
static get prompts() {
return require('./lib/prompts');
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | prompts | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
static get types() {
return require('./lib/types');
} | Use an enquirer plugin.
```js
const Enquirer = require('enquirer');
const enquirer = new Enquirer();
const plugin = enquirer => {
// do stuff to enquire instance
};
enquirer.use(plugin);
```
@name use()
@param {Function} `plugin` Plugin function that takes an instance of Enquirer.
@return {Object} Returns the Enquir... | types | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
static get prompt() {
const fn = (questions, ...rest) => {
let enquirer = new this(...rest);
let emit = enquirer.emit.bind(enquirer);
enquirer.emit = (...args) => {
fn.emit(...args);
return emit(...args);
};
return enquirer.prompt(questions);
};
utils.mixinEmitt... | Prompt function that takes a "question" object or array of question objects,
and returns an object with responses from the user.
```js
const { prompt } = require('enquirer');
const response = await prompt({
type: 'input',
name: 'username',
message: 'What is your username?'
});
console.log(response);
```
@name En... | prompt | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
fn = (questions, ...rest) => {
let enquirer = new this(...rest);
let emit = enquirer.emit.bind(enquirer);
enquirer.emit = (...args) => {
fn.emit(...args);
return emit(...args);
};
return enquirer.prompt(questions);
} | Prompt function that takes a "question" object or array of question objects,
and returns an object with responses from the user.
```js
const { prompt } = require('enquirer');
const response = await prompt({
type: 'input',
name: 'username',
message: 'What is your username?'
});
console.log(response);
```
@name En... | fn | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
fn = (questions, ...rest) => {
let enquirer = new this(...rest);
let emit = enquirer.emit.bind(enquirer);
enquirer.emit = (...args) => {
fn.emit(...args);
return emit(...args);
};
return enquirer.prompt(questions);
} | Prompt function that takes a "question" object or array of question objects,
and returns an object with responses from the user.
```js
const { prompt } = require('enquirer');
const response = await prompt({
type: 'input',
name: 'username',
message: 'What is your username?'
});
console.log(response);
```
@name En... | fn | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
define = name => {
utils.defineExport(Enquirer, name, () => Enquirer.types[name]);
} | Prompt function that takes a "question" object or array of question objects,
and returns an object with responses from the user.
```js
const { prompt } = require('enquirer');
const response = await prompt({
type: 'input',
name: 'username',
message: 'What is your username?'
});
console.log(response);
```
@name En... | define | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
define = name => {
utils.defineExport(Enquirer, name, () => Enquirer.types[name]);
} | Prompt function that takes a "question" object or array of question objects,
and returns an object with responses from the user.
```js
const { prompt } = require('enquirer');
const response = await prompt({
type: 'input',
name: 'username',
message: 'What is your username?'
});
console.log(response);
```
@name En... | define | javascript | enquirer/enquirer | index.js | https://github.com/enquirer/enquirer/blob/master/index.js | MIT |
autofill = (answers = {}) => {
return enquirer => {
let prompt = enquirer.prompt.bind(enquirer);
let context = { ...enquirer.answers, ...answers };
enquirer.prompt = async questions => {
let list = [].concat(questions || []);
let choices = [];
for (let item of list) {
let value... | Example "autofill" plugin - to achieve similar goal to autofill for web forms.
_This isn't really needed in Enquirer, since the `autofill` option does
effectively the same thing natively_. This is just an example. | autofill | javascript | enquirer/enquirer | examples/autofill-plugin.js | https://github.com/enquirer/enquirer/blob/master/examples/autofill-plugin.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.