@code-pushup/js-packages-plugin 0.34.0 → 0.39.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 (36) hide show
  1. package/CONTRIBUTING.md +15 -5
  2. package/README.md +17 -3
  3. package/bin.js +289 -195
  4. package/index.js +497 -97
  5. package/package.json +3 -3
  6. package/src/lib/config.d.ts +2 -2
  7. package/src/lib/constants.d.ts +3 -8
  8. package/src/lib/package-managers/constants.d.ts +2 -0
  9. package/src/lib/package-managers/index.d.ts +2 -0
  10. package/src/lib/package-managers/npm/audit-result.d.ts +5 -0
  11. package/src/lib/package-managers/npm/npm.d.ts +2 -0
  12. package/src/lib/package-managers/npm/outdated-result.d.ts +2 -0
  13. package/src/lib/package-managers/npm/types.d.ts +38 -0
  14. package/src/lib/package-managers/package-managers.d.ts +3 -0
  15. package/src/lib/package-managers/pnpm/audit-result.d.ts +3 -0
  16. package/src/lib/package-managers/pnpm/outdated-result.d.ts +2 -0
  17. package/src/lib/package-managers/pnpm/pnpm.d.ts +2 -0
  18. package/src/lib/package-managers/pnpm/types.d.ts +26 -0
  19. package/src/lib/package-managers/types.d.ts +26 -0
  20. package/src/lib/package-managers/yarn-classic/audit-result.d.ts +2 -0
  21. package/src/lib/package-managers/yarn-classic/outdated-result.d.ts +2 -0
  22. package/src/lib/package-managers/yarn-classic/types.d.ts +49 -0
  23. package/src/lib/package-managers/yarn-classic/yarn-classic.d.ts +2 -0
  24. package/src/lib/package-managers/yarn-modern/audit-result.d.ts +2 -0
  25. package/src/lib/package-managers/yarn-modern/outdated-result.d.ts +2 -0
  26. package/src/lib/package-managers/yarn-modern/types.d.ts +26 -0
  27. package/src/lib/package-managers/yarn-modern/yarn-modern.d.ts +2 -0
  28. package/src/lib/runner/audit/constants.d.ts +1 -5
  29. package/src/lib/runner/audit/transform.d.ts +2 -2
  30. package/src/lib/runner/audit/types.d.ts +0 -87
  31. package/src/lib/runner/audit/utils.d.ts +2 -0
  32. package/src/lib/runner/outdated/constants.d.ts +2 -5
  33. package/src/lib/runner/outdated/transform.d.ts +2 -2
  34. package/src/lib/runner/outdated/types.d.ts +0 -43
  35. package/src/lib/runner/audit/unify-type.d.ts +0 -8
  36. package/src/lib/runner/outdated/unify-type.d.ts +0 -5
package/CONTRIBUTING.md CHANGED
@@ -2,9 +2,19 @@
2
2
 
3
3
  ## Adding new package managers
4
4
 
5
- In order to add a support for a new package manager, one needs to do the following.
5
+ In order to add a support for a new package manager, one needs to do the following:
6
6
 
7
- 1. Expand `packageManagerSchema` in `config.ts`.
8
- 2. Expand `<command>Args` in `runner/<command>/constants.ts` with a set of arguments to be run for a given package manager command.
9
- 3. Create a custom type in `runner/<command>/types.ts` with relevant properties based on expected command JSON output.
10
- 4. Create a function in `runner/<command>/unify-type.ts` that will transform JSON output into a normalized type `OutdatedResult` or `AuditResult` and add it to `normalized<command>Mapper` in `runner/<command>/constants.ts`.
7
+ 1. Expand `packageManagerIdSchema` in `config.ts`.
8
+ 2. Create a new object of `PackageManager` type in `package-managers/<name>/<name>.ts` and fill it in with all relevant data. Following the current pattern of separate files for audit and outdated result and types is recommended.
9
+ 3. Extend `package-managers/package-managers.ts` record with the new package manager.
10
+
11
+ > [!NOTE]
12
+ > Should your package manager require specific behaviour, feel free to request a property addition or change.
13
+
14
+ ### Notable properties
15
+
16
+ - `(audit|check).unifyResult()`: In order to process the results in a unified way, the expected type needs to be defined in `runner/(audit|check)/types.ts` and its transformation to normalised result implemented in `runner/(audit|check)/unify-type.ts`. This function is then referenced in the object to be called accordingly.
17
+ - `audit.getCommandArgs(depGroup)`: The `audit` command is run for one dependency group. In order to filter out the other dependencies, the arguments are provided dynamically based on this function. One may include frequently used arguments from `COMMON_AUDIT_ARGS`.
18
+ - `audit.ignoreExitCode`: Some package managers do not allow non-zero exit code override. To ignore non-zero exit code, set this property to `true`.
19
+ - `audit.supportedDepGroups`: Some package managers do not support `audit` check for all types of dependencies (e.g. optional). In that case, please list a supported subset of dependencies in this property. By default, all dependency groups are considered supported.
20
+ - `audit.postProcessResult()`: The `audit` check often does not offer exclusive result for all dependency groups. In order to filter out duplicates after the results are normalised, add a post-processing function here.
package/README.md CHANGED
@@ -22,7 +22,21 @@ It supports the following package managers:
22
22
 
23
23
  1. If you haven't already, install [@code-pushup/cli](../cli/README.md) and create a configuration file.
24
24
 
25
- 2. Insert plugin configuration with your package manager. By default, both `audit` and `outdated` checks will be run. The result should look as follows:
25
+ 2. Install as a dev dependency with your package manager:
26
+
27
+ ```sh
28
+ npm install --save-dev @code-pushup/js-packages-plugin
29
+ ```
30
+
31
+ ```sh
32
+ yarn add --dev @code-pushup/js-packages-plugin
33
+ ```
34
+
35
+ ```sh
36
+ pnpm add --save-dev @code-pushup/js-packages-plugin
37
+ ```
38
+
39
+ 3. Insert plugin configuration with your package manager. By default, both `audit` and `outdated` checks will be run. The result should look as follows:
26
40
 
27
41
  ```js
28
42
  import jsPackagesPlugin from '@code-pushup/js-packages-plugin';
@@ -50,7 +64,7 @@ It supports the following package managers:
50
64
  };
51
65
  ```
52
66
 
53
- 3. (Optional) Reference individual audits or the provided plugin groups which you wish to include in custom categories (use `npx code-pushup print-config` to list audits and groups).
67
+ 4. (Optional) Reference individual audits or the provided plugin groups which you wish to include in custom categories (use `npx code-pushup print-config` to list audits and groups).
54
68
 
55
69
  💡 Assign weights based on what influence each command should have on the overall category score (assign weight 0 to only include as extra info, without influencing category score).
56
70
 
@@ -88,7 +102,7 @@ It supports the following package managers:
88
102
  };
89
103
  ```
90
104
 
91
- 4. Run the CLI with `npx code-pushup collect` and view or upload report (refer to [CLI docs](../cli/README.md)).
105
+ 5. Run the CLI with `npx code-pushup collect` and view or upload report (refer to [CLI docs](../cli/README.md)).
92
106
 
93
107
  ## Plugin architecture
94
108