Instantly share code, notes, and snippets.

@koenbok /circle.ts Secret
Created Dec 11, 2018

Embed
What would you like to do?
Framer X Git Publish Examples
import * as fs from "fs";
import { join, resolve } from "path";
import * as child_process from "child_process";
function getInfo(path: string) {
return JSON.parse(fs.readFileSync(join(path, "package.json")).toString());
}
function getRemoteInfo(path: string) {
const info = getInfo(path);
return JSON.parse(
child_process
.execSync(`yarn info ${info.name} --json`, {
cwd: path
})
.toString()
);
}
function getSuggestedVersion(version: string) {
const parts = version.split(".");
parts[1] = (parseInt(parts[1]) + 1).toString();
return parts.join(".");
}
async function publish(path: string, version?: string) {
const remoteInfo = getRemoteInfo(path);
version = version || getSuggestedVersion(remoteInfo.data.version);
run(
path,
"yarn",
"publish",
"--access=restricted",
`--new-version=${version}`,
"--no-git-tag-version"
);
console.log(`\n\n*** Published v${version} to Framer Store\n\n`);
}
function run(path: string, command: string, ...args) {
child_process.spawnSync(command, args, {
cwd: path,
stdio: [process.stdin, process.stdout, process.stderr]
});
}
async function main() {
const [a, b, path, version] = process.argv;
publish(resolve(path), version);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment