@codefast/cli 0.3.14-canary.0 → 0.3.14-canary.2
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/{commands/arrange.mjs → lib/arrange/adapters/primary/cli/arrange.command.mjs} +32 -33
- package/dist/lib/arrange/adapters/primary/cli/arrange.presentation.module.mjs +14 -0
- package/dist/lib/arrange/adapters/primary/cli/presentation.tokens.mjs +5 -0
- package/dist/lib/arrange/{infra → adapters/secondary}/domain-source-parser.adapter.mjs +5 -8
- package/dist/lib/arrange/{infra → adapters/secondary}/file-walker.adapter.mjs +11 -9
- package/dist/lib/arrange/adapters/secondary/workspace-resolver.adapter.mjs +233 -0
- package/dist/lib/arrange/application/services/arrange-file-processor.service.mjs +37 -12
- package/dist/lib/arrange/application/services/arrange-target-path-resolver.service.mjs +21 -0
- package/dist/lib/arrange/application/services/arrange-target-scanner.service.mjs +10 -4
- package/dist/lib/arrange/application/use-cases/analyze-directory.use-case.mjs +7 -10
- package/dist/lib/arrange/{presentation/prepare-arrange.orchestrator.mjs → application/use-cases/prepare-arrange-workspace.use-case.mjs} +25 -20
- package/dist/lib/arrange/application/use-cases/run-arrange-sync.use-case.mjs +10 -19
- package/dist/lib/arrange/application/use-cases/suggest-cn-groups.use-case.mjs +9 -5
- package/dist/lib/arrange/arrange.module.mjs +17 -13
- package/dist/lib/arrange/contracts/tokens.mjs +6 -5
- package/dist/lib/arrange/domain/arrange-analyze.service.mjs +1 -1
- package/dist/lib/arrange/domain/ast/ast-helpers.helper.mjs +1 -1
- package/dist/lib/arrange/domain/ast/ast-node.model.mjs +1 -21
- package/dist/lib/arrange/domain/ast/collectors-tv.collector.mjs +2 -2
- package/dist/lib/arrange/domain/ast/targets.model.mjs +6 -6
- package/dist/lib/arrange/domain/grouping.domain.mjs +3 -2
- package/dist/lib/arrange/domain/imports.domain.mjs +1 -1
- package/dist/lib/arrange/domain/source-text-formatters.formatter.mjs +19 -2
- package/dist/lib/{tag/presentation/create-tag-progress-listener.presenter.mjs → arrange/domain/tailwind-grouping.service.mjs} +10 -7
- package/dist/lib/arrange/domain/{tokenizer.util.mjs → tailwind-token-classifier.domain-service.mjs} +3 -29
- package/dist/lib/arrange/domain/tailwind-token.value-object.mjs +31 -0
- package/dist/lib/arrange/{infra/ts-ast-translator.adapter.mjs → infrastructure/typescript-ast-translator.adapter.mjs} +2 -2
- package/dist/lib/arrange/presentation/arrange-analyze.presenter.mjs +259 -0
- package/dist/lib/arrange/presentation/arrange-cli.schema.mjs +18 -0
- package/dist/lib/arrange/presentation/arrange-sync.presenter.mjs +23 -2
- package/dist/lib/arrange/presentation/group-file-preview.presenter.mjs +10 -14
- package/dist/lib/bootstrap/composition-root.mjs +33 -0
- package/dist/lib/config/application/services/load-config.service.mjs +17 -0
- package/dist/lib/config/contracts/tokens.mjs +2 -1
- package/dist/lib/config/infrastructure/config-loader.adapter.mjs +306 -0
- package/dist/lib/config/{infra → infrastructure}/config-schema.adapter.mjs +2 -2
- package/dist/lib/{arrange/presentation/present-analyze-report.presenter.mjs → config/infrastructure/config-warning-reporter.adapter.mjs} +9 -8
- package/dist/lib/core/{presentation/try-load-codefast-config.presenter.mjs → application/load-codefast-config.use-case.mjs} +22 -22
- package/dist/lib/core/{presentation/global-cli-options.presenter.mjs → application/services/global-cli-options-parser.service.mjs} +3 -3
- package/dist/lib/core/application/services/schema-validator.service.mjs +17 -0
- package/dist/lib/core/contracts/tokens.mjs +7 -2
- package/dist/lib/core/core.module.mjs +3 -3
- package/dist/lib/core/{application/utils/caught-unknown-message.util.mjs → domain/caught-unknown-message.value-object.mjs} +1 -1
- package/dist/lib/core/domain/errors.domain.mjs +13 -12
- package/dist/lib/core/domain/result.model.mjs +1 -7
- package/dist/lib/core/infrastructure/infrastructure.module.mjs +30 -0
- package/dist/lib/core/infrastructure/path.adapter.mjs +246 -0
- package/dist/lib/core/{infra/logging-decorator.adapter.mjs → infrastructure/port-telemetry.decorator.mjs} +1 -1
- package/dist/lib/core/infrastructure/repo-root-resolver.adapter.mjs +233 -0
- package/dist/lib/core/{application/utils/verbose-diagnostics.util.mjs → infrastructure/verbose-diagnostics.policy.mjs} +1 -1
- package/dist/lib/core/presentation/cli-executor.presenter.mjs +3 -18
- package/dist/lib/core/presentation/cli-schema.parser.mjs +7 -0
- package/dist/lib/core/presentation/presentation.module.mjs +1 -7
- package/dist/lib/{infra → infrastructure}/node-io.adapter.mjs +22 -3
- package/dist/lib/{infra/workspace/repo-root.adapter.mjs → infrastructure/workspace/repo-root-resolver.service.mjs} +1 -1
- package/dist/lib/kernel/contracts/tokens.mjs +5 -0
- package/dist/{commands/mirror.mjs → lib/mirror/adapters/primary/cli/mirror.command.mjs} +17 -12
- package/dist/lib/mirror/{infra → adapters/secondary}/file-system-service.adapter.mjs +14 -9
- package/dist/lib/mirror/{infra → adapters/secondary}/mirror-sync-reporter.adapter.mjs +12 -5
- package/dist/lib/mirror/{infra → adapters/secondary}/package-repository.adapter.mjs +12 -6
- package/dist/lib/mirror/{application/services/sync-workspace-package.service.mjs → adapters/secondary/sync-workspace-package.adapter.mjs} +29 -29
- package/dist/lib/mirror/{infra → adapters/secondary}/workspace-service.adapter.mjs +12 -7
- package/dist/lib/mirror/application/{use-cases/generate-mirror-exports.use-case.mjs → services/generate-mirror-exports.service.mjs} +7 -7
- package/dist/lib/mirror/{presentation/resolve-mirror-package-arg.presenter.mjs → application/services/mirror-package-arg-resolver.service.mjs} +4 -4
- package/dist/lib/mirror/{presentation/prepare-mirror.orchestrator.mjs → application/use-cases/prepare-mirror-sync.use-case.mjs} +23 -22
- package/dist/lib/mirror/application/use-cases/run-mirror-sync.use-case.mjs +12 -12
- package/dist/lib/mirror/contracts/tokens.mjs +3 -3
- package/dist/lib/mirror/domain/package-display-name.policy.mjs +9 -0
- package/dist/lib/mirror/{infra/path-normalizer.adapter.mjs → domain/path-normalizer.value-object.mjs} +1 -1
- package/dist/lib/mirror/{infra/dirent-list.adapter.mjs → infrastructure/dirent-list.guard.mjs} +1 -1
- package/dist/lib/mirror/infrastructure/mirror-console-reporter.presenter.mjs +99 -0
- package/dist/lib/mirror/{infra/package-filter.adapter.mjs → infrastructure/package-filter-resolver.service.mjs} +2 -2
- package/dist/lib/mirror/{infra/update-pkg.adapter.mjs → infrastructure/package-json-exports.repository.mjs} +4 -19
- package/dist/lib/mirror/{infra/workspace-packages.adapter.mjs → infrastructure/workspace-packages.service.mjs} +4 -4
- package/dist/lib/mirror/mirror.module.mjs +17 -15
- package/dist/lib/mirror/presentation/{mirror-cli-schema.presenter.mjs → mirror-cli.schema.mjs} +1 -1
- package/dist/lib/shared/source-code/domain/text-edit.model.mjs +32 -5
- package/dist/lib/shared/source-code/{infra/tsx-file-walk.adapter.mjs → infrastructure/typescript-source-file-walker.service.mjs} +2 -2
- package/dist/lib/tag/adapters/primary/cli/presentation.tokens.mjs +6 -0
- package/dist/{commands/tag.mjs → lib/tag/adapters/primary/cli/tag.command.mjs} +23 -21
- package/dist/lib/tag/adapters/primary/cli/tag.presentation.module.mjs +13 -0
- package/dist/lib/tag/{infra → adapters/secondary}/tag-since-writer.adapter.mjs +12 -7
- package/dist/lib/tag/{infra → adapters/secondary}/tag-target-resolver.adapter.mjs +12 -5
- package/dist/lib/tag/{infra → adapters/secondary}/tag-version-resolver.adapter.mjs +10 -8
- package/dist/lib/tag/{infra → adapters/secondary}/typescript-tree-walk.adapter.mjs +12 -5
- package/dist/lib/tag/{presentation/resolve-tag-cli-target.presenter.mjs → application/services/tag-cli-target-path-resolver.service.mjs} +1 -1
- package/dist/lib/tag/application/services/tag-target-runner.service.mjs +21 -0
- package/dist/lib/tag/{presentation/prepare-tag.orchestrator.mjs → application/use-cases/prepare-tag-sync.use-case.mjs} +23 -23
- package/dist/lib/tag/application/use-cases/run-tag-sync.use-case.mjs +14 -31
- package/dist/lib/tag/contracts/tokens.mjs +2 -4
- package/dist/lib/tag/{infra → infrastructure}/tag-target-candidates.adapter.mjs +4 -4
- package/dist/lib/tag/presentation/present-tag-sync-result.presenter.mjs +1 -1
- package/dist/lib/tag/presentation/{tag-cli-schema.presenter.mjs → tag-cli.schema.mjs} +1 -1
- package/dist/lib/tag/presentation/tag-sync-progress-listener.presenter.mjs +243 -0
- package/dist/lib/tag/presentation/tag-sync.presenter.mjs +6 -23
- package/dist/lib/tag/tag.module.mjs +15 -13
- package/dist/program.mjs +2 -2
- package/package.json +16 -9
- package/dist/lib/arrange/application/arrange-analyze-json.format.mjs +0 -10
- package/dist/lib/arrange/application/arrange-group-json.format.mjs +0 -11
- package/dist/lib/arrange/application/arrange-sync-cli-result.mjs +0 -7
- package/dist/lib/arrange/application/arrange-sync-json.format.mjs +0 -12
- package/dist/lib/arrange/application/use-cases/group-file.use-case.mjs +0 -35
- package/dist/lib/arrange/arrange.feature.module.mjs +0 -19
- package/dist/lib/arrange/arrange.presentation.module.mjs +0 -13
- package/dist/lib/arrange/domain/errors.domain.mjs +0 -18
- package/dist/lib/arrange/infra/ensure-cn-import.adapter.mjs +0 -10
- package/dist/lib/arrange/infra/merge-cn-literal-pool-for-test.test-helper.mjs +0 -18
- package/dist/lib/arrange/presentation/arrange-cli-schema.presenter.mjs +0 -29
- package/dist/lib/arrange/presentation/formatters.presenter.mjs +0 -2
- package/dist/lib/arrange/presentation/present-analyze-cli.presenter.mjs +0 -7
- package/dist/lib/arrange/presentation/report.presenter.mjs +0 -24
- package/dist/lib/arrange/presentation/resolve-arrange-cli-target.presenter.mjs +0 -21
- package/dist/lib/config/application/use-cases/load-config.use-case.mjs +0 -17
- package/dist/lib/config/infra/loader.adapter.mjs +0 -84
- package/dist/lib/core/application/schema-parse.util.mjs +0 -17
- package/dist/lib/core/infra/composition-root.mjs +0 -21
- package/dist/lib/core/infra/infra.module.mjs +0 -23
- package/dist/lib/core/infra/path.adapter.mjs +0 -13
- package/dist/lib/core/operational/contracts/tokens.mjs +0 -7
- package/dist/lib/core/presentation/load-codefast-config.presenter.mjs +0 -18
- package/dist/lib/core/presentation/parse-cli-schema.presenter.mjs +0 -7
- package/dist/lib/infra/config-reporter.adapter.mjs +0 -11
- package/dist/lib/kernel/di/command.token.mjs +0 -5
- package/dist/lib/mirror/contracts/use-cases.contract.mjs +0 -1
- package/dist/lib/mirror/infra/mirror-sync-cli-options.adapter.mjs +0 -1
- package/dist/lib/mirror/mirror.feature.module.mjs +0 -19
- package/dist/lib/mirror/mirror.presentation.module.mjs +0 -11
- package/dist/lib/mirror/presentation/reporter.presenter.mjs +0 -111
- package/dist/lib/tag/contracts/presentation.contract.mjs +0 -1
- package/dist/lib/tag/contracts/use-cases.contract.mjs +0 -1
- package/dist/lib/tag/infra/tag-sync-cli-options.adapter.mjs +0 -1
- package/dist/lib/tag/presentation/resolve-tag-workspace-root.presenter.mjs +0 -12
- package/dist/lib/tag/tag.feature.module.mjs +0 -19
- package/dist/lib/tag/tag.presentation.module.mjs +0 -15
- /package/dist/lib/arrange/{contracts/presentation.contract.mjs → application/ports/workspace-resolver.port.mjs} +0 -0
- /package/dist/lib/arrange/contracts/{use-cases.contract.mjs → analyze-report-presenter.contract.mjs} +0 -0
- /package/dist/lib/{arrange/infra/arrange-sync-cli-options.adapter.mjs → config/application/ports/config-warning-reporter.port.mjs} +0 -0
- /package/dist/lib/core/{contracts/presentation.contract.mjs → application/ports/repo-root-resolver.port.mjs} +0 -0
- /package/dist/lib/core/{presentation/command.interface.mjs → application/ports/runtime.port.mjs} +0 -0
- /package/dist/lib/{infra/fs-contract.port.mjs → kernel/contracts/cli-command.contract.mjs} +0 -0
- /package/dist/lib/{mirror/contracts/presentation.contract.mjs → tag/contracts/tag-sync-result-presenter.contract.mjs} +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import "../domain/constants.domain.mjs";
|
|
2
|
+
import { CliLoggerToken } from "../../core/contracts/tokens.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { inject, injectable } from "@codefast/di";
|
|
5
|
+
//#region src/lib/arrange/presentation/arrange-analyze.presenter.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 printAnalyzeReport(analyzeRootDirectoryPath, analyzeReport, logger) {
|
|
217
|
+
logger.out(`Path: ${path.resolve(analyzeRootDirectoryPath)}`);
|
|
218
|
+
logger.out(`.ts/.tsx files: ${analyzeReport.files}`);
|
|
219
|
+
logger.out(`cn(...) call sites: ${analyzeReport.cnCallExpressions}`);
|
|
220
|
+
logger.out(`tv(...) call sites: ${analyzeReport.tvCallExpressions}`);
|
|
221
|
+
logger.out(`\nLong cn(...) string literals (≥18 tokens — consider splitting arguments): ${analyzeReport.longCnStringLiterals.length}`);
|
|
222
|
+
for (const findingEntry of analyzeReport.longCnStringLiterals.slice(0, 40)) logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
223
|
+
if (analyzeReport.longCnStringLiterals.length > 40) logger.out(` … and ${analyzeReport.longCnStringLiterals.length - 40} more`);
|
|
224
|
+
logger.out(`\nLong tv({...}) string literals in base/variants/… (≥18 tokens): ${analyzeReport.longTvStringLiterals.length}`);
|
|
225
|
+
for (const findingEntry of analyzeReport.longTvStringLiterals.slice(0, 40)) logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
226
|
+
if (analyzeReport.longTvStringLiterals.length > 40) logger.out(` … and ${analyzeReport.longTvStringLiterals.length - 40} more`);
|
|
227
|
+
logger.out(`\nJSX className="..." or className={'...'} (static strings, ≥18 tokens): ${analyzeReport.longJsxClassNameLiterals.length}`);
|
|
228
|
+
for (const findingEntry of analyzeReport.longJsxClassNameLiterals.slice(0, 40)) logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
229
|
+
if (analyzeReport.longJsxClassNameLiterals.length > 40) logger.out(` … and ${analyzeReport.longJsxClassNameLiterals.length - 40} more`);
|
|
230
|
+
logger.out(`\ncn(...) nested inside tv({...}) (prefer a string or array — preview/apply can rewrite): ${analyzeReport.cnInsideTvCalls.length}`);
|
|
231
|
+
for (const findingEntry of analyzeReport.cnInsideTvCalls.slice(0, 40)) logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.argCount} args) ${findingEntry.preview}`);
|
|
232
|
+
if (analyzeReport.cnInsideTvCalls.length > 40) logger.out(` … and ${analyzeReport.cnInsideTvCalls.length - 40} more`);
|
|
233
|
+
}
|
|
234
|
+
_dec = injectable([inject(CliLoggerToken)]);
|
|
235
|
+
let _PresentAnalyzeReportPresenterImpl;
|
|
236
|
+
(class {
|
|
237
|
+
logger;
|
|
238
|
+
static {
|
|
239
|
+
({c: [_PresentAnalyzeReportPresenterImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
240
|
+
}
|
|
241
|
+
constructor(logger) {
|
|
242
|
+
this.logger = logger;
|
|
243
|
+
}
|
|
244
|
+
present(resolvedTargetPath, report) {
|
|
245
|
+
printAnalyzeReport(resolvedTargetPath, report, this.logger);
|
|
246
|
+
}
|
|
247
|
+
static {
|
|
248
|
+
_initClass();
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
function formatArrangeAnalyzeJsonOutput(analyzeRootPath, report) {
|
|
252
|
+
return JSON.stringify({
|
|
253
|
+
schemaVersion: 1,
|
|
254
|
+
analyzeRootPath,
|
|
255
|
+
report
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
export { _PresentAnalyzeReportPresenterImpl as PresentAnalyzeReportPresenterImpl, formatArrangeAnalyzeJsonOutput };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/lib/arrange/presentation/arrange-cli.schema.ts
|
|
3
|
+
const arrangeAnalyzeDirectoryRequestSchema = z.object({ analyzeRootPath: z.string().min(1, "analyzeRootPath is required") });
|
|
4
|
+
const arrangeSyncRunRequestSchema = z.object({
|
|
5
|
+
rootDir: z.string().min(1),
|
|
6
|
+
targetPath: z.string().min(1),
|
|
7
|
+
write: z.boolean(),
|
|
8
|
+
withClassName: z.boolean().optional(),
|
|
9
|
+
cnImport: z.string().optional(),
|
|
10
|
+
config: z.unknown().optional()
|
|
11
|
+
});
|
|
12
|
+
const arrangeSuggestGroupsRequestSchema = z.object({
|
|
13
|
+
inlineClasses: z.string().min(1, "Pass a class string. Example: codefast arrange group \"flex gap-2 text-sm rounded-md\""),
|
|
14
|
+
emitTvStyleArray: z.boolean(),
|
|
15
|
+
trailingClassName: z.boolean()
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { arrangeAnalyzeDirectoryRequestSchema, arrangeSuggestGroupsRequestSchema, arrangeSyncRunRequestSchema };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../core/domain/cli-exit-codes.domain.mjs";
|
|
2
2
|
//#region src/lib/arrange/presentation/arrange-sync.presenter.ts
|
|
3
|
+
function exitCodeForArrangeSyncResult(result) {
|
|
4
|
+
return result.hookError !== null ? 1 : 0;
|
|
5
|
+
}
|
|
3
6
|
function presentArrangeSyncResult(logger, result, write) {
|
|
4
7
|
logger.out(`\nTotal: ${result.filePaths.length} file(s), ${result.totalFound} site(s) (cn/tv/JSX className) to review.`);
|
|
5
8
|
if (write) logger.out(`Applied: ${result.totalChanged} site(s) updated.`);
|
|
@@ -8,5 +11,23 @@ function presentArrangeSyncResult(logger, result, write) {
|
|
|
8
11
|
if (result.hookError !== null) logger.err(result.hookError);
|
|
9
12
|
return exitCodeForArrangeSyncResult(result);
|
|
10
13
|
}
|
|
14
|
+
function formatArrangeSyncJsonOutput(result, write) {
|
|
15
|
+
const { previewPlans: _plans, ...serializableResult } = result;
|
|
16
|
+
const payload = {
|
|
17
|
+
schemaVersion: 1,
|
|
18
|
+
ok: result.hookError === null,
|
|
19
|
+
write,
|
|
20
|
+
result: serializableResult
|
|
21
|
+
};
|
|
22
|
+
return JSON.stringify(payload);
|
|
23
|
+
}
|
|
24
|
+
function formatArrangeGroupJsonOutput(output) {
|
|
25
|
+
const payload = {
|
|
26
|
+
schemaVersion: 1,
|
|
27
|
+
primaryLine: output.primaryLine,
|
|
28
|
+
bucketsCommentLine: output.bucketsCommentLine
|
|
29
|
+
};
|
|
30
|
+
return JSON.stringify(payload);
|
|
31
|
+
}
|
|
11
32
|
//#endregion
|
|
12
|
-
export { presentArrangeSyncResult };
|
|
33
|
+
export { exitCodeForArrangeSyncResult, formatArrangeGroupJsonOutput, formatArrangeSyncJsonOutput, presentArrangeSyncResult };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliLoggerToken } from "../../core/
|
|
1
|
+
import { CliLoggerToken } from "../../core/contracts/tokens.mjs";
|
|
2
2
|
import { lineOf } from "../domain/ast/ast-helpers.helper.mjs";
|
|
3
3
|
import { inject, injectable } from "@codefast/di";
|
|
4
4
|
//#region src/lib/arrange/presentation/group-file-preview.presenter.ts
|
|
@@ -213,29 +213,28 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
213
213
|
}
|
|
214
214
|
let _dec, _initClass;
|
|
215
215
|
function printGroupFilePreview(logger, args) {
|
|
216
|
-
const { out } = logger;
|
|
217
216
|
const { filePath, reportTotal, cnInTvNoReplacement, cnInTvCalls, unwrapReplacementByCall, sourceText, domainSf, unwrapEdits, plannedGroupEdits } = args;
|
|
218
217
|
let header = `\n── ${filePath} (${reportTotal} site(s)`;
|
|
219
218
|
if (cnInTvNoReplacement > 0) header += `; plus ${cnInTvNoReplacement} cn() inside tv left unchanged (0 args)`;
|
|
220
219
|
header += `) ──`;
|
|
221
|
-
out(header);
|
|
220
|
+
logger.out(header);
|
|
222
221
|
for (const call of cnInTvCalls) {
|
|
223
222
|
const replacement = unwrapReplacementByCall.get(call);
|
|
224
223
|
if (replacement === void 0) {
|
|
225
|
-
out(` Line ${lineOf(domainSf, call)} [tv ⊃ cn]: cn(...) has no arguments — skipped`);
|
|
224
|
+
logger.out(` Line ${lineOf(domainSf, call)} [tv ⊃ cn]: cn(...) has no arguments — skipped`);
|
|
226
225
|
continue;
|
|
227
226
|
}
|
|
228
227
|
const start = call.pos;
|
|
229
228
|
const end = call.end;
|
|
230
229
|
if (sourceText.slice(start, end) === replacement) continue;
|
|
231
|
-
out(` Line ${lineOf(domainSf, call)} [tv ⊃ cn → string/array]:`);
|
|
232
|
-
out(` ${replacement.split("\n").join("\n ")}`);
|
|
230
|
+
logger.out(` Line ${lineOf(domainSf, call)} [tv ⊃ cn → string/array]:`);
|
|
231
|
+
logger.out(` ${replacement.split("\n").join("\n ")}`);
|
|
233
232
|
}
|
|
234
|
-
if (unwrapEdits.length > 0 && plannedGroupEdits.length > 0) out(" ([cn] / [tv] / [JSX className] lines below reflect content after unwrap of cn inside tv.)");
|
|
233
|
+
if (unwrapEdits.length > 0 && plannedGroupEdits.length > 0) logger.out(" ([cn] / [tv] / [JSX className] lines below reflect content after unwrap of cn inside tv.)");
|
|
235
234
|
for (const plan of plannedGroupEdits) {
|
|
236
|
-
out(` Line ${lineOf(plan.lineSf, plan.reportNode)} [${plan.label}]:`);
|
|
237
|
-
out(` ${plan.replacement.split("\n").join("\n ")}`);
|
|
238
|
-
out(` // Buckets: ${JSON.stringify(plan.bucketSummary)}`);
|
|
235
|
+
logger.out(` Line ${lineOf(plan.lineSf, plan.reportNode)} [${plan.label}]:`);
|
|
236
|
+
logger.out(` ${plan.replacement.split("\n").join("\n ")}`);
|
|
237
|
+
logger.out(` // Buckets: ${JSON.stringify(plan.bucketSummary)}`);
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
240
|
function printGroupFilePreviewFromWork(logger, work) {
|
|
@@ -251,9 +250,6 @@ function printGroupFilePreviewFromWork(logger, work) {
|
|
|
251
250
|
plannedGroupEdits: work.plannedGroupEdits
|
|
252
251
|
});
|
|
253
252
|
}
|
|
254
|
-
function createGroupFilePreviewPresenter(logger) {
|
|
255
|
-
return { printGroupFilePreviewFromWork: (work) => printGroupFilePreviewFromWork(logger, work) };
|
|
256
|
-
}
|
|
257
253
|
_dec = injectable([inject(CliLoggerToken)]);
|
|
258
254
|
let _GroupFilePreviewPresenterAdapter;
|
|
259
255
|
(class {
|
|
@@ -272,4 +268,4 @@ let _GroupFilePreviewPresenterAdapter;
|
|
|
272
268
|
}
|
|
273
269
|
});
|
|
274
270
|
//#endregion
|
|
275
|
-
export { _GroupFilePreviewPresenterAdapter as GroupFilePreviewPresenterAdapter
|
|
271
|
+
export { _GroupFilePreviewPresenterAdapter as GroupFilePreviewPresenterAdapter };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ArrangeCommand as _ArrangeCommand } from "../arrange/adapters/primary/cli/arrange.command.mjs";
|
|
2
|
+
import { ArrangePresentationModule } from "../arrange/adapters/primary/cli/arrange.presentation.module.mjs";
|
|
3
|
+
import { ArrangeModule } from "../arrange/arrange.module.mjs";
|
|
4
|
+
import { MirrorCommand as _MirrorCommand } from "../mirror/adapters/primary/cli/mirror.command.mjs";
|
|
5
|
+
import { MirrorModule } from "../mirror/mirror.module.mjs";
|
|
6
|
+
import { TagCommand as _TagCommand } from "../tag/adapters/primary/cli/tag.command.mjs";
|
|
7
|
+
import { TagPresentationModule } from "../tag/adapters/primary/cli/tag.presentation.module.mjs";
|
|
8
|
+
import { TagModule } from "../tag/tag.module.mjs";
|
|
9
|
+
import { CliCommandToken } from "../kernel/contracts/tokens.mjs";
|
|
10
|
+
import { Container } from "@codefast/di";
|
|
11
|
+
//#region src/lib/bootstrap/composition-root.ts
|
|
12
|
+
function createCliRuntimeContainer() {
|
|
13
|
+
const runtimeContainer = Container.create();
|
|
14
|
+
runtimeContainer.load(ArrangePresentationModule, ArrangeModule);
|
|
15
|
+
runtimeContainer.bind(_ArrangeCommand).to(_ArrangeCommand).singleton();
|
|
16
|
+
runtimeContainer.bind(CliCommandToken).to(_ArrangeCommand).whenNamed("arrange").singleton();
|
|
17
|
+
runtimeContainer.load(MirrorModule);
|
|
18
|
+
runtimeContainer.bind(_MirrorCommand).to(_MirrorCommand).singleton();
|
|
19
|
+
runtimeContainer.bind(CliCommandToken).to(_MirrorCommand).whenNamed("mirror").singleton();
|
|
20
|
+
runtimeContainer.load(TagPresentationModule, TagModule);
|
|
21
|
+
runtimeContainer.bind(_TagCommand).to(_TagCommand).singleton();
|
|
22
|
+
runtimeContainer.bind(CliCommandToken).to(_TagCommand).whenNamed("tag").singleton();
|
|
23
|
+
return runtimeContainer;
|
|
24
|
+
}
|
|
25
|
+
function resolveCliCommands(runtimeContainer) {
|
|
26
|
+
return [
|
|
27
|
+
runtimeContainer.resolve(_ArrangeCommand),
|
|
28
|
+
runtimeContainer.resolve(_MirrorCommand),
|
|
29
|
+
runtimeContainer.resolve(_TagCommand)
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { createCliRuntimeContainer, resolveCliCommands };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppError } from "../../../core/domain/errors.domain.mjs";
|
|
2
|
+
import { err, ok } from "../../../core/domain/result.model.mjs";
|
|
3
|
+
import { messageFromCaughtUnknown } from "../../../core/domain/caught-unknown-message.value-object.mjs";
|
|
4
|
+
//#region src/lib/config/application/services/load-config.service.ts
|
|
5
|
+
async function loadCodefastConfig(configLoader, rootDir) {
|
|
6
|
+
try {
|
|
7
|
+
const { config, warnings } = await configLoader.loadConfig(rootDir);
|
|
8
|
+
return ok({
|
|
9
|
+
config,
|
|
10
|
+
warnings
|
|
11
|
+
});
|
|
12
|
+
} catch (caughtError) {
|
|
13
|
+
return err(new AppError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { loadCodefastConfig };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { token } from "@codefast/di";
|
|
2
2
|
//#region src/lib/config/contracts/tokens.ts
|
|
3
3
|
const ConfigLoaderPortToken = token("ConfigLoaderPort");
|
|
4
|
+
const ConfigWarningReporterPortToken = token("ConfigWarningReporterPort");
|
|
4
5
|
//#endregion
|
|
5
|
-
export { ConfigLoaderPortToken };
|
|
6
|
+
export { ConfigLoaderPortToken, ConfigWarningReporterPortToken };
|