generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73fe389
commit 07b4e66
Showing
12 changed files
with
410 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export class Stringutil { | ||
public static cleanName(name: string, allowUnderscores = false): string { | ||
if (!name) return ''; | ||
return allowUnderscores ? name.replace(/[^a-z0-9_]+/gi, '') : name.replace(/[^a-z0-9]+/gi, ''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Stringutil } from './stringutil'; | ||
|
||
export class StringVal { | ||
public val: string; | ||
public type: string; | ||
|
||
public constructor(val: string, type?: string) { | ||
this.val = val; | ||
this.type = type; | ||
} | ||
|
||
public cleanName(allowUnderscores = false): string { | ||
return Stringutil.cleanName(this.val, allowUnderscores); | ||
} | ||
public isNameCleaned(): boolean { | ||
return !this.val || this.val === this.cleanName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* eslint-disable no-prototype-builtins */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
export class jsonutil { | ||
// Recursive method to find a property in the JSON | ||
public static findProperty(obj: any, propertyName: string): any { | ||
if (obj === null || typeof obj !== 'object') { | ||
return null; | ||
} | ||
|
||
// Check if the property exists in the current object | ||
if (propertyName in obj) { | ||
return obj[propertyName]; | ||
} | ||
|
||
// If it's an array, use findInArray | ||
if (Array.isArray(obj)) { | ||
return this.findInArray(obj, propertyName); | ||
} | ||
|
||
// Otherwise, search through all keys | ||
for (const key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
const result = this.findProperty(obj[key], propertyName); | ||
if (result !== null) { | ||
return result; | ||
} | ||
} | ||
} | ||
|
||
return null; // Property not found | ||
} | ||
|
||
// Method to find a property in an array | ||
public static findInArray(arr: any[], propertyName: string): any { | ||
for (const item of arr) { | ||
const result = jsonutil.findProperty(item, propertyName); | ||
if (result !== null) { | ||
return result; | ||
} | ||
} | ||
return null; // Property not found in the array | ||
} | ||
} |
Oops, something went wrong.