@teambit/pnpm 0.0.554 → 0.0.558

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/pnpm",
3
- "version": "0.0.554",
3
+ "version": "0.0.558",
4
4
  "homepage": "https://bit.dev/teambit/dependencies/pnpm",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.dependencies",
8
8
  "name": "pnpm",
9
- "version": "0.0.554"
9
+ "version": "0.0.558"
10
10
  },
11
11
  "dependencies": {
12
12
  "@pnpm/error": "2.0.0",
@@ -33,11 +33,11 @@
33
33
  "user-home": "2.0.0",
34
34
  "@babel/runtime": "7.12.18",
35
35
  "core-js": "^3.0.0",
36
- "@teambit/dependency-resolver": "0.0.554",
37
- "@teambit/logger": "0.0.470",
38
- "@teambit/cli": "0.0.385",
39
- "@teambit/pkg": "0.0.554",
40
- "@teambit/component": "0.0.554"
36
+ "@teambit/dependency-resolver": "0.0.558",
37
+ "@teambit/logger": "0.0.473",
38
+ "@teambit/cli": "0.0.388",
39
+ "@teambit/pkg": "0.0.558",
40
+ "@teambit/component": "0.0.558"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/lodash": "4.14.165",
@@ -48,10 +48,10 @@
48
48
  "@types/jest": "^26.0.0",
49
49
  "@types/react-dom": "^17.0.5",
50
50
  "@types/node": "12.20.4",
51
- "@teambit/dependencies.aspect-docs.pnpm": "0.0.104"
51
+ "@teambit/dependencies.aspect-docs.pnpm": "0.0.107"
52
52
  },
53
53
  "peerDependencies": {
54
- "@teambit/legacy": "1.0.171",
54
+ "@teambit/legacy": "1.0.174",
55
55
  "react-dom": "^16.8.0 || ^17.0.0",
56
56
  "react": "^16.8.0 || ^17.0.0"
57
57
  },
@@ -79,12 +79,20 @@
79
79
  "react": "-"
80
80
  },
81
81
  "peerDependencies": {
82
- "@teambit/legacy": "1.0.171",
82
+ "@teambit/legacy": "1.0.174",
83
83
  "react-dom": "^16.8.0 || ^17.0.0",
84
84
  "react": "^16.8.0 || ^17.0.0"
85
85
  }
86
86
  }
87
87
  },
88
+ "files": [
89
+ "dist",
90
+ "!dist/tsconfig.tsbuildinfo",
91
+ "README.md",
92
+ "README.mdx",
93
+ "*.js",
94
+ "*.json"
95
+ ],
88
96
  "private": false,
89
97
  "engines": {
90
98
  "node": ">=12.22.0"
package/tsconfig.json CHANGED
@@ -15,9 +15,9 @@
15
15
  "skipLibCheck": true,
16
16
  "moduleResolution": "node",
17
17
  "esModuleInterop": true,
18
- "outDir": "dist",
19
18
  "composite": true,
20
19
  "emitDeclarationOnly": true,
20
+ "outDir": "dist",
21
21
  "experimentalDecorators": true,
22
22
  "emitDecoratorMetadata": true,
23
23
  "allowSyntheticDefaultImports": true,
@@ -25,7 +25,6 @@
25
25
  "strict": true,
26
26
  "noImplicitAny": false,
27
27
  "rootDir": ".",
28
- "removeComments": true,
29
28
  "preserveConstEnums": true,
30
29
  "resolveJsonModule": true
31
30
  },
@@ -1,40 +0,0 @@
1
- import PnpmError from '@pnpm/error';
2
- import { FetchFromRegistry, GetCredentials } from '@pnpm/fetching-types';
3
- import createResolveFromGit from '@pnpm/git-resolver';
4
- import resolveFromLocal from '@pnpm/local-resolver';
5
- import createResolveFromNpm, {
6
- PackageMeta,
7
- PackageMetaCache,
8
- ResolveFromNpmOptions,
9
- ResolverFactoryOptions,
10
- } from '@pnpm/npm-resolver';
11
- import { ResolveFunction } from '@pnpm/resolver-base';
12
- import resolveFromTarball from '@pnpm/tarball-resolver';
13
-
14
- export { PackageMeta, PackageMetaCache, ResolveFunction, ResolverFactoryOptions };
15
-
16
- export function createResolver(
17
- fetchFromRegistry: FetchFromRegistry,
18
- getCredentials: GetCredentials,
19
- pnpmOpts: ResolverFactoryOptions
20
- ): ResolveFunction {
21
- const resolveFromNpm = createResolveFromNpm(fetchFromRegistry, getCredentials, pnpmOpts);
22
- const resolveFromGit = createResolveFromGit(pnpmOpts);
23
- return async (wantedDependency, opts) => {
24
- const resolution =
25
- (await resolveFromNpm(wantedDependency, opts as ResolveFromNpmOptions)) ||
26
- (wantedDependency.pref &&
27
- ((await resolveFromTarball(wantedDependency as { pref: string })) ||
28
- (await resolveFromGit(wantedDependency as { pref: string })) ||
29
- (await resolveFromLocal(wantedDependency as { pref: string }, opts))));
30
- if (!resolution) {
31
- throw new PnpmError(
32
- 'SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER',
33
- `${wantedDependency.alias ? `${wantedDependency.alias}@` : ''}${
34
- wantedDependency.pref
35
- } isn't supported by any available resolver.`
36
- );
37
- }
38
- return resolution;
39
- };
40
- }
@@ -1,27 +0,0 @@
1
- import { PackageManagerProxyConfig } from '@teambit/dependency-resolver';
2
- import { Config } from '@pnpm/config'
3
-
4
- export function getProxyConfig(config: Config): PackageManagerProxyConfig {
5
- const httpProxy = config.httpProxy;
6
- const httpsProxy = config.httpsProxy || httpProxy;
7
- const proxyConfig: PackageManagerProxyConfig = {
8
- httpProxy,
9
- httpsProxy,
10
- ca: config.ca,
11
- cert: config.cert,
12
- key: config.key,
13
- noProxy: config.rawConfig.noproxy,
14
- strictSSL: config.strictSsl,
15
- };
16
- return proxyConfig;
17
- }
18
-
19
- export type ProxyConfig = {
20
- ca?: string;
21
- cert?: string;
22
- httpProxy?: string;
23
- httpsProxy?: string;
24
- key?: string;
25
- noProxy?: boolean | string;
26
- strictSSL?: boolean;
27
- };
package/get-registries.ts DELETED
@@ -1,100 +0,0 @@
1
- import getCredentialsByURI from 'credentials-by-uri';
2
- import { RegistriesMap } from '@teambit/dependency-resolver';
3
- import { stripTrailingChar } from '@teambit/legacy/dist/utils';
4
- import { Config } from '@pnpm/config'
5
- import { isEmpty } from 'lodash';
6
- import toNerfDart from 'nerf-dart';
7
-
8
- type OriginalAuthConfig = {
9
- originalAuthType: string;
10
- originalAuthValue: string;
11
- };
12
-
13
- export function getRegistries(config: Config): RegistriesMap {
14
- const registriesMap: RegistriesMap = {};
15
-
16
- Object.keys(config.registries).forEach((regName) => {
17
- const uri = config.registries[regName];
18
- let credentials = getCredentialsByURI(config.rawConfig, uri);
19
- let originalAuthConfig = getOriginalAuthConfigByUri(config.rawConfig, uri);
20
- if (isEmpty(credentials)) {
21
- credentials = getCredentialsByURI(config.rawConfig, switchTrailingSlash(uri));
22
- originalAuthConfig = getOriginalAuthConfigByUri(config.rawConfig, switchTrailingSlash(uri));
23
- }
24
- registriesMap[regName] = {
25
- uri,
26
- alwaysAuth: !!credentials.alwaysAuth,
27
- authHeaderValue: credentials.authHeaderValue,
28
- ...originalAuthConfig,
29
- };
30
- });
31
- return registriesMap;
32
- }
33
-
34
- // based on https://github.com/pnpm/credentials-by-uri/blob/master/index.js
35
- function getOriginalAuthConfigByUri(config: Record<string, any>, uri: string): OriginalAuthConfig {
36
- const nerfed = toNerfDart(uri);
37
- const defnerf = toNerfDart(config.registry);
38
-
39
- const creds = getScopedCredentials(nerfed, `${nerfed}:`, config);
40
- if (nerfed !== defnerf) return creds;
41
- const defaultCredentials = getScopedCredentials(nerfed, '', config);
42
- return {
43
- originalAuthType: creds.originalAuthType || defaultCredentials.originalAuthType,
44
- originalAuthValue: creds.originalAuthValue || defaultCredentials.originalAuthValue,
45
- };
46
- }
47
-
48
- function getScopedCredentials(nerfed: string, scope: string, config: Record<string, any>): OriginalAuthConfig {
49
- const token = config[`${scope}_authToken`];
50
- // Check for bearer token
51
- if (token) {
52
- return {
53
- originalAuthType: `authToken`,
54
- originalAuthValue: token,
55
- };
56
- }
57
-
58
- const auth = config[`${scope}_auth`];
59
-
60
- // Check for basic auth token
61
- if (auth) {
62
- return {
63
- originalAuthType: `auth`,
64
- originalAuthValue: auth,
65
- };
66
- }
67
-
68
- // Check for username/password auth
69
- let username;
70
- let password;
71
- if (config[`${scope}username`]) {
72
- username = config[`${scope}username`];
73
- }
74
- if (config[`${scope}_password`]) {
75
- if (scope === '') {
76
- password = config[`${scope}_password`];
77
- } else {
78
- password = Buffer.from(config[`${scope}_password`], 'base64').toString('utf8');
79
- }
80
- }
81
-
82
- if (username && password) {
83
- return {
84
- originalAuthType: `user-pass`,
85
- originalAuthValue: `${username}:${password}`,
86
- };
87
- }
88
-
89
- return {
90
- originalAuthType: '',
91
- originalAuthValue: '',
92
- };
93
- }
94
-
95
- function switchTrailingSlash(uri: string): string {
96
- if (!uri.endsWith('/')) {
97
- return `${uri}/`;
98
- }
99
- return stripTrailingChar(uri, '/');
100
- }
package/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export { PnpmPackageManager } from './pnpm.package-manager';
2
- export type { PnpmMain } from './pnpm.main.runtime';
3
- export { PnpmAspect } from './pnpm.aspect';
package/log-converter.ts DELETED
@@ -1,12 +0,0 @@
1
- import { LogBase } from '@pnpm/logger';
2
- import { Logger } from '@teambit/logger';
3
-
4
- export function logConverter(logger: Logger) {
5
- return (log: LogBase) => {
6
- // TODO: think whether to use this or delegate output to the package manager.
7
- if (log.level === 'debug') logger.debug(log.toString());
8
- if (log.level === 'warn') logger.warn(log.toString());
9
- if (log.level === 'debug') logger.debug(log.toString());
10
- if (log.level === 'error') logger.error(log.toString());
11
- };
12
- }
package/lynx.ts DELETED
@@ -1,322 +0,0 @@
1
- import semver from 'semver';
2
- import parsePackageName from 'parse-package-name';
3
- import defaultReporter from '@pnpm/default-reporter';
4
- // import createClient from '@pnpm/client'
5
- // import { createFetchFromRegistry } from '@pnpm/fetch';
6
- import { streamParser } from '@pnpm/logger';
7
- // import createStore, { ResolveFunction, StoreController } from '@pnpm/package-store';
8
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
- // import { PreferredVersions, RequestPackageOptions, StoreController, WantedDependency } from '@pnpm/package-store';
10
- import { StoreController, WantedDependency } from '@pnpm/package-store';
11
- import { createNewStoreController } from '@pnpm/store-connection-manager';
12
- // TODO: this should be taken from - @pnpm/store-connection-manager
13
- // it's not taken from there since it's not exported.
14
- // here is a bug in pnpm about it https://github.com/pnpm/pnpm/issues/2748
15
- import { CreateNewStoreControllerOptions } from '@pnpm/store-connection-manager/lib/createNewStoreController';
16
- import {
17
- ResolvedPackageVersion,
18
- Registries,
19
- NPM_REGISTRY,
20
- Registry,
21
- PackageManagerProxyConfig,
22
- PackageManagerNetworkConfig,
23
- } from '@teambit/dependency-resolver';
24
- // import execa from 'execa';
25
- // import createFetcher from '@pnpm/tarball-fetcher';
26
- import { MutatedProject, mutateModules } from '@pnpm/core';
27
- // import { ReporterFunction } from '@pnpm/core/lib/types';
28
- // import { createResolver } from './create-resolver';
29
- // import {isValidPath} from '@teambit/legacy/dist/utils';
30
- // import {createResolver} from '@pnpm/default-resolver';
31
- import createResolverAndFetcher, { ClientOptions } from '@pnpm/client';
32
- import pickRegistryForPackage from '@pnpm/pick-registry-for-package';
33
- import { Logger } from '@teambit/logger';
34
- import toNerfDart from 'nerf-dart';
35
- import { readConfig } from './read-config';
36
-
37
- type RegistriesMap = {
38
- default: string;
39
- [registryName: string]: string;
40
- };
41
-
42
- // TODO: DO NOT DELETE - uncomment when this is solved https://github.com/pnpm/pnpm/issues/2910
43
- // function getReporter(logger: Logger): ReporterFunction {
44
- // return ((logObj) => {
45
- // // TODO: print correctly not the entire object
46
- // logger.console(logObj)
47
- // });
48
- // }
49
-
50
- async function createStoreController(
51
- storeDir: string,
52
- cacheDir: string,
53
- registries: Registries,
54
- proxyConfig: PackageManagerProxyConfig = {},
55
- networkConfig: PackageManagerNetworkConfig = {}
56
- ): Promise<StoreController> {
57
- // const fetchFromRegistry = createFetchFromRegistry({});
58
- // const getCredentials = () => ({ authHeaderValue: '', alwaysAuth: false });
59
- // const resolver: ResolveFunction = createResolver(fetchFromRegistry, getCredentials, {
60
- // metaCache: new Map(),
61
- // storeDir,
62
- // });
63
- // const fetcher = createFetcher(fetchFromRegistry, getCredentials, {});
64
- // const { resolve, fetchers } = createClient({
65
- // // authConfig,
66
- // metaCache: new Map(),
67
- // // retry: retryOpts,
68
- // storeDir,
69
- // // ...resolveOpts,
70
- // // ...fetchOpts,
71
- // })
72
- // const storeController = await createStore(resolve, fetchers, {
73
- // storeDir,
74
- // verifyStoreIntegrity: true,
75
- // });
76
- // const pnpmConfig = await readConfig();
77
- const authConfig = getAuthConfig(registries);
78
- const opts: CreateNewStoreControllerOptions = {
79
- cacheDir,
80
- storeDir,
81
- rawConfig: authConfig,
82
- verifyStoreIntegrity: true,
83
- httpProxy: proxyConfig?.httpProxy,
84
- httpsProxy: proxyConfig?.httpsProxy,
85
- ca: proxyConfig?.ca,
86
- cert: proxyConfig?.cert,
87
- key: proxyConfig?.key,
88
- localAddress: networkConfig?.localAddress,
89
- noProxy: proxyConfig?.noProxy,
90
- strictSsl: proxyConfig.strictSSL,
91
- maxSockets: networkConfig.maxSockets,
92
- networkConcurrency: networkConfig.networkConcurrency,
93
- };
94
- const { ctrl } = await createNewStoreController(opts);
95
- return ctrl;
96
- }
97
-
98
- async function generateResolverAndFetcher(
99
- cacheDir: string,
100
- registries: Registries,
101
- proxyConfig: PackageManagerProxyConfig = {},
102
- networkConfig: PackageManagerNetworkConfig = {}
103
- ) {
104
- const pnpmConfig = await readConfig();
105
- const authConfig = getAuthConfig(registries);
106
- const opts: ClientOptions = {
107
- authConfig: Object.assign({}, pnpmConfig.config.rawConfig, authConfig),
108
- cacheDir,
109
- httpProxy: proxyConfig?.httpProxy,
110
- httpsProxy: proxyConfig?.httpsProxy,
111
- ca: proxyConfig?.ca,
112
- cert: proxyConfig?.cert,
113
- key: proxyConfig?.key,
114
- localAddress: networkConfig?.localAddress,
115
- noProxy: proxyConfig?.noProxy,
116
- strictSsl: proxyConfig.strictSSL,
117
- timeout: networkConfig.fetchTimeout,
118
- retry: {
119
- factor: networkConfig.fetchRetryFactor,
120
- maxTimeout: networkConfig.fetchRetryMaxtimeout,
121
- minTimeout: networkConfig.fetchRetryMintimeout,
122
- retries: networkConfig.fetchRetries,
123
- },
124
- };
125
- const result = createResolverAndFetcher(opts);
126
- return result;
127
- }
128
-
129
- export async function install(
130
- rootPathToManifest,
131
- pathsToManifests,
132
- storeDir: string,
133
- cacheDir: string,
134
- registries: Registries,
135
- proxyConfig: PackageManagerProxyConfig = {},
136
- networkConfig: PackageManagerNetworkConfig = {},
137
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
138
- logger?: Logger
139
- ) {
140
- const packagesToBuild: MutatedProject[] = []; // @pnpm/core will use this to install the packages
141
- const workspacePackages = {}; // @pnpm/core will use this to link packages to each other
142
-
143
- // This will create local link by pnpm to a component exists in the ws.
144
- // it will later deleted by the link process
145
- // we keep it here to better support case like this:
146
- // compA@1.0.0 uses compB@1.0.0
147
- // I have compB@2.0.0 in my workspace
148
- // now I install compA@1.0.0
149
- // compA is hoisted to the root and install B@1.0.0 hoisted to the root as well
150
- // now we will make link to B@2.0.0 and A will break
151
- // with this we will have a link to the local B by pnpm so it will install B@1.0.0 inside A
152
- // then when overriding the link, A will still works
153
- // This is the rational behind not deleting this completely, but need further check that it really works
154
-
155
- // eslint-disable-next-line
156
- for (const rootDir in pathsToManifests) {
157
- const manifest = pathsToManifests[rootDir];
158
- packagesToBuild.push({
159
- buildIndex: 0, // workspace components should be installed before the root
160
- manifest,
161
- rootDir,
162
- mutation: 'install',
163
- });
164
- workspacePackages[manifest.name] = workspacePackages[manifest.name] || {};
165
- workspacePackages[manifest.name][manifest.version] = { dir: rootDir, manifest };
166
- }
167
- packagesToBuild.push({
168
- buildIndex: 1, // install the root package after the workspace components were installed
169
- manifest: rootPathToManifest.manifest,
170
- mutation: 'install',
171
- rootDir: rootPathToManifest.rootDir,
172
- });
173
- const registriesMap = getRegistriesMap(registries);
174
- const authConfig = getAuthConfig(registries);
175
- const storeController = await createStoreController(storeDir, cacheDir, registries, proxyConfig, networkConfig);
176
- const opts = {
177
- storeDir,
178
- dir: rootPathToManifest.rootDir,
179
- storeController,
180
- update: true,
181
- workspacePackages,
182
- registries: registriesMap,
183
- rawConfig: authConfig,
184
- // TODO: uncomment when this is solved https://github.com/pnpm/pnpm/issues/2910
185
- // reporter: logger ? getReporter(logger) : undefined,
186
- };
187
-
188
- defaultReporter({
189
- context: {
190
- argv: [],
191
- },
192
- reportingOptions: {
193
- appendOnly: false,
194
- // logLevel: 'error' as LogLevel,
195
- // streamLifecycleOutput: opts.config.stream,
196
- throttleProgress: 200,
197
- },
198
- streamParser,
199
- });
200
- await mutateModules(packagesToBuild, opts);
201
- }
202
-
203
- export async function resolveRemoteVersion(
204
- packageName: string,
205
- rootDir: string,
206
- cacheDir: string,
207
- registries: Registries,
208
- proxyConfig: PackageManagerProxyConfig = {},
209
- networkConfig: PackageManagerNetworkConfig = {}
210
- ): Promise<ResolvedPackageVersion> {
211
- const { resolve } = await generateResolverAndFetcher(cacheDir, registries, proxyConfig, networkConfig);
212
- const resolveOpts = {
213
- projectDir: rootDir,
214
- registry: '',
215
- };
216
- try {
217
- const parsedPackage = parsePackageName(packageName);
218
- const registriesMap = getRegistriesMap(registries);
219
- const registry = pickRegistryForPackage(registriesMap, parsedPackage.name);
220
- const wantedDep: WantedDependency = {
221
- alias: parsedPackage.name,
222
- pref: parsedPackage.version,
223
- };
224
- const isValidRange = parsedPackage.version ? !!semver.validRange(parsedPackage.version) : false;
225
- resolveOpts.registry = registry;
226
- const val = await resolve(wantedDep, resolveOpts);
227
- const version = isValidRange ? parsedPackage.version : val.manifest.version;
228
- // const { stdout } = await execa('npm', ['view', packageName, 'version'], {});
229
-
230
- return {
231
- packageName: val.manifest.name,
232
- version,
233
- isSemver: true,
234
- resolvedVia: val.resolvedVia,
235
- };
236
- } catch (e: any) {
237
- if (!e.message?.includes('is not a valid string')) {
238
- throw e;
239
- }
240
- // The provided package is probably a git url or path to a folder
241
- const wantedDep: WantedDependency = {
242
- alias: undefined,
243
- pref: packageName,
244
- };
245
- const val = await resolve(wantedDep, resolveOpts);
246
- return {
247
- packageName: val.manifest.name,
248
- version: val.normalizedPref,
249
- isSemver: false,
250
- resolvedVia: val.resolvedVia,
251
- };
252
- }
253
- }
254
-
255
- function getRegistriesMap(registries: Registries): RegistriesMap {
256
- const registriesMap = {
257
- default: registries.defaultRegistry.uri || NPM_REGISTRY,
258
- };
259
-
260
- Object.entries(registries.scopes).forEach(([registryName, registry]) => {
261
- registriesMap[`@${registryName}`] = registry.uri;
262
- });
263
- return registriesMap;
264
- }
265
-
266
- function getAuthConfig(registries: Registries): Record<string, any> {
267
- const res: any = {};
268
- res.registry = registries.defaultRegistry.uri;
269
- if (registries.defaultRegistry.alwaysAuth) {
270
- res['always-auth'] = true;
271
- }
272
- const defaultAuthTokens = getAuthTokenForRegistry(registries.defaultRegistry, true);
273
- defaultAuthTokens.forEach(({ keyName, val }) => {
274
- res[keyName] = val;
275
- });
276
-
277
- Object.entries(registries.scopes).forEach(([, registry]) => {
278
- const authTokens = getAuthTokenForRegistry(registry);
279
- authTokens.forEach(({ keyName, val }) => {
280
- res[keyName] = val;
281
- });
282
- if (registry.alwaysAuth) {
283
- const nerfed = toNerfDart(registry.uri);
284
- const alwaysAuthKeyName = `${nerfed}:always-auth`;
285
- res[alwaysAuthKeyName] = true;
286
- }
287
- });
288
- return res;
289
- }
290
-
291
- function getAuthTokenForRegistry(registry: Registry, isDefault = false): { keyName: string; val: string }[] {
292
- const nerfed = toNerfDart(registry.uri);
293
- if (registry.originalAuthType === 'authToken') {
294
- return [
295
- {
296
- keyName: `${nerfed}:_authToken`,
297
- val: registry.originalAuthValue || '',
298
- },
299
- ];
300
- }
301
- if (registry.originalAuthType === 'auth') {
302
- return [
303
- {
304
- keyName: isDefault ? '_auth' : `${nerfed}:_auth`,
305
- val: registry.originalAuthValue || '',
306
- },
307
- ];
308
- }
309
- if (registry.originalAuthType === 'user-pass') {
310
- return [
311
- {
312
- keyName: `${nerfed}:username`,
313
- val: registry.originalAuthValue?.split(':')[0] || '',
314
- },
315
- {
316
- keyName: `${nerfed}:_password`,
317
- val: registry.originalAuthValue?.split(':')[1] || '',
318
- },
319
- ];
320
- }
321
- return [];
322
- }
package/pnpm.aspect.ts DELETED
@@ -1,7 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const PnpmAspect = Aspect.create({
4
- id: 'teambit.dependencies/pnpm',
5
- dependencies: [],
6
- defaultConfig: {},
7
- });
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
-
3
- export const Logo = () => (
4
- <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>
5
- <img style={{ width: 70 }} src="https://static.bit.dev/brands/pnpm.svg" />
6
- </div>
7
- );
package/pnpm.docs.mdx DELETED
@@ -1,8 +0,0 @@
1
- ---
2
- description: Enables the use of pnpm in a Bit workspace
3
- labels: ['pnpm', 'package manager']
4
- ---
5
-
6
- import { Pnpm } from '@teambit/dependencies.aspect-docs.pnpm';
7
-
8
- <Pnpm />
@@ -1,20 +0,0 @@
1
- import { MainRuntime } from '@teambit/cli';
2
- import { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';
3
- import { LoggerAspect, LoggerMain } from '@teambit/logger';
4
- import { PkgAspect, PkgMain } from '@teambit/pkg';
5
-
6
- import { PnpmAspect } from './pnpm.aspect';
7
- import { PnpmPackageManager } from './pnpm.package-manager';
8
-
9
- export class PnpmMain {
10
- static runtime = MainRuntime;
11
- static dependencies = [DependencyResolverAspect, PkgAspect, LoggerAspect];
12
-
13
- static async provider([depResolver, pkg, loggerExt]: [DependencyResolverMain, PkgMain, LoggerMain]) {
14
- const logger = loggerExt.createLogger(PnpmAspect.id);
15
- depResolver.registerPackageManager(new PnpmPackageManager(depResolver, pkg, logger));
16
- return new PnpmMain();
17
- }
18
- }
19
-
20
- PnpmAspect.addRuntime(PnpmMain);
@@ -1,175 +0,0 @@
1
- import { ComponentMap } from '@teambit/component';
2
- import {
3
- ComponentsManifestsMap,
4
- CreateFromComponentsOptions,
5
- WorkspacePolicy,
6
- DependencyResolverMain,
7
- PackageManager,
8
- PackageManagerInstallOptions,
9
- PackageManagerResolveRemoteVersionOptions,
10
- ResolvedPackageVersion,
11
- Registries,
12
- Registry,
13
- BIT_DEV_REGISTRY,
14
- PackageManagerProxyConfig,
15
- PackageManagerNetworkConfig,
16
- } from '@teambit/dependency-resolver';
17
- import { Logger } from '@teambit/logger';
18
- import { memoize, omit } from 'lodash';
19
- import { PkgMain } from '@teambit/pkg';
20
- import { join } from 'path';
21
- import userHome from 'user-home';
22
- import { readConfig } from './read-config';
23
-
24
- const defaultStoreDir = join(userHome, '.pnpm-store');
25
- const defaultCacheDir = join(userHome, '.pnpm-cache');
26
-
27
- export class PnpmPackageManager implements PackageManager {
28
- private readConfig = memoize(readConfig);
29
- constructor(private depResolver: DependencyResolverMain, private pkg: PkgMain, private logger: Logger) {}
30
-
31
- async install(
32
- rootDir: string,
33
- rootPolicy: WorkspacePolicy,
34
- componentDirectoryMap: ComponentMap<string>,
35
- installOptions: PackageManagerInstallOptions = {}
36
- ): Promise<void> {
37
- // require it dynamically for performance purpose. the pnpm package require many files - do not move to static import
38
- // eslint-disable-next-line global-require, import/no-dynamic-require
39
- const { install } = require('./lynx');
40
- const storeDir = installOptions?.cacheRootDir ? join(installOptions?.cacheRootDir, '.pnpm-store') : defaultStoreDir;
41
- const cacheDir = installOptions?.cacheRootDir ? join(installOptions?.cacheRootDir, '.pnpm-cache') : defaultCacheDir;
42
-
43
- const components = componentDirectoryMap.toArray().map(([component]) => component);
44
- const options: CreateFromComponentsOptions = {
45
- filterComponentsFromManifests: true,
46
- createManifestForComponentsWithoutDependencies: true,
47
- dedupe: installOptions.dedupe,
48
- dependencyFilterFn: installOptions.dependencyFilterFn,
49
- };
50
- const workspaceManifest = await this.depResolver.getWorkspaceManifest(
51
- undefined,
52
- undefined,
53
- rootPolicy,
54
- rootDir,
55
- components,
56
- options
57
- );
58
- const rootManifest = workspaceManifest.toJson({
59
- includeDir: true,
60
- copyPeerToRuntime: installOptions.copyPeerToRuntimeOnRoot,
61
- });
62
-
63
- const componentsManifests = this.computeComponentsManifests(
64
- componentDirectoryMap,
65
- workspaceManifest.componentsManifestsMap,
66
- // In case of not deduping we want to install peers inside the components
67
- // !options.dedupe
68
- installOptions.copyPeerToRuntimeOnComponents
69
- );
70
- this.logger.debug('root manifest for installation', rootManifest);
71
- this.logger.debug('components manifests for installation', componentsManifests);
72
- this.logger.setStatusLine('installing dependencies using pnpm');
73
- // turn off the logger because it interrupts the pnpm output
74
- this.logger.off();
75
- const registries = await this.depResolver.getRegistries();
76
- const proxyConfig = await this.depResolver.getProxyConfig();
77
- const networkConfig = await this.depResolver.getNetworkConfig();
78
- await install(
79
- rootManifest,
80
- componentsManifests,
81
- storeDir,
82
- cacheDir,
83
- registries,
84
- proxyConfig,
85
- networkConfig,
86
- this.logger
87
- );
88
- this.logger.on();
89
- // Make a divider row to improve output
90
- this.logger.console('-------------------------');
91
- this.logger.consoleSuccess('installing dependencies using pnpm');
92
- }
93
-
94
- private computeComponentsManifests(
95
- componentDirectoryMap: ComponentMap<string>,
96
- componentsManifestsFromWorkspace: ComponentsManifestsMap,
97
- copyPeerToRuntime = false
98
- ) {
99
- return componentDirectoryMap.toArray().reduce((acc, [component, dir]) => {
100
- const packageName = this.pkg.getPackageName(component);
101
- if (componentsManifestsFromWorkspace.has(packageName)) {
102
- acc[dir] = componentsManifestsFromWorkspace.get(packageName)?.toJson({ copyPeerToRuntime });
103
- }
104
- return acc;
105
- }, {});
106
- }
107
-
108
- async resolveRemoteVersion(
109
- packageName: string,
110
- options: PackageManagerResolveRemoteVersionOptions
111
- ): Promise<ResolvedPackageVersion> {
112
- // require it dynamically for performance purpose. the pnpm package require many files - do not move to static import
113
- // eslint-disable-next-line global-require, import/no-dynamic-require
114
- const { resolveRemoteVersion } = require('./lynx');
115
- const cacheDir = options?.cacheRootDir ? join(options?.cacheRootDir, '.pnpm-cache') : defaultStoreDir;
116
- const registries = await this.depResolver.getRegistries();
117
- const proxyConfig = await this.depResolver.getProxyConfig();
118
- const networkConfig = await this.depResolver.getNetworkConfig();
119
- return resolveRemoteVersion(packageName, options.rootDir, cacheDir, registries, proxyConfig, networkConfig);
120
- }
121
-
122
- async getProxyConfig?(): Promise<PackageManagerProxyConfig> {
123
- // eslint-disable-next-line global-require, import/no-dynamic-require
124
- const { getProxyConfig } = require('./get-proxy-config');
125
- const { config } = await this.readConfig();
126
- return getProxyConfig(config);
127
- }
128
-
129
- async getNetworkConfig?(): Promise<PackageManagerNetworkConfig> {
130
- const { config } = await this.readConfig();
131
- return {
132
- maxSockets: config.maxSockets,
133
- networkConcurrency: config.networkConcurrency,
134
- fetchRetries: config.fetchRetries,
135
- fetchTimeout: config.fetchTimeout,
136
- fetchRetryMaxtimeout: config.fetchRetryMaxtimeout,
137
- fetchRetryMintimeout: config.fetchRetryMintimeout,
138
- };
139
- }
140
-
141
- async getRegistries(): Promise<Registries> {
142
- // eslint-disable-next-line global-require, import/no-dynamic-require
143
- const { getRegistries } = require('./get-registries');
144
- const { config } = await this.readConfig();
145
- const pnpmRegistry = await getRegistries(config);
146
- const defaultRegistry = new Registry(
147
- pnpmRegistry.default.uri,
148
- pnpmRegistry.default.alwaysAuth,
149
- pnpmRegistry.default.authHeaderValue,
150
- pnpmRegistry.default.originalAuthType,
151
- pnpmRegistry.default.originalAuthValue
152
- );
153
-
154
- const pnpmScoped = omit(pnpmRegistry, ['default']);
155
- const scopesRegistries: Record<string, Registry> = Object.keys(pnpmScoped).reduce((acc, scopedRegName) => {
156
- const scopedReg = pnpmScoped[scopedRegName];
157
- const name = scopedRegName.replace('@', '');
158
- acc[name] = new Registry(
159
- scopedReg.uri,
160
- scopedReg.alwaysAuth,
161
- scopedReg.authHeaderValue,
162
- scopedReg.originalAuthType,
163
- scopedReg.originalAuthValue
164
- );
165
- return acc;
166
- }, {});
167
-
168
- // Add bit registry server if not exist
169
- if (!scopesRegistries.bit) {
170
- scopesRegistries.bit = new Registry(BIT_DEV_REGISTRY, true);
171
- }
172
-
173
- return new Registries(defaultRegistry, scopesRegistries);
174
- }
175
- }
package/read-config.ts DELETED
@@ -1,15 +0,0 @@
1
- import getConfig from '@pnpm/config';
2
-
3
- export async function readConfig() {
4
- const pnpmConfig = await getConfig({
5
- cliOptions: {
6
- // 'global': true,
7
- // 'link-workspace-packages': true,
8
- },
9
- packageManager: {
10
- name: 'pnpm',
11
- version: '1.0.0',
12
- },
13
- });
14
- return pnpmConfig;
15
- }
package/types/asset.d.ts DELETED
@@ -1,29 +0,0 @@
1
- declare module '*.png' {
2
- const value: any;
3
- export = value;
4
- }
5
- declare module '*.svg' {
6
- import type { FunctionComponent, SVGProps } from 'react';
7
-
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
9
- const src: string;
10
- export default src;
11
- }
12
-
13
- // @TODO Gilad
14
- declare module '*.jpg' {
15
- const value: any;
16
- export = value;
17
- }
18
- declare module '*.jpeg' {
19
- const value: any;
20
- export = value;
21
- }
22
- declare module '*.gif' {
23
- const value: any;
24
- export = value;
25
- }
26
- declare module '*.bmp' {
27
- const value: any;
28
- export = value;
29
- }
package/types/style.d.ts DELETED
@@ -1,42 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: { readonly [key: string]: string };
3
- export default classes;
4
- }
5
- declare module '*.module.scss' {
6
- const classes: { readonly [key: string]: string };
7
- export default classes;
8
- }
9
- declare module '*.module.sass' {
10
- const classes: { readonly [key: string]: string };
11
- export default classes;
12
- }
13
-
14
- declare module '*.module.less' {
15
- const classes: { readonly [key: string]: string };
16
- export default classes;
17
- }
18
-
19
- declare module '*.less' {
20
- const classes: { readonly [key: string]: string };
21
- export default classes;
22
- }
23
-
24
- declare module '*.css' {
25
- const classes: { readonly [key: string]: string };
26
- export default classes;
27
- }
28
-
29
- declare module '*.sass' {
30
- const classes: { readonly [key: string]: string };
31
- export default classes;
32
- }
33
-
34
- declare module '*.scss' {
35
- const classes: { readonly [key: string]: string };
36
- export default classes;
37
- }
38
-
39
- declare module '*.mdx' {
40
- const component: any;
41
- export default component;
42
- }