@vcmap/plugin-cli 2.1.7 → 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 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" src="./node_modules/@vcmap/ui/start.js"></script>
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
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import program from 'commander';
2
+ import { program } from 'commander';
3
3
  import './src/defaultCommand.js';
4
4
  import { create, serve, build, pack, preview, update } from './index.js';
5
5
  import { version } from './src/pluginCliHelper.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/plugin-cli",
3
- "version": "2.1.7",
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
- "archiver": "^5.0.0",
35
- "commander": "^6.0.0",
36
- "express": "^4.17.3",
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.3.5",
40
- "tar": "^6.1.13",
41
- "vite": "^3.2.0",
42
- "vite-plugin-vue2": "^2.0.2",
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.23",
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 { createVuePlugin } from 'vite-plugin-vue2';
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: [createVuePlugin(), vcsOl()],
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: ['src/', 'dist/', 'plugin-assets/', 'LICENSE.md', 'README.md'],
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, 'CHANGES.md'),
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 archiver from 'archiver';
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
- return new Promise((resolve, reject) => {
43
- const zipStream = fs.createWriteStream(
44
- resolveContext('dist', `${name.replace(/\//, '-')}.zip`),
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
- zipStream.on('close', () => {
49
- resolve();
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
- archive.on('error', (err) => {
53
- reject(err);
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
- archive.on('warning', (err) => {
57
- logger.error(err);
58
- });
79
+ const fileName = resolveContext('dist', file);
80
+ const read = fs.createReadStream(fileName);
81
+ const write = fs.createWriteStream(`${fileName}.gz`);
59
82
 
60
- archive.pipe(zipStream);
61
- [
62
- ['package.json'],
63
- ['README.md'],
64
- ['config.json'],
65
- ['dist', 'index.js'],
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 { createVuePlugin } from 'vite-plugin-vue2';
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,18 +109,26 @@ export default async function serve(options) {
107
109
 
108
110
  const server = await createServer({
109
111
  root: getContext(),
110
- publicDir: false,
112
+ publicDir: './node_modules/@vcmap/ui/public',
111
113
  resolve: {
112
114
  alias: {
113
115
  '@cesium/engine': '@vcmap-cesium/engine',
116
+ tinyqueue: 'tinyqueue/tinyqueue.js',
114
117
  },
115
118
  dedupe: Object.keys(peerDependencies),
116
119
  },
117
120
  optimizeDeps: {
118
121
  exclude: ['@vcmap/ui', '@vcmap/core', 'ol', 'proj4'],
119
- include: ['fast-deep-equal', 'rbush-knn', 'pbf', '@vcmap-cesium/engine'],
122
+ include: [
123
+ 'fast-deep-equal',
124
+ 'rbush',
125
+ 'rbush-knn',
126
+ 'pbf',
127
+ '@vcmap-cesium/engine',
128
+ 'vue',
129
+ ],
120
130
  },
121
- plugins: [createVuePlugin(), createConfigJsonReloadPlugin()],
131
+ plugins: [vue2(), createConfigJsonReloadPlugin()],
122
132
  server: {
123
133
  middlewareMode: true,
124
134
  https: mergedOptions.https,