Vapor:无法从命令行迁移/恢复

问题描述 投票:0回答:1

我正在尝试从 Vapor 应用程序的命令行运行迁移。基本命令

swift run App
似乎不起作用。这是一个典型的测试,比较旧的语法。

danieldonaldson@Daniels-Mac-mini wb2-web % vapor run  migrate      
This command is deprecated. Use `swift run App` instead.
Error: Invalid URL: /Volumes/500 GB Current/Current Work/wb2-web/Package.swift
danieldonaldson@Daniels-Mac-mini wb2-web % swift run App migrate
error: no executable product named 'App'

Package.swift 文件位于 Active Directory 中,并且似乎使用名称“App”。

 targets: [
        .target(
            name: "App",
            dependencies: [
                .product(name: "Vapor", package: "vapor"),
                .product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
                .product(name: "Fluent", package: "fluent"),
                .product(name: "Leaf", package: "leaf"),
//                .product(name: "SendGrid", package: "sendgrid"),
            ],
            swiftSettings: [
                // Enable better optimizations when building in Release configuration. -- Despite the use of
                // the `.unsafeFlags` construct required by SwiftPM, this flag is recommended for Release
                // builds. See <https://github.com/swift-server/guides#building-for-production> for details.
                .unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
            ]
        ),

虽然在顶部,但名称不同:

let package = Package(
    name: "Authentication",
    platforms: [
       .macOS(.v10_15)
    ],

但这个名称已经使用了几年,没有进行任何更改。我通常不会手动迁移或恢复,但在这种情况下我必须测试一些东西。所以我不知道这个是什么时候出现的,但我确实需要检查一下......

为什么 swift 找不到 App 可执行文件?我相信这是相当标准的 Vapor 练习。

ios swift xcode vapor
1个回答
1
投票

在 Package.swift 中,您有一个

.target
.executableTarget.
最近的 Vapor 4 版本查看的是
executableTarget
名称,而不是
target
名称。您的
executableTarget
名称很可能是“Run”,所以只需使用

swift run Run
© www.soinside.com 2019 - 2024. All rights reserved.