@codefast/cli 0.3.14 → 0.3.16-canary.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/README.md +8 -3
- package/dist/arrange/analyze.mjs +24 -0
- package/dist/{lib/arrange/presentation/arrange-cli.schema.mjs → arrange/cli-schema.mjs} +10 -1
- package/dist/arrange/command.mjs +106 -0
- package/dist/{lib/arrange/domain/arrange-analyze.service.mjs → arrange/domain/analyze-service.mjs} +17 -10
- package/dist/{lib/arrange/domain/ast/ast-node.model.mjs → arrange/domain/ast/ast-node.mjs} +57 -3
- package/dist/{lib/arrange/domain/ast/collectors-cn.collector.mjs → arrange/domain/ast/collectors-cn.mjs} +21 -9
- package/dist/{lib/arrange/domain/ast/collectors-jsx.collector.mjs → arrange/domain/ast/collectors-jsx.mjs} +5 -2
- package/dist/{lib/arrange/domain/ast/collectors-tv.collector.mjs → arrange/domain/ast/collectors-tv.mjs} +21 -6
- package/dist/{lib/arrange/domain/ast/ast-helpers.helper.mjs → arrange/domain/ast/helpers.mjs} +26 -9
- package/dist/{lib/arrange/domain/ast/targets.model.mjs → arrange/domain/ast/targets.mjs} +19 -10
- package/dist/{lib/arrange/domain/constants.domain.mjs → arrange/domain/constants.mjs} +63 -18
- package/dist/{lib/arrange/domain/arrange-grouping.service.mjs → arrange/domain/grouping-service.mjs} +31 -10
- package/dist/{lib/arrange/domain/grouping.domain.mjs → arrange/domain/grouping.mjs} +39 -18
- package/dist/{lib/arrange/domain/imports.domain.mjs → arrange/domain/imports.mjs} +7 -3
- package/dist/{lib/arrange/domain/source-text-formatters.formatter.mjs → arrange/domain/source-text-formatters.mjs} +22 -5
- package/dist/{lib/arrange/domain/tailwind-token.value-object.mjs → arrange/domain/tailwind-token.mjs} +12 -3
- package/dist/{lib/arrange/domain/tailwind-token-classifier.domain-service.mjs → arrange/domain/token-classifier.mjs} +40 -15
- package/dist/arrange/output.mjs +79 -0
- package/dist/arrange/process-file.mjs +42 -0
- package/dist/arrange/resolve-target.mjs +24 -0
- package/dist/arrange/scan-target.mjs +20 -0
- package/dist/arrange/source-parse.mjs +18 -0
- package/dist/arrange/suggest.mjs +15 -0
- package/dist/arrange/sync.mjs +51 -0
- package/dist/arrange/typescript-ast-translator.mjs +354 -0
- package/dist/arrange/workspace.mjs +31 -0
- package/dist/bin.mjs +1 -1
- package/dist/{program.mjs → cli.mjs} +14 -19
- package/dist/core/cli/format-error.mjs +15 -0
- package/dist/core/cli/global-options.mjs +10 -0
- package/dist/core/cli/positional.mjs +11 -0
- package/dist/core/cli/result-handle.mjs +51 -0
- package/dist/core/config/loader.mjs +79 -0
- package/dist/{lib/config/infrastructure/config-schema.adapter.mjs → core/config/schema.mjs} +20 -6
- package/dist/core/config/warnings.mjs +12 -0
- package/dist/core/config.mjs +19 -0
- package/dist/{lib/core/domain/caught-unknown-message.value-object.mjs → core/errors.mjs} +20 -4
- package/dist/core/exit-codes.mjs +17 -0
- package/dist/core/filesystem/node.mjs +32 -0
- package/dist/core/logger.mjs +15 -0
- package/dist/{lib/core/domain/result.model.mjs → core/result.mjs} +7 -3
- package/dist/{lib/core/application/services/schema-validator.service.mjs → core/schema-parse.mjs} +6 -5
- package/dist/{lib/shared/source-code/domain/text-edit.model.mjs → core/source-text-edit.mjs} +15 -14
- package/dist/core/verbose-diagnostics.mjs +11 -0
- package/dist/core/workspace/resolver.mjs +177 -0
- package/dist/core/workspace/typescript-walk.mjs +36 -0
- package/dist/mirror/cli-result.mjs +21 -0
- package/dist/{lib/mirror/presentation/mirror-cli.schema.mjs → mirror/cli-schema.mjs} +4 -4
- package/dist/mirror/command.mjs +57 -0
- package/dist/mirror/dist-filesystem-impl.mjs +42 -0
- package/dist/{lib/mirror/domain/constants.domain.mjs → mirror/domain/constants.mjs} +16 -1
- package/dist/{lib/mirror/infrastructure/dirent-list.guard.mjs → mirror/domain/dirent-guard.mjs} +5 -2
- package/dist/{lib/mirror/domain/errors.domain.mjs → mirror/domain/errors.mjs} +7 -1
- package/dist/{lib/mirror/application/services/generate-mirror-exports.service.mjs → mirror/domain/exports.mjs} +17 -10
- package/dist/{lib/mirror/domain/package-display-name.policy.mjs → mirror/domain/package-display-name.mjs} +5 -2
- package/dist/{lib/mirror/domain/path-normalizer.value-object.mjs → mirror/domain/path-normalizer.mjs} +4 -1
- package/dist/mirror/output.mjs +45 -0
- package/dist/mirror/package-path.mjs +32 -0
- package/dist/mirror/prepare.mjs +33 -0
- package/dist/mirror/sync-reporter.mjs +104 -0
- package/dist/mirror/sync-workspace-package.mjs +103 -0
- package/dist/mirror/sync.mjs +87 -0
- package/dist/{lib/mirror/infrastructure/package-json-exports.repository.mjs → mirror/write-exports.mjs} +35 -31
- package/dist/tag/cli-result.mjs +11 -0
- package/dist/{lib/tag/presentation/tag-cli.schema.mjs → tag/cli-schema.mjs} +4 -1
- package/dist/tag/command.mjs +56 -0
- package/dist/{lib/tag/presentation/tag-sync.presenter.mjs → tag/output.mjs} +54 -28
- package/dist/tag/prepare.mjs +29 -0
- package/dist/tag/resolve-target-path.mjs +12 -0
- package/dist/tag/since-writer.mjs +130 -0
- package/dist/tag/sync.mjs +141 -0
- package/dist/tag/target-candidates.mjs +68 -0
- package/dist/tag/target-runner.mjs +26 -0
- package/dist/tag/version-resolver.mjs +25 -0
- package/package.json +8 -9
- package/dist/lib/arrange/adapters/primary/cli/arrange.command.mjs +0 -324
- package/dist/lib/arrange/adapters/primary/cli/arrange.presentation.module.mjs +0 -14
- package/dist/lib/arrange/adapters/primary/cli/presentation.tokens.mjs +0 -5
- package/dist/lib/arrange/adapters/secondary/domain-source-parser.adapter.mjs +0 -239
- package/dist/lib/arrange/adapters/secondary/file-walker.adapter.mjs +0 -241
- package/dist/lib/arrange/adapters/secondary/workspace-resolver.adapter.mjs +0 -233
- package/dist/lib/arrange/application/requests/suggest-groups.request.mjs +0 -1
- package/dist/lib/arrange/application/services/arrange-file-processor.service.mjs +0 -267
- package/dist/lib/arrange/application/services/arrange-target-path-resolver.service.mjs +0 -21
- package/dist/lib/arrange/application/services/arrange-target-scanner.service.mjs +0 -243
- package/dist/lib/arrange/application/use-cases/analyze-directory.use-case.mjs +0 -255
- package/dist/lib/arrange/application/use-cases/prepare-arrange-workspace.use-case.mjs +0 -263
- package/dist/lib/arrange/application/use-cases/run-arrange-sync.use-case.mjs +0 -274
- package/dist/lib/arrange/application/use-cases/suggest-cn-groups.use-case.mjs +0 -237
- package/dist/lib/arrange/arrange.module.mjs +0 -31
- package/dist/lib/arrange/contracts/analyze-report-presenter.contract.mjs +0 -1
- package/dist/lib/arrange/contracts/models.mjs +0 -1
- package/dist/lib/arrange/contracts/services.contract.mjs +0 -1
- package/dist/lib/arrange/contracts/tokens.mjs +0 -15
- package/dist/lib/arrange/domain/tailwind-grouping.service.mjs +0 -231
- package/dist/lib/arrange/domain/types.domain.mjs +0 -1
- package/dist/lib/arrange/infrastructure/typescript-ast-translator.adapter.mjs +0 -355
- package/dist/lib/arrange/presentation/arrange-analyze.presenter.mjs +0 -259
- package/dist/lib/arrange/presentation/arrange-sync.presenter.mjs +0 -33
- package/dist/lib/arrange/presentation/group-file-preview.presenter.mjs +0 -271
- package/dist/lib/bootstrap/composition-root.mjs +0 -33
- package/dist/lib/config/application/ports/config-loader.port.mjs +0 -1
- package/dist/lib/config/application/ports/config-warning-reporter.port.mjs +0 -1
- package/dist/lib/config/application/services/load-config.service.mjs +0 -17
- package/dist/lib/config/contracts/tokens.mjs +0 -6
- package/dist/lib/config/domain/schema.domain.mjs +0 -1
- package/dist/lib/config/infrastructure/config-loader.adapter.mjs +0 -306
- package/dist/lib/config/infrastructure/config-warning-reporter.adapter.mjs +0 -234
- package/dist/lib/core/application/load-codefast-config.use-case.mjs +0 -245
- package/dist/lib/core/application/ports/cli-io.port.mjs +0 -1
- package/dist/lib/core/application/ports/path.port.mjs +0 -1
- package/dist/lib/core/application/ports/repo-root-resolver.port.mjs +0 -1
- package/dist/lib/core/application/ports/runtime.port.mjs +0 -1
- package/dist/lib/core/application/services/global-cli-options-parser.service.mjs +0 -9
- package/dist/lib/core/contracts/tokens.mjs +0 -10
- package/dist/lib/core/core.module.mjs +0 -9
- package/dist/lib/core/domain/cli-exit-codes.domain.mjs +0 -11
- package/dist/lib/core/domain/errors.domain.mjs +0 -17
- package/dist/lib/core/infrastructure/infrastructure.module.mjs +0 -30
- package/dist/lib/core/infrastructure/path.adapter.mjs +0 -246
- package/dist/lib/core/infrastructure/port-telemetry.decorator.mjs +0 -62
- package/dist/lib/core/infrastructure/repo-root-resolver.adapter.mjs +0 -233
- package/dist/lib/core/infrastructure/verbose-diagnostics.policy.mjs +0 -9
- package/dist/lib/core/presentation/cli-executor.presenter.mjs +0 -42
- package/dist/lib/core/presentation/cli-schema.parser.mjs +0 -7
- package/dist/lib/core/presentation/format-app-error.presenter.mjs +0 -17
- package/dist/lib/core/presentation/presentation.module.mjs +0 -5
- package/dist/lib/infrastructure/node-io.adapter.mjs +0 -285
- package/dist/lib/infrastructure/workspace/repo-root-resolver.service.mjs +0 -21
- package/dist/lib/kernel/contracts/cli-command.contract.mjs +0 -1
- package/dist/lib/kernel/contracts/tokens.mjs +0 -5
- package/dist/lib/mirror/adapters/primary/cli/mirror.command.mjs +0 -272
- package/dist/lib/mirror/adapters/secondary/file-system-service.adapter.mjs +0 -261
- package/dist/lib/mirror/adapters/secondary/mirror-sync-reporter.adapter.mjs +0 -243
- package/dist/lib/mirror/adapters/secondary/package-repository.adapter.mjs +0 -241
- package/dist/lib/mirror/adapters/secondary/sync-workspace-package.adapter.mjs +0 -351
- package/dist/lib/mirror/adapters/secondary/workspace-service.adapter.mjs +0 -237
- package/dist/lib/mirror/application/mirror-sync-json.format.mjs +0 -12
- package/dist/lib/mirror/application/ports/file-system-service.port.mjs +0 -1
- package/dist/lib/mirror/application/ports/mirror-sync-reporter.port.mjs +0 -1
- package/dist/lib/mirror/application/ports/package-repository.port.mjs +0 -1
- package/dist/lib/mirror/application/ports/sync-workspace-package.port.mjs +0 -1
- package/dist/lib/mirror/application/ports/workspace-service.port.mjs +0 -1
- package/dist/lib/mirror/application/requests/mirror-sync.request.mjs +0 -1
- package/dist/lib/mirror/application/services/mirror-package-arg-resolver.service.mjs +0 -20
- package/dist/lib/mirror/application/use-cases/prepare-mirror-sync.use-case.mjs +0 -264
- package/dist/lib/mirror/application/use-cases/run-mirror-sync.use-case.mjs +0 -302
- package/dist/lib/mirror/contracts/models.mjs +0 -1
- package/dist/lib/mirror/contracts/tokens.mjs +0 -11
- package/dist/lib/mirror/domain/types.domain.mjs +0 -1
- package/dist/lib/mirror/infrastructure/mirror-console-reporter.presenter.mjs +0 -99
- package/dist/lib/mirror/infrastructure/package-filter-resolver.service.mjs +0 -25
- package/dist/lib/mirror/infrastructure/workspace-packages.service.mjs +0 -158
- package/dist/lib/mirror/mirror.module.mjs +0 -25
- package/dist/lib/shared/source-code/infrastructure/typescript-source-file-walker.service.mjs +0 -33
- package/dist/lib/tag/adapters/primary/cli/presentation.tokens.mjs +0 -6
- package/dist/lib/tag/adapters/primary/cli/tag.command.mjs +0 -285
- package/dist/lib/tag/adapters/primary/cli/tag.presentation.module.mjs +0 -13
- package/dist/lib/tag/adapters/secondary/tag-since-writer.adapter.mjs +0 -348
- package/dist/lib/tag/adapters/secondary/tag-target-resolver.adapter.mjs +0 -233
- package/dist/lib/tag/adapters/secondary/tag-version-resolver.adapter.mjs +0 -249
- package/dist/lib/tag/adapters/secondary/typescript-tree-walk.adapter.mjs +0 -233
- package/dist/lib/tag/application/ports/tag-since-writer.port.mjs +0 -1
- package/dist/lib/tag/application/ports/tag-version-resolver.port.mjs +0 -1
- package/dist/lib/tag/application/ports/target-resolver.port.mjs +0 -1
- package/dist/lib/tag/application/ports/typescript-tree-walk.port.mjs +0 -1
- package/dist/lib/tag/application/requests/tag-sync.request.mjs +0 -1
- package/dist/lib/tag/application/services/tag-cli-target-path-resolver.service.mjs +0 -9
- package/dist/lib/tag/application/services/tag-target-runner.service.mjs +0 -21
- package/dist/lib/tag/application/tag-sync-cli-result.mjs +0 -11
- package/dist/lib/tag/application/tag-sync-json.format.mjs +0 -14
- package/dist/lib/tag/application/use-cases/prepare-tag-sync.use-case.mjs +0 -264
- package/dist/lib/tag/application/use-cases/run-tag-sync.use-case.mjs +0 -381
- package/dist/lib/tag/contracts/models.mjs +0 -1
- package/dist/lib/tag/contracts/tag-sync-result-presenter.contract.mjs +0 -1
- package/dist/lib/tag/contracts/tokens.mjs +0 -10
- package/dist/lib/tag/domain/types.domain.mjs +0 -1
- package/dist/lib/tag/infrastructure/tag-target-candidates.adapter.mjs +0 -170
- package/dist/lib/tag/presentation/colors.presenter.mjs +0 -12
- package/dist/lib/tag/presentation/present-tag-sync-result.presenter.mjs +0 -233
- package/dist/lib/tag/presentation/tag-sync-progress-listener.presenter.mjs +0 -243
- package/dist/lib/tag/tag.module.mjs +0 -23
- /package/dist/{lib/arrange/application/ports/domain-source-parser.port.mjs → arrange/domain/types.mjs} +0 -0
- /package/dist/{lib/arrange/application/ports/file-walker.port.mjs → core/filesystem/port.mjs} +0 -0
- /package/dist/{lib/arrange/application/ports/group-file-preview.port.mjs → mirror/domain/dist-filesystem.mjs} +0 -0
- /package/dist/{lib/arrange/application/ports/workspace-resolver.port.mjs → mirror/domain/types.mjs} +0 -0
- /package/dist/{lib/arrange/application/requests/analyze-directory.request.mjs → mirror/sync-types.mjs} +0 -0
- /package/dist/{lib/arrange/application/requests/arrange-sync.request.mjs → tag/domain/types.mjs} +0 -0
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { CliFsToken, LoadCodefastConfigUseCaseToken, RepoRootResolverPortToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
-
import { ok } from "../../../core/domain/result.model.mjs";
|
|
3
|
-
import { resolveTagCliTargetPath } from "../services/tag-cli-target-path-resolver.service.mjs";
|
|
4
|
-
import { inject, injectable } from "@codefast/di";
|
|
5
|
-
//#region src/lib/tag/application/use-cases/prepare-tag-sync.use-case.ts
|
|
6
|
-
function toPrimitive(input, hint) {
|
|
7
|
-
if (typeof input !== "object" || input === null) return input;
|
|
8
|
-
var prim = input[Symbol.toPrimitive];
|
|
9
|
-
if (prim !== void 0) {
|
|
10
|
-
var res = prim.call(input, hint || "default");
|
|
11
|
-
if (typeof res !== "object") return res;
|
|
12
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
13
|
-
}
|
|
14
|
-
return (hint === "string" ? String : Number)(input);
|
|
15
|
-
}
|
|
16
|
-
function toPropertyKey(arg) {
|
|
17
|
-
var key = toPrimitive(arg, "string");
|
|
18
|
-
return typeof key === "symbol" ? key : String(key);
|
|
19
|
-
}
|
|
20
|
-
function checkInRHS(value) {
|
|
21
|
-
if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
function setFunctionName(fn, name, prefix) {
|
|
25
|
-
if (typeof name === "symbol") {
|
|
26
|
-
name = name.description;
|
|
27
|
-
name = name ? "[" + name + "]" : "";
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
Object.defineProperty(fn, "name", {
|
|
31
|
-
configurable: true,
|
|
32
|
-
value: prefix ? prefix + " " + name : name
|
|
33
|
-
});
|
|
34
|
-
} catch (_) {}
|
|
35
|
-
return fn;
|
|
36
|
-
}
|
|
37
|
-
function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
|
|
38
|
-
var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
|
|
39
|
-
var defineProperty = Object.defineProperty;
|
|
40
|
-
var create = Object.create;
|
|
41
|
-
var metadata;
|
|
42
|
-
var existingNonFields = [create(null), create(null)];
|
|
43
|
-
var hasClassDecs = classDecs.length;
|
|
44
|
-
var _;
|
|
45
|
-
function createRunInitializers(initializers, useStaticThis, hasValue) {
|
|
46
|
-
return function(thisArg, value) {
|
|
47
|
-
if (useStaticThis) {
|
|
48
|
-
value = thisArg;
|
|
49
|
-
thisArg = targetClass;
|
|
50
|
-
}
|
|
51
|
-
for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
|
|
52
|
-
return hasValue ? value : thisArg;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function assertCallable(fn, hint1, hint2, throwUndefined) {
|
|
56
|
-
if (typeof fn !== "function") {
|
|
57
|
-
if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
|
|
58
|
-
}
|
|
59
|
-
return fn;
|
|
60
|
-
}
|
|
61
|
-
function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
|
|
62
|
-
function assertInstanceIfPrivate(target) {
|
|
63
|
-
if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
|
|
64
|
-
}
|
|
65
|
-
var decs = [].concat(decInfo[0]);
|
|
66
|
-
var decVal = decInfo[3];
|
|
67
|
-
var isClass = !ret;
|
|
68
|
-
var isAccessor = kind === 1;
|
|
69
|
-
var isGetter = kind === 3;
|
|
70
|
-
var isSetter = kind === 4;
|
|
71
|
-
var isMethod = kind === 2;
|
|
72
|
-
function bindPropCall(name, useStaticThis, before) {
|
|
73
|
-
return function(_this, value) {
|
|
74
|
-
if (useStaticThis) {
|
|
75
|
-
value = _this;
|
|
76
|
-
_this = Class;
|
|
77
|
-
}
|
|
78
|
-
if (before) before(_this);
|
|
79
|
-
return desc[name].call(_this, value);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
var desc1 = {};
|
|
83
|
-
var init = [];
|
|
84
|
-
var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
|
|
85
|
-
if (!isClass) {
|
|
86
|
-
if (isPrivate) {
|
|
87
|
-
if (isField || isAccessor) desc1 = {
|
|
88
|
-
get: setFunctionName(function() {
|
|
89
|
-
return decVal(this);
|
|
90
|
-
}, name, "get"),
|
|
91
|
-
set: function(value) {
|
|
92
|
-
decInfo[4](this, value);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
else desc1[key] = decVal;
|
|
96
|
-
if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
|
|
97
|
-
} else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
|
|
98
|
-
if (!isField && !isPrivate) {
|
|
99
|
-
_ = existingNonFields[+isStatic][name];
|
|
100
|
-
if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
|
|
101
|
-
existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
var newValue = Class;
|
|
105
|
-
for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
|
|
106
|
-
var dec = assertCallable(decs[i], "A decorator", "be", true);
|
|
107
|
-
var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
|
|
108
|
-
var decoratorFinishedRef = {};
|
|
109
|
-
var ctx = {
|
|
110
|
-
kind: [
|
|
111
|
-
"field",
|
|
112
|
-
"accessor",
|
|
113
|
-
"method",
|
|
114
|
-
"getter",
|
|
115
|
-
"setter",
|
|
116
|
-
"class"
|
|
117
|
-
][kind],
|
|
118
|
-
name,
|
|
119
|
-
metadata,
|
|
120
|
-
addInitializer: (function(decoratorFinishedRef, initializer) {
|
|
121
|
-
if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
|
|
122
|
-
assertCallable(initializer, "An initializer", "be", true);
|
|
123
|
-
initializers.push(initializer);
|
|
124
|
-
}).bind(null, decoratorFinishedRef)
|
|
125
|
-
};
|
|
126
|
-
if (isClass) {
|
|
127
|
-
_ = dec.call(decThis, newValue, ctx);
|
|
128
|
-
decoratorFinishedRef.v = 1;
|
|
129
|
-
if (assertCallable(_, "class decorators", "return")) newValue = _;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
ctx.static = isStatic;
|
|
133
|
-
ctx.private = isPrivate;
|
|
134
|
-
_ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
|
|
135
|
-
return name in target;
|
|
136
|
-
} };
|
|
137
|
-
if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
|
|
138
|
-
assertInstanceIfPrivate(_this);
|
|
139
|
-
return desc1.value;
|
|
140
|
-
} : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
|
|
141
|
-
return target[name];
|
|
142
|
-
};
|
|
143
|
-
if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
|
|
144
|
-
target[name] = value;
|
|
145
|
-
};
|
|
146
|
-
newValue = dec.call(decThis, isAccessor ? {
|
|
147
|
-
get: desc1.get,
|
|
148
|
-
set: desc1.set
|
|
149
|
-
} : desc1[key], ctx);
|
|
150
|
-
decoratorFinishedRef.v = 1;
|
|
151
|
-
if (isAccessor) {
|
|
152
|
-
if (typeof newValue === "object" && newValue) {
|
|
153
|
-
if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
|
|
154
|
-
if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
|
|
155
|
-
if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
|
|
156
|
-
} else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
|
|
157
|
-
} else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
|
|
158
|
-
else desc1[key] = newValue;
|
|
159
|
-
}
|
|
160
|
-
if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
|
|
161
|
-
if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
|
|
162
|
-
else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
|
|
163
|
-
else defineProperty(Class, name, desc1);
|
|
164
|
-
return newValue;
|
|
165
|
-
}
|
|
166
|
-
function applyMemberDecs() {
|
|
167
|
-
var ret = [];
|
|
168
|
-
var protoInitializers;
|
|
169
|
-
var staticInitializers;
|
|
170
|
-
var pushInitializers = function(initializers) {
|
|
171
|
-
if (initializers) ret.push(createRunInitializers(initializers));
|
|
172
|
-
};
|
|
173
|
-
var applyMemberDecsOfKind = function(isStatic, isField) {
|
|
174
|
-
for (var i = 0; i < memberDecs.length; i++) {
|
|
175
|
-
var decInfo = memberDecs[i];
|
|
176
|
-
var kind = decInfo[1];
|
|
177
|
-
var kindOnly = kind & 7;
|
|
178
|
-
if ((kind & 8) == isStatic && !kindOnly == isField) {
|
|
179
|
-
var name = decInfo[2];
|
|
180
|
-
var isPrivate = !!decInfo[3];
|
|
181
|
-
var decoratorsHaveThis = kind & 16;
|
|
182
|
-
applyDec(isStatic ? targetClass : targetClass.prototype, decInfo, decoratorsHaveThis, isPrivate ? "#" + name : toPropertyKey(name), kindOnly, kindOnly < 2 ? [] : isStatic ? staticInitializers = staticInitializers || [] : protoInitializers = protoInitializers || [], ret, !!isStatic, isPrivate, isField, isStatic && isPrivate ? function(_) {
|
|
183
|
-
return checkInRHS(_) === targetClass;
|
|
184
|
-
} : instanceBrand);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
applyMemberDecsOfKind(8, 0);
|
|
189
|
-
applyMemberDecsOfKind(0, 0);
|
|
190
|
-
applyMemberDecsOfKind(8, 1);
|
|
191
|
-
applyMemberDecsOfKind(0, 1);
|
|
192
|
-
pushInitializers(protoInitializers);
|
|
193
|
-
pushInitializers(staticInitializers);
|
|
194
|
-
return ret;
|
|
195
|
-
}
|
|
196
|
-
function defineMetadata(Class) {
|
|
197
|
-
return defineProperty(Class, symbolMetadata, {
|
|
198
|
-
configurable: true,
|
|
199
|
-
enumerable: true,
|
|
200
|
-
value: metadata
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
|
|
204
|
-
metadata = create(metadata == null ? null : metadata);
|
|
205
|
-
_ = applyMemberDecs();
|
|
206
|
-
if (!hasClassDecs) defineMetadata(targetClass);
|
|
207
|
-
return {
|
|
208
|
-
e: _,
|
|
209
|
-
get c() {
|
|
210
|
-
var initializers = [];
|
|
211
|
-
return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
let _dec, _initClass;
|
|
216
|
-
function resolveTagWorkspaceRootPath(args) {
|
|
217
|
-
try {
|
|
218
|
-
return args.repoRootResolver.findRepoRoot(args.currentWorkingDirectory);
|
|
219
|
-
} catch {
|
|
220
|
-
return args.currentWorkingDirectory;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
_dec = injectable([
|
|
224
|
-
inject(CliFsToken),
|
|
225
|
-
inject(RepoRootResolverPortToken),
|
|
226
|
-
inject(LoadCodefastConfigUseCaseToken)
|
|
227
|
-
]);
|
|
228
|
-
let _PrepareTagSyncUseCaseImpl;
|
|
229
|
-
(class {
|
|
230
|
-
fs;
|
|
231
|
-
repoRootResolver;
|
|
232
|
-
loadCodefastConfig;
|
|
233
|
-
static {
|
|
234
|
-
({c: [_PrepareTagSyncUseCaseImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
235
|
-
}
|
|
236
|
-
constructor(fs, repoRootResolver, loadCodefastConfig) {
|
|
237
|
-
this.fs = fs;
|
|
238
|
-
this.repoRootResolver = repoRootResolver;
|
|
239
|
-
this.loadCodefastConfig = loadCodefastConfig;
|
|
240
|
-
}
|
|
241
|
-
async execute(args) {
|
|
242
|
-
const rootDir = resolveTagWorkspaceRootPath({
|
|
243
|
-
repoRootResolver: this.repoRootResolver,
|
|
244
|
-
currentWorkingDirectory: args.currentWorkingDirectory
|
|
245
|
-
});
|
|
246
|
-
const loadedOutcome = await this.loadCodefastConfig.execute(rootDir);
|
|
247
|
-
if (!loadedOutcome.ok) return loadedOutcome;
|
|
248
|
-
const resolvedTargetPath = resolveTagCliTargetPath({
|
|
249
|
-
fs: this.fs,
|
|
250
|
-
currentWorkingDirectory: args.currentWorkingDirectory,
|
|
251
|
-
rawTarget: args.rawTarget
|
|
252
|
-
});
|
|
253
|
-
return ok({
|
|
254
|
-
rootDir,
|
|
255
|
-
config: loadedOutcome.value.config,
|
|
256
|
-
resolvedTargetPath
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
static {
|
|
260
|
-
_initClass();
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
//#endregion
|
|
264
|
-
export { _PrepareTagSyncUseCaseImpl as PrepareTagSyncUseCaseImpl };
|
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
import { CliFsToken, CliPathToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
-
import { AppError } from "../../../core/domain/errors.domain.mjs";
|
|
3
|
-
import { err, ok } from "../../../core/domain/result.model.mjs";
|
|
4
|
-
import { messageFromCaughtUnknown } from "../../../core/domain/caught-unknown-message.value-object.mjs";
|
|
5
|
-
import { TagSinceWriterPortToken, TagTargetResolverPortToken, TagVersionResolverPortToken, TypeScriptTreeWalkPortToken } from "../../contracts/tokens.mjs";
|
|
6
|
-
import { runTagOnTarget } from "../services/tag-target-runner.service.mjs";
|
|
7
|
-
import { inject, injectable } from "@codefast/di";
|
|
8
|
-
//#region src/lib/tag/application/use-cases/run-tag-sync.use-case.ts
|
|
9
|
-
function toPrimitive(input, hint) {
|
|
10
|
-
if (typeof input !== "object" || input === null) return input;
|
|
11
|
-
var prim = input[Symbol.toPrimitive];
|
|
12
|
-
if (prim !== void 0) {
|
|
13
|
-
var res = prim.call(input, hint || "default");
|
|
14
|
-
if (typeof res !== "object") return res;
|
|
15
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16
|
-
}
|
|
17
|
-
return (hint === "string" ? String : Number)(input);
|
|
18
|
-
}
|
|
19
|
-
function toPropertyKey(arg) {
|
|
20
|
-
var key = toPrimitive(arg, "string");
|
|
21
|
-
return typeof key === "symbol" ? key : String(key);
|
|
22
|
-
}
|
|
23
|
-
function checkInRHS(value) {
|
|
24
|
-
if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
function setFunctionName(fn, name, prefix) {
|
|
28
|
-
if (typeof name === "symbol") {
|
|
29
|
-
name = name.description;
|
|
30
|
-
name = name ? "[" + name + "]" : "";
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
Object.defineProperty(fn, "name", {
|
|
34
|
-
configurable: true,
|
|
35
|
-
value: prefix ? prefix + " " + name : name
|
|
36
|
-
});
|
|
37
|
-
} catch (_) {}
|
|
38
|
-
return fn;
|
|
39
|
-
}
|
|
40
|
-
function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
|
|
41
|
-
var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
|
|
42
|
-
var defineProperty = Object.defineProperty;
|
|
43
|
-
var create = Object.create;
|
|
44
|
-
var metadata;
|
|
45
|
-
var existingNonFields = [create(null), create(null)];
|
|
46
|
-
var hasClassDecs = classDecs.length;
|
|
47
|
-
var _;
|
|
48
|
-
function createRunInitializers(initializers, useStaticThis, hasValue) {
|
|
49
|
-
return function(thisArg, value) {
|
|
50
|
-
if (useStaticThis) {
|
|
51
|
-
value = thisArg;
|
|
52
|
-
thisArg = targetClass;
|
|
53
|
-
}
|
|
54
|
-
for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
|
|
55
|
-
return hasValue ? value : thisArg;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function assertCallable(fn, hint1, hint2, throwUndefined) {
|
|
59
|
-
if (typeof fn !== "function") {
|
|
60
|
-
if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
|
|
61
|
-
}
|
|
62
|
-
return fn;
|
|
63
|
-
}
|
|
64
|
-
function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
|
|
65
|
-
function assertInstanceIfPrivate(target) {
|
|
66
|
-
if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
|
|
67
|
-
}
|
|
68
|
-
var decs = [].concat(decInfo[0]);
|
|
69
|
-
var decVal = decInfo[3];
|
|
70
|
-
var isClass = !ret;
|
|
71
|
-
var isAccessor = kind === 1;
|
|
72
|
-
var isGetter = kind === 3;
|
|
73
|
-
var isSetter = kind === 4;
|
|
74
|
-
var isMethod = kind === 2;
|
|
75
|
-
function bindPropCall(name, useStaticThis, before) {
|
|
76
|
-
return function(_this, value) {
|
|
77
|
-
if (useStaticThis) {
|
|
78
|
-
value = _this;
|
|
79
|
-
_this = Class;
|
|
80
|
-
}
|
|
81
|
-
if (before) before(_this);
|
|
82
|
-
return desc[name].call(_this, value);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
var desc1 = {};
|
|
86
|
-
var init = [];
|
|
87
|
-
var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
|
|
88
|
-
if (!isClass) {
|
|
89
|
-
if (isPrivate) {
|
|
90
|
-
if (isField || isAccessor) desc1 = {
|
|
91
|
-
get: setFunctionName(function() {
|
|
92
|
-
return decVal(this);
|
|
93
|
-
}, name, "get"),
|
|
94
|
-
set: function(value) {
|
|
95
|
-
decInfo[4](this, value);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
else desc1[key] = decVal;
|
|
99
|
-
if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
|
|
100
|
-
} else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
|
|
101
|
-
if (!isField && !isPrivate) {
|
|
102
|
-
_ = existingNonFields[+isStatic][name];
|
|
103
|
-
if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
|
|
104
|
-
existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
var newValue = Class;
|
|
108
|
-
for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
|
|
109
|
-
var dec = assertCallable(decs[i], "A decorator", "be", true);
|
|
110
|
-
var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
|
|
111
|
-
var decoratorFinishedRef = {};
|
|
112
|
-
var ctx = {
|
|
113
|
-
kind: [
|
|
114
|
-
"field",
|
|
115
|
-
"accessor",
|
|
116
|
-
"method",
|
|
117
|
-
"getter",
|
|
118
|
-
"setter",
|
|
119
|
-
"class"
|
|
120
|
-
][kind],
|
|
121
|
-
name,
|
|
122
|
-
metadata,
|
|
123
|
-
addInitializer: (function(decoratorFinishedRef, initializer) {
|
|
124
|
-
if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
|
|
125
|
-
assertCallable(initializer, "An initializer", "be", true);
|
|
126
|
-
initializers.push(initializer);
|
|
127
|
-
}).bind(null, decoratorFinishedRef)
|
|
128
|
-
};
|
|
129
|
-
if (isClass) {
|
|
130
|
-
_ = dec.call(decThis, newValue, ctx);
|
|
131
|
-
decoratorFinishedRef.v = 1;
|
|
132
|
-
if (assertCallable(_, "class decorators", "return")) newValue = _;
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
ctx.static = isStatic;
|
|
136
|
-
ctx.private = isPrivate;
|
|
137
|
-
_ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
|
|
138
|
-
return name in target;
|
|
139
|
-
} };
|
|
140
|
-
if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
|
|
141
|
-
assertInstanceIfPrivate(_this);
|
|
142
|
-
return desc1.value;
|
|
143
|
-
} : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
|
|
144
|
-
return target[name];
|
|
145
|
-
};
|
|
146
|
-
if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
|
|
147
|
-
target[name] = value;
|
|
148
|
-
};
|
|
149
|
-
newValue = dec.call(decThis, isAccessor ? {
|
|
150
|
-
get: desc1.get,
|
|
151
|
-
set: desc1.set
|
|
152
|
-
} : desc1[key], ctx);
|
|
153
|
-
decoratorFinishedRef.v = 1;
|
|
154
|
-
if (isAccessor) {
|
|
155
|
-
if (typeof newValue === "object" && newValue) {
|
|
156
|
-
if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
|
|
157
|
-
if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
|
|
158
|
-
if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
|
|
159
|
-
} else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
|
|
160
|
-
} else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
|
|
161
|
-
else desc1[key] = newValue;
|
|
162
|
-
}
|
|
163
|
-
if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
|
|
164
|
-
if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
|
|
165
|
-
else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
|
|
166
|
-
else defineProperty(Class, name, desc1);
|
|
167
|
-
return newValue;
|
|
168
|
-
}
|
|
169
|
-
function applyMemberDecs() {
|
|
170
|
-
var ret = [];
|
|
171
|
-
var protoInitializers;
|
|
172
|
-
var staticInitializers;
|
|
173
|
-
var pushInitializers = function(initializers) {
|
|
174
|
-
if (initializers) ret.push(createRunInitializers(initializers));
|
|
175
|
-
};
|
|
176
|
-
var applyMemberDecsOfKind = function(isStatic, isField) {
|
|
177
|
-
for (var i = 0; i < memberDecs.length; i++) {
|
|
178
|
-
var decInfo = memberDecs[i];
|
|
179
|
-
var kind = decInfo[1];
|
|
180
|
-
var kindOnly = kind & 7;
|
|
181
|
-
if ((kind & 8) == isStatic && !kindOnly == isField) {
|
|
182
|
-
var name = decInfo[2];
|
|
183
|
-
var isPrivate = !!decInfo[3];
|
|
184
|
-
var decoratorsHaveThis = kind & 16;
|
|
185
|
-
applyDec(isStatic ? targetClass : targetClass.prototype, decInfo, decoratorsHaveThis, isPrivate ? "#" + name : toPropertyKey(name), kindOnly, kindOnly < 2 ? [] : isStatic ? staticInitializers = staticInitializers || [] : protoInitializers = protoInitializers || [], ret, !!isStatic, isPrivate, isField, isStatic && isPrivate ? function(_) {
|
|
186
|
-
return checkInRHS(_) === targetClass;
|
|
187
|
-
} : instanceBrand);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
applyMemberDecsOfKind(8, 0);
|
|
192
|
-
applyMemberDecsOfKind(0, 0);
|
|
193
|
-
applyMemberDecsOfKind(8, 1);
|
|
194
|
-
applyMemberDecsOfKind(0, 1);
|
|
195
|
-
pushInitializers(protoInitializers);
|
|
196
|
-
pushInitializers(staticInitializers);
|
|
197
|
-
return ret;
|
|
198
|
-
}
|
|
199
|
-
function defineMetadata(Class) {
|
|
200
|
-
return defineProperty(Class, symbolMetadata, {
|
|
201
|
-
configurable: true,
|
|
202
|
-
enumerable: true,
|
|
203
|
-
value: metadata
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
|
|
207
|
-
metadata = create(metadata == null ? null : metadata);
|
|
208
|
-
_ = applyMemberDecs();
|
|
209
|
-
if (!hasClassDecs) defineMetadata(targetClass);
|
|
210
|
-
return {
|
|
211
|
-
e: _,
|
|
212
|
-
get c() {
|
|
213
|
-
var initializers = [];
|
|
214
|
-
return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
let _dec, _initClass;
|
|
219
|
-
async function runTagOnAfterWriteHook(hook, modifiedFiles) {
|
|
220
|
-
if (!hook || modifiedFiles.length === 0) return null;
|
|
221
|
-
try {
|
|
222
|
-
await hook({ files: modifiedFiles });
|
|
223
|
-
return null;
|
|
224
|
-
} catch (caughtHookError) {
|
|
225
|
-
return `[tag] onAfterWrite hook failed: ${messageFromCaughtUnknown(caughtHookError)}`;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
function summarizeVersions(targetResults) {
|
|
229
|
-
const distinctVersions = extractDistinctVersions(targetResults);
|
|
230
|
-
if (distinctVersions.size === 0) return "none";
|
|
231
|
-
if (distinctVersions.size > 1) return "mixed";
|
|
232
|
-
for (const version of distinctVersions) return version;
|
|
233
|
-
return "none";
|
|
234
|
-
}
|
|
235
|
-
function extractDistinctVersions(targetResults) {
|
|
236
|
-
return new Set(targetResults.map((targetResult) => targetResult.result?.version).filter((version) => typeof version === "string" && version.length > 0));
|
|
237
|
-
}
|
|
238
|
-
function chooseWorkspacePackageTargetPath(candidate, pathService, fs) {
|
|
239
|
-
if (candidate.source !== "workspace-package") return {
|
|
240
|
-
targetPath: candidate.candidatePath,
|
|
241
|
-
source: candidate.source
|
|
242
|
-
};
|
|
243
|
-
const preferredSourceDir = pathService.join(candidate.candidatePath, "src");
|
|
244
|
-
if (fs.existsSync(preferredSourceDir) && fs.statSync(preferredSourceDir).isDirectory()) return {
|
|
245
|
-
targetPath: preferredSourceDir,
|
|
246
|
-
source: "workspace-package-selected-src"
|
|
247
|
-
};
|
|
248
|
-
return {
|
|
249
|
-
targetPath: candidate.candidatePath,
|
|
250
|
-
source: "workspace-package-selected-root"
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function resolveTargetSelection(candidate, rootDir, pathService, fs) {
|
|
254
|
-
const selectedTarget = chooseWorkspacePackageTargetPath(candidate, pathService, fs);
|
|
255
|
-
const rootRelativeTargetPath = pathService.relative(rootDir, selectedTarget.targetPath).split(pathService.separator).join("/");
|
|
256
|
-
return {
|
|
257
|
-
targetPath: selectedTarget.targetPath,
|
|
258
|
-
rootRelativeTargetPath: rootRelativeTargetPath || ".",
|
|
259
|
-
source: selectedTarget.source,
|
|
260
|
-
packageDir: candidate.packageDir,
|
|
261
|
-
packageName: candidate.packageName
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
function filterSkippedCandidates(targetCandidates, skipPackages) {
|
|
265
|
-
if (!skipPackages || skipPackages.length === 0) return {
|
|
266
|
-
includedCandidates: targetCandidates,
|
|
267
|
-
skippedPackages: []
|
|
268
|
-
};
|
|
269
|
-
const skipPackageSet = new Set(skipPackages);
|
|
270
|
-
const includedCandidates = [];
|
|
271
|
-
const skippedPackages = [];
|
|
272
|
-
for (const candidate of targetCandidates) {
|
|
273
|
-
const packageName = candidate.packageName;
|
|
274
|
-
if (packageName && skipPackageSet.has(packageName)) {
|
|
275
|
-
skippedPackages.push(packageName);
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
includedCandidates.push(candidate);
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
includedCandidates,
|
|
282
|
-
skippedPackages
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
async function runOnResolvedTarget(resolvedTarget, write, fs, pathService, versionResolver, sinceWriter, typeScriptTreeWalk, listener) {
|
|
286
|
-
listener?.onTargetStarted(resolvedTarget);
|
|
287
|
-
const absoluteTargetPath = pathService.resolve(resolvedTarget.targetPath);
|
|
288
|
-
if (!fs.existsSync(absoluteTargetPath)) {
|
|
289
|
-
const missingTargetResult = {
|
|
290
|
-
target: resolvedTarget,
|
|
291
|
-
targetExists: false,
|
|
292
|
-
runError: `Not found: ${absoluteTargetPath}`,
|
|
293
|
-
result: null
|
|
294
|
-
};
|
|
295
|
-
listener?.onTargetCompleted(resolvedTarget, missingTargetResult);
|
|
296
|
-
return missingTargetResult;
|
|
297
|
-
}
|
|
298
|
-
try {
|
|
299
|
-
const targetRunResult = {
|
|
300
|
-
target: resolvedTarget,
|
|
301
|
-
targetExists: true,
|
|
302
|
-
runError: null,
|
|
303
|
-
result: runTagOnTarget(absoluteTargetPath, { write }, fs, pathService, versionResolver, sinceWriter, typeScriptTreeWalk)
|
|
304
|
-
};
|
|
305
|
-
listener?.onTargetCompleted(resolvedTarget, targetRunResult);
|
|
306
|
-
return targetRunResult;
|
|
307
|
-
} catch (caughtRunError) {
|
|
308
|
-
const failedTargetRunResult = {
|
|
309
|
-
target: resolvedTarget,
|
|
310
|
-
targetExists: true,
|
|
311
|
-
runError: messageFromCaughtUnknown(caughtRunError),
|
|
312
|
-
result: null
|
|
313
|
-
};
|
|
314
|
-
listener?.onTargetCompleted(resolvedTarget, failedTargetRunResult);
|
|
315
|
-
return failedTargetRunResult;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
_dec = injectable([
|
|
319
|
-
inject(CliFsToken),
|
|
320
|
-
inject(CliPathToken),
|
|
321
|
-
inject(TagTargetResolverPortToken),
|
|
322
|
-
inject(TypeScriptTreeWalkPortToken),
|
|
323
|
-
inject(TagVersionResolverPortToken),
|
|
324
|
-
inject(TagSinceWriterPortToken)
|
|
325
|
-
]);
|
|
326
|
-
let _RunTagSyncUseCaseImpl;
|
|
327
|
-
(class {
|
|
328
|
-
fs;
|
|
329
|
-
path;
|
|
330
|
-
targetResolver;
|
|
331
|
-
typeScriptTreeWalk;
|
|
332
|
-
versionResolver;
|
|
333
|
-
sinceWriter;
|
|
334
|
-
static {
|
|
335
|
-
({c: [_RunTagSyncUseCaseImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
336
|
-
}
|
|
337
|
-
constructor(fs, path, targetResolver, typeScriptTreeWalk, versionResolver, sinceWriter) {
|
|
338
|
-
this.fs = fs;
|
|
339
|
-
this.path = path;
|
|
340
|
-
this.targetResolver = targetResolver;
|
|
341
|
-
this.typeScriptTreeWalk = typeScriptTreeWalk;
|
|
342
|
-
this.versionResolver = versionResolver;
|
|
343
|
-
this.sinceWriter = sinceWriter;
|
|
344
|
-
}
|
|
345
|
-
async execute(input) {
|
|
346
|
-
try {
|
|
347
|
-
const tagConfig = input.config;
|
|
348
|
-
const { includedCandidates, skippedPackages } = filterSkippedCandidates(await this.targetResolver.resolveTagTargetCandidates(input.rootDir, input.targetPath), input.skipPackages);
|
|
349
|
-
const selectedTargets = includedCandidates.map((candidate) => resolveTargetSelection(candidate, input.rootDir, this.path, this.fs));
|
|
350
|
-
const targetExecutionResults = await Promise.all(selectedTargets.map((resolvedTarget) => runOnResolvedTarget(resolvedTarget, input.write, this.fs, this.path, this.versionResolver, this.sinceWriter, this.typeScriptTreeWalk, input.listener)));
|
|
351
|
-
const allFileResults = targetExecutionResults.flatMap((targetResult) => targetResult.result?.fileResults ?? []);
|
|
352
|
-
const filesScanned = targetExecutionResults.reduce((sum, targetResult) => sum + (targetResult.result?.filesScanned ?? 0), 0);
|
|
353
|
-
const filesChanged = targetExecutionResults.reduce((sum, targetResult) => sum + (targetResult.result?.filesChanged ?? 0), 0);
|
|
354
|
-
const taggedDeclarations = targetExecutionResults.reduce((sum, targetResult) => sum + (targetResult.result?.taggedDeclarations ?? 0), 0);
|
|
355
|
-
const modifiedFiles = allFileResults.filter((entry) => entry.changed).map((entry) => entry.filePath);
|
|
356
|
-
const hookError = input.write && modifiedFiles.length > 0 ? await runTagOnAfterWriteHook(tagConfig?.onAfterWrite, modifiedFiles) : null;
|
|
357
|
-
const distinctVersions = [...extractDistinctVersions(targetExecutionResults)].sort((left, right) => left.localeCompare(right));
|
|
358
|
-
return ok({
|
|
359
|
-
mode: input.write ? "applied" : "dry-run",
|
|
360
|
-
selectedTargets,
|
|
361
|
-
resolvedTargets: selectedTargets,
|
|
362
|
-
skippedPackages,
|
|
363
|
-
targetResults: targetExecutionResults,
|
|
364
|
-
filesScanned,
|
|
365
|
-
filesChanged,
|
|
366
|
-
taggedDeclarations,
|
|
367
|
-
versionSummary: summarizeVersions(targetExecutionResults),
|
|
368
|
-
distinctVersions,
|
|
369
|
-
modifiedFiles,
|
|
370
|
-
hookError
|
|
371
|
-
});
|
|
372
|
-
} catch (caughtError) {
|
|
373
|
-
return err(new AppError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
static {
|
|
377
|
-
_initClass();
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
//#endregion
|
|
381
|
-
export { _RunTagSyncUseCaseImpl as RunTagSyncUseCaseImpl };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { token } from "@codefast/di";
|
|
2
|
-
//#region src/lib/tag/contracts/tokens.ts
|
|
3
|
-
const TagTargetResolverPortToken = token("TagTargetResolverPort");
|
|
4
|
-
const TypeScriptTreeWalkPortToken = token("TypeScriptTreeWalkPort");
|
|
5
|
-
const TagSinceWriterPortToken = token("TagSinceWriterPort");
|
|
6
|
-
const TagVersionResolverPortToken = token("TagVersionResolverPort");
|
|
7
|
-
const RunTagSyncUseCaseToken = token("RunTagSyncUseCase");
|
|
8
|
-
const PrepareTagSyncUseCaseToken = token("PrepareTagSyncUseCase");
|
|
9
|
-
//#endregion
|
|
10
|
-
export { PrepareTagSyncUseCaseToken, RunTagSyncUseCaseToken, TagSinceWriterPortToken, TagTargetResolverPortToken, TagVersionResolverPortToken, TypeScriptTreeWalkPortToken };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|