@ankhorage/projects 0.7.1 → 0.7.3
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
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
|
|
|
@@ -5,6 +5,7 @@ import { resolveExpoRuntimePlan } from '@ankhorage/expo-runtime/planning';
|
|
|
5
5
|
import { createNavigatorPlan, generateNavigator } from '@ankhorage/navigator';
|
|
6
6
|
import { materializeTemplateRevision } from '@ankhorage/templates';
|
|
7
7
|
import { composeGeneratedRuntimeMaterialization } from './composeGeneratedRuntimeMaterialization.js';
|
|
8
|
+
import { formatTypeScriptLiteral } from './formatTypeScriptLiteral.js';
|
|
8
9
|
/*** Create the public, caller-targeted Expo materializer for stored immutable project revisions. */
|
|
9
10
|
export function createExpoProjectMaterializer(input) {
|
|
10
11
|
return {
|
|
@@ -66,7 +67,7 @@ function createGeneratedFiles(manifest, navigatorInput) {
|
|
|
66
67
|
})),
|
|
67
68
|
{
|
|
68
69
|
relativePath: 'src/ankh.manifest.ts',
|
|
69
|
-
source: `export default ${
|
|
70
|
+
source: `export default ${formatTypeScriptLiteral(manifest)} as const;\n`,
|
|
70
71
|
},
|
|
71
72
|
...navigator.files.map((file) => ({
|
|
72
73
|
relativePath: file.path,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*** Render serializable data as deterministic, policy-compliant TypeScript source. */
|
|
2
|
+
export function formatTypeScriptLiteral(value, depth = 0) {
|
|
3
|
+
if (value === null)
|
|
4
|
+
return 'null';
|
|
5
|
+
if (typeof value === 'string')
|
|
6
|
+
return formatTypeScriptString(value);
|
|
7
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
8
|
+
return String(value);
|
|
9
|
+
if (Array.isArray(value))
|
|
10
|
+
return formatTypeScriptArray(value, depth);
|
|
11
|
+
if (isRecord(value))
|
|
12
|
+
return formatTypeScriptRecord(value, depth);
|
|
13
|
+
throw new Error('Generated manifest values must be JSON-serializable.');
|
|
14
|
+
}
|
|
15
|
+
/*** Render a serializable array with canonical indentation and trailing commas. */
|
|
16
|
+
function formatTypeScriptArray(values, depth) {
|
|
17
|
+
if (values.length === 0)
|
|
18
|
+
return '[]';
|
|
19
|
+
const indentation = ' '.repeat(depth + 1);
|
|
20
|
+
const closingIndentation = ' '.repeat(depth);
|
|
21
|
+
return `[\n${values.map((value) => `${indentation}${formatTypeScriptLiteral(value, depth + 1)},`).join('\n')}\n${closingIndentation}]`;
|
|
22
|
+
}
|
|
23
|
+
/*** Render an object with sorted keys so equal manifests produce equal source. */
|
|
24
|
+
function formatTypeScriptRecord(value, depth) {
|
|
25
|
+
const entries = Object.entries(value).sort(([left], [right]) => left.localeCompare(right));
|
|
26
|
+
if (entries.length === 0)
|
|
27
|
+
return '{}';
|
|
28
|
+
const indentation = ' '.repeat(depth + 1);
|
|
29
|
+
const closingIndentation = ' '.repeat(depth);
|
|
30
|
+
return `{\n${entries.map(([key, entryValue]) => `${indentation}${formatTypeScriptPropertyKey(key)}: ${formatTypeScriptLiteral(entryValue, depth + 1)},`).join('\n')}\n${closingIndentation}}`;
|
|
31
|
+
}
|
|
32
|
+
/*** Use an identifier key where TypeScript permits it and quote required property names. */
|
|
33
|
+
function formatTypeScriptPropertyKey(key) {
|
|
34
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(key) ? key : formatTypeScriptString(key);
|
|
35
|
+
}
|
|
36
|
+
/*** Emit a single-quoted TypeScript string without a formatter runtime dependency. */
|
|
37
|
+
function formatTypeScriptString(value) {
|
|
38
|
+
const jsonContent = JSON.stringify(value).slice(1, -1);
|
|
39
|
+
return `'${jsonContent.replaceAll("'", "\\'").replaceAll('\u2028', '\\u2028').replaceAll('\u2029', '\\u2029')}'`;
|
|
40
|
+
}
|
|
41
|
+
/*** Narrow a JSON-compatible object for recursive rendering. */
|
|
42
|
+
function isRecord(value) {
|
|
43
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/projects",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Standalone project identity and repository actions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ankhorage",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"import": "./dist/capabilities/index.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"packageManager": "bun@1.4.
|
|
40
|
+
"packageManager": "bun@1.4.5",
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && bun x tsc -p tsconfig.build.json",
|
|
43
43
|
"check-types": "bun x tsc --noEmit -p tsconfig.json",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"version-packages": "ankhorage-changeset version"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@ankhorage/devtools": "^2.12.
|
|
57
|
+
"@ankhorage/devtools": "^2.12.8",
|
|
58
58
|
"@ankhorage/paradox": "^0.3.7",
|
|
59
59
|
"@types/bun": "^1.4.5",
|
|
60
60
|
"@types/node": "^26.6.11",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@ankhorage/api": "^0.5.2",
|
|
65
65
|
"@ankhorage/api-fastify": "^0.4.0",
|
|
66
|
-
"@ankhorage/contracts": "^
|
|
66
|
+
"@ankhorage/contracts": "^27.0.1",
|
|
67
67
|
"@ankhorage/data-sources": "^2.4.0",
|
|
68
68
|
"@ankhorage/expo-runtime": "^7.6.0",
|
|
69
69
|
"@ankhorage/navigator": "^3.7.0",
|