Skip to content
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

Use a different strategy for pulsar -p on Windows… #1063

Conversation

savetheclocktower
Copy link
Contributor

@savetheclocktower savetheclocktower commented Jul 21, 2024

…by handling the argument processing in the batch file.

This one is a bit ridiculous, but somehow less ridiculous than what I was doing in #1054.

We opt into a bunch of headaches by trying to use the Electron app itself to handle command-line output. Most of the features of pulsar in the terminal are necessary evils, but for the reason discovered in #1054 (Electron can't do magical encoding conversion on its output the way Node can) we should try to minimize the stuff we ask pulsar to write to STDOUT. (Windows especially, since that's the platform least likely to have terminal output rendered as UTF-8; but it's a theoretical concern on other platforms as well.)

If we could intercept -p/--package at the script level, we could redirect those calls to ppm before they hit Electron. Then we wouldn't be creating any new encoding issues for ourselves.

Luckily, we already have some wrapper scripts meant to handle calls to pulsar. On Windows, it's pulsar.cmd, a file written in ancient batch file syntax. Imagine all the things you'd want from a scripting language if you were inventing one in the year 2024; batch files seem like they were intentionally designed to have none of those features. But there are lots of masochists online! Stack Overflow and SS64.com were quite useful in figuring out how to do this.

The idea is to behave identically in the batch file as we already do in parse-command-line.js when we see a -p or --package flag:

  • ignore all arguments prior to -p/--package, then
  • assemble all the arguments after -p/--package, then
  • pass them as arguments to ppm.

This is convoluted in batch files because they don't have loops or array methods, but it's possible nonetheless.

Testing

This is very important to test thoroughly on Windows, since we can't really write automated tests for this. Here's what I did, and it all seemed to work great:

  • Verify all these commands produce the same output:
    • pulsar --package --version
    • pulsar -p -v
    • ppm --version
    • pulsar --wait --package --version (testing that any arguments before --package are ignored
  • Verify these commands produce the same output, and that it's not weird-looking or garbled:
    • pulsar --package list
    • pulsar -p list
    • ppm list
    • pulsar -v --package list
  • Verify that commands which don't use --package/-p behave like they always did:
    • pulsar .
    • pulsar --dev .
    • pulsar --wait foo.js
    • pulsar --test spec/*-spec.js

Should we do this on all platforms?

Yes! But Windows is the most salient because of the extant bugs with pulsar -p on that platform.

Right now, pulsar --package list on my macOS machine starts the Pulsar icon bouncing in the dock for a brief second before we get output. That's because we're launching a GUI app just to launch a command-line app. It'll be faster if we cut out the middle man.

Once we do this on all platforms, should we remove the equivalent functionality from Pulsar?

No. Because we do handle lots of command-line stuff via the main process, most of the command-line switches will still work if you invoke Pulsar.exe or the actual pulsar Electron executable. And we should keep handling those for these reasons:

  • Some Windows users might have needed to add Pulsar to their PATH manually and incorrectly assumed that they should add the folder that holds Pulsar.exe, rather than the one that holds pulsar.cmd.
  • Some Linux users are using the AppImage version. As far as I can tell, invoking the AppImage file from the terminal is much like invoking the actual pulsar executable (instead of pulsar.sh). (And as I understand it, the -p flag was basically invented for this use case!) If we can change the AppImage so that invoking it somehow hits the logic in pulsar.sh, then that'd be grand; failing that, handling -p/--package redundantly in the main process is a fallback that helps AppImage users not to be second-class citizens.

For the same reasons, this PR is a companion to #1054, not a replacement.

…by handling the argument processing in the batch file.
@Spiker985
Copy link
Member

It looks fine in theory, I'll have to see if I can get this onto my work laptop, otherwise I'll have to set up a QEMU instance in order to test

I switched off my Arch Linux install, over to NixOS, and in the jump I didn't migrate my MacOS builds or Windows build.

@savetheclocktower
Copy link
Contributor Author

It looks fine in theory, I'll have to see if I can get this onto my work laptop, otherwise I'll have to set up a QEMU instance in order to test

I switched off my Arch Linux install, over to NixOS, and in the jump I didn't migrate my MacOS builds or Windows build.

That's kind of you. I added you because I seemed to remember you had a Windows machine, but hopefully you won't have to go to such lengths and we'll be able to find a couple more Windows testers.

@DeeDeeG
Copy link
Member

DeeDeeG commented Jul 25, 2024

I have tested this! Here are my notes, following from the "Testing" section of the PR body text above.

All test commands were run in cmd.exe.

Rolling 1.119.2024071703 (control)

(From the commit on master branch that is the immediate parent commit of this PR's commits)

Testing notes for Rolling (click to expand):
Verify all these commands produce the same output:
    pulsar --package --version
    pulsar -p -v
    ppm --version
    pulsar --wait --package --version (testing that any arguments before --package are ignored

Perhaps as expected for current Rolling, these test commands did not work successfully:

C:\Users\User>pulsar --package --version

Pulsar  : 1.119.2024071703
Electron: 12.2.3
Chrome  : 89.0.4389.128
Node    : 14.16.0

C:\Users\User>pulsar -p -v

Pulsar  : 1.119.2024071703
Electron: 12.2.3
Chrome  : 89.0.4389.128
Node    : 14.16.0

C:\Users\User>ppm --version
AssignProcessToJobObject: (87) The parameter is incorrect.

C:\Users\User>pulsar --wait --package --version

Pulsar  : 1.119.2024071703
Electron: 12.2.3
Chrome  : 89.0.4389.128
Node    : 14.16.0

Furthermore, the command just above with the --wait did get stuck waiting for Pulsar, which it really shouldn't for good user experience when running a --version command.

Verify these commands produce the same output, and that it's not weird-looking or garbled:
    pulsar --package list
    pulsar -p list
    ppm list
    pulsar -v --package list

Nope, as probably to be expected, these tests failed. Outputs were distinct and did not match. Setting aside much of the output being broken, as it's off-topic for this particular PR, I guess. See output below:

C:\Users\User>pulsar --package list


C:\Users\User>pulsar -p list


C:\Users\User>ppm list
Built-in Atom Packages (95)
├── atom-dark-syntax@0.29.1
├── atom-dark-ui@0.53.3
├── atom-light-syntax@0.29.1
├── atom-light-ui@0.46.3
├── base16-tomorrow-dark-theme@1.6.0
├── base16-tomorrow-light-theme@1.6.0
├── one-dark-ui@1.12.5
├── one-light-ui@1.12.5
├── one-dark-syntax@1.8.4
├── one-light-syntax@1.8.4
├── solarized-dark-syntax@1.3.0
├── solarized-light-syntax@1.3.0
├── about@1.9.1
├── archive-view@0.66.0
├── autocomplete-atom-api@0.10.7
├── autocomplete-css@0.17.5
├── autocomplete-html@0.8.9
├── autocomplete-plus@2.42.6
├── autocomplete-snippets@1.12.1
├── autoflow@0.29.4
├── autosave@0.24.6
├── background-tips@0.28.1
├── bookmarks@0.46.0
├── bracket-matcher@0.92.0
├── command-palette@0.43.5
├── dalek@0.2.2
├── deprecation-cop@0.56.9
├── dev-live-reload@0.48.1
├── encoding-selector@0.23.9
├── exception-reporting@0.43.1
├── find-and-replace@0.219.8
├── fuzzy-finder@1.14.3
├── github@0.36.20
├── git-diff@1.3.9
├── go-to-line@0.33.0
├── grammar-selector@0.50.1
├── image-view@0.64.0
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.39.1
├── line-ending-selector@0.7.7
├── link@0.31.6
├── markdown-preview@0.160.2
├── notifications@0.73.0
├── open-on-github@1.3.2
├── package-generator@1.3.0
├── pulsar-updater@1.0.0
├── settings-view@0.261.11
├── snippets@1.8.0
├── spell-check@0.77.1
├── status-bar@1.8.17
├── styleguide@0.49.12
├── symbol-provider-ctags@1.0.0
├── symbol-provider-tree-sitter@1.0.0
├── symbols-view@1.0.0
├── tabs@0.110.2
├── timecop@0.36.2
├── tree-view@0.229.1
├── update-package-dependencies@0.13.1
├── welcome@0.36.9
├── whitespace@0.37.8
├── wrap-guide@0.41.1
├── language-c@0.60.20
├── language-clojure@0.22.8
├── language-coffee-script@0.50.0
├── language-csharp@1.1.0
├── language-css@0.45.4
├── language-gfm@0.90.8
├── language-git@0.19.1
├── language-go@0.47.3
├── language-html@0.53.1
├── language-hyperlink@0.17.1
├── language-java@0.32.1
├── language-javascript@0.134.2
├── language-json@1.0.5
├── language-less@0.34.3
├── language-make@0.23.0
├── language-mustache@0.14.5
├── language-objective-c@0.16.0
├── language-perl@0.38.1
├── language-php@0.48.1
├── language-property-list@0.9.1
├── language-python@0.53.6
├── language-ruby@0.73.0
├── language-ruby-on-rails@0.25.3
├── language-rust-bundled@0.1.1
├── language-sass@0.62.2
├── language-shellscript@0.28.2
├── language-source@0.9.0
├── language-sql@0.25.10
├── language-text@0.7.4
├── language-todo@0.29.4
├── language-toml@0.20.0
├── language-typescript@0.6.4
├── language-xml@0.35.3
└── language-yaml@0.32.0

Community Packages (0) C:\Users\User\.pulsar\packages
└── (empty)

Git Packages (1) C:\Users\User\.pulsar\packages
└── pulsar-ide-clangd@0.6.1 (savetheclocktower/pulsar-ide-clangd#2ce8af6d)


C:\Users\User>pulsar -v --package list

Pulsar  : 1.119.2024071703
Electron: 12.2.3
Chrome  : 89.0.4389.128
Node    : 14.16.0
Verify that commands which don't use --package/-p behave like they always did:
    	
    pulsar --dev .
    pulsar --wait foo.js
    pulsar --test spec/*-spec.js

Results varied. Stuff mostly seems to work, even on Rolling, but with some quirks:

  • pulsar --dev .
    • Sure. If I set ATOM_DEV_RESOURCE_PATH env var correctly to point to a prepared copy of the core repo first. As to be expected.
  • pulsar --wait foo.js
    • Sure, but weirdly, it exits cmd.exe right when I exit Pulsar if a file/path is specified. And it "sticks" cmd.exe on semingly waiting for Pulsar to exit, even after I do fully exit Pulsar, if I don't specify a file or path when launched with --wait.
  • pulsar --test spec/*-spec.js
    • Sure, but only if I specify specific real single filename. The wildcard thing is not working in cmd.exe. To be pedantic: needs to be a backslash \ for Windows .cmd.exe, not a forward slash /.

Binary from CI for this PR #1063 (seeing if the fix works)

Testing notes for this PR (click to expand):
Verify all these commands produce the same output:
    pulsar --package --version
    pulsar -p -v
    ppm --version
    pulsar --wait --package --version (testing that any arguments before --package are ignored

Yes, fix appears to have worked, in the sense that output is consistent (consistently broken, but that is beyond the scope of and therefore beside the point of the present PR, I think):

PS C:\Users\User\Downloads> pulsar --package --version
AssignProcessToJobObject: (87) The parameter is incorrect.
PS C:\Users\User\Downloads> pulsar -p -v
AssignProcessToJobObject: (87) The parameter is incorrect.
PS C:\Users\User\Downloads> ppm --version
AssignProcessToJobObject: (87) The parameter is incorrect.
PS C:\Users\User\Downloads> pulsar --wait --package --version
AssignProcessToJobObject: (87) The parameter is incorrect.
Verify these commands produce the same output, and that it's not weird-looking or garbled:
    pulsar --package list
    pulsar -p list
    ppm list
    pulsar -v --package list

Yes, output is the same each time and doesn't seem messed up in any particular way:

PS C:\Users\User\Downloads> pulsar --package list
Built-in Atom Packages (95)
├── atom-dark-syntax@0.29.1
├── atom-dark-ui@0.53.3
├── atom-light-syntax@0.29.1
├── atom-light-ui@0.46.3
├── base16-tomorrow-dark-theme@1.6.0
├── base16-tomorrow-light-theme@1.6.0
├── one-dark-ui@1.12.5
├── one-light-ui@1.12.5
├── one-dark-syntax@1.8.4
├── one-light-syntax@1.8.4
├── solarized-dark-syntax@1.3.0
├── solarized-light-syntax@1.3.0
├── about@1.9.1
├── archive-view@0.66.0
├── autocomplete-atom-api@0.10.7
├── autocomplete-css@0.17.5
├── autocomplete-html@0.8.9
├── autocomplete-plus@2.42.6
├── autocomplete-snippets@1.12.1
├── autoflow@0.29.4
├── autosave@0.24.6
├── background-tips@0.28.1
├── bookmarks@0.46.0
├── bracket-matcher@0.92.0
├── command-palette@0.43.5
├── dalek@0.2.2
├── deprecation-cop@0.56.9
├── dev-live-reload@0.48.1
├── encoding-selector@0.23.9
├── exception-reporting@0.43.1
├── find-and-replace@0.219.8
├── fuzzy-finder@1.14.3
├── github@0.36.20
├── git-diff@1.3.9
├── go-to-line@0.33.0
├── grammar-selector@0.50.1
├── image-view@0.64.0
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.39.1
├── line-ending-selector@0.7.7
├── link@0.31.6
├── markdown-preview@0.160.2
├── notifications@0.73.0
├── open-on-github@1.3.2
├── package-generator@1.3.0
├── pulsar-updater@1.0.0
├── settings-view@0.261.11
├── snippets@1.8.0
├── spell-check@0.77.1
├── status-bar@1.8.17
├── styleguide@0.49.12
├── symbol-provider-ctags@1.0.0
├── symbol-provider-tree-sitter@1.0.0
├── symbols-view@1.0.0
├── tabs@0.110.2
├── timecop@0.36.2
├── tree-view@0.229.1
├── update-package-dependencies@0.13.1
├── welcome@0.36.9
├── whitespace@0.37.8
├── wrap-guide@0.41.1
├── language-c@0.60.20
├── language-clojure@0.22.8
├── language-coffee-script@0.50.0
├── language-csharp@1.1.0
├── language-css@0.45.4
├── language-gfm@0.90.8
├── language-git@0.19.1
├── language-go@0.47.3
├── language-html@0.53.1
├── language-hyperlink@0.17.1
├── language-java@0.32.1
├── language-javascript@0.134.2
├── language-json@1.0.5
├── language-less@0.34.3
├── language-make@0.23.0
├── language-mustache@0.14.5
├── language-objective-c@0.16.0
├── language-perl@0.38.1
├── language-php@0.48.1
├── language-property-list@0.9.1
├── language-python@0.53.6
├── language-ruby@0.73.0
├── language-ruby-on-rails@0.25.3
├── language-rust-bundled@0.1.1
├── language-sass@0.62.2
├── language-shellscript@0.28.2
├── language-source@0.9.0
├── language-sql@0.25.10
├── language-text@0.7.4
├── language-todo@0.29.4
├── language-toml@0.20.0
├── language-typescript@0.6.4
├── language-xml@0.35.3
└── language-yaml@0.32.0

Community Packages (0) C:\Users\User\.pulsar\packages
└── (empty)

Git Packages (1) C:\Users\User\.pulsar\packages
└── pulsar-ide-clangd@0.6.1 (savetheclocktower/pulsar-ide-clangd#2ce8af6d)

PS C:\Users\User\Downloads> pulsar -p list
Built-in Atom Packages (95)
├── atom-dark-syntax@0.29.1
├── atom-dark-ui@0.53.3
├── atom-light-syntax@0.29.1
├── atom-light-ui@0.46.3
├── base16-tomorrow-dark-theme@1.6.0
├── base16-tomorrow-light-theme@1.6.0
├── one-dark-ui@1.12.5
├── one-light-ui@1.12.5
├── one-dark-syntax@1.8.4
├── one-light-syntax@1.8.4
├── solarized-dark-syntax@1.3.0
├── solarized-light-syntax@1.3.0
├── about@1.9.1
├── archive-view@0.66.0
├── autocomplete-atom-api@0.10.7
├── autocomplete-css@0.17.5
├── autocomplete-html@0.8.9
├── autocomplete-plus@2.42.6
├── autocomplete-snippets@1.12.1
├── autoflow@0.29.4
├── autosave@0.24.6
├── background-tips@0.28.1
├── bookmarks@0.46.0
├── bracket-matcher@0.92.0
├── command-palette@0.43.5
├── dalek@0.2.2
├── deprecation-cop@0.56.9
├── dev-live-reload@0.48.1
├── encoding-selector@0.23.9
├── exception-reporting@0.43.1
├── find-and-replace@0.219.8
├── fuzzy-finder@1.14.3
├── github@0.36.20
├── git-diff@1.3.9
├── go-to-line@0.33.0
├── grammar-selector@0.50.1
├── image-view@0.64.0
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.39.1
├── line-ending-selector@0.7.7
├── link@0.31.6
├── markdown-preview@0.160.2
├── notifications@0.73.0
├── open-on-github@1.3.2
├── package-generator@1.3.0
├── pulsar-updater@1.0.0
├── settings-view@0.261.11
├── snippets@1.8.0
├── spell-check@0.77.1
├── status-bar@1.8.17
├── styleguide@0.49.12
├── symbol-provider-ctags@1.0.0
├── symbol-provider-tree-sitter@1.0.0
├── symbols-view@1.0.0
├── tabs@0.110.2
├── timecop@0.36.2
├── tree-view@0.229.1
├── update-package-dependencies@0.13.1
├── welcome@0.36.9
├── whitespace@0.37.8
├── wrap-guide@0.41.1
├── language-c@0.60.20
├── language-clojure@0.22.8
├── language-coffee-script@0.50.0
├── language-csharp@1.1.0
├── language-css@0.45.4
├── language-gfm@0.90.8
├── language-git@0.19.1
├── language-go@0.47.3
├── language-html@0.53.1
├── language-hyperlink@0.17.1
├── language-java@0.32.1
├── language-javascript@0.134.2
├── language-json@1.0.5
├── language-less@0.34.3
├── language-make@0.23.0
├── language-mustache@0.14.5
├── language-objective-c@0.16.0
├── language-perl@0.38.1
├── language-php@0.48.1
├── language-property-list@0.9.1
├── language-python@0.53.6
├── language-ruby@0.73.0
├── language-ruby-on-rails@0.25.3
├── language-rust-bundled@0.1.1
├── language-sass@0.62.2
├── language-shellscript@0.28.2
├── language-source@0.9.0
├── language-sql@0.25.10
├── language-text@0.7.4
├── language-todo@0.29.4
├── language-toml@0.20.0
├── language-typescript@0.6.4
├── language-xml@0.35.3
└── language-yaml@0.32.0

Community Packages (0) C:\Users\User\.pulsar\packages
└── (empty)

Git Packages (1) C:\Users\User\.pulsar\packages
└── pulsar-ide-clangd@0.6.1 (savetheclocktower/pulsar-ide-clangd#2ce8af6d)

PS C:\Users\User\Downloads> ppm list
Built-in Atom Packages (95)
├── atom-dark-syntax@0.29.1
├── atom-dark-ui@0.53.3
├── atom-light-syntax@0.29.1
├── atom-light-ui@0.46.3
├── base16-tomorrow-dark-theme@1.6.0
├── base16-tomorrow-light-theme@1.6.0
├── one-dark-ui@1.12.5
├── one-light-ui@1.12.5
├── one-dark-syntax@1.8.4
├── one-light-syntax@1.8.4
├── solarized-dark-syntax@1.3.0
├── solarized-light-syntax@1.3.0
├── about@1.9.1
├── archive-view@0.66.0
├── autocomplete-atom-api@0.10.7
├── autocomplete-css@0.17.5
├── autocomplete-html@0.8.9
├── autocomplete-plus@2.42.6
├── autocomplete-snippets@1.12.1
├── autoflow@0.29.4
├── autosave@0.24.6
├── background-tips@0.28.1
├── bookmarks@0.46.0
├── bracket-matcher@0.92.0
├── command-palette@0.43.5
├── dalek@0.2.2
├── deprecation-cop@0.56.9
├── dev-live-reload@0.48.1
├── encoding-selector@0.23.9
├── exception-reporting@0.43.1
├── find-and-replace@0.219.8
├── fuzzy-finder@1.14.3
├── github@0.36.20
├── git-diff@1.3.9
├── go-to-line@0.33.0
├── grammar-selector@0.50.1
├── image-view@0.64.0
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.39.1
├── line-ending-selector@0.7.7
├── link@0.31.6
├── markdown-preview@0.160.2
├── notifications@0.73.0
├── open-on-github@1.3.2
├── package-generator@1.3.0
├── pulsar-updater@1.0.0
├── settings-view@0.261.11
├── snippets@1.8.0
├── spell-check@0.77.1
├── status-bar@1.8.17
├── styleguide@0.49.12
├── symbol-provider-ctags@1.0.0
├── symbol-provider-tree-sitter@1.0.0
├── symbols-view@1.0.0
├── tabs@0.110.2
├── timecop@0.36.2
├── tree-view@0.229.1
├── update-package-dependencies@0.13.1
├── welcome@0.36.9
├── whitespace@0.37.8
├── wrap-guide@0.41.1
├── language-c@0.60.20
├── language-clojure@0.22.8
├── language-coffee-script@0.50.0
├── language-csharp@1.1.0
├── language-css@0.45.4
├── language-gfm@0.90.8
├── language-git@0.19.1
├── language-go@0.47.3
├── language-html@0.53.1
├── language-hyperlink@0.17.1
├── language-java@0.32.1
├── language-javascript@0.134.2
├── language-json@1.0.5
├── language-less@0.34.3
├── language-make@0.23.0
├── language-mustache@0.14.5
├── language-objective-c@0.16.0
├── language-perl@0.38.1
├── language-php@0.48.1
├── language-property-list@0.9.1
├── language-python@0.53.6
├── language-ruby@0.73.0
├── language-ruby-on-rails@0.25.3
├── language-rust-bundled@0.1.1
├── language-sass@0.62.2
├── language-shellscript@0.28.2
├── language-source@0.9.0
├── language-sql@0.25.10
├── language-text@0.7.4
├── language-todo@0.29.4
├── language-toml@0.20.0
├── language-typescript@0.6.4
├── language-xml@0.35.3
└── language-yaml@0.32.0

Community Packages (0) C:\Users\User\.pulsar\packages
└── (empty)

Git Packages (1) C:\Users\User\.pulsar\packages
└── pulsar-ide-clangd@0.6.1 (savetheclocktower/pulsar-ide-clangd#2ce8af6d)

PS C:\Users\User\Downloads>  pulsar -v --package list
Built-in Atom Packages (95)
├── atom-dark-syntax@0.29.1
├── atom-dark-ui@0.53.3
├── atom-light-syntax@0.29.1
├── atom-light-ui@0.46.3
├── base16-tomorrow-dark-theme@1.6.0
├── base16-tomorrow-light-theme@1.6.0
├── one-dark-ui@1.12.5
├── one-light-ui@1.12.5
├── one-dark-syntax@1.8.4
├── one-light-syntax@1.8.4
├── solarized-dark-syntax@1.3.0
├── solarized-light-syntax@1.3.0
├── about@1.9.1
├── archive-view@0.66.0
├── autocomplete-atom-api@0.10.7
├── autocomplete-css@0.17.5
├── autocomplete-html@0.8.9
├── autocomplete-plus@2.42.6
├── autocomplete-snippets@1.12.1
├── autoflow@0.29.4
├── autosave@0.24.6
├── background-tips@0.28.1
├── bookmarks@0.46.0
├── bracket-matcher@0.92.0
├── command-palette@0.43.5
├── dalek@0.2.2
├── deprecation-cop@0.56.9
├── dev-live-reload@0.48.1
├── encoding-selector@0.23.9
├── exception-reporting@0.43.1
├── find-and-replace@0.219.8
├── fuzzy-finder@1.14.3
├── github@0.36.20
├── git-diff@1.3.9
├── go-to-line@0.33.0
├── grammar-selector@0.50.1
├── image-view@0.64.0
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.39.1
├── line-ending-selector@0.7.7
├── link@0.31.6
├── markdown-preview@0.160.2
├── notifications@0.73.0
├── open-on-github@1.3.2
├── package-generator@1.3.0
├── pulsar-updater@1.0.0
├── settings-view@0.261.11
├── snippets@1.8.0
├── spell-check@0.77.1
├── status-bar@1.8.17
├── styleguide@0.49.12
├── symbol-provider-ctags@1.0.0
├── symbol-provider-tree-sitter@1.0.0
├── symbols-view@1.0.0
├── tabs@0.110.2
├── timecop@0.36.2
├── tree-view@0.229.1
├── update-package-dependencies@0.13.1
├── welcome@0.36.9
├── whitespace@0.37.8
├── wrap-guide@0.41.1
├── language-c@0.60.20
├── language-clojure@0.22.8
├── language-coffee-script@0.50.0
├── language-csharp@1.1.0
├── language-css@0.45.4
├── language-gfm@0.90.8
├── language-git@0.19.1
├── language-go@0.47.3
├── language-html@0.53.1
├── language-hyperlink@0.17.1
├── language-java@0.32.1
├── language-javascript@0.134.2
├── language-json@1.0.5
├── language-less@0.34.3
├── language-make@0.23.0
├── language-mustache@0.14.5
├── language-objective-c@0.16.0
├── language-perl@0.38.1
├── language-php@0.48.1
├── language-property-list@0.9.1
├── language-python@0.53.6
├── language-ruby@0.73.0
├── language-ruby-on-rails@0.25.3
├── language-rust-bundled@0.1.1
├── language-sass@0.62.2
├── language-shellscript@0.28.2
├── language-source@0.9.0
├── language-sql@0.25.10
├── language-text@0.7.4
├── language-todo@0.29.4
├── language-toml@0.20.0
├── language-typescript@0.6.4
├── language-xml@0.35.3
└── language-yaml@0.32.0

Community Packages (0) C:\Users\User\.pulsar\packages
└── (empty)

Git Packages (1) C:\Users\User\.pulsar\packages
└── pulsar-ide-clangd@0.6.1 (savetheclocktower/pulsar-ide-clangd#2ce8af6d)
Verify that commands which don't use --package/-p behave like they always did:
    	
    pulsar --dev .
    pulsar --wait foo.js
    pulsar --test spec/*-spec.js

Yeah, seems like these work the same as before. My exact notes from testing this, but any/all quirks seem the same as Rolling before/without this PR:

pulsar --wait (no file or path specified) results in the editor being "stuck" in pulsar --wait and requiring a Ctrl + C to get an open prompt again.

pulsar --wait foo.js opens Pulsar with a tab open to foo.js for editing, but cmd.exe immediately closes when you do File -> Exit in Pulsar.

pulsar --dev works (with ATOM_DEV_RESOURCE_PATH set properly to point to a prepared core repo dir)

pulsar --test spec\[some-specific-spec-file-here]-spec.js worked (For literally running pulsar --test spec/*-spec.js verbatim, the wildcard thing isn't working, and I get Error: Cannot find module 'C:\Users\User\pulsar\spec\*-spec.js')

Summary of Findings

Fix appears to work where it's intended to -- remaining quirks are presumably out of scope for the present PR, but may for all I know be addressed in #1054. In any case, I don't see any issues from this testing per se for the current PR. 👍

Comment on lines 76 to 87
:trim_args_for_package_mode
if not "%1"=="--package" (
if not "%1" == "-p" (
REM Roughly the same as `ARGV.shift`. Everything except the initial argument
REM moves forward, and the second argument is removed from the list.
SHIFT /1
goto :trim_args_for_package_mode
)
)
REM When we reach this point, `-p`/`--package` is the argument in the %1
REM position. Now we'll call `shift` once more to remove it from the list.
SHIFT /1
Copy link
Member

@DeeDeeG DeeDeeG Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurs to me someone could ask folks to copy-paste some long pulsar command ending with -p install [some package] in order to obfuscate the true purpose of the command. And that's basically remote arbitrary code execution at that point, for example given the flexibility npm lifecycle scripts have, and given how arbitrarily capable packages can be in general.

This sort of short-circuiting is fine for --version, since hopefully "just doing a version print and then immediately exiting Pulsar" won't be chainable into an exploit. I think package installation is a little more sensitive, though.

Can we make -p / --package throw an error and print a usage hint if it's not the first argument after pulsar itself? I think that'd be safer. And I think not much would be lost, at least in terms of I don't think this puts much of a barrier up for things a user should reasonably expect to be able to do (or would ever need to do).

Thoughts on this?

P.S. if this is what we've been doing on Linux and macOS all this time, I'd consider it a to-do to align Linux and macOS with whatever we settle on.

Copy link
Contributor Author

@savetheclocktower savetheclocktower Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make -p / --package throw an error and print a usage hint if it's not the first argument after pulsar itself? I think that'd be safer. And I think not much would be lost, at least in terms of I don't think this puts much of a barrier up for things a user should reasonably expect to be able to do (or would ever need to do).

We can, but I'd ask for that to be filed as a separate issue so that we can make it behave that way on all platforms simultaneously.

EDIT: To elaborate… the way this PR handles -p/--package is exactly how Pulsar itself handles them. That was intentional. There's a fair point to be made about that not making a ton of sense, but that is how it's currently handled regardless of your platform.

@savetheclocktower savetheclocktower marked this pull request as ready for review July 25, 2024 16:49
Copy link
Member

@confused-Techie confused-Techie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone ahead and done some manual testing with this.

I just placed the new contents of pulsar.cmd into my existing copy and ran through all of the commands you listed, using different variations of -p and --package.

Mostly everything seemed to execute exactly as it should, including running commands meant for just Pulsar.

But I did encounter an error running pulsar --package install atom-clock which returns:

Unrecognized command: installatom-clock

So seems maybe we are loosing spaces when passing the values to ppm?

@savetheclocktower
Copy link
Contributor Author

So seems maybe we are loosing spaces when passing the values to ppm?

Weird! I'll put in extra spaces just to be safe.

Copy link
Member

@confused-Techie confused-Techie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work!

Testing now and everything seems to be happy as can be.

I'll be clear and say I haven't tested every single command, but from what I have things are looking good.

I'd also really like to point out this resolves the long-standing bug of windows not getting output from ppm.

Take a look at the output of the following commands:

Before this PR:

> pulsar --package install atom-clock


>

After this PR:

> pulsar --package install atom-clock
Installing atom-clock to C:\Users(user)\.pulsar\packages done
>

I'll also go ahead and make some confirmations:

  • ppm -v still works
  • pulsar -p -v returns ppm info
  • pulsar -v returns pulsar info
  • pulsar --package --version returns ppm info
  • ppm --version still works
  • pulsar --wait --package --version returns ppm info

So seems everything here works, and goes above and beyond to solve a longstanding and really annoying bug. Love to see it!

I'd say we are good to go, but if anyone else is testing then of course we want to allow ample time for different systems to ensure everything is expected

@savetheclocktower
Copy link
Contributor Author

I'll give this one a week or so just in case anyone else wants to take a look at it.

Copy link
Member

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, from my + @confused-Techie's testing. 👍

@confused-Techie
Copy link
Member

With two approvals, and a week has passed allowing other tests, I'd assume we are good to merge. Any loose ends on this one @savetheclocktower?

@savetheclocktower savetheclocktower merged commit ddaffa2 into pulsar-edit:master Aug 3, 2024
103 checks passed
@savetheclocktower savetheclocktower deleted the fix-pulsar-p-on-windows branch August 3, 2024 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants