Skip to content

Commit 9f878e2

Browse files
fix: plain clone works fully + Deno container (Refs affinescript#122)
## Make a plain clone work fully + Deno container (Refs affinescript#122, #126; ubicity#30) Follow-up to #31. After the `.ts` elimination the repo did not run from a clean clone. This makes it work end-to-end, including containerised. ### Fixes 1. **`src/storage.js` regenerated** with the fixed async-IIFE backend (affinescript#126). The version merged in #31 was generated *before* that fix, so `loadAllExperiences` was a `SyntaxError` (`await` inside a non-async IIFE). 2. **`deno.json`**: `exports` → `./src/index.js`; added `"nodeModulesDir": "auto"` (npm:zod had no resolution); every task / glob `.ts` entrypoint (`cli`/`capture`/`visualize`/`index`) → `.js` (they were deleted in #31). 3. **`node:` prefix** on all bare node-builtin imports deno rejects: `export/import` (`fs`), `capture` (`process`, `readline/promises`), `mapper/privacy` (`crypto`), `performance` (`perf_hooks`). 4. **`.tool-versions`**: pin `deno 2.7.14` (matches CI `setup-deno` and `flake.nix`) so an `asdf`/`mise` clone provisions deno. 5. **Containerfile** rewritten on `denoland/deno:2.7.14` (was a stale Node image that cannot run this Deno project); `.dockerignore` keeps `tests/` so the image can run the suite; `docker-compose.yml` names `Containerfile` explicitly so `docker compose` (not just podman) finds it. ### Verification - Local: `deno task test` → **44 passed / 0 failed**. - Containerised: `docker build -f Containerfile -t ubicity .` → builds clean; `docker run --rm ubicity test --allow-read --allow-write tests/` → **44 passed / 0 failed**; default CMD (CLI help) works. - A plain `git clone` now works fully via: host deno (`.tool-versions` / `flake.nix` both provide 2.7.14) **or** the container. `flake.nix` already provided deno (unchanged). storage.affine remains the source of truth for storage.js (affinescript#122 showcase). Refs hyperpolymath/affinescript#122 #126, ubicity#30. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent f2cb58f commit 9f878e2

13 files changed

Lines changed: 755 additions & 122 deletions

.dockerignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ node_modules
22
npm-debug.log
33
.git
44
.gitignore
5-
*.md
6-
!README.md
7-
tests
85
.github
96
.eslintrc.json
107
.prettierrc.json
118
ubicity-data/*
129
!ubicity-data/.gitkeep
1310
DENO_MIGRATION_PREVIEW.md
1411
STACK_ANALYSIS.md
12+
bin
13+
coverage
14+
wasm/target

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
deno 2.7.14
12
nodejs 25.6.1
23
just 1.36.0

Containerfile

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
# UbiCity Docker Container
2-
# Provides isolated environment for running UbiCity tools
1+
# UbiCity container — Deno runtime.
2+
#
3+
# This project is Deno-first (deno.json tasks, Deno.* filesystem APIs,
4+
# jsr:@std/* + npm: deps). The previous Node Containerfile could not run
5+
# it. Pinned to the .tool-versions deno so a plain `git clone` builds an
6+
# image that runs the full test suite and CLI with no host toolchain.
7+
#
8+
# docker build -t ubicity .
9+
# docker run --rm ubicity # CLI help
10+
# docker run --rm ubicity deno task stats
11+
# docker run --rm -v ./data:/app/ubicity-data ubicity deno task report
12+
# docker run --rm ubicity \
13+
# deno test --allow-read --allow-write tests/ # full suite (44 tests)
14+
FROM denoland/deno:2.7.14
315

4-
FROM node:20-alpine
5-
6-
# Set working directory
716
WORKDIR /app
817

9-
# Install dependencies
10-
COPY package*.json ./
11-
RUN npm ci --only=production
18+
# Manifests first for build-cache friendliness.
19+
COPY deno.json deno.lock package.json ./
1220

13-
# Copy application code
14-
COPY src/ ./src/
15-
COPY schema/ ./schema/
16-
COPY examples/ ./examples/
17-
COPY scripts/ ./scripts/
21+
# Application + tests + assets (.dockerignore trims git/node_modules/etc).
22+
COPY . .
1823

19-
# Create data directory
20-
RUN mkdir -p ubicity-data/experiences ubicity-data/analyses ubicity-data/maps
24+
# Warm the module cache: jsr:@std/* + npm: deps. nodeModulesDir "auto"
25+
# in deno.json materialises node_modules at build time so runtime needs
26+
# no network.
27+
RUN deno cache src/index.js
2128

22-
# Expose volume for data persistence
29+
# Data directory (mountable volume for persistence).
30+
RUN mkdir -p ubicity-data/experiences ubicity-data/analyses ubicity-data/maps
2331
VOLUME ["/app/ubicity-data"]
2432

25-
# Set Node.js environment
26-
ENV NODE_ENV=production
27-
28-
# Default command: show help
29-
CMD ["node", "src/cli.js", "help"]
33+
ENV UBICITY_LOG_LEVEL=info
3034

31-
# Example usage:
32-
# docker build -t ubicity .
33-
# docker run -v ./data:/app/ubicity-data ubicity stats
34-
# docker run -v ./data:/app/ubicity-data ubicity report
35+
# Default: CLI help. Override the args to run any deno task / test, e.g.
36+
# docker run --rm ubicity test --allow-read --allow-write tests/
37+
ENTRYPOINT ["deno"]
38+
CMD ["run", "--allow-read", "--allow-write", "src/cli.js", "help"]

deno.json

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
{
22
"name": "@ubicity/core",
33
"version": "0.3.0",
4-
"exports": "./src/index.ts",
4+
"exports": "./src/index.js",
5+
"nodeModulesDir": "auto",
56
"tasks": {
6-
"dev": "deno run --watch src/cli.ts",
7-
"start": "deno run --allow-read --allow-write src/cli.ts",
8-
"capture": "deno run --allow-read --allow-write src/capture.ts",
9-
"capture:quick": "deno run --allow-read --allow-write src/capture.ts quick",
10-
"capture:full": "deno run --allow-read --allow-write src/capture.ts full",
11-
"visualize": "deno run --allow-read --allow-write src/visualize.ts",
12-
"report": "deno run --allow-read --allow-write src/cli.ts report",
13-
"hotspots": "deno run --allow-read --allow-write src/cli.ts hotspots",
14-
"stats": "deno run --allow-read --allow-write src/cli.ts stats",
7+
"dev": "deno run --watch src/cli.js",
8+
"start": "deno run --allow-read --allow-write src/cli.js",
9+
"capture": "deno run --allow-read --allow-write src/capture.js",
10+
"capture:quick": "deno run --allow-read --allow-write src/capture.js quick",
11+
"capture:full": "deno run --allow-read --allow-write src/capture.js full",
12+
"visualize": "deno run --allow-read --allow-write src/visualize.js",
13+
"report": "deno run --allow-read --allow-write src/cli.js report",
14+
"hotspots": "deno run --allow-read --allow-write src/cli.js hotspots",
15+
"stats": "deno run --allow-read --allow-write src/cli.js stats",
1516
"test": "deno test --allow-read --allow-write tests/",
1617
"test:watch": "deno test --watch --allow-read --allow-write tests/",
1718
"bench": "deno bench --allow-read --allow-write benchmarks/",
18-
"check": "deno check src/**/*.ts",
19+
"check": "deno check src/**/*.js",
1920
"fmt": "deno fmt",
2021
"fmt:check": "deno fmt --check",
2122
"lint": "deno lint",
22-
"cache": "deno cache --reload src/index.ts",
23+
"cache": "deno cache --reload src/index.js",
2324
"compile": "deno task compile:cli && deno task compile:capture && deno task compile:wasm",
24-
"compile:cli": "deno compile --allow-read --allow-write --output ./bin/ubicity src/cli.ts",
25-
"compile:capture": "deno compile --allow-read --allow-write --output ./bin/ubicity-capture src/capture.ts",
25+
"compile:cli": "deno compile --allow-read --allow-write --output ./bin/ubicity src/cli.js",
26+
"compile:capture": "deno compile --allow-read --allow-write --output ./bin/ubicity-capture src/capture.js",
2627
"compile:wasm": "deno task rescript:build && deno task wasm:build",
2728
"rescript:build": "rescript build",
2829
"rescript:clean": "rescript clean",
@@ -77,8 +78,8 @@
7778
],
7879
"lint": {
7980
"include": [
80-
"src/**/*.ts",
81-
"tests/**/*.ts",
81+
"src/**/*.js",
82+
"tests/**/*.{ts,js}",
8283
"benchmarks/**/*.ts"
8384
],
8485
"rules": {
@@ -92,8 +93,8 @@
9293
},
9394
"fmt": {
9495
"include": [
95-
"src/**/*.ts",
96-
"tests/**/*.ts",
96+
"src/**/*.js",
97+
"tests/**/*.{ts,js}",
9798
"benchmarks/**/*.ts"
9899
],
99100
"useTabs": false,

0 commit comments

Comments
 (0)