Skip to content

Commit

Permalink
Support CLI selection for creating SubQuery and Subgraph projects (#2523
Browse files Browse the repository at this point in the history
)

* Support CLI selection for creating SubQuery and Subgraph projects

* some change

* Update messages

---------

Co-authored-by: Scott Twiname <[email protected]>
  • Loading branch information
yoozo and stwiname authored Aug 8, 2024
1 parent 56c40c9 commit d9ece31
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Default deployment type to SubQuery when deploying to the managed service (#2523).

## [5.2.0] - 2024-08-05
### Changed
Expand Down
11 changes: 11 additions & 0 deletions packages/cli/src/commands/project/create-project.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import assert from 'assert';
import {Command, Flags} from '@oclif/core';
import {BASE_PROJECT_URL, ROOT_API_URL_PROD} from '../../constants';
import {createProject} from '../../controller/project-controller';
Expand All @@ -19,12 +20,21 @@ export default class Create_project extends Command {
description: Flags.string({description: 'Enter description', default: '', required: false}),
apiVersion: Flags.string({description: 'Enter api version', default: '2', required: false}),
dedicatedDB: Flags.string({description: 'Enter dedicated DataBase', required: false}),
projectType: Flags.string({
description: 'Enter project type [subquery|subgraph]',
default: 'subquery',
required: false,
}),
};

async run(): Promise<void> {
const {flags} = await this.parse(Create_project);

let {gitRepo, org, projectName} = flags;
assert(
['subquery'].includes(flags.projectType),
'Invalid project type, only "subquery" is supported. Please deploy Subgraphs through the website.'
);
const authToken = await checkToken();

org = await valueOrPrompt(org, 'Enter organisation', 'Organisation is required');
Expand All @@ -35,6 +45,7 @@ export default class Create_project extends Command {
org,
flags.subtitle,
flags.logoURL,
flags.projectType === 'subquery' ? 1 : 3,
projectName,
authToken,
gitRepo,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/controller/deploy-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe.skip('CLI deploy, delete, promote', () => {
org,
subtitle,
logoURl,
1,
projectName,
testAuth,
repository,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/controller/project-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('CLI create project and delete project', () => {
org!,
subtitle,
logoURl,
1,
projectName,
testAuth!,
repository,
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/controller/project-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function createProject(
organization: string,
subtitle: string,
logoUrl: string,
project_type: number,
project_name: string,
authToken: string,
gitRepository: string,
Expand All @@ -42,6 +43,7 @@ export async function createProject(
name: project_name,
subtitle: subtitle,
dedicateDBKey: dedicateDB,
type: project_type,
},
});
return res.data as unknown as CreateProjectResponse;
Expand Down

0 comments on commit d9ece31

Please sign in to comment.