@tolinax/ayoune-cli 2024.2.9 → 2024.2.11

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.
@@ -11,25 +11,44 @@ import path from "path";
11
11
  import { writeFile } from "fs/promises";
12
12
  export async function handleCollectionOperation(module, collection, entry, opts) {
13
13
  spinner.start({ text: "", color: "magenta" });
14
- const res = await apiCallHandler(`${module}/${collection.toLowerCase()}/${entry}?responseFormat=table`);
15
- const editContent = res.payload;
16
- console.log(editContent);
17
- spinner.success({
18
- text: `Got entry ${res.payload.name} - Took ${res.meta.responseTime} ms`,
19
- });
20
- spinner.stop();
14
+ let res;
15
+ let editContent;
21
16
  const action = await promptDefaultAction();
22
17
  switch (action) {
23
18
  case "edit":
19
+ res = await apiCallHandler(`${module}/${collection.toLowerCase()}/${entry}?responseFormat=table`);
20
+ spinner.success({
21
+ text: `Got entry ${res.payload.name} - Took ${res.meta.responseTime} ms`,
22
+ });
23
+ spinner.stop();
24
+ editContent = res.payload;
24
25
  await handleEditOperation(module, collection, editContent);
25
26
  break;
26
27
  case "edit raw":
28
+ res = await apiCallHandler(`${module}/${collection.toLowerCase()}/${entry}?responseFormat=${opts.responseFormat}`);
29
+ spinner.success({
30
+ text: `Got entry ${res.payload.name} - Took ${res.meta.responseTime} ms`,
31
+ });
32
+ spinner.stop();
33
+ editContent = res.payload;
27
34
  await handleEditRawOperation(module, collection, editContent);
28
35
  break;
29
36
  case "describe":
37
+ res = await apiCallHandler(`${module}/${collection.toLowerCase()}/${entry}?responseFormat=yaml}`);
38
+ spinner.success({
39
+ text: `Got entry ${res.payload.name} - Took ${res.meta.responseTime} ms`,
40
+ });
41
+ spinner.stop();
42
+ editContent = res.payload;
30
43
  console.log(yaml.dump(editContent));
31
44
  break;
32
45
  case "download":
46
+ res = await apiCallHandler(`${module}/${collection.toLowerCase()}/${entry}?responseFormat=yaml}`);
47
+ spinner.success({
48
+ text: `Got entry ${res.payload.name} - Took ${res.meta.responseTime} ms`,
49
+ });
50
+ spinner.stop();
51
+ editContent = res.payload;
33
52
  const folder = await promptFilePath();
34
53
  const fileName = await promptFileName(`${collection}_${editContent._id}.${opts.responseFormat}`);
35
54
  await writeFile(path.join(folder, fileName), editContent, {
@@ -1,11 +1,17 @@
1
1
  import inquirer from "inquirer";
2
+ import os from "os";
3
+ import path from "path";
2
4
  export async function promptFilePath() {
3
- const { path } = await inquirer.prompt([
5
+ const { filePath } = await inquirer.prompt([
4
6
  {
5
7
  type: "fuzzypath",
6
- name: "path",
8
+ name: "filePath",
7
9
  message: "Select a target directory:",
10
+ itemType: "directory",
11
+ rootPath: path.join(os.homedir(), "aYOUne"),
12
+ suggestOnly: true,
13
+ depthLimit: 8,
8
14
  },
9
15
  ]);
10
- return path;
16
+ return filePath;
11
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolinax/ayoune-cli",
3
- "version": "2024.2.9",
3
+ "version": "2024.2.11",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./index.js",