Permalink
Browse files

|🚨 @phenomic/core: introduce `content` option to folder for the cont…

…ent (and `dist` option is now relative to `path`)
  • Loading branch information...
MoOx committed Mar 6, 2018
1 parent 141a6cb commit 24657cc6b9b85e725d25f2dd5bb82367a2956b59
@@ -51,6 +51,7 @@ export type PhenomicInputPlugins = {
export type PhenomicInputConfig = {
path?: string,
content?: string,
outdir?: string,
port?: number,
bundleName?: string,
@@ -157,6 +158,7 @@ export type PhenomicExtensions = PhenomicPreset;
export type PhenomicConfig = {
path: string,
content: string,
outdir: string,
port: number,
bundleName: string,
@@ -19,9 +19,8 @@ import getPath from "../utils/getPath";
const debug = require("debug")("phenomic:core:commands:build");
const contentFolder = "content";
const getContentPath = (config: PhenomicConfig) =>
getPath(path.join(config.path, contentFolder));
getPath(path.join(config.path, config.content));
let lastStamp = Date.now();
async function getContent(db, config: PhenomicConfig) {
@@ -39,31 +38,34 @@ async function getContent(db, config: PhenomicConfig) {
throw Error("Phenomic expects at least a collector plugin");
}
let contentPath;
try {
const contentPath = await getContentPath(config);
const files = oneShot({
path: contentPath,
plugins: config.plugins
});
await db.destroy();
await Promise.all(
files.map(file =>
processFile({
config,
db,
file,
transformers,
collectors
})
)
);
contentPath = await getContentPath(config);
} catch (e) {
log.warn(
`no '${
contentFolder
config.content
}' folder found. Please create and put files in this folder if you want the content to be accessible (eg: markdown or JSON files). `
);
throw e;
}
const files = oneShot({
path: contentPath,
plugins: config.plugins
});
await db.destroy();
await Promise.all(
files.map(file =>
processFile({
config,
db,
file,
transformers,
collectors
})
)
);
}
function createFetchFunction(port: number) {
debug("creating fetch function");
@@ -14,9 +14,8 @@ import getPath from "../utils/getPath";
const debug = require("debug")("phenomic:core:commands:start");
const contentFolder = "content";
const getContentPath = (config: PhenomicConfig) =>
getPath(path.join(config.path, contentFolder));
getPath(path.join(config.path, config.content));
function createDevServer(config: PhenomicConfig) {
debug("creating dev server");
@@ -87,7 +86,7 @@ async function start(config: PhenomicConfig) {
} catch (e) {
log.warn(
`no '${
contentFolder
config.content
}' folder found. Please create and put files in this folder if you want the content to be accessible (eg: markdown or JSON files). `
);
}
@@ -65,6 +65,7 @@ function flattenConfiguration(
debug("flattenConfiguration", config);
return {
path: config.path || "",
content: config.content || "",
outdir: config.outdir || "",
port: config.port || 8080,
bundleName: config.bundleName || "",
@@ -1,8 +1,7 @@
import path from "path";
export default {
path: process.cwd(),
outdir: path.join(process.cwd(), "dist"),
content: "content",
outdir: "dist",
port: 3333,
bundleName: "phenomic.main",
plugins: []
@@ -17,7 +17,7 @@ module.exports = (config: PhenomicConfig) => ({
publicPath: "/", // @todo make this dynamic
path: path.isAbsolute(config.outdir)
? config.outdir
: path.join(process.cwd(), config.outdir),
: path.join(config.path, config.outdir),
...(process.env.PHENOMIC_ENV !== "static"
? {
filename: "phenomic/[name].js",
@@ -40,7 +40,7 @@ export default function(
return new Promise((resolve, reject) => {
getPath(path.join(config.path, options.path)).then(
(publicPath: string) => {
fse.copy(publicPath, config.outdir, err => {
fse.copy(publicPath, path.join(config.path, config.outdir), err => {
if (err) {
reject(err);
}

0 comments on commit 24657cc

Please sign in to comment.