@webiny/cli-core 0.0.0-unstable.0156a4c312
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/Cli.d.ts +8 -0
- package/Cli.js +17 -0
- package/Cli.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/abstractions/createAbstraction.d.ts +2 -0
- package/abstractions/createAbstraction.js +7 -0
- package/abstractions/createAbstraction.js.map +1 -0
- package/abstractions/features/CliCommand.d.ts +41 -0
- package/abstractions/features/CliCommand.js +5 -0
- package/abstractions/features/CliCommand.js.map +1 -0
- package/abstractions/features/ErrorHandler.d.ts +15 -0
- package/abstractions/features/ErrorHandler.js +5 -0
- package/abstractions/features/ErrorHandler.js.map +1 -0
- package/abstractions/features/GlobalCliOption.d.ts +20 -0
- package/abstractions/features/GlobalCliOption.js +5 -0
- package/abstractions/features/GlobalCliOption.js.map +1 -0
- package/abstractions/features/IsCi.d.ts +8 -0
- package/abstractions/features/IsCi.js +5 -0
- package/abstractions/features/IsCi.js.map +1 -0
- package/abstractions/features/index.d.ts +4 -0
- package/abstractions/features/index.js +4 -0
- package/abstractions/features/types.d.ts +8 -0
- package/abstractions/features/types.js +0 -0
- package/abstractions/index.d.ts +2 -0
- package/abstractions/index.js +2 -0
- package/abstractions/services/ArgvParserService.d.ts +7 -0
- package/abstractions/services/ArgvParserService.js +5 -0
- package/abstractions/services/ArgvParserService.js.map +1 -0
- package/abstractions/services/CliParamsService.d.ts +15 -0
- package/abstractions/services/CliParamsService.js +5 -0
- package/abstractions/services/CliParamsService.js.map +1 -0
- package/abstractions/services/CommandsRegistryService.d.ts +8 -0
- package/abstractions/services/CommandsRegistryService.js +5 -0
- package/abstractions/services/CommandsRegistryService.js.map +1 -0
- package/abstractions/services/DefaultAppsService.d.ts +8 -0
- package/abstractions/services/DefaultAppsService.js +5 -0
- package/abstractions/services/DefaultAppsService.js.map +1 -0
- package/abstractions/services/GetArgvService.d.ts +7 -0
- package/abstractions/services/GetArgvService.js +5 -0
- package/abstractions/services/GetArgvService.js.map +1 -0
- package/abstractions/services/GetCliRunnerService.d.ts +7 -0
- package/abstractions/services/GetCliRunnerService.js +5 -0
- package/abstractions/services/GetCliRunnerService.js.map +1 -0
- package/abstractions/services/GetIsCiService.d.ts +8 -0
- package/abstractions/services/GetIsCiService.js +5 -0
- package/abstractions/services/GetIsCiService.js.map +1 -0
- package/abstractions/services/GetProjectSdkService.d.ts +8 -0
- package/abstractions/services/GetProjectSdkService.js +5 -0
- package/abstractions/services/GetProjectSdkService.js.map +1 -0
- package/abstractions/services/GlobalOptionsRegistryService.d.ts +8 -0
- package/abstractions/services/GlobalOptionsRegistryService.js +5 -0
- package/abstractions/services/GlobalOptionsRegistryService.js.map +1 -0
- package/abstractions/services/LoggerService.d.ts +13 -0
- package/abstractions/services/LoggerService.js +5 -0
- package/abstractions/services/LoggerService.js.map +1 -0
- package/abstractions/services/RunCliRunnerService.d.ts +7 -0
- package/abstractions/services/RunCliRunnerService.js +5 -0
- package/abstractions/services/RunCliRunnerService.js.map +1 -0
- package/abstractions/services/StdioService.d.ts +9 -0
- package/abstractions/services/StdioService.js +5 -0
- package/abstractions/services/StdioService.js.map +1 -0
- package/abstractions/services/UiService.d.ts +15 -0
- package/abstractions/services/UiService.js +5 -0
- package/abstractions/services/UiService.js.map +1 -0
- package/abstractions/services/index.d.ts +13 -0
- package/abstractions/services/index.js +13 -0
- package/createCliContainer.d.ts +3 -0
- package/createCliContainer.js +97 -0
- package/createCliContainer.js.map +1 -0
- package/decorators/CommandsWithGracefulErrorHandling.d.ts +10 -0
- package/decorators/CommandsWithGracefulErrorHandling.js +40 -0
- package/decorators/CommandsWithGracefulErrorHandling.js.map +1 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/exports/cli/command.d.ts +1 -0
- package/exports/cli/command.js +1 -0
- package/exports/cli.d.ts +2 -0
- package/exports/cli.js +2 -0
- package/extensions/CliCommand.d.ts +4 -0
- package/extensions/CliCommand.js +20 -0
- package/extensions/CliCommand.js.map +1 -0
- package/extensions/CliCommandDecorator.d.ts +4 -0
- package/extensions/CliCommandDecorator.js +20 -0
- package/extensions/CliCommandDecorator.js.map +1 -0
- package/extensions/index.d.ts +5 -0
- package/extensions/index.js +9 -0
- package/extensions/index.js.map +1 -0
- package/features/AboutCommand.d.ts +12 -0
- package/features/AboutCommand.js +88 -0
- package/features/AboutCommand.js.map +1 -0
- package/features/BuildCommand/BuildCommand.d.ts +15 -0
- package/features/BuildCommand/BuildCommand.js +75 -0
- package/features/BuildCommand/BuildCommand.js.map +1 -0
- package/features/BuildCommand/buildRunners/BaseBuildRunner.d.ts +14 -0
- package/features/BuildCommand/buildRunners/BaseBuildRunner.js +13 -0
- package/features/BuildCommand/buildRunners/BaseBuildRunner.js.map +1 -0
- package/features/BuildCommand/buildRunners/BuildRunner.d.ts +6 -0
- package/features/BuildCommand/buildRunners/BuildRunner.js +27 -0
- package/features/BuildCommand/buildRunners/BuildRunner.js.map +1 -0
- package/features/BuildCommand/buildRunners/MultipleBuildsRunner.d.ts +4 -0
- package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js +26 -0
- package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js.map +1 -0
- package/features/BuildCommand/buildRunners/SingleBuildRunner.d.ts +4 -0
- package/features/BuildCommand/buildRunners/SingleBuildRunner.js +20 -0
- package/features/BuildCommand/buildRunners/SingleBuildRunner.js.map +1 -0
- package/features/BuildCommand/buildRunners/ZeroBuildsRunner.d.ts +4 -0
- package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js +7 -0
- package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js.map +1 -0
- package/features/BuildCommand/index.d.ts +1 -0
- package/features/BuildCommand/index.js +1 -0
- package/features/ConfigCommand.d.ts +16 -0
- package/features/ConfigCommand.js +63 -0
- package/features/ConfigCommand.js.map +1 -0
- package/features/DeployCommand/index.d.ts +20 -0
- package/features/DeployCommand/index.js +0 -0
- package/features/DepsSync/BuildDependencyTree.d.ts +9 -0
- package/features/DepsSync/BuildDependencyTree.js +22 -0
- package/features/DepsSync/BuildDependencyTree.js.map +1 -0
- package/features/DepsSync/DependencyTree.d.ts +12 -0
- package/features/DepsSync/DependencyTree.js +120 -0
- package/features/DepsSync/DependencyTree.js.map +1 -0
- package/features/DepsSync/ListAllPackageJsonFiles.d.ts +7 -0
- package/features/DepsSync/ListAllPackageJsonFiles.js +23 -0
- package/features/DepsSync/ListAllPackageJsonFiles.js.map +1 -0
- package/features/DepsSync/ListAllPackages.d.ts +3 -0
- package/features/DepsSync/ListAllPackages.js +13 -0
- package/features/DepsSync/ListAllPackages.js.map +1 -0
- package/features/DepsSync/commands/SyncDepsCommand.d.ts +13 -0
- package/features/DepsSync/commands/SyncDepsCommand.js +38 -0
- package/features/DepsSync/commands/SyncDepsCommand.js.map +1 -0
- package/features/DepsSync/commands/VerifyDepsCommand.d.ts +13 -0
- package/features/DepsSync/commands/VerifyDepsCommand.js +80 -0
- package/features/DepsSync/commands/VerifyDepsCommand.js.map +1 -0
- package/features/DepsSync/createDependencyTree.d.ts +3 -0
- package/features/DepsSync/createDependencyTree.js +34 -0
- package/features/DepsSync/createDependencyTree.js.map +1 -0
- package/features/DepsSync/createReferenceFile.d.ts +7 -0
- package/features/DepsSync/createReferenceFile.js +26 -0
- package/features/DepsSync/createReferenceFile.js.map +1 -0
- package/features/DepsSync/index.d.ts +2 -0
- package/features/DepsSync/index.js +2 -0
- package/features/DepsSync/paths.d.ts +3 -0
- package/features/DepsSync/paths.js +5 -0
- package/features/DepsSync/paths.js.map +1 -0
- package/features/DepsSync/types.d.ts +45 -0
- package/features/DepsSync/types.js +10 -0
- package/features/DepsSync/types.js.map +1 -0
- package/features/DisableTelemetryCommand.d.ts +11 -0
- package/features/DisableTelemetryCommand.js +34 -0
- package/features/DisableTelemetryCommand.js.map +1 -0
- package/features/EnableTelemetryCommand.d.ts +11 -0
- package/features/EnableTelemetryCommand.js +34 -0
- package/features/EnableTelemetryCommand.js.map +1 -0
- package/features/ExtensionCommand/ExtensionCommand.d.ts +12 -0
- package/features/ExtensionCommand/ExtensionCommand.js +68 -0
- package/features/ExtensionCommand/ExtensionCommand.js.map +1 -0
- package/features/ExtensionCommand/index.d.ts +1 -0
- package/features/ExtensionCommand/index.js +1 -0
- package/features/InfoCommand/InfoCommand.d.ts +10 -0
- package/features/InfoCommand/InfoCommand.js +66 -0
- package/features/InfoCommand/InfoCommand.js.map +1 -0
- package/features/InfoCommand/PrintInfoForEnv.d.ts +14 -0
- package/features/InfoCommand/PrintInfoForEnv.js +37 -0
- package/features/InfoCommand/PrintInfoForEnv.js.map +1 -0
- package/features/InfoCommand/index.d.ts +1 -0
- package/features/InfoCommand/index.js +1 -0
- package/features/IsCi/IsCi.d.ts +7 -0
- package/features/IsCi/IsCi.js +20 -0
- package/features/IsCi/IsCi.js.map +1 -0
- package/features/IsCi/index.d.ts +1 -0
- package/features/IsCi/index.js +1 -0
- package/features/OpenCommand.d.ts +10 -0
- package/features/OpenCommand.js +55 -0
- package/features/OpenCommand.js.map +1 -0
- package/features/UpgradeCommand/UpgradeCommand.d.ts +29 -0
- package/features/UpgradeCommand/UpgradeCommand.js +123 -0
- package/features/UpgradeCommand/UpgradeCommand.js.map +1 -0
- package/features/UpgradeCommand/UpgradeCommandHandler.d.ts +11 -0
- package/features/UpgradeCommand/UpgradeCommandHandler.js +105 -0
- package/features/UpgradeCommand/UpgradeCommandHandler.js.map +1 -0
- package/features/UpgradeCommand/abstraction.d.ts +23 -0
- package/features/UpgradeCommand/abstraction.js +5 -0
- package/features/UpgradeCommand/abstraction.js.map +1 -0
- package/features/UpgradeCommand/feature.d.ts +4 -0
- package/features/UpgradeCommand/feature.js +13 -0
- package/features/UpgradeCommand/feature.js.map +1 -0
- package/features/UpgradeCommand/index.d.ts +2 -0
- package/features/UpgradeCommand/index.js +2 -0
- package/features/Wcp/LinkProjectCommand.d.ts +13 -0
- package/features/Wcp/LinkProjectCommand.js +127 -0
- package/features/Wcp/LinkProjectCommand.js.map +1 -0
- package/features/Wcp/LoginCommand.d.ts +13 -0
- package/features/Wcp/LoginCommand.js +112 -0
- package/features/Wcp/LoginCommand.js.map +1 -0
- package/features/Wcp/LogoutCommand.d.ts +13 -0
- package/features/Wcp/LogoutCommand.js +35 -0
- package/features/Wcp/LogoutCommand.js.map +1 -0
- package/features/Wcp/WhoAmICommand.d.ts +15 -0
- package/features/Wcp/WhoAmICommand.js +38 -0
- package/features/Wcp/WhoAmICommand.js.map +1 -0
- package/features/common/index.d.ts +1 -0
- package/features/common/index.js +1 -0
- package/features/common/options.d.ts +20 -0
- package/features/common/options.js +43 -0
- package/features/common/options.js.map +1 -0
- package/features/globalOptions/LogLevelGlobalOption.d.ts +5 -0
- package/features/globalOptions/LogLevelGlobalOption.js +31 -0
- package/features/globalOptions/LogLevelGlobalOption.js.map +1 -0
- package/features/globalOptions/ShowLogsGlobalOption.d.ts +5 -0
- package/features/globalOptions/ShowLogsGlobalOption.js +22 -0
- package/features/globalOptions/ShowLogsGlobalOption.js.map +1 -0
- package/features/globalOptions/StackTraceGlobalOption.d.ts +5 -0
- package/features/globalOptions/StackTraceGlobalOption.js +22 -0
- package/features/globalOptions/StackTraceGlobalOption.js.map +1 -0
- package/features/globalOptions/TraceGlobalOption.d.ts +5 -0
- package/features/globalOptions/TraceGlobalOption.js +22 -0
- package/features/globalOptions/TraceGlobalOption.js.map +1 -0
- package/features/globalOptions/index.d.ts +4 -0
- package/features/globalOptions/index.js +4 -0
- package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.d.ts +6 -0
- package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js +21 -0
- package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js.map +1 -0
- package/features/gracefulErrorHandlers/index.d.ts +1 -0
- package/features/gracefulErrorHandlers/index.js +1 -0
- package/features/index.d.ts +18 -0
- package/features/index.js +18 -0
- package/features/utils/index.d.ts +1 -0
- package/features/utils/index.js +1 -0
- package/features/utils/measureDuration.d.ts +1 -0
- package/features/utils/measureDuration.js +10 -0
- package/features/utils/measureDuration.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +55 -0
- package/services/ArgvParserService/ArgvParserService.d.ts +7 -0
- package/services/ArgvParserService/ArgvParserService.js +35 -0
- package/services/ArgvParserService/ArgvParserService.js.map +1 -0
- package/services/ArgvParserService/index.d.ts +1 -0
- package/services/ArgvParserService/index.js +1 -0
- package/services/CliParamsService/CliParamsService.d.ts +7 -0
- package/services/CliParamsService/CliParamsService.js +24 -0
- package/services/CliParamsService/CliParamsService.js.map +1 -0
- package/services/CliParamsService/index.d.ts +1 -0
- package/services/CliParamsService/index.js +1 -0
- package/services/CommandsRegistryService/CommandsRegistryService.d.ts +7 -0
- package/services/CommandsRegistryService/CommandsRegistryService.js +25 -0
- package/services/CommandsRegistryService/CommandsRegistryService.js.map +1 -0
- package/services/CommandsRegistryService/index.d.ts +1 -0
- package/services/CommandsRegistryService/index.js +1 -0
- package/services/DefaultAppsService/DefaultAppsService.d.ts +5 -0
- package/services/DefaultAppsService/DefaultAppsService.js +15 -0
- package/services/DefaultAppsService/DefaultAppsService.js.map +1 -0
- package/services/DefaultAppsService/index.d.ts +1 -0
- package/services/DefaultAppsService/index.js +1 -0
- package/services/GetArgvService/GetArgvService.d.ts +7 -0
- package/services/GetArgvService/GetArgvService.js +20 -0
- package/services/GetArgvService/GetArgvService.js.map +1 -0
- package/services/GetArgvService/index.d.ts +1 -0
- package/services/GetArgvService/index.js +1 -0
- package/services/GetCliRunnerService/GetCliRunnerService.d.ts +13 -0
- package/services/GetCliRunnerService/GetCliRunnerService.js +135 -0
- package/services/GetCliRunnerService/GetCliRunnerService.js.map +1 -0
- package/services/GetCliRunnerService/index.d.ts +1 -0
- package/services/GetCliRunnerService/index.js +1 -0
- package/services/GetIsCiService/GetIsCiService.d.ts +5 -0
- package/services/GetIsCiService/GetIsCiService.js +16 -0
- package/services/GetIsCiService/GetIsCiService.js.map +1 -0
- package/services/GetIsCiService/index.d.ts +1 -0
- package/services/GetIsCiService/index.js +1 -0
- package/services/GetProjectSdkService/GetProjectSdkService.d.ts +9 -0
- package/services/GetProjectSdkService/GetProjectSdkService.js +32 -0
- package/services/GetProjectSdkService/GetProjectSdkService.js.map +1 -0
- package/services/GetProjectSdkService/index.d.ts +1 -0
- package/services/GetProjectSdkService/index.js +1 -0
- package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.d.ts +7 -0
- package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js +25 -0
- package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js.map +1 -0
- package/services/GlobalOptionsRegistryService/index.d.ts +1 -0
- package/services/GlobalOptionsRegistryService/index.js +1 -0
- package/services/LoggerService/LoggerService.d.ts +18 -0
- package/services/LoggerService/LoggerService.js +88 -0
- package/services/LoggerService/LoggerService.js.map +1 -0
- package/services/LoggerService/index.d.ts +1 -0
- package/services/LoggerService/index.js +1 -0
- package/services/RunCliRunnerService/RunCliRunnerService.d.ts +11 -0
- package/services/RunCliRunnerService/RunCliRunnerService.js +22 -0
- package/services/RunCliRunnerService/RunCliRunnerService.js.map +1 -0
- package/services/RunCliRunnerService/index.d.ts +1 -0
- package/services/RunCliRunnerService/index.js +1 -0
- package/services/StdioService/StdioService.d.ts +13 -0
- package/services/StdioService/StdioService.js +21 -0
- package/services/StdioService/StdioService.js.map +1 -0
- package/services/StdioService/index.d.ts +1 -0
- package/services/StdioService/index.js +1 -0
- package/services/UiService/UiService.d.ts +35 -0
- package/services/UiService/UiService.js +83 -0
- package/services/UiService/UiService.js.map +1 -0
- package/services/UiService/index.d.ts +1 -0
- package/services/UiService/index.js +1 -0
- package/services/index.d.ts +13 -0
- package/services/index.js +13 -0
- package/utils/ManuallyReportedError.d.ts +3 -0
- package/utils/ManuallyReportedError.js +10 -0
- package/utils/ManuallyReportedError.js.map +1 -0
- package/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.d.ts +1 -0
- package/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js +53 -0
- package/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js.map +1 -0
- package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.d.ts +1 -0
- package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.js +12 -0
- package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.js.map +1 -0
- package/utils/ensureSameWebinyPackageVersions/hashYarnLock.d.ts +1 -0
- package/utils/ensureSameWebinyPackageVersions/hashYarnLock.js +16 -0
- package/utils/ensureSameWebinyPackageVersions/hashYarnLock.js.map +1 -0
- package/utils/ensureSameWebinyPackageVersions/index.d.ts +6 -0
- package/utils/ensureSameWebinyPackageVersions/index.js +6 -0
- package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.d.ts +1 -0
- package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js +31 -0
- package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js.map +1 -0
- package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.d.ts +1 -0
- package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js +13 -0
- package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js.map +1 -0
- package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.d.ts +1 -0
- package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js +24 -0
- package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js.map +1 -0
- package/utils/suppressPunycodeWarnings.d.ts +4 -0
- package/utils/suppressPunycodeWarnings.js +7 -0
- package/utils/suppressPunycodeWarnings.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GlobalOptionsRegistryService.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GetArgvService, LoggerService } from "../../abstractions/index.js";
|
|
2
|
+
export declare class DefaultLoggerService implements LoggerService.Interface {
|
|
3
|
+
private readonly getArgvService;
|
|
4
|
+
private pinoLogger;
|
|
5
|
+
constructor(getArgvService: GetArgvService.Interface);
|
|
6
|
+
trace(message?: any, ...optionalParams: any[]): void;
|
|
7
|
+
fatal(message?: any, ...optionalParams: any[]): void;
|
|
8
|
+
debug(message?: any, ...optionalParams: any[]): void;
|
|
9
|
+
info(message?: any, ...optionalParams: any[]): void;
|
|
10
|
+
warn(message?: any, ...optionalParams: any[]): void;
|
|
11
|
+
error(message?: any, ...optionalParams: any[]): void;
|
|
12
|
+
log(message?: any, ...optionalParams: any[]): void;
|
|
13
|
+
private getLogger;
|
|
14
|
+
private getLogStream;
|
|
15
|
+
private getLogFileName;
|
|
16
|
+
private getLogLevel;
|
|
17
|
+
}
|
|
18
|
+
export declare const loggerService: import("@webiny/di").Implementation<typeof DefaultLoggerService>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { GetArgvService, LoggerService } from "../../abstractions/index.js";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { findUpSync } from "find-up";
|
|
5
|
+
import { pino } from "pino";
|
|
6
|
+
import pino_pretty from "pino-pretty";
|
|
7
|
+
import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
|
|
8
|
+
const DEFAULT_LOG_LEVEL = "info";
|
|
9
|
+
class DefaultLoggerService {
|
|
10
|
+
constructor(getArgvService){
|
|
11
|
+
this.getArgvService = getArgvService;
|
|
12
|
+
this.pinoLogger = null;
|
|
13
|
+
}
|
|
14
|
+
trace(message, ...optionalParams) {
|
|
15
|
+
const logger = this.getLogger();
|
|
16
|
+
logger.trace(message, ...optionalParams);
|
|
17
|
+
}
|
|
18
|
+
fatal(message, ...optionalParams) {
|
|
19
|
+
const logger = this.getLogger();
|
|
20
|
+
logger.fatal(message, ...optionalParams);
|
|
21
|
+
}
|
|
22
|
+
debug(message, ...optionalParams) {
|
|
23
|
+
const logger = this.getLogger();
|
|
24
|
+
logger.debug(message, ...optionalParams);
|
|
25
|
+
}
|
|
26
|
+
info(message, ...optionalParams) {
|
|
27
|
+
const logger = this.getLogger();
|
|
28
|
+
logger.info(message, ...optionalParams);
|
|
29
|
+
}
|
|
30
|
+
warn(message, ...optionalParams) {
|
|
31
|
+
const logger = this.getLogger();
|
|
32
|
+
logger.warn(message, ...optionalParams);
|
|
33
|
+
}
|
|
34
|
+
error(message, ...optionalParams) {
|
|
35
|
+
const logger = this.getLogger();
|
|
36
|
+
logger.error(message, ...optionalParams);
|
|
37
|
+
}
|
|
38
|
+
log(message, ...optionalParams) {
|
|
39
|
+
const logger = this.getLogger();
|
|
40
|
+
logger.info(message, ...optionalParams);
|
|
41
|
+
}
|
|
42
|
+
getLogger() {
|
|
43
|
+
if (this.pinoLogger) return this.pinoLogger;
|
|
44
|
+
const logStream = this.getLogStream();
|
|
45
|
+
const level = this.getLogLevel();
|
|
46
|
+
this.pinoLogger = pino({
|
|
47
|
+
level
|
|
48
|
+
}, logStream);
|
|
49
|
+
return this.pinoLogger;
|
|
50
|
+
}
|
|
51
|
+
getLogStream() {
|
|
52
|
+
const argv = this.getArgvService.execute();
|
|
53
|
+
if (argv.showLogs) return pino_pretty({
|
|
54
|
+
ignore: "pid,hostname"
|
|
55
|
+
});
|
|
56
|
+
const webinyConfigPath = findUpSync("webiny.config.tsx");
|
|
57
|
+
if (!webinyConfigPath) throw new Error("Could not find project root path.");
|
|
58
|
+
const projectRootPath = node_path.dirname(webinyConfigPath);
|
|
59
|
+
const logsFolderPath = node_path.join(projectRootPath, ".webiny", "logs");
|
|
60
|
+
const logsFileName = this.getLogFileName();
|
|
61
|
+
if (!__rspack_external_node_fs_1b05aee1.existsSync(logsFolderPath)) __rspack_external_node_fs_1b05aee1.mkdirSync(logsFolderPath, {
|
|
62
|
+
recursive: true
|
|
63
|
+
});
|
|
64
|
+
const logFilePath = node_path.join(logsFolderPath, logsFileName);
|
|
65
|
+
return __rspack_external_node_fs_1b05aee1.createWriteStream(logFilePath, {
|
|
66
|
+
flags: "a"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
getLogFileName() {
|
|
70
|
+
const now = new Date();
|
|
71
|
+
const dateStr = now.toISOString().split("T")[0];
|
|
72
|
+
return `logs-${dateStr}.log`;
|
|
73
|
+
}
|
|
74
|
+
getLogLevel() {
|
|
75
|
+
const argv = this.getArgvService.execute();
|
|
76
|
+
return process.env.WEBINY_CLI_LOG_LEVEL || argv.logLevel || DEFAULT_LOG_LEVEL;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const loggerService = createImplementation({
|
|
80
|
+
abstraction: LoggerService,
|
|
81
|
+
implementation: DefaultLoggerService,
|
|
82
|
+
dependencies: [
|
|
83
|
+
GetArgvService
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
export { DefaultLoggerService, loggerService };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=LoggerService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services/LoggerService/LoggerService.js","sources":["../../../src/services/LoggerService/LoggerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GetArgvService, LoggerService } from \"~/abstractions/index.js\";\nimport * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport { findUpSync } from \"find-up\";\nimport { pino, type Logger } from \"pino\";\nimport pinoPretty from \"pino-pretty\";\n\nconst DEFAULT_LOG_LEVEL = \"info\";\n\nexport class DefaultLoggerService implements LoggerService.Interface {\n private pinoLogger: Logger | null = null;\n\n constructor(private readonly getArgvService: GetArgvService.Interface) {}\n\n trace(message?: any, ...optionalParams: any[]) {\n const logger = this.getLogger();\n logger.trace(message, ...optionalParams);\n }\n\n fatal(message?: any, ...optionalParams: any[]) {\n const logger = this.getLogger();\n logger.fatal(message, ...optionalParams);\n }\n\n debug(message?: any, ...optionalParams: any[]) {\n const logger = this.getLogger();\n logger.debug(message, ...optionalParams);\n }\n\n info(message?: any, ...optionalParams: any[]) {\n const logger = this.getLogger();\n logger.info(message, ...optionalParams);\n }\n\n warn(message?: any, ...optionalParams: any[]) {\n const logger = this.getLogger();\n logger.warn(message, ...optionalParams);\n }\n\n error(message?: any, ...optionalParams: any[]) {\n const logger = this.getLogger();\n logger.error(message, ...optionalParams);\n }\n\n log(message?: any, ...optionalParams: any[]) {\n const logger = this.getLogger();\n logger.info(message, ...optionalParams);\n }\n\n private getLogger() {\n if (this.pinoLogger) {\n return this.pinoLogger;\n }\n\n const logStream = this.getLogStream();\n const level = this.getLogLevel();\n\n this.pinoLogger = pino({ level }, logStream);\n\n return this.pinoLogger;\n }\n\n private getLogStream() {\n const argv = this.getArgvService.execute();\n if (argv.showLogs) {\n return pinoPretty({\n ignore: \"pid,hostname\"\n });\n }\n\n // Wanted to use `GetProjectSdkService` to get project root path, but\n // to get that, had to call async method, which is not allowed in constructor.\n // TODO: implement a better way to get project root path.\n const webinyConfigPath = findUpSync(\"webiny.config.tsx\");\n if (!webinyConfigPath) {\n // Should not happen, but just in case.\n throw new Error(\"Could not find project root path.\");\n }\n\n const projectRootPath = path.dirname(webinyConfigPath!);\n\n const logsFolderPath = path.join(projectRootPath, \".webiny\", \"logs\");\n const logsFileName = this.getLogFileName();\n\n if (!fs.existsSync(logsFolderPath)) {\n fs.mkdirSync(logsFolderPath, { recursive: true });\n }\n\n const logFilePath = path.join(logsFolderPath, logsFileName);\n\n // Ensure the file exists or can be appended to\n return fs.createWriteStream(logFilePath, { flags: \"a\" });\n }\n\n private getLogFileName() {\n const now = new Date();\n const dateStr = now.toISOString().split(\"T\")[0];\n return `logs-${dateStr}.log`;\n }\n\n private getLogLevel() {\n const argv = this.getArgvService.execute();\n return process.env.WEBINY_CLI_LOG_LEVEL || argv.logLevel || DEFAULT_LOG_LEVEL;\n }\n}\n\nexport const loggerService = createImplementation({\n abstraction: LoggerService,\n implementation: DefaultLoggerService,\n dependencies: [GetArgvService]\n});\n"],"names":["DEFAULT_LOG_LEVEL","DefaultLoggerService","getArgvService","message","optionalParams","logger","logStream","level","pino","argv","pinoPretty","webinyConfigPath","findUpSync","Error","projectRootPath","path","logsFolderPath","logsFileName","fs","logFilePath","now","Date","dateStr","process","loggerService","createImplementation","LoggerService","GetArgvService"],"mappings":";;;;;;;AAQA,MAAMA,oBAAoB;AAEnB,MAAMC;IAGT,YAA6BC,cAAwC,CAAE;aAA1CA,cAAc,GAAdA;aAFrB,UAAU,GAAkB;IAEoC;IAExE,MAAMC,OAAa,EAAE,GAAGC,cAAqB,EAAE;QAC3C,MAAMC,SAAS,IAAI,CAAC,SAAS;QAC7BA,OAAO,KAAK,CAACF,YAAYC;IAC7B;IAEA,MAAMD,OAAa,EAAE,GAAGC,cAAqB,EAAE;QAC3C,MAAMC,SAAS,IAAI,CAAC,SAAS;QAC7BA,OAAO,KAAK,CAACF,YAAYC;IAC7B;IAEA,MAAMD,OAAa,EAAE,GAAGC,cAAqB,EAAE;QAC3C,MAAMC,SAAS,IAAI,CAAC,SAAS;QAC7BA,OAAO,KAAK,CAACF,YAAYC;IAC7B;IAEA,KAAKD,OAAa,EAAE,GAAGC,cAAqB,EAAE;QAC1C,MAAMC,SAAS,IAAI,CAAC,SAAS;QAC7BA,OAAO,IAAI,CAACF,YAAYC;IAC5B;IAEA,KAAKD,OAAa,EAAE,GAAGC,cAAqB,EAAE;QAC1C,MAAMC,SAAS,IAAI,CAAC,SAAS;QAC7BA,OAAO,IAAI,CAACF,YAAYC;IAC5B;IAEA,MAAMD,OAAa,EAAE,GAAGC,cAAqB,EAAE;QAC3C,MAAMC,SAAS,IAAI,CAAC,SAAS;QAC7BA,OAAO,KAAK,CAACF,YAAYC;IAC7B;IAEA,IAAID,OAAa,EAAE,GAAGC,cAAqB,EAAE;QACzC,MAAMC,SAAS,IAAI,CAAC,SAAS;QAC7BA,OAAO,IAAI,CAACF,YAAYC;IAC5B;IAEQ,YAAY;QAChB,IAAI,IAAI,CAAC,UAAU,EACf,OAAO,IAAI,CAAC,UAAU;QAG1B,MAAME,YAAY,IAAI,CAAC,YAAY;QACnC,MAAMC,QAAQ,IAAI,CAAC,WAAW;QAE9B,IAAI,CAAC,UAAU,GAAGC,KAAK;YAAED;QAAM,GAAGD;QAElC,OAAO,IAAI,CAAC,UAAU;IAC1B;IAEQ,eAAe;QACnB,MAAMG,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO;QACxC,IAAIA,KAAK,QAAQ,EACb,OAAOC,YAAW;YACd,QAAQ;QACZ;QAMJ,MAAMC,mBAAmBC,WAAW;QACpC,IAAI,CAACD,kBAED,MAAM,IAAIE,MAAM;QAGpB,MAAMC,kBAAkBC,UAAAA,OAAY,CAACJ;QAErC,MAAMK,iBAAiBD,UAAAA,IAAS,CAACD,iBAAiB,WAAW;QAC7D,MAAMG,eAAe,IAAI,CAAC,cAAc;QAExC,IAAI,CAACC,mCAAAA,UAAa,CAACF,iBACfE,mCAAAA,SAAY,CAACF,gBAAgB;YAAE,WAAW;QAAK;QAGnD,MAAMG,cAAcJ,UAAAA,IAAS,CAACC,gBAAgBC;QAG9C,OAAOC,mCAAAA,iBAAoB,CAACC,aAAa;YAAE,OAAO;QAAI;IAC1D;IAEQ,iBAAiB;QACrB,MAAMC,MAAM,IAAIC;QAChB,MAAMC,UAAUF,IAAI,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE;QAC/C,OAAO,CAAC,KAAK,EAAEE,QAAQ,IAAI,CAAC;IAChC;IAEQ,cAAc;QAClB,MAAMb,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO;QACxC,OAAOc,QAAQ,GAAG,CAAC,oBAAoB,IAAId,KAAK,QAAQ,IAAIT;IAChE;AACJ;AAEO,MAAMwB,gBAAgBC,qBAAqB;IAC9C,aAAaC;IACb,gBAAgBzB;IAChB,cAAc;QAAC0B;KAAe;AAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LoggerService.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LoggerService.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GetCliRunnerService, RunCliRunnerService } from "../../abstractions/index.js";
|
|
2
|
+
export declare class DefaultRunCliRunnerService implements RunCliRunnerService.Interface {
|
|
3
|
+
private readonly getCliRunnerService;
|
|
4
|
+
constructor(getCliRunnerService: GetCliRunnerService.Interface);
|
|
5
|
+
execute(): Promise<{
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
$0: string;
|
|
8
|
+
_: (string | number)[];
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare const runCliRunnerService: import("@webiny/di").Implementation<typeof DefaultRunCliRunnerService>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { GetCliRunnerService, RunCliRunnerService } from "../../abstractions/index.js";
|
|
3
|
+
import { hideBin } from "yargs/helpers";
|
|
4
|
+
class DefaultRunCliRunnerService {
|
|
5
|
+
constructor(getCliRunnerService){
|
|
6
|
+
this.getCliRunnerService = getCliRunnerService;
|
|
7
|
+
}
|
|
8
|
+
async execute() {
|
|
9
|
+
const cliRunner = await this.getCliRunnerService.execute();
|
|
10
|
+
return cliRunner.parseAsync(hideBin(process.argv));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const runCliRunnerService = createImplementation({
|
|
14
|
+
abstraction: RunCliRunnerService,
|
|
15
|
+
implementation: DefaultRunCliRunnerService,
|
|
16
|
+
dependencies: [
|
|
17
|
+
GetCliRunnerService
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
export { DefaultRunCliRunnerService, runCliRunnerService };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=RunCliRunnerService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services/RunCliRunnerService/RunCliRunnerService.js","sources":["../../../src/services/RunCliRunnerService/RunCliRunnerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GetCliRunnerService, RunCliRunnerService } from \"~/abstractions/index.js\";\nimport { hideBin } from \"yargs/helpers\";\nimport { Argv } from \"yargs\";\n\nexport class DefaultRunCliRunnerService implements RunCliRunnerService.Interface {\n constructor(private readonly getCliRunnerService: GetCliRunnerService.Interface) {}\n\n async execute() {\n const cliRunner = (await this.getCliRunnerService.execute()) as Argv;\n // Use process.argv directly since it's the actual argv being used\n return cliRunner.parseAsync(hideBin(process.argv));\n }\n}\n\nexport const runCliRunnerService = createImplementation({\n abstraction: RunCliRunnerService,\n implementation: DefaultRunCliRunnerService,\n dependencies: [GetCliRunnerService]\n});\n"],"names":["DefaultRunCliRunnerService","getCliRunnerService","cliRunner","hideBin","process","runCliRunnerService","createImplementation","RunCliRunnerService","GetCliRunnerService"],"mappings":";;;AAKO,MAAMA;IACT,YAA6BC,mBAAkD,CAAE;aAApDA,mBAAmB,GAAnBA;IAAqD;IAElF,MAAM,UAAU;QACZ,MAAMC,YAAa,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO;QAEzD,OAAOA,UAAU,UAAU,CAACC,QAAQC,QAAQ,IAAI;IACpD;AACJ;AAEO,MAAMC,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBP;IAChB,cAAc;QAACQ;KAAoB;AACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RunCliRunnerService.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RunCliRunnerService.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StdioService } from "../../abstractions/index.js";
|
|
2
|
+
export declare class DefaultStdioService implements StdioService.Interface {
|
|
3
|
+
getStdout(): NodeJS.WriteStream & {
|
|
4
|
+
fd: 1;
|
|
5
|
+
};
|
|
6
|
+
getStderr(): NodeJS.WriteStream & {
|
|
7
|
+
fd: 2;
|
|
8
|
+
};
|
|
9
|
+
getStdin(): NodeJS.ReadStream & {
|
|
10
|
+
fd: 0;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare const stdioService: import("@webiny/di").Implementation<typeof DefaultStdioService>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { StdioService } from "../../abstractions/index.js";
|
|
3
|
+
class DefaultStdioService {
|
|
4
|
+
getStdout() {
|
|
5
|
+
return process.stdout;
|
|
6
|
+
}
|
|
7
|
+
getStderr() {
|
|
8
|
+
return process.stderr;
|
|
9
|
+
}
|
|
10
|
+
getStdin() {
|
|
11
|
+
return process.stdin;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const stdioService = createImplementation({
|
|
15
|
+
abstraction: StdioService,
|
|
16
|
+
implementation: DefaultStdioService,
|
|
17
|
+
dependencies: []
|
|
18
|
+
});
|
|
19
|
+
export { DefaultStdioService, stdioService };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=StdioService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services/StdioService/StdioService.js","sources":["../../../src/services/StdioService/StdioService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { StdioService } from \"~/abstractions/index.js\";\n\nexport class DefaultStdioService implements StdioService.Interface {\n getStdout() {\n return process.stdout;\n }\n\n getStderr() {\n return process.stderr;\n }\n\n getStdin() {\n return process.stdin;\n }\n}\n\nexport const stdioService = createImplementation({\n abstraction: StdioService,\n implementation: DefaultStdioService,\n dependencies: []\n});\n"],"names":["DefaultStdioService","process","stdioService","createImplementation","StdioService"],"mappings":";;AAGO,MAAMA;IACT,YAAY;QACR,OAAOC,QAAQ,MAAM;IACzB;IAEA,YAAY;QACR,OAAOA,QAAQ,MAAM;IACzB;IAEA,WAAW;QACP,OAAOA,QAAQ,KAAK;IACxB;AACJ;AAEO,MAAMC,eAAeC,qBAAqB;IAC7C,aAAaC;IACb,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./StdioService.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./StdioService.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UiService, StdioService, IsCi } from "../../abstractions/index.js";
|
|
2
|
+
export declare class DefaultUiService implements UiService.Interface {
|
|
3
|
+
private readonly stdio;
|
|
4
|
+
private readonly isCi;
|
|
5
|
+
constructor(stdio: StdioService.Interface, isCi: IsCi.Interface);
|
|
6
|
+
raw(text: string): void;
|
|
7
|
+
text(text: string): void;
|
|
8
|
+
textBold(text: string): void;
|
|
9
|
+
emptyLine(): void;
|
|
10
|
+
success(text: string, ...args: any[]): void;
|
|
11
|
+
info(text: string, ...args: any[]): void;
|
|
12
|
+
warning(text: string, ...args: any[]): void;
|
|
13
|
+
error(text: string, ...args: any[]): void;
|
|
14
|
+
debug(text: string, ...args: any[]): void;
|
|
15
|
+
private typedColorizedText;
|
|
16
|
+
/**
|
|
17
|
+
* Prefixes every line of `message` with the gutter, wrapping the text to the terminal width
|
|
18
|
+
* first.
|
|
19
|
+
*
|
|
20
|
+
* The wrap has to happen here rather than being left to the terminal. Writing the whole message
|
|
21
|
+
* as one long line means the terminal wraps it at column 0, with no knowledge of the gutter -
|
|
22
|
+
* so continuation lines start underneath the pipe instead of underneath the text, and a wrapped
|
|
23
|
+
* sentence reads as though it belongs to a different paragraph.
|
|
24
|
+
*/
|
|
25
|
+
private applyGutter;
|
|
26
|
+
/**
|
|
27
|
+
* Width available for the text itself, or `null` when there is nothing to wrap to.
|
|
28
|
+
*
|
|
29
|
+
* `columns` is undefined whenever stdout is not a TTY - piped to a file, or read by another
|
|
30
|
+
* process. Wrapping to a guessed width there would bake line breaks into output that something
|
|
31
|
+
* else is going to reflow anyway, so the message is left as a single line.
|
|
32
|
+
*/
|
|
33
|
+
private getTextWidth;
|
|
34
|
+
}
|
|
35
|
+
export declare const uiService: import("@webiny/di").Implementation<typeof DefaultUiService>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import util from "util";
|
|
4
|
+
import wrap_ansi from "wrap-ansi";
|
|
5
|
+
import { IsCi, StdioService, UiService } from "../../abstractions/index.js";
|
|
6
|
+
const NEW_LINE = "\n";
|
|
7
|
+
const PIPE_SYMBOL = "┃";
|
|
8
|
+
const GUTTER_WIDTH = 2;
|
|
9
|
+
const MIN_TEXT_WIDTH = 20;
|
|
10
|
+
const LOG_COLORS = {
|
|
11
|
+
info: chalk.blueBright,
|
|
12
|
+
error: chalk.red,
|
|
13
|
+
warning: chalk.yellow,
|
|
14
|
+
success: chalk.green,
|
|
15
|
+
debug: chalk.gray
|
|
16
|
+
};
|
|
17
|
+
class DefaultUiService {
|
|
18
|
+
constructor(stdio, isCi){
|
|
19
|
+
this.stdio = stdio;
|
|
20
|
+
this.isCi = isCi;
|
|
21
|
+
}
|
|
22
|
+
raw(text) {
|
|
23
|
+
this.stdio.getStdout().write(text);
|
|
24
|
+
}
|
|
25
|
+
text(text) {
|
|
26
|
+
this.stdio.getStdout().write(text);
|
|
27
|
+
this.stdio.getStdout().write(NEW_LINE);
|
|
28
|
+
}
|
|
29
|
+
textBold(text) {
|
|
30
|
+
this.text(chalk.bold(text));
|
|
31
|
+
}
|
|
32
|
+
emptyLine() {
|
|
33
|
+
this.stdio.getStdout().write(chalk.gray("∙") + NEW_LINE);
|
|
34
|
+
}
|
|
35
|
+
success(text, ...args) {
|
|
36
|
+
this.typedColorizedText("success", text, ...args);
|
|
37
|
+
}
|
|
38
|
+
info(text, ...args) {
|
|
39
|
+
this.typedColorizedText("info", text, ...args);
|
|
40
|
+
}
|
|
41
|
+
warning(text, ...args) {
|
|
42
|
+
this.typedColorizedText("warning", text, ...args);
|
|
43
|
+
}
|
|
44
|
+
error(text, ...args) {
|
|
45
|
+
this.typedColorizedText("error", text, ...args);
|
|
46
|
+
}
|
|
47
|
+
debug(text, ...args) {
|
|
48
|
+
this.typedColorizedText("debug", text, ...args);
|
|
49
|
+
}
|
|
50
|
+
typedColorizedText(type, text, ...args) {
|
|
51
|
+
if (this.isCi.execute()) {
|
|
52
|
+
const prefix = `${type}: `;
|
|
53
|
+
return this.text(prefix + util.format(text, ...args));
|
|
54
|
+
}
|
|
55
|
+
const gutter = `${LOG_COLORS[type](PIPE_SYMBOL)} `;
|
|
56
|
+
const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, (match)=>LOG_COLORS[type](match));
|
|
57
|
+
const message = util.format(textWithColorizedPlaceholders, ...args);
|
|
58
|
+
return this.text(this.applyGutter(message, gutter));
|
|
59
|
+
}
|
|
60
|
+
applyGutter(message, gutter) {
|
|
61
|
+
const textWidth = this.getTextWidth();
|
|
62
|
+
const wrapped = textWidth ? wrap_ansi(message, textWidth, {
|
|
63
|
+
hard: true
|
|
64
|
+
}) : message;
|
|
65
|
+
return wrapped.split(NEW_LINE).map((line)=>gutter + line).join(NEW_LINE);
|
|
66
|
+
}
|
|
67
|
+
getTextWidth() {
|
|
68
|
+
const columns = this.stdio.getStdout().columns;
|
|
69
|
+
if (!columns) return null;
|
|
70
|
+
return Math.max(columns - GUTTER_WIDTH, MIN_TEXT_WIDTH);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const uiService = createImplementation({
|
|
74
|
+
abstraction: UiService,
|
|
75
|
+
implementation: DefaultUiService,
|
|
76
|
+
dependencies: [
|
|
77
|
+
StdioService,
|
|
78
|
+
IsCi
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
export { DefaultUiService, uiService };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=UiService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services/UiService/UiService.js","sources":["../../../src/services/UiService/UiService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport chalk from \"chalk\";\nimport util from \"util\";\nimport wrapAnsi from \"wrap-ansi\";\nimport { UiService, StdioService, IsCi } from \"~/abstractions/index.js\";\n\nconst NEW_LINE = \"\\n\";\nconst PIPE_SYMBOL = \"┃\";\n\n// Visible width of the `┃ ` gutter that prefixes every line of a typed message. Hardcoded rather\n// than measured because the pipe is a single-column glyph and the colour codes around it occupy no\n// columns at all.\nconst GUTTER_WIDTH = 2;\n\n// A floor for very narrow terminals, so the wrap width can never go to zero or negative.\nconst MIN_TEXT_WIDTH = 20;\n\nconst LOG_COLORS = {\n info: chalk.blueBright,\n error: chalk.red,\n warning: chalk.yellow,\n success: chalk.green,\n debug: chalk.gray\n} as const;\n\nexport class DefaultUiService implements UiService.Interface {\n constructor(\n private readonly stdio: StdioService.Interface,\n private readonly isCi: IsCi.Interface\n ) {}\n\n raw(text: string) {\n this.stdio.getStdout().write(text);\n }\n\n text(text: string) {\n this.stdio.getStdout().write(text);\n this.stdio.getStdout().write(NEW_LINE);\n }\n\n textBold(text: string) {\n this.text(chalk.bold(text));\n }\n\n emptyLine() {\n this.stdio.getStdout().write(chalk.gray(\"∙\") + NEW_LINE);\n }\n\n // The following methods are used to print texts with a specific type prefix.\n success(text: string, ...args: any[]) {\n this.typedColorizedText(\"success\", text, ...args);\n }\n\n info(text: string, ...args: any[]) {\n this.typedColorizedText(\"info\", text, ...args);\n }\n\n warning(text: string, ...args: any[]) {\n this.typedColorizedText(\"warning\", text, ...args);\n }\n\n error(text: string, ...args: any[]) {\n this.typedColorizedText(\"error\", text, ...args);\n }\n\n debug(text: string, ...args: any[]) {\n this.typedColorizedText(\"debug\", text, ...args);\n }\n\n private typedColorizedText(type: keyof typeof LOG_COLORS, text: string, ...args: any[]) {\n // Use plain text format in CI environments.\n if (this.isCi.execute()) {\n const prefix = `${type}: `;\n return this.text(prefix + util.format(text, ...args));\n }\n\n const gutter = `${LOG_COLORS[type](PIPE_SYMBOL)} `;\n\n // Replace all placeholders (match with `/%[a-zA-Z]/g` regex) with colorized values.\n const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, match => {\n return LOG_COLORS[type](match);\n });\n\n const message = util.format(textWithColorizedPlaceholders, ...args);\n\n return this.text(this.applyGutter(message, gutter));\n }\n\n /**\n * Prefixes every line of `message` with the gutter, wrapping the text to the terminal width\n * first.\n *\n * The wrap has to happen here rather than being left to the terminal. Writing the whole message\n * as one long line means the terminal wraps it at column 0, with no knowledge of the gutter -\n * so continuation lines start underneath the pipe instead of underneath the text, and a wrapped\n * sentence reads as though it belongs to a different paragraph.\n */\n private applyGutter(message: string, gutter: string) {\n const textWidth = this.getTextWidth();\n\n // `hard` also breaks words longer than a whole line - a long file path, or a URL. Letting\n // those overflow would hand them straight back to the terminal's own wrapping, which is\n // the column-0 behaviour this method exists to avoid.\n const wrapped = textWidth ? wrapAnsi(message, textWidth, { hard: true }) : message;\n\n return wrapped\n .split(NEW_LINE)\n .map(line => gutter + line)\n .join(NEW_LINE);\n }\n\n /**\n * Width available for the text itself, or `null` when there is nothing to wrap to.\n *\n * `columns` is undefined whenever stdout is not a TTY - piped to a file, or read by another\n * process. Wrapping to a guessed width there would bake line breaks into output that something\n * else is going to reflow anyway, so the message is left as a single line.\n */\n private getTextWidth() {\n const columns = this.stdio.getStdout().columns;\n if (!columns) {\n return null;\n }\n\n return Math.max(columns - GUTTER_WIDTH, MIN_TEXT_WIDTH);\n }\n}\n\nexport const uiService = createImplementation({\n abstraction: UiService,\n implementation: DefaultUiService,\n dependencies: [StdioService, IsCi]\n});\n"],"names":["NEW_LINE","PIPE_SYMBOL","GUTTER_WIDTH","MIN_TEXT_WIDTH","LOG_COLORS","chalk","DefaultUiService","stdio","isCi","text","args","type","prefix","util","gutter","textWithColorizedPlaceholders","match","message","textWidth","wrapped","wrapAnsi","line","columns","Math","uiService","createImplementation","UiService","StdioService","IsCi"],"mappings":";;;;;AAMA,MAAMA,WAAW;AACjB,MAAMC,cAAc;AAKpB,MAAMC,eAAe;AAGrB,MAAMC,iBAAiB;AAEvB,MAAMC,aAAa;IACf,MAAMC,MAAM,UAAU;IACtB,OAAOA,MAAM,GAAG;IAChB,SAASA,MAAM,MAAM;IACrB,SAASA,MAAM,KAAK;IACpB,OAAOA,MAAM,IAAI;AACrB;AAEO,MAAMC;IACT,YACqBC,KAA6B,EAC7BC,IAAoB,CACvC;aAFmBD,KAAK,GAALA;aACAC,IAAI,GAAJA;IAClB;IAEH,IAAIC,IAAY,EAAE;QACd,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;IACjC;IAEA,KAAKA,IAAY,EAAE;QACf,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACT;IACjC;IAEA,SAASS,IAAY,EAAE;QACnB,IAAI,CAAC,IAAI,CAACJ,MAAM,IAAI,CAACI;IACzB;IAEA,YAAY;QACR,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACJ,MAAM,IAAI,CAAC,OAAOL;IACnD;IAGA,QAAQS,IAAY,EAAE,GAAGC,IAAW,EAAE;QAClC,IAAI,CAAC,kBAAkB,CAAC,WAAWD,SAASC;IAChD;IAEA,KAAKD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAC/B,IAAI,CAAC,kBAAkB,CAAC,QAAQD,SAASC;IAC7C;IAEA,QAAQD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAClC,IAAI,CAAC,kBAAkB,CAAC,WAAWD,SAASC;IAChD;IAEA,MAAMD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAChC,IAAI,CAAC,kBAAkB,CAAC,SAASD,SAASC;IAC9C;IAEA,MAAMD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAChC,IAAI,CAAC,kBAAkB,CAAC,SAASD,SAASC;IAC9C;IAEQ,mBAAmBC,IAA6B,EAAEF,IAAY,EAAE,GAAGC,IAAW,EAAE;QAEpF,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI;YACrB,MAAME,SAAS,GAAGD,KAAK,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,IAAI,CAACC,SAASC,KAAK,MAAM,CAACJ,SAASC;QACnD;QAEA,MAAMI,SAAS,GAAGV,UAAU,CAACO,KAAK,CAACV,aAAa,CAAC,CAAC;QAGlD,MAAMc,gCAAgCN,KAAK,OAAO,CAAC,cAAcO,CAAAA,QACtDZ,UAAU,CAACO,KAAK,CAACK;QAG5B,MAAMC,UAAUJ,KAAK,MAAM,CAACE,kCAAkCL;QAE9D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAACO,SAASH;IAC/C;IAWQ,YAAYG,OAAe,EAAEH,MAAc,EAAE;QACjD,MAAMI,YAAY,IAAI,CAAC,YAAY;QAKnC,MAAMC,UAAUD,YAAYE,UAASH,SAASC,WAAW;YAAE,MAAM;QAAK,KAAKD;QAE3E,OAAOE,QACF,KAAK,CAACnB,UACN,GAAG,CAACqB,CAAAA,OAAQP,SAASO,MACrB,IAAI,CAACrB;IACd;IASQ,eAAe;QACnB,MAAMsB,UAAU,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,OAAO;QAC9C,IAAI,CAACA,SACD,OAAO;QAGX,OAAOC,KAAK,GAAG,CAACD,UAAUpB,cAAcC;IAC5C;AACJ;AAEO,MAAMqB,YAAYC,qBAAqB;IAC1C,aAAaC;IACb,gBAAgBpB;IAChB,cAAc;QAACqB;QAAcC;KAAK;AACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./UiService.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./UiService.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./ArgvParserService/index.js";
|
|
2
|
+
export * from "./DefaultAppsService/index.js";
|
|
3
|
+
export * from "./CliParamsService/index.js";
|
|
4
|
+
export * from "./CommandsRegistryService/index.js";
|
|
5
|
+
export * from "./GetArgvService/index.js";
|
|
6
|
+
export * from "./GetCliRunnerService/index.js";
|
|
7
|
+
export * from "./GetIsCiService/index.js";
|
|
8
|
+
export * from "./GlobalOptionsRegistryService/index.js";
|
|
9
|
+
export * from "./GetProjectSdkService/index.js";
|
|
10
|
+
export * from "./LoggerService/index.js";
|
|
11
|
+
export * from "./RunCliRunnerService/index.js";
|
|
12
|
+
export * from "./StdioService/index.js";
|
|
13
|
+
export * from "./UiService/index.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./ArgvParserService/index.js";
|
|
2
|
+
export * from "./DefaultAppsService/index.js";
|
|
3
|
+
export * from "./CliParamsService/index.js";
|
|
4
|
+
export * from "./CommandsRegistryService/index.js";
|
|
5
|
+
export * from "./GetArgvService/index.js";
|
|
6
|
+
export * from "./GetCliRunnerService/index.js";
|
|
7
|
+
export * from "./GetIsCiService/index.js";
|
|
8
|
+
export * from "./GlobalOptionsRegistryService/index.js";
|
|
9
|
+
export * from "./GetProjectSdkService/index.js";
|
|
10
|
+
export * from "./LoggerService/index.js";
|
|
11
|
+
export * from "./RunCliRunnerService/index.js";
|
|
12
|
+
export * from "./StdioService/index.js";
|
|
13
|
+
export * from "./UiService/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ManuallyReportedError.js","sources":["../../src/utils/ManuallyReportedError.ts"],"sourcesContent":["export class ManuallyReportedError extends Error {\n static from(cause: Error): ManuallyReportedError {\n return new ManuallyReportedError(cause.message, { cause });\n }\n}\n"],"names":["ManuallyReportedError","Error","cause"],"mappings":"AAAO,MAAMA,8BAA8BC;IACvC,OAAO,KAAKC,KAAY,EAAyB;QAC7C,OAAO,IAAIF,sBAAsBE,MAAM,OAAO,EAAE;YAAEA;QAAM;IAC5D;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ensureSameWebinyPackageVersions: () => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { getCacheFilePath } from "./getCacheFilePath.js";
|
|
3
|
+
import { hashYarnLock } from "./hashYarnLock.js";
|
|
4
|
+
import { listWebinyPackageVersions } from "./listWebinyPackageVersions.js";
|
|
5
|
+
import { readClearedYarnLockHash } from "./readClearedYarnLockHash.js";
|
|
6
|
+
import { writeClearedYarnLockHash } from "./writeClearedYarnLockHash.js";
|
|
7
|
+
const DEBUG_FLAG = "--debug";
|
|
8
|
+
const usingDebugFlag = process.argv.includes(DEBUG_FLAG);
|
|
9
|
+
const SKIP_WEBINY_VERSIONS_CHECK_FLAG = "--no-package-versions-check";
|
|
10
|
+
const skippingWebinyVersionsCheck = process.argv.includes(SKIP_WEBINY_VERSIONS_CHECK_FLAG);
|
|
11
|
+
const ensureSameWebinyPackageVersions = ()=>{
|
|
12
|
+
if (skippingWebinyVersionsCheck) return;
|
|
13
|
+
const cacheFilePath = getCacheFilePath();
|
|
14
|
+
const yarnLockHash = hashYarnLock();
|
|
15
|
+
if (cacheFilePath && yarnLockHash) {
|
|
16
|
+
const clearedYarnLockHash = readClearedYarnLockHash(cacheFilePath);
|
|
17
|
+
if (clearedYarnLockHash === yarnLockHash) return;
|
|
18
|
+
}
|
|
19
|
+
let webinyVersions;
|
|
20
|
+
try {
|
|
21
|
+
webinyVersions = listWebinyPackageVersions();
|
|
22
|
+
} catch (e) {
|
|
23
|
+
const message = [
|
|
24
|
+
"Failed to inspect Webiny package versions."
|
|
25
|
+
];
|
|
26
|
+
if (!usingDebugFlag) message.push(`For more information, try running with ${chalk.yellow(DEBUG_FLAG)}.`);
|
|
27
|
+
message.push("Learn more: https://webiny.link/webiny-package-versions-check");
|
|
28
|
+
console.warn(chalk.yellow(message.join(" ")));
|
|
29
|
+
if (usingDebugFlag) console.warn(e);
|
|
30
|
+
console.log();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const mismatchedPackages = [];
|
|
34
|
+
for (const [pkg, versions] of webinyVersions.entries())if (versions.size > 1) mismatchedPackages.push([
|
|
35
|
+
pkg,
|
|
36
|
+
versions
|
|
37
|
+
]);
|
|
38
|
+
if (mismatchedPackages.length > 0) {
|
|
39
|
+
const message = [
|
|
40
|
+
"The following Webiny packages have mismatched versions:",
|
|
41
|
+
"",
|
|
42
|
+
...mismatchedPackages.map(([pkg, versions])=>`‣ ${pkg}: ${Array.from(versions).join(", ")}`),
|
|
43
|
+
"",
|
|
44
|
+
`Please ensure all Webiny packages are using the same version. If you think this is a mistake, you can also skip this check by appending the ${chalk.red(SKIP_WEBINY_VERSIONS_CHECK_FLAG)} flag. Learn more: https://webiny.link/webiny-package-versions-check`
|
|
45
|
+
];
|
|
46
|
+
console.error(chalk.red(message.join("\n")));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
if (cacheFilePath && yarnLockHash) writeClearedYarnLockHash(cacheFilePath, yarnLockHash);
|
|
50
|
+
};
|
|
51
|
+
export { ensureSameWebinyPackageVersions };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=ensureSameWebinyPackageVersions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { getCacheFilePath } from \"./getCacheFilePath.js\";\nimport { hashYarnLock } from \"./hashYarnLock.js\";\nimport { listWebinyPackageVersions } from \"./listWebinyPackageVersions.js\";\nimport { readClearedYarnLockHash } from \"./readClearedYarnLockHash.js\";\nimport { writeClearedYarnLockHash } from \"./writeClearedYarnLockHash.js\";\n\nconst DEBUG_FLAG = \"--debug\";\nconst usingDebugFlag = process.argv.includes(DEBUG_FLAG);\n\nconst SKIP_WEBINY_VERSIONS_CHECK_FLAG = \"--no-package-versions-check\";\nconst skippingWebinyVersionsCheck = process.argv.includes(SKIP_WEBINY_VERSIONS_CHECK_FLAG);\n\n/*\n * Two `@webiny/*` packages on different versions in one install produce failures that are hard to\n * read, so the CLI refuses to start on a mismatch. The check runs on every invocation and the `yarn\n * info` call behind it is slow, so a pass is remembered against the lockfile hash and skipped while\n * that hash holds.\n *\n * Only a pass is cached. A failed `yarn info` warns and returns, and a mismatch exits, so neither\n * writes the file and the next run checks again.\n */\nexport const ensureSameWebinyPackageVersions = (): void => {\n // Just in case, we want to allow users to skip the check.\n if (skippingWebinyVersionsCheck) {\n return;\n }\n\n const cacheFilePath = getCacheFilePath();\n const yarnLockHash = hashYarnLock();\n\n if (cacheFilePath && yarnLockHash) {\n const clearedYarnLockHash = readClearedYarnLockHash(cacheFilePath);\n if (clearedYarnLockHash === yarnLockHash) {\n return;\n }\n }\n\n let webinyVersions: Map<string, Set<string>>;\n try {\n webinyVersions = listWebinyPackageVersions();\n } catch (e) {\n const message = [\"Failed to inspect Webiny package versions.\"];\n\n if (!usingDebugFlag) {\n message.push(`For more information, try running with ${chalk.yellow(DEBUG_FLAG)}.`);\n }\n\n message.push(\"Learn more: https://webiny.link/webiny-package-versions-check\");\n\n console.warn(chalk.yellow(message.join(\" \")));\n if (usingDebugFlag) {\n console.warn(e);\n }\n\n console.log();\n return;\n }\n\n const mismatchedPackages: Array<[string, Set<string>]> = [];\n for (const [pkg, versions] of webinyVersions.entries()) {\n if (versions.size > 1) {\n mismatchedPackages.push([pkg, versions]);\n }\n }\n\n if (mismatchedPackages.length > 0) {\n const message = [\n \"The following Webiny packages have mismatched versions:\",\n \"\",\n ...mismatchedPackages.map(([pkg, versions]) => {\n return `‣ ${pkg}: ${Array.from(versions).join(\", \")}`;\n }),\n \"\",\n `Please ensure all Webiny packages are using the same version. If you think this is a mistake, you can also skip this check by appending the ${chalk.red(\n SKIP_WEBINY_VERSIONS_CHECK_FLAG\n )} flag. Learn more: https://webiny.link/webiny-package-versions-check`\n ];\n\n console.error(chalk.red(message.join(\"\\n\")));\n process.exit(1);\n }\n\n if (cacheFilePath && yarnLockHash) {\n writeClearedYarnLockHash(cacheFilePath, yarnLockHash);\n }\n};\n"],"names":["DEBUG_FLAG","usingDebugFlag","process","SKIP_WEBINY_VERSIONS_CHECK_FLAG","skippingWebinyVersionsCheck","ensureSameWebinyPackageVersions","cacheFilePath","getCacheFilePath","yarnLockHash","hashYarnLock","clearedYarnLockHash","readClearedYarnLockHash","webinyVersions","listWebinyPackageVersions","e","message","chalk","console","mismatchedPackages","pkg","versions","Array","writeClearedYarnLockHash"],"mappings":";;;;;;AAOA,MAAMA,aAAa;AACnB,MAAMC,iBAAiBC,QAAQ,IAAI,CAAC,QAAQ,CAACF;AAE7C,MAAMG,kCAAkC;AACxC,MAAMC,8BAA8BF,QAAQ,IAAI,CAAC,QAAQ,CAACC;AAWnD,MAAME,kCAAkC;IAE3C,IAAID,6BACA;IAGJ,MAAME,gBAAgBC;IACtB,MAAMC,eAAeC;IAErB,IAAIH,iBAAiBE,cAAc;QAC/B,MAAME,sBAAsBC,wBAAwBL;QACpD,IAAII,wBAAwBF,cACxB;IAER;IAEA,IAAII;IACJ,IAAI;QACAA,iBAAiBC;IACrB,EAAE,OAAOC,GAAG;QACR,MAAMC,UAAU;YAAC;SAA6C;QAE9D,IAAI,CAACd,gBACDc,QAAQ,IAAI,CAAC,CAAC,uCAAuC,EAAEC,MAAM,MAAM,CAAChB,YAAY,CAAC,CAAC;QAGtFe,QAAQ,IAAI,CAAC;QAEbE,QAAQ,IAAI,CAACD,MAAM,MAAM,CAACD,QAAQ,IAAI,CAAC;QACvC,IAAId,gBACAgB,QAAQ,IAAI,CAACH;QAGjBG,QAAQ,GAAG;QACX;IACJ;IAEA,MAAMC,qBAAmD,EAAE;IAC3D,KAAK,MAAM,CAACC,KAAKC,SAAS,IAAIR,eAAe,OAAO,GAChD,IAAIQ,SAAS,IAAI,GAAG,GAChBF,mBAAmB,IAAI,CAAC;QAACC;QAAKC;KAAS;IAI/C,IAAIF,mBAAmB,MAAM,GAAG,GAAG;QAC/B,MAAMH,UAAU;YACZ;YACA;eACGG,mBAAmB,GAAG,CAAC,CAAC,CAACC,KAAKC,SAAS,GAC/B,CAAC,EAAE,EAAED,IAAI,EAAE,EAAEE,MAAM,IAAI,CAACD,UAAU,IAAI,CAAC,OAAO;YAEzD;YACA,CAAC,4IAA4I,EAAEJ,MAAM,GAAG,CACpJb,iCACF,oEAAoE,CAAC;SAC1E;QAEDc,QAAQ,KAAK,CAACD,MAAM,GAAG,CAACD,QAAQ,IAAI,CAAC;QACrCb,QAAQ,IAAI,CAAC;IACjB;IAEA,IAAII,iBAAiBE,cACjBc,yBAAyBhB,eAAeE;AAEhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCacheFilePath: () => string | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { findUpSync } from "find-up";
|
|
3
|
+
const CACHE_FILE_NAME = "package-versions-check.json";
|
|
4
|
+
const getCacheFilePath = ()=>{
|
|
5
|
+
const webinyConfigFilePath = findUpSync("webiny.config.tsx");
|
|
6
|
+
if (!webinyConfigFilePath) return null;
|
|
7
|
+
const projectRootFolderPath = path.dirname(webinyConfigFilePath);
|
|
8
|
+
return path.join(projectRootFolderPath, ".webiny", CACHE_FILE_NAME);
|
|
9
|
+
};
|
|
10
|
+
export { getCacheFilePath };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=getCacheFilePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ensureSameWebinyPackageVersions/getCacheFilePath.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/getCacheFilePath.ts"],"sourcesContent":["import path from \"path\";\nimport { findUpSync } from \"find-up\";\n\nconst CACHE_FILE_NAME = \"package-versions-check.json\";\n\n/*\n * Locates `.webiny/package-versions-check.json` for the project the CLI was invoked in.\n *\n * The version check runs before the CLI has a DI container, so this cannot go through\n * `LocalStorageService`. It finds the project root the same way `GetProjectService` does, by walking\n * up to `webiny.config.tsx`, so both agree on which project is being written to. Returns null outside\n * a project, where there is nowhere to cache.\n */\nexport const getCacheFilePath = (): string | null => {\n const webinyConfigFilePath = findUpSync(\"webiny.config.tsx\");\n if (!webinyConfigFilePath) {\n return null;\n }\n\n const projectRootFolderPath = path.dirname(webinyConfigFilePath);\n\n return path.join(projectRootFolderPath, \".webiny\", CACHE_FILE_NAME);\n};\n"],"names":["CACHE_FILE_NAME","getCacheFilePath","webinyConfigFilePath","findUpSync","projectRootFolderPath","path"],"mappings":";;AAGA,MAAMA,kBAAkB;AAUjB,MAAMC,mBAAmB;IAC5B,MAAMC,uBAAuBC,WAAW;IACxC,IAAI,CAACD,sBACD,OAAO;IAGX,MAAME,wBAAwBC,KAAK,OAAO,CAACH;IAE3C,OAAOG,KAAK,IAAI,CAACD,uBAAuB,WAAWJ;AACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hashYarnLock: () => string | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import crypto_0 from "crypto";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { findUpSync } from "find-up";
|
|
4
|
+
const hashYarnLock = ()=>{
|
|
5
|
+
const yarnLockFilePath = findUpSync("yarn.lock");
|
|
6
|
+
if (!yarnLockFilePath) return null;
|
|
7
|
+
try {
|
|
8
|
+
const contents = fs.readFileSync(yarnLockFilePath);
|
|
9
|
+
return crypto_0.createHash("sha1").update(contents).digest("hex");
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export { hashYarnLock };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=hashYarnLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ensureSameWebinyPackageVersions/hashYarnLock.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/hashYarnLock.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport fs from \"fs\";\nimport { findUpSync } from \"find-up\";\n\n/*\n * Hashes the lockfile, which is what keys the cached result of the version check.\n *\n * `yarn info` resolves from the install state, so its answer can only change when `yarn.lock` does.\n * That makes the lockfile hash a faithful key: a manifest edit that has not been installed yet cannot\n * change what the check sees.\n *\n * Returns null when there is no lockfile, and also when one exists but cannot be read, which happens\n * if an install is rewriting it. Callers treat null as a cache miss, because the cache exists to skip\n * work and must never be the reason the CLI fails to start.\n */\nexport const hashYarnLock = (): string | null => {\n const yarnLockFilePath = findUpSync(\"yarn.lock\");\n if (!yarnLockFilePath) {\n return null;\n }\n\n try {\n const contents = fs.readFileSync(yarnLockFilePath);\n\n return crypto.createHash(\"sha1\").update(contents).digest(\"hex\");\n } catch {\n return null;\n }\n};\n"],"names":["hashYarnLock","yarnLockFilePath","findUpSync","contents","fs","crypto"],"mappings":";;;AAeO,MAAMA,eAAe;IACxB,MAAMC,mBAAmBC,WAAW;IACpC,IAAI,CAACD,kBACD,OAAO;IAGX,IAAI;QACA,MAAME,WAAWC,GAAG,YAAY,CAACH;QAEjC,OAAOI,SAAAA,UAAiB,CAAC,QAAQ,MAAM,CAACF,UAAU,MAAM,CAAC;IAC7D,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./ensureSameWebinyPackageVersions.js";
|
|
2
|
+
export * from "./getCacheFilePath.js";
|
|
3
|
+
export * from "./hashYarnLock.js";
|
|
4
|
+
export * from "./listWebinyPackageVersions.js";
|
|
5
|
+
export * from "./readClearedYarnLockHash.js";
|
|
6
|
+
export * from "./writeClearedYarnLockHash.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./ensureSameWebinyPackageVersions.js";
|
|
2
|
+
export * from "./getCacheFilePath.js";
|
|
3
|
+
export * from "./hashYarnLock.js";
|
|
4
|
+
export * from "./listWebinyPackageVersions.js";
|
|
5
|
+
export * from "./readClearedYarnLockHash.js";
|
|
6
|
+
export * from "./writeClearedYarnLockHash.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const listWebinyPackageVersions: () => Map<string, Set<string>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { execaSync } from "execa";
|
|
2
|
+
const listWebinyPackageVersions = ()=>{
|
|
3
|
+
const patterns = [
|
|
4
|
+
"@webiny/*",
|
|
5
|
+
"webiny"
|
|
6
|
+
];
|
|
7
|
+
const args = [
|
|
8
|
+
"info",
|
|
9
|
+
...patterns,
|
|
10
|
+
"--name-only",
|
|
11
|
+
"--all",
|
|
12
|
+
"--recursive",
|
|
13
|
+
"--json"
|
|
14
|
+
];
|
|
15
|
+
const { stdout } = execaSync("yarn", args, {
|
|
16
|
+
encoding: "utf8"
|
|
17
|
+
});
|
|
18
|
+
const lines = stdout.trim().split("\n").map((line)=>JSON.parse(line));
|
|
19
|
+
const versionMap = new Map();
|
|
20
|
+
for (const entry of lines){
|
|
21
|
+
const match = entry.match(/^(webiny|@webiny\/[^@]+)@npm:(.+)$/);
|
|
22
|
+
if (!match) continue;
|
|
23
|
+
const [, pkg, version] = match;
|
|
24
|
+
if (!versionMap.has(pkg)) versionMap.set(pkg, new Set());
|
|
25
|
+
versionMap.get(pkg).add(version);
|
|
26
|
+
}
|
|
27
|
+
return versionMap;
|
|
28
|
+
};
|
|
29
|
+
export { listWebinyPackageVersions };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=listWebinyPackageVersions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.ts"],"sourcesContent":["import { execaSync } from \"execa\";\n\n/*\n * Asks yarn which versions of each Webiny package the install resolved to, keyed by package name.\n * More than one version in a set is the mismatch the check is looking for.\n *\n * Both patterns are needed. `@webiny/*` covers the scoped packages, and `webiny` covers the unscoped\n * umbrella package, which is the one a generated project actually depends on: `template.package.json`\n * ships `webiny` and `@webiny/mcp` and nothing else. A scoped-only glob leaves the single most\n * important package in a user's project out of the comparison.\n *\n * `--recursive` is what makes this work outside this monorepo. `--all` on its own reports only the\n * direct dependencies of the workspaces, and in a generated project the only direct Webiny\n * dependencies are `webiny` and `@webiny/mcp`; every scoped package is transitive underneath them.\n * Without it the check would compare two packages and call that a pass. It costs nothing measurable,\n * and in this repo the two flags return the same set because every package here is a workspace.\n *\n * This is the expensive call the cache exists to avoid: it takes the better part of a second in a\n * project of any size.\n */\nexport const listWebinyPackageVersions = (): Map<string, Set<string>> => {\n const patterns = [\"@webiny/*\", \"webiny\"];\n const args = [\"info\", ...patterns, \"--name-only\", \"--all\", \"--recursive\", \"--json\"];\n\n const { stdout } = execaSync(\"yarn\", args, {\n encoding: \"utf8\"\n });\n\n // Each line is a JSON string, so parse them individually.\n const lines = stdout\n .trim()\n .split(\"\\n\")\n .map(line => JSON.parse(line) as string);\n\n const versionMap = new Map<string, Set<string>>();\n\n for (const entry of lines) {\n // Example entries: \"@webiny/cli@npm:5.42.3\" and \"webiny@npm:5.42.3\". Anything resolved to\n // something other than npm, a workspace in this repo for instance, has no version to compare.\n const match = entry.match(/^(webiny|@webiny\\/[^@]+)@npm:(.+)$/);\n if (!match) {\n continue;\n }\n\n const [, pkg, version] = match;\n if (!versionMap.has(pkg)) {\n versionMap.set(pkg, new Set());\n }\n\n versionMap.get(pkg)!.add(version);\n }\n\n return versionMap;\n};\n"],"names":["listWebinyPackageVersions","patterns","args","stdout","execaSync","lines","line","JSON","versionMap","Map","entry","match","pkg","version","Set"],"mappings":";AAoBO,MAAMA,4BAA4B;IACrC,MAAMC,WAAW;QAAC;QAAa;KAAS;IACxC,MAAMC,OAAO;QAAC;WAAWD;QAAU;QAAe;QAAS;QAAe;KAAS;IAEnF,MAAM,EAAEE,MAAM,EAAE,GAAGC,UAAU,QAAQF,MAAM;QACvC,UAAU;IACd;IAGA,MAAMG,QAAQF,OACT,IAAI,GACJ,KAAK,CAAC,MACN,GAAG,CAACG,CAAAA,OAAQC,KAAK,KAAK,CAACD;IAE5B,MAAME,aAAa,IAAIC;IAEvB,KAAK,MAAMC,SAASL,MAAO;QAGvB,MAAMM,QAAQD,MAAM,KAAK,CAAC;QAC1B,IAAI,CAACC,OACD;QAGJ,MAAM,GAAGC,KAAKC,QAAQ,GAAGF;QACzB,IAAI,CAACH,WAAW,GAAG,CAACI,MAChBJ,WAAW,GAAG,CAACI,KAAK,IAAIE;QAG5BN,WAAW,GAAG,CAACI,KAAM,GAAG,CAACC;IAC7B;IAEA,OAAOL;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readClearedYarnLockHash: (cacheFilePath: string) => string | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
const readClearedYarnLockHash = (cacheFilePath)=>{
|
|
3
|
+
try {
|
|
4
|
+
const contents = fs.readFileSync(cacheFilePath, "utf8");
|
|
5
|
+
const cache = JSON.parse(contents);
|
|
6
|
+
return cache.yarnLockHash ?? null;
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export { readClearedYarnLockHash };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=readClearedYarnLockHash.js.map
|