Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

g4c

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

g4c

CodeSandbox basic git commands wrapper.

  • 0.0.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-96.55%
Maintainers
1
Weekly downloads
 
Created
Source

g4c - Git for CodeSandbox

Summary

Aims to seamlessly support basic git commands via a bash alias in CodeSandbox.

  • Master sandbox
  • Git tracker

Commands we will support

Note: To bypass the bash alias and access the real git, use \git

  • git add .

  • git commit -m "My commit message"

  • git push

  • git pull

  • git status

  • g4c install

    • To be run after install through the package.json "prestart" script. Reads the env vars and modifies the container with a stable private key and a .bashrc alias.
  • g4c keygen

    • Runs ssh-keygen and escapes the new lines for use in G4C_ED25519

Setup

First, yarn add --dev g4c. This will give you access to the g4c command.

Second, generate your ssh-keys with npx g4c keygen

Third, configure the CodeSandbox secret environment variables

  • G4C_EMAIL
    • eg: 12345-CrashOverride@users.noreply.gitlab.com
  • G4C_REMOTE
  • G4C_ED25519
    • Your private key, with new lines replaced by $ signs
  • G4C_RSA (alternatively)
    • same thing, but for RSA

Finally, add "predev": "npx -y g4c i || :" under your package.json scripts. Replace prestart with predevelop, preserve or prestart if you do not have a "dev" script.

"install" scripts won't work as we need access to the secrets which are not available at install time, only at final runtime.

Known Issues

  • Binaries like PNGs are problematic. They are modified by CSB every time they are written, so keeping the exact same binary in git as in CSB is impossible. It may be possible to hide this issue by handling exif data.
  • npx -y g4c i should install latest if not found

Also,

Every call to rsyncjs copies all files, even if they are the same or have been copied before. As read calls are cheaper than write ones, one solution is to add support for a checksum function which will compare the file if the destination is younger. Hardlinks are not an option in CSB, as /sandbox has it's own device.

# How does git find changes?
Indexing. For every tracked file, Git records information such as its size, creation time and last modification time in a file known as the index. To determine whether a file has changed, Git compares its current stats with those cached in the index. If they match, then Git can skip reading the file again.

CodeSandbox it's self uses a similar strategy, because of it, the git clone files and the sandbox directory will have very similar mtime/ctime.

Keywords

FAQs

Package last updated on 09 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc