get-codex-lost-world 1.0.4 → 1.0.6

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.
@@ -9,11 +9,9 @@ function printTargetShortcuts() {
9
9
  'Target shortcuts:',
10
10
  ' --mac-silicon Build/download for Apple Silicon Mac (default source: original Codex.dmg on macOS arm64 host)',
11
11
  ' --mac-intel Build/download for Intel Mac (.dmg)',
12
- ' --windows-x64 Build/download for Windows x64 (.zip)',
13
- ' --windows-arm64 Build/download for Windows arm64 (.zip)',
14
12
  '',
15
13
  'Example:',
16
- ' npx get-codex-lost-world --windows-x64 --workdir /tmp/codex',
14
+ ' npx get-codex-lost-world -w ~/Downloads',
17
15
  ].join('\n');
18
16
 
19
17
  process.stdout.write(`${message}\n`);
@@ -23,8 +21,6 @@ function remapShortcutArgs(argv = []) {
23
21
  const targetShortcuts = {
24
22
  '--mac-silicon': ['--platform', 'mac', '--format', 'dmg'],
25
23
  '--mac-intel': ['--platform', 'mac', '--arch', 'x64', '--format', 'dmg'],
26
- '--windows-x64': ['--platform', 'windows', '--arch', 'x64', '--format', 'zip'],
27
- '--windows-arm64': ['--platform', 'windows', '--arch', 'arm64', '--format', 'zip'],
28
24
  };
29
25
 
30
26
  const selectedShortcuts = argv.filter((arg) => Object.prototype.hasOwnProperty.call(targetShortcuts, arg));
@@ -59,4 +55,4 @@ main().catch((error) => {
59
55
  process.stderr.write(`${message}\n\n${usage()}\n`);
60
56
  process.stderr.write('Use --target-help to see target shortcuts.\n');
61
57
  process.exit(1);
62
- });
58
+ });
package/lib/ci/state.js CHANGED
@@ -1,15 +1,19 @@
1
1
  'use strict';
2
2
 
3
- function shouldBuild({ incomingLastModified, cachedLastModified, force }) {
3
+ function shouldBuild({ incomingLastModified, cachedLastModified, incomingNpmVersion, cachedNpmVersion, force }) {
4
4
  if (force === true) {
5
5
  return true;
6
6
  }
7
7
 
8
- if (incomingLastModified === cachedLastModified) {
9
- return false;
8
+ if (incomingLastModified !== cachedLastModified) {
9
+ return true;
10
+ }
11
+
12
+ if (incomingNpmVersion && incomingNpmVersion !== cachedNpmVersion) {
13
+ return true;
10
14
  }
11
15
 
12
- return true;
16
+ return false;
13
17
  }
14
18
 
15
19
  module.exports = {
@@ -11,16 +11,10 @@ function makeOutputName(version) {
11
11
  return `CodexIntelMac_${sanitizeVersion(version)}.dmg`;
12
12
  }
13
13
 
14
- function makeOutputNameForTarget({ version, platform, arch, format }) {
14
+ function makeOutputNameForTarget({ version, format }) {
15
15
  const safeVersion = sanitizeVersion(version);
16
- const normalizedPlatform = String(platform || '').trim().toLowerCase();
17
- const normalizedArch = String(arch || '').trim().toLowerCase();
18
16
  const normalizedFormat = String(format || '').trim().toLowerCase();
19
17
 
20
- if (normalizedPlatform === 'windows') {
21
- return `CodexWindows_${normalizedArch || 'x64'}_${safeVersion}.${normalizedFormat || 'zip'}`;
22
- }
23
-
24
18
  return `CodexIntelMac_${safeVersion}.${normalizedFormat || 'dmg'}`;
25
19
  }
26
20
 
@@ -237,8 +237,16 @@ function getDefaultDeps(overrides = {}) {
237
237
  if (!normalizedLocation || !normalizedName) {
238
238
  throw new Error('downloader.download requires location and filename');
239
239
  }
240
- fs.mkdirSync(normalizedLocation, { recursive: true });
240
+
241
241
  const outputPath = path.join(normalizedLocation, normalizedName);
242
+ if (fs.existsSync(outputPath)) {
243
+ const answer = await io.prompt(`File already exists: ${outputPath}\nOverwrite? (y/N)`, 'N');
244
+ if (!isAffirmative(answer)) {
245
+ throw new Error(`Download aborted: ${outputPath} already exists.`);
246
+ }
247
+ }
248
+
249
+ fs.mkdirSync(normalizedLocation, { recursive: true });
242
250
  return streamDownload(url, outputPath);
243
251
  },
244
252
  },
@@ -279,11 +287,7 @@ function getDefaultDownloadsLocation(env) {
279
287
  }
280
288
 
281
289
  function getDefaultBuildLocation(env) {
282
- if (env && typeof env.PWD === 'string' && env.PWD.trim() !== '') {
283
- return env.PWD.trim();
284
- }
285
-
286
- return process.cwd();
290
+ return getDefaultDownloadsLocation(env);
287
291
  }
288
292
 
289
293
  function usage() {
@@ -296,9 +300,9 @@ function usage() {
296
300
  ' -c, --cache Show latest release info and optionally download/sign it',
297
301
  ' -s, --sign <path> Ad-hoc sign a local app/dmg path',
298
302
  ' -w, --workdir <path> Build working directory (download source + write Intel DMG)',
299
- ' --platform <p> Target platform: mac | windows',
300
- ' --arch <a> Target arch: x64 | arm64 (windows)',
301
- ' --format <f> Target format: dmg | zip',
303
+ ' --platform <p> Target platform: mac',
304
+ ' --arch <a> Target arch: x64',
305
+ ' --format <f> Target format: dmg',
302
306
  '',
303
307
  'Other options:',
304
308
  ' -h, --help Show this help message',
@@ -311,32 +315,16 @@ function usage() {
311
315
  ].join('\n');
312
316
  }
313
317
 
314
- function mapHostArchToTargetArch(hostArch) {
315
- const normalized = String(hostArch || '').trim().toLowerCase();
316
- if (normalized === 'arm64') {
317
- return 'arm64';
318
- }
319
-
320
- return 'x64';
321
- }
322
-
323
- function resolveDefaultTargetInput(parsed, env) {
324
- const runtimePlatform = String((env && env.RUNTIME_PLATFORM) || process.platform || '').trim().toLowerCase();
325
- const runtimeArch = String((env && env.RUNTIME_ARCH) || process.arch || '').trim().toLowerCase();
326
-
327
- const inferredPlatform = runtimePlatform === 'win32' ? 'windows' : 'mac';
318
+ function resolveDefaultTargetInput(parsed, _env) {
328
319
  const selectedPlatform = typeof parsed.platform === 'string' && parsed.platform.trim() !== ''
329
320
  ? parsed.platform
330
- : inferredPlatform;
331
-
332
- const normalizedPlatform = String(selectedPlatform).trim().toLowerCase();
333
- const inferredArch = normalizedPlatform === 'windows' ? mapHostArchToTargetArch(runtimeArch) : 'x64';
321
+ : 'mac';
334
322
  const selectedArch = typeof parsed.arch === 'string' && parsed.arch.trim() !== ''
335
323
  ? parsed.arch
336
- : inferredArch;
324
+ : 'x64';
337
325
  const selectedFormat = typeof parsed.format === 'string' && parsed.format.trim() !== ''
338
326
  ? parsed.format
339
- : (normalizedPlatform === 'windows' ? 'zip' : 'dmg');
327
+ : 'dmg';
340
328
 
341
329
  return {
342
330
  platform: selectedPlatform,
@@ -385,15 +373,6 @@ async function runCacheMode(parsed, deps) {
385
373
  : (downloadResult && downloadResult.path) || fallbackPath;
386
374
  deps.io.log(`Download done: ${downloadedPath}`);
387
375
 
388
- if (target.platform === 'windows') {
389
- return {
390
- mode: 'cache',
391
- downloaded: true,
392
- signed: false,
393
- path: downloadedPath,
394
- target,
395
- };
396
- }
397
376
 
398
377
  const signAnswer = await deps.io.prompt('Sign downloaded file? (Y/n)', 'Y');
399
378
  let signed = false;
@@ -18,33 +18,15 @@ function pickLatestAssetForTarget(release, target = {}) {
18
18
  const assets = Array.isArray(release?.assets) ? release.assets : [];
19
19
  const platform = String(target.platform || 'mac').trim().toLowerCase();
20
20
  const arch = String(target.arch || 'x64').trim().toLowerCase();
21
- const format = String(target.format || (platform === 'windows' ? 'zip' : 'dmg')).trim().toLowerCase();
21
+ const format = String(target.format || 'dmg').trim().toLowerCase();
22
22
 
23
- const candidates = assets.filter((asset) => typeof asset?.name === 'string' && asset.name.toLowerCase().endsWith(`.${format}`));
23
+ const candidates = assets
24
+ .filter((asset) => typeof asset?.name === 'string' && asset.name.toLowerCase().endsWith(`.${format}`))
25
+ .sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at));
24
26
  if (candidates.length === 0) {
25
27
  throw new Error(`No .${format} asset found in release assets`);
26
28
  }
27
29
 
28
- if (platform === 'windows') {
29
- const strictMatch = candidates.find((asset) => {
30
- const name = asset.name.toLowerCase();
31
- return name.includes('windows') && name.includes(arch);
32
- });
33
-
34
- if (strictMatch) {
35
- ensureAssetUrl(strictMatch, `.${format}`);
36
- return strictMatch;
37
- }
38
-
39
- const archMatch = candidates.find((asset) => asset.name.toLowerCase().includes(arch));
40
- if (archMatch) {
41
- ensureAssetUrl(archMatch, `.${format}`);
42
- return archMatch;
43
- }
44
-
45
- throw new Error(`No .${format} asset found for windows/${arch}`);
46
- }
47
-
48
30
  const preferred = candidates.find((asset) => /^CodexIntelMac_.*\.dmg$/i.test(asset.name));
49
31
  const selected = preferred || candidates[0];
50
32
  ensureAssetUrl(selected, `.${format}`);
@@ -1,15 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const SUPPORTED_PLATFORMS = ['mac', 'windows'];
3
+ const SUPPORTED_PLATFORMS = ['mac'];
4
4
 
5
5
  const SUPPORTED_ARCHES_BY_PLATFORM = {
6
6
  mac: ['x64'],
7
- windows: ['x64', 'arm64'],
8
7
  };
9
8
 
10
9
  const SUPPORTED_FORMATS_BY_PLATFORM = {
11
10
  mac: ['dmg'],
12
- windows: ['zip'],
13
11
  };
14
12
 
15
13
  function normalizeValue(value) {
@@ -19,7 +17,7 @@ function normalizeValue(value) {
19
17
  function normalizeTarget(input = {}) {
20
18
  const platform = normalizeValue(input.platform) || 'mac';
21
19
  const arch = normalizeValue(input.arch) || 'x64';
22
- const format = normalizeValue(input.format) || (platform === 'windows' ? 'zip' : 'dmg');
20
+ const format = normalizeValue(input.format) || 'dmg';
23
21
  const target = { platform, arch, format };
24
22
  validateTarget(target);
25
23
  return target;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "get-codex-lost-world",
3
- "version": "1.0.4",
4
- "description": "CLI to download/build Codex Mac Intel DMG and Windows ZIP artifacts from upstream Codex.dmg.",
3
+ "version": "1.0.6",
4
+ "description": "CLI to download/build Codex Mac Intel DMG artifacts from upstream Codex.dmg.",
5
5
  "main": "lib/get-codex-lost-world/main.js",
6
6
  "bin": {
7
7
  "get-codex-lost-world": "bin/get-codex-lost-world.js"
@@ -17,9 +17,7 @@
17
17
  "codex",
18
18
  "intel",
19
19
  "build",
20
- "mac",
21
- "windows",
22
- "zip"
20
+ "mac"
23
21
  ],
24
22
  "author": "0x0a0d",
25
23
  "license": "ISC",
@@ -45,18 +45,22 @@ function appendGithubOutput(filePath, outputs) {
45
45
  function run(env = process.env) {
46
46
  const incomingLastModified = env.LAST_MODIFIED;
47
47
  const cachedLastModified = env.CACHED_LAST_MODIFIED;
48
+ const incomingNpmVersion = env.NPM_CODEX_VERSION;
49
+ const cachedNpmVersion = env.CACHED_NPM_CODEX_VERSION;
48
50
  const force = parseForce(env.FORCE);
49
51
 
50
52
  const build = shouldBuild({
51
53
  incomingLastModified,
52
54
  cachedLastModified,
55
+ incomingNpmVersion,
56
+ cachedNpmVersion,
53
57
  force,
54
58
  });
55
59
 
56
60
  const reason = getReason({ force, build });
57
61
 
58
62
  process.stdout.write(
59
- `CI check: should_build=${build} (reason=${reason}, incoming=${incomingLastModified || ''}, cached=${cachedLastModified || ''}, force=${force})\n`
63
+ `CI check: should_build=${build} (reason=${reason}, incoming=${incomingLastModified || ''}, cached=${cachedLastModified || ''}, npm_incoming=${incomingNpmVersion || ''}, npm_cached=${cachedNpmVersion || ''}, force=${force})\n`
60
64
  );
61
65
 
62
66
  appendGithubOutput(env.GITHUB_OUTPUT, {