@patternfly/create-element
Advanced tools
Comparing version 0.0.2-next.5 to 1.0.0-next.6
# @patternfly/create-element | ||
## 1.0.0-next.6 | ||
### Major Changes | ||
- 1c99aa06: - fix build script (ship .js to npm) | ||
- bump version to 1.0.0 | ||
## 0.0.2-next.5 | ||
@@ -4,0 +11,0 @@ |
158
main.js
@@ -1,95 +0,81 @@ | ||
import { generateElement } from './generator/element.js'; | ||
import Chalk from 'chalk'; | ||
import Yargs from 'yargs'; | ||
import prompts from 'prompts'; | ||
const ERR_BAD_CE_TAG_NAME = 'Custom element tag names must contain a hyphen (-)'; | ||
import { generateElement } from "./generator/element.js"; | ||
import Chalk from "chalk"; | ||
import Yargs from "yargs"; | ||
import prompts from "prompts"; | ||
const ERR_BAD_CE_TAG_NAME = "Custom element tag names must contain a hyphen (-)"; | ||
const b = Chalk.cyanBright; | ||
function banner() { | ||
console.log(`${Chalk.cyan(` | ||
${b('`qQQQQQQg.')} | ||
'${b('N@@@@@@@;')} | ||
7${b('g@@@@@@@S')} | ||
^QD${b('Q@@@@@@@|')} | ||
+QQQ${b('K@@@@@@@@i')} | ||
'jQQQQD${b('d@@@@@@@@X,')} | ||
,mQQQQQQQb${b('k@@@@@@@@@b+')} | ||
.;7qQQQQQQQQQD~;${b('8@@@@@@@@@8}^\'')} | ||
=77JyU%NQQQQQQQQQNi\` ${b('`cQ@@@@@@@@@@@BKauz|')} | ||
${b('%@@@@@@QQ#')}gDR&QDL. ${b('`iN@@@@@@@@@@@@@@Q')} | ||
${b('%@@@@@@@@@@@QK')}= ${b('+RQ@@@@@@@@@@@Q')} | ||
${b('%@@@@@@@@@@@@@@B7.')} \`?bQBRd%${b('NQQ@@@@@@Q')} | ||
${b('=7uaq#@@@@@@@@@@@Qz`')} \`|WQQQQQQQQQN%UyJ77? | ||
${b('.!Ig@@@@@@@@@B!')},qQQQQQQQQQbz;. | ||
${b('~A@@@@@@@@@X')}qQQQQQQQk^ | ||
${b(';D@@@@@@@@K')}DQQQQK; | ||
${b('*@@@@@@@@b')}NQQ* | ||
${b('=@@@@@@@Q')}dQ< | ||
${b('j@@@@@@@Wx')} | ||
${b('_@@@@@@@Q,')} | ||
${b('`bQQQQQQ%``')} | ||
console.log(`${Chalk.cyan(` | ||
${b("`qQQQQQQg.")} | ||
'${b("N@@@@@@@;")} | ||
7${b("g@@@@@@@S")} | ||
^QD${b("Q@@@@@@@|")} | ||
+QQQ${b("K@@@@@@@@i")} | ||
'jQQQQD${b("d@@@@@@@@X,")} | ||
,mQQQQQQQb${b("k@@@@@@@@@b+")} | ||
.;7qQQQQQQQQQD~;${b("8@@@@@@@@@8}^'")} | ||
=77JyU%NQQQQQQQQQNi\` ${b("`cQ@@@@@@@@@@@BKauz|")} | ||
${b("%@@@@@@QQ#")}gDR&QDL. ${b("`iN@@@@@@@@@@@@@@Q")} | ||
${b("%@@@@@@@@@@@QK")}= ${b("+RQ@@@@@@@@@@@Q")} | ||
${b("%@@@@@@@@@@@@@@B7.")} \`?bQBRd%${b("NQQ@@@@@@Q")} | ||
${b("=7uaq#@@@@@@@@@@@Qz`")} \`|WQQQQQQQQQN%UyJ77? | ||
${b(".!Ig@@@@@@@@@B!")},qQQQQQQQQQbz;. | ||
${b("~A@@@@@@@@@X")}qQQQQQQQk^ | ||
${b(";D@@@@@@@@K")}DQQQQK; | ||
${b("*@@@@@@@@b")}NQQ* | ||
${b("=@@@@@@@Q")}dQ< | ||
${b("j@@@@@@@Wx")} | ||
${b("_@@@@@@@Q,")} | ||
${b("`bQQQQQQ%``")} | ||
${Chalk.bold(Chalk.blue('PatternFly Elements'))} | ||
${Chalk.bold(Chalk.blue("PatternFly Elements"))} | ||
`)}`); | ||
} | ||
export async function promptForElementGeneratorOptions(options) { | ||
banner(); | ||
return { | ||
...options, | ||
...await prompts([{ | ||
type: () => !options?.tagName && 'text', | ||
name: 'tagName', | ||
message: 'What is the element\'s tag name?', | ||
initial: options?.tagName ?? '', | ||
validate: name => name.includes('-') || ERR_BAD_CE_TAG_NAME, | ||
}, { | ||
type: () => !options?.scope && 'text', | ||
name: 'scope', | ||
message: 'What is the package\'s NPM scope?', | ||
initial: options?.scope ?? '' | ||
}]), | ||
}; | ||
banner(); | ||
return { | ||
...options, | ||
...await prompts([{ | ||
type: () => !options?.tagName && "text", | ||
name: "tagName", | ||
message: "What is the element's tag name?", | ||
initial: options?.tagName ?? "", | ||
validate: (name) => name.includes("-") || ERR_BAD_CE_TAG_NAME | ||
}, { | ||
type: () => !options?.scope && "text", | ||
name: "scope", | ||
message: "What is the package's NPM scope?", | ||
initial: options?.scope ?? "" | ||
}]) | ||
}; | ||
} | ||
export async function main() { | ||
return Promise.resolve(Yargs(process.argv) | ||
.scriptName('npm init @patternfly/element') | ||
.usage('$0 [<cmd>] [args]') | ||
.option('directory', { | ||
type: 'string', | ||
default: process.cwd(), | ||
demandOption: false, | ||
description: 'Output directory', | ||
}) | ||
.option('silent', { | ||
type: 'boolean', | ||
default: false, | ||
description: 'Do not log anything to stdout', | ||
}) | ||
.option('tagName', { | ||
alias: 'n', | ||
type: 'string', | ||
description: 'Custom element tag name. e.g. `pfe-button`', | ||
}) | ||
.option('scope', { | ||
alias: 's', | ||
type: 'string', | ||
description: 'NPM package scope. e.g. `@patternfly`', | ||
}) | ||
.option('overwrite', { | ||
type: 'boolean', | ||
default: false, | ||
description: 'Overwrite files without prompting', | ||
}) | ||
.help() | ||
.check(({ name }) => { | ||
if (typeof name === 'string' && !name.includes('-')) { | ||
throw new Error(ERR_BAD_CE_TAG_NAME); | ||
} | ||
else { | ||
return true; | ||
} | ||
})) | ||
.then(({ argv }) => argv) | ||
.then(promptForElementGeneratorOptions) | ||
.then(generateElement); | ||
return Promise.resolve(Yargs(process.argv).scriptName("npm init @patternfly/element").usage("$0 [<cmd>] [args]").option("directory", { | ||
type: "string", | ||
default: process.cwd(), | ||
demandOption: false, | ||
description: "Output directory" | ||
}).option("silent", { | ||
type: "boolean", | ||
default: false, | ||
description: "Do not log anything to stdout" | ||
}).option("tagName", { | ||
alias: "n", | ||
type: "string", | ||
description: "Custom element tag name. e.g. `pfe-button`" | ||
}).option("scope", { | ||
alias: "s", | ||
type: "string", | ||
description: "NPM package scope. e.g. `@patternfly`" | ||
}).option("overwrite", { | ||
type: "boolean", | ||
default: false, | ||
description: "Overwrite files without prompting" | ||
}).help().check(({ name }) => { | ||
if (typeof name === "string" && !name.includes("-")) { | ||
throw new Error(ERR_BAD_CE_TAG_NAME); | ||
} else { | ||
return true; | ||
} | ||
})).then(({ argv }) => argv).then(promptForElementGeneratorOptions).then(generateElement); | ||
} | ||
//# sourceMappingURL=main.js.map |
{ | ||
"name": "@patternfly/create-element", | ||
"version": "0.0.2-next.5", | ||
"version": "1.0.0-next.6", | ||
"description": "Scaffold web components monorepos based on PatternFly Elements", | ||
@@ -28,3 +28,3 @@ "author": "Benny Powers <bennyp@redhat.com>", | ||
"scripts": { | ||
"prepublishOnly": "tsc -b .", | ||
"prepublishOnly": "npm run build", | ||
"clean": "rimraf './main.{js,d.ts}' './generator/*.{js,d.ts}' bin/main.d.ts", | ||
@@ -31,0 +31,0 @@ "build": "run-p build:*", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55502
563