diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index cbb38f1f..1de747e2 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -91,7 +91,6 @@ jobs: CI: true PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} run: npm run test:integration:cleanup - typescript-compilation-tests: name: TS compile runs-on: ubuntu-latest diff --git a/utils/cleanupResources.ts b/utils/cleanupResources.ts index a76a9f4b..a419c1a0 100644 --- a/utils/cleanupResources.ts +++ b/utils/cleanupResources.ts @@ -1,4 +1,7 @@ -var dotenv = require('dotenv'); +const dotenv = require('dotenv'); + +const pinecone = require('../dist'); + dotenv.config(); for (const envVar of ['PINECONE_API_KEY']) { @@ -8,23 +11,33 @@ for (const envVar of ['PINECONE_API_KEY']) { console.log(`INFO Found environment variable ${envVar} in .env file`); } } - -var pinecone = require('../dist'); - (async () => { const p = new pinecone.Pinecone(); const collectionList = await p.listCollections(); - for (const collection of collectionList.collections) { - console.log(`Deleting collection ${collection.name}`); - await p.deleteCollection(collection.name); + if (collectionList.collections) { + for (const collection of collectionList.collections) { + console.log(`Deleting collection ${collection.name}`); + await p.deleteCollection(collection.name); + } } const response = await p.listIndexes(); - for (const index of response.indexes) { - console.log(`Deleting index ${index.name}`); - await p.deleteIndex(index.name); + if (response.indexes) { + for (const index of response.indexes) { + if (index.deletionProtection === 'enabled') { + console.log( + 'Changing deletionProtection status for index...', + index.name + ); + await p.configureIndex(index.name, { deletionProtection: 'disabled' }); + console.log(`Deleting index ${index.name}...`); + await p.deleteIndex(index.name); + } else { + console.log(`Deleting index ${index.name}`); + await p.deleteIndex(index.name); + } + } + process.exit(); } - - process.exit(); })(); diff --git a/utils/replInit.ts b/utils/replInit.ts index 350b1e40..169ebf0f 100644 --- a/utils/replInit.ts +++ b/utils/replInit.ts @@ -2,7 +2,7 @@ // and import top level exports of the built version of the library so it can be easily used for // manual testing. It will typically be invoked via `npm run repl`. -var dotenv = require('dotenv'); +const dotenv = require('dotenv'); dotenv.config(); const expectedVars = ['PINECONE_API_KEY']; @@ -14,8 +14,8 @@ for (const envVar of expectedVars) { } } -var myrepl = require('repl').start(); -var pinecone = require('../dist'); +const myrepl = require('repl').start(); +const pinecone = require('../dist'); // Automatically import all top-level exports from the built version of the library. for (const [key, value] of Object.entries(pinecone)) {