diffx-js 0.5.3 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffx-js",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "description": "A Node.js wrapper for the diffx CLI tool - semantic diffing of JSON, YAML, TOML, XML, INI, and CSV files. Focuses on structural meaning rather than formatting.",
5
5
  "keywords": [
6
6
  "diff",
@@ -22,14 +22,13 @@
22
22
  ],
23
23
  "main": "lib.js",
24
24
  "bin": {
25
- "diffx": "./index.js"
25
+ "diffx": "index.js"
26
26
  },
27
27
  "scripts": {
28
28
  "test": "node test.js",
29
29
  "examples": "node examples.js",
30
30
  "verify": "node index.js --help",
31
- "prepublish": "npm run verify",
32
- "download-binaries": "node scripts/download-all-binaries.js"
31
+ "prepublish": "npm run verify"
33
32
  },
34
33
  "engines": {
35
34
  "node": ">=12.0.0"
@@ -37,8 +36,6 @@
37
36
  "files": [
38
37
  "index.js",
39
38
  "lib.js",
40
- "scripts/download-binary.js",
41
- "scripts/download-all-binaries.js",
42
39
  "bin/",
43
40
  "README.md",
44
41
  "examples.js",
@@ -58,7 +55,7 @@
58
55
  "homepage": "https://github.com/kako-jun/diffx",
59
56
  "repository": {
60
57
  "type": "git",
61
- "url": "https://github.com/kako-jun/diffx.git",
58
+ "url": "git+https://github.com/kako-jun/diffx.git",
62
59
  "directory": "diffx-npm"
63
60
  },
64
61
  "bugs": {
@@ -1,166 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const https = require('https');
6
- const { execSync } = require('child_process');
7
-
8
- const DIFFX_VERSION = require('../package.json').version;
9
- const BINARY_DIR = path.join(__dirname, '..', 'bin');
10
-
11
- // All platform configurations
12
- const PLATFORMS = [
13
- {
14
- name: 'linux-x64',
15
- file: 'diffx-linux-x86_64.tar.gz',
16
- binaryName: 'diffx',
17
- subdir: 'linux-x64'
18
- },
19
- {
20
- name: 'darwin-x64',
21
- file: 'diffx-macos-x86_64.tar.gz',
22
- binaryName: 'diffx',
23
- subdir: 'darwin-x64'
24
- },
25
- {
26
- name: 'darwin-arm64',
27
- file: 'diffx-macos-aarch64.tar.gz',
28
- binaryName: 'diffx',
29
- subdir: 'darwin-arm64'
30
- },
31
- {
32
- name: 'win32-x64',
33
- file: 'diffx-windows-x86_64.zip',
34
- binaryName: 'diffx.exe',
35
- subdir: 'win32-x64'
36
- }
37
- ];
38
-
39
- function downloadFile(url, dest) {
40
- return new Promise((resolve, reject) => {
41
- console.log(`Downloading ${path.basename(dest)}...`);
42
- const file = fs.createWriteStream(dest);
43
-
44
- https.get(url, (response) => {
45
- if (response.statusCode === 302 || response.statusCode === 301) {
46
- // Follow redirect
47
- downloadFile(response.headers.location, dest).then(resolve).catch(reject);
48
- return;
49
- }
50
-
51
- if (response.statusCode !== 200) {
52
- reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));
53
- return;
54
- }
55
-
56
- response.pipe(file);
57
-
58
- file.on('finish', () => {
59
- file.close();
60
- resolve();
61
- });
62
-
63
- file.on('error', (err) => {
64
- fs.unlink(dest, () => {}); // Delete the file async
65
- reject(err);
66
- });
67
- }).on('error', (err) => {
68
- reject(err);
69
- });
70
- });
71
- }
72
-
73
- async function extractArchive(archivePath, extractDir) {
74
- if (archivePath.endsWith('.zip')) {
75
- // Use Node.js built-in for cross-platform ZIP extraction
76
- const { execSync } = require('child_process');
77
- try {
78
- // Try with PowerShell on Windows
79
- if (process.platform === 'win32') {
80
- execSync(`powershell -command "Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force"`, { stdio: 'inherit' });
81
- } else {
82
- // For Linux/macOS, use Python's zipfile module (more widely available than unzip)
83
- execSync(`python3 -c "import zipfile; zipfile.ZipFile('${archivePath}').extractall('${extractDir}')"`, { stdio: 'inherit' });
84
- }
85
- } catch (error) {
86
- // Fallback to manual extraction using Node.js modules
87
- const AdmZip = require('adm-zip');
88
- const zip = new AdmZip(archivePath);
89
- zip.extractAllTo(extractDir, true);
90
- }
91
- } else if (archivePath.endsWith('.tar.gz')) {
92
- execSync(`tar -xzf "${archivePath}" -C "${extractDir}"`, { stdio: 'inherit' });
93
- }
94
- }
95
-
96
- async function downloadPlatformBinary(platform) {
97
- const downloadUrl = `https://github.com/kako-jun/diffx/releases/download/v${DIFFX_VERSION}/${platform.file}`;
98
- const platformDir = path.join(BINARY_DIR, platform.subdir);
99
- const archivePath = path.join(platformDir, platform.file);
100
-
101
- // Create platform-specific directory
102
- if (!fs.existsSync(platformDir)) {
103
- fs.mkdirSync(platformDir, { recursive: true });
104
- }
105
-
106
- // Check if binary already exists
107
- const binaryPath = path.join(platformDir, platform.binaryName);
108
- if (fs.existsSync(binaryPath)) {
109
- console.log(`Binary for ${platform.name} already exists, skipping download.`);
110
- return;
111
- }
112
-
113
- try {
114
- // Download archive
115
- await downloadFile(downloadUrl, archivePath);
116
-
117
- // Extract binary
118
- console.log(`Extracting ${platform.name} binary...`);
119
- await extractArchive(archivePath, platformDir);
120
-
121
- // Clean up archive
122
- fs.unlinkSync(archivePath);
123
-
124
- // Make binary executable on Unix systems
125
- if (platform.binaryName !== 'diffx.exe') {
126
- fs.chmodSync(binaryPath, '755');
127
- }
128
-
129
- console.log(`SUCCESS: ${platform.name} binary installed at ${binaryPath}`);
130
-
131
- } catch (error) {
132
- console.error(`ERROR: Failed to download ${platform.name} binary:`, error.message);
133
- throw error;
134
- }
135
- }
136
-
137
- async function main() {
138
- try {
139
- console.log(`Downloading diffx v${DIFFX_VERSION} binaries for all platforms...`);
140
-
141
- // Create main bin directory
142
- if (!fs.existsSync(BINARY_DIR)) {
143
- fs.mkdirSync(BINARY_DIR, { recursive: true });
144
- }
145
-
146
- // Download all platform binaries
147
- for (const platform of PLATFORMS) {
148
- await downloadPlatformBinary(platform);
149
- }
150
-
151
- console.log('\nšŸŽ‰ All platform binaries downloaded successfully!');
152
- console.log('\nBinary structure:');
153
- console.log('bin/');
154
- for (const platform of PLATFORMS) {
155
- console.log(` └── ${platform.subdir}/${platform.binaryName}`);
156
- }
157
-
158
- } catch (error) {
159
- console.error('ERROR: Failed to download platform binaries:', error.message);
160
- process.exit(1);
161
- }
162
- }
163
-
164
- if (require.main === module) {
165
- main();
166
- }
@@ -1,123 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const https = require('https');
6
- const { execSync } = require('child_process');
7
-
8
- const DIFFX_VERSION = require('../package.json').version;
9
- const BINARY_DIR = path.join(__dirname, '..', 'bin');
10
-
11
- function getPlatform() {
12
- const platform = process.platform;
13
- const arch = process.arch;
14
-
15
- if (platform === 'win32') {
16
- return 'diffx-windows-x86_64.zip';
17
- } else if (platform === 'darwin') {
18
- if (arch === 'arm64') {
19
- return 'diffx-macos-aarch64.tar.gz';
20
- } else {
21
- return 'diffx-macos-x86_64.tar.gz';
22
- }
23
- } else if (platform === 'linux') {
24
- return 'diffx-linux-x86_64.tar.gz';
25
- } else {
26
- throw new Error(`Unsupported platform: ${platform}-${arch}`);
27
- }
28
- }
29
-
30
- function downloadFile(url, dest) {
31
- return new Promise((resolve, reject) => {
32
- console.log(`Downloading diffx binary from ${url}...`);
33
- const file = fs.createWriteStream(dest);
34
-
35
- https.get(url, (response) => {
36
- if (response.statusCode === 302 || response.statusCode === 301) {
37
- // Follow redirect
38
- downloadFile(response.headers.location, dest).then(resolve).catch(reject);
39
- return;
40
- }
41
-
42
- if (response.statusCode !== 200) {
43
- reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));
44
- return;
45
- }
46
-
47
- response.pipe(file);
48
-
49
- file.on('finish', () => {
50
- file.close();
51
- resolve();
52
- });
53
-
54
- file.on('error', (err) => {
55
- fs.unlink(dest, () => {}); // Delete the file async
56
- reject(err);
57
- });
58
- }).on('error', (err) => {
59
- reject(err);
60
- });
61
- });
62
- }
63
-
64
- async function extractArchive(archivePath, extractDir) {
65
- if (archivePath.endsWith('.zip')) {
66
- // Use unzip for Windows
67
- if (process.platform === 'win32') {
68
- execSync(`powershell -command "Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force"`, { stdio: 'inherit' });
69
- } else {
70
- execSync(`unzip -o "${archivePath}" -d "${extractDir}"`, { stdio: 'inherit' });
71
- }
72
- } else if (archivePath.endsWith('.tar.gz')) {
73
- execSync(`tar -xzf "${archivePath}" -C "${extractDir}"`, { stdio: 'inherit' });
74
- }
75
- }
76
-
77
- async function main() {
78
- try {
79
- // Skip download if binary already exists
80
- const binaryName = process.platform === 'win32' ? 'diffx.exe' : 'diffx';
81
- const binaryPath = path.join(BINARY_DIR, binaryName);
82
-
83
- if (fs.existsSync(binaryPath)) {
84
- console.log('diffx binary already exists, skipping download.');
85
- return;
86
- }
87
-
88
- const platformFile = getPlatform();
89
- const downloadUrl = `https://github.com/kako-jun/diffx/releases/download/v${DIFFX_VERSION}/${platformFile}`;
90
-
91
- // Create bin directory
92
- if (!fs.existsSync(BINARY_DIR)) {
93
- fs.mkdirSync(BINARY_DIR, { recursive: true });
94
- }
95
-
96
- // Download archive
97
- const archivePath = path.join(BINARY_DIR, platformFile);
98
- await downloadFile(downloadUrl, archivePath);
99
-
100
- console.log('Extracting binary...');
101
- await extractArchive(archivePath, BINARY_DIR);
102
-
103
- // Clean up archive
104
- fs.unlinkSync(archivePath);
105
-
106
- // Make binary executable on Unix systems
107
- if (process.platform !== 'win32') {
108
- fs.chmodSync(binaryPath, '755');
109
- }
110
-
111
- console.log(`SUCCESS: diffx binary installed successfully at ${binaryPath}`);
112
-
113
- } catch (error) {
114
- console.error('ERROR: Failed to download diffx binary:', error.message);
115
- console.error('You may need to install diffx manually from: https://github.com/kako-jun/diffx/releases');
116
- // Don't fail the installation, just warn
117
- process.exit(0);
118
- }
119
- }
120
-
121
- if (require.main === module) {
122
- main();
123
- }