-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Titanium CLI v7 Beta 1 #618
Conversation
…titles, wired up prompting
Did a very quick test with the latest version, but only info, sdk and create. The short-cut to create a project in one line: tidev/titanium-sdk#13641 (comment) is not working anymore. It think that's how the editors call the CLI but I'll have to double check. Do you think the Think this: |
I tested The Fixed the SDK prompt hint! |
Ah, I just saw it was showing the package.json error again because I'm running it in the CLI folder which has a package.json. If I run it in a normal folder it works! We had that before, didn't see the error before as it was showing the help page again.
Keep the |
Is the Ah, I see. OK, |
If you run it in a folder with a package.json it will output
|
Fixed the I cannot reproduce the |
Fixed The
In any case, I fixed v7 to properly resolve the path making |
@m1ga says:
|
The Titanium CLI has been long overdue for a little ❤️
Dependencies are extremely out-of-date. Some of them are deprecated, abandoned, and/or contained critical issues. Things got so bad, we disabled Dependabot. Since the Titanium CLI wasn't an ES module, we couldn't adopt newer libraries.
On top of that, the Titanium CLI is littered with a bunch of half baked ideas. It supported for localized strings, but we sadly lost all of the translated strings a long time ago. It sorta had the beginnings of shell tab completion, but I never finished it. The whole "selected SDK" concept was really bad (sorry). The list goes on and on.
After a nearly a month of late nights and weekends, I essentially rewrote the entire CLI. Let's start at the top.
1. Node.js 18 or newer is required
Node.js 16 and older are all end-of-life. We will continue to test and support any actively maintained Node.js release.
2. The Titanium CLI is now a proper ES module.
This means the CLI and SDK can use any ES module npm package!
3. Remove all Appcelerator/Axway related stuff
Removed the
ti login
,ti logout
, andti whoami
commands. Removed telemetry. This was dead code.4. Removed i18n logic
The CLI would detect your locale and display messages in your preferred language, however really only had strings in English. A long time ago we had Spanish, Hindi, and a good chunk of Ukrainian, but we sadly lost all of the translations. So the whole i18n stuff was pointless.
5. Removed incomplete tab completion code
Never worked. Dead code. Removed.
6. No more selected SDK
Back in the day, we were adding new iOS and Android settings to the
tiapp.xml
every release, so I put thetiapp.xml
parser in the SDK, not the CLI. Part of the reason besides new settings being added was the logic that translated the XML into JSON was rather strict. Another part was we sorta thought we would ship the SDK way more often than the CLI. Turns out, we would ship a new CLI every release.The CLI would have to load a Titanium SDK so that it could parse the
tiapp.xml
and get the project's<sdk-version>
. If that version didn't match the one used to read thetiapp.xml
, it would "fork" the CLI again with the correct SDK. This was slow.Another artifact was when you did
ti sdk install
, we would say pass in--default
to select the newly installed SDK. You would useti sdk select
to change the selected SDK.I have finally fixed this horrible design. I have removed
ti sdk select
. There is no more need for the--default
flag when you install an SDK. No more forking the correct SDK. The CLI now parses thetiapp.xml
and selects the correct SDK based on your project or the--sdk
option. When you create a new project, it will prompt you which SDK to create the project for.7.
--log-level
is now a global optionThis used to be a SDK command option, but the logger is owned by the CLI, not the SDK. It didn't make sense. The "trace" level logging will now output a some extra CLI related info, but in general you should stick with "info" or "debug".
When I started building the CLI, it wasn't clear as to how the logger was going to be used. We didn't know if we were going to write it to disk or exactly how the log levels were going to work. We chose the
winston
package, but I had to hack it a bit to do what I needed. Now that we're a little older and wiser, Winston is no longer needed. I ripped it out and replaced it with a lightweight logger. It doesn't have bells and whistles, but it gets the job done.Furthermore,
trace
,debug
,warn
, anderror
log messages are written tostderr
.info
and normalconsole.log()
output is written tostdout
. Undecided if this was the best idea, so we'll see.Lastly, if you set
--log-level trace
, it displays a total command run time at the end. Maybe interesting if you do a dist build or something, not so much for simulator/emulator builds as the process stays running to display app logs.8.
ti config
changesBefore
ti config --output json
would display the config with the key being the dot notation name andti config --output json-object
would display the config as an object. This was dumb. I've replaced this with a simpleti config --json
which returns the object form of the config. Simple.9.
paths.commands
setting removedThis was a list of paths to search for commands to add in addition to the build-in commands and SDK commands. Since this setting was probably never used and searching/loading additional commands is slow, this setting has been removed.
10.
ti info
changesLike
ti config
,--output json
has been replaced with a simple--json
.The following information has been removed:
jarsigner
executable (unsued, no need now that we use Gradle)nodeAppcVer
in CLI/SDK info (unused)Also removed the old "v1" Android and iOS detection code. This code path would only run if there wasn't an SDK installed. "v2" Android and iOS detection is done by the SDK. If you don't have an SDK, then there's nothing to detect.
11.
ti module
changesThis command displays installed modules. The JSON output contains both
iphone
andios
data which are exactly the same. This is an artifact of when the iPad was released and I started trying to move away from calling thingsiphone
.12.
ti sdk
changesAs listed above,
ti sdk select
removed andti sdk install
no longer supports--default
.ti sdk list
can now be invoked by runningti sdk ls
.ti sdk install
has been shortened toti sdk i
andti sdk uninstall
has been shortened toti sdk rm
.ti sdk list
supports--json
and no longer returns anactiveSDK
property.ti sdk install
now usesundici
to download the SDK. It's suppose to be faster. Can you tell?13.
ti setup
changesRemoved all Windows publishing info, user locale, and SDK setup. It's no longer needed.
Under the "check" screen, removed a bunch of useless info such as haxm, Xcode CLI tools, and CLI dependency info.
14. Updated dependencies
The CLI no longer relies on the outdated
node-appc
. This package was a collection of common code to be shared across all Appc Node.js-based projects, however Titanium packages were the ones that really used it. Since this package contains more code than the CLI needs and this package is so out-of-date, only the necessary pieces were copied and updated into the CLI code base.Other packages where replaced with modern alternatives:
colors
withchalk
fields
withprompts
humanize
withpretty-bytes
request
withundici
15. Command Line Parsing
The Titanium CLI originally used
optimist
, but it wasn't long beforeoptimist
was copied directly into the Titanium CLI and heavily modified. I needed to make it parse args out-of-order, lazy load additional command contexts and options, etc. I figured it was time to modernize this and I have switched over to Commander.js.As cool as this idea is, I sort of regret it. In short, Commander.js isn't great at loading additional options and such while parsing. I had to do a bunch of hacks using hooks and manipulating state. It works, but it's still gross. I passed the point of no return long before I realized this. I was tempted to use
cli-kit
, a library I wrote for the Axway CLI and Appc Daemon, but at the end of the day, the complications all stem from the platform specific code in the SDK, not the CLI. The idea now is to refactor the SDK code to use Commander.js better.16. Prompting
As apart of this refactor, I've switched the default prompt library from
fields
toprompts
. I wrotefields
and it was pretty rad, but I didn't really take it to the next level. There wasn't time to introduce new cute prompts. I had hoped to takefields
and modernize it as apart ofcli-kit
, but that never happened.prompts
is a decent library and the default prompt library. Just note that some of the prompts are coming from the SDK and continue to use fields.17. Switching to
pnpm
For development, I've switched over to the superior
pnpm
package manager. Just runpnpm i
to install the dependencies. There's no build command because there's no transpilation, no TypeScript, no Babel. Maybe someday...18. Tests and Linting
All test were incredibly out-of-date. It's much easier to start over. Sit tight, they'll be back.
19. Performance Improvement?
Sadly I don't have benchmarks, but hopefully there's a noticable speed gain. Here's what changed:
esbuild
--log-level trace
Prelimiary package deltas:
Help Wanted
This is a monster PR that needs lots of testing. You must use Node 18 or newer. Clone and pull this PR. Run
pnpm i
. Link thebin/ti.js
script toti
. I developed this on Windows with very limited testing on macOS. I have not tested Linux at all. I have not tested this with the VS Code or Atom plugins. I expect issues.Here's the plan:
7_0_X
branchnext
so users can thennpm i -g titanium@next
to test itlatest
Cheers!