@ui5/webcomponents-react-cli
Advanced tools
Comparing version 0.0.0-94cc89a9ef to 0.0.0-96b1a4d225
@@ -5,19 +5,19 @@ #!/usr/bin/env node | ||
import * as process from 'process'; | ||
const options = { | ||
packageName: { | ||
type: 'string' | ||
}, | ||
out: { | ||
type: 'string', | ||
short: 'o' | ||
}, | ||
additionalComponentNote: { | ||
type: 'string' | ||
} | ||
}; | ||
const { values, positionals } = parseArgs({ options, allowPositionals: true }); | ||
const { positionals } = parseArgs({ allowPositionals: true, strict: false }); | ||
const [command] = positionals; | ||
console.log(command); | ||
switch (command) { | ||
case 'create-wrappers': { | ||
const wrapperOptions = { | ||
packageName: { | ||
type: 'string' | ||
}, | ||
out: { | ||
type: 'string', | ||
short: 'o' | ||
}, | ||
additionalComponentNote: { | ||
type: 'string' | ||
} | ||
}; | ||
const { values } = parseArgs({ options: wrapperOptions, allowPositionals: true }); | ||
const { packageName, out, additionalComponentNote } = values; | ||
@@ -42,3 +42,2 @@ const missingParameters = []; | ||
const outDir = resolve(process.cwd(), values.out); | ||
// eslint-disable-next-line @typescript-eslint/await-thenable | ||
await createWrapperModule.default(packageName, outDir, { additionalComponentNote }); | ||
@@ -48,7 +47,68 @@ break; | ||
case 'resolve-cem': { | ||
const cemOptions = { | ||
packageName: { | ||
type: 'string' | ||
}, | ||
out: { | ||
type: 'string', | ||
short: 'o' | ||
} | ||
}; | ||
const { values } = parseArgs({ options: cemOptions, allowPositionals: true }); | ||
const { packageName, out } = values; | ||
const missingParameters = []; | ||
if (!packageName) { | ||
missingParameters.push('--packageName'); | ||
} | ||
if (!out) { | ||
missingParameters.push('--out'); | ||
} | ||
if (missingParameters.length > 0) { | ||
console.error(` | ||
Missing parameters: ${missingParameters.join(', ')} | ||
Example: ui5-wcr resolve-cem --packageName @ui5/webcomponents --out ./src/components | ||
Please add the missing parameters and try again. | ||
`); | ||
process.exit(1); | ||
} | ||
const resolveCEM = await import('../scripts/resolve-cem/main.js'); | ||
const outPath = resolve(process.cwd(), values.out); | ||
await resolveCEM.default(values.packageName, outPath); | ||
const outPath = resolve(process.cwd(), out); | ||
await resolveCEM.default(packageName, outPath); | ||
break; | ||
} | ||
case 'codemod': { | ||
const codemodOptions = { | ||
transform: { | ||
type: 'string' | ||
}, | ||
src: { | ||
type: 'string' | ||
}, | ||
typescript: { | ||
type: 'boolean', | ||
default: false | ||
} | ||
}; | ||
const { values } = parseArgs({ options: codemodOptions, allowPositionals: true }); | ||
const missingParameters = []; | ||
if (!values.src) { | ||
missingParameters.push('--src'); | ||
} | ||
if (!values.transform) { | ||
missingParameters.push('--transform'); | ||
} | ||
if (missingParameters.length > 0) { | ||
console.error(` | ||
Missing parameters: ${missingParameters.join(', ')} | ||
Example: ui5-wcr codemod --src ./src --transform v2 (--typescript) | ||
Please add the missing parameters and try again. | ||
`); | ||
process.exit(1); | ||
} | ||
const codemod = await import('../scripts/codemod/main.js'); | ||
await codemod.default(values.transform, values.src, values.typescript); | ||
break; | ||
} | ||
default: | ||
@@ -55,0 +115,0 @@ console.warn('Unknown command', command); |
@@ -12,6 +12,6 @@ import dedent from 'dedent'; | ||
switch (type) { | ||
case 'HTMLElement | string | undefined': | ||
case 'HTMLElement | string': | ||
// opener props only accept strings as prop types | ||
return 'string'; | ||
// case 'HTMLElement | string | undefined': | ||
// case 'HTMLElement | string': | ||
// // opener props only accept strings as prop types | ||
// return 'string'; | ||
default: | ||
@@ -51,3 +51,3 @@ if (!loggedTypes.has(type)) { | ||
const references = attribute.type?.references; | ||
const isEnum = references != null && references?.length > 0; | ||
const isEnum = references != null && references?.length > 0 && attribute.default !== '{}'; | ||
if (isEnum) { | ||
@@ -54,0 +54,0 @@ type += ` | keyof typeof ${type}`; |
@@ -6,3 +6,2 @@ import type * as CEM from '@ui5/webcomponents-tools/lib/cem/types-internal.d.ts'; | ||
phase: RenderingPhase; | ||
private dynamicImportPath; | ||
private attributes; | ||
@@ -15,3 +14,3 @@ private slots; | ||
private since; | ||
setDynamicImportPath(value: string): this; | ||
private isExperimental; | ||
setAttributes(attrs: CEM.ClassField[]): this; | ||
@@ -24,4 +23,5 @@ setSlots(slots: CEM.Slot[]): this; | ||
setSince(value: string | undefined): this; | ||
setIsExperimental(value?: boolean | string): this; | ||
prepare(context: WebComponentWrapper): void; | ||
render(context: WebComponentWrapper): string; | ||
} |
@@ -6,3 +6,2 @@ import dedent from 'dedent'; | ||
phase = RenderingPhase.component; | ||
dynamicImportPath; | ||
attributes = []; | ||
@@ -15,6 +14,3 @@ slots = []; | ||
since; | ||
setDynamicImportPath(value) { | ||
this.dynamicImportPath = value; | ||
return this; | ||
} | ||
isExperimental = false; | ||
setAttributes(attrs) { | ||
@@ -48,2 +44,6 @@ this.attributes.push(...attrs); | ||
} | ||
setIsExperimental(value) { | ||
this.isExperimental = value; | ||
return this; | ||
} | ||
prepare(context) { | ||
@@ -64,2 +64,5 @@ context.exportSet.add(context.componentName); | ||
} | ||
if (this.isExperimental) { | ||
comment += ` * @experimental${typeof this.isExperimental === 'string' ? ` ${this.isExperimental}` : ''}\n`; | ||
} | ||
comment += '*/'; | ||
@@ -86,4 +89,3 @@ const component = dedent ` | ||
.toSorted((a, b) => a.localeCompare(b)) | ||
.join(', ')}], | ||
() => import('${this.dynamicImportPath}') | ||
.join(', ')}] | ||
); | ||
@@ -90,0 +92,0 @@ |
@@ -120,3 +120,3 @@ import dedent from 'dedent'; | ||
prepare(context) { | ||
context.addTypeImport(process.env.INTERFACES_IMPORT_PATH ?? '@ui5/webcomponents-react', 'Ui5DomRef'); | ||
context.addTypeImport(process.env.INTERFACES_IMPORT_PATH ?? '@ui5/webcomponents-react-base', 'Ui5DomRef'); | ||
context.typeExportSet.add(`${context.componentName}DomRef`); | ||
@@ -123,0 +123,0 @@ for (const member of this._members) { |
@@ -12,9 +12,5 @@ import { mkdir, writeFile } from 'node:fs/promises'; | ||
import { WebComponentWrapper } from './WebComponentWrapper.js'; | ||
const WITH_WEB_COMPONENT_IMPORT_PATH = process.env.WITH_WEB_COMPONENT_IMPORT_PATH ?? '@ui5/webcomponents-react'; | ||
const WITH_WEB_COMPONENT_IMPORT_PATH = process.env.WITH_WEB_COMPONENT_IMPORT_PATH ?? '@ui5/webcomponents-react-base'; | ||
function filterAttributes(member) { | ||
return (member.kind === 'field' && | ||
member.privacy === 'public' && | ||
!member.readonly && | ||
!member.static && | ||
member._ui5validator !== 'Object'); | ||
return member.kind === 'field' && member.privacy === 'public' && !member.readonly && !member.static; | ||
} | ||
@@ -51,6 +47,6 @@ export default async function createWrappers(packageName, outDir, options) { | ||
.setEvents(declaration.events ?? []) | ||
.setDynamicImportPath(webComponentImport) | ||
.setNote(options.additionalComponentNote ?? '') | ||
.setIsAbstract(declaration._ui5abstract ?? false) | ||
.setSince(declaration._ui5since)); | ||
.setSince(declaration._ui5since) | ||
.setIsExperimental(declaration._ui5experimental)); | ||
wrapper.addRenderer(new ExportsRenderer()); | ||
@@ -57,0 +53,0 @@ const componentTargetFolder = resolve(outDir, declaration.name); |
@@ -43,3 +43,3 @@ import dedent from 'dedent'; | ||
descriptionParts.push(' * __Note:__ When passing a custom React component to this prop, you have to make sure your component reads the `slot` prop and appends it to the most outer element of your component.'); | ||
descriptionParts.push(`* Learn more about it [here](https://sap.github.io/ui5-webcomponents-react/?path=/docs/knowledge-base-handling-slots--docs).`); | ||
descriptionParts.push(`* Learn more about it [here](https://sap.github.io/ui5-webcomponents-react/v2/?path=/docs/knowledge-base-handling-slots--docs).`); | ||
} | ||
@@ -85,2 +85,9 @@ if (sinceFilter(slot._ui5since)) { | ||
} | ||
if (Object.prototype.hasOwnProperty.call(event, '_ui5Bubbles') || | ||
Object.prototype.hasOwnProperty.call(event, '_ui5Cancelable')) { | ||
descriptionParts.push(` *`); | ||
descriptionParts.push(`* | cancelable | bubbles |`); | ||
descriptionParts.push(`* | :--------: | :-----: |`); | ||
descriptionParts.push(`* | ${event._ui5Cancelable ? '✅' : '❌'}|${event._ui5Bubbles ? '✅' : '❌'}|`); | ||
} | ||
const domRef = `${context.componentName}DomRef`; | ||
@@ -115,3 +122,3 @@ let eventType = '(event: unknown) => void;'; | ||
prepare(context) { | ||
const interfacesImportPath = process.env.INTERFACES_IMPORT_PATH ?? '@ui5/webcomponents-react'; | ||
const interfacesImportPath = process.env.INTERFACES_IMPORT_PATH ?? '@ui5/webcomponents-react-base'; | ||
context.addTypeImport(interfacesImportPath, 'CommonProps'); | ||
@@ -118,0 +125,0 @@ context.typeExportSet.add(`${context.componentName}PropTypes`); |
@@ -1,2 +0,1 @@ | ||
import TurndownService from 'turndown'; | ||
let ui5TagNameToComponentNameMap = {}; | ||
@@ -6,19 +5,2 @@ export function setGlobalTagNameMap(map) { | ||
} | ||
const turndownService = new TurndownService({ | ||
headingStyle: 'atx', | ||
codeBlockStyle: 'fenced' | ||
}); | ||
turndownService.addRule('ui5-link', { | ||
filter: (node) => node.nodeName === 'UI5-LINK' && !!node.getAttribute('href'), | ||
replacement: (content, node) => { | ||
// @ts-expect-error: types seem to be incorrect | ||
const href = node.getAttribute('href'); | ||
// @ts-expect-error: types seem to be incorrect | ||
let title = node.getAttribute('title') ?? ''; | ||
if (title) { | ||
title = ` "${title}"`; | ||
} | ||
return `[${content}](${href}${title})`; | ||
} | ||
}); | ||
function replaceUi5TagNames(text) { | ||
@@ -58,2 +40,3 @@ let newText = text.replaceAll(/`([\w\d-]+)`/g, (match, tagName) => { | ||
case 'sap.ui.webc.base.types.Float': | ||
case 'number': | ||
return 'number'; | ||
@@ -60,0 +43,0 @@ case 'string': |
@@ -24,3 +24,4 @@ import { getCEM } from './cem-reader.js'; | ||
'onInvalidation', | ||
'getStaticAreaItemDomRef' | ||
'getStaticAreaItemDomRef', | ||
'fireDecoratorEvent' | ||
]); | ||
@@ -27,0 +28,0 @@ function mergeArraysWithoutDuplicates(currentValues, newValue) { |
@@ -10,2 +10,5 @@ import { getCEM } from './cem-reader.js'; | ||
const resolvedModule = customElementManifest.modules.find((mod) => mod.path === modulePath); | ||
if (!resolvedModule) { | ||
console.warn('Resolved Module not found for:', reference.name, 'in', pkgName); | ||
} | ||
if (resolvedModule) { | ||
@@ -12,0 +15,0 @@ const exportDeclaration = resolvedModule.exports?.find((exp) => exp.declaration.name === name); |
@@ -6,3 +6,3 @@ { | ||
"license": "Apache-2.0", | ||
"version": "0.0.0-94cc89a9ef", | ||
"version": "0.0.0-96b1a4d225", | ||
"type": "module", | ||
@@ -36,6 +36,5 @@ "types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"dedent": "^1.5.1", | ||
"turndown": "^7.1.2" | ||
"dedent": "^1.5.1" | ||
}, | ||
"gitHead": "94cc89a9ef9143dadda09053defa061d49381b2a" | ||
"gitHead": "96b1a4d2259fc9f6f5bc83d6db4ed3cad4435ea0" | ||
} |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
114452
1
38
2446
1
30
- Removedturndown@^7.1.2
- Removed@mixmark-io/domino@2.2.0(transitive)
- Removedturndown@7.2.0(transitive)