@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n42/cli",
3
- "version": "0.1.63",
3
+ "version": "0.1.68",
4
4
  "description": "Node42 CLI – Command-line interface for Peppol eDelivery path discovery, diagnostics, and tooling",
5
5
  "keywords": [
6
6
  "node42"
package/src/auth.js CHANGED
@@ -51,12 +51,11 @@ async function login() {
51
51
 
52
52
  await checkAuth();
53
53
  user = getUser();
54
+ stopSpinner();
54
55
 
55
56
  console.log(
56
57
  `Authenticated as ${user.userName} <${user.userMail}> (${user.role})`
57
58
  );
58
-
59
- stopSpinner();
60
59
  }
61
60
 
62
61
  function logout() {
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
- .action((participantId) => {
101
- const artefacts = db.artefactsByParticipant(participantId);
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
- console.log(`${dt}: ${file}`);
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");
package/src/discover.js CHANGED
@@ -126,8 +126,6 @@ async function runDiscovery(participantId, options) {
126
126
  id: refId,
127
127
  participantId,
128
128
  options,
129
- output,
130
- format,
131
129
  createdAt: Date.now()
132
130
  });
133
131