@tolinax/ayoune-cli 2024.2.15 → 2024.2.17

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 inquirer from "inquirer";
2
- import { apiCallHandler } from "../api/apiCallHandler.js";
3
- import { spinner } from "../../index.js";
4
- export async function handleEditRawOperation(module, collection, result) {
5
- const { content } = await inquirer.prompt([
6
- {
7
- type: "editor",
8
- name: "content",
9
- postfix: ".json",
10
- message: "Edit",
11
- default: JSON.stringify(result, null, 4),
12
- },
13
- ]);
14
- const contentToSave = JSON.parse(content);
15
- const { save } = await inquirer.prompt([
16
- {
17
- type: "confirm",
18
- name: "save",
19
- message: "Save changes",
20
- },
21
- ]);
22
- if (save) {
23
- spinner.start({
24
- text: `Attempting to save [${contentToSave.name}]`,
25
- color: "magenta",
26
- });
27
- const res = await apiCallHandler(`${module}/${collection.toLowerCase()}`, "put", JSON.parse(content));
28
- result = res.payload;
29
- console.log(result);
30
- spinner.success({
31
- text: `Saved [${contentToSave.name}] - Took ${res.meta.responseTime} ms`,
32
- });
33
- spinner.stop();
34
- }
35
- }
1
+ import inquirer from "inquirer";
2
+ import { apiCallHandler } from "../api/apiCallHandler.js";
3
+ import { spinner } from "../../index.js";
4
+ export async function handleEditRawOperation(module, collection, result) {
5
+ const { content } = await inquirer.prompt([
6
+ {
7
+ type: "editor",
8
+ name: "content",
9
+ postfix: ".json",
10
+ message: "Edit",
11
+ default: JSON.stringify(result, null, 4),
12
+ },
13
+ ]);
14
+ const contentToSave = JSON.parse(content);
15
+ const { save } = await inquirer.prompt([
16
+ {
17
+ type: "confirm",
18
+ name: "save",
19
+ message: "Save changes",
20
+ },
21
+ ]);
22
+ if (save) {
23
+ spinner.start({
24
+ text: `Attempting to save [${contentToSave.name}]`,
25
+ color: "magenta",
26
+ });
27
+ const res = await apiCallHandler(`${module}/${collection.toLowerCase()}`, "put", JSON.parse(content));
28
+ result = res.payload;
29
+ console.log(result);
30
+ spinner.success({
31
+ text: `Saved [${contentToSave.name}] - Took ${res.meta.responseTime} ms`,
32
+ });
33
+ spinner.stop();
34
+ }
35
+ }
@@ -1,25 +1,25 @@
1
- // Operation handling functions
2
- import { apiCallHandler } from "../api/apiCallHandler.js";
3
- import { spinner } from "../../index.js";
4
- import { handleResponseFormatOptions } from "../helpers/handleResponseFormatOptions.js";
5
- export async function handleGetOperation(module, collection, opts) {
6
- spinner.start({
7
- text: `Getting entries in [${collection}]`,
8
- color: "magenta",
9
- });
10
- let res = await apiCallHandler(`${module}/${collection.toLowerCase()}`, "get", null, {
11
- page: opts.page,
12
- responseFormat: opts.responseFormat,
13
- limit: opts.limit,
14
- from: opts.from,
15
- fields: opts.fields,
16
- hideMeta: opts.hideMeta,
17
- verbosity: opts.verbosity,
18
- });
19
- let { plainResult, result, meta, content } = handleResponseFormatOptions(opts, res);
20
- spinner.success({
21
- text: `Got ${opts.limit} entries of ${meta.pageInfo.totalEntries} : Page ${meta.pageInfo.page} of ${meta.pageInfo.totalPages}`,
22
- });
23
- spinner.stop();
24
- return { data: plainResult, content, result, meta };
25
- }
1
+ // Operation handling functions
2
+ import { apiCallHandler } from "../api/apiCallHandler.js";
3
+ import { spinner } from "../../index.js";
4
+ import { handleResponseFormatOptions } from "../helpers/handleResponseFormatOptions.js";
5
+ export async function handleGetOperation(module, collection, opts) {
6
+ spinner.start({
7
+ text: `Getting entries in [${collection}]`,
8
+ color: "magenta",
9
+ });
10
+ let res = await apiCallHandler(`${module}/${collection.toLowerCase()}`, "get", null, {
11
+ page: opts.page,
12
+ responseFormat: opts.responseFormat,
13
+ limit: opts.limit,
14
+ from: opts.from,
15
+ fields: opts.fields,
16
+ hideMeta: opts.hideMeta,
17
+ verbosity: opts.verbosity,
18
+ });
19
+ let { plainResult, result, meta, content } = handleResponseFormatOptions(opts, res);
20
+ spinner.success({
21
+ text: `Got ${opts.limit} entries of ${meta.pageInfo.totalEntries} : Page ${meta.pageInfo.page} of ${meta.pageInfo.totalPages}`,
22
+ });
23
+ spinner.stop();
24
+ return { data: plainResult, content, result, meta };
25
+ }
@@ -1,15 +1,15 @@
1
- import inquirer from "inquirer";
2
- export async function promptAudits(result) {
3
- const { audit } = await inquirer.prompt([
4
- {
5
- type: "list",
6
- name: "audit",
7
- message: "Choose a audit:",
8
- choices: result.map((el) => ({
9
- name: `${el.action} at ${el.ts} by ${el._userID.first_name} ${el._userID.last_name}`,
10
- value: el._id,
11
- })),
12
- },
13
- ]);
14
- return audit;
15
- }
1
+ import inquirer from "inquirer";
2
+ export async function promptAudits(result) {
3
+ const { audit } = await inquirer.prompt([
4
+ {
5
+ type: "list",
6
+ name: "audit",
7
+ message: "Choose a audit:",
8
+ choices: result.map((el) => ({
9
+ name: `${el.action} at ${el.ts} by ${el._userID.first_name} ${el._userID.last_name}`,
10
+ value: el._id,
11
+ })),
12
+ },
13
+ ]);
14
+ return audit;
15
+ }
@@ -1,12 +1,12 @@
1
- import inquirer from "inquirer";
2
- export async function promptFileName(name) {
3
- const { fileName } = await inquirer.prompt([
4
- {
5
- type: "text",
6
- name: "fileName",
7
- message: "Specify a file name",
8
- default: name,
9
- },
10
- ]);
11
- return fileName;
12
- }
1
+ import inquirer from "inquirer";
2
+ export async function promptFileName(name) {
3
+ const { fileName } = await inquirer.prompt([
4
+ {
5
+ type: "text",
6
+ name: "fileName",
7
+ message: "Specify a file name",
8
+ default: name,
9
+ },
10
+ ]);
11
+ return fileName;
12
+ }
@@ -1,18 +1,18 @@
1
- import inquirer from "inquirer";
2
- import os from "os";
3
- import path from "path";
4
- export async function promptFilePath(fp) {
5
- const { filePath } = await inquirer.prompt([
6
- {
7
- type: "fuzzypath",
8
- name: "filePath",
9
- message: "Select a target directory:",
10
- itemType: "directory",
11
- default: fp,
12
- rootPath: path.join(os.homedir(), "aYOUne"),
13
- suggestOnly: false,
14
- depthLimit: 8,
15
- },
16
- ]);
17
- return filePath;
18
- }
1
+ import inquirer from "inquirer";
2
+ import os from "os";
3
+ import path from "path";
4
+ export async function promptFilePath(fp) {
5
+ const { filePath } = await inquirer.prompt([
6
+ {
7
+ type: "fuzzypath",
8
+ name: "filePath",
9
+ message: "Select a target directory:",
10
+ itemType: "directory",
11
+ default: fp,
12
+ rootPath: path.join(os.homedir(), "aYOUne"),
13
+ suggestOnly: false,
14
+ depthLimit: 8,
15
+ },
16
+ ]);
17
+ return filePath;
18
+ }
@@ -1,6 +1,6 @@
1
1
  // Prompt functions
2
2
  import inquirer from "inquirer";
3
- import { aYOUneModules } from "@tolinax/ayoune-models/data/modules.js";
3
+ import { aYOUneModules } from "../../data/modules.js";
4
4
  export async function promptModule() {
5
5
  const { module } = await inquirer.prompt([
6
6
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolinax/ayoune-cli",
3
- "version": "2024.2.15",
3
+ "version": "2024.2.17",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -102,7 +102,6 @@
102
102
  }
103
103
  },
104
104
  "dependencies": {
105
- "@tolinax/ayoune-models": "^2024.2.29",
106
105
  "axios": "^1.6.7",
107
106
  "axios-retry": "^4.0.0",
108
107
  "chalk": "^5.3.0",
@@ -1,11 +0,0 @@
1
- import inquirer from "inquirer";
2
- export async function promptFilePath() {
3
- const { path } = await inquirer.prompt([
4
- {
5
- type: "fuzzypath",
6
- name: "path",
7
- message: "Select a target directory:",
8
- },
9
- ]);
10
- return path;
11
- }