Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ if test $(git rev-parse --abbrev-ref HEAD) = "main" ; then
fi

yarn lint-staged
moon run scripts:syncpack-lint
22 changes: 22 additions & 0 deletions .moon/tasks/tag-syncpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$schema: https://moonrepo.dev/schemas/tasks.json
tasks:
syncpack-lint:
toolchain: node
preset: utility
script: syncpack lint --dependency-types prod,dev
options:
runFromWorkspaceRoot: true
syncpack-fix:
toolchain: node
preset: utility
script: syncpack fix
options:
runFromWorkspaceRoot: true
syncpack-format:
toolchain: node
preset: utility
script: syncpack format
options:
runFromWorkspaceRoot: true
inheritedBy:
tag: syncpack
22 changes: 14 additions & 8 deletions .moon/tasks/tag-trunk.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
$schema: https://moonrepo.dev/schemas/tasks.json
fileGroups:
sources:
- src/**/*
trunk-config:
- Trunk.toml
- Cargo.toml
- "*.html"
trunk-dist:
- ./target/trunk/dist/**/*
tasks:
serve:
command: trunk serve
preset: server
mkTarget:
command: mkdir -p target/apps
build:
trunk-build:
script: env -u NO_COLOR trunk build
toolchain: system
inputs:
- src/**/*
- "*.html"
- "*.toml"
deps:
- mkTarget
- "@group(sources)"
- "@group(trunk-config)"
outputs:
- "@group(trunk-dist)"
inheritedBy:
tag: trunk
6 changes: 6 additions & 0 deletions .syncpackrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# yaml-language-server: $schema=./node_modules/syncpack/schema.json
source:
- package.json
- apps/*/package.json
- libs/*/package.json
- etc/scripts/package.json
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/ora-npm-8.0.1-d9010b6b37-3d37bb3f53.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/counter/Trunk.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[build]
filehash = false
public_url = "/apps/counter/"
dist = "target/apps/counter/"
dist = "target/trunk/dist/"
4 changes: 4 additions & 0 deletions apps/counter/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ tags:
- trunk
toolchains:
default: rust
tasks:
build:
deps:
- ~:trunk-build
project:
description: app
title: "@n8v/counter"
Expand Down
2 changes: 2 additions & 0 deletions apps/recorder/Trunk.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[build]
filehash = false
public_url = "/apps/recorder/"
dist = "target/trunk/dist/"
4 changes: 4 additions & 0 deletions apps/recorder/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ tags:
- trunk
toolchains:
default: rust
tasks:
build:
deps:
- ~:trunk-build
project:
description: app
title: "@n8v/recorder"
Expand Down
18 changes: 14 additions & 4 deletions etc/scripts/moon-tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { getBuildNumber } from "@n8v/scripts/utils/get-build-number";
import { getRev } from "@n8v/scripts/utils/get-rev";
import { workDirs } from "@n8v/scripts/utils/work-dirs";
import fse from "fs-extra";
// eslint-disable-next-line unicorn/import-style
import * as path from "node:path";

$.verbose = true;

Expand All @@ -16,11 +18,19 @@ $.env.GATSBY_BUILD_NUMBER = getBuildNumber();
$.env.GATSBY_REV = await getRev();
$.env.GATSBY_MODE = $.env.MODE;

await $`moon run app:build`;
await $`moon run app:build counter:build recorder:build`;

await $`moon run counter:build`;
// Merge the rust/trunk bundles into the gatsby site so that
// URLs like /apps/counter/ and /apps/recorder/ resolve correctly.
await fse.copy(
workDirs.apps.counter.target.trunk.dist.path,
path.join(workDirs.apps.app.public.path, "apps/counter"),
);

await fse.copy(
workDirs.apps.counter.target.path,
workDirs.apps.app.public.path,
workDirs.apps.recorder.target.trunk.dist.path,
path.join(workDirs.apps.app.public.path, "apps/recorder"),
);

// Populate the repo-root /target/ aggregator (apps + release)
await $`moon run scripts:collect-workspace-targets`;
85 changes: 85 additions & 0 deletions etc/scripts/moon-tasks/collect-workspace-targets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env -S yarn dlx tsx
import "zx/globals";
import { workDirs } from "@n8v/scripts/utils/work-dirs";
import fse from "fs-extra";
// eslint-disable-next-line unicorn/import-style
import * as path from "node:path";

$.verbose = true;
cd(workDirs.path);

// Prepare output directories
await fse.emptyDir(workDirs.target.path);
await fse.emptyDir(workDirs.target.apps.path);
await fse.emptyDir(workDirs.target.release.path);

// Collect per-app target outputs into /target/apps/<name>/
const appTargets: { name: string; source: string }[] = [
{
name: "counter",
source: workDirs.apps.counter.target.path,
},
{
name: "recorder",
source: workDirs.apps.recorder.target.path,
},
];

await Promise.all(
appTargets.map(async ({ name, source }) => {
if (!(await fse.pathExists(source))) {
console.log(`Skipping ${name}: ${source} does not exist`);
return;
}

const destination = path.join(workDirs.target.apps.path, name);
// Copy only the trunk/dist subtree to avoid massive Cargo caches
const trunkDistribution = path.join(source, "trunk/dist");

if (await fse.pathExists(trunkDistribution)) {
await fse.copy(trunkDistribution, path.join(destination, "trunk/dist"));
console.log(`Copied ${trunkDistribution} -> ${destination}/trunk/dist`);
}
}),
);

// Also aggregate the gatsby app output under /target/apps/app/gatsby/public
if (await fse.pathExists(workDirs.apps.app.public.path)) {
const gatsbyDestination = path.join(
workDirs.target.apps.path,
"app/gatsby/public",
);
await fse.copy(workDirs.apps.app.public.path, gatsbyDestination);
console.log(
`Copied ${workDirs.apps.app.public.path} -> ${gatsbyDestination}`,
);
}

// Populate /target/release/ with side-by-side per-app bundles
const releaseLayout: { name: string; source: string }[] = [
{
name: "app",
source: workDirs.apps.app.public.path,
},
{
name: "counter",
source: workDirs.apps.counter.target.trunk.dist.path,
},
{
name: "recorder",
source: workDirs.apps.recorder.target.trunk.dist.path,
},
];

await Promise.all(
releaseLayout.map(async ({ name, source }) => {
if (!(await fse.pathExists(source))) {
console.log(`Skipping release/${name}: ${source} does not exist`);
return;
}

const destination = path.join(workDirs.target.release.path, name);
await fse.copy(source, destination);
console.log(`Copied release artifact: ${source} -> ${destination}`);
}),
);
4 changes: 1 addition & 3 deletions etc/scripts/moon-tasks/post-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
import "zx/globals";
$.verbose = true;
await $`node_modules/.bin/husky`.pipe(process.stdout);
await $`node_modules/.bin/syncpack fix-mismatches --types=prod,dev`.pipe(
process.stdout,
);
await $`node_modules/.bin/syncpack fix`.pipe(process.stdout);
9 changes: 9 additions & 0 deletions etc/scripts/moon.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# yaml-language-server: $schema: 'https://moonrepo.dev/schemas/project.json'
language: typescript
tags:
- syncpack
tasks:
lint:
preset: utility
Expand All @@ -15,6 +17,13 @@ tasks:
publish:
preset: utility
script: $projectRoot/moon-tasks/publish.ts
collect-workspace-targets:
preset: utility
script: $projectRoot/moon-tasks/collect-workspace-targets.ts
check:
preset: utility
deps:
- ~:syncpack-lint
toolchains:
default: node
project:
Expand Down
1 change: 1 addition & 0 deletions etc/scripts/utils/clean-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ $.verbose = true;

export const cleanBuild = async () => {
await fse.emptyDir(workDirs.apps.app.public.path);
await fse.emptyDir(workDirs.target.path);
};
30 changes: 27 additions & 3 deletions etc/scripts/utils/work-dirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ const apps = path.resolve(root, "apps");
const etc = path.resolve(root, "etc");
const app = path.resolve(apps, "app");
const counter = path.resolve(apps, "counter");
const recorder = path.resolve(apps, "recorder");
const workflowRuntime = path.resolve(etc, "workflow-runtime");
const scripts = path.resolve(etc, "scripts");
const target = path.resolve(root, "target");

// eslint-disable-next-line unicorn/prevent-abbreviations
export const workDirs = {
Expand All @@ -27,13 +29,26 @@ export const workDirs = {
counter: {
path: counter,
target: {
apps: {
path: path.resolve(counter, "target/apps"),
},
path: path.resolve(counter, "target"),
trunk: {
dist: {
path: path.resolve(counter, "target/trunk/dist"),
},
},
},
},
path: apps,
recorder: {
path: recorder,
target: {
path: path.resolve(recorder, "target"),
trunk: {
dist: {
path: path.resolve(recorder, "target/trunk/dist"),
},
},
},
},
},

etc: {
Expand All @@ -46,4 +61,13 @@ export const workDirs = {
},
},
path: root,
target: {
apps: {
path: path.resolve(target, "apps"),
},
path: target,
release: {
path: path.resolve(target, "release"),
},
},
};
4 changes: 4 additions & 0 deletions etc/workflow-runtime/src/workflow_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (m *WorkflowRuntime) BuildEnv(ctx context.Context) *WorkflowRuntime {
WithFile("/workspace/.prototools", m.Dir.File(".prototools")).
// proto use
WithExec([]string{"proto", "use"}).
// Install cargo-binstall (fast prebuilt installer for cargo bins)
WithExec([]string{"bash", "-l", "-c", "curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash"}).
// Install trunk and wasm-bindgen-cli via cargo-binstall (matches .moon/toolchains.yml)
WithExec([]string{"bash", "-l", "-c", "cargo binstall --no-confirm --locked trunk@0.21.14 wasm-bindgen-cli@0.2.118"}).
WithMountedDirectory("/workspace", source).
WithMountedDirectory("/workspace/.git", m.Dir.Directory(".git")).
// moon setup
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"react-toastify": "^11.0.5",
"rooks": "^7.14.1",
"sass": "^1.83.4",
"syncpack": "^13.0.0",
"syncpack": "^14.2.1",
"theme-ui-sketchy-preset": "^0.1.3",
"ts-pattern": "^5.6.2",
"tsconfig-moon": "^1.3.0",
Expand All @@ -100,5 +100,6 @@
"resolutions": {
"msgpackr": "^1.11.9",
"ordered-binary": "^1.6.1"
}
},
"packageManager": "yarn@4.10.3"
}
6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
},
{
"path": "./etc/scripts"
},
{
"path": "apps/app"
},
{
"path": "etc/scripts"
}
]
}
Loading
Loading