flashorm 2.4.0 โ 2.4.5
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 +62 -29
- package/bin/flash.js +52 -52
- package/index.js +28 -28
- package/package.json +52 -52
- package/scripts/download.js +152 -152
package/README.md
CHANGED
|
@@ -4,16 +4,17 @@ A powerful, database-agnostic migration CLI tool built in Go with multi-database
|
|
|
4
4
|
|
|
5
5
|
## โจ Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
7
|
+
- ๐๏ธ **Multi-Database Support**: PostgreSQL, MySQL, SQLite, ScyllaDB / Cassandra, ClickHouse
|
|
8
|
+
- ๐ **Migration Management**: Create, apply, rollback, and track migrations
|
|
9
|
+
- ๐ฟ **Schema Branching**: Git-like branching for database schemas
|
|
10
|
+
- ๐ฑ **Database Seeding**: Generate realistic fake data for development
|
|
10
11
|
- ๐ **Safe Migration System**: Transaction-based execution with automatic rollback
|
|
11
12
|
- ๐ค **Smart Export System**: Multiple formats (JSON, CSV, SQLite)
|
|
12
13
|
- ๐ง **Type-Safe Code Generation**: Generate fully typed JavaScript/TypeScript code
|
|
13
|
-
- โก **Blazing Fast**: 2.
|
|
14
|
+
- โก **Blazing Fast**: 2.8x faster than Drizzle, 11.9x faster than Prisma
|
|
14
15
|
- ๐ป **Raw SQL Execution**: Execute SQL files or inline queries
|
|
15
16
|
- ๐ฏ **Prisma-like Commands**: Familiar CLI interface
|
|
16
|
-
- ๐จ **Enum Support**: Full PostgreSQL ENUM support
|
|
17
|
+
- ๐จ **Enum Support**: Full PostgreSQL ENUM support with generated union types
|
|
17
18
|
|
|
18
19
|
## ๐ Performance
|
|
19
20
|
|
|
@@ -52,14 +53,14 @@ flash --version
|
|
|
52
53
|
### 1. Initialize Project
|
|
53
54
|
|
|
54
55
|
```bash
|
|
55
|
-
flash init --postgresql # or --mysql, --sqlite
|
|
56
|
+
flash init --postgresql # or --mysql, --sqlite, --scylla, --clickhouse
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
This creates:
|
|
59
60
|
|
|
60
61
|
```
|
|
61
62
|
your-project/
|
|
62
|
-
โโโ flash.
|
|
63
|
+
โโโ flash.toml
|
|
63
64
|
โโโ .env
|
|
64
65
|
โโโ db/
|
|
65
66
|
โโโ schema/
|
|
@@ -222,14 +223,15 @@ main().catch((err) => {
|
|
|
222
223
|
### Visual Database Editor
|
|
223
224
|
|
|
224
225
|
```bash
|
|
225
|
-
# Launch FlashORM Studio (web-based database editor
|
|
226
|
+
# Launch FlashORM Studio (web-based database editor for PostgreSQL, MySQL, SQLite,
|
|
227
|
+
# ScyllaDB, ClickHouse, MongoDB, and Redis)
|
|
226
228
|
flash studio
|
|
227
229
|
|
|
228
230
|
# Launch on custom port
|
|
229
231
|
flash studio --port 3000
|
|
230
232
|
|
|
231
233
|
# Connect to any database directly
|
|
232
|
-
flash studio
|
|
234
|
+
flash studio "postgresql://user:pass@localhost:5432/mydb"
|
|
233
235
|
|
|
234
236
|
# Launch without opening browser
|
|
235
237
|
flash studio --browser=false
|
|
@@ -251,6 +253,8 @@ flash studio --browser=false
|
|
|
251
253
|
flash init --postgresql
|
|
252
254
|
flash init --mysql
|
|
253
255
|
flash init --sqlite
|
|
256
|
+
flash init --scylla
|
|
257
|
+
flash init --clickhouse
|
|
254
258
|
```
|
|
255
259
|
|
|
256
260
|
### Migrations
|
|
@@ -306,6 +310,39 @@ flash export --csv
|
|
|
306
310
|
flash export --sqlite
|
|
307
311
|
```
|
|
308
312
|
|
|
313
|
+
### Database Seeding
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Seed all tables with default count
|
|
317
|
+
flash seed
|
|
318
|
+
|
|
319
|
+
# Seed with custom count
|
|
320
|
+
flash seed --count 100
|
|
321
|
+
|
|
322
|
+
# Seed specific tables with different counts
|
|
323
|
+
flash seed users:100 posts:500
|
|
324
|
+
|
|
325
|
+
# Truncate before seeding
|
|
326
|
+
flash seed --truncate --force
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Schema Branching
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# Create a feature branch
|
|
333
|
+
flash branch create feature/new-schema
|
|
334
|
+
|
|
335
|
+
# Switch between branches
|
|
336
|
+
flash checkout feature/new-schema
|
|
337
|
+
flash checkout main
|
|
338
|
+
|
|
339
|
+
# List branches
|
|
340
|
+
flash branch list
|
|
341
|
+
|
|
342
|
+
# Merge branches
|
|
343
|
+
flash branch merge feature/new-schema
|
|
344
|
+
```
|
|
345
|
+
|
|
309
346
|
### Database Operations
|
|
310
347
|
|
|
311
348
|
```bash
|
|
@@ -344,25 +381,21 @@ flash <command> --help
|
|
|
344
381
|
|
|
345
382
|
## โ๏ธ Configuration
|
|
346
383
|
|
|
347
|
-
**flash.
|
|
384
|
+
**flash.toml**
|
|
348
385
|
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
"enabled": true
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
386
|
+
```toml
|
|
387
|
+
version = "2"
|
|
388
|
+
schema_dir = "db/schema"
|
|
389
|
+
queries = "db/queries/"
|
|
390
|
+
migrations_path = "db/migrations"
|
|
391
|
+
export_path = "db/export"
|
|
392
|
+
|
|
393
|
+
[database]
|
|
394
|
+
provider = "postgresql"
|
|
395
|
+
url_env = "DATABASE_URL"
|
|
396
|
+
|
|
397
|
+
[gen.js]
|
|
398
|
+
enabled = true
|
|
366
399
|
```
|
|
367
400
|
|
|
368
401
|
## ๐จ PostgreSQL ENUM Support
|
|
@@ -621,8 +654,8 @@ flash studio --port 3000
|
|
|
621
654
|
- **Visual Database Editor**: Manage your database visually with FlashORM Studio
|
|
622
655
|
- **Raw SQL Support**: Execute SQL files or queries directly from CLI
|
|
623
656
|
- **Type-Safe**: Full TypeScript support with generated types
|
|
624
|
-
- **Fast**: 2.
|
|
625
|
-
- **Multi-DB**: PostgreSQL, MySQL,
|
|
657
|
+
- **Fast**: 2.8x-11.9x faster than popular ORMs
|
|
658
|
+
- **Multi-DB**: PostgreSQL, MySQL, SQLite, ScyllaDB, Cassandra, ClickHouse
|
|
626
659
|
- **Zero Config**: Works out of the box with sensible defaults
|
|
627
660
|
|
|
628
661
|
## ๐ License
|
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.5",
|
|
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.5';
|
|
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
|
+
}
|