Skip to content

Commit 529e361

Browse files
committed
chore: bun bundles
1 parent 77c9ae8 commit 529e361

File tree

6 files changed

+67
-7
lines changed

6 files changed

+67
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ package.tgz
2121
**/scrapy-wrapper/templates/*
2222

2323
test/tmp
24-
oclif.manifest.json
2524
tmp
2625

2726
package-lock.json
2827
scripts/temporary-reference.md
28+
29+
bundles/*

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"dist"
2525
],
2626
"bin": {
27-
"apify": "./dist/entrypoints/apify.js",
28-
"actor": "./dist/entrypoints/actor.js"
27+
"actor": "./dist/entrypoints/actor.js",
28+
"apify": "./dist/entrypoints/apify.js"
2929
},
3030
"contributors": [
3131
"Jakub Drobník <[email protected]>",
@@ -111,6 +111,7 @@
111111
"@sapphire/result": "^2.6.6",
112112
"@types/adm-zip": "^0.5.5",
113113
"@types/archiver": "^6.0.2",
114+
"@types/bun": "^1.2.5",
114115
"@types/chai": "^4.3.17",
115116
"@types/cors": "^2.8.17",
116117
"@types/express": "^4.17.21",

scripts/build-cli-bundles.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference types="@types/bun" />
2+
3+
import { basename } from 'node:path';
4+
5+
import { $, fileURLToPath } from 'bun';
6+
7+
import { version } from '../package.json' with { type: 'json' };
8+
9+
const targets = ['bun-linux-x64', 'bun-linux-arm64', 'bun-windows-x64', 'bun-darwin-arm64', 'bun-darwin-x64'];
10+
11+
const entryPoints = [
12+
//
13+
fileURLToPath(new URL('../src/entrypoints/apify.ts', import.meta.url)),
14+
];
15+
16+
for (const entryPoint of entryPoints) {
17+
const cliName = basename(entryPoint, '.ts');
18+
19+
for (const target of targets) {
20+
const [, os, arch] = target.split('-');
21+
22+
const fileName = `${cliName}-${version}-${os}-${arch}`;
23+
24+
const outFile = fileURLToPath(new URL(`../bundles/${fileName}`, import.meta.url));
25+
26+
console.log(`Building ${cliName} for ${target} (result: ${fileName})...`);
27+
await $`bun build --compile --target=${target} --outfile=${outFile} ${entryPoint}`;
28+
}
29+
}

src/lib/consts.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/* eslint-disable @typescript-eslint/no-duplicate-enum-values */
22
/* eslint-disable no-underscore-dangle */
33

4-
import { readFileSync } from 'node:fs';
54
import { homedir, arch, platform } from 'node:os';
65
import { join } from 'node:path';
76

87
import { KEY_VALUE_STORE_KEYS, META_ORIGINS } from '@apify/consts';
98

9+
import pkg from '../../package.json' with { type: 'json' };
10+
1011
export const DEFAULT_LOCAL_STORAGE_DIR = 'storage';
1112

1213
export const LEGACY_LOCAL_STORAGE_DIR = 'apify_storage';
@@ -84,8 +85,6 @@ export const INPUT_FILE_REG_EXP = new RegExp(`^${KEY_VALUE_STORE_KEYS.INPUT}\\..
8485

8586
export const MAIN_FILE = 'main.js';
8687

87-
const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
88-
8988
export const SUPPORTED_NODEJS_VERSION = pkg.engines.node;
9089

9190
export const CURRENT_APIFY_CLI_VERSION = pkg.version;

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// For now we need this :(
1313
"skipLibCheck": true,
1414
"tsBuildInfoFile": "dist/.tsbuildinfo",
15-
"noImplicitOverride": true
15+
"noImplicitOverride": true,
16+
"types": ["node"]
1617
},
1718
"include": ["src"]
1819
}

yarn.lock

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,15 @@ __metadata:
15771577
languageName: node
15781578
linkType: hard
15791579

1580+
"@types/bun@npm:^1.2.5":
1581+
version: 1.2.5
1582+
resolution: "@types/bun@npm:1.2.5"
1583+
dependencies:
1584+
bun-types: "npm:1.2.5"
1585+
checksum: 10c0/228fbaee32c91353696740361e7ab4b3650906d85e10d3d8ea0c8b2669e529b756e67f444609ca98ee400a5774c3cedfa611ca2b51d7d8db37f5c1db42d654cd
1586+
languageName: node
1587+
linkType: hard
1588+
15801589
"@types/cacheable-request@npm:^6.0.1":
15811590
version: 6.0.3
15821591
resolution: "@types/cacheable-request@npm:6.0.3"
@@ -1913,6 +1922,15 @@ __metadata:
19131922
languageName: node
19141923
linkType: hard
19151924

1925+
"@types/ws@npm:~8.5.10":
1926+
version: 8.5.14
1927+
resolution: "@types/ws@npm:8.5.14"
1928+
dependencies:
1929+
"@types/node": "npm:*"
1930+
checksum: 10c0/be88a0b6252f939cb83340bd1b4d450287f752c19271195cd97564fd94047259a9bb8c31c585a61b69d8a1b069a99df9dd804db0132d3359c54d3890c501416a
1931+
languageName: node
1932+
linkType: hard
1933+
19161934
"@types/yargs-parser@npm:*":
19171935
version: 21.0.3
19181936
resolution: "@types/yargs-parser@npm:21.0.3"
@@ -2449,6 +2467,7 @@ __metadata:
24492467
"@sapphire/timestamp": "npm:^1.0.3"
24502468
"@types/adm-zip": "npm:^0.5.5"
24512469
"@types/archiver": "npm:^6.0.2"
2470+
"@types/bun": "npm:^1.2.5"
24522471
"@types/chai": "npm:^4.3.17"
24532472
"@types/cors": "npm:^2.8.17"
24542473
"@types/express": "npm:^4.17.21"
@@ -2955,6 +2974,16 @@ __metadata:
29552974
languageName: node
29562975
linkType: hard
29572976

2977+
"bun-types@npm:1.2.5":
2978+
version: 1.2.5
2979+
resolution: "bun-types@npm:1.2.5"
2980+
dependencies:
2981+
"@types/node": "npm:*"
2982+
"@types/ws": "npm:~8.5.10"
2983+
checksum: 10c0/ef3c3d673def40b2461b8eba6b4f7f5bcd7430590ab576d45748279642945bd4298497893ff26efd040def1739e658f67908a7257f6af5368bdd4ca2331b30b9
2984+
languageName: node
2985+
linkType: hard
2986+
29582987
"bundle-name@npm:^4.1.0":
29592988
version: 4.1.0
29602989
resolution: "bundle-name@npm:4.1.0"

0 commit comments

Comments
 (0)