Skip to content

Commit adb3385

Browse files
committed
refactor(apps): rename apps-import identifiers to reflect apps-backend
DATADOG_APPS_IMPORT and isDatadogAppsInstalled predated the @datadog/apps-backend runtime split and no longer matched the package they check for.
1 parent dbcfc95 commit adb3385

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

packages/plugins/apps/src/backend/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function isActionCatalogInstalled(fromDir: string): boolean {
2121
}
2222

2323
/** Check if the @datadog/apps-backend "JS Function with Actions" runtime factory is installed. */
24-
export function isDatadogAppsInstalled(fromDir: string): boolean {
24+
export function isDatadogAppsBackendInstalled(fromDir: string): boolean {
2525
return isPackageExportInstalled('@datadog/apps-backend/runtime/jsFunctionWithActions', fromDir);
2626
}
2727

@@ -30,7 +30,7 @@ export const ACTION_CATALOG_IMPORT =
3030
"import { setExecuteActionImplementation } from '@datadog/action-catalog/action-execution';";
3131

3232
/** The import line that exposes @datadog/apps-backend backend context initialization. */
33-
export const DATADOG_APPS_IMPORT = `\
33+
export const DATADOG_APPS_BACKEND_IMPORT = `\
3434
import { buildRuntimeFromJsFunctionWithActions } from '@datadog/apps-backend/runtime/jsFunctionWithActions';
3535
import { setBackend } from '@datadog/apps-backend/runtime';`;
3636

packages/plugins/apps/src/backend/virtual-entry.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Backend Functions - generateVirtualEntryContent', () => {
1818
describe('without action-catalog', () => {
1919
beforeEach(() => {
2020
jest.spyOn(shared, 'isActionCatalogInstalled').mockReturnValue(false);
21-
jest.spyOn(shared, 'isDatadogAppsInstalled').mockReturnValue(false);
21+
jest.spyOn(shared, 'isDatadogAppsBackendInstalled').mockReturnValue(false);
2222
});
2323

2424
test('Should import the function by name from the entry path', () => {
@@ -105,7 +105,7 @@ describe('Backend Functions - generateVirtualEntryContent', () => {
105105
describe('with action-catalog', () => {
106106
beforeEach(() => {
107107
jest.spyOn(shared, 'isActionCatalogInstalled').mockReturnValue(true);
108-
jest.spyOn(shared, 'isDatadogAppsInstalled').mockReturnValue(false);
108+
jest.spyOn(shared, 'isDatadogAppsBackendInstalled').mockReturnValue(false);
109109
});
110110

111111
test('Should include action-catalog import', () => {
@@ -132,7 +132,7 @@ describe('Backend Functions - generateVirtualEntryContent', () => {
132132
describe('with @datadog/apps-backend', () => {
133133
beforeEach(() => {
134134
jest.spyOn(shared, 'isActionCatalogInstalled').mockReturnValue(false);
135-
jest.spyOn(shared, 'isDatadogAppsInstalled').mockReturnValue(true);
135+
jest.spyOn(shared, 'isDatadogAppsBackendInstalled').mockReturnValue(true);
136136
});
137137

138138
test('Should import and set the backend context before calling the handler', () => {
@@ -157,7 +157,7 @@ describe('Backend Functions - generateVirtualEntryContent', () => {
157157

158158
test('Should escape entry paths with special characters', () => {
159159
jest.spyOn(shared, 'isActionCatalogInstalled').mockReturnValue(false);
160-
jest.spyOn(shared, 'isDatadogAppsInstalled').mockReturnValue(false);
160+
jest.spyOn(shared, 'isDatadogAppsBackendInstalled').mockReturnValue(false);
161161
const result = generateVirtualEntryContent(
162162
'handler',
163163
'/path/with "quotes"/handler.ts',
@@ -171,7 +171,7 @@ describe('Backend Functions - generateDevVirtualEntryContent', () => {
171171
beforeEach(() => {
172172
jest.restoreAllMocks();
173173
jest.spyOn(shared, 'isActionCatalogInstalled').mockReturnValue(false);
174-
jest.spyOn(shared, 'isDatadogAppsInstalled').mockReturnValue(false);
174+
jest.spyOn(shared, 'isDatadogAppsBackendInstalled').mockReturnValue(false);
175175
});
176176

177177
test('Should produce identical output to generateVirtualEntryContent', () => {
@@ -202,7 +202,7 @@ describe('Backend Functions - args round-trip via $.backendFunctionArgs', () =>
202202
beforeEach(() => {
203203
jest.restoreAllMocks();
204204
jest.spyOn(shared, 'isActionCatalogInstalled').mockReturnValue(false);
205-
jest.spyOn(shared, 'isDatadogAppsInstalled').mockReturnValue(false);
205+
jest.spyOn(shared, 'isDatadogAppsBackendInstalled').mockReturnValue(false);
206206
});
207207

208208
// Extract the body of the generated `main($)` function so we can eval it

packages/plugins/apps/src/backend/virtual-entry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
import {
66
ACTION_CATALOG_IMPORT,
7-
DATADOG_APPS_IMPORT,
7+
DATADOG_APPS_BACKEND_IMPORT,
88
SET_BACKEND_CONTEXT_SNIPPET,
99
SET_EXECUTE_ACTION_SNIPPET,
1010
isActionCatalogInstalled,
11-
isDatadogAppsInstalled,
11+
isDatadogAppsBackendInstalled,
1212
} from './shared';
1313

1414
/**
@@ -21,12 +21,12 @@ export function generateVirtualEntryContent(
2121
projectRoot: string,
2222
): string {
2323
const lines: string[] = [];
24-
const hasDatadogAppsBackendRuntime = isDatadogAppsInstalled(projectRoot);
24+
const hasDatadogAppsBackendRuntime = isDatadogAppsBackendInstalled(projectRoot);
2525

2626
lines.push(`import { ${functionName} } from ${JSON.stringify(entryPath)};`);
2727

2828
if (hasDatadogAppsBackendRuntime) {
29-
lines.push(DATADOG_APPS_IMPORT);
29+
lines.push(DATADOG_APPS_BACKEND_IMPORT);
3030
}
3131

3232
if (isActionCatalogInstalled(projectRoot)) {

0 commit comments

Comments
 (0)