@ankhorage/projects 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/features/projects/composition/composeGeneratedRuntimeMaterialization.d.ts +11 -0
- package/dist/features/projects/composition/composeGeneratedRuntimeMaterialization.js +27 -0
- package/dist/features/projects/composition/createExpoProjectMaterializer.js +25 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/projects
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Standalone project identity and repository actions.
|
|
9
9
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NavigatorGenerationBindings } from '@ankhorage/contracts/navigator';
|
|
2
|
+
/*** Compose generated Runtime dependencies and bindings with caller-owned Navigator extensions. */
|
|
3
|
+
export declare function composeGeneratedRuntimeMaterialization(input: Readonly<{
|
|
4
|
+
readonly callerBindings: NavigatorGenerationBindings;
|
|
5
|
+
readonly packageSource: string;
|
|
6
|
+
readonly runtimeBindings: NavigatorGenerationBindings;
|
|
7
|
+
readonly runtimeDependencies: Readonly<Record<string, string>>;
|
|
8
|
+
}>): Readonly<{
|
|
9
|
+
navigatorBindings: NavigatorGenerationBindings;
|
|
10
|
+
packageSource: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*** Compose generated Runtime dependencies and bindings with caller-owned Navigator extensions. */
|
|
2
|
+
export function composeGeneratedRuntimeMaterialization(input) {
|
|
3
|
+
assertNoConflictingRuntimeBindings(input.callerBindings, input.runtimeBindings);
|
|
4
|
+
const packageJson = JSON.parse(input.packageSource);
|
|
5
|
+
return {
|
|
6
|
+
navigatorBindings: {
|
|
7
|
+
guards: { ...input.callerBindings.guards, ...input.runtimeBindings.guards },
|
|
8
|
+
screens: { ...input.callerBindings.screens, ...input.runtimeBindings.screens },
|
|
9
|
+
},
|
|
10
|
+
packageSource: `${JSON.stringify({
|
|
11
|
+
...packageJson,
|
|
12
|
+
dependencies: { ...packageJson.dependencies, ...input.runtimeDependencies },
|
|
13
|
+
}, null, 2)}\n`,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/*** Reject a caller attempt to replace an immutable Runtime-owned manifest screen binding. */
|
|
17
|
+
function assertNoConflictingRuntimeBindings(callerBindings, runtimeBindings) {
|
|
18
|
+
for (const [screenId, runtimeBinding] of Object.entries(runtimeBindings.screens)) {
|
|
19
|
+
const callerEntry = Object.entries(callerBindings.screens).find(([id]) => id === screenId);
|
|
20
|
+
const callerBinding = callerEntry?.[1];
|
|
21
|
+
if (callerBinding !== undefined &&
|
|
22
|
+
(callerBinding.module !== runtimeBinding.module ||
|
|
23
|
+
callerBinding.exportName !== runtimeBinding.exportName)) {
|
|
24
|
+
throw new Error(`Navigator binding conflicts with generated Runtime screen '${screenId}'.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { lstat, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile, } from 'node:fs/promises';
|
|
2
2
|
import { basename, dirname, relative, resolve } from 'node:path';
|
|
3
|
-
import { resolveExpoRuntimeGeneratedAppScaffold } from '@ankhorage/expo-runtime/generated-app';
|
|
3
|
+
import { resolveExpoRuntimeGeneratedAppScaffold, resolveExpoRuntimeGeneratedAppSources, } from '@ankhorage/expo-runtime/generated-app';
|
|
4
4
|
import { resolveExpoRuntimePlan } from '@ankhorage/expo-runtime/planning';
|
|
5
5
|
import { createNavigatorPlan, generateNavigator } from '@ankhorage/navigator';
|
|
6
6
|
import { materializeTemplateRevision } from '@ankhorage/templates';
|
|
7
|
+
import { composeGeneratedRuntimeMaterialization } from './composeGeneratedRuntimeMaterialization.js';
|
|
7
8
|
/*** Create the public, caller-targeted Expo materializer for stored immutable project revisions. */
|
|
8
9
|
export function createExpoProjectMaterializer(input) {
|
|
9
10
|
return {
|
|
@@ -36,18 +37,37 @@ async function materializeExpoProjectAsync(input, project, revision) {
|
|
|
36
37
|
function createGeneratedFiles(manifest, navigatorInput) {
|
|
37
38
|
const runtimePlan = ownerApis.resolveExpoRuntimePlan(manifest);
|
|
38
39
|
assertNoErrors(runtimePlan.diagnostics, 'Expo Runtime');
|
|
40
|
+
const runtime = ownerApis.resolveExpoRuntimeGeneratedAppSources(manifest, runtimePlan, {
|
|
41
|
+
manifestModuleSpecifier: '../ankh.manifest',
|
|
42
|
+
screenModuleSpecifier: '../generated/runtimeManifestScreens',
|
|
43
|
+
});
|
|
44
|
+
assertNoErrors(runtime.diagnostics, 'Expo Runtime');
|
|
45
|
+
const scaffold = ownerApis.resolveExpoRuntimeGeneratedAppScaffold(manifest, runtimePlan);
|
|
46
|
+
const packageSource = composeGeneratedRuntimeMaterialization({
|
|
47
|
+
callerBindings: navigatorInput.bindings,
|
|
48
|
+
packageSource: scaffold.files.find(({ relativePath }) => relativePath === 'package.json')?.source ?? '',
|
|
49
|
+
runtimeBindings: runtime.navigatorBindings,
|
|
50
|
+
runtimeDependencies: runtime.dependencies,
|
|
51
|
+
});
|
|
39
52
|
const navigatorPlan = ownerApis.createNavigatorPlan(manifest.navigator, {
|
|
40
53
|
platform: navigatorInput.platform,
|
|
41
54
|
expoRouterVersion: navigatorInput.expoRouterVersion,
|
|
42
55
|
});
|
|
43
|
-
const navigator = ownerApis.generateNavigator(navigatorPlan,
|
|
56
|
+
const navigator = ownerApis.generateNavigator(navigatorPlan, packageSource.navigatorBindings);
|
|
44
57
|
assertNoErrors(navigator.diagnostics, 'Navigator');
|
|
45
|
-
const runtime = ownerApis.resolveExpoRuntimeGeneratedAppScaffold(manifest, runtimePlan);
|
|
46
58
|
const files = [
|
|
59
|
+
...scaffold.files.map((file) => ({
|
|
60
|
+
relativePath: file.relativePath,
|
|
61
|
+
source: file.relativePath === 'package.json' ? packageSource.packageSource : file.source,
|
|
62
|
+
})),
|
|
47
63
|
...runtime.files.map((file) => ({
|
|
48
64
|
relativePath: file.relativePath,
|
|
49
65
|
source: file.source,
|
|
50
66
|
})),
|
|
67
|
+
{
|
|
68
|
+
relativePath: 'src/ankh.manifest.ts',
|
|
69
|
+
source: `export default ${JSON.stringify(manifest, null, 2)} as const;\n`,
|
|
70
|
+
},
|
|
51
71
|
...navigator.files.map((file) => ({
|
|
52
72
|
relativePath: file.path,
|
|
53
73
|
source: file.contents,
|
|
@@ -73,6 +93,7 @@ const ownerApis = {
|
|
|
73
93
|
createNavigatorPlan: createNavigatorPlan,
|
|
74
94
|
generateNavigator: generateNavigator,
|
|
75
95
|
resolveExpoRuntimePlan: resolveExpoRuntimePlan,
|
|
96
|
+
resolveExpoRuntimeGeneratedAppSources: resolveExpoRuntimeGeneratedAppSources,
|
|
76
97
|
resolveExpoRuntimeGeneratedAppScaffold: resolveExpoRuntimeGeneratedAppScaffold,
|
|
77
98
|
};
|
|
78
99
|
/*** Reject unavailable owner emitters rather than reproducing their source in Projects. */
|
|
@@ -81,6 +102,7 @@ function assertReleasedOwnerApis() {
|
|
|
81
102
|
typeof ownerApis.createNavigatorPlan !== 'function' ||
|
|
82
103
|
typeof ownerApis.generateNavigator !== 'function' ||
|
|
83
104
|
typeof ownerApis.resolveExpoRuntimePlan !== 'function' ||
|
|
105
|
+
typeof ownerApis.resolveExpoRuntimeGeneratedAppSources !== 'function' ||
|
|
84
106
|
typeof ownerApis.resolveExpoRuntimeGeneratedAppScaffold !== 'function') {
|
|
85
107
|
throw new Error('Required released owner materialization API is unavailable.');
|
|
86
108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/projects",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Standalone project identity and repository actions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ankhorage",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@ankhorage/api-fastify": "^0.4.0",
|
|
66
66
|
"@ankhorage/contracts": "^26.11.1",
|
|
67
67
|
"@ankhorage/data-sources": "^2.4.0",
|
|
68
|
-
"@ankhorage/expo-runtime": "^7.
|
|
68
|
+
"@ankhorage/expo-runtime": "^7.5.0",
|
|
69
69
|
"@ankhorage/navigator": "^3.5.22",
|
|
70
70
|
"@ankhorage/permissions": "^0.2.64",
|
|
71
71
|
"@ankhorage/runtime": "^5.6.4",
|