2018-05-08 21:21:19 +00:00
|
|
|
// @flow
|
2018-02-18 16:13:29 +00:00
|
|
|
const path = require("path");
|
|
|
|
const fs = require("fs");
|
2018-02-17 21:28:47 +00:00
|
|
|
|
|
|
|
// Make sure any symlinks in the project folder are resolved:
|
|
|
|
// https://github.com/facebookincubator/create-react-app/issues/637
|
|
|
|
const appDirectory = fs.realpathSync(process.cwd());
|
2018-02-18 16:13:29 +00:00
|
|
|
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
|
2018-02-17 21:28:47 +00:00
|
|
|
|
|
|
|
const envPublicUrl = process.env.PUBLIC_URL;
|
|
|
|
|
2018-05-08 21:21:19 +00:00
|
|
|
function ensureSlash(path /*: string */, needsSlash /*: bool */) {
|
2018-02-18 16:13:29 +00:00
|
|
|
const hasSlash = path.endsWith("/");
|
2018-02-17 21:28:47 +00:00
|
|
|
if (hasSlash && !needsSlash) {
|
2018-05-08 21:21:19 +00:00
|
|
|
return path.substr(0, path.length - 1);
|
2018-02-17 21:28:47 +00:00
|
|
|
} else if (!hasSlash && needsSlash) {
|
|
|
|
return `${path}/`;
|
|
|
|
} else {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 21:21:19 +00:00
|
|
|
const getPublicUrl = () => envPublicUrl || "/";
|
2018-02-17 21:28:47 +00:00
|
|
|
|
2018-05-08 21:21:19 +00:00
|
|
|
// We use `PUBLIC_URL` environment variable field to infer "public path" at
|
|
|
|
// which the app is served. Defaults to "/"
|
2018-02-17 21:28:47 +00:00
|
|
|
// Webpack needs to know it to put the right <script> hrefs into HTML even in
|
|
|
|
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
|
|
|
// We can't use a relative path in HTML because we don't want to load something
|
|
|
|
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
2018-05-08 21:21:19 +00:00
|
|
|
function getServedPath() {
|
|
|
|
return ensureSlash(getPublicUrl(), true);
|
2018-02-17 21:28:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// config after eject: we're in ./config/
|
|
|
|
module.exports = {
|
2018-02-18 16:13:29 +00:00
|
|
|
dotenv: resolveApp(".env"),
|
|
|
|
appBuild: resolveApp("build"),
|
2018-06-02 00:17:44 +00:00
|
|
|
appPublic: resolveApp("src/v1/app/public"),
|
|
|
|
appHtml: resolveApp("src/v1/app/public/index.html"),
|
|
|
|
appIndexJs: resolveApp("src/v1/app/index.js"),
|
2018-02-18 16:13:29 +00:00
|
|
|
appPackageJson: resolveApp("package.json"),
|
|
|
|
appSrc: resolveApp("src"),
|
|
|
|
yarnLockFile: resolveApp("yarn.lock"),
|
2018-06-02 00:17:44 +00:00
|
|
|
testsSetup: resolveApp("src/v1/setupTests.js"),
|
2018-02-18 16:13:29 +00:00
|
|
|
appNodeModules: resolveApp("node_modules"),
|
2018-05-08 21:21:19 +00:00
|
|
|
publicUrl: getPublicUrl(),
|
|
|
|
servedPath: getServedPath(),
|
2018-03-19 05:43:23 +00:00
|
|
|
|
|
|
|
backendBuild: resolveApp("bin"),
|
|
|
|
// This object should have one key-value pair per entry point. For
|
|
|
|
// each key, the value should be the path to the entry point for the
|
|
|
|
// source file, and the key will be the filename of the bundled entry
|
|
|
|
// point within the build directory.
|
|
|
|
backendEntryPoints: {
|
2018-06-29 19:12:37 +00:00
|
|
|
sourcecred: resolveApp("src/v1/cli/sourcecred.js"),
|
2018-06-02 00:17:44 +00:00
|
|
|
"commands/combine": resolveApp("src/v1/cli/commands/combine.js"),
|
|
|
|
"commands/graph": resolveApp("src/v1/cli/commands/graph.js"),
|
|
|
|
"commands/plugin-graph": resolveApp("src/v1/cli/commands/pluginGraph.js"),
|
|
|
|
"commands/start": resolveApp("src/v1/cli/commands/start.js"),
|
|
|
|
apiApp: resolveApp("src/v1/app/apiApp.js"),
|
2018-06-29 19:12:37 +00:00
|
|
|
//
|
2018-06-29 18:47:24 +00:00
|
|
|
sourcecredV3: resolveApp("src/v3/cli/sourcecred.js"),
|
2018-06-29 19:12:37 +00:00
|
|
|
"commands/load-plugin-v3": resolveApp("src/v3/cli/commands/loadPlugin.js"),
|
|
|
|
//
|
2018-03-21 01:32:05 +00:00
|
|
|
fetchAndPrintGithubRepo: resolveApp(
|
2018-06-02 00:17:44 +00:00
|
|
|
"src/v1/plugins/github/bin/fetchAndPrintGithubRepo.js"
|
|
|
|
),
|
2018-06-12 01:57:37 +00:00
|
|
|
fetchAndPrintGithubRepoV3: resolveApp(
|
|
|
|
"src/v3/plugins/github/bin/fetchAndPrintGithubRepo.js"
|
|
|
|
),
|
2018-06-02 00:17:44 +00:00
|
|
|
createExampleRepo: resolveApp(
|
|
|
|
"src/v1/plugins/git/bin/createExampleRepo.js"
|
2018-03-19 05:43:23 +00:00
|
|
|
),
|
2018-06-20 22:28:37 +00:00
|
|
|
createExampleRepoV3: resolveApp(
|
|
|
|
"src/v3/plugins/git/bin/createExampleRepo.js"
|
|
|
|
),
|
2018-04-28 03:51:54 +00:00
|
|
|
loadAndPrintGitRepository: resolveApp(
|
2018-06-02 00:17:44 +00:00
|
|
|
"src/v1/plugins/git/bin/loadAndPrintRepository.js"
|
2018-04-28 03:51:54 +00:00
|
|
|
),
|
2018-06-20 22:28:37 +00:00
|
|
|
loadAndPrintGitRepositoryV3: resolveApp(
|
|
|
|
"src/v3/plugins/git/bin/loadAndPrintRepository.js"
|
|
|
|
),
|
2018-03-19 05:43:23 +00:00
|
|
|
},
|
2018-02-17 21:28:47 +00:00
|
|
|
};
|