@vcmap/plugin-cli 2.1.8 → 2.1.9
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/assets/index.html +33 -1
- package/cli.js +1 -1
- package/package.json +9 -10
- package/src/build.js +2 -2
- package/src/create.js +9 -2
- package/src/pack.js +47 -38
- package/src/serve.js +7 -4
package/assets/index.html
CHANGED
|
@@ -3,6 +3,35 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
6
|
+
<link
|
|
7
|
+
rel="icon"
|
|
8
|
+
type="image/png"
|
|
9
|
+
href="./assets/favicon-32.png"
|
|
10
|
+
sizes="32x32"
|
|
11
|
+
/>
|
|
12
|
+
<link
|
|
13
|
+
rel="icon"
|
|
14
|
+
type="image/png"
|
|
15
|
+
href="./assets/favicon-128.png"
|
|
16
|
+
sizes="128x128"
|
|
17
|
+
/>
|
|
18
|
+
<link
|
|
19
|
+
rel="icon"
|
|
20
|
+
type="image/png"
|
|
21
|
+
href="./assets/favicon-180.png"
|
|
22
|
+
sizes="180x180"
|
|
23
|
+
/>
|
|
24
|
+
<link
|
|
25
|
+
rel="icon"
|
|
26
|
+
type="image/png"
|
|
27
|
+
href="./assets/favicon-192.png"
|
|
28
|
+
sizes="192x192"
|
|
29
|
+
/>
|
|
30
|
+
<link rel="icon" type="image/svg+xml" href="./assets/favicon.svg" />
|
|
31
|
+
<link
|
|
32
|
+
rel="stylesheet"
|
|
33
|
+
href="./assets/@mdi/font/css/materialdesignicons.min.css"
|
|
34
|
+
/>
|
|
6
35
|
</head>
|
|
7
36
|
<body style="height: 100vh">
|
|
8
37
|
<noscript>
|
|
@@ -72,6 +101,9 @@
|
|
|
72
101
|
}
|
|
73
102
|
}
|
|
74
103
|
</style>
|
|
75
|
-
<script type="module"
|
|
104
|
+
<script type="module">
|
|
105
|
+
import { initAppFromAppConfig } from '@vcmap/ui';
|
|
106
|
+
initAppFromAppConfig('#app', 'app.config.json');
|
|
107
|
+
</script>
|
|
76
108
|
</body>
|
|
77
109
|
</html>
|
package/cli.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/plugin-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "A CLI to help develop and build plugins for the VC Map",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,19 +31,18 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@vcmap/rollup-plugin-vcs-ol": "^1.0.2",
|
|
33
33
|
"@vcsuite/cli-logger": "^1.0.0",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"prompts": "^2.4.1",
|
|
34
|
+
"commander": "^10.0.1",
|
|
35
|
+
"express": "^4.18.2",
|
|
36
|
+
"prompts": "^2.4.2",
|
|
38
37
|
"sass": "1.32.13",
|
|
39
|
-
"semver": "^7.
|
|
40
|
-
"tar": "^6.1.
|
|
41
|
-
"vite": "^3.
|
|
42
|
-
"
|
|
38
|
+
"semver": "^7.5.1",
|
|
39
|
+
"tar": "^6.1.15",
|
|
40
|
+
"vite": "^4.3.8",
|
|
41
|
+
"@vitejs/plugin-vue2": "^2.2.0",
|
|
43
42
|
"vue-template-compiler": "~2.7.14"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
|
-
"@vcmap/ui": "^5.0.0-rc.
|
|
45
|
+
"@vcmap/ui": "^5.0.0-rc.25",
|
|
47
46
|
"vue": "~2.7.14"
|
|
48
47
|
},
|
|
49
48
|
"peerDependenciesMeta": {
|
package/src/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { rm, mkdir } from 'fs/promises';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
-
import
|
|
4
|
+
import vue2 from '@vitejs/plugin-vue2';
|
|
5
5
|
import vcsOl from '@vcmap/rollup-plugin-vcs-ol';
|
|
6
6
|
import { logger } from '@vcsuite/cli-logger';
|
|
7
7
|
import { getPluginEntry, getPluginName } from './packageJsonHelpers.js';
|
|
@@ -19,7 +19,7 @@ import { executeUiNpm, resolveMapUi } from './hostingHelpers.js';
|
|
|
19
19
|
export function getDefaultConfig() {
|
|
20
20
|
return {
|
|
21
21
|
publicDir: false,
|
|
22
|
-
plugins: [
|
|
22
|
+
plugins: [vue2(), vcsOl()],
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
package/src/create.js
CHANGED
|
@@ -154,7 +154,14 @@ async function createPluginTemplate(options, pluginPath) {
|
|
|
154
154
|
license: options.license,
|
|
155
155
|
dependencies: {},
|
|
156
156
|
keywords: ['vcmap', 'plugin'],
|
|
157
|
-
files: [
|
|
157
|
+
files: [
|
|
158
|
+
'src/',
|
|
159
|
+
'dist/',
|
|
160
|
+
'plugin-assets/',
|
|
161
|
+
'LICENSE.md',
|
|
162
|
+
'README.md',
|
|
163
|
+
'CHANGELOG.md',
|
|
164
|
+
],
|
|
158
165
|
exports: {
|
|
159
166
|
'.': './src/index.js',
|
|
160
167
|
'./dist': './dist/index.js',
|
|
@@ -273,7 +280,7 @@ async function createPlugin(options) {
|
|
|
273
280
|
);
|
|
274
281
|
|
|
275
282
|
const writeChangesPromise = fs.promises.writeFile(
|
|
276
|
-
path.join(pluginPath, '
|
|
283
|
+
path.join(pluginPath, 'CHANGELOG.md'),
|
|
277
284
|
`# v${options.version}\nDocument features and fixes`,
|
|
278
285
|
);
|
|
279
286
|
|
package/src/pack.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import tar from 'tar';
|
|
4
|
+
import { pipeline } from 'stream';
|
|
5
|
+
import { createGzip } from 'zlib';
|
|
6
|
+
import { rm } from 'fs/promises';
|
|
3
7
|
import { logger } from '@vcsuite/cli-logger';
|
|
4
8
|
import { getPluginName } from './packageJsonHelpers.js';
|
|
5
|
-
import { resolveContext } from './context.js';
|
|
9
|
+
import { getContext, resolveContext } from './context.js';
|
|
6
10
|
import build from './build.js';
|
|
7
11
|
|
|
8
12
|
/**
|
|
@@ -38,49 +42,54 @@ async function ensureConfigJson() {
|
|
|
38
42
|
* @param {string} name
|
|
39
43
|
* @returns {Promise<void>}
|
|
40
44
|
*/
|
|
41
|
-
function zip(name) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
46
|
-
const archive = archiver('zip', { zlib: { level: 5 } });
|
|
45
|
+
async function zip(name) {
|
|
46
|
+
if (fs.existsSync(resolveContext('CHANGES.md'))) {
|
|
47
|
+
console.error('Please rename CHANGES.md to CHANGELOG.md');
|
|
48
|
+
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const files = [
|
|
51
|
+
['package.json'],
|
|
52
|
+
['README.md'],
|
|
53
|
+
['CHANGELOG.md'],
|
|
54
|
+
['LICENSE.md'],
|
|
55
|
+
['config.json'],
|
|
56
|
+
['plugin-assets'],
|
|
57
|
+
]
|
|
58
|
+
.map((fileArray) =>
|
|
59
|
+
path.relative(resolveContext(), resolveContext(...fileArray)),
|
|
60
|
+
)
|
|
61
|
+
.filter(fs.existsSync);
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
const file = `${name.replace(/\//, '-')}.tar`;
|
|
64
|
+
await tar.c(
|
|
65
|
+
{
|
|
66
|
+
file: resolveContext('dist', file),
|
|
67
|
+
cwd: getContext(),
|
|
68
|
+
},
|
|
69
|
+
files,
|
|
70
|
+
);
|
|
71
|
+
await tar.r(
|
|
72
|
+
{
|
|
73
|
+
file: resolveContext('dist', file),
|
|
74
|
+
cwd: resolveContext('dist'),
|
|
75
|
+
},
|
|
76
|
+
['index.js'],
|
|
77
|
+
);
|
|
55
78
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
79
|
+
const fileName = resolveContext('dist', file);
|
|
80
|
+
const read = fs.createReadStream(fileName);
|
|
81
|
+
const write = fs.createWriteStream(`${fileName}.gz`);
|
|
59
82
|
|
|
60
|
-
|
|
61
|
-
[
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
].forEach((fileArray) => {
|
|
67
|
-
const file = resolveContext(...fileArray);
|
|
68
|
-
if (fs.existsSync(file)) {
|
|
69
|
-
archive.file(file, { name: `${name}/${fileArray.pop()}` });
|
|
83
|
+
await new Promise((res, rej) => {
|
|
84
|
+
pipeline([read, createGzip(), write], (err) => {
|
|
85
|
+
if (err) {
|
|
86
|
+
rej(err);
|
|
87
|
+
} else {
|
|
88
|
+
res();
|
|
70
89
|
}
|
|
71
90
|
});
|
|
72
|
-
|
|
73
|
-
if (fs.existsSync(resolveContext('plugin-assets'))) {
|
|
74
|
-
archive.directory(
|
|
75
|
-
resolveContext('plugin-assets'),
|
|
76
|
-
`${name}/plugin-assets`,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
archive.finalize().then(() => {
|
|
81
|
-
resolve();
|
|
82
|
-
});
|
|
83
91
|
});
|
|
92
|
+
await rm(fileName);
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
/**
|
package/src/serve.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { createServer } from 'vite';
|
|
3
|
-
import
|
|
3
|
+
import vue2 from '@vitejs/plugin-vue2';
|
|
4
4
|
import express from 'express';
|
|
5
5
|
import { logger } from '@vcsuite/cli-logger';
|
|
6
6
|
import path from 'path';
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from './hostingHelpers.js';
|
|
18
18
|
import { getPackageJson, getPluginName } from './packageJsonHelpers.js';
|
|
19
19
|
import { getVcmConfigJs } from './pluginCliHelper.js';
|
|
20
|
-
import { buildMapUI } from './build.js';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* @typedef {HostingOptions} ServeOptions
|
|
@@ -93,10 +92,13 @@ export default async function serve(options) {
|
|
|
93
92
|
const vcmConfigJs = await getVcmConfigJs();
|
|
94
93
|
const mergedOptions = { ...vcmConfigJs, ...options };
|
|
95
94
|
await printVcmapUiVersion();
|
|
95
|
+
/*
|
|
96
96
|
// In case @vcmap/ui is linked via git+ssh, dist folder is not available and must be built first
|
|
97
|
+
// Currently not needed, keep it here if the same problem happens again
|
|
97
98
|
if (!fs.existsSync(resolveMapUi('dist'))) {
|
|
98
99
|
await buildMapUI();
|
|
99
100
|
}
|
|
101
|
+
*/
|
|
100
102
|
checkReservedDirectories();
|
|
101
103
|
const app = express();
|
|
102
104
|
const port = mergedOptions.port || 8008;
|
|
@@ -107,7 +109,7 @@ export default async function serve(options) {
|
|
|
107
109
|
|
|
108
110
|
const server = await createServer({
|
|
109
111
|
root: getContext(),
|
|
110
|
-
publicDir:
|
|
112
|
+
publicDir: './node_modules/@vcmap/ui/public',
|
|
111
113
|
resolve: {
|
|
112
114
|
alias: {
|
|
113
115
|
'@cesium/engine': '@vcmap-cesium/engine',
|
|
@@ -119,13 +121,14 @@ export default async function serve(options) {
|
|
|
119
121
|
exclude: ['@vcmap/ui', '@vcmap/core', 'ol', 'proj4'],
|
|
120
122
|
include: [
|
|
121
123
|
'fast-deep-equal',
|
|
124
|
+
'rbush',
|
|
122
125
|
'rbush-knn',
|
|
123
126
|
'pbf',
|
|
124
127
|
'@vcmap-cesium/engine',
|
|
125
128
|
'vue',
|
|
126
129
|
],
|
|
127
130
|
},
|
|
128
|
-
plugins: [
|
|
131
|
+
plugins: [vue2(), createConfigJsonReloadPlugin()],
|
|
129
132
|
server: {
|
|
130
133
|
middlewareMode: true,
|
|
131
134
|
https: mergedOptions.https,
|