Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --no-upgrade flag #79

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be noUpgrade or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commander is smart enough to handle this automatically

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insane

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the types work automatically too (it parses the string)


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
Loading