Skip to content

test: add local npm registry to failing tests #15173

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

Merged
merged 1 commit into from
Jul 26, 2019
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
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/misc/ask-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async function() {
// Install the CLI with TTY force enabled
const execution = execWithEnv(
'npm',
['install', packages['@angular/cli'].tar],
['install', packages['@angular/cli'].tar, '--registry=http://localhost:4873'],
{ ...process.env, 'NG_FORCE_TTY': '1' },
);

Expand Down
8 changes: 7 additions & 1 deletion tests/legacy-cli/e2e/tests/schematics_cli/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export default async function () {
}

const startCwd = process.cwd();
await silentNpm('install', '-g', packages['@angular-devkit/schematics-cli'].tar, '--unsafe-perm');
await silentNpm(
'install',
'-g',
packages['@angular-devkit/schematics-cli'].tar,
'--unsafe-perm',
Copy link
Member

Choose a reason for hiding this comment

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

Same here for the package name.
Also, is unsafe-perm actually needed?

'--registry=http://localhost:4873',
);
await exec(process.platform.startsWith('win') ? 'where' : 'which', 'schematics');

// create blank schematic
Expand Down
2 changes: 0 additions & 2 deletions tests/legacy-cli/e2e/tests/update/update-1.0.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as fs from 'fs';
import { createProjectFromAsset } from '../../utils/assets';
import { ng, silentNpm } from '../../utils/process';
import { isPrereleaseCli, useBuiltPackages, useCIChrome, useCIDefaults } from '../../utils/project';
Expand All @@ -8,7 +7,6 @@ export default async function() {
const extraUpdateArgs = (await isPrereleaseCli()) ? ['--next', '--force'] : [];

await createProjectFromAsset('1.0-project');
fs.writeFileSync('.npmrc', 'registry = http://localhost:4873', 'utf8');

await useCIChrome('.');
await expectToFail(() => ng('build'));
Expand Down
2 changes: 0 additions & 2 deletions tests/legacy-cli/e2e/tests/update/update-1.7-longhand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as fs from 'fs';
import { createProjectFromAsset } from '../../utils/assets';
import { ng, silentNpm } from '../../utils/process';
import { isPrereleaseCli, useBuiltPackages } from '../../utils/project';
Expand All @@ -8,7 +7,6 @@ export default async function() {
const extraUpdateArgs = (await isPrereleaseCli()) ? ['--next', '--force'] : [];

await createProjectFromAsset('1.7-project');
fs.writeFileSync('.npmrc', 'registry = http://localhost:4873', 'utf8');

await expectToFail(() => ng('build'));
await ng('update', '@angular/cli', '--migrate-only', '--from=1.7.1');
Expand Down
16 changes: 9 additions & 7 deletions tests/legacy-cli/e2e/utils/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {join} from 'path';
import * as glob from 'glob';
import {getGlobalVariable} from './env';
import {relative} from 'path';
import {copyFile} from './fs';
import {copyFile, writeFile} from './fs';
import {useBuiltPackages} from './project';
import { git, silentNpm } from './process';

Expand Down Expand Up @@ -39,10 +39,12 @@ export function copyAssets(assetName: string) {
}


export function createProjectFromAsset(assetName: string, useNpmPackages = false) {
return Promise.resolve()
.then(() => copyAssets(assetName))
.then(dir => process.chdir(dir))
.then(() => useNpmPackages ? null : useBuiltPackages())
.then(() => silentNpm('install'));
export async function createProjectFromAsset(assetName: string, useNpmPackages = false) {
const dir = await copyAssets(assetName);
process.chdir(dir);
if (!useNpmPackages) {
await useBuiltPackages();
Copy link
Member

Choose a reason for hiding this comment

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

Technically, no test should be using the built packages directly anymore but this fixes the problem for now.

We should revisit these tests though. Potentially using npx to generate a new project of the appropriate version directly.

await writeFile('.npmrc', 'registry = http://localhost:4873', 'utf8');
}
await silentNpm('install');
}