create-absolutejs 0.4.2 → 0.5.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.
package/dist/data.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { FrontendLabels, AvailableDependency } from './types';
2
2
  export declare const availableFrontends: readonly ["react", "html", "svelte", "vue", "htmx"];
3
3
  export declare const availableAuthProviders: readonly ["absoluteAuth", "none"];
4
- export declare const availableDrizzleDialects: readonly ["gel", "mysql", "postgresql", "sqlite", "singlestore"];
4
+ export declare const availableDrizzleDialects: readonly ["gel", "mysql", "postgresql", "sqlite", "singlestore", "mariadb"];
5
5
  export declare const availablePrismaDialects: readonly ["mysql", "postgresql", "sqlite", "mongodb", "mariadb", "cockroachdb", "mssql"];
6
6
  export declare const availableDatabaseEngines: readonly ["postgresql", "mysql", "sqlite", "mongodb", "mariadb", "gel", "singlestore", "cockroachdb", "mssql", "none"];
7
7
  export declare const availableDirectoryConfigurations: readonly ["default", "custom"];
@@ -13,5 +13,6 @@ export declare const availablePlugins: AvailableDependency[];
13
13
  export declare const absoluteAuthPlugin: AvailableDependency;
14
14
  export declare const scopedStatePlugin: AvailableDependency;
15
15
  export declare const eslintAndPrettierDependencies: AvailableDependency[];
16
+ export declare const eslintReactDependencies: AvailableDependency[];
16
17
  export declare const defaultDependencies: AvailableDependency[];
17
18
  export declare const defaultPlugins: AvailableDependency[];
package/dist/data.js CHANGED
@@ -13,7 +13,8 @@ export const availableDrizzleDialects = [
13
13
  'mysql',
14
14
  'postgresql',
15
15
  'sqlite',
16
- 'singlestore'
16
+ 'singlestore',
17
+ 'mariadb'
17
18
  ];
18
19
  export const availablePrismaDialects = [
19
20
  'mysql',
@@ -107,6 +108,52 @@ export const eslintAndPrettierDependencies = [
107
108
  {
108
109
  latestVersion: '3.5.3',
109
110
  value: 'prettier'
111
+ },
112
+ {
113
+ latestVersion: '4.4.1',
114
+ value: '@stylistic/eslint-plugin-ts'
115
+ },
116
+ {
117
+ latestVersion: '8.47.0',
118
+ value: '@typescript-eslint/parser'
119
+ },
120
+ {
121
+ latestVersion: '0.1.6',
122
+ value: 'eslint-plugin-absolute'
123
+ },
124
+ {
125
+ latestVersion: '2.32.0',
126
+ value: 'eslint-plugin-import'
127
+ },
128
+ {
129
+ latestVersion: '7.2.1',
130
+ value: 'eslint-plugin-promise'
131
+ },
132
+ {
133
+ latestVersion: '3.0.1',
134
+ value: 'eslint-plugin-security'
135
+ },
136
+ {
137
+ latestVersion: '8.47.0',
138
+ value: 'typescript-eslint'
139
+ }
140
+ ];
141
+ export const eslintReactDependencies = [
142
+ {
143
+ latestVersion: '6.10.2',
144
+ value: 'eslint-plugin-jsx-a11y'
145
+ },
146
+ {
147
+ latestVersion: '7.37.5',
148
+ value: 'eslint-plugin-react'
149
+ },
150
+ {
151
+ latestVersion: '19.1.0-rc.2',
152
+ value: 'eslint-plugin-react-compiler'
153
+ },
154
+ {
155
+ latestVersion: '7.0.0',
156
+ value: 'eslint-plugin-react-hooks'
110
157
  }
111
158
  ];
112
159
  export const defaultDependencies = [
@@ -1,14 +1,14 @@
1
1
  import { writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  const databaseURLS = {
4
- cockroachdb: 'cockroachdb://user:password@localhost:26257/database',
5
- gel: 'gel://user:password@localhost:5432/database',
6
- mariadb: 'mariadb://user:password@localhost:3306/database',
4
+ cockroachdb: 'postgresql://root@localhost:26257/database',
5
+ gel: 'gel://admin@localhost:5656/main?tls_security=insecure',
6
+ mariadb: 'mariadb://user:userpassword@localhost:3306/database',
7
7
  mongodb: 'mongodb://user:password@localhost:27017/database',
8
- mssql: 'mssql://user:password@localhost:1433/database',
9
- mysql: 'mysql://user:password@localhost:3306/database',
8
+ mssql: 'Server=localhost,1433;Database=master;User Id=sa;Password=SApassword1;Encrypt=true;TrustServerCertificate=true',
9
+ mysql: 'mysql://user:userpassword@localhost:3306/database',
10
10
  postgresql: 'postgresql://user:password@localhost:5432/database',
11
- singlestore: 'singlestore://user:password@localhost:3306/database'
11
+ singlestore: 'mysql://root:password@localhost:3306/database'
12
12
  };
13
13
  export const generateEnv = ({ databaseEngine, databaseHost, envVariables = [], projectName }) => {
14
14
  const vars = [...envVariables];
@@ -2,9 +2,40 @@ import { writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import { spinner } from '@clack/prompts';
4
4
  import { green } from 'picocolors';
5
- import { absoluteAuthPlugin, availablePlugins, defaultDependencies, defaultPlugins, eslintAndPrettierDependencies } from '../../data';
5
+ import { absoluteAuthPlugin, availablePlugins, defaultDependencies, defaultPlugins, eslintAndPrettierDependencies, eslintReactDependencies } from '../../data';
6
6
  import { getPackageVersion } from '../../utils/getPackageVersion';
7
+ import { initTemplates } from '../db/dockerInitTemplates';
7
8
  import { computeFlags } from '../project/computeFlags';
9
+ const dbScripts = {
10
+ cockroachdb: {
11
+ clientCmd: 'cockroach sql --insecure --database=database',
12
+ waitCmd: initTemplates.cockroachdb.wait
13
+ },
14
+ gel: {
15
+ clientCmd: 'gel -H localhost -P 5656 -u admin --tls-security insecure -b main',
16
+ waitCmd: initTemplates.gel.wait
17
+ },
18
+ mariadb: {
19
+ clientCmd: 'MYSQL_PWD=userpassword mariadb -h127.0.0.1 -u user database',
20
+ waitCmd: initTemplates.mariadb.wait
21
+ },
22
+ mssql: {
23
+ clientCmd: '/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P SApassword1',
24
+ waitCmd: initTemplates.mssql.wait
25
+ },
26
+ mysql: {
27
+ clientCmd: 'MYSQL_PWD=userpassword mysql -h127.0.0.1 -u user database',
28
+ waitCmd: initTemplates.mysql.wait
29
+ },
30
+ postgresql: {
31
+ clientCmd: 'psql -h localhost -U user -d database',
32
+ waitCmd: initTemplates.postgresql.wait
33
+ },
34
+ singlestore: {
35
+ clientCmd: 'singlestore -u root -ppassword -D database',
36
+ waitCmd: initTemplates.singlestore.wait
37
+ }
38
+ };
8
39
  export const createPackageJson = ({ projectName, authProvider, plugins, databaseEngine, orm, databaseHost, useTailwind, latest, frontendDirectories, codeQualityTool }) => {
9
40
  const s = spinner();
10
41
  if (latest)
@@ -12,6 +43,7 @@ export const createPackageJson = ({ projectName, authProvider, plugins, database
12
43
  const resolveVersion = (name, listed) => latest ? (getPackageVersion(name) ?? listed) : listed;
13
44
  const dependencies = {};
14
45
  const devDependencies = {};
46
+ devDependencies['typescript'] = resolveVersion('typescript', '5.9.3');
15
47
  const flags = computeFlags(frontendDirectories);
16
48
  for (const p of defaultPlugins) {
17
49
  dependencies[p.value] = resolveVersion(p.value, p.latestVersion);
@@ -43,6 +75,11 @@ export const createPackageJson = ({ projectName, authProvider, plugins, database
43
75
  dependencies['react'] = resolveVersion('react', '19.2.0');
44
76
  devDependencies['@types/react'] = resolveVersion('@types/react', '19.2.0');
45
77
  }
78
+ if (flags.requiresReact && codeQualityTool === 'eslint+prettier') {
79
+ eslintReactDependencies.forEach((dep) => {
80
+ devDependencies[dep.value] = resolveVersion(dep.value, dep.latestVersion);
81
+ });
82
+ }
46
83
  if (flags.requiresSvelte) {
47
84
  dependencies['svelte'] = resolveVersion('svelte', '5.34.7');
48
85
  }
@@ -78,41 +115,42 @@ export const createPackageJson = ({ projectName, authProvider, plugins, database
78
115
  test: 'echo "Error: no test specified" && exit 1',
79
116
  typecheck: 'bun run tsc --noEmit'
80
117
  };
81
- if (databaseEngine === 'postgresql' &&
82
- (!databaseHost || databaseHost === 'none')) {
83
- scripts['db:up'] =
84
- 'sh -c "docker info >/dev/null 2>&1 || sudo service docker start; docker compose -p postgresql -f db/docker-compose.db.yml up -d db"';
85
- scripts['db:down'] =
86
- 'docker compose -p postgresql -f db/docker-compose.db.yml down';
87
- scripts['db:reset'] =
88
- 'docker compose -p postgresql -f db/docker-compose.db.yml down -v';
89
- scripts['db:psql'] =
90
- "docker compose -p postgresql -f db/docker-compose.db.yml exec db bash -lc 'until pg_isready -U user -h localhost --quiet; do sleep 1; done; exec psql -h localhost -U user -d database'";
118
+ const isLocal = !databaseHost || databaseHost === 'none';
119
+ if (isLocal &&
120
+ databaseEngine !== undefined &&
121
+ databaseEngine !== 'none' &&
122
+ databaseEngine !== 'sqlite' &&
123
+ databaseEngine !== 'mongodb') {
124
+ const config = dbScripts[databaseEngine];
125
+ const dockerPrefix = `docker compose -p ${databaseEngine} -f db/docker-compose.db.yml`;
126
+ scripts['db:up'] = `${dockerPrefix} up -d db`;
127
+ scripts['postdb:up'] =
128
+ `${dockerPrefix} exec db bash -lc '${config.waitCmd}'`;
129
+ scripts['db:down'] = `${dockerPrefix} down`;
130
+ scripts['db:reset'] = `${dockerPrefix} down -v`;
131
+ scripts[`db:${databaseEngine}`] =
132
+ `${dockerPrefix} exec -it db bash -lc '${config.clientCmd}'`;
91
133
  scripts['predev'] = 'bun db:up';
92
- scripts['predb:psql'] = 'bun db:up';
134
+ scripts[`predb:${databaseEngine}`] = 'bun db:up';
93
135
  scripts['postdev'] = 'bun db:down';
94
- scripts['postdb:psql'] = 'bun db:down';
136
+ scripts[`postdb:${databaseEngine}`] = 'bun db:down';
95
137
  }
96
- if (databaseEngine === 'mysql') {
138
+ if (isLocal &&
139
+ (databaseEngine === 'mysql' || databaseEngine === 'mariadb') &&
140
+ orm === 'drizzle') {
97
141
  dependencies['mysql2'] = resolveVersion('mysql2', '3.14.2');
98
142
  }
99
- if (databaseEngine === 'mysql' &&
100
- (!databaseHost || databaseHost === 'none')) {
101
- scripts['db:up'] =
102
- 'sh -c "docker info >/dev/null 2>&1 || sudo service docker start; docker compose -p mysql -f db/docker-compose.db.yml up -d db"';
103
- scripts['db:down'] =
104
- 'docker compose -p mysql -f db/docker-compose.db.yml down';
105
- scripts['db:reset'] =
106
- 'docker compose -p mysql -f db/docker-compose.db.yml down -v';
107
- scripts['db:mysql'] =
108
- "docker compose -p mysql -f db/docker-compose.db.yml exec -e MYSQL_PWD=rootpassword db bash -lc 'until mysqladmin ping -h127.0.0.1 --silent; do sleep 1; done; exec mysql -h127.0.0.1 -uroot'";
109
- scripts['predev'] = 'bun db:up';
110
- scripts['predb:mysql'] = 'bun db:up';
111
- scripts['postdev'] = 'bun db:down';
112
- scripts['postdb:mysql'] = 'bun db:down';
143
+ if (isLocal && databaseEngine === 'singlestore') {
144
+ dependencies['mysql2'] = resolveVersion('mysql2', '3.14.2');
145
+ }
146
+ if (isLocal && databaseEngine === 'mssql') {
147
+ dependencies['mssql'] = resolveVersion('mssql', '12.1.0');
148
+ devDependencies['@types/mssql'] = resolveVersion('@types/mssql', '9.1.8');
149
+ }
150
+ if (isLocal && databaseEngine === 'gel') {
151
+ dependencies['gel'] = resolveVersion('gel', '2.1.1');
113
152
  }
114
- if (databaseEngine === 'sqlite' &&
115
- (!databaseHost || databaseHost === 'none')) {
153
+ if (isLocal && databaseEngine === 'sqlite') {
116
154
  scripts['db:sqlite'] = 'sqlite3 db/database.sqlite';
117
155
  scripts['db:init'] = 'sqlite3 db/database.sqlite < db/init.sql';
118
156
  }
@@ -2,4 +2,5 @@ export declare const initalizeRoot: (projectName: string, templatesDirectory: st
2
2
  backendDirectory: string;
3
3
  frontendDirectory: string;
4
4
  projectAssetsDirectory: string;
5
+ typesDirectory: string;
5
6
  };
@@ -7,7 +7,8 @@ export const initalizeRoot = (projectName, templatesDirectory) => {
7
7
  mkdirSync(projectName);
8
8
  const srcDir = join(projectName, 'src');
9
9
  mkdirSync(srcDir);
10
- mkdirSync(join(srcDir, 'types'));
10
+ const typesDirectory = join(srcDir, 'types');
11
+ mkdirSync(typesDirectory);
11
12
  const constantsSrc = join(templatesDirectory, 'constants.ts');
12
13
  const constantsDest = join(srcDir, 'constants.ts');
13
14
  copyFileSync(constantsSrc, constantsDest);
@@ -22,5 +23,10 @@ export const initalizeRoot = (projectName, templatesDirectory) => {
22
23
  mkdirSync(join(projectAssetsDirectory, 'svg'), { recursive: true });
23
24
  copyFileSync(join(templatesDirectory, 'assets', 'ico', 'favicon.ico'), join(projectAssetsDirectory, 'ico', 'favicon.ico'));
24
25
  copyFileSync(join(templatesDirectory, 'assets', 'png', 'absolutejs-temp.png'), join(projectAssetsDirectory, 'png', 'absolutejs-temp.png'));
25
- return { backendDirectory, frontendDirectory, projectAssetsDirectory };
26
+ return {
27
+ backendDirectory,
28
+ frontendDirectory,
29
+ projectAssetsDirectory,
30
+ typesDirectory
31
+ };
26
32
  };
@@ -1,6 +1,6 @@
1
1
  export declare const userTables: {
2
2
  readonly cockroachdb: "CREATE TABLE IF NOT EXISTS users (\n auth_sub VARCHAR(255) PRIMARY KEY,\n created_at TIMESTAMP NOT NULL DEFAULT NOW(),\n metadata JSONB DEFAULT '{}'::jsonb\n);";
3
- readonly gel: "CREATE TABLE IF NOT EXISTS users (\n auth_sub VARCHAR(255) PRIMARY KEY,\n created_at TIMESTAMP NOT NULL DEFAULT NOW(),\n metadata JSON DEFAULT '{}'::json\n);";
3
+ readonly gel: "create type users {\n create required property auth_sub: str {\n create constraint exclusive;\n };\n\n create required property created_at: datetime {\n set default := datetime_current();\n };\n\n create required property metadata: json {\n set default := to_json('{}');\n };\n};";
4
4
  readonly mariadb: "CREATE TABLE IF NOT EXISTS users (\n auth_sub VARCHAR(255) PRIMARY KEY,\n created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n metadata JSON DEFAULT ('{}')\n);";
5
5
  readonly mssql: "IF OBJECT_ID('users','U') IS NULL\nBEGIN\n CREATE TABLE users (\n auth_sub NVARCHAR(255) PRIMARY KEY,\n created_at DATETIME2 NOT NULL DEFAULT SYSUTCDATETIME(),\n metadata NVARCHAR(MAX) NULL\n );\nEND;";
6
6
  readonly mysql: "CREATE TABLE IF NOT EXISTS users (\n auth_sub VARCHAR(255) PRIMARY KEY,\n created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n metadata JSON DEFAULT (JSON_OBJECT())\n);";
@@ -8,8 +8,8 @@ export declare const userTables: {
8
8
  readonly singlestore: "CREATE TABLE IF NOT EXISTS users (\n auth_sub VARCHAR(255) PRIMARY KEY,\n created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n metadata JSON DEFAULT ('{}')\n);";
9
9
  };
10
10
  export declare const countHistoryTables: {
11
- readonly cockroachdb: "CREATE TABLE IF NOT EXISTS count_history (\n uid INT PRIMARY KEY DEFAULT unique_rowid(),\n count INT NOT NULL,\n created_at TIMESTAMP NOT NULL DEFAULT NOW()\n);";
12
- readonly gel: "CREATE TABLE IF NOT EXISTS count_history (\n uid INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,\n count INTEGER NOT NULL,\n created_at TIMESTAMP NOT NULL DEFAULT NOW()\n);";
11
+ readonly cockroachdb: "CREATE SEQUENCE IF NOT EXISTS count_history_uid_seq START WITH 1 INCREMENT BY 1;\nCREATE TABLE IF NOT EXISTS count_history (\n uid BIGINT PRIMARY KEY DEFAULT nextval('count_history_uid_seq'),\n count INT NOT NULL,\n created_at TIMESTAMP NOT NULL DEFAULT NOW()\n);";
12
+ readonly gel: "create scalar type CountHistoryUid extending sequence;\ncreate type count_history {\n create required property uid: CountHistoryUid {\n create constraint exclusive;\n set default := sequence_next(introspect CountHistoryUid);\n };\n\n create required property count: int16;\n\n create required property created_at: datetime {\n set default := datetime_current();\n };\n};";
13
13
  readonly mariadb: "CREATE TABLE IF NOT EXISTS count_history (\n uid INT AUTO_INCREMENT PRIMARY KEY,\n count INT NOT NULL,\n created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n);";
14
14
  readonly mssql: "IF OBJECT_ID('count_history','U') IS NULL\nBEGIN\n CREATE TABLE count_history (\n uid INT IDENTITY(1,1) PRIMARY KEY,\n count INT NOT NULL,\n created_at DATETIME2 NOT NULL DEFAULT SYSUTCDATETIME()\n );\nEND;";
15
15
  readonly mysql: "CREATE TABLE IF NOT EXISTS count_history (\n uid INT AUTO_INCREMENT PRIMARY KEY,\n count INT NOT NULL,\n created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n);";
@@ -18,20 +18,20 @@ export declare const countHistoryTables: {
18
18
  };
19
19
  export declare const initTemplates: {
20
20
  readonly cockroachdb: {
21
- readonly cli: "cockroach sql --insecure --host=localhost -e";
22
- readonly wait: "until pg_isready -U root -h localhost --quiet; do sleep 1; done";
21
+ readonly cli: "sleep 1; cockroach sql --insecure --host localhost --database=database -e";
22
+ readonly wait: "until (cockroach sql --insecure -e \"select 1\" >/dev/null 2>&1) ; do sleep 1; done";
23
23
  };
24
24
  readonly gel: {
25
- readonly cli: "psql -U user -d database -c";
26
- readonly wait: "until pg_isready -U user -h localhost --quiet; do sleep 1; done";
25
+ readonly cli: "gel query -H localhost -P 5656 -u admin --tls-security insecure -b main ";
26
+ readonly wait: "until gel query -H localhost -P 5656 -u admin --tls-security insecure \"select 1\"; do sleep 1; done";
27
27
  };
28
28
  readonly mariadb: {
29
- readonly cli: "MYSQL_PWD=userpassword mariadb -h127.0.0.1 -u user -e";
30
- readonly wait: "until mysqladmin ping -h127.0.0.1 --silent; do sleep 1; done";
29
+ readonly cli: "MYSQL_PWD=userpassword mariadb -h127.0.0.1 -u user database -e";
30
+ readonly wait: "until mariadb-admin ping -h127.0.0.1 --silent; do sleep 1; done";
31
31
  };
32
32
  readonly mssql: {
33
- readonly cli: "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P sapassword -Q";
34
- readonly wait: "until /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P sapassword -Q \"SELECT 1\" >/dev/null 2>&1; do sleep 1; done";
33
+ readonly cli: "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P SApassword1 -Q";
34
+ readonly wait: "until /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P SApassword1 -Q \"SELECT 1\" >/dev/null 2>&1; do sleep 1; done";
35
35
  };
36
36
  readonly mysql: {
37
37
  readonly cli: "MYSQL_PWD=userpassword mysql -h127.0.0.1 -u user database -e";
@@ -42,7 +42,7 @@ export declare const initTemplates: {
42
42
  readonly wait: "until pg_isready -U user -h localhost --quiet; do sleep 1; done";
43
43
  };
44
44
  readonly singlestore: {
45
- readonly cli: "MYSQL_PWD=userpassword mysql -h127.0.0.1 -u user -e";
46
- readonly wait: "until mysqladmin ping -h127.0.0.1 --silent; do sleep 1; done";
45
+ readonly cli: "singlestore -u root -ppassword -e \"CREATE DATABASE IF NOT EXISTS \\`database\\`\" > /dev/null && singlestore -u root -ppassword -D database -e";
46
+ readonly wait: "until singlestore -u root -ppassword -e \"SELECT 1\" >/dev/null 2>&1; do sleep 1; done";
47
47
  };
48
48
  };
@@ -43,8 +43,9 @@ const cockroachdbUsers = `CREATE TABLE IF NOT EXISTS users (
43
43
  created_at TIMESTAMP NOT NULL DEFAULT NOW(),
44
44
  metadata JSONB DEFAULT '{}'::jsonb
45
45
  );`;
46
- const cockroachdbCountHistory = `CREATE TABLE IF NOT EXISTS count_history (
47
- uid INT PRIMARY KEY DEFAULT unique_rowid(),
46
+ const cockroachdbCountHistory = `CREATE SEQUENCE IF NOT EXISTS count_history_uid_seq START WITH 1 INCREMENT BY 1;
47
+ CREATE TABLE IF NOT EXISTS count_history (
48
+ uid BIGINT PRIMARY KEY DEFAULT nextval('count_history_uid_seq'),
48
49
  count INT NOT NULL,
49
50
  created_at TIMESTAMP NOT NULL DEFAULT NOW()
50
51
  );`;
@@ -64,16 +65,32 @@ BEGIN
64
65
  created_at DATETIME2 NOT NULL DEFAULT SYSUTCDATETIME()
65
66
  );
66
67
  END;`;
67
- const gelUsers = `CREATE TABLE IF NOT EXISTS users (
68
- auth_sub VARCHAR(255) PRIMARY KEY,
69
- created_at TIMESTAMP NOT NULL DEFAULT NOW(),
70
- metadata JSON DEFAULT '{}'::json
71
- );`;
72
- const gelCountHistory = `CREATE TABLE IF NOT EXISTS count_history (
73
- uid INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
74
- count INTEGER NOT NULL,
75
- created_at TIMESTAMP NOT NULL DEFAULT NOW()
76
- );`;
68
+ const gelUsers = `create type users {
69
+ create required property auth_sub: str {
70
+ create constraint exclusive;
71
+ };
72
+
73
+ create required property created_at: datetime {
74
+ set default := datetime_current();
75
+ };
76
+
77
+ create required property metadata: json {
78
+ set default := to_json('{}');
79
+ };
80
+ };`;
81
+ const gelCountHistory = `create scalar type CountHistoryUid extending sequence;
82
+ create type count_history {
83
+ create required property uid: CountHistoryUid {
84
+ create constraint exclusive;
85
+ set default := sequence_next(introspect CountHistoryUid);
86
+ };
87
+
88
+ create required property count: int16;
89
+
90
+ create required property created_at: datetime {
91
+ set default := datetime_current();
92
+ };
93
+ };`;
77
94
  export const userTables = {
78
95
  cockroachdb: cockroachdbUsers,
79
96
  gel: gelUsers,
@@ -94,20 +111,20 @@ export const countHistoryTables = {
94
111
  };
95
112
  export const initTemplates = {
96
113
  cockroachdb: {
97
- cli: 'cockroach sql --insecure --host=localhost -e',
98
- wait: 'until pg_isready -U root -h localhost --quiet; do sleep 1; done'
114
+ cli: 'sleep 1; cockroach sql --insecure --host localhost --database=database -e',
115
+ wait: 'until (cockroach sql --insecure -e "select 1" >/dev/null 2>&1) ; do sleep 1; done'
99
116
  },
100
117
  gel: {
101
- cli: 'psql -U user -d database -c',
102
- wait: 'until pg_isready -U user -h localhost --quiet; do sleep 1; done'
118
+ cli: 'gel query -H localhost -P 5656 -u admin --tls-security insecure -b main ',
119
+ wait: 'until gel query -H localhost -P 5656 -u admin --tls-security insecure "select 1"; do sleep 1; done'
103
120
  },
104
121
  mariadb: {
105
- cli: 'MYSQL_PWD=userpassword mariadb -h127.0.0.1 -u user -e',
106
- wait: 'until mysqladmin ping -h127.0.0.1 --silent; do sleep 1; done'
122
+ cli: 'MYSQL_PWD=userpassword mariadb -h127.0.0.1 -u user database -e',
123
+ wait: 'until mariadb-admin ping -h127.0.0.1 --silent; do sleep 1; done'
107
124
  },
108
125
  mssql: {
109
- cli: '/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P sapassword -Q',
110
- wait: 'until /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P sapassword -Q "SELECT 1" >/dev/null 2>&1; do sleep 1; done'
126
+ cli: '/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P SApassword1 -Q',
127
+ wait: 'until /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P SApassword1 -Q "SELECT 1" >/dev/null 2>&1; do sleep 1; done'
111
128
  },
112
129
  mysql: {
113
130
  cli: 'MYSQL_PWD=userpassword mysql -h127.0.0.1 -u user database -e',
@@ -118,7 +135,7 @@ export const initTemplates = {
118
135
  wait: 'until pg_isready -U user -h localhost --quiet; do sleep 1; done'
119
136
  },
120
137
  singlestore: {
121
- cli: 'MYSQL_PWD=userpassword mysql -h127.0.0.1 -u user -e',
122
- wait: 'until mysqladmin ping -h127.0.0.1 --silent; do sleep 1; done'
138
+ cli: 'singlestore -u root -ppassword -e "CREATE DATABASE IF NOT EXISTS \\`database\\`" > /dev/null && singlestore -u root -ppassword -D database -e',
139
+ wait: 'until singlestore -u root -ppassword -e "SELECT 1" >/dev/null 2>&1; do sleep 1; done'
123
140
  }
124
141
  };
@@ -0,0 +1,8 @@
1
+ import { AuthProvider, DatabaseEngine, DatabaseHost } from '../../types';
2
+ type GenerateTypesProps = {
3
+ databaseEngine: DatabaseEngine;
4
+ databaseHost: DatabaseHost;
5
+ authProvider: AuthProvider;
6
+ };
7
+ export declare const generateDatabaseTypes: ({ databaseEngine, databaseHost, authProvider }: GenerateTypesProps) => string;
8
+ export {};
@@ -0,0 +1,62 @@
1
+ import { isDrizzleDialect } from '../../typeGuards';
2
+ export const generateDatabaseTypes = ({ databaseEngine, databaseHost, authProvider }) => {
3
+ let dbImport = '';
4
+ let dbTypeLine = '';
5
+ if (databaseHost === 'neon') {
6
+ dbImport = `import { NeonHttpDatabase } from 'drizzle-orm/neon-http';`;
7
+ dbTypeLine = 'export type DatabaseType = NeonHttpDatabase<SchemaType>;';
8
+ }
9
+ else if (databaseHost === 'planetscale') {
10
+ dbImport = `import { PlanetScaleDatabase } from 'drizzle-orm/planetscale-serverless';`;
11
+ dbTypeLine =
12
+ 'export type DatabaseType = PlanetScaleDatabase<SchemaType>;';
13
+ }
14
+ else if (databaseHost === 'turso') {
15
+ dbImport = `import { LibSQLDatabase } from 'drizzle-orm/libsql';`;
16
+ dbTypeLine = 'export type DatabaseType = LibSQLDatabase<SchemaType>;';
17
+ }
18
+ if ((!databaseHost || databaseHost === 'none') &&
19
+ isDrizzleDialect(databaseEngine)) {
20
+ switch (databaseEngine) {
21
+ case 'gel':
22
+ dbImport = `import { GelJsDatabase } from 'drizzle-orm/gel';`;
23
+ dbTypeLine =
24
+ 'export type DatabaseType = GelJsDatabase<SchemaType>;';
25
+ break;
26
+ case 'mariadb':
27
+ case 'mysql':
28
+ dbImport = `import { Mysql2Database } from 'drizzle-orm/mysql2';`;
29
+ dbTypeLine =
30
+ 'export type DatabaseType = Mysql2Database<SchemaType>;';
31
+ break;
32
+ case 'postgresql':
33
+ dbImport = `import { BunSQLDatabase } from 'drizzle-orm/bun-sql';`;
34
+ dbTypeLine =
35
+ 'export type DatabaseType = BunSQLDatabase<SchemaType>;';
36
+ break;
37
+ case 'singlestore':
38
+ dbImport = `import { SingleStoreDriverDatabase } from 'drizzle-orm/singlestore';`;
39
+ dbTypeLine =
40
+ 'export type DatabaseType = SingleStoreDriverDatabase<SchemaType>;';
41
+ break;
42
+ case 'sqlite':
43
+ dbImport = `import { BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite';`;
44
+ dbTypeLine =
45
+ 'export type DatabaseType = BunSQLiteDatabase<SchemaType>;';
46
+ break;
47
+ }
48
+ }
49
+ const schemaImport = authProvider === 'absoluteAuth'
50
+ ? `import { users, SchemaType } from '../../db/schema';`
51
+ : `import { countHistory, SchemaType } from '../../db/schema';`;
52
+ const extraTypes = authProvider === 'absoluteAuth'
53
+ ? `export type User = typeof users.$inferSelect;
54
+ export type NewUser = typeof users.$inferInsert;`
55
+ : `export type CountHistory = typeof countHistory.$inferSelect;
56
+ export type NewCountHistory = typeof countHistory.$inferInsert;`;
57
+ return `${schemaImport}
58
+ ${dbImport}
59
+
60
+ ${dbTypeLine ? `${dbTypeLine}\n\n` : '\n'}${extraTypes}
61
+ `;
62
+ };
@@ -1,21 +1,20 @@
1
1
  const templates = {
2
2
  cockroachdb: {
3
+ command: 'start-single-node --insecure',
3
4
  env: {
4
- COCKROACH_INSECURE: 'true'
5
+ COCKROACH_DATABASE: 'database'
5
6
  },
6
- image: 'cockroachdb/cockroach:v24.1.0',
7
+ image: 'cockroachdb/cockroach:latest-v25.3',
7
8
  port: '26257:26257',
8
9
  volumePath: '/cockroach/cockroach-data'
9
10
  },
10
11
  gel: {
11
12
  env: {
12
- GEL_DB: 'database',
13
- GEL_PASSWORD: 'password',
14
- GEL_USER: 'user'
13
+ GEL_SERVER_SECURITY: 'insecure_dev_mode'
15
14
  },
16
- image: 'gel:latest',
17
- port: '4000:4000',
18
- volumePath: '/var/lib/gel'
15
+ image: 'geldata/gel:latest',
16
+ port: '5656:5656',
17
+ volumePath: '/var/lib/gel/data'
19
18
  },
20
19
  mariadb: {
21
20
  env: {
@@ -41,8 +40,7 @@ const templates = {
41
40
  mssql: {
42
41
  env: {
43
42
  ACCEPT_EULA: 'Y',
44
- MSSQL_PID: 'Express',
45
- SA_PASSWORD: 'Strong_Passw0rd'
43
+ MSSQL_SA_PASSWORD: 'SApassword1'
46
44
  },
47
45
  image: 'mcr.microsoft.com/mssql/server:2022-latest',
48
46
  port: '1433:1433',
@@ -73,9 +71,9 @@ const templates = {
73
71
  env: {
74
72
  ROOT_PASSWORD: 'password'
75
73
  },
76
- image: 'singlestore/cluster-in-a-box:latest',
74
+ image: 'ghcr.io/singlestore-labs/singlestoredb-dev', // NOTE: No tag specified due to data persistence
77
75
  port: '3306:3306',
78
- volumePath: '/var/lib/memsql'
76
+ volumePath: '/data'
79
77
  }
80
78
  };
81
79
  export const generateDockerContainer = (databaseEngine) => {
@@ -84,7 +82,8 @@ export const generateDockerContainer = (databaseEngine) => {
84
82
  databaseEngine === 'sqlite') {
85
83
  throw new Error('Internal type error: Expected a valid local database engine');
86
84
  }
87
- const { image, port, env, volumePath } = templates[databaseEngine];
85
+ const { image, port, env, volumePath, command } = templates[databaseEngine];
86
+ const commandLines = command ? ` command: ${command}` : '';
88
87
  const envLines = Object.entries(env)
89
88
  .map(([key, value]) => ` ${key}: ${value}`)
90
89
  .join('\n');
@@ -96,6 +95,7 @@ export const generateDockerContainer = (databaseEngine) => {
96
95
  ${envLines}
97
96
  ports:
98
97
  - "${port}"
98
+ ${commandLines}
99
99
  volumes:
100
100
  - db_data:${volumePath}
101
101
 
@@ -1,8 +1,7 @@
1
- import { AuthProvider, AvailableDrizzleDialect, DatabaseHost } from '../../types';
1
+ import { AuthProvider, AvailableDrizzleDialect } from '../../types';
2
2
  type GenerateSchemaProps = {
3
3
  databaseEngine: AvailableDrizzleDialect;
4
- databaseHost: DatabaseHost;
5
4
  authProvider: AuthProvider;
6
5
  };
7
- export declare const generateDrizzleSchema: ({ databaseEngine, databaseHost, authProvider }: GenerateSchemaProps) => string;
6
+ export declare const generateDrizzleSchema: ({ databaseEngine, authProvider }: GenerateSchemaProps) => string;
8
7
  export {};