diff --git a/lib/util/init.js b/lib/util/init.js index e1bb92aa1..230881d3f 100644 --- a/lib/util/init.js +++ b/lib/util/init.js @@ -24,7 +24,9 @@ const Init = { * @returns {Promise.} - */ async initProject(properties, credentialName) { - Init._checkPathForCloud(); + if (!(await Init._checkPathForCloud())) { + return; + } const skipInteraction = Util.skipInteraction; if (!properties) { @@ -196,7 +198,9 @@ const Init = { * @returns {Promise.} - */ async joinProject() { - Init._checkPathForCloud(); + if (!(await Init._checkPathForCloud())) { + return; + } const responses = await inquirer.prompt([ { @@ -376,7 +380,9 @@ const Init = { * @returns {Promise.} success flag */ async upgradeProject(properties, initial, repoName) { - Init._checkPathForCloud(); + if (!(await Init._checkPathForCloud())) { + return; + } let status; const versionBeforeUpgrade = properties?.version || '0.0.0'; @@ -412,25 +418,59 @@ const Init = { return true; }, /** - * check if git repo is being saved on a cloud service and warns the user + * check if git repo is being saved on a cloud service and warn the user * * @private * @returns {void} throws errors if problems were found */ - _checkPathForCloud() { + async _checkPathForCloud() { const absolutePath = path.resolve(''); // popular cloud services and their respective default name for the absolute path - const cloudServices = ['Dropbox', 'OneDrive', 'Google Drive']; + // * CloudDocs is the default folder name for iCloud + const cloudServices = ['Dropbox', 'OneDrive', 'Google Drive', 'iCloud', 'CloudDocs']; + let cloudServiceFound = false; for (const variable in cloudServices) { if (absolutePath.includes(cloudServices[variable])) { Util.logger.warn( - `It seems your project folder will be synchronized via '${cloudServices[variable]}'. This can reduce the overall performance of your computer due to conflicts with Git.` + `It seems your project folder will be synchronized via '${ + cloudServices[variable] === 'CloudDocs' ? 'iCloud' : cloudServices[variable] + }'. This can reduce the overall performance of your computer due to conflicts with Git.` ); Util.logger.warn( - `We strongly recommend moving your project folder outside of the '${cloudServices[variable]}' folder.` + `We strongly recommend moving your project folder outside of the '${ + cloudServices[variable] === 'CloudDocs' ? 'iCloud' : cloudServices[variable] + }' folder.` ); + cloudServiceFound = true; + } + } + if (!cloudServiceFound && absolutePath.includes(process.env.USERPROFILE)) { + // warn user to not place project folder into user profile folder + Util.logger.warn( + `It seems your project folder is located in your user profile's default folder which is often synchronized to webservices like ${cloudServices.join( + ', ' + )}. This can reduce the overall performance of your computer due to conflicts between with Git.` + ); + Util.logger.warn( + `We strongly recommend moving your project folder outside of this folder.` + ); + cloudServiceFound = true; + } + if (cloudServiceFound) { + const responses = await inquirer.prompt([ + { + type: 'confirm', + name: 'ignoreCloudWarning', + message: 'Do you want to continue anyways?', + default: false, + }, + ]); + if (!responses.ignoreCloudWarning) { + Util.logger.error('Exiting due to cloud service warning'); + return false; } } + return true; }, /**