mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 16:02:10 +00:00
fix(cli): check for existing resource even in raw mode
This commit is contained in:
+9
-13
@@ -27,20 +27,17 @@ export async function pushApp(
|
||||
remotePath: string,
|
||||
app: AppFile | AppWithLastVersion | undefined,
|
||||
newApp: AppFile,
|
||||
raw: boolean,
|
||||
message?: string
|
||||
): Promise<void> {
|
||||
remotePath = removeType(remotePath, "app");
|
||||
if (raw) {
|
||||
// deleting old app if it exists in raw mode
|
||||
try {
|
||||
app = await AppService.getAppByPath({
|
||||
workspace,
|
||||
path: remotePath.replaceAll("\\", "/"),
|
||||
});
|
||||
} catch {
|
||||
//ignore
|
||||
}
|
||||
// deleting old app if it exists in raw mode
|
||||
try {
|
||||
app = await AppService.getAppByPath({
|
||||
workspace,
|
||||
path: remotePath.replaceAll("\\", "/"),
|
||||
});
|
||||
} catch {
|
||||
//ignore
|
||||
}
|
||||
|
||||
if (app) {
|
||||
@@ -119,8 +116,7 @@ async function push(opts: GlobalOptions, filePath: string) {
|
||||
workspace.workspaceId,
|
||||
remotePath,
|
||||
app,
|
||||
parseFromFile(filePath),
|
||||
false
|
||||
parseFromFile(filePath)
|
||||
);
|
||||
console.log(colors.bold.underline.green("App pushed"));
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// windmill
|
||||
export { setClient } from "https://deno.land/x/windmill@v1.216.0/mod.ts";
|
||||
export * from "https://deno.land/x/windmill@v1.216.0/windmill-api/index.ts";
|
||||
export { setClient } from "https://deno.land/x/windmill@v1.225.0/mod.ts";
|
||||
export * from "https://deno.land/x/windmill@v1.225.0/windmill-api/index.ts";
|
||||
export { SEP } from "https://deno.land/std@0.201.0/path/separator.ts";
|
||||
// cliffy
|
||||
export { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.2/command/mod.ts";
|
||||
|
||||
+9
-13
@@ -43,8 +43,7 @@ export async function pushFolder(
|
||||
workspace: string,
|
||||
name: string,
|
||||
folder: Folder | FolderFile | undefined,
|
||||
localFolder: FolderFile,
|
||||
raw: boolean
|
||||
localFolder: FolderFile
|
||||
): Promise<void> {
|
||||
if (name.startsWith(SEP)) {
|
||||
name = name.substring(1);
|
||||
@@ -55,15 +54,13 @@ export async function pushFolder(
|
||||
name = name.split(SEP)[0];
|
||||
log.debug(`Processing local folder ${name}`);
|
||||
|
||||
if (raw) {
|
||||
// deleting old app if it exists in raw mode
|
||||
try {
|
||||
folder = await FolderService.getFolder({ workspace, name });
|
||||
log.debug(`Folder ${name} exists on remote`);
|
||||
} catch {
|
||||
log.debug(`Folder ${name} does not exist on remote`);
|
||||
//ignore
|
||||
}
|
||||
// deleting old app if it exists in raw mode
|
||||
try {
|
||||
folder = await FolderService.getFolder({ workspace, name });
|
||||
log.debug(`Folder ${name} exists on remote`);
|
||||
} catch {
|
||||
log.debug(`Folder ${name} does not exist on remote`);
|
||||
//ignore
|
||||
}
|
||||
|
||||
if (folder) {
|
||||
@@ -120,8 +117,7 @@ async function push(opts: GlobalOptions, filePath: string, remotePath: string) {
|
||||
workspace.workspaceId,
|
||||
remotePath,
|
||||
undefined,
|
||||
parseFromFile(filePath),
|
||||
false
|
||||
parseFromFile(filePath)
|
||||
);
|
||||
console.log(colors.bold.underline.green("Folder pushed"));
|
||||
}
|
||||
|
||||
+10
-13
@@ -24,20 +24,18 @@ export async function pushResourceType(
|
||||
workspace: string,
|
||||
remotePath: string,
|
||||
resource: ResourceTypeFile | ResourceType | undefined,
|
||||
localResource: ResourceTypeFile,
|
||||
raw: boolean
|
||||
localResource: ResourceTypeFile
|
||||
): Promise<void> {
|
||||
remotePath = removeType(remotePath, "resource-type");
|
||||
if (raw) {
|
||||
try {
|
||||
resource = await ResourceService.getResourceType({
|
||||
workspace: workspace,
|
||||
path: remotePath,
|
||||
});
|
||||
} catch {
|
||||
// resource type doesn't exist
|
||||
}
|
||||
try {
|
||||
resource = await ResourceService.getResourceType({
|
||||
workspace: workspace,
|
||||
path: remotePath,
|
||||
});
|
||||
} catch {
|
||||
// resource type doesn't exist
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
if (isSuperset(localResource, resource)) {
|
||||
return;
|
||||
@@ -77,8 +75,7 @@ async function push(opts: PushOptions, filePath: string, name: string) {
|
||||
workspace.workspaceId,
|
||||
name,
|
||||
undefined,
|
||||
parseFromFile(filePath),
|
||||
true
|
||||
parseFromFile(filePath)
|
||||
);
|
||||
log.info(colors.bold.underline.green("Resource pushed"));
|
||||
}
|
||||
|
||||
+10
-13
@@ -26,20 +26,18 @@ export async function pushResource(
|
||||
workspace: string,
|
||||
remotePath: string,
|
||||
resource: ResourceFile | Resource | undefined,
|
||||
localResource: ResourceFile,
|
||||
raw: boolean
|
||||
localResource: ResourceFile
|
||||
): Promise<void> {
|
||||
remotePath = removeType(remotePath, "resource");
|
||||
if (raw) {
|
||||
try {
|
||||
resource = await ResourceService.getResource({
|
||||
workspace: workspace,
|
||||
path: remotePath.replaceAll("\\", "/"),
|
||||
});
|
||||
} catch {
|
||||
// flow doesn't exist
|
||||
}
|
||||
try {
|
||||
resource = await ResourceService.getResource({
|
||||
workspace: workspace,
|
||||
path: remotePath.replaceAll("\\", "/"),
|
||||
});
|
||||
} catch {
|
||||
// flow doesn't exist
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
if (isSuperset(localResource, resource)) {
|
||||
return;
|
||||
@@ -90,8 +88,7 @@ async function push(opts: PushOptions, filePath: string, remotePath: string) {
|
||||
workspace.workspaceId,
|
||||
remotePath,
|
||||
undefined,
|
||||
parseFromFile(filePath),
|
||||
true
|
||||
parseFromFile(filePath)
|
||||
);
|
||||
log.info(colors.bold.underline.green(`Resource ${remotePath} pushed`));
|
||||
}
|
||||
|
||||
+9
-13
@@ -44,22 +44,19 @@ export async function pushSchedule(
|
||||
workspace: string,
|
||||
path: string,
|
||||
schedule: Schedule | ScheduleFile | undefined,
|
||||
localSchedule: ScheduleFile,
|
||||
raw: boolean
|
||||
localSchedule: ScheduleFile
|
||||
): Promise<void> {
|
||||
path = removeType(path, "schedule");
|
||||
|
||||
log.debug(`Processing local schedule ${path}`);
|
||||
|
||||
if (raw) {
|
||||
// deleting old app if it exists in raw mode
|
||||
try {
|
||||
schedule = await ScheduleService.getSchedule({ workspace, path });
|
||||
log.debug(`Schedule ${path} exists on remote`);
|
||||
} catch {
|
||||
log.debug(`Schedule ${path} does not exist on remote`);
|
||||
//ignore
|
||||
}
|
||||
// deleting old app if it exists in raw mode
|
||||
try {
|
||||
schedule = await ScheduleService.getSchedule({ workspace, path });
|
||||
log.debug(`Schedule ${path} exists on remote`);
|
||||
} catch {
|
||||
log.debug(`Schedule ${path} does not exist on remote`);
|
||||
//ignore
|
||||
}
|
||||
|
||||
if (schedule) {
|
||||
@@ -116,8 +113,7 @@ async function push(opts: GlobalOptions, filePath: string, remotePath: string) {
|
||||
workspace.workspaceId,
|
||||
remotePath,
|
||||
undefined,
|
||||
parseFromFile(filePath),
|
||||
false
|
||||
parseFromFile(filePath)
|
||||
);
|
||||
console.log(colors.bold.underline.green("Schedule pushed"));
|
||||
}
|
||||
|
||||
@@ -732,7 +732,6 @@ async function push(
|
||||
oldObj,
|
||||
newObj,
|
||||
opts.plainSecrets ?? false,
|
||||
opts.raw,
|
||||
opts.message
|
||||
);
|
||||
|
||||
@@ -766,7 +765,6 @@ async function push(
|
||||
undefined,
|
||||
obj,
|
||||
opts.plainSecrets ?? false,
|
||||
opts.raw,
|
||||
opts.message
|
||||
);
|
||||
|
||||
|
||||
+6
-14
@@ -99,33 +99,25 @@ export async function pushObj(
|
||||
befObj: any,
|
||||
newObj: any,
|
||||
plainSecrets: boolean,
|
||||
checkForCreate: boolean,
|
||||
message?: string
|
||||
) {
|
||||
const typeEnding = getTypeStrFromPath(p);
|
||||
|
||||
if (typeEnding === "app") {
|
||||
await pushApp(workspace, p, befObj, newObj, checkForCreate, message);
|
||||
await pushApp(workspace, p, befObj, newObj, message);
|
||||
} else if (typeEnding === "folder") {
|
||||
await pushFolder(workspace, p, befObj, newObj, checkForCreate);
|
||||
await pushFolder(workspace, p, befObj, newObj);
|
||||
} else if (typeEnding === "variable") {
|
||||
await pushVariable(
|
||||
workspace,
|
||||
p,
|
||||
befObj,
|
||||
newObj,
|
||||
plainSecrets,
|
||||
checkForCreate
|
||||
);
|
||||
await pushVariable(workspace, p, befObj, newObj, plainSecrets);
|
||||
} else if (typeEnding === "flow") {
|
||||
const flowName = p.split(".flow/")[0];
|
||||
await pushFlow(workspace, flowName, flowName + ".flow", message);
|
||||
} else if (typeEnding === "resource") {
|
||||
await pushResource(workspace, p, befObj, newObj, checkForCreate);
|
||||
await pushResource(workspace, p, befObj, newObj);
|
||||
} else if (typeEnding === "resource-type") {
|
||||
await pushResourceType(workspace, p, befObj, newObj, checkForCreate);
|
||||
await pushResourceType(workspace, p, befObj, newObj);
|
||||
} else if (typeEnding === "schedule") {
|
||||
await pushSchedule(workspace, p, befObj, newObj, checkForCreate);
|
||||
await pushSchedule(workspace, p, befObj, newObj);
|
||||
} else {
|
||||
throw new Error("infer type unreachable");
|
||||
}
|
||||
|
||||
+11
-16
@@ -52,23 +52,20 @@ export async function pushVariable(
|
||||
remotePath: string,
|
||||
variable: VariableFile | ListableVariable | undefined,
|
||||
localVariable: VariableFile,
|
||||
plainSecrets: boolean,
|
||||
raw: boolean
|
||||
plainSecrets: boolean
|
||||
): Promise<void> {
|
||||
remotePath = removeType(remotePath, "variable");
|
||||
log.debug(`Processing local variable ${remotePath}`);
|
||||
|
||||
if (raw) {
|
||||
try {
|
||||
variable = await VariableService.getVariable({
|
||||
workspace: workspace,
|
||||
path: remotePath.replaceAll("\\", "/"),
|
||||
decryptSecret: plainSecrets,
|
||||
});
|
||||
log.debug(`Variable ${remotePath} exists on remote`);
|
||||
} catch {
|
||||
log.debug(`Variable ${remotePath} does not exist on remote`);
|
||||
}
|
||||
try {
|
||||
variable = await VariableService.getVariable({
|
||||
workspace: workspace,
|
||||
path: remotePath.replaceAll("\\", "/"),
|
||||
decryptSecret: plainSecrets,
|
||||
});
|
||||
log.debug(`Variable ${remotePath} exists on remote`);
|
||||
} catch {
|
||||
log.debug(`Variable ${remotePath} does not exist on remote`);
|
||||
}
|
||||
|
||||
if (variable) {
|
||||
@@ -125,8 +122,7 @@ async function push(
|
||||
remotePath,
|
||||
undefined,
|
||||
parseFromFile(filePath),
|
||||
opts.plainSecrets,
|
||||
true
|
||||
opts.plainSecrets
|
||||
);
|
||||
log.info(colors.bold.underline.green(`Variable ${remotePath} pushed`));
|
||||
}
|
||||
@@ -171,7 +167,6 @@ async function add(
|
||||
is_secret: !opts.public,
|
||||
description: "",
|
||||
},
|
||||
true,
|
||||
true
|
||||
);
|
||||
log.info(colors.bold.underline.green(`Variable ${remotePath} pushed`));
|
||||
|
||||
Reference in New Issue
Block a user