Skip to content

Commit

Permalink
Code scanning enums
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfarrell76 committed Dec 14, 2023
1 parent 8f72e05 commit 25e3d43
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"**/.pnp.*": true
},
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"cSpell.words": [
"aaid",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/privacy-types",
"description": "Core enums and types that can be useful when interacting with Transcend's public APIs.",
"version": "4.61.0",
"version": "4.62.0",
"homepage": "https://github.com/transcend-io/privacy-types",
"repository": {
"type": "git",
Expand Down
10 changes: 10 additions & 0 deletions src/code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* The types of files that can be used to detect a code package
*/
export enum CodePackageType {
PackageJson = 'PACKAGE_JSON',
RequirementsTxt = 'REQUIREMENTS_TXT',
Gradle = 'GRADLE',
CocoaPods = 'COCOA_PODS',
Pubspec = 'PUBSPEC',
}
24 changes: 24 additions & 0 deletions src/getRegistryLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { CodePackageType } from './code';

export const CODE_PACKAGE_TYPE_TO_LINK: {
[k in CodePackageType]: (name: string) => string;
} = {
[CodePackageType.CocoaPods]: (name) => `https://cocoapods.org/pods/${name}`,
[CodePackageType.Gradle]: (name) =>
`https://mvnrepository.com/artifact/${name.split(':').join('/')}`,
[CodePackageType.PackageJson]: (name) =>
`https://www.npmjs.com/package/${name}`,
[CodePackageType.RequirementsTxt]: (name) =>
`https://pypi.org/project/${name}`,
[CodePackageType.Pubspec]: (name) => `https://pub.dev/packages/${name}`,
};

/**
* Get the registry link for a given code package
* @param name - Name of package
* @param type - Type of registry
* @returns The registry link
*/
export function getRegistryLink(name: string, type: CodePackageType): string {
return CODE_PACKAGE_TYPE_TO_LINK[type](name);
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export * from './assessmentForm';
export * from './datapoint';
export * from './largeLanguageModels';
export * from './prompt';
export * from './getRegistryLink';
export * from './code';

0 comments on commit 25e3d43

Please sign in to comment.