Skip to content

Allow project creation by name#243

Open
purplecabbage wants to merge 14 commits intomasterfrom
CreateProject
Open

Allow project creation by name#243
purplecabbage wants to merge 14 commits intomasterfrom
CreateProject

Conversation

@purplecabbage
Copy link
Copy Markdown
Member

@purplecabbage purplecabbage commented Mar 26, 2026

Description

Allow create calls for new projects in dev-console. Assumes name is unique, or it will fail with the appropriate message.
This will enable agents to create new App Builder projects without user interaction.

aio console project create --name=alphaNumericName1 --title="alphaNumeric with spaces" --description="free text up to 1000 char"
--json output is now formatted for both human readability and machines

Related Issue

ACNA-4400

Motivation and Context

Agents need to be able to create projects with all parameters specified, the only other way to create a project was through `app init' with prompts for a project name,title,description ...

How Has This Been Tested?

  • tested against live dev-console api

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@purplecabbage purplecabbage marked this pull request as ready for review March 26, 2026 23:18
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new console project create command to enable non-interactive Adobe Developer Console project creation (by name) for a specified (or configured) organization, intended to support agent workflows.

Changes:

  • Introduces src/commands/console/project/create.js implementing project creation with local validation and a pre-check for duplicate project names.
  • Adds test/commands/console/project/create.test.js covering core create-path behavior and several validation/error cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
src/commands/console/project/create.js New CLI command to create a Console project by name/title/description with validations and org resolution.
test/commands/console/project/create.test.js New unit tests validating creation inputs, org selection behavior, and basic duplicate/validation errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +42
command = new TheCommand()
mockConsoleCLIInstance.createProject.mockReset()
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeEach only resets createProject, but several tests mutate getProjects’s resolved value. Not resetting getProjects here makes the suite more order-dependent as it grows. Consider resetting/re-initializing both mocks in beforeEach (similar to other command test suites).

Suggested change
command = new TheCommand()
mockConsoleCLIInstance.createProject.mockReset()
command = new TheCommand()
mockConsoleCLIInstance.getProjects.mockReset()
mockConsoleCLIInstance.getProjects.mockResolvedValue([])
mockConsoleCLIInstance.createProject.mockReset()
mockConsoleCLIInstance.createProject.mockResolvedValue(mockProject)

Copilot uses AI. Check for mistakes.
Comment on lines +53 to +63
await this.initSdk()
// check name is not already in use
const projects = await this.consoleCLI.getProjects(orgId)
if (projects.find(project => project.name === projectDetails.name)) {
this.error(`Project ${projectDetails.name} already exists. Please choose a different name.`)
}

// if we get here, all validation passed, so call server to create project
const project = await this.consoleCLI.createProject(orgId, projectDetails)
this.log(`Project ${project.name} created successfully.`)
return project
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command doesn’t wrap SDK calls in a try/catch/finally and never calls cleanOutput(). Other console commands ensure LibConsoleCLI.cleanStdOut() is called in a finally block so terminal output isn’t left in a dirty state when requests fail. Consider aligning with the existing pattern (logger debug in catch + cleanOutput() in finally).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

*/
printJson (data) {
this.log(JSON.stringify(data))
this.log(JSON.stringify(data, 0, 2))
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.stringify(data, 0, 2) relies on a non-standard-looking replacer argument (0). While it currently behaves like undefined, it’s confusing to readers and easy to misinterpret. Use null (or omit the replacer argument) to make the intent of pretty-printing explicit.

Suggested change
this.log(JSON.stringify(data, 0, 2))
this.log(JSON.stringify(data, null, 2))

Copilot uses AI. Check for mistakes.
}

CreateCommand.aliases = [
'console:project:create',
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateCommand.aliases includes the command’s own canonical name (console:project:create). In oclif this is redundant and differs from the pattern in other commands (aliases are only for alternative spellings like console:project:ls). Consider removing the self-alias and keeping only true alternatives (e.g., console:project:init).

Suggested change
'console:project:create',

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

// Project title allows only alphanumeric values and spaces
if (!/^[a-zA-Z0-9\s]+$/.test(projectDetails.title)) {
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title validation regex uses \s, which matches tabs/newlines and other whitespace—not just spaces as the error message states. This can allow control characters in --title (e.g., newlines) and produce unexpected output/log formatting. Use a pattern that only permits literal spaces (and consider trimming) to align behavior with the validation message.

Suggested change
if (!/^[a-zA-Z0-9\s]+$/.test(projectDetails.title)) {
if (!/^[a-zA-Z0-9 ]+$/.test(projectDetails.title)) {

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 46
printJson (data) {
this.log(JSON.stringify(data))
this.log(JSON.stringify(data, 0, 2))
}
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printJson() now pretty-prints JSON for all commands, which changes the --json output format across the plugin but isn’t mentioned in the PR description. If the intent is only to support structured output for project:create, consider scoping formatting changes to that command (or call this out explicitly). Also, pass null as the JSON.stringify replacer instead of 0 for clarity (0 is ignored by JSON.stringify).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

purplecabbage and others added 2 commits March 27, 2026 23:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants