Skip to content

Commit

Permalink
feat(misc): do not add typescript or @nrwl/cli during add nx to monor…
Browse files Browse the repository at this point in the history
…epo (#9736)
  • Loading branch information
FrozenPandaz committed Apr 8, 2022
1 parent 32b49b6 commit bbb0841
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions packages/add-nx-to-monorepo/src/add-nx-to-monorepo.ts
Expand Up @@ -45,7 +45,6 @@ export async function addNxToMonorepo() {
}

createNxJsonFile(repoRoot);
createTsConfigIfMissing(repoRoot);

addDepsToPackageJson(repoRoot, useCloud);

Expand Down Expand Up @@ -264,42 +263,12 @@ function deduceDefaultBase() {
}
}

function createTsConfigIfMissing(repoRoot: string) {
if (!hasRootTsConfig(repoRoot)) {
fs.writeFileSync(
'tsconfig.base.json',
JSON.stringify({ compilerOptions: {} }, null, 2)
);
}
}

function hasRootTsConfig(repoRoot: string) {
try {
readJsonFile(repoRoot, `tsconfig.base.json`);
return true;
} catch (e) {
try {
readJsonFile(repoRoot, `tsconfig.json`);
return true;
} catch (e) {
return false;
}
}
}

// add dependencies
function addDepsToPackageJson(repoRoot: string, useCloud: boolean) {
const json = readJsonFile(repoRoot, `package.json`);
if (!json.devDependencies) json.devDependencies = {};
json.devDependencies['@nrwl/workspace'] = 'NX_VERSION';
json.devDependencies['@nrwl/cli'] = 'NX_VERSION';
json.devDependencies['nx'] = 'NX_VERSION';
if (
!(json.dependencies && json.dependencies['typescript']) &&
!json.devDependencies['typescript']
) {
json.devDependencies['typescript'] = '4.2.4';
}
if (useCloud) {
json.devDependencies['@nrwl/nx-cloud'] = 'latest';
}
Expand Down Expand Up @@ -366,11 +335,3 @@ function printFinalMessage(repoRoot) {
],
});
}

function removeWindowsDriveLetter(osSpecificPath: string): string {
return osSpecificPath.replace(/^[A-Z]:/, '');
}

function normalizePath(osSpecificPath: string): string {
return removeWindowsDriveLetter(osSpecificPath).split(path.sep).join('/');
}

0 comments on commit bbb0841

Please sign in to comment.