Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
feat(create-graphback): add ability to disable templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Enda Phelan committed Oct 12, 2020
1 parent 1fcee77 commit 57de515
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/create-graphback/src/init/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function checkDirectory(path: string, name: string): void {
async function chooseTemplate(filter: string = ''): Promise<Template> {
const regex = new RegExp(`.*${filter}.*`, 'i');
const displayedTemplates = allTemplates.filter((template: Template) =>
regex.test(`${chalk.green(template.name)} ${template.description}`)
!template.disabled && regex.test(`${chalk.green(template.name)} ${template.description}`)
);
if (!displayedTemplates.length) {
logInfo(`create-graphback could not find templates matching the given filter: "${filter}".
Expand Down
16 changes: 13 additions & 3 deletions packages/create-graphback/src/init/starterTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const allTemplates: Template[] = [
branch: 'templates-1.0.0',
path: '/templates/ts-react-apollo-client',
mountpath: "client"
},{
}, {
uri: 'https://github.com/aerogear/graphback',
branch: 'templates-1.0.0',
path: '/templates/ts-apollo-mongodb-backend',
Expand All @@ -44,13 +44,18 @@ export const allTemplates: Template[] = [
{
name: 'fastify-fullstack-react-mongo-ts',
description: 'GraphQL Server based on Fastify connecting to MongoDB database and React client using TypeScript',
/**
* Keeping this template disabled until the following issue is fixed or investigated further:
* https://github.com/aerogear/graphback/issues/2174
*/
disabled: true,
repos: [
{
uri: 'https://github.com/aerogear/graphback',
branch: 'templates-1.0.0',
path: '/templates/ts-react-apollo-client',
mountpath: "client"
},{
}, {
uri: 'https://github.com/aerogear/graphback',
branch: 'templates-1.0.0',
path: '/templates/ts-fastify-mongodb-backend',
Expand All @@ -68,6 +73,11 @@ export const allTemplates: Template[] = [
{
name: 'fastify-mongo-server-ts',
description: 'GraphQL Server based on Fastify connecting to MongoDB database using TypeScript',
/**
* Keeping this template disabled until the following issue is fixed or investigated further:
* https://github.com/aerogear/graphback/issues/2174
*/
disabled: true,
repos: [{
uri: 'https://github.com/aerogear/graphback',
branch: 'templates-1.0.0',
Expand Down Expand Up @@ -184,7 +194,7 @@ export async function extractTemplate(template: Template, name: string) {
const file = await downloadRepository(tarInfo);
repo.mountpath = repo.mountpath || "";
const output = `${process.cwd()}/${name}/${repo.mountpath}`;
if(!existsSync(output)){
if (!existsSync(output)) {
mkdirSync(output);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/create-graphback/src/init/templateMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export interface Template {
name: string
description: string
repos: TemplateRepository[]
// If disabled, this template will not be available to select in CLI
disabled?: boolean
}

/**
Expand Down

0 comments on commit 57de515

Please sign in to comment.