-
Notifications
You must be signed in to change notification settings - Fork 182
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
[PDE-3436] refactor(cli): Explicitly require zapier-core in commands #579
Conversation
requiresCore() { | ||
return false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I tried declaring it in a constructor.
class AnalyticsCommand extends BaseCommand {
constructor() {
super();
this.requiresCore = true;
}
// ...
But I kept getting this error, which seemed to be something with oclif.
TypeError: Cannot read properties of undefined (reading 'scopedEnvVarKey')
at BuildCommand._run (~/z/zapier-repos/zapier-platform/packages/cli/node_modules/@oclif/command/lib/command.js:41:44)
at Command.run (~/z/zapier-repos/zapier-platform/packages/cli/node_modules/@oclif/command/lib/command.js:162:16)
at async Config.runCommand (~/z/zapier-repos/zapier-platform/packages/cli/node_modules/@oclif/config/lib/config.js:173:24)
at async Main.run (~/z/zapier-repos/zapier-platform/packages/cli/node_modules/@oclif/command/lib/main.js:27:9)
at async Main._run (~/z/zapier-repos/zapier-platform/packages/cli/node_modules/@oclif/command/lib/command.js:43:20)
If you've got any insight happy to hear what might be causing it. I didn't see anything in Oclif's docs and couldn't find anything relevant on Google.
if (this.requiresCore()) { | ||
this.throwForInvalidAppInstall(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I set the requirement too true
for all the packages that do require core but I'm no where near 100% sure on that. And I don't have a huge amount of faith that the unit tests would actually catch it if it's wrong for a command.
requiresCore() { | ||
return false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests failed without this here.
requiresCore() { | ||
return false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@robwa10 I just found we already have a flag called
So it's easier than we thought. You only need to set |
@eliangcs great catch, I should have seen that earlier as well! But at least it helped me learn how to do what I wanted to do in the first place. I've made the changes to add that flag to all the files that need it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure zapier test
and zapier validate
(and perhaps zapier build
) require core installation, so their skipValidInstallCheck
should be false
. And commands like zapier analytics
and zapier team:*
don't require core installation. Can you double check that you have the right list of commands? Thanks!
@eliangcs sorry about missing the commands in the folders (
I couldn't think of another way to test the commands to be sure if they needed core or not. If you've got any suggestions on other ways let me know! 👍 :ty: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also did the same for all the commands and got the same results as yours. Posting here for clarity:
command skipValidInstallCheck
-----------------------------------------------------------------------------------------
analytics true
build false // depends on `validate`, which requires core
convert true
delete:integration true
delete:version true
deprecate true
describe false // depends on `definition` local command to get app definition
env:get true
env:set true
env:unset true
history true
init true
integrations true
jobs true
link true
login true
logout true
logs true
migrate true
promote true
push false // depends on `validate`, which requires core
register true
scaffold true
team:add true
team:get true
team:remove true
test false // "Cannot find module 'zapier-platform-core'" when skipped
upload true // works as long as build.zip and source.zip exist
users:add true
users:get true
users:links true
users:remove true
validate false // "Cannot find module 'zapier-platform-core'" when skipped
versions true
I pushed a commit to remove the skipValidInstallCheck = false
statements. They're unnecessary because the default is already false. Also did some cleaning while I was there. If the changes look good to you, please go ahead and merge it. Thanks!
This change requires all cli commands to declare whether they need the
zapier-platform-core
package.