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
Ftp exist check #178
Ftp exist check #178
Conversation
|
^example screenshot when it finds an existing directory
Also ps. PR closes #105 |
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.
Our conversation earlier makes a lot more sense now I've looked at this.
I had assumed the check would be at deploy time which is why I wasn't concerned that the check might fail if you weren't connected to the network (because the deploy would also fail).
I like the idea of checking at project init and this is a useful check, but I think we need check at deploy time too.
| @@ -41,6 +41,7 @@ | |||
| "babel-core": "^7.0.0-bridge.0", | |||
| "babel-jest": "^26.1.0", | |||
| "babel-loader": "^8.2.2", | |||
| "basic-ftp": "^5.0.2", | |||
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 wonder if there's anything ftp-deploy does that's special. It'd be ideal if we didn't depend on two separate FTP packages.
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.
Yeah I agree. I had to use the alternate FTP package because ftp-deploy simply deploys and doesn't have too much other functionality.
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.
Hey @drzax I spoke to @colingourlay a bit this morning. My thinking on this is I'd like to not mess around with ftp-deploy which we've relied on in production for ages and it does its 1 job very well, as I don't know the full functionality of basic-ftp. Technically it should deploy the same, but seeing as the 1 job of this PR is to check for existing directories and not overwrite them, I don't really want to be messing around with implementing a different deploy library, which may even have unexpected consequences of overwriting other directories if not properly battle-tested with different configs and environments etc.
Happy to go to work on this feature straight away after merging this PR though. What do you think?
src/generators/project/index.js
Outdated
|
|
||
| // Ours | ||
| const { OUTPUT_DIRECTORY_NAME } = require('../../constants'); | ||
| const { cmd, hvy, opt, sec } = require('../../utils/color'); | ||
| const { success } = require('../../utils/logging'); | ||
| const { installDependencies } = require('../../utils/npm'); | ||
| const { combine } = require('../../utils/structures'); | ||
| const { getCredentials } = require('../../config/deploy'); | ||
|
|
||
| const DEPLOY_DIRECTORY = '/www/res/sites/news-projects/'; |
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.
Deploy directory isn't necessarily a constant. It would be good if (a) this path were not defined in multiple places (it's also here) and, (b) at deploy time, it checked based on the actual deploy where contentftp is the deploy target in .aunty/deploy.json.
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.
OK after talking with @colingourlay I'm going to get the deploy directory elsewhere and delete this.
src/config/deploy.js
Outdated
| @@ -139,3 +139,16 @@ module.exports.addProfileProperties = config => { | |||
|
|
|||
| return combine(config, profileProps); | |||
| }; | |||
|
|
|||
| module.exports.getCredentials = () => { | |||
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.
The config resolution is quite complex so it might be best if @colingourlay could advise, but it would be nice if credentials were fetched the same way as for deploy. For example, it seems from https://github.com/abcnews/aunty/blob/main/src/config/deploy.js#L123 that it's possible to set the profiles file path to something other than the default for the purposes of deploy and we wouldn't want to end up with a mismatch here.
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.
Yes this would be nice. @colingourlay I might grab you to run through a few things when I can.
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 with this, should be able to get it from getDeployConfig from what @colingourlay tells me.
|
Thanks @drzax these are really helpful and yep @colingourlay's help on this would be great too. I agree we should probably have it check at deploy and release time and just ask the user if they're sure they want to overwrite to the directory each time. I just had concerns because after a project is created and deployed for the 1st time, then the user will have to say Y (yes) they want to overwrite on every subsequent deploy/release. I'm just spitballing here now having a think .... what if we generated a unique ID for each project when created and put it in the base directory or something, that way we could check that the remote unique ID matches the local unique ID on deploy/upload and then we wouldn't even really need to ask them every time. Would that work? |
|
I would want it to check if the specific branch or tag I'm deploying already exists. So for most |
|
Implemented a warning if the FTP check fails when generating a new project due to no network or no credentials. |
|
Okay, I think this is pretty much ready to go. Simplified the process of getting credentials. Talked over all the functionality with @colingourlay Tested and working. |
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.
Code all looks good to me. I think it makes sense to prioritise being cautious about changing the ftp deploy process over reducing npm deps.
👍 👍
src/cli/deploy/index.js
Outdated
|
|
||
| const overwriteSelection = ( | ||
| await cliSelect({ | ||
| defaultValue: 0, |
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.
Not sure how cliSelect config works, but it seems like 'Yes' might be the default here? 'No' would be a safer choice.
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.
Yep, that was a deliberate choice as most of the time you'll want to do the overwrite so it's just a single keypress confirmation, but absolutely a No default would be safer. Personally, I use aunty build && aunty deploy quite a bit to make latest working changes to interactives available to others while in the dev process and then proxy my local dev server using "Resource Override" in the browser. I can default it to No though and we'll check how it feels with the extra downarrow keypress.

Hi all, I'm going to open this PR as it basically works as is and could be merged, but I could maybe do with some feedback about developing it more and how to handle some edge cases, also as I'm not too familiar with Yeoman and all its user interaction stuff.
So what it does is this:
When a user generates a new project with
aunty newit uses Yeoman's validate feature to run a function that lists the contents of the/www/res/sites/news-projects/FTP directory and checks the folder names against the sluggified project name. If a match is found it doesn't let the user proceed and asks them to choose a different project name.So the edge cases are:
I guess my question is, what do we do when one of these errors happens. My feeling is that maybe we just console.log a warning that the FTP check failed and that there is a small possibility that the project already exists on the server, and then just leave it to the user to check manually or pray that it doesn't exist.
Keen to hear feedback.