@patterkit/cli 0.11.4 → 0.12.0
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/dist/cli.js +41 -14
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -55,7 +55,10 @@ import {
|
|
|
55
55
|
listOpenSuggestions,
|
|
56
56
|
applySuggestionDecisions,
|
|
57
57
|
qualifierNamer,
|
|
58
|
-
scriptFontLicences
|
|
58
|
+
scriptFontLicences,
|
|
59
|
+
findProjectFile,
|
|
60
|
+
readProjectManifest,
|
|
61
|
+
detectMergeType
|
|
59
62
|
} from "@patterkit/ops";
|
|
60
63
|
import { createHash } from "crypto";
|
|
61
64
|
import { writeTextFiles, writeBinaryFile, currentUser } from "@wildwinter/simple-vc-lib";
|
|
@@ -63,7 +66,7 @@ import { writeTextFiles, writeBinaryFile, currentUser } from "@wildwinter/simple
|
|
|
63
66
|
// package.json
|
|
64
67
|
var package_default = {
|
|
65
68
|
name: "@patterkit/cli",
|
|
66
|
-
version: "0.
|
|
69
|
+
version: "0.12.0",
|
|
67
70
|
description: "The `patter` CLI: validate, format, export, play, test coverage, localise, and merge Patter projects.",
|
|
68
71
|
type: "module",
|
|
69
72
|
license: "MIT",
|
|
@@ -92,8 +95,8 @@ var package_default = {
|
|
|
92
95
|
"build:standalone:others": "node scripts/build-standalone.mjs --targets=linux-x64,linux-arm64,windows-x64"
|
|
93
96
|
},
|
|
94
97
|
dependencies: {
|
|
95
|
-
"@patterkit/core": "0.
|
|
96
|
-
"@patterkit/ops": "0.
|
|
98
|
+
"@patterkit/core": "0.9.0",
|
|
99
|
+
"@patterkit/ops": "0.20.0",
|
|
97
100
|
"@wildwinter/simple-vc-lib": "^0.5.2"
|
|
98
101
|
}
|
|
99
102
|
};
|
|
@@ -109,6 +112,22 @@ function libraryNotices() {
|
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
// src/main.ts
|
|
115
|
+
function mergeManifest(ours, path) {
|
|
116
|
+
let type;
|
|
117
|
+
try {
|
|
118
|
+
type = detectMergeType(ours);
|
|
119
|
+
} catch {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
if (type !== "extension" || typeof ours["extension"] !== "string") return void 0;
|
|
123
|
+
let projectFile;
|
|
124
|
+
try {
|
|
125
|
+
projectFile = findProjectFile(path);
|
|
126
|
+
} catch {
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
129
|
+
return readProjectManifest(dirname(projectFile), ours["extension"]);
|
|
130
|
+
}
|
|
112
131
|
var isPatterSource = (path) => SHARD_EXTENSIONS.some((ext) => path.endsWith(ext));
|
|
113
132
|
function writeMergeResult(result, out, realPath, announce) {
|
|
114
133
|
const write = (path, content) => {
|
|
@@ -193,8 +212,9 @@ Usage:
|
|
|
193
212
|
patter pack [path] -o file Pack a project (the .patter folder) into a portable .patterpack
|
|
194
213
|
patter unpack <file> -o dir Explode a .patterpack into source shards under dir
|
|
195
214
|
[--merge --base sent.patterpack] Merge a returned .patterpack into the project
|
|
196
|
-
patter merge BASE OURS THEIRS 3-way merge of Patter source by node id (flow/loc/authoring/project)
|
|
197
|
-
|
|
215
|
+
patter merge BASE OURS THEIRS 3-way merge of Patter source by node id (flow/loc/authoring/project),
|
|
216
|
+
and of extension data by its manifest (extension)
|
|
217
|
+
[-o out] [--type flow|loc|authoring|project|extension] [--json]
|
|
198
218
|
[--path realfile] (where the conflict sidecar belongs when -o is a VCS
|
|
199
219
|
temporary file: git's %P)
|
|
200
220
|
patter mergetool BASE THEIRS OURS OUT VCS merge-tool wrapper: Patter source -> structured merge,
|
|
@@ -251,7 +271,7 @@ var SHORT = {
|
|
|
251
271
|
"share-scopes": "share-scopes [path] [--at DIR]",
|
|
252
272
|
pack: "pack [path] -o FILE",
|
|
253
273
|
unpack: "unpack <file> -o DIR [--merge --base SENT.patterpack]",
|
|
254
|
-
merge: "merge BASE OURS THEIRS [-o out | --json] [--type flow|loc|authoring|project] [--path realfile]",
|
|
274
|
+
merge: "merge BASE OURS THEIRS [-o out | --json] [--type flow|loc|authoring|project|extension] [--path realfile]",
|
|
255
275
|
mergetool: "mergetool BASE THEIRS OURS OUT [--fallback cmd]"
|
|
256
276
|
};
|
|
257
277
|
var EXCLUSIVE = {
|
|
@@ -454,7 +474,7 @@ async function run(cmd, positionals, flags) {
|
|
|
454
474
|
}
|
|
455
475
|
case "validate": {
|
|
456
476
|
const loaded = loadProject(positionals[0] ?? ".");
|
|
457
|
-
const { structural, conditions, interpolation, hygiene, staleBundles, unresolvedMerges, orphans, reachability, gameScopes, localisation, ok } = runValidate(loaded);
|
|
477
|
+
const { structural, conditions, interpolation, hygiene, staleBundles, unresolvedMerges, orphans, reachability, gameScopes, localisation, extensions, ok } = runValidate(loaded);
|
|
458
478
|
const warn = (i) => i.severity === "warning" ? "warning: " : "";
|
|
459
479
|
for (const i of structural) console.error(` [${i.code}] ${i.severity === "warning" ? "warning: " : ""}${i.message}`);
|
|
460
480
|
for (const i of conditions) console.error(` [${i.field}] ${i.nodeId}: ${warn(i)}${i.message} (${i.src})`);
|
|
@@ -465,11 +485,12 @@ async function run(cmd, positionals, flags) {
|
|
|
465
485
|
for (const i of orphans) console.error(` [not-in-project] ${i.message}`);
|
|
466
486
|
for (const i of gameScopes) console.error(` [game-scopes] ${i.file}: ${warn(i)}${i.message}`);
|
|
467
487
|
for (const i of localisation) console.error(` [localisation] ${i.file}: ${warn(i)}${i.message}`);
|
|
488
|
+
for (const i of extensions) console.error(` [extension] ${i.file}: ${warn(i)}${i.message}`);
|
|
468
489
|
for (const i of reachability) console.error(` [unreachable] ${i.nodeId}: ${i.message} (${i.src})`);
|
|
469
490
|
const isError = (i) => i.severity === "error";
|
|
470
491
|
const structuralWarnings = structural.filter((i) => i.severity === "warning").length;
|
|
471
|
-
const warnings = reachability.length + structuralWarnings + [...conditions, ...interpolation, ...gameScopes, ...localisation].filter((i) => !isError(i)).length;
|
|
472
|
-
const count = structural.length - structuralWarnings + [...conditions, ...interpolation, ...gameScopes, ...localisation].filter(isError).length + hygiene.length + staleBundles.length + unresolvedMerges.length + orphans.length;
|
|
492
|
+
const warnings = reachability.length + structuralWarnings + [...conditions, ...interpolation, ...gameScopes, ...localisation, ...extensions].filter((i) => !isError(i)).length;
|
|
493
|
+
const count = structural.length - structuralWarnings + [...conditions, ...interpolation, ...gameScopes, ...localisation, ...extensions].filter(isError).length + hygiene.length + staleBundles.length + unresolvedMerges.length + orphans.length;
|
|
473
494
|
const advisory = warnings ? `, ${warnings} warning(s) above` : "";
|
|
474
495
|
if (ok) console.log(`ok - ${loaded.scenes.length} scene(s), no issues${advisory}`);
|
|
475
496
|
else console.error(`
|
|
@@ -481,12 +502,15 @@ ${count} issue(s)${advisory}`);
|
|
|
481
502
|
const check = flags.check === true;
|
|
482
503
|
const results = runFormat(positionals);
|
|
483
504
|
if (results.every((r) => r.skipped)) {
|
|
484
|
-
console.error("format: no Patter source among the files given (.patterflow, .patterloc, .patterx, .patterproj)");
|
|
505
|
+
console.error("format: no Patter source among the files given (.patterflow, .patterloc, .patterx, .patterproj, .patterextension)");
|
|
485
506
|
return 0;
|
|
486
507
|
}
|
|
487
508
|
const changed = results.filter((r) => r.changed);
|
|
488
509
|
if (!check && !commitWrites(changed.map((r) => r.write))) return 1;
|
|
489
|
-
for (const r of changed)
|
|
510
|
+
for (const r of changed) {
|
|
511
|
+
console.log(`${check ? "would format" : "formatted"}: ${r.file}`);
|
|
512
|
+
for (const n of r.notes ?? []) console.log(` ${check ? "would have " : ""}${n}`);
|
|
513
|
+
}
|
|
490
514
|
if (changed.length === 0) console.log("already canonical");
|
|
491
515
|
return check && changed.length > 0 ? 1 : 0;
|
|
492
516
|
}
|
|
@@ -774,6 +798,7 @@ ${count} issue(s)${advisory}`);
|
|
|
774
798
|
for (const name of res.other) console.error(`warning: not unpacked (not a project file): ${name}`);
|
|
775
799
|
if (res.gameScopes?.error) console.error(`warning: their World properties were not written to ${res.gameScopes.path}: ${res.gameScopes.error}`);
|
|
776
800
|
else if (res.gameScopes) console.log(`game scopes: ${res.gameScopes.path} (their World properties)`);
|
|
801
|
+
for (const rel of res.manifestsKept ?? []) console.error(`warning: kept this project's ${rel}; the returned pack has a different version of it`);
|
|
777
802
|
const changed = res.shards.filter((sh) => sh.changed).length;
|
|
778
803
|
console.log(`
|
|
779
804
|
${changed} of ${res.shards.length} shard(s) changed in ${flags.o}; ${res.conflicts} conflict(s), ${res.warnings} warning(s)`);
|
|
@@ -793,9 +818,10 @@ ${shards.length} shard(s)${scopes.length ? ` and ${scopes.length} game scopes fi
|
|
|
793
818
|
const src = parseThree(baseP, oursP, theirsP, "merge");
|
|
794
819
|
if (!src) return 2;
|
|
795
820
|
const typeFlag = typeof flags.type === "string" && flags.type !== "auto" ? flags.type : void 0;
|
|
821
|
+
const manifest = mergeManifest(src.ours, typeof flags.path === "string" ? flags.path : typeof flags.o === "string" && flags.o !== "-" ? flags.o : oursP);
|
|
796
822
|
let result;
|
|
797
823
|
try {
|
|
798
|
-
result = runMerge(src.base, src.ours, src.theirs, { type: typeFlag });
|
|
824
|
+
result = runMerge(src.base, src.ours, src.theirs, { type: typeFlag, ...manifest ? { manifest } : {} });
|
|
799
825
|
} catch (e) {
|
|
800
826
|
if (e instanceof UnsupportedMergeError) {
|
|
801
827
|
console.error(`merge: ${e.message}`);
|
|
@@ -826,7 +852,8 @@ ${shards.length} shard(s)${scopes.length ? ` and ${scopes.length} game scopes fi
|
|
|
826
852
|
const src = parseThree(baseP, oursP, theirsP, "mergetool");
|
|
827
853
|
if (!src) return 2;
|
|
828
854
|
try {
|
|
829
|
-
|
|
855
|
+
const manifest = mergeManifest(src.ours, outP);
|
|
856
|
+
return writeMergeResult(runMerge(src.base, src.ours, src.theirs, manifest ? { manifest } : void 0), outP, outP, false);
|
|
830
857
|
} catch (e) {
|
|
831
858
|
if (e instanceof UnsupportedMergeError) {
|
|
832
859
|
console.error(`mergetool: ${e.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patterkit/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "The `patter` CLI: validate, format, export, play, test coverage, localise, and merge Patter projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"build:standalone:others": "node scripts/build-standalone.mjs --targets=linux-x64,linux-arm64,windows-x64"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@patterkit/core": "0.
|
|
33
|
-
"@patterkit/ops": "0.
|
|
32
|
+
"@patterkit/core": "0.9.0",
|
|
33
|
+
"@patterkit/ops": "0.20.0",
|
|
34
34
|
"@wildwinter/simple-vc-lib": "^0.5.2"
|
|
35
35
|
}
|
|
36
36
|
}
|