@nightlybuildgroup/vault 1.7.0 → 1.7.1
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 +1 -1
- package/src/commands/add.js +5 -4
- package/src/commands/items.js +4 -4
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -75,9 +75,10 @@ async function resolveFolderId(bw, session, folderName) {
|
|
|
75
75
|
return created.id;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
// Resolves a collection given by name OR id (and an optional org name/id).
|
|
79
|
+
async function resolveCollection(bw, session, collectionRef, org) {
|
|
79
80
|
const collections = await bw.listCollections({ session });
|
|
80
|
-
let matches = collections.filter((c) => c.name ===
|
|
81
|
+
let matches = collections.filter((c) => c.name === collectionRef || c.id === collectionRef);
|
|
81
82
|
if (org) {
|
|
82
83
|
const orgs = await bw.listOrganizations({ session });
|
|
83
84
|
const match = orgs.find((o) => o.id === org || o.name === org);
|
|
@@ -85,10 +86,10 @@ async function resolveCollection(bw, session, collectionName, org) {
|
|
|
85
86
|
matches = matches.filter((c) => c.organizationId === orgId);
|
|
86
87
|
}
|
|
87
88
|
if (matches.length === 0) {
|
|
88
|
-
throw new Error(`no collection
|
|
89
|
+
throw new Error(`no collection "${collectionRef}"${org ? ` in organization "${org}"` : ''}`);
|
|
89
90
|
}
|
|
90
91
|
if (matches.length > 1) {
|
|
91
|
-
throw new Error(`multiple collections named "${
|
|
92
|
+
throw new Error(`multiple collections named "${collectionRef}"; disambiguate with --organization <name|id>`);
|
|
92
93
|
}
|
|
93
94
|
return matches[0];
|
|
94
95
|
}
|
package/src/commands/items.js
CHANGED
|
@@ -43,16 +43,16 @@ export async function runItems(args, deps) {
|
|
|
43
43
|
let folderId;
|
|
44
44
|
if (folder !== null) {
|
|
45
45
|
const folders = await bw.listFolders({ session });
|
|
46
|
-
const match = folders.find((f) => f.name === folder
|
|
47
|
-
if (!match) throw new Error(`no folder
|
|
46
|
+
const match = folders.find((f) => f.id && (f.name === folder || f.id === folder));
|
|
47
|
+
if (!match) throw new Error(`no folder "${folder}"`);
|
|
48
48
|
folderId = match.id;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
let collectionId;
|
|
52
52
|
if (collection !== null) {
|
|
53
53
|
const collections = await bw.listCollections({ session });
|
|
54
|
-
const match = collections.find((c) => c.name === collection);
|
|
55
|
-
if (!match) throw new Error(`no collection
|
|
54
|
+
const match = collections.find((c) => c.name === collection || c.id === collection);
|
|
55
|
+
if (!match) throw new Error(`no collection "${collection}"`);
|
|
56
56
|
collectionId = match.id;
|
|
57
57
|
}
|
|
58
58
|
|