Skip to content

Commit 74d6c33

Browse files
committed
chore: bun bundles
1 parent 318d7ec commit 74d6c33

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
@@ -1625,6 +1625,15 @@ __metadata:
16251625
languageName: node
16261626
linkType: hard
16271627

1628+
"@types/bun@npm:^1.2.5":
1629+
version: 1.2.5
1630+
resolution: "@types/bun@npm:1.2.5"
1631+
dependencies:
1632+
bun-types: "npm:1.2.5"
1633+
checksum: 10c0/228fbaee32c91353696740361e7ab4b3650906d85e10d3d8ea0c8b2669e529b756e67f444609ca98ee400a5774c3cedfa611ca2b51d7d8db37f5c1db42d654cd
1634+
languageName: node
1635+
linkType: hard
1636+
16281637
"@types/cacheable-request@npm:^6.0.1":
16291638
version: 6.0.3
16301639
resolution: "@types/cacheable-request@npm:6.0.3"
@@ -1961,6 +1970,15 @@ __metadata:
19611970
languageName: node
19621971
linkType: hard
19631972

1973+
"@types/ws@npm:~8.5.10":
1974+
version: 8.5.14
1975+
resolution: "@types/ws@npm:8.5.14"
1976+
dependencies:
1977+
"@types/node": "npm:*"
1978+
checksum: 10c0/be88a0b6252f939cb83340bd1b4d450287f752c19271195cd97564fd94047259a9bb8c31c585a61b69d8a1b069a99df9dd804db0132d3359c54d3890c501416a
1979+
languageName: node
1980+
linkType: hard
1981+
19641982
"@types/yargs-parser@npm:*":
19651983
version: 21.0.3
19661984
resolution: "@types/yargs-parser@npm:21.0.3"
@@ -2576,6 +2594,7 @@ __metadata:
25762594
"@sapphire/timestamp": "npm:^1.0.3"
25772595
"@types/adm-zip": "npm:^0.5.5"
25782596
"@types/archiver": "npm:^6.0.2"
2597+
"@types/bun": "npm:^1.2.5"
25792598
"@types/chai": "npm:^4.3.17"
25802599
"@types/cors": "npm:^2.8.17"
25812600
"@types/express": "npm:^4.17.21"
@@ -3083,6 +3102,16 @@ __metadata:
30833102
languageName: node
30843103
linkType: hard
30853104

3105+
"bun-types@npm:1.2.5":
3106+
version: 1.2.5
3107+
resolution: "bun-types@npm:1.2.5"
3108+
dependencies:
3109+
"@types/node": "npm:*"
3110+
"@types/ws": "npm:~8.5.10"
3111+
checksum: 10c0/ef3c3d673def40b2461b8eba6b4f7f5bcd7430590ab576d45748279642945bd4298497893ff26efd040def1739e658f67908a7257f6af5368bdd4ca2331b30b9
3112+
languageName: node
3113+
linkType: hard
3114+
30863115
"bundle-name@npm:^4.1.0":
30873116
version: 4.1.0
30883117
resolution: "bundle-name@npm:4.1.0"

0 commit comments

Comments
 (0)