Skip to content

Commit

Permalink
fix id checking
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhauck committed Sep 6, 2024
1 parent 37f1ff9 commit 325bd53
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion demos/compareJSON/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/compareSolutions/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/copyItemInfo/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/copySolutions/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/createSolution/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/deleteSolution/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/deploySolution/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/getItemInfo/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/implementedTypes/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/reuseDeployedItems/package-lock.json

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

2 changes: 1 addition & 1 deletion demos/verifySolution/package-lock.json

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

25 changes: 14 additions & 11 deletions packages/creator/src/createItemTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,30 +550,33 @@ export function _templatizeResources(
let dataString = JSON.stringify(fileJson);
if (fileJson && idTest.test(dataString)) {
const ids: string[] = dataString.match(idTest) as string[];
const verifiedIds: string[] = [];
const promises = [];
const idLookup = [];
ids.forEach((id) => {
idLookup.push(id);
if (verifiedIds.indexOf(id) === -1) {
verifiedIds.push(id);
if (idLookup.indexOf(id) === -1) {
idLookup.push(id);
promises.push(isItem(id, srcAuthentication));
idLookup.push(id);
promises.push(isGroup(id, srcAuthentication));
}
});

// eslint-disable-next-line @typescript-eslint/no-floating-promises
Promise.all(promises).then((results) => {
const verifiedIds = [];
results.forEach((isValid, i) => {
if (isValid) {
const id: string = idLookup[i];
// templatize the itemId--but only once per unique id
const regEx = new RegExp(id, "gm");
dataString = dataString.replace(regEx, "{{" + id + ".itemId}}");

// update the dependencies
if (itemTemplate.dependencies.indexOf(id) === -1) {
itemTemplate.dependencies.push(id);
if (verifiedIds.indexOf(id) < 0 && id) {
// templatize the itemId--but only once per unique id
const regEx = new RegExp(id, "gm");
dataString = dataString.replace(regEx, "{{" + id + ".itemId}}");

// update the dependencies
if (itemTemplate.dependencies.indexOf(id) === -1) {
itemTemplate.dependencies.push(id);
}
verifiedIds.push(id);
}
}
});
Expand Down

0 comments on commit 325bd53

Please sign in to comment.