Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update setup-dev message #1858

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"mkdirp": "^1.0.4",
"nix-clap": "^1.3.12",
"nyc": "^15.1.0",
"optional-require": "^1.0.2",
"optional-require": "^1.1.0",
"pkg-up": "^3.1.0",
"prompts": "^2.3.2",
"ps-get": "^1.1.0",
Expand Down
21 changes: 11 additions & 10 deletions packages/xarc-app-dev/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Fs from "fs";
import _ from "lodash";
import Url from "url";
import { XarcInternalOptions, XarcOptions } from "../config/opt2/xarc-options";
import { optionalRequire } from "optional-require";

export const getOptArchetypeRequire = require("@xarc/webpack/lib/util/get-opt-require"); // eslint-disable-line

Expand All @@ -29,7 +30,7 @@ export const formUrl = ({
host = "",
port = "",
path = "",
search = ""
search = "",
}): string => {
const proto = protocol.toString().toLowerCase();
const sp = port.toString();
Expand Down Expand Up @@ -155,18 +156,18 @@ export function loadXarcOptions(
const data = Fs.readFileSync(filename, "utf-8");
return (cachedXarcOptions = JSON.parse(data, jsonParser));
} catch (err) {
// eslint-disable-next-line
const runner = optionalRequire("@xarc/run") ? "xrun" : "clap";
if (showError) {
// eslint-disable-next-line
console.error(ck`
<red>ERROR</>: Electrode xarc fail to load <cyan>.etmp/xarc-options.json</> in
dev mode. This means you are trying to use something not through
xarc's development tasks.
<red>ERROR</>: Electrode xarc fail to load <cyan>.etmp/xarc-options.json</> in dev mode.

full path: ${filename}

Please run "clap setup-dev" once to initialize the file
<cyan>.etmp/xarc-options.json</> before doing your thing that loads
xarc's development code.
CAUSE: This means you are loading xarc's development code directly instead of through its task runner.

<green>SOLUTION: Please run "${runner} setup-dev" once to initialize the file <cyan>.etmp/xarc-options.json</>
before loading xarc's development code.</>
`);

console.error(err.stack); // eslint-disable-line
Expand All @@ -175,7 +176,7 @@ xarc's development code.
return (cachedXarcOptions = {
webpack: {},
babel: {},
options: {}
options: {},
} as XarcInternalOptions);
}
}
Expand Down Expand Up @@ -257,5 +258,5 @@ export function getDevAdminPortFromEnv(fallback?: number): number {
process.env.ELECTRODE_ADMIN_PORT
);

return [fromEnv, fallback, 0].find(x => isValidPort(x));
return [fromEnv, fallback, 0].find((x) => isValidPort(x));
}