npq 3.4.5 → 3.4.7

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.
@@ -30,7 +30,7 @@ class Marshall extends BaseMarshall {
30
30
  * @returns
31
31
  */
32
32
  async validate(pkg) {
33
- // @TODO move some of these utility functions about first package vesion
33
+ // @TODO move some of these utility functions about first package version
34
34
  // published, date diff, etc into the package repo utils
35
35
  const pakument = await this.packageRepoUtils.getPackageInfo(pkg.packageName)
36
36
 
@@ -67,16 +67,27 @@ class Marshall extends BaseMarshall {
67
67
 
68
68
  const firstPublishedDateString = pakument.time[firstVersionForUser.version]
69
69
 
70
- const dateDiffInMs = new Date(versionPublishedDateString) - new Date(firstPublishedDateString)
71
- let dateDiffInDays = 0
72
- if (dateDiffInMs > 0) {
73
- dateDiffInDays = Math.round(dateDiffInMs / (1000 * 60 * 60 * 24))
70
+ // get date in ms
71
+ const currentDate = new Date()
72
+ const dateDiffInMsVersionPublished = currentDate - new Date(versionPublishedDateString)
73
+ console.log(dateDiffInMsVersionPublished)
74
+ let dateDiffVersionPublished = 0
75
+ if (dateDiffInMsVersionPublished > 0) {
76
+ dateDiffVersionPublished = Math.round(dateDiffInMsVersionPublished / (1000 * 60 * 60 * 24))
74
77
  }
75
78
 
76
- if (dateDiffInDays <= 30) {
77
- throw new Error(
78
- `The user ${npmUser.name} <${npmUser.email}> published this package for the first time only ${dateDiffInDays} days ago.`
79
- )
79
+ if (dateDiffVersionPublished <= 45) {
80
+ const dateDiffInMs = new Date(versionPublishedDateString) - new Date(firstPublishedDateString)
81
+ let dateDiffInDays = 0
82
+ if (dateDiffInMs > 0) {
83
+ dateDiffInDays = Math.round(dateDiffInMs / (1000 * 60 * 60 * 24))
84
+ }
85
+
86
+ if (dateDiffInDays <= 30) {
87
+ throw new Error(
88
+ `The user ${npmUser.name} <${npmUser.email}> published this package for the first time only ${dateDiffInDays} days prior to this version.`
89
+ )
90
+ }
80
91
  }
81
92
 
82
93
  return versionPublishedDateString
@@ -54,7 +54,7 @@ class Marshall extends BaseMarshall {
54
54
 
55
55
  if (data && data.issuesCount && data.issuesCount > 0) {
56
56
  const packageSecurityInfo = `${SNYK_PACKAGE_PAGE}${encodeURIComponent(pkg.packageName)}`
57
- throw new Error(`${data.issuesCount} vulnerabilitie(s) found: ${packageSecurityInfo}`)
57
+ throw new Error(`${data.issuesCount} vulnerable path(s) found: ${packageSecurityInfo}`)
58
58
  }
59
59
 
60
60
  return data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npq",
3
- "version": "3.4.5",
3
+ "version": "3.4.7",
4
4
  "description": "marshall your npm/npm package installs with high quality and class 🎖",
5
5
  "bin": {
6
6
  "npq": "./bin/npq.js",