build(aio): consider devDependencies
when overwriting dependencies of local Angular packages (#19687)
Previously, only `dependencies` were taken into account. PR Close #19687
This commit is contained in:
parent
591dcc26af
commit
18f1b016e5
@ -76,15 +76,17 @@ class NgPackagesInstaller {
|
|||||||
// Prevent accidental publishing of the package, if something goes wrong.
|
// Prevent accidental publishing of the package, if something goes wrong.
|
||||||
tmpConfig.private = true;
|
tmpConfig.private = true;
|
||||||
|
|
||||||
// Overwrite project dependencies to Angular packages with local files.
|
// Overwrite project dependencies/devDependencies to Angular packages with local files.
|
||||||
const deps = tmpConfig.dependencies || {};
|
['dependencies', 'devDependencies'].forEach(prop => {
|
||||||
Object.keys(deps).forEach(key2 => {
|
const deps = tmpConfig[prop] || {};
|
||||||
const pkg2 = packages[key2];
|
Object.keys(deps).forEach(key2 => {
|
||||||
if (pkg2) {
|
const pkg2 = packages[key2];
|
||||||
// point the core Angular packages at the distributable folder
|
if (pkg2) {
|
||||||
deps[key2] = `file:${pkg2.parentDir}/${key2.replace('@angular/', '')}`;
|
// point the core Angular packages at the distributable folder
|
||||||
this._log(`Overriding dependency of local ${key} with local package: ${key2}: ${deps[key2]}`);
|
deps[key2] = `file:${pkg2.parentDir}/${key2.replace('@angular/', '')}`;
|
||||||
}
|
this._log(`Overriding dependency of local ${key} with local package: ${key2}: ${deps[key2]}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(pkg.packageJsonPath, JSON.stringify(tmpConfig));
|
fs.writeFileSync(pkg.packageJsonPath, JSON.stringify(tmpConfig));
|
||||||
|
@ -81,7 +81,10 @@ describe('NgPackagesInstaller', () => {
|
|||||||
'@angular/tsc-wrapped': {
|
'@angular/tsc-wrapped': {
|
||||||
parentDir: toolsDir,
|
parentDir: toolsDir,
|
||||||
packageJsonPath: `${toolsDir}/tsc-wrapped/package.json`,
|
packageJsonPath: `${toolsDir}/tsc-wrapped/package.json`,
|
||||||
config: { peerDependencies: { tsickle: '^1.4.0' } }
|
config: {
|
||||||
|
devDependencies: { '@angular/common': '4.4.4-1ab23cd4' },
|
||||||
|
peerDependencies: { tsickle: '^1.4.0' }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
spyOn(installer, '_getDistPackages').and.callFake(() => copyJsonObj(dummyNgPackages));
|
spyOn(installer, '_getDistPackages').and.callFake(() => copyJsonObj(dummyNgPackages));
|
||||||
@ -160,7 +163,10 @@ describe('NgPackagesInstaller', () => {
|
|||||||
private: true,
|
private: true,
|
||||||
dependencies: { '@angular/tsc-wrapped': `file:${toolsDir}/tsc-wrapped` }
|
dependencies: { '@angular/tsc-wrapped': `file:${toolsDir}/tsc-wrapped` }
|
||||||
}))],
|
}))],
|
||||||
[pkgJsonFor('tsc-wrapped'), JSON.stringify(overwriteConfigFor('tsc-wrapped', {private: true}))],
|
[pkgJsonFor('tsc-wrapped'), JSON.stringify(overwriteConfigFor('tsc-wrapped', {
|
||||||
|
private: true,
|
||||||
|
devDependencies: { '@angular/common': `file:${packagesDir}/common` }
|
||||||
|
}))],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(lastFiveArgs).toEqual(['core', 'common', 'compiler', 'compiler-cli', 'tsc-wrapped']
|
expect(lastFiveArgs).toEqual(['core', 'common', 'compiler', 'compiler-cli', 'tsc-wrapped']
|
||||||
@ -201,7 +207,7 @@ describe('NgPackagesInstaller', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('_getDistPackages', () => {
|
describe('_getDistPackages()', () => {
|
||||||
it('should include top level Angular packages', () => {
|
it('should include top level Angular packages', () => {
|
||||||
const ngPackages = installer._getDistPackages();
|
const ngPackages = installer._getDistPackages();
|
||||||
const expectedValue = jasmine.objectContaining({
|
const expectedValue = jasmine.objectContaining({
|
||||||
@ -259,7 +265,7 @@ describe('NgPackagesInstaller', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('_printWarning', () => {
|
describe('_printWarning()', () => {
|
||||||
it('should mention the message passed in the warning', () => {
|
it('should mention the message passed in the warning', () => {
|
||||||
installer._printWarning();
|
installer._printWarning();
|
||||||
expect(console.warn.calls.argsFor(0)[0]).toContain('is running against the local Angular build');
|
expect(console.warn.calls.argsFor(0)[0]).toContain('is running against the local Angular build');
|
||||||
@ -282,7 +288,7 @@ describe('NgPackagesInstaller', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('_installDeps', () => {
|
describe('_installDeps()', () => {
|
||||||
it('should run yarn install with the given options', () => {
|
it('should run yarn install with the given options', () => {
|
||||||
installer._installDeps('option-1', 'option-2');
|
installer._installDeps('option-1', 'option-2');
|
||||||
expect(shelljs.exec).toHaveBeenCalledWith('yarn install option-1 option-2', { cwd: absoluteRootDir });
|
expect(shelljs.exec).toHaveBeenCalledWith('yarn install option-1 option-2', { cwd: absoluteRootDir });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user