@teambit/typescript 0.0.872 → 0.0.874

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.
@@ -4,6 +4,8 @@ import { Command, CommandOptions } from '@teambit/cli';
4
4
  import chalk from 'chalk';
5
5
  import { TypescriptMain } from '../typescript.main.runtime';
6
6
 
7
+ type Flags = { dryRun?: boolean; noDedupe?: boolean; dryRunWithTsconfig?: boolean; clean?: boolean; silent?: boolean };
8
+
7
9
  export default class WriteTsconfigCmd implements Command {
8
10
  name = 'write-tsconfig';
9
11
  description = 'EXPERIMENTAL. write tsconfig.json files in the component directories';
@@ -14,49 +16,58 @@ export default class WriteTsconfigCmd implements Command {
14
16
  ['s', 'silent', 'do not prompt for confirmation'],
15
17
  ['', 'no-dedupe', "write tsconfig.json inside each one of the component's dir, avoid deduping"],
16
18
  ['', 'dry-run', 'show the paths that tsconfig will be written per env'],
17
- ['', 'dry-run-with-tsconfig', 'show the tsconfig.json content and the paths it will be written per env'],
19
+ [
20
+ '',
21
+ 'dry-run-with-tsconfig',
22
+ 'use with --json flag. show the tsconfig.json content and the paths it will be written per env',
23
+ ],
24
+ ['j', 'json', 'json format'],
18
25
  ] as CommandOptions;
19
26
 
20
27
  constructor(private tsMain: TypescriptMain) {}
21
28
 
22
- async report(
23
- _args,
24
- {
25
- clean,
26
- silent,
27
- dryRun,
28
- noDedupe,
29
- dryRunWithTsconfig,
30
- }: { dryRun?: boolean; noDedupe?: boolean; dryRunWithTsconfig?: boolean; clean?: boolean; silent?: boolean }
31
- ) {
32
- const { writeResults, cleanResults } = await this.tsMain.writeTsconfigJson({
33
- clean,
34
- dedupe: !noDedupe,
35
- dryRun: dryRun || dryRunWithTsconfig,
36
- dryRunWithTsconfig,
37
- silent,
38
- });
29
+ async report(_args, flags: Flags) {
30
+ const { cleanResults, writeResults } = await this.json(_args, flags);
31
+ if (flags.dryRunWithTsconfig) {
32
+ throw new Error(`use --json flag along with --dry-run-with-tsconfig`);
33
+ }
34
+ const isDryRun = flags.dryRun;
39
35
  const cleanResultsOutput = cleanResults
40
- ? `${chalk.green(`the following paths were deleted`)}\n${cleanResults.join('\n')}\n\n`
36
+ ? `${chalk.green(`the following paths ${isDryRun ? 'will be' : 'were'} deleted`)}\n${cleanResults.join('\n')}\n\n`
41
37
  : '';
42
- if (dryRunWithTsconfig) {
43
- return JSON.stringify(writeResults, undefined, 2);
44
- }
45
- if (dryRun) {
46
- const withoutTsconfig = writeResults.map((s) => omit(s, ['tsconfig']));
47
- return JSON.stringify(withoutTsconfig, undefined, 2);
48
- }
38
+
49
39
  const totalFiles = writeResults.map((r) => r.paths.length).reduce((acc, current) => acc + current);
50
- const writeTitle = chalk.green(`${totalFiles} files have been written successfully`);
40
+ const writeTitle = isDryRun
41
+ ? chalk.green(`${totalFiles} files will be written`)
42
+ : chalk.green(`${totalFiles} files have been written successfully`);
51
43
  const writeOutput = writeResults
52
44
  .map((result) => {
53
45
  const paths = result.paths
54
46
  .map((p) => path.join(p, 'tsconfig.json'))
55
47
  .map((str) => ` ${str}`)
56
48
  .join('\n');
57
- return `The following paths were written according to env ${chalk.bold(result.envId)}\n${paths}`;
49
+ return `The following paths are according to env(s) ${chalk.bold(result.envIds.join(', '))}\n${paths}`;
58
50
  })
59
51
  .join('\n\n');
60
52
  return `${cleanResultsOutput}${writeTitle}\n${writeOutput}`;
61
53
  }
54
+
55
+ async json(_args, flags: Flags) {
56
+ const { clean, silent, noDedupe, dryRunWithTsconfig } = flags;
57
+ const dryRun = dryRunWithTsconfig ? true : flags.dryRun;
58
+ const { cleanResults, writeResults } = await this.tsMain.writeTsconfigJson({
59
+ clean,
60
+ dedupe: !noDedupe,
61
+ dryRun,
62
+ dryRunWithTsconfig,
63
+ silent,
64
+ });
65
+
66
+ if (dryRun) {
67
+ const writeJson = dryRunWithTsconfig ? writeResults : writeResults.map((s) => omit(s, ['tsconfig']));
68
+ // return JSON.stringify({ cleanResults, writeResults: writeJson }, undefined, 2);
69
+ return { cleanResults, writeResults: writeJson };
70
+ }
71
+ return { cleanResults, writeResults };
72
+ }
62
73
  }
@@ -1,5 +1,13 @@
1
+ /// <reference types="lodash" />
1
2
  import { Command, CommandOptions } from '@teambit/cli';
2
3
  import { TypescriptMain } from '../typescript.main.runtime';
4
+ declare type Flags = {
5
+ dryRun?: boolean;
6
+ noDedupe?: boolean;
7
+ dryRunWithTsconfig?: boolean;
8
+ clean?: boolean;
9
+ silent?: boolean;
10
+ };
3
11
  export default class WriteTsconfigCmd implements Command {
4
12
  private tsMain;
5
13
  name: string;
@@ -8,11 +16,10 @@ export default class WriteTsconfigCmd implements Command {
8
16
  group: string;
9
17
  options: CommandOptions;
10
18
  constructor(tsMain: TypescriptMain);
11
- report(_args: any, { clean, silent, dryRun, noDedupe, dryRunWithTsconfig, }: {
12
- dryRun?: boolean;
13
- noDedupe?: boolean;
14
- dryRunWithTsconfig?: boolean;
15
- clean?: boolean;
16
- silent?: boolean;
17
- }): Promise<string>;
19
+ report(_args: any, flags: Flags): Promise<string>;
20
+ json(_args: any, flags: Flags): Promise<{
21
+ cleanResults: string[] | undefined;
22
+ writeResults: import("lodash").Omit<import("../tsconfig-writer").TsconfigPathsPerEnv, "tsconfig">[];
23
+ }>;
18
24
  }
25
+ export {};
@@ -56,46 +56,62 @@ class WriteTsconfigCmd {
56
56
  (0, _defineProperty2().default)(this, "description", 'EXPERIMENTAL. write tsconfig.json files in the component directories');
57
57
  (0, _defineProperty2().default)(this, "alias", '');
58
58
  (0, _defineProperty2().default)(this, "group", 'development');
59
- (0, _defineProperty2().default)(this, "options", [['c', 'clean', 'delete tsconfig files from the workspace. highly recommended to run it with "--dry-run" first'], ['s', 'silent', 'do not prompt for confirmation'], ['', 'no-dedupe', "write tsconfig.json inside each one of the component's dir, avoid deduping"], ['', 'dry-run', 'show the paths that tsconfig will be written per env'], ['', 'dry-run-with-tsconfig', 'show the tsconfig.json content and the paths it will be written per env']]);
59
+ (0, _defineProperty2().default)(this, "options", [['c', 'clean', 'delete tsconfig files from the workspace. highly recommended to run it with "--dry-run" first'], ['s', 'silent', 'do not prompt for confirmation'], ['', 'no-dedupe', "write tsconfig.json inside each one of the component's dir, avoid deduping"], ['', 'dry-run', 'show the paths that tsconfig will be written per env'], ['', 'dry-run-with-tsconfig', 'use with --json flag. show the tsconfig.json content and the paths it will be written per env'], ['j', 'json', 'json format']]);
60
60
  }
61
61
 
62
- async report(_args, {
63
- clean,
64
- silent,
65
- dryRun,
66
- noDedupe,
67
- dryRunWithTsconfig
68
- }) {
62
+ async report(_args, flags) {
69
63
  const {
70
- writeResults,
71
- cleanResults
64
+ cleanResults,
65
+ writeResults
66
+ } = await this.json(_args, flags);
67
+
68
+ if (flags.dryRunWithTsconfig) {
69
+ throw new Error(`use --json flag along with --dry-run-with-tsconfig`);
70
+ }
71
+
72
+ const isDryRun = flags.dryRun;
73
+ const cleanResultsOutput = cleanResults ? `${_chalk().default.green(`the following paths ${isDryRun ? 'will be' : 'were'} deleted`)}\n${cleanResults.join('\n')}\n\n` : '';
74
+ const totalFiles = writeResults.map(r => r.paths.length).reduce((acc, current) => acc + current);
75
+ const writeTitle = isDryRun ? _chalk().default.green(`${totalFiles} files will be written`) : _chalk().default.green(`${totalFiles} files have been written successfully`);
76
+ const writeOutput = writeResults.map(result => {
77
+ const paths = result.paths.map(p => _path().default.join(p, 'tsconfig.json')).map(str => ` ${str}`).join('\n');
78
+ return `The following paths are according to env(s) ${_chalk().default.bold(result.envIds.join(', '))}\n${paths}`;
79
+ }).join('\n\n');
80
+ return `${cleanResultsOutput}${writeTitle}\n${writeOutput}`;
81
+ }
82
+
83
+ async json(_args, flags) {
84
+ const {
85
+ clean,
86
+ silent,
87
+ noDedupe,
88
+ dryRunWithTsconfig
89
+ } = flags;
90
+ const dryRun = dryRunWithTsconfig ? true : flags.dryRun;
91
+ const {
92
+ cleanResults,
93
+ writeResults
72
94
  } = await this.tsMain.writeTsconfigJson({
73
95
  clean,
74
96
  dedupe: !noDedupe,
75
- dryRun: dryRun || dryRunWithTsconfig,
97
+ dryRun,
76
98
  dryRunWithTsconfig,
77
99
  silent
78
100
  });
79
- const cleanResultsOutput = cleanResults ? `${_chalk().default.green(`the following paths were deleted`)}\n${cleanResults.join('\n')}\n\n` : '';
80
-
81
- if (dryRunWithTsconfig) {
82
- return JSON.stringify(writeResults, undefined, 2);
83
- }
84
101
 
85
102
  if (dryRun) {
86
- const withoutTsconfig = writeResults.map(s => (0, _lodash().omit)(s, ['tsconfig']));
87
- return JSON.stringify(withoutTsconfig, undefined, 2);
88
- }
89
-
90
- const totalFiles = writeResults.map(r => r.paths.length).reduce((acc, current) => acc + current);
103
+ const writeJson = dryRunWithTsconfig ? writeResults : writeResults.map(s => (0, _lodash().omit)(s, ['tsconfig'])); // return JSON.stringify({ cleanResults, writeResults: writeJson }, undefined, 2);
91
104
 
92
- const writeTitle = _chalk().default.green(`${totalFiles} files have been written successfully`);
105
+ return {
106
+ cleanResults,
107
+ writeResults: writeJson
108
+ };
109
+ }
93
110
 
94
- const writeOutput = writeResults.map(result => {
95
- const paths = result.paths.map(p => _path().default.join(p, 'tsconfig.json')).map(str => ` ${str}`).join('\n');
96
- return `The following paths were written according to env ${_chalk().default.bold(result.envId)}\n${paths}`;
97
- }).join('\n\n');
98
- return `${cleanResultsOutput}${writeTitle}\n${writeOutput}`;
111
+ return {
112
+ cleanResults,
113
+ writeResults
114
+ };
99
115
  }
100
116
 
101
117
  }
@@ -1 +1 @@
1
- {"version":3,"names":["WriteTsconfigCmd","constructor","tsMain","report","_args","clean","silent","dryRun","noDedupe","dryRunWithTsconfig","writeResults","cleanResults","writeTsconfigJson","dedupe","cleanResultsOutput","chalk","green","join","JSON","stringify","undefined","withoutTsconfig","map","s","omit","totalFiles","r","paths","length","reduce","acc","current","writeTitle","writeOutput","result","p","path","str","bold","envId"],"sources":["write-tsconfig.cmd.ts"],"sourcesContent":["import path from 'path';\nimport { omit } from 'lodash';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { TypescriptMain } from '../typescript.main.runtime';\n\nexport default class WriteTsconfigCmd implements Command {\n name = 'write-tsconfig';\n description = 'EXPERIMENTAL. write tsconfig.json files in the component directories';\n alias = '';\n group = 'development';\n options = [\n ['c', 'clean', 'delete tsconfig files from the workspace. highly recommended to run it with \"--dry-run\" first'],\n ['s', 'silent', 'do not prompt for confirmation'],\n ['', 'no-dedupe', \"write tsconfig.json inside each one of the component's dir, avoid deduping\"],\n ['', 'dry-run', 'show the paths that tsconfig will be written per env'],\n ['', 'dry-run-with-tsconfig', 'show the tsconfig.json content and the paths it will be written per env'],\n ] as CommandOptions;\n\n constructor(private tsMain: TypescriptMain) {}\n\n async report(\n _args,\n {\n clean,\n silent,\n dryRun,\n noDedupe,\n dryRunWithTsconfig,\n }: { dryRun?: boolean; noDedupe?: boolean; dryRunWithTsconfig?: boolean; clean?: boolean; silent?: boolean }\n ) {\n const { writeResults, cleanResults } = await this.tsMain.writeTsconfigJson({\n clean,\n dedupe: !noDedupe,\n dryRun: dryRun || dryRunWithTsconfig,\n dryRunWithTsconfig,\n silent,\n });\n const cleanResultsOutput = cleanResults\n ? `${chalk.green(`the following paths were deleted`)}\\n${cleanResults.join('\\n')}\\n\\n`\n : '';\n if (dryRunWithTsconfig) {\n return JSON.stringify(writeResults, undefined, 2);\n }\n if (dryRun) {\n const withoutTsconfig = writeResults.map((s) => omit(s, ['tsconfig']));\n return JSON.stringify(withoutTsconfig, undefined, 2);\n }\n const totalFiles = writeResults.map((r) => r.paths.length).reduce((acc, current) => acc + current);\n const writeTitle = chalk.green(`${totalFiles} files have been written successfully`);\n const writeOutput = writeResults\n .map((result) => {\n const paths = result.paths\n .map((p) => path.join(p, 'tsconfig.json'))\n .map((str) => ` ${str}`)\n .join('\\n');\n return `The following paths were written according to env ${chalk.bold(result.envId)}\\n${paths}`;\n })\n .join('\\n\\n');\n return `${cleanResultsOutput}${writeTitle}\\n${writeOutput}`;\n }\n}\n"],"mappings":";;;;;;;;;;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,IAAIb,MAAJ,EAAY;MACV,MAAMc,eAAe,GAAGX,YAAY,CAACY,GAAb,CAAkBC,CAAD,IAAO,IAAAC,cAAA,EAAKD,CAAL,EAAQ,CAAC,UAAD,CAAR,CAAxB,CAAxB;MACA,OAAOL,IAAI,CAACC,SAAL,CAAeE,eAAf,EAAgCD,SAAhC,EAA2C,CAA3C,CAAP;IACD;;IACD,MAAMK,UAAU,GAAGf,YAAY,CAACY,GAAb,CAAkBI,CAAD,IAAOA,CAAC,CAACC,KAAF,CAAQC,MAAhC,EAAwCC,MAAxC,CAA+C,CAACC,GAAD,EAAMC,OAAN,KAAkBD,GAAG,GAAGC,OAAvE,CAAnB;;IACA,MAAMC,UAAU,GAAGjB,gBAAA,CAAMC,KAAN,CAAa,GAAES,UAAW,uCAA1B,CAAnB;;IACA,MAAMQ,WAAW,GAAGvB,YAAY,CAC7BY,GADiB,CACZY,MAAD,IAAY;MACf,MAAMP,KAAK,GAAGO,MAAM,CAACP,KAAP,CACXL,GADW,CACNa,CAAD,IAAOC,eAAA,CAAKnB,IAAL,CAAUkB,CAAV,EAAa,eAAb,CADA,EAEXb,GAFW,CAENe,GAAD,IAAU,KAAIA,GAAI,EAFX,EAGXpB,IAHW,CAGN,IAHM,CAAd;MAIA,OAAQ,qDAAoDF,gBAAA,CAAMuB,IAAN,CAAWJ,MAAM,CAACK,KAAlB,CAAyB,KAAIZ,KAAM,EAA/F;IACD,CAPiB,EAQjBV,IARiB,CAQZ,MARY,CAApB;IASA,OAAQ,GAAEH,kBAAmB,GAAEkB,UAAW,KAAIC,WAAY,EAA1D;EACD;;AAtDsD"}
1
+ {"version":3,"names":["WriteTsconfigCmd","constructor","tsMain","report","_args","flags","cleanResults","writeResults","json","dryRunWithTsconfig","Error","isDryRun","dryRun","cleanResultsOutput","chalk","green","join","totalFiles","map","r","paths","length","reduce","acc","current","writeTitle","writeOutput","result","p","path","str","bold","envIds","clean","silent","noDedupe","writeTsconfigJson","dedupe","writeJson","s","omit"],"sources":["write-tsconfig.cmd.ts"],"sourcesContent":["import path from 'path';\nimport { omit } from 'lodash';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { TypescriptMain } from '../typescript.main.runtime';\n\ntype Flags = { dryRun?: boolean; noDedupe?: boolean; dryRunWithTsconfig?: boolean; clean?: boolean; silent?: boolean };\n\nexport default class WriteTsconfigCmd implements Command {\n name = 'write-tsconfig';\n description = 'EXPERIMENTAL. write tsconfig.json files in the component directories';\n alias = '';\n group = 'development';\n options = [\n ['c', 'clean', 'delete tsconfig files from the workspace. highly recommended to run it with \"--dry-run\" first'],\n ['s', 'silent', 'do not prompt for confirmation'],\n ['', 'no-dedupe', \"write tsconfig.json inside each one of the component's dir, avoid deduping\"],\n ['', 'dry-run', 'show the paths that tsconfig will be written per env'],\n [\n '',\n 'dry-run-with-tsconfig',\n 'use with --json flag. show the tsconfig.json content and the paths it will be written per env',\n ],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n\n constructor(private tsMain: TypescriptMain) {}\n\n async report(_args, flags: Flags) {\n const { cleanResults, writeResults } = await this.json(_args, flags);\n if (flags.dryRunWithTsconfig) {\n throw new Error(`use --json flag along with --dry-run-with-tsconfig`);\n }\n const isDryRun = flags.dryRun;\n const cleanResultsOutput = cleanResults\n ? `${chalk.green(`the following paths ${isDryRun ? 'will be' : 'were'} deleted`)}\\n${cleanResults.join('\\n')}\\n\\n`\n : '';\n\n const totalFiles = writeResults.map((r) => r.paths.length).reduce((acc, current) => acc + current);\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\n .map((result) => {\n const paths = result.paths\n .map((p) => path.join(p, 'tsconfig.json'))\n .map((str) => ` ${str}`)\n .join('\\n');\n return `The following paths are according to env(s) ${chalk.bold(result.envIds.join(', '))}\\n${paths}`;\n })\n .join('\\n\\n');\n return `${cleanResultsOutput}${writeTitle}\\n${writeOutput}`;\n }\n\n async json(_args, flags: Flags) {\n const { clean, silent, noDedupe, dryRunWithTsconfig } = flags;\n const dryRun = dryRunWithTsconfig ? true : flags.dryRun;\n const { cleanResults, writeResults } = await this.tsMain.writeTsconfigJson({\n clean,\n dedupe: !noDedupe,\n dryRun,\n dryRunWithTsconfig,\n silent,\n });\n\n if (dryRun) {\n const writeJson = dryRunWithTsconfig ? writeResults : writeResults.map((s) => omit(s, ['tsconfig']));\n // return JSON.stringify({ cleanResults, writeResults: writeJson }, undefined, 2);\n return { cleanResults, writeResults: writeJson };\n }\n return { cleanResults, writeResults };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKe,MAAMA,gBAAN,CAA0C;EAkBvDC,WAAW,CAASC,MAAT,EAAiC;IAAA,KAAxBA,MAAwB,GAAxBA,MAAwB;IAAA,8CAjBrC,gBAiBqC;IAAA,qDAhB9B,sEAgB8B;IAAA,+CAfpC,EAeoC;IAAA,+CAdpC,aAcoC;IAAA,iDAblC,CACR,CAAC,GAAD,EAAM,OAAN,EAAe,+FAAf,CADQ,EAER,CAAC,GAAD,EAAM,QAAN,EAAgB,gCAAhB,CAFQ,EAGR,CAAC,EAAD,EAAK,WAAL,EAAkB,4EAAlB,CAHQ,EAIR,CAAC,EAAD,EAAK,SAAL,EAAgB,sDAAhB,CAJQ,EAKR,CACE,EADF,EAEE,uBAFF,EAGE,+FAHF,CALQ,EAUR,CAAC,GAAD,EAAM,MAAN,EAAc,aAAd,CAVQ,CAakC;EAAE;;EAElC,MAANC,MAAM,CAACC,KAAD,EAAQC,KAAR,EAAsB;IAChC,MAAM;MAAEC,YAAF;MAAgBC;IAAhB,IAAiC,MAAM,KAAKC,IAAL,CAAUJ,KAAV,EAAiBC,KAAjB,CAA7C;;IACA,IAAIA,KAA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B,MAAM;MAAE4B,KAAF;MAASC,MAAT;MAAiBC,QAAjB;MAA2B1B;IAA3B,IAAkDJ,KAAxD;IACA,MAAMO,MAAM,GAAGH,kBAAkB,GAAG,IAAH,GAAUJ,KAAK,CAACO,MAAjD;IACA,MAAM;MAAEN,YAAF;MAAgBC;IAAhB,IAAiC,MAAM,KAAKL,MAAL,CAAYkC,iBAAZ,CAA8B;MACzEH,KADyE;MAEzEI,MAAM,EAAE,CAACF,QAFgE;MAGzEvB,MAHyE;MAIzEH,kBAJyE;MAKzEyB;IALyE,CAA9B,CAA7C;;IAQA,IAAItB,MAAJ,EAAY;MACV,MAAM0B,SAAS,GAAG7B,kBAAkB,GAAGF,YAAH,GAAkBA,YAAY,CAACW,GAAb,CAAkBqB,CAAD,IAAO,IAAAC,cAAA,EAAKD,CAAL,EAAQ,CAAC,UAAD,CAAR,CAAxB,CAAtD,CADU,CAEV;;MACA,OAAO;QAAEjC,YAAF;QAAgBC,YAAY,EAAE+B;MAA9B,CAAP;IACD;;IACD,OAAO;MAAEhC,YAAF;MAAgBC;IAAhB,CAAP;EACD;;AA/DsD"}
@@ -13,40 +13,40 @@ function _tsconfigWriter() {
13
13
  describe('dedupePath', () => {
14
14
  it('should return the root-dir if there is only one env involved', () => {
15
15
  const input = [{
16
- id: 'env1',
16
+ ids: ['env1'],
17
17
  paths: ['p1/e1, p2']
18
18
  }];
19
19
  const output = (0, _tsconfigWriter().dedupePaths)(input);
20
20
  expect(output).toEqual([{
21
- id: 'env1',
21
+ ids: ['env1'],
22
22
  paths: ['.']
23
23
  }]);
24
24
  });
25
25
  it('should set the env with the most components', () => {
26
26
  const input = [{
27
- id: 'env1',
27
+ ids: ['env1'],
28
28
  paths: ['p1/e1', 'p1/e2']
29
29
  }, {
30
- id: 'env2',
30
+ ids: ['env2'],
31
31
  paths: ['p1/e3']
32
32
  }];
33
33
  const output = (0, _tsconfigWriter().dedupePaths)(input); // @ts-ignore
34
34
 
35
35
  expect(output).toEqual( // @ts-ignore
36
36
  expect.arrayContaining([{
37
- id: 'env1',
37
+ ids: ['env1'],
38
38
  paths: ['.']
39
39
  }, {
40
- id: 'env2',
40
+ ids: ['env2'],
41
41
  paths: ['p1/e3']
42
42
  }]));
43
43
  });
44
44
  it('should not set any env to a shared dir if it no env has max components', () => {
45
45
  const input = [{
46
- id: 'env1',
46
+ ids: ['env1'],
47
47
  paths: ['p1/e1']
48
48
  }, {
49
- id: 'env2',
49
+ ids: ['env2'],
50
50
  paths: ['p1/e2']
51
51
  }];
52
52
  const output = (0, _tsconfigWriter().dedupePaths)(input);
@@ -1 +1 @@
1
- {"version":3,"names":["describe","it","input","id","paths","output","dedupePaths","expect","toEqual","arrayContaining","length"],"sources":["dedupe-path.spec.ts"],"sourcesContent":["import { dedupePaths } from './tsconfig-writer';\n\ndescribe('dedupePath', () => {\n it('should return the root-dir if there is only one env involved', () => {\n const input = [{ id: 'env1', paths: ['p1/e1, p2'] }];\n const output = dedupePaths(input);\n expect(output).toEqual([{ id: 'env1', paths: ['.'] }]);\n });\n it('should set the env with the most components', () => {\n const input = [\n { id: 'env1', paths: ['p1/e1', 'p1/e2'] },\n { id: 'env2', paths: ['p1/e3'] },\n ];\n const output = dedupePaths(input);\n // @ts-ignore\n expect(output).toEqual(\n // @ts-ignore\n expect.arrayContaining([\n { id: 'env1', paths: ['.'] },\n { id: 'env2', paths: ['p1/e3'] },\n ])\n );\n });\n it('should not set any env to a shared dir if it no env has max components', () => {\n const input = [\n { id: 'env1', paths: ['p1/e1'] },\n { id: 'env2', paths: ['p1/e2'] },\n ];\n const output = dedupePaths(input);\n expect(output.length).toEqual(2);\n // @ts-ignore\n expect(output).toEqual(expect.arrayContaining(input));\n });\n});\n"],"mappings":";;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEAA,QAAQ,CAAC,YAAD,EAAe,MAAM;EAC3BC,EAAE,CAAC,8DAAD,EAAiE,MAAM;IACvE,MAAMC,KAAK,GAAG,CAAC;MAAEC,EA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CAAN,CAAeG,OAAf,CAAuBD,MAAM,CAACE,eAAP,CAAuBP,KAAvB,CAAvB;EACD,CATC,CAAF;AAUD,CA/BO,CAAR"}
1
+ {"version":3,"names":["describe","it","input","ids","paths","output","dedupePaths","expect","toEqual","arrayContaining","length"],"sources":["dedupe-path.spec.ts"],"sourcesContent":["import { dedupePaths } from './tsconfig-writer';\n\ndescribe('dedupePath', () => {\n it('should return the root-dir if there is only one env involved', () => {\n const input = [{ ids: ['env1'], paths: ['p1/e1, p2'] }];\n const output = dedupePaths(input);\n expect(output).toEqual([{ ids: ['env1'], paths: ['.'] }]);\n });\n it('should set the env with the most components', () => {\n const input = [\n { ids: ['env1'], paths: ['p1/e1', 'p1/e2'] },\n { ids: ['env2'], paths: ['p1/e3'] },\n ];\n const output = dedupePaths(input);\n // @ts-ignore\n expect(output).toEqual(\n // @ts-ignore\n expect.arrayContaining([\n { ids: ['env1'], paths: ['.'] },\n { ids: ['env2'], paths: ['p1/e3'] },\n ])\n );\n });\n it('should not set any env to a shared dir if it no env has max components', () => {\n const input = [\n { ids: ['env1'], paths: ['p1/e1'] },\n { ids: ['env2'], paths: ['p1/e2'] },\n ];\n const output = dedupePaths(input);\n expect(output.length).toEqual(2);\n // @ts-ignore\n expect(output).toEqual(expect.arrayContaining(input));\n });\n});\n"],"mappings":";;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEAA,QAAQ,CAAC,YAAD,EAAe,MAAM;EAC3BC,EAAE,CAAC,8DAAD,EAAiE,MAAM;IACvE,MAAMC,KAAK,GAAG,CAAC;MAAEC,GAAG,EAAE,CAAC,MAAD,CAAP;MAAiBC,KAAK,EAAE,CAAC,WAAD;IAAxB,CAAD,CAAd;IACA,MAAMC,MAAM,GAAG,IAAAC,6BAAA,EAAYJ,KAAZ,CAAf;IACAK,MAAM,CAACF,MAAD,CAAN,CAAeG,OAAf,CAAuB,CAAC;MAAEL,GAAG,EAAE,CAAC,MAAD,CAAP;MAAiBC,KAAK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ace } from '@teambit/workspace';
3
3
  import { Logger } from '@teambit/logger';
4
4
  import { TsconfigWriterOptions } from './typescript.main.runtime';
5
5
  export declare type TsconfigPathsPerEnv = {
6
- envId: string;
6
+ envIds: string[];
7
7
  tsconfig: Record<string, any>;
8
8
  paths: string[];
9
9
  };
@@ -19,8 +19,8 @@ export declare class TsconfigWriter {
19
19
  private writeFiles;
20
20
  private getPathsPerEnv;
21
21
  }
22
- declare type PathsPerEnvId = {
23
- id: string;
22
+ declare type PathsPerEnvIds = {
23
+ ids: string[];
24
24
  paths: string[];
25
25
  };
26
26
  /**
@@ -44,5 +44,5 @@ declare type PathsPerEnvId = {
44
44
  * if in a shared-dir, some components using env1 and some env2, it finds the env that has the max number of
45
45
  * components, this env will be optimized. other components, will have the files written inside their dirs.
46
46
  */
47
- export declare function dedupePaths(pathsPerEnvId: PathsPerEnvId[]): PathsPerEnvId[];
47
+ export declare function dedupePaths(pathsPerEnvId: PathsPerEnvIds[]): PathsPerEnvIds[];
48
48
  export {};
@@ -10,6 +10,8 @@ require("core-js/modules/es.array.unscopables.flat.js");
10
10
 
11
11
  require("core-js/modules/es.promise.js");
12
12
 
13
+ require("core-js/modules/es.regexp.exec.js");
14
+
13
15
  Object.defineProperty(exports, "__esModule", {
14
16
  value: true
15
17
  });
@@ -85,7 +87,7 @@ class TsconfigWriter {
85
87
  async write(envsExecutionContext, options) {
86
88
  const pathsPerEnvs = this.getPathsPerEnv(envsExecutionContext, options);
87
89
  const tsconfigPathsPerEnv = pathsPerEnvs.map(pathsPerEnv => ({
88
- envId: pathsPerEnv.id,
90
+ envIds: pathsPerEnv.ids,
89
91
  tsconfig: pathsPerEnv.env.getTsConfig(),
90
92
  paths: pathsPerEnv.paths
91
93
  }));
@@ -166,20 +168,52 @@ ${_chalk().default.bold('Do you want to continue? [yes(y)/no(n)]')}`
166
168
  });
167
169
 
168
170
  if (!dedupe) {
169
- return pathsPerEnvs;
171
+ return pathsPerEnvs.map(({
172
+ id,
173
+ env,
174
+ paths
175
+ }) => ({
176
+ ids: [id],
177
+ env,
178
+ paths
179
+ }));
170
180
  }
171
181
 
172
- const pathsPerEnvId = pathsPerEnvs.map(p => ({
173
- id: p.id,
174
- paths: p.paths
182
+ const envsWithFiles = envsExecutionContext.map(e => ({
183
+ id: e.id,
184
+ file: e.env.getTsConfig()
175
185
  }));
176
- const envsPerDedupedPaths = dedupePaths(pathsPerEnvId);
186
+ const envsPerFile = [];
187
+
188
+ const isEnvProcessed = envId => envsPerFile.map(e => e.envIds).flat().find(e => e === envId);
189
+
190
+ envsWithFiles.forEach(({
191
+ id,
192
+ file
193
+ }) => {
194
+ if (isEnvProcessed(id)) return;
195
+ const foundSameFile = envsWithFiles.filter(e => (0, _lodash().isEqual)(file, e.file));
196
+ envsPerFile.push({
197
+ envIds: foundSameFile.map(f => f.id),
198
+ fileContent: file
199
+ });
200
+ });
201
+ const pathsPerEnvIds = envsPerFile.map(e => ({
202
+ ids: e.envIds,
203
+ paths: (0, _lodash().compact)(e.envIds.map(envId => {
204
+ var _pathsPerEnvs$find;
205
+
206
+ return (_pathsPerEnvs$find = pathsPerEnvs.find(p => p.id === envId)) === null || _pathsPerEnvs$find === void 0 ? void 0 : _pathsPerEnvs$find.paths;
207
+ }).flat())
208
+ })); // const pathsPerEnvIds = pathsPerEnvs.map((p) => ({ ids: p.ids, paths: p.paths }));
209
+
210
+ const envsPerDedupedPaths = dedupePaths(pathsPerEnvIds);
177
211
  const dedupedPathsPerEnvs = envsPerDedupedPaths.map(envWithDedupePaths => {
178
- const found = pathsPerEnvs.find(p => p.id === envWithDedupePaths.id);
179
- if (!found) throw new Error(`dedupedPathsPerEnvs, unable to find ${envWithDedupePaths.id}`);
212
+ const found = pathsPerEnvs.find(p => envWithDedupePaths.ids.includes(p.id));
213
+ if (!found) throw new Error(`dedupedPathsPerEnvs, unable to find ${envWithDedupePaths.ids}`);
180
214
  return {
181
215
  env: found.env,
182
- id: found.id,
216
+ ids: envWithDedupePaths.ids,
183
217
  paths: envWithDedupePaths.paths
184
218
  };
185
219
  });
@@ -241,27 +275,27 @@ function getAllParentsDirOfPath(p) {
241
275
 
242
276
  function dedupePaths(pathsPerEnvId) {
243
277
  const rootDir = '.';
244
- const individualPathPerEnvId = pathsPerEnvId.reduce((acc, current) => {
278
+ const individualPathPerConcatenatedEnvIds = pathsPerEnvId.reduce((acc, current) => {
245
279
  current.paths.forEach(p => {
246
- acc[p] = current.id;
280
+ acc[p] = current.ids.join(',');
247
281
  });
248
282
  return acc;
249
283
  }, {});
250
- const allPaths = Object.keys(individualPathPerEnvId);
284
+ const allPaths = Object.keys(individualPathPerConcatenatedEnvIds);
251
285
  const allPossibleDirs = getAllPossibleDirsFromPaths(allPaths);
252
286
  const allPathsPerEnvId = {}; // null when parent-dir has same amount of comps per env.
253
287
 
254
288
  const calculateBestEnvForDir = dir => {
255
- if (individualPathPerEnvId[dir]) {
289
+ if (individualPathPerConcatenatedEnvIds[dir]) {
256
290
  // it's the component dir, so it's the best env
257
- allPathsPerEnvId[dir] = individualPathPerEnvId[dir];
291
+ allPathsPerEnvId[dir] = individualPathPerConcatenatedEnvIds[dir];
258
292
  return;
259
293
  }
260
294
 
261
295
  const allPathsShareSameDir = dir === rootDir ? allPaths : allPaths.filter(p => p.startsWith(`${dir}/`));
262
296
  const countPerEnv = {};
263
297
  allPathsShareSameDir.forEach(p => {
264
- const envIdStr = individualPathPerEnvId[p];
298
+ const envIdStr = individualPathPerConcatenatedEnvIds[p];
265
299
  if (countPerEnv[envIdStr]) countPerEnv[envIdStr] += 1;else countPerEnv[envIdStr] = 1;
266
300
  });
267
301
  const max = Math.max(...Object.values(countPerEnv));
@@ -275,7 +309,7 @@ function dedupePaths(pathsPerEnvId) {
275
309
  }); // this is the actual deduping. if found a shorter path with the same env, then no need for this path.
276
310
  // in other words, return only the paths that their parent is null or has a different env.
277
311
 
278
- const dedupedPathsPerEnvId = Object.keys(allPathsPerEnvId).reduce((acc, current) => {
312
+ const dedupedPathsPerEnvIds = Object.keys(allPathsPerEnvId).reduce((acc, current) => {
279
313
  if (allPathsPerEnvId[current] && allPathsPerEnvId[_path().default.dirname(current)] !== allPathsPerEnvId[current]) {
280
314
  acc[current] = allPathsPerEnvId[current];
281
315
  }
@@ -283,11 +317,11 @@ function dedupePaths(pathsPerEnvId) {
283
317
  return acc;
284
318
  }, {}); // rootDir parent is always rootDir, so leave it as is.
285
319
 
286
- if (allPathsPerEnvId[rootDir]) dedupedPathsPerEnvId[rootDir] = allPathsPerEnvId[rootDir];
287
- const envIdPerDedupedPaths = (0, _lodash().invertBy)(dedupedPathsPerEnvId);
288
- return Object.keys(envIdPerDedupedPaths).map(envIdStr => ({
289
- id: envIdStr,
290
- paths: envIdPerDedupedPaths[envIdStr]
320
+ if (allPathsPerEnvId[rootDir]) dedupedPathsPerEnvIds[rootDir] = allPathsPerEnvId[rootDir];
321
+ const envIdsPerDedupedPaths = (0, _lodash().invertBy)(dedupedPathsPerEnvIds);
322
+ return Object.keys(envIdsPerDedupedPaths).map(envIdStr => ({
323
+ ids: envIdStr.split(','),
324
+ paths: envIdsPerDedupedPaths[envIdStr]
291
325
  }));
292
326
  }
293
327
 
@@ -1 +1 @@
1
- {"version":3,"names":["TsconfigWriter","constructor","workspace","logger","write","envsExecutionContext","options","pathsPerEnvs","getPathsPerEnv","tsconfigPathsPerEnv","map","pathsPerEnv","envId","id","tsconfig","env","getTsConfig","paths","dryRun","silent","promptForWriting","p","flat","writeFiles","clean","dedupe","componentPaths","allPossibleDirs","getAllPossibleDirsFromPaths","dirsWithTsconfig","filterDirsWithTsconfigFile","tsconfigFiles","dir","path","join","length","promptForCleaning","deleteFiles","dirs","clearStatusLine","ok","yesno","question","chalk","underline","bold","PromptCanceled","Promise","all","f","fs","remove","tsconfigPathsPerEnvs","writeJSON","spaces","envExecution","components","c","componentDir","undefined","relative","pathsPerEnvId","envsPerDedupedPaths","dedupePaths","dedupedPathsPerEnvs","envWithDedupePaths","found","find","Error","hasTsconfig","pathExists","compact","getAllParentsDirOfPath","push","uniq","current","dirname","rootDir","individualPathPerEnvId","reduce","acc","forEach","allPaths","Object","keys","allPathsPerEnvId","calculateBestEnvForDir","allPathsShareSameDir","filter","startsWith","countPerEnv","envIdStr","max","Math","values","envWithMax","dirPath","dedupedPathsPerEnvId","envIdPerDedupedPaths","invertBy"],"sources":["tsconfig-writer.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport yesno from 'yesno';\nimport { PathLinuxRelative } from '@teambit/legacy/dist/utils/path';\nimport { compact, invertBy, uniq } from 'lodash';\nimport { PromptCanceled } from '@teambit/legacy/dist/prompts/exceptions';\nimport { Environment, ExecutionContext } from '@teambit/envs';\nimport { Workspace } from '@teambit/workspace';\nimport { Logger } from '@teambit/logger';\nimport chalk from 'chalk';\nimport { TsconfigWriterOptions } from './typescript.main.runtime';\n\nexport type TsconfigPathsPerEnv = { envId: string; tsconfig: Record<string, any>; paths: string[] };\n\ntype PathsPerEnv = { env: Environment; id: string; paths: string[] };\n\nexport class TsconfigWriter {\n constructor(private workspace: Workspace, private logger: Logger) {}\n\n async write(\n envsExecutionContext: ExecutionContext[],\n options: TsconfigWriterOptions\n ): Promise<TsconfigPathsPerEnv[]> {\n const pathsPerEnvs = this.getPathsPerEnv(envsExecutionContext, options);\n const tsconfigPathsPerEnv = pathsPerEnvs.map((pathsPerEnv) => ({\n envId: pathsPerEnv.id,\n tsconfig: pathsPerEnv.env.getTsConfig(),\n paths: pathsPerEnv.paths,\n }));\n if (options.dryRun) return tsconfigPathsPerEnv;\n if (!options.silent) await this.promptForWriting(tsconfigPathsPerEnv.map((p) => p.paths).flat());\n await this.writeFiles(tsconfigPathsPerEnv);\n return tsconfigPathsPerEnv;\n }\n\n async clean(envsExecutionContext: ExecutionContext[], { dryRun, silent }: TsconfigWriterOptions): Promise<string[]> {\n const pathsPerEnvs = this.getPathsPerEnv(envsExecutionContext, { dedupe: false });\n const componentPaths = pathsPerEnvs.map((p) => p.paths).flat();\n const allPossibleDirs = getAllPossibleDirsFromPaths(componentPaths);\n const dirsWithTsconfig = await filterDirsWithTsconfigFile(allPossibleDirs);\n const tsconfigFiles = dirsWithTsconfig.map((dir) => path.join(dir, 'tsconfig.json'));\n if (dryRun) return tsconfigFiles;\n if (!dirsWithTsconfig.length) return [];\n if (!silent) await this.promptForCleaning(tsconfigFiles);\n await this.deleteFiles(tsconfigFiles);\n return tsconfigFiles;\n }\n\n private async promptForWriting(dirs: string[]) {\n this.logger.clearStatusLine();\n const tsconfigFiles = dirs.map((dir) => path.join(dir, 'tsconfig.json'));\n const ok = await yesno({\n question: `${chalk.underline('The following paths will be written:')}\n${tsconfigFiles.join('\\n')}\n${chalk.bold('Do you want to continue? [yes(y)/no(n)]')}`,\n });\n if (!ok) {\n throw new PromptCanceled();\n }\n }\n\n private async promptForCleaning(tsconfigFiles: string[]) {\n this.logger.clearStatusLine();\n const ok = await yesno({\n question: `${chalk.underline('The following paths will be deleted:')}\n${tsconfigFiles.join('\\n')}\n${chalk.bold('Do you want to continue? [yes(y)/no(n)]')}`,\n });\n if (!ok) {\n throw new PromptCanceled();\n }\n }\n\n private async deleteFiles(tsconfigFiles: string[]) {\n await Promise.all(tsconfigFiles.map((f) => fs.remove(f)));\n }\n\n private async writeFiles(tsconfigPathsPerEnvs: TsconfigPathsPerEnv[]) {\n await Promise.all(\n tsconfigPathsPerEnvs.map((pathsPerEnv) => {\n return Promise.all(\n pathsPerEnv.paths.map((p) => fs.writeJSON(path.join(p, 'tsconfig.json'), pathsPerEnv.tsconfig, { spaces: 2 }))\n );\n })\n );\n }\n\n private getPathsPerEnv(envsExecutionContext: ExecutionContext[], { dedupe }: TsconfigWriterOptions): PathsPerEnv[] {\n const pathsPerEnvs = envsExecutionContext.map((envExecution) => {\n return {\n id: envExecution.id,\n env: envExecution.env,\n paths: envExecution.components.map((c) => this.workspace.componentDir(c.id, undefined, { relative: true })),\n };\n });\n if (!dedupe) {\n return pathsPerEnvs;\n }\n\n const pathsPerEnvId = pathsPerEnvs.map((p) => ({ id: p.id, paths: p.paths }));\n const envsPerDedupedPaths = dedupePaths(pathsPerEnvId);\n const dedupedPathsPerEnvs: PathsPerEnv[] = envsPerDedupedPaths.map((envWithDedupePaths) => {\n const found = pathsPerEnvs.find((p) => p.id === envWithDedupePaths.id);\n if (!found) throw new Error(`dedupedPathsPerEnvs, unable to find ${envWithDedupePaths.id}`);\n return {\n env: found.env,\n id: found.id,\n paths: envWithDedupePaths.paths,\n };\n });\n\n return dedupedPathsPerEnvs;\n }\n}\n\ntype PathsPerEnvId = { id: string; paths: string[] };\n\nasync function filterDirsWithTsconfigFile(dirs: string[]): Promise<string[]> {\n const dirsWithTsconfig = await Promise.all(\n dirs.map(async (dir) => {\n const hasTsconfig = await fs.pathExists(path.join(dir, 'tsconfig.json'));\n return hasTsconfig ? dir : undefined;\n })\n );\n return compact(dirsWithTsconfig);\n}\n\nfunction getAllPossibleDirsFromPaths(paths: PathLinuxRelative[]): PathLinuxRelative[] {\n const dirs = paths.map((p) => getAllParentsDirOfPath(p)).flat();\n dirs.push('.'); // add the root dir\n return uniq(dirs);\n}\n\nfunction getAllParentsDirOfPath(p: PathLinuxRelative): PathLinuxRelative[] {\n const all: string[] = [];\n let current = p;\n while (current !== '.') {\n all.push(current);\n current = path.dirname(current);\n }\n return all;\n}\n\n/**\n * easier to understand by an example:\n * input:\n * [\n * { id: react, paths: [ui/button, ui/form] },\n * { id: aspect, paths: [p/a1, p/a2] },\n * { id: node, paths: [p/n1] },\n * ]\n *\n * output:\n * [\n * { id: react, paths: [ui] },\n * { id: aspect, paths: [p] },\n * { id: node, paths: [p/n1] },\n * ]\n *\n * the goal is to minimize the amount of files to write per env if possible.\n * when multiple components of the same env share a root-dir, then, it's enough to write a file in that shared dir.\n * if in a shared-dir, some components using env1 and some env2, it finds the env that has the max number of\n * components, this env will be optimized. other components, will have the files written inside their dirs.\n */\nexport function dedupePaths(pathsPerEnvId: PathsPerEnvId[]): PathsPerEnvId[] {\n const rootDir = '.';\n const individualPathPerEnvId: { [path: string]: string } = pathsPerEnvId.reduce((acc, current) => {\n current.paths.forEach((p) => {\n acc[p] = current.id;\n });\n return acc;\n }, {});\n const allPaths = Object.keys(individualPathPerEnvId);\n const allPossibleDirs = getAllPossibleDirsFromPaths(allPaths);\n\n const allPathsPerEnvId: { [path: string]: string | null } = {}; // null when parent-dir has same amount of comps per env.\n\n const calculateBestEnvForDir = (dir: string) => {\n if (individualPathPerEnvId[dir]) {\n // it's the component dir, so it's the best env\n allPathsPerEnvId[dir] = individualPathPerEnvId[dir];\n return;\n }\n const allPathsShareSameDir = dir === rootDir ? allPaths : allPaths.filter((p) => p.startsWith(`${dir}/`));\n const countPerEnv: { [env: string]: number } = {};\n allPathsShareSameDir.forEach((p) => {\n const envIdStr = individualPathPerEnvId[p];\n if (countPerEnv[envIdStr]) countPerEnv[envIdStr] += 1;\n else countPerEnv[envIdStr] = 1;\n });\n const max = Math.max(...Object.values(countPerEnv));\n const envWithMax = Object.keys(countPerEnv).filter((env) => countPerEnv[env] === max);\n if (!envWithMax.length) throw new Error(`must be at least one env related to path \"${dir}\"`);\n if (envWithMax.length > 1) allPathsPerEnvId[dir] = null;\n else allPathsPerEnvId[dir] = envWithMax[0];\n };\n\n allPossibleDirs.forEach((dirPath) => {\n calculateBestEnvForDir(dirPath);\n });\n\n // this is the actual deduping. if found a shorter path with the same env, then no need for this path.\n // in other words, return only the paths that their parent is null or has a different env.\n const dedupedPathsPerEnvId = Object.keys(allPathsPerEnvId).reduce((acc, current) => {\n if (allPathsPerEnvId[current] && allPathsPerEnvId[path.dirname(current)] !== allPathsPerEnvId[current]) {\n acc[current] = allPathsPerEnvId[current];\n }\n\n return acc;\n }, {});\n // rootDir parent is always rootDir, so leave it as is.\n if (allPathsPerEnvId[rootDir]) dedupedPathsPerEnvId[rootDir] = allPathsPerEnvId[rootDir];\n\n const envIdPerDedupedPaths = invertBy(dedupedPathsPerEnvId);\n\n return Object.keys(envIdPerDedupedPaths).map((envIdStr) => ({ id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AwB,IAAxB,CAA3B,KACKqD,gBAAgB,CAACrD,GAAD,CAAhB,GAAwB+D,UAAU,CAAC,CAAD,CAAlC;EACN,CAlBD;;EAoBApE,eAAe,CAACsD,OAAhB,CAAyBe,OAAD,IAAa;IACnCV,sBAAsB,CAACU,OAAD,CAAtB;EACD,CAFD,EAjC2E,CAqC3E;EACA;;EACA,MAAMC,oBAAoB,GAAGd,MAAM,CAACC,IAAP,CAAYC,gBAAZ,EAA8BN,MAA9B,CAAqC,CAACC,GAAD,EAAML,OAAN,KAAkB;IAClF,IAAIU,gBAAgB,CAACV,OAAD,CAAhB,IAA6BU,gBAAgB,CAACpD,eAAA,CAAK2C,OAAL,CAAaD,OAAb,CAAD,CAAhB,KAA4CU,gBAAgB,CAACV,OAAD,CAA7F,EAAwG;MACtGK,GAAG,CAACL,OAAD,CAAH,GAAeU,gBAAgB,CAACV,OAAD,CAA/B;IACD;;IAED,OAAOK,GAAP;EACD,CAN4B,EAM1B,EAN0B,CAA7B,CAvC2E,CA8C3E;;EACA,IAAIK,gBAAgB,CAACR,OAAD,CAApB,EAA+BoB,oBAAoB,CAACpB,OAAD,CAApB,GAAgCQ,gBAAgB,CAACR,OAAD,CAAhD;EAE/B,MAAMqB,oBAAoB,GAAG,IAAAC,kBAAA,EAASF,oBAAT,CAA7B;EAEA,OAAOd,MAAM,CAACC,IAAP,CAAYc,oBAAZ,EAAkCxF,GAAlC,CAAuCiF,QAAD,KAAe;IAAE9E,EAAE,EAAE8E,QAAN;IAAgB1E,KAAK,EAAEiF,oBAAoB,CAACP,QAAD;EAA3C,CAAf,CAAtC,CAAP;AACD"}
1
+ {"version":3,"names":["TsconfigWriter","constructor","workspace","logger","write","envsExecutionContext","options","pathsPerEnvs","getPathsPerEnv","tsconfigPathsPerEnv","map","pathsPerEnv","envIds","ids","tsconfig","env","getTsConfig","paths","dryRun","silent","promptForWriting","p","flat","writeFiles","clean","dedupe","componentPaths","allPossibleDirs","getAllPossibleDirsFromPaths","dirsWithTsconfig","filterDirsWithTsconfigFile","tsconfigFiles","dir","path","join","length","promptForCleaning","deleteFiles","dirs","clearStatusLine","ok","yesno","question","chalk","underline","bold","PromptCanceled","Promise","all","f","fs","remove","tsconfigPathsPerEnvs","writeJSON","spaces","envExecution","id","components","c","componentDir","undefined","relative","envsWithFiles","e","file","envsPerFile","isEnvProcessed","envId","find","forEach","foundSameFile","filter","isEqual","push","fileContent","pathsPerEnvIds","compact","envsPerDedupedPaths","dedupePaths","dedupedPathsPerEnvs","envWithDedupePaths","found","includes","Error","hasTsconfig","pathExists","getAllParentsDirOfPath","uniq","current","dirname","pathsPerEnvId","rootDir","individualPathPerConcatenatedEnvIds","reduce","acc","allPaths","Object","keys","allPathsPerEnvId","calculateBestEnvForDir","allPathsShareSameDir","startsWith","countPerEnv","envIdStr","max","Math","values","envWithMax","dirPath","dedupedPathsPerEnvIds","envIdsPerDedupedPaths","invertBy","split"],"sources":["tsconfig-writer.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport yesno from 'yesno';\nimport { PathLinuxRelative } from '@teambit/legacy/dist/utils/path';\nimport { compact, invertBy, isEqual, uniq } from 'lodash';\nimport { PromptCanceled } from '@teambit/legacy/dist/prompts/exceptions';\nimport { Environment, ExecutionContext } from '@teambit/envs';\nimport { Workspace } from '@teambit/workspace';\nimport { Logger } from '@teambit/logger';\nimport chalk from 'chalk';\nimport { TsconfigWriterOptions } from './typescript.main.runtime';\n\nexport type TsconfigPathsPerEnv = { envIds: string[]; tsconfig: Record<string, any>; paths: string[] };\n\ntype PathsPerEnv = { env: Environment; ids: string[]; paths: string[] };\n\nexport class TsconfigWriter {\n constructor(private workspace: Workspace, private logger: Logger) {}\n\n async write(\n envsExecutionContext: ExecutionContext[],\n options: TsconfigWriterOptions\n ): Promise<TsconfigPathsPerEnv[]> {\n const pathsPerEnvs = this.getPathsPerEnv(envsExecutionContext, options);\n const tsconfigPathsPerEnv = pathsPerEnvs.map((pathsPerEnv) => ({\n envIds: pathsPerEnv.ids,\n tsconfig: pathsPerEnv.env.getTsConfig(),\n paths: pathsPerEnv.paths,\n }));\n if (options.dryRun) return tsconfigPathsPerEnv;\n if (!options.silent) await this.promptForWriting(tsconfigPathsPerEnv.map((p) => p.paths).flat());\n await this.writeFiles(tsconfigPathsPerEnv);\n return tsconfigPathsPerEnv;\n }\n\n async clean(envsExecutionContext: ExecutionContext[], { dryRun, silent }: TsconfigWriterOptions): Promise<string[]> {\n const pathsPerEnvs = this.getPathsPerEnv(envsExecutionContext, { dedupe: false });\n const componentPaths = pathsPerEnvs.map((p) => p.paths).flat();\n const allPossibleDirs = getAllPossibleDirsFromPaths(componentPaths);\n const dirsWithTsconfig = await filterDirsWithTsconfigFile(allPossibleDirs);\n const tsconfigFiles = dirsWithTsconfig.map((dir) => path.join(dir, 'tsconfig.json'));\n if (dryRun) return tsconfigFiles;\n if (!dirsWithTsconfig.length) return [];\n if (!silent) await this.promptForCleaning(tsconfigFiles);\n await this.deleteFiles(tsconfigFiles);\n return tsconfigFiles;\n }\n\n private async promptForWriting(dirs: string[]) {\n this.logger.clearStatusLine();\n const tsconfigFiles = dirs.map((dir) => path.join(dir, 'tsconfig.json'));\n const ok = await yesno({\n question: `${chalk.underline('The following paths will be written:')}\n${tsconfigFiles.join('\\n')}\n${chalk.bold('Do you want to continue? [yes(y)/no(n)]')}`,\n });\n if (!ok) {\n throw new PromptCanceled();\n }\n }\n\n private async promptForCleaning(tsconfigFiles: string[]) {\n this.logger.clearStatusLine();\n const ok = await yesno({\n question: `${chalk.underline('The following paths will be deleted:')}\n${tsconfigFiles.join('\\n')}\n${chalk.bold('Do you want to continue? [yes(y)/no(n)]')}`,\n });\n if (!ok) {\n throw new PromptCanceled();\n }\n }\n\n private async deleteFiles(tsconfigFiles: string[]) {\n await Promise.all(tsconfigFiles.map((f) => fs.remove(f)));\n }\n\n private async writeFiles(tsconfigPathsPerEnvs: TsconfigPathsPerEnv[]) {\n await Promise.all(\n tsconfigPathsPerEnvs.map((pathsPerEnv) => {\n return Promise.all(\n pathsPerEnv.paths.map((p) => fs.writeJSON(path.join(p, 'tsconfig.json'), pathsPerEnv.tsconfig, { spaces: 2 }))\n );\n })\n );\n }\n\n private getPathsPerEnv(envsExecutionContext: ExecutionContext[], { dedupe }: TsconfigWriterOptions): PathsPerEnv[] {\n const pathsPerEnvs = envsExecutionContext.map((envExecution) => {\n return {\n id: envExecution.id,\n env: envExecution.env,\n paths: envExecution.components.map((c) => this.workspace.componentDir(c.id, undefined, { relative: true })),\n };\n });\n if (!dedupe) {\n return pathsPerEnvs.map(({ id, env, paths }) => ({ ids: [id], env, paths }));\n }\n\n const envsWithFiles = envsExecutionContext.map((e) => ({\n id: e.id,\n file: e.env.getTsConfig(),\n }));\n const envsPerFile: { envIds: string[]; fileContent: Record<string, any> }[] = [];\n const isEnvProcessed = (envId: string) =>\n envsPerFile\n .map((e) => e.envIds)\n .flat()\n .find((e) => e === envId);\n envsWithFiles.forEach(({ id, file }) => {\n if (isEnvProcessed(id)) return;\n const foundSameFile = envsWithFiles.filter((e) => isEqual(file, e.file));\n envsPerFile.push({ envIds: foundSameFile.map((f) => f.id), fileContent: file });\n });\n const pathsPerEnvIds = envsPerFile.map((e) => ({\n ids: e.envIds,\n paths: compact(e.envIds.map((envId) => pathsPerEnvs.find((p) => p.id === envId)?.paths).flat()),\n }));\n // const pathsPerEnvIds = pathsPerEnvs.map((p) => ({ ids: p.ids, paths: p.paths }));\n const envsPerDedupedPaths = dedupePaths(pathsPerEnvIds);\n const dedupedPathsPerEnvs: PathsPerEnv[] = envsPerDedupedPaths.map((envWithDedupePaths) => {\n const found = pathsPerEnvs.find((p) => envWithDedupePaths.ids.includes(p.id));\n if (!found) throw new Error(`dedupedPathsPerEnvs, unable to find ${envWithDedupePaths.ids}`);\n return {\n env: found.env,\n ids: envWithDedupePaths.ids,\n paths: envWithDedupePaths.paths,\n };\n });\n\n return dedupedPathsPerEnvs;\n }\n}\n\ntype PathsPerEnvIds = { ids: string[]; paths: string[] };\n\nasync function filterDirsWithTsconfigFile(dirs: string[]): Promise<string[]> {\n const dirsWithTsconfig = await Promise.all(\n dirs.map(async (dir) => {\n const hasTsconfig = await fs.pathExists(path.join(dir, 'tsconfig.json'));\n return hasTsconfig ? dir : undefined;\n })\n );\n return compact(dirsWithTsconfig);\n}\n\nfunction getAllPossibleDirsFromPaths(paths: PathLinuxRelative[]): PathLinuxRelative[] {\n const dirs = paths.map((p) => getAllParentsDirOfPath(p)).flat();\n dirs.push('.'); // add the root dir\n return uniq(dirs);\n}\n\nfunction getAllParentsDirOfPath(p: PathLinuxRelative): PathLinuxRelative[] {\n const all: string[] = [];\n let current = p;\n while (current !== '.') {\n all.push(current);\n current = path.dirname(current);\n }\n return all;\n}\n\n/**\n * easier to understand by an example:\n * input:\n * [\n * { id: react, paths: [ui/button, ui/form] },\n * { id: aspect, paths: [p/a1, p/a2] },\n * { id: node, paths: [p/n1] },\n * ]\n *\n * output:\n * [\n * { id: react, paths: [ui] },\n * { id: aspect, paths: [p] },\n * { id: node, paths: [p/n1] },\n * ]\n *\n * the goal is to minimize the amount of files to write per env if possible.\n * when multiple components of the same env share a root-dir, then, it's enough to write a file in that shared dir.\n * if in a shared-dir, some components using env1 and some env2, it finds the env that has the max number of\n * components, this env will be optimized. other components, will have the files written inside their dirs.\n */\nexport function dedupePaths(pathsPerEnvId: PathsPerEnvIds[]): PathsPerEnvIds[] {\n const rootDir = '.';\n const individualPathPerConcatenatedEnvIds: { [path: string]: string } = pathsPerEnvId.reduce((acc, current) => {\n current.paths.forEach((p) => {\n acc[p] = current.ids.join(',');\n });\n return acc;\n }, {});\n const allPaths = Object.keys(individualPathPerConcatenatedEnvIds);\n const allPossibleDirs = getAllPossibleDirsFromPaths(allPaths);\n\n const allPathsPerEnvId: { [path: string]: string | null } = {}; // null when parent-dir has same amount of comps per env.\n\n const calculateBestEnvForDir = (dir: string) => {\n if (individualPathPerConcatenatedEnvIds[dir]) {\n // it's the component dir, so it's the best env\n allPathsPerEnvId[dir] = individualPathPerConcatenatedEnvIds[dir];\n return;\n }\n const allPathsShareSameDir = dir === rootDir ? allPaths : allPaths.filter((p) => p.startsWith(`${dir}/`));\n const countPerEnv: { [env: string]: number } = {};\n allPathsShareSameDir.forEach((p) => {\n const envIdStr = individualPathPerConcatenatedEnvIds[p];\n if (countPerEnv[envIdStr]) countPerEnv[envIdStr] += 1;\n else countPerEnv[envIdStr] = 1;\n });\n const max = Math.max(...Object.values(countPerEnv));\n const envWithMax = Object.keys(countPerEnv).filter((env) => countPerEnv[env] === max);\n if (!envWithMax.length) throw new Error(`must be at least one env related to path \"${dir}\"`);\n if (envWithMax.length > 1) allPathsPerEnvId[dir] = null;\n else allPathsPerEnvId[dir] = envWithMax[0];\n };\n\n allPossibleDirs.forEach((dirPath) => {\n calculateBestEnvForDir(dirPath);\n });\n\n // this is the actual deduping. if found a shorter path with the same env, then no need for this path.\n // in other words, return only the paths that their parent is null or has a different env.\n const dedupedPathsPerEnvIds = Object.keys(allPathsPerEnvId).reduce((acc, current) => {\n if (allPathsPerEnvId[current] && allPathsPerEnvId[path.dirname(current)] !== allPathsPerEnvId[current]) {\n acc[current] = allPathsPerEnvId[current];\n }\n\n return acc;\n }, {});\n // rootDir parent is always rootDir, so leave it as is.\n if (allPathsPerEnvId[rootDir]) dedupedPathsPerEnvIds[rootDir] = allPathsPerEnvId[rootDir];\n\n const envIdsPerDedupedPaths = invertBy(dedupedPathsPerEnvIds);\n\n return Object.keys(envIdsPerDedupedPaths).map((envIdStr) => ({\n ids: envIdStr.split(','),\n paths: envIdsPerDedupedPaths[envIdStr],\n }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;I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EAjC6E,CAqC7E;EACA;;EACA,MAAMC,qBAAqB,GAAGb,MAAM,CAACC,IAAP,CAAYC,gBAAZ,EAA8BL,MAA9B,CAAqC,CAACC,GAAD,EAAMN,OAAN,KAAkB;IACnF,IAAIU,gBAAgB,CAACV,OAAD,CAAhB,IAA6BU,gBAAgB,CAACjE,eAAA,CAAKwD,OAAL,CAAaD,OAAb,CAAD,CAAhB,KAA4CU,gBAAgB,CAACV,OAAD,CAA7F,EAAwG;MACtGM,GAAG,CAACN,OAAD,CAAH,GAAeU,gBAAgB,CAACV,OAAD,CAA/B;IACD;;IAED,OAAOM,GAAP;EACD,CAN6B,EAM3B,EAN2B,CAA9B,CAvC6E,CA8C7E;;EACA,IAAII,gBAAgB,CAACP,OAAD,CAApB,EAA+BkB,qBAAqB,CAAClB,OAAD,CAArB,GAAiCO,gBAAgB,CAACP,OAAD,CAAjD;EAE/B,MAAMmB,qBAAqB,GAAG,IAAAC,kBAAA,EAASF,qBAAT,CAA9B;EAEA,OAAOb,MAAM,CAACC,IAAP,CAAYa,qBAAZ,EAAmCpG,GAAnC,CAAwC6F,QAAD,KAAe;IAC3D1F,GAAG,EAAE0F,QAAQ,CAACS,KAAT,CAAe,GAAf,CADsD;IAE3D/F,KAAK,EAAE6F,qBAAqB,CAACP,QAAD;EAF+B,CAAf,CAAvC,CAAP;AAID"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "0.0.872",
3
+ "version": "0.0.874",
4
4
  "homepage": "https://bit.dev/teambit/typescript/typescript",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.typescript",
8
8
  "name": "typescript",
9
- "version": "0.0.872"
9
+ "version": "0.0.874"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -19,22 +19,22 @@
19
19
  "@babel/runtime": "7.12.18",
20
20
  "core-js": "^3.0.0",
21
21
  "@teambit/harmony": "0.3.3",
22
- "@teambit/compiler": "0.0.872",
22
+ "@teambit/compiler": "0.0.874",
23
23
  "@teambit/typescript.modules.ts-config-mutator": "0.0.74",
24
- "@teambit/component": "0.0.872",
25
- "@teambit/dependency-resolver": "0.0.872",
24
+ "@teambit/component": "0.0.874",
25
+ "@teambit/dependency-resolver": "0.0.874",
26
26
  "@teambit/semantics.entities.semantic-schema": "0.0.38",
27
27
  "@teambit/ts-server": "0.0.38",
28
- "@teambit/aspect-loader": "0.0.872",
29
- "@teambit/envs": "0.0.872",
30
- "@teambit/logger": "0.0.675",
31
- "@teambit/workspace": "0.0.872",
28
+ "@teambit/aspect-loader": "0.0.874",
29
+ "@teambit/envs": "0.0.874",
30
+ "@teambit/logger": "0.0.677",
31
+ "@teambit/workspace": "0.0.874",
32
32
  "@teambit/bit-error": "0.0.400",
33
- "@teambit/builder": "0.0.872",
34
- "@teambit/isolator": "0.0.872",
35
- "@teambit/schema": "0.0.872",
36
- "@teambit/cli": "0.0.582",
37
- "@teambit/pkg": "0.0.872"
33
+ "@teambit/builder": "0.0.874",
34
+ "@teambit/isolator": "0.0.874",
35
+ "@teambit/schema": "0.0.874",
36
+ "@teambit/cli": "0.0.584",
37
+ "@teambit/pkg": "0.0.874"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/lodash": "4.14.165",
@@ -50,7 +50,7 @@
50
50
  "@teambit/typescript.aspect-docs.typescript": "0.0.145"
51
51
  },
52
52
  "peerDependencies": {
53
- "@teambit/legacy": "1.0.363",
53
+ "@teambit/legacy": "1.0.365",
54
54
  "react-dom": "^16.8.0 || ^17.0.0",
55
55
  "react": "^16.8.0 || ^17.0.0"
56
56
  },
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.872/dist/typescript.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.872/dist/typescript.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.874/dist/typescript.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.874/dist/typescript.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];