Interesting!
I gave it a go, and had to correct some code to get the script to build and run:
lines 85 and 86:
print(URL(filePath: target))
newPrefix = URL(filePath: target).lastPathComponent
to
print(URL(fileURLWithPath: target))newPrefix = URL(fileURLWithPath: target).lastPathComponent
and line 346 tmp.append(component: newName) to tmp.appendingPathComponent(newName)
but are running into an error:
./TemplatePackageToolLibrary/setup.swift all
TemplatePackageToolLibrary/setup.swift:346:13: warning: result of call to 'appendingPathComponent' is unused
tmp.appendingPathComponent(newName)
^ ~~~~~~~~~
TemplatePackageToolLibrary/setup.swift:345:13: warning: variable 'tmp' was never mutated; consider changing to 'let' constant
var tmp = srcURL.deletingLastPathComponent()
~~~ ^
let
w00t! A New Project!
/usr/local/bin/git
Script: TemplatePackageToolLibrary/setup.swift
Please enter new package name:
FooBar
Create subfolder with this name? (alternative is to use this directory)
y
fetching repo...
Cloning into 'FooBar'...
remote: Enumerating objects: 51, done.
remote: Counting objects: 100% (51/51), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 51 (delta 22), reused 40 (delta 13), pack-reused 0
Receiving objects: 100% (51/51), 16.87 KiB | 2.41 MiB/s, done.
Resolving deltas: 100% (22/22), done.
FooBar in FooBar
setup/setup.swift:137: Fatal error: name not full replaced due to Error Domain=NSCocoaErrorDomain Code=516 "A file with the same name already exists."
Stack dump:
0. Program arguments: /usr/libexec/swift/bin/swift-frontend -frontend -interpret TemplatePackageToolLibrary/setup.swift -disable-objc-interop -color-diagnostics -new-driver-path /usr/libexec/swift/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/libexec/swift/lib/swift -module-name setup -plugin-path /usr/libexec/swift/lib/swift/host/plugins -plugin-path /usr/libexec/swift/local/lib/swift/host/plugins -- all
1. Swift version 5.10 (swift-5.10-RELEASE)
2. Compiling with the current language version
3. While running user code "TemplatePackageToolLibrary/setup.swift"
#0 0x000055d394ad7b03 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/libexec/swift/bin/swift-frontend+0x616eb03)
#1 0x000055d394ad5a8e llvm::sys::RunSignalHandlers() (/usr/libexec/swift/bin/swift-frontend+0x616ca8e)
#2 0x000055d394ad7e7f SignalHandler(int) (/usr/libexec/swift/bin/swift-frontend+0x616ee7f)
#3 0x00007f261abf5420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f261a6d255f $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF (/usr/libexec/swift/lib/swift/linux/libswiftCore.so+0x16455f)
#5 0x00007f2616f55eea
#6 0x000055d38f73e88f llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::Optional<llvm::StringRef>) (/usr/libexec/swift/bin/swift-frontend+0xdd588f)
#7 0x000055d38f622608 swift::SwiftJIT::runMain(llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >) (/usr/libexec/swift/bin/swift-frontend+0xcb9608)
#8 0x000055d38f620413 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions const&, swift::SILOptions const&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >&&) (/usr/libexec/swift/bin/swift-frontend+0xcb7413)
#9 0x000055d38f5cc636 processCommandLineAndRunImmediately(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >&&, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::FrontendObserver*, int&) (/usr/libexec/swift/bin/swift-frontend+0xc63636)
#10 0x000055d38f5c7886 performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) (/usr/libexec/swift/bin/swift-frontend+0xc5e886)
#11 0x000055d38f5c691b swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/usr/libexec/swift/bin/swift-frontend+0xc5d91b)
#12 0x000055d38f5d9bda withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) (/usr/libexec/swift/bin/swift-frontend+0xc70bda)
#13 0x000055d38f5cac88 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/usr/libexec/swift/bin/swift-frontend+0xc61c88)
#14 0x000055d38f5c86fd swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/libexec/swift/bin/swift-frontend+0xc5f6fd)
#15 0x000055d38f4626cf swift::mainEntry(int, char const**) (/usr/libexec/swift/bin/swift-frontend+0xaf96cf)
#16 0x00007f2619112083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3
#17 0x000055d38f46121e _start (/usr/libexec/swift/bin/swift-frontend+0xaf821e)
💣 Program crashed: Illegal instruction at 0x00007f261a6d255f
Thread 0 "swift-frontend" crashed:
0 0x00007f261a6d255f _assertionFailure(_:_:file:line:flags:) + 351 in libswiftCore.so
1 0x00007f2616f55eea
Backtrace took 0.15s
Illegal instruction (core dumped)
Apparantly the script wants to rename 'FooBar' to 'FooBar'.
Am I missing some instruction?