Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/app-info-organization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': minor
---

Show the organization name and ID in `app info`
28 changes: 28 additions & 0 deletions packages/app/src/cli/services/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,34 @@ describe('info', () => {
expect(rawResult.usesWorkspaces).toBe(false)
})
})

test('returns the organization name and ID using the default output format', async () => {
await inTemporaryDirectory(async (tmp) => {
// Given
const app = mockApp({directory: tmp})

// When
const result = (await info(app, remoteApp, ORG1, testProject(), infoOptions())) as AlertCustomSection[]
const configData = tabularDataSectionFromInfo(result, 'CURRENT APP CONFIGURATION\n')

// Then
expect(configData).toContainEqual(['Organization', 'test (123)'])
})
})

test('returns the organization name and ID using the json output format', async () => {
await inTemporaryDirectory(async (tmp) => {
// Given
const app = mockApp({directory: tmp})

// When
const result = await info(app, remoteApp, ORG1, testProject(), {...infoOptions(), format: 'json'})

// Then
const resultObject = JSON.parse((result as TokenizedString).value)
expect(resultObject.organization).toEqual({id: '123', businessName: 'test'})
})
})
})

function mockApp({
Expand Down
17 changes: 14 additions & 3 deletions packages/app/src/cli/services/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function info(
if (options.webEnv) {
return infoWeb(app, remoteApp, organization, options)
} else {
return infoApp(app, remoteApp, project, options)
return infoApp(app, remoteApp, organization, project, options)
}
}

Expand All @@ -53,6 +53,7 @@ async function infoWeb(
async function infoApp(
app: AppLinkedInterface,
remoteApp: OrganizationApp,
organization: Organization,
project: Project,
options: InfoOptions,
): Promise<OutputMessage | AlertCustomSection[]> {
Expand All @@ -63,6 +64,7 @@ async function infoApp(
packageManager: project.packageManager,
nodeDependencies: project.nodeDependencies,
usesWorkspaces: project.usesWorkspaces,
organization: {id: organization.id, businessName: organization.businessName},
allExtensions: extensionsInfo,
}
if ('realExtensions' in appWithSupportedExtensions) {
Expand All @@ -88,7 +90,7 @@ async function infoApp(
2,
)}`
} else {
const appInfo = new AppInfo(app, remoteApp, project, options)
const appInfo = new AppInfo(app, remoteApp, organization, project, options)
return appInfo.output()
}
}
Expand Down Expand Up @@ -120,12 +122,20 @@ const NOT_LOADED_TEXT = 'NOT LOADED'
class AppInfo {
private readonly app: AppLinkedInterface
private readonly remoteApp: OrganizationApp
private readonly organization: Organization
private readonly project: Project
private readonly options: InfoOptions

constructor(app: AppLinkedInterface, remoteApp: OrganizationApp, project: Project, options: InfoOptions) {
constructor(
app: AppLinkedInterface,
remoteApp: OrganizationApp,
organization: Organization,
project: Project,
options: InfoOptions,
) {
this.app = app
this.remoteApp = remoteApp
this.organization = organization
this.project = project
this.options = options
}
Expand Down Expand Up @@ -160,6 +170,7 @@ class AppInfo {
['Configuration file', {filePath: basename(this.app.configPath) || configurationFileNames.app}],
['App name', this.remoteApp.title ? {userInput: this.remoteApp.title} : NOT_CONFIGURED_TOKEN],
['Client ID', this.remoteApp.apiKey || NOT_CONFIGURED_TOKEN],
['Organization', `${this.organization.businessName} (${this.organization.id})`],
['Access scopes', getAppScopes(this.app.configuration)],
[
'Dev store',
Expand Down
Loading