Skip to content

Commit

Permalink
ZETA-6955; fx.
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieGreenman committed Oct 25, 2023
1 parent 97ff1f3 commit 092fb55
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 31 deletions.
6 changes: 0 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ module.exports = {
transformIgnorePatterns: [
"node_modules/(?!(angular-html-parser)/)"
],
globals: {
'ts-jest': {
diagnostics: false,
useESM: true
}
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(t|j)s$',
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
};
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/razroo/razzle"
"url": "https://github.com/razroo/codemorph"
},
"keywords": [
"razroo",
Expand All @@ -36,9 +36,9 @@
"author": "Razroo",
"license": "RAZROO",
"bugs": {
"url": "https://github.com/razroo/razzle/issues"
"url": "https://github.com/razroo/codemorph/issues"
},
"homepage": "https://github.com/razroo/razzle#readme",
"homepage": "https://github.com/razroo/codemorph#readme",
"devDependencies": {
"@angular-devkit/architect": "~0.1300.0",
"@angular-devkit/build-angular": "~13.0.0",
Expand Down Expand Up @@ -99,7 +99,7 @@
"minimatch": "^9.0.3",
"parse5": "^6.0.1",
"path": "^0.12.7",
"prettier": "^2.3.0",
"prettier": "^3.0.3",
"query-ast": "^1.0.4",
"resolve": "^1.22.2",
"scss-parser": "^1.0.5",
Expand Down
6 changes: 0 additions & 6 deletions src/rz/angular/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ module.exports = {
transformIgnorePatterns: [
"node_modules/(?!(angular-html-parser)/)"
],
globals: {
'ts-jest': {
diagnostics: false,
useESM: true
}
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(t|j)s$',
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
};
13 changes: 6 additions & 7 deletions src/rz/angular/morph-angular-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { insertCodeAfterElement } from './add-sibling-html';
import { insertIntoHtmlTag } from './insert-into-html-tag/insert-into-html-tag';
import { updateHtmlTag } from './update-html-tag';
import * as prettier from 'prettier';
import * as parserHtml from 'prettier/parser-html';

import { deleteHtmlElement } from '../html/delete-html-element/delete-html-element';
import { prependHtml } from '../html/prepend-html/prepend-html';
import { appendHtml } from '../html/append-html/append-html';
Expand All @@ -19,12 +19,11 @@ let angularHtmlParse: any;
angularHtmlParse = (await import('angular-html-parser')).parse;
})();

function convertToAngularHtmlAndPrettify(htmlAst: any) {
async function convertToAngularHtmlAndPrettify(htmlAst: any) {
const htmlString = astToHtml(htmlAst.rootNodes);

return prettier.format(htmlString, {
return await prettier.format(htmlString, {
parser: "html",
plugins: [parserHtml]
});
}

Expand All @@ -38,7 +37,7 @@ export function createUnifiedTree(htmlString: string | any): any {
}

// fileToBeAddedToTree is top level
export function morphHtml(editHtmlInput: EditHtmlInput): string {
export async function morphHtml(editHtmlInput: EditHtmlInput): Promise<string> {
let fileToBeAddedToTree = parseHtml(editHtmlInput.fileToBeAddedTo);

editHtmlInput.edits.forEach((edit: EditHtmlFile) => {
Expand All @@ -65,6 +64,6 @@ export function morphHtml(editHtmlInput: EditHtmlInput): string {
fileToBeAddedToTree = appendHtml(edit, fileToBeAddedToTree);
}
});

return convertToAngularHtmlAndPrettify(fileToBeAddedToTree);
return await convertToAngularHtmlAndPrettify(fileToBeAddedToTree)
}
4 changes: 2 additions & 2 deletions src/rz/morph/morph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import { EditFileEffect, NOT_SUPPORTED, NOT_SUPPORTED_TYPE } from './interfaces/

// takes in singular object and makes all edits to files
// used when editing a file
export function morphCode(editInput: any): string {
export async function morphCode(editInput: any): Promise<string> {
switch(editInput.fileType) {
case 'html':
return morphHtml(editInput as EditHtmlInput)
return await morphHtml(editInput as EditHtmlInput)
case 'ts':
case 'spec.ts':
return morphTypescript(editInput);
Expand Down

0 comments on commit 092fb55

Please sign in to comment.