@vcmap/plugin-cli 2.1.1 → 2.1.2
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 +3 -4
- package/src/build.js +22 -3
- package/src/buildStagingApp.js +3 -7
- package/src/preview.js +5 -1
- package/src/serve.js +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/plugin-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
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.
|
|
43
|
+
"@vcmap/ui": "^5.0.0-rc.17",
|
|
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
|
|
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
|
|
@@ -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
|
|
59
|
-
await
|
|
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
|
+
}
|
package/src/buildStagingApp.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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/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
|
|
@@ -71,6 +72,10 @@ export default async function serve(options) {
|
|
|
71
72
|
const { default: vcmConfigJs } = await getVcmConfigJs();
|
|
72
73
|
const mergedOptions = { ...vcmConfigJs, ...options };
|
|
73
74
|
await printVcmapUiVersion();
|
|
75
|
+
// In case @vcmap/ui is linked via git+ssh, dist folder is not available and must be built first
|
|
76
|
+
if (!fs.existsSync(resolveMapUi('dist'))) {
|
|
77
|
+
await buildMapUI();
|
|
78
|
+
}
|
|
74
79
|
checkReservedDirectories();
|
|
75
80
|
const app = express();
|
|
76
81
|
const port = mergedOptions.port || 8008;
|