update cli

This commit is contained in:
Ruben Fiszel
2023-02-22 01:07:48 +01:00
parent 3d7a5a4520
commit 7558fb83d2
3 changed files with 24 additions and 13 deletions
+6 -2
View File
@@ -1,4 +1,4 @@
import { Any, model, property } from "./decoverto.ts";
import { Any, model, property, array } from "./decoverto.ts";
import {
AppService,
AppWithLastVersion,
@@ -16,11 +16,14 @@ export class AppFile implements Resource, PushDiffs {
summary: string;
@property(Any)
policy: Policy;
@property(array(() => Number))
versions: number[];
constructor(value: string, summary: string, policy: Policy) {
constructor(value: string, summary: string, policy: Policy, versions: number[]) {
this.value = value;
this.summary = summary;
this.policy = policy;
this.versions = versions;
}
async pushDiffs(
workspace: string,
@@ -38,6 +41,7 @@ export class AppFile implements Resource, PushDiffs {
summary?: string | undefined;
value?: any;
policy?: Policy | undefined;
versions?: number[] | undefined;
} = {};
for (const diff of diffs) {
if (
+4 -1
View File
@@ -48,6 +48,10 @@ export class FlowFile implements Resource, PushDiffs {
path: remotePath,
})
) {
console.log({
workspace: workspace,
path: remotePath,
})
console.log(
colors.bold.yellow(
`Applying ${diffs.length} diffs to existing flow... ${remotePath}`,
@@ -95,7 +99,6 @@ export class FlowFile implements Resource, PushDiffs {
...changeset,
...base_changeset,
}
console.log(JSON.stringify(update, null, 4));
await FlowService.updateFlow({
workspace: workspace,
path: remotePath,
+14 -10
View File
@@ -192,8 +192,8 @@ async function compareDynFSElement(
if (m2[k] === undefined) {
changes.push({ name: "added", path: k, content: v });
} else if (m2[k] != v) {
console.log(m2[k], v)
Deno.exit(1)
// await Deno.writeTextFile("/tmp/k", m2[k])
// await Deno.writeTextFile("/tmp/v", v)
changes.push({ name: "edited", path: k, after: v, before: m2[k] });
}
}
@@ -216,9 +216,9 @@ async function ignoreF() {
} = gitignore_parser.compile(
await Deno.readTextFile(".wmillignore"),
);
return ignore.denies
return (p: string) => p.startsWith(".wmill") || ignore.denies(p);
} catch (e) {
return () => false
return (p: string) => p.startsWith(".wmill");
}
}
@@ -255,12 +255,15 @@ async function pull(
const target = path.join(Deno.cwd(), change.path);
const stateTarget = path.join(Deno.cwd(), ".wmill", change.path)
if (change.name === "edited") {
if (await Deno.readTextFile(target) !== change.before && !opts.yes) {
console.log(colors.red(`Conflict detected on ${change.path}\nBoth local and remote have been modified.`))
if (await Confirm.prompt("Preserve local (push to change remote and avoid seeing this again)?")) {
continue;
try {
if (await Deno.readTextFile(target) !== change.before && !opts.yes) {
console.log(colors.red(`Conflict detected on ${change.path}\nBoth local and remote have been modified.`))
if (await Confirm.prompt("Preserve local (push to change remote and avoid seeing this again)?")) {
continue;
}
}
}
} catch { }
if (change.path.endsWith(".json")) {
const diffs =
microdiff(
@@ -269,6 +272,7 @@ async function pull(
{ cyclesFix: false },
)
console.log(diffs)
console.log(`Editing ${getTypeStrFromPath(change.path)} json ${change.path}`)
await applyDiff(
diffs,
@@ -385,7 +389,7 @@ async function push(opts: GlobalOptions & { raw: boolean, yes: boolean }) {
console.log("Computing diff local vs remote ...");
const remote = ZipFSElement((await downloadZip(workspace))!)
const local = await FSFSElement(path.join(Deno.cwd(), opts.raw ? "" : ".wmill"))
const local = await FSFSElement(path.join(Deno.cwd(), ""))
const changes = await compareDynFSElement(local, remote, await ignoreF(), opts.raw)
console.log(`${changes.length} changes to apply`);