@ditojs/server 1.2.1 → 1.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/master/packages/server",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"node >= 14"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@ditojs/admin": "^1.
|
|
25
|
-
"@ditojs/router": "^1.
|
|
26
|
-
"@ditojs/utils": "^1.
|
|
24
|
+
"@ditojs/admin": "^1.3.0",
|
|
25
|
+
"@ditojs/router": "^1.3.0",
|
|
26
|
+
"@ditojs/utils": "^1.3.0",
|
|
27
27
|
"@koa/cors": "^3.2.0",
|
|
28
28
|
"@koa/multer": "^3.0.0",
|
|
29
29
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"koa-session": "^6.2.0",
|
|
54
54
|
"koa-static": "^5.0.0",
|
|
55
55
|
"mime-types": "^2.1.35",
|
|
56
|
-
"minimatch": "^5.0.1",
|
|
57
56
|
"multer": "^1.4.4",
|
|
58
57
|
"multer-s3": "^2.10.0",
|
|
59
58
|
"nanoid": "^3.3.1",
|
|
@@ -82,5 +81,5 @@
|
|
|
82
81
|
"pg": "^8.7.3",
|
|
83
82
|
"sqlite3": "^5.0.2"
|
|
84
83
|
},
|
|
85
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "23aac9eddfc17e3e9367db2b7ac73595bc2bad37"
|
|
86
85
|
}
|
|
@@ -13,7 +13,7 @@ import { merge } from '@ditojs/utils'
|
|
|
13
13
|
import { Controller } from './Controller.js'
|
|
14
14
|
import { handleConnectMiddleware } from '../middleware/index.js'
|
|
15
15
|
import { ControllerError } from '../errors/index.js'
|
|
16
|
-
import { formatJson } from '../utils/index.js'
|
|
16
|
+
import { formatJson, deprecate } from '../utils/index.js'
|
|
17
17
|
|
|
18
18
|
export class AdminController extends Controller {
|
|
19
19
|
// @override
|
|
@@ -34,11 +34,19 @@ export class AdminController extends Controller {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
getPath(name) {
|
|
37
|
-
const
|
|
37
|
+
const { config } = this
|
|
38
|
+
let str = config[name]
|
|
39
|
+
if (config.build?.path || config.dist?.path) {
|
|
40
|
+
deprecate(`config.admin.build.path and config.admin.dist.path are deprecated. Use config.admin.root and config.admin.dist instead.`)
|
|
41
|
+
|
|
42
|
+
str = name === 'root' ? config.build?.path
|
|
43
|
+
: name === 'dist' ? config.dist?.path
|
|
44
|
+
: null
|
|
45
|
+
}
|
|
38
46
|
if (!str) {
|
|
39
47
|
throw new ControllerError(
|
|
40
48
|
this,
|
|
41
|
-
`Missing admin.${name}
|
|
49
|
+
`Missing \`config.admin.${name}\` configuration.`
|
|
42
50
|
)
|
|
43
51
|
}
|
|
44
52
|
return path.resolve(str)
|
|
@@ -85,8 +93,8 @@ export class AdminController extends Controller {
|
|
|
85
93
|
this.koa = new Koa()
|
|
86
94
|
this.koa.use(this.middleware())
|
|
87
95
|
if (this.mode === 'development') {
|
|
88
|
-
// Calling getPath() throws exception if admin.
|
|
89
|
-
if (this.getPath('
|
|
96
|
+
// Calling getPath() throws exception if config.admin.root is not defined:
|
|
97
|
+
if (this.getPath('root')) {
|
|
90
98
|
this.app.once('after:start', () => this.setupViteServer())
|
|
91
99
|
}
|
|
92
100
|
} else {
|
|
@@ -128,14 +136,14 @@ export class AdminController extends Controller {
|
|
|
128
136
|
const development = this.mode === 'development'
|
|
129
137
|
|
|
130
138
|
const cwd = path.resolve('.')
|
|
131
|
-
const root = this.getPath('
|
|
139
|
+
const root = this.getPath('root')
|
|
132
140
|
const base = `${this.url}/`
|
|
133
141
|
const views = path.join(root, 'views')
|
|
134
142
|
|
|
135
143
|
// Read `package.json` from the closest package.json, so we can emulate
|
|
136
144
|
// ESM-style imports mappings in rollup / vite.
|
|
137
145
|
const pkg = findUpSync('package.json', { cwd: root })
|
|
138
|
-
const { imports } = JSON.parse(fs.readFileSync(pkg, 'utf8'))
|
|
146
|
+
const { imports = {} } = JSON.parse(fs.readFileSync(pkg, 'utf8'))
|
|
139
147
|
|
|
140
148
|
return defineConfig(merge({
|
|
141
149
|
root,
|
|
@@ -209,7 +217,7 @@ export class AdminController extends Controller {
|
|
|
209
217
|
replacement: '#',
|
|
210
218
|
customResolver(id) {
|
|
211
219
|
for (const [find, replacement] of Object.entries(imports)) {
|
|
212
|
-
picomatch.isMatch(id, find, {
|
|
220
|
+
picomatch.isMatch(id, find.replace('*', '**'), {
|
|
213
221
|
capture: true,
|
|
214
222
|
onMatch({ input, regex }) {
|
|
215
223
|
const replacementPath = path.resolve(replacement)
|