|
| 1 | +/*! |
| 2 | +This file is part of CycloneDX JavaScript Library. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +
|
| 16 | +SPDX-License-Identifier: Apache-2.0 |
| 17 | +Copyright (c) OWASP Foundation. All Rights Reserved. |
| 18 | +*/ |
| 19 | + |
| 20 | +/** |
| 21 | + * Example showcasing the deprecated symbols still work. |
| 22 | + * @see https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1350 |
| 23 | + */ |
| 24 | + |
| 25 | +import * as fs from 'node:fs' |
| 26 | +import * as path from 'node:path' |
| 27 | + |
| 28 | +import * as CDX from '@cyclonedx/cyclonedx-library' |
| 29 | +// full Library is available as `CDX`, now |
| 30 | + |
| 31 | +const dBU1 = CDX.Utils.BomUtility.randomSerialNumber() |
| 32 | +console.log(dBU1) |
| 33 | + |
| 34 | +const dNU1 = CDX.Utils.NpmjsUtility.defaultRegistryMatcher.test('foo') |
| 35 | +const dNU2 = CDX.Utils.NpmjsUtility.parsePackageIntegrity('sha1-aSbRsZT7xze47tUTdW3i/Np+pAg=') |
| 36 | +console.log(dNU1, dNU2) |
| 37 | + |
| 38 | +type dLU1_T = CDX.Utils.LicenseUtility.LicenseEvidenceGatherer |
| 39 | +const fsU: CDX.Utils.LicenseUtility.FsUtils<string> = fs |
| 40 | +const pathU: CDX.Utils.LicenseUtility.PathUtils<string> = path |
| 41 | +const dLU1: dLU1_T = new CDX.Utils.LicenseUtility.LicenseEvidenceGatherer({fs: fsU, path: pathU}) |
| 42 | +console.log(dLU1) |
| 43 | + |
| 44 | +const dTnpj1: CDX.Types.NodePackageJson = {} |
| 45 | +// const dTnpj2 =CDX.Types.isNodePackageJson(dTnpj1) |
| 46 | +try { CDX.Types.assertNodePackageJson(dTnpj1) } catch { /* pass */ } |
| 47 | +console.log(dTnpj1) |
| 48 | + |
| 49 | +type dF1_T = CDX.Factories.PackageUrlFactory |
| 50 | +type dF2_T = CDX.Factories.LicenseFactory |
| 51 | +const dF1: dF1_T = new CDX.Factories.PackageUrlFactory('generic') |
| 52 | +const dF2: dF2_T = new CDX.Factories.LicenseFactory() |
| 53 | +console.log(dF1, dF2) |
| 54 | + |
| 55 | +type dFnpj3_T = CDX.Factories.FromNodePackageJson.PackageUrlFactory |
| 56 | +const dFnpj3: dFnpj3_T = new CDX.Factories.FromNodePackageJson.PackageUrlFactory('npm') |
| 57 | +type dFnpj4_T = CDX.Factories.FromNodePackageJson.ExternalReferenceFactory |
| 58 | +const dFnpj4: dFnpj4_T = new CDX.Factories.FromNodePackageJson.ExternalReferenceFactory() |
| 59 | +console.log(dFnpj3, dFnpj4) |
| 60 | + |
| 61 | +type dBnpj1_T = CDX.Builders.FromNodePackageJson.ComponentBuilder |
| 62 | +const dBnpj1: dBnpj1_T = new CDX.Builders.FromNodePackageJson.ComponentBuilder(dFnpj4, dF2) |
| 63 | +type dBnpj2_T = CDX.Builders.FromNodePackageJson.ToolBuilder |
| 64 | +const dBnpj2: dBnpj2_T = new CDX.Builders.FromNodePackageJson.ToolBuilder(dFnpj4) |
| 65 | +console.log(dBnpj1, dBnpj2) |
0 commit comments