@n42/cli 0.1.63 → 0.1.68
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/package.json +1 -1
- package/src/auth.js +1 -2
- package/src/cli.js +48 -4
- package/src/discover.js +0 -2
package/package.json
CHANGED
package/src/auth.js
CHANGED
package/src/cli.js
CHANGED
|
@@ -97,18 +97,62 @@ program
|
|
|
97
97
|
program
|
|
98
98
|
.command("history <participantId>")
|
|
99
99
|
.description("Show local discovery history for a participant")
|
|
100
|
-
.
|
|
101
|
-
|
|
100
|
+
.option("--today", "Show only today's artefacts")
|
|
101
|
+
.option("--day <yyyy-mm-dd>", "Show artefacts for a specific day")
|
|
102
|
+
.option("--last <n>", "Show only last N results", parseInt)
|
|
103
|
+
.action((participantId, options) => {
|
|
104
|
+
let artefacts = db.artefactsByParticipant(participantId) ?? [];
|
|
105
|
+
|
|
106
|
+
// newest first
|
|
107
|
+
artefacts.sort((a, b) => b.createdAt - a.createdAt);
|
|
108
|
+
|
|
109
|
+
// ---- DATE FILTER ----
|
|
110
|
+
let dayFilter = null;
|
|
111
|
+
let filterInfo = "";
|
|
112
|
+
|
|
113
|
+
if (options.today) {
|
|
114
|
+
dayFilter = new Date().toISOString().slice(0, 10);
|
|
115
|
+
filterInfo = ", created today";
|
|
116
|
+
} else if (options.day) {
|
|
117
|
+
dayFilter = options.day;
|
|
118
|
+
filterInfo = `, created ${options.day}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (dayFilter) {
|
|
122
|
+
artefacts = artefacts.filter(x =>
|
|
123
|
+
new Date(x.createdAt).toISOString().slice(0, 10) === dayFilter
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ---- LAST N FILTER ----
|
|
128
|
+
if (options.last && Number.isInteger(options.last) && options.last > 0) {
|
|
129
|
+
artefacts = artefacts.slice(0, options.last);
|
|
130
|
+
filterInfo += `, showing last ${options.last}`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!artefacts.length) {
|
|
134
|
+
clearScreen(`Node42 CLI v${pkg.version}`);
|
|
135
|
+
console.log(`No artefacts found. (${dayFilter})`);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ---- OUTPUT ----
|
|
140
|
+
clearScreen(`Node42 CLI v${pkg.version}`);
|
|
141
|
+
console.log(`Found ${artefacts.length} artefact(s)${filterInfo}\n`);
|
|
102
142
|
|
|
103
143
|
for (const item of artefacts) {
|
|
104
144
|
const d = new Date(item.createdAt);
|
|
105
|
-
const dt = d.toISOString().slice(0,19).replace("T"," ");
|
|
145
|
+
const dt = d.toISOString().slice(0, 19).replace("T", " ");
|
|
106
146
|
const ext = getArtefactExt(item.output, item.format);
|
|
107
147
|
const file = path.join(ARTEFACTS_DIR, `${item.id}.${ext}`);
|
|
108
|
-
|
|
148
|
+
|
|
149
|
+
console.log(`${dt} ${file}`);
|
|
109
150
|
}
|
|
151
|
+
|
|
152
|
+
console.log("");
|
|
110
153
|
});
|
|
111
154
|
|
|
155
|
+
|
|
112
156
|
const discover = program
|
|
113
157
|
.command("discover")
|
|
114
158
|
.description("Discovery and diagnostic tooling for eDelivery paths");
|