@teambit/formatter 1.0.667 → 1.0.669
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/format.cmd.d.ts +6 -6
- package/dist/format.cmd.js.map +1 -1
- package/dist/format.task.d.ts +1 -1
- package/dist/format.task.js.map +1 -1
- package/dist/formatter-context.d.ts +1 -1
- package/dist/formatter-context.js.map +1 -1
- package/dist/formatter-env-type.d.ts +2 -2
- package/dist/formatter-env-type.js.map +1 -1
- package/dist/formatter.d.ts +2 -2
- package/dist/formatter.js.map +1 -1
- package/dist/formatter.main.runtime.d.ts +8 -8
- package/dist/formatter.main.runtime.js.map +1 -1
- package/dist/formatter.service.d.ts +4 -4
- package/dist/formatter.service.js.map +1 -1
- package/dist/{preview-1753809186996.js → preview-1753848836384.js} +2 -2
- package/package.json +9 -9
package/dist/format.cmd.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TimerResponse } from '@teambit/toolbox.time.timer';
|
|
2
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
3
|
-
import { ComponentFactory, ComponentID } from '@teambit/component';
|
|
4
|
-
import { Workspace } from '@teambit/workspace';
|
|
5
|
-
import { FormatterMain } from './formatter.main.runtime';
|
|
6
|
-
import { ComponentFormatResult, FormatResults } from './formatter';
|
|
1
|
+
import type { TimerResponse } from '@teambit/toolbox.time.timer';
|
|
2
|
+
import type { Command, CommandOptions } from '@teambit/cli';
|
|
3
|
+
import type { ComponentFactory, ComponentID } from '@teambit/component';
|
|
4
|
+
import type { Workspace } from '@teambit/workspace';
|
|
5
|
+
import type { FormatterMain } from './formatter.main.runtime';
|
|
6
|
+
import type { ComponentFormatResult, FormatResults } from './formatter';
|
|
7
7
|
export type FormatCmdOptions = {
|
|
8
8
|
changed?: boolean;
|
|
9
9
|
json?: boolean;
|
package/dist/format.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_toolboxTime","data","require","_legacy","_chalk","_interopRequireDefault","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FormatCmd","constructor","formatter","componentHost","workspace","name","description","COMPONENT_PATTERN_HELP","report","pattern","formatterOptions","duration","code","componentsIdsToFormat","json","title","chalk","bold","cyan","length","toString","componentsOutputs","getAllComponentsResultOutput","results","check","seconds","summery","formatterCmdOptions","timer","Timer","create","start","componentsIds","getIdsToFormat","changed","componentsToFormat","getMany","opts","formatterResults","format","jsonFormatterResults","toJsonFormatResults","timerResponse","stop","statusCode","getStatusCode","map","comp","id","hasIssues","some","file","idsByPattern","getNewAndModifiedIds","listIds","componentsResult","context","allResults","getOneComponentResultOutput","join","componentResult","componentId","ignoreVersion","filesWithIssues","filter","fileResult","green","subTitle","red","files","getOneComponentFileResultOutput","filePath","exports","newResults","res","resultsWithoutComponent","result","component","compact","flatten","errors"],"sources":["format.cmd.ts"],"sourcesContent":["import { TimerResponse, Timer } from '@teambit/toolbox.time.timer';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\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 code: number;\n componentsIdsToFormat: string[];\n};\n\nexport class FormatCmd implements Command {\n name = 'format [component-pattern]';\n description = 'format components in the development workspace';\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\n group = 'testing';\n helpUrl = 'reference/formatting/formatter-overview';\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([pattern]: [string], formatterOptions: FormatCmdOptions) {\n const { duration, data, code, componentsIdsToFormat } = await this.json([pattern], 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 {\n data: `${title}\\n\\n${componentsOutputs}\\n\\n${summery}`,\n code,\n };\n }\n\n async json([pattern]: [string], formatterCmdOptions: FormatCmdOptions): Promise<JsonFormatResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToFormat(pattern, 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 const statusCode = this.getStatusCode(jsonFormatterResults, formatterCmdOptions.check);\n\n return {\n duration: timerResponse,\n data: jsonFormatterResults,\n code: statusCode,\n componentsIdsToFormat: componentsToFormat.map((comp) => comp.id.toString()),\n };\n }\n\n private getStatusCode(results: JsonFormatDataResults, check = false): number {\n if (!check) return 0;\n const hasIssues = results.results.some((comp) => comp.results.some((file) => file.hasIssues));\n if (hasIssues) return 1;\n return 0;\n }\n\n private async getIdsToFormat(pattern: string, changed = false): Promise<ComponentID[]> {\n if (pattern) {\n return this.workspace.idsByPattern(pattern);\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,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;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,MAAM,EAAEzD,OAAO,EAAEyD;EACnB,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_toolboxTime","data","require","_legacy","_chalk","_interopRequireDefault","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FormatCmd","constructor","formatter","componentHost","workspace","name","description","COMPONENT_PATTERN_HELP","report","pattern","formatterOptions","duration","code","componentsIdsToFormat","json","title","chalk","bold","cyan","length","toString","componentsOutputs","getAllComponentsResultOutput","results","check","seconds","summery","formatterCmdOptions","timer","Timer","create","start","componentsIds","getIdsToFormat","changed","componentsToFormat","getMany","opts","formatterResults","format","jsonFormatterResults","toJsonFormatResults","timerResponse","stop","statusCode","getStatusCode","map","comp","id","hasIssues","some","file","idsByPattern","getNewAndModifiedIds","listIds","componentsResult","context","allResults","getOneComponentResultOutput","join","componentResult","componentId","ignoreVersion","filesWithIssues","filter","fileResult","green","subTitle","red","files","getOneComponentFileResultOutput","filePath","exports","newResults","res","resultsWithoutComponent","result","component","compact","flatten","errors"],"sources":["format.cmd.ts"],"sourcesContent":["import type { TimerResponse } from '@teambit/toolbox.time.timer';\nimport { Timer } from '@teambit/toolbox.time.timer';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport type { Command, CommandOptions } from '@teambit/cli';\nimport type { ComponentFactory, ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport type { EnvsExecutionResult } from '@teambit/envs';\nimport type { Workspace } from '@teambit/workspace';\nimport { compact, flatten } from 'lodash';\nimport type { FormatterMain } from './formatter.main.runtime';\nimport type { ComponentFormatResult, FormatResults, FileFormatResult } from './formatter';\nimport type { 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 code: number;\n componentsIdsToFormat: string[];\n};\n\nexport class FormatCmd implements Command {\n name = 'format [component-pattern]';\n description = 'format components in the development workspace';\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\n group = 'testing';\n helpUrl = 'reference/formatting/formatter-overview';\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([pattern]: [string], formatterOptions: FormatCmdOptions) {\n const { duration, data, code, componentsIdsToFormat } = await this.json([pattern], 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 {\n data: `${title}\\n\\n${componentsOutputs}\\n\\n${summery}`,\n code,\n };\n }\n\n async json([pattern]: [string], formatterCmdOptions: FormatCmdOptions): Promise<JsonFormatResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToFormat(pattern, 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 const statusCode = this.getStatusCode(jsonFormatterResults, formatterCmdOptions.check);\n\n return {\n duration: timerResponse,\n data: jsonFormatterResults,\n code: statusCode,\n componentsIdsToFormat: componentsToFormat.map((comp) => comp.id.toString()),\n };\n }\n\n private getStatusCode(results: JsonFormatDataResults, check = false): number {\n if (!check) return 0;\n const hasIssues = results.results.some((comp) => comp.results.some((file) => file.hasIssues));\n if (hasIssues) return 1;\n return 0;\n }\n\n private async getIdsToFormat(pattern: string, changed = false): Promise<ComponentID[]> {\n if (pattern) {\n return this.workspace.idsByPattern(pattern);\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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BAAuB,CAAC;EACzC,CAAC,CAAC;EACF,OAAO;IACLpD,OAAO,EAAE,IAAAuD,iBAAO,EAAC,IAAAC,iBAAO,EAACN,UAAU,CAAC,CAAC;IACrCO,MAAM,EAAEzD,OAAO,EAAEyD;EACnB,CAAC;AACH","ignoreList":[]}
|
package/dist/format.task.d.ts
CHANGED
package/dist/format.task.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormatTask","constructor","aspectId","name","execute","context","env","getFormatter","componentsResults","formatter","results","check","map","formatResult","component","metadata","errors","exports"],"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(\n readonly aspectId: string,\n readonly name = 'format'\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n if (!context.env.getFormatter) {\n return {\n componentsResults: [],\n };\n }\n\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,WAAWA,CACAC,QAAgB,EAChBC,IAAI,GAAG,QAAQ,EACxB;IAAA,KAFSD,QAAgB,GAAhBA,QAAgB;IAAA,KAChBC,IAAI,GAAJA,IAAI;EACZ;EAEH,MAAMC,OAAOA,CAACC,OAAqB,EAA4B;IAC7D,IAAI,CAACA,OAAO,CAACC,GAAG,CAACC,YAAY,EAAE;MAC7B,OAAO;QACLC,iBAAiB,EAAE;MACrB,CAAC;IACH;IAEA,MAAMC,SAAoB,GAAGJ,OAAO,CAACC,GAAG,CAACC,YAAY,CAAC,CAAC;IACvD;IACA,MAAMG,OAAO,GAAG,MAAMD,SAAS,CAACE,KAAK,CAACN,OAAO,CAAC;IAC9C,MAAMG,iBAAiB,GAAGE,OAAO,CAACA,OAAO,CAACE,GAAG,CAAEC,YAAY,IAAsB;MAC/E,OAAO;QACLC,SAAS,EAAED,YAAY,CAACC,SAAS;QACjCC,QAAQ,EAAE;UACRL,OAAO,EAAEG,YAAY,CAACH;QACxB,CAAC;QACDM,MAAM,EAAE;MACV,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;MACLR;IACF,CAAC;EACH;AACF;AAACS,OAAA,CAAAjB,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["FormatTask","constructor","aspectId","name","execute","context","env","getFormatter","componentsResults","formatter","results","check","map","formatResult","component","metadata","errors","exports"],"sources":["format.task.ts"],"sourcesContent":["import type { BuildTask, BuiltTaskResult, BuildContext, ComponentResult } from '@teambit/builder';\nimport type { Formatter } from './formatter';\n\nexport class FormatTask implements BuildTask {\n constructor(\n readonly aspectId: string,\n readonly name = 'format'\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n if (!context.env.getFormatter) {\n return {\n componentsResults: [],\n };\n }\n\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,WAAWA,CACAC,QAAgB,EAChBC,IAAI,GAAG,QAAQ,EACxB;IAAA,KAFSD,QAAgB,GAAhBA,QAAgB;IAAA,KAChBC,IAAI,GAAJA,IAAI;EACZ;EAEH,MAAMC,OAAOA,CAACC,OAAqB,EAA4B;IAC7D,IAAI,CAACA,OAAO,CAACC,GAAG,CAACC,YAAY,EAAE;MAC7B,OAAO;QACLC,iBAAiB,EAAE;MACrB,CAAC;IACH;IAEA,MAAMC,SAAoB,GAAGJ,OAAO,CAACC,GAAG,CAACC,YAAY,CAAC,CAAC;IACvD;IACA,MAAMG,OAAO,GAAG,MAAMD,SAAS,CAACE,KAAK,CAACN,OAAO,CAAC;IAC9C,MAAMG,iBAAiB,GAAGE,OAAO,CAACA,OAAO,CAACE,GAAG,CAAEC,YAAY,IAAsB;MAC/E,OAAO;QACLC,SAAS,EAAED,YAAY,CAACC,SAAS;QACjCC,QAAQ,EAAE;UACRL,OAAO,EAAEG,YAAY,CAACH;QACxB,CAAC;QACDM,MAAM,EAAE;MACV,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;MACLR;IACF,CAAC;EACH;AACF;AAACS,OAAA,CAAAjB,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["formatter-context.ts"],"sourcesContent":["import { ExecutionContext } from '@teambit/envs';\n\nexport type FormatterOptions = { check?: boolean };\nexport interface FormatterContext extends ExecutionContext, FormatterOptions {}\n// export interface FormatterContext extends ExecutionContext {}\n// export type FormatterContext = ExecutionContext;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["formatter-context.ts"],"sourcesContent":["import type { ExecutionContext } from '@teambit/envs';\n\nexport type FormatterOptions = { check?: boolean };\nexport interface FormatterContext extends ExecutionContext, FormatterOptions {}\n// export interface FormatterContext extends ExecutionContext {}\n// export type FormatterContext = ExecutionContext;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["formatter-env-type.ts"],"sourcesContent":["import { EnvHandler } from '@teambit/envs';\nimport { Formatter } from './formatter';\n\nexport interface FormatterEnv {\n /**\n * return a Formatter instance.\n */\n formatter(): EnvHandler<Formatter>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["formatter-env-type.ts"],"sourcesContent":["import type { EnvHandler } from '@teambit/envs';\nimport type { Formatter } from './formatter';\n\nexport interface FormatterEnv {\n /**\n * return a Formatter instance.\n */\n formatter(): EnvHandler<Formatter>;\n}\n"],"mappings":"","ignoreList":[]}
|
package/dist/formatter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Component } from '@teambit/component';
|
|
2
|
-
import { FormatterContext } from './formatter-context';
|
|
1
|
+
import type { Component } from '@teambit/component';
|
|
2
|
+
import type { FormatterContext } from './formatter-context';
|
|
3
3
|
export type ComponentFormatResult = {
|
|
4
4
|
/**
|
|
5
5
|
* the formatted component.
|
package/dist/formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["formatter.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { FormatterContext } from './formatter-context';\n\nexport type ComponentFormatResult = {\n /**\n * the formatted component.\n */\n component: Component;\n\n /**\n * format results for each file of the component.\n */\n results: FileFormatResult[];\n};\n\nexport type FileFormatResult = {\n /**\n * path of the formatted file.\n */\n filePath: string;\n\n /**\n * Does the file has formatting issues (needs format)\n */\n hasIssues: boolean;\n\n /**\n * The new file content after the formatting\n */\n newContent?: string;\n};\n\nexport type FormatResults = {\n results: ComponentFormatResult[];\n errors: Error[];\n};\n\nexport interface Formatter {\n id: string;\n format(context: FormatterContext): Promise<FormatResults>;\n formatSnippet(snippet: string, filepath?: string): Promise<string>;\n check(context: FormatterContext): Promise<FormatResults>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["formatter.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport type { FormatterContext } from './formatter-context';\n\nexport type ComponentFormatResult = {\n /**\n * the formatted component.\n */\n component: Component;\n\n /**\n * format results for each file of the component.\n */\n results: FileFormatResult[];\n};\n\nexport type FileFormatResult = {\n /**\n * path of the formatted file.\n */\n filePath: string;\n\n /**\n * Does the file has formatting issues (needs format)\n */\n hasIssues: boolean;\n\n /**\n * The new file content after the formatting\n */\n newContent?: string;\n};\n\nexport type FormatResults = {\n results: ComponentFormatResult[];\n errors: Error[];\n};\n\nexport interface Formatter {\n id: string;\n format(context: FormatterContext): Promise<FormatResults>;\n formatSnippet(snippet: string, filepath?: string): Promise<string>;\n check(context: FormatterContext): Promise<FormatResults>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CLIMain } from '@teambit/cli';
|
|
2
|
-
import { Component, ComponentMain } from '@teambit/component';
|
|
3
|
-
import { EnvsMain, ExecutionContext } from '@teambit/envs';
|
|
4
|
-
import { Logger, LoggerMain } from '@teambit/logger';
|
|
5
|
-
import { Workspace } from '@teambit/workspace';
|
|
1
|
+
import type { CLIMain } from '@teambit/cli';
|
|
2
|
+
import type { Component, ComponentMain } from '@teambit/component';
|
|
3
|
+
import type { EnvsMain, ExecutionContext } from '@teambit/envs';
|
|
4
|
+
import type { Logger, LoggerMain } from '@teambit/logger';
|
|
5
|
+
import type { Workspace } from '@teambit/workspace';
|
|
6
6
|
import { FormatterService } from './formatter.service';
|
|
7
7
|
import { FormatTask } from './format.task';
|
|
8
|
-
import { FormatterOptions } from './formatter-context';
|
|
9
|
-
import { Formatter } from './formatter';
|
|
10
|
-
import { SnappingMain } from '@teambit/snapping';
|
|
8
|
+
import type { FormatterOptions } from './formatter-context';
|
|
9
|
+
import type { Formatter } from './formatter';
|
|
10
|
+
import type { SnappingMain } from '@teambit/snapping';
|
|
11
11
|
export type FormatterConfig = {
|
|
12
12
|
formatOnPreSnap?: boolean;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_component","_envs","_logger","_workspace","_formatter","_formatter2","_format","_format2","_snapping","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FormatterMain","constructor","envs","formatterService","logger","format","components","opts","envsRuntime","createEnvironment","formatResults","run","toFormatServiceOptions","check","getFormatter","context","options","createTask","name","FormatTask","FormatterAspect","id","provider","cli","component","loggerAspect","workspace","snapping","config","createLogger","FormatterService","formatterMain","registerService","register","FormatCmd","getHost","registerOnPreSnap","formatOnPreSnap","exports","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","LoggerAspect","WorkspaceAspect","SnappingAspect","addRuntime"],"sources":["formatter.main.runtime.ts"],"sourcesContent":["import { CLIAspect,
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_component","_envs","_logger","_workspace","_formatter","_formatter2","_format","_format2","_snapping","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FormatterMain","constructor","envs","formatterService","logger","format","components","opts","envsRuntime","createEnvironment","formatResults","run","toFormatServiceOptions","check","getFormatter","context","options","createTask","name","FormatTask","FormatterAspect","id","provider","cli","component","loggerAspect","workspace","snapping","config","createLogger","FormatterService","formatterMain","registerService","register","FormatCmd","getHost","registerOnPreSnap","formatOnPreSnap","exports","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","LoggerAspect","WorkspaceAspect","SnappingAspect","addRuntime"],"sources":["formatter.main.runtime.ts"],"sourcesContent":["import type { CLIMain } from '@teambit/cli';\nimport { CLIAspect, MainRuntime } from '@teambit/cli';\nimport type { Component, ComponentMain } from '@teambit/component';\nimport { ComponentAspect } from '@teambit/component';\nimport type { EnvsMain, ExecutionContext } from '@teambit/envs';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport { FormatterAspect } from './formatter.aspect';\nimport { FormatterService } from './formatter.service';\nimport { FormatTask } from './format.task';\nimport { FormatCmd } from './format.cmd';\nimport type { FormatterOptions } from './formatter-context';\nimport type { Formatter } from './formatter';\nimport type { SnappingMain } from '@teambit/snapping';\nimport { SnappingAspect } from '@teambit/snapping';\n\nexport type FormatterConfig = {\n formatOnPreSnap?: boolean;\n};\nexport class FormatterMain {\n static runtime = MainRuntime;\n\n constructor(\n private envs: EnvsMain,\n private formatterService: FormatterService,\n private logger: Logger\n ) {}\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 getFormatter(context: ExecutionContext, options: FormatterOptions): Formatter | undefined {\n return this.formatterService.getFormatter(context, options);\n }\n\n private toFormatServiceOptions(opts: FormatterOptions, check = false): FormatterOptions {\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, SnappingAspect];\n\n static defaultConfig: FormatterConfig = {};\n\n static async provider(\n [envs, cli, component, loggerAspect, workspace, snapping]: [\n EnvsMain,\n CLIMain,\n ComponentMain,\n LoggerMain,\n Workspace,\n SnappingMain,\n ],\n config: FormatterConfig\n ) {\n const logger = loggerAspect.createLogger(FormatterAspect.id);\n const formatterService = new FormatterService(config);\n const formatterMain = new FormatterMain(envs, formatterService, logger);\n envs.registerService(formatterService);\n cli.register(new FormatCmd(formatterMain, component.getHost(), workspace));\n snapping.registerOnPreSnap(async (components) => {\n if (!config.formatOnPreSnap) {\n return;\n }\n await formatterMain.format(components, { check: false });\n });\n\n return formatterMain;\n }\n}\n\nFormatterAspect.addRuntime(FormatterMain);\n"],"mappings":";;;;;;AACA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,YAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,WAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,QAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,OAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,SAAA;EAAA,MAAAT,IAAA,G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C1EC,QAAQ,CAACS,iBAAiB,CAAC,MAAO9B,UAAU,IAAK;MAC/C,IAAI,CAACsB,MAAM,CAACS,eAAe,EAAE;QAC3B;MACF;MACA,MAAMN,aAAa,CAAC1B,MAAM,CAACC,UAAU,EAAE;QAAEO,KAAK,EAAE;MAAM,CAAC,CAAC;IAC1D,CAAC,CAAC;IAEF,OAAOkB,aAAa;EACtB;AACF;AAACO,OAAA,CAAAtC,aAAA,GAAAA,aAAA;AAAAhB,eAAA,CA3EYgB,aAAa,aACPuC,kBAAW;AAAAvD,eAAA,CADjBgB,aAAa,kBA8CF,CAACwC,kBAAU,EAAEC,gBAAS,EAAEC,4BAAe,EAAEC,sBAAY,EAAEC,4BAAe,EAAEC,0BAAc,CAAC;AAAA7D,eAAA,CA9ClGgB,aAAa,mBAgDgB,CAAC,CAAC;AA6B5CoB,4BAAe,CAAC0B,UAAU,CAAC9C,aAAa,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
|
|
2
|
-
import { Formatter, FormatResults } from './formatter';
|
|
3
|
-
import { FormatterOptions } from './formatter-context';
|
|
4
|
-
import { FormatterConfig } from './formatter.main.runtime';
|
|
1
|
+
import type { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
|
|
2
|
+
import type { Formatter, FormatResults } from './formatter';
|
|
3
|
+
import type { FormatterOptions } from './formatter-context';
|
|
4
|
+
import type { FormatterConfig } from './formatter.main.runtime';
|
|
5
5
|
type FormatterTransformationMap = ServiceTransformationMap & {
|
|
6
6
|
getFormatter: () => Formatter;
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_cliHighlight","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FormatterService","constructor","formatterConfig","run","context","options","formatter","getFormatter","results","errors","mergedOpts","optionsWithDefaults","formatterContext","mergeContext","check","format","env","defaults","assign","render","descriptor","getDescriptor","name","chalk","green","id","displayName","version","configLabel","configObj","config","highlight","language","ignoreIllegals","transform","undefined","icon","displayConfig","exports"],"sources":["formatter.service.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { defaults } from 'lodash';\nimport {
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_cliHighlight","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FormatterService","constructor","formatterConfig","run","context","options","formatter","getFormatter","results","errors","mergedOpts","optionsWithDefaults","formatterContext","mergeContext","check","format","env","defaults","assign","render","descriptor","getDescriptor","name","chalk","green","id","displayName","version","configLabel","configObj","config","highlight","language","ignoreIllegals","transform","undefined","icon","displayConfig","exports"],"sources":["formatter.service.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { defaults } from 'lodash';\nimport type {\n EnvService,\n ExecutionContext,\n EnvDefinition,\n Env,\n EnvContext,\n ServiceTransformationMap,\n} from '@teambit/envs';\nimport highlight from 'cli-highlight';\nimport type { Formatter, FormatResults } from './formatter';\nimport type { FormatterContext, FormatterOptions } from './formatter-context';\nimport type { FormatterConfig } from './formatter.main.runtime';\n\ntype FormatterTransformationMap = ServiceTransformationMap & {\n getFormatter: () => Formatter;\n};\nexport class FormatterService implements EnvService<FormatResults> {\n name = 'formatter';\n\n constructor(private formatterConfig: FormatterConfig) {}\n\n async run(context: ExecutionContext, options: FormatterOptions): Promise<FormatResults> {\n const formatter = this.getFormatter(context, options);\n if (!formatter) {\n return { results: [], errors: [] };\n }\n const mergedOpts = this.optionsWithDefaults(options);\n const formatterContext: FormatterContext = this.mergeContext(mergedOpts, context);\n\n const results = options.check ? await formatter.check(formatterContext) : await formatter.format(formatterContext);\n return results;\n }\n\n getFormatter(context: ExecutionContext, options: FormatterOptions): Formatter | undefined {\n const mergedOpts = this.optionsWithDefaults(options);\n const formatterContext: FormatterContext = this.mergeContext(mergedOpts, context);\n const formatter = context.env.getFormatter?.(formatterContext);\n\n return formatter;\n }\n\n private optionsWithDefaults(options: FormatterOptions): FormatterOptions {\n return defaults(options, this.formatterConfig);\n }\n\n private mergeContext(options: FormatterOptions, 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 const name = `${chalk.green('configured formatter:')} ${descriptor?.id} (${descriptor?.displayName} @ ${\n descriptor?.version\n })`;\n const configLabel = chalk.green('formatter config:');\n const configObj = descriptor?.config\n ? highlight(descriptor?.config, { language: 'json', ignoreIllegals: true })\n : '';\n return `${name}\\n${configLabel}\\n${configObj}`;\n }\n\n transform(env: Env, context: EnvContext): FormatterTransformationMap | undefined {\n // Old env\n if (!env?.formatter) return undefined;\n return {\n getFormatter: () => env.formatter()(context),\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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OA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AG;IAC/D,CAAC;EACH;AACF;AAACY,OAAA,CAAAtC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_formatter@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_formatter@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_formatter@1.0.669/dist/formatter.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_formatter@1.0.669/dist/formatter.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/formatter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.669",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/defender/formatter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.defender",
|
|
8
8
|
"name": "formatter",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.669"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "4.1.2",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"@teambit/legacy.constants": "0.0.13",
|
|
17
17
|
"@teambit/toolbox.time.timer": "0.0.5",
|
|
18
18
|
"@teambit/harmony": "0.4.7",
|
|
19
|
-
"@teambit/cli": "0.0.
|
|
20
|
-
"@teambit/component": "1.0.
|
|
21
|
-
"@teambit/envs": "1.0.
|
|
22
|
-
"@teambit/workspace": "1.0.
|
|
23
|
-
"@teambit/builder": "1.0.
|
|
24
|
-
"@teambit/logger": "0.0.
|
|
25
|
-
"@teambit/snapping": "1.0.
|
|
19
|
+
"@teambit/cli": "0.0.1246",
|
|
20
|
+
"@teambit/component": "1.0.669",
|
|
21
|
+
"@teambit/envs": "1.0.669",
|
|
22
|
+
"@teambit/workspace": "1.0.669",
|
|
23
|
+
"@teambit/builder": "1.0.669",
|
|
24
|
+
"@teambit/logger": "0.0.1339",
|
|
25
|
+
"@teambit/snapping": "1.0.669"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/lodash": "4.14.165",
|