Skip to content

Commit

Permalink
Fixed the issue of remote server not present.
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushNautiyalDeveloper committed Jan 31, 2024
1 parent cbeba16 commit c5cc299
Showing 1 changed file with 42 additions and 37 deletions.
79 changes: 42 additions & 37 deletions src/commands/new/glee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class NewGlee extends Command {
};

async getFilteredServers(serversObject: any) {
console.log({ serversObject });
const servers = Object.keys(serversObject);

const localServers = await prompt([
Expand Down Expand Up @@ -112,12 +113,15 @@ export default class NewGlee extends Command {
await this.validateFile(file, projectName, PROJECT_DIRECTORY);

try {
console.log(file);
const asyncapiInput = (await load(file)) || (await load());
console.log(asyncapiInput);

const serversObject = asyncapiInput.toJson().servers;

const filteredRemoteServers =
await this.getFilteredServers(serversObject);
const serversObject = asyncapiInput.toJson()?.servers;
let filteredRemoteServers: any[] = [];
if (serversObject) {
filteredRemoteServers = await this.getFilteredServers(serversObject);
}

const temporaryFileDirectory = 'asyncapi.yaml';
const { currentFileDirectory, updatedAsyncApiContent } =
Expand All @@ -140,20 +144,20 @@ export default class NewGlee extends Command {
);
} catch (err: any) {
switch (err.code) {
case 'EACCES':
this.error(
`Unable to create the project. We tried to access the "${PROJECT_DIRECTORY}" directory but it was not possible due to file access permissions. Please check the write permissions of your current working directory ("${process.cwd()}").`
);
break;
case 'EPERM':
this.error(
`Unable to create the project. We tried to create the "${PROJECT_DIRECTORY}" directory but the operation requires elevated privileges. Please check the privileges for your current user.`
);
break;
default:
this.error(
`Unable to create the project. Please check the following message for further info about the error:\n\n${err}`
);
case 'EACCES':

Check failure on line 147 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 6 spaces but found 8
this.error(

Check failure on line 148 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 8 spaces but found 10
`Unable to create the project. We tried to access the "${PROJECT_DIRECTORY}" directory but it was not possible due to file access permissions. Please check the write permissions of your current working directory ("${process.cwd()}").`

Check failure on line 149 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 10 spaces but found 12
);

Check failure on line 150 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 8 spaces but found 10
break;

Check failure on line 151 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 8 spaces but found 10
case 'EPERM':

Check failure on line 152 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 6 spaces but found 8
this.error(

Check failure on line 153 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 8 spaces but found 10
`Unable to create the project. We tried to create the "${PROJECT_DIRECTORY}" directory but the operation requires elevated privileges. Please check the privileges for your current user.`

Check failure on line 154 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 10 spaces but found 12
);

Check failure on line 155 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 8 spaces but found 10
break;

Check failure on line 156 in src/commands/new/glee.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 8 spaces but found 10
default:
this.error(
`Unable to create the project. Please check the following message for further info about the error:\n\n${err}`
);
}
}
}
Expand Down Expand Up @@ -183,6 +187,7 @@ export default class NewGlee extends Command {
}

if (file) {
console.log('file running');
await this.handleGenerateProjectWithFile(
file,
CURRENT_GLEE_TEMPLATE,
Expand All @@ -194,25 +199,25 @@ export default class NewGlee extends Command {
await fPromises.mkdir(PROJECT_DIRECTORY);
} catch (err: any) {
switch (err.code) {
case 'EEXIST':
this.error(
`Unable to create the project. We tried to use "${projectName}" as the directory of your new project but it already exists (${PROJECT_DIRECTORY}). Please specify a different name for the new project. For example, run the following command instead:\n\n asyncapi new ${this.commandName} --name ${projectName}-1\n`
);
break;
case 'EACCES':
this.error(
`Unable to create the project. We tried to access the "${PROJECT_DIRECTORY}" directory but it was not possible due to file access permissions. Please check the write permissions of your current working directory ("${process.cwd()}").`
);
break;
case 'EPERM':
this.error(
`Unable to create the project. We tried to create the "${PROJECT_DIRECTORY}" directory but the operation requires elevated privileges. Please check the privileges for your current user.`
);
break;
default:
this.error(
`Unable to create the project. Please check the following message for further info about the error:\n\n${err}`
);
case 'EEXIST':
this.error(
`Unable to create the project. We tried to use "${projectName}" as the directory of your new project but it already exists (${PROJECT_DIRECTORY}). Please specify a different name for the new project. For example, run the following command instead:\n\n asyncapi new ${this.commandName} --name ${projectName}-1\n`
);
break;
case 'EACCES':
this.error(
`Unable to create the project. We tried to access the "${PROJECT_DIRECTORY}" directory but it was not possible due to file access permissions. Please check the write permissions of your current working directory ("${process.cwd()}").`
);
break;
case 'EPERM':
this.error(
`Unable to create the project. We tried to create the "${PROJECT_DIRECTORY}" directory but the operation requires elevated privileges. Please check the privileges for your current user.`
);
break;
default:
this.error(
`Unable to create the project. Please check the following message for further info about the error:\n\n${err}`
);
}
}

Expand Down

0 comments on commit c5cc299

Please sign in to comment.