flashorm 2.4.0 โ 2.4.1-beta-dev
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 +632 -632
- package/bin/flash.js +52 -52
- package/index.js +28 -28
- package/package.json +52 -52
- package/scripts/download.js +152 -152
package/bin/flash.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawn } = require('child_process');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
|
|
7
|
-
const platform = process.platform;
|
|
8
|
-
const binaryName = platform === 'win32' ? 'flash.exe' : 'flash';
|
|
9
|
-
const binaryPath = path.join(__dirname, binaryName);
|
|
10
|
-
|
|
11
|
-
// If binary doesn't exist, try to download it
|
|
12
|
-
if (!fs.existsSync(binaryPath)) {
|
|
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();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function executeBinary() {
|
|
39
|
-
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
40
|
-
stdio: 'inherit',
|
|
41
|
-
windowsHide: true
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
child.on('exit', (code) => {
|
|
45
|
-
process.exit(code || 0);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
child.on('error', (err) => {
|
|
49
|
-
console.error('โ Failed to start flash:', err);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
const platform = process.platform;
|
|
8
|
+
const binaryName = platform === 'win32' ? 'flash.exe' : 'flash';
|
|
9
|
+
const binaryPath = path.join(__dirname, binaryName);
|
|
10
|
+
|
|
11
|
+
// If binary doesn't exist, try to download it
|
|
12
|
+
if (!fs.existsSync(binaryPath)) {
|
|
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();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function executeBinary() {
|
|
39
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
40
|
+
stdio: 'inherit',
|
|
41
|
+
windowsHide: true
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
child.on('exit', (code) => {
|
|
45
|
+
process.exit(code || 0);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
child.on('error', (err) => {
|
|
49
|
+
console.error('โ Failed to start flash:', err);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
});
|
|
52
|
+
}
|
package/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const { execSync } = require('child_process');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
function getBinaryPath() {
|
|
6
|
-
const platform = process.platform;
|
|
7
|
-
const binaryName = platform === 'win32' ? 'flash.exe' : 'flash';
|
|
8
|
-
const binaryPath = path.join(__dirname, 'bin', binaryName);
|
|
9
|
-
|
|
10
|
-
if (!fs.existsSync(binaryPath)) {
|
|
11
|
-
throw new Error('flash binary not found. Please reinstall: npm install -g flashorm');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return binaryPath;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function exec(command, options = {}) {
|
|
18
|
-
const binaryPath = getBinaryPath();
|
|
19
|
-
return execSync(`"${binaryPath}" ${command}`, {
|
|
20
|
-
encoding: 'utf8',
|
|
21
|
-
...options
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
getBinaryPath,
|
|
27
|
-
exec
|
|
28
|
-
};
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
function getBinaryPath() {
|
|
6
|
+
const platform = process.platform;
|
|
7
|
+
const binaryName = platform === 'win32' ? 'flash.exe' : 'flash';
|
|
8
|
+
const binaryPath = path.join(__dirname, 'bin', binaryName);
|
|
9
|
+
|
|
10
|
+
if (!fs.existsSync(binaryPath)) {
|
|
11
|
+
throw new Error('flash binary not found. Please reinstall: npm install -g flashorm');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return binaryPath;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function exec(command, options = {}) {
|
|
18
|
+
const binaryPath = getBinaryPath();
|
|
19
|
+
return execSync(`"${binaryPath}" ${command}`, {
|
|
20
|
+
encoding: 'utf8',
|
|
21
|
+
...options
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
getBinaryPath,
|
|
27
|
+
exec
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "flashorm",
|
|
3
|
-
"version": "2.4.
|
|
4
|
-
"description": "A powerful, database-agnostic ORM with plugin-based architecture - Base CLI only",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"flash": "./bin/flash.js"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"orm",
|
|
11
|
-
"database",
|
|
12
|
-
"migration",
|
|
13
|
-
"sqlc",
|
|
14
|
-
"postgresql",
|
|
15
|
-
"mysql",
|
|
16
|
-
"sqlite",
|
|
17
|
-
"cli",
|
|
18
|
-
"typescript",
|
|
19
|
-
"javascript",
|
|
20
|
-
"type-safe",
|
|
21
|
-
"plugins"
|
|
22
|
-
],
|
|
23
|
-
"author": "Rana718",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "https://github.com/Lumos-Labs-HQ/flash.git"
|
|
28
|
-
},
|
|
29
|
-
"homepage": "https://github.com/Lumos-Labs-HQ/flash#readme",
|
|
30
|
-
"bugs": {
|
|
31
|
-
"url": "https://github.com/Lumos-Labs-HQ/flash/issues"
|
|
32
|
-
},
|
|
33
|
-
"engines": {
|
|
34
|
-
"node": ">=14.0.0"
|
|
35
|
-
},
|
|
36
|
-
"os": [
|
|
37
|
-
"darwin",
|
|
38
|
-
"linux",
|
|
39
|
-
"win32"
|
|
40
|
-
],
|
|
41
|
-
"cpu": [
|
|
42
|
-
"x64",
|
|
43
|
-
"arm64"
|
|
44
|
-
],
|
|
45
|
-
"files": [
|
|
46
|
-
"bin/",
|
|
47
|
-
"scripts/download.js",
|
|
48
|
-
"index.js",
|
|
49
|
-
"README.md"
|
|
50
|
-
],
|
|
51
|
-
"optionalDependencies": {}
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "flashorm",
|
|
3
|
+
"version": "2.4.1-beta-dev",
|
|
4
|
+
"description": "A powerful, database-agnostic ORM with plugin-based architecture - Base CLI only",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"flash": "./bin/flash.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"orm",
|
|
11
|
+
"database",
|
|
12
|
+
"migration",
|
|
13
|
+
"sqlc",
|
|
14
|
+
"postgresql",
|
|
15
|
+
"mysql",
|
|
16
|
+
"sqlite",
|
|
17
|
+
"cli",
|
|
18
|
+
"typescript",
|
|
19
|
+
"javascript",
|
|
20
|
+
"type-safe",
|
|
21
|
+
"plugins"
|
|
22
|
+
],
|
|
23
|
+
"author": "Rana718",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/Lumos-Labs-HQ/flash.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/Lumos-Labs-HQ/flash#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/Lumos-Labs-HQ/flash/issues"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=14.0.0"
|
|
35
|
+
},
|
|
36
|
+
"os": [
|
|
37
|
+
"darwin",
|
|
38
|
+
"linux",
|
|
39
|
+
"win32"
|
|
40
|
+
],
|
|
41
|
+
"cpu": [
|
|
42
|
+
"x64",
|
|
43
|
+
"arm64"
|
|
44
|
+
],
|
|
45
|
+
"files": [
|
|
46
|
+
"bin/",
|
|
47
|
+
"scripts/download.js",
|
|
48
|
+
"index.js",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"optionalDependencies": {}
|
|
52
|
+
}
|
package/scripts/download.js
CHANGED
|
@@ -1,152 +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.4.
|
|
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
|
+
#!/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.4.1-beta-dev';
|
|
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
|
+
}
|