Skip to content

Commit

Permalink
Prettified Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
renhiyama authored and actions-user committed Oct 26, 2023
1 parent e5cdcb9 commit c7707cd
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
".": "./imports.js",
"./packit": "./packit-intellisense.js"
}
}
}
10 changes: 5 additions & 5 deletions src/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ fs.writeFileSync(
//setup import maps URLs
let importmap = {},
browserimportmap = {};
importmap["@reejs/server"] = GetPackage("@reejs/server");
importmap["@reejs/utils/log.js"] = GetPackage("@reejs/utils/log.js");
importmap["@reejs/react/app.jsx"] = GetPackage("@reejs/react/app.jsx");
importmap["@reejs/imports/debug.js"] = GetPackage("@reejs/imports/debug.js");
importmap["@reejs/server"] = GetPackage("@reejs/server");
importmap["@reejs/utils/log.js"] = GetPackage("@reejs/utils/log.js");
importmap["@reejs/react/app.jsx"] = GetPackage("@reejs/react/app.jsx");
importmap["@reejs/imports/debug.js"] = GetPackage("@reejs/imports/debug.js");

if (features.includes("react")) {
importmap["react"] = GetPackage("react");
importmap["react-dom"] = GetPackage("react-dom");
Expand Down
2 changes: 1 addition & 1 deletion src/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"bin": {
"create-reejs": "./index.js"
}
}
}
57 changes: 31 additions & 26 deletions src/imports/URLImportInstaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ if (!fs.existsSync(path.join(_reejsDir, "failsafe", "package.json")))
if (!globalThis.fetch) {
if (!fs.existsSync(path.join(_reejsDir, "failsafe", "fetch.js"))) {
let fetchFileCode = await fetchUrl(
`${process.env.ESM_SERVER || "https://esm.sh"
`${
process.env.ESM_SERVER || "https://esm.sh"
}/v128/[email protected]/node/node-fetch.bundle.mjs`
);
fs.writeFileSync(
Expand Down Expand Up @@ -162,21 +163,21 @@ let URLToFile = function (url, noFolderPath = false, reejsDir) {

let fileString = noFolderPath
? "./" +
crypto
.createHash("sha256")
.update(url + UA)
.digest("hex")
.slice(0, 6) +
fileExt
: path.join(
reejsDir == true ? path.join(processCwd, ".reejs") : _reejsDir,
"cache",
crypto
.createHash("sha256")
.update(url + UA)
.digest("hex")
.slice(0, 6) + fileExt
);
.slice(0, 6) +
fileExt
: path.join(
reejsDir == true ? path.join(processCwd, ".reejs") : _reejsDir,
"cache",
crypto
.createHash("sha256")
.update(url + UA)
.digest("hex")
.slice(0, 6) + fileExt
);
return fileString;
};

Expand All @@ -186,9 +187,9 @@ let followRedirect = async function (url, forBrowser = false) {
return (
await fetch(
(process.env.ESM_SERVER || "https://esm.sh/") +
"/" +
url.replace("npm:", "") +
"?bundle",
"/" +
url.replace("npm:", "") +
"?bundle",
{
headers: {
"User-Agent": forBrowser
Expand Down Expand Up @@ -238,7 +239,8 @@ let lexer, parser;

if (!fs.existsSync(path.join(_reejsDir, "failsafe", "spinnies.js"))) {
let spinniesCode = await fetchUrl(
`${process.env.ESM_SERVER || "https://esm.sh"}/v128/[email protected]/${globalThis?.Deno ? "denonext" : "node"
`${process.env.ESM_SERVER || "https://esm.sh"}/v128/[email protected]/${
globalThis?.Deno ? "denonext" : "node"
}/spinnies.bundle.mjs`
);
fs.writeFileSync(
Expand Down Expand Up @@ -327,7 +329,8 @@ let dl = async function (
if (res != url && !NOTIFIED_UPDATE_URL.some(u => u == url)) {
spinners.succeed(originalUrl, {
text: styleit(
`${isChild ? "├─ " : ""
`${
isChild ? "├─ " : ""
}🪄 %c Please use specific version for %c${url} %cto access %c${res} %cfaster without pinging for latest version`,
"",
"color: yellow",
Expand Down Expand Up @@ -383,7 +386,8 @@ let dl = async function (
//set timeout for fetch for 30 secs, after which throw error
let timeout = setTimeout(async () => {
throw new Error(
`Failed to download ${finalURL}\nUser Agent: ${forBrowser ? `Mozilla/5.0 (reejs/${pkgJson.version})` : UA
`Failed to download ${finalURL}\nUser Agent: ${
forBrowser ? `Mozilla/5.0 (reejs/${pkgJson.version})` : UA
}\n${await res.text()}`
);
}, 30000);
Expand Down Expand Up @@ -467,10 +471,10 @@ let dl = async function (
ext === "jsx"
? ["jsx"]
: ext === "ts"
? ["typescript"]
: ext === "tsx"
? ["typescript", "jsx"]
: [];
? ["typescript"]
: ext === "tsx"
? ["typescript", "jsx"]
: [];
code = parser.transform(code, {
transforms,
production: true,
Expand Down Expand Up @@ -557,9 +561,9 @@ let dl = async function (
if (e.startsWith("npm:")) {
return await followRedirect(
(process.env.ESM_SERVER || "https://esm.sh") +
"/" +
e.replace("npm:", "") +
"?bundle",
"/" +
e.replace("npm:", "") +
"?bundle",
forBrowser
);
} else if (e.startsWith("/")) {
Expand Down Expand Up @@ -688,7 +692,8 @@ let dl = async function (
if ((isChild && process.env.DEBUG) || !isChild)
spinners.update(originalUrl, {
text: styleit(
`${isChild ? "├─ " : ""}%c${finalURL} %cin %c${(Date.now() - start) / 1000
`${isChild ? "├─ " : ""}%c${finalURL} %cin %c${
(Date.now() - start) / 1000
}s`,
"",
"color: blue",
Expand Down
2 changes: 1 addition & 1 deletion src/imports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
"type": "git",
"url": "https://github.com/rovelstars/reejs.git"
}
}
}
2 changes: 1 addition & 1 deletion src/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"keywords": [],
"author": "",
"license": "MIT"
}
}
2 changes: 1 addition & 1 deletion src/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"keywords": [],
"author": "",
"license": "MIT"
}
}
2 changes: 1 addition & 1 deletion src/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"dependencies": {
"@reejs/imports": "*"
}
}
}

0 comments on commit c7707cd

Please sign in to comment.