@codefast/cli 0.3.14-canary.2 → 0.3.15
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/bootstrap/cli-application.module.mjs +18 -0
- package/dist/bootstrap/composition-root.mjs +14 -0
- package/dist/bootstrap/register-cli-command-trees.mjs +7 -0
- package/dist/{lib → domains}/arrange/application/use-cases/analyze-directory.use-case.mjs +12 -12
- package/dist/{lib → domains}/arrange/application/use-cases/prepare-arrange-workspace.use-case.mjs +19 -18
- package/dist/{lib → domains}/arrange/application/use-cases/run-arrange-sync.use-case.mjs +18 -18
- package/dist/{lib → domains}/arrange/application/use-cases/suggest-cn-groups.use-case.mjs +5 -5
- package/dist/domains/arrange/arrange.module.mjs +38 -0
- package/dist/domains/arrange/composition/tokens.mjs +17 -0
- package/dist/{lib/arrange/domain/arrange-analyze.service.mjs → domains/arrange/domain/arrange-analyze.domain-service.mjs} +1 -1
- package/dist/{lib/arrange/domain/arrange-grouping.service.mjs → domains/arrange/domain/arrange-grouping.domain-service.mjs} +2 -2
- package/dist/{lib → domains}/arrange/domain/ast/ast-helpers.helper.mjs +2 -2
- package/dist/{lib → domains}/arrange/domain/ast/ast-node.model.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/ast/collectors-cn.collector.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/ast/collectors-jsx.collector.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/ast/collectors-tv.collector.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/ast/targets.model.mjs +2 -2
- package/dist/{lib → domains}/arrange/domain/constants.domain.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/grouping.domain.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/imports.domain.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/source-text-formatters.formatter.mjs +2 -2
- package/dist/{lib/arrange/domain/tailwind-grouping.service.mjs → domains/arrange/domain/tailwind-grouping.domain-service.mjs} +5 -5
- package/dist/{lib → domains}/arrange/domain/tailwind-token-classifier.domain-service.mjs +1 -1
- package/dist/{lib → domains}/arrange/domain/tailwind-token.value-object.mjs +1 -1
- package/dist/{lib/arrange/application/services/arrange-file-processor.service.mjs → domains/arrange/infrastructure/adapters/arrange-file-processor.adapter.mjs} +8 -8
- package/dist/domains/arrange/infrastructure/adapters/arrange-target-path-resolver.adapter.mjs +247 -0
- package/dist/{lib/arrange/application/services/arrange-target-scanner.service.mjs → domains/arrange/infrastructure/adapters/arrange-target-scanner.adapter.mjs} +8 -8
- package/dist/{lib/arrange/adapters/secondary → domains/arrange/infrastructure/adapters}/domain-source-parser.adapter.mjs +10 -8
- package/dist/{lib/arrange/adapters/secondary → domains/arrange/infrastructure/adapters}/file-walker.adapter.mjs +8 -9
- package/dist/domains/arrange/infrastructure/typescript-ast-translator.mjs +580 -0
- package/dist/{lib/arrange/adapters/primary → domains/arrange/presentation}/cli/arrange.command.mjs +195 -54
- package/dist/{lib/arrange/presentation → domains/arrange/presentation/presenters}/arrange-analyze.presenter.mjs +26 -33
- package/dist/{lib/arrange/presentation → domains/arrange/presentation/presenters}/arrange-cli.schema.mjs +1 -1
- package/dist/{lib/tag/presentation/present-tag-sync-result.presenter.mjs → domains/arrange/presentation/presenters/arrange-sync.presenter.mjs} +12 -9
- package/dist/{lib/arrange/presentation → domains/arrange/presentation/presenters}/group-file-preview.presenter.mjs +46 -46
- package/dist/domains/config/composition/tokens.mjs +7 -0
- package/dist/{lib/config/infrastructure/config-schema.adapter.mjs → domains/config/domain/codefast-config.schema.mjs} +6 -6
- package/dist/{lib/config/infrastructure → domains/config/infrastructure/adapters}/config-loader.adapter.mjs +76 -77
- package/dist/{lib/config/infrastructure → domains/config/infrastructure/adapters}/config-warning-reporter.adapter.mjs +6 -6
- package/dist/domains/config/infrastructure/adapters/zod-codefast-config-schema.adapter.mjs +236 -0
- package/dist/domains/mirror/application/mirror-sync-cli-result.mjs +15 -0
- package/dist/{lib → domains}/mirror/application/use-cases/prepare-mirror-sync.use-case.mjs +14 -15
- package/dist/{lib → domains}/mirror/application/use-cases/run-mirror-sync.use-case.mjs +69 -54
- package/dist/{lib/mirror/contracts → domains/mirror/composition}/tokens.mjs +4 -3
- package/dist/{lib → domains}/mirror/domain/constants.domain.mjs +1 -1
- package/dist/{lib → domains}/mirror/domain/errors.domain.mjs +1 -1
- package/dist/{lib/mirror/application/services/generate-mirror-exports.service.mjs → domains/mirror/domain/generate-mirror-exports.domain-service.mjs} +2 -2
- package/dist/{lib → domains}/mirror/domain/package-display-name.policy.mjs +1 -1
- package/dist/{lib → domains}/mirror/domain/path-normalizer.value-object.mjs +1 -1
- package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/file-system-service.adapter.mjs +8 -8
- package/dist/domains/mirror/infrastructure/adapters/mirror-package-path-resolver.adapter.mjs +252 -0
- package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/mirror-sync-reporter.adapter.mjs +94 -15
- package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/package-repository.adapter.mjs +4 -4
- package/dist/{lib/mirror/adapters/secondary → domains/mirror/infrastructure/adapters}/sync-workspace-package.adapter.mjs +23 -46
- package/dist/{lib/mirror/infrastructure → domains/mirror/infrastructure/guards}/dirent-list.guard.mjs +1 -1
- package/dist/{lib → domains}/mirror/infrastructure/package-json-exports.repository.mjs +27 -27
- package/dist/domains/mirror/mirror.module.mjs +26 -0
- package/dist/{lib/mirror/adapters/primary → domains/mirror/presentation}/cli/mirror.command.mjs +83 -27
- package/dist/{lib/mirror/presentation → domains/mirror/presentation/presenters}/mirror-cli.schema.mjs +1 -4
- package/dist/domains/mirror/presentation/presenters/present-mirror-sync-progress.presenter.mjs +265 -0
- package/dist/domains/tag/application/ports/outbound/tag-eligible-workspace-paths.port.mjs +1 -0
- package/dist/domains/tag/application/ports/outbound/tag-since-writer.port.mjs +1 -0
- package/dist/domains/tag/application/ports/outbound/tag-target-path-resolver.port.mjs +1 -0
- package/dist/domains/tag/application/ports/outbound/tag-target-runner.port.mjs +1 -0
- package/dist/domains/tag/application/ports/outbound/tag-version-resolver.port.mjs +1 -0
- package/dist/domains/tag/application/ports/presenting/present-tag-sync-progress.presenter.mjs +1 -0
- package/dist/domains/tag/application/ports/presenting/present-tag-sync-result.presenter.mjs +1 -0
- package/dist/domains/tag/application/requests/tag-sync-execution-input.mjs +1 -0
- package/dist/domains/tag/application/requests/tag-sync.request.mjs +1 -0
- package/dist/{lib → domains}/tag/application/tag-sync-cli-result.mjs +3 -3
- package/dist/{lib → domains}/tag/application/use-cases/prepare-tag-sync.use-case.mjs +20 -24
- package/dist/{lib → domains}/tag/application/use-cases/run-tag-sync.use-case.mjs +123 -129
- package/dist/domains/tag/composition/tokens.mjs +13 -0
- package/dist/domains/tag/contracts/models.mjs +1 -0
- package/dist/domains/tag/domain/types.domain.mjs +1 -0
- package/dist/{lib/tag/adapters/secondary → domains/tag/infrastructure/adapters}/tag-since-writer.adapter.mjs +105 -105
- package/dist/{lib/tag/adapters/secondary/typescript-tree-walk.adapter.mjs → domains/tag/infrastructure/adapters/tag-target-path-resolver.adapter.mjs} +11 -9
- package/dist/domains/tag/infrastructure/adapters/tag-target-resolver.adapter.mjs +302 -0
- package/dist/domains/tag/infrastructure/adapters/tag-target-runner.adapter.mjs +259 -0
- package/dist/{lib/tag/adapters/secondary → domains/tag/infrastructure/adapters}/tag-version-resolver.adapter.mjs +6 -6
- package/dist/{lib/tag/adapters/primary → domains/tag/presentation}/cli/tag.command.mjs +67 -27
- package/dist/{lib/tag/presentation/tag-sync-progress-listener.presenter.mjs → domains/tag/presentation/presenters/present-tag-sync-progress.presenter.mjs} +14 -9
- package/dist/domains/tag/presentation/presenters/present-tag-sync-result.presenter.mjs +290 -0
- package/dist/{lib/tag/presentation → domains/tag/presentation/presenters}/tag-cli.schema.mjs +1 -1
- package/dist/domains/tag/tag.module.mjs +28 -0
- package/dist/program.mjs +3 -2
- package/dist/shell/application/cli-runtime.tokens.mjs +18 -0
- package/dist/shell/application/coordination/cli-executor.coordination.mjs +1 -0
- package/dist/shell/application/coordination/cli-schema-parsing.coordination.mjs +1 -0
- package/dist/shell/application/global-cli-options.model.mjs +5 -0
- package/dist/shell/application/ports/inbound/load-codefast-config.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/cli-fs.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/cli-logger.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/cli-path.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/cli-runtime.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/cli-telemetry.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/cli-verbose-diagnostics.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/format-app-error.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/global-cli-options-parse.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/repo-root-resolver.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/typescript-source-file-walker.port.mjs +1 -0
- package/dist/shell/application/ports/outbound/workspace-package-layout.port.mjs +1 -0
- package/dist/shell/application/ports/primary/command.port.mjs +1 -0
- package/dist/shell/application/services/cli-executor.service.mjs +267 -0
- package/dist/shell/application/services/schema-validator.service.mjs +236 -0
- package/dist/{lib/core/application → shell/application/use-cases}/load-codefast-config.use-case.mjs +11 -13
- package/dist/shell/composition/tokens.mjs +5 -0
- package/dist/shell/contracts/cli-command-slots.mjs +11 -0
- package/dist/{lib/core → shell}/domain/caught-unknown-message.value-object.mjs +1 -1
- package/dist/{lib/core → shell}/domain/cli-exit-codes.domain.mjs +1 -1
- package/dist/shell/domain/cli-positional-arg.value-object.mjs +6 -0
- package/dist/{lib/core → shell}/domain/errors.domain.mjs +1 -1
- package/dist/{lib/core → shell}/domain/result.model.mjs +1 -1
- package/dist/{lib/shared/source-code/domain/text-edit.model.mjs → shell/domain/source-text-edit.support.mjs} +2 -2
- package/dist/shell/infrastructure/adapters/cli-verbose-diagnostics.adapter.mjs +228 -0
- package/dist/{lib/tag/adapters/secondary/tag-target-resolver.adapter.mjs → shell/infrastructure/adapters/format-app-error.adapter.mjs} +16 -13
- package/dist/shell/infrastructure/adapters/global-cli-options-parser.adapter.mjs +233 -0
- package/dist/{lib/mirror/adapters/secondary/workspace-service.adapter.mjs → shell/infrastructure/adapters/repo-root-resolver.adapter.mjs} +20 -13
- package/dist/shell/infrastructure/adapters/typescript-source-file-walker.adapter.mjs +259 -0
- package/dist/shell/infrastructure/commander/commander-cli-host.adapter.mjs +69 -0
- package/dist/{lib/infrastructure/node-io.adapter.mjs → shell/infrastructure/node/node-cli-fs.adapter.mjs} +11 -47
- package/dist/{lib/arrange/adapters/secondary/workspace-resolver.adapter.mjs → shell/infrastructure/node/node-cli-logger.adapter.mjs} +11 -13
- package/dist/{lib/core/infrastructure/path.adapter.mjs → shell/infrastructure/node/node-cli-path.adapter.mjs} +1 -1
- package/dist/{lib/core/infrastructure/repo-root-resolver.adapter.mjs → shell/infrastructure/node/node-cli-runtime.adapter.mjs} +14 -13
- package/dist/shell/infrastructure/telemetry/cli-telemetry.adapter.mjs +280 -0
- package/dist/shell/infrastructure/workspace/node-pnpm-workspace-package-layout.adapter.mjs +385 -0
- package/dist/shell/shell.module.mjs +43 -0
- package/dist/shell/wiring/optional-cli-port-telemetry-activation.mjs +13 -0
- package/package.json +9 -7
- 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/application/services/arrange-target-path-resolver.service.mjs +0 -21
- package/dist/lib/arrange/arrange.module.mjs +0 -31
- package/dist/lib/arrange/contracts/tokens.mjs +0 -15
- package/dist/lib/arrange/infrastructure/typescript-ast-translator.adapter.mjs +0 -355
- package/dist/lib/arrange/presentation/arrange-sync.presenter.mjs +0 -33
- package/dist/lib/bootstrap/composition-root.mjs +0 -33
- package/dist/lib/config/application/services/load-config.service.mjs +0 -17
- package/dist/lib/config/contracts/tokens.mjs +0 -6
- package/dist/lib/core/application/services/global-cli-options-parser.service.mjs +0 -9
- package/dist/lib/core/application/services/schema-validator.service.mjs +0 -17
- package/dist/lib/core/contracts/tokens.mjs +0 -10
- package/dist/lib/core/core.module.mjs +0 -9
- package/dist/lib/core/infrastructure/infrastructure.module.mjs +0 -30
- package/dist/lib/core/infrastructure/port-telemetry.decorator.mjs +0 -62
- 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/workspace/repo-root-resolver.service.mjs +0 -21
- package/dist/lib/kernel/contracts/tokens.mjs +0 -5
- package/dist/lib/mirror/application/mirror-sync-json.format.mjs +0 -12
- package/dist/lib/mirror/application/services/mirror-package-arg-resolver.service.mjs +0 -20
- 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.presentation.module.mjs +0 -13
- 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-json.format.mjs +0 -14
- package/dist/lib/tag/contracts/tokens.mjs +0 -10
- 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/tag-sync.presenter.mjs +0 -61
- package/dist/lib/tag/tag.module.mjs +0 -23
- /package/dist/{lib/arrange/application/ports/domain-source-parser.port.mjs → domains/arrange/application/ports/inbound/analyze-directory.port.mjs} +0 -0
- /package/dist/{lib/arrange/application/ports/file-walker.port.mjs → domains/arrange/application/ports/inbound/prepare-arrange-workspace.port.mjs} +0 -0
- /package/dist/{lib/arrange/application/ports/group-file-preview.port.mjs → domains/arrange/application/ports/inbound/run-arrange-sync.port.mjs} +0 -0
- /package/dist/{lib/arrange/application/ports/workspace-resolver.port.mjs → domains/arrange/application/ports/inbound/suggest-cn-groups.port.mjs} +0 -0
- /package/dist/{lib/arrange/application/requests/analyze-directory.request.mjs → domains/arrange/application/ports/outbound/arrange-file-processor.port.mjs} +0 -0
- /package/dist/{lib/arrange/application/requests/arrange-sync.request.mjs → domains/arrange/application/ports/outbound/arrange-target-path-resolver.port.mjs} +0 -0
- /package/dist/{lib/arrange/application/requests/suggest-groups.request.mjs → domains/arrange/application/ports/outbound/arrange-target-scanner.port.mjs} +0 -0
- /package/dist/{lib/arrange/contracts/analyze-report-presenter.contract.mjs → domains/arrange/application/ports/outbound/domain-source-parser.port.mjs} +0 -0
- /package/dist/{lib/arrange/contracts/models.mjs → domains/arrange/application/ports/outbound/file-walker.port.mjs} +0 -0
- /package/dist/{lib/arrange/contracts/services.contract.mjs → domains/arrange/application/ports/presenting/present-analyze-report.presenter.mjs} +0 -0
- /package/dist/{lib/arrange/domain/types.domain.mjs → domains/arrange/application/ports/presenting/present-arrange-sync-result.presenter.mjs} +0 -0
- /package/dist/{lib/config/application/ports/config-loader.port.mjs → domains/arrange/application/ports/presenting/present-group-file-preview.presenter.mjs} +0 -0
- /package/dist/{lib/config/application/ports/config-warning-reporter.port.mjs → domains/arrange/application/requests/analyze-directory.request.mjs} +0 -0
- /package/dist/{lib/config/domain/schema.domain.mjs → domains/arrange/application/requests/arrange-sync.request.mjs} +0 -0
- /package/dist/{lib/core/application/ports/cli-io.port.mjs → domains/arrange/application/requests/suggest-groups.request.mjs} +0 -0
- /package/dist/{lib/mirror → domains/arrange}/contracts/models.mjs +0 -0
- /package/dist/{lib/mirror → domains/arrange}/domain/types.domain.mjs +0 -0
- /package/dist/{lib/core/application/ports/path.port.mjs → domains/config/application/ports/outbound/codefast-config-schema.port.mjs} +0 -0
- /package/dist/{lib/core/application/ports/repo-root-resolver.port.mjs → domains/config/application/ports/outbound/config-loader.port.mjs} +0 -0
- /package/dist/{lib/core/application/ports/runtime.port.mjs → domains/config/application/ports/outbound/config-warning-reporter.port.mjs} +0 -0
- /package/dist/{lib/kernel/contracts/cli-command.contract.mjs → domains/config/domain/schema.domain.mjs} +0 -0
- /package/dist/{lib/mirror/application/ports/file-system-service.port.mjs → domains/mirror/application/ports/inbound/prepare-mirror-sync.port.mjs} +0 -0
- /package/dist/{lib/mirror/application/ports/mirror-sync-reporter.port.mjs → domains/mirror/application/ports/inbound/run-mirror-sync.port.mjs} +0 -0
- /package/dist/{lib/mirror/application/ports/package-repository.port.mjs → domains/mirror/application/ports/outbound/file-system-service.port.mjs} +0 -0
- /package/dist/{lib/mirror/application/ports/sync-workspace-package.port.mjs → domains/mirror/application/ports/outbound/mirror-package-path.port.mjs} +0 -0
- /package/dist/{lib/mirror/application/ports/workspace-service.port.mjs → domains/mirror/application/ports/outbound/mirror-sync-reporter.port.mjs} +0 -0
- /package/dist/{lib/mirror/application/requests/mirror-sync.request.mjs → domains/mirror/application/ports/outbound/package-repository.port.mjs} +0 -0
- /package/dist/{lib/tag/application/ports/tag-since-writer.port.mjs → domains/mirror/application/ports/outbound/sync-workspace-package.port.mjs} +0 -0
- /package/dist/{lib/tag/application/ports/tag-version-resolver.port.mjs → domains/mirror/application/ports/presenting/present-mirror-sync-progress.presenter.mjs} +0 -0
- /package/dist/{lib/tag/application/ports/target-resolver.port.mjs → domains/mirror/application/requests/mirror-sync-execution-input.mjs} +0 -0
- /package/dist/{lib/tag/application/ports/typescript-tree-walk.port.mjs → domains/mirror/application/requests/mirror-sync.request.mjs} +0 -0
- /package/dist/{lib/tag → domains/mirror}/contracts/models.mjs +0 -0
- /package/dist/{lib/tag → domains/mirror}/domain/types.domain.mjs +0 -0
- /package/dist/{lib/tag/application/requests/tag-sync.request.mjs → domains/tag/application/ports/inbound/prepare-tag-sync.port.mjs} +0 -0
- /package/dist/{lib/tag/contracts/tag-sync-result-presenter.contract.mjs → domains/tag/application/ports/inbound/run-tag-sync.port.mjs} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CliFilesystemPortToken } from "../../../../shell/application/cli-runtime.tokens.mjs";
|
|
2
|
+
import { CodefastConfigSchemaPortToken } from "../../composition/tokens.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { inject, injectable } from "@codefast/di";
|
|
5
|
-
import { ZodError } from "zod";
|
|
6
5
|
import jiti from "jiti";
|
|
7
|
-
//#region src/
|
|
6
|
+
//#region src/domains/config/infrastructure/adapters/config-loader.adapter.ts
|
|
8
7
|
function toPrimitive(input, hint) {
|
|
9
8
|
if (typeof input !== "object" || input === null) return input;
|
|
10
9
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -215,92 +214,92 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
215
214
|
};
|
|
216
215
|
}
|
|
217
216
|
let _dec, _initClass;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
"codefast.config.js",
|
|
221
|
-
"codefast.config.cjs"
|
|
222
|
-
];
|
|
223
|
-
const CONFIG_JSON = "codefast.config.json";
|
|
224
|
-
const cachedLoads = /* @__PURE__ */ new Map();
|
|
225
|
-
function formatZodError(error, filePath) {
|
|
226
|
-
const formatted = error.issues.map((issue) => {
|
|
227
|
-
return ` - ${issue.path.length > 0 ? issue.path.join(".") : "<root>"}: ${issue.message}`;
|
|
228
|
-
}).join("\n");
|
|
229
|
-
return `Invalid config schema in ${path.basename(filePath)}:\n${formatted}`;
|
|
230
|
-
}
|
|
231
|
-
function parseLoadedConfig(raw, filePath) {
|
|
232
|
-
try {
|
|
233
|
-
return codefastConfigSchema.parse(raw);
|
|
234
|
-
} catch (caughtError) {
|
|
235
|
-
if (caughtError instanceof ZodError) throw new Error(formatZodError(caughtError, filePath));
|
|
236
|
-
throw caughtError;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
function listConfigCandidates(startDir, fs) {
|
|
240
|
-
const candidates = [];
|
|
241
|
-
let current = path.resolve(startDir);
|
|
242
|
-
while (true) {
|
|
243
|
-
for (const name of CONFIG_JS_PRIORITY) {
|
|
244
|
-
const candidate = path.join(current, name);
|
|
245
|
-
if (fs.existsSync(candidate)) candidates.push(candidate);
|
|
246
|
-
}
|
|
247
|
-
const jsonCandidate = path.join(current, CONFIG_JSON);
|
|
248
|
-
if (fs.existsSync(jsonCandidate)) candidates.push(jsonCandidate);
|
|
249
|
-
const parent = path.dirname(current);
|
|
250
|
-
if (parent === current) break;
|
|
251
|
-
current = parent;
|
|
252
|
-
}
|
|
253
|
-
return candidates;
|
|
254
|
-
}
|
|
255
|
-
async function readConfigFromPath(filePath, fs, jitiBaseDir) {
|
|
256
|
-
if (path.extname(filePath) === ".json") {
|
|
257
|
-
const content = await fs.readFile(filePath, "utf8");
|
|
258
|
-
return parseLoadedConfig(JSON.parse(content), filePath);
|
|
259
|
-
}
|
|
260
|
-
const moduleConfig = jiti(jitiBaseDir, {
|
|
261
|
-
interopDefault: true,
|
|
262
|
-
moduleCache: false
|
|
263
|
-
})(filePath);
|
|
264
|
-
return parseLoadedConfig(typeof moduleConfig === "object" && moduleConfig !== null && "default" in moduleConfig ? moduleConfig.default : moduleConfig, filePath);
|
|
265
|
-
}
|
|
266
|
-
async function loadOnce(fs, startDir) {
|
|
267
|
-
const warnings = [];
|
|
268
|
-
const configPaths = listConfigCandidates(startDir, fs);
|
|
269
|
-
if (configPaths.length === 0) return {
|
|
270
|
-
config: {},
|
|
271
|
-
warnings
|
|
272
|
-
};
|
|
273
|
-
const configPath = configPaths[0];
|
|
274
|
-
if (configPath === void 0) return {
|
|
275
|
-
config: {},
|
|
276
|
-
warnings
|
|
277
|
-
};
|
|
278
|
-
return {
|
|
279
|
-
config: await readConfigFromPath(configPath, fs, startDir),
|
|
280
|
-
warnings,
|
|
281
|
-
configPath
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
_dec = injectable([inject(CliFsToken)]);
|
|
285
|
-
let _ConfigLoaderAdapterImpl;
|
|
217
|
+
_dec = injectable([inject(CliFilesystemPortToken), inject(CodefastConfigSchemaPortToken)]);
|
|
218
|
+
let _ConfigLoaderAdapter;
|
|
286
219
|
(class {
|
|
287
220
|
fs;
|
|
221
|
+
configSchema;
|
|
288
222
|
static {
|
|
289
|
-
({c: [
|
|
223
|
+
({c: [_ConfigLoaderAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
290
224
|
}
|
|
291
|
-
constructor(fs) {
|
|
225
|
+
constructor(fs, configSchema) {
|
|
292
226
|
this.fs = fs;
|
|
227
|
+
this.configSchema = configSchema;
|
|
293
228
|
}
|
|
229
|
+
configJsPriority = [
|
|
230
|
+
"codefast.config.mjs",
|
|
231
|
+
"codefast.config.js",
|
|
232
|
+
"codefast.config.cjs"
|
|
233
|
+
];
|
|
234
|
+
configJson = "codefast.config.json";
|
|
235
|
+
cachedLoads = /* @__PURE__ */ new Map();
|
|
294
236
|
async loadConfig(startDir) {
|
|
295
237
|
const cacheKey = path.resolve(startDir);
|
|
296
|
-
if (!cachedLoads.has(cacheKey)) cachedLoads.set(cacheKey, loadOnce(
|
|
297
|
-
const cached = cachedLoads.get(cacheKey);
|
|
238
|
+
if (!this.cachedLoads.has(cacheKey)) this.cachedLoads.set(cacheKey, this.loadOnce(cacheKey));
|
|
239
|
+
const cached = this.cachedLoads.get(cacheKey);
|
|
298
240
|
if (cached === void 0) throw new Error("config loader cache invariant violated");
|
|
299
241
|
return cached;
|
|
300
242
|
}
|
|
243
|
+
formatZodError(error, filePath) {
|
|
244
|
+
const formatted = error.issues.map((issue) => {
|
|
245
|
+
return ` - ${issue.path.length > 0 ? issue.path.join(".") : "<root>"}: ${issue.message}`;
|
|
246
|
+
}).join("\n");
|
|
247
|
+
return `Invalid config schema in ${path.basename(filePath)}:\n${formatted}`;
|
|
248
|
+
}
|
|
249
|
+
parseLoadedConfig(raw, filePath) {
|
|
250
|
+
const outcome = this.configSchema.safeParseLoadedConfig(raw);
|
|
251
|
+
if (outcome.kind === "invalid_schema") throw new Error(this.formatZodError(outcome.zodError, filePath));
|
|
252
|
+
return outcome.config;
|
|
253
|
+
}
|
|
254
|
+
listConfigCandidates(startDir) {
|
|
255
|
+
const candidates = [];
|
|
256
|
+
let current = path.resolve(startDir);
|
|
257
|
+
while (true) {
|
|
258
|
+
for (const name of this.configJsPriority) {
|
|
259
|
+
const candidate = path.join(current, name);
|
|
260
|
+
if (this.fs.existsSync(candidate)) candidates.push(candidate);
|
|
261
|
+
}
|
|
262
|
+
const jsonCandidate = path.join(current, this.configJson);
|
|
263
|
+
if (this.fs.existsSync(jsonCandidate)) candidates.push(jsonCandidate);
|
|
264
|
+
const parent = path.dirname(current);
|
|
265
|
+
if (parent === current) break;
|
|
266
|
+
current = parent;
|
|
267
|
+
}
|
|
268
|
+
return candidates;
|
|
269
|
+
}
|
|
270
|
+
async readConfigFromPath(filePath, jitiBaseDir) {
|
|
271
|
+
if (path.extname(filePath) === ".json") {
|
|
272
|
+
const content = await this.fs.readFile(filePath, "utf8");
|
|
273
|
+
return this.parseLoadedConfig(JSON.parse(content), filePath);
|
|
274
|
+
}
|
|
275
|
+
const moduleConfig = jiti(jitiBaseDir, {
|
|
276
|
+
interopDefault: true,
|
|
277
|
+
moduleCache: false
|
|
278
|
+
})(filePath);
|
|
279
|
+
const unwrappedConfig = typeof moduleConfig === "object" && moduleConfig !== null && "default" in moduleConfig ? moduleConfig.default : moduleConfig;
|
|
280
|
+
return this.parseLoadedConfig(unwrappedConfig, filePath);
|
|
281
|
+
}
|
|
282
|
+
async loadOnce(startDir) {
|
|
283
|
+
const warnings = [];
|
|
284
|
+
const configPaths = this.listConfigCandidates(startDir);
|
|
285
|
+
if (configPaths.length === 0) return {
|
|
286
|
+
config: {},
|
|
287
|
+
warnings
|
|
288
|
+
};
|
|
289
|
+
const configPath = configPaths[0];
|
|
290
|
+
if (configPath === void 0) return {
|
|
291
|
+
config: {},
|
|
292
|
+
warnings
|
|
293
|
+
};
|
|
294
|
+
return {
|
|
295
|
+
config: await this.readConfigFromPath(configPath, startDir),
|
|
296
|
+
warnings,
|
|
297
|
+
configPath
|
|
298
|
+
};
|
|
299
|
+
}
|
|
301
300
|
static {
|
|
302
301
|
_initClass();
|
|
303
302
|
}
|
|
304
303
|
});
|
|
305
304
|
//#endregion
|
|
306
|
-
export {
|
|
305
|
+
export { _ConfigLoaderAdapter as ConfigLoaderAdapter };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CliLoggerPortToken } from "../../../../shell/application/cli-runtime.tokens.mjs";
|
|
2
2
|
import { inject, injectable } from "@codefast/di";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/domains/config/infrastructure/adapters/config-warning-reporter.adapter.ts
|
|
4
4
|
function toPrimitive(input, hint) {
|
|
5
5
|
if (typeof input !== "object" || input === null) return input;
|
|
6
6
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -211,9 +211,7 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
let _dec, _initClass;
|
|
214
|
-
|
|
215
|
-
const RESET = "\x1B[0m";
|
|
216
|
-
_dec = injectable([inject(CliLoggerToken)]);
|
|
214
|
+
_dec = injectable([inject(CliLoggerPortToken)]);
|
|
217
215
|
let _ConfigWarningReporterAdapter;
|
|
218
216
|
(class {
|
|
219
217
|
logger;
|
|
@@ -223,8 +221,10 @@ let _ConfigWarningReporterAdapter;
|
|
|
223
221
|
constructor(logger) {
|
|
224
222
|
this.logger = logger;
|
|
225
223
|
}
|
|
224
|
+
yellowAnsi = "\x1B[33m";
|
|
225
|
+
resetAnsi = "\x1B[0m";
|
|
226
226
|
reportSchemaWarnings(warnings) {
|
|
227
|
-
for (const warningMessage of warnings) this.logger.out(`${
|
|
227
|
+
for (const warningMessage of warnings) this.logger.out(`${this.yellowAnsi}⚠ ${warningMessage}${this.resetAnsi}`);
|
|
228
228
|
}
|
|
229
229
|
static {
|
|
230
230
|
_initClass();
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { codefastConfigRootSchema } from "../../domain/codefast-config.schema.mjs";
|
|
2
|
+
import { injectable } from "@codefast/di";
|
|
3
|
+
//#region src/domains/config/infrastructure/adapters/zod-codefast-config-schema.adapter.ts
|
|
4
|
+
function toPrimitive(input, hint) {
|
|
5
|
+
if (typeof input !== "object" || input === null) return input;
|
|
6
|
+
var prim = input[Symbol.toPrimitive];
|
|
7
|
+
if (prim !== void 0) {
|
|
8
|
+
var res = prim.call(input, hint || "default");
|
|
9
|
+
if (typeof res !== "object") return res;
|
|
10
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
11
|
+
}
|
|
12
|
+
return (hint === "string" ? String : Number)(input);
|
|
13
|
+
}
|
|
14
|
+
function toPropertyKey(arg) {
|
|
15
|
+
var key = toPrimitive(arg, "string");
|
|
16
|
+
return typeof key === "symbol" ? key : String(key);
|
|
17
|
+
}
|
|
18
|
+
function checkInRHS(value) {
|
|
19
|
+
if (Object(value) !== value) throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function setFunctionName(fn, name, prefix) {
|
|
23
|
+
if (typeof name === "symbol") {
|
|
24
|
+
name = name.description;
|
|
25
|
+
name = name ? "[" + name + "]" : "";
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
Object.defineProperty(fn, "name", {
|
|
29
|
+
configurable: true,
|
|
30
|
+
value: prefix ? prefix + " " + name : name
|
|
31
|
+
});
|
|
32
|
+
} catch (_) {}
|
|
33
|
+
return fn;
|
|
34
|
+
}
|
|
35
|
+
function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
|
|
36
|
+
var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
|
|
37
|
+
var defineProperty = Object.defineProperty;
|
|
38
|
+
var create = Object.create;
|
|
39
|
+
var metadata;
|
|
40
|
+
var existingNonFields = [create(null), create(null)];
|
|
41
|
+
var hasClassDecs = classDecs.length;
|
|
42
|
+
var _;
|
|
43
|
+
function createRunInitializers(initializers, useStaticThis, hasValue) {
|
|
44
|
+
return function(thisArg, value) {
|
|
45
|
+
if (useStaticThis) {
|
|
46
|
+
value = thisArg;
|
|
47
|
+
thisArg = targetClass;
|
|
48
|
+
}
|
|
49
|
+
for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
|
|
50
|
+
return hasValue ? value : thisArg;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function assertCallable(fn, hint1, hint2, throwUndefined) {
|
|
54
|
+
if (typeof fn !== "function") {
|
|
55
|
+
if (throwUndefined || fn !== void 0) throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
|
|
56
|
+
}
|
|
57
|
+
return fn;
|
|
58
|
+
}
|
|
59
|
+
function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
|
|
60
|
+
function assertInstanceIfPrivate(target) {
|
|
61
|
+
if (!hasPrivateBrand(target)) throw new TypeError("Attempted to access private element on non-instance");
|
|
62
|
+
}
|
|
63
|
+
var decs = [].concat(decInfo[0]);
|
|
64
|
+
var decVal = decInfo[3];
|
|
65
|
+
var isClass = !ret;
|
|
66
|
+
var isAccessor = kind === 1;
|
|
67
|
+
var isGetter = kind === 3;
|
|
68
|
+
var isSetter = kind === 4;
|
|
69
|
+
var isMethod = kind === 2;
|
|
70
|
+
function bindPropCall(name, useStaticThis, before) {
|
|
71
|
+
return function(_this, value) {
|
|
72
|
+
if (useStaticThis) {
|
|
73
|
+
value = _this;
|
|
74
|
+
_this = Class;
|
|
75
|
+
}
|
|
76
|
+
if (before) before(_this);
|
|
77
|
+
return desc[name].call(_this, value);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
var desc1 = {};
|
|
81
|
+
var init = [];
|
|
82
|
+
var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
|
|
83
|
+
if (!isClass) {
|
|
84
|
+
if (isPrivate) {
|
|
85
|
+
if (isField || isAccessor) desc1 = {
|
|
86
|
+
get: setFunctionName(function() {
|
|
87
|
+
return decVal(this);
|
|
88
|
+
}, name, "get"),
|
|
89
|
+
set: function(value) {
|
|
90
|
+
decInfo[4](this, value);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
else desc1[key] = decVal;
|
|
94
|
+
if (!isField) setFunctionName(desc1[key], name, isMethod ? "" : key);
|
|
95
|
+
} else if (!isField) desc1 = Object.getOwnPropertyDescriptor(Class, name);
|
|
96
|
+
if (!isField && !isPrivate) {
|
|
97
|
+
_ = existingNonFields[+isStatic][name];
|
|
98
|
+
if (_ && (_ ^ kind) !== 7) throw new Error("Decorating two elements with the same name (" + desc1[key].name + ") is not supported yet");
|
|
99
|
+
existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var newValue = Class;
|
|
103
|
+
for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
|
|
104
|
+
var dec = assertCallable(decs[i], "A decorator", "be", true);
|
|
105
|
+
var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
|
|
106
|
+
var decoratorFinishedRef = {};
|
|
107
|
+
var ctx = {
|
|
108
|
+
kind: [
|
|
109
|
+
"field",
|
|
110
|
+
"accessor",
|
|
111
|
+
"method",
|
|
112
|
+
"getter",
|
|
113
|
+
"setter",
|
|
114
|
+
"class"
|
|
115
|
+
][kind],
|
|
116
|
+
name,
|
|
117
|
+
metadata,
|
|
118
|
+
addInitializer: (function(decoratorFinishedRef, initializer) {
|
|
119
|
+
if (decoratorFinishedRef.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
|
|
120
|
+
assertCallable(initializer, "An initializer", "be", true);
|
|
121
|
+
initializers.push(initializer);
|
|
122
|
+
}).bind(null, decoratorFinishedRef)
|
|
123
|
+
};
|
|
124
|
+
if (isClass) {
|
|
125
|
+
_ = dec.call(decThis, newValue, ctx);
|
|
126
|
+
decoratorFinishedRef.v = 1;
|
|
127
|
+
if (assertCallable(_, "class decorators", "return")) newValue = _;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
ctx.static = isStatic;
|
|
131
|
+
ctx.private = isPrivate;
|
|
132
|
+
_ = ctx.access = { has: isPrivate ? hasPrivateBrand.bind() : function(target) {
|
|
133
|
+
return name in target;
|
|
134
|
+
} };
|
|
135
|
+
if (!isSetter) _.get = isPrivate ? isMethod ? function(_this) {
|
|
136
|
+
assertInstanceIfPrivate(_this);
|
|
137
|
+
return desc1.value;
|
|
138
|
+
} : bindPropCall("get", 0, assertInstanceIfPrivate) : function(target) {
|
|
139
|
+
return target[name];
|
|
140
|
+
};
|
|
141
|
+
if (!isMethod && !isGetter) _.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
|
|
142
|
+
target[name] = value;
|
|
143
|
+
};
|
|
144
|
+
newValue = dec.call(decThis, isAccessor ? {
|
|
145
|
+
get: desc1.get,
|
|
146
|
+
set: desc1.set
|
|
147
|
+
} : desc1[key], ctx);
|
|
148
|
+
decoratorFinishedRef.v = 1;
|
|
149
|
+
if (isAccessor) {
|
|
150
|
+
if (typeof newValue === "object" && newValue) {
|
|
151
|
+
if (_ = assertCallable(newValue.get, "accessor.get")) desc1.get = _;
|
|
152
|
+
if (_ = assertCallable(newValue.set, "accessor.set")) desc1.set = _;
|
|
153
|
+
if (_ = assertCallable(newValue.init, "accessor.init")) init.unshift(_);
|
|
154
|
+
} else if (newValue !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
|
|
155
|
+
} else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) if (isField) init.unshift(newValue);
|
|
156
|
+
else desc1[key] = newValue;
|
|
157
|
+
}
|
|
158
|
+
if (kind < 2) ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
|
|
159
|
+
if (!isField && !isClass) if (isPrivate) if (isAccessor) ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
|
|
160
|
+
else ret.push(isMethod ? desc1[key] : assertCallable.call.bind(desc1[key]));
|
|
161
|
+
else defineProperty(Class, name, desc1);
|
|
162
|
+
return newValue;
|
|
163
|
+
}
|
|
164
|
+
function applyMemberDecs() {
|
|
165
|
+
var ret = [];
|
|
166
|
+
var protoInitializers;
|
|
167
|
+
var staticInitializers;
|
|
168
|
+
var pushInitializers = function(initializers) {
|
|
169
|
+
if (initializers) ret.push(createRunInitializers(initializers));
|
|
170
|
+
};
|
|
171
|
+
var applyMemberDecsOfKind = function(isStatic, isField) {
|
|
172
|
+
for (var i = 0; i < memberDecs.length; i++) {
|
|
173
|
+
var decInfo = memberDecs[i];
|
|
174
|
+
var kind = decInfo[1];
|
|
175
|
+
var kindOnly = kind & 7;
|
|
176
|
+
if ((kind & 8) == isStatic && !kindOnly == isField) {
|
|
177
|
+
var name = decInfo[2];
|
|
178
|
+
var isPrivate = !!decInfo[3];
|
|
179
|
+
var decoratorsHaveThis = kind & 16;
|
|
180
|
+
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(_) {
|
|
181
|
+
return checkInRHS(_) === targetClass;
|
|
182
|
+
} : instanceBrand);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
applyMemberDecsOfKind(8, 0);
|
|
187
|
+
applyMemberDecsOfKind(0, 0);
|
|
188
|
+
applyMemberDecsOfKind(8, 1);
|
|
189
|
+
applyMemberDecsOfKind(0, 1);
|
|
190
|
+
pushInitializers(protoInitializers);
|
|
191
|
+
pushInitializers(staticInitializers);
|
|
192
|
+
return ret;
|
|
193
|
+
}
|
|
194
|
+
function defineMetadata(Class) {
|
|
195
|
+
return defineProperty(Class, symbolMetadata, {
|
|
196
|
+
configurable: true,
|
|
197
|
+
enumerable: true,
|
|
198
|
+
value: metadata
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (parentClass !== void 0) metadata = parentClass[symbolMetadata];
|
|
202
|
+
metadata = create(metadata == null ? null : metadata);
|
|
203
|
+
_ = applyMemberDecs();
|
|
204
|
+
if (!hasClassDecs) defineMetadata(targetClass);
|
|
205
|
+
return {
|
|
206
|
+
e: _,
|
|
207
|
+
get c() {
|
|
208
|
+
var initializers = [];
|
|
209
|
+
return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)];
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
let _dec, _initClass;
|
|
214
|
+
_dec = injectable();
|
|
215
|
+
let _ZodCodefastConfigSchemaAdapter;
|
|
216
|
+
(class {
|
|
217
|
+
static {
|
|
218
|
+
({c: [_ZodCodefastConfigSchemaAdapter, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
219
|
+
}
|
|
220
|
+
safeParseLoadedConfig(raw) {
|
|
221
|
+
const parsed = codefastConfigRootSchema.safeParse(raw);
|
|
222
|
+
if (parsed.success) return {
|
|
223
|
+
kind: "ok",
|
|
224
|
+
config: parsed.data
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
kind: "invalid_schema",
|
|
228
|
+
zodError: parsed.error
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
static {
|
|
232
|
+
_initClass();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
//#endregion
|
|
236
|
+
export { _ZodCodefastConfigSchemaAdapter as ZodCodefastConfigSchemaAdapter };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "../../../shell/domain/cli-exit-codes.domain.mjs";
|
|
2
|
+
//#region src/domains/mirror/application/mirror-sync-cli-result.ts
|
|
3
|
+
function exitCodeForMirrorSyncResult(stats) {
|
|
4
|
+
return stats.packagesErrored > 0 ? 1 : 0;
|
|
5
|
+
}
|
|
6
|
+
function formatMirrorSyncJsonOutput(stats, elapsedSeconds) {
|
|
7
|
+
return JSON.stringify({
|
|
8
|
+
schemaVersion: 1,
|
|
9
|
+
ok: stats.packagesErrored === 0,
|
|
10
|
+
elapsedSeconds,
|
|
11
|
+
stats
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { exitCodeForMirrorSyncResult, formatMirrorSyncJsonOutput };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AppError } from "
|
|
3
|
-
import { err, ok } from "
|
|
4
|
-
import { messageFromCaughtUnknown } from "
|
|
5
|
-
import {
|
|
1
|
+
import { LoadCodefastConfigUseCaseToken, RepoRootResolverPortToken } from "../../../../shell/application/cli-runtime.tokens.mjs";
|
|
2
|
+
import { AppError } from "../../../../shell/domain/errors.domain.mjs";
|
|
3
|
+
import { err, ok } from "../../../../shell/domain/result.model.mjs";
|
|
4
|
+
import { messageFromCaughtUnknown } from "../../../../shell/domain/caught-unknown-message.value-object.mjs";
|
|
5
|
+
import { MirrorPackagePathPortToken } from "../../composition/tokens.mjs";
|
|
6
6
|
import { inject, injectable } from "@codefast/di";
|
|
7
|
-
//#region src/
|
|
7
|
+
//#region src/domains/mirror/application/use-cases/prepare-mirror-sync.use-case.ts
|
|
8
8
|
function toPrimitive(input, hint) {
|
|
9
9
|
if (typeof input !== "object" || input === null) return input;
|
|
10
10
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -216,20 +216,20 @@ function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis,
|
|
|
216
216
|
}
|
|
217
217
|
let _dec, _initClass;
|
|
218
218
|
_dec = injectable([
|
|
219
|
-
inject(
|
|
219
|
+
inject(MirrorPackagePathPortToken),
|
|
220
220
|
inject(RepoRootResolverPortToken),
|
|
221
221
|
inject(LoadCodefastConfigUseCaseToken)
|
|
222
222
|
]);
|
|
223
|
-
let
|
|
223
|
+
let _PrepareMirrorSyncUseCase;
|
|
224
224
|
(class {
|
|
225
|
-
|
|
225
|
+
mirrorPackagePath;
|
|
226
226
|
repoRootResolver;
|
|
227
227
|
loadCodefastConfig;
|
|
228
228
|
static {
|
|
229
|
-
({c: [
|
|
229
|
+
({c: [_PrepareMirrorSyncUseCase, _initClass]} = _apply_decs_2311(this, [_dec], []));
|
|
230
230
|
}
|
|
231
|
-
constructor(
|
|
232
|
-
this.
|
|
231
|
+
constructor(mirrorPackagePath, repoRootResolver, loadCodefastConfig) {
|
|
232
|
+
this.mirrorPackagePath = mirrorPackagePath;
|
|
233
233
|
this.repoRootResolver = repoRootResolver;
|
|
234
234
|
this.loadCodefastConfig = loadCodefastConfig;
|
|
235
235
|
}
|
|
@@ -240,8 +240,7 @@ let _PrepareMirrorSyncUseCaseImpl;
|
|
|
240
240
|
} catch (caughtError) {
|
|
241
241
|
return err(new AppError("INFRA_FAILURE", messageFromCaughtUnknown(caughtError), caughtError));
|
|
242
242
|
}
|
|
243
|
-
const filterOutcome =
|
|
244
|
-
fs: this.fs,
|
|
243
|
+
const filterOutcome = this.mirrorPackagePath.resolveFromCliArg({
|
|
245
244
|
rootDir,
|
|
246
245
|
packageArg: args.packageArg,
|
|
247
246
|
currentWorkingDirectory: args.currentWorkingDirectory
|
|
@@ -261,4 +260,4 @@ let _PrepareMirrorSyncUseCaseImpl;
|
|
|
261
260
|
}
|
|
262
261
|
});
|
|
263
262
|
//#endregion
|
|
264
|
-
export {
|
|
263
|
+
export { _PrepareMirrorSyncUseCase as PrepareMirrorSyncUseCase };
|