Skip to content

Commit

Permalink
Merge branch 'master' into SFINT-5790
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMilord authored Jan 16, 2025
2 parents f7e7185 + a1dc782 commit 2b532bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3106,5 +3106,3 @@ export class AtomicTimeframeFacet {
export declare interface AtomicTimeframeFacet extends Components.AtomicTimeframeFacet {}



import type {} from '@coveo/atomic/components';
17 changes: 11 additions & 6 deletions packages/atomic-angular/scripts/build-lit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { createWriteStream, readFileSync, writeFileSync } from 'fs';
const isLitDeclaration = (declaration) => declaration?.superclass?.name === 'LitElement';

const atomicAngularModuleFilePath ='projects/atomic-angular/src/lib/stencil-generated/atomic-angular.module.ts';
const atomicAngularModuleFileContent = readFileSync(atomicAngularModuleFilePath, 'utf-8');
const atomicAngularComponentFileStream = createWriteStream('projects/atomic-angular/src/lib/stencil-generated/components.ts', {flags: 'a'});
const atomicAngularComponentFilePath = 'projects/atomic-angular/src/lib/stencil-generated/components.ts';
let atomicAngularModuleFileContent = readFileSync(atomicAngularModuleFilePath, 'utf-8');
let atomicAngularComponentFileContent = readFileSync(atomicAngularComponentFilePath, 'utf-8');
const litDeclarations = [];


const startTag = '//#region Lit Declarations';
const endTag = '//#endregion Lit Declarations';
const declarationToProxyCmp = (declaration) =>
`
@ProxyCmp({
Expand All @@ -31,6 +33,7 @@ export class ${declaration.name} {
export declare interface ${declaration.name} extends Lit${declaration.name} {}
`
atomicAngularComponentFileContent = atomicAngularComponentFileContent.replace(new RegExp(`${startTag}.*?${endTag}`, 'gm'), '').trimEnd() + `\n\n${startTag}\n`;

const declarationToLitImport = (declaration) => `${declaration.name} as Lit${declaration.name}`;

Expand All @@ -39,14 +42,14 @@ const litImports = []
for (const module of cem.modules) {
for (const declaration of module.declarations) {
if (isLitDeclaration(declaration)) {
atomicAngularComponentFileStream.write(declarationToProxyCmp(declaration));
atomicAngularComponentFileContent += declarationToProxyCmp(declaration);
litImports.push(declarationToLitImport(declaration));
litDeclarations.push(`${declaration.name}`);
}
}
}
atomicAngularComponentFileStream.write(`\nimport type {${litImports.join(',')}} from '@coveo/atomic/components';`);
atomicAngularComponentFileStream.end();

atomicAngularComponentFileContent+=`\n${litDeclarations.join('\n')}\nimport type {${litImports.join(',')}} from '@coveo/atomic/components';\n${endTag}`;


if(litDeclarations.length > 0) {
Expand All @@ -56,4 +59,6 @@ if(litDeclarations.length > 0) {
.replace(/const DECLARATIONS = \[\n/m, `const DECLARATIONS = [\n${litDeclarations.join(',\n')},\n`)
.replace(/^import \{$/m, `import {\n${litDeclarations.join(',\n')},`)
);

writeFileSync(atomicAngularComponentFilePath, atomicAngularComponentFileContent.trimEnd());
}

0 comments on commit 2b532bb

Please sign in to comment.