@patternfly/create-element
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -8,4 +8,6 @@ #!/usr/bin/env node | ||
} catch (e) { | ||
if (e) console.error(e); | ||
if (e) { | ||
console.error(e); | ||
} | ||
} | ||
})(); |
@@ -6,3 +6,4 @@ import type { GenerateElementOptions } from '../main'; | ||
* Generate an Element | ||
* @param options element generator options | ||
*/ | ||
export declare function generateElement(options: GenerateElementOptions): Promise<void>; |
@@ -14,9 +14,9 @@ import Case from 'case'; | ||
/** | ||
* Available filenames. | ||
* | ||
* To add a new file to the element template, | ||
* 1. Add a key to this enum | ||
* 2. Add the template file's path to `TEMPLATE_FILE_PATHS` | ||
* 3. Add the output path to `getFilePathsRelativeToPackageDir`, interpolating as needed. | ||
*/ | ||
* Available filenames. | ||
* | ||
* To add a new file to the element template, | ||
* 1. Add a key to this enum | ||
* 2. Add the template file's path to `TEMPLATE_FILE_PATHS` | ||
* 3. Add the output path to `getFilePathsRelativeToPackageDir`, interpolating as needed. | ||
*/ | ||
var FileKey; | ||
@@ -26,4 +26,2 @@ (function (FileKey) { | ||
FileKey["demo"] = "demo"; | ||
FileKey["demoCss"] = "demoCss"; | ||
FileKey["demoScript"] = "demoScript"; | ||
FileKey["docs"] = "docs"; | ||
@@ -56,4 +54,2 @@ FileKey["readme"] = "readme"; | ||
demo: `demo/${options.tagName}.html`, | ||
demoCss: `demo/demo.css`, | ||
demoScript: `demo/${options.tagName}.js`, | ||
docs: `docs/${options.tagName}.md`, | ||
@@ -87,3 +83,7 @@ readme: 'README.md', | ||
}); | ||
/** e.g. /Users/alj/Developer/jazz-elements/elements/pf-jazz-hands/pf-jazz-hands.ts */ | ||
/** | ||
* e.g. /home/alj/Developer/jazz-elements/elements/pf-jazz-hands/pf-jazz-hands.ts | ||
* @param key file key e.g. component | ||
* @param options element generator options | ||
*/ | ||
const getOutputFilePath = (key, options) => join(getComponentAbsPath(options), getFilePathsRelativeToPackageDir(options)[key]); | ||
@@ -144,2 +144,3 @@ async function shouldWriteToDir(options) { | ||
* Generate an Element | ||
* @param options element generator options | ||
*/ | ||
@@ -146,0 +147,0 @@ export async function generateElement(options) { |
import { readFile, writeFile } from 'fs/promises'; | ||
export { readFile, writeFile }; | ||
/** | ||
* @param [string] prop name | ||
*/ | ||
export declare function getInterpolationRegExp(string?: string): RegExp; | ||
/** | ||
* @param template ejs-like template | ||
* @param interpolations record of keywords to replace. | ||
*/ | ||
export declare function processTemplate(template: string, interpolations: Record<string, string>): string; | ||
/** Check if a file exists at a given absolute path */ | ||
/** | ||
* Check if a file exists at a given absolute path | ||
* @param path path to file to check | ||
*/ | ||
export declare function exists(path: string): Promise<boolean>; | ||
/** $ mkdir -p path */ | ||
/** | ||
* $ mkdir -p path | ||
* @param path dir to mk, p | ||
*/ | ||
export declare function mkdirp(path: string): Promise<void>; | ||
/** | ||
* @param path json file path | ||
*/ | ||
export declare function readJson<T = unknown>(path: string): Promise<T>; |
import { mkdir, readFile, stat, writeFile } from 'fs/promises'; | ||
export { readFile, writeFile }; | ||
/** | ||
* @param [string] prop name | ||
*/ | ||
export function getInterpolationRegExp(string) { | ||
@@ -11,2 +14,6 @@ if (typeof string === 'string') { | ||
} | ||
/** | ||
* @param template ejs-like template | ||
* @param interpolations record of keywords to replace. | ||
*/ | ||
export function processTemplate(template, interpolations) { | ||
@@ -20,3 +27,6 @@ let partial = template; | ||
} | ||
/** Check if a file exists at a given absolute path */ | ||
/** | ||
* Check if a file exists at a given absolute path | ||
* @param path path to file to check | ||
*/ | ||
export async function exists(path) { | ||
@@ -30,6 +40,12 @@ try { | ||
} | ||
/** $ mkdir -p path */ | ||
/** | ||
* $ mkdir -p path | ||
* @param path dir to mk, p | ||
*/ | ||
export async function mkdirp(path) { | ||
await mkdir(path, { recursive: true }); | ||
} | ||
/** | ||
* @param path json file path | ||
*/ | ||
export async function readJson(path) { | ||
@@ -36,0 +52,0 @@ return readFile(path, 'utf8').then(x => JSON.parse(x)); |
@@ -1,2 +0,5 @@ | ||
/** Memoize an oft-called nary function */ | ||
/** | ||
* Memoize an oft-called nary function | ||
* @param fn pure function to memoize | ||
*/ | ||
export declare function memoize<T extends (...args: any[]) => unknown>(fn: T): T; |
@@ -1,2 +0,5 @@ | ||
/** Memoize an oft-called nary function */ | ||
/** | ||
* Memoize an oft-called nary function | ||
* @param fn pure function to memoize | ||
*/ | ||
export function memoize(fn) { | ||
@@ -3,0 +6,0 @@ if (!fn) { |
@@ -17,3 +17,9 @@ export interface BaseOptions { | ||
export type PromptOptions<T> = Partial<T> & BaseOptions; | ||
/** | ||
* @param options the tag and package names, among others | ||
*/ | ||
export declare function promptForElementGeneratorOptions(options?: PromptOptions<GenerateElementOptions>): Promise<GenerateElementOptions>; | ||
/** | ||
* Prompt to generate an element definition | ||
*/ | ||
export declare function main(): Promise<void>; |
10
main.js
@@ -39,2 +39,5 @@ import { generateElement, PackageJSONError } from './generator/element.js'; | ||
} | ||
/** | ||
* @param options the tag and package names, among others | ||
*/ | ||
export async function promptForElementGeneratorOptions(options) { | ||
@@ -55,5 +58,8 @@ banner(); | ||
async function getDefaultPackageName() { | ||
return (await readJsonOrVoid(join(process.cwd(), 'elements', 'package.json')))?.name ?? | ||
(await readJsonOrVoid(join(process.cwd(), 'package.json')))?.name ?? ''; | ||
return (await readJsonOrVoid(join(process.cwd(), 'elements', 'package.json')))?.name | ||
?? (await readJsonOrVoid(join(process.cwd(), 'package.json')))?.name ?? ''; | ||
} | ||
/** | ||
* Prompt to generate an element definition | ||
*/ | ||
export async function main() { | ||
@@ -60,0 +66,0 @@ return Promise.resolve(Yargs(process.argv) |
{ | ||
"name": "@patternfly/create-element", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Scaffold web components monorepos based on PatternFly Elements", | ||
@@ -46,9 +46,9 @@ "author": "Benny Powers <bennyp@redhat.com>", | ||
"dependencies": { | ||
"case": "1.6.3", | ||
"chalk": "5.0.1", | ||
"execa": "^7.1.0", | ||
"ncp": "2.0.0", | ||
"prompts": "2.4.2", | ||
"tslib": "2.5.0", | ||
"yargs": "17.7.1" | ||
"case": "^1.6.3", | ||
"chalk": "^5.3.0", | ||
"execa": "^9.3.1", | ||
"ncp": "^2.0.0", | ||
"prompts": "^2.4.2", | ||
"tslib": "^2.6.3", | ||
"yargs": "^17.7.2" | ||
}, | ||
@@ -55,0 +55,0 @@ "directories": { |
import { test } from '@playwright/test'; | ||
import { PfeDemoPage } from '@patternfly/pfe-tools/test/playwright/PfeDemoPage.js'; | ||
import { SSRPage } from '@patternfly/pfe-tools/test/playwright/SSRPage.js'; | ||
@@ -12,2 +13,14 @@ const tagName = '<%= tagName %>'; | ||
}); | ||
test('ssr', async ({ browser }) => { | ||
const fixture = new SSRPage({ | ||
tagName, | ||
browser, | ||
demoDir: new URL('../demo/', import.meta.url), | ||
importSpecifiers: [ | ||
`@patternfly/elements/${tagName}/${tagName}.js`, | ||
], | ||
}); | ||
await fixture.snapshots(); | ||
}); | ||
}); |
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
26683
522
17
+ Added@sec-ant/readable-stream@0.4.1(transitive)
+ Added@sindresorhus/merge-streams@4.0.0(transitive)
+ Addedchalk@5.3.0(transitive)
+ Addedexeca@9.4.0(transitive)
+ Addedfigures@6.1.0(transitive)
+ Addedget-stream@9.0.1(transitive)
+ Addedhuman-signals@8.0.0(transitive)
+ Addedis-plain-obj@4.1.0(transitive)
+ Addedis-stream@4.0.1(transitive)
+ Addedis-unicode-supported@2.1.0(transitive)
+ Addednpm-run-path@6.0.0(transitive)
+ Addedparse-ms@4.0.0(transitive)
+ Addedpretty-ms@9.1.0(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedstrip-final-newline@4.0.0(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedunicorn-magic@0.3.0(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyoctocolors@2.1.1(transitive)
- Removedchalk@5.0.1(transitive)
- Removedexeca@7.2.0(transitive)
- Removedget-stream@6.0.1(transitive)
- Removedhuman-signals@4.3.1(transitive)
- Removedis-stream@3.0.0(transitive)
- Removedmerge-stream@2.0.0(transitive)
- Removedmimic-fn@4.0.0(transitive)
- Removednpm-run-path@5.3.0(transitive)
- Removedonetime@6.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstrip-final-newline@3.0.0(transitive)
- Removedtslib@2.5.0(transitive)
- Removedyargs@17.7.1(transitive)
Updatedcase@^1.6.3
Updatedchalk@^5.3.0
Updatedexeca@^9.3.1
Updatedncp@^2.0.0
Updatedprompts@^2.4.2
Updatedtslib@^2.6.3
Updatedyargs@^17.7.2