@vcmap/plugin-cli 2.0.10 → 2.0.12
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/README.md +70 -14
- package/assets/{helloWorld/.gitlab-ci.yml → .gitlab-ci.yml} +10 -0
- package/assets/gitignore +30 -0
- package/assets/index.html +29 -33
- package/assets/index.js +62 -0
- package/cli.js +7 -9
- package/index.js +1 -0
- package/package.json +8 -8
- package/src/build.js +0 -10
- package/src/buildStagingApp.js +12 -1
- package/src/create.js +198 -87
- package/src/hostingHelpers.js +9 -18
- package/src/packageJsonHelpers.js +34 -1
- package/src/pluginCliHelper.js +41 -0
- package/src/preview.js +13 -9
- package/src/serve.js +18 -17
- package/src/update.js +50 -0
- package/assets/helloWorld/build/staging/Dockerfile +0 -2
- package/assets/helloWorld/plugin-assets/vcs_logo.png +0 -0
- package/assets/helloWorld/src/helloWorld.vue +0 -54
- package/assets/helloWorld/src/index.js +0 -72
package/src/serve.js
CHANGED
|
@@ -4,8 +4,6 @@ import { createVuePlugin } from 'vite-plugin-vue2';
|
|
|
4
4
|
import express from 'express';
|
|
5
5
|
import { logger } from '@vcsuite/cli-logger';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import { VuetifyResolver } from 'unplugin-vue-components/dist/resolvers.js';
|
|
8
|
-
import Components from 'unplugin-vue-components/dist/vite.js';
|
|
9
7
|
import { getContext } from './context.js';
|
|
10
8
|
import {
|
|
11
9
|
addConfigRoute,
|
|
@@ -17,10 +15,11 @@ import {
|
|
|
17
15
|
resolveMapUi,
|
|
18
16
|
} from './hostingHelpers.js';
|
|
19
17
|
import { getPluginName } from './packageJsonHelpers.js';
|
|
18
|
+
import { getVcmConfigJs } from './pluginCliHelper.js';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* @typedef {HostingOptions} ServeOptions
|
|
23
|
-
* @property {string} [mapConfig] -
|
|
22
|
+
* @property {string} [mapConfig] - a filename or URL to a map config
|
|
24
23
|
*/
|
|
25
24
|
|
|
26
25
|
async function getProxy(protocol, port) {
|
|
@@ -50,6 +49,13 @@ async function getProxy(protocol, port) {
|
|
|
50
49
|
if (hasThisPlugin) {
|
|
51
50
|
delete proxy[hasThisPlugin];
|
|
52
51
|
}
|
|
52
|
+
|
|
53
|
+
// exampleData is not part of the @vcmap/ui package and must be proxied therefore
|
|
54
|
+
proxy['^/exampleData'] = {
|
|
55
|
+
target: 'https://raw.githubusercontent.com/virtualcitySYSTEMS/map-ui/main',
|
|
56
|
+
changeOrigin: true,
|
|
57
|
+
secure: false,
|
|
58
|
+
};
|
|
53
59
|
return proxy;
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -62,13 +68,15 @@ export default async function serve(options) {
|
|
|
62
68
|
logger.error('Can only serve in dev mode, if the map ui is a dependency of the current context');
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
71
|
+
const { default: vcmConfigJs } = await getVcmConfigJs();
|
|
72
|
+
const mergedOptions = { ...vcmConfigJs, ...options };
|
|
65
73
|
await printVcmapUiVersion();
|
|
66
74
|
checkReservedDirectories();
|
|
67
75
|
const app = express();
|
|
68
|
-
const port =
|
|
76
|
+
const port = mergedOptions.port || 8008;
|
|
69
77
|
|
|
70
78
|
logger.info('Starting development server...');
|
|
71
|
-
const proxy = await getProxy(
|
|
79
|
+
const proxy = await getProxy(mergedOptions.https ? 'https' : 'http', port);
|
|
72
80
|
|
|
73
81
|
const server = await createServer({
|
|
74
82
|
root: getContext(),
|
|
@@ -90,18 +98,11 @@ export default async function serve(options) {
|
|
|
90
98
|
plugins: [
|
|
91
99
|
createVuePlugin(),
|
|
92
100
|
createConfigJsonReloadPlugin(),
|
|
93
|
-
Components({
|
|
94
|
-
resolvers: [
|
|
95
|
-
VuetifyResolver(),
|
|
96
|
-
],
|
|
97
|
-
include: [],
|
|
98
|
-
exclude: [],
|
|
99
|
-
}),
|
|
100
101
|
],
|
|
101
102
|
server: {
|
|
102
|
-
middlewareMode:
|
|
103
|
-
https:
|
|
104
|
-
proxy,
|
|
103
|
+
middlewareMode: true,
|
|
104
|
+
https: mergedOptions.https,
|
|
105
|
+
proxy: { ...mergedOptions.proxy, ...proxy },
|
|
105
106
|
},
|
|
106
107
|
css: {
|
|
107
108
|
preprocessorOptions: {
|
|
@@ -112,10 +113,10 @@ export default async function serve(options) {
|
|
|
112
113
|
},
|
|
113
114
|
});
|
|
114
115
|
|
|
115
|
-
addMapConfigRoute(app,
|
|
116
|
+
addMapConfigRoute(app, mergedOptions.mapConfig, mergedOptions.auth, mergedOptions.config);
|
|
116
117
|
addIndexRoute(app, server);
|
|
117
118
|
addPluginAssets(app, 'src');
|
|
118
|
-
await addConfigRoute(app,
|
|
119
|
+
await addConfigRoute(app, mergedOptions.auth, mergedOptions.config);
|
|
119
120
|
|
|
120
121
|
app.use(server.middlewares);
|
|
121
122
|
|
package/src/update.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { logger } from '@vcsuite/cli-logger';
|
|
2
|
+
import { DepType, getPackageJson, installDeps } from './packageJsonHelpers.js';
|
|
3
|
+
import { name, promiseExec } from './pluginCliHelper.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Update peer dependencies of a provided packageJson with @vcmap/ui@latest peers
|
|
7
|
+
* @param {Object} pluginPeer - peerDependencies of a plugin
|
|
8
|
+
* @param {string} pluginPath
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
export async function updatePeerDependencies(pluginPeer, pluginPath) {
|
|
12
|
+
const { stdout, stderr } = await promiseExec('npm view @vcmap/ui --json');
|
|
13
|
+
logger.error(stderr);
|
|
14
|
+
const { name: mapName, peerDependencies: mapPeer } = JSON.parse(stdout);
|
|
15
|
+
const peerDeps = [`${mapName}@latest`]; // @vcmap/ui is a required peer dep and will be updated in any case
|
|
16
|
+
if (pluginPeer) {
|
|
17
|
+
const pluginPeerDeps = Object.keys(pluginPeer)
|
|
18
|
+
.filter(depName => !!mapPeer[depName] && pluginPeer[depName] !== mapPeer[depName])
|
|
19
|
+
.map(depName => `${depName}@${mapPeer[depName]}`);
|
|
20
|
+
peerDeps.push(pluginPeerDeps);
|
|
21
|
+
}
|
|
22
|
+
logger.spin('Updating peer dependencies');
|
|
23
|
+
await installDeps(peerDeps, DepType.PEER, pluginPath);
|
|
24
|
+
logger.stopSpinner();
|
|
25
|
+
logger.success('Updated peer dependencies');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Updates the @vcmap/plugin-cli
|
|
30
|
+
* @param {string} pluginPath
|
|
31
|
+
* @returns {Promise<void>}
|
|
32
|
+
*/
|
|
33
|
+
async function updateCli(pluginPath) {
|
|
34
|
+
logger.spin(`Updating ${name}`);
|
|
35
|
+
await installDeps([`${name}@latest`], DepType.DEV, pluginPath);
|
|
36
|
+
logger.stopSpinner();
|
|
37
|
+
logger.success(`Updated ${name}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Updating peer dependencies to @vmap/ui@latest
|
|
42
|
+
* Updating @vcmap/plugin-cli
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
export default async function update() {
|
|
46
|
+
const packageJson = await getPackageJson();
|
|
47
|
+
await updatePeerDependencies(packageJson.peerDependencies, process.cwd());
|
|
48
|
+
await updateCli(process.cwd());
|
|
49
|
+
logger.success(`Updated plugin ${packageJson.name}`);
|
|
50
|
+
}
|
|
Binary file
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-sheet class="hello-world">
|
|
3
|
-
<v-card class="pa-2 ma-2">
|
|
4
|
-
<v-container>
|
|
5
|
-
<v-row class="justify-center mb-4">
|
|
6
|
-
<h1>{{ $t('helloWorld.helloWorld') }}</h1>
|
|
7
|
-
</v-row>
|
|
8
|
-
<v-row class="justify-center mb-4">
|
|
9
|
-
<v-img
|
|
10
|
-
:src="logoUrl"
|
|
11
|
-
alt="plugin-assets example"
|
|
12
|
-
max-width="200"
|
|
13
|
-
/>
|
|
14
|
-
</v-row>
|
|
15
|
-
<v-row class="justify-center">
|
|
16
|
-
<VcsButton
|
|
17
|
-
icon="mdi-times"
|
|
18
|
-
@click="closeSelf"
|
|
19
|
-
>
|
|
20
|
-
{{ $t('helloWorld.close')}}
|
|
21
|
-
</VcsButton>
|
|
22
|
-
</v-row>
|
|
23
|
-
</v-container>
|
|
24
|
-
</v-card>
|
|
25
|
-
</v-sheet>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<style>
|
|
29
|
-
.hello-world {
|
|
30
|
-
background-color: aqua;
|
|
31
|
-
}
|
|
32
|
-
</style>
|
|
33
|
-
<script>
|
|
34
|
-
import { inject } from 'vue';
|
|
35
|
-
import { VcsButton, getPluginAssetUrl } from '@vcmap/ui';
|
|
36
|
-
import { name } from '../package.json';
|
|
37
|
-
|
|
38
|
-
export const windowId = 'hello_world_window_id_plugin-cli';
|
|
39
|
-
|
|
40
|
-
export default {
|
|
41
|
-
name: 'HelloWorld',
|
|
42
|
-
components: { VcsButton },
|
|
43
|
-
setup() {
|
|
44
|
-
const app = inject('vcsApp');
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
closeSelf() {
|
|
48
|
-
app.windowManager.remove(windowId);
|
|
49
|
-
},
|
|
50
|
-
logoUrl: getPluginAssetUrl(app, name, 'plugin-assets/vcs_logo.png'),
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
</script>
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { WindowSlot } from '@vcmap/ui';
|
|
2
|
-
import { version, name } from '../package.json';
|
|
3
|
-
import HelloWorld, { windowId } from './helloWorld.vue';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {T} config - the configuration of this plugin instance, passed in from the app.
|
|
7
|
-
* @param {string} baseUrl - the absolute URL from which the plugin was loaded (without filename, ending on /)
|
|
8
|
-
* @returns {import("@vcmap/ui/src/vcsUiApp").VcsPlugin<T>}
|
|
9
|
-
* @template {Object} T
|
|
10
|
-
* @template {Object} S
|
|
11
|
-
*/
|
|
12
|
-
export default function(config, baseUrl) {
|
|
13
|
-
return {
|
|
14
|
-
get name() { return name; },
|
|
15
|
-
get version() { return version; },
|
|
16
|
-
/**
|
|
17
|
-
* @param {import("@vcmap/ui").VcsUiApp} vcsUiApp
|
|
18
|
-
* @param {S=} state
|
|
19
|
-
* @returns {Promise<void>}
|
|
20
|
-
*/
|
|
21
|
-
initialize: async (vcsUiApp, state) => {
|
|
22
|
-
console.log('Called before loading the rest of the current context. Passed in the containing Vcs UI App ');
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* @param {import("@vcmap/ui").VcsUiApp} vcsUiApp
|
|
26
|
-
* @returns {Promise<void>}
|
|
27
|
-
*/
|
|
28
|
-
onVcsAppMounted: async (vcsUiApp) => {
|
|
29
|
-
console.log('Called when the root UI component is mounted and managers are ready to accept components');
|
|
30
|
-
vcsUiApp.windowManager.add({
|
|
31
|
-
id: windowId,
|
|
32
|
-
component: HelloWorld,
|
|
33
|
-
WindowSlot: WindowSlot.DETACHED,
|
|
34
|
-
position: {
|
|
35
|
-
left: '40%',
|
|
36
|
-
right: '40%',
|
|
37
|
-
},
|
|
38
|
-
}, name);
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* @returns {Promise<S>}
|
|
42
|
-
*/
|
|
43
|
-
getState: async () => {
|
|
44
|
-
console.log('Called when serializing this plugin instance');
|
|
45
|
-
return {};
|
|
46
|
-
},
|
|
47
|
-
/**
|
|
48
|
-
* @returns {Promise<T>}
|
|
49
|
-
*/
|
|
50
|
-
toJSON: async () => {
|
|
51
|
-
console.log('Called when serializing this plugin instance');
|
|
52
|
-
return {};
|
|
53
|
-
},
|
|
54
|
-
i18n: {
|
|
55
|
-
en: {
|
|
56
|
-
helloWorld: {
|
|
57
|
-
helloWorld: '@vcmap/plugin-cli - Hello World',
|
|
58
|
-
close: 'Close',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
de: {
|
|
62
|
-
helloWorld: {
|
|
63
|
-
helloWorld: '@vcmap/plugin-cli - Hallo Welt',
|
|
64
|
-
close: 'Schließen',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
destroy() {
|
|
69
|
-
console.log('hook to cleanup');
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
};
|