@teambit/workspace-config-files 0.0.1
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/dist/config-writer-entry.d.ts +94 -0
- package/dist/config-writer-entry.js +3 -0
- package/dist/config-writer-entry.js.map +1 -0
- package/dist/dedup-paths.d.ts +28 -0
- package/dist/dedup-paths.js +121 -0
- package/dist/dedup-paths.js.map +1 -0
- package/dist/dedup-paths.spec.d.ts +1 -0
- package/dist/dedup-paths.spec.js +198 -0
- package/dist/dedup-paths.spec.js.map +1 -0
- package/dist/format-outputs.d.ts +5 -0
- package/dist/format-outputs.js +105 -0
- package/dist/format-outputs.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1679542267429.js +7 -0
- package/dist/workspace-config-files.aspect.d.ts +2 -0
- package/dist/workspace-config-files.aspect.js +19 -0
- package/dist/workspace-config-files.aspect.js.map +1 -0
- package/dist/workspace-config-files.docs.mdx +21 -0
- package/dist/workspace-config-files.main.runtime.d.ts +147 -0
- package/dist/workspace-config-files.main.runtime.js +480 -0
- package/dist/workspace-config-files.main.runtime.js.map +1 -0
- package/dist/ws-config.cmd.d.ts +63 -0
- package/dist/ws-config.cmd.js +163 -0
- package/dist/ws-config.cmd.js.map +1 -0
- package/package-tar/teambit-workspace-config-files-0.0.1.tgz +0 -0
- package/package.json +65 -0
- package/tsconfig.json +40 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
- package/workspace-config-files.docs.mdx +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatListOutput","result","head","rows","map","entry","aspectId","configWriter","name","cliName","table","Table","style","push","toString","formatWriteOutput","writeConfigFilesResult","flags","cleanResults","writeResults","wsDir","isDryRun","dryRun","dryRunWithContent","cleanResultsOutput","getCleanResultsOutput","writeResultsOutput","getWriteResultsOutput","formatCleanOutput","chalk","green","length","join","totalFiles","totalWrittenFiles","writeTitle","writeOutput","aspectsWritersResults","aspectWritersResults","getOneAspectOutput","title","blue","bold","writersOutput","writersResult","oneWritersResults","getOneWriterOutput","cyan","realConfigFilesOutput","getRealConfigFilesOutput","configFiles","extendingConfigFilesOutput","getExtendingConfigFilesOutput","extendingConfigFiles","envsWrittenConfigFiles","magenta","writtenConfigFilesOutput","envsWrittenConfigFile","getEnvGroupConfigFilesOutput","envIds","filePath","relative","configFile","envsWrittenExtendingConfigFile","getEnvGroupExtendingConfigFilesOutput","extendingConfigFile","paths","filePaths","p","extendingTarget"],"sources":["format-outputs.ts"],"sourcesContent":["import Table from 'cli-table';\nimport chalk from 'chalk';\nimport { relative } from 'path';\nimport {\n AspectWritersResults,\n ConfigWritersList,\n EnvsWrittenConfigFile,\n EnvsWrittenConfigFiles,\n EnvsWrittenExtendingConfigFile,\n EnvsWrittenExtendingConfigFiles,\n OneConfigFileWriterResult,\n WriteConfigFilesResult,\n} from './workspace-config-files.main.runtime';\nimport type { CleanConfigCmdFlags, WriteConfigCmdFlags } from './ws-config.cmd';\n\nexport function formatListOutput(result: ConfigWritersList): string {\n const head = ['Aspect ID', 'name', 'CLI name'];\n\n const rows = result.map((entry) => {\n return [\n entry.aspectId,\n entry.configWriter.name,\n entry.configWriter.cliName,\n ]\n });\n const table = new Table({ head, style: { head: ['cyan'] } });\n table.push(...rows)\n return table.toString();\n}\nexport function formatWriteOutput(writeConfigFilesResult: WriteConfigFilesResult, flags: WriteConfigCmdFlags): string {\n const { cleanResults, writeResults, wsDir } = writeConfigFilesResult;\n const isDryRun = !!(flags.dryRun || flags.dryRunWithContent);\n const cleanResultsOutput = getCleanResultsOutput(cleanResults, isDryRun);\n const writeResultsOutput = getWriteResultsOutput(writeResults, wsDir, isDryRun);\n\n return `${cleanResultsOutput}${writeResultsOutput}`;\n}\n\nexport function formatCleanOutput(cleanResults: string[] = [], flags: CleanConfigCmdFlags): string {\n const isDryRun = !!flags.dryRun;\n const cleanResultsOutput = getCleanResultsOutput(cleanResults, isDryRun);\n\n return `${cleanResultsOutput}`;\n}\n\nfunction getCleanResultsOutput(cleanResults: string[] | undefined, isDryRun: boolean) {\n const cleanResultsOutput = cleanResults\n ? `${chalk.green(\n `the following ${cleanResults.length} paths ${isDryRun ? 'will be' : 'were'} deleted:`\n )}\\n ${cleanResults.join('\\n ')}\\n`\n : '';\n return cleanResultsOutput;\n}\nfunction getWriteResultsOutput(writeResults: WriteConfigFilesResult['writeResults'], wsDir: string, isDryRun: boolean) {\n const totalFiles = writeResults.totalWrittenFiles;\n\n const writeTitle = isDryRun\n ? chalk.green(`${totalFiles} files will be written`)\n : chalk.green(`${totalFiles} files have been written successfully`);\n const writeOutput = writeResults.aspectsWritersResults\n .map((aspectWritersResults) => getOneAspectOutput(aspectWritersResults, wsDir))\n .join('\\n\\n');\n return `${writeTitle}\\n${writeOutput}`;\n}\nfunction getOneAspectOutput(aspectWritersResults: AspectWritersResults, wsDir: string): string {\n const title = chalk.blue(\n `The following paths are according to aspect ${chalk.bold(aspectWritersResults.aspectId.toString())}`\n );\n const writersOutput = aspectWritersResults.writersResult\n .map((oneWritersResults) => getOneWriterOutput(oneWritersResults, wsDir))\n .join('\\n\\n');\n return `${title}\\n${writersOutput}`;\n}\nfunction getOneWriterOutput(oneWritersResults: OneConfigFileWriterResult, wsDir: string): string {\n const title = chalk.cyan(` The following paths are according to writer ${chalk.bold(oneWritersResults.name)}`);\n const realConfigFilesOutput = getRealConfigFilesOutput(oneWritersResults.configFiles, wsDir);\n const extendingConfigFilesOutput = getExtendingConfigFilesOutput(oneWritersResults.extendingConfigFiles, wsDir);\n return `${title}\\n${realConfigFilesOutput}\\n\\n${extendingConfigFilesOutput}`;\n}\n\nfunction getRealConfigFilesOutput(envsWrittenConfigFiles: EnvsWrittenConfigFiles, wsDir: string): string {\n const title = chalk.magenta(` Real config files`);\n const writtenConfigFilesOutput = envsWrittenConfigFiles\n .map((envsWrittenConfigFile) => getEnvGroupConfigFilesOutput(envsWrittenConfigFile, wsDir))\n .join('\\n\\n');\n return `${title}\\n${writtenConfigFilesOutput}`;\n}\nfunction getEnvGroupConfigFilesOutput(envsWrittenConfigFile: EnvsWrittenConfigFile, wsDir: string): string {\n const title = ` The following paths are according to env(s) ${chalk.bold(\n envsWrittenConfigFile.envIds.join(', ')\n )}`;\n const filePath = relative(wsDir, envsWrittenConfigFile.configFile.filePath);\n return `${title}\\n ${filePath}`;\n}\nfunction getExtendingConfigFilesOutput(extendingConfigFiles: EnvsWrittenExtendingConfigFiles, wsDir: string): string {\n const title = chalk.magenta(` Extending config files`);\n\n const extendingConfigFilesOutput = extendingConfigFiles\n .map((envsWrittenExtendingConfigFile) =>\n getEnvGroupExtendingConfigFilesOutput(envsWrittenExtendingConfigFile, wsDir)\n )\n .join('\\n\\n');\n return `${title}\\n${extendingConfigFilesOutput}`;\n}\nfunction getEnvGroupExtendingConfigFilesOutput(\n envsWrittenExtendingConfigFile: EnvsWrittenExtendingConfigFile,\n wsDir: string\n): string {\n const title = ` The following paths are according to env(s) ${chalk.bold(\n envsWrittenExtendingConfigFile.envIds.join(', ')\n )}`;\n const extendingConfigFile = envsWrittenExtendingConfigFile.extendingConfigFile;\n const paths = extendingConfigFile.filePaths\n .map((p) => ` ${relative(wsDir, p)} --> ${relative(wsDir, extendingConfigFile.extendingTarget)}`)\n .join('\\n ');\n return `${title}\\n ${paths}`;\n}\n"],"mappings":";;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAaO,SAASA,gBAAgB,CAACC,MAAyB,EAAU;EAClE,MAAMC,IAAI,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC;EAE9C,MAAMC,IAAI,GAAGF,MAAM,CAACG,GAAG,CAAEC,KAAK,IAAK;IACjC,OAAO,CACLA,KAAK,CAACC,QAAQ,EACdD,KAAK,CAACE,YA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B,KAAK,GAAI,mDAAkDX,gBAAK,CAACa,IAAI,CACzEqB,8BAA8B,CAACJ,MAAM,CAAC3B,IAAI,CAAC,IAAI,CAAC,CAChD,EAAC;EACH,MAAMiC,mBAAmB,GAAGF,8BAA8B,CAACE,mBAAmB;EAC9E,MAAMC,KAAK,GAAGD,mBAAmB,CAACE,SAAS,CACxC/D,GAAG,CAAEgE,CAAC,IAAM,KAAI,IAAAP,gBAAQ,EAACzC,KAAK,EAAEgD,CAAC,CAAE,QAAO,IAAAP,gBAAQ,EAACzC,KAAK,EAAE6C,mBAAmB,CAACI,eAAe,CAAE,EAAC,CAAC,CACjGrC,IAAI,CAAC,QAAQ,CAAC;EACjB,OAAQ,GAAEQ,KAAM,SAAQ0B,KAAM,EAAC;AACjC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WorkspaceConfigFilesAspect } from './workspace-config-files.aspect';
|
|
2
|
+
export type { WorkspaceConfigFilesMain, WrittenConfigFile, EnvCompsDirsMap, EnvMapValue } from './workspace-config-files.main.runtime';
|
|
3
|
+
export type { ConfigWriterEntry, ExtendingConfigFile, ConfigFile, PostProcessExtendingConfigFilesArgs } from './config-writer-entry';
|
|
4
|
+
export default WorkspaceConfigFilesAspect;
|
|
5
|
+
export { WorkspaceConfigFilesAspect };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "WorkspaceConfigFilesAspect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _workspaceConfigFiles().WorkspaceConfigFilesAspect;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
function _workspaceConfigFiles() {
|
|
14
|
+
const data = require("./workspace-config-files.aspect");
|
|
15
|
+
_workspaceConfigFiles = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
var _default = _workspaceConfigFiles().WorkspaceConfigFilesAspect;
|
|
21
|
+
exports.default = _default;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WorkspaceConfigFilesAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceConfigFilesAspect } from './workspace-config-files.aspect';\n\nexport type { WorkspaceConfigFilesMain, WrittenConfigFile, EnvCompsDirsMap, EnvMapValue } from './workspace-config-files.main.runtime';\nexport type { ConfigWriterEntry, ExtendingConfigFile, ConfigFile, PostProcessExtendingConfigFilesArgs } from './config-writer-entry';\nexport default WorkspaceConfigFilesAspect;\nexport { WorkspaceConfigFilesAspect };\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA6E,eAI9DA,kDAA0B;AAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
;
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace-config-files@0.0.1/dist/workspace-config-files.docs.mdx';
|
|
3
|
+
|
|
4
|
+
export const compositions = [];
|
|
5
|
+
export const overview = [overview_0];
|
|
6
|
+
|
|
7
|
+
export const compositions_metadata = {"compositions":[]};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WorkspaceConfigFilesAspect = void 0;
|
|
7
|
+
function _harmony() {
|
|
8
|
+
const data = require("@teambit/harmony");
|
|
9
|
+
_harmony = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
const WorkspaceConfigFilesAspect = _harmony().Aspect.create({
|
|
15
|
+
id: 'teambit.workspace/workspace-config-files'
|
|
16
|
+
});
|
|
17
|
+
exports.WorkspaceConfigFilesAspect = WorkspaceConfigFilesAspect;
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=workspace-config-files.aspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WorkspaceConfigFilesAspect","Aspect","create","id"],"sources":["workspace-config-files.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const WorkspaceConfigFilesAspect = Aspect.create({\n id: 'teambit.workspace/workspace-config-files',\n});\n "],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,0BAA0B,GAAGC,iBAAM,CAACC,MAAM,CAAC;EACtDC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Write config files in the workspace.
|
|
3
|
+
labels: ['core aspect', 'cli', 'configuration', 'workspace']
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
This aspect provides the ability to write configuration files in the workspace.
|
|
7
|
+
It provides an API to write configuration files in the workspace, and also provides cli commands to write configuration files.
|
|
8
|
+
|
|
9
|
+
### Register configuration writers
|
|
10
|
+
|
|
11
|
+
This aspect provides a `registerConfigWriter` function to register configuration writers.
|
|
12
|
+
It accpets an array of `ConfigWriterEntry`.
|
|
13
|
+
See the exported interface for more details.
|
|
14
|
+
|
|
15
|
+
### Commands
|
|
16
|
+
|
|
17
|
+
Main command is `bit ws-config` which has the following sub commands:
|
|
18
|
+
- `bit ws-config write` - write configuration files according to the components' envs
|
|
19
|
+
- `bit ws-config clean` - remove all configuration files from the workspace
|
|
20
|
+
- `bit ws-config list` - list all registered configuration writers.
|
|
21
|
+
this is useful for filtering used configuration writers when using the `--writers` flag in the write/clean commands.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
|
2
|
+
import { SlotRegistry } from '@teambit/harmony';
|
|
3
|
+
import type { Workspace } from '@teambit/workspace';
|
|
4
|
+
import { Environment } from '@teambit/envs';
|
|
5
|
+
import type { EnvsMain } from '@teambit/envs';
|
|
6
|
+
import { Logger } from '@teambit/logger';
|
|
7
|
+
import type { LoggerMain } from '@teambit/logger';
|
|
8
|
+
import { ConfigFile, ConfigWriterEntry, ExtendingConfigFile } from './config-writer-entry';
|
|
9
|
+
export declare type ConfigWriterSlot = SlotRegistry<ConfigWriterEntry[]>;
|
|
10
|
+
export declare type ConfigWritersList = Array<{
|
|
11
|
+
aspectId: string;
|
|
12
|
+
configWriter: ConfigWriterEntry;
|
|
13
|
+
}>;
|
|
14
|
+
export declare type CleanConfigFilesOptions = {
|
|
15
|
+
silent?: boolean;
|
|
16
|
+
dryRun?: boolean;
|
|
17
|
+
writers?: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare type WriteConfigFilesOptions = {
|
|
20
|
+
clean?: boolean;
|
|
21
|
+
silent?: boolean;
|
|
22
|
+
dedupe?: boolean;
|
|
23
|
+
dryRun?: boolean;
|
|
24
|
+
dryRunWithContent?: boolean;
|
|
25
|
+
writers?: string[];
|
|
26
|
+
};
|
|
27
|
+
export declare type WrittenConfigFile = Required<ConfigFile> & {
|
|
28
|
+
filePath: string;
|
|
29
|
+
};
|
|
30
|
+
export declare type WrittenExtendingConfigFile = ExtendingConfigFile & {
|
|
31
|
+
filePaths: string[];
|
|
32
|
+
};
|
|
33
|
+
export declare type WrittenConfigFilesMap = {
|
|
34
|
+
[configFileHash: string]: {
|
|
35
|
+
envIds: string[];
|
|
36
|
+
configFile: WrittenConfigFile;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare type ExtendingConfigFilesMap = {
|
|
40
|
+
[configFileHash: string]: {
|
|
41
|
+
envIds: string[];
|
|
42
|
+
extendingConfigFile: Required<ExtendingConfigFile>;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export declare type CompPathExtendingHashMap = {
|
|
46
|
+
[compPath: string]: string;
|
|
47
|
+
};
|
|
48
|
+
export declare type EnvMapValue = {
|
|
49
|
+
env: Environment;
|
|
50
|
+
id: string[];
|
|
51
|
+
paths: string[];
|
|
52
|
+
};
|
|
53
|
+
export declare type EnvCompsDirsMap = {
|
|
54
|
+
[envId: string]: EnvMapValue;
|
|
55
|
+
};
|
|
56
|
+
export declare type EnvsWrittenConfigFile = {
|
|
57
|
+
envIds: string[];
|
|
58
|
+
configFile: WrittenConfigFile;
|
|
59
|
+
};
|
|
60
|
+
export declare type EnvsWrittenConfigFiles = Array<EnvsWrittenConfigFile>;
|
|
61
|
+
export declare type EnvsWrittenExtendingConfigFile = {
|
|
62
|
+
envIds: string[];
|
|
63
|
+
extendingConfigFile: WrittenExtendingConfigFile;
|
|
64
|
+
};
|
|
65
|
+
export declare type EnvsWrittenExtendingConfigFiles = Array<EnvsWrittenExtendingConfigFile>;
|
|
66
|
+
export declare type OneConfigFileWriterResult = {
|
|
67
|
+
name: string;
|
|
68
|
+
totalWrittenFiles: number;
|
|
69
|
+
configFiles: EnvsWrittenConfigFiles;
|
|
70
|
+
totalConfigFiles: number;
|
|
71
|
+
extendingConfigFiles: EnvsWrittenExtendingConfigFiles;
|
|
72
|
+
totalExtendingConfigFiles: number;
|
|
73
|
+
};
|
|
74
|
+
export declare type AspectWritersResults = {
|
|
75
|
+
aspectId: string;
|
|
76
|
+
writersResult: OneConfigFileWriterResult[];
|
|
77
|
+
totalWrittenFiles: number;
|
|
78
|
+
};
|
|
79
|
+
export declare type WriteConfigFilesResult = {
|
|
80
|
+
cleanResults?: string[];
|
|
81
|
+
writeResults: {
|
|
82
|
+
totalWrittenFiles: number;
|
|
83
|
+
aspectsWritersResults: AspectWritersResults[];
|
|
84
|
+
};
|
|
85
|
+
wsDir: string;
|
|
86
|
+
};
|
|
87
|
+
export declare class WorkspaceConfigFilesMain {
|
|
88
|
+
readonly configWriterSlot: ConfigWriterSlot;
|
|
89
|
+
private workspace;
|
|
90
|
+
private envs;
|
|
91
|
+
private logger;
|
|
92
|
+
constructor(configWriterSlot: ConfigWriterSlot, workspace: Workspace, envs: EnvsMain, logger: Logger);
|
|
93
|
+
/**
|
|
94
|
+
* It writes the configuration files for the workspace
|
|
95
|
+
* for example: tsconfig, eslint config and prettier config files.
|
|
96
|
+
* @param {WriteConfigFilesOptions} options - WriteConfigFilesOptions = {}
|
|
97
|
+
* @returns An object with the following properties:
|
|
98
|
+
* - writeResults: An object with the following properties:
|
|
99
|
+
* - aspectsWritersResults: An array of objects with the following properties:
|
|
100
|
+
* - aspect: The aspect that was written
|
|
101
|
+
* - totalWrittenFiles: The number of files that were written
|
|
102
|
+
* - totalWrittenFiles: The total number of files that were written
|
|
103
|
+
* - cleanResults: array of deleted paths
|
|
104
|
+
*/
|
|
105
|
+
writeConfigFiles(options?: WriteConfigFilesOptions): Promise<WriteConfigFilesResult>;
|
|
106
|
+
/**
|
|
107
|
+
* It cleans (delete) the config files from the workspace.
|
|
108
|
+
* This will check each file and will only delete it in case it was generated by bit
|
|
109
|
+
* @param {CleanConfigFilesOptions} options - CleanConfigFilesOptions = {}
|
|
110
|
+
* @returns An array of strings.
|
|
111
|
+
*/
|
|
112
|
+
cleanConfigFiles(options?: CleanConfigFilesOptions): Promise<string[]>;
|
|
113
|
+
/**
|
|
114
|
+
* It returns a list of all the config writers that have been registered with the config writer slot
|
|
115
|
+
* @returns An array of objects with aspectId and configWriter properties.
|
|
116
|
+
*/
|
|
117
|
+
listConfigWriters(): ConfigWritersList;
|
|
118
|
+
private write;
|
|
119
|
+
private handleOneAspectWriter;
|
|
120
|
+
private handleOneConfigFileWriter;
|
|
121
|
+
private handleRealConfigFiles;
|
|
122
|
+
private writeConfigFile;
|
|
123
|
+
private writeExtendingConfigFiles;
|
|
124
|
+
private buildExtendingConfigFilesMap;
|
|
125
|
+
private generateExtendingFile;
|
|
126
|
+
private getConfigsRootDir;
|
|
127
|
+
private getCacheDir;
|
|
128
|
+
private getExecContext;
|
|
129
|
+
private getEnvComponentsDirsMap;
|
|
130
|
+
private getConfigWriters;
|
|
131
|
+
private getFlatConfigWriters;
|
|
132
|
+
/**
|
|
133
|
+
* Clean config files written by the config-writers
|
|
134
|
+
* @param envsExecutionContext
|
|
135
|
+
* @param param1
|
|
136
|
+
* @returns Array of paths of deleted config files
|
|
137
|
+
*/
|
|
138
|
+
clean({ dryRun, silent, writers }: WriteConfigFilesOptions): Promise<string[]>;
|
|
139
|
+
private promptForCleaning;
|
|
140
|
+
private deleteFiles;
|
|
141
|
+
registerConfigWriter(...configWriterEntries: ConfigWriterEntry[]): void;
|
|
142
|
+
static slots: ((registerFn: () => string) => SlotRegistry<ConfigWriterEntry[]>)[];
|
|
143
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
144
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
145
|
+
static provider([cli, workspace, envs, loggerAspect]: [CLIMain, Workspace, EnvsMain, LoggerMain], _config: any, [configWriterSlot]: [ConfigWriterSlot]): Promise<WorkspaceConfigFilesMain>;
|
|
146
|
+
}
|
|
147
|
+
export default WorkspaceConfigFilesMain;
|