flashorm 2.2.0-beta1 → 2.2.0-beta3

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/README.md CHANGED
@@ -32,20 +32,19 @@ A powerful, database-agnostic migration CLI tool built in Go with multi-database
32
32
  npm install -g flashorm
33
33
  ```
34
34
 
35
- ### For Bun Users
35
+ The binary will be automatically downloaded on first use. The package:
36
+ - ✅ Downloads only the binary for your platform (Linux, macOS, Windows)
37
+ - ✅ Automatically cleans up binaries for other platforms
38
+ - ✅ Works seamlessly with npm, yarn, pnpm, and bun
39
+ - ✅ No postinstall scripts (no security warnings!)
36
40
 
37
- Bun blocks postinstall scripts by default. After installation, run:
41
+ ### Bun Users
38
42
 
39
- ```bash
40
- bun pm trust flashorm
41
- ```
43
+ No special configuration needed! The binary downloads on first `flash` command execution:
42
44
 
43
- Or add to your `package.json`:
44
-
45
- ```json
46
- {
47
- "trustedDependencies": ["flashorm"]
48
- }
45
+ ```bash
46
+ bun add -g flashorm
47
+ flash --version
49
48
  ```
50
49
 
51
50
  ## 🏁 Quick Start
package/bin/flash.js CHANGED
@@ -8,21 +8,45 @@ const platform = process.platform;
8
8
  const binaryName = platform === 'win32' ? 'flash.exe' : 'flash';
9
9
  const binaryPath = path.join(__dirname, binaryName);
10
10
 
11
+ // If binary doesn't exist, try to download it
11
12
  if (!fs.existsSync(binaryPath)) {
12
- console.error(' flash binary not found. Please reinstall: npm install -g flashorm');
13
- process.exit(1);
13
+ console.log('📥 Binary not found. Downloading...');
14
+
15
+ // Import and wait for download
16
+ const downloadPromise = require('../scripts/download.js');
17
+
18
+ downloadPromise
19
+ .then(() => {
20
+ if (!fs.existsSync(binaryPath)) {
21
+ console.error('❌ Download completed but binary not found. Please try: npm install flashorm --force');
22
+ process.exit(1);
23
+ }
24
+ executeBinary();
25
+ })
26
+ .catch((err) => {
27
+ console.error('❌ Failed to download flash binary');
28
+ console.error('Error:', err.message);
29
+ console.error('');
30
+ console.error('Please try: npm install flashorm --force');
31
+ process.exit(1);
32
+ });
33
+ } else {
34
+ // Binary exists, execute it
35
+ executeBinary();
14
36
  }
15
37
 
16
- const child = spawn(binaryPath, process.argv.slice(2), {
17
- stdio: 'inherit',
18
- windowsHide: true
19
- });
38
+ function executeBinary() {
39
+ const child = spawn(binaryPath, process.argv.slice(2), {
40
+ stdio: 'inherit',
41
+ windowsHide: true
42
+ });
20
43
 
21
- child.on('exit', (code) => {
22
- process.exit(code || 0);
23
- });
44
+ child.on('exit', (code) => {
45
+ process.exit(code || 0);
46
+ });
24
47
 
25
- child.on('error', (err) => {
26
- console.error('❌ Failed to start flash:', err);
27
- process.exit(1);
28
- });
48
+ child.on('error', (err) => {
49
+ console.error('❌ Failed to start flash:', err);
50
+ process.exit(1);
51
+ });
52
+ }
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "flashorm",
3
- "version": "2.2.0-beta1",
3
+ "version": "2.2.0-beta3",
4
4
  "description": "A powerful, database-agnostic ORM with plugin-based architecture - Base CLI only",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "flash": "./bin/flash.js"
8
8
  },
9
- "scripts": {
10
- "install": "node scripts/install.js"
11
- },
12
9
  "keywords": [
13
10
  "orm",
14
11
  "database",
@@ -47,8 +44,9 @@
47
44
  ],
48
45
  "files": [
49
46
  "bin/",
50
- "scripts/",
47
+ "scripts/download.js",
51
48
  "index.js",
52
49
  "README.md"
53
- ]
50
+ ],
51
+ "optionalDependencies": {}
54
52
  }
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env node
2
+
3
+ const https = require('https');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const VERSION = '2.2.0-beta3');
8
+ const REPO = 'Lumos-Labs-HQ/flash';
9
+
10
+ const platform = process.platform;
11
+ const arch = process.arch;
12
+
13
+ const platformMap = {
14
+ 'darwin': 'darwin',
15
+ 'linux': 'linux',
16
+ 'win32': 'windows'
17
+ };
18
+
19
+ const archMap = {
20
+ 'x64': 'amd64',
21
+ 'arm64': 'arm64'
22
+ };
23
+
24
+ const mappedPlatform = platformMap[platform];
25
+ const mappedArch = archMap[arch];
26
+
27
+ if (!mappedPlatform || !mappedArch) {
28
+ console.error(`❌ Unsupported platform: ${platform}-${arch}`);
29
+ process.exit(1);
30
+ }
31
+
32
+ const binaryName = platform === 'win32' ? 'flash.exe' : 'flash';
33
+ const downloadName = `flash-${mappedPlatform}-${mappedArch}${platform === 'win32' ? '.exe' : ''}`;
34
+ const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/${downloadName}`;
35
+
36
+ const binDir = path.join(__dirname, '..', 'bin');
37
+ const binaryPath = path.join(binDir, binaryName);
38
+
39
+ // Clean up binaries for other platforms
40
+ function cleanupOtherBinaries() {
41
+ try {
42
+ const files = fs.readdirSync(binDir);
43
+ files.forEach(file => {
44
+ const filePath = path.join(binDir, file);
45
+ if (file.startsWith('flash') && file !== 'flash.js' && file !== binaryName) {
46
+ try {
47
+ fs.unlinkSync(filePath);
48
+ console.log(`🧹 Removed unused binary: ${file}`);
49
+ } catch (err) {
50
+ // Ignore cleanup errors
51
+ }
52
+ }
53
+ });
54
+ } catch (err) {
55
+ // Ignore if bin dir doesn't exist
56
+ }
57
+ }
58
+
59
+ // Skip if binary already exists for this platform
60
+ if (fs.existsSync(binaryPath)) {
61
+ console.log(`✅ Binary already exists for ${platform}-${arch}`);
62
+ cleanupOtherBinaries();
63
+ process.exit(0);
64
+ }
65
+
66
+ console.log(`📦 Installing FlashORM v${VERSION} for ${platform}-${arch}...`);
67
+ console.log(`📥 Downloading from: ${downloadUrl}`);
68
+
69
+ if (!fs.existsSync(binDir)) {
70
+ fs.mkdirSync(binDir, { recursive: true });
71
+ }
72
+
73
+ function downloadBinary(url) {
74
+ return new Promise((resolve, reject) => {
75
+ const file = fs.createWriteStream(binaryPath);
76
+
77
+ https.get(url, (response) => {
78
+ if (response.statusCode === 302 || response.statusCode === 301) {
79
+ // Follow redirect
80
+ file.close();
81
+ fs.unlinkSync(binaryPath);
82
+ downloadBinary(response.headers.location).then(resolve).catch(reject);
83
+ return;
84
+ }
85
+
86
+ if (response.statusCode !== 200) {
87
+ file.close();
88
+ fs.unlinkSync(binaryPath);
89
+ reject(new Error(`Download failed with status ${response.statusCode}`));
90
+ return;
91
+ }
92
+
93
+ response.pipe(file);
94
+
95
+ file.on('finish', () => {
96
+ file.close(() => {
97
+ try {
98
+ fs.chmodSync(binaryPath, 0o755);
99
+ cleanupOtherBinaries();
100
+ resolve();
101
+ } catch (err) {
102
+ reject(err);
103
+ }
104
+ });
105
+ });
106
+
107
+ file.on('error', (err) => {
108
+ fs.unlink(binaryPath, () => { });
109
+ reject(err);
110
+ });
111
+ }).on('error', (err) => {
112
+ fs.unlink(binaryPath, () => { });
113
+ reject(err);
114
+ });
115
+ });
116
+ }
117
+
118
+ // Main execution
119
+ if (require.main === module) {
120
+ downloadBinary(downloadUrl)
121
+ .then(() => {
122
+ console.log(`✅ FlashORM installed successfully!`);
123
+ console.log('');
124
+ console.log('📦 Plugin System');
125
+ console.log(' FlashORM uses a plugin-based architecture.');
126
+ console.log(' The base CLI includes essential commands:');
127
+ console.log(' • flash --version (show version)');
128
+ console.log(' • flash plugins (list plugins)');
129
+ console.log(' • flash add-plug (install plugins)');
130
+ console.log(' • flash rm-plug (remove plugins)');
131
+ console.log('');
132
+ console.log(' Install plugins for ORM functionality:');
133
+ console.log('');
134
+ console.log(' flash add-plug core # ORM features (migrations, codegen, export)');
135
+ console.log(' flash add-plug studio # Visual database editor');
136
+ console.log(' flash add-plug all # Everything (core + studio)');
137
+ console.log('');
138
+ console.log(`🚀 Run 'flash --help' to get started!`);
139
+ })
140
+ .catch((err) => {
141
+ console.error('❌ Download failed:', err.message);
142
+ console.error('');
143
+ console.error('Please try:');
144
+ console.error(' 1. Check your internet connection');
145
+ console.error(' 2. Verify the release exists on GitHub');
146
+ console.error(` 3. Manual install: ${downloadUrl}`);
147
+ process.exit(1);
148
+ });
149
+ } else {
150
+ // Being required as a module
151
+ module.exports = downloadBinary(downloadUrl);
152
+ }
@@ -1,128 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const https = require('https');
4
- const fs = require('fs');
5
- const path = require('path');
6
-
7
- const VERSION = '2.2.0-beta1';
8
- const REPO = 'Lumos-Labs-HQ/flash';
9
-
10
- const platform = process.platform;
11
- const arch = process.arch;
12
-
13
- const platformMap = {
14
- 'darwin': 'darwin',
15
- 'linux': 'linux',
16
- 'win32': 'windows'
17
- };
18
-
19
- const archMap = {
20
- 'x64': 'amd64',
21
- 'arm64': 'arm64'
22
- };
23
-
24
- const mappedPlatform = platformMap[platform];
25
- const mappedArch = archMap[arch];
26
-
27
- if (!mappedPlatform || !mappedArch) {
28
- console.error(`❌ Unsupported platform: ${platform}-${arch}`);
29
- process.exit(1);
30
- }
31
-
32
- const binaryName = platform === 'win32' ? 'flash.exe' : 'flash';
33
- const downloadName = `flash-${mappedPlatform}-${mappedArch}${platform === 'win32' ? '.exe' : ''}`;
34
- const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/${downloadName}`;
35
-
36
- const binDir = path.join(__dirname, '..', 'bin');
37
- const binaryPath = path.join(binDir, binaryName);
38
-
39
- console.log(`📦 Installing FlashORM Base CLI v${VERSION} for ${platform}-${arch}...`);
40
- console.log(`📥 Downloading from: ${downloadUrl}`);
41
-
42
- if (!fs.existsSync(binDir)) {
43
- fs.mkdirSync(binDir, { recursive: true });
44
- }
45
-
46
- // Clean up any existing binaries (other platforms)
47
- const cleanupBinaries = () => {
48
- const files = fs.readdirSync(binDir);
49
- files.forEach(file => {
50
- const filePath = path.join(binDir, file);
51
- if (file.startsWith('flash') && file !== 'flash.js' && file !== binaryName) {
52
- try {
53
- fs.unlinkSync(filePath);
54
- console.log(`🧹 Cleaned up: ${file}`);
55
- } catch (err) {
56
- // Ignore cleanup errors
57
- }
58
- }
59
- });
60
- };
61
-
62
- const file = fs.createWriteStream(binaryPath);
63
-
64
- https.get(downloadUrl, (response) => {
65
- if (response.statusCode === 302 || response.statusCode === 301) {
66
- https.get(response.headers.location, (redirectResponse) => {
67
- redirectResponse.pipe(file);
68
- file.on('finish', () => {
69
- file.close(() => {
70
- fs.chmodSync(binaryPath, 0o755);
71
- cleanupBinaries();
72
- console.log(`✅ FlashORM Base CLI installed successfully!`);
73
- console.log('');
74
- console.log('📦 Plugin System');
75
- console.log(' FlashORM now uses a plugin-based architecture.');
76
- console.log(' The base CLI includes only essential commands:');
77
- console.log(' • flash --version (show version)');
78
- console.log(' • flash plugins (list plugins)');
79
- console.log(' • flash add-plug (install plugins)');
80
- console.log(' • flash rm-plug (remove plugins)');
81
- console.log('');
82
- console.log(' Install plugins for ORM functionality:');
83
- console.log('');
84
- console.log(' flash add-plug core # ORM features (migrations, codegen, export)');
85
- console.log(' flash add-plug studio # Visual database editor');
86
- console.log(' flash add-plug all # Everything (core + studio)');
87
- console.log('');
88
- console.log(`🚀 Run 'flash --help' to get started!`);
89
- });
90
- });
91
- });
92
- } else {
93
- response.pipe(file);
94
- file.on('finish', () => {
95
- file.close(() => {
96
- fs.chmodSync(binaryPath, 0o755);
97
- cleanupBinaries();
98
- console.log(`✅ FlashORM Base CLI installed successfully!`);
99
- console.log('');
100
- console.log('📦 Plugin System');
101
- console.log(' FlashORM now uses a plugin-based architecture.');
102
- console.log(' The base CLI includes only essential commands:');
103
- console.log(' • flash --version (show version)');
104
- console.log(' • flash plugins (list plugins)');
105
- console.log(' • flash add-plug (install plugins)');
106
- console.log(' • flash rm-plug (remove plugins)');
107
- console.log('');
108
- console.log(' Install plugins for ORM functionality:');
109
- console.log('');
110
- console.log(' flash add-plug core # ORM features (migrations, codegen, export)');
111
- console.log(' flash add-plug studio # Visual database editor');
112
- console.log(' flash add-plug all # Everything (core + studio)');
113
- console.log('');
114
- console.log(`🚀 Run 'flash --help' to get started!`);
115
- });
116
- });
117
- }
118
- }).on('error', (err) => {
119
- if (fs.existsSync(binaryPath)) {
120
- fs.unlinkSync(binaryPath);
121
- }
122
- console.error(`❌ Download failed: ${err.message}`);
123
- console.error(`Please check: ${downloadUrl}`);
124
- console.error('');
125
- console.error('You can also download manually from:');
126
- console.error(` https://github.com/${REPO}/releases/tag/v${VERSION}`);
127
- process.exit(1);
128
- });