-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathsecure-registry.ts
More file actions
50 lines (42 loc) · 1.95 KB
/
secure-registry.ts
File metadata and controls
50 lines (42 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { expectFileNotToExist, expectFileToExist, rimraf } from '../../../utils/fs';
import { getActivePackageManager, installWorkspacePackages } from '../../../utils/packages';
import { git, ng } from '../../../utils/process';
import { createNpmConfigForAuthentication } from '../../../utils/registry';
import { expectToFail } from '../../../utils/utils';
export default async function () {
const originalNpmConfigRegistry = process.env['NPM_CONFIG_REGISTRY'];
try {
// The environment variable has priority over the .npmrc
delete process.env['NPM_CONFIG_REGISTRY'];
const packageManager = getActivePackageManager();
const supportsUnscopedAuth = packageManager === 'yarn';
const command = ['add', '@angular/pwa', '--skip-confirmation'];
// Works with unscoped registry authentication details
if (supportsUnscopedAuth) {
// Some package managers such as Bun and NPM do not support unscoped auth.
await createNpmConfigForAuthentication(false);
await expectFileNotToExist('public/manifest.webmanifest');
await ng(...command);
await expectFileToExist('public/manifest.webmanifest');
await git('clean', '-dxf');
}
// Works with scoped registry authentication details
await expectFileNotToExist('public/manifest.webmanifest');
await createNpmConfigForAuthentication(true);
await ng(...command);
await expectFileToExist('public/manifest.webmanifest');
await git('clean', '-dxf');
// Invalid authentication token
if (supportsUnscopedAuth) {
// Some package managers such as Bun and NPM do not support unscoped auth.
await createNpmConfigForAuthentication(false, true);
await expectToFail(() => ng(...command));
}
await createNpmConfigForAuthentication(true, true);
await expectToFail(() => ng(...command));
} finally {
process.env['NPM_CONFIG_REGISTRY'] = originalNpmConfigRegistry;
await git('clean', '-dxf');
await installWorkspacePackages();
}
}