Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return () => {
const repo = new RepoGit(repoPath);
// We should eventually nuke the repo and clone it again. But we do not
// store the repos in CI yet so it's not necessary. Also, be careful not
// to nuke monorepo in CI.
invariant(repo.isCorrupted() === false, `Repo located in '${repoPath}' is corrupted.`);
};
}
// @flow strict-local
import { invariant } from '@adeira/js';
import iterateConfigs from '../src/iterateConfigs';
import createClonePhase from '../src/phases/createClonePhase';
import createCheckCorruptedRepoPhase from '../src/phases/createCheckCorruptedRepoPhase';
import createCleanPhase from '../src/phases/createCleanPhase';
import createImportSyncPhase from '../src/phases/createImportSyncPhase';
// TODO: check we can actually import this package (whether we have config for it)
// yarn monorepo-babel-node src/core/monorepo-shipit/bin/importit.js git@github.com:kiwicom/fetch.git 1
const argv = process.argv.splice(2); // TODO: better CLI
invariant(argv.length === 2, 'Importit expects two arguments: git URL and PR number.');
const exportedRepoURL = argv[0]; // git@github.com:kiwicom/fetch.git
const pullRequestNumber = argv[1];
const gitRegex = /^git@github.com:(?.+)\.git$/;
invariant(
gitRegex.test(exportedRepoURL),
'We currently support imports only from GitHub.com - please open an issue to add additional services.',
);
const match = exportedRepoURL.match(gitRegex);
const packageName = match?.groups?.packageName;
invariant(packageName != null, 'Cannot figure out package name from: %s', exportedRepoURL);
iterateConfigs(config => {
if (config.exportedRepoURL === exportedRepoURL) {
function validateInputs(globPattern: GlobPattern, options?: GlobOptions): void {
// Only forward slashes must be used, but we cannot disallow backslash since
// escaping is still allowed. See: https://github.com/isaacs/node-glob#windows
invariant(
!isWindowsPath(globPattern),
`Your glob patterns looks like absolute Windows path but this is not allowed. Glob doesn't accept paths but glob patterns instead. Invalid pattern: ${globPattern}`,
);
invariant(
isValidRoot(globPattern, options),
`Your glob pattern starts from root but you didn't define any root in glob options. Invalid pattern: ${globPattern}`,
);
}
export default function moveDirectoriesReverse(
changeset: Changeset,
mapping: Map,
): Changeset {
const reversedMapping = new Map();
for (const [src, dest] of mapping.entries()) {
invariant(
!reversedMapping.has(dest),
'It is not possible to reverse mapping with duplicate destinations.',
);
reversedMapping.set(dest, src);
}
// subdirectories (most specific) should go first
return moveDirectories(changeset, new Map([...reversedMapping].sort().reverse()));
}
function validateInputs(globPattern: GlobPattern, options?: GlobOptions): void {
// Only forward slashes must be used, but we cannot disallow backslash since
// escaping is still allowed. See: https://github.com/isaacs/node-glob#windows
invariant(
!isWindowsPath(globPattern),
`Your glob patterns looks like absolute Windows path but this is not allowed. Glob doesn't accept paths but glob patterns instead. Invalid pattern: ${globPattern}`,
);
invariant(
isValidRoot(globPattern, options),
`Your glob pattern starts from root but you didn't define any root in glob options. Invalid pattern: ${globPattern}`,
);
}
}
if (minusLines <= 0 && plusLines <= 0) {
continue;
}
if (leftmost === '+') {
--plusLines;
} else if (leftmost === '-') {
--minusLines;
} else if (leftmost === ' ' || leftmost === '') {
// context goes from both
--plusLines;
--minusLines;
} else {
invariant(false, "Can't parse hunk line %s: %s", lineNumber, line);
}
contents += `${line}\n`;
}
if (contents !== '') {
yield contents;
}
}
function _runJestTimezoneVariants(config, ciNode: CINode) {
if (ciNode.total > 1) {
const index = ciNode.index - 1;
const timezones = [
'UTC',
'Asia/Tokyo', // +9
'America/Lima', // -5
];
invariant(
timezones[index] !== undefined,
`CI node with index ${ciNode.index} is not supported.`,
);
_runJest(config, timezones[index]);
} else {
_runJest(config, 'UTC');
}
}
export default function Polling() {
const [abTestEnabled, setAbTest] = useState(false);
// If we add the polling config on server, the server also keeps polling, which is unnecessary
const cacheConfig = isBrowser()
? { poll: 1000 } // 1 second
: {};
useInterval(() => {
// Please note: this 'useInterval' hook is not used for the polling but for A/B test.
setAbTest(Math.random() >= 0.5);
}, 2500);
function renderPollingResponse({ currency }: PollingQueryResponse) {
if (!currency) {
return null;
}
const { code, rate, format } = currency;
const now = new Date().toString();
export default function SSRQueryRenderer(props: Props) {
// We have to re-create the environment here with initialized store for SSR.
const environment = createRelayEnvironment(props.ssrData);
if (!isBrowser() && props.ssrData != null) {
// When we get here on the server, we have already fetched data
// Using the QueryRenderer will dispatch a new request to BE from the server, so just return
// The data from the store instead.
const data = getDataFromRequest(
{ query: props.query, variables: props.variables },
environment,
);
return (
{data != null ? props.onResponse(data) : <div>loading...</div>}
);
}
return (
parseDiffHunk = (hunk: string) => {
const [head, tail] = splitHead(hunk, '\n');
const match = head.match(/^diff --git [ab]\/(?:.*?) [ab]\/(?