@merkur/cli 0.35.6 → 0.35.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/cli",
3
- "version": "0.35.6",
3
+ "version": "0.35.8",
4
4
  "description": "Merkur is tiny and extensible library for creating front-end microservices.",
5
5
  "bin": {
6
6
  "merkur": "./bin/merkur.mjs"
@@ -66,5 +66,5 @@
66
66
  "engines": {
67
67
  "node": ">=20"
68
68
  },
69
- "gitHead": "0b561365fceb97789e3c626dddb068b8c0e2a5d0"
69
+ "gitHead": "9c99e3f25e9afa6f94a5907facec8419fbaed59e"
70
70
  }
package/src/CLIConfig.mjs CHANGED
@@ -1,30 +1,34 @@
1
1
  import { EMITTER_EVENTS, emitter, RESULT_KEY } from './emitter.mjs';
2
2
 
3
- export async function createCLIConfig({ args, context, command } = {}) {
3
+ export async function createCLIConfig({ args, command } = {}) {
4
4
  const environment = process.env.NODE_ENV;
5
5
  const isProduction = environment === 'production';
6
6
 
7
+ return {
8
+ environment,
9
+ isProduction,
10
+ command: command ?? 'unknown',
11
+ watch: args?.watch ?? !isProduction,
12
+ writeToDisk: args?.writeToDisk ?? isProduction,
13
+ outFile: args?.outFile ?? './build/widget.cjs',
14
+ port: args?.port ?? 4444,
15
+ runTask: args?.runTask ?? [],
16
+ devServerPort: args?.devServerPort ?? 4445,
17
+ projectFolder: args?.projectFolder ?? process.cwd(),
18
+ cliFolder: import.meta.dirname,
19
+ buildFolder: args?.buildFolder ?? './build',
20
+ staticFolder: args?.staticFolder ?? './build/static',
21
+ staticPath: args?.staticPath ?? '/static',
22
+ hasRunDevServer: args?.hasRunDevServer ?? false,
23
+ hasRunWidgetServer: args?.hasRunWidgetServer ?? false,
24
+ inspect: args.inspect ?? false,
25
+ verbose: args.verbose ?? false,
26
+ };
27
+ }
28
+
29
+ export async function updateCLIConfig({ cliConfig, context, args }) {
7
30
  let event = {
8
- cliConfig: {
9
- environment,
10
- isProduction,
11
- command: command ?? 'unknown',
12
- watch: args?.watch ?? !isProduction,
13
- writeToDisk: args?.writeToDisk ?? isProduction,
14
- outFile: args?.outFile ?? './build/widget.cjs',
15
- port: args?.port ?? 4444,
16
- runTask: args?.runTask ?? [],
17
- devServerPort: args?.devServerPort ?? 4445,
18
- projectFolder: args?.projectFolder ?? process.cwd(),
19
- cliFolder: import.meta.dirname,
20
- buildFolder: args?.buildFolder ?? './build',
21
- staticFolder: args?.staticFolder ?? './build/static',
22
- staticPath: args?.staticPath ?? '/static',
23
- hasRunDevServer: args?.hasRunDevServer ?? false,
24
- hasRunWidgetServer: args?.hasRunWidgetServer ?? false,
25
- inspect: args.inspect ?? false,
26
- verbose: args.verbose ?? false,
27
- },
31
+ cliConfig,
28
32
  context,
29
33
  args,
30
34
  [RESULT_KEY]: 'cliConfig',
@@ -14,9 +14,10 @@ export async function build({ args, command }) {
14
14
  const buildTime = time();
15
15
 
16
16
  const context = await createContext();
17
- const baseCliConfig = await createCLIConfig({ args, context, command });
17
+ const baseCliConfig = await createCLIConfig({ args, command });
18
18
 
19
19
  const { merkurConfig, cliConfig } = await createMerkurConfig({
20
+ args,
20
21
  cliConfig: baseCliConfig,
21
22
  context,
22
23
  });
@@ -11,9 +11,10 @@ import { handleExit } from '../handleExit.mjs';
11
11
 
12
12
  export async function dev({ args, command }) {
13
13
  const context = await createContext();
14
- const baseCliConfig = await createCLIConfig({ args, context, command });
14
+ const baseCliConfig = await createCLIConfig({ args, command });
15
15
 
16
16
  const { merkurConfig, cliConfig } = await createMerkurConfig({
17
+ args,
17
18
  cliConfig: baseCliConfig,
18
19
  context,
19
20
  });
@@ -7,9 +7,10 @@ import { handleExit } from '../handleExit.mjs';
7
7
 
8
8
  export async function start({ args, command }) {
9
9
  const context = await createContext();
10
- let baseCliConfig = await createCLIConfig({ args, context, command });
10
+ let baseCliConfig = await createCLIConfig({ args, command });
11
11
 
12
12
  const { merkurConfig, cliConfig } = await createMerkurConfig({
13
+ args,
13
14
  cliConfig: baseCliConfig,
14
15
  context,
15
16
  });
@@ -11,9 +11,10 @@ import { handleExit } from '../handleExit.mjs';
11
11
 
12
12
  export async function test({ args, command }) {
13
13
  const context = await createContext();
14
- let baseCliConfig = await createCLIConfig({ args, context, command });
14
+ let baseCliConfig = await createCLIConfig({ args, command });
15
15
 
16
16
  const { merkurConfig, cliConfig } = await createMerkurConfig({
17
+ args,
17
18
  cliConfig: baseCliConfig,
18
19
  context,
19
20
  });
package/src/devServer.mjs CHANGED
@@ -25,7 +25,7 @@ export async function runDevServer({ context, merkurConfig, cliConfig }) {
25
25
  path: playgroundPath,
26
26
  widgetHandler,
27
27
  } = merkurConfig.playground;
28
- const { cliFolder, command, writeToDisk } = cliConfig;
28
+ const { cliFolder, projectFolder, command, writeToDisk } = cliConfig;
29
29
 
30
30
  return new Promise((resolve, reject) => {
31
31
  const app = express();
@@ -118,7 +118,11 @@ export async function runDevServer({ context, merkurConfig, cliConfig }) {
118
118
  const playgroundTemplate = ejs.compile(
119
119
  fs.readFileSync(template, 'utf8'),
120
120
  {
121
- views: [path.dirname(template), templateFolder],
121
+ views: [
122
+ `${projectFolder}/server/playground/templates/`,
123
+ path.dirname(template),
124
+ templateFolder,
125
+ ],
122
126
  },
123
127
  );
124
128
 
@@ -1,6 +1,7 @@
1
1
  import path from 'node:path';
2
2
 
3
3
  import { EMITTER_EVENTS, emitter, RESULT_KEY } from './emitter.mjs';
4
+ import { updateCLIConfig } from './CLIConfig.mjs';
4
5
  import { createLogger } from './logger.mjs';
5
6
  import { devPlugin } from './plugins/devPlugin.mjs';
6
7
  import { deepMerge } from './utils.mjs';
@@ -8,7 +9,7 @@ import { COMMAND_NAME } from './commands/constant.mjs';
8
9
 
9
10
  const MERKUR_CONFIG_FILE = 'merkur.config.mjs';
10
11
 
11
- export async function createMerkurConfig({ cliConfig, context } = {}) {
12
+ export async function createMerkurConfig({ cliConfig, context, args } = {}) {
12
13
  const logger = createLogger('merkurConfig', cliConfig);
13
14
  const { projectFolder } = cliConfig;
14
15
  let merkurConfig;
@@ -29,12 +30,14 @@ export async function createMerkurConfig({ cliConfig, context } = {}) {
29
30
  logger.error(error);
30
31
  }
31
32
 
32
- cliConfig = { ...(merkurConfig?.cliConfig ?? {}), ...cliConfig };
33
+ cliConfig = { ...cliConfig, ...(merkurConfig?.cliConfig ?? {}), ...args };
33
34
 
34
35
  await loadExtender({ merkurConfig, cliConfig, logger, context });
35
36
 
36
37
  await registerHooks({ merkurConfig });
37
38
 
39
+ cliConfig = await updateCLIConfig({ args, cliConfig, context });
40
+
38
41
  let event = {
39
42
  merkurConfig: {
40
43
  ...merkurConfig,
@@ -0,0 +1,18 @@
1
+ <% if(widgetProperties?.slot?.headline?.html){ %>
2
+ <div class="headline-view"><%- widgetProperties && widgetProperties.slot && widgetProperties.slot.headline &&
3
+ widgetProperties.slot.headline.html %></div>
4
+ <% } %>
5
+ <div class="merkur-view"><%- html %></div>
6
+ <script>
7
+ window.addEventListener('load', function () {
8
+ __merkur__.create(<% - JSON.stringify(widgetProperties) %>)
9
+ .then(function (widget) {
10
+ widget.containerSelector = '.merkur-view';
11
+ if (widget?.slot?.headline) {
12
+ widget.slot.headline.containerSelector = '.headline-view';
13
+ }
14
+
15
+ widget.mount();
16
+ });
17
+ });
18
+ </script>
@@ -9,25 +9,8 @@
9
9
  </head>
10
10
 
11
11
  <body>
12
- <% if(widgetProperties?.slot?.headline?.html){ %>
13
- <div class="headline-view"><%- widgetProperties && widgetProperties.slot && widgetProperties.slot.headline && widgetProperties.slot.headline.html %>
14
- <% } %>
15
- </div>
16
- <div class="merkur-view"><%- html %></div>
17
- <script>
18
- window.addEventListener('load', function () {
19
- __merkur__.create(<%- JSON.stringify(widgetProperties) %>)
20
- .then(function (widget) {
21
- widget.containerSelector = '.merkur-view';
22
- if (widget?.slot?.headline) {
23
- widget.slot.headline.containerSelector = '.headline-view';
24
- }
25
-
26
- widget.mount();
27
- });
28
- });
29
- </script>
30
- <%- include('./footer.ejs', {assets, merkurConfig, devClient, widgetProperties}) %>
12
+ <%- include('./body.ejs', {assets, merkurConfig, devClient, widgetProperties}) %>
13
+ <%- include('./footer.ejs', {assets, merkurConfig, devClient, widgetProperties}) %>
31
14
  </body>
32
15
 
33
16
  </html>