as-test 0.5.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
 
3
- ## 2026-03-04
3
+ ## 2026-03-11 - v1.0.0
4
+
5
+ ### Docs
6
+
7
+ - docs: add README guidance for strict config validation behavior and example error output.
4
8
 
5
9
  ### CLI & Config Validation
6
10
 
@@ -8,10 +12,15 @@
8
12
  - feat: reject unknown config keys with nearest-key suggestions.
9
13
  - feat: show structured validation diagnostics with JSON paths and fix hints.
10
14
  - feat: fail fast on invalid config JSON with parser error details.
11
-
12
- ### Docs
13
-
14
- - docs: add README guidance for strict config validation behavior and example error output.
15
+ -
16
+ ### Release Readiness
17
+
18
+ - fix: resolve `@assemblyscript/wasi-shim` and `try-as` with package resolution instead of assuming a local `./node_modules` folder, so nested example projects and other valid installs run correctly.
19
+ - fix: pass the WASI shim config to `asc` as a cwd-relative path, which avoids nested-project WASI build failures with standalone examples.
20
+ - feat: add root `test:examples` coverage and include full standalone example validation in `release:check`.
21
+ - feat: validate all examples in both `wasi` and `bindings` modes as part of release readiness.
22
+ - docs: update README and examples docs for the standalone example layout and root-level validation flow.
23
+ - chore: promote package version to `1.0.0` and switch `publishConfig` to public npm publishing.
15
24
 
16
25
  ## 2026-02-25 - v0.5.3
17
26
 
package/README.md CHANGED
@@ -56,13 +56,19 @@ npm install as-test --save-dev
56
56
 
57
57
  Full runnable examples live in `examples/`, including:
58
58
 
59
+ - one standalone project per example (initialized with `ast init`)
59
60
  - complete spec files for core features
60
61
  - import mocking and import snapshot patterns
61
- - mode-based runtime matrix config in `examples/as-test.config.json`
62
- - a dedicated config you can run directly
63
62
 
64
63
  See `examples/README.md` for the walkthrough.
65
64
 
65
+ Quick validation from this repo:
66
+
67
+ ```bash
68
+ npm test
69
+ npm run test:examples
70
+ ```
71
+
66
72
  ## Writing Tests
67
73
 
68
74
  Create `assembly/__tests__/math.spec.ts`:
@@ -3,7 +3,7 @@ import { glob } from "glob";
3
3
  import chalk from "chalk";
4
4
  import { spawnSync } from "child_process";
5
5
  import * as path from "path";
6
- import { applyMode, getPkgRunner, loadConfig, tokenizeCommand, } from "../util.js";
6
+ import { applyMode, getPkgRunner, loadConfig, tokenizeCommand, resolveProjectModule, } from "../util.js";
7
7
  const DEFAULT_CONFIG_PATH = path.join(process.cwd(), "./as-test.config.json");
8
8
  export async function build(configPath = DEFAULT_CONFIG_PATH, selectors = [], modeName, featureToggles = {}) {
9
9
  const loadedConfig = loadConfig(configPath, false);
@@ -171,7 +171,7 @@ function stripSuiteSuffix(selector) {
171
171
  }
172
172
  function ensureDeps(config) {
173
173
  if (config.buildOptions.target == "wasi") {
174
- if (!existsSync("./node_modules/@assemblyscript/wasi-shim/asconfig.json")) {
174
+ if (!resolveWasiShim()) {
175
175
  console.log(`${chalk.bgRed(" ERROR ")}${chalk.dim(":")} could not find @assemblyscript/wasi-shim! Add it to your dependencies to run with WASI!`);
176
176
  process.exit(1);
177
177
  }
@@ -233,7 +233,11 @@ function getDefaultBuildArgs(config, featureToggles) {
233
233
  buildArgs.push("--use", "AS_TEST_BINDINGS=1", "--bindings", "raw", "--exportRuntime", "--exportStart", "_start");
234
234
  }
235
235
  else if (config.buildOptions.target == "wasi") {
236
- buildArgs.push("--use", "AS_TEST_WASI=1", "--config", "./node_modules/@assemblyscript/wasi-shim/asconfig.json");
236
+ const wasiShim = resolveWasiShim();
237
+ if (!wasiShim) {
238
+ throw new Error('WASI target requires package "@assemblyscript/wasi-shim"');
239
+ }
240
+ buildArgs.push("--use", "AS_TEST_WASI=1", "--config", wasiShim.configPath);
237
241
  }
238
242
  else {
239
243
  console.log(`${chalk.bgRed(" ERROR ")}${chalk.dim(":")} could not determine target in config! Set target to 'bindings' or 'wasi'`);
@@ -263,6 +267,28 @@ function resolveCoverageEnabled(rawCoverage, override) {
263
267
  return true;
264
268
  }
265
269
  function hasTryAsRuntime() {
266
- return (existsSync(path.join(process.cwd(), "node_modules/try-as")) ||
267
- existsSync(path.join(process.cwd(), "node_modules/try-as/package.json")));
270
+ return resolveProjectModule("try-as/package.json") != null;
271
+ }
272
+ function resolveWasiShim() {
273
+ const resolved = resolveProjectModule("@assemblyscript/wasi-shim/asconfig.json");
274
+ if (!resolved)
275
+ return null;
276
+ if (!existsSync(resolved))
277
+ return null;
278
+ const relative = path.relative(process.cwd(), resolved).replace(/\\/g, "/");
279
+ return {
280
+ configPath: normalizeCliPath(relative),
281
+ };
282
+ }
283
+ function quoteCliArg(value) {
284
+ if (!/[\s"]/g.test(value))
285
+ return value;
286
+ return `"${value.replace(/"/g, '\\"')}"`;
287
+ }
288
+ function normalizeCliPath(value) {
289
+ if (!value.length)
290
+ return ".";
291
+ if (value.startsWith(".") || value.startsWith("/"))
292
+ return value;
293
+ return "./" + value;
268
294
  }
package/bin/util.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { existsSync, readFileSync } from "fs";
2
2
  import { BuildOptions, Config, CoverageOptions, ModeConfig, ReporterConfig, RunOptions, Runtime, } from "./types.js";
3
3
  import chalk from "chalk";
4
+ import { createRequire } from "module";
4
5
  import { delimiter, dirname, join } from "path";
5
6
  import { fileURLToPath } from "url";
6
7
  export function formatTime(ms) {
@@ -875,3 +876,16 @@ export function tokenizeCommand(command) {
875
876
  }
876
877
  return out;
877
878
  }
879
+ export function resolveProjectModule(specifier) {
880
+ const cwdRequire = createRequire(join(process.cwd(), "package.json"));
881
+ const localRequire = createRequire(import.meta.url);
882
+ for (const req of [cwdRequire, localRequire]) {
883
+ try {
884
+ return req.resolve(specifier);
885
+ }
886
+ catch {
887
+ // try next resolver
888
+ }
889
+ }
890
+ return null;
891
+ }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "as-test",
3
- "version": "0.5.4",
3
+ "version": "1.0.0",
4
4
  "author": "Jairus Tanaka",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/JairusSW/as-test.git"
8
8
  },
9
9
  "dependencies": {
10
- "as-console": "^7.0.0",
11
10
  "as-rainbow": "^0.1.0",
11
+ "as-console": "^7.0.0",
12
12
  "chalk": "^5.6.2",
13
13
  "glob": "^13.0.3",
14
14
  "typer-diff": "^1.1.1"
@@ -59,17 +59,18 @@
59
59
  ],
60
60
  "license": "MIT",
61
61
  "publishConfig": {
62
- "@JairusSW:registry": "https://npm.pkg.github.com"
62
+ "access": "public"
63
63
  },
64
64
  "scripts": {
65
65
  "test": "node ./bin/index.js test",
66
+ "test:examples": "npm --prefix ./examples run test",
66
67
  "typecheck": "tsc -p cli --noEmit && tsc -p transform --noEmit",
67
68
  "lint": "eslint transform/src/**/*.ts tools/**/*.js eslint.config.js",
68
69
  "build:transform": "tsc -p ./transform",
69
70
  "build:cli": "tsc -p cli",
70
71
  "build:run": "npm run build:cli",
71
72
  "prettier": "prettier -w .",
72
- "release:check": "npm run build:cli && npm run build:transform && npm run test && npm pack --dry-run --cache /tmp/as-test-npm-cache",
73
+ "release:check": "npm run build:cli && npm run build:transform && npm run test && npm run test:examples && npm pack --dry-run --cache /tmp/as-test-npm-cache",
73
74
  "prepublishOnly": "npm run build:cli && npm run build:transform && npm run test"
74
75
  },
75
76
  "type": "module",