@opengis/cms 0.0.15 → 0.0.16
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 +8 -5
- package/plugin.js +32 -7
- package/server/app.js +9 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/cms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "cms",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Softpro",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"dev": "node server --cms=cms/softpro"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@opengis/admin": "0.
|
|
25
|
+
"@opengis/admin": "0.4.4",
|
|
26
26
|
"@opengis/fastify-auth": "1.1.0",
|
|
27
|
-
"@opengis/fastify-file": "1.1.
|
|
28
|
-
"@opengis/fastify-table": "1.4.
|
|
27
|
+
"@opengis/fastify-file": "1.1.2",
|
|
28
|
+
"@opengis/fastify-table": "1.4.5",
|
|
29
29
|
"@opengis/v3-core": "0.3.190",
|
|
30
30
|
"@opengis/v3-filter": "0.0.74",
|
|
31
31
|
"@vitejs/plugin-vue": "5.0.4",
|
|
@@ -42,6 +42,9 @@
|
|
|
42
42
|
"vue-i18n": "11.1.5",
|
|
43
43
|
"vue-router": "4.4.3"
|
|
44
44
|
},
|
|
45
|
+
"overrides": {
|
|
46
|
+
"@opengis/fastify-table": "1.4.5"
|
|
47
|
+
},
|
|
45
48
|
"devDependencies": {
|
|
46
49
|
"@parcel/watcher": "2.4.1",
|
|
47
50
|
"@tailwindcss/typography": "0.5.10",
|
|
@@ -58,4 +61,4 @@
|
|
|
58
61
|
"vite": "5.1.4",
|
|
59
62
|
"vue-tsc": "1.8.27"
|
|
60
63
|
}
|
|
61
|
-
}
|
|
64
|
+
}
|
package/plugin.js
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
|
|
1
5
|
import { config, execMigrations } from '@opengis/fastify-table/utils.js';
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
// cross-env cms=cms/softpro npm start
|
|
10
|
+
if (process.argv.find(el => el.includes('--cms'))) {
|
|
11
|
+
const subdir = process.argv.find(el => el.includes('--cms')).substring(6);
|
|
12
|
+
const cmsDir = path.join(dirname, '..', subdir).replace(/\\/g, '/'); // from app.js
|
|
13
|
+
|
|
14
|
+
const cmsConfig = existsSync(path.join(cmsDir, 'setting.json'))
|
|
15
|
+
? JSON.parse(readFileSync(path.join(cmsDir, 'setting.json'), 'utf8'))
|
|
16
|
+
: {};
|
|
17
|
+
|
|
18
|
+
config.auth = config.auth || cmsConfig.auth;
|
|
19
|
+
config.pg = cmsConfig.pg;
|
|
20
|
+
config.cms = cmsConfig.cms || {};
|
|
21
|
+
config.cms.root = cmsDir;
|
|
22
|
+
config.folder = path.posix.join(config.folder || '', config.cms.folder || subdir);
|
|
23
|
+
}
|
|
4
24
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
25
|
+
export default async function (app, opts = config) {
|
|
26
|
+
const { prefix = '/api' } = opts;
|
|
27
|
+
if (!opts.pg || opts.cms?.provider === 'file') {
|
|
28
|
+
app.register(import('./server/routes/fileContent/index.mjs'), { prefix });
|
|
29
|
+
} else {
|
|
30
|
+
app.register(import('./server/routes/cms/index.mjs'), { prefix });
|
|
31
|
+
app.register(import('./server/routes/contentType/index.mjs'), { prefix });
|
|
32
|
+
app.register(import('./server/routes/category/index.mjs'), { prefix });
|
|
33
|
+
const pg = await getPGAsync(opts.pg);
|
|
34
|
+
execMigrations(path.join(dirname, 'migrations'), pg).catch(err => console.log(err));
|
|
35
|
+
}
|
|
11
36
|
}
|
package/server/app.js
CHANGED
|
@@ -1,50 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
|
|
5
|
-
import { config, pgClients, execMigrations, getPGAsync } from '@opengis/fastify-table/utils.js';
|
|
6
|
-
|
|
7
|
-
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
|
|
9
|
-
// cross-env cms=cms/softpro npm start
|
|
10
|
-
if (process.argv.find(el => el.includes('--cms'))) {
|
|
11
|
-
const subdir = process.argv.find(el => el.includes('--cms')).substring(6);
|
|
12
|
-
const cmsDir = path.join(dirname, '..', subdir).replace(/\\/g, '/'); // from app.js
|
|
13
|
-
|
|
14
|
-
const cmsConfig = existsSync(path.join(cmsDir, 'setting.json'))
|
|
15
|
-
? JSON.parse(readFileSync(path.join(cmsDir, 'setting.json'), 'utf8'))
|
|
16
|
-
: {};
|
|
17
|
-
|
|
18
|
-
config.auth = config.auth || cmsConfig.auth;
|
|
19
|
-
config.pg = cmsConfig.pg;
|
|
20
|
-
config.cms = cmsConfig.cms || {};
|
|
21
|
-
config.cms.root = cmsDir;
|
|
22
|
-
config.folder = path.posix.join(config.folder || '', config.cms.folder || subdir);
|
|
23
|
-
}
|
|
1
|
+
import { config } from '@opengis/fastify-table/utils.js';
|
|
24
2
|
|
|
25
3
|
config.prefix = config.prefix || '/api';
|
|
26
|
-
const { prefix } = config;
|
|
27
4
|
|
|
28
|
-
export default async function (
|
|
5
|
+
export default async function (app) {
|
|
29
6
|
// core
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
app.register(import('./plugins/adminHook.js'));
|
|
8
|
+
app.register(import('./plugins/hook.js'));
|
|
32
9
|
|
|
33
|
-
|
|
10
|
+
app.register(import('@opengis/fastify-table'), config);
|
|
34
11
|
// fastify.register(import('@opengis/fastify-auth'), config);
|
|
35
|
-
|
|
12
|
+
app.register(import('@opengis/fastify-file'), config);
|
|
36
13
|
|
|
37
|
-
|
|
14
|
+
app.register(import('./plugins/vite.js'));
|
|
38
15
|
// API
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!config.pg || config.cms?.provider === 'file') {
|
|
42
|
-
fastify.register(import('./routes/fileContent/index.mjs'), { prefix });
|
|
43
|
-
} else {
|
|
44
|
-
fastify.register(import('./routes/cms/index.mjs'), { prefix });
|
|
45
|
-
fastify.register(import('./routes/contentType/index.mjs'), { prefix });
|
|
46
|
-
fastify.register(import('./routes/category/index.mjs'), { prefix });
|
|
47
|
-
const pg = await getPGAsync(config.pg);
|
|
48
|
-
execMigrations(path.join(dirname, 'migrations'), pg).catch(err => console.log(err));
|
|
49
|
-
}
|
|
16
|
+
app.register(import('./routes/root.mjs'));
|
|
17
|
+
app.register(import('../plugin.js'));
|
|
50
18
|
}
|