npq 3.4.4 → 3.4.6
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.
package/lib/cliCommons.js
CHANGED
|
@@ -33,6 +33,14 @@ class cliCommons {
|
|
|
33
33
|
|
|
34
34
|
static getOptions() {
|
|
35
35
|
return {
|
|
36
|
+
S: {
|
|
37
|
+
alias: ['save', 'save-prod', 'save-optional', 'save-bundle'],
|
|
38
|
+
type: 'boolean'
|
|
39
|
+
},
|
|
40
|
+
g: {
|
|
41
|
+
alias: 'global',
|
|
42
|
+
type: 'boolean'
|
|
43
|
+
},
|
|
36
44
|
P: {
|
|
37
45
|
alias: ['save-prod', 'peer'],
|
|
38
46
|
type: 'boolean'
|
|
@@ -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
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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 (
|
|
77
|
-
|
|
78
|
-
|
|
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
|