@teambit/generator 0.0.0-e3178287df8e32bdda79061371f177e643b2508e → 0.0.0-e366e67c1fbc13a90ba11f1214fb76efb8fdca09

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.
Files changed (88) hide show
  1. package/dist/component-generator.d.ts +9 -9
  2. package/dist/component-generator.js.map +1 -1
  3. package/dist/component-template.d.ts +1 -1
  4. package/dist/component-template.js.map +1 -1
  5. package/dist/create.cmd.d.ts +4 -3
  6. package/dist/create.cmd.js +5 -1
  7. package/dist/create.cmd.js.map +1 -1
  8. package/dist/generator-env-type.d.ts +3 -3
  9. package/dist/generator-env-type.js.map +1 -1
  10. package/dist/generator.graphql.d.ts +3 -3
  11. package/dist/generator.graphql.js.map +1 -1
  12. package/dist/generator.main.runtime.d.ts +24 -17
  13. package/dist/generator.main.runtime.js +49 -1
  14. package/dist/generator.main.runtime.js.map +1 -1
  15. package/dist/generator.service.d.ts +3 -3
  16. package/dist/generator.service.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/new.cmd.d.ts +4 -3
  20. package/dist/new.cmd.js +4 -1
  21. package/dist/new.cmd.js.map +1 -1
  22. package/dist/{preview-1752582455144.js → preview-1764019157602.js} +2 -2
  23. package/dist/starter-list.d.ts +2 -2
  24. package/dist/starter-list.js.map +1 -1
  25. package/dist/starter.plugin.d.ts +2 -2
  26. package/dist/starter.plugin.js.map +1 -1
  27. package/dist/template-list.d.ts +2 -2
  28. package/dist/template-list.js.map +1 -1
  29. package/dist/templates/basic/basic.starter.d.ts +1 -1
  30. package/dist/templates/basic/basic.starter.js.map +1 -1
  31. package/dist/templates/basic/template/files/workspace-config.d.ts +1 -1
  32. package/dist/templates/basic/template/files/workspace-config.js.map +1 -1
  33. package/dist/templates/component-generator/files/component-template.d.ts +1 -1
  34. package/dist/templates/component-generator/files/component-template.js.map +1 -1
  35. package/dist/templates/component-generator/files/index.d.ts +1 -1
  36. package/dist/templates/component-generator/files/index.js.map +1 -1
  37. package/dist/templates/component-generator/index.d.ts +1 -1
  38. package/dist/templates/component-generator/index.js.map +1 -1
  39. package/dist/templates/component-generator-standalone/files/aspect-file.d.ts +1 -1
  40. package/dist/templates/component-generator-standalone/files/aspect-file.js.map +1 -1
  41. package/dist/templates/component-generator-standalone/files/index.d.ts +1 -1
  42. package/dist/templates/component-generator-standalone/files/index.js.map +1 -1
  43. package/dist/templates/component-generator-standalone/files/main-runtime.d.ts +1 -1
  44. package/dist/templates/component-generator-standalone/files/main-runtime.js.map +1 -1
  45. package/dist/templates/component-generator-standalone/index.d.ts +1 -1
  46. package/dist/templates/component-generator-standalone/index.js.map +1 -1
  47. package/dist/templates/starter/files/doc-file.d.ts +1 -1
  48. package/dist/templates/starter/files/doc-file.js.map +1 -1
  49. package/dist/templates/starter/files/index.d.ts +1 -1
  50. package/dist/templates/starter/files/index.js.map +1 -1
  51. package/dist/templates/starter/files/starter.d.ts +1 -1
  52. package/dist/templates/starter/files/starter.js.map +1 -1
  53. package/dist/templates/starter/index.d.ts +1 -1
  54. package/dist/templates/starter/index.js.map +1 -1
  55. package/dist/templates/starter-standalone/files/doc-file.d.ts +1 -1
  56. package/dist/templates/starter-standalone/files/doc-file.js.map +1 -1
  57. package/dist/templates/starter-standalone/files/index.d.ts +1 -1
  58. package/dist/templates/starter-standalone/files/index.js.map +1 -1
  59. package/dist/templates/starter-standalone/files/starter.d.ts +1 -1
  60. package/dist/templates/starter-standalone/files/starter.js.map +1 -1
  61. package/dist/templates/starter-standalone/index.d.ts +1 -1
  62. package/dist/templates/starter-standalone/index.js.map +1 -1
  63. package/dist/templates.cmd.d.ts +2 -2
  64. package/dist/templates.cmd.js +2 -2
  65. package/dist/templates.cmd.js.map +1 -1
  66. package/dist/workspace-generator.d.ts +5 -5
  67. package/dist/workspace-generator.js.map +1 -1
  68. package/dist/workspace-template.d.ts +1 -1
  69. package/dist/workspace-template.js.map +1 -1
  70. package/generator.service.tsx +3 -3
  71. package/package.json +31 -30
  72. package/templates/basic/basic.starter.ts +1 -1
  73. package/templates/basic/template/files/workspace-config.ts +1 -1
  74. package/templates/component-generator/files/component-template.ts +1 -1
  75. package/templates/component-generator/files/index.ts +1 -1
  76. package/templates/component-generator/index.ts +1 -1
  77. package/templates/component-generator-standalone/files/aspect-file.ts +1 -1
  78. package/templates/component-generator-standalone/files/index.ts +1 -1
  79. package/templates/component-generator-standalone/files/main-runtime.ts +1 -1
  80. package/templates/component-generator-standalone/index.ts +1 -1
  81. package/templates/starter/files/doc-file.ts +1 -1
  82. package/templates/starter/files/index.ts +1 -1
  83. package/templates/starter/files/starter.ts +1 -1
  84. package/templates/starter/index.ts +1 -1
  85. package/templates/starter-standalone/files/doc-file.ts +1 -1
  86. package/templates/starter-standalone/files/index.ts +1 -1
  87. package/templates/starter-standalone/files/starter.ts +1 -1
  88. package/templates/starter-standalone/index.ts +1 -1
@@ -1,13 +1,13 @@
1
- import { Workspace } from '@teambit/workspace';
2
- import { EnvsMain } from '@teambit/envs';
3
- import { Logger } from '@teambit/logger';
4
- import { TrackerMain } from '@teambit/tracker';
5
- import { NewComponentHelperMain } from '@teambit/new-component-helper';
1
+ import type { Workspace } from '@teambit/workspace';
2
+ import type { EnvsMain } from '@teambit/envs';
3
+ import type { Logger } from '@teambit/logger';
4
+ import type { TrackerMain } from '@teambit/tracker';
5
+ import type { NewComponentHelperMain } from '@teambit/new-component-helper';
6
6
  import { ComponentID } from '@teambit/component-id';
7
- import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
8
- import { ComponentTemplate, PromptResults } from './component-template';
9
- import { CreateOptions } from './create.cmd';
10
- import { OnComponentCreateSlot } from './generator.main.runtime';
7
+ import type { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
8
+ import type { ComponentTemplate, PromptResults } from './component-template';
9
+ import type { CreateOptions } from './create.cmd';
10
+ import type { OnComponentCreateSlot } from './generator.main.runtime';
11
11
  export type GenerateResult = {
12
12
  id: ComponentID;
13
13
  dir: string;
@@ -1 +1 @@
1
- {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_enquirer","_pMapSeries","_path","_envs","_camelcase","_bitError","_workspaceModules","_pkgModules","_componentId","e","__esModule","default","ComponentGenerator","constructor","workspace","componentIds","options","template","envs","newComponentHelper","tracker","wsConfigFiles","logger","onComponentCreateSlot","aspectId","envId","installOptions","promptResults","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","getOptionResultFromArgs","option","args","process","argv","slice","argIndex","indexOf","name","type","argValue","Error","choices","includes","getPromptOptionResult","prompt","getPromptResults","promptOptions","undefined","fromArg","skip","optionResult","namePascalCase","camelcase","pascalCase","nameCamelCase","ComponentID","fromString","files","generateFiles","mainFile","find","file","isMain","writeComponentFiles","f","relativePath","content","addResults","track","rootDir","componentName","fullName","defaultScope","scope","component","get","hasEnvConfiguredOriginally","hasEnvConfigured","envBeforeConfigChanges","getEnv","config","boundConfig","bind","userEnv","env","isInWorkspace","hasId","ignoreVersion","toStringWithoutVersion","toString","templateEnv","EnvsAspect","Object","keys","configWithEnv","addEnvIfProvidedByFlag","setEntireConfig","getEnvData","envFromFlag","envFromTemplate","setBy","isSameAsThisEnvId","packageName","componentIdToPackageName","state","_consumer","envSetBy","isApp","isEnv","dependencies","installMissingDependencies","addEnvToConfig","exports"],"sources":["component-generator.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { prompt } from 'enquirer';\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 { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport { ComponentID } from '@teambit/component-id';\nimport { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n\nimport { ComponentTemplate, ComponentConfig, PromptOption, PromptResults } 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 InstallOptions = { optimizeReportForNonTerminal?: boolean };\n\nexport type OnComponentCreateFn = (generateResults: GenerateResult[], installOptions?: InstallOptions) => 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 private installOptions: InstallOptions = {},\n private promptResults?: PromptResults\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, this.installOptions)));\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 getOptionResultFromArgs(option: PromptOption): string | boolean | undefined {\n const args = process.argv.slice(2);\n const argIndex = args.indexOf(`--${option.name}`);\n if (argIndex === -1) {\n return;\n }\n if (option.type === 'confirm') {\n return true;\n }\n const argValue = args[argIndex + 1];\n if (!argValue) {\n throw new Error(`Missing value for ${option.name}`);\n }\n if (option.type === 'select' && !option.choices?.includes(argValue)) {\n throw new Error(\n `Invalid value for ${option.name}. Please use one of the following values: ${option.choices?.join(', ')}`\n );\n }\n return argValue;\n }\n\n private async getPromptOptionResult(option: PromptOption): Promise<Record<string, string | boolean>> {\n switch (option.type) {\n case 'input':\n return prompt({\n type: 'input',\n name: option.name,\n message: option.message,\n });\n case 'confirm':\n return prompt({\n type: 'confirm',\n name: option.name,\n message: option.message,\n });\n case 'select':\n return prompt({\n type: 'select',\n name: option.name,\n message: option.message,\n choices: option.choices,\n });\n default:\n throw new Error(`unexpected prompt type ${option.type}`);\n }\n }\n\n private async getPromptResults(): Promise<PromptResults | undefined> {\n if (this.promptResults) {\n return this.promptResults;\n }\n const promptOptions = this.template.promptOptions?.();\n if (!promptOptions) {\n return undefined;\n }\n const promptResults: PromptResults = {};\n for await (const option of promptOptions) {\n const fromArg = this.getOptionResultFromArgs(option);\n if (fromArg) {\n promptResults[option.name] = fromArg;\n continue;\n }\n if (option.skip && option.skip(promptResults)) {\n continue;\n }\n try {\n const optionResult = await this.getPromptOptionResult(option);\n promptResults[option.name] = optionResult[option.name];\n } catch (err: any) {\n if (!err) {\n // for some reason, when the user clicks Ctrl+C, the error is an empty string\n throw new Error(`The prompt has been canceled`);\n }\n throw err;\n }\n }\n return promptResults;\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 const promptResults = await this.getPromptResults();\n\n const files = await this.template.generateFiles({\n name,\n namePascalCase,\n nameCamelCase,\n componentId,\n aspectId,\n envId: this.envId,\n promptResults,\n });\n const mainFile = files.find((file) => file.isMain);\n await this.newComponentHelper.writeComponentFiles(\n componentPath,\n files.map((f) => ({ path: f.relativePath, content: f.content }))\n );\n const addResults = await this.tracker.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope || componentId.scope,\n });\n const component = await this.workspace.get(componentId);\n const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);\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.hasId(this.envId, { ignoreVersion: true });\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.hasId(envId, { ignoreVersion: true });\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"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,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,IA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,KAAK,GAAG6G,aAAa,GAAG,IAAI,CAAC7G,KAAK,CAACgH,sBAAsB,CAAC,CAAC,GAAG,IAAI,CAAChH,KAAK,CAACiH,QAAQ,CAAC,CAAC;MACrF;IACF;IACA,OAAO;MACLrF,EAAE,EAAEpB,WAAW;MACfyC,GAAG,EAAExC,aAAa;MAClBwE,KAAK,EAAEU,UAAU,CAACV,KAAK;MACvB6C,WAAW,EAAE,IAAAC,sCAAwB,EAAC7B,SAAS,CAAC8B,KAAK,CAACC,SAAS,CAAC;MAChEjI,KAAK;MACLkI,QAAQ,EAAEN,KAAK;MACfO,KAAK,EAAE,IAAI,CAAC3I,QAAQ,CAAC2I,KAAK;MAC1BC,KAAK,EAAE,IAAI,CAAC5I,QAAQ,CAAC4I,KAAK;MAC1BC,YAAY,EAAE,IAAI,CAAC7I,QAAQ,CAAC6I,YAAY;MACxCC,0BAA0B,EAAE,IAAI,CAAC9I,QAAQ,CAAC8I;IAC5C,CAAC;EACH;EAEA,MAAcf,sBAAsBA,CAACf,MAAwB,EAAwC;IACnG,MAAMG,OAAO,GAAG,IAAI,CAACpH,OAAO,CAACqH,GAAG,CAAC,CAAC;IAClC,MAAMM,WAAW,GAAGV,MAAM,GAAGW,kBAAU,CAACvF,EAAE,CAAC,EAAEgF,GAAG;IAChD,IAAI,CAACD,OAAO,IAAIA,OAAO,KAAKO,WAAW,EAAE;MACvC,OAAOV,MAAM;IACf;IACAA,MAAM,GAAGA,MAAM,IAAI,CAAC,CAAC;IACrB,IAAIU,WAAW,EAAE;MACf;MACA,OAAOV,MAAM,CAACU,WAAW,CAAC;IAC5B;IACA,MAAM,IAAI,CAACvH,OAAO,CAAC4I,cAAc,CAAC5B,OAAO,EAAEH,MAAM,CAAC;IAElD,OAAOA,MAAM;EACf;AACF;AAACgC,OAAA,CAAArJ,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_enquirer","_pMapSeries","_path","_envs","_camelcase","_bitError","_workspaceModules","_pkgModules","_componentId","e","__esModule","default","ComponentGenerator","constructor","workspace","componentIds","options","template","envs","newComponentHelper","tracker","wsConfigFiles","logger","onComponentCreateSlot","aspectId","envId","installOptions","promptResults","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","getOptionResultFromArgs","option","args","process","argv","slice","argIndex","indexOf","name","type","argValue","Error","choices","includes","getPromptOptionResult","prompt","getPromptResults","promptOptions","undefined","fromArg","skip","optionResult","namePascalCase","camelcase","pascalCase","nameCamelCase","ComponentID","fromString","files","generateFiles","mainFile","find","file","isMain","writeComponentFiles","f","relativePath","content","addResults","track","rootDir","componentName","fullName","defaultScope","scope","component","get","hasEnvConfiguredOriginally","hasEnvConfigured","envBeforeConfigChanges","getEnv","config","boundConfig","bind","userEnv","env","isInWorkspace","hasId","ignoreVersion","toStringWithoutVersion","toString","templateEnv","EnvsAspect","Object","keys","configWithEnv","addEnvIfProvidedByFlag","setEntireConfig","getEnvData","envFromFlag","envFromTemplate","setBy","isSameAsThisEnvId","packageName","componentIdToPackageName","state","_consumer","envSetBy","isApp","isEnv","dependencies","installMissingDependencies","addEnvToConfig","exports"],"sources":["component-generator.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { prompt } from 'enquirer';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport type { Workspace } from '@teambit/workspace';\nimport type { EnvsMain } from '@teambit/envs';\nimport { EnvsAspect } from '@teambit/envs';\nimport camelcase from 'camelcase';\nimport { BitError } from '@teambit/bit-error';\nimport type { Logger } from '@teambit/logger';\nimport type { TrackerMain } from '@teambit/tracker';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport type { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport { ComponentID } from '@teambit/component-id';\nimport type { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n\nimport type { ComponentTemplate, ComponentConfig, PromptOption, PromptResults } from './component-template';\nimport type { CreateOptions } from './create.cmd';\nimport type { 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 InstallOptions = { optimizeReportForNonTerminal?: boolean };\n\nexport type OnComponentCreateFn = (generateResults: GenerateResult[], installOptions?: InstallOptions) => 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 private installOptions: InstallOptions = {},\n private promptResults?: PromptResults\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, this.installOptions)));\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 getOptionResultFromArgs(option: PromptOption): string | boolean | undefined {\n const args = process.argv.slice(2);\n const argIndex = args.indexOf(`--${option.name}`);\n if (argIndex === -1) {\n return;\n }\n if (option.type === 'confirm') {\n return true;\n }\n const argValue = args[argIndex + 1];\n if (!argValue) {\n throw new Error(`Missing value for ${option.name}`);\n }\n if (option.type === 'select' && !option.choices?.includes(argValue)) {\n throw new Error(\n `Invalid value for ${option.name}. Please use one of the following values: ${option.choices?.join(', ')}`\n );\n }\n return argValue;\n }\n\n private async getPromptOptionResult(option: PromptOption): Promise<Record<string, string | boolean>> {\n switch (option.type) {\n case 'input':\n return prompt({\n type: 'input',\n name: option.name,\n message: option.message,\n });\n case 'confirm':\n return prompt({\n type: 'confirm',\n name: option.name,\n message: option.message,\n });\n case 'select':\n return prompt({\n type: 'select',\n name: option.name,\n message: option.message,\n choices: option.choices,\n });\n default:\n throw new Error(`unexpected prompt type ${option.type}`);\n }\n }\n\n private async getPromptResults(): Promise<PromptResults | undefined> {\n if (this.promptResults) {\n return this.promptResults;\n }\n const promptOptions = this.template.promptOptions?.();\n if (!promptOptions) {\n return undefined;\n }\n const promptResults: PromptResults = {};\n for await (const option of promptOptions) {\n const fromArg = this.getOptionResultFromArgs(option);\n if (fromArg) {\n promptResults[option.name] = fromArg;\n continue;\n }\n if (option.skip && option.skip(promptResults)) {\n continue;\n }\n try {\n const optionResult = await this.getPromptOptionResult(option);\n promptResults[option.name] = optionResult[option.name];\n } catch (err: any) {\n if (!err) {\n // for some reason, when the user clicks Ctrl+C, the error is an empty string\n throw new Error(`The prompt has been canceled`);\n }\n throw err;\n }\n }\n return promptResults;\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 const promptResults = await this.getPromptResults();\n\n const files = await this.template.generateFiles({\n name,\n namePascalCase,\n nameCamelCase,\n componentId,\n aspectId,\n envId: this.envId,\n promptResults,\n });\n const mainFile = files.find((file) => file.isMain);\n await this.newComponentHelper.writeComponentFiles(\n componentPath,\n files.map((f) => ({ path: f.relativePath, content: f.content }))\n );\n const addResults = await this.tracker.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope || componentId.scope,\n });\n const component = await this.workspace.get(componentId);\n const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);\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.hasId(this.envId, { ignoreVersion: true });\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.hasId(envId, { ignoreVersion: true });\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"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,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;E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AI,CAAChH,KAAK,CAACiH,QAAQ,CAAC,CAAC;MACrF;IACF;IACA,OAAO;MACLrF,EAAE,EAAEpB,WAAW;MACfyC,GAAG,EAAExC,aAAa;MAClBwE,KAAK,EAAEU,UAAU,CAACV,KAAK;MACvB6C,WAAW,EAAE,IAAAC,sCAAwB,EAAC7B,SAAS,CAAC8B,KAAK,CAACC,SAAS,CAAC;MAChEjI,KAAK;MACLkI,QAAQ,EAAEN,KAAK;MACfO,KAAK,EAAE,IAAI,CAAC3I,QAAQ,CAAC2I,KAAK;MAC1BC,KAAK,EAAE,IAAI,CAAC5I,QAAQ,CAAC4I,KAAK;MAC1BC,YAAY,EAAE,IAAI,CAAC7I,QAAQ,CAAC6I,YAAY;MACxCC,0BAA0B,EAAE,IAAI,CAAC9I,QAAQ,CAAC8I;IAC5C,CAAC;EACH;EAEA,MAAcf,sBAAsBA,CAACf,MAAwB,EAAwC;IACnG,MAAMG,OAAO,GAAG,IAAI,CAACpH,OAAO,CAACqH,GAAG,CAAC,CAAC;IAClC,MAAMM,WAAW,GAAGV,MAAM,GAAGW,kBAAU,CAACvF,EAAE,CAAC,EAAEgF,GAAG;IAChD,IAAI,CAACD,OAAO,IAAIA,OAAO,KAAKO,WAAW,EAAE;MACvC,OAAOV,MAAM;IACf;IACAA,MAAM,GAAGA,MAAM,IAAI,CAAC,CAAC;IACrB,IAAIU,WAAW,EAAE;MACf;MACA,OAAOV,MAAM,CAACU,WAAW,CAAC;IAC5B;IACA,MAAM,IAAI,CAACvH,OAAO,CAAC4I,cAAc,CAAC5B,OAAO,EAAEH,MAAM,CAAC;IAElD,OAAOA,MAAM;EACf;AACF;AAACgC,OAAA,CAAArJ,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ComponentID } from '@teambit/component';
1
+ import type { ComponentID } from '@teambit/component';
2
2
  /**
3
3
  * BaseComponentTemplateOptions describes the foundational properties for components.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["component-template.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component';\n\n/**\n * BaseComponentTemplateOptions describes the foundational properties for components.\n */\nexport interface BaseComponentTemplateOptions {\n /**\n * component-name as entered by the user, e.g. `use-date`.\n * without the scope and the namespace.\n */\n name: string;\n\n /**\n * component-name as upper camel case, e.g. `use-date` becomes `UseDate`.\n * useful when generating the file content, for example for a class name.\n */\n namePascalCase: string;\n\n /**\n * component-name as lower camel case, e.g. `use-date` becomes `useDate`.\n * useful when generating the file content, for example for a function/variable name.\n */\n nameCamelCase: string;\n\n /**\n * component id.\n * the name is the name+namespace. the scope is the scope entered by --scope flag or the defaultScope\n */\n componentId: ComponentID;\n\n /**\n * aspect id of the aspect that register the template itself\n */\n aspectId: ComponentID | string;\n\n /**\n * env id of the env that register the template itself.\n * This will be usually identical to the aspectId but aspectId will always exist,\n * while envId will be undefined if the template is not registered by an env.\n */\n envId?: ComponentID;\n\n /**\n * path of the component.\n */\n path?: string;\n /**\n * scope of the component.\n */\n scope?: string;\n /**\n * namespace of the component.\n */\n namespace?: string;\n /**\n * when a template implements the promptOptions function, this object will be populated with the user responses.\n */\n promptResults?: PromptResults;\n}\n\n/**\n * ComponentContext represents foundational properties for a component context.\n */\nexport type ComponentContext = BaseComponentTemplateOptions;\n\nexport interface ComponentFile {\n /**\n * relative path of the file within the component.\n */\n relativePath: string;\n\n /**\n * file content\n */\n content: string;\n\n /**\n * whether this file will be tracked as the main file\n */\n isMain?: boolean;\n}\n\nexport interface ConfigContext {\n /**\n * Aspect id of the aspect that register the template itself\n */\n aspectId: string;\n}\n\nexport type ComponentConfig = { [aspectName: string]: any };\n\nexport interface ComponentTemplateOptions {\n /**\n * name of the component template. for example: `hook`, `react-component` or `module`.\n */\n name?: string;\n\n /**\n * display name of the template.\n */\n displayName?: string;\n\n /**\n * example name for the component template.\n */\n exampleComponentName?: string;\n\n /**\n * short description of the template. shown in the `bit templates` command.\n */\n description?: string;\n\n /**\n * hide this template so that it is not listed with `bit templates`\n */\n hidden?: boolean;\n\n /**\n * env to use for the generated component.\n */\n env?: string;\n\n /**\n * adds a metadata that the component that this template creates is of type env.\n * This will be used later to do further configuration for example:\n * - ensure to create the .bit_root for it\n */\n isEnv?: boolean;\n\n /**\n * adds a metadata that the component that this template creates is of type app.\n * This will be used later to do further configuration for example:\n * - add it to the workspace.jsonc as app\n * - ensure to create the .bit_root for it\n */\n isApp?: boolean;\n\n /**\n * list of dependencies to install when the component is created.\n */\n dependencies?: string[];\n\n /**\n * Perform installation of missing dependencies after component generation.\n * This is the same as of running `bit install --add-missing-deps` after component generation.\n */\n installMissingDependencies?: boolean;\n}\n\n/**\n * PromptOption is shown to the user before calling the generateFiles function.\n * The prompt is using enquirer under the hood. see https://www.npmjs.com/package/enquirer.\n * Examples:\n * - input: {name: 'name', message: 'enter your name', type: 'input'}\n * - confirm: {name: 'isHappy', message: 'are you happy?', type: 'confirm'}\n * - select: {name: 'color', message: 'pick a color', type: 'select', choices: ['red', 'blue', 'green']}\n */\nexport type PromptOption = {\n name: string;\n message: string;\n type: 'input' | 'confirm' | 'select';\n choices?: string[]; // for select type\n skip?: (previousResults: PromptResults) => boolean; // skip this prompt if this function returns true\n};\n\n/**\n * PromptResults is the result of the user input received from the promptOptions.\n * The key is the name of the prompt option and the value is the user input.\n * in case the prompt-option is of type 'confirm', the value will be a boolean.\n */\nexport type PromptResults = Record<string, string | boolean>;\n\nexport interface ComponentTemplate extends ComponentTemplateOptions {\n name: string;\n\n /**\n * in case the template requires user input, this function will be called to prompt the user.\n * the results will be passed to the generateFiles function.\n */\n promptOptions?: () => PromptOption[];\n\n /**\n * template function for generating the file of a certain component.,\n */\n generateFiles(context: ComponentContext): Promise<ComponentFile[]> | ComponentFile[];\n\n /**\n * component config. gets saved in the .bitmap file and it overrides the workspace.jsonc config.\n * for example, you can set the env that will be used for this component as follows:\n * \"teambit.envs/envs\": {\n * \"env\": \"teambit.harmony/aspect\"\n * },\n */\n config?: ComponentConfig | ((context: ConfigContext) => ComponentConfig);\n}\n\nexport type GetComponentTemplates = () => ComponentTemplate[];\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["component-template.ts"],"sourcesContent":["import type { ComponentID } from '@teambit/component';\n\n/**\n * BaseComponentTemplateOptions describes the foundational properties for components.\n */\nexport interface BaseComponentTemplateOptions {\n /**\n * component-name as entered by the user, e.g. `use-date`.\n * without the scope and the namespace.\n */\n name: string;\n\n /**\n * component-name as upper camel case, e.g. `use-date` becomes `UseDate`.\n * useful when generating the file content, for example for a class name.\n */\n namePascalCase: string;\n\n /**\n * component-name as lower camel case, e.g. `use-date` becomes `useDate`.\n * useful when generating the file content, for example for a function/variable name.\n */\n nameCamelCase: string;\n\n /**\n * component id.\n * the name is the name+namespace. the scope is the scope entered by --scope flag or the defaultScope\n */\n componentId: ComponentID;\n\n /**\n * aspect id of the aspect that register the template itself\n */\n aspectId: ComponentID | string;\n\n /**\n * env id of the env that register the template itself.\n * This will be usually identical to the aspectId but aspectId will always exist,\n * while envId will be undefined if the template is not registered by an env.\n */\n envId?: ComponentID;\n\n /**\n * path of the component.\n */\n path?: string;\n /**\n * scope of the component.\n */\n scope?: string;\n /**\n * namespace of the component.\n */\n namespace?: string;\n /**\n * when a template implements the promptOptions function, this object will be populated with the user responses.\n */\n promptResults?: PromptResults;\n}\n\n/**\n * ComponentContext represents foundational properties for a component context.\n */\nexport type ComponentContext = BaseComponentTemplateOptions;\n\nexport interface ComponentFile {\n /**\n * relative path of the file within the component.\n */\n relativePath: string;\n\n /**\n * file content\n */\n content: string;\n\n /**\n * whether this file will be tracked as the main file\n */\n isMain?: boolean;\n}\n\nexport interface ConfigContext {\n /**\n * Aspect id of the aspect that register the template itself\n */\n aspectId: string;\n}\n\nexport type ComponentConfig = { [aspectName: string]: any };\n\nexport interface ComponentTemplateOptions {\n /**\n * name of the component template. for example: `hook`, `react-component` or `module`.\n */\n name?: string;\n\n /**\n * display name of the template.\n */\n displayName?: string;\n\n /**\n * example name for the component template.\n */\n exampleComponentName?: string;\n\n /**\n * short description of the template. shown in the `bit templates` command.\n */\n description?: string;\n\n /**\n * hide this template so that it is not listed with `bit templates`\n */\n hidden?: boolean;\n\n /**\n * env to use for the generated component.\n */\n env?: string;\n\n /**\n * adds a metadata that the component that this template creates is of type env.\n * This will be used later to do further configuration for example:\n * - ensure to create the .bit_root for it\n */\n isEnv?: boolean;\n\n /**\n * adds a metadata that the component that this template creates is of type app.\n * This will be used later to do further configuration for example:\n * - add it to the workspace.jsonc as app\n * - ensure to create the .bit_root for it\n */\n isApp?: boolean;\n\n /**\n * list of dependencies to install when the component is created.\n */\n dependencies?: string[];\n\n /**\n * Perform installation of missing dependencies after component generation.\n * This is the same as of running `bit install --add-missing-deps` after component generation.\n */\n installMissingDependencies?: boolean;\n}\n\n/**\n * PromptOption is shown to the user before calling the generateFiles function.\n * The prompt is using enquirer under the hood. see https://www.npmjs.com/package/enquirer.\n * Examples:\n * - input: {name: 'name', message: 'enter your name', type: 'input'}\n * - confirm: {name: 'isHappy', message: 'are you happy?', type: 'confirm'}\n * - select: {name: 'color', message: 'pick a color', type: 'select', choices: ['red', 'blue', 'green']}\n */\nexport type PromptOption = {\n name: string;\n message: string;\n type: 'input' | 'confirm' | 'select';\n choices?: string[]; // for select type\n skip?: (previousResults: PromptResults) => boolean; // skip this prompt if this function returns true\n};\n\n/**\n * PromptResults is the result of the user input received from the promptOptions.\n * The key is the name of the prompt option and the value is the user input.\n * in case the prompt-option is of type 'confirm', the value will be a boolean.\n */\nexport type PromptResults = Record<string, string | boolean>;\n\nexport interface ComponentTemplate extends ComponentTemplateOptions {\n name: string;\n\n /**\n * in case the template requires user input, this function will be called to prompt the user.\n * the results will be passed to the generateFiles function.\n */\n promptOptions?: () => PromptOption[];\n\n /**\n * template function for generating the file of a certain component.,\n */\n generateFiles(context: ComponentContext): Promise<ComponentFile[]> | ComponentFile[];\n\n /**\n * component config. gets saved in the .bitmap file and it overrides the workspace.jsonc config.\n * for example, you can set the env that will be used for this component as follows:\n * \"teambit.envs/envs\": {\n * \"env\": \"teambit.harmony/aspect\"\n * },\n */\n config?: ComponentConfig | ((context: ConfigContext) => ComponentConfig);\n}\n\nexport type GetComponentTemplates = () => ComponentTemplate[];\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Command, CommandOptions } from '@teambit/cli';
2
- import { ComponentID } from '@teambit/component';
3
- import { GeneratorMain } from './generator.main.runtime';
1
+ import type { Command, CommandOptions } from '@teambit/cli';
2
+ import type { ComponentID } from '@teambit/component';
3
+ import type { GeneratorMain } from './generator.main.runtime';
4
4
  import type { BaseComponentTemplateOptions } from './component-template';
5
5
  /**
6
6
  * CreateOptions combines foundational properties with additional options for creating a component.
@@ -14,6 +14,7 @@ export declare class CreateCmd implements Command {
14
14
  private generator;
15
15
  name: string;
16
16
  description: string;
17
+ extendedDescription: string;
17
18
  alias: string;
18
19
  loader: boolean;
19
20
  helpUrl: string;
@@ -23,7 +23,8 @@ class CreateCmd {
23
23
  constructor(generator) {
24
24
  this.generator = generator;
25
25
  _defineProperty(this, "name", 'create <template-name> <component-names...>');
26
- _defineProperty(this, "description", 'create a new component (source files and config) using a template.');
26
+ _defineProperty(this, "description", 'scaffold new component(s) from a template (sources, config, and env)');
27
+ _defineProperty(this, "extendedDescription", "Generates one or more components from a chosen template with ready-to-use source files, configuration, and environment. Use it to quickly scaffold consistent components across your workspace. Run 'bit templates' to discover available templates.");
27
28
  _defineProperty(this, "alias", '');
28
29
  _defineProperty(this, "loader", true);
29
30
  _defineProperty(this, "helpUrl", 'reference/starters/create-starter');
@@ -43,6 +44,9 @@ class CreateCmd {
43
44
  }, {
44
45
  cmd: 'bit create mdx docs/create-components --aspect teambit.mdx/mdx-env --scope my-org.my-scope',
45
46
  description: "creates an mdx component named 'docs/create-components' and sets it scope to 'my-org.my-scope'. \nby default, the scope is the `defaultScope` value, configured in your `workspace.jsonc`."
47
+ }, {
48
+ cmd: 'bit create react my-org.my-scope/hooks/use-session',
49
+ description: "creates a component named 'hooks/use-session' with scope 'my-org.my-scope'. \nthe scope is parsed from the component name (bit.cloud scopes contain a dot)."
46
50
  }, {
47
51
  cmd: 'bit create react ui/button --aspect teambit.react/react-env --env teambit.community/envs/community-react@3.0.3',
48
52
  description: "creates a component named 'ui/button' from the teambit.react/react-env env and sets it to use the 'community-react' env. \n(the template's default env is 'teambit.react/react-env')."
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CreateCmd","constructor","generator","name","description","cmd","report","templateName","componentNames","options","aspectId","template","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","envSetBy","packageName","join","footer","green","exports"],"sources":["create.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport { GeneratorMain } from './generator.main.runtime';\nimport type { BaseComponentTemplateOptions } from './component-template';\n\n/**\n * CreateOptions combines foundational properties with additional options for creating a component.\n */\nexport type CreateOptions = BaseComponentTemplateOptions & {\n env?: string;\n aspect?: string;\n force?: boolean;\n};\n\nexport class CreateCmd implements Command {\n name = 'create <template-name> <component-names...>';\n description = 'create a new component (source files and config) using a template.';\n alias = '';\n loader = true;\n helpUrl = 'reference/starters/create-starter';\n arguments = [\n {\n name: 'template-name',\n description:\n \"the template for generating the component \\n(run 'bit templates' for a list of available templates)\",\n },\n {\n name: 'component-names...',\n description: 'a list of component names to generate',\n },\n ];\n examples = [\n {\n cmd: 'bit create react ui/button --aspect teambit.react/react-env',\n description: \"creates a component named 'ui/button' using the 'react' template\",\n },\n {\n cmd: 'bit create module utils/is-string utils/is-number --aspect teambit.node/node',\n description:\n \"creates two components, 'utils/is-string' and 'utils/is-number' using the 'node' template from the 'node' aspect(env)\",\n },\n {\n cmd: 'bit create mdx docs/create-components --aspect teambit.mdx/mdx-env --scope my-org.my-scope',\n description:\n \"creates an mdx component named 'docs/create-components' and sets it scope to 'my-org.my-scope'. \\nby default, the scope is the `defaultScope` value, configured in your `workspace.jsonc`.\",\n },\n {\n cmd: 'bit create react ui/button --aspect teambit.react/react-env --env teambit.community/envs/community-react@3.0.3',\n description:\n \"creates a component named 'ui/button' from the teambit.react/react-env env and sets it to use the 'community-react' env. \\n(the template's default env is 'teambit.react/react-env').\",\n },\n ];\n group = 'component-development';\n options = [\n ['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`],\n ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`],\n ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'],\n ['t', 'template <string>', 'env-id of the template. alias for --aspect.'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ['e', 'env <string>', \"set the component's environment. (overrides the env from variants and the template)\"],\n ['f', 'force', 'replace existing files at the target location'],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain) {}\n\n async report(\n [templateName, componentNames]: [string, string[]],\n options: Partial<CreateOptions> & {\n template?: string | ComponentID;\n force?: boolean;\n }\n ) {\n options.aspectId = options.aspectId ?? options.template;\n const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);\n const title = `${results.length} component(s) were created`;\n\n const componentsData = results\n .map((result) => {\n return `${chalk.bold(result.id.toString())}\n location: ${result.dir}\n env: ${result.envId} (set by ${result.envSetBy})\n package: ${result.packageName}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants, template config or --env flag.`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AA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KAAK,YAAYN,MAAM,CAACO,QAAQ;AACvD,gBAAgBP,MAAM,CAACQ,WAAW;AAClC,CAAC;IACK,CAAC,CAAC,CACDC,IAAI,CAAC,IAAI,CAAC;IACb,MAAMC,MAAM,GAAG,sFAAsF;IAErG,OAAO,GAAGT,gBAAK,CAACU,KAAK,CAACf,KAAK,CAAC,OAAOE,cAAc,OAAOY,MAAM,EAAE;EAClE;AACF;AAACE,OAAA,CAAA9B,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CreateCmd","constructor","generator","name","description","cmd","report","templateName","componentNames","options","aspectId","template","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","envSetBy","packageName","join","footer","green","exports"],"sources":["create.cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from '@teambit/cli';\nimport type { ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport type { GeneratorMain } from './generator.main.runtime';\nimport type { BaseComponentTemplateOptions } from './component-template';\n\n/**\n * CreateOptions combines foundational properties with additional options for creating a component.\n */\nexport type CreateOptions = BaseComponentTemplateOptions & {\n env?: string;\n aspect?: string;\n force?: boolean;\n};\n\nexport class CreateCmd implements Command {\n name = 'create <template-name> <component-names...>';\n description = 'scaffold new component(s) from a template (sources, config, and env)';\n extendedDescription =\n \"Generates one or more components from a chosen template with ready-to-use source files, configuration, and environment. Use it to quickly scaffold consistent components across your workspace. Run 'bit templates' to discover available templates.\";\n alias = '';\n loader = true;\n helpUrl = 'reference/starters/create-starter';\n arguments = [\n {\n name: 'template-name',\n description:\n \"the template for generating the component \\n(run 'bit templates' for a list of available templates)\",\n },\n {\n name: 'component-names...',\n description: 'a list of component names to generate',\n },\n ];\n examples = [\n {\n cmd: 'bit create react ui/button --aspect teambit.react/react-env',\n description: \"creates a component named 'ui/button' using the 'react' template\",\n },\n {\n cmd: 'bit create module utils/is-string utils/is-number --aspect teambit.node/node',\n description:\n \"creates two components, 'utils/is-string' and 'utils/is-number' using the 'node' template from the 'node' aspect(env)\",\n },\n {\n cmd: 'bit create mdx docs/create-components --aspect teambit.mdx/mdx-env --scope my-org.my-scope',\n description:\n \"creates an mdx component named 'docs/create-components' and sets it scope to 'my-org.my-scope'. \\nby default, the scope is the `defaultScope` value, configured in your `workspace.jsonc`.\",\n },\n {\n cmd: 'bit create react my-org.my-scope/hooks/use-session',\n description:\n \"creates a component named 'hooks/use-session' with scope 'my-org.my-scope'. \\nthe scope is parsed from the component name (bit.cloud scopes contain a dot).\",\n },\n {\n cmd: 'bit create react ui/button --aspect teambit.react/react-env --env teambit.community/envs/community-react@3.0.3',\n description:\n \"creates a component named 'ui/button' from the teambit.react/react-env env and sets it to use the 'community-react' env. \\n(the template's default env is 'teambit.react/react-env').\",\n },\n ];\n group = 'component-development';\n options = [\n ['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`],\n ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`],\n ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'],\n ['t', 'template <string>', 'env-id of the template. alias for --aspect.'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ['e', 'env <string>', \"set the component's environment. (overrides the env from variants and the template)\"],\n ['f', 'force', 'replace existing files at the target location'],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain) {}\n\n async report(\n [templateName, componentNames]: [string, string[]],\n options: Partial<CreateOptions> & {\n template?: string | ComponentID;\n force?: boolean;\n }\n ) {\n options.aspectId = options.aspectId ?? options.template;\n const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);\n const title = `${results.length} component(s) were created`;\n\n const componentsData = results\n .map((result) => {\n return `${chalk.bold(result.id.toString())}\n location: ${result.dir}\n env: ${result.envId} (set by ${result.envSetBy})\n package: ${result.packageName}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants, template config or --env flag.`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb,CAAA,CAAAiB,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAI1B;AACA;AACA;;AAOO,MAAMgB,SAAS,CAAoB;EAwDxCC,WAAWA,CAASC,SAAwB,EAAE;IAAA,KAA1BA,SAAwB,GAAxBA,SAAwB;IAAApB,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AAMC,OAAO,GAAG,MAAM,IAAI,CAACV,SAAS,CAACW,yBAAyB,CAACL,cAAc,EAAED,YAAY,EAAEE,OAAO,CAAC;IACrG,MAAMK,KAAK,GAAG,GAAGF,OAAO,CAACG,MAAM,4BAA4B;IAE3D,MAAMC,cAAc,GAAGJ,OAAO,CAC3BK,GAAG,CAAEC,MAAM,IAAK;MACf,OAAO,GAAGC,gBAAK,CAACC,IAAI,CAACF,MAAM,CAACG,EAAE,CAACC,QAAQ,CAAC,CAAC,CAAC;AAClD,gBAAgBJ,MAAM,CAACK,GAAG;AAC1B,gBAAgBL,MAAM,CAACM,KAAK,YAAYN,MAAM,CAACO,QAAQ;AACvD,gBAAgBP,MAAM,CAACQ,WAAW;AAClC,CAAC;IACK,CAAC,CAAC,CACDC,IAAI,CAAC,IAAI,CAAC;IACb,MAAMC,MAAM,GAAG,sFAAsF;IAErG,OAAO,GAAGT,gBAAK,CAACU,KAAK,CAACf,KAAK,CAAC,OAAOE,cAAc,OAAOY,MAAM,EAAE;EAClE;AACF;AAACE,OAAA,CAAA9B,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { EnvHandler } from '@teambit/envs';
2
- import { TemplateList } from './template-list';
3
- import { StarterList } from './starter-list';
1
+ import type { EnvHandler } from '@teambit/envs';
2
+ import type { TemplateList } from './template-list';
3
+ import type { StarterList } from './starter-list';
4
4
  export interface GeneratorEnv {
5
5
  /**
6
6
  * return a template list instance.
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["generator-env-type.ts"],"sourcesContent":["import { EnvHandler } from '@teambit/envs';\nimport { TemplateList } from './template-list';\nimport { StarterList } from './starter-list';\n\nexport interface GeneratorEnv {\n /**\n * return a template list instance.\n */\n generators(): EnvHandler<TemplateList>;\n /**\n * return a starter list instance.\n */\n starters(): EnvHandler<StarterList>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["generator-env-type.ts"],"sourcesContent":["import type { EnvHandler } from '@teambit/envs';\nimport type { TemplateList } from './template-list';\nimport type { StarterList } from './starter-list';\n\nexport interface GeneratorEnv {\n /**\n * return a template list instance.\n */\n generators(): EnvHandler<TemplateList>;\n /**\n * return a starter list instance.\n */\n starters(): EnvHandler<StarterList>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Schema } from '@teambit/graphql';
2
- import { GeneratorMain } from './generator.main.runtime';
3
- import { CreateOptions } from './create.cmd';
1
+ import type { Schema } from '@teambit/graphql';
2
+ import type { GeneratorMain } from './generator.main.runtime';
3
+ import type { CreateOptions } from './create.cmd';
4
4
  export type CreateQueryOptions = CreateOptions & {
5
5
  templateName: string;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_graphqlTag","data","require","_excluded","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","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","_ref","name","templateName","options","res","generateComponentTemplate","map","component","id","toString","dir","files","Generator","templates","listTemplates","Query"],"sources":["generator.graphql.ts"],"sourcesContent":["import { Schema } from '@teambit/graphql';\nimport { gql } from 'graphql-tag';\nimport { GeneratorMain } from './generator.main.runtime';\nimport { CreateOptions } from './create.cmd';\n\nexport type CreateQueryOptions = CreateOptions & { templateName: string };\n\nexport function generatorSchema(generator: GeneratorMain): Schema {\n return {\n typeDefs: gql`\n type GenerateResult {\n id: String\n dir: String\n files: [String]\n }\n\n type Mutation {\n # create Component by template\n createComponent(\n name: String!\n templateName: String!\n scope: String\n namespace: String\n aspect: String\n ): [GenerateResult]\n }\n\n type TemplateDescriptor {\n aspectId: String!\n name: String!\n }\n\n type Generator {\n templates: [TemplateDescriptor]\n }\n\n type Query {\n generator: Generator\n }\n `,\n resolvers: {\n Mutation: {\n createComponent: async (req: any, { name, templateName, ...options }: CreateQueryOptions) => {\n const res = await generator.generateComponentTemplate([name], templateName, { name, ...options });\n return res.map((component) => ({\n id: component.id.toString(),\n dir: component.dir,\n files: component.files,\n }));\n },\n },\n Generator: {\n templates: async () => {\n return generator.listTemplates();\n },\n },\n Query: {\n generator: () => generator,\n },\n },\n };\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkC,MAAAE,SAAA;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CA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C,GAAG,EAAEH,SAAS,CAACG,GAAG;YAClBC,KAAK,EAAEJ,SAAS,CAACI;UACnB,CAAC,CAAC,CAAC;QACL;MACF,CAAC;MACDC,SAAS,EAAE;QACTC,SAAS,EAAE,MAAAA,CAAA,KAAY;UACrB,OAAOpB,SAAS,CAACqB,aAAa,CAAC,CAAC;QAClC;MACF,CAAC;MACDC,KAAK,EAAE;QACLtB,SAAS,EAAEA,CAAA,KAAMA;MACnB;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_graphqlTag","data","require","_excluded","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","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","_ref","name","templateName","options","res","generateComponentTemplate","map","component","id","toString","dir","files","Generator","templates","listTemplates","Query"],"sources":["generator.graphql.ts"],"sourcesContent":["import type { Schema } from '@teambit/graphql';\nimport { gql } from 'graphql-tag';\nimport type { GeneratorMain } from './generator.main.runtime';\nimport type { CreateOptions } from './create.cmd';\n\nexport type CreateQueryOptions = CreateOptions & { templateName: string };\n\nexport function generatorSchema(generator: GeneratorMain): Schema {\n return {\n typeDefs: gql`\n type GenerateResult {\n id: String\n dir: String\n files: [String]\n }\n\n type Mutation {\n # create Component by template\n createComponent(\n name: String!\n templateName: String!\n scope: String\n namespace: String\n aspect: String\n ): [GenerateResult]\n }\n\n type TemplateDescriptor {\n aspectId: String!\n name: String!\n }\n\n type Generator {\n templates: [TemplateDescriptor]\n }\n\n type Query {\n generator: Generator\n }\n `,\n resolvers: {\n Mutation: {\n createComponent: async (req: any, { name, templateName, ...options }: CreateQueryOptions) => {\n const res = await generator.generateComponentTemplate([name], templateName, { name, ...options });\n return res.map((component) => ({\n id: component.id.toString(),\n dir: component.dir,\n files: component.files,\n }));\n },\n },\n Generator: {\n templates: async () => {\n return generator.listTemplates();\n },\n },\n Query: {\n generator: () => generator,\n },\n },\n };\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkC,MAAAE,SAAA;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,WAAAd,CAAA,IAAAE,MAAA,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AAS,EAAE,MAAAA,CAAA,KAAY;UACrB,OAAOpB,SAAS,CAACqB,aAAa,CAAC,CAAC;QAClC;MACF,CAAC;MACDC,KAAK,EAAE;QACLtB,SAAS,EAAEA,CAAA,KAAMA;MACnB;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,21 +1,21 @@
1
- import { GraphqlMain } from '@teambit/graphql';
2
- import { CLIMain } from '@teambit/cli';
3
- import { Workspace } from '@teambit/workspace';
4
- import { EnvDefinition, EnvsMain } from '@teambit/envs';
5
- import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
1
+ import type { GraphqlMain } from '@teambit/graphql';
2
+ import type { CLIMain } from '@teambit/cli';
3
+ import type { Workspace } from '@teambit/workspace';
4
+ import type { EnvDefinition, EnvsMain } from '@teambit/envs';
5
+ import type { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
6
6
  import type { ComponentMain, Component } from '@teambit/component';
7
- import { Harmony, SlotRegistry } from '@teambit/harmony';
8
- import { GitMain } from '@teambit/git';
9
- import { AspectLoaderMain } from '@teambit/aspect-loader';
10
- import { TrackerMain } from '@teambit/tracker';
11
- import { NewComponentHelperMain } from '@teambit/new-component-helper';
12
- import { Logger, LoggerMain } from '@teambit/logger';
13
- import { DeprecationMain } from '@teambit/deprecation';
14
- import { ComponentTemplate, GetComponentTemplates, PromptResults } from './component-template';
15
- import { CreateOptions } from './create.cmd';
16
- import { GenerateResult, InstallOptions, OnComponentCreateFn } from './component-generator';
17
- import { WorkspaceTemplate } from './workspace-template';
18
- import { NewOptions } from './new.cmd';
7
+ import type { Harmony, SlotRegistry } from '@teambit/harmony';
8
+ import type { GitMain } from '@teambit/git';
9
+ import type { AspectLoaderMain } from '@teambit/aspect-loader';
10
+ import type { TrackerMain } from '@teambit/tracker';
11
+ import type { NewComponentHelperMain } from '@teambit/new-component-helper';
12
+ import type { Logger, LoggerMain } from '@teambit/logger';
13
+ import type { DeprecationMain } from '@teambit/deprecation';
14
+ import type { ComponentTemplate, GetComponentTemplates, PromptResults } from './component-template';
15
+ import type { CreateOptions } from './create.cmd';
16
+ import type { GenerateResult, InstallOptions, OnComponentCreateFn } from './component-generator';
17
+ import type { WorkspaceTemplate } from './workspace-template';
18
+ import type { NewOptions } from './new.cmd';
19
19
  export type ComponentTemplateSlot = SlotRegistry<ComponentTemplate[] | GetComponentTemplates>;
20
20
  export type WorkspaceTemplateSlot = SlotRegistry<WorkspaceTemplate[]>;
21
21
  export type OnComponentCreateSlot = SlotRegistry<OnComponentCreateFn>;
@@ -151,6 +151,13 @@ export declare class GeneratorMain {
151
151
  }>;
152
152
  searchRegisteredWorkspaceTemplate(name?: string, aspectId?: string, remoteEnvsAspect?: EnvsMain): Promise<WorkspaceTemplate | undefined>;
153
153
  getTemplateWithId(templateName: string, aspect?: string): Promise<ComponentTemplateWithId>;
154
+ /**
155
+ * Parse the scope from a component name if provided in the format: scope/name
156
+ * This only works for bit.cloud scopes (containing a dot), e.g., "my-org.my-scope/hooks/use-session"
157
+ * Local bare-scopes don't contain a dot, so we can't distinguish between scope/name and namespace/name.
158
+ * @returns { scope, name } where scope is the extracted scope (or undefined) and name is the remaining component name
159
+ */
160
+ private parseScopeFromComponentIdStr;
154
161
  generateComponentTemplate(componentNames: string[], templateName: string, options: Partial<CreateOptions>, installOptions?: InstallOptions, promptResults?: PromptResults): Promise<GenerateResult[]>;
155
162
  private getEnvIdFromTemplateWithId;
156
163
  generateWorkspaceTemplate(workspaceName: string, templateName: string, options: NewOptions & {
@@ -137,6 +137,13 @@ function _lodash() {
137
137
  };
138
138
  return data;
139
139
  }
140
+ function _legacyBitId() {
141
+ const data = require("@teambit/legacy-bit-id");
142
+ _legacyBitId = function () {
143
+ return data;
144
+ };
145
+ return data;
146
+ }
140
147
  function _logger() {
141
148
  const data = require("@teambit/logger");
142
149
  _logger = function () {
@@ -528,6 +535,38 @@ class GeneratorMain {
528
535
  if (!templateWithId) throw new (_bitError().BitError)(`template "${templateName}" was not found`);
529
536
  return templateWithId;
530
537
  }
538
+
539
+ /**
540
+ * Parse the scope from a component name if provided in the format: scope/name
541
+ * This only works for bit.cloud scopes (containing a dot), e.g., "my-org.my-scope/hooks/use-session"
542
+ * Local bare-scopes don't contain a dot, so we can't distinguish between scope/name and namespace/name.
543
+ * @returns { scope, name } where scope is the extracted scope (or undefined) and name is the remaining component name
544
+ */
545
+ parseScopeFromComponentIdStr(componentIdStr) {
546
+ const firstSlashIndex = componentIdStr.indexOf('/');
547
+ if (firstSlashIndex === -1) {
548
+ // no slash, so no scope prefix, e.g., "button"
549
+ return {
550
+ scope: undefined,
551
+ name: componentIdStr
552
+ };
553
+ }
554
+ const potentialScope = componentIdStr.substring(0, firstSlashIndex);
555
+ // bit.cloud scopes always contain a dot (e.g., "my-org.my-scope")
556
+ // local bare-scopes don't contain a dot, so we can't distinguish them from namespace/name
557
+ if (potentialScope.includes('.') && (0, _legacyBitId().isValidScopeName)(potentialScope)) {
558
+ const name = componentIdStr.substring(firstSlashIndex + 1);
559
+ return {
560
+ scope: potentialScope,
561
+ name
562
+ };
563
+ }
564
+ // no dot in the first segment, treat the whole string as the component name
565
+ return {
566
+ scope: undefined,
567
+ name: componentIdStr
568
+ };
569
+ }
531
570
  async generateComponentTemplate(componentNames, templateName, options, installOptions, promptResults) {
532
571
  if (!this.workspace) throw new (_workspace().OutsideWorkspaceError)();
533
572
  await this.loadAspects();
@@ -536,7 +575,16 @@ class GeneratorMain {
536
575
  aspect
537
576
  } = options;
538
577
  const templateWithId = await this.getTemplateWithId(templateName, aspect);
539
- const componentIds = componentNames.map(componentName => this.newComponentHelper.getNewComponentId(componentName, namespace, options.scope));
578
+ const componentIds = componentNames.map(componentName => {
579
+ // Support scope/name syntax for bit.cloud scopes (containing a dot)
580
+ // e.g., "my-org.my-scope/hooks/use-session" -> scope: "my-org.my-scope", name: "hooks/use-session"
581
+ const {
582
+ scope: parsedScope,
583
+ name: parsedName
584
+ } = this.parseScopeFromComponentIdStr(componentName);
585
+ const scope = parsedScope || options.scope;
586
+ return this.newComponentHelper.getNewComponentId(parsedName, namespace, scope);
587
+ });
540
588
  const componentNameSameAsTemplateName = componentIds.find(componentId => componentId.name === templateName);
541
589
  if (componentNameSameAsTemplateName) {
542
590
  const compNamePascal = (0, _camelcase().default)(templateName, {