windmill-cli 1.516.0 → 1.518.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/dev.js +2 -2
- package/esm/flow.js +2 -44
- package/esm/gen/core/OpenAPI.js +1 -1
- package/esm/main.js +6 -5
- package/esm/metadata.js +39 -226
- package/esm/sync.js +107 -126
- package/esm/windmill-utils-internal/src/gen/types.gen.js +2 -0
- package/esm/windmill-utils-internal/src/inline-scripts/extractor.js +79 -0
- package/esm/windmill-utils-internal/src/inline-scripts/replacer.js +92 -0
- package/esm/windmill-utils-internal/src/parse/parse-schema.js +202 -0
- package/esm/windmill-utils-internal/src/path-utils/path-assigner.js +55 -0
- package/package.json +1 -1
- package/types/dev.d.ts.map +1 -1
- package/types/flow.d.ts +0 -2
- package/types/flow.d.ts.map +1 -1
- package/types/main.d.ts +1 -1
- package/types/main.d.ts.map +1 -1
- package/types/metadata.d.ts +1 -44
- package/types/metadata.d.ts.map +1 -1
- package/types/sync.d.ts +4 -6
- package/types/sync.d.ts.map +1 -1
- package/types/windmill-utils-internal/src/gen/types.gen.d.ts +7320 -0
- package/types/windmill-utils-internal/src/gen/types.gen.d.ts.map +1 -0
- package/types/windmill-utils-internal/src/inline-scripts/extractor.d.ts +34 -0
- package/types/windmill-utils-internal/src/inline-scripts/extractor.d.ts.map +1 -0
- package/types/windmill-utils-internal/src/inline-scripts/replacer.d.ts +17 -0
- package/types/windmill-utils-internal/src/inline-scripts/replacer.d.ts.map +1 -0
- package/types/windmill-utils-internal/src/parse/parse-schema.d.ts +94 -0
- package/types/windmill-utils-internal/src/parse/parse-schema.d.ts.map +1 -0
- package/types/windmill-utils-internal/src/path-utils/path-assigner.d.ts +29 -0
- package/types/windmill-utils-internal/src/path-utils/path-assigner.d.ts.map +1 -0
package/esm/dev.js
CHANGED
|
@@ -7,7 +7,7 @@ import { resolveWorkspace } from "./context.js";
|
|
|
7
7
|
import { mergeConfigWithConfigFile, readConfigFile, } from "./conf.js";
|
|
8
8
|
import { exts, findGlobalDeps, removeExtensionToPath } from "./script.js";
|
|
9
9
|
import { inferContentTypeFromFilePath } from "./script_common.js";
|
|
10
|
-
import { replaceInlineScripts } from "./
|
|
10
|
+
import { replaceInlineScripts } from "./windmill-utils-internal/src/inline-scripts/replacer.js";
|
|
11
11
|
import { parseMetadataFile } from "./metadata.js";
|
|
12
12
|
const PORT = 3001;
|
|
13
13
|
async function dev(opts) {
|
|
@@ -48,7 +48,7 @@ async function dev(opts) {
|
|
|
48
48
|
if (typ == "flow") {
|
|
49
49
|
const localPath = cpath.split(DOT_FLOW_SEP)[0] + DOT_FLOW_SEP;
|
|
50
50
|
const localFlow = (await yamlParseFile(localPath + "flow.yaml"));
|
|
51
|
-
replaceInlineScripts(localFlow.value.modules, localPath, undefined);
|
|
51
|
+
await replaceInlineScripts(localFlow.value.modules, async (path) => await dntShim.Deno.readTextFile(localPath + path), log, localPath, SEP, undefined, (path, newPath) => dntShim.Deno.renameSync(path, newPath), (path) => dntShim.Deno.removeSync(path));
|
|
52
52
|
currentLastEdit = {
|
|
53
53
|
type: "flow",
|
|
54
54
|
flow: localFlow,
|
package/esm/flow.js
CHANGED
|
@@ -11,50 +11,8 @@ import { defaultFlowDefinition } from "./bootstrap/flow_bootstrap.js";
|
|
|
11
11
|
import { generateFlowLockInternal } from "./metadata.js";
|
|
12
12
|
import { mergeConfigWithConfigFile } from "./conf.js";
|
|
13
13
|
import { FSFSElement, elementsToMap, ignoreF } from "./sync.js";
|
|
14
|
-
import {
|
|
14
|
+
import { replaceInlineScripts } from "./windmill-utils-internal/src/inline-scripts/replacer.js";
|
|
15
15
|
const alreadySynced = [];
|
|
16
|
-
export function replaceInlineScripts(modules, localPath, removeLocks) {
|
|
17
|
-
modules.forEach((m, i) => {
|
|
18
|
-
if (!m.value) {
|
|
19
|
-
throw Error(`Module value is undefined for flow module ${i} in ${localPath}`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (m.value.type == "rawscript") {
|
|
23
|
-
if (m.value.content.startsWith("!inline")) {
|
|
24
|
-
const path = m.value.content.split(" ")[1];
|
|
25
|
-
m.value.content = dntShim.Deno.readTextFileSync(localPath + path);
|
|
26
|
-
const lock = m.value.lock;
|
|
27
|
-
if (removeLocks && removeLocks.includes(path)) {
|
|
28
|
-
m.value.lock = undefined;
|
|
29
|
-
}
|
|
30
|
-
else if (lock &&
|
|
31
|
-
typeof lock == "string" &&
|
|
32
|
-
lock.trimStart().startsWith("!inline ")) {
|
|
33
|
-
const path = lock.split(" ")[1];
|
|
34
|
-
try {
|
|
35
|
-
m.value.lock = readInlinePathSync(localPath + path);
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
log.error(`Lock file ${path} not found`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if (m.value.type == "forloopflow") {
|
|
44
|
-
replaceInlineScripts(m.value.modules, localPath, removeLocks);
|
|
45
|
-
}
|
|
46
|
-
else if (m.value.type == "whileloopflow") {
|
|
47
|
-
replaceInlineScripts(m.value.modules, localPath, removeLocks);
|
|
48
|
-
}
|
|
49
|
-
else if (m.value.type == "branchall") {
|
|
50
|
-
m.value.branches.forEach((b) => replaceInlineScripts(b.modules, localPath, removeLocks));
|
|
51
|
-
}
|
|
52
|
-
else if (m.value.type == "branchone") {
|
|
53
|
-
m.value.branches.forEach((b) => replaceInlineScripts(b.modules, localPath, removeLocks));
|
|
54
|
-
replaceInlineScripts(m.value.default, localPath, removeLocks);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
16
|
export async function pushFlow(workspace, remotePath, localPath, message) {
|
|
59
17
|
if (alreadySynced.includes(localPath)) {
|
|
60
18
|
return;
|
|
@@ -75,7 +33,7 @@ export async function pushFlow(workspace, remotePath, localPath, message) {
|
|
|
75
33
|
localPath += SEP;
|
|
76
34
|
}
|
|
77
35
|
const localFlow = (await yamlParseFile(localPath + "flow.yaml"));
|
|
78
|
-
replaceInlineScripts(localFlow.value.modules, localPath,
|
|
36
|
+
await replaceInlineScripts(localFlow.value.modules, async (path) => await dntShim.Deno.readTextFile(localPath + path), log, localPath, SEP);
|
|
79
37
|
if (flow) {
|
|
80
38
|
if (isSuperset(localFlow, flow)) {
|
|
81
39
|
log.info(colors.green(`Flow ${remotePath} is up to date`));
|
package/esm/gen/core/OpenAPI.js
CHANGED
package/esm/main.js
CHANGED
|
@@ -39,7 +39,7 @@ export { flow, app, script, workspace, resource, resourceType, user, variable, h
|
|
|
39
39
|
// console.error(JSON.stringify(event.error, null, 4));
|
|
40
40
|
// }
|
|
41
41
|
// });
|
|
42
|
-
export const VERSION = "1.
|
|
42
|
+
export const VERSION = "1.518.1";
|
|
43
43
|
const command = new Command()
|
|
44
44
|
.name("wmill")
|
|
45
45
|
.action(() => log.info(`Welcome to Windmill CLI ${VERSION}. Use -h for help.`))
|
|
@@ -162,7 +162,8 @@ const command = new Command()
|
|
|
162
162
|
}
|
|
163
163
|
catch (error) {
|
|
164
164
|
// If there's an error checking backend settings, just continue with defaults
|
|
165
|
-
|
|
165
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
166
|
+
log.warn(`Could not check backend for git-sync settings: ${errorMessage}`);
|
|
166
167
|
log.info("Continuing with default settings");
|
|
167
168
|
}
|
|
168
169
|
}
|
|
@@ -174,16 +175,16 @@ const command = new Command()
|
|
|
174
175
|
// Create .cursor/rules directory
|
|
175
176
|
await dntShim.Deno.mkdir(".cursor/rules", { recursive: true });
|
|
176
177
|
// Create windmill.mdc file
|
|
177
|
-
if (!await dntShim.Deno.stat(".cursor/rules/script.mdc").catch(() => null)) {
|
|
178
|
+
if (!(await dntShim.Deno.stat(".cursor/rules/script.mdc").catch(() => null))) {
|
|
178
179
|
await dntShim.Deno.writeTextFile(".cursor/rules/script.mdc", scriptGuidanceContent);
|
|
179
180
|
log.info(colors.green("Created .cursor/rules/script.mdc"));
|
|
180
181
|
}
|
|
181
|
-
if (!await dntShim.Deno.stat(".cursor/rules/flow.mdc").catch(() => null)) {
|
|
182
|
+
if (!(await dntShim.Deno.stat(".cursor/rules/flow.mdc").catch(() => null))) {
|
|
182
183
|
await dntShim.Deno.writeTextFile(".cursor/rules/flow.mdc", flowGuidanceContent);
|
|
183
184
|
log.info(colors.green("Created .cursor/rules/flow.mdc"));
|
|
184
185
|
}
|
|
185
186
|
// Create CLAUDE.md file
|
|
186
|
-
if (!await dntShim.Deno.stat("CLAUDE.md").catch(() => null)) {
|
|
187
|
+
if (!(await dntShim.Deno.stat("CLAUDE.md").catch(() => null))) {
|
|
187
188
|
await dntShim.Deno.writeTextFile("CLAUDE.md", `
|
|
188
189
|
# Claude
|
|
189
190
|
|
package/esm/metadata.js
CHANGED
|
@@ -5,9 +5,11 @@ import { defaultScriptMetadata, } from "./bootstrap/script_bootstrap.js";
|
|
|
5
5
|
import { languagesWithRawReqsSupport, } from "./script_common.js";
|
|
6
6
|
import { inferContentTypeFromFilePath } from "./script_common.js";
|
|
7
7
|
import { exts, findGlobalDeps } from "./script.js";
|
|
8
|
-
import { FSFSElement,
|
|
8
|
+
import { FSFSElement, findCodebase, newPathAssigner, yamlOptions } from "./sync.js";
|
|
9
9
|
import { generateHash, readInlinePathSync } from "./utils.js";
|
|
10
|
-
import { replaceInlineScripts } from "./
|
|
10
|
+
import { replaceInlineScripts } from "./windmill-utils-internal/src/inline-scripts/replacer.js";
|
|
11
|
+
import { extractInlineScripts as extractInlineScriptsForFlows } from "./windmill-utils-internal/src/inline-scripts/extractor.js";
|
|
12
|
+
import { argSigToJsonSchemaType } from "./windmill-utils-internal/src/parse/parse-schema.js";
|
|
11
13
|
import { getIsWin } from "./main.js";
|
|
12
14
|
export class LockfileGenerationError extends Error {
|
|
13
15
|
constructor(message) {
|
|
@@ -104,10 +106,10 @@ export async function generateFlowLockInternal(folder, dryRun, workspace, opts,
|
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
log.info(`Recomputing locks of ${changedScripts.join(", ")} in ${folder}`);
|
|
107
|
-
replaceInlineScripts(flowValue.value.modules, folder + SEP, changedScripts);
|
|
109
|
+
await replaceInlineScripts(flowValue.value.modules, async (path) => await dntShim.Deno.readTextFile(folder + SEP + path), log, folder + SEP, SEP, changedScripts, (path, newPath) => dntShim.Deno.renameSync(path, newPath), (path) => dntShim.Deno.removeSync(path));
|
|
108
110
|
//removeChangedLocks
|
|
109
111
|
flowValue.value = await updateFlow(workspace, flowValue.value, remote_path, rawReqs);
|
|
110
|
-
const inlineScripts = extractInlineScriptsForFlows(flowValue.value.modules, newPathAssigner(opts.defaultTs ?? "bun"));
|
|
112
|
+
const inlineScripts = extractInlineScriptsForFlows(flowValue.value.modules, {}, SEP, opts.defaultTs, newPathAssigner(opts.defaultTs ?? "bun"));
|
|
111
113
|
inlineScripts
|
|
112
114
|
.filter((s) => s.path.endsWith(".lock"))
|
|
113
115
|
.forEach((s) => {
|
|
@@ -478,216 +480,6 @@ function sortObject(obj) {
|
|
|
478
480
|
[key]: obj[key],
|
|
479
481
|
}), {});
|
|
480
482
|
}
|
|
481
|
-
//copied straight fron frontend /src/utils/inferArgs.ts
|
|
482
|
-
export function argSigToJsonSchemaType(t, oldS) {
|
|
483
|
-
const newS = { type: "" };
|
|
484
|
-
if (t === "int") {
|
|
485
|
-
newS.type = "integer";
|
|
486
|
-
}
|
|
487
|
-
else if (t === "float") {
|
|
488
|
-
newS.type = "number";
|
|
489
|
-
}
|
|
490
|
-
else if (t === "bool") {
|
|
491
|
-
newS.type = "boolean";
|
|
492
|
-
}
|
|
493
|
-
else if (t === "email") {
|
|
494
|
-
newS.type = "string";
|
|
495
|
-
newS.format = "email";
|
|
496
|
-
}
|
|
497
|
-
else if (t === "sql") {
|
|
498
|
-
newS.type = "string";
|
|
499
|
-
newS.format = "sql";
|
|
500
|
-
}
|
|
501
|
-
else if (t === "yaml") {
|
|
502
|
-
newS.type = "string";
|
|
503
|
-
newS.format = "yaml";
|
|
504
|
-
}
|
|
505
|
-
else if (t === "bytes") {
|
|
506
|
-
newS.type = "string";
|
|
507
|
-
newS.contentEncoding = "base64";
|
|
508
|
-
newS.originalType = "bytes";
|
|
509
|
-
}
|
|
510
|
-
else if (t === "datetime") {
|
|
511
|
-
newS.type = "string";
|
|
512
|
-
newS.format = "date-time";
|
|
513
|
-
}
|
|
514
|
-
else if (typeof t !== "string" && "oneof" in t) {
|
|
515
|
-
newS.type = "object";
|
|
516
|
-
if (t.oneof) {
|
|
517
|
-
newS.oneOf = t.oneof.map((obj) => {
|
|
518
|
-
const oldObjS = oldS.oneOf?.find((o) => o?.title === obj.label) ?? undefined;
|
|
519
|
-
const properties = {};
|
|
520
|
-
for (const prop of obj.properties) {
|
|
521
|
-
if (oldObjS?.properties && prop.key in oldObjS?.properties) {
|
|
522
|
-
properties[prop.key] = oldObjS?.properties[prop.key];
|
|
523
|
-
}
|
|
524
|
-
else {
|
|
525
|
-
properties[prop.key] = { description: "", type: "" };
|
|
526
|
-
}
|
|
527
|
-
argSigToJsonSchemaType(prop.typ, properties[prop.key]);
|
|
528
|
-
}
|
|
529
|
-
return {
|
|
530
|
-
type: "object",
|
|
531
|
-
title: obj.label,
|
|
532
|
-
properties,
|
|
533
|
-
order: oldObjS?.order ?? undefined,
|
|
534
|
-
};
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
else if (typeof t !== "string" && `object` in t) {
|
|
539
|
-
newS.type = "object";
|
|
540
|
-
if (t.object.name) {
|
|
541
|
-
newS.format = `resource-${t.object.name}`;
|
|
542
|
-
}
|
|
543
|
-
if (t.object.props) {
|
|
544
|
-
const properties = {};
|
|
545
|
-
for (const prop of t.object.props) {
|
|
546
|
-
if (oldS.properties && prop.key in oldS.properties) {
|
|
547
|
-
properties[prop.key] = oldS.properties[prop.key];
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
properties[prop.key] = { description: "", type: "" };
|
|
551
|
-
}
|
|
552
|
-
argSigToJsonSchemaType(prop.typ, properties[prop.key]);
|
|
553
|
-
}
|
|
554
|
-
newS.properties = properties;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
else if (typeof t !== "string" && `str` in t) {
|
|
558
|
-
newS.type = "string";
|
|
559
|
-
if (t.str) {
|
|
560
|
-
newS.originalType = "enum";
|
|
561
|
-
newS.enum = t.str;
|
|
562
|
-
}
|
|
563
|
-
else if (oldS.originalType == "string" && oldS.enum) {
|
|
564
|
-
newS.originalType = "string";
|
|
565
|
-
newS.enum = oldS.enum;
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
newS.originalType = "string";
|
|
569
|
-
newS.enum = undefined;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
else if (typeof t !== "string" && `resource` in t) {
|
|
573
|
-
newS.type = "object";
|
|
574
|
-
newS.format = `resource-${t.resource}`;
|
|
575
|
-
}
|
|
576
|
-
else if (typeof t !== "string" && `dynselect` in t) {
|
|
577
|
-
newS.type = "object";
|
|
578
|
-
newS.format = `dynselect-${t.dynselect}`;
|
|
579
|
-
}
|
|
580
|
-
else if (typeof t !== "string" && `list` in t) {
|
|
581
|
-
newS.type = "array";
|
|
582
|
-
if (t.list === "int" || t.list === "float") {
|
|
583
|
-
newS.items = { type: "number" };
|
|
584
|
-
newS.originalType = "number[]";
|
|
585
|
-
}
|
|
586
|
-
else if (t.list === "bytes") {
|
|
587
|
-
newS.items = { type: "string", contentEncoding: "base64" };
|
|
588
|
-
newS.originalType = "bytes[]";
|
|
589
|
-
}
|
|
590
|
-
else if (t.list &&
|
|
591
|
-
typeof t.list == "object" &&
|
|
592
|
-
"str" in t.list &&
|
|
593
|
-
t.list.str) {
|
|
594
|
-
newS.items = { type: "string", enum: t.list.str };
|
|
595
|
-
newS.originalType = "enum[]";
|
|
596
|
-
}
|
|
597
|
-
else if (t.list == "string" ||
|
|
598
|
-
(t.list && typeof t.list == "object" && "str" in t.list)) {
|
|
599
|
-
newS.items = { type: "string", enum: oldS.items?.enum };
|
|
600
|
-
newS.originalType = "string[]";
|
|
601
|
-
}
|
|
602
|
-
else if (t.list &&
|
|
603
|
-
typeof t.list == "object" &&
|
|
604
|
-
"resource" in t.list &&
|
|
605
|
-
t.list.resource) {
|
|
606
|
-
newS.items = {
|
|
607
|
-
type: "resource",
|
|
608
|
-
resourceType: t.list.resource,
|
|
609
|
-
};
|
|
610
|
-
newS.originalType = "resource[]";
|
|
611
|
-
}
|
|
612
|
-
else if (t.list &&
|
|
613
|
-
typeof t.list == "object" &&
|
|
614
|
-
"object" in t.list &&
|
|
615
|
-
t.list.object) {
|
|
616
|
-
if (t.list.object.name) {
|
|
617
|
-
newS.format = `resource-${t.list.object.name}`;
|
|
618
|
-
}
|
|
619
|
-
if (t.list.object.props && t.list.object.props.length > 0) {
|
|
620
|
-
const properties = {};
|
|
621
|
-
for (const prop of t.list.object.props) {
|
|
622
|
-
properties[prop.key] = { description: "", type: "" };
|
|
623
|
-
argSigToJsonSchemaType(prop.typ, properties[prop.key]);
|
|
624
|
-
}
|
|
625
|
-
newS.items = { type: "object", properties: properties };
|
|
626
|
-
}
|
|
627
|
-
else {
|
|
628
|
-
newS.items = { type: "object" };
|
|
629
|
-
}
|
|
630
|
-
newS.originalType = "record[]";
|
|
631
|
-
}
|
|
632
|
-
else {
|
|
633
|
-
newS.items = { type: "object" };
|
|
634
|
-
newS.originalType = "object[]";
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
else {
|
|
638
|
-
newS.type = "object";
|
|
639
|
-
}
|
|
640
|
-
const preservedFields = [
|
|
641
|
-
"description",
|
|
642
|
-
"pattern",
|
|
643
|
-
"min",
|
|
644
|
-
"max",
|
|
645
|
-
"currency",
|
|
646
|
-
"currencyLocale",
|
|
647
|
-
"multiselect",
|
|
648
|
-
"customErrorMessage",
|
|
649
|
-
"required",
|
|
650
|
-
"showExpr",
|
|
651
|
-
"password",
|
|
652
|
-
"order",
|
|
653
|
-
"dateFormat",
|
|
654
|
-
"title",
|
|
655
|
-
"placeholder",
|
|
656
|
-
];
|
|
657
|
-
preservedFields.forEach((field) => {
|
|
658
|
-
// @ts-ignore
|
|
659
|
-
if (oldS[field] !== undefined) {
|
|
660
|
-
// @ts-ignore
|
|
661
|
-
newS[field] = oldS[field];
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
if (oldS.type != newS.type) {
|
|
665
|
-
for (const prop of Object.getOwnPropertyNames(newS)) {
|
|
666
|
-
if (prop != "description") {
|
|
667
|
-
// @ts-ignore
|
|
668
|
-
delete oldS[prop];
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
else if ((oldS.format == "date" || oldS.format === "date-time") &&
|
|
673
|
-
newS.format == "string") {
|
|
674
|
-
newS.format = oldS.format;
|
|
675
|
-
}
|
|
676
|
-
else if (newS.format == "date-time" && oldS.format == "date") {
|
|
677
|
-
newS.format = "date";
|
|
678
|
-
}
|
|
679
|
-
else if (oldS.items?.type != newS.items?.type) {
|
|
680
|
-
delete oldS.items;
|
|
681
|
-
}
|
|
682
|
-
if (oldS.format && !newS.format) {
|
|
683
|
-
oldS.format = undefined;
|
|
684
|
-
}
|
|
685
|
-
Object.assign(oldS, newS);
|
|
686
|
-
// if (sameItems && savedItems != undefined && savedItems.enum != undefined) {
|
|
687
|
-
// sendUserToast(JSON.stringify(savedItems))
|
|
688
|
-
// oldS.items = savedItems
|
|
689
|
-
// }
|
|
690
|
-
}
|
|
691
483
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
692
484
|
// end of refactoring TODO //
|
|
693
485
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -770,12 +562,20 @@ export async function readLockfile() {
|
|
|
770
562
|
}
|
|
771
563
|
}
|
|
772
564
|
catch {
|
|
773
|
-
const lock = { locks: {} };
|
|
565
|
+
const lock = { locks: {}, version: "v2" };
|
|
774
566
|
await dntShim.Deno.writeTextFile(WMILL_LOCKFILE, yamlStringify(lock, yamlOptions));
|
|
775
567
|
log.info(colors.green("wmill-lock.yaml created"));
|
|
776
568
|
return lock;
|
|
777
569
|
}
|
|
778
570
|
}
|
|
571
|
+
function v2LockPath(path, subpath) {
|
|
572
|
+
if (subpath) {
|
|
573
|
+
return `${path}+${subpath}`;
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
return path;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
779
579
|
export async function checkifMetadataUptodate(path, hash, conf, subpath) {
|
|
780
580
|
if (!conf) {
|
|
781
581
|
conf = await readLockfile();
|
|
@@ -783,9 +583,16 @@ export async function checkifMetadataUptodate(path, hash, conf, subpath) {
|
|
|
783
583
|
if (!conf.locks) {
|
|
784
584
|
return false;
|
|
785
585
|
}
|
|
786
|
-
const
|
|
787
|
-
|
|
788
|
-
|
|
586
|
+
const isV2 = conf?.version == "v2";
|
|
587
|
+
if (isV2) {
|
|
588
|
+
const current = conf.locks?.[v2LockPath(path, subpath)];
|
|
589
|
+
return current == hash;
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
const obj = conf.locks?.[path];
|
|
593
|
+
const current = subpath && typeof obj == "object" ? obj?.[subpath] : obj;
|
|
594
|
+
return current == hash;
|
|
595
|
+
}
|
|
789
596
|
}
|
|
790
597
|
export async function generateScriptHash(rawReqs, scriptContent, newMetadataContent) {
|
|
791
598
|
return await generateHash((rawReqs ?? "") + scriptContent + newMetadataContent);
|
|
@@ -795,16 +602,22 @@ export async function updateMetadataGlobalLock(path, hash, subpath) {
|
|
|
795
602
|
if (!conf?.locks) {
|
|
796
603
|
conf.locks = {};
|
|
797
604
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
prev = {};
|
|
802
|
-
conf.locks[path] = prev;
|
|
803
|
-
}
|
|
804
|
-
prev[subpath] = hash;
|
|
605
|
+
const isV2 = conf?.version == "v2";
|
|
606
|
+
if (isV2) {
|
|
607
|
+
conf.locks[v2LockPath(path, hash)] = hash;
|
|
805
608
|
}
|
|
806
609
|
else {
|
|
807
|
-
|
|
610
|
+
if (subpath) {
|
|
611
|
+
let prev = conf.locks[path];
|
|
612
|
+
if (!prev || typeof prev != "object") {
|
|
613
|
+
prev = {};
|
|
614
|
+
conf.locks[path] = prev;
|
|
615
|
+
}
|
|
616
|
+
prev[subpath] = hash;
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
conf.locks[path] = hash;
|
|
620
|
+
}
|
|
808
621
|
}
|
|
809
622
|
await dntShim.Deno.writeTextFile(WMILL_LOCKFILE, yamlStringify(conf, yamlOptions));
|
|
810
623
|
}
|