@tolinax/ayoune-cli 2024.2.6 → 2024.2.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.
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { parseInteger } from "../helpers/parseInt.js";
|
|
2
|
-
import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
|
|
3
|
-
import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
|
|
4
|
-
import { handleListOperation } from "../operations/handleListOperation.js";
|
|
5
|
-
import { saveFile } from "../helpers/saveFile.js";
|
|
6
|
-
import { localStorage } from "../helpers/localStorage.js";
|
|
7
|
-
export function createListCommand(program) {
|
|
8
|
-
program
|
|
9
|
-
.command("list [collection]")
|
|
10
|
-
.alias("l")
|
|
11
|
-
.description("List entries in collection")
|
|
12
|
-
.option("-p, --page <number>", "Page", parseInteger, 1)
|
|
13
|
-
.option("-l, --limit <number>", "Limit", parseInteger, 20)
|
|
14
|
-
.option("-f, --from <date>", "From date")
|
|
15
|
-
.action(async (collection, options) => {
|
|
16
|
-
try {
|
|
17
|
-
const opts = { ...program.opts(), ...options };
|
|
18
|
-
if (!collection) {
|
|
19
|
-
collection = await promptCollectionWithModule();
|
|
20
|
-
}
|
|
21
|
-
const module = getModuleFromCollection(collection);
|
|
22
|
-
localStorage.setItem("lastModule", module.module);
|
|
23
|
-
localStorage.setItem("lastCollection", collection);
|
|
24
|
-
let result = {};
|
|
25
|
-
let entry = "";
|
|
26
|
-
result = await handleListOperation(module.module, collection, opts);
|
|
27
|
-
if (opts.save) {
|
|
28
|
-
await saveFile("list", opts, result);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
console.error(e);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
1
|
+
import { parseInteger } from "../helpers/parseInt.js";
|
|
2
|
+
import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
|
|
3
|
+
import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
|
|
4
|
+
import { handleListOperation } from "../operations/handleListOperation.js";
|
|
5
|
+
import { saveFile } from "../helpers/saveFile.js";
|
|
6
|
+
import { localStorage } from "../helpers/localStorage.js";
|
|
7
|
+
export function createListCommand(program) {
|
|
8
|
+
program
|
|
9
|
+
.command("list [collection]")
|
|
10
|
+
.alias("l")
|
|
11
|
+
.description("List entries in collection")
|
|
12
|
+
.option("-p, --page <number>", "Page", parseInteger, 1)
|
|
13
|
+
.option("-l, --limit <number>", "Limit", parseInteger, 20)
|
|
14
|
+
.option("-f, --from <date>", "From date")
|
|
15
|
+
.action(async (collection, options) => {
|
|
16
|
+
try {
|
|
17
|
+
const opts = { ...program.opts(), ...options };
|
|
18
|
+
if (!collection) {
|
|
19
|
+
collection = await promptCollectionWithModule();
|
|
20
|
+
}
|
|
21
|
+
const module = getModuleFromCollection(collection);
|
|
22
|
+
localStorage.setItem("lastModule", module.module);
|
|
23
|
+
localStorage.setItem("lastCollection", collection);
|
|
24
|
+
let result = {};
|
|
25
|
+
let entry = "";
|
|
26
|
+
result = await handleListOperation(module.module, collection, opts);
|
|
27
|
+
if (opts.save) {
|
|
28
|
+
await saveFile("list", opts, result);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
console.error(e);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { promptModule } from "../prompts/promptModule.js";
|
|
2
|
-
import { promptCollectionInModule } from "../prompts/promptCollectionInModule.js";
|
|
3
|
-
import { promptOperation } from "../prompts/promptOperation.js";
|
|
4
|
-
import { handleListOperation } from "../operations/handleListOperation.js";
|
|
5
|
-
import { promptEntry } from "../prompts/promptEntry.js";
|
|
6
|
-
import { handleCollectionOperation } from "../operations/handleCollectionOperation.js";
|
|
7
|
-
import { localStorage } from "../helpers/localStorage.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { promptModule } from "../prompts/promptModule.js";
|
|
2
|
+
import { promptCollectionInModule } from "../prompts/promptCollectionInModule.js";
|
|
3
|
+
import { promptOperation } from "../prompts/promptOperation.js";
|
|
4
|
+
import { handleListOperation } from "../operations/handleListOperation.js";
|
|
5
|
+
import { promptEntry } from "../prompts/promptEntry.js";
|
|
6
|
+
import { handleCollectionOperation } from "../operations/handleCollectionOperation.js";
|
|
7
|
+
import { localStorage } from "../helpers/localStorage.js";
|
|
8
|
+
import { parseInteger } from "../helpers/parseInt.js";
|
|
9
|
+
export function createModulesCommand(program) {
|
|
10
|
+
program
|
|
11
|
+
.command("modules")
|
|
12
|
+
.alias("m")
|
|
13
|
+
.description("List modules")
|
|
14
|
+
.option("-p, --page <number>", "Page", parseInteger, 1)
|
|
15
|
+
.option("-l, --limit <number>", "Limit", parseInteger, 20)
|
|
16
|
+
.option("-f, --from <date>", "From date")
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
try {
|
|
19
|
+
const opts = { ...program.opts(), ...options };
|
|
20
|
+
const module = await promptModule();
|
|
21
|
+
const collection = await promptCollectionInModule(module);
|
|
22
|
+
const operation = await promptOperation();
|
|
23
|
+
localStorage.setItem("lastModule", module);
|
|
24
|
+
localStorage.setItem("lastCollection", collection);
|
|
25
|
+
let entry = "";
|
|
26
|
+
if (operation === "list") {
|
|
27
|
+
const { result } = await handleListOperation(module, collection, opts);
|
|
28
|
+
entry = await promptEntry(result);
|
|
29
|
+
}
|
|
30
|
+
await handleCollectionOperation(module, collection, entry, operation);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.error(e);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// All the remaining operations are classified here
|
|
2
|
-
import { apiCallHandler } from "../api/apiCallHandler.js";
|
|
3
|
-
import { handleEditOperation } from "./handleEditOperation.js";
|
|
4
|
-
import { handleEditRawOperation } from "./handleEditRawOperation.js";
|
|
5
|
-
import { spinner } from "../../index.js";
|
|
6
|
-
import { promptDefaultAction } from "../prompts/promptDefaultAction.js";
|
|
7
|
-
export async function handleCollectionOperation(module, collection, entry, operation) {
|
|
8
|
-
spinner.start({ text: "", color: "magenta" });
|
|
9
|
-
const res = await apiCallHandler(`${module}/${collection.toLowerCase()}/${entry}?responseFormat=table`);
|
|
10
|
-
const editContent = res.payload;
|
|
11
|
-
console.log(editContent);
|
|
12
|
-
spinner.success({
|
|
13
|
-
text: `Got entry ${res.payload.name} - Took ${res.meta.responseTime} ms`,
|
|
14
|
-
});
|
|
15
|
-
spinner.stop();
|
|
16
|
-
const action = await promptDefaultAction();
|
|
17
|
-
switch (action) {
|
|
18
|
-
case "edit":
|
|
19
|
-
await handleEditOperation(module, collection, editContent);
|
|
20
|
-
break;
|
|
21
|
-
case "edit raw":
|
|
22
|
-
await handleEditRawOperation(module, collection, editContent);
|
|
23
|
-
break;
|
|
24
|
-
default:
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
// All the remaining operations are classified here
|
|
2
|
+
import { apiCallHandler } from "../api/apiCallHandler.js";
|
|
3
|
+
import { handleEditOperation } from "./handleEditOperation.js";
|
|
4
|
+
import { handleEditRawOperation } from "./handleEditRawOperation.js";
|
|
5
|
+
import { spinner } from "../../index.js";
|
|
6
|
+
import { promptDefaultAction } from "../prompts/promptDefaultAction.js";
|
|
7
|
+
export async function handleCollectionOperation(module, collection, entry, operation) {
|
|
8
|
+
spinner.start({ text: "", color: "magenta" });
|
|
9
|
+
const res = await apiCallHandler(`${module}/${collection.toLowerCase()}/${entry}?responseFormat=table`);
|
|
10
|
+
const editContent = res.payload;
|
|
11
|
+
console.log(editContent);
|
|
12
|
+
spinner.success({
|
|
13
|
+
text: `Got entry ${res.payload.name} - Took ${res.meta.responseTime} ms`,
|
|
14
|
+
});
|
|
15
|
+
spinner.stop();
|
|
16
|
+
const action = await promptDefaultAction();
|
|
17
|
+
switch (action) {
|
|
18
|
+
case "edit":
|
|
19
|
+
await handleEditOperation(module, collection, editContent);
|
|
20
|
+
break;
|
|
21
|
+
case "edit raw":
|
|
22
|
+
await handleEditRawOperation(module, collection, editContent);
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|