Format authored monorepo code with pinned language formatters
This commit is contained in:
Vendored
+48
-105
@@ -1,18 +1,12 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import {
|
||||
capabilityId,
|
||||
type WorkspaceRevision,
|
||||
} from "../../src/capability-model/index.js";
|
||||
import { capabilityId, type WorkspaceRevision } from "../../src/capability-model/index.js";
|
||||
import {
|
||||
compileCapabilityResourceSource,
|
||||
compileCapabilitySource,
|
||||
type CapabilityImportEnvironment,
|
||||
} from "../../src/capability-language/index.js";
|
||||
import type {
|
||||
InterfaceRevision,
|
||||
PackageRevision,
|
||||
} from "../../src/capability-model/index.js";
|
||||
import type { InterfaceRevision, PackageRevision } from "../../src/capability-model/index.js";
|
||||
|
||||
export const fixtureId = {
|
||||
workspace: capabilityId.workspace("workspace:todo"),
|
||||
@@ -29,9 +23,7 @@ export const fixtureId = {
|
||||
projectTitle: capabilityId.slot("slot:project:title"),
|
||||
personName: capabilityId.slot("slot:person:name"),
|
||||
projectOwner: capabilityId.edgeType("edge:project:owner"),
|
||||
projectOwnerProjection: capabilityId.edgeProjection(
|
||||
"projection:project-owner:owner",
|
||||
),
|
||||
projectOwnerProjection: capabilityId.edgeProjection("projection:project-owner:owner"),
|
||||
projectNamedConformance: {
|
||||
atomId: capabilityId.atom("atom:project"),
|
||||
interfaceRevisionId: capabilityId.interfaceRevision("interface:named@1"),
|
||||
@@ -49,31 +41,18 @@ export const fixtureId = {
|
||||
interfaceRevisionId: capabilityId.interfaceRevision("interface:summary@1"),
|
||||
},
|
||||
todoRuntimeV1: capabilityId.packageRevision("package:todo-runtime@1"),
|
||||
summaryGetExport: capabilityId.packageExport(
|
||||
"export:todo-runtime:summary-get",
|
||||
),
|
||||
createPersonExport: capabilityId.packageExport(
|
||||
"export:todo-runtime:create-person",
|
||||
),
|
||||
summaryGetExport: capabilityId.packageExport("export:todo-runtime:summary-get"),
|
||||
createPersonExport: capabilityId.packageExport("export:todo-runtime:create-person"),
|
||||
titlePort: capabilityId.dependencyPort("port:summary:title"),
|
||||
namedPort: capabilityId.dependencyPort("port:summary:named"),
|
||||
personPort: capabilityId.dependencyPort("port:summary:person"),
|
||||
} as const;
|
||||
|
||||
export const capabilityFixturePath = resolve(
|
||||
process.cwd(),
|
||||
"test/fixtures/todo.capabilities.qx",
|
||||
);
|
||||
export const capabilityFixturePath = resolve(process.cwd(), "test/fixtures/todo.capabilities.qx");
|
||||
|
||||
export const capabilityFixtureSource = readFileSync(
|
||||
capabilityFixturePath,
|
||||
"utf8",
|
||||
);
|
||||
export const capabilityFixtureSource = readFileSync(capabilityFixturePath, "utf8");
|
||||
|
||||
const resourceSource = (name: string) => readFileSync(
|
||||
resolve(process.cwd(), "test/fixtures", name),
|
||||
"utf8",
|
||||
);
|
||||
const resourceSource = (name: string) => readFileSync(resolve(process.cwd(), "test/fixtures", name), "utf8");
|
||||
|
||||
export const capabilityResourceSources = {
|
||||
named: resourceSource("named.interface.qx"),
|
||||
@@ -85,110 +64,74 @@ export const capabilityResourceSources = {
|
||||
const source = (repository: string, commit: string) => ({ repository, commit });
|
||||
|
||||
const interfaceRevision = (
|
||||
resource: { kind: "interface"; revision: InterfaceRevision } |
|
||||
{ kind: "package"; revision: PackageRevision },
|
||||
resource: { kind: "interface"; revision: InterfaceRevision } | { kind: "package"; revision: PackageRevision },
|
||||
) => {
|
||||
if (resource.kind !== "interface") throw new Error("Expected interface fixture");
|
||||
return resource.revision;
|
||||
};
|
||||
|
||||
const packageRevision = (
|
||||
resource: { kind: "interface"; revision: InterfaceRevision } |
|
||||
{ kind: "package"; revision: PackageRevision },
|
||||
resource: { kind: "interface"; revision: InterfaceRevision } | { kind: "package"; revision: PackageRevision },
|
||||
) => {
|
||||
if (resource.kind !== "package") throw new Error("Expected package fixture");
|
||||
return resource.revision;
|
||||
};
|
||||
|
||||
export const compileCapabilityFixture = (overrides: Partial<{
|
||||
workspace: string;
|
||||
named: string;
|
||||
owned: string;
|
||||
summary: string;
|
||||
todo: string;
|
||||
}> = {}) => {
|
||||
const named = compileCapabilityResourceSource(
|
||||
overrides.named ?? capabilityResourceSources.named,
|
||||
{
|
||||
source: source(
|
||||
"https://repos.quixos.org/quixos-todo/interface-named.git",
|
||||
"2".repeat(40),
|
||||
),
|
||||
fileName: "named.interface.qx",
|
||||
},
|
||||
);
|
||||
export const compileCapabilityFixture = (
|
||||
overrides: Partial<{
|
||||
workspace: string;
|
||||
named: string;
|
||||
owned: string;
|
||||
summary: string;
|
||||
todo: string;
|
||||
}> = {},
|
||||
) => {
|
||||
const named = compileCapabilityResourceSource(overrides.named ?? capabilityResourceSources.named, {
|
||||
source: source("https://repos.quixos.org/quixos-todo/interface-named.git", "2".repeat(40)),
|
||||
fileName: "named.interface.qx",
|
||||
});
|
||||
if (!named.ok) return named;
|
||||
const namedRevision = interfaceRevision(named.resource);
|
||||
const namedEnvironment: CapabilityImportEnvironment = {
|
||||
interfaces: new Map([["Named", namedRevision]]),
|
||||
interfaceClosure: [namedRevision],
|
||||
};
|
||||
const owned = compileCapabilityResourceSource(
|
||||
overrides.owned ?? capabilityResourceSources.owned,
|
||||
{
|
||||
source: source(
|
||||
"https://repos.quixos.org/quixos-todo/interface-owned.git",
|
||||
"3".repeat(40),
|
||||
),
|
||||
fileName: "owned.interface.qx",
|
||||
environment: namedEnvironment,
|
||||
},
|
||||
);
|
||||
const owned = compileCapabilityResourceSource(overrides.owned ?? capabilityResourceSources.owned, {
|
||||
source: source("https://repos.quixos.org/quixos-todo/interface-owned.git", "3".repeat(40)),
|
||||
fileName: "owned.interface.qx",
|
||||
environment: namedEnvironment,
|
||||
});
|
||||
if (!owned.ok) return owned;
|
||||
const ownedRevision = interfaceRevision(owned.resource);
|
||||
const summary = compileCapabilityResourceSource(
|
||||
overrides.summary ?? capabilityResourceSources.summary,
|
||||
{
|
||||
source: source(
|
||||
"https://repos.quixos.org/quixos-todo/interface-summary.git",
|
||||
"4".repeat(40),
|
||||
),
|
||||
fileName: "summary.interface.qx",
|
||||
},
|
||||
);
|
||||
const summary = compileCapabilityResourceSource(overrides.summary ?? capabilityResourceSources.summary, {
|
||||
source: source("https://repos.quixos.org/quixos-todo/interface-summary.git", "4".repeat(40)),
|
||||
fileName: "summary.interface.qx",
|
||||
});
|
||||
if (!summary.ok) return summary;
|
||||
const summaryRevision = interfaceRevision(summary.resource);
|
||||
const todo = compileCapabilityResourceSource(
|
||||
overrides.todo ?? capabilityResourceSources.todo,
|
||||
{
|
||||
source: source(
|
||||
"https://repos.quixos.org/quixos-todo/package-todo-runtime.git",
|
||||
"5".repeat(40),
|
||||
),
|
||||
fileName: "todo.package.qx",
|
||||
environment: namedEnvironment,
|
||||
},
|
||||
);
|
||||
const todo = compileCapabilityResourceSource(overrides.todo ?? capabilityResourceSources.todo, {
|
||||
source: source("https://repos.quixos.org/quixos-todo/package-todo-runtime.git", "5".repeat(40)),
|
||||
fileName: "todo.package.qx",
|
||||
environment: namedEnvironment,
|
||||
});
|
||||
if (!todo.ok) return todo;
|
||||
const todoRevision = packageRevision(todo.resource);
|
||||
return compileCapabilitySource(
|
||||
overrides.workspace ?? capabilityFixtureSource,
|
||||
capabilityFixturePath,
|
||||
{
|
||||
interfaces: new Map([
|
||||
["Named", namedRevision],
|
||||
["Owned", ownedRevision],
|
||||
["Summary", summaryRevision],
|
||||
]),
|
||||
packages: new Map([["TodoRuntime", todoRevision]]),
|
||||
interfaceClosure: [
|
||||
namedRevision,
|
||||
ownedRevision,
|
||||
summaryRevision,
|
||||
],
|
||||
packageClosure: [todoRevision],
|
||||
},
|
||||
);
|
||||
return compileCapabilitySource(overrides.workspace ?? capabilityFixtureSource, capabilityFixturePath, {
|
||||
interfaces: new Map([
|
||||
["Named", namedRevision],
|
||||
["Owned", ownedRevision],
|
||||
["Summary", summaryRevision],
|
||||
]),
|
||||
packages: new Map([["TodoRuntime", todoRevision]]),
|
||||
interfaceClosure: [namedRevision, ownedRevision, summaryRevision],
|
||||
packageClosure: [todoRevision],
|
||||
});
|
||||
};
|
||||
|
||||
export const makeValidCapabilityWorkspace = (): WorkspaceRevision => {
|
||||
const result = compileCapabilityFixture();
|
||||
if (!result.ok) {
|
||||
throw new Error(
|
||||
result.diagnostics
|
||||
.map((entry) => `${entry.phase}/${entry.code}: ${entry.message}`)
|
||||
.join("\n"),
|
||||
);
|
||||
throw new Error(result.diagnostics.map((entry) => `${entry.phase}/${entry.code}: ${entry.message}`).join("\n"));
|
||||
}
|
||||
return structuredClone(result.workspace);
|
||||
};
|
||||
|
||||
Vendored
+2
-2
@@ -8,7 +8,7 @@ workspace Todo id "workspace:todo" revision "workspace:todo@1" commit "111111111
|
||||
import package TodoRuntime;
|
||||
|
||||
shared state ProjectTitle id "slot:project:title" on Project : string
|
||||
policy optimistic-register default "Untitled project";
|
||||
policy optimistic-register default "Untitled project";
|
||||
|
||||
conform Project as Named {
|
||||
bind name.get to state ProjectTitle.read;
|
||||
@@ -19,7 +19,7 @@ workspace Todo id "workspace:todo" revision "workspace:todo@1" commit "111111111
|
||||
|
||||
conform Person as Named {
|
||||
private state PersonName id "slot:person:name" on Person : string
|
||||
policy optimistic-register default "Anonymous";
|
||||
policy optimistic-register default "Anonymous";
|
||||
bind name.get to state PersonName.read;
|
||||
bind name.set to state PersonName.write;
|
||||
bind name.watch-start to state PersonName.watch-start;
|
||||
|
||||
Vendored
+5
-5
@@ -3,10 +3,10 @@ external atom Person id "atom:person";
|
||||
|
||||
package TodoRuntime id "package:todo-runtime" revision "package:todo-runtime@1" {
|
||||
operation summaryGet id "export:todo-runtime:summary-get" : unit -> string
|
||||
mode call receiver interfaces [Named] requires {
|
||||
state title id "port:summary:title" : string [read];
|
||||
interface named id "port:summary:named" : Named;
|
||||
constructor person id "port:summary:person" : Person;
|
||||
};
|
||||
mode call receiver interfaces [Named] requires {
|
||||
state title id "port:summary:title" : string [read];
|
||||
interface named id "port:summary:named" : Named;
|
||||
constructor person id "port:summary:person" : Person;
|
||||
};
|
||||
constructor createPerson id "export:todo-runtime:create-person" constructs Person : unit;
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ workspace WebStudioFixture id "workspace:web-studio-fixture" revision "workspace
|
||||
import package ComponentRuntime;
|
||||
|
||||
shared state ProjectName id "slot:project:name" on Project : string
|
||||
policy optimistic-register default "Untitled project";
|
||||
policy optimistic-register default "Untitled project";
|
||||
shared edge ProjectComponentEdge id "edge:project:component" {
|
||||
atom ProjectComponent projection subject id "projection:component:subject" exactly-one;
|
||||
atom Project projection component id "projection:project:component" optional-one;
|
||||
|
||||
Reference in New Issue
Block a user