umpordez 1.0.2 → 1.0.3
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/package.json
CHANGED
package/template/seed.sh
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
+
set -e
|
|
2
3
|
|
|
3
4
|
echo "Database Setup"
|
|
4
5
|
echo "=============="
|
|
@@ -7,7 +8,7 @@ echo ""
|
|
|
7
8
|
DB_NAME="{{DB_NAME}}"
|
|
8
9
|
|
|
9
10
|
echo "Creating database '$DB_NAME'..."
|
|
10
|
-
createdb "$DB_NAME" 2>/dev/null && echo "Database created" || echo "Database already exists
|
|
11
|
+
createdb "$DB_NAME" 2>/dev/null && echo "Database created" || echo "Database already exists"
|
|
11
12
|
echo ""
|
|
12
13
|
|
|
13
14
|
echo "Running migrations..."
|
|
@@ -15,7 +16,7 @@ echo "Running migrations..."
|
|
|
15
16
|
echo ""
|
|
16
17
|
|
|
17
18
|
echo "Seeding admin user..."
|
|
18
|
-
(cd server && npm run console -- --task=seed-admin)
|
|
19
|
+
(cd server && npm run console -- --task=seed-admin --email={{ADMIN_EMAIL}} --password={{ADMIN_PASSWORD}})
|
|
19
20
|
echo ""
|
|
20
21
|
|
|
21
22
|
echo "=============="
|
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>{{PROJECT_NAME}}</title>
|
|
7
|
+
<script>
|
|
8
|
+
(function() {
|
|
9
|
+
var t = localStorage.getItem('ui-theme') || '{{DEFAULT_THEME}}';
|
|
10
|
+
if (t === 'system') {
|
|
11
|
+
t = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
12
|
+
? 'dark' : 'light';
|
|
13
|
+
}
|
|
14
|
+
document.documentElement.classList.add(t);
|
|
15
|
+
})();
|
|
16
|
+
</script>
|
|
7
17
|
</head>
|
|
8
18
|
<body>
|
|
9
19
|
<div id="root"></div>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { Knex } from 'knex';
|
|
2
|
-
import bcrypt from 'bcrypt';
|
|
3
|
-
|
|
4
|
-
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
const passwordHash = await bcrypt.hash('{{ADMIN_PASSWORD}}', 10);
|
|
6
|
-
|
|
7
|
-
const [user] = await knex('users')
|
|
8
|
-
.insert({
|
|
9
|
-
email: '{{ADMIN_EMAIL}}',
|
|
10
|
-
password_hash: passwordHash,
|
|
11
|
-
name: 'Admin',
|
|
12
|
-
role: 'admin'
|
|
13
|
-
})
|
|
14
|
-
.returning('*');
|
|
15
|
-
|
|
16
|
-
const [account] = await knex('accounts')
|
|
17
|
-
.insert({
|
|
18
|
-
name: 'Admin Account',
|
|
19
|
-
status: 'active',
|
|
20
|
-
settings: JSON.stringify({})
|
|
21
|
-
})
|
|
22
|
-
.returning('*');
|
|
23
|
-
|
|
24
|
-
await knex('user_in_accounts').insert({
|
|
25
|
-
user_id: user.id,
|
|
26
|
-
account_id: account.id,
|
|
27
|
-
role: 'owner'
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export async function down(knex: Knex): Promise<void> {
|
|
32
|
-
const user = await knex('users')
|
|
33
|
-
.where({ email: '{{ADMIN_EMAIL}}' })
|
|
34
|
-
.first();
|
|
35
|
-
|
|
36
|
-
if (user) {
|
|
37
|
-
await knex('user_in_accounts').where({ user_id: user.id }).del();
|
|
38
|
-
await knex('users').where({ id: user.id }).del();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
await knex('accounts').where({ name: 'Admin Account' }).del();
|
|
42
|
-
}
|