Convert to ESM.

This commit is contained in:
Dillon Kearns 2023-01-22 09:33:26 -08:00
parent 69d7237af9
commit 9600de126b
28 changed files with 464 additions and 381 deletions

2
codegen/.gitignore vendored
View File

@ -1,3 +1,3 @@
Gen/
elm-pages-codegen.js
elm-pages-codegen.cjs

View File

@ -1,6 +1,6 @@
// this middleware is only active when (config.base !== '/')
module.exports = function baseMiddleware(base) {
export function baseMiddleware(base) {
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
return function viteBaseMiddleware(req, res, next) {
// `req.url` only contains the path, since that is what gets passed in the HTTP request.
@ -34,11 +34,11 @@ module.exports = function baseMiddleware(base) {
const suggestionUrl = `${base}/${path.slice(1)}`;
res.end(
`The server is configured with a public base URL of ${base} - ` +
`did you mean to visit ${suggestionUrl} instead?`
`did you mean to visit ${suggestionUrl} instead?`
);
return;
}
next();
};
};
}

View File

@ -1,24 +1,25 @@
const fs = require("./dir-helpers.js");
const fsPromises = require("fs").promises;
const { runElmReview } = require("./compile-elm.js");
const { restoreColorSafe } = require("./error-formatter");
const path = require("path");
const spawnCallback = require("cross-spawn").spawn;
const codegen = require("./codegen.js");
const terser = require("terser");
const os = require("os");
const { Worker, SHARE_ENV } = require("worker_threads");
const { ensureDirSync } = require("./file-helpers.js");
const { generateClientFolder } = require("./codegen.js");
const which = require("which");
const { build } = require("vite");
const preRenderHtml = require("./pre-render-html.js");
const esbuild = require("esbuild");
const { createHash } = require("crypto");
const { merge_vite_configs } = require("./vite-utils.js");
const { resolveConfig } = require("./config.js");
const globby = require("globby");
import * as fs from "./dir-helpers.js";
import * as fsPromises from "fs/promises";
import { runElmReview } from "./compile-elm.js";
import { restoreColorSafe } from "./error-formatter.js";
import * as path from "path";
import { spawn as spawnCallback } from "cross-spawn";
import * as codegen from "./codegen.js";
import * as terser from "terser";
import * as os from "os";
import { Worker, SHARE_ENV } from "worker_threads";
import { ensureDirSync } from "./file-helpers.js";
import { generateClientFolder } from "./codegen.js";
import { default as which } from "which";
import { build } from "vite";
import * as preRenderHtml from "./pre-render-html.js";
import * as esbuild from "esbuild";
import { createHash } from "crypto";
import { merge_vite_configs } from "./vite-utils.js";
import { resolveConfig } from "./config.js";
import { globbySync } from "globby";
import { fileURLToPath } from "url";
import { copyFile } from "fs/promises";
let pool = [];
let pagesReady;
@ -65,7 +66,7 @@ async function ensureRequiredExecutables() {
}
}
async function run(options) {
export async function run(options) {
try {
await ensureRequiredDirs();
await ensureRequiredExecutables();
@ -110,7 +111,11 @@ async function run(options) {
withoutExtension
);
const assetManifestPath = path.join(process.cwd(), "dist/manifest.json");
const manifest = require(assetManifestPath);
const manifest = (
await import(assetManifestPath, {
assert: { type: "json" },
})
).default;
const indexTemplate = await fsPromises.readFile(
"dist/elm-stuff/elm-pages/index.html",
"utf-8"
@ -161,7 +166,7 @@ async function run(options) {
})
.catch((error) => {
const portBackendTaskFileFound =
globby.sync("./custom-backend-task.*").length > 0;
globbySync("./custom-backend-task.*").length > 0;
if (portBackendTaskFileFound) {
// don't present error if there are no files matching custom-backend-task
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
@ -170,7 +175,7 @@ async function run(options) {
});
// TODO extract common code for compiling ports file?
XMLHttpRequest = {};
global.XMLHttpRequest = {};
const compileCli = compileCliApp(options);
try {
await compileCli;
@ -207,6 +212,7 @@ async function run(options) {
processedIndexTemplate
);
} catch (error) {
console.trace(error);
if (error) {
console.error(restoreColorSafe(error));
}
@ -220,6 +226,8 @@ async function run(options) {
*/
function initWorker(basePath, whenDone) {
return new Promise((resolve, reject) => {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
activeWorkers += 1;
let newWorker = {
worker: new Worker(path.join(__dirname, "./render-worker.js"), {
@ -369,7 +377,7 @@ function elmOptimizeLevel2(outputPath, cwd) {
subprocess.on("close", async (code) => {
if (code === 0) {
await fs.copyFile(optimizedOutputPath, outputPath);
await copyFile(optimizedOutputPath, outputPath);
resolve();
} else {
if (!buildError) {
@ -539,7 +547,7 @@ async function runTerser(filePath) {
}
}
async function compileCliApp(options) {
export async function compileCliApp(options) {
await spawnElmMake(
// TODO should be --optimize, but there seems to be an issue with the html to JSON with --optimize
options.debug ? "debug" : "optimize",
@ -671,5 +679,3 @@ function defaultPreloadForFile(file) {
* @param {string} contentJsonString
* @returns {string}
*/
module.exports = { run, compileCliApp };

View File

@ -1,25 +1,27 @@
#!/usr/bin/env node
"use strict";
const build = require("./build.js");
const dirHelpers = require("./dir-helpers.js");
const dev = require("./dev-server.js");
const init = require("./init.js");
const codegen = require("./codegen.js");
const fs = require("fs");
const path = require("path");
const { restoreColorSafe } = require("./error-formatter");
const renderer = require("../../generator/src/render");
const globby = require("globby");
const esbuild = require("esbuild");
const copyModifiedElmJson = require("./rewrite-elm-json.js");
const { ensureDirSync, deleteIfExists } = require("./file-helpers.js");
import * as build from "./build.js";
import * as dev from "./dev-server.js";
import * as init from "./init.js";
import * as codegen from "./codegen.js";
import * as fs from "fs";
import * as path from "path";
import { restoreColorSafe } from "./error-formatter.js";
import * as renderer from "./render.js";
import { globbySync } from "globby";
import * as esbuild from "esbuild";
import { rewriteElmJson } from "./rewrite-elm-json.js";
import { ensureDirSync, deleteIfExists } from "./file-helpers.js";
import * as commander from "commander";
import { runElmCodegenInstall } from "./elm-codegen.js";
const commander = require("commander");
const { runElmCodegenInstall } = require("./elm-codegen.js");
const Argument = commander.Argument;
const Option = commander.Option;
const packageVersion = require("../../package.json").version;
import * as packageJson from "../../package.json" assert { type: "json" };
const packageVersion = packageJson.version;
async function main() {
const program = new commander.Command();
@ -124,7 +126,7 @@ async function main() {
path.join("./script/elm-stuff/elm-pages/.elm-pages/Main.elm"),
generatorWrapperFile(moduleName)
);
await copyModifiedElmJson(
await rewriteElmJson(
"./script/elm.json",
"./script/elm-stuff/elm-pages/elm.json"
);
@ -151,7 +153,7 @@ async function main() {
})
.catch((error) => {
const portBackendTaskFileFound =
globby.sync("./custom-backend-task.*").length > 0;
globbySync("./custom-backend-task.*").length > 0;
if (portBackendTaskFileFound) {
// don't present error if there are no files matching custom-backend-task
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
@ -169,10 +171,14 @@ async function main() {
// TODO have option for compiling with --debug or not (maybe allow running with elm-optimize-level-2 as well?)
await build.compileCliApp({ debug: "debug" });
process.chdir("../");
fs.renameSync(
"./script/elm-stuff/elm-pages/elm.js",
"./script/elm-stuff/elm-pages/elm.cjs"
);
await renderer.runGenerator(
unprocessedCliOptions,
resolvedPortsPath,
requireElm("./script/elm-stuff/elm-pages/elm.js"),
await requireElm("./script/elm-stuff/elm-pages/elm.cjs"),
moduleName
);
} catch (error) {
@ -187,7 +193,7 @@ async function main() {
.option("--port <number>", "serve site at localhost:<port>", "8000")
.action(async (options) => {
await codegen.generate("/");
const DocServer = require("elm-doc-preview");
const DocServer = (await import("elm-doc-preview")).default;
const server = new DocServer({
port: options.port,
browser: true,
@ -257,11 +263,11 @@ function normalizeUrl(rawPagePath) {
/**
* @param {string} compiledElmPath
*/
function requireElm(compiledElmPath) {
async function requireElm(compiledElmPath) {
const warnOriginal = console.warn;
console.warn = function () {};
Elm = require(path.resolve(compiledElmPath));
let Elm = (await import(path.resolve(compiledElmPath))).default;
console.warn = warnOriginal;
return Elm;
}

View File

@ -1,21 +1,24 @@
const fs = require("fs");
const fsExtra = require("fs-extra");
const copyModifiedElmJson = require("./rewrite-elm-json.js");
const copyModifiedElmJsonClient = require("./rewrite-client-elm-json.js");
const { elmPagesCliFile, elmPagesUiFile } = require("./elm-file-constants.js");
const spawnCallback = require("cross-spawn").spawn;
const which = require("which");
const {
generateTemplateModuleConnector,
} = require("./generate-template-module-connector.js");
const path = require("path");
const { ensureDirSync, deleteIfExists } = require("./file-helpers.js");
import * as fs from "fs";
import * as fsExtra from "fs-extra/esm";
import { rewriteElmJson } from "./rewrite-elm-json.js";
import { rewriteClientElmJson } from "./rewrite-client-elm-json.js";
import { elmPagesCliFile, elmPagesUiFile } from "./elm-file-constants.js";
import { spawn as spawnCallback } from "cross-spawn";
import { default as which } from "which";
import { generateTemplateModuleConnector } from "./generate-template-module-connector.js";
import * as path from "path";
import { ensureDirSync, deleteIfExists } from "./file-helpers.js";
import { fileURLToPath } from "url";
global.builtAt = new Date();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
* @param {string} basePath
*/
async function generate(basePath) {
export async function generate(basePath) {
const cliCode = await generateTemplateModuleConnector(basePath, "cli");
const browserCode = await generateTemplateModuleConnector(
basePath,
@ -63,7 +66,7 @@ async function generate(basePath) {
browserCode.fetcherModules
),
// write modified elm.json to elm-stuff/elm-pages/
copyModifiedElmJson("./elm.json", "./elm-stuff/elm-pages/elm.json"),
rewriteElmJson("./elm.json", "./elm-stuff/elm-pages/elm.json"),
// ...(await listFiles("./Pages/Internal")).map(copyToBoth),
]);
}
@ -85,7 +88,7 @@ async function newCopyBoth(modulePath) {
);
}
async function generateClientFolder(basePath) {
export async function generateClientFolder(basePath) {
const browserCode = await generateTemplateModuleConnector(
basePath,
"browser"
@ -97,7 +100,7 @@ async function generateClientFolder(basePath) {
await newCopyBoth("SharedTemplate.elm");
await newCopyBoth("SiteConfig.elm");
await copyModifiedElmJsonClient();
await rewriteClientElmJson();
await fsExtra.copy("./app", "./elm-stuff/elm-pages/client/app", {
recursive: true,
});
@ -230,5 +233,3 @@ async function listFiles(dir) {
function merge(arrays) {
return [].concat.apply([], arrays);
}
module.exports = { generate, generateClientFolder };

View File

@ -1 +1 @@
module.exports = { compatibilityKey: 6 };
export const compatibilityKey = 6;

View File

@ -1,17 +1,21 @@
const spawnCallback = require("cross-spawn").spawn;
const fs = require("fs");
const fsHelpers = require("./dir-helpers.js");
const fsPromises = require("fs").promises;
const path = require("path");
const kleur = require("kleur");
const { inject } = require("elm-hot");
const pathToClientElm = path.join(
process.cwd(),
"elm-stuff/elm-pages/",
"browser-elm.js"
);
import { spawn as spawnCallback } from "cross-spawn";
import * as fs from "fs";
import * as fsHelpers from "./dir-helpers.js";
import * as fsPromises from "fs/promises";
import * as path from "path";
import * as kleur from "kleur/colors";
import { inject } from "elm-hot";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function compileElmForBrowser(options) {
export async function compileElmForBrowser(options) {
// TODO do I need to make sure this is run from the right cwd? Before it was run outside of this function in the global scope, need to make sure that doesn't change semantics.
const pathToClientElm = path.join(
process.cwd(),
"elm-stuff/elm-pages/",
"browser-elm.js"
);
await runElm(options, "./.elm-pages/Main.elm", pathToClientElm);
return fs.promises.writeFile(
"./.elm-pages/cache/elm.js",
@ -26,7 +30,7 @@ async function compileElmForBrowser(options) {
);
}
async function compileCliApp(
export async function compileCliApp(
options,
elmEntrypointPath,
outputPath,
@ -211,7 +215,7 @@ async function runElm(options, elmEntrypointPath, outputPath, cwd) {
/**
* @param {string} [ cwd ]
*/
async function runElmReview(cwd) {
export async function runElmReview(cwd) {
const startTime = Date.now();
return new Promise((resolve, reject) => {
const child = spawnCallback(
@ -284,12 +288,6 @@ function elmOptimizeLevel2(outputPath, cwd) {
});
}
module.exports = {
compileElmForBrowser,
runElmReview,
compileCliApp,
};
/**
* @param {number} start
* @param {number} subtract

View File

@ -1,6 +1,6 @@
const path = require("path");
import * as path from "path";
async function resolveConfig() {
export async function resolveConfig() {
const initialConfig = await await import(
path.join(process.cwd(), "elm-pages.config.mjs")
)
@ -37,5 +37,3 @@ function defaultHeadTagsTemplate(context) {
<meta name="generator" content="elm-pages v${context.cliVersion}" />
`;
}
module.exports = { resolveConfig };

View File

@ -1,38 +1,43 @@
const path = require("path");
const fs = require("fs");
const which = require("which");
const chokidar = require("chokidar");
const { URL } = require("url");
const {
import * as path from "path";
import * as fs from "fs";
import { default as which } from "which";
import * as chokidar from "chokidar";
import { URL } from "url";
import {
compileElmForBrowser,
runElmReview,
compileCliApp,
} = require("./compile-elm.js");
const http = require("http");
const https = require("https");
const codegen = require("./codegen.js");
const kleur = require("kleur");
const serveStatic = require("serve-static");
const connect = require("connect");
const { restoreColorSafe } = require("./error-formatter");
const { Worker, SHARE_ENV } = require("worker_threads");
const os = require("os");
const { ensureDirSync } = require("./file-helpers.js");
const baseMiddleware = require("./basepath-middleware.js");
const devcert = require("devcert");
const busboy = require("busboy");
const { createServer: createViteServer } = require("vite");
const cliVersion = require("../../package.json").version;
const esbuild = require("esbuild");
const { merge_vite_configs } = require("./vite-utils.js");
const { templateHtml } = require("./pre-render-html.js");
const { resolveConfig } = require("./config.js");
const globby = require("globby");
} from "./compile-elm.js";
import * as http from "http";
import * as https from "https";
import * as codegen from "./codegen.js";
import * as kleur from "kleur/colors";
import { default as serveStatic } from "serve-static";
import { default as connect } from "connect";
import { restoreColorSafe } from "./error-formatter.js";
import { Worker, SHARE_ENV } from "worker_threads";
import * as os from "os";
import { ensureDirSync } from "./file-helpers.js";
import { baseMiddleware } from "./basepath-middleware.js";
import * as devcert from "devcert";
import * as busboy from "busboy";
import { createServer as createViteServer } from "vite";
import * as esbuild from "esbuild";
import { merge_vite_configs } from "./vite-utils.js";
import { templateHtml } from "./pre-render-html.js";
import { resolveConfig } from "./config.js";
import { globbySync } from "globby";
import * as packageJson from "../../package.json" assert { type: "json" };
import { fileURLToPath } from "url";
const cliVersion = packageJson.version;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
* @param {{ port: string; base: string; https: boolean; debug: boolean; }} options
*/
async function start(options) {
export async function start(options) {
let threadReadyQueue = [];
let pool = [];
ensureDirSync(path.join(process.cwd(), ".elm-pages", "http-response-cache"));
@ -46,6 +51,7 @@ async function start(options) {
const serveCachedFiles = serveStatic(".elm-pages/cache", { index: false });
const generatedFilesDirectory = "elm-stuff/elm-pages/generated-files";
fs.mkdirSync(generatedFilesDirectory, { recursive: true });
const serveStaticCode = serveStatic(
path.join(__dirname, "../static-code"),
{}
@ -175,7 +181,7 @@ async function start(options) {
})
.catch((error) => {
const portBackendTaskFileFound =
globby.sync("./custom-backend-task.*").length > 0;
globbySync("./custom-backend-task.*").length > 0;
if (portBackendTaskFileFound) {
// don't present error if there are no files matching custom-backend-task
// if there are files matching custom-backend-task, warn the user in case something went wrong loading it
@ -784,4 +790,3 @@ function paramsToObject(entries) {
}
return result;
}
module.exports = { start };

View File

@ -1,5 +1,7 @@
const util = require("util");
const fsSync = require("fs");
import * as util from "util";
import * as fsSync from "fs";
import * as path from "path";
const fs = {
writeFile: util.promisify(fsSync.writeFile),
writeFileSync: fsSync.writeFileSync,
@ -15,14 +17,14 @@ const fs = {
/**
* @param {import("fs").PathLike} dirName
*/
async function tryMkdir(dirName) {
export async function tryMkdir(dirName) {
const exists = await fs.exists(dirName);
if (!exists) {
await fs.mkdir(dirName, { recursive: true });
}
}
function fileExists(file) {
export function fileExists(file) {
return fsSync.promises
.access(file, fsSync.constants.F_OK)
.then(() => true)
@ -33,18 +35,16 @@ function fileExists(file) {
* @param {string} filePath
* @param {string} data
*/
function writeFileSyncSafe(filePath, data) {
export function writeFileSyncSafe(filePath, data) {
fsSync.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, data);
}
const path = require("path");
/**
* @param {string} srcDirectory
* @param {string} destDir
*/
async function copyDirFlat(srcDirectory, destDir) {
export async function copyDirFlat(srcDirectory, destDir) {
const items = await fs.readdir(srcDirectory);
items.forEach(function (childItemName) {
copyDirNested(
@ -58,7 +58,7 @@ async function copyDirFlat(srcDirectory, destDir) {
* @param {string} src
* @param {string} dest
*/
async function copyDirNested(src, dest) {
export async function copyDirNested(src, dest) {
var exists = fsSync.existsSync(src);
var stats = exists && fsSync.statSync(src);
var isDirectory = exists && stats.isDirectory();
@ -76,19 +76,3 @@ async function copyDirNested(src, dest) {
}
}
module.exports = {
writeFile: fs.writeFile,
writeFileSync: fs.writeFileSync,
readFile: fs.readFile,
readFileSync: fsSync.readFileSync,
copyFile: fs.copyFile,
exists: fs.exists,
writeFileSyncSafe,
tryMkdir,
copyDirFlat,
copyDirNested,
rmSync: fs.rm,
rm: fs.rm,
existsSync: fs.existsSync,
fileExists: fileExists,
};

View File

@ -1,6 +1,6 @@
const spawnCallback = require("cross-spawn").spawn;
import { spawn as spawnCallback } from "cross-spawn";
function runElmCodegenInstall() {
export function runElmCodegenInstall() {
return new Promise(async (resolve, reject) => {
const subprocess = spawnCallback(`elm-codegen`, ["install"], {
// ignore stdout
@ -33,5 +33,3 @@ function runElmCodegenInstall() {
});
});
}
module.exports = { runElmCodegenInstall };

View File

@ -1,4 +1,4 @@
function elmPagesUiFile() {
export function elmPagesUiFile() {
return `module Pages exposing (builtAt)
import Time
@ -12,7 +12,6 @@ builtAt =
`;
}
function elmPagesCliFile() {
export function elmPagesCliFile() {
return elmPagesUiFile();
}
module.exports = { elmPagesUiFile, elmPagesCliFile };

View File

@ -1,4 +1,6 @@
const kleur = require("kleur");
"use strict";
import * as kleur from "kleur/colors";
/* Thanks to elm-live for this code!
https://github.com/wking-io/elm-live/blob/e317b4914c471addea7243c47f28dcebe27a5d36/lib/src/build.js#L65
@ -82,7 +84,7 @@ function toKleurColor(color) {
/**
* @param {RootObject} error
* */
const restoreColor = (error) => {
export const restoreColor = (error) => {
try {
if (error.type === "compile-errors") {
return error.errors
@ -111,7 +113,7 @@ const restoreColor = (error) => {
* @param {string} error
* @returns {string}
*/
function restoreColorSafe(error) {
export function restoreColorSafe(error) {
try {
if (typeof error === "string") {
const asJson = JSON.parse(error);
@ -149,8 +151,6 @@ const restoreProblem =
}
};
module.exports = { restoreColor, restoreColorSafe };
/** @typedef { CompilerError | ReportError | IElmReviewError } RootObject */
/** @typedef { { type: "compile-errors"; errors: Error_[]; } } CompilerError */

View File

@ -1,7 +1,6 @@
const fs = require("fs");
module.exports = { ensureDirSync, deleteIfExists };
import * as fs from "fs";
function ensureDirSync(dirpath) {
export function ensureDirSync(dirpath) {
try {
fs.mkdirSync(dirpath, { recursive: true });
} catch (err) {
@ -9,7 +8,7 @@ function ensureDirSync(dirpath) {
}
}
function deleteIfExists(/** @type string */ filePath) {
export function deleteIfExists(/** @type string */ filePath) {
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}

View File

@ -1,17 +1,16 @@
const globby = require("globby");
const path = require("path");
const mm = require("micromatch");
const routeHelpers = require("./route-codegen-helpers");
const { runElmCodegenInstall } = require("./elm-codegen");
const { compileCliApp } = require("./compile-elm");
const { restoreColorSafe } = require("./error-formatter");
import { globbySync } from "globby";
import * as path from "path";
import { default as mm } from "micromatch";
import * as routeHelpers from "./route-codegen-helpers.js";
import { restoreColorSafe } from "./error-formatter.js";
import { fileURLToPath } from "url";
/**
* @param {string} basePath
* @param {'browser' | 'cli'} phase
*/
async function generateTemplateModuleConnector(basePath, phase) {
const templates = globby.sync(["app/Route/**/*.elm"], {}).map((file) => {
export async function generateTemplateModuleConnector(basePath, phase) {
const templates = globbySync(["app/Route/**/*.elm"], {}).map((file) => {
const captures = mm.capture("app/Route/**/*.elm", file);
if (captures) {
return path.join(captures[0], captures[1]).split(path.sep);
@ -63,10 +62,12 @@ async function generateTemplateModuleConnector(basePath, phase) {
}
async function runElmCodegenCli(templates, basePath, phase) {
const filePath = path.join(__dirname, `../../codegen/elm-pages-codegen.js`);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const filePath = path.join(__dirname, `../../codegen/elm-pages-codegen.cjs`);
const promise = new Promise((resolve, reject) => {
const elmPagesCodegen = require(filePath).Elm.Generate;
const promise = new Promise(async (resolve, reject) => {
const elmPagesCodegen = (await import(filePath)).default.Elm.Generate;
const app = elmPagesCodegen.init({
flags: { templates: templates, basePath, phase },
@ -91,7 +92,7 @@ async function runElmCodegenCli(templates, basePath, phase) {
* @param {string[][]} templates
* @returns
*/
function sortTemplates(templates) {
export function sortTemplates(templates) {
return templates.sort((first, second) => {
const a = sortScore(first);
const b = sortScore(second);
@ -230,5 +231,3 @@ submit toMsg options =
function camelToKebab(input) {
return input.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
}
module.exports = { generateTemplateModuleConnector, sortTemplates };

View File

@ -1,12 +1,15 @@
const fs = require("fs");
const copySync = require("fs-extra").copySync;
const path = require("path");
const kleur = require("kleur");
import * as fs from "fs";
import { copySync } from "fs-extra/esm";
import * as path from "path";
import * as kleur from "kleur/colors";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
* @param {string} name
*/
async function run(name) {
export async function run(name) {
console.log("Creating " + name + " project...");
const appRoot = path.resolve(name.toString());
@ -36,5 +39,3 @@ async function run(name) {
kleur.green("Project is successfully created in `" + appRoot + "`.")
);
}
module.exports = { run };

View File

@ -1,11 +1,16 @@
const seo = require("./seo-renderer.js");
const cliVersion = require("../../package.json").version;
const path = require("path");
import * as seo from "./seo-renderer.js";
import * as packageJson from "../../package.json" assert { type: "json" };
import * as path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const cliVersion = packageJson.version;
/** @typedef { { head: any[]; errors: any[]; html: string; route: string; title: string; } } Arg */
/** @typedef { { tag : 'PageProgress'; args : Arg[] } } PageProgress */
function wrapHtml(basePath, fromElm, contentDatPayload) {
export function wrapHtml(basePath, fromElm, contentDatPayload) {
const seoData = seo.gather(fromElm.head);
return {
kind: "html-template",
@ -21,7 +26,7 @@ function wrapHtml(basePath, fromElm, contentDatPayload) {
* @param {boolean} devMode
* @param {(context: {cliVersion: string;}) => string} userHeadTagsTemplate
*/
function templateHtml(devMode, userHeadTagsTemplate) {
export function templateHtml(devMode, userHeadTagsTemplate) {
return /* html */ `<!DOCTYPE html>
<!-- ROOT --><html lang="en">
<head>
@ -65,7 +70,7 @@ function indent(snippet) {
/**
* @param {string} processedTemplate
*/
function replaceTemplate(processedTemplate, info) {
export function replaceTemplate(processedTemplate, info) {
return processedTemplate
.replace(
/<!--\s*PLACEHOLDER_HEAD_AND_DATA\s*-->/,
@ -77,8 +82,3 @@ function replaceTemplate(processedTemplate, info) {
.replace(/<!-- ROOT -->\S*<html lang="en">/m, info.rootElement);
}
module.exports = {
wrapHtml,
templateHtml,
replaceTemplate,
};

View File

@ -1,9 +1,10 @@
const renderer = require("../../generator/src/render");
const path = require("path");
const fs = require("./dir-helpers.js");
import * as renderer from "../../generator/src/render.js";
import * as path from "path";
import * as fs from "./dir-helpers.js";
import { readFileSync, writeFileSync } from "fs";
import { stat } from "fs/promises";
import { parentPort, threadId, workerData } from "worker_threads";
const compiledElmPath = path.join(process.cwd(), "elm-stuff/elm-pages/elm.js");
const { parentPort, threadId, workerData } = require("worker_threads");
let Elm;
global.staticHttpCache = {};
@ -13,7 +14,7 @@ async function run({ mode, pathname, serverRequest, portsFilePath }) {
const renderResult = await renderer.render(
portsFilePath,
workerData.basePath,
requireElm(mode),
await requireElm(mode),
mode,
pathname,
serverRequest,
@ -42,20 +43,18 @@ async function run({ mode, pathname, serverRequest, portsFilePath }) {
console.timeEnd(`${threadId} ${pathname}`);
}
function requireElm(mode) {
if (mode === "build") {
if (!Elm) {
const warnOriginal = console.warn;
console.warn = function () {};
Elm = require(compiledElmPath);
console.warn = warnOriginal;
}
return Elm;
} else {
delete require.cache[require.resolve(compiledElmPath)];
return require(compiledElmPath);
async function requireElm(mode) {
let elmImportPath = compiledElmPath;
if (mode !== "build") {
const { mtimeMs } = await stat(compiledElmPath);
console.log({ mtimeMs });
elmImportPath = `${compiledElmPath}?time=${mtimeMs}`;
}
const warnOriginal = console.warn;
console.warn = function () {};
const Elm = (await import(elmImportPath)).default;
console.warn = warnOriginal;
return Elm;
}
async function outputString(
@ -67,13 +66,13 @@ async function outputString(
const args = fromElm;
const normalizedRoute = args.route.replace(/index$/, "");
await fs.tryMkdir(`./dist/${normalizedRoute}`);
const template = await fs.readFileSync("./dist/template.html", "utf8");
fs.writeFileSync(
const template = readFileSync("./dist/template.html", "utf8");
writeFileSync(
`dist/${normalizedRoute}/index.html`,
renderTemplate(template, fromElm)
);
args.contentDatPayload &&
fs.writeFileSync(
writeFileSync(
`dist/${normalizedRoute}/content.dat`,
Buffer.from(args.contentDatPayload.buffer)
);

View File

@ -1,24 +1,22 @@
// @ts-check
const path = require("path");
const mm = require("micromatch");
const matter = require("gray-matter");
const globby = require("globby");
const fsPromises = require("fs").promises;
const preRenderHtml = require("./pre-render-html.js");
const { lookupOrPerform } = require("./request-cache.js");
const kleur = require("kleur");
const cookie = require("cookie-signature");
const { compatibilityKey } = require("./compatibility-key.js");
kleur.enabled = true;
import * as path from "path";
import { default as mm } from "micromatch";
import { default as matter } from "gray-matter";
import { globby } from "globby";
import * as fsPromises from "fs/promises";
import * as preRenderHtml from "./pre-render-html.js";
import { lookupOrPerform } from "./request-cache.js";
import * as kleur from "kleur/colors";
import * as cookie from "cookie-signature";
import { compatibilityKey } from "./compatibility-key.js";
import * as fs from "fs";
process.on("unhandledRejection", (error) => {
console.error(error);
});
let foundErrors;
module.exports = { render, runGenerator };
/**
*
* @param {string} basePath
@ -29,7 +27,7 @@ module.exports = { render, runGenerator };
* @param {boolean} hasFsAccess
* @returns
*/
async function render(
export async function render(
portsFile,
basePath,
elmModule,
@ -39,12 +37,12 @@ async function render(
addBackendTaskWatcher,
hasFsAccess
) {
const { fs, resetInMemoryFs } = require("./request-cache-fs.js")(hasFsAccess);
resetInMemoryFs();
// const { fs, resetInMemoryFs } = require("./request-cache-fs.js")(hasFsAccess);
// resetInMemoryFs();
foundErrors = false;
// since init/update are never called in pre-renders, and BackendTask.Http is called using pure NodeJS HTTP fetching
// we can provide a fake HTTP instead of xhr2 (which is otherwise needed for Elm HTTP requests from Node)
XMLHttpRequest = {};
global.XMLHttpRequest = {};
const result = await runElmApp(
portsFile,
basePath,
@ -53,7 +51,6 @@ async function render(
path,
request,
addBackendTaskWatcher,
fs,
hasFsAccess
);
return result;
@ -66,19 +63,19 @@ async function render(
* @param {any} portsFile
* @param {string} scriptModuleName
*/
async function runGenerator(
export async function runGenerator(
cliOptions,
portsFile,
elmModule,
scriptModuleName
) {
global.isRunningGenerator = true;
const { fs, resetInMemoryFs } = require("./request-cache-fs.js")(true);
resetInMemoryFs();
// const { fs, resetInMemoryFs } = require("./request-cache-fs.js")(true);
// resetInMemoryFs();
foundErrors = false;
// since init/update are never called in pre-renders, and BackendTask.Http is called using pure NodeJS HTTP fetching
// we can provide a fake HTTP instead of xhr2 (which is otherwise needed for Elm HTTP requests from Node)
XMLHttpRequest = {};
global.XMLHttpRequest = {};
const result = await runGeneratorAppHelp(
cliOptions,
portsFile,
@ -87,7 +84,6 @@ async function runGenerator(
scriptModuleName,
"production",
"",
fs,
true
);
return result;
@ -112,7 +108,6 @@ function runGeneratorAppHelp(
scriptModuleName,
mode,
pagePath,
fs,
hasFsAccess
) {
const isDevServer = mode !== "build";
@ -182,7 +177,6 @@ function runGeneratorAppHelp(
app,
mode,
requestToPerform,
fs,
hasFsAccess,
patternsToWatch
);
@ -193,7 +187,6 @@ function runGeneratorAppHelp(
app,
mode,
requestToPerform,
fs,
hasFsAccess,
requestToPerform
);
@ -236,7 +229,6 @@ function runElmApp(
pagePath,
request,
addBackendTaskWatcher,
fs,
hasFsAccess
) {
const isDevServer = mode !== "build";
@ -331,7 +323,6 @@ function runElmApp(
app,
mode,
requestToPerform,
fs,
hasFsAccess,
patternsToWatch
);
@ -342,7 +333,6 @@ function runElmApp(
app,
mode,
requestToPerform,
fs,
hasFsAccess,
requestToPerform
);
@ -415,7 +405,6 @@ async function runHttpJob(
app,
mode,
requestToPerform,
fs,
hasFsAccess,
useCache
) {
@ -474,7 +463,6 @@ async function runInternalJob(
app,
mode,
requestToPerform,
fs,
hasFsAccess,
patternsToWatch
) {

View File

@ -1,6 +1,7 @@
const path = require("path");
const kleur = require("kleur");
const fsPromises = require("fs/promises");
import * as path from "path";
import * as fsPromises from "fs/promises";
import * as kleur from "kleur/colors";
import { default as makeFetchHappenOriginal } from "make-fetch-happen";
const defaultHttpCachePath = "./.elm-pages/http-cache";
@ -13,8 +14,14 @@ const defaultHttpCachePath = "./.elm-pages/http-cache";
* @param {boolean} hasFsAccess
* @returns {Promise<Response>}
*/
function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
const makeFetchHappen = require("make-fetch-happen").defaults({
export function lookupOrPerform(
portsFile,
mode,
rawRequest,
hasFsAccess,
useCache
) {
const makeFetchHappen = makeFetchHappenOriginal.defaults({
cache: mode === "build" ? "no-cache" : "default",
});
return new Promise(async (resolve, reject) => {
@ -29,7 +36,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
const portBackendTaskPath = path.resolve(portsFile);
// On Windows, we need cannot use paths directly and instead must use a file:// URL.
// portBackendTask = await require(url.pathToFileURL(portBackendTaskPath).href);
portBackendTask = require(portBackendTaskPath);
portBackendTask = await import(portBackendTaskPath);
} catch (e) {
portBackendTaskImportError = e;
}
@ -270,5 +277,3 @@ async function canAccess(filePath) {
return false;
}
}
module.exports = { lookupOrPerform };

View File

@ -1,6 +1,6 @@
const fs = require("fs");
import * as fs from "fs";
module.exports = async function () {
export async function rewriteClientElmJson() {
var elmJson = JSON.parse(
(await fs.promises.readFile("./elm.json")).toString()
);
@ -9,11 +9,11 @@ module.exports = async function () {
await writeFileIfChanged(
"./elm-stuff/elm-pages/client/elm.json",
JSON.stringify(rewriteElmJson(elmJson))
JSON.stringify(rewriteClientElmJsonHelp(elmJson))
);
};
}
function rewriteElmJson(elmJson) {
function rewriteClientElmJsonHelp(elmJson) {
// The internal generated file will be at:
// ./elm-stuff/elm-pages/
// So, we need to take the existing elmJson and

View File

@ -1,6 +1,6 @@
const fs = require("fs");
import * as fs from "fs";
module.exports = async function (sourceElmJsonPath, targetElmJsonPath) {
export async function rewriteElmJson(sourceElmJsonPath, targetElmJsonPath) {
var elmJson = JSON.parse(
(await fs.promises.readFile(sourceElmJsonPath)).toString()
);
@ -9,11 +9,11 @@ module.exports = async function (sourceElmJsonPath, targetElmJsonPath) {
await writeFileIfChanged(
targetElmJsonPath,
JSON.stringify(rewriteElmJson(elmJson))
JSON.stringify(rewriteElmJsonHelp(elmJson))
);
};
}
function rewriteElmJson(elmJson) {
function rewriteElmJsonHelp(elmJson) {
// The internal generated file will be at:
// ./elm-stuff/elm-pages/
// So, we need to take the existing elmJson and

View File

@ -1,7 +1,7 @@
/**
* @param {string[]} name
*/
function routeParams(name) {
export function routeParams(name) {
return name
.map((section) => {
const routeParamMatch = section.match(/([A-Z][A-Za-z0-9]*)__?$/);
@ -17,7 +17,7 @@ function routeParams(name) {
* @param {string[]} name
* @returns {Segment[]}
*/
function parseRouteParams(name) {
export function parseRouteParams(name) {
return name.flatMap((section) => {
const routeParamMatch = section.match(/([A-Z][A-Za-z0-9]*)(_?_?)$/);
const maybeParam = (routeParamMatch && routeParamMatch[1]) || "TODO";
@ -68,7 +68,7 @@ function parseRouteParams(name) {
* @param {string[]} name
* @returns {( Segment | {kind: 'static'; name: string})[]}
*/
function parseRouteParamsWithStatic(name) {
export function parseRouteParamsWithStatic(name) {
return name.flatMap((section) => {
const routeParamMatch = section.match(/([A-Z][A-Za-z0-9]*)(_?_?)$/);
const maybeParam = (routeParamMatch && routeParamMatch[1]) || "TODO";
@ -123,7 +123,7 @@ function parseRouteParamsWithStatic(name) {
* @param {string[]} name
* @returns {string}
*/
function routeVariantDefinition(name) {
export function routeVariantDefinition(name) {
const newLocal = parseRouteParams(name);
if (newLocal.length == 0) {
return routeVariant(name);
@ -151,7 +151,7 @@ function routeVariantDefinition(name) {
* @param {string[]} name
* @returns {string}
*/
function toPathPattern(name) {
export function toPathPattern(name) {
return (
"/" +
parseRouteParamsWithStatic(name)
@ -181,7 +181,7 @@ function toPathPattern(name) {
* @param {string[]} name
* @returns {string[]}
*/
function toPathPatterns(name) {
export function toPathPatterns(name) {
const segments = parseRouteParamsWithStatic(name);
const lastSegment = segments[segments.length - 1];
@ -199,7 +199,7 @@ function toPathPatterns(name) {
/**
* @param {string[]} segments
*/
function joinPath(segments) {
export function joinPath(segments) {
const joined = segments.join("/");
if (joined.startsWith("/")) {
return joined;
@ -211,7 +211,7 @@ function joinPath(segments) {
/**
* @return {string[]}
*/
function newHelper(segments) {
export function newHelper(segments) {
return segments.map((param) => {
switch (param.kind) {
case "static": {
@ -238,7 +238,7 @@ function newHelper(segments) {
* @param {string[]} name
* @returns {string}
*/
function toElmPathPattern(name) {
export function toElmPathPattern(name) {
const parsedSegments = parseRouteParamsWithStatic(name);
const foundEndings = parsedSegments.flatMap((segment) => {
@ -297,14 +297,14 @@ function toElmPathPattern(name) {
* @param {string} input
* @returns {string}
*/
function camelToKebab(input) {
export function camelToKebab(input) {
return input.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
}
/**
* @param {string[]} name
*/
function paramsRecord(name) {
export function paramsRecord(name) {
return `{ ${parseRouteParams(name).map((param) => {
switch (param.kind) {
case "dynamic": {
@ -326,7 +326,7 @@ function paramsRecord(name) {
/**
* @param {string[]} name
*/
function routeVariant(name) {
export function routeVariant(name) {
return `${name.join("__")}`;
}
@ -334,44 +334,29 @@ function routeVariant(name) {
* @param {string[]} name
* @param {string} paramsName
*/
function destructureRoute(name, paramsName) {
export function destructureRoute(name, paramsName) {
return emptyRouteParams(name)
? `Route.${routeVariant(name)}`
: `(Route.${routeVariant(name)} ${paramsName})`;
}
function referenceRouteParams(name, paramsName) {
export function referenceRouteParams(name, paramsName) {
return emptyRouteParams(name) ? `{}` : paramsName;
}
/**
* @param {string[]} name
*/
function emptyRouteParams(name) {
export function emptyRouteParams(name) {
return parseRouteParams(name).length === 0;
}
/**
* @param {string} name
*/
function toFieldName(name) {
export function toFieldName(name) {
if (name === "SPLAT") {
return "splat";
} else {
return name.charAt(0).toLowerCase() + name.slice(1);
}
}
module.exports = {
routeParams,
routeVariantDefinition,
routeVariant,
toFieldName,
paramsRecord,
toPathPattern,
toPathPatterns,
parseRouteParams,
parseRouteParamsWithStatic,
toElmPathPattern,
destructureRoute,
referenceRouteParams,
};

View File

@ -1,11 +1,9 @@
module.exports = { gather };
/** @typedef { { type: 'root'; keyValuePair: [string, string] } } RootTagModifier */
/**
* @param {( SeoTag | RootTagModifier )[]} tags
*/
function gather(tags) {
export function gather(tags) {
const withoutRootModifiers = tags.flatMap((value) => {
if (value.type === "root") {
return [];

View File

@ -4,7 +4,7 @@
* @param {...import('vite').UserConfig} configs
* @returns {import('vite').UserConfig}
*/
function merge_vite_configs(...configs) {
export function merge_vite_configs(...configs) {
return deep_merge(
...configs.map((config) => ({
...config,
@ -75,4 +75,3 @@ function merge_into(a, b) {
}
}
}
module.exports = { merge_vite_configs };

View File

@ -1,7 +1,7 @@
{
"compilerOptions": {
"types": ["node"],
"module": "commonjs",
"module": "esnext",
"checkJs": true,
"allowJs": true,
"target": "es5",

240
package-lock.json generated
View File

@ -11,7 +11,7 @@
"dependencies": {
"busboy": "^1.0.0",
"chokidar": "^3.5.3",
"commander": "^9.5.0",
"commander": "^10.0.0",
"connect": "^3.7.0",
"cookie-signature": "^1.1.0",
"cross-spawn": "7.0.3",
@ -19,8 +19,8 @@
"elm-doc-preview": "^5.0.5",
"elm-hot": "^1.1.6",
"esbuild": "^0.16.15",
"fs-extra": "^10.1.0",
"globby": "11.0.4",
"fs-extra": "^11.1.0",
"globby": "^13.1.3",
"gray-matter": "^4.0.3",
"jsesc": "^3.0.2",
"kleur": "^4.1.5",
@ -30,7 +30,7 @@
"serve-static": "^1.15.0",
"terser": "^5.16.1",
"vite": "^4.0.4",
"which": "^2.0.2"
"which": "^3.0.0"
},
"bin": {
"elm-pages": "generator/src/cli.js"
@ -1025,14 +1025,6 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"engines": {
"node": ">=8"
}
},
"node_modules/asn1": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
@ -1882,11 +1874,11 @@
"integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w=="
},
"node_modules/commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz",
"integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==",
"engines": {
"node": "^12.20.0 || >=14"
"node": ">=14"
}
},
"node_modules/common-tags": {
@ -1971,6 +1963,20 @@
"node": ">= 8"
}
},
"node_modules/cross-spawn/node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/cypress": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-12.3.0.tgz",
@ -2487,6 +2493,21 @@
"node": ">=10"
}
},
"node_modules/elm-review/node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/elm-solve-deps-wasm": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/elm-solve-deps-wasm/-/elm-solve-deps-wasm-1.0.2.tgz",
@ -2526,6 +2547,15 @@
"balanced-match": "^1.0.0"
}
},
"node_modules/elm-test/node_modules/commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true,
"engines": {
"node": "^12.20.0 || >=14"
}
},
"node_modules/elm-test/node_modules/glob": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
@ -2557,6 +2587,21 @@
"node": ">=10"
}
},
"node_modules/elm-test/node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/elm-tooling": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/elm-tooling/-/elm-tooling-1.11.0.tgz",
@ -2633,6 +2678,15 @@
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
"dev": true
},
"node_modules/elm-verify-examples/node_modules/commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true,
"engines": {
"node": "^12.20.0 || >=14"
}
},
"node_modules/elm-verify-examples/node_modules/elm-test": {
"version": "0.19.1-revision9",
"resolved": "https://registry.npmjs.org/elm-test/-/elm-test-0.19.1-revision9.tgz",
@ -2808,6 +2862,21 @@
"node": ">= 4.0.0"
}
},
"node_modules/elm-verify-examples/node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/elmi-to-json": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/elmi-to-json/-/elmi-to-json-1.4.3.tgz",
@ -3425,16 +3494,16 @@
}
},
"node_modules/fs-extra": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz",
"integrity": "sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=12"
"node": ">=14.14"
}
},
"node_modules/fs-minipass": {
@ -3593,19 +3662,18 @@
}
},
"node_modules/globby": {
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
"integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==",
"version": "13.1.3",
"resolved": "https://registry.npmjs.org/globby/-/globby-13.1.3.tgz",
"integrity": "sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==",
"dependencies": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.1.1",
"ignore": "^5.1.4",
"merge2": "^1.3.0",
"slash": "^3.0.0"
"fast-glob": "^3.2.11",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^4.0.0"
},
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
@ -6491,11 +6559,14 @@
"dev": true
},
"node_modules/slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
"integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==",
"engines": {
"node": ">=8"
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/slice-ansi": {
@ -7223,17 +7294,17 @@
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/which/-/which-3.0.0.tgz",
"integrity": "sha512-nla//68K9NU6yRiwDY/Q8aU6siKlSs64aEC7+IV56QoAuyQT2ovsJcgGYGyqMOmI/CGN1BOR6mM5EN0FBO+zyQ==",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
"node-which": "bin/which.js"
},
"engines": {
"node": ">= 8"
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"node_modules/which-module": {
@ -8160,11 +8231,6 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="
},
"asn1": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
@ -8807,9 +8873,9 @@
"integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w=="
},
"commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ=="
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz",
"integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA=="
},
"common-tags": {
"version": "1.8.2",
@ -8870,6 +8936,16 @@
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"dependencies": {
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"requires": {
"isexe": "^2.0.0"
}
}
}
},
"cypress": {
@ -9280,6 +9356,15 @@
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
}
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
}
}
},
@ -9316,6 +9401,12 @@
"balanced-match": "^1.0.0"
}
},
"commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true
},
"glob": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
@ -9337,6 +9428,15 @@
"requires": {
"brace-expansion": "^2.0.1"
}
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
}
}
},
@ -9404,6 +9504,12 @@
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
"dev": true
},
"commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true
},
"elm-test": {
"version": "0.19.1-revision9",
"resolved": "https://registry.npmjs.org/elm-test/-/elm-test-0.19.1-revision9.tgz",
@ -9535,6 +9641,15 @@
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
}
}
},
@ -10017,9 +10132,9 @@
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
},
"fs-extra": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz",
"integrity": "sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
@ -10144,16 +10259,15 @@
}
},
"globby": {
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
"integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==",
"version": "13.1.3",
"resolved": "https://registry.npmjs.org/globby/-/globby-13.1.3.tgz",
"integrity": "sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==",
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.1.1",
"ignore": "^5.1.4",
"merge2": "^1.3.0",
"slash": "^3.0.0"
"fast-glob": "^3.2.11",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^4.0.0"
}
},
"got": {
@ -12284,9 +12398,9 @@
"dev": true
},
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
"integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew=="
},
"slice-ansi": {
"version": "3.0.0",
@ -12807,9 +12921,9 @@
}
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/which/-/which-3.0.0.tgz",
"integrity": "sha512-nla//68K9NU6yRiwDY/Q8aU6siKlSs64aEC7+IV56QoAuyQT2ovsJcgGYGyqMOmI/CGN1BOR6mM5EN0FBO+zyQ==",
"requires": {
"isexe": "^2.0.0"
}

View File

@ -1,5 +1,6 @@
{
"name": "elm-pages",
"type": "module",
"version": "3.0.0-beta.18",
"homepage": "https://elm-pages.com",
"moduleResolution": "node",
@ -10,7 +11,7 @@
"test": "./test.sh",
"test:snapshot": "(cd examples/escaping && npm install && npm test) && (cd examples/base-path && npm install && npm test)",
"cypress": "npm start & cypress run",
"build:generator": "elm-codegen install && (cd codegen && lamdera make Generate.elm --output elm-pages-codegen.js)",
"build:generator": "elm-codegen install && (cd codegen && lamdera make Generate.elm --output elm-pages-codegen.js && mv elm-pages-codegen.js elm-pages-codegen.cjs)",
"review": "elm-review"
},
"repository": "https://github.com/dillonkearns/elm-pages",
@ -26,7 +27,7 @@
"dependencies": {
"busboy": "^1.0.0",
"chokidar": "^3.5.3",
"commander": "^9.5.0",
"commander": "^10.0.0",
"connect": "^3.7.0",
"cookie-signature": "^1.1.0",
"cross-spawn": "7.0.3",
@ -34,8 +35,8 @@
"elm-doc-preview": "^5.0.5",
"elm-hot": "^1.1.6",
"esbuild": "^0.16.15",
"fs-extra": "^10.1.0",
"globby": "11.0.4",
"fs-extra": "^11.1.0",
"globby": "^13.1.3",
"gray-matter": "^4.0.3",
"jsesc": "^3.0.2",
"kleur": "^4.1.5",
@ -45,7 +46,7 @@
"serve-static": "^1.15.0",
"terser": "^5.16.1",
"vite": "^4.0.4",
"which": "^2.0.2"
"which": "^3.0.0"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
@ -70,11 +71,11 @@
"generator/review/",
"generator/dead-code-review/",
"src/",
"codegen/elm-pages-codegen.js",
"codegen/elm-pages-codegen.cjs",
"generator/template/",
"generator/static-code/"
],
"bin": {
"elm-pages": "generator/src/cli.js"
}
}
}