@teambit/formatter 0.0.432 → 0.0.433

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.
@@ -1,56 +1,40 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.FormatCmd = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function _timer() {
25
18
  const data = require("@teambit/legacy/dist/toolbox/timer");
26
-
27
19
  _timer = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  function _chalk() {
35
25
  const data = _interopRequireDefault(require("chalk"));
36
-
37
26
  _chalk = function () {
38
27
  return data;
39
28
  };
40
-
41
29
  return data;
42
30
  }
43
-
44
31
  function _lodash() {
45
32
  const data = require("lodash");
46
-
47
33
  _lodash = function () {
48
34
  return data;
49
35
  };
50
-
51
36
  return data;
52
37
  }
53
-
54
38
  class FormatCmd {
55
39
  constructor(formatter, componentHost, workspace) {
56
40
  this.formatter = formatter;
@@ -61,16 +45,13 @@ class FormatCmd {
61
45
  (0, _defineProperty2().default)(this, "group", 'development');
62
46
  (0, _defineProperty2().default)(this, "options", [['c', 'changed', 'format only new and modified components'], ['', 'check', 'will output a human-friendly message and a list of unformatted files, if any'], ['j', 'json', 'return the format results in json format']]);
63
47
  }
64
-
65
48
  async report([components = []], formatterOptions) {
66
49
  const {
67
50
  duration,
68
51
  data,
69
52
  componentsIdsToFormat
70
53
  } = await this.json([components], formatterOptions);
71
-
72
54
  const title = _chalk().default.bold(`formatting total of ${_chalk().default.cyan(componentsIdsToFormat.length.toString())} component(s) in workspace '${_chalk().default.cyan(this.componentHost.name)}`);
73
-
74
55
  const componentsOutputs = this.getAllComponentsResultOutput(data.results, {
75
56
  check: formatterOptions.check
76
57
  });
@@ -80,10 +61,8 @@ class FormatCmd {
80
61
  const summery = `formatted ${_chalk().default.cyan(componentsIdsToFormat.length.toString())} components in ${_chalk().default.cyan(seconds.toString())}.`;
81
62
  return `${title}\n\n${componentsOutputs}\n\n${summery}`;
82
63
  }
83
-
84
64
  async json([components = []], formatterCmdOptions) {
85
65
  const timer = _timer().Timer.create();
86
-
87
66
  timer.start();
88
67
  const componentsIds = await this.getIdsToFormat(components, formatterCmdOptions.changed);
89
68
  const componentsToFormat = await this.workspace.getMany(componentsIds);
@@ -97,57 +76,42 @@ class FormatCmd {
97
76
  componentsIdsToFormat: componentsToFormat.map(comp => comp.id.toString())
98
77
  };
99
78
  }
100
-
101
79
  async getIdsToFormat(components, changed = false) {
102
80
  if (components.length) {
103
81
  return this.workspace.resolveMultipleComponentIds(components);
104
82
  }
105
-
106
83
  if (changed) {
107
84
  return this.workspace.getNewAndModifiedIds();
108
85
  }
109
-
110
86
  return this.componentHost.listIds();
111
87
  }
112
-
113
88
  getAllComponentsResultOutput(componentsResult, context) {
114
89
  const allResults = componentsResult.map(comp => this.getOneComponentResultOutput(comp, context));
115
90
  return allResults.join('\n\n');
116
91
  }
117
-
118
92
  getOneComponentResultOutput(componentResult, context) {
119
93
  const title = _chalk().default.bold.cyan(componentResult.componentId.toString({
120
94
  ignoreVersion: true
121
95
  }));
122
-
123
96
  const filesWithIssues = componentResult.results.filter(fileResult => fileResult.hasIssues);
124
-
125
97
  if (!filesWithIssues || !filesWithIssues.length) {
126
98
  return `${title}\n${_chalk().default.green('no issues found')}`;
127
99
  }
128
-
129
100
  let subTitle = _chalk().default.green('the following files have been re-formatted:');
130
-
131
101
  if (context.check) {
132
102
  subTitle = _chalk().default.red('issues found in the following files:');
133
103
  }
134
-
135
104
  const files = filesWithIssues.map(this.getOneComponentFileResultOutput);
136
105
  return `${title}\n${subTitle}\n${files.join('\n')}`;
137
106
  }
138
-
139
107
  getOneComponentFileResultOutput(fileResult) {
140
108
  return fileResult.filePath;
141
109
  }
142
-
143
110
  }
144
-
145
111
  exports.FormatCmd = FormatCmd;
146
-
147
112
  function toJsonFormatResults(results) {
148
113
  const newResults = results.results.map(res => {
149
114
  var _res$data;
150
-
151
115
  const resultsWithoutComponent = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.results.map(result => {
152
116
  return {
153
117
  componentId: result.component.id,
@@ -1 +1 @@
1
- {"version":3,"names":["FormatCmd","constructor","formatter","componentHost","workspace","report","components","formatterOptions","duration","data","componentsIdsToFormat","json","title","chalk","bold","cyan","length","toString","name","componentsOutputs","getAllComponentsResultOutput","results","check","seconds","summery","formatterCmdOptions","timer","Timer","create","start","componentsIds","getIdsToFormat","changed","componentsToFormat","getMany","opts","formatterResults","format","jsonFormatterResults","toJsonFormatResults","timerResponse","stop","map","comp","id","resolveMultipleComponentIds","getNewAndModifiedIds","listIds","componentsResult","context","allResults","getOneComponentResultOutput","join","componentResult","componentId","ignoreVersion","filesWithIssues","filter","fileResult","hasIssues","green","subTitle","red","files","getOneComponentFileResultOutput","filePath","newResults","res","resultsWithoutComponent","result","component","compact","flatten","errors"],"sources":["format.cmd.ts"],"sourcesContent":["import { TimerResponse, Timer } from '@teambit/legacy/dist/toolbox/timer';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentFactory, ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport { EnvsExecutionResult } from '@teambit/envs';\nimport { Workspace } from '@teambit/workspace';\nimport { compact, flatten } from 'lodash';\nimport { FormatterMain } from './formatter.main.runtime';\nimport { ComponentFormatResult, FormatResults, FileFormatResult } from './formatter';\nimport { FormatterOptions } from './formatter-context';\n\nexport type FormatCmdOptions = {\n changed?: boolean;\n json?: boolean;\n check?: boolean;\n};\n\ntype OutputContext = {\n check?: boolean;\n};\n\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonComponentFormatResult = Omit<ComponentFormatResult, 'component'> & {\n componentId: ComponentID;\n};\n\nexport type JsonFormatDataResults = Omit<FormatResults, 'results'> & { results: JsonComponentFormatResult[] };\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonFormatResults = {\n duration: TimerResponse;\n data: JsonFormatDataResults;\n componentsIdsToFormat: string[];\n};\n\nexport class FormatCmd implements Command {\n name = 'format [component...]';\n description = 'format components in the development workspace';\n group = 'development';\n options = [\n ['c', 'changed', 'format only new and modified components'],\n ['', 'check', 'will output a human-friendly message and a list of unformatted files, if any'],\n ['j', 'json', 'return the format results in json format'],\n ] as CommandOptions;\n\n constructor(\n private formatter: FormatterMain,\n private componentHost: ComponentFactory,\n private workspace: Workspace\n ) {}\n\n async report([components = []]: [string[]], formatterOptions: FormatCmdOptions) {\n const { duration, data, componentsIdsToFormat } = await this.json([components], formatterOptions);\n\n const title = chalk.bold(\n `formatting total of ${chalk.cyan(\n componentsIdsToFormat.length.toString()\n )} component(s) in workspace '${chalk.cyan(this.componentHost.name)}`\n );\n\n const componentsOutputs = this.getAllComponentsResultOutput(data.results, { check: formatterOptions.check });\n\n const { seconds } = duration;\n const summery = `formatted ${chalk.cyan(componentsIdsToFormat.length.toString())} components in ${chalk.cyan(\n seconds.toString()\n )}.`;\n\n return `${title}\\n\\n${componentsOutputs}\\n\\n${summery}`;\n }\n\n async json([components = []]: [string[]], formatterCmdOptions: FormatCmdOptions): Promise<JsonFormatResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToFormat(components, formatterCmdOptions.changed);\n const componentsToFormat = await this.workspace.getMany(componentsIds);\n const opts: FormatterOptions = {};\n const formatterResults = formatterCmdOptions.check\n ? await this.formatter.check(componentsToFormat, opts)\n : await this.formatter.format(componentsToFormat, opts);\n const jsonFormatterResults = toJsonFormatResults(formatterResults);\n const timerResponse = timer.stop();\n return {\n duration: timerResponse,\n data: jsonFormatterResults,\n componentsIdsToFormat: componentsToFormat.map((comp) => comp.id.toString()),\n };\n }\n\n private async getIdsToFormat(components: string[], changed = false): Promise<ComponentID[]> {\n if (components.length) {\n return this.workspace.resolveMultipleComponentIds(components);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.componentHost.listIds();\n }\n\n private getAllComponentsResultOutput(componentsResult: JsonComponentFormatResult[], context: OutputContext) {\n const allResults = componentsResult.map((comp) => this.getOneComponentResultOutput(comp, context));\n return allResults.join('\\n\\n');\n }\n\n private getOneComponentResultOutput(componentResult: JsonComponentFormatResult, context: OutputContext) {\n const title = chalk.bold.cyan(componentResult.componentId.toString({ ignoreVersion: true }));\n const filesWithIssues = componentResult.results.filter((fileResult) => fileResult.hasIssues);\n if (!filesWithIssues || !filesWithIssues.length) {\n return `${title}\\n${chalk.green('no issues found')}`;\n }\n let subTitle = chalk.green('the following files have been re-formatted:');\n if (context.check) {\n subTitle = chalk.red('issues found in the following files:');\n }\n const files = filesWithIssues.map(this.getOneComponentFileResultOutput);\n return `${title}\\n${subTitle}\\n${files.join('\\n')}`;\n }\n\n private getOneComponentFileResultOutput(fileResult: FileFormatResult) {\n return fileResult.filePath;\n }\n}\n\nfunction toJsonFormatResults(results: EnvsExecutionResult<FormatResults>): JsonFormatDataResults {\n const newResults = results.results.map((res) => {\n const resultsWithoutComponent = res.data?.results.map((result) => {\n return {\n componentId: result.component.id,\n results: result.results,\n };\n });\n return compact(resultsWithoutComponent);\n });\n return {\n results: compact(flatten(newResults)),\n errors: results?.errors,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAgCO,MAAMA,SAAN,CAAmC;EAUxCC,WAAW,CACDC,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gBqB,GAAhB,CAAqByB,GAAD,IAAS;IAAA;;IAC9C,MAAMC,uBAAuB,gBAAGD,GAAG,CAAC1D,IAAP,8CAAG,UAAUY,OAAV,CAAkBqB,GAAlB,CAAuB2B,MAAD,IAAY;MAChE,OAAO;QACLf,WAAW,EAAEe,MAAM,CAACC,SAAP,CAAiB1B,EADzB;QAELvB,OAAO,EAAEgD,MAAM,CAAChD;MAFX,CAAP;IAID,CAL+B,CAAhC;IAMA,OAAO,IAAAkD,iBAAA,EAAQH,uBAAR,CAAP;EACD,CARkB,CAAnB;EASA,OAAO;IACL/C,OAAO,EAAE,IAAAkD,iBAAA,EAAQ,IAAAC,iBAAA,EAAQN,UAAR,CAAR,CADJ;IAELO,MAAM,EAAEpD,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEoD;EAFZ,CAAP;AAID"}
1
+ {"version":3,"names":["FormatCmd","constructor","formatter","componentHost","workspace","report","components","formatterOptions","duration","data","componentsIdsToFormat","json","title","chalk","bold","cyan","length","toString","name","componentsOutputs","getAllComponentsResultOutput","results","check","seconds","summery","formatterCmdOptions","timer","Timer","create","start","componentsIds","getIdsToFormat","changed","componentsToFormat","getMany","opts","formatterResults","format","jsonFormatterResults","toJsonFormatResults","timerResponse","stop","map","comp","id","resolveMultipleComponentIds","getNewAndModifiedIds","listIds","componentsResult","context","allResults","getOneComponentResultOutput","join","componentResult","componentId","ignoreVersion","filesWithIssues","filter","fileResult","hasIssues","green","subTitle","red","files","getOneComponentFileResultOutput","filePath","newResults","res","resultsWithoutComponent","result","component","compact","flatten","errors"],"sources":["format.cmd.ts"],"sourcesContent":["import { TimerResponse, Timer } from '@teambit/legacy/dist/toolbox/timer';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentFactory, ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport { EnvsExecutionResult } from '@teambit/envs';\nimport { Workspace } from '@teambit/workspace';\nimport { compact, flatten } from 'lodash';\nimport { FormatterMain } from './formatter.main.runtime';\nimport { ComponentFormatResult, FormatResults, FileFormatResult } from './formatter';\nimport { FormatterOptions } from './formatter-context';\n\nexport type FormatCmdOptions = {\n changed?: boolean;\n json?: boolean;\n check?: boolean;\n};\n\ntype OutputContext = {\n check?: boolean;\n};\n\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonComponentFormatResult = Omit<ComponentFormatResult, 'component'> & {\n componentId: ComponentID;\n};\n\nexport type JsonFormatDataResults = Omit<FormatResults, 'results'> & { results: JsonComponentFormatResult[] };\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonFormatResults = {\n duration: TimerResponse;\n data: JsonFormatDataResults;\n componentsIdsToFormat: string[];\n};\n\nexport class FormatCmd implements Command {\n name = 'format [component...]';\n description = 'format components in the development workspace';\n group = 'development';\n options = [\n ['c', 'changed', 'format only new and modified components'],\n ['', 'check', 'will output a human-friendly message and a list of unformatted files, if any'],\n ['j', 'json', 'return the format results in json format'],\n ] as CommandOptions;\n\n constructor(\n private formatter: FormatterMain,\n private componentHost: ComponentFactory,\n private workspace: Workspace\n ) {}\n\n async report([components = []]: [string[]], formatterOptions: FormatCmdOptions) {\n const { duration, data, componentsIdsToFormat } = await this.json([components], formatterOptions);\n\n const title = chalk.bold(\n `formatting total of ${chalk.cyan(\n componentsIdsToFormat.length.toString()\n )} component(s) in workspace '${chalk.cyan(this.componentHost.name)}`\n );\n\n const componentsOutputs = this.getAllComponentsResultOutput(data.results, { check: formatterOptions.check });\n\n const { seconds } = duration;\n const summery = `formatted ${chalk.cyan(componentsIdsToFormat.length.toString())} components in ${chalk.cyan(\n seconds.toString()\n )}.`;\n\n return `${title}\\n\\n${componentsOutputs}\\n\\n${summery}`;\n }\n\n async json([components = []]: [string[]], formatterCmdOptions: FormatCmdOptions): Promise<JsonFormatResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToFormat(components, formatterCmdOptions.changed);\n const componentsToFormat = await this.workspace.getMany(componentsIds);\n const opts: FormatterOptions = {};\n const formatterResults = formatterCmdOptions.check\n ? await this.formatter.check(componentsToFormat, opts)\n : await this.formatter.format(componentsToFormat, opts);\n const jsonFormatterResults = toJsonFormatResults(formatterResults);\n const timerResponse = timer.stop();\n return {\n duration: timerResponse,\n data: jsonFormatterResults,\n componentsIdsToFormat: componentsToFormat.map((comp) => comp.id.toString()),\n };\n }\n\n private async getIdsToFormat(components: string[], changed = false): Promise<ComponentID[]> {\n if (components.length) {\n return this.workspace.resolveMultipleComponentIds(components);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.componentHost.listIds();\n }\n\n private getAllComponentsResultOutput(componentsResult: JsonComponentFormatResult[], context: OutputContext) {\n const allResults = componentsResult.map((comp) => this.getOneComponentResultOutput(comp, context));\n return allResults.join('\\n\\n');\n }\n\n private getOneComponentResultOutput(componentResult: JsonComponentFormatResult, context: OutputContext) {\n const title = chalk.bold.cyan(componentResult.componentId.toString({ ignoreVersion: true }));\n const filesWithIssues = componentResult.results.filter((fileResult) => fileResult.hasIssues);\n if (!filesWithIssues || !filesWithIssues.length) {\n return `${title}\\n${chalk.green('no issues found')}`;\n }\n let subTitle = chalk.green('the following files have been re-formatted:');\n if (context.check) {\n subTitle = chalk.red('issues found in the following files:');\n }\n const files = filesWithIssues.map(this.getOneComponentFileResultOutput);\n return `${title}\\n${subTitle}\\n${files.join('\\n')}`;\n }\n\n private getOneComponentFileResultOutput(fileResult: FileFormatResult) {\n return fileResult.filePath;\n }\n}\n\nfunction toJsonFormatResults(results: EnvsExecutionResult<FormatResults>): JsonFormatDataResults {\n const newResults = results.results.map((res) => {\n const resultsWithoutComponent = res.data?.results.map((result) => {\n return {\n componentId: result.component.id,\n results: result.results,\n };\n });\n return compact(resultsWithoutComponent);\n });\n return {\n results: compact(flatten(newResults)),\n errors: results?.errors,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AA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AE;IACpE,OAAOA,UAAU,CAACO,QAAQ;EAC5B;AACF;AAAC;AAED,SAAS1B,mBAAmB,CAAClB,OAA2C,EAAyB;EAC/F,MAAM6C,UAAU,GAAG7C,OAAO,CAACA,OAAO,CAACqB,GAAG,CAAEyB,GAAG,IAAK;IAAA;IAC9C,MAAMC,uBAAuB,gBAAGD,GAAG,CAAC1D,IAAI,8CAAR,UAAUY,OAAO,CAACqB,GAAG,CAAE2B,MAAM,IAAK;MAChE,OAAO;QACLf,WAAW,EAAEe,MAAM,CAACC,SAAS,CAAC1B,EAAE;QAChCvB,OAAO,EAAEgD,MAAM,CAAChD;MAClB,CAAC;IACH,CAAC,CAAC;IACF,OAAO,IAAAkD,iBAAO,EAACH,uBAAuB,CAAC;EACzC,CAAC,CAAC;EACF,OAAO;IACL/C,OAAO,EAAE,IAAAkD,iBAAO,EAAC,IAAAC,iBAAO,EAACN,UAAU,CAAC,CAAC;IACrCO,MAAM,EAAEpD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEoD;EACnB,CAAC;AACH"}
@@ -1,21 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.promise.js");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.FormatTask = void 0;
9
-
10
8
  class FormatTask {
11
9
  constructor(aspectId, name = 'format') {
12
10
  this.aspectId = aspectId;
13
11
  this.name = name;
14
12
  }
15
-
16
13
  async execute(context) {
17
- const formatter = context.env.getFormatter(); // TODO: add option to select between check and format here
18
-
14
+ const formatter = context.env.getFormatter();
15
+ // TODO: add option to select between check and format here
19
16
  const results = await formatter.check(context);
20
17
  const componentsResults = results.results.map(formatResult => {
21
18
  return {
@@ -30,9 +27,7 @@ class FormatTask {
30
27
  componentsResults
31
28
  };
32
29
  }
33
-
34
30
  }
35
-
36
31
  exports.FormatTask = FormatTask;
37
32
 
38
33
  //# sourceMappingURL=format.task.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FormatTask","constructor","aspectId","name","execute","context","formatter","env","getFormatter","results","check","componentsResults","map","formatResult","component","metadata","errors"],"sources":["format.task.ts"],"sourcesContent":["import { BuildTask, BuiltTaskResult, BuildContext, ComponentResult } from '@teambit/builder';\nimport { Formatter } from './formatter';\n\nexport class FormatTask implements BuildTask {\n constructor(readonly aspectId: string, readonly name = 'format') {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const formatter: Formatter = context.env.getFormatter();\n // TODO: add option to select between check and format here\n const results = await formatter.check(context);\n const componentsResults = results.results.map((formatResult): ComponentResult => {\n return {\n component: formatResult.component,\n metadata: {\n results: formatResult.results,\n },\n errors: [],\n };\n });\n\n return {\n componentsResults,\n };\n }\n}\n"],"mappings":";;;;;;;;;AAGO,MAAMA,UAAN,CAAsC;EAC3CC,WAAW,CAAUC,QAAV,EAAqCC,IAAI,GAAG,QAA5C,EAAsD;IAAA,KAA5CD,QAA4C,GAA5CA,QAA4C;IAAA,KAAjBC,IAAiB,GAAjBA,IAAiB;EAAE;;EAEtD,MAAPC,OAAO,CAACC,OAAD,EAAkD;IAC7D,MAAMC,SAAoB,GAAGD,OAAO,CAACE,GAAR,CAAYC,YAAZ,EAA7B,CAD6D,CAE7D;;IACA,MAAMC,OAAO,GAAG,MAAMH,SAAS,CAACI,KAAV,CAAgBL,OAAhB,CAAtB;IACA,MAAMM,iBAAiB,GAAGF,OAAO,CAACA,OAAR,CAAgBG,GAAhB,CAAqBC,YAAD,IAAmC;MAC/E,OAAO;QACLC,SAAS,EAAED,YAAY,CAACC,SADnB;QAELC,QAAQ,EAAE;UACRN,OAAO,EAAEI,YAAY,CAACJ;QADd,CAFL;QAKLO,MAAM,EAAE;MALH,CAAP;IAOD,CARyB,CAA1B;IAUA,OAAO;MACLL;IADK,CAAP;EAGD;;AApB0C"}
1
+ {"version":3,"names":["FormatTask","constructor","aspectId","name","execute","context","formatter","env","getFormatter","results","check","componentsResults","map","formatResult","component","metadata","errors"],"sources":["format.task.ts"],"sourcesContent":["import { BuildTask, BuiltTaskResult, BuildContext, ComponentResult } from '@teambit/builder';\nimport { Formatter } from './formatter';\n\nexport class FormatTask implements BuildTask {\n constructor(readonly aspectId: string, readonly name = 'format') {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const formatter: Formatter = context.env.getFormatter();\n // TODO: add option to select between check and format here\n const results = await formatter.check(context);\n const componentsResults = results.results.map((formatResult): ComponentResult => {\n return {\n component: formatResult.component,\n metadata: {\n results: formatResult.results,\n },\n errors: [],\n };\n });\n\n return {\n componentsResults,\n };\n }\n}\n"],"mappings":";;;;;;;AAGO,MAAMA,UAAU,CAAsB;EAC3CC,WAAW,CAAUC,QAAgB,EAAWC,IAAI,GAAG,QAAQ,EAAE;IAAA,KAA5CD,QAAgB,GAAhBA,QAAgB;IAAA,KAAWC,IAAI,GAAJA,IAAI;EAAc;EAElE,MAAMC,OAAO,CAACC,OAAqB,EAA4B;IAC7D,MAAMC,SAAoB,GAAGD,OAAO,CAACE,GAAG,CAACC,YAAY,EAAE;IACvD;IACA,MAAMC,OAAO,GAAG,MAAMH,SAAS,CAACI,KAAK,CAACL,OAAO,CAAC;IAC9C,MAAMM,iBAAiB,GAAGF,OAAO,CAACA,OAAO,CAACG,GAAG,CAAEC,YAAY,IAAsB;MAC/E,OAAO;QACLC,SAAS,EAAED,YAAY,CAACC,SAAS;QACjCC,QAAQ,EAAE;UACRN,OAAO,EAAEI,YAAY,CAACJ;QACxB,CAAC;QACDO,MAAM,EAAE;MACV,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;MACLL;IACF,CAAC;EACH;AACF;AAAC"}
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.FormatterAspect = void 0;
7
-
8
7
  function _harmony() {
9
8
  const data = require("@teambit/harmony");
10
-
11
9
  _harmony = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  const FormatterAspect = _harmony().Aspect.create({
19
15
  id: 'teambit.defender/formatter'
20
16
  });
21
-
22
17
  exports.FormatterAspect = FormatterAspect;
23
18
 
24
19
  //# sourceMappingURL=formatter.aspect.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FormatterAspect","Aspect","create","id"],"sources":["formatter.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const FormatterAspect = Aspect.create({\n id: 'teambit.defender/formatter',\n});\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,eAAe,GAAGC,iBAAA,CAAOC,MAAP,CAAc;EAC3CC,EAAE,EAAE;AADuC,CAAd,CAAxB"}
1
+ {"version":3,"names":["FormatterAspect","Aspect","create","id"],"sources":["formatter.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const FormatterAspect = Aspect.create({\n id: 'teambit.defender/formatter',\n});\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,eAAe,GAAGC,iBAAM,CAACC,MAAM,CAAC;EAC3CC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC"}
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.Logo = void 0;
9
-
10
8
  function _react() {
11
9
  const data = _interopRequireDefault(require("react"));
12
-
13
10
  _react = function () {
14
11
  return data;
15
12
  };
16
-
17
13
  return data;
18
14
  }
19
-
20
15
  const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
21
16
  style: {
22
17
  height: '100%',
@@ -29,7 +24,6 @@ const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
29
24
  },
30
25
  src: "https://static.bit.dev/extensions-icons/formatter.svg"
31
26
  }));
32
-
33
27
  exports.Logo = Logo;
34
28
 
35
29
  //# sourceMappingURL=formatter.composition.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["formatter.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/formatter.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAV;IAAkBC,OAAO,EAAE,MAA3B;IAAmCC,cAAc,EAAE;EAAnD;AAAZ,gBACE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAT,CAAZ;EAA2B,GAAG,EAAC;AAA/B,EADF,CADK"}
1
+ {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["formatter.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/formatter.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAG,CAAE;EAAC,GAAG,EAAC;AAAuD,EAAG,CAE5F;AAAC"}
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.linterSchema = linterSchema;
9
-
10
8
  function _graphqlTag() {
11
9
  const data = _interopRequireDefault(require("graphql-tag"));
12
-
13
10
  _graphqlTag = function () {
14
11
  return data;
15
12
  };
16
-
17
13
  return data;
18
14
  }
19
-
20
15
  function linterSchema() {
21
16
  return {
22
17
  typeDefs: (0, _graphqlTag().default)``,
@@ -1 +1 @@
1
- {"version":3,"names":["linterSchema","typeDefs","gql","resolvers"],"sources":["formatter.graphql.ts"],"sourcesContent":["import gql from 'graphql-tag';\n\nexport function linterSchema() {\n return {\n typeDefs: gql``,\n resolvers: {},\n };\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,SAASA,YAAT,GAAwB;EAC7B,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAA,CAAI,EADT;IAELC,SAAS,EAAE;EAFN,CAAP;AAID"}
1
+ {"version":3,"names":["linterSchema","typeDefs","gql","resolvers"],"sources":["formatter.graphql.ts"],"sourcesContent":["import gql from 'graphql-tag';\n\nexport function linterSchema() {\n return {\n typeDefs: gql``,\n resolvers: {},\n };\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,SAASA,YAAY,GAAG;EAC7B,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAG,CAAC,EAAC;IACfC,SAAS,EAAE,CAAC;EACd,CAAC;AACH"}
@@ -1,161 +1,120 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.FormatterMain = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function _cli() {
25
18
  const data = require("@teambit/cli");
26
-
27
19
  _cli = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  function _component() {
35
25
  const data = require("@teambit/component");
36
-
37
26
  _component = function () {
38
27
  return data;
39
28
  };
40
-
41
29
  return data;
42
30
  }
43
-
44
31
  function _envs() {
45
32
  const data = require("@teambit/envs");
46
-
47
33
  _envs = function () {
48
34
  return data;
49
35
  };
50
-
51
36
  return data;
52
37
  }
53
-
54
38
  function _logger() {
55
39
  const data = require("@teambit/logger");
56
-
57
40
  _logger = function () {
58
41
  return data;
59
42
  };
60
-
61
43
  return data;
62
44
  }
63
-
64
45
  function _workspace() {
65
46
  const data = require("@teambit/workspace");
66
-
67
47
  _workspace = function () {
68
48
  return data;
69
49
  };
70
-
71
50
  return data;
72
51
  }
73
-
74
52
  function _formatter() {
75
53
  const data = require("./formatter.aspect");
76
-
77
54
  _formatter = function () {
78
55
  return data;
79
56
  };
80
-
81
57
  return data;
82
58
  }
83
-
84
59
  function _formatter2() {
85
60
  const data = require("./formatter.service");
86
-
87
61
  _formatter2 = function () {
88
62
  return data;
89
63
  };
90
-
91
64
  return data;
92
65
  }
93
-
94
66
  function _format() {
95
67
  const data = require("./format.task");
96
-
97
68
  _format = function () {
98
69
  return data;
99
70
  };
100
-
101
71
  return data;
102
72
  }
103
-
104
73
  function _format2() {
105
74
  const data = require("./format.cmd");
106
-
107
75
  _format2 = function () {
108
76
  return data;
109
77
  };
110
-
111
78
  return data;
112
79
  }
113
-
114
80
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
115
-
116
81
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
117
-
118
82
  class FormatterMain {
119
83
  constructor(envs, formatterService) {
120
84
  this.envs = envs;
121
85
  this.formatterService = formatterService;
122
86
  }
87
+
123
88
  /**
124
89
  * format an array of components.
125
90
  */
126
-
127
-
128
91
  async format(components, opts) {
129
92
  const envsRuntime = await this.envs.createEnvironment(components);
130
93
  const formatResults = envsRuntime.run(this.formatterService, this.toFormatServiceOptions(opts, false));
131
94
  return formatResults;
132
95
  }
96
+
133
97
  /**
134
98
  * check format an array of components.
135
99
  */
136
-
137
-
138
100
  async check(components, opts) {
139
101
  const envsRuntime = await this.envs.createEnvironment(components);
140
102
  const formatResults = envsRuntime.run(this.formatterService, this.toFormatServiceOptions(opts, true));
141
103
  return formatResults;
142
104
  }
143
-
144
105
  toFormatServiceOptions(opts, check = false) {
145
106
  return _objectSpread(_objectSpread({}, opts), {}, {
146
107
  check
147
108
  });
148
109
  }
110
+
149
111
  /**
150
112
  * create a format task for build pipelines.
151
113
  * @param name name of the task.
152
114
  */
153
-
154
-
155
115
  createTask(name) {
156
116
  return new (_format().FormatTask)(_formatter().FormatterAspect.id, name);
157
117
  }
158
-
159
118
  static async provider([envs, cli, component, loggerAspect, workspace], config) {
160
119
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
161
120
  const logger = loggerAspect.createLogger(_formatter().FormatterAspect.id);
@@ -165,14 +124,11 @@ class FormatterMain {
165
124
  cli.register(new (_format2().FormatCmd)(formatterAspect, component.getHost(), workspace));
166
125
  return formatterAspect;
167
126
  }
168
-
169
127
  }
170
-
171
128
  exports.FormatterMain = FormatterMain;
172
129
  (0, _defineProperty2().default)(FormatterMain, "runtime", _cli().MainRuntime);
173
130
  (0, _defineProperty2().default)(FormatterMain, "dependencies", [_envs().EnvsAspect, _cli().CLIAspect, _component().ComponentAspect, _logger().LoggerAspect, _workspace().WorkspaceAspect]);
174
131
  (0, _defineProperty2().default)(FormatterMain, "defaultConfig", {});
175
-
176
132
  _formatter().FormatterAspect.addRuntime(FormatterMain);
177
133
 
178
134
  //# sourceMappingURL=formatter.main.runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FormatterMain","constructor","envs","formatterService","format","components","opts","envsRuntime","createEnvironment","formatResults","run","toFormatServiceOptions","check","createTask","name","FormatTask","FormatterAspect","id","provider","cli","component","loggerAspect","workspace","config","logger","createLogger","FormatterService","formatterAspect","registerService","register","FormatCmd","getHost","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","LoggerAspect","WorkspaceAspect","addRuntime"],"sources":["formatter.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain } from '@teambit/component';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { FormatterAspect } from './formatter.aspect';\nimport { FormatterService, FormatterServiceOptions } from './formatter.service';\nimport { FormatTask } from './format.task';\nimport { FormatCmd } from './format.cmd';\nimport { FormatterOptions } from './formatter-context';\n\nexport type FormatterConfig = {};\nexport class FormatterMain {\n static runtime = MainRuntime;\n\n constructor(private envs: EnvsMain, private formatterService: FormatterService) {}\n\n /**\n * format an array of components.\n */\n async format(components: Component[], opts: FormatterOptions) {\n const envsRuntime = await this.envs.createEnvironment(components);\n const formatResults = envsRuntime.run(this.formatterService, this.toFormatServiceOptions(opts, false));\n return formatResults;\n }\n\n /**\n * check format an array of components.\n */\n async check(components: Component[], opts: FormatterOptions) {\n const envsRuntime = await this.envs.createEnvironment(components);\n const formatResults = envsRuntime.run(this.formatterService, this.toFormatServiceOptions(opts, true));\n return formatResults;\n }\n\n private toFormatServiceOptions(opts: FormatterOptions, check = false): FormatterServiceOptions {\n return {\n ...opts,\n check,\n };\n }\n\n /**\n * create a format task for build pipelines.\n * @param name name of the task.\n */\n createTask(name?: string): FormatTask {\n return new FormatTask(FormatterAspect.id, name);\n }\n\n static dependencies = [EnvsAspect, CLIAspect, ComponentAspect, LoggerAspect, WorkspaceAspect];\n\n static defaultConfig: FormatterConfig = {};\n\n static async provider(\n [envs, cli, component, loggerAspect, workspace]: [EnvsMain, CLIMain, ComponentMain, LoggerMain, Workspace],\n config: FormatterConfig\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const logger = loggerAspect.createLogger(FormatterAspect.id);\n const formatterService = new FormatterService(config);\n const formatterAspect = new FormatterMain(envs, formatterService);\n envs.registerService(formatterService);\n cli.register(new FormatCmd(formatterAspect, component.getHost(), workspace));\n\n return formatterAspect;\n }\n}\n\nFormatterAspect.addRuntime(FormatterMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAIO,MAAMA,aAAN,CAAoB;EAGzBC,WAAW,CAASC,IAAT,EAAiCC,gBAAjC,EAAqE;IAAA,KAA5DD,IAA4D,GAA5DA,IAA4D;IAAA,KAApCC,gBAAoC,GAApCA,gBAAoC;EAAE;EAElF;AACF;AACA;;;EACc,MAANC,MAAM,CAACC,UAAD,EAA0BC,IAA1B,EAAkD;IAC5D,MA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,eAAd,EAA+BP,SAAS,CAACW,OAAV,EAA/B,EAAoDT,SAApD,CAAb;IAEA,OAAOK,eAAP;EACD;;AAtDwB;;;gCAAd3B,a,aACMgC,kB;gCADNhC,a,kBAsCW,CAACiC,kBAAD,EAAaC,gBAAb,EAAwBC,4BAAxB,EAAyCC,sBAAzC,EAAuDC,4BAAvD,C;gCAtCXrC,a,mBAwC6B,E;;AAiB1CgB,4BAAA,CAAgBsB,UAAhB,CAA2BtC,aAA3B"}
1
+ {"version":3,"names":["FormatterMain","constructor","envs","formatterService","format","components","opts","envsRuntime","createEnvironment","formatResults","run","toFormatServiceOptions","check","createTask","name","FormatTask","FormatterAspect","id","provider","cli","component","loggerAspect","workspace","config","logger","createLogger","FormatterService","formatterAspect","registerService","register","FormatCmd","getHost","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","LoggerAspect","WorkspaceAspect","addRuntime"],"sources":["formatter.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain } from '@teambit/component';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { FormatterAspect } from './formatter.aspect';\nimport { FormatterService, FormatterServiceOptions } from './formatter.service';\nimport { FormatTask } from './format.task';\nimport { FormatCmd } from './format.cmd';\nimport { FormatterOptions } from './formatter-context';\n\nexport type FormatterConfig = {};\nexport class FormatterMain {\n static runtime = MainRuntime;\n\n constructor(private envs: EnvsMain, private formatterService: FormatterService) {}\n\n /**\n * format an array of components.\n */\n async format(components: Component[], opts: FormatterOptions) {\n const envsRuntime = await this.envs.createEnvironment(components);\n const formatResults = envsRuntime.run(this.formatterService, this.toFormatServiceOptions(opts, false));\n return formatResults;\n }\n\n /**\n * check format an array of components.\n */\n async check(components: Component[], opts: FormatterOptions) {\n const envsRuntime = await this.envs.createEnvironment(components);\n const formatResults = envsRuntime.run(this.formatterService, this.toFormatServiceOptions(opts, true));\n return formatResults;\n }\n\n private toFormatServiceOptions(opts: FormatterOptions, check = false): FormatterServiceOptions {\n return {\n ...opts,\n check,\n };\n }\n\n /**\n * create a format task for build pipelines.\n * @param name name of the task.\n */\n createTask(name?: string): FormatTask {\n return new FormatTask(FormatterAspect.id, name);\n }\n\n static dependencies = [EnvsAspect, CLIAspect, ComponentAspect, LoggerAspect, WorkspaceAspect];\n\n static defaultConfig: FormatterConfig = {};\n\n static async provider(\n [envs, cli, component, loggerAspect, workspace]: [EnvsMain, CLIMain, ComponentMain, LoggerMain, Workspace],\n config: FormatterConfig\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const logger = loggerAspect.createLogger(FormatterAspect.id);\n const formatterService = new FormatterService(config);\n const formatterAspect = new FormatterMain(envs, formatterService);\n envs.registerService(formatterService);\n cli.register(new FormatCmd(formatterAspect, component.getHost(), workspace));\n\n return formatterAspect;\n }\n}\n\nFormatterAspect.addRuntime(FormatterMain);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAyC;AAAA;AAIlC,MAAMA,aAAa,CAAC;EAGzBC,WAAW,CAASC,IAAc,EAAUC,gBAAkC,EAAE;IAAA,KAA5DD,IAAc,GAAdA,IAAc;IAAA,KAAUC,gBAAkC,GAAlCA,gBAAkC;EAAG;;EAEjF;AACF;AACA;EACE,MAAMC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AAQ,CAAC,KAAIC,oBAAS,EAACH,eAAe,EAAEP,SAAS,CAACW,OAAO,EAAE,EAAET,SAAS,CAAC,CAAC;IAE5E,OAAOK,eAAe;EACxB;AACF;AAAC;AAAA,gCAvDY3B,aAAa,aACPgC,kBAAW;AAAA,gCADjBhC,aAAa,kBAsCF,CAACiC,kBAAU,EAAEC,gBAAS,EAAEC,4BAAe,EAAEC,sBAAY,EAAEC,4BAAe,CAAC;AAAA,gCAtClFrC,aAAa,mBAwCgB,CAAC,CAAC;AAiB5CgB,4BAAe,CAACsB,UAAU,CAACtC,aAAa,CAAC"}
@@ -1,70 +1,51 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.promise.js");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.FormatterService = void 0;
11
-
12
9
  function _defineProperty2() {
13
10
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  _defineProperty2 = function () {
16
12
  return data;
17
13
  };
18
-
19
14
  return data;
20
15
  }
21
-
22
16
  function _lodash() {
23
17
  const data = require("lodash");
24
-
25
18
  _lodash = function () {
26
19
  return data;
27
20
  };
28
-
29
21
  return data;
30
22
  }
31
-
32
23
  function _react() {
33
24
  const data = _interopRequireDefault(require("react"));
34
-
35
25
  _react = function () {
36
26
  return data;
37
27
  };
38
-
39
28
  return data;
40
29
  }
41
-
42
30
  function _ink() {
43
31
  const data = require("ink");
44
-
45
32
  _ink = function () {
46
33
  return data;
47
34
  };
48
-
49
35
  return data;
50
36
  }
51
-
52
37
  function _cliHighlight() {
53
38
  const data = _interopRequireDefault(require("cli-highlight"));
54
-
55
39
  _cliHighlight = function () {
56
40
  return data;
57
41
  };
58
-
59
42
  return data;
60
43
  }
61
-
62
44
  class FormatterService {
63
45
  constructor(formatterConfig) {
64
46
  this.formatterConfig = formatterConfig;
65
47
  (0, _defineProperty2().default)(this, "name", 'formatter');
66
48
  }
67
-
68
49
  async run(context, options) {
69
50
  const mergedOpts = this.optionsWithDefaults(options);
70
51
  const formatterContext = this.mergeContext(mergedOpts, context);
@@ -72,16 +53,13 @@ class FormatterService {
72
53
  const results = options.check ? await formatter.check(formatterContext) : await formatter.format(formatterContext);
73
54
  return results;
74
55
  }
75
-
76
56
  optionsWithDefaults(options) {
77
57
  return (0, _lodash().defaults)(options, this.formatterConfig);
78
58
  }
79
-
80
59
  mergeContext(options, context) {
81
60
  const formatterContext = Object.assign({}, options, context);
82
61
  return formatterContext;
83
62
  }
84
-
85
63
  render(env) {
86
64
  const descriptor = this.getDescriptor(env);
87
65
  return /*#__PURE__*/_react().default.createElement(_ink().Text, {
@@ -95,7 +73,6 @@ class FormatterService {
95
73
  ignoreIllegals: true
96
74
  })), /*#__PURE__*/_react().default.createElement(_ink().Newline, null));
97
75
  }
98
-
99
76
  getDescriptor(env) {
100
77
  if (!env.env.getFormatter) return undefined;
101
78
  const mergedOpts = this.optionsWithDefaults({});
@@ -109,9 +86,7 @@ class FormatterService {
109
86
  displayName: formatter.displayName ? formatter.displayName : '?'
110
87
  };
111
88
  }
112
-
113
89
  }
114
-
115
90
  exports.FormatterService = FormatterService;
116
91
 
117
92
  //# sourceMappingURL=formatter.service.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FormatterService","constructor","formatterConfig","run","context","options","mergedOpts","optionsWithDefaults","formatterContext","mergeContext","formatter","env","getFormatter","results","check","format","defaults","Object","assign","render","descriptor","getDescriptor","id","displayName","version","config","highlight","language","ignoreIllegals","undefined","icon","displayConfig"],"sources":["formatter.service.tsx"],"sourcesContent":["import { defaults } from 'lodash';\nimport React from 'react';\nimport { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';\nimport { Text, Newline } from 'ink';\nimport highlight from 'cli-highlight';\nimport { Formatter, FormatResults } from './formatter';\nimport { FormatterContext, FormatterOptions } from './formatter-context';\nimport { FormatterConfig } from './formatter.main.runtime';\n\nexport type FormatterServiceOptions = FormatterOptions & {\n check?: boolean;\n};\n\nexport class FormatterService implements EnvService<FormatResults> {\n name = 'formatter';\n\n constructor(private formatterConfig: FormatterConfig) {}\n\n async run(context: ExecutionContext, options: FormatterServiceOptions): Promise<FormatResults> {\n const mergedOpts = this.optionsWithDefaults(options);\n const formatterContext: FormatterContext = this.mergeContext(mergedOpts, context);\n const formatter: Formatter = context.env.getFormatter(formatterContext);\n\n const results = options.check ? await formatter.check(formatterContext) : await formatter.format(formatterContext);\n return results;\n }\n\n private optionsWithDefaults(options: FormatterServiceOptions): FormatterServiceOptions {\n return defaults(options, this.formatterConfig);\n }\n\n private mergeContext(options: FormatterServiceOptions, context?: ExecutionContext): FormatterContext {\n const formatterContext: FormatterContext = Object.assign({}, options, context);\n return formatterContext;\n }\n\n render(env: EnvDefinition) {\n const descriptor = this.getDescriptor(env);\n\n return (\n <Text key={descriptor?.id}>\n <Text color=\"cyan\">configured formatter: </Text>\n <Text>\n {descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})\n </Text>\n <Newline />\n <Text color=\"cyan\">formatter config:</Text>\n <Newline />\n <Text>\n {descriptor?.config && highlight(descriptor?.config, { language: 'javascript', ignoreIllegals: true })}\n </Text>\n <Newline />\n </Text>\n );\n }\n\n getDescriptor(env: EnvDefinition) {\n if (!env.env.getFormatter) return undefined;\n const mergedOpts = this.optionsWithDefaults({});\n const formatterContext = this.mergeContext(mergedOpts);\n const formatter = env.env.getFormatter(formatterContext);\n\n return {\n id: formatter.id,\n icon: formatter.icon,\n config: formatter.displayConfig ? formatter.displayConfig() : undefined,\n version: formatter.version ? formatter.version() : '?',\n displayName: formatter.displayName ? formatter.displayName : '?',\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;A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,aACqBA,UADrB,uBACqBA,UAAU,CAAEG,WADjC,SACiDH,UADjD,aACiDA,UADjD,uBACiDA,UAAU,CAAEI,OAD7D,MAFF,eAKE,+BAAC,cAAD,OALF,eAME,+BAAC,WAAD;MAAM,KAAK,EAAC;IAAZ,uBANF,eAOE,+BAAC,cAAD,OAPF,eAQE,+BAAC,WAAD,QACG,CAAAJ,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEK,MAAZ,KAAsB,IAAAC,uBAAA,EAAUN,UAAV,aAAUA,UAAV,uBAAUA,UAAU,CAAEK,MAAtB,EAA8B;MAAEE,QAAQ,EAAE,YAAZ;MAA0BC,cAAc,EAAE;IAA1C,CAA9B,CADzB,CARF,eAWE,+BAAC,cAAD,OAXF,CADF;EAeD;;EAEDP,aAAa,CAACV,GAAD,EAAqB;IAChC,IAAI,CAACA,GAAG,CAACA,GAAJ,CAAQC,YAAb,EAA2B,OAAOiB,SAAP;IAC3B,MAAMvB,UAAU,GAAG,KAAKC,mBAAL,CAAyB,EAAzB,CAAnB;IACA,MAAMC,gBAAgB,GAAG,KAAKC,YAAL,CAAkBH,UAAlB,CAAzB;IACA,MAAMI,SAAS,GAAGC,GAAG,CAACA,GAAJ,CAAQC,YAAR,CAAqBJ,gBAArB,CAAlB;IAEA,OAAO;MACLc,EAAE,EAAEZ,SAAS,CAACY,EADT;MAELQ,IAAI,EAAEpB,SAAS,CAACoB,IAFX;MAGLL,MAAM,EAAEf,SAAS,CAACqB,aAAV,GAA0BrB,SAAS,CAACqB,aAAV,EAA1B,GAAsDF,SAHzD;MAILL,OAAO,EAAEd,SAAS,CAACc,OAAV,GAAoBd,SAAS,CAACc,OAAV,EAApB,GAA0C,GAJ9C;MAKLD,WAAW,EAAEb,SAAS,CAACa,WAAV,GAAwBb,SAAS,CAACa,WAAlC,GAAgD;IALxD,CAAP;EAOD;;AAxDgE"}
1
+ {"version":3,"names":["FormatterService","constructor","formatterConfig","run","context","options","mergedOpts","optionsWithDefaults","formatterContext","mergeContext","formatter","env","getFormatter","results","check","format","defaults","Object","assign","render","descriptor","getDescriptor","id","displayName","version","config","highlight","language","ignoreIllegals","undefined","icon","displayConfig"],"sources":["formatter.service.tsx"],"sourcesContent":["import { defaults } from 'lodash';\nimport React from 'react';\nimport { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';\nimport { Text, Newline } from 'ink';\nimport highlight from 'cli-highlight';\nimport { Formatter, FormatResults } from './formatter';\nimport { FormatterContext, FormatterOptions } from './formatter-context';\nimport { FormatterConfig } from './formatter.main.runtime';\n\nexport type FormatterServiceOptions = FormatterOptions & {\n check?: boolean;\n};\n\nexport class FormatterService implements EnvService<FormatResults> {\n name = 'formatter';\n\n constructor(private formatterConfig: FormatterConfig) {}\n\n async run(context: ExecutionContext, options: FormatterServiceOptions): Promise<FormatResults> {\n const mergedOpts = this.optionsWithDefaults(options);\n const formatterContext: FormatterContext = this.mergeContext(mergedOpts, context);\n const formatter: Formatter = context.env.getFormatter(formatterContext);\n\n const results = options.check ? await formatter.check(formatterContext) : await formatter.format(formatterContext);\n return results;\n }\n\n private optionsWithDefaults(options: FormatterServiceOptions): FormatterServiceOptions {\n return defaults(options, this.formatterConfig);\n }\n\n private mergeContext(options: FormatterServiceOptions, context?: ExecutionContext): FormatterContext {\n const formatterContext: FormatterContext = Object.assign({}, options, context);\n return formatterContext;\n }\n\n render(env: EnvDefinition) {\n const descriptor = this.getDescriptor(env);\n\n return (\n <Text key={descriptor?.id}>\n <Text color=\"cyan\">configured formatter: </Text>\n <Text>\n {descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})\n </Text>\n <Newline />\n <Text color=\"cyan\">formatter config:</Text>\n <Newline />\n <Text>\n {descriptor?.config && highlight(descriptor?.config, { language: 'javascript', ignoreIllegals: true })}\n </Text>\n <Newline />\n </Text>\n );\n }\n\n getDescriptor(env: EnvDefinition) {\n if (!env.env.getFormatter) return undefined;\n const mergedOpts = this.optionsWithDefaults({});\n const formatterContext = this.mergeContext(mergedOpts);\n const formatter = env.env.getFormatter(formatterContext);\n\n return {\n id: formatter.id,\n icon: formatter.icon,\n config: formatter.displayConfig ? formatter.displayConfig() : undefined,\n version: formatter.version ? formatter.version() : '?',\n displayName: formatter.displayName ? formatter.displayName : '?',\n };\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;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AASO,MAAMA,gBAAgB,CAAsC;EAGjEC,WAAW,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;IAAA,8CAF7C,WAAW;EAEqC;EAEvD,MAAMC,GAAG,CAACC,OAAyB,EAAEC,OAAgC,EAA0B;IAC7F,MAAMC,UAAU,GAAG,IAAI,CAACC,mBAAmB,CAACF,OAAO,CAAC;IACpD,MAAMG,gBAAkC,GAAG,IAAI,CAACC,YAAY,CAACH,UAAU,EAAEF,OAAO,CAAC;IACjF,MAAMM,SAAoB,GAAGN,OAAO,CAACO,GAAG,CAACC,YAAY,CAACJ,gBAAgB,CAAC;IAEvE,MAAMK,OAAO,GAAGR,OAAO,CAACS,KAAK,GAAG,MAAMJ,SAAS,CAACI,KAAK,CAACN,gBAAgB,CAAC,GAAG,MAAME,SAAS,CAACK,MAAM,CAACP,gBAAgB,CAAC;IAClH,OAAOK,OAAO;EAChB;EAEQN,mBAAmB,CAACF,OAAgC,EAA2B;IACrF,OAAO,IAAAW,kBAAQ,EAACX,OAAO,EAAE,IAAI,CAACH,eAAe,CAAC;EAChD;EAEQO,YAAY,CAACJ,OAAgC,EAAED,OAA0B,EAAoB;IACnG,MAAMI,gBAAkC,GAAGS,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEb,OAAO,EAAED,OAAO,CAAC;IAC9E,OAAOI,gBAAgB;E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ACqB,aAAa,GAAGrB,SAAS,CAACqB,aAAa,EAAE,GAAGF,SAAS;MACvEL,OAAO,EAAEd,SAAS,CAACc,OAAO,GAAGd,SAAS,CAACc,OAAO,EAAE,GAAG,GAAG;MACtDD,WAAW,EAAEb,SAAS,CAACa,WAAW,GAAGb,SAAS,CAACa,WAAW,GAAG;IAC/D,CAAC;EACH;AACF;AAAC"}
package/dist/index.js CHANGED
@@ -34,29 +34,21 @@ Object.defineProperty(exports, "FormatterAspect", {
34
34
  }
35
35
  });
36
36
  exports.default = void 0;
37
-
38
37
  function _formatter() {
39
38
  const data = require("./formatter.aspect");
40
-
41
39
  _formatter = function () {
42
40
  return data;
43
41
  };
44
-
45
42
  return data;
46
43
  }
47
-
48
44
  function _formatter2() {
49
45
  const data = require("./formatter");
50
-
51
46
  _formatter2 = function () {
52
47
  return data;
53
48
  };
54
-
55
49
  return data;
56
50
  }
57
-
58
51
  var _default = _formatter().FormatterAspect;
59
-
60
52
  exports.default = _default;
61
53
 
62
54
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["FormatterAspect"],"sources":["index.ts"],"sourcesContent":["import { FormatterAspect } from './formatter.aspect';\n\nexport { FormatterAspect };\nexport type { FormatterMain, FormatterConfig } from './formatter.main.runtime';\nexport { FormatResults, Formatter, FileFormatResult, ComponentFormatResult } from './formatter';\nexport type { FormatTask } from './format.task';\nexport type { FormatterContext, FormatterOptions } from './formatter-context';\nexport default FormatterAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;eAGeA,4B"}
1
+ {"version":3,"names":["FormatterAspect"],"sources":["index.ts"],"sourcesContent":["import { FormatterAspect } from './formatter.aspect';\n\nexport { FormatterAspect };\nexport type { FormatterMain, FormatterConfig } from './formatter.main.runtime';\nexport { FormatResults, Formatter, FileFormatResult, ComponentFormatResult } from './formatter';\nexport type { FormatTask } from './format.task';\nexport type { FormatterContext, FormatterOptions } from './formatter-context';\nexport default FormatterAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAgG,eAGjFA,4BAAe;AAAA"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/formatter",
3
- "version": "0.0.432",
3
+ "version": "0.0.433",
4
4
  "homepage": "https://bit.dev/teambit/defender/formatter",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.defender",
8
8
  "name": "formatter",
9
- "version": "0.0.432"
9
+ "version": "0.0.433"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -18,10 +18,10 @@
18
18
  "core-js": "^3.0.0",
19
19
  "@teambit/harmony": "0.3.3",
20
20
  "@teambit/cli": "0.0.591",
21
- "@teambit/component": "0.0.881",
22
- "@teambit/envs": "0.0.881",
23
- "@teambit/workspace": "0.0.881",
24
- "@teambit/builder": "0.0.881",
21
+ "@teambit/component": "0.0.882",
22
+ "@teambit/envs": "0.0.882",
23
+ "@teambit/workspace": "0.0.882",
24
+ "@teambit/builder": "0.0.882",
25
25
  "@teambit/logger": "0.0.684"
26
26
  },
27
27
  "devDependencies": {
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_formatter@0.0.432/dist/formatter.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_formatter@0.0.432/dist/formatter.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_formatter@0.0.433/dist/formatter.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_formatter@0.0.433/dist/formatter.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];