Skip to content

Commit 7ba31ed

Browse files
Merge pull request #6 from NullVoxPopuli/custom-usable-in-resources-v7
Hook in to the registerUsable API in ember-resources v7
2 parents e413cc8 + 38e55e6 commit 7ba31ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2015
-77
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
with:
101101
node-version: 18.18.1
102102
- uses: ./.github/actions/download-built-package
103-
- run: pnpm --filter test-app test:ember
103+
- run: pnpm --filter '*' test:ember
104104

105105
floating_tests:
106106
name: Floating Deps Test
@@ -115,7 +115,7 @@ jobs:
115115
args: '--no-lockfile'
116116
- uses: ./.github/actions/download-built-package
117117
- run: pnpm i -f
118-
- run: pnpm --filter test-app test:ember
118+
- run: pnpm --filter '*' test:ember
119119

120120

121121
try_scenarios:
@@ -150,3 +150,36 @@ jobs:
150150
run: >-
151151
node_modules/.bin/ember try:one ${{ matrix.try-scenario }}
152152
--skip-cleanup
153+
154+
try_scenarios_er-7:
155+
name: ${{ matrix.try-scenario }} (resources@7)
156+
timeout-minutes: 5
157+
runs-on: ubuntu-latest
158+
needs: [default_tests]
159+
160+
strategy:
161+
fail-fast: false
162+
matrix:
163+
try-scenario:
164+
- ember-3.28
165+
- ember-4.0.0
166+
- ember-4.4
167+
- ember-4.8
168+
- ember-4.12
169+
- ember-release
170+
- ember-beta
171+
- ember-canary
172+
- embroider-safe
173+
- embroider-optimized
174+
175+
steps:
176+
- uses: actions/checkout@v4
177+
- uses: wyvox/action-setup-pnpm@v3
178+
with:
179+
node-version: 18.18.1
180+
- uses: ./.github/actions/download-built-package
181+
- name: Run Tests
182+
working-directory: ./test-app-ember-resources-7
183+
run: >-
184+
node_modules/.bin/ember try:one ${{ matrix.try-scenario }}
185+
--skip-cleanup

ember-modify-based-class-resource/src/core/class-based/resource.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { setOwner } from '@ember/application';
44
import { assert } from '@ember/debug';
55
// @ts-ignore
66
import { invokeHelper } from '@ember/helper';
7+
import { dependencySatisfies, importSync, macroCondition } from '@embroider/macros';
78

89
import { DEFAULT_THUNK, normalizeThunk } from '../utils';
910

@@ -15,6 +16,19 @@ import type { HelperLike } from '@glint/template';
1516
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
1617
import type { Invoke } from '@glint/template/-private/integration';
1718

19+
const TYPE = 'class-based';
20+
21+
if (macroCondition(dependencySatisfies('ember-resources', '>= 7.0.0'))) {
22+
// These types don't matter to consumers
23+
const { registerUsable } = importSync('ember-resources') as any;
24+
25+
(registerUsable as any)(TYPE, (context: any, config: any) => {
26+
let { definition, thunk } = config;
27+
28+
return invokeHelper(context, definition, () => normalizeThunk(thunk));
29+
});
30+
}
31+
1832
/**
1933
* @private utility type
2034
*
@@ -276,7 +290,7 @@ export class Resource<Args = unknown> {
276290
return {
277291
thunk: contextOrThunk,
278292
definition: this,
279-
type: 'class-based',
293+
type: TYPE,
280294
__INTERNAL__: true,
281295
} as unknown as SomeResource;
282296
}

0 commit comments

Comments
 (0)