@nebula.js/cli-serve 2.2.0 → 2.3.0

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.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Manages loading and delivering fixtures.
3
+ *
4
+ * Fixtures are transpiled and included when Nebula serve is starting. Fixtures in the specified `--fixturePath` with the extension `.fix.js` are included.
5
+ */
6
+ window.serveFixtures = {
7
+ get(key = '') {
8
+ const k = key.startsWith('./') ? key : `./${key}`;
9
+ let context;
10
+ try {
11
+ // see: https://webpack.js.org/guides/dependency-management/#requirecontext
12
+ context = require.context('fixtures', true, /\.fix\.js$/);
13
+ } catch (_) {
14
+ throw new Error('Specified "--fixturePath" does not exist');
15
+ }
16
+
17
+ if (context.keys().includes(k)) {
18
+ return context(k).default;
19
+ }
20
+
21
+ console.groupCollapsed(`No fixture found at "${k}"`);
22
+ if (context.keys().length === 0) {
23
+ console.info('No fixtures available.');
24
+ } else {
25
+ console.info('Fixtures available:');
26
+ console.info(context.keys());
27
+ console.info('Is the fixture you are looking for not in the list?');
28
+ }
29
+ console.info(
30
+ 'Specify "--fixturePath" to Nebula serve to specify their loction. Note that the fixture\'s file name must end with ".fix.js".'
31
+ );
32
+ console.groupEnd();
33
+
34
+ throw new Error(`No fixture found at "${k}"`);
35
+ },
36
+ };
@@ -62,9 +62,10 @@ const options = {
62
62
  webIntegrationId: {
63
63
  type: 'string',
64
64
  },
65
- ACCEPT_EULA: {
66
- type: 'boolean',
67
- default: false,
65
+ fixturePath: {
66
+ type: 'string',
67
+ default: 'test/component',
68
+ description: 'Path to a folder that will be used as basis when locating fixtures',
68
69
  },
69
70
  };
70
71
 
package/lib/serve.js CHANGED
@@ -10,7 +10,6 @@ const build = require('@nebula.js/cli-build');
10
10
  const initConfig = require('./init-config');
11
11
 
12
12
  const webpackServe = require('./webpack.serve');
13
- const useEngine = require('./engine');
14
13
 
15
14
  const initiateWatch = async ({ snPath, snName, host }) => {
16
15
  // TODO - timeout
@@ -103,11 +102,6 @@ module.exports = async (argv) => {
103
102
  }
104
103
 
105
104
  const serveConfig = extend(true, {}, defaultServeConfig, argv);
106
-
107
- let stopEngine = () => {};
108
- if (serveConfig.ACCEPT_EULA) {
109
- stopEngine = await useEngine(serveConfig);
110
- }
111
105
  const host = serveConfig.host || 'localhost';
112
106
  const port = serveConfig.port || (await portfinder.getPortPromise({ host }));
113
107
  const enigmaConfig = serveConfig.enigma;
@@ -169,7 +163,6 @@ module.exports = async (argv) => {
169
163
  });
170
164
 
171
165
  const close = async () => {
172
- await stopEngine();
173
166
  if (watcher) {
174
167
  watcher.close();
175
168
  }
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const webpack = require('webpack');
3
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
4
5
 
5
6
  const babelPath = require.resolve('babel-loader');
6
7
  const babelPresetEnvPath = require.resolve('@babel/preset-env');
@@ -22,6 +23,7 @@ const cfg = ({ srcDir, distDir, dev = false, serveConfig = {} }) => {
22
23
  eRender: [path.resolve(srcDir, 'eRender')],
23
24
  eDev: [path.resolve(srcDir, 'eDev')],
24
25
  eHub: [path.resolve(srcDir, 'eHub')],
26
+ fixtures: [path.resolve(__dirname, './fixtures.js')],
25
27
  },
26
28
  devtool: dev ? 'eval-cheap-module-source-map' : false,
27
29
  output: {
@@ -36,7 +38,7 @@ const cfg = ({ srcDir, distDir, dev = false, serveConfig = {} }) => {
36
38
  '@nebula.js/conversion': path.resolve(__dirname, '../../../apis/conversion/src'),
37
39
  '@nebula.js/locale/all.json$': path.resolve(__dirname, '../../../apis/locale/all.json'),
38
40
  '@nebula.js/locale': path.resolve(__dirname, '../../../apis/locale/src'),
39
- fixtures: path.resolve(__dirname, '../../../test/component'),
41
+ fixtures: path.resolve(process.cwd(), serveConfig.fixturePath || ''),
40
42
  },
41
43
  extensions: ['.dev.js', '.js', '.jsx'],
42
44
  },
@@ -91,7 +93,8 @@ const cfg = ({ srcDir, distDir, dev = false, serveConfig = {} }) => {
91
93
  new HtmlWebpackPlugin({
92
94
  template: path.resolve(srcDir, 'eRender.html'),
93
95
  filename: 'eRender.html',
94
- chunks: ['eRender'],
96
+ // Include fixture only when running Nebula serve
97
+ chunks: dev ? ['eRender', 'fixtures'] : ['eRender'],
95
98
  favicon,
96
99
  scripts: serveConfig.scripts,
97
100
  stylesheets: serveConfig.stylesheets,
@@ -108,7 +111,17 @@ const cfg = ({ srcDir, distDir, dev = false, serveConfig = {} }) => {
108
111
  chunks: ['eHub'],
109
112
  favicon,
110
113
  }),
114
+ new CopyWebpackPlugin({
115
+ patterns: ['stardust.js', 'stardust.js.map'].map((filename) => ({
116
+ from: path.resolve(__dirname, `../../../apis/stardust/dist/${filename}`),
117
+ to: distDir,
118
+ })),
119
+ }),
111
120
  ],
121
+ externals: {
122
+ // Ensure dependency is shared for rendering, fixtures and elsewhere.
123
+ '@nebula.js/stardust': 'stardust',
124
+ },
112
125
  };
113
126
 
114
127
  return config;
@@ -11,7 +11,9 @@ const cfg = ({ srcDir = path.resolve(__dirname, '../dist'), serveConfig = {} })
11
11
 
12
12
  const config = {
13
13
  mode: 'development',
14
- entry: path.resolve(__dirname, './sn.js'),
14
+ entry: {
15
+ fixtures: [path.resolve(__dirname, './fixtures.js')],
16
+ },
15
17
  devtool: false,
16
18
  infrastructureLogging: {
17
19
  level: 'error',
@@ -44,7 +46,7 @@ const cfg = ({ srcDir = path.resolve(__dirname, '../dist'), serveConfig = {} })
44
46
  },
45
47
  resolve: {
46
48
  alias: {
47
- fixtures: path.resolve(process.cwd(), 'test/component'),
49
+ fixtures: path.resolve(process.cwd(), serveConfig.fixturePath),
48
50
  },
49
51
  },
50
52
  plugins: [
@@ -54,13 +56,19 @@ const cfg = ({ srcDir = path.resolve(__dirname, '../dist'), serveConfig = {} })
54
56
  inject: 'head',
55
57
  scripts: serveConfig.scripts,
56
58
  stylesheets: serveConfig.stylesheets,
59
+ chunks: ['fixtures'],
57
60
  }),
58
61
  new HtmlWebpackPlugin({
59
62
  template: path.resolve(srcDir, 'eDev.html'),
60
63
  filename: 'eDev.html',
61
64
  inject: 'head',
65
+ chunks: [],
62
66
  }),
63
67
  ],
68
+ externals: {
69
+ // Ensure dependency is shared for rendering, fixtures and elsewhere.
70
+ '@nebula.js/stardust': 'stardust',
71
+ },
64
72
  };
65
73
 
66
74
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula.js/cli-serve",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "QlikTech International AB",
@@ -18,7 +18,6 @@
18
18
  "command.js",
19
19
  "data",
20
20
  "dist",
21
- "docker-compose.yml",
22
21
  "lib"
23
22
  ],
24
23
  "scripts": {
@@ -28,7 +27,7 @@
28
27
  "prepublishOnly": "rm -rf dist && yarn run build"
29
28
  },
30
29
  "dependencies": {
31
- "@nebula.js/cli-build": "^2.2.0",
30
+ "@nebula.js/cli-build": "^2.3.0",
32
31
  "body-parser": "1.19.0",
33
32
  "chalk": "4.1.2",
34
33
  "chokidar": "3.5.2",
@@ -37,34 +36,36 @@
37
36
  "extend": "3.0.2",
38
37
  "html-webpack-plugin": "5.5.0",
39
38
  "portfinder": "1.0.28",
40
- "puppeteer": "10.4.0",
39
+ "puppeteer": "12.0.1",
41
40
  "regenerator-runtime": "0.13.9",
42
41
  "source-map-loader": "3.0.0",
43
- "webpack": "5.64.0",
44
- "webpack-dev-server": "4.5.0",
45
- "ws": "8.2.3",
46
- "yargs": "17.2.1"
42
+ "webpack": "5.64.4",
43
+ "webpack-dev-server": "4.6.0",
44
+ "ws": "8.3.0",
45
+ "yargs": "17.3.0"
47
46
  },
48
47
  "devDependencies": {
49
48
  "@babel/core": "7.16.0",
50
- "@babel/preset-env": "7.16.0",
49
+ "@babel/preset-env": "7.16.4",
51
50
  "@babel/preset-react": "7.16.0",
52
51
  "@material-ui/core": "4.12.3",
53
- "@nebula.js/nucleus": "^2.2.0",
54
- "@nebula.js/snapshooter": "^2.2.0",
55
- "@nebula.js/stardust": "^2.2.0",
56
- "@nebula.js/ui": "^2.2.0",
52
+ "@nebula.js/enigma-mocker": "^2.3.0",
53
+ "@nebula.js/nucleus": "^2.3.0",
54
+ "@nebula.js/snapshooter": "^2.3.0",
55
+ "@nebula.js/stardust": "^2.3.0",
56
+ "@nebula.js/ui": "^2.3.0",
57
57
  "autosuggest-highlight": "3.2.0",
58
58
  "babel-loader": "8.2.3",
59
+ "copy-webpack-plugin": "^10.0.0",
59
60
  "d3-require": "1.2.4",
60
61
  "enigma.js": "2.7.3",
61
62
  "eslint-import-resolver-alias": "1.1.2",
62
63
  "eslint-import-resolver-webpack": "0.13.2",
63
64
  "monaco-editor": "0.30.1",
64
- "monaco-editor-webpack-plugin": "4.2.0",
65
+ "monaco-editor-webpack-plugin": "6.0.0",
65
66
  "react": "17.0.2",
66
67
  "react-dom": "17.0.2",
67
68
  "webpack-cli": "4.9.1"
68
69
  },
69
- "gitHead": "774fb035b462f8011bfc3c517ee620920f3ee94c"
70
+ "gitHead": "db408ff3d6013a4558dbb9be24ae1188c1e78d44"
70
71
  }
@@ -1,51 +0,0 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
- /*! javascript-number-formatter - v1.1.11 - http://mottie.github.com/javascript-number-formatter/ * © ecava */
8
-
9
- /**
10
- * A better abstraction over CSS.
11
- *
12
- * @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present
13
- * @website https://github.com/cssinjs/jss
14
- * @license MIT
15
- */
16
-
17
- /** @license React v0.20.2
18
- * scheduler.production.min.js
19
- *
20
- * Copyright (c) Facebook, Inc. and its affiliates.
21
- *
22
- * This source code is licensed under the MIT license found in the
23
- * LICENSE file in the root directory of this source tree.
24
- */
25
-
26
- /** @license React v17.0.2
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */
34
-
35
- /** @license React v17.0.2
36
- * react-is.production.min.js
37
- *
38
- * Copyright (c) Facebook, Inc. and its affiliates.
39
- *
40
- * This source code is licensed under the MIT license found in the
41
- * LICENSE file in the root directory of this source tree.
42
- */
43
-
44
- /** @license React v17.0.2
45
- * react.production.min.js
46
- *
47
- * Copyright (c) Facebook, Inc. and its affiliates.
48
- *
49
- * This source code is licensed under the MIT license found in the
50
- * LICENSE file in the root directory of this source tree.
51
- */
@@ -1,13 +0,0 @@
1
- version: '3.1'
2
-
3
- services:
4
- engine:
5
- image: qlikcore/engine:${ENGINE_VERSION:-12.972.0}
6
- # restart: always
7
- command: |
8
- -S AcceptEULA=${ACCEPT_EULA:-no}
9
- -S DocumentDirectory=/apps
10
- ports:
11
- - ${ENGINE_PORT:-9076}:9076
12
- volumes:
13
- - ${APPS_PATH:-./data/apps}:/apps
package/lib/engine.js DELETED
@@ -1,49 +0,0 @@
1
- const path = require('path');
2
- const { spawn } = require('child_process');
3
-
4
- const execCmd = (cmd, cmdArgs = [], opts) =>
5
- new Promise((resolve, reject) => {
6
- const child = spawn(cmd, cmdArgs, opts);
7
- const res = {
8
- exitCode: null,
9
- out: '',
10
- err: '',
11
- };
12
- child.on('error', reject);
13
- child.stdout.on('data', (chunk) => {
14
- res.out += chunk.toString();
15
- });
16
- child.stderr.on('data', (chunk) => {
17
- res.err += chunk.toString();
18
- });
19
- child.on('exit', (exitCode) => {
20
- res.exitCode = exitCode;
21
- if (exitCode === 0) {
22
- resolve(res);
23
- } else {
24
- reject(res);
25
- }
26
- });
27
- });
28
-
29
- const useEngine = ({ ACCEPT_EULA = false, cwd = path.resolve(__dirname, '../'), files }) => {
30
- if (ACCEPT_EULA !== true) {
31
- throw new Error('Need to accept EULA in order to start engine container');
32
- }
33
- console.error('Starting engine container...');
34
- const f = (files || []).reduce((acc, curr) => [...acc, '-f', curr], []);
35
- process.env.ACCEPT_EULA = 'yes';
36
- const stopEngine = async () => {
37
- console.error('Stopping engine container...');
38
- try {
39
- await execCmd('docker-compose', [...f, 'down', '--remove-orphans'], {
40
- cwd,
41
- });
42
- } catch (err) {
43
- console.error(err);
44
- }
45
- };
46
- return execCmd('docker-compose', [...f, 'up', '-d', '--build'], { cwd }).then(() => stopEngine);
47
- };
48
-
49
- module.exports = useEngine;
package/lib/sn.js DELETED
@@ -1 +0,0 @@
1
- // dummy entrypoint