Skip to content

Commit 19b6c37

Browse files
Fix (schematics): fixed dependency versions (#6210)
* fix(dchematics): fixed dependency versions * fix(schematics): fixed dependency versions
1 parent 6b47941 commit 19b6c37

File tree

5 files changed

+27
-30
lines changed

5 files changed

+27
-30
lines changed

scripts/set-version.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@ import { sync as glob } from 'glob';
44
const packagesGlob = './src/**/package.json';
55
const mainPackage = './package.json';
66
const docsVersion = './apps/ngx-bootstrap-docs/src/assets/json/current-version.json';
7+
const schematicDependencyVersion = './src/schematics/src/utils/current_dependency_versions.json';
78

89
(async () => {
910
const version = await readJson(mainPackage).then(json => json.version);
10-
const packages = [docsVersion, ...glob(packagesGlob)]
11+
const packages = [docsVersion, schematicDependencyVersion, ...glob(packagesGlob)]
1112
.map(async packagePath => {
1213
const packageJson = await readJson(packagePath);
13-
packageJson.version = version;
14+
if (packageJson.version) {
15+
packageJson.version = version;
16+
}
17+
18+
if (packageJson.NGX_BOOTSTRAP_VERSION) {
19+
packageJson.NGX_BOOTSTRAP_VERSION = version;
20+
}
21+
1422
await writeJson(packagePath, packageJson, { spaces: 2 });
1523
});
1624

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"NGX_BOOTSTRAP_VERSION": "7.0.0-rc.4",
3+
"BOOTSTRAP_VERSION": "^4.5.0"
4+
}

src/schematics/src/utils/getVersions.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
import { normalize } from '@angular-devkit/core';
22
import { Tree } from '@angular-devkit/schematics';
3+
import * as currentVersions from './current_dependency_versions.json';
4+
5+
const NGX_BOOTSTRAP_VERSION = currentVersions.NGX_BOOTSTRAP_VERSION;
6+
const BOOTSTRAP_VERSION = currentVersions.BOOTSTRAP_VERSION;
37

4-
let NGX_BOOTSTRAP_VERSION = '7.0.0-rc.1';
5-
const BOOTSTRAP_VERSION = '^4.5.0';
6-
const dependencies = [
7-
{ name: 'bootstrap', version: BOOTSTRAP_VERSION},
8-
{ name: 'ngx-bootstrap', version: NGX_BOOTSTRAP_VERSION}
9-
];
108
// Regular expression that matches all possible Angular CLI default style files
119
const defaultStyleFileRegex = /styles\.(c|le|sc|sa)ss/;
1210
// Regular expression that matches all files that have a proper stylesheet extension
1311
const validStyleFileRegex = /\.(c|le|sc|sa)ss/;
1412

1513
export function getDependencies(host: Tree): { name: string, version: string }[] {
16-
if (host.exists('node_modules/ngx-bootstrap/schematics/package.json')) {
17-
const sourceText = host.read('node_modules/ngx-bootstrap/schematics/package.json')?.toString('utf-8');
18-
const json = JSON.parse(sourceText);
19-
if (json.version) {
20-
NGX_BOOTSTRAP_VERSION = json.version;
21-
return updateVersionDependencies(json.version, 'ngx-bootstrap');
22-
}
23-
}
24-
return dependencies;
25-
}
26-
27-
function updateVersionDependencies(version: string, name: string): { name: string, version: string }[] {
28-
dependencies.find(dep => {
29-
if (dep.name === name) {
30-
dep.version = version;
31-
}
32-
});
33-
return dependencies;
14+
return [
15+
{ name: 'bootstrap', version: BOOTSTRAP_VERSION},
16+
{ name: 'ngx-bootstrap', version: NGX_BOOTSTRAP_VERSION}
17+
];
3418
}
3519

3620
export function getProjectStyleFile(existingStyles: string[], extension?: string): string | null {

src/schematics/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
"skipLibCheck": true,
1717
"strict": false,
1818
"target": "es2015",
19-
"types": [
20-
"node"
21-
],
19+
"types": ["node", "jest"],
20+
"resolveJsonModule": true,
2221
"lib": [
2322
"es2018",
2423
"dom"

src/schematics/tsconfig.lib.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"module": "commonjs",
55
"outDir": "../../dist/out-tsc",
66
"declaration": true,
7-
"types": ["node", "jest"]
7+
"target": "es2015",
8+
"types": ["node", "jest"],
9+
"resolveJsonModule": true
810
},
911
"exclude": ["**/*.spec.ts"],
1012
"include": ["**/*.ts"]

0 commit comments

Comments
 (0)