@@ -428,30 +428,27 @@ const createAttribute = async (databaseId, collectionId, attribute) => {
428428const deployCollection = async ({ all, yes } = {}) => {
429429 let response = {};
430430
431- let collectionIds = [];
432- const configCollections = localConfig.getCollections();
431+ const collections = [];
433432
434433 if (all) {
435- if (configCollections .length === 0) {
434+ if (localConfig.getCollections() .length === 0) {
436435 throw new Error("No collections found in the current directory. Run `{{ language .params .executableName }} init collection` to fetch all your collections.");
437436 }
438- collectionIds.push(...configCollections.map((c) => c.$id));
439- }
440-
441- if (collectionIds.length < = 0) {
442- let answers = await inquirer.prompt(questionsDeployCollections[0])
443- collectionIds.push(...answers.collections);
444- }
445-
446- let collections = [];
447-
448- for (const collectionId of collectionIds) {
449- const idCollections = configCollections.filter((c) => c.$id === collectionId);
450- collections.push(...idCollections);
437+ collections.push(...localConfig.getCollections());
438+ } else {
439+ const answers = await inquirer.prompt(questionsDeployCollections[0])
440+ const configCollections = new Map();
441+ localConfig.getCollections().forEach((c) => {
442+ configCollections.set(`${c['databaseId']}|${c['$id']}`, c);
443+ });
444+ answers.collections.forEach((a) => {
445+ const collection = configCollections.get(a);
446+ collections.push(collection);
447+ })
451448 }
452449
453450 for (let collection of collections) {
454- log(`Deploying collection ${collection.name} ( ${collection['$id']} )`)
451+ log(`Deploying collection ${collection.name} ( ${collection['databaseId']} - ${collection[' $id']} )`)
455452
456453 let databaseId;
457454
0 commit comments