node-codesandbox
v1.0.0-alpha.1
Published
Upload code to codesandbox
Downloads
9
Readme
node-codesandbox
Upload code to CodeSandbox using Node.
How is this different from the CodeSandbox CLI?
This is basically the CodeSandbox CLI plus the ability to modify what files are being uploaded in a config object.
This package can be seen as a proof of concept because if this proves to be something thats useful to people it should likely just be part of the CLI itself. I created it as a seperate package because I needed a quick and easy way to to do this and due to the simplicity of the CodeSandbox API and the way the CLI is currently structured it was faster to do this in a seperate package. And as a bonus it also helped me better understand how the CodeSandbox API works.
Usage
import {Uploader, getApiTokenFromUser, logSandboxUrl} from 'node-codesandbox';
(async () => {
const token = await getApiTokenFromUser();
const uploader = new Uploader(token);
const {sandboxUrl} = await uploader.upload(`path/to/folder`, {
include: ['playground', 'src'], // When defined, the uploader will only upload these files (supports glob patterns)
exclude: ['**/.DS_Store'], // Files to exclude (supports glob patterns)
files: {
'README.md': '# Hello!', // Extra files to include
},
});
logSandboxUrl(sandboxUrl);
})();