@genex-ai/cli-demo 1.36.18-dev.1071 → 1.36.19-dev.1075

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.
Files changed (2) hide show
  1. package/dist/index.js +105 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -29935,6 +29935,14 @@ var INPUT_MIN = 64 * 1024;
29935
29935
  var INPUT_MAX = 1024 * 1024;
29936
29936
  var S_IFMT2 = 61440;
29937
29937
  var S_IFLNK = 40960;
29938
+ var S_IFREG2 = 32768;
29939
+ var EXECUTE_BITS = 73;
29940
+ var PROGRAM_MODE = 33261;
29941
+ var FILE_MODE2 = 33188;
29942
+ var FOLDER_MODE = 16877;
29943
+ var PROGRAM_HEAD_BYTES = 4;
29944
+ var PROGRAM_MAGICS = /* @__PURE__ */ new Set([2135247942, 4277009102, 4277009103, 3472551422, 3489328638, 3405691582, 3199925962]);
29945
+ var SHEBANG = "#!";
29938
29946
  var isDirectory = (entry) => entry.name.endsWith("/");
29939
29947
  var isSymlink = (entry) => entry.mode !== null && (entry.mode & S_IFMT2) === S_IFLNK;
29940
29948
  async function readAt2(file, position, length) {
@@ -29988,6 +29996,28 @@ function applyZip64(extra, entry, overflowed) {
29988
29996
  at += 4 + length;
29989
29997
  }
29990
29998
  }
29999
+ function entryAt(data, at) {
30000
+ if (data.readUInt32LE(at) !== CENTRAL_SIGNATURE2) throw new Error("broken zip directory entry");
30001
+ const madeBy = data.readUInt16LE(at + 4);
30002
+ const nameLength = data.readUInt16LE(at + 28);
30003
+ const extraLength = data.readUInt16LE(at + 30);
30004
+ const commentLength = data.readUInt16LE(at + 32);
30005
+ const external = data.readUInt32LE(at + 38);
30006
+ const entry = {
30007
+ name: data.toString("utf8", at + 46, at + 46 + nameLength),
30008
+ method: data.readUInt16LE(at + 10),
30009
+ compressedSize: data.readUInt32LE(at + 20),
30010
+ uncompressedSize: data.readUInt32LE(at + 24),
30011
+ localOffset: data.readUInt32LE(at + 42),
30012
+ mode: madeBy >> 8 === UNIX_HOST2 ? external >>> 16 : null
30013
+ };
30014
+ applyZip64(data.subarray(at + 46 + nameLength, at + 46 + nameLength + extraLength), entry, {
30015
+ uncompressed: entry.uncompressedSize === U32_MAX,
30016
+ compressed: entry.compressedSize === U32_MAX,
30017
+ offset: entry.localOffset === U32_MAX
30018
+ });
30019
+ return { entry, madeBy, external, next: at + 46 + nameLength + extraLength + commentLength };
30020
+ }
29991
30021
  async function readZipEntries(filePath) {
29992
30022
  const file = await fs46.open(filePath, "r");
29993
30023
  try {
@@ -29997,27 +30027,9 @@ async function readZipEntries(filePath) {
29997
30027
  const entries = [];
29998
30028
  let at = 0;
29999
30029
  while (entries.length < directory.count && at + 46 <= data.length) {
30000
- if (data.readUInt32LE(at) !== CENTRAL_SIGNATURE2) throw new Error("broken zip directory entry");
30001
- const madeBy = data.readUInt16LE(at + 4);
30002
- const nameLength = data.readUInt16LE(at + 28);
30003
- const extraLength = data.readUInt16LE(at + 30);
30004
- const commentLength = data.readUInt16LE(at + 32);
30005
- const external = data.readUInt32LE(at + 38);
30006
- const entry = {
30007
- name: data.toString("utf8", at + 46, at + 46 + nameLength),
30008
- method: data.readUInt16LE(at + 10),
30009
- compressedSize: data.readUInt32LE(at + 20),
30010
- uncompressedSize: data.readUInt32LE(at + 24),
30011
- localOffset: data.readUInt32LE(at + 42),
30012
- mode: madeBy >> 8 === UNIX_HOST2 ? external >>> 16 : null
30013
- };
30014
- applyZip64(data.subarray(at + 46 + nameLength, at + 46 + nameLength + extraLength), entry, {
30015
- uncompressed: entry.uncompressedSize === U32_MAX,
30016
- compressed: entry.compressedSize === U32_MAX,
30017
- offset: entry.localOffset === U32_MAX
30018
- });
30019
- entries.push(entry);
30020
- at += 46 + nameLength + extraLength + commentLength;
30030
+ const record = entryAt(data, at);
30031
+ entries.push(record.entry);
30032
+ at = record.next;
30021
30033
  }
30022
30034
  if (entries.length !== directory.count) throw new Error("zip directory ends early");
30023
30035
  return entries;
@@ -30028,13 +30040,58 @@ async function readZipEntries(filePath) {
30028
30040
  async function readZipEntryHead(filePath, entry, maxBytes) {
30029
30041
  const file = await fs46.open(filePath, "r");
30030
30042
  try {
30031
- const local = await readAt2(file, entry.localOffset, 30);
30032
- if (local.length < 30 || local.readUInt32LE(0) !== LOCAL_SIGNATURE2) throw new Error(`broken zip entry ${entry.name}`);
30033
- const start = entry.localOffset + 30 + local.readUInt16LE(26) + local.readUInt16LE(28);
30034
- if (entry.method === 0) return await readAt2(file, start, Math.min(maxBytes, entry.uncompressedSize));
30035
- if (entry.method !== 8) throw new Error(`${entry.name} uses a compression this command cannot read`);
30036
- const input = await readAt2(file, start, Math.min(entry.compressedSize, INPUT_MAX, Math.max(maxBytes, INPUT_MIN)));
30037
- return await inflateHead(input, maxBytes);
30043
+ return await entryHead(file, entry, maxBytes);
30044
+ } finally {
30045
+ await file.close();
30046
+ }
30047
+ }
30048
+ async function entryHead(file, entry, maxBytes) {
30049
+ const local = await readAt2(file, entry.localOffset, 30);
30050
+ if (local.length < 30 || local.readUInt32LE(0) !== LOCAL_SIGNATURE2) throw new Error(`broken zip entry ${entry.name}`);
30051
+ const start = entry.localOffset + 30 + local.readUInt16LE(26) + local.readUInt16LE(28);
30052
+ if (entry.method === 0) return await readAt2(file, start, Math.min(maxBytes, entry.uncompressedSize));
30053
+ if (entry.method !== 8) throw new Error(`${entry.name} uses a compression this command cannot read`);
30054
+ const input = await readAt2(file, start, Math.min(entry.compressedSize, INPUT_MAX, Math.max(maxBytes, INPUT_MIN)));
30055
+ return await inflateHead(input, maxBytes);
30056
+ }
30057
+ function isProgramHead(head) {
30058
+ if (head.toString("latin1", 0, SHEBANG.length) === SHEBANG) return true;
30059
+ return head.length >= PROGRAM_HEAD_BYTES && PROGRAM_MAGICS.has(head.readUInt32BE(0));
30060
+ }
30061
+ function wantedMode(mode, directory, program) {
30062
+ if (directory) return mode ?? FOLDER_MODE;
30063
+ if (mode === null) return program ? PROGRAM_MODE : FILE_MODE2;
30064
+ const type = mode & S_IFMT2;
30065
+ const regular = type === S_IFREG2 || type === 0;
30066
+ if (!program || !regular) return mode;
30067
+ return (mode | S_IFREG2 | EXECUTE_BITS) >>> 0;
30068
+ }
30069
+ async function markPrograms(filePath) {
30070
+ const file = await fs46.open(filePath, "r+");
30071
+ try {
30072
+ const { size } = await file.stat();
30073
+ const directory = await findDirectory2(file, size);
30074
+ const data = await readAt2(file, directory.offset, directory.bytes);
30075
+ let marked = 0;
30076
+ let changed = false;
30077
+ let at = 0;
30078
+ for (let read = 0; read < directory.count && at + 46 <= data.length; read++) {
30079
+ const { entry, madeBy, external, next } = entryAt(data, at);
30080
+ const here = at;
30081
+ at = next;
30082
+ if (isSymlink(entry)) continue;
30083
+ const folder = isDirectory(entry);
30084
+ const head = folder ? Buffer.alloc(0) : await entryHead(file, entry, PROGRAM_HEAD_BYTES).catch(() => Buffer.alloc(0));
30085
+ const program = isProgramHead(head);
30086
+ const mode = wantedMode(entry.mode, folder, program);
30087
+ if (mode === entry.mode) continue;
30088
+ if (program) marked++;
30089
+ data.writeUInt16LE(UNIX_HOST2 << 8 | madeBy & 255, here + 4);
30090
+ data.writeUInt32LE((mode << 16 | external & 65535) >>> 0, here + 38);
30091
+ changed = true;
30092
+ }
30093
+ if (changed) await file.write(data, 0, data.length, directory.offset);
30094
+ return marked;
30038
30095
  } finally {
30039
30096
  await file.close();
30040
30097
  }
@@ -30266,7 +30323,22 @@ async function packTarget(dir) {
30266
30323
  if (apps.length === 1) return { target: path49.join(dir, apps[0].name), keepParent: true };
30267
30324
  return { target: dir, keepParent: false };
30268
30325
  }
30269
- async function packNativeBuild(input) {
30326
+ var windowsTar = () => path49.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe");
30327
+ async function zipFolder(target, keepParent, zipPath, opts) {
30328
+ const platform = opts.platform ?? process.platform;
30329
+ if (platform === "darwin") {
30330
+ await run4("ditto", ["-c", "-k", "--sequesterRsrc", ...keepParent ? ["--keepParent"] : [], target, zipPath]);
30331
+ return;
30332
+ }
30333
+ const cwd = keepParent ? path49.dirname(target) : target;
30334
+ if (platform === "win32") {
30335
+ const names2 = keepParent ? [path49.basename(target)] : await fs47.readdir(target);
30336
+ await run4(opts.tar ?? windowsTar(), ["-a", "-c", "-f", zipPath, ...names2], { cwd });
30337
+ return;
30338
+ }
30339
+ await run4("zip", ["-q", "-r", "-y", zipPath, keepParent ? path49.basename(target) : "."], { cwd });
30340
+ }
30341
+ async function packNativeBuild(input, opts = {}) {
30270
30342
  const stat = await fs47.stat(input).catch(() => null);
30271
30343
  if (!stat) throw new NativeBuildError(`${input} does not exist.`);
30272
30344
  if (stat.isFile()) {
@@ -30279,18 +30351,14 @@ async function packNativeBuild(input) {
30279
30351
  const zipPath = path49.join(dir, `${path49.basename(target).replace(/[^A-Za-z0-9._-]+/g, "-") || "build"}.zip`);
30280
30352
  const cleanup = () => fs47.rm(dir, { recursive: true, force: true });
30281
30353
  try {
30282
- if (process.platform === "darwin") {
30283
- await run4("ditto", ["-c", "-k", "--sequesterRsrc", ...keepParent ? ["--keepParent"] : [], target, zipPath]);
30284
- } else if (keepParent) {
30285
- await run4("zip", ["-q", "-r", "-y", zipPath, path49.basename(target)], { cwd: path49.dirname(target) });
30286
- } else {
30287
- await run4("zip", ["-q", "-r", "-y", zipPath, "."], { cwd: target });
30288
- }
30354
+ await zipFolder(target, keepParent, zipPath, opts);
30355
+ await markPrograms(zipPath);
30289
30356
  } catch (err) {
30290
30357
  await cleanup();
30291
30358
  const missing = err.code === "ENOENT";
30359
+ const zipper = (opts.platform ?? process.platform) === "win32" ? "tar.exe" : "zip";
30292
30360
  throw new NativeBuildError(
30293
- missing ? "Couldn't zip the build: no `zip` on this machine. Zip it yourself (keeping links) and pass the .zip." : `Couldn't zip the build: ${err.message}`
30361
+ missing ? `Couldn't zip the build: no \`${zipper}\` on this machine. Zip it yourself (keeping links) and pass the .zip.` : `Couldn't zip the build: ${err.message}`
30294
30362
  );
30295
30363
  }
30296
30364
  return { zipPath, cleanup };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genex-ai/cli-demo",
3
- "version": "1.36.18-dev.1071",
3
+ "version": "1.36.19-dev.1075",
4
4
  "description": "Set up your project's agent workspace (.claude/.codex/.cursor in the game folder), authorize, create a game project, generate AI assets, and publish (genex CLI).",
5
5
  "type": "module",
6
6
  "bin": {