Skip to content

Commit

Permalink
fix: broken named imports (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
kon14 authored Jul 18, 2022
1 parent b206ac9 commit 8003b39
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ npm install -g @conduitplatform/cli
$ conduit COMMAND
running command...
$ conduit (--version|-v)
@conduitplatform/cli/0.0.4 linux-x64 node-v16.15.0
@conduitplatform/cli/0.0.5 linux-x64 node-v16.15.0
$ conduit --help [COMMAND]
USAGE
$ conduit COMMAND
Expand Down Expand Up @@ -111,7 +111,7 @@ DESCRIPTION

## `conduit generateClient graphql`

Generate a GraphQL client library for Conduit's GraphQL API
Generate client libraries for your Conduit GraphQL APIs

```
USAGE
Expand All @@ -122,12 +122,12 @@ FLAGS
-t, --client-type=<value> The client type to generate a library for
DESCRIPTION
Generate a GraphQL client library for Conduit's GraphQL API
Generate client libraries for your Conduit GraphQL APIs
```

## `conduit generateClient rest`

Generate a REST API client library for Conduit'S REST API
Generate client libraries for your Conduit REST APIs

```
USAGE
Expand All @@ -138,7 +138,7 @@ FLAGS
-t, --client-type=<value> The client type to generate a library for
DESCRIPTION
Generate a REST API client library for Conduit'S REST API
Generate client libraries for your Conduit REST APIs
```

## `conduit generateSchema [PATH]`
Expand All @@ -158,7 +158,7 @@ EXAMPLES
Generating schemas
```

_See code: [dist/commands/generateSchema.ts](https://github.com/ConduitPlatform/CLI/blob/v0.0.4/dist/commands/generateSchema.ts)_
_See code: [src/commands/generateSchema.ts](https://github.com/ConduitPlatform/CLI/blob/v0.0.5/src/commands/generateSchema.ts)_

## `conduit help [COMMAND]`

Expand Down Expand Up @@ -201,7 +201,7 @@ EXAMPLES
Login Successful!
```

_See code: [dist/commands/init.ts](https://github.com/ConduitPlatform/CLI/blob/v0.0.4/dist/commands/init.ts)_
_See code: [src/commands/init.ts](https://github.com/ConduitPlatform/CLI/blob/v0.0.5/src/commands/init.ts)_
<!-- commandsstop -->

# Roadmap
Expand Down
40 changes: 23 additions & 17 deletions src/utils/generateClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { booleanPrompt } from './cli';
import * as fs from 'fs';
import * as path from 'path';
import { recoverApiConfig } from './requestUtils';
import Init from '../commands/init';
import { Init } from '../commands/init';

export interface GenerateClientFlags {
'client-type': string | undefined,
'output-path': string | undefined,
'client-type': string | undefined;
'output-path': string | undefined;
}

export async function getClientType(parsedFlags: GenerateClientFlags, supportedClientTypes: string[]) {
export async function getClientType(
parsedFlags: GenerateClientFlags,
supportedClientTypes: string[],
) {
let clientType = parsedFlags['client-type'] ?? '';
while (!supportedClientTypes.includes(clientType)) {
console.log('\nSupported Client Types:');
Expand All @@ -31,7 +34,9 @@ export async function getOutputPath(
}
let outputPath: string | undefined = parsedFlags['output-path'];
while (!outputPath || !validateDirectoryPath(outputPath)) {
outputPath = await CliUx.ux.prompt('Specify output directory path', { default: process.cwd() });
outputPath = await CliUx.ux.prompt('Specify output directory path', {
default: process.cwd(),
});
}
let directoryName = `conduit-${apiType}-`;
if (apiType === 'rest') {
Expand All @@ -43,18 +48,19 @@ export async function getOutputPath(
}

export async function getBaseUrl(command: Command) {
const { url } = await recoverApiConfig(command)
.catch(async () => {
const runInit = await booleanPrompt(
'No configuration found. Run init and proceed?', 'yes');
if (!runInit) {
console.log('Aborting');
process.exit(0);
}
const init = new Init(command.argv, command.config);
await init.run();
return await recoverApiConfig(command);
});
const { url } = await recoverApiConfig(command).catch(async () => {
const runInit = await booleanPrompt(
'No configuration found. Run init and proceed?',
'yes',
);
if (!runInit) {
console.log('Aborting');
process.exit(0);
}
const init = new Init(command.argv, command.config);
await init.run();
return await recoverApiConfig(command);
});
return url;
}

Expand Down
19 changes: 13 additions & 6 deletions src/utils/requestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import * as path from 'path';
import { Command } from '@oclif/core';
import { Requests } from '../http/http';
import { booleanPrompt } from './cli';
import Init from './../commands/init';
import { Init } from './../commands/init';

export async function getRequestClient(command: Command) {
const apiConfigPath = path.join(command.config.configDir, 'config.json');
const adminConfigPath = path.join(command.config.configDir, 'admin.json');
if (!fs.existsSync(apiConfigPath) || !fs.existsSync(adminConfigPath)) {
const runInit = await booleanPrompt(
'No configuration found. Run init and proceed?', 'yes');
'No configuration found. Run init and proceed?',
'yes',
);
if (!runInit) {
console.log('Aborting');
process.exit(0);
Expand All @@ -35,7 +37,9 @@ export async function recoverApiConfig(command: Command) {
}

export async function recoverSecurityClientConfig(command: Command) {
const securityClientConfig = await fs.readJSON(path.join(command.config.configDir, 'securityClient.json'));
const securityClientConfig = await fs.readJSON(
path.join(command.config.configDir, 'securityClient.json'),
);
return {
clientId: securityClientConfig.clientId as string,
clientSecret: securityClientConfig.clientSecret as string,
Expand All @@ -45,7 +49,7 @@ export async function recoverSecurityClientConfig(command: Command) {
export async function storeConfiguration(
command: Command,
environment: { url: string; masterKey: string },
admin: { admin: string, password: string },
admin: { admin: string; password: string },
) {
await fs.ensureFile(path.join(command.config.configDir, 'config.json'));
await fs.ensureFile(path.join(command.config.configDir, 'admin.json'));
Expand All @@ -55,8 +59,11 @@ export async function storeConfiguration(

export async function storeSecurityClientConfiguration(
command: Command,
securityClient: { clientId: string, clientSecret: string }
securityClient: { clientId: string; clientSecret: string },
) {
await fs.ensureFile(path.join(command.config.configDir, 'securityClient.json'));
await fs.writeJSON(path.join(command.config.configDir, 'securityClient.json'), securityClient);
await fs.writeJSON(
path.join(command.config.configDir, 'securityClient.json'),
securityClient,
);
}

0 comments on commit 8003b39

Please sign in to comment.