dcp-client 5.1.0 → 5.1.1

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.
@@ -27,7 +27,7 @@ ${progName} - Query values from dcpConfig
27
27
  Copyright (c) 2018-2025 Distributive Corp., All Rights Reserved.
28
28
 
29
29
  Usage: ${progName} [--keys] [--to-string] [--json]
30
- [--programName=string]
30
+ [--program-name=string]
31
31
  [--scheduler=URL] [--bundle-location[=URL]]
32
32
  [--no-remote-config] [--remote-config=URL]
33
33
  <--all | path.to.config.variable [path.to.config.variable...]>
@@ -109,7 +109,7 @@ for (let i=2; i < process.argv.length; i++)
109
109
  mods.push(JSON.stringify);
110
110
  mods.push(stringModFn);
111
111
  break;
112
- case '--programName':
112
+ case '--program-name':
113
113
  dcpClientOptions.programName = optarg;
114
114
  break;
115
115
  case '--scheduler':
@@ -0,0 +1,149 @@
1
+ #! /usr/bin/env node
2
+ /**
3
+ * @file dcp-client/bin/dcp-module-bundler.js
4
+ *
5
+ * Run webpack using dynamic in-memory input.
6
+ * Uses unionfs to layer memfs on top of fs,
7
+ * in order to resolve modules in the local filesystem.
8
+ *
9
+ * @author Paul, paul@distributive.network
10
+ * @date June 2025
11
+ */
12
+ // @ts-check
13
+ 'use strict';
14
+
15
+ const webpack = require('webpack');
16
+ const process = require('process');
17
+ const debug = require('debug')('webpack');
18
+ const fs = require('fs');
19
+ const { Union } = require('unionfs');
20
+ const { createFsFromVolume, Volume } = require('memfs');
21
+ const debugDetails = debug.extend('details');
22
+
23
+ //
24
+ // Tracing Note:
25
+ //
26
+ // DEBUG=webpack -- turns on debug(...)
27
+ // DEBUG=webpack:details -- turns on debugDetails(...)
28
+ // Debug=webpack* -- turns on debug(...) and debugDetails(...)
29
+ //
30
+
31
+ function compile (compiler)
32
+ {
33
+ try
34
+ {
35
+ return new Promise((resolve, reject) => {
36
+ compiler.run((err, stats) => {
37
+ (err) ? reject(err) : resolve(stats);
38
+ });
39
+ });
40
+ }
41
+ catch (error)
42
+ {
43
+ debug('Webpack compilation failure:', error);
44
+ throw error;
45
+ }
46
+ }
47
+
48
+ function showDiags (stats)
49
+ {
50
+ const statsConfig = {
51
+ colors: true,
52
+ errors: true,
53
+ errorCause: true,
54
+ errorDetails: true,
55
+ errorErrors: true,
56
+ errorStack: true,
57
+ warnings: true,
58
+ assets: false, // Include information about generated assets
59
+ chunks: false, // Include information about chunks
60
+ entrypoints: false, // Include information about entrypoints
61
+ modules: false, // Include information about modules
62
+ // You can add more options here based on what you need:
63
+ // https://webpack.js.org/api/stats/#stats-options
64
+ };
65
+
66
+ // Convert stats to a JSON object for easier access and filtering
67
+ const info = stats.toJson(statsConfig);
68
+
69
+ if (stats.hasErrors())
70
+ {
71
+ debug('Webpack compilation errors:');
72
+ info.errors.forEach(error => debug(error.message));
73
+ throw new Error('Webpack compilation failed with errors.', { cause: info.errors });
74
+ }
75
+
76
+ if (stats.hasWarnings())
77
+ {
78
+ debug('Webpack compilation warnings:');
79
+ info.warnings.forEach(warning => debug(warning.message));
80
+ }
81
+
82
+ debugDetails('webpack compilation stats:', JSON.stringify(info, null, 2));
83
+
84
+ return info;
85
+ }
86
+
87
+ async function inMemWebpack (config)
88
+ {
89
+ // Create a memory filesystem
90
+ let memVolume = new Volume();
91
+ let memfs = createFsFromVolume(memVolume);
92
+
93
+ // Create a union filesystem that combines memory fs and normal node fs.
94
+ let ufs = new Union();
95
+ // @ts-ignore
96
+ ufs.use(memfs).use(fs);
97
+
98
+ // Place the input in memfs and update config.entry.
99
+ const buf = fs.readFileSync(config.entry);
100
+ config.entry = '/inMemoryinput.js';
101
+ memfs.writeFileSync(config.entry, buf);
102
+ if (debug.enabled)
103
+ {
104
+ const _buf = memfs.readFileSync(config.entry);
105
+ if (!Buffer.isBuffer(_buf))
106
+ throw new Error("Webpack: Buffer.isBuffer has failed");
107
+ }
108
+
109
+ const compiler = webpack(config);
110
+ try
111
+ {
112
+ // @ts-ignore
113
+ compiler.inputFileSystem = ufs;
114
+ const stats = await compile(compiler);
115
+ showDiags(stats);
116
+ }
117
+ finally
118
+ {
119
+ compiler.close((closeErr) => {
120
+ if (debug.enabled && closeErr)
121
+ debug('Failure closing webpack compiler', { cause: closeErr });
122
+ });
123
+ }
124
+ }
125
+
126
+ async function main ()
127
+ {
128
+ const success = 0;
129
+ const failure = 1;
130
+
131
+ debug('Webpack command-line args', process.argv);
132
+ try
133
+ {
134
+ // node dcp-module-bundler.js configFile.json
135
+ const configuration = require(process.argv[2]);
136
+ debug('Webpack configuration:', configuration);
137
+
138
+ await inMemWebpack(configuration);
139
+ }
140
+ catch (error)
141
+ {
142
+ process.exitCode = failure;
143
+ debug('Failure compiling webpack', { cause: error });
144
+ throw error;
145
+ }
146
+ process.exitCode = success;
147
+ }
148
+
149
+ ( async () => { await main(); } )();
package/build/bundle CHANGED
@@ -174,7 +174,7 @@ fi
174
174
  NO_LOG=1 \
175
175
  SKIP_SUDO_CHECK=1 \
176
176
  DCP_LOCAL_CONFIG_EXTRAS="${BUNDLE_TMP}/local-config.incl" \
177
- "${DCP_SRC}/install.sh" -N ${DCP_INSTALL_FLAGS} build-dcp-client
177
+ "${DCP_SRC}/install.sh" -NI ${DCP_INSTALL_FLAGS} autogen-schemas build-dcp-client
178
178
 
179
179
  EXIT_CODE="$?"
180
180
  if [ "$EXIT_CODE" != "0" ]; then