@noormdev/cli 1.0.0-alpha.0

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.
@@ -0,0 +1 @@
1
+ import"./chunk-WOT6VMZA.js";import{Kysely as n,MssqlDialect as r}from"kysely";async function i(t){let o=await import("tedious"),s=await import("tarn"),e=new n({dialect:new r({tarn:{...s,options:{min:t.pool?.min??0,max:t.pool?.max??10}},tedious:{...o,connectionFactory:()=>new o.Connection({server:t.host??"localhost",authentication:{type:"default",options:{userName:t.user,password:t.password}},options:{port:t.port??1433,database:t.database,trustServerCertificate:!t.ssl,encrypt:!!t.ssl}})}})});return{db:e,dialect:"mssql",destroy:()=>e.destroy()}}export{i as createMssqlConnection};
@@ -0,0 +1 @@
1
+ import"./chunk-WOT6VMZA.js";import{Kysely as n,MysqlDialect as a}from"kysely";async function c(o){let t=await import("mysql2"),s=(t.default?.createPool??t.createPool)({host:o.host??"localhost",port:o.port??3306,user:o.user,password:o.password,database:o.database,connectionLimit:o.pool?.max??10,ssl:o.ssl?{}:void 0}),e=new n({dialect:new a({pool:s})});return{db:e,dialect:"mysql",destroy:()=>e.destroy()}}export{c as createMysqlConnection};
@@ -0,0 +1 @@
1
+ import"./chunk-WOT6VMZA.js";import{Kysely as r,PostgresDialect as a}from"kysely";async function p(o){let t=await import("pg"),e=t.default?.Pool??t.Pool,n=new e({host:o.host??"localhost",port:o.port??5432,user:o.user,password:o.password,database:o.database,min:o.pool?.min??0,max:o.pool?.max??10,ssl:o.ssl}),s=new r({dialect:new a({pool:n})});return{db:s,dialect:"postgres",destroy:()=>s.destroy()}}export{p as createPostgresConnection};
@@ -0,0 +1 @@
1
+ import"./chunk-WOT6VMZA.js";import{Kysely as o,SqliteDialect as i}from"kysely";import a from"better-sqlite3";function c(e){let t=e.filename??e.database,n=new o({dialect:new i({database:new a(t)})});return{db:n,dialect:"sqlite",destroy:()=>n.destroy()}}export{c as createSqliteConnection};
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@noormdev/cli",
3
+ "version": "1.0.0-alpha.0",
4
+ "description": "Database schema & changeset manager CLI",
5
+ "type": "module",
6
+ "bin": {
7
+ "noorm": "./dist/index.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "files": [
11
+ "dist",
12
+ "scripts"
13
+ ],
14
+ "dependencies": {
15
+ "better-sqlite3": "^12.5.0",
16
+ "pg": "^8.16.3",
17
+ "mysql2": "^3.15.3",
18
+ "tedious": "^19.1.3",
19
+ "tarn": "^3.0.2"
20
+ },
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "keywords": [
25
+ "database",
26
+ "schema",
27
+ "migrations",
28
+ "cli",
29
+ "noorm"
30
+ ],
31
+ "license": "ISC",
32
+ "scripts": {
33
+ "postinstall": "node scripts/postinstall.js"
34
+ }
35
+ }
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Creates a stable symlink in /usr/local/bin for Node version independence.
5
+ *
6
+ * When using nvm/fnm, npm bin directories are version-specific. This script
7
+ * creates a symlink in /usr/local/bin so `noorm` works across version switches.
8
+ */
9
+
10
+ import { symlink, unlink, readlink } from 'fs/promises';
11
+ import { existsSync } from 'fs';
12
+ import { dirname, resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+
15
+ const __dirname = dirname(fileURLToPath(import.meta.url));
16
+ const BIN_PATH = '/usr/local/bin/noorm';
17
+ const SOURCE = resolve(__dirname, '../dist/index.js');
18
+
19
+ async function main() {
20
+
21
+ // Skip on Windows
22
+ if (process.platform === 'win32') {
23
+
24
+ return;
25
+
26
+ }
27
+
28
+ // Skip if not a global install (local node_modules)
29
+ if (__dirname.includes('node_modules') && !__dirname.includes('/lib/node_modules/')) {
30
+
31
+ return;
32
+
33
+ }
34
+
35
+ // Check if symlink already exists and points to correct location
36
+ if (existsSync(BIN_PATH)) {
37
+
38
+ try {
39
+
40
+ const existing = await readlink(BIN_PATH);
41
+
42
+ if (existing === SOURCE) {
43
+
44
+ return; // Already correct
45
+
46
+ }
47
+
48
+ await unlink(BIN_PATH);
49
+
50
+ }
51
+ catch {
52
+
53
+ // Not a symlink or can't read - try to proceed anyway
54
+
55
+ }
56
+
57
+ }
58
+
59
+ try {
60
+
61
+ await symlink(SOURCE, BIN_PATH);
62
+ console.log(`✓ Symlinked noorm to ${BIN_PATH}`);
63
+
64
+ }
65
+ catch (err) {
66
+
67
+ if (err.code === 'EACCES') {
68
+
69
+ console.log(`\nTo enable noorm globally (survives Node version switches):\n`);
70
+ console.log(` sudo ln -sf "${SOURCE}" ${BIN_PATH}\n`);
71
+
72
+ }
73
+
74
+ // Don't fail install on symlink errors
75
+
76
+ }
77
+
78
+ }
79
+
80
+ main();