elm-pages 3.0.22 → 3.0.24
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/generator/src/cli.js
CHANGED
|
@@ -180,6 +180,10 @@ async function main() {
|
|
|
180
180
|
"Output path for compiled script",
|
|
181
181
|
"./myscript.mjs"
|
|
182
182
|
)
|
|
183
|
+
.option(
|
|
184
|
+
"--set-version <version>",
|
|
185
|
+
"Set the version string for the bundled script"
|
|
186
|
+
)
|
|
183
187
|
.option(
|
|
184
188
|
"--external <package-or-pattern>",
|
|
185
189
|
"build site to be served under a base path",
|
|
@@ -236,7 +240,8 @@ await renderer.runGenerator(
|
|
|
236
240
|
[...process.argv].splice(2),
|
|
237
241
|
customBackendTask,
|
|
238
242
|
Elm,
|
|
239
|
-
"${moduleName}"
|
|
243
|
+
"${moduleName}",
|
|
244
|
+
"${options.setVersion || "Version not set."}"
|
|
240
245
|
);
|
|
241
246
|
`;
|
|
242
247
|
// source: https://github.com/evanw/esbuild/pull/2067#issuecomment-1073039746
|
package/generator/src/render.js
CHANGED
|
@@ -77,12 +77,14 @@ export async function render(
|
|
|
77
77
|
* @param {string[]} cliOptions
|
|
78
78
|
* @param {any} portsFile
|
|
79
79
|
* @param {string} scriptModuleName
|
|
80
|
+
* @param {string} versionMessage
|
|
80
81
|
*/
|
|
81
82
|
export async function runGenerator(
|
|
82
83
|
cliOptions,
|
|
83
84
|
portsFile,
|
|
84
85
|
elmModule,
|
|
85
|
-
scriptModuleName
|
|
86
|
+
scriptModuleName,
|
|
87
|
+
versionMessage
|
|
86
88
|
) {
|
|
87
89
|
global.isRunningGenerator = true;
|
|
88
90
|
// const { fs, resetInMemoryFs } = require("./request-cache-fs.js")(true);
|
|
@@ -100,7 +102,8 @@ export async function runGenerator(
|
|
|
100
102
|
scriptModuleName,
|
|
101
103
|
"production",
|
|
102
104
|
"",
|
|
103
|
-
true
|
|
105
|
+
true,
|
|
106
|
+
versionMessage
|
|
104
107
|
);
|
|
105
108
|
return result;
|
|
106
109
|
} catch (error) {
|
|
@@ -119,6 +122,7 @@ export async function runGenerator(
|
|
|
119
122
|
* @param {typeof import("fs") | import("memfs").IFs} fs
|
|
120
123
|
* @param {boolean} hasFsAccess
|
|
121
124
|
* @param {string} scriptModuleName
|
|
125
|
+
* @param {string} versionMessage
|
|
122
126
|
*/
|
|
123
127
|
function runGeneratorAppHelp(
|
|
124
128
|
cliOptions,
|
|
@@ -128,12 +132,22 @@ function runGeneratorAppHelp(
|
|
|
128
132
|
scriptModuleName,
|
|
129
133
|
mode,
|
|
130
134
|
pagePath,
|
|
131
|
-
hasFsAccess
|
|
135
|
+
hasFsAccess,
|
|
136
|
+
versionMessage
|
|
132
137
|
) {
|
|
133
138
|
const isDevServer = mode !== "build";
|
|
134
139
|
let patternsToWatch = new Set();
|
|
135
140
|
let app = null;
|
|
136
141
|
let killApp;
|
|
142
|
+
// Handle version flag with early return
|
|
143
|
+
if (
|
|
144
|
+
cliOptions.length === 1 &&
|
|
145
|
+
(cliOptions[0] === "--version" || cliOptions[0] === "-v")
|
|
146
|
+
) {
|
|
147
|
+
console.log(versionMessage);
|
|
148
|
+
return Promise.resolve();
|
|
149
|
+
}
|
|
150
|
+
|
|
137
151
|
return new Promise((resolve, reject) => {
|
|
138
152
|
const isBytes = pagePath.match(/content\.dat\/?$/);
|
|
139
153
|
|
|
@@ -141,7 +155,7 @@ function runGeneratorAppHelp(
|
|
|
141
155
|
flags: {
|
|
142
156
|
compatibilityKey,
|
|
143
157
|
argv: ["", `elm-pages run ${scriptModuleName}`, ...cliOptions],
|
|
144
|
-
versionMessage: "
|
|
158
|
+
versionMessage: versionMessage || "",
|
|
145
159
|
},
|
|
146
160
|
});
|
|
147
161
|
|