@vcmap/plugin-cli 2.1.1 → 2.1.3

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 CHANGED
@@ -177,7 +177,7 @@ caching more readily.
177
177
  The following libraries are provided by the @vcmap/ui in a deployed application. You should define these
178
178
  as peer dependencies if you use them in your plugin:
179
179
  - @vcmap/core
180
- - @vcmap/cesium
180
+ - @vcmap-cesium/engine
181
181
  - ol
182
182
  - vue
183
183
  - vuetify
@@ -197,12 +197,12 @@ a plugin and _that the provided index files_ are used (over directly importing f
197
197
 
198
198
  For instance:
199
199
  ```js
200
- import Cartesian3 from '@vcmap/cesium/Source/Core/Cartesian3.js';
200
+ import Cartesian3 from '@vcmap-cesium/engine/Source/Core/Cartesian3.js';
201
201
  ```
202
202
 
203
203
  should be rewritten to:
204
204
  ```js
205
- import { Cartesian3 } from '@vcmap/cesium';
205
+ import { Cartesian3 } from '@vcmap-cesium/engine';
206
206
  ```
207
207
 
208
208
  ### What about openlayers?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/plugin-cli",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "A CLI to help develop and build plugins for the VC Map",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  "vue-template-compiler": "~2.7.14"
41
41
  },
42
42
  "peerDependencies": {
43
- "@vcmap/ui": "^5.0.0-rc.15",
43
+ "@vcmap/ui": "^5.0.0-rc.21",
44
44
  "vue": "~2.7.14"
45
45
  },
46
46
  "peerDependenciesMeta": {
@@ -56,8 +56,7 @@
56
56
  "eslint": "^8.9.0"
57
57
  },
58
58
  "eslintIgnore": [
59
- "node_modules",
60
- "assets/helloWorld"
59
+ "node_modules"
61
60
  ],
62
61
  "eslintConfig": {
63
62
  "extends": "@vcsuite/eslint-config/node",
package/src/build.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import path from 'path';
2
- import fs from 'fs/promises';
2
+ import { rm, mkdir } from 'fs/promises';
3
+ import fs from 'fs';
3
4
  import { createVuePlugin } from 'vite-plugin-vue2';
4
5
  import vcsOl from '@vcmap/rollup-plugin-vcs-ol';
5
6
  import { logger } from '@vcsuite/cli-logger';
6
7
  import { getPluginEntry, getPluginName } from './packageJsonHelpers.js';
7
8
  import { getContext } from './context.js';
9
+ import { executeUiNpm, resolveMapUi } from './hostingHelpers.js';
8
10
 
9
11
  /**
10
12
  * @typedef {Object} BuildOptions
@@ -30,12 +32,12 @@ export function getDefaultConfig() {
30
32
  */
31
33
  export async function getLibraryPaths(pluginName) {
32
34
  const { libraries } = await import('@vcmap/ui/build/buildHelpers.js');
33
- const pluginPath = path.join('plugins', ...pluginName.split('/'));
35
+ const pluginPath = path.posix.join('plugins', ...pluginName.split('/'));
34
36
  const libraryPaths = {};
35
37
  Object.entries(libraries).forEach(([library, assetName]) => {
36
- const assetPath = path.join('assets', `${assetName}.js`);
38
+ const assetPath = path.posix.join('assets', `${assetName}.js`);
37
39
 
38
- libraryPaths[library] = path.relative(pluginPath, assetPath);
40
+ libraryPaths[library] = path.posix.relative(pluginPath, assetPath);
39
41
  });
40
42
  return libraryPaths;
41
43
  }
@@ -55,8 +57,8 @@ export default async function buildModule(options) {
55
57
  const libraryPaths = await getLibraryPaths(pluginName);
56
58
  const distPath = path.join(getContext(), 'dist');
57
59
  if (!options.keepDistFolder) {
58
- await fs.rm(distPath, { recursive: true, force: true });
59
- await fs.mkdir(distPath);
60
+ await rm(distPath, { recursive: true, force: true });
61
+ await mkdir(distPath);
60
62
  }
61
63
  const external = Object.keys(libraryPaths);
62
64
  const config = {
@@ -89,3 +91,20 @@ export default async function buildModule(options) {
89
91
  const { buildLibrary } = await import('@vcmap/ui/build/buildHelpers.js');
90
92
  await buildLibrary(config, options.outputPath ?? '', 'index', '', true);
91
93
  }
94
+
95
+ /**
96
+ * Builds the @vcmap/ui dependency and removes its own core dependency
97
+ * @returns {Promise<void>}
98
+ */
99
+ export async function buildMapUI() {
100
+ logger.spin('building @vcmap/ui dependency');
101
+ await executeUiNpm('--production=false --no-package-lock', 'install');
102
+ // remove own core dependency to allow linking core via git+ssh
103
+ const coreDepPath = resolveMapUi('node_modules', '@vcmap', 'core');
104
+ if (fs.existsSync(coreDepPath)) {
105
+ await rm(coreDepPath, { recursive: true, force: true });
106
+ }
107
+ await executeUiNpm('build');
108
+ logger.stopSpinner();
109
+ logger.info('@vcmap/ui built');
110
+ }
@@ -3,9 +3,9 @@ import path from 'path';
3
3
  import fs from 'fs';
4
4
  import { logger } from '@vcsuite/cli-logger';
5
5
  import { getContext, resolveContext } from './context.js';
6
- import { executeUiNpm, getConfigJson, resolveMapUi } from './hostingHelpers.js';
6
+ import { getConfigJson, resolveMapUi } from './hostingHelpers.js';
7
7
  import { getPluginName } from './packageJsonHelpers.js';
8
- import buildModule, { getDefaultConfig } from './build.js';
8
+ import buildModule, { buildMapUI, getDefaultConfig } from './build.js';
9
9
  import setupMapUi from './setupMapUi.js';
10
10
 
11
11
 
@@ -37,11 +37,7 @@ export default async function buildStagingApp() {
37
37
 
38
38
  // In case @vcmap/ui is linked via git+ssh, dist folder is not available and must be built first
39
39
  if (!fs.existsSync(resolveMapUi('dist'))) {
40
- logger.spin('building @vcmap/ui');
41
- await executeUiNpm('--production=false --no-package-lock', 'install');
42
- await executeUiNpm('build');
43
- logger.stopSpinner();
44
- logger.info('@vcmap/ui built');
40
+ await buildMapUI();
45
41
  }
46
42
 
47
43
  await copyFile(
package/src/create.js CHANGED
@@ -311,7 +311,7 @@ export default async function create() {
311
311
 
312
312
  const peerDependencyChoices = [
313
313
  { title: '@vcmap/core', value: '@vcmap/core' },
314
- { title: '@vcmap/cesium', value: '@vcmap/cesium' },
314
+ { title: '@vcmap-cesium/engine', value: '@vcmap-cesium/engine' },
315
315
  { title: 'ol', value: 'ol' },
316
316
  { title: 'vue', value: 'vue' },
317
317
  { title: 'vuetify', value: 'vuetify' },
package/src/preview.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  printVcmapUiVersion,
14
14
  resolveMapUi,
15
15
  } from './hostingHelpers.js';
16
- import build, { getDefaultConfig, getLibraryPaths } from './build.js';
16
+ import build, { buildMapUI, getDefaultConfig, getLibraryPaths } from './build.js';
17
17
  import { getContext } from './context.js';
18
18
  import setupMapUi from './setupMapUi.js';
19
19
  import { getVcmConfigJs } from './pluginCliHelper.js';
@@ -79,6 +79,10 @@ export default async function preview(options) {
79
79
  const mergedOptions = { ...vcmConfigJs, ...options };
80
80
  if (!mergedOptions.vcm) {
81
81
  await printVcmapUiVersion();
82
+ // In case @vcmap/ui is linked via git+ssh, dist folder is not available and must be built first
83
+ if (!fs.existsSync(resolveMapUi('dist'))) {
84
+ await buildMapUI();
85
+ }
82
86
  }
83
87
  checkReservedDirectories();
84
88
  await build({ development: false, watch: true });
package/src/serve.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  } from './hostingHelpers.js';
17
17
  import { getPluginName } from './packageJsonHelpers.js';
18
18
  import { getVcmConfigJs } from './pluginCliHelper.js';
19
+ import { buildMapUI } from './build.js';
19
20
 
20
21
  /**
21
22
  * @typedef {HostingOptions} ServeOptions
@@ -56,6 +57,11 @@ async function getProxy(protocol, port) {
56
57
  changeOrigin: true,
57
58
  secure: false,
58
59
  };
60
+ // Cesium engine assets are not part of Build
61
+ proxy['/node_modules/@vcmap-cesium/engine/Build/Assets'] = {
62
+ target,
63
+ rewrite: p => p.replace(/Build/, 'Source'),
64
+ };
59
65
  return proxy;
60
66
  }
61
67
 
@@ -71,6 +77,10 @@ export default async function serve(options) {
71
77
  const { default: vcmConfigJs } = await getVcmConfigJs();
72
78
  const mergedOptions = { ...vcmConfigJs, ...options };
73
79
  await printVcmapUiVersion();
80
+ // In case @vcmap/ui is linked via git+ssh, dist folder is not available and must be built first
81
+ if (!fs.existsSync(resolveMapUi('dist'))) {
82
+ await buildMapUI();
83
+ }
74
84
  checkReservedDirectories();
75
85
  const app = express();
76
86
  const port = mergedOptions.port || 8008;
@@ -92,7 +102,7 @@ export default async function serve(options) {
92
102
  'fast-deep-equal',
93
103
  'rbush-knn',
94
104
  'pbf',
95
- '@vcmap/cesium',
105
+ '@vcmap-cesium/engine',
96
106
  ],
97
107
  },
98
108
  plugins: [