as-test 0.5.4 → 1.0.1

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,14 @@
1
1
  # Change Log
2
2
 
3
- ## 2026-03-04
3
+ ## 2026-03-11 - v1.0.1
4
+
5
+ - patch: automatically tokenize buildOptions.args so that `["--enable simd"]` becomes `["--enable", "simd"]`
6
+
7
+ ## 2026-03-11 - v1.0.0
8
+
9
+ ### Docs
10
+
11
+ - docs: add README guidance for strict config validation behavior and example error output.
4
12
 
5
13
  ### CLI & Config Validation
6
14
 
@@ -8,10 +16,15 @@
8
16
  - feat: reject unknown config keys with nearest-key suggestions.
9
17
  - feat: show structured validation diagnostics with JSON paths and fix hints.
10
18
  - 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.
19
+ -
20
+ ### Release Readiness
21
+
22
+ - 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.
23
+ - fix: pass the WASI shim config to `asc` as a cwd-relative path, which avoids nested-project WASI build failures with standalone examples.
24
+ - feat: add root `test:examples` coverage and include full standalone example validation in `release:check`.
25
+ - feat: validate all examples in both `wasi` and `bindings` modes as part of release readiness.
26
+ - docs: update README and examples docs for the standalone example layout and root-level validation flow.
27
+ - chore: promote package version to `1.0.0` and switch `publishConfig` to public npm publishing.
15
28
 
16
29
  ## 2026-02-25 - v0.5.3
17
30
 
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);
@@ -59,7 +59,13 @@ function getBuildCommand(config, pkgRunner, file, outFile, modeName, featureTogg
59
59
  };
60
60
  }
61
61
  function getUserBuildArgs(config) {
62
- return config.buildOptions.args.filter((value) => value.length > 0);
62
+ const args = [];
63
+ for (const value of config.buildOptions.args) {
64
+ if (!value.length)
65
+ continue;
66
+ args.push(...tokenizeCommand(value));
67
+ }
68
+ return args;
63
69
  }
64
70
  function expandBuildCommand(template, file, outFile, target, modeName) {
65
71
  const name = path
@@ -171,7 +177,7 @@ function stripSuiteSuffix(selector) {
171
177
  }
172
178
  function ensureDeps(config) {
173
179
  if (config.buildOptions.target == "wasi") {
174
- if (!existsSync("./node_modules/@assemblyscript/wasi-shim/asconfig.json")) {
180
+ if (!resolveWasiShim()) {
175
181
  console.log(`${chalk.bgRed(" ERROR ")}${chalk.dim(":")} could not find @assemblyscript/wasi-shim! Add it to your dependencies to run with WASI!`);
176
182
  process.exit(1);
177
183
  }
@@ -233,7 +239,11 @@ function getDefaultBuildArgs(config, featureToggles) {
233
239
  buildArgs.push("--use", "AS_TEST_BINDINGS=1", "--bindings", "raw", "--exportRuntime", "--exportStart", "_start");
234
240
  }
235
241
  else if (config.buildOptions.target == "wasi") {
236
- buildArgs.push("--use", "AS_TEST_WASI=1", "--config", "./node_modules/@assemblyscript/wasi-shim/asconfig.json");
242
+ const wasiShim = resolveWasiShim();
243
+ if (!wasiShim) {
244
+ throw new Error('WASI target requires package "@assemblyscript/wasi-shim"');
245
+ }
246
+ buildArgs.push("--use", "AS_TEST_WASI=1", "--config", wasiShim.configPath);
237
247
  }
238
248
  else {
239
249
  console.log(`${chalk.bgRed(" ERROR ")}${chalk.dim(":")} could not determine target in config! Set target to 'bindings' or 'wasi'`);
@@ -263,6 +273,28 @@ function resolveCoverageEnabled(rawCoverage, override) {
263
273
  return true;
264
274
  }
265
275
  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")));
276
+ return resolveProjectModule("try-as/package.json") != null;
277
+ }
278
+ function resolveWasiShim() {
279
+ const resolved = resolveProjectModule("@assemblyscript/wasi-shim/asconfig.json");
280
+ if (!resolved)
281
+ return null;
282
+ if (!existsSync(resolved))
283
+ return null;
284
+ const relative = path.relative(process.cwd(), resolved).replace(/\\/g, "/");
285
+ return {
286
+ configPath: normalizeCliPath(relative),
287
+ };
288
+ }
289
+ function quoteCliArg(value) {
290
+ if (!/[\s"]/g.test(value))
291
+ return value;
292
+ return `"${value.replace(/"/g, '\\"')}"`;
293
+ }
294
+ function normalizeCliPath(value) {
295
+ if (!value.length)
296
+ return ".";
297
+ if (value.startsWith(".") || value.startsWith("/"))
298
+ return value;
299
+ return "./" + value;
268
300
  }
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.1",
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",