Make Camino examples and scaffolds complete Yarn and Nix packages
This commit is contained in:
@@ -37,9 +37,25 @@ export async function executionScaffold(
|
||||
formatQuixosLock({ formatVersion: 1, quixos: { resolver: "git", ...spec.tools.quixos }, resources: [] }),
|
||||
);
|
||||
create("quixos.check.json", json({ backend: "execution" }));
|
||||
create("quixos.components.json", "{}\n");
|
||||
create("package.json", json({ name: `@quixos/${spec.name.toLowerCase()}`, private: true, type: "module" }));
|
||||
create(".gitignore", "node_modules/\ndist/\nsrc/gen/\n.quixos/\nresult\n");
|
||||
create("components.nix", "{\n}\n");
|
||||
create(
|
||||
"package.json",
|
||||
json({
|
||||
name: `@quixos/${spec.name.toLowerCase()}`,
|
||||
private: true,
|
||||
type: "module",
|
||||
packageManager: "yarn@4.18.0",
|
||||
scripts: { typecheck: "qx-workspace check" },
|
||||
}),
|
||||
);
|
||||
create(
|
||||
".gitignore",
|
||||
"node_modules/\ndist/\nsrc/gen/\n.quixos/\nresult\n.yarn/cache/\n.yarn/install-state.gz\n.yarn/unplugged/\n",
|
||||
);
|
||||
create(
|
||||
".yarnrc.yml",
|
||||
'enableScripts: true\n\ngenerateDefaultNix: false\n\nindividualNixPackaging: true\n\nnodeLinker: node-modules\n\nsupportedArchitectures:\n os:\n - current\n - linux\n cpu:\n - current\n - x64\n - arm64\n libc:\n - current\n - glibc\n\nplugins:\n - checksum: 271de9a785321a37c564b8e2a6b5cd689850b20572d5fee8ec0a6b8e7a5d4cfb59e533524af2b4a537e00da12828abd062eaec6978556e3dd9149a020db2591b\n path: .yarn/plugins/yarn-plugin-nixify.cjs\n spec: "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/yarn-plugin-nixify-patched/raw/commit/4528fdd20b30d869262443b3f044549810e75fb8/dist/yarn-plugin-nixify.js"\n',
|
||||
);
|
||||
for (const lane of ["browser", "server", "remote"])
|
||||
create(
|
||||
`src/${lane}.ts`,
|
||||
@@ -56,22 +72,36 @@ export async function executionScaffold(
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in {
|
||||
quixosPackages.checkedArtifacts = { plan, generator, core, sharedRuntime, typescript, packageRevisionId, react ? null, ... }:
|
||||
(import (helpers + "/artifacts.nix")) {
|
||||
inherit pkgs plan core sharedRuntime typescript packageRevisionId;
|
||||
protocol = generator;
|
||||
src = ./.;
|
||||
components = let entries = builtins.fromJSON (builtins.readFile ./quixos.components.json); in
|
||||
if entries == {} then null else
|
||||
if react == null then throw "Component entries require the workspace-selected React runtime" else
|
||||
{ inherit (react) sdk runtime; inherit entries; };
|
||||
portable = {
|
||||
entry = "src/server.ts";
|
||||
entries.browser = "src/browser.ts";
|
||||
bindingOutput = "src/gen/qx.ts";
|
||||
};
|
||||
remote = { entry = "src/remote.ts"; bindingOutput = "src/gen/remote.ts"; };
|
||||
};
|
||||
devShells.default = (import (helpers + "/quixos-package-helpers.nix")).mkCaminoYarnShell { inherit pkgs; };
|
||||
quixosPackages.checkedArtifacts = context:
|
||||
import ./package.nix { inherit pkgs context; camino = import (helpers + "/quixos-package-helpers.nix"); };
|
||||
});
|
||||
}
|
||||
`,
|
||||
);
|
||||
create(
|
||||
"package.nix",
|
||||
`{ pkgs, camino, context }:
|
||||
let
|
||||
plan = builtins.fromJSON (builtins.readFile context.plan);
|
||||
package = pkgs.lib.findFirst (entry: entry.revision == context.packageRevisionId)
|
||||
(throw "Package missing from checked plan") plan.definition.packages;
|
||||
portable = builtins.filter (entry: entry.execution.kind != "remote") package.exports;
|
||||
remote = builtins.filter (entry: entry.execution.kind == "remote") package.exports;
|
||||
modules = import ./components.nix;
|
||||
dependencies = if builtins.pathExists ./yarn-project.nix
|
||||
then camino.mkCaminoYarnDependencies { inherit pkgs; src = ./.; } else null;
|
||||
in camino.assembleCaminoPackage {
|
||||
inherit pkgs context;
|
||||
artifacts =
|
||||
pkgs.lib.optional (portable != []) (camino.mkCaminoTypeScriptPackage {
|
||||
inherit pkgs context dependencies; src = ./.;
|
||||
entry = "src/server.ts"; entries.browser = "src/browser.ts";
|
||||
targets = pkgs.lib.unique (pkgs.lib.concatMap (entry: entry.execution.targets) portable);
|
||||
}) ++ pkgs.lib.optional (remote != []) (camino.mkCaminoTypeScriptService {
|
||||
inherit pkgs context dependencies; src = ./.; entry = "src/remote.ts";
|
||||
}) ++ pkgs.lib.optional (modules != {}) (camino.mkCaminoReactPackage {
|
||||
inherit pkgs context dependencies modules; src = ./.;
|
||||
});
|
||||
}
|
||||
`,
|
||||
@@ -163,7 +193,7 @@ export async function executionScaffold(
|
||||
for (const [file, content] of Object.entries(spec.initialFiles)) {
|
||||
if (
|
||||
typeof content !== "string" ||
|
||||
!/^(?:package\.qx|quixos\.components\.json|quixos\.controllers\.json|README\.md|(?:src|queries)\/(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_.-]+)$/.test(
|
||||
!/^(?:package\.qx|(?:package|components|flake|yarn-project)\.nix|package\.json|yarn\.lock|\.yarnrc\.yml|\.gitignore|\.yarn\/plugins\/[A-Za-z0-9_.-]+\.cjs|quixos\.controllers\.json|README\.md|(?:src|queries)\/(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_.-]+)$/.test(
|
||||
file,
|
||||
) ||
|
||||
file.split("/").some((part) => part === ".." || part === "." || part === "gen")
|
||||
|
||||
Reference in New Issue
Block a user