Skip to content

Commit

Permalink
fix(cli): fixes new command (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
goldcaddy77 committed Nov 29, 2019
1 parent 80d0233 commit 6b1054e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ WARTHOG_AUTO_OPEN_PLAYGROUND=true yarn start:dev
### Create new project with the CLI

```bash
yarn global add warthog@beta
# Add warthog so that we can use the CLI
yarn add warthog

# Bootstrap a new application using Warthog CLI
yarn warthog new

# Install dependencies from generated package.json
yarn

# Generate a resource (model, resolver and service)
yarn warthog generate user name! nickname age:int! verified:bool!

Expand Down
6 changes: 5 additions & 1 deletion src/cli/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ export default {

const newFolder = toolbox.filesystem.path(__dirname, '../templates/new');
const files = await getFileRecursive(newFolder);

files.forEach(async file => {
const relativePath = path.relative(newFolder, file);
await generateFile(
toolbox,
props,
`new/${relativePath}`,
path.join(process.cwd(), 'new_app'),
process.cwd(),
relativePath.slice(0, -4) // remove .ejs
);
});
Expand All @@ -53,6 +54,9 @@ async function generateFile(
destFolder: string,
filename: string
) {
if (filename.startsWith('_')) {
filename = filename.replace(/^_/, '.');
}
const target = path.join(destFolder, '/', filename);

const generated = await toolbox.template.generate({
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions src/schema/getSchemaInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ export async function getSchemaInfo(options: BuildSchemaOptions) {

// get builded schema info from retrospection
const result = await graphql(schema, getIntrospectionQuery());
expect(result.errors).toBeUndefined();

if (!result || !result.data) {
throw new Error('Unable to introspect schema');
}

const schemaIntrospection = result.data.__schema as IntrospectionSchema;
expect(schemaIntrospection).toBeDefined();

const queryType = schemaIntrospection.types.find(
type => type.name === schemaIntrospection.queryType.name
) as IntrospectionObjectType;
Expand Down

0 comments on commit 6b1054e

Please sign in to comment.