@teambit/install 0.0.0-019dfe796cb827647fea4f5ea377789618005504

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.
Files changed (77) hide show
  1. package/dist/esm.mjs +7 -0
  2. package/dist/exceptions/dependency-type-not-supported-in-policy.d.ts +4 -0
  3. package/dist/exceptions/dependency-type-not-supported-in-policy.js +21 -0
  4. package/dist/exceptions/dependency-type-not-supported-in-policy.js.map +1 -0
  5. package/dist/exceptions/index.d.ts +1 -0
  6. package/dist/exceptions/index.js +20 -0
  7. package/dist/exceptions/index.js.map +1 -0
  8. package/dist/index.d.ts +5 -0
  9. package/dist/index.js +35 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/install.aspect.d.ts +2 -0
  12. package/dist/install.aspect.js +18 -0
  13. package/dist/install.aspect.js.map +1 -0
  14. package/dist/install.cmd.d.ts +55 -0
  15. package/dist/install.cmd.js +170 -0
  16. package/dist/install.cmd.js.map +1 -0
  17. package/dist/install.main.runtime.d.ts +248 -0
  18. package/dist/install.main.runtime.js +1400 -0
  19. package/dist/install.main.runtime.js.map +1 -0
  20. package/dist/link/component-list-links.d.ts +10 -0
  21. package/dist/link/component-list-links.js +102 -0
  22. package/dist/link/component-list-links.js.map +1 -0
  23. package/dist/link/core-aspects-links.d.ts +7 -0
  24. package/dist/link/core-aspects-links.js +83 -0
  25. package/dist/link/core-aspects-links.js.map +1 -0
  26. package/dist/link/get-package-name-from-target.d.ts +1 -0
  27. package/dist/link/get-package-name-from-target.js +13 -0
  28. package/dist/link/get-package-name-from-target.js.map +1 -0
  29. package/dist/link/index.d.ts +1 -0
  30. package/dist/link/index.js +20 -0
  31. package/dist/link/index.js.map +1 -0
  32. package/dist/link/link-row.d.ts +12 -0
  33. package/dist/link/link-row.js +32 -0
  34. package/dist/link/link-row.js.map +1 -0
  35. package/dist/link/link-to-dir.d.ts +2 -0
  36. package/dist/link/link-to-dir.js +35 -0
  37. package/dist/link/link-to-dir.js.map +1 -0
  38. package/dist/link/link.cmd.d.ts +47 -0
  39. package/dist/link/link.cmd.js +145 -0
  40. package/dist/link/link.cmd.js.map +1 -0
  41. package/dist/link/nested-deps-in-nm-links.d.ts +7 -0
  42. package/dist/link/nested-deps-in-nm-links.js +59 -0
  43. package/dist/link/nested-deps-in-nm-links.js.map +1 -0
  44. package/dist/link/rewire-row.d.ts +6 -0
  45. package/dist/link/rewire-row.js +26 -0
  46. package/dist/link/rewire-row.js.map +1 -0
  47. package/dist/pick-outdated-pkgs.d.ts +12 -0
  48. package/dist/pick-outdated-pkgs.js +180 -0
  49. package/dist/pick-outdated-pkgs.js.map +1 -0
  50. package/dist/pick-outdated-pkgs.spec.d.ts +1 -0
  51. package/dist/pick-outdated-pkgs.spec.js +169 -0
  52. package/dist/pick-outdated-pkgs.spec.js.map +1 -0
  53. package/dist/preview-1756139709945.js +7 -0
  54. package/dist/uninstall.cmd.d.ts +12 -0
  55. package/dist/uninstall.cmd.js +26 -0
  56. package/dist/uninstall.cmd.js.map +1 -0
  57. package/dist/update.cmd.d.ts +26 -0
  58. package/dist/update.cmd.js +52 -0
  59. package/dist/update.cmd.js.map +1 -0
  60. package/esm.mjs +7 -0
  61. package/exceptions/dependency-type-not-supported-in-policy.ts +7 -0
  62. package/exceptions/index.ts +1 -0
  63. package/install.cmd.tsx +208 -0
  64. package/link/component-list-links.ts +79 -0
  65. package/link/core-aspects-links.ts +57 -0
  66. package/link/get-package-name-from-target.ts +5 -0
  67. package/link/index.ts +1 -0
  68. package/link/link-row.ts +20 -0
  69. package/link/link-to-dir.ts +13 -0
  70. package/link/link.cmd.ts +118 -0
  71. package/link/nested-deps-in-nm-links.ts +47 -0
  72. package/link/rewire-row.ts +17 -0
  73. package/package.json +96 -0
  74. package/types/asset.d.ts +41 -0
  75. package/types/style.d.ts +42 -0
  76. package/uninstall.cmd.tsx +18 -0
  77. package/update.cmd.tsx +67 -0
@@ -0,0 +1,248 @@
1
+ import type { CompilerMain } from '@teambit/compiler';
2
+ import type { CLIMain } from '@teambit/cli';
3
+ import type { Workspace } from '@teambit/workspace';
4
+ import type { GenerateResult, GeneratorMain } from '@teambit/generator';
5
+ import type { ApplicationMain } from '@teambit/application';
6
+ import type { VariantsMain } from '@teambit/variants';
7
+ import type { Component } from '@teambit/component';
8
+ import { ComponentMap } from '@teambit/component';
9
+ import type { Harmony, SlotRegistry } from '@teambit/harmony';
10
+ import { type DependenciesGraph } from '@teambit/objects';
11
+ import type { CodemodResult, NodeModulesLinksResult } from '@teambit/workspace.modules.node-modules-linker';
12
+ import type { EnvsMain } from '@teambit/envs';
13
+ import type { IpcEventsMain } from '@teambit/ipc-events';
14
+ import type { WorkspaceDependencyLifecycleType, DependencyResolverMain, LinkingOptions, LinkResults, WorkspacePolicy } from '@teambit/dependency-resolver';
15
+ import type { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
16
+ import type { Logger, LoggerMain } from '@teambit/logger';
17
+ import type { IssuesMain } from '@teambit/issues';
18
+ import type { AspectLoaderMain } from '@teambit/aspect-loader';
19
+ import type { BundlerMain } from '@teambit/bundler';
20
+ import type { UiMain } from '@teambit/ui';
21
+ export type WorkspaceLinkOptions = LinkingOptions & {
22
+ rootPolicy?: WorkspacePolicy;
23
+ linkToBitRoots?: boolean;
24
+ includePeers?: boolean;
25
+ };
26
+ export type WorkspaceLinkResults = {
27
+ legacyLinkResults?: NodeModulesLinksResult[];
28
+ legacyLinkCodemodResults?: CodemodResult[];
29
+ } & LinkResults;
30
+ export type WorkspaceInstallOptions = {
31
+ addMissingDeps?: boolean;
32
+ skipUnavailable?: boolean;
33
+ addMissingPeers?: boolean;
34
+ lifecycleType?: WorkspaceDependencyLifecycleType;
35
+ dedupe?: boolean;
36
+ import?: boolean;
37
+ showExternalPackageManagerPrompt?: boolean;
38
+ copyPeerToRuntimeOnRoot?: boolean;
39
+ copyPeerToRuntimeOnComponents?: boolean;
40
+ updateExisting?: boolean;
41
+ skipIfExisting?: boolean;
42
+ savePrefix?: string;
43
+ compile?: boolean;
44
+ includeOptionalDeps?: boolean;
45
+ updateAll?: boolean;
46
+ recurringInstall?: boolean;
47
+ optimizeReportForNonTerminal?: boolean;
48
+ lockfileOnly?: boolean;
49
+ writeConfigFiles?: boolean;
50
+ skipPrune?: boolean;
51
+ dependenciesGraph?: DependenciesGraph;
52
+ };
53
+ export type ModulesInstallOptions = Omit<WorkspaceInstallOptions, 'updateExisting' | 'lifecycleType' | 'import'>;
54
+ type PreLink = (linkOpts?: WorkspaceLinkOptions) => Promise<void>;
55
+ type PreInstall = (installOpts?: WorkspaceInstallOptions) => Promise<void>;
56
+ type PostInstall = () => Promise<void>;
57
+ type PreLinkSlot = SlotRegistry<PreLink>;
58
+ type PreInstallSlot = SlotRegistry<PreInstall>;
59
+ type PostInstallSlot = SlotRegistry<PostInstall>;
60
+ export declare class InstallMain {
61
+ private dependencyResolver;
62
+ private logger;
63
+ private workspace;
64
+ private variants;
65
+ private compiler;
66
+ private envs;
67
+ private wsConfigFiles;
68
+ private aspectLoader;
69
+ private app;
70
+ private generator;
71
+ private preLinkSlot;
72
+ private preInstallSlot;
73
+ private postInstallSlot;
74
+ private ipcEvents;
75
+ private harmony;
76
+ private visitedAspects;
77
+ private oldNonLoadedEnvs;
78
+ constructor(dependencyResolver: DependencyResolverMain, logger: Logger, workspace: Workspace, variants: VariantsMain, compiler: CompilerMain, envs: EnvsMain, wsConfigFiles: WorkspaceConfigFilesMain, aspectLoader: AspectLoaderMain, app: ApplicationMain, generator: GeneratorMain, preLinkSlot: PreLinkSlot, preInstallSlot: PreInstallSlot, postInstallSlot: PostInstallSlot, ipcEvents: IpcEventsMain, harmony: Harmony);
79
+ /**
80
+ * Install dependencies for all components in the workspace
81
+ *
82
+ * @returns
83
+ * @memberof Workspace
84
+ */
85
+ install(packages?: string[], options?: WorkspaceInstallOptions): Promise<ComponentMap<string>>;
86
+ registerPreLink(fn: PreLink): void;
87
+ registerPreInstall(fn: PreInstall): void;
88
+ registerPostInstall(fn: PostInstall): void;
89
+ onComponentCreate(generateResults: GenerateResult[], installOptions?: Partial<WorkspaceInstallOptions>): Promise<void>;
90
+ private _addPackages;
91
+ private _installModules;
92
+ private shouldClearCacheOnInstall;
93
+ /**
94
+ * This function is very important to fix some issues that might happen during the installation process.
95
+ * The case is the following:
96
+ * during/before the installation process we load some envs from their bit.env files
97
+ * this contains code like:
98
+ * protected tsconfigPath = require.resolve('./config/tsconfig.json');
99
+ * protected eslintConfigPath = require.resolve('./config/eslintrc.cjs');
100
+ * When we load that file, we calculated the resolved path, and it's stored in the env
101
+ * object instance.
102
+ * then later on during the install we move the env to another location (like bit roots)
103
+ * which points to a .pnpm folder with some peers, that changed during the install
104
+ * then when we take this env object and call write ws config for example
105
+ * or compile
106
+ * we use that resolved path to calculate the final tsconfig
107
+ * however that file is no longer exists which result in an error
108
+ * This function will check if an env folder doesn't exist anymore, and will re-load it
109
+ * from its new location.
110
+ * This usually happen when we have install running in the middle of the process followed
111
+ * by other bit ops.
112
+ * examples:
113
+ * bit new - which might run few installs then other ops.
114
+ * bit switch - which might run few installs then other ops, and potentially change the
115
+ * peer deps during the install.
116
+ * bit server (vscode plugin) - which keep the process always live, so any install ops
117
+ * that change the location, will cause the vscode plugin/bit server to crash later.
118
+ * @returns
119
+ */
120
+ private reloadMovedEnvs;
121
+ private reloadRegisteredEnvs;
122
+ private reloadNonLoadedEnvs;
123
+ private reloadEnvs;
124
+ private reloadAspects;
125
+ private reloadOneAspectsGroup;
126
+ /**
127
+ * This function groups the components to aspects to load into groups.
128
+ * The order of the groups is important, the first group should be loaded first.
129
+ * The order inside the group is not important.
130
+ * The groups are:
131
+ * 1. aspects definitions without components (this should be an empty group, if it's not, we should check why).
132
+ * 2. aspects which are not in the workspace but in the scope / node modules.
133
+ * 3. envs of aspects (which are also aspects)
134
+ * 4. other aspects (the rest)
135
+ * @param aspects
136
+ * @returns
137
+ */
138
+ private groupAspectsToLoad;
139
+ private regroupEnvsIdsFromTheList;
140
+ private _getComponentsManifestsAndRootPolicy;
141
+ /**
142
+ * The function `tryWriteConfigFiles` attempts to write workspace config files, and if it fails, it logs an error
143
+ * message.
144
+ * @returns If the condition `!shouldWrite` is true, then nothing is being returned. Otherwise, if the `writeConfigFiles`
145
+ * function is successfully executed, nothing is being returned. If an error occurs during the execution of
146
+ * `writeConfigFiles`, an error message is being returned.
147
+ */
148
+ private tryWriteConfigFiles;
149
+ private addConfiguredAspectsToWorkspacePolicy;
150
+ private addConfiguredGeneratorEnvsToWorkspacePolicy;
151
+ private _addMissingPackagesToRootPolicy;
152
+ private _getMissingPackagesWithoutRootDeps;
153
+ private _getAllMissingPackages;
154
+ private _getComponentsManifests;
155
+ setOldNonLoadedEnvs(): string[];
156
+ /**
157
+ * This function returns a list of old non-loaded environments names.
158
+ * @returns an array of strings called `oldNonLoadedEnvs`. This array contains the names of environment variables that
159
+ * failed to load as extensions and are also don't have an env.jsonc file.
160
+ * If this list is not empty, then the user might need to run another install to make sure all dependencies resolved
161
+ * correctly
162
+ */
163
+ getOldNonLoadedEnvs(): string[];
164
+ private _updateRootDirs;
165
+ private _getRootManifests;
166
+ private _getEnvManifests;
167
+ private _getEnvDependencies;
168
+ /**
169
+ * Return the package name of the env with its version.
170
+ * (only if the env is not a core env and is not in the workspace)
171
+ * @param envId
172
+ * @returns
173
+ */
174
+ private _getEnvPackage;
175
+ private _getAppManifests;
176
+ private _getAllUsedEnvIds;
177
+ /**
178
+ * Updates out-of-date dependencies in the workspace.
179
+ *
180
+ * @param options.all {Boolean} updates all outdated dependencies without showing a prompt.
181
+ */
182
+ updateDependencies(options: {
183
+ forceVersionBump?: 'major' | 'minor' | 'patch' | 'compatible';
184
+ patterns?: string[];
185
+ all: boolean;
186
+ }): Promise<ComponentMap<string> | null>;
187
+ addDuplicateComponentAndPackageIssue(components: Component[]): Promise<void>;
188
+ private _updateComponentsConfig;
189
+ private _updateVariantsPolicies;
190
+ /**
191
+ * Uninstall the specified packages from dependencies.
192
+ *
193
+ * @param {string[]} the list of packages that should be removed from dependencies.
194
+ */
195
+ uninstallDependencies(packages: string[]): Promise<ComponentMap<string>>;
196
+ /**
197
+ * This function returns all the locations of the external links that should be created inside node_modules.
198
+ * This information may then be passed to the package manager, which will create the links on its own.
199
+ */
200
+ calculateLinks(options?: WorkspaceLinkOptions): Promise<{
201
+ linkResults: WorkspaceLinkResults;
202
+ linkedRootDeps: Record<string, string>;
203
+ }>;
204
+ linkCodemods(compDirMap: ComponentMap<string>, options?: {
205
+ rewire?: boolean;
206
+ }): Promise<{
207
+ linksResults: NodeModulesLinksResult[];
208
+ codemodResults: any;
209
+ }>;
210
+ link(options?: WorkspaceLinkOptions): Promise<WorkspaceLinkResults>;
211
+ private _linkAllComponentsToBitRoots;
212
+ private getRootComponentDirByRootId;
213
+ /**
214
+ * Generate a filter to pass to the installer
215
+ * This will filter deps which are come from remotes which defined in scope.json
216
+ * those components comes from local remotes, usually doesn't have a package in a registry
217
+ * so no reason to try to install them (it will fail)
218
+ */
219
+ private generateFilterFnForDepsFromLocalRemote;
220
+ private getComponentsDirectory;
221
+ private onRootAspectAddedSubscriber;
222
+ private onAspectsResolveSubscriber;
223
+ onComponentChange(component: Component): Promise<void>;
224
+ static slots: (((registerFn: () => string) => SlotRegistry<PreLinkSlot>) | ((registerFn: () => string) => SlotRegistry<PreInstallSlot>))[];
225
+ static dependencies: import("@teambit/harmony").Aspect[];
226
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
227
+ static provider([dependencyResolver, workspace, loggerExt, variants, cli, compiler, issues, envs, app, ipcEvents, generator, wsConfigFiles, aspectLoader, bundler, ui,]: [
228
+ DependencyResolverMain,
229
+ Workspace,
230
+ LoggerMain,
231
+ VariantsMain,
232
+ CLIMain,
233
+ CompilerMain,
234
+ IssuesMain,
235
+ EnvsMain,
236
+ ApplicationMain,
237
+ IpcEventsMain,
238
+ GeneratorMain,
239
+ WorkspaceConfigFilesMain,
240
+ AspectLoaderMain,
241
+ BundlerMain,
242
+ UiMain
243
+ ], _: any, [preLinkSlot, preInstallSlot, postInstallSlot]: [PreLinkSlot, PreInstallSlot, PostInstallSlot], harmony: Harmony): Promise<InstallMain>;
244
+ private handleExternalPackageManagerPrompt;
245
+ private disableExternalPackageManagerMode;
246
+ private removePostInstallScript;
247
+ }
248
+ export default InstallMain;