1.0.3 • Published 2 years ago

sync-gist v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Gist Sync

This package lets you sync data to and from a gist.

Usage

interface YourData {
    thing1: number;
    thing2: number;
}

const client = new SyncClient<YourData>({
    personalAccessToken: '<YOUR_ACCESS_TOKEN>', // Generate one at https://github.com/settings/tokens/new. Requires the `gist` scope.
    gistFileName: 'yourConfigFile.json',
});

const remoteConfig = await client.pullData(); // Config is the remote config, or undefined, if there was no data.

// A sync pulls the remote data and lets you merge the local and remote config before pushing.
await client.sync({
    thing1: 7,
    thing2: 99
}, (local, remote) => {
    // Your complicated merge resolution algorithm which definitely doesn't lose data:
    return local;
});

// Alternatively, you can just push your current config
await client.pushData({
    thing1: 9,
    thing2: 7
}, /*force=*/true);
1.0.2

2 years ago

1.0.1

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago