@teambit/workspace-config-files 0.0.127 → 0.0.129
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 +12 -1
- package/dist/config-writer-entry.js.map +1 -1
- package/dist/{preview-1693624677571.js → preview-1693884000014.js} +1 -1
- package/dist/writers/extending-config-files.js +27 -4
- package/dist/writers/extending-config-files.js.map +1 -1
- package/package.json +7 -7
- package/writers/extending-config-files.ts +20 -3
|
@@ -37,6 +37,13 @@ export declare type PostProcessExtendingConfigFilesArgs = {
|
|
|
37
37
|
*/
|
|
38
38
|
paths: string[];
|
|
39
39
|
envMapValue: EnvMapValue;
|
|
40
|
+
/**
|
|
41
|
+
* This is a flag for backward compatibility
|
|
42
|
+
* We used to return string from the post process, so old versions of bit only knows to handle string results
|
|
43
|
+
* while in new version we support getting array of objects
|
|
44
|
+
* we need to know if bit the user is using support the new format or not
|
|
45
|
+
*/
|
|
46
|
+
supportSpecificPathChange?: boolean;
|
|
40
47
|
};
|
|
41
48
|
export declare type GenerateExtendingConfigFilesArgs = {
|
|
42
49
|
workspaceDir: string;
|
|
@@ -44,6 +51,10 @@ export declare type GenerateExtendingConfigFilesArgs = {
|
|
|
44
51
|
writtenConfigFiles: WrittenConfigFile[];
|
|
45
52
|
envMapValue: EnvMapValue;
|
|
46
53
|
};
|
|
54
|
+
export declare type PostProcessExtendingConfigFilesOneFile = {
|
|
55
|
+
path: string;
|
|
56
|
+
content: string;
|
|
57
|
+
};
|
|
47
58
|
export declare type MergeConfigFilesFunc = (configFile: ConfigFile, configFile2: ConfigFile) => string;
|
|
48
59
|
export interface ConfigWriterEntry {
|
|
49
60
|
/**
|
|
@@ -100,7 +111,7 @@ export interface ConfigWriterEntry {
|
|
|
100
111
|
* or based on other config files that were written.
|
|
101
112
|
* @param args
|
|
102
113
|
*/
|
|
103
|
-
postProcessExtendingConfigFiles?(args: PostProcessExtendingConfigFilesArgs): Promise<string | undefined>;
|
|
114
|
+
postProcessExtendingConfigFiles?(args: PostProcessExtendingConfigFilesArgs): Promise<string | Array<PostProcessExtendingConfigFilesOneFile> | undefined>;
|
|
104
115
|
/**
|
|
105
116
|
* Find all the files that are relevant for the config type.
|
|
106
117
|
* This is used to clean / delete these files
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["config-writer-entry.ts"],"sourcesContent":["import { Environment, ExecutionContext } from '@teambit/envs';\nimport { EnvMapValue } from './workspace-config-files.main.runtime';\nimport { WrittenConfigFile } from './writers';\n\nexport type ConfigFile = {\n /**\n * Name of the config file.\n * supports also using `{hash}` in the name, which will be replaced by the hash of the config file.\n */\n name: string;\n /**\n * Content of the config file.\n * I.E the content of the tsconfig.json file.\n */\n content: string;\n /**\n * Hash of the config file.\n */\n hash?: string;\n};\n\nexport type ExtendingConfigFileAdditionalProp = {\n /**\n * the config file that this config file extends.\n */\n extendingTarget: WrittenConfigFile;\n\n /**\n * When replacing the config file name with the actual path of the config file, use absolute paths.\n */\n useAbsPaths?: boolean;\n};\n\nexport type ExtendingConfigFile = ConfigFile & ExtendingConfigFileAdditionalProp;\n\nexport type PostProcessExtendingConfigFilesArgs = {\n workspaceDir: string;\n configsRootDir: string;\n extendingConfigFile: ExtendingConfigFile;\n /**\n * Paths that the file will be written to.\n */\n paths: string[];\n envMapValue: EnvMapValue;\n};\n\nexport type GenerateExtendingConfigFilesArgs = {\n workspaceDir: string;\n configsRootDir: string;\n writtenConfigFiles: WrittenConfigFile[];\n envMapValue: EnvMapValue;\n};\n\nexport type MergeConfigFilesFunc = (configFile: ConfigFile, configFile2: ConfigFile) => string;\nexport interface ConfigWriterEntry {\n /**\n * Id is used for few things:\n * 1. merge/post process different configs files (from different envs) together.\n * 2. filter the config writer by the cli when using --writers flag.\n */\n id: string;\n\n /**\n * Name of the config writer.\n * used for outputs and logging.\n */\n name: string;\n\n /**\n * Get's the component env and return the config file content\n * for example the eslint config to tsconfig.\n * This also enable to return a hash of the config file, which will be used to determine if\n * 2 config files are the same.\n * If the hash is not provided, the content will be used as the hash.\n * This enables the specific config type to ignore specific fields when calculating the\n * hash in order to ignore theses fields when determining if 2 config files are the same.\n * The calc function also get the target directory of the config file (calculated by this aspect) as sometime there\n * is a need to change the config file content based on the target directory.\n * for example, change the includes/excludes paths to be relative to the target directory.\n * The calc can return undefined if the config file is not relevant for the component. or not supported by the subscriber.\n * for example if the component uses babel to compile, then tsconfig is not relevant.\n * @param env\n */\n calcConfigFiles(executionContext: ExecutionContext, env: Environment, dir: string): ConfigFile[] | undefined;\n\n /**\n * Provide a function that knows how to merge 2 config files together.\n * This is used when 2 different envs generate the same config file hash.\n * sometime we want to merge the 2 config files together.\n * @param configFile\n * @param configFile2\n */\n mergeConfigFiles?: MergeConfigFilesFunc;\n\n /**\n * This will be used to generate an extending file content.\n * For example, the tsconfig.json file will extend the real tsconfig.{hash}.json file (that were coming from the env).\n * That way we can avoid writing the same config file multiple times.\n * It also reduces the risk of the user manually change the config file and then the changes will be lost.\n * This function support returning a file with content with a dsl using `{}` to replace the config file name.\n * for example:\n * content = `{\n * \"extends\": {configFile.name},\n * }`\n */\n generateExtendingFile(args: GenerateExtendingConfigFilesArgs): ExtendingConfigFile | undefined;\n\n /**\n * This enables the writer to do some post processing after the extending config files were calculated and deduped.\n * this is important in case when we need to change a config file / extending config file after it was calculated\n * based on all the environments in the ws\n * or based on other config files that were written.\n * @param args\n */\n postProcessExtendingConfigFiles?(args: PostProcessExtendingConfigFilesArgs): Promise<string | undefined>;\n\n /**\n * Find all the files that are relevant for the config type.\n * This is used to clean / delete these files\n * This should return an array of glob patterns (that will passed to the globby/minimatch library)\n * @param dir\n */\n patterns: string[];\n\n /**\n * A function to determine if a file was generated by bit.\n * This is useful to check if the config file was generated by bit to prevent delete user's file.\n * @param filePath\n * @returns\n */\n isBitGenerated?: (filePath: string) => boolean;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["config-writer-entry.ts"],"sourcesContent":["import { Environment, ExecutionContext } from '@teambit/envs';\nimport { EnvMapValue } from './workspace-config-files.main.runtime';\nimport { WrittenConfigFile } from './writers';\n\nexport type ConfigFile = {\n /**\n * Name of the config file.\n * supports also using `{hash}` in the name, which will be replaced by the hash of the config file.\n */\n name: string;\n /**\n * Content of the config file.\n * I.E the content of the tsconfig.json file.\n */\n content: string;\n /**\n * Hash of the config file.\n */\n hash?: string;\n};\n\nexport type ExtendingConfigFileAdditionalProp = {\n /**\n * the config file that this config file extends.\n */\n extendingTarget: WrittenConfigFile;\n\n /**\n * When replacing the config file name with the actual path of the config file, use absolute paths.\n */\n useAbsPaths?: boolean;\n};\n\nexport type ExtendingConfigFile = ConfigFile & ExtendingConfigFileAdditionalProp;\n\nexport type PostProcessExtendingConfigFilesArgs = {\n workspaceDir: string;\n configsRootDir: string;\n extendingConfigFile: ExtendingConfigFile;\n /**\n * Paths that the file will be written to.\n */\n paths: string[];\n envMapValue: EnvMapValue;\n /**\n * This is a flag for backward compatibility\n * We used to return string from the post process, so old versions of bit only knows to handle string results\n * while in new version we support getting array of objects\n * we need to know if bit the user is using support the new format or not\n */\n supportSpecificPathChange?: boolean;\n};\n\nexport type GenerateExtendingConfigFilesArgs = {\n workspaceDir: string;\n configsRootDir: string;\n writtenConfigFiles: WrittenConfigFile[];\n envMapValue: EnvMapValue;\n};\n\nexport type PostProcessExtendingConfigFilesOneFile = {\n path: string;\n content: string;\n};\n\nexport type MergeConfigFilesFunc = (configFile: ConfigFile, configFile2: ConfigFile) => string;\nexport interface ConfigWriterEntry {\n /**\n * Id is used for few things:\n * 1. merge/post process different configs files (from different envs) together.\n * 2. filter the config writer by the cli when using --writers flag.\n */\n id: string;\n\n /**\n * Name of the config writer.\n * used for outputs and logging.\n */\n name: string;\n\n /**\n * Get's the component env and return the config file content\n * for example the eslint config to tsconfig.\n * This also enable to return a hash of the config file, which will be used to determine if\n * 2 config files are the same.\n * If the hash is not provided, the content will be used as the hash.\n * This enables the specific config type to ignore specific fields when calculating the\n * hash in order to ignore theses fields when determining if 2 config files are the same.\n * The calc function also get the target directory of the config file (calculated by this aspect) as sometime there\n * is a need to change the config file content based on the target directory.\n * for example, change the includes/excludes paths to be relative to the target directory.\n * The calc can return undefined if the config file is not relevant for the component. or not supported by the subscriber.\n * for example if the component uses babel to compile, then tsconfig is not relevant.\n * @param env\n */\n calcConfigFiles(executionContext: ExecutionContext, env: Environment, dir: string): ConfigFile[] | undefined;\n\n /**\n * Provide a function that knows how to merge 2 config files together.\n * This is used when 2 different envs generate the same config file hash.\n * sometime we want to merge the 2 config files together.\n * @param configFile\n * @param configFile2\n */\n mergeConfigFiles?: MergeConfigFilesFunc;\n\n /**\n * This will be used to generate an extending file content.\n * For example, the tsconfig.json file will extend the real tsconfig.{hash}.json file (that were coming from the env).\n * That way we can avoid writing the same config file multiple times.\n * It also reduces the risk of the user manually change the config file and then the changes will be lost.\n * This function support returning a file with content with a dsl using `{}` to replace the config file name.\n * for example:\n * content = `{\n * \"extends\": {configFile.name},\n * }`\n */\n generateExtendingFile(args: GenerateExtendingConfigFilesArgs): ExtendingConfigFile | undefined;\n\n /**\n * This enables the writer to do some post processing after the extending config files were calculated and deduped.\n * this is important in case when we need to change a config file / extending config file after it was calculated\n * based on all the environments in the ws\n * or based on other config files that were written.\n * @param args\n */\n postProcessExtendingConfigFiles?(\n args: PostProcessExtendingConfigFilesArgs\n ): Promise<string | Array<PostProcessExtendingConfigFilesOneFile> | undefined>;\n\n /**\n * Find all the files that are relevant for the config type.\n * This is used to clean / delete these files\n * This should return an array of glob patterns (that will passed to the globby/minimatch library)\n * @param dir\n */\n patterns: string[];\n\n /**\n * A function to determine if a file was generated by bit.\n * This is useful to check if the config file was generated by bit to prevent delete user's file.\n * @param filePath\n * @returns\n */\n isBitGenerated?: (filePath: string) => boolean;\n}\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
;
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace-config-files@0.0.
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace-config-files@0.0.129/dist/workspace-config-files.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -163,17 +163,40 @@ async function postProcessExtendingConfigFiles(envEntries, envCompsDirsMap, exte
|
|
|
163
163
|
if (!dedupEntry) {
|
|
164
164
|
return undefined;
|
|
165
165
|
}
|
|
166
|
-
const
|
|
166
|
+
const postProcessRes = await postProcessFunc({
|
|
167
167
|
configsRootDir,
|
|
168
168
|
extendingConfigFile: extendingConfigFileEntry.extendingConfigFile,
|
|
169
169
|
envMapValue: envMapVal,
|
|
170
170
|
workspaceDir,
|
|
171
|
-
paths: dedupEntry.paths
|
|
171
|
+
paths: dedupEntry.paths,
|
|
172
|
+
supportSpecificPathChange: true
|
|
172
173
|
});
|
|
173
|
-
if (!
|
|
174
|
+
if (!postProcessRes) {
|
|
174
175
|
return undefined;
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
+
if (typeof postProcessRes === 'string') {
|
|
178
|
+
extendingConfigFileEntry.extendingConfigFile.content = postProcessRes;
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
postProcessRes.forEach(({
|
|
182
|
+
path,
|
|
183
|
+
content
|
|
184
|
+
}) => {
|
|
185
|
+
// Remove it from the current entry
|
|
186
|
+
dedupEntry.paths = dedupEntry.paths.filter(currPath => currPath !== path);
|
|
187
|
+
const newHash = (0, _utils().sha1)(content);
|
|
188
|
+
extendingConfigFilesMap[newHash] = JSON.parse(JSON.stringify(extendingConfigFileEntry));
|
|
189
|
+
extendingConfigFilesMap[newHash].extendingConfigFile.content = content;
|
|
190
|
+
const foundNewHash = fileHashPerDedupedPaths.find(entry => entry.fileHash === newHash);
|
|
191
|
+
if (foundNewHash) {
|
|
192
|
+
foundNewHash.paths.push(path);
|
|
193
|
+
} else {
|
|
194
|
+
fileHashPerDedupedPaths.push({
|
|
195
|
+
fileHash: newHash,
|
|
196
|
+
paths: [path]
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
177
200
|
return undefined;
|
|
178
201
|
});
|
|
179
202
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_normalizePath","data","_interopRequireDefault","require","_stringFormat","_utils","_fsExtra","_path","_pMapSeries","_lodash","_dedupPaths","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","handleExtendingConfigFiles","envEntries","envCompsDirsMap","writtenRealConfigFiles","configsRootDir","workspaceDir","opts","extendingConfigFilesMap","buildExtendingConfigFilesMap","fileHashPerDedupedPaths","dedupePaths","postProcessExtendingConfigFiles","envsWrittenExtendingConfigFiles","writeExtendingConfigFiles","allEnvsCalculatedExtendingConfigFiles","compact","pMapSeries","envConfigFileEntry","envMapVal","envId","writtenConfigFilesForEnv","getEnvOnlyWrittenRealConfigFiles","extendingConfigFile","generateOneExtendingConfigFile","undefined","indexExtendingConfigFiles","values","reduce","acc","envIds","writtenRealConfigFile","includes","writtenConfigFiles","envMapValue","configWriter","executionContext","args","generateExtendingFile","hash","sha1","content","useAbsPaths","multiEnvCalculatedExtendingConfigFiles","mergedConfigFiles","curr","currentValue","postProcessFunc","extendingConfigFileEntry","find","entry","dedupEntry","fileHashPerDedupedPath","fileHash","newContent","paths","finalResult","Promise","all","map","envsConfigFile","configFile","name","format","writtenPaths","path","filePath","join","targetPath","extendingTarget","normalize","relative","dirname","replace","dryRun","fs","outputFile","res","filePaths"],"sources":["extending-config-files.ts"],"sourcesContent":["import normalize from 'normalize-path';\nimport format from 'string-format';\nimport { sha1 } from '@teambit/legacy/dist/utils';\nimport fs from 'fs-extra';\nimport { dirname, join, relative } from 'path';\nimport pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ExtendingConfigFile } from '../config-writer-entry';\nimport { DedupedPaths, dedupePaths } from '../dedup-paths';\nimport {\n EnvCompsDirsMap,\n EnvConfigWriterEntry,\n EnvMapValue,\n WriteConfigFilesOptions,\n} from '../workspace-config-files.main.runtime';\nimport { WrittenConfigFile, WrittenRealConfigFilesByHash } from './real-config-files';\n\ntype EnvCalculatedExtendingConfigFile = {\n envId: string;\n extendingConfigFile: Required<ExtendingConfigFile>;\n};\nexport type WrittenExtendingConfigFile = ExtendingConfigFile & {\n filePaths: string[];\n};\nexport type EnvsWrittenExtendingConfigFile = { envIds: string[]; extendingConfigFile: WrittenExtendingConfigFile };\nexport type EnvsWrittenExtendingConfigFiles = Array<EnvsWrittenExtendingConfigFile>;\nexport type ExtendingConfigFilesMap = {\n [configFileHash: string]: {\n envIds: string[];\n extendingConfigFile: Required<ExtendingConfigFile>;\n };\n};\n\nexport async function handleExtendingConfigFiles(\n envEntries: EnvConfigWriterEntry[],\n envCompsDirsMap: EnvCompsDirsMap,\n writtenRealConfigFiles: WrittenRealConfigFilesByHash,\n configsRootDir: string,\n workspaceDir: string,\n opts: WriteConfigFilesOptions\n): Promise<EnvsWrittenExtendingConfigFiles> {\n const extendingConfigFilesMap = await buildExtendingConfigFilesMap(\n envEntries,\n writtenRealConfigFiles,\n envCompsDirsMap,\n configsRootDir,\n workspaceDir\n );\n const fileHashPerDedupedPaths = dedupePaths(extendingConfigFilesMap, envCompsDirsMap);\n await postProcessExtendingConfigFiles(\n envEntries,\n envCompsDirsMap,\n extendingConfigFilesMap,\n fileHashPerDedupedPaths,\n configsRootDir,\n workspaceDir\n );\n const envsWrittenExtendingConfigFiles = await writeExtendingConfigFiles(\n extendingConfigFilesMap,\n fileHashPerDedupedPaths,\n workspaceDir,\n opts\n );\n return envsWrittenExtendingConfigFiles;\n}\n\nasync function buildExtendingConfigFilesMap(\n envEntries: EnvConfigWriterEntry[],\n writtenRealConfigFiles: WrittenRealConfigFilesByHash,\n envCompsDirsMap: EnvCompsDirsMap,\n configsRootDir: string,\n workspaceDir: string\n): Promise<ExtendingConfigFilesMap> {\n const allEnvsCalculatedExtendingConfigFiles: EnvCalculatedExtendingConfigFile[] = compact(\n await pMapSeries(envEntries, async (envConfigFileEntry) => {\n const envMapVal = envCompsDirsMap[envConfigFileEntry.envId];\n const writtenConfigFilesForEnv: WrittenConfigFile[] = getEnvOnlyWrittenRealConfigFiles(\n envConfigFileEntry.envId,\n writtenRealConfigFiles\n );\n const extendingConfigFile = generateOneExtendingConfigFile(\n writtenConfigFilesForEnv,\n envConfigFileEntry,\n envMapVal,\n configsRootDir,\n workspaceDir\n );\n if (!extendingConfigFile) {\n return undefined;\n }\n return {\n envId: envConfigFileEntry.envId,\n extendingConfigFile,\n };\n })\n );\n const extendingConfigFilesMap: ExtendingConfigFilesMap = indexExtendingConfigFiles(\n allEnvsCalculatedExtendingConfigFiles\n );\n return extendingConfigFilesMap;\n}\n\nfunction getEnvOnlyWrittenRealConfigFiles(\n envId: string,\n writtenRealConfigFiles: WrittenRealConfigFilesByHash\n): WrittenConfigFile[] {\n return Object.values(writtenRealConfigFiles).reduce((acc, { envIds, writtenRealConfigFile }) => {\n if (envIds.includes(envId)) {\n acc.push(writtenRealConfigFile);\n }\n return acc;\n }, [] as WrittenConfigFile[]);\n}\n\nfunction generateOneExtendingConfigFile(\n writtenConfigFiles: WrittenConfigFile[],\n envConfigFileEntry: EnvConfigWriterEntry,\n envMapValue: EnvMapValue,\n configsRootDir: string,\n workspaceDir: string\n): Required<ExtendingConfigFile> | undefined {\n const { configWriter, executionContext } = envConfigFileEntry;\n const args = {\n workspaceDir,\n configsRootDir,\n writtenConfigFiles,\n executionContext,\n envMapValue,\n };\n const extendingConfigFile = configWriter.generateExtendingFile(args);\n if (!extendingConfigFile) return undefined;\n const hash = extendingConfigFile.hash || sha1(extendingConfigFile.content);\n return {\n ...extendingConfigFile,\n useAbsPaths: !!extendingConfigFile.useAbsPaths,\n hash,\n };\n}\n\nfunction indexExtendingConfigFiles(\n multiEnvCalculatedExtendingConfigFiles: EnvCalculatedExtendingConfigFile[]\n): ExtendingConfigFilesMap {\n const mergedConfigFiles = multiEnvCalculatedExtendingConfigFiles.reduce(\n (acc, curr: EnvCalculatedExtendingConfigFile) => {\n const extendingConfigFile = curr.extendingConfigFile;\n const currentValue = acc[extendingConfigFile.hash];\n if (currentValue) {\n currentValue.envIds.push(curr.envId);\n } else {\n acc[extendingConfigFile.hash] = { envIds: [curr.envId], extendingConfigFile };\n }\n return acc;\n },\n {}\n );\n return mergedConfigFiles;\n}\n\nasync function postProcessExtendingConfigFiles(\n envEntries: EnvConfigWriterEntry[],\n envCompsDirsMap: EnvCompsDirsMap,\n extendingConfigFilesMap: ExtendingConfigFilesMap,\n fileHashPerDedupedPaths: DedupedPaths,\n configsRootDir: string,\n workspaceDir: string\n) {\n await pMapSeries(envEntries, async (envConfigFileEntry) => {\n const postProcessFunc = envConfigFileEntry.configWriter.postProcessExtendingConfigFiles;\n if (!postProcessFunc) {\n return undefined;\n }\n const envMapVal = envCompsDirsMap[envConfigFileEntry.envId];\n const extendingConfigFileEntry = Object.values(extendingConfigFilesMap).find((entry) => {\n return entry.envIds.includes(envConfigFileEntry.envId);\n });\n if (!extendingConfigFileEntry) {\n return undefined;\n }\n const dedupEntry = fileHashPerDedupedPaths.find((fileHashPerDedupedPath) => {\n return fileHashPerDedupedPath.fileHash === extendingConfigFileEntry.extendingConfigFile.hash;\n });\n if (!dedupEntry) {\n return undefined;\n }\n\n const newContent = await postProcessFunc({\n configsRootDir,\n extendingConfigFile: extendingConfigFileEntry.extendingConfigFile,\n envMapValue: envMapVal,\n workspaceDir,\n paths: dedupEntry.paths,\n });\n if (!newContent) {\n return undefined;\n }\n extendingConfigFileEntry.extendingConfigFile.content = newContent;\n return undefined;\n });\n}\n\nasync function writeExtendingConfigFiles(\n extendingConfigFilesMap: ExtendingConfigFilesMap,\n fileHashPerDedupedPaths: DedupedPaths,\n workspaceDir: string,\n opts: WriteConfigFilesOptions\n): Promise<EnvsWrittenExtendingConfigFiles> {\n const finalResult: EnvsWrittenExtendingConfigFiles = await Promise.all(\n fileHashPerDedupedPaths.map(async ({ fileHash, paths }) => {\n const envsConfigFile = extendingConfigFilesMap[fileHash];\n const configFile = envsConfigFile.extendingConfigFile;\n const hash = configFile.hash || sha1(configFile.content);\n const name = format(configFile.name, { hash });\n const writtenPaths = await Promise.all(\n paths.map(async (path) => {\n const filePath = join(workspaceDir, path, name);\n const targetPath = configFile.useAbsPaths\n ? configFile.extendingTarget.filePath\n : normalize(`./${relative(dirname(filePath), configFile.extendingTarget.filePath)}`);\n const content = configFile.content.replace(`{${configFile.extendingTarget.name}}`, targetPath);\n if (!opts.dryRun) {\n await fs.outputFile(filePath, content);\n }\n return filePath;\n })\n );\n const res: EnvsWrittenExtendingConfigFile = {\n envIds: envsConfigFile.envIds,\n extendingConfigFile: {\n name,\n hash,\n content: configFile.content,\n extendingTarget: configFile.extendingTarget,\n filePaths: writtenPaths,\n },\n };\n return res;\n })\n );\n return finalResult;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GA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AU,CAACC,IAAI,EAAE;MAAEvB;IAAK,CAAC,CAAC;IAC9C,MAAMyB,YAAY,GAAG,MAAMP,OAAO,CAACC,GAAG,CACpCH,KAAK,CAACI,GAAG,CAAC,MAAOM,IAAI,IAAK;MACxB,MAAMC,QAAQ,GAAG,IAAAC,YAAI,EAAC7D,YAAY,EAAE2D,IAAI,EAAEH,IAAI,CAAC;MAC/C,MAAMM,UAAU,GAAGP,UAAU,CAACnB,WAAW,GACrCmB,UAAU,CAACQ,eAAe,CAACH,QAAQ,GACnC,IAAAI,wBAAS,EAAE,KAAI,IAAAC,gBAAQ,EAAC,IAAAC,eAAO,EAACN,QAAQ,CAAC,EAAEL,UAAU,CAACQ,eAAe,CAACH,QAAQ,CAAE,EAAC,CAAC;MACtF,MAAMzB,OAAO,GAAGoB,UAAU,CAACpB,OAAO,CAACgC,OAAO,CAAE,IAAGZ,UAAU,CAACQ,eAAe,CAACP,IAAK,GAAE,EAAEM,UAAU,CAAC;MAC9F,IAAI,CAAC7D,IAAI,CAACmE,MAAM,EAAE;QAChB,MAAMC,kBAAE,CAACC,UAAU,CAACV,QAAQ,EAAEzB,OAAO,CAAC;MACxC;MACA,OAAOyB,QAAQ;IACjB,CAAC,CACH,CAAC;IACD,MAAMW,GAAmC,GAAG;MAC1C/C,MAAM,EAAE8B,cAAc,CAAC9B,MAAM;MAC7BP,mBAAmB,EAAE;QACnBuC,IAAI;QACJvB,IAAI;QACJE,OAAO,EAAEoB,UAAU,CAACpB,OAAO;QAC3B4B,eAAe,EAAER,UAAU,CAACQ,eAAe;QAC3CS,SAAS,EAAEd;MACb;IACF,CAAC;IACD,OAAOa,GAAG;EACZ,CAAC,CACH,CAAC;EACD,OAAOrB,WAAW;AACpB"}
|
|
1
|
+
{"version":3,"names":["_normalizePath","data","_interopRequireDefault","require","_stringFormat","_utils","_fsExtra","_path","_pMapSeries","_lodash","_dedupPaths","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","handleExtendingConfigFiles","envEntries","envCompsDirsMap","writtenRealConfigFiles","configsRootDir","workspaceDir","opts","extendingConfigFilesMap","buildExtendingConfigFilesMap","fileHashPerDedupedPaths","dedupePaths","postProcessExtendingConfigFiles","envsWrittenExtendingConfigFiles","writeExtendingConfigFiles","allEnvsCalculatedExtendingConfigFiles","compact","pMapSeries","envConfigFileEntry","envMapVal","envId","writtenConfigFilesForEnv","getEnvOnlyWrittenRealConfigFiles","extendingConfigFile","generateOneExtendingConfigFile","undefined","indexExtendingConfigFiles","values","reduce","acc","envIds","writtenRealConfigFile","includes","writtenConfigFiles","envMapValue","configWriter","executionContext","args","generateExtendingFile","hash","sha1","content","useAbsPaths","multiEnvCalculatedExtendingConfigFiles","mergedConfigFiles","curr","currentValue","postProcessFunc","extendingConfigFileEntry","find","entry","dedupEntry","fileHashPerDedupedPath","fileHash","postProcessRes","paths","supportSpecificPathChange","path","currPath","newHash","JSON","parse","stringify","foundNewHash","finalResult","Promise","all","map","envsConfigFile","configFile","name","format","writtenPaths","filePath","join","targetPath","extendingTarget","normalize","relative","dirname","replace","dryRun","fs","outputFile","res","filePaths"],"sources":["extending-config-files.ts"],"sourcesContent":["import normalize from 'normalize-path';\nimport format from 'string-format';\nimport { sha1 } from '@teambit/legacy/dist/utils';\nimport fs from 'fs-extra';\nimport { dirname, join, relative } from 'path';\nimport pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ExtendingConfigFile } from '../config-writer-entry';\nimport { DedupedPaths, dedupePaths } from '../dedup-paths';\nimport {\n EnvCompsDirsMap,\n EnvConfigWriterEntry,\n EnvMapValue,\n WriteConfigFilesOptions,\n} from '../workspace-config-files.main.runtime';\nimport { WrittenConfigFile, WrittenRealConfigFilesByHash } from './real-config-files';\n\ntype EnvCalculatedExtendingConfigFile = {\n envId: string;\n extendingConfigFile: Required<ExtendingConfigFile>;\n};\nexport type WrittenExtendingConfigFile = ExtendingConfigFile & {\n filePaths: string[];\n};\nexport type EnvsWrittenExtendingConfigFile = { envIds: string[]; extendingConfigFile: WrittenExtendingConfigFile };\nexport type EnvsWrittenExtendingConfigFiles = Array<EnvsWrittenExtendingConfigFile>;\nexport type ExtendingConfigFilesMap = {\n [configFileHash: string]: {\n envIds: string[];\n extendingConfigFile: Required<ExtendingConfigFile>;\n };\n};\n\nexport async function handleExtendingConfigFiles(\n envEntries: EnvConfigWriterEntry[],\n envCompsDirsMap: EnvCompsDirsMap,\n writtenRealConfigFiles: WrittenRealConfigFilesByHash,\n configsRootDir: string,\n workspaceDir: string,\n opts: WriteConfigFilesOptions\n): Promise<EnvsWrittenExtendingConfigFiles> {\n const extendingConfigFilesMap = await buildExtendingConfigFilesMap(\n envEntries,\n writtenRealConfigFiles,\n envCompsDirsMap,\n configsRootDir,\n workspaceDir\n );\n const fileHashPerDedupedPaths = dedupePaths(extendingConfigFilesMap, envCompsDirsMap);\n await postProcessExtendingConfigFiles(\n envEntries,\n envCompsDirsMap,\n extendingConfigFilesMap,\n fileHashPerDedupedPaths,\n configsRootDir,\n workspaceDir\n );\n const envsWrittenExtendingConfigFiles = await writeExtendingConfigFiles(\n extendingConfigFilesMap,\n fileHashPerDedupedPaths,\n workspaceDir,\n opts\n );\n return envsWrittenExtendingConfigFiles;\n}\n\nasync function buildExtendingConfigFilesMap(\n envEntries: EnvConfigWriterEntry[],\n writtenRealConfigFiles: WrittenRealConfigFilesByHash,\n envCompsDirsMap: EnvCompsDirsMap,\n configsRootDir: string,\n workspaceDir: string\n): Promise<ExtendingConfigFilesMap> {\n const allEnvsCalculatedExtendingConfigFiles: EnvCalculatedExtendingConfigFile[] = compact(\n await pMapSeries(envEntries, async (envConfigFileEntry) => {\n const envMapVal = envCompsDirsMap[envConfigFileEntry.envId];\n const writtenConfigFilesForEnv: WrittenConfigFile[] = getEnvOnlyWrittenRealConfigFiles(\n envConfigFileEntry.envId,\n writtenRealConfigFiles\n );\n const extendingConfigFile = generateOneExtendingConfigFile(\n writtenConfigFilesForEnv,\n envConfigFileEntry,\n envMapVal,\n configsRootDir,\n workspaceDir\n );\n if (!extendingConfigFile) {\n return undefined;\n }\n return {\n envId: envConfigFileEntry.envId,\n extendingConfigFile,\n };\n })\n );\n const extendingConfigFilesMap: ExtendingConfigFilesMap = indexExtendingConfigFiles(\n allEnvsCalculatedExtendingConfigFiles\n );\n return extendingConfigFilesMap;\n}\n\nfunction getEnvOnlyWrittenRealConfigFiles(\n envId: string,\n writtenRealConfigFiles: WrittenRealConfigFilesByHash\n): WrittenConfigFile[] {\n return Object.values(writtenRealConfigFiles).reduce((acc, { envIds, writtenRealConfigFile }) => {\n if (envIds.includes(envId)) {\n acc.push(writtenRealConfigFile);\n }\n return acc;\n }, [] as WrittenConfigFile[]);\n}\n\nfunction generateOneExtendingConfigFile(\n writtenConfigFiles: WrittenConfigFile[],\n envConfigFileEntry: EnvConfigWriterEntry,\n envMapValue: EnvMapValue,\n configsRootDir: string,\n workspaceDir: string\n): Required<ExtendingConfigFile> | undefined {\n const { configWriter, executionContext } = envConfigFileEntry;\n const args = {\n workspaceDir,\n configsRootDir,\n writtenConfigFiles,\n executionContext,\n envMapValue,\n };\n const extendingConfigFile = configWriter.generateExtendingFile(args);\n if (!extendingConfigFile) return undefined;\n const hash = extendingConfigFile.hash || sha1(extendingConfigFile.content);\n return {\n ...extendingConfigFile,\n useAbsPaths: !!extendingConfigFile.useAbsPaths,\n hash,\n };\n}\n\nfunction indexExtendingConfigFiles(\n multiEnvCalculatedExtendingConfigFiles: EnvCalculatedExtendingConfigFile[]\n): ExtendingConfigFilesMap {\n const mergedConfigFiles = multiEnvCalculatedExtendingConfigFiles.reduce(\n (acc, curr: EnvCalculatedExtendingConfigFile) => {\n const extendingConfigFile = curr.extendingConfigFile;\n const currentValue = acc[extendingConfigFile.hash];\n if (currentValue) {\n currentValue.envIds.push(curr.envId);\n } else {\n acc[extendingConfigFile.hash] = { envIds: [curr.envId], extendingConfigFile };\n }\n return acc;\n },\n {}\n );\n return mergedConfigFiles;\n}\n\nasync function postProcessExtendingConfigFiles(\n envEntries: EnvConfigWriterEntry[],\n envCompsDirsMap: EnvCompsDirsMap,\n extendingConfigFilesMap: ExtendingConfigFilesMap,\n fileHashPerDedupedPaths: DedupedPaths,\n configsRootDir: string,\n workspaceDir: string\n) {\n await pMapSeries(envEntries, async (envConfigFileEntry) => {\n const postProcessFunc = envConfigFileEntry.configWriter.postProcessExtendingConfigFiles;\n if (!postProcessFunc) {\n return undefined;\n }\n const envMapVal = envCompsDirsMap[envConfigFileEntry.envId];\n const extendingConfigFileEntry = Object.values(extendingConfigFilesMap).find((entry) => {\n return entry.envIds.includes(envConfigFileEntry.envId);\n });\n if (!extendingConfigFileEntry) {\n return undefined;\n }\n const dedupEntry = fileHashPerDedupedPaths.find((fileHashPerDedupedPath) => {\n return fileHashPerDedupedPath.fileHash === extendingConfigFileEntry.extendingConfigFile.hash;\n });\n if (!dedupEntry) {\n return undefined;\n }\n\n const postProcessRes = await postProcessFunc({\n configsRootDir,\n extendingConfigFile: extendingConfigFileEntry.extendingConfigFile,\n envMapValue: envMapVal,\n workspaceDir,\n paths: dedupEntry.paths,\n supportSpecificPathChange: true,\n });\n if (!postProcessRes) {\n return undefined;\n }\n if (typeof postProcessRes === 'string') {\n extendingConfigFileEntry.extendingConfigFile.content = postProcessRes;\n return undefined;\n }\n postProcessRes.forEach(({ path, content }) => {\n // Remove it from the current entry\n dedupEntry.paths = dedupEntry.paths.filter((currPath) => currPath !== path);\n const newHash = sha1(content);\n extendingConfigFilesMap[newHash] = JSON.parse(JSON.stringify(extendingConfigFileEntry));\n extendingConfigFilesMap[newHash].extendingConfigFile.content = content;\n const foundNewHash = fileHashPerDedupedPaths.find((entry) => entry.fileHash === newHash);\n if (foundNewHash) {\n foundNewHash.paths.push(path);\n } else {\n fileHashPerDedupedPaths.push({ fileHash: newHash, paths: [path] });\n }\n });\n return undefined;\n });\n}\n\nasync function writeExtendingConfigFiles(\n extendingConfigFilesMap: ExtendingConfigFilesMap,\n fileHashPerDedupedPaths: DedupedPaths,\n workspaceDir: string,\n opts: WriteConfigFilesOptions\n): Promise<EnvsWrittenExtendingConfigFiles> {\n const finalResult: EnvsWrittenExtendingConfigFiles = await Promise.all(\n fileHashPerDedupedPaths.map(async ({ fileHash, paths }) => {\n const envsConfigFile = extendingConfigFilesMap[fileHash];\n const configFile = envsConfigFile.extendingConfigFile;\n const hash = configFile.hash || sha1(configFile.content);\n const name = format(configFile.name, { hash });\n const writtenPaths = await Promise.all(\n paths.map(async (path) => {\n const filePath = join(workspaceDir, path, name);\n const targetPath = configFile.useAbsPaths\n ? configFile.extendingTarget.filePath\n : normalize(`./${relative(dirname(filePath), configFile.extendingTarget.filePath)}`);\n const content = configFile.content.replace(`{${configFile.extendingTarget.name}}`, targetPath);\n if (!opts.dryRun) {\n await fs.outputFile(filePath, content);\n }\n return filePath;\n })\n );\n const res: EnvsWrittenExtendingConfigFile = {\n envIds: envsConfigFile.envIds,\n extendingConfigFile: {\n name,\n hash,\n content: configFile.content,\n extendingTarget: configFile.extendingTarget,\n filePaths: writtenPaths,\n },\n };\n return res;\n })\n );\n return finalResult;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA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2B,UAAU,CAACO,eAAe,CAACH,QAAQ,GACnC,IAAAI,wBAAS,EAAE,KAAI,IAAAC,gBAAQ,EAAC,IAAAC,eAAO,EAACN,QAAQ,CAAC,EAAEJ,UAAU,CAACO,eAAe,CAACH,QAAQ,CAAE,EAAC,CAAC;MACtF,MAAMhC,OAAO,GAAG4B,UAAU,CAAC5B,OAAO,CAACuC,OAAO,CAAE,IAAGX,UAAU,CAACO,eAAe,CAACN,IAAK,GAAE,EAAEK,UAAU,CAAC;MAC9F,IAAI,CAACpE,IAAI,CAAC0E,MAAM,EAAE;QAChB,MAAMC,kBAAE,CAACC,UAAU,CAACV,QAAQ,EAAEhC,OAAO,CAAC;MACxC;MACA,OAAOgC,QAAQ;IACjB,CAAC,CACH,CAAC;IACD,MAAMW,GAAmC,GAAG;MAC1CtD,MAAM,EAAEsC,cAAc,CAACtC,MAAM;MAC7BP,mBAAmB,EAAE;QACnB+C,IAAI;QACJ/B,IAAI;QACJE,OAAO,EAAE4B,UAAU,CAAC5B,OAAO;QAC3BmC,eAAe,EAAEP,UAAU,CAACO,eAAe;QAC3CS,SAAS,EAAEb;MACb;IACF,CAAC;IACD,OAAOY,GAAG;EACZ,CAAC,CACH,CAAC;EACD,OAAOpB,WAAW;AACpB"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/workspace-config-files",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.129",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/workspace/workspace-config-files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "workspace-config-files",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.129"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"core-js": "^3.0.0",
|
|
21
21
|
"@babel/runtime": "7.20.0",
|
|
22
22
|
"@teambit/harmony": "0.4.6",
|
|
23
|
-
"@teambit/envs": "0.0.
|
|
24
|
-
"@teambit/cli": "0.0.
|
|
25
|
-
"@teambit/logger": "0.0.
|
|
26
|
-
"@teambit/workspace": "0.0.
|
|
23
|
+
"@teambit/envs": "0.0.1149",
|
|
24
|
+
"@teambit/cli": "0.0.768",
|
|
25
|
+
"@teambit/logger": "0.0.861",
|
|
26
|
+
"@teambit/workspace": "0.0.1149",
|
|
27
27
|
"@teambit/bit-error": "0.0.402"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@teambit/legacy": "1.0.
|
|
43
|
+
"@teambit/legacy": "1.0.553",
|
|
44
44
|
"react": "^16.8.0 || ^17.0.0",
|
|
45
45
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
46
46
|
},
|
|
@@ -183,17 +183,34 @@ async function postProcessExtendingConfigFiles(
|
|
|
183
183
|
return undefined;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
const
|
|
186
|
+
const postProcessRes = await postProcessFunc({
|
|
187
187
|
configsRootDir,
|
|
188
188
|
extendingConfigFile: extendingConfigFileEntry.extendingConfigFile,
|
|
189
189
|
envMapValue: envMapVal,
|
|
190
190
|
workspaceDir,
|
|
191
191
|
paths: dedupEntry.paths,
|
|
192
|
+
supportSpecificPathChange: true,
|
|
192
193
|
});
|
|
193
|
-
if (!
|
|
194
|
+
if (!postProcessRes) {
|
|
194
195
|
return undefined;
|
|
195
196
|
}
|
|
196
|
-
|
|
197
|
+
if (typeof postProcessRes === 'string') {
|
|
198
|
+
extendingConfigFileEntry.extendingConfigFile.content = postProcessRes;
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
postProcessRes.forEach(({ path, content }) => {
|
|
202
|
+
// Remove it from the current entry
|
|
203
|
+
dedupEntry.paths = dedupEntry.paths.filter((currPath) => currPath !== path);
|
|
204
|
+
const newHash = sha1(content);
|
|
205
|
+
extendingConfigFilesMap[newHash] = JSON.parse(JSON.stringify(extendingConfigFileEntry));
|
|
206
|
+
extendingConfigFilesMap[newHash].extendingConfigFile.content = content;
|
|
207
|
+
const foundNewHash = fileHashPerDedupedPaths.find((entry) => entry.fileHash === newHash);
|
|
208
|
+
if (foundNewHash) {
|
|
209
|
+
foundNewHash.paths.push(path);
|
|
210
|
+
} else {
|
|
211
|
+
fileHashPerDedupedPaths.push({ fileHash: newHash, paths: [path] });
|
|
212
|
+
}
|
|
213
|
+
});
|
|
197
214
|
return undefined;
|
|
198
215
|
});
|
|
199
216
|
}
|