@treeseed/sdk 0.5.1 → 0.5.3

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.
@@ -1543,12 +1543,22 @@ function ensureTreeseedActVerificationTooling({ tenantRoot = process.cwd(), inst
1543
1543
  attemptedInstall: false,
1544
1544
  installedDuringConfig: false
1545
1545
  });
1546
- const wranglerCheck = checkCommand(process.execPath, [resolveWranglerBin(), "--version"], { cwd: tenantRoot, env });
1547
- const wranglerCli = toolStatus(
1548
- "wranglerCli",
1549
- wranglerCheck.ok,
1550
- wranglerCheck.ok ? wranglerCheck.stdout.split("\n")[0] ?? "Wrangler CLI detected." : wranglerCheck.detail || "Wrangler CLI is unavailable."
1551
- );
1546
+ const wranglerCli = (() => {
1547
+ try {
1548
+ const wranglerCheck = checkCommand(process.execPath, [resolveWranglerBin(), "--version"], { cwd: tenantRoot, env });
1549
+ return toolStatus(
1550
+ "wranglerCli",
1551
+ wranglerCheck.ok,
1552
+ wranglerCheck.ok ? wranglerCheck.stdout.split("\n")[0] ?? "Wrangler CLI detected." : wranglerCheck.detail || "Wrangler CLI is unavailable."
1553
+ );
1554
+ } catch (error) {
1555
+ return toolStatus(
1556
+ "wranglerCli",
1557
+ false,
1558
+ error instanceof Error && error.message ? error.message : "Wrangler CLI is unavailable."
1559
+ );
1560
+ }
1561
+ })();
1552
1562
  const railwayCheck = checkCommand("railway", ["--version"], { cwd: tenantRoot, env });
1553
1563
  const railwayCli = toolStatus(
1554
1564
  "railwayCli",
@@ -1,18 +1,18 @@
1
- import { existsSync, readFileSync, readdirSync } from 'node:fs';
1
+ import { existsSync, mkdtempSync, readFileSync, readdirSync } from 'node:fs';
2
2
  import { basename, extname, join, resolve } from 'node:path';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { spawnSync } from 'node:child_process';
5
5
  import { packageRoot } from './package-tools.js';
6
- const npmCacheDir = resolve(tmpdir(), 'treeseed-npm-cache');
6
+ const npmCacheDir = mkdtempSync(join(tmpdir(), 'treeseed-sdk-npm-cache-'));
7
7
  const textExtensions = new Set(['.js', '.ts', '.mjs', '.cjs', '.d.js', '.json', '.md']);
8
8
  const forbiddenPatterns = [
9
9
  /['"`]workspace:[^'"`\n]+['"`]/,
10
10
  /['"`](?:\.\.\/|\.\/)[^'"`\n]*src\/[^'"`\n]*\.(?:[cm]?js|ts|tsx|json|astro|css)['"`]/,
11
11
  /['"`][^'"`\n]*\/packages\/[^'"`\n]*\/src\/[^'"`\n]*['"`]/,
12
12
  ];
13
- function run(command, args) {
13
+ function run(command, args, cwd = packageRoot) {
14
14
  const result = spawnSync(command, args, {
15
- cwd: packageRoot,
15
+ cwd,
16
16
  stdio: 'inherit',
17
17
  env: {
18
18
  ...process.env,
@@ -24,6 +24,32 @@ function run(command, args) {
24
24
  process.exit(result.status ?? 1);
25
25
  }
26
26
  }
27
+ function assertNoLocalDependencyLinks() {
28
+ const packageJson = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'));
29
+ for (const sectionName of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
30
+ for (const [dependencyName, version] of Object.entries(packageJson[sectionName] ?? {})) {
31
+ if (version.startsWith('workspace:') || version.startsWith('file:')) {
32
+ throw new Error(`package.json ${sectionName}.${dependencyName} must not use local dependency specifiers: ${version}`);
33
+ }
34
+ }
35
+ }
36
+ const lockfile = JSON.parse(readFileSync(resolve(packageRoot, 'package-lock.json'), 'utf8'));
37
+ for (const [entryKey, entryValue] of Object.entries(lockfile.packages ?? {})) {
38
+ if (entryKey.startsWith('../') || entryKey.includes('/../')) {
39
+ throw new Error(`package-lock.json contains forbidden local package entry: ${entryKey}`);
40
+ }
41
+ if (entryValue.link) {
42
+ throw new Error(`package-lock.json contains forbidden linked dependency entry: ${entryKey}`);
43
+ }
44
+ const resolved = entryValue.resolved ?? '';
45
+ if (resolved.startsWith('../')
46
+ || resolved.startsWith('./')
47
+ || resolved.startsWith('file:')
48
+ || resolved.startsWith('workspace:')) {
49
+ throw new Error(`package-lock.json contains forbidden local resolution for ${entryKey}: ${resolved}`);
50
+ }
51
+ }
52
+ }
27
53
  function walkFiles(root) {
28
54
  const files = [];
29
55
  for (const entry of readdirSync(root, { withFileTypes: true })) {
@@ -71,6 +97,7 @@ function assertCleanDistArtifacts() {
71
97
  }
72
98
  }
73
99
  }
100
+ assertNoLocalDependencyLinks();
74
101
  run('npm', ['run', 'lint']);
75
102
  scanDirectory(resolve(packageRoot, 'dist'));
76
103
  assertCleanDistArtifacts();
@@ -10,8 +10,12 @@ const packageRoot = resolve(scriptRoot, '..');
10
10
  const sourceRunner = resolve(packageRoot, 'scripts', 'run-ts.mjs');
11
11
  const sourceEntry = resolve(packageRoot, 'src', 'verification.ts');
12
12
  const publishedEntry = resolve(packageRoot, 'dist', 'verification.js');
13
+ const entrypointCheckOnly = process.env.TREESEED_VERIFY_ENTRYPOINT_CHECK === 'true';
13
14
 
14
15
  if (existsSync(sourceRunner) && existsSync(sourceEntry)) {
16
+ if (entrypointCheckOnly) {
17
+ process.exit(0);
18
+ }
15
19
  const result = spawnSync(process.execPath, [sourceRunner, sourceEntry], {
16
20
  cwd: process.cwd(),
17
21
  env: process.env,
@@ -21,6 +25,9 @@ if (existsSync(sourceRunner) && existsSync(sourceEntry)) {
21
25
  }
22
26
 
23
27
  if (existsSync(publishedEntry)) {
28
+ if (entrypointCheckOnly) {
29
+ process.exit(0);
30
+ }
24
31
  const { runTreeseedVerifyDriver } = await import('../dist/verification.js');
25
32
  process.exit(runTreeseedVerifyDriver({ packageRoot: process.cwd() }));
26
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -42,8 +42,8 @@
42
42
  "fixtures:check": "node ./scripts/run-ts.mjs ./scripts/fixture-tools.ts check",
43
43
  "lint": "npm run fixtures:check && npm run build:dist",
44
44
  "verify:direct": "npm run release:verify",
45
- "verify:local": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='direct'; await import('@treeseed/sdk/scripts/verify-driver')\"",
46
- "verify:action": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='act'; await import('@treeseed/sdk/scripts/verify-driver')\"",
45
+ "verify:local": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='direct'; await import('./scripts/verify-driver.mjs')\"",
46
+ "verify:action": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='act'; await import('./scripts/verify-driver.mjs')\"",
47
47
  "verify": "node ./scripts/verify-driver.mjs",
48
48
  "release:setup": "npm run setup:ci",
49
49
  "release:check-tag": "node ./scripts/run-ts.mjs ./scripts/assert-release-tag-version.ts",
@@ -10,8 +10,12 @@ const packageRoot = resolve(scriptRoot, '..');
10
10
  const sourceRunner = resolve(packageRoot, 'scripts', 'run-ts.mjs');
11
11
  const sourceEntry = resolve(packageRoot, 'src', 'verification.ts');
12
12
  const publishedEntry = resolve(packageRoot, 'dist', 'verification.js');
13
+ const entrypointCheckOnly = process.env.TREESEED_VERIFY_ENTRYPOINT_CHECK === 'true';
13
14
 
14
15
  if (existsSync(sourceRunner) && existsSync(sourceEntry)) {
16
+ if (entrypointCheckOnly) {
17
+ process.exit(0);
18
+ }
15
19
  const result = spawnSync(process.execPath, [sourceRunner, sourceEntry], {
16
20
  cwd: process.cwd(),
17
21
  env: process.env,
@@ -21,6 +25,9 @@ if (existsSync(sourceRunner) && existsSync(sourceEntry)) {
21
25
  }
22
26
 
23
27
  if (existsSync(publishedEntry)) {
28
+ if (entrypointCheckOnly) {
29
+ process.exit(0);
30
+ }
24
31
  const { runTreeseedVerifyDriver } = await import('../dist/verification.js');
25
32
  process.exit(runTreeseedVerifyDriver({ packageRoot: process.cwd() }));
26
33
  }