@webiny/cli-core 0.0.0-unstable.e622468070 → 0.0.0-unstable.eb81deee7e
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 +2 -1
- package/Cli.js +12 -11
- package/Cli.js.map +1 -1
- package/abstractions/createAbstraction.js +3 -2
- package/abstractions/createAbstraction.js.map +1 -1
- package/abstractions/features/CliCommand.d.ts +4 -0
- package/abstractions/features/CliCommand.js +2 -1
- package/abstractions/features/CliCommand.js.map +1 -1
- package/abstractions/features/ErrorHandler.js +2 -1
- package/abstractions/features/ErrorHandler.js.map +1 -1
- package/abstractions/features/GlobalCliOption.js +2 -1
- package/abstractions/features/GlobalCliOption.js.map +1 -1
- package/abstractions/features/IsCi.js +2 -1
- package/abstractions/features/IsCi.js.map +1 -1
- package/abstractions/features/index.js +0 -2
- package/abstractions/features/types.js +0 -3
- package/abstractions/index.js +0 -2
- package/abstractions/services/ArgvParserService.js +2 -1
- package/abstractions/services/ArgvParserService.js.map +1 -1
- package/abstractions/services/CliParamsService.js +2 -1
- package/abstractions/services/CliParamsService.js.map +1 -1
- package/abstractions/services/CommandsRegistryService.js +2 -1
- package/abstractions/services/CommandsRegistryService.js.map +1 -1
- 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.js +2 -1
- package/abstractions/services/GetArgvService.js.map +1 -1
- package/abstractions/services/GetCliRunnerService.js +2 -1
- package/abstractions/services/GetCliRunnerService.js.map +1 -1
- package/abstractions/services/GetIsCiService.js +2 -1
- package/abstractions/services/GetIsCiService.js.map +1 -1
- package/abstractions/services/GetProjectSdkService.js +2 -1
- package/abstractions/services/GetProjectSdkService.js.map +1 -1
- package/abstractions/services/GlobalOptionsRegistryService.js +2 -1
- package/abstractions/services/GlobalOptionsRegistryService.js.map +1 -1
- package/abstractions/services/LoggerService.js +2 -1
- package/abstractions/services/LoggerService.js.map +1 -1
- package/abstractions/services/RunCliRunnerService.js +2 -1
- package/abstractions/services/RunCliRunnerService.js.map +1 -1
- package/abstractions/services/StdioService.js +2 -1
- package/abstractions/services/StdioService.js.map +1 -1
- package/abstractions/services/UiService.js +2 -1
- package/abstractions/services/UiService.js.map +1 -1
- package/abstractions/services/index.d.ts +1 -0
- package/abstractions/services/index.js +1 -2
- package/createCliContainer.d.ts +1 -1
- package/createCliContainer.js +88 -119
- package/createCliContainer.js.map +1 -1
- package/decorators/CommandsWithGracefulErrorHandling.js +34 -32
- package/decorators/CommandsWithGracefulErrorHandling.js.map +1 -1
- package/decorators/index.d.ts +0 -1
- package/decorators/index.js +0 -3
- package/exports/cli/command.js +0 -2
- package/exports/cli.d.ts +2 -0
- package/exports/cli.js +2 -0
- package/extensions/CliCommand.d.ts +3 -7
- package/extensions/CliCommand.js +15 -18
- package/extensions/CliCommand.js.map +1 -1
- package/extensions/CliCommandDecorator.d.ts +3 -7
- package/extensions/CliCommandDecorator.js +15 -18
- package/extensions/CliCommandDecorator.js.map +1 -1
- package/extensions/index.d.ts +2 -6
- package/extensions/index.js +5 -2
- package/extensions/index.js.map +1 -1
- package/features/AboutCommand.js +80 -86
- package/features/AboutCommand.js.map +1 -1
- package/features/BuildCommand/BuildCommand.d.ts +7 -3
- package/features/BuildCommand/BuildCommand.js +68 -37
- package/features/BuildCommand/BuildCommand.js.map +1 -1
- package/features/BuildCommand/buildRunners/BaseBuildRunner.js +10 -13
- package/features/BuildCommand/buildRunners/BaseBuildRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/BuildRunner.js +18 -21
- package/features/BuildCommand/buildRunners/BuildRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js +20 -19
- package/features/BuildCommand/buildRunners/MultipleBuildsRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/SingleBuildRunner.js +15 -14
- package/features/BuildCommand/buildRunners/SingleBuildRunner.js.map +1 -1
- package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js +3 -4
- package/features/BuildCommand/buildRunners/ZeroBuildsRunner.js.map +1 -1
- package/features/BuildCommand/index.js +0 -2
- package/features/ConfigCommand.js +55 -56
- package/features/ConfigCommand.js.map +1 -1
- package/features/DeployCommand/index.d.ts +20 -1
- package/features/DeployCommand/index.js +0 -3
- package/features/DepsSync/BuildDependencyTree.js +17 -22
- package/features/DepsSync/BuildDependencyTree.js.map +1 -1
- package/features/DepsSync/DependencyTree.js +108 -119
- package/features/DepsSync/DependencyTree.js.map +1 -1
- package/features/DepsSync/ListAllPackageJsonFiles.js +19 -14
- package/features/DepsSync/ListAllPackageJsonFiles.js.map +1 -1
- package/features/DepsSync/ListAllPackages.d.ts +1 -1
- package/features/DepsSync/ListAllPackages.js +9 -9
- package/features/DepsSync/ListAllPackages.js.map +1 -1
- package/features/DepsSync/commands/SyncDepsCommand.js +30 -24
- package/features/DepsSync/commands/SyncDepsCommand.js.map +1 -1
- package/features/DepsSync/commands/VerifyDepsCommand.js +70 -71
- package/features/DepsSync/commands/VerifyDepsCommand.js.map +1 -1
- package/features/DepsSync/createDependencyTree.d.ts +1 -1
- package/features/DepsSync/createDependencyTree.js +25 -18
- package/features/DepsSync/createDependencyTree.js.map +1 -1
- package/features/DepsSync/createReferenceFile.js +22 -26
- package/features/DepsSync/createReferenceFile.js.map +1 -1
- package/features/DepsSync/index.js +0 -2
- package/features/DepsSync/paths.js +3 -6
- package/features/DepsSync/paths.js.map +1 -1
- package/features/DepsSync/types.js +7 -6
- package/features/DepsSync/types.js.map +1 -1
- package/features/DisableTelemetryCommand.js +28 -25
- package/features/DisableTelemetryCommand.js.map +1 -1
- package/features/EnableTelemetryCommand.js +28 -25
- package/features/EnableTelemetryCommand.js.map +1 -1
- package/features/ExtensionCommand/ExtensionCommand.js +60 -63
- package/features/ExtensionCommand/ExtensionCommand.js.map +1 -1
- package/features/ExtensionCommand/index.js +0 -2
- package/features/InfoCommand/InfoCommand.js +58 -56
- package/features/InfoCommand/InfoCommand.js.map +1 -1
- package/features/InfoCommand/PrintInfoForEnv.js +31 -47
- package/features/InfoCommand/PrintInfoForEnv.js.map +1 -1
- package/features/InfoCommand/index.js +0 -2
- package/features/IsCi/IsCi.js +14 -11
- package/features/IsCi/IsCi.js.map +1 -1
- package/features/IsCi/index.js +1 -3
- package/features/OpenCommand.js +48 -47
- package/features/OpenCommand.js.map +1 -1
- 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.js +120 -139
- package/features/Wcp/LinkProjectCommand.js.map +1 -1
- package/features/Wcp/LoginCommand.js +104 -118
- package/features/Wcp/LoginCommand.js.map +1 -1
- package/features/Wcp/LogoutCommand.js +29 -23
- package/features/Wcp/LogoutCommand.js.map +1 -1
- package/features/Wcp/WhoAmICommand.js +33 -29
- package/features/Wcp/WhoAmICommand.js.map +1 -1
- package/features/common/index.js +0 -2
- package/features/common/options.js +41 -50
- package/features/common/options.js.map +1 -1
- package/features/globalOptions/LogLevelGlobalOption.js +25 -16
- package/features/globalOptions/LogLevelGlobalOption.js.map +1 -1
- package/features/globalOptions/ShowLogsGlobalOption.js +16 -15
- package/features/globalOptions/ShowLogsGlobalOption.js.map +1 -1
- package/features/globalOptions/StackTraceGlobalOption.js +16 -15
- package/features/globalOptions/StackTraceGlobalOption.js.map +1 -1
- 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 +1 -0
- package/features/globalOptions/index.js +1 -2
- package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js +12 -18
- package/features/gracefulErrorHandlers/MissingFilesInBuildGracefulErrorHandler.js.map +1 -1
- package/features/gracefulErrorHandlers/index.d.ts +0 -2
- package/features/gracefulErrorHandlers/index.js +0 -4
- package/features/index.d.ts +1 -5
- package/features/index.js +1 -7
- package/features/utils/index.js +0 -2
- package/features/utils/measureDuration.js +7 -8
- package/features/utils/measureDuration.js.map +1 -1
- package/index.js +0 -2
- package/package.json +38 -31
- package/services/ArgvParserService/ArgvParserService.js +27 -33
- package/services/ArgvParserService/ArgvParserService.js.map +1 -1
- package/services/ArgvParserService/index.js +0 -2
- package/services/CliParamsService/CliParamsService.js +18 -15
- package/services/CliParamsService/CliParamsService.js.map +1 -1
- package/services/CliParamsService/index.js +0 -2
- package/services/CommandsRegistryService/CommandsRegistryService.js +19 -13
- package/services/CommandsRegistryService/CommandsRegistryService.js.map +1 -1
- package/services/CommandsRegistryService/index.js +0 -2
- 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.js +14 -11
- package/services/GetArgvService/GetArgvService.js.map +1 -1
- package/services/GetArgvService/index.js +0 -2
- package/services/GetCliRunnerService/GetCliRunnerService.js +123 -148
- package/services/GetCliRunnerService/GetCliRunnerService.js.map +1 -1
- package/services/GetCliRunnerService/index.js +0 -2
- package/services/GetIsCiService/GetIsCiService.js +9 -8
- package/services/GetIsCiService/GetIsCiService.js.map +1 -1
- package/services/GetIsCiService/index.js +1 -3
- package/services/GetProjectSdkService/GetProjectSdkService.js +25 -24
- package/services/GetProjectSdkService/GetProjectSdkService.js.map +1 -1
- package/services/GetProjectSdkService/index.js +0 -2
- package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js +19 -13
- package/services/GlobalOptionsRegistryService/GlobalOptionsRegistryService.js.map +1 -1
- package/services/GlobalOptionsRegistryService/index.js +0 -2
- package/services/LoggerService/LoggerService.js +76 -88
- package/services/LoggerService/LoggerService.js.map +1 -1
- package/services/LoggerService/index.js +0 -2
- package/services/RunCliRunnerService/RunCliRunnerService.d.ts +1 -1
- package/services/RunCliRunnerService/RunCliRunnerService.js +15 -13
- package/services/RunCliRunnerService/RunCliRunnerService.js.map +1 -1
- package/services/RunCliRunnerService/index.js +0 -2
- package/services/StdioService/StdioService.js +15 -14
- package/services/StdioService/StdioService.js.map +1 -1
- package/services/StdioService/index.js +0 -2
- package/services/UiService/UiService.d.ts +18 -0
- package/services/UiService/UiService.js +71 -58
- package/services/UiService/UiService.js.map +1 -1
- package/services/UiService/index.js +0 -2
- package/services/index.d.ts +1 -0
- package/services/index.js +1 -2
- package/utils/ManuallyReportedError.js +7 -6
- package/utils/ManuallyReportedError.js.map +1 -1
- 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
- package/abstractions/features/index.js.map +0 -1
- package/abstractions/features/types.js.map +0 -1
- package/abstractions/index.js.map +0 -1
- package/abstractions/services/index.js.map +0 -1
- package/decorators/DeployCommandWithTelemetry.d.ts +0 -11
- package/decorators/DeployCommandWithTelemetry.js +0 -91
- package/decorators/DeployCommandWithTelemetry.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/exports/cli/command.js.map +0 -1
- package/exports/cli/index.d.ts +0 -2
- package/exports/cli/index.js +0 -4
- package/exports/cli/index.js.map +0 -1
- package/features/BuildCommand/index.js.map +0 -1
- package/features/DeployCommand/DeployCommand.d.ts +0 -30
- package/features/DeployCommand/DeployCommand.js +0 -168
- package/features/DeployCommand/DeployCommand.js.map +0 -1
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.d.ts +0 -20
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.js +0 -20
- package/features/DeployCommand/deployOutputs/BaseDeployOutput.js.map +0 -1
- package/features/DeployCommand/deployOutputs/DeployOutput.d.ts +0 -5
- package/features/DeployCommand/deployOutputs/DeployOutput.js +0 -24
- package/features/DeployCommand/deployOutputs/DeployOutput.js.map +0 -1
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.d.ts +0 -4
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js +0 -61
- package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js.map +0 -1
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.d.ts +0 -4
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js +0 -44
- package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js.map +0 -1
- package/features/DeployCommand/index.js.map +0 -1
- package/features/DepsSync/index.js.map +0 -1
- package/features/DestroyCommand/DestroyCommand.d.ts +0 -22
- package/features/DestroyCommand/DestroyCommand.js +0 -78
- package/features/DestroyCommand/DestroyCommand.js.map +0 -1
- package/features/DestroyCommand/index.d.ts +0 -1
- package/features/DestroyCommand/index.js +0 -3
- package/features/DestroyCommand/index.js.map +0 -1
- package/features/ExtensionCommand/index.js.map +0 -1
- package/features/InfoCommand/index.js.map +0 -1
- package/features/IsCi/index.js.map +0 -1
- package/features/OutputCommand.d.ts +0 -12
- package/features/OutputCommand.js +0 -79
- package/features/OutputCommand.js.map +0 -1
- package/features/PulumiCommand/PulumiCommand.d.ts +0 -13
- package/features/PulumiCommand/PulumiCommand.js +0 -50
- package/features/PulumiCommand/PulumiCommand.js.map +0 -1
- package/features/PulumiCommand/index.d.ts +0 -1
- package/features/PulumiCommand/index.js +0 -3
- package/features/PulumiCommand/index.js.map +0 -1
- package/features/RefreshCommand/RefreshCommand.d.ts +0 -12
- package/features/RefreshCommand/RefreshCommand.js +0 -45
- package/features/RefreshCommand/RefreshCommand.js.map +0 -1
- package/features/RefreshCommand/index.d.ts +0 -1
- package/features/RefreshCommand/index.js +0 -3
- package/features/RefreshCommand/index.js.map +0 -1
- package/features/WatchCommand/WatchCommand.d.ts +0 -11
- package/features/WatchCommand/WatchCommand.js +0 -143
- package/features/WatchCommand/WatchCommand.js.map +0 -1
- package/features/WatchCommand/createPrefixer.d.ts +0 -2
- package/features/WatchCommand/createPrefixer.js +0 -20
- package/features/WatchCommand/createPrefixer.js.map +0 -1
- package/features/WatchCommand/getRandomColorForString.d.ts +0 -1
- package/features/WatchCommand/getRandomColorForString.js +0 -11
- package/features/WatchCommand/getRandomColorForString.js.map +0 -1
- package/features/WatchCommand/index.d.ts +0 -1
- package/features/WatchCommand/index.js +0 -3
- package/features/WatchCommand/index.js.map +0 -1
- package/features/common/index.js.map +0 -1
- package/features/globalOptions/index.js.map +0 -1
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.d.ts +0 -6
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js +0 -26
- package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js.map +0 -1
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.d.ts +0 -6
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js +0 -29
- package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js.map +0 -1
- package/features/gracefulErrorHandlers/index.js.map +0 -1
- package/features/index.js.map +0 -1
- package/features/utils/index.js.map +0 -1
- package/index.js.map +0 -1
- package/services/ArgvParserService/index.js.map +0 -1
- package/services/CliParamsService/index.js.map +0 -1
- package/services/CommandsRegistryService/index.js.map +0 -1
- package/services/GetArgvService/index.js.map +0 -1
- package/services/GetCliRunnerService/index.js.map +0 -1
- package/services/GetIsCiService/index.js.map +0 -1
- package/services/GetProjectSdkService/index.js.map +0 -1
- package/services/GlobalOptionsRegistryService/index.js.map +0 -1
- package/services/LoggerService/index.js.map +0 -1
- package/services/RunCliRunnerService/index.js.map +0 -1
- package/services/StdioService/index.js.map +0 -1
- package/services/UiService/index.js.map +0 -1
- package/services/index.js.map +0 -1
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.ts"],"sourcesContent":["import fs from \"fs\";\n\n/*\n * Reads the lockfile hash recorded the last time the version check passed. Null means \"no usable\n * record\", covering a first run, a deleted cache and a file we cannot read or parse, all of which\n * should simply run the check again.\n */\nexport const readClearedYarnLockHash = (cacheFilePath: string): string | null => {\n try {\n const contents = fs.readFileSync(cacheFilePath, \"utf8\");\n const cache = JSON.parse(contents) as { yarnLockHash?: string };\n\n return cache.yarnLockHash ?? null;\n } catch {\n return null;\n }\n};\n"],"names":["readClearedYarnLockHash","cacheFilePath","contents","fs","cache","JSON"],"mappings":";AAOO,MAAMA,0BAA0B,CAACC;IACpC,IAAI;QACA,MAAMC,WAAWC,GAAG,YAAY,CAACF,eAAe;QAChD,MAAMG,QAAQC,KAAK,KAAK,CAACH;QAEzB,OAAOE,MAAM,YAAY,IAAI;IACjC,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const writeClearedYarnLockHash: (cacheFilePath: string, yarnLockHash: string) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import crypto_0 from "crypto";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
const writeClearedYarnLockHash = (cacheFilePath, yarnLockHash)=>{
|
|
5
|
+
const temporaryFilePath = `${cacheFilePath}.${process.pid}.${crypto_0.randomUUID()}.tmp`;
|
|
6
|
+
try {
|
|
7
|
+
fs.mkdirSync(path.dirname(cacheFilePath), {
|
|
8
|
+
recursive: true
|
|
9
|
+
});
|
|
10
|
+
fs.writeFileSync(temporaryFilePath, JSON.stringify({
|
|
11
|
+
yarnLockHash
|
|
12
|
+
}));
|
|
13
|
+
fs.renameSync(temporaryFilePath, cacheFilePath);
|
|
14
|
+
} catch {
|
|
15
|
+
try {
|
|
16
|
+
fs.rmSync(temporaryFilePath, {
|
|
17
|
+
force: true
|
|
18
|
+
});
|
|
19
|
+
} catch {}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export { writeClearedYarnLockHash };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=writeClearedYarnLockHash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport fs from \"fs\";\nimport path from \"path\";\n\n/*\n * Records the lockfile hash that the version check just passed on.\n *\n * Written to a temporary file and renamed into place, because `webiny watch` can be running while\n * another command starts. A plain write truncates first, so a reader arriving in that window would\n * parse a half-written file, treat it as a miss and pay for `yarn info` again. The rename is atomic,\n * and the temporary file sits in the same directory so it never crosses a filesystem boundary.\n */\nexport const writeClearedYarnLockHash = (cacheFilePath: string, yarnLockHash: string): void => {\n const temporaryFilePath = `${cacheFilePath}.${process.pid}.${crypto.randomUUID()}.tmp`;\n\n try {\n fs.mkdirSync(path.dirname(cacheFilePath), { recursive: true });\n fs.writeFileSync(temporaryFilePath, JSON.stringify({ yarnLockHash }));\n fs.renameSync(temporaryFilePath, cacheFilePath);\n } catch {\n // A read-only or otherwise unwritable project just pays for the check every time. Clear the\n // temporary file if we got as far as creating one, so failures don't pile up in `.webiny/`.\n try {\n fs.rmSync(temporaryFilePath, { force: true });\n } catch {\n // Nothing further to try.\n }\n }\n};\n"],"names":["writeClearedYarnLockHash","cacheFilePath","yarnLockHash","temporaryFilePath","process","crypto","fs","path","JSON"],"mappings":";;;AAYO,MAAMA,2BAA2B,CAACC,eAAuBC;IAC5D,MAAMC,oBAAoB,GAAGF,cAAc,CAAC,EAAEG,QAAQ,GAAG,CAAC,CAAC,EAAEC,SAAAA,UAAiB,GAAG,IAAI,CAAC;IAEtF,IAAI;QACAC,GAAG,SAAS,CAACC,KAAK,OAAO,CAACN,gBAAgB;YAAE,WAAW;QAAK;QAC5DK,GAAG,aAAa,CAACH,mBAAmBK,KAAK,SAAS,CAAC;YAAEN;QAAa;QAClEI,GAAG,UAAU,CAACH,mBAAmBF;IACrC,EAAE,OAAM;QAGJ,IAAI;YACAK,GAAG,MAAM,CAACH,mBAAmB;gBAAE,OAAO;YAAK;QAC/C,EAAE,OAAM,CAER;IACJ;AACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const originalConsoleError = console.error;
|
|
2
|
+
console.error = (message, ...args)=>{
|
|
3
|
+
if ("string" == typeof message && message.includes("punycode")) return;
|
|
4
|
+
originalConsoleError.call(console, message, ...args);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=suppressPunycodeWarnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/suppressPunycodeWarnings.js","sources":["../../src/utils/suppressPunycodeWarnings.ts"],"sourcesContent":["// Suppress the `punycode` deprecation warning emitted by transitive deps.\n// This is a known upstream issue we can't fix, so we filter it out.\nconst originalConsoleError = console.error;\nconsole.error = (message: unknown, ...args: unknown[]) => {\n if (typeof message === \"string\" && message.includes(\"punycode\")) {\n return;\n }\n originalConsoleError.call(console, message, ...args);\n};\n"],"names":["originalConsoleError","console","message","args"],"mappings":"AAEA,MAAMA,uBAAuBC,QAAQ,KAAK;AAC1CA,QAAQ,KAAK,GAAG,CAACC,SAAkB,GAAGC;IAClC,IAAI,AAAmB,YAAnB,OAAOD,WAAwBA,QAAQ,QAAQ,CAAC,aAChD;IAEJF,qBAAqB,IAAI,CAACC,SAASC,YAAYC;AACnD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CliCommandFactory","ErrorHandler","GlobalCliOption","IsCi"],"sources":["index.ts"],"sourcesContent":["export { CliCommandFactory } from \"./CliCommand.js\";\nexport { ErrorHandler } from \"./ErrorHandler.js\";\nexport { GlobalCliOption } from \"./GlobalCliOption.js\";\nexport { IsCi } from \"./IsCi.js\";\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,SAASC,YAAY;AACrB,SAASC,eAAe;AACxB,SAASC,IAAI","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { AppName } from \"@webiny/project\";\n\nexport interface IBaseAppParams {\n _: string[]; // TODO: implement this in a better way (handler method probably should have this in its context/meta data)\n app: AppName;\n env: string;\n variant?: string;\n region?: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./features/index.js\";\nexport * from \"./services/index.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ArgvParserService.js\";\nexport * from \"./CliParamsService.js\";\nexport * from \"./CommandsRegistryService.js\";\nexport * from \"./GetArgvService.js\";\nexport * from \"./GetCliRunnerService.js\";\nexport * from \"./GetIsCiService.js\";\nexport * from \"./GlobalOptionsRegistryService.js\";\nexport * from \"./GetProjectSdkService.js\";\nexport * from \"./LoggerService.js\";\nexport * from \"./RunCliRunnerService.js\";\nexport * from \"./StdioService.js\";\nexport * from \"./UiService.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CliCommandFactory, GetProjectSdkService } from "../abstractions/index.js";
|
|
2
|
-
export declare class DeployCommandWithTelemetry<TParams> implements CliCommandFactory.Interface<TParams> {
|
|
3
|
-
private getProjectSdkService;
|
|
4
|
-
private decoratee;
|
|
5
|
-
constructor(getProjectSdkService: GetProjectSdkService.Interface, decoratee: CliCommandFactory.Interface<TParams>);
|
|
6
|
-
execute(): Promise<import("../abstractions/features/CliCommand").ICliCommandDefinition<TParams>>;
|
|
7
|
-
private sendEvent;
|
|
8
|
-
}
|
|
9
|
-
export declare const deployCommandWithTelemetry: typeof DeployCommandWithTelemetry & {
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<import("../abstractions/features/CliCommand").ICliCommand<any>>;
|
|
11
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { isEnabled as globalIsTelemetryEnabled, sendEvent as telemetrySendEvent } from "@webiny/telemetry/cli.js";
|
|
2
|
-
import { CliCommandFactory, GetProjectSdkService } from "../abstractions/index.js";
|
|
3
|
-
import { GracefulError } from "@webiny/project";
|
|
4
|
-
const isDeployCommand = command => {
|
|
5
|
-
return command.name === "deploy";
|
|
6
|
-
};
|
|
7
|
-
export class DeployCommandWithTelemetry {
|
|
8
|
-
constructor(getProjectSdkService, decoratee) {
|
|
9
|
-
this.getProjectSdkService = getProjectSdkService;
|
|
10
|
-
this.decoratee = decoratee;
|
|
11
|
-
}
|
|
12
|
-
async execute() {
|
|
13
|
-
const command = await this.decoratee.execute();
|
|
14
|
-
if (!isDeployCommand(command)) {
|
|
15
|
-
// If the command is not a `deploy` command, we do not need to wrap it with telemetry.
|
|
16
|
-
return command;
|
|
17
|
-
}
|
|
18
|
-
if (!globalIsTelemetryEnabled()) {
|
|
19
|
-
return command;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Check if telemetry is disabled via an extension.
|
|
23
|
-
const projectSdk = await this.getProjectSdkService.execute();
|
|
24
|
-
const projectSdkTelemetryEnabled = await projectSdk.isTelemetryEnabled();
|
|
25
|
-
if (!projectSdkTelemetryEnabled) {
|
|
26
|
-
return command;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Getting a different type without type assertion. :|
|
|
30
|
-
const deployCommand = command;
|
|
31
|
-
const originalCommandHandler = deployCommand.handler;
|
|
32
|
-
deployCommand.handler = async params => {
|
|
33
|
-
if ("app" in params) {
|
|
34
|
-
const telemetryProperties = {
|
|
35
|
-
app: params.app || "unknown",
|
|
36
|
-
env: params.env || "unknown",
|
|
37
|
-
variant: params.variant || "unknown",
|
|
38
|
-
region: params.region || "unknown",
|
|
39
|
-
commandParams: JSON.stringify(params)
|
|
40
|
-
};
|
|
41
|
-
try {
|
|
42
|
-
await this.sendEvent("cli-pulumi-command-deploy-start", telemetryProperties);
|
|
43
|
-
const result = await originalCommandHandler(params);
|
|
44
|
-
await this.sendEvent("cli-pulumi-command-deploy-end", telemetryProperties);
|
|
45
|
-
return result;
|
|
46
|
-
} catch (e) {
|
|
47
|
-
const event = e instanceof GracefulError ? "cli-pulumi-command-deploy-error-graceful" : "cli-pulumi-command-deploy-error";
|
|
48
|
-
await this.sendEvent(event, {
|
|
49
|
-
...telemetryProperties,
|
|
50
|
-
errorMessage: e.message,
|
|
51
|
-
errorStack: e.stack
|
|
52
|
-
});
|
|
53
|
-
throw e;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const telemetryProperties = {
|
|
57
|
-
env: params.env || "unknown",
|
|
58
|
-
variant: params.variant || "unknown",
|
|
59
|
-
region: params.region || "unknown",
|
|
60
|
-
commandParams: JSON.stringify(params)
|
|
61
|
-
};
|
|
62
|
-
try {
|
|
63
|
-
await this.sendEvent("cli-project-deploy-start", telemetryProperties);
|
|
64
|
-
const result = await originalCommandHandler(params);
|
|
65
|
-
await this.sendEvent("cli-project-deploy-end", telemetryProperties);
|
|
66
|
-
return result;
|
|
67
|
-
} catch (e) {
|
|
68
|
-
const event = e instanceof GracefulError ? "cli-project-deploy-error-graceful" : "cli-project-deploy-error";
|
|
69
|
-
await this.sendEvent(event, {
|
|
70
|
-
...telemetryProperties,
|
|
71
|
-
errorMessage: e.message,
|
|
72
|
-
errorStack: e.stack
|
|
73
|
-
});
|
|
74
|
-
throw e;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
return command;
|
|
78
|
-
}
|
|
79
|
-
sendEvent(event, properties = {}) {
|
|
80
|
-
return telemetrySendEvent({
|
|
81
|
-
event,
|
|
82
|
-
properties
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
export const deployCommandWithTelemetry = CliCommandFactory.createDecorator({
|
|
87
|
-
decorator: DeployCommandWithTelemetry,
|
|
88
|
-
dependencies: [GetProjectSdkService]
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=DeployCommandWithTelemetry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isEnabled","globalIsTelemetryEnabled","sendEvent","telemetrySendEvent","CliCommandFactory","GetProjectSdkService","GracefulError","isDeployCommand","command","name","DeployCommandWithTelemetry","constructor","getProjectSdkService","decoratee","execute","projectSdk","projectSdkTelemetryEnabled","isTelemetryEnabled","deployCommand","originalCommandHandler","handler","params","telemetryProperties","app","env","variant","region","commandParams","JSON","stringify","result","e","event","errorMessage","message","errorStack","stack","properties","deployCommandWithTelemetry","createDecorator","decorator","dependencies"],"sources":["DeployCommandWithTelemetry.ts"],"sourcesContent":["import {\n isEnabled as globalIsTelemetryEnabled,\n sendEvent as telemetrySendEvent\n} from \"@webiny/telemetry/cli.js\";\nimport { CliCommandFactory, GetProjectSdkService } from \"~/abstractions/index.js\";\nimport { IDeployCommandParams } from \"~/features/index.js\";\nimport { GracefulError } from \"@webiny/project\";\n\nconst isDeployCommand = (\n command: CliCommandFactory.CommandDefinition<any>\n): command is CliCommandFactory.CommandDefinition<IDeployCommandParams> => {\n return command.name === \"deploy\";\n};\n\nexport class DeployCommandWithTelemetry<TParams> implements CliCommandFactory.Interface<TParams> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private decoratee: CliCommandFactory.Interface<TParams>\n ) {}\n\n async execute() {\n const command = await this.decoratee.execute();\n\n if (!isDeployCommand(command)) {\n // If the command is not a `deploy` command, we do not need to wrap it with telemetry.\n return command;\n }\n\n if (!globalIsTelemetryEnabled()) {\n return command;\n }\n\n // Check if telemetry is disabled via an extension.\n const projectSdk = await this.getProjectSdkService.execute();\n const projectSdkTelemetryEnabled = await projectSdk.isTelemetryEnabled();\n if (!projectSdkTelemetryEnabled) {\n return command;\n }\n\n // Getting a different type without type assertion. :|\n const deployCommand = command as CliCommandFactory.CommandDefinition<IDeployCommandParams>;\n const originalCommandHandler = deployCommand.handler;\n\n deployCommand.handler = async (params: IDeployCommandParams) => {\n if (\"app\" in params) {\n const telemetryProperties = {\n app: params.app || \"unknown\",\n env: params.env || \"unknown\",\n variant: params.variant || \"unknown\",\n region: params.region || \"unknown\",\n commandParams: JSON.stringify(params)\n };\n\n try {\n await this.sendEvent(\"cli-pulumi-command-deploy-start\", telemetryProperties);\n\n const result = await originalCommandHandler(params);\n\n await this.sendEvent(\"cli-pulumi-command-deploy-end\", telemetryProperties);\n\n return result;\n } catch (e) {\n const event =\n e instanceof GracefulError\n ? \"cli-pulumi-command-deploy-error-graceful\"\n : \"cli-pulumi-command-deploy-error\";\n\n await this.sendEvent(event, {\n ...telemetryProperties,\n errorMessage: e.message,\n errorStack: e.stack\n });\n\n throw e;\n }\n }\n\n const telemetryProperties = {\n env: params.env || \"unknown\",\n variant: params.variant || \"unknown\",\n region: params.region || \"unknown\",\n commandParams: JSON.stringify(params)\n };\n\n try {\n await this.sendEvent(\"cli-project-deploy-start\", telemetryProperties);\n const result = await originalCommandHandler(params);\n await this.sendEvent(\"cli-project-deploy-end\", telemetryProperties);\n return result;\n } catch (e) {\n const event =\n e instanceof GracefulError\n ? \"cli-project-deploy-error-graceful\"\n : \"cli-project-deploy-error\";\n\n await this.sendEvent(event, {\n ...telemetryProperties,\n errorMessage: e.message,\n errorStack: e.stack\n });\n\n throw e;\n }\n };\n\n return command;\n }\n\n private sendEvent(event: string, properties: Record<string, any> = {}) {\n return telemetrySendEvent({\n event,\n properties\n });\n }\n}\n\nexport const deployCommandWithTelemetry = CliCommandFactory.createDecorator({\n decorator: DeployCommandWithTelemetry,\n dependencies: [GetProjectSdkService]\n});\n"],"mappings":"AAAA,SACIA,SAAS,IAAIC,wBAAwB,EACrCC,SAAS,IAAIC,kBAAkB,QAC5B,0BAA0B;AACjC,SAASC,iBAAiB,EAAEC,oBAAoB;AAEhD,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,MAAMC,eAAe,GACjBC,OAAiD,IACsB;EACvE,OAAOA,OAAO,CAACC,IAAI,KAAK,QAAQ;AACpC,CAAC;AAED,OAAO,MAAMC,0BAA0B,CAA0D;EAC7FC,WAAWA,CACCC,oBAAoD,EACpDC,SAA+C,EACzD;IAAA,KAFUD,oBAAoD,GAApDA,oBAAoD;IAAA,KACpDC,SAA+C,GAA/CA,SAA+C;EACxD;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMN,OAAO,GAAG,MAAM,IAAI,CAACK,SAAS,CAACC,OAAO,CAAC,CAAC;IAE9C,IAAI,CAACP,eAAe,CAACC,OAAO,CAAC,EAAE;MAC3B;MACA,OAAOA,OAAO;IAClB;IAEA,IAAI,CAACP,wBAAwB,CAAC,CAAC,EAAE;MAC7B,OAAOO,OAAO;IAClB;;IAEA;IACA,MAAMO,UAAU,GAAG,MAAM,IAAI,CAACH,oBAAoB,CAACE,OAAO,CAAC,CAAC;IAC5D,MAAME,0BAA0B,GAAG,MAAMD,UAAU,CAACE,kBAAkB,CAAC,CAAC;IACxE,IAAI,CAACD,0BAA0B,EAAE;MAC7B,OAAOR,OAAO;IAClB;;IAEA;IACA,MAAMU,aAAa,GAAGV,OAAoE;IAC1F,MAAMW,sBAAsB,GAAGD,aAAa,CAACE,OAAO;IAEpDF,aAAa,CAACE,OAAO,GAAG,MAAOC,MAA4B,IAAK;MAC5D,IAAI,KAAK,IAAIA,MAAM,EAAE;QACjB,MAAMC,mBAAmB,GAAG;UACxBC,GAAG,EAAEF,MAAM,CAACE,GAAG,IAAI,SAAS;UAC5BC,GAAG,EAAEH,MAAM,CAACG,GAAG,IAAI,SAAS;UAC5BC,OAAO,EAAEJ,MAAM,CAACI,OAAO,IAAI,SAAS;UACpCC,MAAM,EAAEL,MAAM,CAACK,MAAM,IAAI,SAAS;UAClCC,aAAa,EAAEC,IAAI,CAACC,SAAS,CAACR,MAAM;QACxC,CAAC;QAED,IAAI;UACA,MAAM,IAAI,CAACnB,SAAS,CAAC,iCAAiC,EAAEoB,mBAAmB,CAAC;UAE5E,MAAMQ,MAAM,GAAG,MAAMX,sBAAsB,CAACE,MAAM,CAAC;UAEnD,MAAM,IAAI,CAACnB,SAAS,CAAC,+BAA+B,EAAEoB,mBAAmB,CAAC;UAE1E,OAAOQ,MAAM;QACjB,CAAC,CAAC,OAAOC,CAAC,EAAE;UACR,MAAMC,KAAK,GACPD,CAAC,YAAYzB,aAAa,GACpB,0CAA0C,GAC1C,iCAAiC;UAE3C,MAAM,IAAI,CAACJ,SAAS,CAAC8B,KAAK,EAAE;YACxB,GAAGV,mBAAmB;YACtBW,YAAY,EAAEF,CAAC,CAACG,OAAO;YACvBC,UAAU,EAAEJ,CAAC,CAACK;UAClB,CAAC,CAAC;UAEF,MAAML,CAAC;QACX;MACJ;MAEA,MAAMT,mBAAmB,GAAG;QACxBE,GAAG,EAAEH,MAAM,CAACG,GAAG,IAAI,SAAS;QAC5BC,OAAO,EAAEJ,MAAM,CAACI,OAAO,IAAI,SAAS;QACpCC,MAAM,EAAEL,MAAM,CAACK,MAAM,IAAI,SAAS;QAClCC,aAAa,EAAEC,IAAI,CAACC,SAAS,CAACR,MAAM;MACxC,CAAC;MAED,IAAI;QACA,MAAM,IAAI,CAACnB,SAAS,CAAC,0BAA0B,EAAEoB,mBAAmB,CAAC;QACrE,MAAMQ,MAAM,GAAG,MAAMX,sBAAsB,CAACE,MAAM,CAAC;QACnD,MAAM,IAAI,CAACnB,SAAS,CAAC,wBAAwB,EAAEoB,mBAAmB,CAAC;QACnE,OAAOQ,MAAM;MACjB,CAAC,CAAC,OAAOC,CAAC,EAAE;QACR,MAAMC,KAAK,GACPD,CAAC,YAAYzB,aAAa,GACpB,mCAAmC,GACnC,0BAA0B;QAEpC,MAAM,IAAI,CAACJ,SAAS,CAAC8B,KAAK,EAAE;UACxB,GAAGV,mBAAmB;UACtBW,YAAY,EAAEF,CAAC,CAACG,OAAO;UACvBC,UAAU,EAAEJ,CAAC,CAACK;QAClB,CAAC,CAAC;QAEF,MAAML,CAAC;MACX;IACJ,CAAC;IAED,OAAOvB,OAAO;EAClB;EAEQN,SAASA,CAAC8B,KAAa,EAAEK,UAA+B,GAAG,CAAC,CAAC,EAAE;IACnE,OAAOlC,kBAAkB,CAAC;MACtB6B,KAAK;MACLK;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMC,0BAA0B,GAAGlC,iBAAiB,CAACmC,eAAe,CAAC;EACxEC,SAAS,EAAE9B,0BAA0B;EACrC+B,YAAY,EAAE,CAACpC,oBAAoB;AACvC,CAAC,CAAC","ignoreList":[]}
|
package/decorators/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CommandsWithGracefulErrorHandling.js\";\nexport * from \"./DeployCommandWithTelemetry.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CliCommandFactory"],"sources":["command.ts"],"sourcesContent":["export { CliCommandFactory } from \"~/abstractions/features/CliCommand.js\";\n"],"mappings":"AAAA,SAASA,iBAAiB","ignoreList":[]}
|
package/exports/cli/index.d.ts
DELETED
package/exports/cli/index.js
DELETED
package/exports/cli/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["LoggerService","Logger","UiService","Ui"],"sources":["index.ts"],"sourcesContent":["export { LoggerService as Logger } from \"~/abstractions/services/LoggerService.js\";\nexport { UiService as Ui } from \"~/abstractions/services/UiService.js\";\n"],"mappings":"AAAA,SAASA,aAAa,IAAIC,MAAM;AAChC,SAASC,SAAS,IAAIC,EAAE","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./BuildCommand.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { CliCommandFactory, GetProjectSdkService, StdioService, UiService } from "../../abstractions/index.js";
|
|
2
|
-
import { AppName } from "@webiny/project";
|
|
3
|
-
export interface IDeployCommandParams {
|
|
4
|
-
apps?: AppName[];
|
|
5
|
-
variant?: string;
|
|
6
|
-
region?: string;
|
|
7
|
-
env: string;
|
|
8
|
-
showDeploymentLogs?: boolean;
|
|
9
|
-
build?: boolean;
|
|
10
|
-
preview?: boolean;
|
|
11
|
-
allowLocalStateFiles?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface IDeploySingleAppParams {
|
|
14
|
-
app: AppName;
|
|
15
|
-
variant?: string;
|
|
16
|
-
region?: string;
|
|
17
|
-
env: string;
|
|
18
|
-
showDeploymentLogs?: boolean;
|
|
19
|
-
build?: boolean;
|
|
20
|
-
preview?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export declare class DeployCommand implements CliCommandFactory.Interface<IDeployCommandParams> {
|
|
23
|
-
private getProjectSdkService;
|
|
24
|
-
private uiService;
|
|
25
|
-
private stdioService;
|
|
26
|
-
constructor(getProjectSdkService: GetProjectSdkService.Interface, uiService: UiService.Interface, stdioService: StdioService.Interface);
|
|
27
|
-
execute(): Promise<CliCommandFactory.CommandDefinition<IDeployCommandParams>>;
|
|
28
|
-
private deployApp;
|
|
29
|
-
}
|
|
30
|
-
export declare const deployCommand: import("@webiny/di").Implementation<typeof DeployCommand>;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { createImplementation } from "@webiny/di";
|
|
2
|
-
import { CliCommandFactory, GetProjectSdkService, StdioService, UiService } from "../../abstractions/index.js";
|
|
3
|
-
import { DeployOutput } from "./deployOutputs/DeployOutput.js";
|
|
4
|
-
import { BuildRunner } from "../BuildCommand/buildRunners/BuildRunner.js";
|
|
5
|
-
import { createBaseAppOptions } from "../common/index.js";
|
|
6
|
-
import { setTimeout } from "node:timers/promises";
|
|
7
|
-
import ora from "ora";
|
|
8
|
-
import open from "open";
|
|
9
|
-
|
|
10
|
-
// TODO: convert to a real service.
|
|
11
|
-
import { PrintInfoForEnv } from "../InfoCommand/PrintInfoForEnv.js";
|
|
12
|
-
const sleep = (ms = 1500) => setTimeout(ms);
|
|
13
|
-
export class DeployCommand {
|
|
14
|
-
constructor(getProjectSdkService, uiService, stdioService) {
|
|
15
|
-
this.getProjectSdkService = getProjectSdkService;
|
|
16
|
-
this.uiService = uiService;
|
|
17
|
-
this.stdioService = stdioService;
|
|
18
|
-
}
|
|
19
|
-
async execute() {
|
|
20
|
-
const projectSdk = await this.getProjectSdkService.execute();
|
|
21
|
-
const ui = this.uiService;
|
|
22
|
-
return {
|
|
23
|
-
name: "deploy",
|
|
24
|
-
description: "Deploys specified app or all apps in the project",
|
|
25
|
-
examples: ["$0 deploy api --env dev", "$0 deploy core api --env dev", "$0 deploy admin --env prod", "$0 deploy --env prod", "$0 deploy"],
|
|
26
|
-
params: [{
|
|
27
|
-
name: "apps",
|
|
28
|
-
description: "Name of the app(s) to deploy (core, admin, or api). You can specify multiple apps.",
|
|
29
|
-
type: "string",
|
|
30
|
-
array: true
|
|
31
|
-
}],
|
|
32
|
-
options: [...createBaseAppOptions(projectSdk), {
|
|
33
|
-
name: "build",
|
|
34
|
-
description: "Build packages before deploying",
|
|
35
|
-
type: "boolean",
|
|
36
|
-
default: true
|
|
37
|
-
}, {
|
|
38
|
-
name: "preview",
|
|
39
|
-
description: "Preview the deploy instead of actually performing it",
|
|
40
|
-
type: "boolean",
|
|
41
|
-
default: false
|
|
42
|
-
}, {
|
|
43
|
-
name: "show-deployment-logs",
|
|
44
|
-
description: "Print deployment logs (automatically enabled in CI environments)",
|
|
45
|
-
type: "boolean",
|
|
46
|
-
default: false
|
|
47
|
-
}, {
|
|
48
|
-
name: "allow-local-state-files",
|
|
49
|
-
description: "Allow using local Pulumi state files with production environment deployment (not recommended).",
|
|
50
|
-
type: "boolean"
|
|
51
|
-
}],
|
|
52
|
-
handler: async params => {
|
|
53
|
-
if (params.apps && params.apps.length > 0) {
|
|
54
|
-
// Deploy specified apps
|
|
55
|
-
for (const appName of params.apps) {
|
|
56
|
-
const appParams = {
|
|
57
|
-
...params,
|
|
58
|
-
app: appName
|
|
59
|
-
};
|
|
60
|
-
const app = await projectSdk.getApp(appName);
|
|
61
|
-
ui.info("Deploying %s app...", app.getDisplayName());
|
|
62
|
-
await this.deployApp(appParams);
|
|
63
|
-
ui.emptyLine();
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
const isCi = projectSdk.isCi();
|
|
67
|
-
const coreStack = await projectSdk.getAppStackOutput("core");
|
|
68
|
-
const isFirstDeployment = !isCi && !coreStack?.deploymentId;
|
|
69
|
-
if (isFirstDeployment) {
|
|
70
|
-
ui.info(`Looks like this is your first time deploying the project.`);
|
|
71
|
-
ui.info(`Note that the initial deployment can take up to %s, so please be patient.`, "10 minutes");
|
|
72
|
-
await sleep();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// 3. Start deploying apps one-by-one.
|
|
76
|
-
isFirstDeployment && ui.emptyLine();
|
|
77
|
-
|
|
78
|
-
// Deploy all apps in the project.
|
|
79
|
-
ui.info("Deploying %s app...", "Core");
|
|
80
|
-
await this.deployApp({
|
|
81
|
-
...params,
|
|
82
|
-
app: "core"
|
|
83
|
-
});
|
|
84
|
-
ui.emptyLine();
|
|
85
|
-
ui.info("Deploying %s app...", "API");
|
|
86
|
-
await this.deployApp({
|
|
87
|
-
...params,
|
|
88
|
-
app: "api"
|
|
89
|
-
});
|
|
90
|
-
ui.emptyLine();
|
|
91
|
-
ui.info("Deploying %s app...", "Admin");
|
|
92
|
-
await this.deployApp({
|
|
93
|
-
...params,
|
|
94
|
-
app: "admin"
|
|
95
|
-
});
|
|
96
|
-
if (isFirstDeployment) {
|
|
97
|
-
ui.success(`Congratulations! You've just deployed a brand new project!`);
|
|
98
|
-
} else {
|
|
99
|
-
ui.success(`Project deployed.`);
|
|
100
|
-
}
|
|
101
|
-
const printInfoForEnv = new PrintInfoForEnv({
|
|
102
|
-
getProjectSdkService: this.getProjectSdkService,
|
|
103
|
-
uiService: this.uiService
|
|
104
|
-
});
|
|
105
|
-
ui.emptyLine();
|
|
106
|
-
ui.textBold("Project Details");
|
|
107
|
-
await printInfoForEnv.execute(params);
|
|
108
|
-
const adminAppOutput = await projectSdk.getAppStackOutput("admin");
|
|
109
|
-
if (isFirstDeployment && adminAppOutput) {
|
|
110
|
-
ui.emptyLine();
|
|
111
|
-
ui.info("The final step is to open the %s app in your browser and complete the installation wizard.", "Admin");
|
|
112
|
-
const spinner = ora(`Opening Admin in your browser...`).start();
|
|
113
|
-
try {
|
|
114
|
-
await sleep(7000);
|
|
115
|
-
open(adminAppOutput.appUrl);
|
|
116
|
-
spinner.succeed(`Successfully opened Admin app in your browser.`);
|
|
117
|
-
} catch {
|
|
118
|
-
spinner.fail(`Failed to open Admin in your browser.`);
|
|
119
|
-
await sleep(1000);
|
|
120
|
-
ui.emptyLine();
|
|
121
|
-
ui.warning(`Failed to open %s app in your browser. To finish the setup and start using the project, please visit %s and complete the installation wizard.`, "Admin", adminAppOutput.appUrl);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
async deployApp(params) {
|
|
129
|
-
const projectSdk = await this.getProjectSdkService.execute();
|
|
130
|
-
const ui = this.uiService;
|
|
131
|
-
const stdio = this.stdioService;
|
|
132
|
-
if (params.build !== false) {
|
|
133
|
-
const packagesBuilder = await projectSdk.buildApp(params);
|
|
134
|
-
const buildRunner = new BuildRunner({
|
|
135
|
-
stdio,
|
|
136
|
-
ui,
|
|
137
|
-
packagesBuilder
|
|
138
|
-
});
|
|
139
|
-
if (!buildRunner.isEmpty()) {
|
|
140
|
-
await buildRunner.run();
|
|
141
|
-
ui.emptyLine();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// We always show deployment logs when doing previews.
|
|
146
|
-
const showDeploymentLogs = Boolean(projectSdk.isCi() || params.preview || params.showDeploymentLogs);
|
|
147
|
-
return await projectSdk.deployApp({
|
|
148
|
-
...params,
|
|
149
|
-
output: pulumiProcess => {
|
|
150
|
-
const deployOutput = new DeployOutput({
|
|
151
|
-
stdio,
|
|
152
|
-
ui,
|
|
153
|
-
showDeploymentLogs,
|
|
154
|
-
deployProcess: pulumiProcess,
|
|
155
|
-
deployParams: params
|
|
156
|
-
});
|
|
157
|
-
return deployOutput.output();
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
export const deployCommand = createImplementation({
|
|
163
|
-
abstraction: CliCommandFactory,
|
|
164
|
-
implementation: DeployCommand,
|
|
165
|
-
dependencies: [GetProjectSdkService, UiService, StdioService]
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
//# sourceMappingURL=DeployCommand.js.map
|