@callstack/licenses 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/build/constants/index.d.ts +1 -0
  3. package/build/constants/index.js +17 -0
  4. package/build/constants/licenses.d.ts +7 -0
  5. package/build/constants/licenses.js +53 -0
  6. package/build/index.d.ts +2 -1
  7. package/build/index.js +5 -4
  8. package/build/licenses/LicenseCategory.d.ts +6 -0
  9. package/build/licenses/LicenseCategory.js +10 -0
  10. package/build/licenses/descriptions.d.ts +16 -0
  11. package/build/licenses/descriptions.js +53 -0
  12. package/build/licenses/index.d.ts +3 -0
  13. package/build/licenses/index.js +19 -0
  14. package/build/licenses/licenseAnalysis.d.ts +15 -0
  15. package/build/licenses/licenseAnalysis.js +65 -0
  16. package/build/{common.d.ts → node/common.d.ts} +6 -6
  17. package/build/{common.js → node/common.js} +75 -60
  18. package/build/node/index.d.ts +3 -0
  19. package/build/node/index.js +19 -0
  20. package/build/node/utils/index.d.ts +2 -0
  21. package/build/node/utils/index.js +38 -0
  22. package/build/{utils → node/utils}/packageUtils.d.ts +2 -2
  23. package/build/{utils → node/utils}/packageUtils.js +1 -1
  24. package/build/types/AggregatedLicensesMapping.d.ts +6 -0
  25. package/build/types/{LicenseObj.d.ts → License.d.ts} +8 -2
  26. package/build/types/LicenseAnalysisResult.d.ts +5 -0
  27. package/build/types/LicenseAnalysisResult.js +2 -0
  28. package/build/types/LicenseStats.d.ts +28 -0
  29. package/build/types/LicenseStats.js +2 -0
  30. package/build/types/ParentPackageInfo.d.ts +14 -0
  31. package/build/types/ParentPackageInfo.js +2 -0
  32. package/build/types/index.d.ts +5 -2
  33. package/build/types/index.js +5 -2
  34. package/build/utils/index.d.ts +0 -2
  35. package/build/utils/index.js +1 -3
  36. package/package.json +20 -7
  37. package/src/constants/index.ts +1 -0
  38. package/src/constants/licenses.ts +58 -0
  39. package/src/index.ts +2 -1
  40. package/src/licenses/LicenseCategory.ts +6 -0
  41. package/src/licenses/descriptions.ts +56 -0
  42. package/src/licenses/index.ts +3 -0
  43. package/src/licenses/licenseAnalysis.ts +78 -0
  44. package/src/{common.ts → node/common.ts} +62 -45
  45. package/src/node/index.ts +3 -0
  46. package/src/node/utils/index.ts +2 -0
  47. package/src/{utils → node/utils}/packageUtils.ts +3 -3
  48. package/src/types/AggregatedLicensesMapping.ts +7 -0
  49. package/src/types/{LicenseObj.ts → License.ts} +9 -2
  50. package/src/types/LicenseAnalysisResult.ts +7 -0
  51. package/src/types/LicenseStats.ts +33 -0
  52. package/src/types/ParentPackageInfo.ts +16 -0
  53. package/src/types/index.ts +5 -2
  54. package/src/utils/index.ts +0 -2
  55. package/build/types/AggregatedLicensesObj.d.ts +0 -6
  56. package/src/types/AggregatedLicensesObj.ts +0 -7
  57. /package/build/{utils → node/utils}/miscUtils.d.ts +0 -0
  58. /package/build/{utils → node/utils}/miscUtils.js +0 -0
  59. /package/build/types/{AggregatedLicensesObj.js → AggregatedLicensesMapping.js} +0 -0
  60. /package/build/types/{LicenseObj.js → License.js} +0 -0
  61. /package/src/{utils → node/utils}/miscUtils.ts +0 -0
@@ -1,10 +1,10 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
- import type { LicenseObj, ScanPackageOptionsFactory } from '../types';
4
+ import type { License, ScanPackageOptionsFactory } from '../../types';
5
+ import { normalizeRepositoryUrl } from '../../utils/repositoryUtils';
5
6
 
6
7
  import { sha512 } from './miscUtils';
7
- import { normalizeRepositoryUrl } from './repositoryUtils';
8
8
 
9
9
  export function getPackageJsonPath(dependency: string, root?: string) {
10
10
  const rootsToSearch = [
@@ -54,7 +54,7 @@ export function normalizePackageName(packageName: string): string {
54
54
  return packageName.replace('/', '_');
55
55
  }
56
56
 
57
- export function prepareAboutLibrariesLicenseField(license: LicenseObj) {
57
+ export function prepareAboutLibrariesLicenseField(license: License) {
58
58
  if (!license.type) {
59
59
  return '';
60
60
  }
@@ -0,0 +1,7 @@
1
+ import type { License } from './License';
2
+
3
+ /**
4
+ * Mapping from package keys in format `<package-name>@<package-version>` to license objects.
5
+ * @see {@link License}
6
+ */
7
+ export type AggregatedLicensesMapping = Record<string, License>;
@@ -1,7 +1,8 @@
1
1
  import type { DependencyType } from './DependencyType';
2
+ import type { ParentPackageInfo } from './ParentPackageInfo';
2
3
  import type { ScanPackageCallContext } from './ScanPackageCallContext';
3
4
 
4
- export type LicenseObj = {
5
+ export type License = {
5
6
  /** Package name */
6
7
  name: string;
7
8
 
@@ -31,4 +32,10 @@ export type LicenseObj = {
31
32
 
32
33
  /** The required version specified in package.json */
33
34
  requiredVersion: string;
34
- } & Pick<ScanPackageCallContext, 'parentPackageName' | 'parentPackageRequiredVersion' | 'parentPackageResolvedVersion'>;
35
+
36
+ /**
37
+ * The name(s) of the package(s) that introduced the package as a dependency (of any type);
38
+ * empty array if the package is a dependency of the root package
39
+ */
40
+ parentPackages: ParentPackageInfo[];
41
+ } & Pick<ScanPackageCallContext, 'parentPackageRequiredVersion' | 'parentPackageResolvedVersion'>;
@@ -0,0 +1,7 @@
1
+ import type { LicenseCategory } from '../licenses/LicenseCategory';
2
+
3
+ import type { LicenseStats } from './LicenseStats';
4
+
5
+ export interface LicenseAnalysisResult extends LicenseStats {
6
+ categorizedLicenses: Record<string, LicenseCategory>;
7
+ }
@@ -0,0 +1,33 @@
1
+ import type { LicenseCategory } from '../licenses/LicenseCategory';
2
+
3
+ export interface LicenseStats {
4
+ /**
5
+ * Total number of packages
6
+ */
7
+ total: number;
8
+
9
+ /**
10
+ * Mapping of license category to count of packages in that category
11
+ */
12
+ byCategory: Record<LicenseCategory, number>;
13
+
14
+ /**
15
+ * Mapping of license name to count of packages with that license
16
+ */
17
+ byLicense: Record<string, number>;
18
+
19
+ /**
20
+ * Information about the presence of different license categories
21
+ */
22
+ categoriesPresence: {
23
+ hasAnyUnknown: boolean;
24
+ hasAnyWeakCopyleft: boolean;
25
+ hasAnyStrongCopyleft: boolean;
26
+ hasAllPermissive: boolean;
27
+ };
28
+
29
+ /**
30
+ * Description of the graph state based on the license categories
31
+ */
32
+ description: string;
33
+ }
@@ -0,0 +1,16 @@
1
+ export type ParentPackageInfo = {
2
+ /**
3
+ * The name of the package
4
+ */
5
+ name: string;
6
+
7
+ /**
8
+ * The required version, as specified in package.json
9
+ */
10
+ requiredVersion: string;
11
+
12
+ /**
13
+ * The resolved version, as specified in package.json
14
+ */
15
+ resolvedVersion: string;
16
+ };
@@ -1,5 +1,5 @@
1
- export * from './LicenseObj';
2
- export * from './AggregatedLicensesObj';
1
+ export * from './License';
2
+ export * from './AggregatedLicensesMapping';
3
3
  export * from './AboutLibrariesLibraryJsonPayload';
4
4
  export * from './AboutLibrariesLicenseJsonPayload';
5
5
  export * from './LicensePlistPayload';
@@ -7,3 +7,6 @@ export * from './AboutLibrariesLikePackageInfo';
7
7
  export * from './ScanPackageOptions';
8
8
  export * from './ScanPackageCallContext';
9
9
  export * from './DependencyType';
10
+ export * from './ParentPackageInfo';
11
+ export * from './LicenseAnalysisResult';
12
+ export * from './LicenseStats';
@@ -1,4 +1,2 @@
1
- export * as PackageUtils from './packageUtils';
2
- export * as MiscUtils from './miscUtils';
3
1
  export * as RepositoryUtils from './repositoryUtils';
4
2
  export * as YamlUtils from './yamlUtils';
@@ -1,6 +0,0 @@
1
- import type { LicenseObj } from './LicenseObj';
2
- /**
3
- * Mapping from package keys in format `<package-name>/<package-version>` to license objects.
4
- * @see {@link LicenseObj}
5
- */
6
- export type AggregatedLicensesObj = Record<string, LicenseObj>;
@@ -1,7 +0,0 @@
1
- import type { LicenseObj } from './LicenseObj';
2
-
3
- /**
4
- * Mapping from package keys in format `<package-name>/<package-version>` to license objects.
5
- * @see {@link LicenseObj}
6
- */
7
- export type AggregatedLicensesObj = Record<string, LicenseObj>;
File without changes
File without changes
File without changes
File without changes