1+ const core = require ( '@actions/core' ) ;
2+ const github = require ( '@actions/github' ) ;
3+ const fs = require ( 'fs' ) ;
4+ const glob = require ( 'glob' ) ;
5+ const yaml = require ( 'yaml' ) ;
6+
7+ import {
8+ PackageCache ,
9+ BuildTarget ,
10+ Package ,
11+ Snapshot ,
12+ Manifest ,
13+ submitSnapshot
14+ } from '@github/dependency-submission-toolkit'
15+ import { YAMLMap } from 'yaml' ;
16+
17+ /**getManifestFromEnvironmentFile(document, fileName) {
18+ core.debug(`getManifestFromEnvironmentFile processing ${fileName}`);
19+
20+ let manifest = new Manifest("Environment", fileName);
21+
22+
23+ /**
24+ let manifest = new Manifest(document.name, fileName);
25+
26+ core.debug(`Processing ${document.packages?.length} packages`);
27+
28+ document.packages?.forEach(pkg => {
29+ let packageName = pkg.name;
30+ let packageVersion = pkg.packageVersion;
31+ let referenceLocator = pkg.externalRefs?.find(ref => ref.referenceCategory === "PACKAGE-MANAGER" && ref.referenceType === "purl")?.referenceLocator;
32+ let genericPurl = `pkg:generic/${packageName}@${packageVersion}`;
33+ // SPDX 2.3 defines a purl field
34+ let purl;
35+ if (pkg.purl != undefined) {
36+ purl = pkg.purl;
37+ } else if (referenceLocator != undefined) {
38+ purl = referenceLocator;
39+ } else {
40+ purl = genericPurl;
41+ }
42+
43+ // Working around weird encoding issues from an SBOM generator
44+ // Find the last instance of %40 and replace it with @
45+ purl = replaceVersionEscape(purl);
46+
47+ let relationships = document.relationships?.find(rel => rel.relatedSpdxElement == pkg.SPDXID && rel.relationshipType == "DEPENDS_ON" && rel.spdxElementId != "SPDXRef-RootPackage");
48+ if (relationships != null && relationships.length > 0) {
49+ manifest.addIndirectDependency(new Package(purl));
50+ } else {
51+ manifest.addDirectDependency(new Package(purl));
52+ }
53+ });
54+ return manifest;
55+ }*/
56+
57+ /***/
58+
59+ export default class CondaParser {
60+
61+ static searchFiles ( filePath = "" , filePattern = "" ) {
62+ if ( filePath == "" ) {
63+ let filePath = core . getInput ( 'filePath' ) ;
64+ }
65+ if ( filePattern == "" ) {
66+ let filePattern = core . getInput ( 'filePattern' ) ;
67+ }
68+
69+ return glob . sync ( `${ filePath } /${ filePattern } ` , { } ) ;
70+ }
71+
72+ static getManifestsFromEnvironmentFiles ( files :string [ ] ) {
73+ core . debug ( `Processing ${ files . length } files` ) ;
74+ let manifests : any [ ] = [ ] ;
75+ files ?. forEach ( filePath => {
76+ core . debug ( `Processing ${ filePath } ` ) ;
77+ const contents = fs . readFileSync ( filePath , 'utf8' )
78+ manifests . push ( yaml . parse ( contents ) ) ;
79+ } ) ;
80+ return manifests ;
81+ }
82+
83+ static getManifestFromYaml ( yaml :any ) {
84+
85+ }
86+ }
0 commit comments