Skip to content

fix(@schematics/update): fix update on local packages #13066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/schematics/update/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,11 @@ export default function(options: UpdateSchema): Rule {
const packages = _buildPackageList(options, allDependencies, logger);
const usingYarn = options.packageManager === 'yarn';

return observableFrom([...allDependencies.keys()]).pipe(
return observableFrom(allDependencies).pipe(
// Grab all package.json from the npm repository. This requires a lot of HTTP calls so we
// try to parallelize as many as possible.
mergeMap(depName => getNpmPackageJson(depName, options.registry, logger, usingYarn)),
mergeMap(([depName, version]) =>
getNpmPackageJson(`${depName}@${version}`, options.registry, logger, usingYarn)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not certain if to add an addition param or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That function is intended to pull all version information from the registry not just a particular version. A more complex change is needed to the full update algorithm to account for package data that does not contain full version history.


// Build a map of all dependencies and their packageJson.
reduce<NpmRepositoryPackageJson, Map<string, NpmRepositoryPackageJson>>(
Expand Down
4 changes: 3 additions & 1 deletion packages/schematics/update/update/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ function readOptions(yarn = false): { [key: string]: string } {
}

/**
* Get the NPM repository's package.json for a package. This is p
* Get the NPM repository's package.json for a package.
* @param {string} packageName The package name to fetch.
* This should include `@<version>` if you are uncertain
* if the package is in the npm repository.
* @param {string} registryUrl The NPM Registry URL to use.
* @param {LoggerApi} logger A logger instance to log debug information.
* @returns An observable that will put the pacakge.json content.
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export default async function(
const obj = packageJson[depKey] as JsonObject | null;
if (obj && obj[depName]) {
if (argv.local) {
obj[depName] = packages[depName].tar;
obj[depName] = 'file:' + packages[depName].tar;
} else if (argv.snapshot) {
const pkg = packages[depName];
if (!pkg.snapshotRepo) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export default async function(
// Set the dependencies to the new build we just used.
for (const packageName of Object.keys(packages)) {
if (packageJson['dependencies'].hasOwnProperty(packageName)) {
packageJson['dependencies'][packageName] = packages[packageName].tar;
packageJson['dependencies'][packageName] = 'file:' + packages[packageName].tar;
} else if (packageJson['devDependencies'].hasOwnProperty(packageName)) {
packageJson['devDependencies'][packageName] = packages[packageName].tar;
packageJson['devDependencies'][packageName] = 'file:' + packages[packageName].tar;
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export function useBuiltPackages() {

for (const packageName of Object.keys(packages)) {
if (json['dependencies'].hasOwnProperty(packageName)) {
json['dependencies'][packageName] = packages[packageName].tar;
json['dependencies'][packageName] = 'file:' + packages[packageName].tar;
} else if (json['devDependencies'].hasOwnProperty(packageName)) {
json['devDependencies'][packageName] = packages[packageName].tar;
json['devDependencies'][packageName] = 'file:' + packages[packageName].tar;
}
}
}));
Expand Down