From ffe2813b7617a8e437c15ce1a425d042ac92ceee Mon Sep 17 00:00:00 2001 From: bighammerw <92004774+bighammerw@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:06:02 +1300 Subject: [PATCH] =?UTF-8?q?change=20createproject=20URL=20,=20project=20cr?= =?UTF-8?q?eate=20issue,=20regx=20for=20project=20nam=E2=80=A6=20(#1323)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * change createproject URL , project create issue, regx for project name and project key * project name can be cap case * code improve by Jay comment Co-authored-by: Louise wang --- packages/cli/src/commands/project/create-project.ts | 3 ++- packages/cli/src/commands/project/index.ts | 2 +- packages/cli/src/controller/project-controller.ts | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/project/create-project.ts b/packages/cli/src/commands/project/create-project.ts index 1b8331f7b5..b679e69943 100644 --- a/packages/cli/src/commands/project/create-project.ts +++ b/packages/cli/src/commands/project/create-project.ts @@ -45,7 +45,8 @@ export default class Create_project extends Command { ROOT_API_URL_PROD ).catch((e) => this.error(e)); + const [account, name] = result.key.split('/'); this.log(`Successfully created project: ${result.key} - \nProject Url: ${BASE_PROJECT_URL}/project/${result.key}`); + \nProject Url: ${BASE_PROJECT_URL}/orgs/${account}/projects/${name}/deployments`); } } diff --git a/packages/cli/src/commands/project/index.ts b/packages/cli/src/commands/project/index.ts index efc26f3510..3ee7df3f06 100644 --- a/packages/cli/src/commands/project/index.ts +++ b/packages/cli/src/commands/project/index.ts @@ -45,7 +45,7 @@ export default class Project extends Command { const handler = Project.optionMapping[userOptions]; // removes arguments -> deployment and everything before it from the process.argv const stripped_argv: string[] = process.argv - .filter((v, idx) => idx > process.argv.indexOf('deployment') && !v.includes('--options')) + .filter((v, idx) => idx > process.argv.indexOf('project') && !v.includes('--options')) .reduce((acc, val) => acc.concat(val.split('=')), []); await handler.run(stripped_argv); diff --git a/packages/cli/src/controller/project-controller.ts b/packages/cli/src/controller/project-controller.ts index 2aa79c28b7..5eac29553f 100644 --- a/packages/cli/src/controller/project-controller.ts +++ b/packages/cli/src/controller/project-controller.ts @@ -7,6 +7,12 @@ import {errorHandle} from '../utils'; interface createProjectType { key: string; } +export const suffixFormat = (value: string) => { + return value + .replace(/(^\s*)|(\s*$)/g, '') + .replace(/\s+/g, '-') + .toLowerCase(); +}; export async function createProject( organization: string, subtitle: string, @@ -31,7 +37,7 @@ export async function createProject( apiVersion: `v${apiVersion}`, description: description, gitRepository: gitRepository, - key: `${organization}/${project_name}`, + key: `${organization}/${suffixFormat(project_name)}`, logoUrl: logoUrl, name: project_name, subtitle: subtitle,