@codefast/cli 0.3.14-canary.1 → 0.3.14
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
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CliFsToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
+
import { isDirentList } from "../../infrastructure/dirent-list.guard.mjs";
|
|
3
|
+
import { normalizePath } from "../../domain/path-normalizer.value-object.mjs";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import { injectable } from "@codefast/di";
|
|
5
|
-
//#region src/lib/mirror/
|
|
5
|
+
import { inject, injectable } from "@codefast/di";
|
|
6
|
+
//#region src/lib/mirror/adapters/secondary/file-system-service.adapter.ts
|
|
6
7
|
function toPrimitive(input, hint) {
|
|
7
8
|
if (typeof input !== "object" || input === null) return input;
|
|
8
9
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -216,15 +217,19 @@ let _dec, _initClass;
|
|
|
216
217
|
function isKnownReadDirError(caughtError) {
|
|
217
218
|
return typeof caughtError === "object" && caughtError !== null && "code" in caughtError && (caughtError.code === "ENOENT" || caughtError.code === "EACCES");
|
|
218
219
|
}
|
|
219
|
-
_dec = injectable([]);
|
|
220
|
+
_dec = injectable([inject(CliFsToken)]);
|
|
220
221
|
let _FileSystemServiceAdapter;
|
|
221
222
|
(class {
|
|
223
|
+
fs;
|
|
222
224
|
static {
|
|
223
225
|
({c: [_FileSystemServiceAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
224
226
|
}
|
|
225
|
-
|
|
227
|
+
constructor(fs) {
|
|
228
|
+
this.fs = fs;
|
|
229
|
+
}
|
|
230
|
+
async listRelativeFilesRecursively(dirPath) {
|
|
226
231
|
try {
|
|
227
|
-
const raw = await fs.readdir(dirPath, {
|
|
232
|
+
const raw = await this.fs.readdir(dirPath, {
|
|
228
233
|
recursive: true,
|
|
229
234
|
withFileTypes: true
|
|
230
235
|
});
|
|
@@ -238,9 +243,9 @@ let _FileSystemServiceAdapter;
|
|
|
238
243
|
throw caughtError;
|
|
239
244
|
}
|
|
240
245
|
}
|
|
241
|
-
async isDirectoryCssOnly(
|
|
246
|
+
async isDirectoryCssOnly(distDir, dirPath) {
|
|
242
247
|
try {
|
|
243
|
-
const raw = await fs.readdir(path.join(distDir, dirPath), { withFileTypes: true });
|
|
248
|
+
const raw = await this.fs.readdir(path.join(distDir, dirPath), { withFileTypes: true });
|
|
244
249
|
if (!isDirentList(raw)) return false;
|
|
245
250
|
if (raw.length === 0) return true;
|
|
246
251
|
return raw.every((dirent) => dirent.isFile() && dirent.name.endsWith(".css"));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { CliRuntimeToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
+
import { configureMirrorColors, logPackageError, logPackageSuccess, logPrunedStaleExport, logSkippedWorkspacePackage, mirrorBanner, mirrorGlobWarning, mirrorNoPackages, mirrorProcessingMode, mirrorSummary, mirrorSummarySeparator } from "../../infrastructure/mirror-console-reporter.presenter.mjs";
|
|
3
|
+
import { inject, injectable } from "@codefast/di";
|
|
4
|
+
//#region src/lib/mirror/adapters/secondary/mirror-sync-reporter.adapter.ts
|
|
4
5
|
function toPrimitive(input, hint) {
|
|
5
6
|
if (typeof input !== "object" || input === null) return input;
|
|
6
7
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -211,13 +212,19 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
211
212
|
};
|
|
212
213
|
}
|
|
213
214
|
let _dec, _initClass;
|
|
214
|
-
_dec = injectable([]);
|
|
215
|
+
_dec = injectable([inject(CliRuntimeToken)]);
|
|
215
216
|
let _MirrorSyncReporterAdapter;
|
|
216
217
|
(class {
|
|
218
|
+
runtime;
|
|
217
219
|
static {
|
|
218
220
|
({c: [_MirrorSyncReporterAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
219
221
|
}
|
|
220
|
-
|
|
222
|
+
constructor(runtime) {
|
|
223
|
+
this.runtime = runtime;
|
|
224
|
+
}
|
|
225
|
+
configureMirrorColors(noColor) {
|
|
226
|
+
configureMirrorColors(noColor, this.runtime.isStdoutTty());
|
|
227
|
+
}
|
|
221
228
|
mirrorBanner = mirrorBanner;
|
|
222
229
|
mirrorProcessingMode = mirrorProcessingMode;
|
|
223
230
|
mirrorNoPackages = mirrorNoPackages;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { CliFsToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
+
import { resolvePackageDisplayName } from "../../domain/package-display-name.policy.mjs";
|
|
3
|
+
import { writePackageJsonExportsAtomic } from "../../infrastructure/package-json-exports.repository.mjs";
|
|
4
|
+
import { inject, injectable } from "@codefast/di";
|
|
5
|
+
//#region src/lib/mirror/adapters/secondary/package-repository.adapter.ts
|
|
4
6
|
function toPrimitive(input, hint) {
|
|
5
7
|
if (typeof input !== "object" || input === null) return input;
|
|
6
8
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -211,17 +213,21 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
211
213
|
};
|
|
212
214
|
}
|
|
213
215
|
let _dec, _initClass;
|
|
214
|
-
_dec = injectable([]);
|
|
216
|
+
_dec = injectable([inject(CliFsToken)]);
|
|
215
217
|
let _PackageRepositoryAdapter;
|
|
216
218
|
(class {
|
|
219
|
+
fs;
|
|
217
220
|
static {
|
|
218
221
|
({c: [_PackageRepositoryAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
219
222
|
}
|
|
223
|
+
constructor(fs) {
|
|
224
|
+
this.fs = fs;
|
|
225
|
+
}
|
|
220
226
|
resolvePackageDisplayName(packageJson, folderBasename) {
|
|
221
227
|
return resolvePackageDisplayName(packageJson, folderBasename);
|
|
222
228
|
}
|
|
223
|
-
writePackageJsonExportsAtomic(
|
|
224
|
-
return writePackageJsonExportsAtomic(fs, packageJsonPath, mergeInput);
|
|
229
|
+
writePackageJsonExportsAtomic(packageJsonPath, mergeInput) {
|
|
230
|
+
return writePackageJsonExportsAtomic(this.fs, packageJsonPath, mergeInput);
|
|
225
231
|
}
|
|
226
232
|
parsePackageJsonShape(rawPackageJson) {
|
|
227
233
|
if (rawPackageJson === null || typeof rawPackageJson !== "object" || Array.isArray(rawPackageJson)) throw new SyntaxError("package.json root must be a JSON object");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CliFsToken, CliLoggerToken, CliPathToken } from "../../../core/
|
|
2
|
-
import { messageFromCaughtUnknown } from "../../../core/
|
|
1
|
+
import { CliFsToken, CliLoggerToken, CliPathToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
+
import { messageFromCaughtUnknown } from "../../../core/domain/caught-unknown-message.value-object.mjs";
|
|
3
3
|
import { FileSystemServicePortToken, MirrorSyncReporterPortToken, PackageRepositoryPortToken } from "../../contracts/tokens.mjs";
|
|
4
4
|
import { DIST_DIR, PACKAGE_JSON } from "../../domain/constants.domain.mjs";
|
|
5
|
-
import { createPathTransform, generateExports } from "
|
|
6
|
-
import { injectable } from "@codefast/di";
|
|
7
|
-
//#region src/lib/mirror/
|
|
5
|
+
import { createPathTransform, generateExports } from "../../application/services/generate-mirror-exports.service.mjs";
|
|
6
|
+
import { inject, injectable } from "@codefast/di";
|
|
7
|
+
//#region src/lib/mirror/adapters/secondary/sync-workspace-package.adapter.ts
|
|
8
8
|
function toPrimitive(input, hint) {
|
|
9
9
|
if (typeof input !== "object" || input === null) return input;
|
|
10
10
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -215,23 +215,23 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
let _dec, _initClass;
|
|
218
|
-
function resolvePackageScopedConfig(configMap,
|
|
218
|
+
function resolvePackageScopedConfig(configMap, packageMeta) {
|
|
219
219
|
if (!configMap) return;
|
|
220
|
-
return configMap[
|
|
220
|
+
return configMap[packageMeta.packageName];
|
|
221
221
|
}
|
|
222
|
-
function isPackageSkipped(
|
|
223
|
-
if (!
|
|
224
|
-
return
|
|
222
|
+
function isPackageSkipped(skipPackagesList, packageMeta) {
|
|
223
|
+
if (!skipPackagesList) return false;
|
|
224
|
+
return skipPackagesList.includes(packageMeta.packageName);
|
|
225
225
|
}
|
|
226
226
|
_dec = injectable([
|
|
227
|
-
CliFsToken,
|
|
228
|
-
CliPathToken,
|
|
229
|
-
PackageRepositoryPortToken,
|
|
230
|
-
FileSystemServicePortToken,
|
|
231
|
-
CliLoggerToken,
|
|
232
|
-
MirrorSyncReporterPortToken
|
|
227
|
+
inject(CliFsToken),
|
|
228
|
+
inject(CliPathToken),
|
|
229
|
+
inject(PackageRepositoryPortToken),
|
|
230
|
+
inject(FileSystemServicePortToken),
|
|
231
|
+
inject(CliLoggerToken),
|
|
232
|
+
inject(MirrorSyncReporterPortToken)
|
|
233
233
|
]);
|
|
234
|
-
let
|
|
234
|
+
let _SyncWorkspacePackageAdapter;
|
|
235
235
|
(class {
|
|
236
236
|
fs;
|
|
237
237
|
pathService;
|
|
@@ -240,7 +240,7 @@ let _SyncWorkspacePackageServiceImpl;
|
|
|
240
240
|
logger;
|
|
241
241
|
mirrorReporter;
|
|
242
242
|
static {
|
|
243
|
-
({c: [
|
|
243
|
+
({c: [_SyncWorkspacePackageAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
244
244
|
}
|
|
245
245
|
constructor(fs, pathService, packageRepository, fileSystemService, logger, mirrorReporter) {
|
|
246
246
|
this.fs = fs;
|
|
@@ -277,16 +277,16 @@ let _SyncWorkspacePackageServiceImpl;
|
|
|
277
277
|
}
|
|
278
278
|
let packageJsonParseError;
|
|
279
279
|
try {
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
const parsedPackageJson = this.packageRepository.parsePackageJsonShape(
|
|
280
|
+
const packageContent = await this.fs.readFile(packageJsonPath, "utf8");
|
|
281
|
+
const rawPackageJson = JSON.parse(packageContent);
|
|
282
|
+
const parsedPackageJson = this.packageRepository.parsePackageJsonShape(rawPackageJson);
|
|
283
283
|
pkgStats.name = this.packageRepository.resolvePackageDisplayName(parsedPackageJson, folderBasename);
|
|
284
284
|
} catch (caughtError) {
|
|
285
285
|
pkgStats.name = folderBasename;
|
|
286
286
|
packageJsonParseError = caughtError;
|
|
287
287
|
}
|
|
288
|
-
const
|
|
289
|
-
if (isPackageSkipped(config.skipPackages,
|
|
288
|
+
const packageMeta = { packageName: pkgStats.name };
|
|
289
|
+
if (isPackageSkipped(config.skipPackages, packageMeta)) {
|
|
290
290
|
pkgStats.skipped = true;
|
|
291
291
|
pkgStats.skipReason = "configured to skip";
|
|
292
292
|
stats.packagesSkipped++;
|
|
@@ -314,14 +314,14 @@ let _SyncWorkspacePackageServiceImpl;
|
|
|
314
314
|
return pkgStats;
|
|
315
315
|
}
|
|
316
316
|
try {
|
|
317
|
-
const pathTransform = createPathTransform(config,
|
|
317
|
+
const pathTransform = createPathTransform(config, packageMeta);
|
|
318
318
|
pkgStats.hasTransform = !!pathTransform;
|
|
319
|
-
const cssConfig = resolvePackageScopedConfig(config.cssExports,
|
|
319
|
+
const cssConfig = resolvePackageScopedConfig(config.cssExports, packageMeta);
|
|
320
320
|
if (cssConfig === false) pkgStats.cssConfigStatus = "disabled";
|
|
321
321
|
else if (cssConfig !== void 0) pkgStats.cssConfigStatus = "configured";
|
|
322
|
-
const customExports = resolvePackageScopedConfig(config.customExports,
|
|
323
|
-
const generatedExports = await generateExports(this.
|
|
324
|
-
const { prunedKeys } = await this.packageRepository.writePackageJsonExportsAtomic(
|
|
322
|
+
const customExports = resolvePackageScopedConfig(config.customExports, packageMeta) || {};
|
|
323
|
+
const generatedExports = await generateExports(this.pathService, this.fileSystemService, distDir, pathTransform, cssConfig, customExports);
|
|
324
|
+
const { prunedKeys } = await this.packageRepository.writePackageJsonExportsAtomic(packageJsonPath, {
|
|
325
325
|
generatedExports: generatedExports.exports,
|
|
326
326
|
managedExportSpecifiers: Object.keys(generatedExports.exports),
|
|
327
327
|
originalPathBySpecifier: generatedExports.originalPathBySpecifier
|
|
@@ -348,4 +348,4 @@ let _SyncWorkspacePackageServiceImpl;
|
|
|
348
348
|
}
|
|
349
349
|
});
|
|
350
350
|
//#endregion
|
|
351
|
-
export {
|
|
351
|
+
export { _SyncWorkspacePackageAdapter as SyncWorkspacePackageAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { CliFsToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
+
import { resolvePackageFilterUnderRoot } from "../../infrastructure/package-filter-resolver.service.mjs";
|
|
3
|
+
import { findWorkspacePackageRelPaths } from "../../infrastructure/workspace-packages.service.mjs";
|
|
4
|
+
import { inject, injectable } from "@codefast/di";
|
|
5
|
+
//#region src/lib/mirror/adapters/secondary/workspace-service.adapter.ts
|
|
5
6
|
function toPrimitive(input, hint) {
|
|
6
7
|
if (typeof input !== "object" || input === null) return input;
|
|
7
8
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -212,17 +213,21 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
212
213
|
};
|
|
213
214
|
}
|
|
214
215
|
let _dec, _initClass;
|
|
215
|
-
_dec = injectable([]);
|
|
216
|
+
_dec = injectable([inject(CliFsToken)]);
|
|
216
217
|
let _WorkspaceServiceAdapter;
|
|
217
218
|
(class {
|
|
219
|
+
fs;
|
|
218
220
|
static {
|
|
219
221
|
({c: [_WorkspaceServiceAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
220
222
|
}
|
|
223
|
+
constructor(fs) {
|
|
224
|
+
this.fs = fs;
|
|
225
|
+
}
|
|
221
226
|
resolvePackageFilterUnderRoot(rootDir, packageFilter) {
|
|
222
227
|
return resolvePackageFilterUnderRoot(rootDir, packageFilter);
|
|
223
228
|
}
|
|
224
|
-
findWorkspacePackageRelPaths(rootDir,
|
|
225
|
-
return findWorkspacePackageRelPaths(rootDir, fs, onGlobWarning);
|
|
229
|
+
findWorkspacePackageRelPaths(rootDir, onGlobWarning) {
|
|
230
|
+
return findWorkspacePackageRelPaths(rootDir, this.fs, onGlobWarning);
|
|
226
231
|
}
|
|
227
232
|
static {
|
|
228
233
|
_initClass();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_JSON_EXPORT, VALID_DTS_EXTENSIONS, VALID_JS_EXTENSIONS } from "../../domain/constants.domain.mjs";
|
|
2
|
-
//#region src/lib/mirror/application/
|
|
2
|
+
//#region src/lib/mirror/application/services/generate-mirror-exports.service.ts
|
|
3
3
|
function resolvePackageScopedConfig(configMap, pkgMeta) {
|
|
4
4
|
if (!configMap) return;
|
|
5
5
|
return configMap[pkgMeta.packageName];
|
|
@@ -131,11 +131,11 @@ function compareTuples(left, right) {
|
|
|
131
131
|
if (left[3] !== right[3]) return left[3] < right[3] ? -1 : 1;
|
|
132
132
|
return 0;
|
|
133
133
|
}
|
|
134
|
-
async function generateCssExports(
|
|
134
|
+
async function generateCssExports(pathService, fileSystemService, distDir, cssConfig) {
|
|
135
135
|
if (cssConfig === false) return {};
|
|
136
136
|
if (cssConfig === true) cssConfig = { enabled: true };
|
|
137
137
|
if (!cssConfig || cssConfig.enabled === false) return {};
|
|
138
|
-
const cssFiles = (await fileSystemService.listRelativeFilesRecursively(
|
|
138
|
+
const cssFiles = (await fileSystemService.listRelativeFilesRecursively(distDir)).filter((relativeDistPath) => relativeDistPath.endsWith(".css"));
|
|
139
139
|
if (!cssFiles.length) return {};
|
|
140
140
|
const cssExports = { ...cssConfig.customExports };
|
|
141
141
|
const cssByDir = /* @__PURE__ */ new Map();
|
|
@@ -153,7 +153,7 @@ async function generateCssExports(fs, pathService, fileSystemService, distDir, c
|
|
|
153
153
|
const exportPath = `./${file}`;
|
|
154
154
|
if (!(exportPath in cssExports)) cssExports[exportPath] = `./dist/${file}`;
|
|
155
155
|
}
|
|
156
|
-
for (const [dirName, dirFiles] of cssByDir.entries()) if (await fileSystemService.isDirectoryCssOnly(
|
|
156
|
+
for (const [dirName, dirFiles] of cssByDir.entries()) if (await fileSystemService.isDirectoryCssOnly(distDir, dirName) && !cssConfig.forceExportFiles) {
|
|
157
157
|
const wildcardExport = `./${dirName}/*`;
|
|
158
158
|
if (!(wildcardExport in cssExports)) cssExports[wildcardExport] = `./dist/${dirName}/*`;
|
|
159
159
|
} else for (const file of dirFiles) {
|
|
@@ -164,8 +164,8 @@ async function generateCssExports(fs, pathService, fileSystemService, distDir, c
|
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
166
166
|
* Compute `package.json#exports` from a built `dist/` tree. No logging; no writes.
|
|
167
|
-
*/ async function generateExports(
|
|
168
|
-
const files = await fileSystemService.listRelativeFilesRecursively(
|
|
167
|
+
*/ async function generateExports(pathService, fileSystemService, distDir, pathTransform, cssConfig, customExports) {
|
|
168
|
+
const files = await fileSystemService.listRelativeFilesRecursively(distDir);
|
|
169
169
|
if (!files.length) return {
|
|
170
170
|
exports: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
171
171
|
originalPathBySpecifier: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
@@ -198,7 +198,7 @@ async function generateCssExports(fs, pathService, fileSystemService, distDir, c
|
|
|
198
198
|
let sortedKeys = Object.keys(exportsObj).sort((pathA, pathB) => compareTuples(getSortTuple(pathA, pathTransform), getSortTuple(pathB, pathTransform)));
|
|
199
199
|
const sortedExports = {};
|
|
200
200
|
for (const exportKey of sortedKeys) sortedExports[exportKey] = exportsObj[exportKey];
|
|
201
|
-
const cssExports = await generateCssExports(
|
|
201
|
+
const cssExports = await generateCssExports(pathService, fileSystemService, distDir, cssConfig ?? { enabled: true });
|
|
202
202
|
Object.assign(sortedExports, cssExports);
|
|
203
203
|
for (const [specifier, mappedPath] of Object.entries(customExports || {})) if (specifier !== "./package.json") sortedExports[specifier] = mappedPath;
|
|
204
204
|
for (const cssSpecifier of Object.keys(cssExports)) if (!(cssSpecifier in originalPathBySpecifier)) originalPathBySpecifier[cssSpecifier] = cssSpecifier;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { err, ok } from "
|
|
1
|
+
import { AppError } from "../../../core/domain/errors.domain.mjs";
|
|
2
|
+
import { err, ok } from "../../../core/domain/result.model.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
//#region src/lib/mirror/
|
|
4
|
+
//#region src/lib/mirror/application/services/mirror-package-arg-resolver.service.ts
|
|
5
5
|
function normalizePathSegments(relPath) {
|
|
6
6
|
return relPath.split(path.sep).join("/").replace(/\\/g, "/");
|
|
7
7
|
}
|
|
@@ -13,7 +13,7 @@ function resolveMirrorPackageArgToRelative(input) {
|
|
|
13
13
|
const resolved = path.isAbsolute(packageArg) ? path.resolve(packageArg) : path.resolve(cwdReal, packageArg);
|
|
14
14
|
const targetReal = fs.canonicalPathSync(resolved);
|
|
15
15
|
const normalized = normalizePathSegments(path.relative(rootReal, targetReal));
|
|
16
|
-
if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") return err(
|
|
16
|
+
if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") return err(new AppError("VALIDATION_ERROR", `Package path must be a subdirectory under monorepo root: ${rootDir}`));
|
|
17
17
|
return ok(normalized);
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { CliFsToken } from "
|
|
2
|
-
import {
|
|
3
|
-
import { err, ok } from "
|
|
4
|
-
import { messageFromCaughtUnknown } from "
|
|
5
|
-
import {
|
|
6
|
-
import { TryLoadCodefastConfigPresenterToken } from "../../core/contracts/tokens.mjs";
|
|
7
|
-
import { parseGlobalCliOptions } from "../../core/presentation/global-cli-options.presenter.mjs";
|
|
8
|
-
import { resolveMirrorPackageArgToRelative } from "./resolve-mirror-package-arg.presenter.mjs";
|
|
1
|
+
import { CliFsToken, LoadCodefastConfigUseCaseToken, RepoRootResolverPortToken } 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 { resolveMirrorPackageArgToRelative } from "../services/mirror-package-arg-resolver.service.mjs";
|
|
9
6
|
import { inject, injectable } from "@codefast/di";
|
|
10
|
-
//#region src/lib/mirror/
|
|
7
|
+
//#region src/lib/mirror/application/use-cases/prepare-mirror-sync.use-case.ts
|
|
11
8
|
function toPrimitive(input, hint) {
|
|
12
9
|
if (typeof input !== "object" || input === null) return input;
|
|
13
10
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -218,26 +215,30 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
218
215
|
};
|
|
219
216
|
}
|
|
220
217
|
let _dec, _initClass;
|
|
221
|
-
_dec = injectable([
|
|
222
|
-
|
|
218
|
+
_dec = injectable([
|
|
219
|
+
inject(CliFsToken),
|
|
220
|
+
inject(RepoRootResolverPortToken),
|
|
221
|
+
inject(LoadCodefastConfigUseCaseToken)
|
|
222
|
+
]);
|
|
223
|
+
let _PrepareMirrorSyncUseCaseImpl;
|
|
223
224
|
(class {
|
|
224
225
|
fs;
|
|
225
|
-
|
|
226
|
+
repoRootResolver;
|
|
227
|
+
loadCodefastConfig;
|
|
226
228
|
static {
|
|
227
|
-
({c: [
|
|
229
|
+
({c: [_PrepareMirrorSyncUseCaseImpl, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
228
230
|
}
|
|
229
|
-
constructor(fs,
|
|
231
|
+
constructor(fs, repoRootResolver, loadCodefastConfig) {
|
|
230
232
|
this.fs = fs;
|
|
231
|
-
this.
|
|
233
|
+
this.repoRootResolver = repoRootResolver;
|
|
234
|
+
this.loadCodefastConfig = loadCodefastConfig;
|
|
232
235
|
}
|
|
233
236
|
async execute(args) {
|
|
234
|
-
const globalsOutcome = parseGlobalCliOptions(args.globalCliRaw);
|
|
235
|
-
if (!globalsOutcome.ok) return globalsOutcome;
|
|
236
237
|
let rootDir;
|
|
237
238
|
try {
|
|
238
|
-
rootDir = findRepoRoot(
|
|
239
|
+
rootDir = this.repoRootResolver.findRepoRoot(args.currentWorkingDirectory);
|
|
239
240
|
} catch (caughtError) {
|
|
240
|
-
return err(
|
|
241
|
+
return err(new AppError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
|
|
241
242
|
}
|
|
242
243
|
const filterOutcome = resolveMirrorPackageArgToRelative({
|
|
243
244
|
fs: this.fs,
|
|
@@ -246,10 +247,10 @@ let _PrepareMirrorOrchestrator;
|
|
|
246
247
|
currentWorkingDirectory: args.currentWorkingDirectory
|
|
247
248
|
});
|
|
248
249
|
if (!filterOutcome.ok) return filterOutcome;
|
|
249
|
-
const loadedOutcome = await this.
|
|
250
|
+
const loadedOutcome = await this.loadCodefastConfig.execute(rootDir);
|
|
250
251
|
if (!loadedOutcome.ok) return loadedOutcome;
|
|
251
252
|
return ok({
|
|
252
|
-
globals:
|
|
253
|
+
globals: args.globals,
|
|
253
254
|
rootDir,
|
|
254
255
|
config: loadedOutcome.value.config,
|
|
255
256
|
packageFilter: filterOutcome.value
|
|
@@ -260,4 +261,4 @@ let _PrepareMirrorOrchestrator;
|
|
|
260
261
|
}
|
|
261
262
|
});
|
|
262
263
|
//#endregion
|
|
263
|
-
export {
|
|
264
|
+
export { _PrepareMirrorSyncUseCaseImpl as PrepareMirrorSyncUseCaseImpl };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CliFsToken, CliLoggerToken } from "../../../core/
|
|
2
|
-
import {
|
|
1
|
+
import { CliFsToken, CliLoggerToken } from "../../../core/contracts/tokens.mjs";
|
|
2
|
+
import { AppError } from "../../../core/domain/errors.domain.mjs";
|
|
3
3
|
import { err, ok } from "../../../core/domain/result.model.mjs";
|
|
4
|
-
import { messageFromCaughtUnknown } from "../../../core/
|
|
5
|
-
import { MirrorSyncReporterPortToken,
|
|
4
|
+
import { messageFromCaughtUnknown } from "../../../core/domain/caught-unknown-message.value-object.mjs";
|
|
5
|
+
import { MirrorSyncReporterPortToken, SyncWorkspacePackagePortToken, WorkspaceServicePortToken } from "../../contracts/tokens.mjs";
|
|
6
6
|
import { formatMirrorSyncJsonOutput } from "../mirror-sync-json.format.mjs";
|
|
7
|
-
import { injectable } from "@codefast/di";
|
|
7
|
+
import { inject, injectable } from "@codefast/di";
|
|
8
8
|
//#region src/lib/mirror/application/use-cases/run-mirror-sync.use-case.ts
|
|
9
9
|
function toPrimitive(input, hint) {
|
|
10
10
|
if (typeof input !== "object" || input === null) return input;
|
|
@@ -217,11 +217,11 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
217
217
|
}
|
|
218
218
|
let _dec, _initClass;
|
|
219
219
|
_dec = injectable([
|
|
220
|
-
CliFsToken,
|
|
221
|
-
CliLoggerToken,
|
|
222
|
-
WorkspaceServicePortToken,
|
|
223
|
-
MirrorSyncReporterPortToken,
|
|
224
|
-
|
|
220
|
+
inject(CliFsToken),
|
|
221
|
+
inject(CliLoggerToken),
|
|
222
|
+
inject(WorkspaceServicePortToken),
|
|
223
|
+
inject(MirrorSyncReporterPortToken),
|
|
224
|
+
inject(SyncWorkspacePackagePortToken)
|
|
225
225
|
]);
|
|
226
226
|
let _RunMirrorSyncUseCaseImpl;
|
|
227
227
|
(class {
|
|
@@ -265,7 +265,7 @@ let _RunMirrorSyncUseCaseImpl;
|
|
|
265
265
|
targetPackages = [this.workspaceService.resolvePackageFilterUnderRoot(request.rootDir, request.packageFilter)];
|
|
266
266
|
if (!json) this.mirrorReporter.mirrorProcessingMode(this.logger, { kind: "single" });
|
|
267
267
|
} else {
|
|
268
|
-
const { relPaths, multiSource } = await this.workspaceService.findWorkspacePackageRelPaths(request.rootDir,
|
|
268
|
+
const { relPaths, multiSource } = await this.workspaceService.findWorkspacePackageRelPaths(request.rootDir, json ? () => {} : (message) => this.mirrorReporter.logWorkspaceGlobWarning(this.logger, message));
|
|
269
269
|
targetPackages = relPaths;
|
|
270
270
|
if (!json) this.mirrorReporter.mirrorProcessingMode(this.logger, {
|
|
271
271
|
kind: "multi",
|
|
@@ -291,7 +291,7 @@ let _RunMirrorSyncUseCaseImpl;
|
|
|
291
291
|
} else this.logger.out(formatMirrorSyncJsonOutput(stats, elapsed));
|
|
292
292
|
return ok(stats);
|
|
293
293
|
} catch (caughtError) {
|
|
294
|
-
return err(
|
|
294
|
+
return err(new AppError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
static {
|
|
@@ -4,8 +4,8 @@ const WorkspaceServicePortToken = token("WorkspaceServicePort");
|
|
|
4
4
|
const PackageRepositoryPortToken = token("PackageRepositoryPort");
|
|
5
5
|
const FileSystemServicePortToken = token("FileSystemServicePort");
|
|
6
6
|
const MirrorSyncReporterPortToken = token("MirrorSyncReporterPort");
|
|
7
|
-
const
|
|
7
|
+
const SyncWorkspacePackagePortToken = token("SyncWorkspacePackagePort");
|
|
8
8
|
const RunMirrorSyncUseCaseToken = token("RunMirrorSyncUseCase");
|
|
9
|
-
const
|
|
9
|
+
const PrepareMirrorSyncUseCaseToken = token("PrepareMirrorSyncUseCase");
|
|
10
10
|
//#endregion
|
|
11
|
-
export { FileSystemServicePortToken, MirrorSyncReporterPortToken, PackageRepositoryPortToken,
|
|
11
|
+
export { FileSystemServicePortToken, MirrorSyncReporterPortToken, PackageRepositoryPortToken, PrepareMirrorSyncUseCaseToken, RunMirrorSyncUseCaseToken, SyncWorkspacePackagePortToken, WorkspaceServicePortToken };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/lib/mirror/domain/package-display-name.policy.ts
|
|
2
|
+
/**
|
|
3
|
+
* Domain rule: prefer `package.json#name` when it is present, otherwise use folder basename.
|
|
4
|
+
*/ function resolvePackageDisplayName(packageJson, folderBasename) {
|
|
5
|
+
const declaredName = packageJson.name;
|
|
6
|
+
return typeof declaredName === "string" && declaredName.length > 0 ? declaredName : folderBasename;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { resolvePackageDisplayName };
|
package/dist/lib/mirror/{infra/dirent-list.adapter.mjs → infrastructure/dirent-list.guard.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/lib/mirror/
|
|
1
|
+
//#region src/lib/mirror/infrastructure/dirent-list.guard.ts
|
|
2
2
|
/**
|
|
3
3
|
* Narrow `fs.promises.readdir` overload result to `Dirent[]` when `withFileTypes: true`.
|
|
4
4
|
* Accepts both historical checks (`isFile` / `isDirectory`) in one guard.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { messageFromCaughtUnknown } from "../../core/domain/caught-unknown-message.value-object.mjs";
|
|
2
|
+
//#region src/lib/mirror/infrastructure/mirror-console-reporter.presenter.ts
|
|
3
|
+
const COLORS = {
|
|
4
|
+
reset: "\x1B[0m",
|
|
5
|
+
bold: "\x1B[1m",
|
|
6
|
+
dim: "\x1B[2m",
|
|
7
|
+
green: "\x1B[32m",
|
|
8
|
+
yellow: "\x1B[33m",
|
|
9
|
+
cyan: "\x1B[36m",
|
|
10
|
+
gray: "\x1B[90m",
|
|
11
|
+
magenta: "\x1B[35m",
|
|
12
|
+
brightGreen: "\x1B[92m",
|
|
13
|
+
brightCyan: "\x1B[96m"
|
|
14
|
+
};
|
|
15
|
+
let colorsEnabled = true;
|
|
16
|
+
function color(value, code) {
|
|
17
|
+
if (!colorsEnabled) return value;
|
|
18
|
+
return `${code}${value}${COLORS.reset}`;
|
|
19
|
+
}
|
|
20
|
+
function configureMirrorColors(noColor, isStdoutTty) {
|
|
21
|
+
colorsEnabled = isStdoutTty && !noColor;
|
|
22
|
+
}
|
|
23
|
+
function mirrorBanner(logger) {
|
|
24
|
+
logger.out(`\n${color("📦 Mirror — package exports", COLORS.bold + COLORS.cyan)}`);
|
|
25
|
+
logger.out(`${color("═".repeat(60), COLORS.dim)}\n`);
|
|
26
|
+
}
|
|
27
|
+
function mirrorProcessingMode(logger, mode) {
|
|
28
|
+
if (mode.kind === "single") {
|
|
29
|
+
logger.out(`${color("Processing single package...", COLORS.dim)}\n`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (mode.source === "default-patterns") {
|
|
33
|
+
logger.out(`${color("Discovering workspace packages using default patterns (packages/*)…", COLORS.dim)}\n`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (mode.source === "pnpm-workspace-yaml") {
|
|
37
|
+
logger.out(`${color("Discovering workspace packages from pnpm-workspace.yaml…", COLORS.dim)}\n`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
logger.out(`${color("pnpm-workspace.yaml declares an empty workspace package list.", COLORS.dim)}\n`);
|
|
41
|
+
}
|
|
42
|
+
function mirrorNoPackages(logger) {
|
|
43
|
+
logger.out(color("⚠ No packages found", COLORS.yellow));
|
|
44
|
+
}
|
|
45
|
+
function mirrorGlobWarning(logger, message) {
|
|
46
|
+
logger.out(color(`⚠ ${message}`, COLORS.yellow));
|
|
47
|
+
}
|
|
48
|
+
function logSkippedWorkspacePackage(logger, index, total, displayName, reason) {
|
|
49
|
+
const progress = color(`[${index}/${total}]`, COLORS.dim);
|
|
50
|
+
logger.out(`${progress} ${color("○", COLORS.gray)} ${color(displayName, COLORS.dim)}`);
|
|
51
|
+
logger.out(` ${color("└─", COLORS.dim)} ${color(`Skipped: ${reason}`, COLORS.gray)}`);
|
|
52
|
+
logger.out("");
|
|
53
|
+
}
|
|
54
|
+
function logPackageSuccess(logger, index, total, packageStats, generatedDistAssetCounts, verbose) {
|
|
55
|
+
const progress = color(`[${index}/${total}]`, COLORS.dim);
|
|
56
|
+
logger.out(`${progress} ${color("✓", COLORS.brightGreen)} ${color(packageStats.name, COLORS.bold)}`);
|
|
57
|
+
if (verbose) {
|
|
58
|
+
logger.out(` ${color("├─", COLORS.dim)} Path: ${packageStats.path}`);
|
|
59
|
+
if (packageStats.hasTransform) logger.out(` ${color("├─", COLORS.dim)} ${color("Custom path transformation", COLORS.cyan)}`);
|
|
60
|
+
if (packageStats.cssConfigStatus) {
|
|
61
|
+
const status = packageStats.cssConfigStatus === "disabled" ? "CSS disabled" : "CSS configured";
|
|
62
|
+
logger.out(` ${color("├─", COLORS.dim)} ${color(status, COLORS.cyan)}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const breakdown = [];
|
|
66
|
+
if (generatedDistAssetCounts.jsCount > 0) breakdown.push(color(`${generatedDistAssetCounts.jsCount} modules`, COLORS.green));
|
|
67
|
+
if (generatedDistAssetCounts.cssCount > 0) breakdown.push(color(`${generatedDistAssetCounts.cssCount} CSS`, COLORS.magenta));
|
|
68
|
+
if (packageStats.customExports > 0) breakdown.push(color(`${packageStats.customExports} custom`, COLORS.yellow));
|
|
69
|
+
const totalExportsText = color(`${packageStats.totalExports} exports`, COLORS.brightCyan);
|
|
70
|
+
if (breakdown.length === 0) logger.out(` ${color("└─", COLORS.dim)} ${totalExportsText}`);
|
|
71
|
+
else logger.out(` ${color("└─", COLORS.dim)} ${breakdown.join(" + ")} = ${totalExportsText}`);
|
|
72
|
+
logger.out("");
|
|
73
|
+
}
|
|
74
|
+
function logPrunedStaleExport(logger, exportSpecifier) {
|
|
75
|
+
logger.out(` ${color("└─", COLORS.dim)} ${color(`Pruned stale export: ${exportSpecifier}`, COLORS.gray)}`);
|
|
76
|
+
}
|
|
77
|
+
function logPackageError(logger, index, total, displayName, errorValue, verbose) {
|
|
78
|
+
logger.out(`${color(`[${index}/${total}]`, COLORS.dim)} ${color("✗", COLORS.yellow)} ${color(displayName, COLORS.bold)}`);
|
|
79
|
+
logger.out(` ${color("└─", COLORS.dim)} ${color(`Error: ${messageFromCaughtUnknown(errorValue)}`, COLORS.yellow)}\n`);
|
|
80
|
+
if (verbose) logger.err(errorValue instanceof Error && errorValue.stack ? errorValue.stack : messageFromCaughtUnknown(errorValue));
|
|
81
|
+
}
|
|
82
|
+
function mirrorSummarySeparator(logger) {
|
|
83
|
+
logger.out(color("═".repeat(60), COLORS.dim));
|
|
84
|
+
}
|
|
85
|
+
function mirrorSummary(logger, stats, elapsedSeconds) {
|
|
86
|
+
logger.out(`${color("📊 Summary", COLORS.bold)} ${color(`(completed in ${elapsedSeconds.toFixed(2)}s)`, COLORS.dim)}\n`);
|
|
87
|
+
logger.out(` ${color("Packages:", COLORS.bold)}`);
|
|
88
|
+
logger.out(` ${color("├─", COLORS.dim)} Processed: ${color(String(stats.packagesProcessed), COLORS.green)}`);
|
|
89
|
+
if (stats.packagesSkipped > 0) logger.out(` ${color("├─", COLORS.dim)} Skipped: ${color(String(stats.packagesSkipped), COLORS.gray)}`);
|
|
90
|
+
if (stats.packagesErrored > 0) logger.out(` ${color("├─", COLORS.dim)} Errors: ${color(String(stats.packagesErrored), COLORS.yellow)}`);
|
|
91
|
+
logger.out(` ${color("└─", COLORS.dim)} Total found: ${stats.packagesFound}\n`);
|
|
92
|
+
logger.out(` ${color("Exports:", COLORS.bold)}`);
|
|
93
|
+
logger.out(` ${color("├─", COLORS.dim)} JS Modules: ${color(String(stats.totalJsModules), COLORS.cyan)}`);
|
|
94
|
+
logger.out(` ${color("├─", COLORS.dim)} CSS Files: ${color(String(stats.totalCssExports), COLORS.magenta)}`);
|
|
95
|
+
logger.out(` ${color("└─", COLORS.dim)} Total: ${color(String(stats.totalExports), COLORS.brightCyan)}\n`);
|
|
96
|
+
logger.out(`${color("═".repeat(60), COLORS.dim)}\n`);
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { configureMirrorColors, logPackageError, logPackageSuccess, logPrunedStaleExport, logSkippedWorkspacePackage, mirrorBanner, mirrorGlobWarning, mirrorNoPackages, mirrorProcessingMode, mirrorSummary, mirrorSummarySeparator };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { normalizePath } from "
|
|
1
|
+
import { normalizePath } from "../domain/path-normalizer.value-object.mjs";
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
//#region src/lib/mirror/
|
|
4
|
+
//#region src/lib/mirror/infrastructure/package-filter-resolver.service.ts
|
|
5
5
|
function tryRealpath(entryPath) {
|
|
6
6
|
try {
|
|
7
7
|
return realpathSync.native(entryPath);
|