0.0.5 • Published 2 years ago

git-beeson-schema v0.0.5

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
2 years ago

Git-BeeSon-Schema

A git utility for beeson

Usage

Check output of the following

NODE_RUN_TEST=true ts-node ./src/index.ts
// A state machine
const gitState = new GitState();

// Author data. Can be varied between commits.
const authorData = {
  email: "97761020+SurroundingArt64@users.noreply.github.com",
  name: "SurroundingArt64",
  time: Math.floor(Date.now() / 1000),
  timeZoneOffset: {
    negative: false,
    value: "0000",
  },
};

// Takes a path to a folder.
// Initializes a git tree with index at the top.
// Recursively updates the tree and creates deflated blobs of all files
// and stores as refs.

// Second argument is the commit data with an empty treeHash.
// The treeHash is computed at run-time.
gitState
  .initializeTreeAndCommit(join(__dirname, "..", "test_repo"), {
    author: authorData,
    committer: authorData,
    message: "feat: initial commit",
    treeHash: "",
  })
  .entries.map((e) => {
    // Logging data of the tree
    if (e instanceof IndexEntry) {
      console.log(
        `${e.definitions.mode.value.toString(8)} blob ${
          e.definitions.sha.value
        }   ${e.filePath}`
      );
    } else {
      // Indicates a subtree/directory
      console.log(`040000 tree ${e.sha}   ${e.filePath}`);
    }
  });

const beeSon = new BeeSon({
  json: { refs: gitState.toArray(), indexHash: gitState.indexCommitHash },
});

console.log(beeSon);
0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago