Skip to content

Commit

Permalink
Merge pull request #240 from hyper63/feat/hyper-config-file
Browse files Browse the repository at this point in the history
feat(core)!: support both hyper.config.js and hyper63.config.js
  • Loading branch information
TillaTheHun0 authored Jun 23, 2021
2 parents ecffc1f + 064a772 commit 12d825d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
12 changes: 3 additions & 9 deletions packages/core/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ export * as R from "https://cdn.skypack.dev/ramda@^0.27.1";
export { default as crocks } from "https://cdn.skypack.dev/crocks@^0.12.4";
export * as z from "https://cdn.skypack.dev/[email protected]";
export * as ms from "https://cdn.skypack.dev/[email protected]";
export { cuid } from "https://deno.land/x/[email protected]/index.js";

/*
export cache from '../port-cache/mod.js'
export data from '../port-data/mod.js'
export storage from '../port-storage/mod.js'
export search from '../port-search/mod.js'
export hooks from '../port-hooks/mod.js'
//export queue from '../port-queue/mod.js'
*/
export { cuid } from "https://deno.land/x/[email protected]/index.js";
export { join } from "https://deno.land/[email protected]/path/mod.ts";
export { exists } from "https://deno.land/[email protected]/fs/mod.ts";
24 changes: 24 additions & 0 deletions packages/core/deps_lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@
"https://cdn.skypack.dev/[email protected]": "505c67d3120ebdefdcf30bba02e40322eb23bbf52641315611812cc98efeb7dc",
"https://cdn.skypack.dev/ramda@^0.27.1": "fb06d7de4305dcdb997f9adc903a463afcdac75d148d638295c420a8922048fd",
"https://cdn.skypack.dev/[email protected]": "9062f35d0134abac378aef1e04fd4ce0fb44af185c8aaa29633c641f5802f725",
"https://deno.land/[email protected]/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58",
"https://deno.land/[email protected]/_util/os.ts": "e282950a0eaa96760c0cf11e7463e66babd15ec9157d4c9ed49cc0925686f6a7",
"https://deno.land/[email protected]/fs/_util.ts": "f2ce811350236ea8c28450ed822a5f42a0892316515b1cd61321dec13569c56b",
"https://deno.land/[email protected]/fs/copy.ts": "631bbafbfe6cba282158abc8aeb7e8251cc69a7ec28ce12878ea1b75fec2add4",
"https://deno.land/[email protected]/fs/empty_dir.ts": "5f08b263dd064dc7917c4bbeb13de0f5505a664b9cdfe312fa86e7518cfaeb84",
"https://deno.land/[email protected]/fs/ensure_dir.ts": "b7c103dc41a3d1dbbb522bf183c519c37065fdc234831a4a0f7d671b1ed5fea7",
"https://deno.land/[email protected]/fs/ensure_file.ts": "c06031af24368e80c330897e4b8e9109efc8602ffabc8f3e2306be07529e1d13",
"https://deno.land/[email protected]/fs/ensure_link.ts": "26e54363508b822afd87a3f6e873bbbcd6b5993dd638f8170758c16262a75065",
"https://deno.land/[email protected]/fs/ensure_symlink.ts": "c07b6d19ef58b6f5c671ffa942e7f9be50315f4f78e2f9f511626fd2e13beccc",
"https://deno.land/[email protected]/fs/eol.ts": "afaebaaac36f48c423b920c836551997715672b80a0fee9aa7667c181a94f2df",
"https://deno.land/[email protected]/fs/exists.ts": "b0d2e31654819cc2a8d37df45d6b14686c0cc1d802e9ff09e902a63e98b85a00",
"https://deno.land/[email protected]/fs/expand_glob.ts": "73e7b13f01097b04ed782b3d63863379b718417417758ba622e282b1e5300b91",
"https://deno.land/[email protected]/fs/mod.ts": "26eee4b52a8c516e37d464094b080ff6822883e7f01ff0ba0a72b8dcd54b9927",
"https://deno.land/[email protected]/fs/move.ts": "4623058e39bbbeb3ad30aeff9c974c55d2d574ad7c480295c12b04c244686a99",
"https://deno.land/[email protected]/fs/walk.ts": "b91c655c60d048035f9cae0e6177991ab3245e786e3ab7d20a5b60012edf2126",
"https://deno.land/[email protected]/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853",
"https://deno.land/[email protected]/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4",
"https://deno.land/[email protected]/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b",
"https://deno.land/[email protected]/path/common.ts": "eaf03d08b569e8a87e674e4e265e099f237472b6fd135b3cbeae5827035ea14a",
"https://deno.land/[email protected]/path/glob.ts": "314ad9ff263b895795208cdd4d5e35a44618ca3c6dd155e226fb15d065008652",
"https://deno.land/[email protected]/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12",
"https://deno.land/[email protected]/path/posix.ts": "f56c3c99feb47f30a40ce9d252ef6f00296fa7c0fcb6dd81211bdb3b8b99ca3b",
"https://deno.land/[email protected]/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c",
"https://deno.land/[email protected]/path/win32.ts": "77f7b3604e0de40f3a7c698e8a79e7f601dc187035a1c21cb1e596666ce112f8",
"https://deno.land/x/[email protected]/fingerprint.js": "34d45895441ad08a1ce2c76da4b72da24c00b68346e9bb3c8dfd10eb5774d74e",
"https://deno.land/x/[email protected]/getRandomValue.js": "52545634d1e62836ed44aeea057caa2d054ea979090049ea8facb2ececa23385",
"https://deno.land/x/[email protected]/index.js": "7313248002e361977e2801d0cbfd6b7d20926dd59c880f1698672a4fdefe999e",
Expand Down
20 changes: 16 additions & 4 deletions packages/core/mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import wrapCore from "./lib/mod.js";
import validateConfig from "./utils/config-schema.js";
import initAdapters from "./utils/plugins.js";
import eventMgr from "./utils/event-mgr.js";
import { R } from "./deps.js";
import { exists, join, R } from "./deps.js";

const { compose, prop, assoc, propOr } = R;

/**
* @returns {function} - listen function
*/
export default function main(config) {
// const config = (await import(process.cwd() + '/hyper63.config')).default
config = !config ? require(process.cwd() + "/hyper63.config") : config;
export default async function main(config) {
config = config ||
await getConfig("hyper.config.js") ||
await getConfig("hyper63.config.js");

config = validateConfig(config);

// TODO: validate config
Expand All @@ -31,3 +33,13 @@ export default function main(config) {
// return app
return app;
}

async function getConfig(name) {
const path = join(Deno.cwd(), name);
if (!(await exists(path))) {
return;
}

const config = (await import(path)).default;
return config;
}

0 comments on commit 12d825d

Please sign in to comment.