@teambit/generator 0.0.517 → 0.0.521

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/create.cmd.ts CHANGED
@@ -27,7 +27,7 @@ export class CreateCmd implements Command {
27
27
 
28
28
  async report([templateName, componentNames]: [string, string[]], options: CreateOptions) {
29
29
  const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);
30
- const title = `the following ${results.length} component(s) were created`;
30
+ const title = `${results.length} component(s) were created`;
31
31
 
32
32
  const componentsData = results
33
33
  .map((result) => {
@@ -45,7 +45,7 @@ class CreateCmd {
45
45
 
46
46
  async report([templateName, componentNames], options) {
47
47
  const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);
48
- const title = `the following ${results.length} component(s) were created`;
48
+ const title = `${results.length} component(s) were created`;
49
49
  const componentsData = results.map(result => {
50
50
  return `${_chalk().default.bold(result.id.toString())}
51
51
  location: ${result.dir}
@@ -1 +1 @@
1
- {"version":3,"sources":["create.cmd.ts"],"names":["CreateCmd","constructor","generator","report","templateName","componentNames","options","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","join","footer","green"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAUO,MAAMA,SAAN,CAAmC;AAcxCC,EAAAA,WAAW,CAASC,SAAT,EAAmC;AAAA,SAA1BA,SAA0B,GAA1BA,SAA0B;AAAA,kDAbvC,2CAauC;AAAA,yDAZhC,wCAYgC;AAAA,8DAX3B,EAW2B;AAAA,mDAVtC,EAUsC;AAAA,oDATrC,IASqC;AAAA,mDARtC,aAQsC;AAAA,qDAPpC,CACR,CAAC,GAAD,EAAM,oBAAN,EAA6B,iEAA7B,CADQ,EAER,CAAC,GAAD,EAAM,gBAAN,EAAyB,iFAAzB,CAFQ,EAGR,CAAC,GAAD,EAAM,iBAAN,EAAyB,qFAAzB,CAHQ,EAIR,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAJQ,CAOoC;AAAE;;AAEpC,QAANC,MAAM,CAAC,CAACC,YAAD,EAAeC,cAAf,CAAD,EAAqDC,OAArD,EAA6E;AACvF,UAAMC,OAAO,GAAG,MAAM,KAAKL,SAAL,CAAeM,yBAAf,CAAyCH,cAAzC,EAAyDD,YAAzD,EAAuEE,OAAvE,CAAtB;AACA,UAAMG,KAAK,GAAI,iBAAgBF,OAAO,CAACG,MAAO,4BAA9C;AAEA,UAAMC,cAAc,GAAGJ,OAAO,CAC3BK,GADoB,CACfC,MAAD,IAAY;AACf,aAAQ,GAAEC,iBAAMC,IAAN,CAAWF,MAAM,CAACG,EAAP,CAAUC,QAAV,EAAX,CAAiC;AACnD,gBAAgBJ,MAAM,CAACK,GAAI;AAC3B,gBAAgBL,MAAM,CAACM,KAAM;AAC7B,CAHQ;AAID,KANoB,EAOpBC,IAPoB,CAOf,IAPe,CAAvB;AAQA,UAAMC,MAAM,GAAI,uKAAhB;AAEA,WAAQ,GAAEP,iBAAMQ,KAAN,CAAYb,KAAZ,CAAmB,OAAME,cAAe,OAAMU,MAAO,EAA/D;AACD;;AA/BuC","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { GeneratorMain } from './generator.main.runtime';\n\nexport type CreateOptions = {\n namespace?: string;\n aspect?: string;\n scope?: string;\n path?: string;\n};\n\nexport class CreateCmd implements Command {\n name = 'create <templateName> <componentNames...>';\n description = 'create a new component from a template';\n shortDescription = '';\n alias = '';\n loader = true;\n group = '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 ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain) {}\n\n async report([templateName, componentNames]: [string, string[]], options: CreateOptions) {\n const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);\n const title = `the following ${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}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants. learn more at https://harmony-docs.bit.dev/building-with-bit/environments/#configure-environment-for-components`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"]}
1
+ {"version":3,"sources":["create.cmd.ts"],"names":["CreateCmd","constructor","generator","report","templateName","componentNames","options","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","join","footer","green"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAUO,MAAMA,SAAN,CAAmC;AAcxCC,EAAAA,WAAW,CAASC,SAAT,EAAmC;AAAA,SAA1BA,SAA0B,GAA1BA,SAA0B;AAAA,kDAbvC,2CAauC;AAAA,yDAZhC,wCAYgC;AAAA,8DAX3B,EAW2B;AAAA,mDAVtC,EAUsC;AAAA,oDATrC,IASqC;AAAA,mDARtC,aAQsC;AAAA,qDAPpC,CACR,CAAC,GAAD,EAAM,oBAAN,EAA6B,iEAA7B,CADQ,EAER,CAAC,GAAD,EAAM,gBAAN,EAAyB,iFAAzB,CAFQ,EAGR,CAAC,GAAD,EAAM,iBAAN,EAAyB,qFAAzB,CAHQ,EAIR,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAJQ,CAOoC;AAAE;;AAEpC,QAANC,MAAM,CAAC,CAACC,YAAD,EAAeC,cAAf,CAAD,EAAqDC,OAArD,EAA6E;AACvF,UAAMC,OAAO,GAAG,MAAM,KAAKL,SAAL,CAAeM,yBAAf,CAAyCH,cAAzC,EAAyDD,YAAzD,EAAuEE,OAAvE,CAAtB;AACA,UAAMG,KAAK,GAAI,GAAEF,OAAO,CAACG,MAAO,4BAAhC;AAEA,UAAMC,cAAc,GAAGJ,OAAO,CAC3BK,GADoB,CACfC,MAAD,IAAY;AACf,aAAQ,GAAEC,iBAAMC,IAAN,CAAWF,MAAM,CAACG,EAAP,CAAUC,QAAV,EAAX,CAAiC;AACnD,gBAAgBJ,MAAM,CAACK,GAAI;AAC3B,gBAAgBL,MAAM,CAACM,KAAM;AAC7B,CAHQ;AAID,KANoB,EAOpBC,IAPoB,CAOf,IAPe,CAAvB;AAQA,UAAMC,MAAM,GAAI,uKAAhB;AAEA,WAAQ,GAAEP,iBAAMQ,KAAN,CAAYb,KAAZ,CAAmB,OAAME,cAAe,OAAMU,MAAO,EAA/D;AACD;;AA/BuC","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { GeneratorMain } from './generator.main.runtime';\n\nexport type CreateOptions = {\n namespace?: string;\n aspect?: string;\n scope?: string;\n path?: string;\n};\n\nexport class CreateCmd implements Command {\n name = 'create <templateName> <componentNames...>';\n description = 'create a new component from a template';\n shortDescription = '';\n alias = '';\n loader = true;\n group = '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 ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain) {}\n\n async report([templateName, componentNames]: [string, string[]], options: CreateOptions) {\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}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants. learn more at https://harmony-docs.bit.dev/building-with-bit/environments/#configure-environment-for-components`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"]}
@@ -66,13 +66,11 @@ export function \${context.namePascalCase}({ text }: \${context.namePascalCase}P
66
66
  {
67
67
  relativePath: \`\${context.name}.docs.mdx\`,
68
68
  content: \`---
69
- description: 'A \${context.namePascalCase} component.'
70
- labels: ['label1', 'label2', 'label3']
69
+ description: 'A React Component for rendering text.'
70
+ labels: ['text', 'ui']
71
71
  ---
72
72
 
73
73
  import { \${context.namePascalCase} } from './\${context.name}';
74
-
75
- ## React Component for rendering text
76
74
  \`
77
75
  },
78
76
 
@@ -1 +1 @@
1
- {"version":3,"sources":["main-runtime.ts"],"names":["mainRuntime","name","namePascalCase"],"mappings":";;;;;;;AAEO,SAASA,WAAT,CAAqB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAArB,EAAiE;AACtE,SAAQ;AACV;AACA,WAAWA,cAAe,oBAAmBD,IAAK;AAClD;AACA,eAAeC,cAAe;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiBA,cAAe;AAChC;AACA;AACA;AACA,EAAEA,cAAe,qBAAoBA,cAAe;AACpD,CA1HE;AA2HD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function mainRuntime({ name, namePascalCase }: ComponentContext) {\n return `import { MainRuntime } from '@teambit/cli';\nimport { GeneratorMain, GeneratorAspect, ComponentContext } from '@teambit/generator';\nimport { ${namePascalCase}Aspect } from './${name}.aspect';\n\nexport class ${namePascalCase}Main {\n static slots = [];\n static dependencies = [GeneratorAspect];\n static runtime = MainRuntime;\n static async provider([generator]: [GeneratorMain]) {\n /**\n * Array of templates. Add as many templates as you want\n * Separate the templates to multiple files if you prefer\n * Modify, add or remove files as needed\n * See the docs file of this component for more info\n */\n\n generator.registerComponentTemplate([\n {\n name: 'component1',\n description: 'description for component1',\n generateFiles: (context: ComponentContext) => {\n return [\n\n // index file\n {\n relativePath: 'index.ts',\n isMain: true,\n content: \\`export { \\${context.namePascalCase} } from './\\${context.name}';\nexport type { \\${context.namePascalCase}Props } from './\\${context.name}';\n\\`,\n },\n\n // component file\n {\n relativePath: \\`\\${context.name}.tsx\\`,\n content: \\`import React from 'react';\n\nexport type \\${context.namePascalCase}Props = {\n /**\n * a text to be rendered in the component.\n */\n text: string\n};\n\nexport function \\${context.namePascalCase}({ text }: \\${context.namePascalCase}Props) {\n return (\n <div>\n {text}\n </div>\n );\n}\\`,\n },\n\n // docs file\n {\n relativePath: \\`\\${context.name}.docs.mdx\\`,\n content: \\`---\ndescription: 'A \\${context.namePascalCase} component.'\nlabels: ['label1', 'label2', 'label3']\n---\n\nimport { \\${context.namePascalCase} } from './\\${context.name}';\n\n## React Component for rendering text\n\\`\n },\n\n // composition file\n {\n relativePath: \\`\\${context.name}.composition.tsx\\`,\n content: \\`import React from 'react';\nimport { \\${context.namePascalCase} } from './\\${context.name}';\n\nexport const Basic\\${context.namePascalCase} = () => (\n <\\${context.namePascalCase} text=\"hello from \\${context.namePascalCase} \" />\n);\n\\`\n },\n\n // test file\n {\n relativePath: \\`\\${context.name}.spec.tsx\\`,\n content: \\`import React from 'react';\nimport { render } from '@testing-library/react';\nimport { Basic\\${context.namePascalCase} } from './\\${context.name}.composition';\n\nit('should render with the correct text', () => {\n const { getByText } = render(<Basic\\${context.namePascalCase} />);\n const rendered = getByText('hello from \\${context.namePascalCase}');\n expect(rendered).toBeTruthy();\n});\n\\`\n },\n // add more files here such as css/sass\n ];\n },\n },\n\n // component 2\n {\n name: 'component2',\n description: 'description for component2',\n generateFiles: (context: ComponentContext) => {\n return [\n\n // index file\n {\n relativePath: 'index.ts',\n isMain: true,\n content: \\`export {} from '';\n\\`,\n },\n ]\n }\n }\n ]);\n\n return new ${namePascalCase}Main();\n }\n}\n\n${namePascalCase}Aspect.addRuntime(${namePascalCase}Main);\n`;\n}\n"]}
1
+ {"version":3,"sources":["main-runtime.ts"],"names":["mainRuntime","name","namePascalCase"],"mappings":";;;;;;;AAEO,SAASA,WAAT,CAAqB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAArB,EAAiE;AACtE,SAAQ;AACV;AACA,WAAWA,cAAe,oBAAmBD,IAAK;AAClD;AACA,eAAeC,cAAe;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiBA,cAAe;AAChC;AACA;AACA;AACA,EAAEA,cAAe,qBAAoBA,cAAe;AACpD,CAxHE;AAyHD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function mainRuntime({ name, namePascalCase }: ComponentContext) {\n return `import { MainRuntime } from '@teambit/cli';\nimport { GeneratorMain, GeneratorAspect, ComponentContext } from '@teambit/generator';\nimport { ${namePascalCase}Aspect } from './${name}.aspect';\n\nexport class ${namePascalCase}Main {\n static slots = [];\n static dependencies = [GeneratorAspect];\n static runtime = MainRuntime;\n static async provider([generator]: [GeneratorMain]) {\n /**\n * Array of templates. Add as many templates as you want\n * Separate the templates to multiple files if you prefer\n * Modify, add or remove files as needed\n * See the docs file of this component for more info\n */\n\n generator.registerComponentTemplate([\n {\n name: 'component1',\n description: 'description for component1',\n generateFiles: (context: ComponentContext) => {\n return [\n\n // index file\n {\n relativePath: 'index.ts',\n isMain: true,\n content: \\`export { \\${context.namePascalCase} } from './\\${context.name}';\nexport type { \\${context.namePascalCase}Props } from './\\${context.name}';\n\\`,\n },\n\n // component file\n {\n relativePath: \\`\\${context.name}.tsx\\`,\n content: \\`import React from 'react';\n\nexport type \\${context.namePascalCase}Props = {\n /**\n * a text to be rendered in the component.\n */\n text: string\n};\n\nexport function \\${context.namePascalCase}({ text }: \\${context.namePascalCase}Props) {\n return (\n <div>\n {text}\n </div>\n );\n}\\`,\n },\n\n // docs file\n {\n relativePath: \\`\\${context.name}.docs.mdx\\`,\n content: \\`---\ndescription: 'A React Component for rendering text.'\nlabels: ['text', 'ui']\n---\n\nimport { \\${context.namePascalCase} } from './\\${context.name}';\n\\`\n },\n\n // composition file\n {\n relativePath: \\`\\${context.name}.composition.tsx\\`,\n content: \\`import React from 'react';\nimport { \\${context.namePascalCase} } from './\\${context.name}';\n\nexport const Basic\\${context.namePascalCase} = () => (\n <\\${context.namePascalCase} text=\"hello from \\${context.namePascalCase} \" />\n);\n\\`\n },\n\n // test file\n {\n relativePath: \\`\\${context.name}.spec.tsx\\`,\n content: \\`import React from 'react';\nimport { render } from '@testing-library/react';\nimport { Basic\\${context.namePascalCase} } from './\\${context.name}.composition';\n\nit('should render with the correct text', () => {\n const { getByText } = render(<Basic\\${context.namePascalCase} />);\n const rendered = getByText('hello from \\${context.namePascalCase}');\n expect(rendered).toBeTruthy();\n});\n\\`\n },\n // add more files here such as css/sass\n ];\n },\n },\n\n // component 2\n {\n name: 'component2',\n description: 'description for component2',\n generateFiles: (context: ComponentContext) => {\n return [\n\n // index file\n {\n relativePath: 'index.ts',\n isMain: true,\n content: \\`export {} from '';\n\\`,\n },\n ]\n }\n }\n ]);\n\n return new ${namePascalCase}Main();\n }\n}\n\n${namePascalCase}Aspect.addRuntime(${namePascalCase}Main);\n`;\n}\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/generator",
3
- "version": "0.0.517",
3
+ "version": "0.0.521",
4
4
  "homepage": "https://bit.dev/teambit/generator/generator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.generator",
8
8
  "name": "generator",
9
- "version": "0.0.517"
9
+ "version": "0.0.521"
10
10
  },
11
11
  "dependencies": {
12
12
  "camelcase": "6.2.0",
@@ -23,19 +23,19 @@
23
23
  "core-js": "^3.0.0",
24
24
  "@teambit/bit-error": "0.0.365",
25
25
  "@teambit/component-id": "0.0.369",
26
- "@teambit/envs": "0.0.517",
27
- "@teambit/workspace": "0.0.517",
26
+ "@teambit/envs": "0.0.521",
27
+ "@teambit/workspace": "0.0.521",
28
28
  "@teambit/cli": "0.0.379",
29
- "@teambit/graphql": "0.0.517",
30
- "@teambit/aspect-loader": "0.0.517",
31
- "@teambit/bit": "0.0.519",
32
- "@teambit/component": "0.0.517",
29
+ "@teambit/graphql": "0.0.521",
30
+ "@teambit/aspect-loader": "0.0.521",
31
+ "@teambit/bit": "0.0.523",
32
+ "@teambit/component": "0.0.521",
33
33
  "@teambit/legacy-bit-id": "0.0.368",
34
- "@teambit/compiler": "0.0.517",
35
- "@teambit/dependency-resolver": "0.0.517",
36
- "@teambit/logger": "0.0.447",
37
- "@teambit/pkg": "0.0.517",
38
- "@teambit/ui": "0.0.517"
34
+ "@teambit/compiler": "0.0.521",
35
+ "@teambit/dependency-resolver": "0.0.521",
36
+ "@teambit/logger": "0.0.449",
37
+ "@teambit/pkg": "0.0.521",
38
+ "@teambit/ui": "0.0.521"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/fs-extra": "9.0.7",
@@ -46,7 +46,7 @@
46
46
  "@types/react-dom": "^17.0.5",
47
47
  "@types/react": "^17.0.8",
48
48
  "@types/node": "12.20.4",
49
- "@teambit/generator.aspect-docs.generator": "0.0.86"
49
+ "@teambit/generator.aspect-docs.generator": "0.0.88"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@teambit/legacy": "1.0.76",
@@ -58,13 +58,11 @@ export function \${context.namePascalCase}({ text }: \${context.namePascalCase}P
58
58
  {
59
59
  relativePath: \`\${context.name}.docs.mdx\`,
60
60
  content: \`---
61
- description: 'A \${context.namePascalCase} component.'
62
- labels: ['label1', 'label2', 'label3']
61
+ description: 'A React Component for rendering text.'
62
+ labels: ['text', 'ui']
63
63
  ---
64
64
 
65
65
  import { \${context.namePascalCase} } from './\${context.name}';
66
-
67
- ## React Component for rendering text
68
66
  \`
69
67
  },
70
68