@teambit/generator 1.0.235 → 1.0.238
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_generator_generator-preview.js +1 -1
- package/artifacts/schema.json +1 -1
- package/dist/component-generator.js +9 -1
- package/dist/component-generator.js.map +1 -1
- package/dist/{preview-1713151252756.js → preview-1713191433000.js} +2 -2
- package/package.json +18 -18
@@ -1,4 +1,4 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<testsuites tests="0" failures="0" errors="0" skipped="0">
|
3
|
-
<testsuite name="teambit.generator/generator@1.0.
|
3
|
+
<testsuite name="teambit.generator/generator@1.0.238" tests="0" failures="0" errors="0" skipped="0"/>
|
4
4
|
</testsuites>
|
@@ -1 +1 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.generator/generator-preview"]=t():e["teambit.generator/generator-preview"]=t()}(self,(()=>(()=>{"use strict";var e={10267:(e,t,n)=>{var o={id:"teambit.generator/aspect-docs/generator@0.0.171",homepage:"https://bit.cloud/teambit/generator/aspect-docs/generator",exported:!0};Object.defineProperty(t,"__esModule",{value:!0}),t.default=c,l(n(41594));var a=n(5016),r=["components"];function l(e){return e&&e.__esModule?e:{default:e}}function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},p.apply(this,arguments)}function m(e,t){if(null==e)return{};var n,o,a=i(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function i(e,t){if(null==e)return{};var n,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||(a[n]=e[n]);return a}l.__bit_component=o,p.__bit_component=o,m.__bit_component=o,i.__bit_component=o;var s={},d="wrapper";function c(e){var t=e.components,n=m(e,r);return(0,a.mdx)(d,p({},s,n,{components:t,mdxType:"MDXLayout"}),(0,a.mdx)("p",null,"Generator extension enable generating new components by pre-defined templates"),(0,a.mdx)("h3",null,"Component location"),(0,a.mdx)("p",null,"Component location in the workspace directory tree is defined with the ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit create")," command (see below). For example, a component named ",(0,a.mdx)("inlineCode",{parentName:"p"},"ShoppingCart")," created in the ",(0,a.mdx)("inlineCode",{parentName:"p"},"acme.shopper")," and the namespace ",(0,a.mdx)("inlineCode",{parentName:"p"},"ui")," will be generated in the following directory:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre"},"acme.shopper/ui/shopping-cart\n")),(0,a.mdx)("h3",null,"Component name"),(0,a.mdx)("p",null,"When using templates Bit will use CamelCasing for passing the component-name to the template, but generated file structure should be in kebab-case, for better cross-operating-system compatibility of the component."),(0,a.mdx)("h3",null,"Automatically ",(0,a.mdx)("inlineCode",{parentName:"h3"},"add")," component"),(0,a.mdx)("p",null,"Bit should automatically register the new component to the ",(0,a.mdx)("inlineCode",{parentName:"p"},".bitmap")," file with a symmetrical name to the component-location in the workspace."),(0,a.mdx)("h2",null,"Register a template"),(0,a.mdx)("p",null,"Any aspect (include envs) can register templates. Each template should have a name and a list of files. Each file has a relative-path to the component-dir and template content. See the ",(0,a.mdx)("inlineCode",{parentName:"p"},"component-template.ts")," file for more info about the exact API."),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},"Component name should be available as a param for the file-content-template."),(0,a.mdx)("li",{parentName:"ul"},"TBD: An environment must have a default template (if not set, use first template in array?).")),(0,a.mdx)("p",null,"To register a template, use the Generator API: ",(0,a.mdx)("inlineCode",{parentName:"p"},"registerComponentTemplate(templates: ComponentTemplate[])"),"."),(0,a.mdx)("p",null,"To make the templates of an aspect available on a workspace, they need to be added to the workspace.jsonc. For example:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-json"},'"teambit.generator/generator": {\n "aspects": [\n "teambit.harmony/aspect"\n ]\n },\n')),(0,a.mdx)("p",null,"In the example above, the aspect ",(0,a.mdx)("inlineCode",{parentName:"p"},"teambit.harmony/aspect")," is configured to be available for the generator."),(0,a.mdx)("h2",null,"Show all available templates"),(0,a.mdx)("p",null,"Introduce a new command ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit templates"),", which groups all available templates by aspects."),(0,a.mdx)("h2",null,"Hide core templates"),(0,a.mdx)("p",null,"Configure the Generator aspect to hide core templates when running ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit templates"),". They'll be only shown when using ",(0,a.mdx)("inlineCode",{parentName:"p"},"--show-all")," flag."),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-json"},'"teambit.generator/generator": {\n "hideCoreTemplates": true\n },\n')),(0,a.mdx)("h2",null,"Generate a template from CLI"),(0,a.mdx)("p",null,"Introduce a ",(0,a.mdx)("inlineCode",{parentName:"p"},"create")," command to use templates."),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-sh"},"bit create <template-name> <component-name...> [--scope | -s] [--namespace | -n] [--aspect | -a]\n")),(0,a.mdx)("h3",null,"Args"),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"<component name>")),(0,a.mdx)("p",null,"Name of the component to create. Will be used as the component's dir name and fed to the component template."),(0,a.mdx)("p",null,(0,a.mdx)("strong",{parentName:"p"},"generated file structure should use kebab-case, while the template itself be in camel case"),"."),(0,a.mdx)("h3",null,"Options"),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"[--scope | -s]")),(0,a.mdx)("p",null,"Sets the component's scope and base directory. If not defined, use the ",(0,a.mdx)("inlineCode",{parentName:"p"},"defaultScope")," from ",(0,a.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/workspace")," config."),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"[--namespace | -n]")),(0,a.mdx)("p",null,"Sets the component's namespace and nested dirs inside the scope. If not define, use empty string."),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"[--aspect | -a]")),(0,a.mdx)("p",null,"Aspect ID that registered this template, required only if there are two templates with the same name from several aspects in the workspace."),(0,a.mdx)("h2",null,"Creating a custom template generator"),(0,a.mdx)("p",null,"See our ",(0,a.mdx)("a",{parentName:"p",href:"https://harmony-docs.bit.dev/extending-bit/creating-a-custom-generator"},"tutorial")," on how to Create your own custom component generator."))}c.__bit_component=o,c.isMDXComponent=!0},29583:(e,t,n)=>{Object.defineProperty(t,"W",{enumerable:!0,get:function(){return o.default}});var o=a(n(10267));function a(e){return e&&e.__esModule?e:{default:e}}a.__bit_component={id:"teambit.generator/aspect-docs/generator@0.0.171",homepage:"https://bit.cloud/teambit/generator/aspect-docs/generator",exported:!0}},
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.generator/generator-preview"]=t():e["teambit.generator/generator-preview"]=t()}(self,(()=>(()=>{"use strict";var e={10267:(e,t,n)=>{var o={id:"teambit.generator/aspect-docs/generator@0.0.171",homepage:"https://bit.cloud/teambit/generator/aspect-docs/generator",exported:!0};Object.defineProperty(t,"__esModule",{value:!0}),t.default=c,l(n(41594));var a=n(5016),r=["components"];function l(e){return e&&e.__esModule?e:{default:e}}function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},p.apply(this,arguments)}function m(e,t){if(null==e)return{};var n,o,a=i(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function i(e,t){if(null==e)return{};var n,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||(a[n]=e[n]);return a}l.__bit_component=o,p.__bit_component=o,m.__bit_component=o,i.__bit_component=o;var s={},d="wrapper";function c(e){var t=e.components,n=m(e,r);return(0,a.mdx)(d,p({},s,n,{components:t,mdxType:"MDXLayout"}),(0,a.mdx)("p",null,"Generator extension enable generating new components by pre-defined templates"),(0,a.mdx)("h3",null,"Component location"),(0,a.mdx)("p",null,"Component location in the workspace directory tree is defined with the ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit create")," command (see below). For example, a component named ",(0,a.mdx)("inlineCode",{parentName:"p"},"ShoppingCart")," created in the ",(0,a.mdx)("inlineCode",{parentName:"p"},"acme.shopper")," and the namespace ",(0,a.mdx)("inlineCode",{parentName:"p"},"ui")," will be generated in the following directory:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre"},"acme.shopper/ui/shopping-cart\n")),(0,a.mdx)("h3",null,"Component name"),(0,a.mdx)("p",null,"When using templates Bit will use CamelCasing for passing the component-name to the template, but generated file structure should be in kebab-case, for better cross-operating-system compatibility of the component."),(0,a.mdx)("h3",null,"Automatically ",(0,a.mdx)("inlineCode",{parentName:"h3"},"add")," component"),(0,a.mdx)("p",null,"Bit should automatically register the new component to the ",(0,a.mdx)("inlineCode",{parentName:"p"},".bitmap")," file with a symmetrical name to the component-location in the workspace."),(0,a.mdx)("h2",null,"Register a template"),(0,a.mdx)("p",null,"Any aspect (include envs) can register templates. Each template should have a name and a list of files. Each file has a relative-path to the component-dir and template content. See the ",(0,a.mdx)("inlineCode",{parentName:"p"},"component-template.ts")," file for more info about the exact API."),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},"Component name should be available as a param for the file-content-template."),(0,a.mdx)("li",{parentName:"ul"},"TBD: An environment must have a default template (if not set, use first template in array?).")),(0,a.mdx)("p",null,"To register a template, use the Generator API: ",(0,a.mdx)("inlineCode",{parentName:"p"},"registerComponentTemplate(templates: ComponentTemplate[])"),"."),(0,a.mdx)("p",null,"To make the templates of an aspect available on a workspace, they need to be added to the workspace.jsonc. For example:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-json"},'"teambit.generator/generator": {\n "aspects": [\n "teambit.harmony/aspect"\n ]\n },\n')),(0,a.mdx)("p",null,"In the example above, the aspect ",(0,a.mdx)("inlineCode",{parentName:"p"},"teambit.harmony/aspect")," is configured to be available for the generator."),(0,a.mdx)("h2",null,"Show all available templates"),(0,a.mdx)("p",null,"Introduce a new command ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit templates"),", which groups all available templates by aspects."),(0,a.mdx)("h2",null,"Hide core templates"),(0,a.mdx)("p",null,"Configure the Generator aspect to hide core templates when running ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit templates"),". They'll be only shown when using ",(0,a.mdx)("inlineCode",{parentName:"p"},"--show-all")," flag."),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-json"},'"teambit.generator/generator": {\n "hideCoreTemplates": true\n },\n')),(0,a.mdx)("h2",null,"Generate a template from CLI"),(0,a.mdx)("p",null,"Introduce a ",(0,a.mdx)("inlineCode",{parentName:"p"},"create")," command to use templates."),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-sh"},"bit create <template-name> <component-name...> [--scope | -s] [--namespace | -n] [--aspect | -a]\n")),(0,a.mdx)("h3",null,"Args"),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"<component name>")),(0,a.mdx)("p",null,"Name of the component to create. Will be used as the component's dir name and fed to the component template."),(0,a.mdx)("p",null,(0,a.mdx)("strong",{parentName:"p"},"generated file structure should use kebab-case, while the template itself be in camel case"),"."),(0,a.mdx)("h3",null,"Options"),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"[--scope | -s]")),(0,a.mdx)("p",null,"Sets the component's scope and base directory. If not defined, use the ",(0,a.mdx)("inlineCode",{parentName:"p"},"defaultScope")," from ",(0,a.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/workspace")," config."),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"[--namespace | -n]")),(0,a.mdx)("p",null,"Sets the component's namespace and nested dirs inside the scope. If not define, use empty string."),(0,a.mdx)("h4",null,(0,a.mdx)("inlineCode",{parentName:"h4"},"[--aspect | -a]")),(0,a.mdx)("p",null,"Aspect ID that registered this template, required only if there are two templates with the same name from several aspects in the workspace."),(0,a.mdx)("h2",null,"Creating a custom template generator"),(0,a.mdx)("p",null,"See our ",(0,a.mdx)("a",{parentName:"p",href:"https://harmony-docs.bit.dev/extending-bit/creating-a-custom-generator"},"tutorial")," on how to Create your own custom component generator."))}c.__bit_component=o,c.isMDXComponent=!0},29583:(e,t,n)=>{Object.defineProperty(t,"W",{enumerable:!0,get:function(){return o.default}});var o=a(n(10267));function a(e){return e&&e.__esModule?e:{default:e}}a.__bit_component={id:"teambit.generator/aspect-docs/generator@0.0.171",homepage:"https://bit.cloud/teambit/generator/aspect-docs/generator",exported:!0}},22700:(e,t,n)=>{var o={id:"teambit.generator/generator@1.0.238",homepage:"https://bit.cloud/teambit/generator/generator",exported:!0};function a(){const e=r(n(41594));return a=function(){return e},e}function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,a.__bit_component=o,r.__bit_component=o;const l=()=>a().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},a().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/generator-new.svg"}));l.__bit_component=o,t.Logo=l},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React}},t={};function n(o){var a=t[o];if(void 0!==a)return a.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{compositions:()=>c,compositions_metadata:()=>h,overview:()=>u});var e={};n.r(e),n.d(e,{default:()=>d});var t=n(22700),a=(n(41594),n(5016));const r=TeambitMdxUiMdxScopeContext;var l=n(29583),p=["components"];function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},m.apply(this,arguments)}var i={},s="wrapper";function d(e){var t=e.components,n=function(e,t){if(null==e)return{};var n,o,a=function(e,t){if(null==e)return{};var n,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,p);return(0,a.mdx)(s,m({},i,n,{components:t,mdxType:"MDXLayout"}),(0,a.mdx)(r.MDXScopeProvider,{components:{Generator:l.W},mdxType:"MDXScopeProvider"},(0,a.mdx)(l.W,{mdxType:"Generator"})))}d.isMDXComponent=!0;const c=[t],u=[e],h={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),o})()));
|
package/artifacts/schema.json
CHANGED
@@ -13159,7 +13159,7 @@
|
|
13159
13159
|
"componentId": {
|
13160
13160
|
"scope": "teambit.generator",
|
13161
13161
|
"name": "generator",
|
13162
|
-
"version": "1.0.
|
13162
|
+
"version": "1.0.238"
|
13163
13163
|
},
|
13164
13164
|
"taggedModuleExports": []
|
13165
13165
|
}
|
@@ -257,10 +257,18 @@ class ComponentGenerator {
|
|
257
257
|
setBy: hasEnvConfiguredOriginally ? 'workspace variants' : '<default>'
|
258
258
|
};
|
259
259
|
};
|
260
|
-
const
|
260
|
+
// eslint-disable-next-line prefer-const
|
261
|
+
let {
|
261
262
|
envId,
|
262
263
|
setBy
|
263
264
|
} = getEnvData();
|
265
|
+
if (envId) {
|
266
|
+
const isInWorkspace = this.workspace.exists(envId);
|
267
|
+
const isSameAsThisEnvId = envId === this.envId?.toString() || envId === this.envId?.toStringWithoutVersion();
|
268
|
+
if (isSameAsThisEnvId && this.envId) {
|
269
|
+
envId = isInWorkspace ? this.envId.toStringWithoutVersion() : this.envId.toString();
|
270
|
+
}
|
271
|
+
}
|
264
272
|
return {
|
265
273
|
id: componentId,
|
266
274
|
dir: componentPath,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_vinyl","data","_interopRequireDefault","require","_fsExtra","_pMapSeries","_path","_envs","_camelcase","_bitError","_workspaceModules","_sources","_componentIdToPackageName","_dataToPersist","_componentId","obj","__esModule","default","ComponentGenerator","constructor","workspace","componentIds","options","template","envs","newComponentHelper","tracker","wsConfigFiles","logger","onComponentCreateSlot","aspectId","envId","generate","force","dirsToDeleteIfFailed","generateResults","pMapSeries","componentId","componentPath","getNewComponentPath","pathFromUser","path","componentsToCreate","length","fs","existsSync","join","BitError","push","generateOneComponent","err","deleteGeneratedComponents","bitMap","write","ids","map","r","id","tryLinkToNodeModules","runOnComponentCreateHook","tryWriteConfigFiles","linkToNodeModulesByIds","consoleFailure","message","fns","values","Promise","all","fn","shouldWrite","isWorkspaceConfigWriteEnabled","clearComponentCache","writeConfigFiles","clean","silent","dedupe","throw","dirs","dir","absoluteDir","remove","code","name","namePascalCase","camelcase","pascalCase","nameCamelCase","ComponentID","fromString","files","generateFiles","mainFile","find","file","isMain","writeComponentFiles","addResults","track","rootDir","relativePath","componentName","fullName","defaultScope","scope","component","get","hasEnvConfiguredOriginally","hasEnvConfigured","isApp","use","toString","envBeforeConfigChanges","getEnv","config","boundConfig","bind","userEnv","env","isInWorkspace","exists","toStringWithoutVersion","templateEnv","EnvsAspect","Object","keys","undefined","configWithEnv","addEnvIfProvidedByFlag","setEntireConfig","getEnvData","envFromFlag","envFromTemplate","setBy","packageName","componentIdToPackageName","state","_consumer","envSetBy","isEnv","dependencies","installMissingDependencies","addEnvToConfig","templateFiles","dataToPersist","DataToPersist","vinylFiles","templateFile","templateFileVinyl","Vinyl","base","contents","Buffer","from","content","AbstractVinyl","fromVinyl","results","v","addManyFiles","addBasePath","persistAllToFS","exports"],"sources":["component-generator.ts"],"sourcesContent":["import Vinyl from 'vinyl';\nimport fs from 'fs-extra';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport camelcase from 'camelcase';\nimport { BitError } from '@teambit/bit-error';\nimport { Logger } from '@teambit/logger';\nimport { TrackerMain } from '@teambit/tracker';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport { ComponentID } from '@teambit/component-id';\nimport { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n\nimport { ComponentTemplate, ComponentFile, ComponentConfig } from './component-template';\nimport { CreateOptions } from './create.cmd';\nimport { OnComponentCreateSlot } from './generator.main.runtime';\n\nexport type GenerateResult = {\n id: ComponentID;\n dir: string;\n files: string[];\n envId: string;\n envSetBy: string;\n packageName: string;\n isApp?: boolean;\n isEnv?: boolean;\n dependencies?: string[];\n installMissingDependencies?: boolean;\n};\n\nexport type OnComponentCreateFn = (generateResults: GenerateResult[]) => Promise<void>;\n\nexport class ComponentGenerator {\n constructor(\n private workspace: Workspace,\n private componentIds: ComponentID[],\n private options: Partial<CreateOptions>,\n private template: ComponentTemplate,\n private envs: EnvsMain,\n private newComponentHelper: NewComponentHelperMain,\n private tracker: TrackerMain,\n private wsConfigFiles: WorkspaceConfigFilesMain,\n private logger: Logger,\n private onComponentCreateSlot: OnComponentCreateSlot,\n private aspectId: string,\n private envId?: ComponentID\n ) {}\n\n async generate(force = false): Promise<GenerateResult[]> {\n const dirsToDeleteIfFailed: string[] = [];\n const generateResults = await pMapSeries(this.componentIds, async (componentId) => {\n try {\n const componentPath = this.newComponentHelper.getNewComponentPath(componentId, {\n pathFromUser: this.options.path,\n componentsToCreate: this.componentIds.length,\n });\n if (!force && fs.existsSync(path.join(this.workspace.path, componentPath))) {\n throw new BitError(\n `unable to create a component at \"${componentPath}\", this path already exists, please use \"--path\" to create the component in a different path`\n );\n }\n dirsToDeleteIfFailed.push(componentPath);\n return await this.generateOneComponent(componentId, componentPath);\n } catch (err: any) {\n await this.deleteGeneratedComponents(dirsToDeleteIfFailed);\n throw err;\n }\n });\n\n await this.workspace.bitMap.write(`create (${this.componentIds.length} components)`);\n\n const ids = generateResults.map((r) => r.id);\n await this.tryLinkToNodeModules(ids);\n await this.runOnComponentCreateHook(generateResults);\n // We are running this after the runOnComponentCreateHook as it require\n // the env to be installed to work properly, and the hook might install\n // the env.\n await this.tryWriteConfigFiles(ids);\n\n return generateResults;\n }\n\n private async tryLinkToNodeModules(ids: ComponentID[]) {\n try {\n await linkToNodeModulesByIds(\n this.workspace,\n ids.map((id) => id)\n );\n } catch (err: any) {\n this.logger.consoleFailure(\n `failed linking the new components to node_modules, please run \"bit link\" manually. error: ${err.message}`\n );\n }\n }\n\n private async runOnComponentCreateHook(generateResults: GenerateResult[]) {\n const fns = this.onComponentCreateSlot.values();\n if (!fns.length) return;\n await Promise.all(fns.map((fn) => fn(generateResults)));\n }\n\n /**\n * The function `tryWriteConfigFiles` attempts to write workspace config files, and if it fails, it logs an error\n * message.\n * @returns If the condition `!shouldWrite` is true, then nothing is being returned. Otherwise, if the `writeConfigFiles`\n * function is successfully executed, nothing is being returned. If an error occurs during the execution of\n * `writeConfigFiles`, an error message is being returned.\n */\n private async tryWriteConfigFiles(ids: ComponentID[]) {\n const shouldWrite = this.wsConfigFiles.isWorkspaceConfigWriteEnabled();\n if (!shouldWrite) return;\n ids.map((id) => this.workspace.clearComponentCache(id));\n const { err } = await this.wsConfigFiles.writeConfigFiles({\n clean: true,\n silent: true,\n dedupe: true,\n throw: false,\n });\n if (err) {\n this.logger.consoleFailure(\n `failed generating workspace config files, please run \"bit ws-config write\" manually. error: ${err.message}`\n );\n }\n }\n\n private async deleteGeneratedComponents(dirs: string[]) {\n await Promise.all(\n dirs.map(async (dir) => {\n const absoluteDir = path.join(this.workspace.path, dir);\n try {\n await fs.remove(absoluteDir);\n } catch (err: any) {\n if (err.code !== 'ENOENT') {\n // if not exist, it's fine\n throw err;\n }\n }\n })\n );\n }\n\n private async generateOneComponent(componentId: ComponentID, componentPath: string): Promise<GenerateResult> {\n const name = componentId.name;\n const namePascalCase = camelcase(name, { pascalCase: true });\n const nameCamelCase = camelcase(name);\n const aspectId = ComponentID.fromString(this.aspectId);\n\n const files = await this.template.generateFiles({\n name,\n namePascalCase,\n nameCamelCase,\n componentId,\n aspectId,\n envId: this.envId,\n });\n const mainFile = files.find((file) => file.isMain);\n await this.writeComponentFiles(componentPath, files);\n const addResults = await this.tracker.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope,\n });\n const component = await this.workspace.get(componentId);\n const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);\n if (this.template.isApp) {\n await this.workspace.use(componentId.toString());\n }\n const envBeforeConfigChanges = this.envs.getEnv(component);\n let config = this.template.config;\n if (config && typeof config === 'function') {\n const boundConfig = this.template.config?.bind(this.template);\n config = boundConfig({ aspectId: this.aspectId });\n }\n\n const userEnv = this.options.env;\n\n if (!config && this.envId && !userEnv) {\n const isInWorkspace = this.workspace.exists(this.envId);\n config = {\n [isInWorkspace ? this.envId.toStringWithoutVersion() : this.envId.toString()]: {},\n 'teambit.envs/envs': {\n env: this.envId.toStringWithoutVersion(),\n },\n };\n }\n\n const templateEnv = config?.[EnvsAspect.id]?.env;\n\n if (config && templateEnv && hasEnvConfiguredOriginally) {\n // remove the env we got from the template.\n delete config[templateEnv];\n delete config[EnvsAspect.id].env;\n if (Object.keys(config[EnvsAspect.id]).length === 0) delete config[EnvsAspect.id];\n if (Object.keys(config).length === 0) config = undefined;\n }\n\n const configWithEnv = await this.addEnvIfProvidedByFlag(config);\n if (configWithEnv) this.workspace.bitMap.setEntireConfig(component.id, configWithEnv);\n\n const getEnvData = () => {\n const envFromFlag = this.options.env; // env entered by the user when running `bit create --env`\n const envFromTemplate = config?.[EnvsAspect.id]?.env;\n if (envFromFlag) {\n return {\n envId: envFromFlag,\n setBy: '--env flag',\n };\n }\n if (envFromTemplate) {\n return {\n envId: envFromTemplate,\n setBy: 'template',\n };\n }\n return {\n envId: envBeforeConfigChanges.id,\n setBy: hasEnvConfiguredOriginally ? 'workspace variants' : '<default>',\n };\n };\n const { envId, setBy } = getEnvData();\n return {\n id: componentId,\n dir: componentPath,\n files: addResults.files,\n packageName: componentIdToPackageName(component.state._consumer),\n envId,\n envSetBy: setBy,\n isApp: this.template.isApp,\n isEnv: this.template.isEnv,\n dependencies: this.template.dependencies,\n installMissingDependencies: this.template.installMissingDependencies,\n };\n }\n\n private async addEnvIfProvidedByFlag(config?: ComponentConfig): Promise<ComponentConfig | undefined> {\n const userEnv = this.options.env; // env entered by the user when running `bit create --env`\n const templateEnv = config?.[EnvsAspect.id]?.env;\n if (!userEnv || userEnv === templateEnv) {\n return config;\n }\n config = config || {};\n if (templateEnv) {\n // the component template has an env and the user wants a different env.\n delete config[templateEnv];\n }\n await this.tracker.addEnvToConfig(userEnv, config);\n\n return config;\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeComponentFiles(\n componentPath: string,\n templateFiles: ComponentFile[]\n ): Promise<PathOsBasedRelative[]> {\n const dataToPersist = new DataToPersist();\n const vinylFiles = templateFiles.map((templateFile) => {\n const templateFileVinyl = new Vinyl({\n base: componentPath,\n path: path.join(componentPath, templateFile.relativePath),\n contents: Buffer.from(templateFile.content),\n });\n return AbstractVinyl.fromVinyl(templateFileVinyl);\n });\n const results = vinylFiles.map((v) => v.path);\n dataToPersist.addManyFiles(vinylFiles);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n return results;\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,SAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA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,KAAKK,WAAW,EAAE;MACvC,OAAOR,MAAM;IACf;IACAA,MAAM,GAAGA,MAAM,IAAI,CAAC,CAAC;IACrB,IAAIQ,WAAW,EAAE;MACf;MACA,OAAOR,MAAM,CAACQ,WAAW,CAAC;IAC5B;IACA,MAAM,IAAI,CAAC/F,OAAO,CAACmH,cAAc,CAACzB,OAAO,EAAEH,MAAM,CAAC;IAElD,OAAOA,MAAM;EACf;;EAEA;AACF;AACA;EACE,MAAclB,mBAAmBA,CAC/BzD,aAAqB,EACrBwG,aAA8B,EACE;IAChC,MAAMC,aAAa,GAAG,KAAIC,wBAAa,EAAC,CAAC;IACzC,MAAMC,UAAU,GAAGH,aAAa,CAACvF,GAAG,CAAE2F,YAAY,IAAK;MACrD,MAAMC,iBAAiB,GAAG,KAAIC,gBAAK,EAAC;QAClCC,IAAI,EAAE/G,aAAa;QACnBG,IAAI,EAAEA,eAAI,CAACK,IAAI,CAACR,aAAa,EAAE4G,YAAY,CAAC/C,YAAY,CAAC;QACzDmD,QAAQ,EAAEC,MAAM,CAACC,IAAI,CAACN,YAAY,CAACO,OAAO;MAC5C,CAAC,CAAC;MACF,OAAOC,wBAAa,CAACC,SAAS,CAACR,iBAAiB,CAAC;IACnD,CAAC,CAAC;IACF,MAAMS,OAAO,GAAGX,UAAU,CAAC1F,GAAG,CAAEsG,CAAC,IAAKA,CAAC,CAACpH,IAAI,CAAC;IAC7CsG,aAAa,CAACe,YAAY,CAACb,UAAU,CAAC;IACtCF,aAAa,CAACgB,WAAW,CAAC,IAAI,CAAC3I,SAAS,CAACqB,IAAI,CAAC;IAC9C,MAAMsG,aAAa,CAACiB,cAAc,CAAC,CAAC;IACpC,OAAOJ,OAAO;EAChB;AACF;AAACK,OAAA,CAAA/I,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_vinyl","data","_interopRequireDefault","require","_fsExtra","_pMapSeries","_path","_envs","_camelcase","_bitError","_workspaceModules","_sources","_componentIdToPackageName","_dataToPersist","_componentId","obj","__esModule","default","ComponentGenerator","constructor","workspace","componentIds","options","template","envs","newComponentHelper","tracker","wsConfigFiles","logger","onComponentCreateSlot","aspectId","envId","generate","force","dirsToDeleteIfFailed","generateResults","pMapSeries","componentId","componentPath","getNewComponentPath","pathFromUser","path","componentsToCreate","length","fs","existsSync","join","BitError","push","generateOneComponent","err","deleteGeneratedComponents","bitMap","write","ids","map","r","id","tryLinkToNodeModules","runOnComponentCreateHook","tryWriteConfigFiles","linkToNodeModulesByIds","consoleFailure","message","fns","values","Promise","all","fn","shouldWrite","isWorkspaceConfigWriteEnabled","clearComponentCache","writeConfigFiles","clean","silent","dedupe","throw","dirs","dir","absoluteDir","remove","code","name","namePascalCase","camelcase","pascalCase","nameCamelCase","ComponentID","fromString","files","generateFiles","mainFile","find","file","isMain","writeComponentFiles","addResults","track","rootDir","relativePath","componentName","fullName","defaultScope","scope","component","get","hasEnvConfiguredOriginally","hasEnvConfigured","isApp","use","toString","envBeforeConfigChanges","getEnv","config","boundConfig","bind","userEnv","env","isInWorkspace","exists","toStringWithoutVersion","templateEnv","EnvsAspect","Object","keys","undefined","configWithEnv","addEnvIfProvidedByFlag","setEntireConfig","getEnvData","envFromFlag","envFromTemplate","setBy","isSameAsThisEnvId","packageName","componentIdToPackageName","state","_consumer","envSetBy","isEnv","dependencies","installMissingDependencies","addEnvToConfig","templateFiles","dataToPersist","DataToPersist","vinylFiles","templateFile","templateFileVinyl","Vinyl","base","contents","Buffer","from","content","AbstractVinyl","fromVinyl","results","v","addManyFiles","addBasePath","persistAllToFS","exports"],"sources":["component-generator.ts"],"sourcesContent":["import Vinyl from 'vinyl';\nimport fs from 'fs-extra';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport camelcase from 'camelcase';\nimport { BitError } from '@teambit/bit-error';\nimport { Logger } from '@teambit/logger';\nimport { TrackerMain } from '@teambit/tracker';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport { ComponentID } from '@teambit/component-id';\nimport { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n\nimport { ComponentTemplate, ComponentFile, ComponentConfig } from './component-template';\nimport { CreateOptions } from './create.cmd';\nimport { OnComponentCreateSlot } from './generator.main.runtime';\n\nexport type GenerateResult = {\n id: ComponentID;\n dir: string;\n files: string[];\n envId: string;\n envSetBy: string;\n packageName: string;\n isApp?: boolean;\n isEnv?: boolean;\n dependencies?: string[];\n installMissingDependencies?: boolean;\n};\n\nexport type OnComponentCreateFn = (generateResults: GenerateResult[]) => Promise<void>;\n\nexport class ComponentGenerator {\n constructor(\n private workspace: Workspace,\n private componentIds: ComponentID[],\n private options: Partial<CreateOptions>,\n private template: ComponentTemplate,\n private envs: EnvsMain,\n private newComponentHelper: NewComponentHelperMain,\n private tracker: TrackerMain,\n private wsConfigFiles: WorkspaceConfigFilesMain,\n private logger: Logger,\n private onComponentCreateSlot: OnComponentCreateSlot,\n private aspectId: string,\n private envId?: ComponentID\n ) {}\n\n async generate(force = false): Promise<GenerateResult[]> {\n const dirsToDeleteIfFailed: string[] = [];\n const generateResults = await pMapSeries(this.componentIds, async (componentId) => {\n try {\n const componentPath = this.newComponentHelper.getNewComponentPath(componentId, {\n pathFromUser: this.options.path,\n componentsToCreate: this.componentIds.length,\n });\n if (!force && fs.existsSync(path.join(this.workspace.path, componentPath))) {\n throw new BitError(\n `unable to create a component at \"${componentPath}\", this path already exists, please use \"--path\" to create the component in a different path`\n );\n }\n dirsToDeleteIfFailed.push(componentPath);\n return await this.generateOneComponent(componentId, componentPath);\n } catch (err: any) {\n await this.deleteGeneratedComponents(dirsToDeleteIfFailed);\n throw err;\n }\n });\n\n await this.workspace.bitMap.write(`create (${this.componentIds.length} components)`);\n\n const ids = generateResults.map((r) => r.id);\n await this.tryLinkToNodeModules(ids);\n await this.runOnComponentCreateHook(generateResults);\n // We are running this after the runOnComponentCreateHook as it require\n // the env to be installed to work properly, and the hook might install\n // the env.\n await this.tryWriteConfigFiles(ids);\n\n return generateResults;\n }\n\n private async tryLinkToNodeModules(ids: ComponentID[]) {\n try {\n await linkToNodeModulesByIds(\n this.workspace,\n ids.map((id) => id)\n );\n } catch (err: any) {\n this.logger.consoleFailure(\n `failed linking the new components to node_modules, please run \"bit link\" manually. error: ${err.message}`\n );\n }\n }\n\n private async runOnComponentCreateHook(generateResults: GenerateResult[]) {\n const fns = this.onComponentCreateSlot.values();\n if (!fns.length) return;\n await Promise.all(fns.map((fn) => fn(generateResults)));\n }\n\n /**\n * The function `tryWriteConfigFiles` attempts to write workspace config files, and if it fails, it logs an error\n * message.\n * @returns If the condition `!shouldWrite` is true, then nothing is being returned. Otherwise, if the `writeConfigFiles`\n * function is successfully executed, nothing is being returned. If an error occurs during the execution of\n * `writeConfigFiles`, an error message is being returned.\n */\n private async tryWriteConfigFiles(ids: ComponentID[]) {\n const shouldWrite = this.wsConfigFiles.isWorkspaceConfigWriteEnabled();\n if (!shouldWrite) return;\n ids.map((id) => this.workspace.clearComponentCache(id));\n const { err } = await this.wsConfigFiles.writeConfigFiles({\n clean: true,\n silent: true,\n dedupe: true,\n throw: false,\n });\n if (err) {\n this.logger.consoleFailure(\n `failed generating workspace config files, please run \"bit ws-config write\" manually. error: ${err.message}`\n );\n }\n }\n\n private async deleteGeneratedComponents(dirs: string[]) {\n await Promise.all(\n dirs.map(async (dir) => {\n const absoluteDir = path.join(this.workspace.path, dir);\n try {\n await fs.remove(absoluteDir);\n } catch (err: any) {\n if (err.code !== 'ENOENT') {\n // if not exist, it's fine\n throw err;\n }\n }\n })\n );\n }\n\n private async generateOneComponent(componentId: ComponentID, componentPath: string): Promise<GenerateResult> {\n const name = componentId.name;\n const namePascalCase = camelcase(name, { pascalCase: true });\n const nameCamelCase = camelcase(name);\n const aspectId = ComponentID.fromString(this.aspectId);\n\n const files = await this.template.generateFiles({\n name,\n namePascalCase,\n nameCamelCase,\n componentId,\n aspectId,\n envId: this.envId,\n });\n const mainFile = files.find((file) => file.isMain);\n await this.writeComponentFiles(componentPath, files);\n const addResults = await this.tracker.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope,\n });\n const component = await this.workspace.get(componentId);\n const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);\n if (this.template.isApp) {\n await this.workspace.use(componentId.toString());\n }\n const envBeforeConfigChanges = this.envs.getEnv(component);\n let config = this.template.config;\n if (config && typeof config === 'function') {\n const boundConfig = this.template.config?.bind(this.template);\n config = boundConfig({ aspectId: this.aspectId });\n }\n\n const userEnv = this.options.env;\n\n if (!config && this.envId && !userEnv) {\n const isInWorkspace = this.workspace.exists(this.envId);\n config = {\n [isInWorkspace ? this.envId.toStringWithoutVersion() : this.envId.toString()]: {},\n 'teambit.envs/envs': {\n env: this.envId.toStringWithoutVersion(),\n },\n };\n }\n\n const templateEnv = config?.[EnvsAspect.id]?.env;\n\n if (config && templateEnv && hasEnvConfiguredOriginally) {\n // remove the env we got from the template.\n delete config[templateEnv];\n delete config[EnvsAspect.id].env;\n if (Object.keys(config[EnvsAspect.id]).length === 0) delete config[EnvsAspect.id];\n if (Object.keys(config).length === 0) config = undefined;\n }\n\n const configWithEnv = await this.addEnvIfProvidedByFlag(config);\n if (configWithEnv) this.workspace.bitMap.setEntireConfig(component.id, configWithEnv);\n\n const getEnvData = () => {\n const envFromFlag = this.options.env; // env entered by the user when running `bit create --env`\n const envFromTemplate = config?.[EnvsAspect.id]?.env;\n if (envFromFlag) {\n return {\n envId: envFromFlag,\n setBy: '--env flag',\n };\n }\n if (envFromTemplate) {\n return {\n envId: envFromTemplate,\n setBy: 'template',\n };\n }\n return {\n envId: envBeforeConfigChanges.id,\n setBy: hasEnvConfiguredOriginally ? 'workspace variants' : '<default>',\n };\n };\n // eslint-disable-next-line prefer-const\n let { envId, setBy } = getEnvData();\n if (envId) {\n const isInWorkspace = this.workspace.exists(envId);\n const isSameAsThisEnvId = envId === this.envId?.toString() || envId === this.envId?.toStringWithoutVersion();\n if (isSameAsThisEnvId && this.envId) {\n envId = isInWorkspace ? this.envId.toStringWithoutVersion() : this.envId.toString();\n }\n }\n return {\n id: componentId,\n dir: componentPath,\n files: addResults.files,\n packageName: componentIdToPackageName(component.state._consumer),\n envId,\n envSetBy: setBy,\n isApp: this.template.isApp,\n isEnv: this.template.isEnv,\n dependencies: this.template.dependencies,\n installMissingDependencies: this.template.installMissingDependencies,\n };\n }\n\n private async addEnvIfProvidedByFlag(config?: ComponentConfig): Promise<ComponentConfig | undefined> {\n const userEnv = this.options.env; // env entered by the user when running `bit create --env`\n const templateEnv = config?.[EnvsAspect.id]?.env;\n if (!userEnv || userEnv === templateEnv) {\n return config;\n }\n config = config || {};\n if (templateEnv) {\n // the component template has an env and the user wants a different env.\n delete config[templateEnv];\n }\n await this.tracker.addEnvToConfig(userEnv, config);\n\n return config;\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeComponentFiles(\n componentPath: string,\n templateFiles: ComponentFile[]\n ): Promise<PathOsBasedRelative[]> {\n const dataToPersist = new DataToPersist();\n const vinylFiles = templateFiles.map((templateFile) => {\n const templateFileVinyl = new Vinyl({\n base: componentPath,\n path: path.join(componentPath, templateFile.relativePath),\n contents: Buffer.from(templateFile.content),\n });\n return AbstractVinyl.fromVinyl(templateFileVinyl);\n });\n const results = vinylFiles.map((v) => v.path);\n dataToPersist.addManyFiles(vinylFiles);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n return results;\n }\n}\n"],"mappings":";;;;;;AAAA,SAA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Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.generator_generator@1.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.generator_generator@1.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.generator_generator@1.0.238/dist/generator.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.generator_generator@1.0.238/dist/generator.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/generator",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.238",
|
4
4
|
"homepage": "https://bit.cloud/teambit/generator/generator",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.generator",
|
8
8
|
"name": "generator",
|
9
|
-
"version": "1.0.
|
9
|
+
"version": "1.0.238"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"camelcase": "6.2.0",
|
@@ -21,25 +21,25 @@
|
|
21
21
|
"@teambit/component-id": "1.2.0",
|
22
22
|
"@teambit/harmony": "0.4.6",
|
23
23
|
"@teambit/git.modules.git-ignore": "1.0.2",
|
24
|
-
"@teambit/envs": "1.0.
|
24
|
+
"@teambit/envs": "1.0.237",
|
25
25
|
"@teambit/logger": "0.0.955",
|
26
|
-
"@teambit/new-component-helper": "1.0.
|
27
|
-
"@teambit/tracker": "1.0.
|
28
|
-
"@teambit/workspace-config-files": "1.0.
|
26
|
+
"@teambit/new-component-helper": "1.0.237",
|
27
|
+
"@teambit/tracker": "1.0.237",
|
28
|
+
"@teambit/workspace-config-files": "1.0.237",
|
29
29
|
"@teambit/workspace.modules.node-modules-linker": "0.0.171",
|
30
|
-
"@teambit/workspace": "1.0.
|
31
|
-
"@teambit/component": "1.0.
|
30
|
+
"@teambit/workspace": "1.0.237",
|
31
|
+
"@teambit/component": "1.0.237",
|
32
32
|
"@teambit/cli": "0.0.862",
|
33
|
-
"@teambit/graphql": "1.0.
|
34
|
-
"@teambit/aspect-loader": "1.0.
|
35
|
-
"@teambit/bit": "1.6.
|
36
|
-
"@teambit/git": "1.0.
|
37
|
-
"@teambit/compiler": "1.0.
|
38
|
-
"@teambit/forking": "1.0.
|
39
|
-
"@teambit/importer": "1.0.
|
40
|
-
"@teambit/install": "1.0.
|
41
|
-
"@teambit/ui": "1.0.
|
42
|
-
"@teambit/config": "0.0.
|
33
|
+
"@teambit/graphql": "1.0.237",
|
34
|
+
"@teambit/aspect-loader": "1.0.237",
|
35
|
+
"@teambit/bit": "1.6.130",
|
36
|
+
"@teambit/git": "1.0.237",
|
37
|
+
"@teambit/compiler": "1.0.237",
|
38
|
+
"@teambit/forking": "1.0.237",
|
39
|
+
"@teambit/importer": "1.0.237",
|
40
|
+
"@teambit/install": "1.0.237",
|
41
|
+
"@teambit/ui": "1.0.237",
|
42
|
+
"@teambit/config": "0.0.988"
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
45
45
|
"@types/fs-extra": "9.0.7",
|