@acalcutt/maplibre-gl-native-test 6.2.0-pre.2 → 6.2.0-pre.20

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/package-binaries.js +142 -0
  2. package/package.json +8 -14
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const tar = require('tar');
6
+
7
+ // Read package.json
8
+ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
9
+
10
+ // Get platform and architecture mappings
11
+ function getPlatform() {
12
+ // Use Node.js built-in process.platform
13
+ switch (process.platform) {
14
+ case 'linux':
15
+ return 'linux';
16
+ case 'darwin':
17
+ return 'darwin';
18
+ case 'win32':
19
+ return 'win32';
20
+ default:
21
+ console.warn(`Unknown platform: ${process.platform}, using as-is`);
22
+ return process.platform;
23
+ }
24
+ }
25
+
26
+ function getArch() {
27
+ // Use Node.js built-in process.arch
28
+ switch (process.arch) {
29
+ case 'x64':
30
+ return 'x64';
31
+ case 'arm64':
32
+ return 'arm64';
33
+ case 'ia32':
34
+ return 'ia32';
35
+ case 'arm':
36
+ return 'arm';
37
+ case 's390x':
38
+ return 's390x';
39
+ case 'ppc64':
40
+ return 'ppc64';
41
+ default:
42
+ console.warn(`Unknown architecture: ${process.arch}, using as-is`);
43
+ return process.arch;
44
+ }
45
+ }
46
+
47
+ // Clean package name for filename
48
+ function cleanPackageName(name) {
49
+ let cleanName = name;
50
+ // If it's a scoped package, get the part after the last slash
51
+ if (cleanName.includes('/')) {
52
+ cleanName = cleanName.split('/').pop();
53
+ }
54
+ // Sanitize the name by removing all @ and / characters
55
+ return cleanName.replace(/[@\/]/g, '-');
56
+ }
57
+
58
+ // Create tarballs for each ABI
59
+ async function createTarballs() {
60
+ const platform = getPlatform();
61
+ const arch = getArch();
62
+ const version = packageJson.version;
63
+ const cleanName = cleanPackageName(packageJson.name);
64
+
65
+ console.log(`Creating tarballs for platform: ${platform}, arch: ${arch}, version: ${version}`);
66
+
67
+ // Find all ABI directories
68
+ const libDir = './lib';
69
+ if (!fs.existsSync(libDir)) {
70
+ console.error(`lib directory not found: ${libDir}`);
71
+ process.exit(1);
72
+ }
73
+
74
+ const abiDirs = fs.readdirSync(libDir)
75
+ .filter(dir => dir.startsWith('node-v') && fs.statSync(path.join(libDir, dir)).isDirectory())
76
+ .filter(dir => fs.existsSync(path.join(libDir, dir, 'mbgl.node')));
77
+
78
+ if (abiDirs.length === 0) {
79
+ console.error('No ABI directories with mbgl.node found');
80
+ process.exit(1);
81
+ }
82
+
83
+ console.log(`Found ABI directories: ${abiDirs.join(', ')}`);
84
+
85
+ const createdTarballs = [];
86
+
87
+ for (const abiDir of abiDirs) {
88
+ const abi = abiDir.replace('node-v', '');
89
+ const tarballName = `${cleanName}-v${version}-node-v${abi}-${platform}-${arch}.tar.gz`;
90
+ const binaryPath = path.join('lib', abiDir, 'mbgl.node');
91
+
92
+ console.log(`Creating tarball: ${tarballName}`);
93
+ console.log(` Platform: ${platform}, Arch: ${arch}, ABI: ${abi}`);
94
+ console.log(` Binary: ${binaryPath}`);
95
+
96
+ try {
97
+ // Create tarball preserving the lib/node-v[abi]/mbgl.node structure
98
+ await tar.create({
99
+ gzip: true,
100
+ file: tarballName,
101
+ cwd: '.',
102
+ }, [binaryPath]);
103
+
104
+ // Verify tarball was created and get its size
105
+ const stats = fs.statSync(tarballName);
106
+ console.log(` Tarball created successfully (${stats.size} bytes)`);
107
+ if (stats.size === 0) {
108
+ throw new Error('Tarball is empty');
109
+ }
110
+ createdTarballs.push(tarballName);
111
+ } catch (error) {
112
+ console.error(`Failed to create tarball ${tarballName}:`, error.message);
113
+ process.exit(1);
114
+ }
115
+ }
116
+ console.log(`\nSuccessfully created ${createdTarballs.length} tarballs:`);
117
+ createdTarballs.forEach(tarball => {
118
+ const stats = fs.statSync(tarball);
119
+ console.log(` ${tarball} (${stats.size} bytes)`);
120
+ });
121
+ return createdTarballs;
122
+ }
123
+
124
+ // Main execution
125
+ if (require.main === module) {
126
+ createTarballs()
127
+ .then(() => {
128
+ console.log('Tarball creation completed successfully');
129
+ process.exit(0);
130
+ })
131
+ .catch(error => {
132
+ console.error('Error creating tarballs:', error);
133
+ process.exit(1);
134
+ });
135
+ }
136
+
137
+ module.exports = {
138
+ createTarballs,
139
+ getPlatform,
140
+ getArch,
141
+ cleanPackageName
142
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acalcutt/maplibre-gl-native-test",
3
- "version": "6.2.0-pre.2",
3
+ "version": "6.2.0-pre.20",
4
4
  "description": "Renders map tiles with MapLibre Native",
5
5
  "keywords": [
6
6
  "maplibre",
@@ -11,13 +11,14 @@
11
11
  },
12
12
  "files": [
13
13
  "lib",
14
- "index.d.ts"
14
+ "index.d.ts",
15
+ "package-binaries.js"
15
16
  ],
16
17
  "main": "index.js",
17
18
  "types": "index.d.ts",
18
19
  "repository": {
19
20
  "type": "git",
20
- "url": "git+https://github.com/maplibre/maplibre-native.git"
21
+ "url": "git+https://github.com/WifiDB/maplibre-native.git"
21
22
  },
22
23
  "license": "BSD-2-Clause",
23
24
  "dependencies": {
@@ -45,12 +46,12 @@
45
46
  "mapbox-gl-styles": "2.0.2",
46
47
  "pixelmatch": "^5.3.0",
47
48
  "pngjs": "^7.0.0",
48
- "prebuild": "^13.0.1",
49
49
  "pretty-bytes": "^6.1.1",
50
50
  "semver": "^7.6.0",
51
51
  "shuffle-seed": "1.1.6",
52
52
  "st": "3.0.0",
53
53
  "tape": "^5.7.5",
54
+ "tar": "^7.4.3",
54
55
  "typescript": "^5.4.5",
55
56
  "xcode": "^3.0.1"
56
57
  },
@@ -58,19 +59,12 @@
58
59
  "node": ">=18"
59
60
  },
60
61
  "scripts": {
61
- "install": "prebuild-install --force || echo 'pre-compiled binary not found, please build from source'",
62
- "prebuild": "prebuild --all --no-embed-source",
62
+ "install": "prebuild-install --verbose --tag-prefix node-v|| echo 'pre-compiled binary not found, please build from source'",
63
+ "package-binaries": "node package-binaries.js",
63
64
  "test": "tape test/js/**/*.test.js",
64
65
  "test-memory": "node --expose-gc test/memory.test.js",
65
66
  "test-expressions": "node -r esm test/expression.test.js",
66
67
  "test-render": "node -r esm test/render.test.js",
67
68
  "test-query": "node -r esm test/query.test.js"
68
- },
69
- "prebuild": {
70
- "targets": [
71
- "18.0.0",
72
- "20.0.0",
73
- "22.0.0"
74
- ]
75
69
  }
76
- }
70
+ }