@zokugun/artifact 0.5.1 → 0.6.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/bin/artifact +1 -1
- package/lib/cli.d.ts +1 -0
- package/lib/cli.js +12 -4
- package/lib/commands/add.d.ts +6 -0
- package/lib/commands/add.js +47 -36
- package/lib/commands/index.d.ts +4 -0
- package/lib/commands/index.js +9 -7
- package/lib/commands/list.d.ts +1 -0
- package/lib/commands/list.js +13 -8
- package/lib/commands/remove.d.ts +6 -0
- package/lib/commands/remove.js +79 -0
- package/lib/commands/update.d.ts +5 -0
- package/lib/commands/update.js +43 -39
- package/lib/compositors/compose.d.ts +7 -0
- package/lib/compositors/compose.js +13 -13
- package/lib/compositors/fork.d.ts +3 -0
- package/lib/compositors/fork.js +4 -4
- package/lib/compositors/index.d.ts +6 -0
- package/lib/compositors/index.js +12 -12
- package/lib/compositors/json.d.ts +2 -0
- package/lib/compositors/json.js +14 -12
- package/lib/compositors/map-sort.d.ts +2 -0
- package/lib/compositors/map-sort.js +2 -2
- package/lib/compositors/rc.d.ts +2 -0
- package/lib/compositors/rc.js +13 -10
- package/lib/compositors/yaml.d.ts +2 -0
- package/lib/compositors/yaml.js +8 -11
- package/lib/configs/index.d.ts +3 -0
- package/lib/configs/index.js +3 -2
- package/lib/configs/install/index.d.ts +3 -0
- package/lib/configs/install/index.js +6 -6
- package/lib/configs/install/read-install-config.d.ts +6 -0
- package/lib/configs/install/read-install-config.js +123 -80
- package/lib/configs/install/update-install-config.d.ts +2 -0
- package/lib/configs/install/write-install-config.d.ts +5 -0
- package/lib/configs/install/write-install-config.js +17 -9
- package/lib/configs/package/index.d.ts +1 -0
- package/lib/configs/package/index.js +2 -2
- package/lib/configs/package/read-package-config.d.ts +3 -0
- package/lib/configs/package/read-package-config.js +159 -40
- package/lib/configs/uninstall/index.d.ts +1 -0
- package/lib/configs/uninstall/index.js +5 -0
- package/lib/configs/uninstall/update-uninstall-config.d.ts +2 -0
- package/lib/configs/uninstall/update-uninstall-config.js +6 -0
- package/lib/configs/utils/constants.d.ts +11 -0
- package/lib/configs/utils/constants.js +24 -0
- package/lib/configs/utils/is-transform.d.ts +2 -0
- package/lib/configs/utils/is-transform.js +16 -0
- package/lib/configs/utils/merge-upsert-property.d.ts +3 -0
- package/lib/configs/utils/merge-upsert-property.js +68 -0
- package/lib/configs/utils/normalize-file-always.d.ts +3 -0
- package/lib/configs/utils/normalize-file-always.js +28 -0
- package/lib/configs/utils/normalize-file-uninstall.d.ts +3 -0
- package/lib/configs/utils/normalize-file-uninstall.js +31 -0
- package/lib/configs/utils/normalize-file-upsert.d.ts +3 -0
- package/lib/configs/utils/normalize-file-upsert.js +54 -0
- package/lib/journeys/commitlint/index.d.ts +2 -0
- package/lib/journeys/commitlint/index.js +15 -15
- package/lib/journeys/config.ts/index.d.ts +2 -0
- package/lib/journeys/config.ts/index.js +5 -5
- package/lib/journeys/default/index.d.ts +2 -0
- package/lib/journeys/default/index.js +11 -14
- package/lib/journeys/fixpack/index.d.ts +2 -0
- package/lib/journeys/fixpack/index.js +13 -13
- package/lib/journeys/gitignore/index.d.ts +2 -0
- package/lib/journeys/gitignore/index.js +5 -5
- package/lib/journeys/ignore/index.d.ts +2 -0
- package/lib/journeys/ignore/index.js +5 -5
- package/lib/journeys/index.d.ts +2 -0
- package/lib/journeys/index.js +20 -20
- package/lib/journeys/npmignore/index.d.ts +2 -0
- package/lib/journeys/npmignore/index.js +5 -5
- package/lib/journeys/package/index.d.ts +2 -0
- package/lib/journeys/package/index.js +27 -30
- package/lib/journeys/rc/index.d.ts +2 -0
- package/lib/journeys/rc/index.js +12 -12
- package/lib/journeys/tsconfig/index.d.ts +2 -0
- package/lib/journeys/tsconfig/index.js +13 -16
- package/lib/parsers/json.d.ts +2 -0
- package/lib/parsers/jsonc/index.d.ts +2 -0
- package/lib/parsers/jsonc/index.js +4 -4
- package/lib/parsers/jsonc/parse.d.ts +5 -0
- package/lib/parsers/jsonc/parse.js +1 -13
- package/lib/parsers/jsonc/stringify.d.ts +2 -0
- package/lib/parsers/jsonc/stringify.js +2 -2
- package/lib/parsers/jsonc/transform.d.ts +10 -0
- package/lib/parsers/yaml.d.ts +2 -0
- package/lib/routes/command.d.ts +4 -0
- package/lib/routes/command.js +10 -10
- package/lib/routes/index.d.ts +8 -0
- package/lib/routes/index.js +17 -15
- package/lib/routes/lines-concat.d.ts +4 -0
- package/lib/routes/lines-concat.js +7 -7
- package/lib/routes/list-concat.d.ts +4 -0
- package/lib/routes/list-concat.js +3 -7
- package/lib/routes/list-sort-concat.d.ts +4 -0
- package/lib/routes/list-sort-concat.js +1 -1
- package/lib/routes/map-concat.d.ts +4 -0
- package/lib/routes/map-concat.js +1 -1
- package/lib/routes/map-delete.d.ts +4 -0
- package/lib/routes/map-delete.js +32 -0
- package/lib/routes/overwrite.d.ts +4 -0
- package/lib/routes/overwrite.js +2 -2
- package/lib/routes/primitive.d.ts +4 -0
- package/lib/routes/primitive.js +3 -3
- package/lib/steps/apply-formatting.d.ts +8 -0
- package/lib/steps/apply-formatting.js +19 -15
- package/lib/steps/configure-branches.d.ts +3 -0
- package/lib/steps/configure-branches.js +8 -5
- package/lib/steps/configure-install-file-actions.d.ts +3 -0
- package/lib/steps/configure-install-file-actions.js +41 -86
- package/lib/steps/configure-uninstall-file-actions.d.ts +3 -0
- package/lib/steps/configure-uninstall-file-actions.js +53 -0
- package/lib/steps/configure-update-file-actions.d.ts +3 -0
- package/lib/steps/configure-update-file-actions.js +64 -97
- package/lib/steps/copy-binary-files.d.ts +3 -0
- package/lib/steps/copy-binary-files.js +24 -11
- package/lib/steps/execute-first-block.d.ts +3 -0
- package/lib/steps/execute-first-block.js +35 -14
- package/lib/steps/execute-next-block.d.ts +3 -0
- package/lib/steps/execute-next-block.js +8 -3
- package/lib/steps/index.d.ts +54 -0
- package/lib/steps/index.js +76 -54
- package/lib/steps/insert-final-new-line.d.ts +6 -0
- package/lib/steps/insert-final-new-line.js +13 -1
- package/lib/steps/merge-text-files.d.ts +3 -0
- package/lib/steps/merge-text-files.js +41 -27
- package/lib/steps/read-editor-config.d.ts +3 -0
- package/lib/steps/read-editor-config.js +21 -26
- package/lib/steps/read-files.d.ts +3 -0
- package/lib/steps/read-files.js +19 -8
- package/lib/steps/read-incoming-config.d.ts +3 -0
- package/lib/steps/read-incoming-config.js +7 -5
- package/lib/steps/read-incoming-package.d.ts +3 -0
- package/lib/steps/read-incoming-package.js +12 -7
- package/lib/steps/remove-files.d.ts +3 -0
- package/lib/steps/remove-files.js +10 -4
- package/lib/steps/rename-files.d.ts +3 -0
- package/lib/steps/rename-files.js +25 -0
- package/lib/steps/replace-templates.d.ts +3 -0
- package/lib/steps/replace-templates.js +19 -5
- package/lib/steps/transform-untouched-files.d.ts +3 -0
- package/lib/steps/transform-untouched-files.js +73 -0
- package/lib/steps/unmerge-text-files.d.ts +3 -0
- package/lib/steps/unmerge-text-files.js +63 -0
- package/lib/steps/validate-newer-package.d.ts +3 -0
- package/lib/steps/validate-newer-package.js +4 -2
- package/lib/steps/validate-not-present-package.d.ts +3 -0
- package/lib/steps/validate-not-present-package.js +7 -4
- package/lib/steps/validate-present-package.d.ts +3 -0
- package/lib/steps/validate-present-package.js +24 -0
- package/lib/steps/write-text-files.d.ts +3 -0
- package/lib/steps/write-text-files.js +16 -7
- package/lib/types/binary-file.d.ts +4 -0
- package/lib/types/command.d.ts +5 -0
- package/lib/types/config.d.ts +58 -0
- package/lib/types/context.d.ts +56 -0
- package/lib/types/format.d.ts +10 -0
- package/lib/types/step.d.ts +3 -0
- package/lib/types/text-file.d.ts +7 -0
- package/lib/types/travel.d.ts +14 -0
- package/lib/utils/apply-transforms.d.ts +2 -0
- package/lib/utils/apply-transforms.js +48 -0
- package/lib/utils/build-journey-plan.d.ts +2 -0
- package/lib/utils/build-route.d.ts +3 -0
- package/lib/utils/build-route.js +92 -0
- package/lib/utils/build-travel-plan.d.ts +2 -0
- package/lib/utils/build-travel.d.ts +3 -0
- package/lib/utils/build-travel.js +32 -0
- package/lib/utils/command/dedupe-strings.d.ts +1 -0
- package/lib/utils/command/index.d.ts +8 -0
- package/lib/utils/command/index.js +14 -14
- package/lib/utils/command/join-command.d.ts +2 -0
- package/lib/utils/command/merge-and-chains.d.ts +1 -0
- package/lib/utils/command/merge-and-chains.js +34 -25
- package/lib/utils/command/merge-command-records.d.ts +2 -0
- package/lib/utils/command/merge-command-records.js +43 -22
- package/lib/utils/command/merge-flag-tokens.d.ts +1 -0
- package/lib/utils/command/merge-flag-tokens.js +1 -1
- package/lib/utils/command/merge-flags-as-string.d.ts +4 -0
- package/lib/utils/command/merge-flags-as-string.js +4 -4
- package/lib/utils/command/merge-or-segments.d.ts +1 -0
- package/lib/utils/command/merge-or-segments.js +28 -28
- package/lib/utils/command/merge-parts-by-prefix.d.ts +1 -0
- package/lib/utils/command/merge-parts-by-prefix.js +6 -6
- package/lib/utils/command/merge-semicolon-segments.d.ts +1 -0
- package/lib/utils/command/merge-semicolon-segments.js +35 -35
- package/lib/utils/command/merge-with-semicolon-mix.d.ts +1 -0
- package/lib/utils/command/merge-with-semicolon-mix.js +12 -12
- package/lib/utils/command/prefix-of-command.d.ts +1 -0
- package/lib/utils/command/prefix-of-command.js +2 -2
- package/lib/utils/command/split-chain.d.ts +1 -0
- package/lib/utils/command/split-command.d.ts +2 -0
- package/lib/utils/command/split-command.js +8 -8
- package/lib/utils/command/split-prefix-and-flags.d.ts +4 -0
- package/lib/utils/command/split-prefix-and-flags.js +5 -5
- package/lib/utils/command/split-segments.d.ts +1 -0
- package/lib/utils/detect-indent.d.ts +5 -0
- package/lib/utils/detect-indent.js +60 -0
- package/lib/utils/flow.d.ts +3 -0
- package/lib/utils/flow.js +12 -0
- package/lib/utils/get-format.d.ts +2 -0
- package/lib/utils/get-format.js +19 -0
- package/lib/utils/has-final-new-line.d.ts +1 -0
- package/lib/utils/has-final-new-line.js +7 -0
- package/lib/utils/read-buffer.d.ts +2 -0
- package/lib/utils/resolve-request.d.ts +3 -0
- package/lib/utils/resolve-request.js +4 -3
- package/lib/utils/template.d.ts +17 -0
- package/lib/utils/template.js +79 -57
- package/lib/utils/to-lines.d.ts +1 -0
- package/lib/utils/trim-final-newline.d.ts +1 -0
- package/lib/utils/try-json.d.ts +1 -0
- package/lib/utils/try-json.js +2 -2
- package/package.json +123 -101
- package/lib/utils/dev-null.js +0 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeFlagTokens = mergeFlagTokens;
|
|
4
4
|
function mergeFlagTokens(currentFlags, incomingFlags) {
|
|
5
|
-
const mergedFlags = currentFlags
|
|
5
|
+
const mergedFlags = [...currentFlags];
|
|
6
6
|
for (const flag of incomingFlags) {
|
|
7
7
|
const name = flag.split(/\s+/)[0];
|
|
8
8
|
const exists = mergedFlags.some((existing) => existing.split(/\s+/)[0] === name);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeFlagsAsString = mergeFlagsAsString;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const merge_flag_tokens_js_1 = require("./merge-flag-tokens.js");
|
|
5
|
+
const split_prefix_and_flags_js_1 = require("./split-prefix-and-flags.js");
|
|
6
6
|
function mergeFlagsAsString(current, incoming) {
|
|
7
|
-
const currentPrefix = (0,
|
|
8
|
-
const mergedFlags = (0,
|
|
7
|
+
const currentPrefix = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(current);
|
|
8
|
+
const mergedFlags = (0, merge_flag_tokens_js_1.mergeFlagTokens)(currentPrefix.flags, incoming.flags);
|
|
9
9
|
return currentPrefix.prefix + (mergedFlags.length > 0 ? ' ' + mergedFlags.join(' ') : '');
|
|
10
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeOrSegments(current: string, incoming: string): string;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeOrSegments = mergeOrSegments;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
const dedupe_strings_js_1 = require("./dedupe-strings.js");
|
|
5
|
+
const merge_flags_as_string_js_1 = require("./merge-flags-as-string.js");
|
|
6
|
+
const merge_semicolon_segments_js_1 = require("./merge-semicolon-segments.js");
|
|
7
|
+
const prefix_of_command_js_1 = require("./prefix-of-command.js");
|
|
8
|
+
const split_chain_js_1 = require("./split-chain.js");
|
|
9
|
+
const split_prefix_and_flags_js_1 = require("./split-prefix-and-flags.js");
|
|
10
|
+
const split_segments_js_1 = require("./split-segments.js");
|
|
11
11
|
function mergeOrSegments(current, incoming) {
|
|
12
|
-
const currentSegments = (0,
|
|
13
|
-
const incomingSegments = (0,
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
return (0,
|
|
12
|
+
const currentSegments = (0, split_segments_js_1.splitSegments)(current);
|
|
13
|
+
const incomingSegments = (0, split_segments_js_1.splitSegments)(incoming);
|
|
14
|
+
const currentOrIndex = currentSegments.findIndex((s) => s.includes('||'));
|
|
15
|
+
const incomingOrIndex = incomingSegments.findIndex((s) => s.includes('||'));
|
|
16
|
+
if (currentOrIndex === -1 || incomingOrIndex === -1) {
|
|
17
|
+
return (0, merge_semicolon_segments_js_1.mergeSemicolonSegments)(current, incoming);
|
|
18
18
|
}
|
|
19
|
-
const currentParts = (0,
|
|
20
|
-
const incomingParts = (0,
|
|
21
|
-
const currentTail = currentSegments.filter((_,
|
|
22
|
-
const incomingTail = incomingSegments.filter((_,
|
|
19
|
+
const currentParts = (0, split_chain_js_1.splitChain)(currentSegments[currentOrIndex], '||');
|
|
20
|
+
const incomingParts = (0, split_chain_js_1.splitChain)(incomingSegments[incomingOrIndex], '||');
|
|
21
|
+
const currentTail = currentSegments.filter((_, index) => index !== currentOrIndex);
|
|
22
|
+
const incomingTail = incomingSegments.filter((_, index) => index !== incomingOrIndex);
|
|
23
23
|
const maxLength = Math.max(currentParts.length, incomingParts.length);
|
|
24
24
|
const chainResult = [];
|
|
25
25
|
const movedToTail = [];
|
|
@@ -27,14 +27,14 @@ function mergeOrSegments(current, incoming) {
|
|
|
27
27
|
const currentPart = currentParts[i];
|
|
28
28
|
const incomingPart = incomingParts[i];
|
|
29
29
|
if (currentPart && incomingPart) {
|
|
30
|
-
const cPref = (0,
|
|
31
|
-
const nPref = (0,
|
|
30
|
+
const cPref = (0, prefix_of_command_js_1.prefixOfCommand)(currentPart);
|
|
31
|
+
const nPref = (0, prefix_of_command_js_1.prefixOfCommand)(incomingPart);
|
|
32
32
|
if (cPref && nPref && cPref === nPref) {
|
|
33
33
|
if (incomingTail.length > 0) {
|
|
34
|
-
chainResult.push((0,
|
|
34
|
+
chainResult.push((0, merge_flags_as_string_js_1.mergeFlagsAsString)(incomingPart, (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(currentPart)));
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
chainResult.push((0,
|
|
37
|
+
chainResult.push((0, merge_flags_as_string_js_1.mergeFlagsAsString)(currentPart, (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(incomingPart)));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
else if (incomingTail.some((t) => t === currentPart || t.startsWith(`${currentPart} `))) {
|
|
@@ -64,22 +64,22 @@ function mergeOrSegments(current, incoming) {
|
|
|
64
64
|
}
|
|
65
65
|
const chainParts = new Set(dedupedChain);
|
|
66
66
|
const rawTail = [...currentTail, ...movedToTail, ...incomingTail];
|
|
67
|
-
const filteredTail = rawTail.filter((tail,
|
|
67
|
+
const filteredTail = rawTail.filter((tail, index) => {
|
|
68
68
|
if (chainParts.has(tail)) {
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
// Keep only the most specific tail when two tails share a prefix.
|
|
72
|
-
return !rawTail.some((other,
|
|
72
|
+
return !rawTail.some((other, otherIndex) => otherIndex !== index && other.startsWith(`${tail} `));
|
|
73
73
|
});
|
|
74
74
|
const mergedChain = dedupedChain.join(' || ');
|
|
75
|
-
const chainPrefixes = new Set(dedupedChain.map(
|
|
75
|
+
const chainPrefixes = new Set(dedupedChain.map(prefix_of_command_js_1.prefixOfCommand).filter(Boolean));
|
|
76
76
|
const mergedSegs = currentSegments
|
|
77
|
-
.map((seg,
|
|
78
|
-
.filter((seg,
|
|
79
|
-
for (const tail of (0,
|
|
77
|
+
.map((seg, index) => (index === currentOrIndex ? mergedChain : seg))
|
|
78
|
+
.filter((seg, index) => index === currentOrIndex || !chainPrefixes.has((0, prefix_of_command_js_1.prefixOfCommand)(seg)));
|
|
79
|
+
for (const tail of (0, dedupe_strings_js_1.dedupeStrings)(filteredTail)) {
|
|
80
80
|
if (!mergedSegs.includes(tail)) {
|
|
81
81
|
mergedSegs.push(tail);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
return (0,
|
|
84
|
+
return (0, dedupe_strings_js_1.dedupeStrings)(mergedSegs).join('; ');
|
|
85
85
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergePartsByPrefix(currentParts: string[], incomingParts: string[]): string[];
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergePartsByPrefix = mergePartsByPrefix;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const merge_flag_tokens_js_1 = require("./merge-flag-tokens.js");
|
|
5
|
+
const split_prefix_and_flags_js_1 = require("./split-prefix-and-flags.js");
|
|
6
6
|
function mergePartsByPrefix(currentParts, incomingParts) {
|
|
7
|
-
const result = currentParts
|
|
7
|
+
const result = [...currentParts];
|
|
8
8
|
for (const incomingPart of incomingParts) {
|
|
9
|
-
const incomingPrefix = (0,
|
|
9
|
+
const incomingPrefix = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(incomingPart);
|
|
10
10
|
let merged = false;
|
|
11
11
|
for (let k = 0; k < result.length; k++) {
|
|
12
|
-
const currentPrefix = (0,
|
|
12
|
+
const currentPrefix = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(result[k]);
|
|
13
13
|
if (currentPrefix.prefix && incomingPrefix.prefix && currentPrefix.prefix === incomingPrefix.prefix) {
|
|
14
|
-
const mergedFlags = (0,
|
|
14
|
+
const mergedFlags = (0, merge_flag_tokens_js_1.mergeFlagTokens)(currentPrefix.flags, incomingPrefix.flags);
|
|
15
15
|
result[k] = currentPrefix.prefix + (mergedFlags.length > 0 ? ' ' + mergedFlags.join(' ') : '');
|
|
16
16
|
merged = true;
|
|
17
17
|
break;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeSemicolonSegments(current: string, incoming: string): string;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeSemicolonSegments = mergeSemicolonSegments;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
const merge_flag_tokens_js_1 = require("./merge-flag-tokens.js");
|
|
5
|
+
const merge_flags_as_string_js_1 = require("./merge-flags-as-string.js");
|
|
6
|
+
const merge_parts_by_prefix_js_1 = require("./merge-parts-by-prefix.js");
|
|
7
|
+
const prefix_of_command_js_1 = require("./prefix-of-command.js");
|
|
8
|
+
const split_chain_js_1 = require("./split-chain.js");
|
|
9
|
+
const split_prefix_and_flags_js_1 = require("./split-prefix-and-flags.js");
|
|
10
|
+
const split_segments_js_1 = require("./split-segments.js");
|
|
11
11
|
function mergeSemicolonSegments(current, incoming) {
|
|
12
|
-
let currentSegments = (0,
|
|
13
|
-
const incomingSegments = (0,
|
|
12
|
+
let currentSegments = (0, split_segments_js_1.splitSegments)(current);
|
|
13
|
+
const incomingSegments = (0, split_segments_js_1.splitSegments)(incoming);
|
|
14
14
|
for (const incomingSegment of incomingSegments) {
|
|
15
15
|
// If the incoming segment is itself a chain (&& or ||), merge subparts accordingly
|
|
16
16
|
if (incomingSegment.includes('||')) {
|
|
@@ -18,12 +18,12 @@ function mergeSemicolonSegments(current, incoming) {
|
|
|
18
18
|
let mergedIntoCurrent = false;
|
|
19
19
|
for (let j = 0; j < currentSegments.length; j++) {
|
|
20
20
|
if (currentSegments[j].includes('||')) {
|
|
21
|
-
const currentParts = (0,
|
|
22
|
-
const newParts = (0,
|
|
21
|
+
const currentParts = (0, split_chain_js_1.splitChain)(currentSegments[j], '||');
|
|
22
|
+
const newParts = (0, merge_parts_by_prefix_js_1.mergePartsByPrefix)(currentParts, incomingParts);
|
|
23
23
|
currentSegments[j] = newParts.join(' || ');
|
|
24
24
|
// remove duplicates that were absorbed
|
|
25
|
-
currentSegments = currentSegments.filter((s,
|
|
26
|
-
if (
|
|
25
|
+
currentSegments = currentSegments.filter((s, index) => {
|
|
26
|
+
if (index === j) {
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
for (const np of newParts) {
|
|
@@ -43,48 +43,48 @@ function mergeSemicolonSegments(current, incoming) {
|
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
45
|
if (incomingSegment.includes('&&')) {
|
|
46
|
-
const incomingParts = (0,
|
|
46
|
+
const incomingParts = (0, split_chain_js_1.splitChain)(incomingSegment, '&&');
|
|
47
47
|
let mergedIntoCurrent = false;
|
|
48
48
|
for (let j = 0; j < currentSegments.length; j++) {
|
|
49
49
|
if (currentSegments[j].includes('&&')) {
|
|
50
|
-
const currentParts = (0,
|
|
50
|
+
const currentParts = (0, split_chain_js_1.splitChain)(currentSegments[j], '&&');
|
|
51
51
|
// If first prefixes align, do positional merge preferring incoming flags first
|
|
52
52
|
let newParts = [];
|
|
53
|
-
if (currentParts.length > 0 && incomingParts.length > 0 && (0,
|
|
53
|
+
if (currentParts.length > 0 && incomingParts.length > 0 && (0, prefix_of_command_js_1.prefixOfCommand)(currentParts[0]) === (0, prefix_of_command_js_1.prefixOfCommand)(incomingParts[0])) {
|
|
54
54
|
const maxLength = Math.max(currentParts.length, incomingParts.length);
|
|
55
55
|
for (let i = 0; i < maxLength; i++) {
|
|
56
|
-
const
|
|
56
|
+
const currentPart = currentParts[i];
|
|
57
57
|
const incPart = incomingParts[i];
|
|
58
|
-
if (
|
|
59
|
-
const
|
|
60
|
-
const incP = (0,
|
|
61
|
-
if (
|
|
58
|
+
if (currentPart && incPart) {
|
|
59
|
+
const currentP = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(currentPart);
|
|
60
|
+
const incP = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(incPart);
|
|
61
|
+
if (currentP.prefix && incP.prefix && currentP.prefix === incP.prefix) {
|
|
62
62
|
// keep current flags first, then append incoming flags if missing
|
|
63
|
-
const mergedFlags = (0,
|
|
64
|
-
newParts.push(
|
|
63
|
+
const mergedFlags = (0, merge_flag_tokens_js_1.mergeFlagTokens)(currentP.flags, incP.flags);
|
|
64
|
+
newParts.push(currentP.prefix + (mergedFlags.length > 0 ? ' ' + mergedFlags.join(' ') : ''));
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
if (
|
|
69
|
-
newParts.push(
|
|
68
|
+
if (currentPart) {
|
|
69
|
+
newParts.push(currentPart);
|
|
70
70
|
}
|
|
71
|
-
if (!
|
|
71
|
+
if (!currentPart && incPart) {
|
|
72
72
|
newParts.push(incPart);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
currentSegments[j] = newParts.join(' && ');
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
newParts = (0,
|
|
78
|
+
newParts = (0, merge_parts_by_prefix_js_1.mergePartsByPrefix)(currentParts, incomingParts);
|
|
79
79
|
currentSegments[j] = newParts.join(' && ');
|
|
80
80
|
}
|
|
81
81
|
// remove duplicates that were absorbed — compare by prefix to avoid formatting mismatches
|
|
82
|
-
const newPrefixes = new Set(newParts.map(
|
|
83
|
-
currentSegments = currentSegments.filter((s,
|
|
84
|
-
if (
|
|
82
|
+
const newPrefixes = new Set(newParts.map(prefix_of_command_js_1.prefixOfCommand).filter(Boolean));
|
|
83
|
+
currentSegments = currentSegments.filter((s, index) => {
|
|
84
|
+
if (index === j) {
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
|
-
const sp = (0,
|
|
87
|
+
const sp = (0, prefix_of_command_js_1.prefixOfCommand)(s);
|
|
88
88
|
if (sp && newPrefixes.has(sp)) {
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
@@ -99,12 +99,12 @@ function mergeSemicolonSegments(current, incoming) {
|
|
|
99
99
|
}
|
|
100
100
|
continue;
|
|
101
101
|
}
|
|
102
|
-
const incomingPartsObject = (0,
|
|
102
|
+
const incomingPartsObject = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(incomingSegment);
|
|
103
103
|
let matched = false;
|
|
104
104
|
for (let i = 0; i < currentSegments.length; i++) {
|
|
105
|
-
const currentPartsObject = (0,
|
|
105
|
+
const currentPartsObject = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(currentSegments[i]);
|
|
106
106
|
if (currentPartsObject.prefix && incomingPartsObject.prefix && currentPartsObject.prefix === incomingPartsObject.prefix) {
|
|
107
|
-
currentSegments[i] = (0,
|
|
107
|
+
currentSegments[i] = (0, merge_flags_as_string_js_1.mergeFlagsAsString)(currentSegments[i], incomingPartsObject);
|
|
108
108
|
matched = true;
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
@@ -117,7 +117,7 @@ function mergeSemicolonSegments(current, incoming) {
|
|
|
117
117
|
const seen = [];
|
|
118
118
|
const deduped = [];
|
|
119
119
|
for (const s of currentSegments) {
|
|
120
|
-
const p = (0,
|
|
120
|
+
const p = (0, prefix_of_command_js_1.prefixOfCommand)(s) || s;
|
|
121
121
|
if (!seen.includes(p)) {
|
|
122
122
|
seen.push(p);
|
|
123
123
|
deduped.push(s);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeWithSemicolonMix(current: string, incoming: string): string | undefined;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeWithSemicolonMix = mergeWithSemicolonMix;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const merge_flags_as_string_js_1 = require("./merge-flags-as-string.js");
|
|
5
|
+
const split_chain_js_1 = require("./split-chain.js");
|
|
6
|
+
const split_prefix_and_flags_js_1 = require("./split-prefix-and-flags.js");
|
|
7
7
|
function mergeWithSemicolonMix(current, incoming) {
|
|
8
8
|
if (!(incoming.includes('&&') && current.includes(';'))) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
const allSegments = current.split(/;|&&/).map((s) => s.trim()).filter(Boolean);
|
|
12
12
|
const chainPart = current.split(';')[0] || '';
|
|
13
|
-
const chainCount = chainPart ? (0,
|
|
13
|
+
const chainCount = chainPart ? (0, split_chain_js_1.splitChain)(chainPart, '&&').length : 0;
|
|
14
14
|
const currentChain = allSegments.slice(0, chainCount);
|
|
15
15
|
const tail = allSegments.slice(chainCount);
|
|
16
|
-
const incomingAnd = (0,
|
|
17
|
-
const chainResult = currentChain
|
|
16
|
+
const incomingAnd = (0, split_chain_js_1.splitChain)(incoming, '&&');
|
|
17
|
+
const chainResult = [...currentChain];
|
|
18
18
|
const appendedTailIdxs = [];
|
|
19
19
|
for (const incomingSegment of incomingAnd) {
|
|
20
|
-
const incomingParts = (0,
|
|
20
|
+
const incomingParts = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(incomingSegment);
|
|
21
21
|
let matched = false;
|
|
22
22
|
for (const [i, allSegment] of allSegments.entries()) {
|
|
23
|
-
const currentParts = (0,
|
|
23
|
+
const currentParts = (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(allSegment);
|
|
24
24
|
if (currentParts.prefix && incomingParts.prefix && currentParts.prefix === incomingParts.prefix) {
|
|
25
25
|
if (i < chainCount) {
|
|
26
26
|
// merge into existing chain position
|
|
27
|
-
const
|
|
28
|
-
chainResult[
|
|
27
|
+
const index = i;
|
|
28
|
+
chainResult[index] = (0, merge_flags_as_string_js_1.mergeFlagsAsString)(chainResult[index], incomingParts);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
// append matching tail segment into chain if not already appended
|
|
32
32
|
if (!appendedTailIdxs.includes(i)) {
|
|
33
|
-
chainResult.push((0,
|
|
33
|
+
chainResult.push((0, merge_flags_as_string_js_1.mergeFlagsAsString)(allSegment, incomingParts));
|
|
34
34
|
appendedTailIdxs.push(i);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -43,6 +43,6 @@ function mergeWithSemicolonMix(current, incoming) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
// Build remaining tail excluding appended indices
|
|
46
|
-
const remainingTail = tail.filter((_,
|
|
46
|
+
const remainingTail = tail.filter((_, index) => !appendedTailIdxs.includes(chainCount + index));
|
|
47
47
|
return chainResult.join(' && ') + (remainingTail.length > 0 ? '; ' + remainingTail.join('; ') : '');
|
|
48
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function prefixOfCommand(command: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prefixOfCommand = prefixOfCommand;
|
|
4
|
-
const
|
|
4
|
+
const split_prefix_and_flags_js_1 = require("./split-prefix-and-flags.js");
|
|
5
5
|
function prefixOfCommand(command) {
|
|
6
|
-
return (0,
|
|
6
|
+
return (0, split_prefix_and_flags_js_1.splitPrefixAndFlags)(command).prefix;
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function splitChain(s: string, operator: '&&' | '||'): string[];
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.splitCommand = splitCommand;
|
|
4
|
-
const
|
|
4
|
+
const lodash_es_1 = require("lodash-es");
|
|
5
5
|
function splitCommand(command) {
|
|
6
6
|
const result = {};
|
|
7
|
-
const splitted = command.split(/([&|]{1,2}|;)/).map(
|
|
7
|
+
const splitted = command.split(/([&|]{1,2}|;)/).map(lodash_es_1.trim);
|
|
8
8
|
for (let i = 0; i < splitted.length; i++) {
|
|
9
9
|
const command = splitted[i];
|
|
10
|
-
const splittedSubcommand = command.split(/([\w-]+=\S+)\s/).filter(
|
|
10
|
+
const splittedSubcommand = command.split(/([\w-]+=\S+)\s/).filter(lodash_es_1.identity);
|
|
11
11
|
if (splittedSubcommand.length > 0) {
|
|
12
|
-
const subcommandWithArgs = (0,
|
|
13
|
-
const subcommand = (0,
|
|
12
|
+
const subcommandWithArgs = (0, lodash_es_1.last)(splittedSubcommand).split(' ');
|
|
13
|
+
const subcommand = (0, lodash_es_1.head)(subcommandWithArgs).trim();
|
|
14
14
|
const args = subcommandWithArgs.slice(1);
|
|
15
|
-
const
|
|
15
|
+
const environment = splittedSubcommand.slice(0, -1);
|
|
16
16
|
const parsedSubcommand = {
|
|
17
|
-
args: args.map(
|
|
18
|
-
env:
|
|
17
|
+
args: args.map(lodash_es_1.trim),
|
|
18
|
+
env: environment.map(lodash_es_1.trim),
|
|
19
19
|
separator: splitted[i + 1],
|
|
20
20
|
};
|
|
21
21
|
if (result[subcommand]) {
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.splitPrefixAndFlags = splitPrefixAndFlags;
|
|
4
4
|
function splitPrefixAndFlags(command) {
|
|
5
5
|
const tokens = command.split(/\s+/).filter(Boolean);
|
|
6
|
-
let
|
|
7
|
-
if (
|
|
8
|
-
|
|
6
|
+
let index = tokens.findIndex((t) => t.startsWith('-'));
|
|
7
|
+
if (index === -1) {
|
|
8
|
+
index = tokens.length;
|
|
9
9
|
}
|
|
10
|
-
const prefix = tokens.slice(0,
|
|
11
|
-
const rest = tokens.slice(
|
|
10
|
+
const prefix = tokens.slice(0, index).join(' ');
|
|
11
|
+
const rest = tokens.slice(index);
|
|
12
12
|
const flags = [];
|
|
13
13
|
for (let i = 0; i < rest.length; i++) {
|
|
14
14
|
const t = rest[i];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function splitSegments(s: string): string[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectIndent = detectIndent;
|
|
4
|
+
const format_js_1 = require("../types/format.js");
|
|
5
|
+
const INDENT_REGEX = /^(?:(\t+)|( +))/;
|
|
6
|
+
const LINE_SEPARATOR_REGEX = /\r\n|\r|\n/;
|
|
7
|
+
function detectIndent(text) {
|
|
8
|
+
const lines = text.split(LINE_SEPARATOR_REGEX);
|
|
9
|
+
const indentations = new Set();
|
|
10
|
+
let spaces = 0;
|
|
11
|
+
let tabs = 0;
|
|
12
|
+
for (const line of lines) {
|
|
13
|
+
const match = INDENT_REGEX.exec(line);
|
|
14
|
+
if (match) {
|
|
15
|
+
if (match[1]) {
|
|
16
|
+
tabs += 1;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
indentations.add(match[2].length);
|
|
20
|
+
spaces += 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (tabs > spaces) {
|
|
25
|
+
return {
|
|
26
|
+
style: format_js_1.IndentStyle.TAB,
|
|
27
|
+
size: 1,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const sorted = [...indentations].sort((a, b) => a - b);
|
|
31
|
+
const diffs = [];
|
|
32
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
33
|
+
const d = sorted[i] - sorted[i - 1];
|
|
34
|
+
if (d > 0) {
|
|
35
|
+
diffs.push(d);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let size = sorted[0];
|
|
39
|
+
if (diffs.length > 0) {
|
|
40
|
+
size = diffs.shift();
|
|
41
|
+
for (const value of diffs) {
|
|
42
|
+
size = gcd(size, value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!size || size === 0) {
|
|
46
|
+
size = sorted[0];
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
style: format_js_1.IndentStyle.SPACE,
|
|
50
|
+
size,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function gcd(a, b) {
|
|
54
|
+
while (b !== 0) {
|
|
55
|
+
const t = a % b;
|
|
56
|
+
a = b;
|
|
57
|
+
b = t;
|
|
58
|
+
}
|
|
59
|
+
return Math.abs(a);
|
|
60
|
+
} // }}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flow = flow;
|
|
4
|
+
function flow(...functions) {
|
|
5
|
+
return async (args) => {
|
|
6
|
+
let result = args;
|
|
7
|
+
for (const fn of functions) {
|
|
8
|
+
result = await fn(result);
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getFormat = getFormat;
|
|
7
|
+
const fnmatch_1 = __importDefault(require("editorconfig/src/lib/fnmatch"));
|
|
8
|
+
function fnmatch(filepath, glob) {
|
|
9
|
+
const matchOptions = { matchBase: true, dot: true, noext: true };
|
|
10
|
+
return (0, fnmatch_1.default)(filepath, glob, matchOptions);
|
|
11
|
+
} // }}}
|
|
12
|
+
function getFormat(name, formats) {
|
|
13
|
+
for (const format of formats) {
|
|
14
|
+
if (fnmatch(name, format.glob)) {
|
|
15
|
+
return format;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasFinalNewLine(text: string): boolean;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveRequest = resolveRequest;
|
|
7
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
7
8
|
const untildify_1 = __importDefault(require("untildify"));
|
|
8
9
|
function resolveRequest(spec) {
|
|
9
10
|
if (spec.startsWith('~')) {
|
|
@@ -32,11 +33,11 @@ function resolveRequest(spec) {
|
|
|
32
33
|
if (spec.includes(':')) {
|
|
33
34
|
const [name, variant] = spec.split(':');
|
|
34
35
|
if (variant.length === 0) {
|
|
35
|
-
|
|
36
|
+
return (0, xtry_1.err)(`Missing variant in "${spec}"`);
|
|
36
37
|
}
|
|
37
|
-
return { name, variant };
|
|
38
|
+
return (0, xtry_1.ok)({ name, variant });
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
|
-
return { name: spec };
|
|
41
|
+
return (0, xtry_1.ok)({ name: spec });
|
|
41
42
|
}
|
|
42
43
|
} // }}}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type DResult } from '@zokugun/xtry';
|
|
2
|
+
export declare class TemplateEngine {
|
|
3
|
+
private readonly basePath;
|
|
4
|
+
private readonly fileCache;
|
|
5
|
+
private readonly variables;
|
|
6
|
+
private readonly variableCache;
|
|
7
|
+
constructor(basePath: string, variables?: Record<string, string>);
|
|
8
|
+
render(template: string): DResult<string>;
|
|
9
|
+
private getValueByPath;
|
|
10
|
+
private parseFile;
|
|
11
|
+
private readConfigFile;
|
|
12
|
+
private resolveExpression;
|
|
13
|
+
private resolveVariable;
|
|
14
|
+
private splitPlaceholder;
|
|
15
|
+
private toDate;
|
|
16
|
+
}
|
|
17
|
+
export declare function unescapeCode(code: string): string;
|