Add "activate" demonstration that bootstraps ce and calls activate.
RENAME
include/vcpkg/commands.zforward.h
include/vcpkg/commands.activate.h
#include <vcpkg/commands.interface.h>
-namespace vcpkg::Commands::Z_Forward
+namespace vcpkg::Commands::Activate
{
- void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
-
- struct ForwardCommand : PathsCommand
+ struct ActivateCommand : PathsCommand
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) const override;
};

MODIFY
src/vcpkg-test/commands.cpp
src/vcpkg-test/commands.cpp
@@ -71,7 +71,7 @@ TEST_CASE ("list of commands is correct", "[commands]")
"build-external",
"export",
"depend-info",
- "z-forward",
+ "activate",
"x-check-support",
"z-print-config",
#if defined(_WIN32)

ADD
src/vcpkg/commands.activate.cpp
+#include <vcpkg/base/system.process.h>
+#include <vcpkg/base/basic_checks.h>
+#include <vcpkg/base/system.print.h>
+#include <vcpkg/tools.h>
+#include <vcpkg/commands.activate.h>
+#include <vcpkg/vcpkgcmdarguments.h>
+#include <vcpkg/vcpkgpaths.h>
+
+namespace vcpkg::Commands::Activate
+{
+ void ActivateCommand::perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) const
+ {
+ print2(Color::warning, "vcpkg-ce is experimental and may change at any time.\n");
+
+ auto node_path = paths.get_tool_exe(Tools::NODE);
+ auto ce_path = paths.root / "node_modules/vcpkg-ce";
+
+ if (!paths.get_filesystem().is_directory(ce_path))
+ {
+ auto npm_path = Path(node_path.parent_path()) / "node_modules" / "npm" / "bin" / "npm-cli.js";
+ Command cmd_provision(node_path);
+ cmd_provision.string_arg(npm_path);
+ cmd_provision.string_arg("--force");
+ cmd_provision.string_arg("install");
+ cmd_provision.string_arg("--no-save");
+ cmd_provision.string_arg("--no-lockfile");
+ cmd_provision.string_arg("--scripts-prepend-node-path=true");
+ cmd_provision.string_arg("https://aka.ms/vcpkg-ce.tgz");
+ const auto provision_status = cmd_execute(cmd_provision);
+ if (provision_status != 0)
+ {
+ Checks::exit_with_message(VCPKG_LINE_INFO, "Failed to provision vcpkg-ce.");
+ }
+ }
+
+ Command cmd_run(node_path);
+ cmd_run.string_arg("--harmony");
+ cmd_run.string_arg(ce_path.native());
+ cmd_run.string_arg("--accept-eula");
+ cmd_run.string_arg("activate");
+ args.add_forwarded_arguments(cmd_run);
+ Checks::exit_with_code(VCPKG_LINE_INFO, cmd_execute(cmd_run));
+ }
+}

MODIFY
src/vcpkg/commands.cpp
src/vcpkg/commands.cpp
#include <vcpkg/base/system.print.h>
#include <vcpkg/build.h>
+#include <vcpkg/commands.activate.h>
#include <vcpkg/commands.add-version.h>
#include <vcpkg/commands.autocomplete.h>
#include <vcpkg/commands.buildexternal.h>
#include <vcpkg/commands.version.h>
#include <vcpkg/commands.xdownload.h>
#include <vcpkg/commands.xvsinstances.h>
-#include <vcpkg/commands.zforward.h>
#include <vcpkg/commands.zprintconfig.h>
#include <vcpkg/export.h>
#include <vcpkg/help.h>
@@ -72,26 +72,26 @@ namespace vcpkg::Commands
Span<const PackageNameAndFunction<const PathsCommand*>> get_available_paths_commands()
{
+ static const Activate::ActivateCommand activate{};
+ static const AddVersion::AddVersionCommand add_version{};
+ static const Autocomplete::AutocompleteCommand autocomplete{};
+ static const Cache::CacheCommand cache{};
+ static const CIClean::CICleanCommand ciclean{};
+ static const CIVerifyVersions::CIVerifyVersionsCommand ci_verify_versions{};
+ static const Create::CreateCommand create{};
+ static const Edit::EditCommand edit{};
+ static const Fetch::FetchCommand fetch{};
+ static const FormatManifest::FormatManifestCommand format_manifest{};
static const Help::HelpCommand help{};
- static const Search::SearchCommand search{};
- static const List::ListCommand list{};
static const Info::InfoCommand info{};
static const Integrate::IntegrateCommand integrate{};
+ static const List::ListCommand list{};
static const Owns::OwnsCommand owns{};
- static const Update::UpdateCommand update{};
- static const Edit::EditCommand edit{};
- static const Create::CreateCommand create{};
- static const Cache::CacheCommand cache{};
- static const PortsDiff::PortsDiffCommand portsdiff{};
- static const Autocomplete::AutocompleteCommand autocomplete{};
- static const Fetch::FetchCommand fetch{};
- static const CIClean::CICleanCommand ciclean{};
static const PortHistory::PortHistoryCommand porthistory{};
+ static const PortsDiff::PortsDiffCommand portsdiff{};
+ static const Search::SearchCommand search{};
+ static const Update::UpdateCommand update{};
static const X_VSInstances::VSInstancesCommand vsinstances{};
- static const FormatManifest::FormatManifestCommand format_manifest{};
- static const CIVerifyVersions::CIVerifyVersionsCommand ci_verify_versions{};
- static const AddVersion::AddVersionCommand add_version{};
- static const Z_Forward::ForwardCommand test_forward{};
static std::vector<PackageNameAndFunction<const PathsCommand*>> t = {
{"/?", &help},
@@ -114,7 +114,7 @@ namespace vcpkg::Commands
{"format-manifest", &format_manifest},
{"x-ci-verify-versions", &ci_verify_versions},
{"x-add-version", &add_version},
- {"z-forward", &test_forward},
+ {"activate", &activate},
};
return t;
}

DELETE
src/vcpkg/commands.zforward.cpp
-#include <vcpkg/base/system.process.h>
-
-#include <vcpkg/commands.zforward.h>
-#include <vcpkg/vcpkgcmdarguments.h>
-
-namespace vcpkg::Commands::Z_Forward
-{
- void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths&)
- {
- Command cmd("insert-executable-name-here");
- cmd.string_arg("--");
- args.add_forwarded_arguments(cmd);
- int status = cmd_execute(cmd);
- Checks::exit_with_code(VCPKG_LINE_INFO, status);
- }
-
- void ForwardCommand::perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) const
- {
- Z_Forward::perform_and_exit(args, paths);
- }
-}

Add "activate" demonstration that bootstraps ce and calls activate.