Complete prepared presentation build and runtime integration
This commit is contained in:
@@ -59,12 +59,26 @@ export async function scaffoldComponent(
|
||||
const configBefore = await fs.readFile(path.join(root, configFile), "utf8");
|
||||
const config = JSON.parse(configBefore);
|
||||
config.queryFrontends = [...new Set([...(config.queryFrontends ?? []), "react"])];
|
||||
const preparationFile = prefix + "quixos.react.json";
|
||||
let preparationBefore: string | undefined;
|
||||
try {
|
||||
preparationBefore = await fs.readFile(path.join(root, preparationFile), "utf8");
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
||||
}
|
||||
const preparation = preparationBefore ? JSON.parse(preparationBefore) : { modules: {} };
|
||||
if (Object.hasOwn(preparation.modules, spec.name)) throw Error("Duplicate presentation preparation");
|
||||
preparation.modules[spec.name] = { inputs: [] };
|
||||
const preparationText = JSON.stringify(preparation, null, 2) + "\n";
|
||||
return {
|
||||
kind: "package",
|
||||
source: spec.source,
|
||||
resourceRoot: spec.directory,
|
||||
validation: "syntax",
|
||||
files: [
|
||||
preparationBefore === undefined
|
||||
? { file: preparationFile, create: preparationText }
|
||||
: { file: preparationFile, expected: preparationBefore, replace: preparationText },
|
||||
{ file: configFile, expected: configBefore, replace: JSON.stringify(config, null, 2) + "\n" },
|
||||
{
|
||||
file: prefix + "package.qx",
|
||||
@@ -79,7 +93,7 @@ export async function scaffoldComponent(
|
||||
{ file: prefix + filename, expected: before, replace: after },
|
||||
{
|
||||
file: prefix + `src/components/${spec.name}.tsx`,
|
||||
create: `import type { Modules } from "../gen/client.js";\n\n// Add explicit query admission and named interface operations from the generated client.\nexport const ${spec.name}: Modules[${JSON.stringify(spec.name)}] = ({subject}) => <p>{subject.object}</p>;\n`,
|
||||
create: `import type { Modules } from "../gen/client.js";\n\n// Declare initial query inputs in quixos.react.json; use interfaces for actions.\nexport const ${spec.name}: Modules[${JSON.stringify(spec.name)}] = ({subject}) => <p>{subject.object}</p>;\n`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user