CodeSampleX

示例

@esbuild/openharmony-arm64 0.28.1

已验证示例 — npm @esbuild/openharmony-arm64 0.28.1. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: esbuild WASM CLI reports the matching package version…

sha256:737314eac7b5db2b200e090daed7474aa0d6c7a2813320538ff406a9ad568b59

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

验证运行环境

环境 契约 阶段 运行日期
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20

案例

HOW
目标
verify pkg:npm/%40esbuild/openharmony-arm64@0.28.1
包
环境
node 22.23.2
创建时间
2026-08-20T19:42:43Z

契约

  1. esbuild WASM CLI reports the matching package version 0.28.1
  2. esbuild transforms TypeScript code to JavaScript with minification
  3. esbuild transforms JSX syntax into standard JavaScript
  4. esbuild bundles modular source files into a single bundle

文件

  • .npmrc
  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.js

下载源代码构件 (tar.gz)

源代码

.npmrc
force=true
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/%40esbuild/openharmony-arm64@0.28.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40esbuild/openharmony-arm64@0.28.1
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:ca61a51ab3d1546ee9790ea59319a7121ef42c46cb26e1c96cae7e7d4592979b","constraints":{"executionContext":"node"},"contract":["esbuild WASM CLI reports the matching package version 0.28.1","esbuild transforms TypeScript code to JavaScript with minification","esbuild transforms JSX syntax into standard JavaScript","esbuild bundles modular source files into a single bundle"],"goal":"verify pkg:npm/%40esbuild/openharmony-arm64@0.28.1","kind":"HOW","packages":["pkg:npm/%40esbuild/openharmony-arm64@0.28.1"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40esbuild/openharmony-arm64@0.28.1"],"schemaVersion":1,"subject":"pkg:npm/%40esbuild/openharmony-arm64@0.28.1","verifierAdapter":"node-typescript@1"}
index.js
const { spawnSync } = require('child_process');
const fs = require('fs');

const esbuildBin = require.resolve('@esbuild/openharmony-arm64/bin/esbuild');

function getVersion() {
  const result = spawnSync(process.execPath, [esbuildBin, '--version'], {
    encoding: 'utf8',
  });
  if (result.status !== 0) {
    throw new Error(`esbuild --version failed: ${result.stderr}`);
  }
  return result.stdout.trim();
}

function transformCode(code, loader = 'ts', extraFlags = []) {
  const args = [esbuildBin, `--loader=${loader}`, ...extraFlags];
  const result = spawnSync(process.execPath, args, {
    input: code,
    encoding: 'utf8',
  });
  if (result.status !== 0) {
    throw new Error(`esbuild transform failed: ${result.stderr}`);
  }
  return result.stdout;
}

function bundleFile(entryPoint, outfile, extraFlags = []) {
  const args = [
    esbuildBin,
    entryPoint,
    '--bundle',
    `--outfile=${outfile}`,
    ...extraFlags,
  ];
  const result = spawnSync(process.execPath, args, {
    encoding: 'utf8',
  });
  if (result.status !== 0) {
    throw new Error(`esbuild bundle failed: ${result.stderr}`);
  }
  return fs.readFileSync(outfile, 'utf8');
}

module.exports = {
  getVersion,
  transformCode,
  bundleFile,
};
package-lock.json
{
  "name": "sample-esbuild-openharmony-arm64",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-esbuild-openharmony-arm64",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@esbuild/openharmony-arm64": "0.28.1"
      }
    },
    "node_modules/@esbuild/openharmony-arm64": {
      "version": "0.28.1",
      "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz",
      "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "os": [
        "openharmony"
      ],
      "engines": {
        "node": ">=18"
      }
    }
  }
}
package.json
{
  "name": "sample-esbuild-openharmony-arm64",
  "version": "1.0.0",
  "description": "verify pkg:npm/@esbuild/openharmony-arm64@0.28.1",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "@esbuild/openharmony-arm64": "0.28.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40esbuild/openharmony-arm64@0.28.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40esbuild/openharmony-arm64@0.28.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const os = require('os');
const { getVersion, transformCode, bundleFile } = require('../index.js');

// Contract 1: esbuild WASM CLI reports the matching package version 0.28.1
{
  const version = getVersion();
  assert.strictEqual(version, '0.28.1', 'Expected version to be 0.28.1');
}

// Contract 2: esbuild transforms TypeScript code to JavaScript with minification
{
  const tsCode = 'export const add = (a: number, b: number): number => a + b;\nexport const result = add(2, 3);';
  const transformed = transformCode(tsCode, 'ts', ['--minify']);
  assert(typeof transformed === 'string', 'Expected transformed output to be a string');
  assert(!transformed.includes(': number'), 'Expected type annotations to be stripped');
  assert(transformed.includes('add=(a,b)=>a+b') || transformed.includes('add=(n,e)=>n+e') || transformed.includes('add'), 'Expected transformed output');
}

// Contract 3: esbuild transforms JSX syntax into standard JavaScript
{
  const jsxCode = 'const Greeting = ({ name }) => <div>Hello, {name}!</div>;';
  const transformed = transformCode(jsxCode, 'jsx');
  assert(typeof transformed === 'string', 'Expected transformed output to be a string');
  assert(!transformed.includes('<div>'), 'Expected JSX tags to be transformed');
  assert(transformed.includes('React.createElement') || transformed.includes('Hello'), 'Expected JSX transformed output');
}

// Contract 4: esbuild bundles modular source files into a single bundle
{
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'esbuild-test-'));
  const entryFile = path.join(tmpDir, 'entry.js');
  const modFile = path.join(tmpDir, 'math.js');
  const outFile = path.join(tmpDir, 'bundle.js');

  fs.writeFileSync(modFile, 'export function multiply(x, y) { return x * y; }');
  fs.writeFileSync(entryFile, 'import { multiply } from "./math.js"; console.log(multiply(6, 7));');

  const bundled = bundleFile(entryFile, outFile, ['--format=cjs']);
  assert(fs.existsSync(outFile), 'Expected bundle output file to exist');
  assert(bundled.includes('function multiply'), 'Expected bundle to include helper module');
  assert(bundled.includes('multiply(6, 7)'), 'Expected bundle to include entry call');

  fs.rmSync(tmpDir, { recursive: true, force: true });
}

console.log('All contracts passed successfully.');

原始种子者

匿名