forked from yarnpkg/berry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
139 lines (125 loc) Β· 4.01 KB
/
index.ts
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import {Plugin, SettingsType, miscUtils, Configuration, Ident} from '@yarnpkg/core';
import {NpmHttpFetcher} from './NpmHttpFetcher';
import {NpmRemapResolver} from './NpmRemapResolver';
import {NpmSemverFetcher} from './NpmSemverFetcher';
import {NpmSemverResolver} from './NpmSemverResolver';
import {NpmTagResolver} from './NpmTagResolver';
import * as npmConfigUtils from './npmConfigUtils';
import * as npmHttpUtils from './npmHttpUtils';
import * as npmPublishUtils from './npmPublishUtils';
export {npmConfigUtils};
export {npmHttpUtils};
export {npmPublishUtils};
export {NpmHttpFetcher};
export {NpmRemapResolver};
export {NpmSemverFetcher};
export {NpmSemverResolver};
export {NpmTagResolver};
export interface Hooks {
/**
* Called when getting the authentication header for a request to the npm registry.
* You can use this mechanism to dynamically query a CLI for the credentials for a
* specific registry.
*/
getNpmAuthenticationHeader?: (currentHeader: string | undefined, registry: string, {
configuration,
ident,
}: { configuration: Configuration, ident?: Ident }) => Promise<string | undefined>;
}
const authSettings = {
npmAlwaysAuth: {
description: `URL of the selected npm registry (note: npm enterprise isn't supported)`,
type: SettingsType.BOOLEAN as const,
default: false,
},
npmAuthIdent: {
description: `Authentication identity for the npm registry (_auth in npm and yarn v1)`,
type: SettingsType.SECRET as const,
default: null,
},
npmAuthToken: {
description: `Authentication token for the npm registry (_authToken in npm and yarn v1)`,
type: SettingsType.SECRET as const,
default: null,
},
};
const registrySettings = {
npmAuditRegistry: {
description: `Registry to query for audit reports`,
type: SettingsType.STRING as const,
default: null,
},
npmPublishRegistry: {
description: `Registry to push packages to`,
type: SettingsType.STRING as const,
default: null,
},
npmRegistryServer: {
description: `URL of the selected npm registry (note: npm enterprise isn't supported)`,
type: SettingsType.STRING as const,
default: `https://registry.yarnpkg.com`,
},
};
declare module '@yarnpkg/core' {
interface ConfigurationValueMap {
npmAlwaysAuth: boolean;
npmAuthIdent: string | null;
npmAuthToken: string | null;
npmAuditRegistry: string | null;
npmPublishRegistry: string | null;
npmRegistryServer: string;
npmScopes: Map<string, miscUtils.ToMapValue<{
npmAlwaysAuth: boolean;
npmAuthIdent: string | null;
npmAuthToken: string | null;
npmPublishRegistry: string | null;
npmRegistryServer: string;
}>>;
npmRegistries: Map<string, miscUtils.ToMapValue<{
npmAlwaysAuth: boolean;
npmAuthIdent: string | null;
npmAuthToken: string | null;
}>>;
}
}
const plugin: Plugin = {
configuration: {
...authSettings,
...registrySettings,
npmScopes: {
description: `Settings per package scope`,
type: SettingsType.MAP,
valueDefinition: {
description: ``,
type: SettingsType.SHAPE,
properties: {
...authSettings,
...registrySettings,
},
},
},
npmRegistries: {
description: `Settings per registry`,
type: SettingsType.MAP,
normalizeKeys: npmConfigUtils.normalizeRegistry,
valueDefinition: {
description: ``,
type: SettingsType.SHAPE,
properties: {
...authSettings,
},
},
},
},
fetchers: [
NpmHttpFetcher,
NpmSemverFetcher,
],
resolvers: [
NpmRemapResolver,
NpmSemverResolver,
NpmTagResolver,
],
};
// eslint-disable-next-line arca/no-default-export
export default plugin;