Skip to content
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"minimatch": "5.1.0",
"ng-packagr": "14.0.0",
"node-fetch": "^2.2.0",
"npm": "^8.11.0",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be possible to use the in-repo version of yarn instead? This would avoid adding another dependency. yarn is also the package manager used for other development related tasks and configured for use by Bazel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think we can do that.

This is just what is used to install the packages being tested so I don't think npm/yarn or the version really matters. Those packages being tested are the cli + yarn + npm and those are the versions which matter (yes, we are discussing the npm/yarn that installs cli+npm+yarn 😨).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@clydin that seems to cause issues with some of the tests which use npm, and now npm and yarn are sharing the same directory which contains the globals? So they have the same globals directory but different global DBs I think?

  Error: Running "npm install --global @angular/cli --registry=http://localhost:34837" returned error. 1...
  STDOUT:
  STDERR:
  npm ERR! code EEXIST
  npm ERR! path /mnt/ramdisk/e2e-main/npm-global/bin/ng
  npm ERR! EEXIST: file already exists
  npm ERR! File exists: /mnt/ramdisk/e2e-main/npm-global/bin/ng
  npm ERR! Remove the existing file and try again, or run npm
  npm ERR! with --force to overwrite files recklessly.

Fixing that will probably require more changes that I'd rather not do right now. Are we ok sticking with the my original commit (46a029c)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok this actually had an easy and obvious fix... the global npm and yarn directories/databases just need to be separate. See diff

@jbedard jbedard Jun 14, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using yarn also requires using yarn for all (un)installations of the packages being tested (cli, yarn, npm): diff1, diff2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now yarn seems to be having other issues. I've seen an issue publishing saying there's a version conflict (the tested cli package depends on something that doesn't exist?), that might be related to this other one:

  npm ERR! code E404
  npm ERR! 404 Not Found - GET http://localhost:62353/pend - no such package available
  npm ERR! 404 
  npm ERR! 404  'pend@~1.2.0' is not in this registry.
  npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
  npm ERR! 404 
  npm ERR! 404 Note that you can also install from a
  npm ERR! 404 tarball, folder, http url, or git url.

?

Are we ok going back to my original change keeping things as-is using npm? It just means installing the extra npm package...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's the commit trying to switch to yarn: 975f92a

I'm going to switch this PR back to npm and we can maybe try yarn again in the future.

"npm-package-arg": "9.0.2",
"open": "8.4.0",
"ora": "5.4.1",
Expand Down
5 changes: 2 additions & 3 deletions tests/legacy-cli/e2e/setup/010-local-publish.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { getGlobalVariable } from '../utils/env';
import { execWithEnv, extractNpmEnv } from '../utils/process';
import { globalNpm, extractNpmEnv } from '../utils/process';
import { isPrereleaseCli } from '../utils/project';

export default async function () {
const testRegistry: string = getGlobalVariable('package-registry');
await execWithEnv(
'npm',
await globalNpm(
[
'run',
'admin',
Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/setup/100-global-cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getGlobalVariable } from '../utils/env';
import { silentNpm } from '../utils/process';
import { globalNpm } from '../utils/process';

const NPM_VERSION = '7.24.0';
const YARN_VERSION = '1.22.18';
Expand All @@ -13,12 +13,12 @@ export default async function () {
const testRegistry: string = getGlobalVariable('package-registry');

// Install global Angular CLI being tested, npm+yarn used by e2e tests.
await silentNpm(
await globalNpm([
'install',
'--global',
`--registry=${testRegistry}`,
'@angular/cli',
`npm@${NPM_VERSION}`,
`yarn@${YARN_VERSION}`,
);
]);
}
1 change: 1 addition & 0 deletions tests/legacy-cli/e2e/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ts_library(
"@npm//@types/yargs-parser",
"@npm//ansi-colors",
"@npm//glob",
"@npm//npm",
"@npm//protractor",
"@npm//puppeteer",
"@npm//rxjs",
Expand Down
10 changes: 10 additions & 0 deletions tests/legacy-cli/e2e/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ export function silentYarn(...args: string[]) {
return _exec({ silent: true }, 'yarn', args);
}

export function globalNpm(args: string[], env?: NodeJS.ProcessEnv) {
if (!process.env.LEGACY_CLI_RUNNER) {
throw new Error(
'The global npm cli should only be executed from the primary e2e runner process',
);
}

return _exec({ silent: true, env }, 'node', [require.resolve('npm'), ...args]);
}

export function npm(...args: string[]) {
return _exec({}, 'npm', args);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/legacy-cli/e2e_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ const argv = yargsParser(process.argv.slice(2), {
*/
process.exitCode = 255;

/**
* Mark this process as the main e2e_runner
*/
process.env.LEGACY_CLI_RUNNER = '1';

const logger = createConsoleLogger(argv.verbose, process.stdout, process.stderr, {
info: (s) => s,
debug: (s) => s,
Expand Down
Loading