-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): check @angular/cli version
* install tailwind deps based on cli version * change prod flag for cli above 12
- Loading branch information
1 parent
823b999
commit d904226
Showing
6 changed files
with
51 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
import { getCliVersion } from './ng-cli-version'; | ||
|
||
export function hasTailwindSupport(tree: Tree): boolean { | ||
return Number(getCliVersion(tree, false)) >= 11.2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { SchematicsException, Tree } from '@angular-devkit/schematics'; | ||
|
||
export function getCliVersion(tree: Tree, withPatch = false): string { | ||
try { | ||
const cliPackageJsonBuffer = tree.read( | ||
'./node_modules/@angular/cli/package.json', | ||
); | ||
|
||
if (cliPackageJsonBuffer == null) { | ||
return ''; | ||
} | ||
|
||
const packageJson = JSON.parse(cliPackageJsonBuffer.toString()); | ||
const currentCliVersion = packageJson['version'] as string; | ||
if (withPatch) { | ||
return currentCliVersion; | ||
} else { | ||
return currentCliVersion.substring(0, currentCliVersion.lastIndexOf('.')); | ||
} | ||
} catch (e) { | ||
throw new SchematicsException( | ||
'Could not identify @angular/cli version. Make sure you have @angular/cli installed.', | ||
); | ||
} | ||
} | ||
|
||
export function getCliVersionAsNumber(tree: Tree): number { | ||
return Number(getCliVersion(tree, false)); | ||
} |