Created
May 13, 2024 07:00
-
-
Save ficapy/7e80b24cc6c2896eb6b64cc61304dddf to your computer and use it in GitHub Desktop.
change all codesandbox public to private
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const id = "YOUR ID"; | |
const query = ` | |
query TeamSidebarData($id: UUID4!) { | |
me { | |
team(id: $id) { | |
sandboxes(limit: 200, orderBy: {field: "updatedAt", direction: DESC}) { | |
...sandboxFragmentDashboard | |
} | |
} | |
} | |
} | |
fragment sandboxFragmentDashboard on Sandbox { | |
id | |
privacy | |
}`; | |
response = await fetch('https://codesandbox.io/api/graphql', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
query, | |
variables: { id } | |
}) | |
}); | |
const resp = await response.json(); | |
for (const sandbox of resp.data.me.team.sandboxes) { | |
if (sandbox.privacy === 0) { | |
console.log(`${sandbox.id}`) | |
await fetch(`https://codesandbox.io/api/v1/sandboxes/${sandbox.id}`, { | |
method: 'PUT', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ sandbox: { privacy: 2 } }) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment