mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 14:34:18 +03:00
Generate files in .elm-pages instead of gen. Fixes #165.
This commit is contained in:
parent
1aa737c431
commit
fff155bc21
2
examples/docs/.gitignore
vendored
2
examples/docs/.gitignore
vendored
@ -2,7 +2,7 @@ node_modules/
|
||||
elm-stuff/
|
||||
dist/
|
||||
.cache/
|
||||
gen/
|
||||
.elm-pages/
|
||||
functions/render/elm-pages-cli.js
|
||||
browser-elm.js
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"source-directories": [
|
||||
"src",
|
||||
"../../src",
|
||||
"gen",
|
||||
".elm-pages",
|
||||
"../../plugins"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
@ -63,4 +63,4 @@
|
||||
},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
}
|
2
examples/repos/.gitignore
vendored
2
examples/repos/.gitignore
vendored
@ -2,7 +2,7 @@ node_modules/
|
||||
elm-stuff/
|
||||
dist/
|
||||
.cache/
|
||||
gen/
|
||||
.elm-pages/
|
||||
functions/render/elm-pages-cli.js
|
||||
browser-elm.js
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"source-directories": [
|
||||
"src",
|
||||
"../../src",
|
||||
"gen",
|
||||
".elm-pages",
|
||||
"../../plugins"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
@ -64,4 +64,4 @@
|
||||
},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
}
|
2
examples/routing/.gitignore
vendored
2
examples/routing/.gitignore
vendored
@ -2,7 +2,7 @@ node_modules/
|
||||
elm-stuff/
|
||||
dist/
|
||||
.cache/
|
||||
gen/
|
||||
.elm-pages/
|
||||
functions/render/elm-pages-cli.js
|
||||
browser-elm.js
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"source-directories": [
|
||||
"src",
|
||||
"../../src",
|
||||
"gen",
|
||||
".elm-pages",
|
||||
"../../plugins"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
@ -64,4 +64,4 @@
|
||||
},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
}
|
2
examples/slides/.gitignore
vendored
2
examples/slides/.gitignore
vendored
@ -2,7 +2,7 @@ node_modules/
|
||||
elm-stuff/
|
||||
dist/
|
||||
.cache/
|
||||
gen/
|
||||
.elm-pages/
|
||||
functions/render/elm-pages-cli.js
|
||||
browser-elm.js
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"source-directories": [
|
||||
"src",
|
||||
"../../src",
|
||||
"gen",
|
||||
".elm-pages",
|
||||
"../../plugins"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
@ -64,4 +64,4 @@
|
||||
},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
}
|
@ -168,7 +168,7 @@ async function outputString(/** @type { PageProgress } */ fromElm) {
|
||||
async function compileElm(options) {
|
||||
const outputPath = `dist/elm.js`;
|
||||
const fullOutputPath = path.join(process.cwd(), `dist/elm.js`);
|
||||
await spawnElmMake(options, "gen/TemplateModulesBeta.elm", outputPath);
|
||||
await spawnElmMake(options, ".elm-pages/TemplateModulesBeta.elm", outputPath);
|
||||
|
||||
if (!options.debug) {
|
||||
await runTerser(fullOutputPath);
|
||||
@ -285,7 +285,7 @@ async function copyAssets() {
|
||||
async function compileCliApp(options) {
|
||||
await spawnElmMake(
|
||||
options,
|
||||
"TemplateModulesBeta.elm",
|
||||
".elm-pages/TemplateModulesBeta.elm",
|
||||
"elm.js",
|
||||
"./elm-stuff/elm-pages"
|
||||
);
|
||||
|
@ -16,46 +16,51 @@ async function writeFiles() {
|
||||
const cliCode = generateTemplateModuleConnector("cli");
|
||||
const browserCode = generateTemplateModuleConnector("browser");
|
||||
ensureDirSync("./elm-stuff");
|
||||
ensureDirSync("./gen");
|
||||
ensureDirSync("./elm-stuff/elm-pages");
|
||||
fs.copyFileSync(path.join(__dirname, `./Page.elm`), `./gen/Page.elm`);
|
||||
ensureDirSync("./.elm-pages");
|
||||
ensureDirSync("./elm-stuff/elm-pages/.elm-pages");
|
||||
fs.copyFileSync(path.join(__dirname, `./Page.elm`), `./.elm-pages/Page.elm`);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, `./Page.elm`),
|
||||
`./elm-stuff/elm-pages/Page.elm`
|
||||
`./elm-stuff/elm-pages/.elm-pages/Page.elm`
|
||||
);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, `./SharedTemplate.elm`),
|
||||
`./gen/SharedTemplate.elm`
|
||||
`./.elm-pages/SharedTemplate.elm`
|
||||
);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, `./SharedTemplate.elm`),
|
||||
`./elm-stuff/elm-pages/SharedTemplate.elm`
|
||||
`./elm-stuff/elm-pages/.elm-pages/SharedTemplate.elm`
|
||||
);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, `./SiteConfig.elm`),
|
||||
`./gen/SiteConfig.elm`
|
||||
`./.elm-pages/SiteConfig.elm`
|
||||
);
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, `./SiteConfig.elm`),
|
||||
`./elm-stuff/elm-pages/SiteConfig.elm`
|
||||
`./elm-stuff/elm-pages/.elm-pages/SiteConfig.elm`
|
||||
);
|
||||
|
||||
// prevent compilation errors if migrating from previous elm-pages version
|
||||
deleteIfExists("./elm-stuff/elm-pages/Pages/ContentCache.elm");
|
||||
deleteIfExists("./elm-stuff/elm-pages/Pages/Platform.elm");
|
||||
|
||||
const uiFileContent = elmPagesUiFile();
|
||||
fs.writeFileSync("./gen/Pages.elm", uiFileContent);
|
||||
fs.writeFileSync("./.elm-pages/Pages.elm", uiFileContent);
|
||||
|
||||
// write `Pages.elm` with cli interface
|
||||
fs.writeFileSync("./elm-stuff/elm-pages/Pages.elm", elmPagesCliFile());
|
||||
fs.writeFileSync(
|
||||
"./elm-stuff/elm-pages/TemplateModulesBeta.elm",
|
||||
"./elm-stuff/elm-pages/.elm-pages/Pages.elm",
|
||||
elmPagesCliFile()
|
||||
);
|
||||
fs.writeFileSync(
|
||||
"./elm-stuff/elm-pages/.elm-pages/TemplateModulesBeta.elm",
|
||||
cliCode.mainModule
|
||||
);
|
||||
fs.writeFileSync("./elm-stuff/elm-pages/Route.elm", cliCode.routesModule);
|
||||
fs.writeFileSync("./gen/TemplateModulesBeta.elm", browserCode.mainModule);
|
||||
fs.writeFileSync("./gen/Route.elm", browserCode.routesModule);
|
||||
fs.writeFileSync(
|
||||
"./elm-stuff/elm-pages/.elm-pages/Route.elm",
|
||||
cliCode.routesModule
|
||||
);
|
||||
fs.writeFileSync(
|
||||
"./.elm-pages/TemplateModulesBeta.elm",
|
||||
browserCode.mainModule
|
||||
);
|
||||
fs.writeFileSync("./.elm-pages/Route.elm", browserCode.routesModule);
|
||||
|
||||
// write modified elm.json to elm-stuff/elm-pages/
|
||||
copyModifiedElmJson();
|
||||
|
@ -33,7 +33,7 @@ async function spawnElmMake(elmEntrypointPath, outputPath, cwd) {
|
||||
}
|
||||
|
||||
async function compileElmForBrowser() {
|
||||
await runElm("gen/TemplateModulesBeta.elm", pathToClientElm);
|
||||
await runElm("./.elm-pages/TemplateModulesBeta.elm", pathToClientElm);
|
||||
return inject(await fs.promises.readFile(pathToClientElm, "utf-8"));
|
||||
}
|
||||
|
||||
|
@ -71,9 +71,9 @@ async function start(options) {
|
||||
|
||||
async function compileCliApp() {
|
||||
await spawnElmMake(
|
||||
"TemplateModulesBeta.elm",
|
||||
".elm-pages/TemplateModulesBeta.elm",
|
||||
"elm.js",
|
||||
"elm-stuff/elm-pages"
|
||||
"elm-stuff/elm-pages/"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
const fs = require("fs");
|
||||
|
||||
module.exports = function() {
|
||||
module.exports = function () {
|
||||
var elmJson = JSON.parse(fs.readFileSync("./elm.json").toString());
|
||||
|
||||
// write new elm.json
|
||||
@ -15,14 +15,16 @@ function rewriteElmJson(elmJson) {
|
||||
// ./elm-stuff/elm-pages/
|
||||
// So, we need to take the existing elmJson and
|
||||
// 1. remove existing path that looks at `Pages.elm`
|
||||
elmJson["source-directories"] = elmJson["source-directories"].filter(item => {
|
||||
return item != "gen";
|
||||
});
|
||||
elmJson["source-directories"] = elmJson["source-directories"].filter(
|
||||
(item) => {
|
||||
return item != ".elm-pages";
|
||||
}
|
||||
);
|
||||
// 2. prepend ../../../ to remaining
|
||||
elmJson["source-directories"] = elmJson["source-directories"].map(item => {
|
||||
elmJson["source-directories"] = elmJson["source-directories"].map((item) => {
|
||||
return "../../" + item;
|
||||
});
|
||||
// 3. add our own secret My.elm module 😈
|
||||
elmJson["source-directories"].push(".");
|
||||
elmJson["source-directories"].push(".elm-pages");
|
||||
return elmJson;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
"source-directories": [
|
||||
"src",
|
||||
"../../src",
|
||||
"gen"
|
||||
".elm-pages"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
"dependencies": {
|
||||
@ -40,4 +40,4 @@
|
||||
"direct": {},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user