diff --git a/cli/apps.ts b/cli/apps.ts index 72f1204bd3..1bbd1bafd5 100644 --- a/cli/apps.ts +++ b/cli/apps.ts @@ -1,6 +1,7 @@ import { Any, model, property } from "./decoverto.ts"; import { AppService, + AppWithLastVersion, colors, microdiff, Policy, @@ -27,14 +28,18 @@ export class AppFile implements Resource, PushDiffs { remotePath: string, diffs: Difference[], ): Promise { - if (await AppService.existsApp({ workspace, path: remotePath })) { + let app: AppWithLastVersion | undefined = undefined; + try { + app = await AppService.getAppByPath({ workspace, path: remotePath }); + } catch (e) {} + + if (app) { console.log( colors.bold.yellow( `Applying ${diffs.length} diffs to existing app... ${remotePath}`, ), ); const changeset: { - path?: string | undefined; summary?: string | undefined; value?: any; policy?: Policy | undefined; @@ -45,7 +50,7 @@ export class AppFile implements Resource, PushDiffs { ( diff.path[0] !== "value" && diff.path[0] !== "policy" && ( diff.path.length !== 1 || - !["path", "summary"].includes( + !["summary"].includes( diff.path[0] as string, ) ) @@ -60,6 +65,13 @@ export class AppFile implements Resource, PushDiffs { } } + if ((!changeset?.policy || JSON.stringify(changeset?.policy) == JSON.stringify(app.policy)) + && (!changeset?.value || JSON.stringify(changeset?.value) == JSON.stringify(app.value)) + && (!changeset?.summary || changeset.summary == app.summary)) { + console.log(colors.yellow(`No changes to push for app ${remotePath}, skipping`)) + return; + } + const hasChanges = Object.values(changeset).some((v) => v !== null && typeof v !== "undefined" ); diff --git a/cli/resource.ts b/cli/resource.ts index f532b8877a..c1165b034e 100644 --- a/cli/resource.ts +++ b/cli/resource.ts @@ -51,11 +51,7 @@ export class ResourceFile implements Resource2, PushDiffs { }; for (const diff of diffs) { if (diff.path[0] === "is_oauth") { - console.log( - colors.yellow( - "! is_oauth has been removed in newer versions. Ignoring.", - ), - ); + //is_oauth is not updatable continue; } if ( diff --git a/cli/script.ts b/cli/script.ts index 33c075366d..52da84b7b9 100644 --- a/cli/script.ts +++ b/cli/script.ts @@ -106,16 +106,21 @@ export async function handleFile(path: string, content: string, workspace: strin } catch { } const language = inferContentTypeFromFilePath(path); + let remote = undefined try { - const remote = await ScriptService.getScriptByPath({ + remote = await ScriptService.getScriptByPath({ workspace, path: remotePath, }); - - if (typed.description === remote.description && content === remote.content && typed.summary === remote.summary && typed.is_template === remote.is_template && typed.kind == remote.kind && typed.lock == remote.lock && JSON.stringify(typed.schema) == JSON.stringify(remote.schema)) { - console.log(colors.yellow.bold(`Skipping script ${remotePath}`)) + } catch { } + + if (remote) { + if (typed.description === remote.description && content === remote.content && typed.summary === remote.summary && typed.is_template === remote.is_template && typed.kind == remote.kind && remote?.lock == typed.lock?.join('\n') && JSON.stringify(typed.schema) == JSON.stringify(remote.schema)) { + console.log(colors.yellow(`No change to push for script ${remotePath}, skipping`)) return true } + + await ScriptService.createScript({ workspace, requestBody: { @@ -133,7 +138,7 @@ export async function handleFile(path: string, content: string, workspace: strin }); console.log(colors.yellow.bold(`Creating script with a parent ${remotePath}`)) - } catch { + } else { // no parent hash await ScriptService.createScript({ workspace: workspace,