@tolinax/ayoune-cli 2024.2.11 → 2024.2.12
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.
|
@@ -9,6 +9,7 @@ import { promptFilePath } from "../prompts/promptFilePath.js";
|
|
|
9
9
|
import { promptFileName } from "../prompts/promptFileName.js";
|
|
10
10
|
import path from "path";
|
|
11
11
|
import { writeFile } from "fs/promises";
|
|
12
|
+
import { mkdirp } from "mkdirp";
|
|
12
13
|
export async function handleCollectionOperation(module, collection, entry, opts) {
|
|
13
14
|
spinner.start({ text: "", color: "magenta" });
|
|
14
15
|
let res;
|
|
@@ -49,7 +50,8 @@ export async function handleCollectionOperation(module, collection, entry, opts)
|
|
|
49
50
|
});
|
|
50
51
|
spinner.stop();
|
|
51
52
|
editContent = res.payload;
|
|
52
|
-
const folder = await promptFilePath();
|
|
53
|
+
const folder = await promptFilePath(collection);
|
|
54
|
+
await mkdirp(folder);
|
|
53
55
|
const fileName = await promptFileName(`${collection}_${editContent._id}.${opts.responseFormat}`);
|
|
54
56
|
await writeFile(path.join(folder, fileName), editContent, {
|
|
55
57
|
encoding: "utf8",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
|
-
export async function promptFilePath() {
|
|
4
|
+
export async function promptFilePath(fp) {
|
|
5
5
|
const { filePath } = await inquirer.prompt([
|
|
6
6
|
{
|
|
7
7
|
type: "fuzzypath",
|
|
8
8
|
name: "filePath",
|
|
9
9
|
message: "Select a target directory:",
|
|
10
10
|
itemType: "directory",
|
|
11
|
+
default: fp,
|
|
11
12
|
rootPath: path.join(os.homedir(), "aYOUne"),
|
|
12
|
-
suggestOnly:
|
|
13
|
+
suggestOnly: false,
|
|
13
14
|
depthLimit: 8,
|
|
14
15
|
},
|
|
15
16
|
]);
|