Skip to content

Commit

Permalink
feat: add --no-upgrade flag (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlalvani authored May 9, 2024
1 parent a598013 commit ec0403b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
4 changes: 3 additions & 1 deletion apps/cli/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,12 @@ const App = (props: {
pkg: string;
version: string;
port: number;
upgrade: boolean;
token?: string;
}) => {
const { exit } = useApp();

const { model, language, pkg, version, token, port } = props;
const { model, language, pkg, version, token, port, upgrade } = props;

const [columns, rows] = useStdoutDimensions();

Expand Down Expand Up @@ -254,6 +255,7 @@ const App = (props: {
"-p",
`${port}`,
...(token ? ["-t", token] : []),
...(upgrade ? [] : ["-n"]),
],
{
shell: true,
Expand Down
12 changes: 9 additions & 3 deletions apps/cli/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ const command = program
(val) => parseInt(val),
3000,
)
.option("-n, --no-upgrade", "skip applying the upgrade")
.option("-s, --simple", "simple mode")
.option("-i, --ipc", "run in ipc mode")
.parse();

const { model, language, port, ipc, simple, token } = command.opts();
const { model, language, port, ipc, simple, token, upgrade } = command.opts();

let [pkg, version] = command.processedArgs;

Expand Down Expand Up @@ -113,13 +114,17 @@ const bumpgen = makeBumpgen({
});

if (simple) {
for await (const event of bumpgen.execute()) {
for await (const event of bumpgen.execute({
upgrade,
})) {
console.log("event", event);
}
} else if (ipc) {
console.log("Running in IPC mode");

for await (const event of bumpgen.executeSerializeable()) {
for await (const event of bumpgen.executeSerializeable({
upgrade,
})) {
console.log("event", event);
try {
const options = {
Expand Down Expand Up @@ -147,6 +152,7 @@ if (simple) {
version={version}
token={token}
port={port}
upgrade={upgrade}
/>,
);
await app.waitUntilExit();
Expand Down
38 changes: 23 additions & 15 deletions packages/bumpgen-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,22 +394,26 @@ const bumpgen = ({
const execute = async function* (options?: {
maxIterations?: number;
timeout?: number;
upgrade?: boolean;
}) {
const upgrade = options?.upgrade ?? true;
let id;
try {
id = v4();
yield {
type: "upgrade.apply" as const,
status: "started" as const,
id,
};
const applied = await bumpgen.upgrade.apply();
yield {
type: "upgrade.apply" as const,
status: "finished" as const,
data: applied,
id,
};
if (upgrade) {
id = v4();
yield {
type: "upgrade.apply" as const,
status: "started" as const,
id,
};
const applied = await bumpgen.upgrade.apply();
yield {
type: "upgrade.apply" as const,
status: "finished" as const,
data: applied,
id,
};
}
let iteration = 0;
const startedAt = Date.now();

Expand Down Expand Up @@ -500,8 +504,12 @@ const bumpgen = ({
}
};

const executeSerializeable = async function* () {
for await (const event of execute()) {
const executeSerializeable = async function* (options?: {
maxIterations?: number;
timeout?: number;
upgrade?: boolean;
}) {
for await (const event of execute(options)) {
if (event.type === "graph.initialize" && event.status === "finished") {
yield {
...event,
Expand Down

0 comments on commit ec0403b

Please sign in to comment.