@arcadia-eternity/content-sdk 4.4.1 → 4.4.2

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.
@@ -4,7 +4,7 @@ import { mkdir, mkdtemp, readFile, rm, writeFile, cp, symlink } from 'node:fs/pr
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join, resolve, dirname } from 'node:path';
6
6
  import { promisify } from 'node:util';
7
- import { emptyNpmContentHost, prepareNpmProject, resolveNpmInvocation } from '@arcadia-eternity/pack-loader/node';
7
+ import { emptyNpmContentHost, parseNpmPackOutput, prepareNpmProject, resolveNpmInvocation, } from '@arcadia-eternity/pack-loader/node';
8
8
  import { AuthorWorkspace } from './workspace.js';
9
9
  import { ProjectTeams, playersFromTeams } from './project-teams.js';
10
10
  import { createHash } from 'node:crypto';
@@ -13,6 +13,11 @@ import { assertEnvironmentRequirements, validateEnvironmentRules } from './envir
13
13
  import { siblingModulePath } from './module-path.js';
14
14
  import { errorCode } from './types.js';
15
15
  const exec = promisify(execFile);
16
+ function requirePackedInfo(entry) {
17
+ if (!entry?.shasum)
18
+ throw new Error('ENVIRONMENT_PACK_INVALID');
19
+ return { ...entry, shasum: entry.shasum };
20
+ }
16
21
  async function npm(args, options) {
17
22
  const invocation = await resolveNpmInvocation(args);
18
23
  return exec(invocation.file, invocation.args, options);
@@ -64,7 +69,7 @@ export async function prepareBattleEnvironment(root = process.cwd(), { offline =
64
69
  const result = await npm(['pack', '--json', '--ignore-scripts', '--pack-destination', temporary, ...cacheArgs], {
65
70
  cwd: root,
66
71
  });
67
- const packed = JSON.parse(String(result.stdout))[0];
72
+ const packed = requirePackedInfo(parseNpmPackOutput(String(result.stdout))[0]);
68
73
  const files = packed.files.map(file => file.path);
69
74
  assert.ok(files.includes(manifest.arcadia.content));
70
75
  if (manifest.arcadia.effects)
@@ -104,7 +109,7 @@ export async function prepareBattleEnvironment(root = process.cwd(), { offline =
104
109
  if (metadata.name !== name)
105
110
  throw new Error(`ENVIRONMENT_SOURCE_IDENTITY: ${name}`);
106
111
  await exec(process.execPath, [siblingModulePath('cli'), 'build'], { cwd: captured });
107
- const info = JSON.parse(String((await npm(['pack', '--json', '--ignore-scripts', ...cacheArgs], { cwd: captured })).stdout))[0];
112
+ const info = requirePackedInfo(parseNpmPackOutput(String((await npm(['pack', '--json', '--ignore-scripts', ...cacheArgs], { cwd: captured })).stdout))[0]);
108
113
  if (info.files.some(file => /^(?:debug|test|scripts|node_modules|\.arcadia|\.github)\//.test(file.path)))
109
114
  throw new Error('ENVIRONMENT_PACKAGE_FILES');
110
115
  await addCandidate(captured, metadata, info);
@@ -3,11 +3,4 @@
3
3
  */
4
4
  export declare function packBuiltProject(directory?: string, { cache }?: {
5
5
  cache?: string;
6
- }): Promise<{
7
- filename: string;
8
- files: Array<{
9
- path: string;
10
- }>;
11
- integrity?: string;
12
- shasum?: string;
13
- }>;
6
+ }): Promise<import("@arcadia-eternity/pack-loader/node").NpmPackEntry>;
@@ -3,7 +3,7 @@ import { statSync } from 'node:fs';
3
3
  import { copyFile, lstat, mkdir, mkdtemp, readFile, realpath, rename, rm, writeFile } from 'node:fs/promises';
4
4
  import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';
5
5
  import { promisify } from 'node:util';
6
- import { compileEffectModule, resolveNpmInvocation } from '@arcadia-eternity/pack-loader/node';
6
+ import { compileEffectModule, parseNpmPackOutput, resolveNpmInvocation } from '@arcadia-eternity/pack-loader/node';
7
7
  import { errorCode } from './types.js';
8
8
  const exec = promisify(execFile);
9
9
  const artifactFile = 'dist/arcadia-effects.json';
@@ -66,8 +66,8 @@ export async function packBuiltProject(directory = process.cwd(), { cache } = {}
66
66
  const root = await realpath(resolve(directory));
67
67
  const manifestText = await readFile(join(root, 'package.json'), 'utf8');
68
68
  const manifest = JSON.parse(manifestText);
69
- const preview = JSON.parse(String((await npm(root, ['pack', '--dry-run', '--ignore-scripts', '--json'], cache)).stdout))[0];
70
- if (!Array.isArray(preview?.files) || preview.files.length > 50000)
69
+ const preview = parseNpmPackOutput(String((await npm(root, ['pack', '--dry-run', '--ignore-scripts', '--json'], cache)).stdout))[0];
70
+ if (!preview || preview.files.length > 50000)
71
71
  fail('npm returned an invalid package file list');
72
72
  const included = new Set(preview.files.map((file) => packagePath(file.path)));
73
73
  if (!included.has('package.json'))
@@ -154,8 +154,8 @@ export async function packBuiltProject(directory = process.cwd(), { cache } = {}
154
154
  }
155
155
  staged.files = [...distributed];
156
156
  await writeFile(join(payload, 'package.json'), JSON.stringify(staged, null, 2) + '\n');
157
- const packed = JSON.parse(String((await npm(payload, ['pack', '--ignore-scripts', '--json', '--pack-destination', output], cache)).stdout))[0];
158
- if (!packed || typeof packed.filename !== 'string' || !Array.isArray(packed.files))
157
+ const packed = parseNpmPackOutput(String((await npm(payload, ['pack', '--ignore-scripts', '--json', '--pack-destination', output], cache)).stdout))[0];
158
+ if (!packed)
159
159
  fail('npm returned an invalid package receipt');
160
160
  packagePath(packed.filename);
161
161
  if (basename(packed.filename) !== packed.filename)
@@ -21,7 +21,7 @@
21
21
  "devDependencies": {
22
22
  "@types/node": "26.6.6",
23
23
  "typescript": "6.0.3",
24
- "@arcadia-eternity/content-sdk": "4.4.1"
24
+ "@arcadia-eternity/content-sdk": "4.4.2"
25
25
  },
26
26
  "arcadia": {
27
27
  "formatVersion": 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcadia-eternity/content-sdk",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -53,9 +53,9 @@
53
53
  "yaml": "2.9.1",
54
54
  "yauzl": "3.4.0",
55
55
  "zod": "4.6.7",
56
- "@arcadia-eternity/pack-loader": "4.4.1",
57
- "@arcadia-eternity/battle": "4.4.1",
58
- "@arcadia-eternity/schema": "4.4.1"
56
+ "@arcadia-eternity/battle": "4.4.2",
57
+ "@arcadia-eternity/pack-loader": "4.4.2",
58
+ "@arcadia-eternity/schema": "4.4.2"
59
59
  },
60
60
  "repository": {
61
61
  "type": "git",