@teambit/generator 0.0.1144 → 0.0.1145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component-template.d.ts +39 -22
- package/dist/component-template.js.map +1 -1
- package/dist/create.cmd.d.ts +10 -9
- package/dist/create.cmd.js +15 -12
- package/dist/create.cmd.js.map +1 -1
- package/dist/generator.graphql.d.ts +4 -0
- package/dist/generator.graphql.js +12 -1
- package/dist/generator.graphql.js.map +1 -1
- package/dist/generator.main.runtime.d.ts +5 -5
- package/dist/generator.main.runtime.js +16 -29
- package/dist/generator.main.runtime.js.map +1 -1
- package/dist/new.cmd.d.ts +6 -7
- package/dist/new.cmd.js +4 -0
- package/dist/new.cmd.js.map +1 -1
- package/dist/{preview-1693279117198.js → preview-1693474270980.js} +2 -2
- package/dist/templates/basic/basic.starter.d.ts +3 -0
- package/dist/templates/basic/basic.starter.js +39 -0
- package/dist/templates/basic/basic.starter.js.map +1 -0
- package/dist/templates/basic/index.d.ts +1 -0
- package/dist/templates/basic/index.js +20 -0
- package/dist/templates/basic/index.js.map +1 -0
- package/dist/templates/basic/template/files/git-ignore.d.ts +1 -0
- package/dist/templates/basic/template/files/git-ignore.js +118 -0
- package/dist/templates/basic/template/files/git-ignore.js.map +1 -0
- package/dist/templates/basic/template/files/workspace-config.d.ts +2 -0
- package/dist/templates/{workspace-generator/index.js → basic/template/files/workspace-config.js} +35 -11
- package/dist/templates/basic/template/files/workspace-config.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/component.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/component.js +35 -0
- package/dist/templates/component-generator/files/component-template-files/component.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/composition.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/composition.js +29 -0
- package/dist/templates/component-generator/files/component-template-files/composition.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/index-file.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/index-file.js +24 -0
- package/dist/templates/component-generator/files/component-template-files/index-file.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/test.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/test.js +31 -0
- package/dist/templates/component-generator/files/component-template-files/test.js.map +1 -0
- package/dist/templates/component-generator/files/component-template.d.ts +2 -0
- package/dist/templates/component-generator/files/component-template.js +67 -0
- package/dist/templates/component-generator/files/component-template.js.map +1 -0
- package/dist/templates/component-generator/files/index.d.ts +1 -1
- package/dist/templates/component-generator/files/index.js +1 -5
- package/dist/templates/component-generator/files/index.js.map +1 -1
- package/dist/templates/component-generator/index.d.ts +1 -1
- package/dist/templates/component-generator/index.js +36 -16
- package/dist/templates/component-generator/index.js.map +1 -1
- package/dist/templates/{component-generator → component-generator-standalone}/files/aspect-file.d.ts +1 -1
- package/dist/templates/component-generator-standalone/files/aspect-file.js.map +1 -0
- package/dist/templates/component-generator-standalone/files/index.d.ts +2 -0
- package/dist/templates/component-generator-standalone/files/index.js +19 -0
- package/dist/templates/component-generator-standalone/files/index.js.map +1 -0
- package/dist/templates/{component-generator → component-generator-standalone}/files/main-runtime.d.ts +1 -1
- package/dist/templates/component-generator-standalone/files/main-runtime.js.map +1 -0
- package/dist/templates/component-generator-standalone/index.d.ts +2 -0
- package/dist/templates/component-generator-standalone/index.js +64 -0
- package/dist/templates/component-generator-standalone/index.js.map +1 -0
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/index.js +59 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/starter/files/doc-file.d.ts +2 -0
- package/dist/templates/starter/files/doc-file.js +33 -0
- package/dist/templates/starter/files/doc-file.js.map +1 -0
- package/dist/templates/starter/files/generate-files.d.ts +1 -0
- package/dist/templates/starter/files/generate-files.js +35 -0
- package/dist/templates/starter/files/generate-files.js.map +1 -0
- package/dist/templates/starter/files/index.d.ts +1 -1
- package/dist/templates/starter/files/index.js +1 -1
- package/dist/templates/starter/files/index.js.map +1 -1
- package/dist/templates/starter/files/starter.d.ts +2 -1
- package/dist/templates/starter/files/starter.js +39 -29
- package/dist/templates/starter/files/starter.js.map +1 -1
- package/dist/templates/starter/files/workspace-config-tpl.js +7 -1
- package/dist/templates/starter/files/workspace-config-tpl.js.map +1 -1
- package/dist/templates/starter/index.d.ts +1 -1
- package/dist/templates/starter/index.js +16 -16
- package/dist/templates/starter/index.js.map +1 -1
- package/dist/templates/starter-standalone/files/doc-file.d.ts +2 -0
- package/dist/templates/starter-standalone/files/doc-file.js +33 -0
- package/dist/templates/starter-standalone/files/doc-file.js.map +1 -0
- package/dist/templates/starter-standalone/files/git-ignore-tpl.d.ts +1 -0
- package/dist/templates/starter-standalone/files/git-ignore-tpl.js +121 -0
- package/dist/templates/starter-standalone/files/git-ignore-tpl.js.map +1 -0
- package/dist/templates/starter-standalone/files/index.d.ts +2 -0
- package/dist/templates/starter-standalone/files/index.js +15 -0
- package/dist/templates/starter-standalone/files/index.js.map +1 -0
- package/dist/templates/starter-standalone/files/starter.d.ts +2 -0
- package/dist/templates/starter-standalone/files/starter.js +44 -0
- package/dist/templates/starter-standalone/files/starter.js.map +1 -0
- package/dist/templates/starter-standalone/files/workspace-config-tpl.d.ts +1 -0
- package/dist/templates/starter-standalone/files/workspace-config-tpl.js +30 -0
- package/dist/templates/starter-standalone/files/workspace-config-tpl.js.map +1 -0
- package/dist/templates/starter-standalone/index.d.ts +2 -0
- package/dist/templates/starter-standalone/index.js +73 -0
- package/dist/templates/starter-standalone/index.js.map +1 -0
- package/dist/workspace-generator.js +17 -1
- package/dist/workspace-generator.js.map +1 -1
- package/dist/workspace-template.d.ts +37 -29
- package/dist/workspace-template.js.map +1 -1
- package/package.json +22 -22
- package/templates/basic/basic.starter.ts +22 -0
- package/templates/basic/index.ts +1 -0
- package/templates/basic/template/files/git-ignore.ts +110 -0
- package/templates/basic/template/files/workspace-config.ts +33 -0
- package/templates/component-generator/files/component-template-files/component.ts +26 -0
- package/templates/component-generator/files/component-template-files/composition.ts +20 -0
- package/templates/component-generator/files/component-template-files/index-file.ts +15 -0
- package/templates/component-generator/files/component-template-files/test.ts +22 -0
- package/templates/component-generator/files/component-template.ts +58 -0
- package/templates/component-generator/files/index.ts +2 -6
- package/templates/component-generator/index.ts +22 -12
- package/templates/{component-generator → component-generator-standalone}/files/aspect-file.ts +1 -1
- package/templates/component-generator-standalone/files/index.ts +10 -0
- package/templates/{component-generator → component-generator-standalone}/files/main-runtime.ts +1 -1
- package/templates/component-generator-standalone/index.ts +39 -0
- package/templates/index.ts +4 -0
- package/templates/starter/files/doc-file.ts +24 -0
- package/templates/starter/files/generate-files.ts +27 -0
- package/templates/starter/files/index.ts +2 -2
- package/templates/starter/files/starter.ts +37 -28
- package/templates/starter/files/workspace-config-tpl.ts +7 -1
- package/templates/starter/index.ts +13 -11
- package/templates/starter-standalone/files/doc-file.ts +24 -0
- package/templates/starter-standalone/files/git-ignore-tpl.ts +113 -0
- package/templates/starter-standalone/files/index.ts +6 -0
- package/templates/starter-standalone/files/starter.ts +35 -0
- package/templates/starter-standalone/files/workspace-config-tpl.ts +22 -0
- package/templates/starter-standalone/index.ts +44 -0
- package/dist/templates/component-generator/files/aspect-file.js.map +0 -1
- package/dist/templates/component-generator/files/main-runtime.js.map +0 -1
- package/dist/templates/starter/files/docs-file.d.ts +0 -1
- package/dist/templates/starter/files/docs-file.js +0 -45
- package/dist/templates/starter/files/docs-file.js.map +0 -1
- package/dist/templates/starter/files/readme-tpl.d.ts +0 -1
- package/dist/templates/starter/files/readme-tpl.js +0 -47
- package/dist/templates/starter/files/readme-tpl.js.map +0 -1
- package/dist/templates/workspace-generator/index.d.ts +0 -2
- package/dist/templates/workspace-generator/index.js.map +0 -1
- package/templates/starter/files/docs-file.ts +0 -37
- package/templates/starter/files/readme-tpl.ts +0 -39
- package/templates/workspace-generator/index.ts +0 -10
- /package/dist/templates/{component-generator → component-generator-standalone}/files/aspect-file.js +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.d.ts +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.js +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.js.map +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/main-runtime.js +0 -0
- /package/templates/{component-generator → component-generator-standalone}/files/docs-file.ts +0 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.starterTemplate = void 0;
|
7
|
+
function _index() {
|
8
|
+
const data = require("./files/index");
|
9
|
+
_index = function () {
|
10
|
+
return data;
|
11
|
+
};
|
12
|
+
return data;
|
13
|
+
}
|
14
|
+
function _starter() {
|
15
|
+
const data = require("./files/starter");
|
16
|
+
_starter = function () {
|
17
|
+
return data;
|
18
|
+
};
|
19
|
+
return data;
|
20
|
+
}
|
21
|
+
function _docFile() {
|
22
|
+
const data = require("./files/doc-file");
|
23
|
+
_docFile = function () {
|
24
|
+
return data;
|
25
|
+
};
|
26
|
+
return data;
|
27
|
+
}
|
28
|
+
function _gitIgnoreTpl() {
|
29
|
+
const data = require("./files/git-ignore-tpl");
|
30
|
+
_gitIgnoreTpl = function () {
|
31
|
+
return data;
|
32
|
+
};
|
33
|
+
return data;
|
34
|
+
}
|
35
|
+
function _workspaceConfigTpl() {
|
36
|
+
const data = require("./files/workspace-config-tpl");
|
37
|
+
_workspaceConfigTpl = function () {
|
38
|
+
return data;
|
39
|
+
};
|
40
|
+
return data;
|
41
|
+
}
|
42
|
+
const starterTemplate = {
|
43
|
+
name: 'standalone-starter',
|
44
|
+
description: 'create your own workspace starter (standalone) - \nDocs: https://bit.dev/reference/starters/create-starter',
|
45
|
+
generateFiles: context => {
|
46
|
+
return [{
|
47
|
+
relativePath: 'index.ts',
|
48
|
+
content: (0, _index().indexFile)(context),
|
49
|
+
isMain: true
|
50
|
+
}, {
|
51
|
+
relativePath: `${context.name}.starter.ts`,
|
52
|
+
content: (0, _starter().starterFile)(context)
|
53
|
+
}, {
|
54
|
+
relativePath: `${context.name}.docs.mdx`,
|
55
|
+
content: (0, _docFile().docFile)(context)
|
56
|
+
}, {
|
57
|
+
relativePath: 'template/files/git-ignore.ts',
|
58
|
+
content: (0, _gitIgnoreTpl().gitIgnoreTemplate)()
|
59
|
+
}, {
|
60
|
+
relativePath: 'template/files/workspace-config.ts',
|
61
|
+
content: (0, _workspaceConfigTpl().workspaceConfigTemplate)()
|
62
|
+
}];
|
63
|
+
},
|
64
|
+
config: {
|
65
|
+
'teambit.harmony/aspect': {},
|
66
|
+
'teambit.envs/envs': {
|
67
|
+
env: 'teambit.harmony/aspect'
|
68
|
+
}
|
69
|
+
}
|
70
|
+
};
|
71
|
+
exports.starterTemplate = starterTemplate;
|
72
|
+
|
73
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_index","data","require","_starter","_docFile","_gitIgnoreTpl","_workspaceConfigTpl","starterTemplate","name","description","generateFiles","context","relativePath","content","indexFile","isMain","starterFile","docFile","gitIgnoreTemplate","workspaceConfigTemplate","config","env","exports"],"sources":["index.ts"],"sourcesContent":["import { ComponentContext, ComponentTemplate } from '@teambit/generator';\nimport { indexFile } from './files/index';\nimport { starterFile } from './files/starter';\nimport { docFile } from './files/doc-file';\nimport { gitIgnoreTemplate } from './files/git-ignore-tpl';\nimport { workspaceConfigTemplate } from './files/workspace-config-tpl';\n\nexport const starterTemplate: ComponentTemplate = {\n name: 'standalone-starter',\n description:\n 'create your own workspace starter (standalone) - \\nDocs: https://bit.dev/reference/starters/create-starter',\n generateFiles: (context: ComponentContext) => {\n return [\n {\n relativePath: 'index.ts',\n content: indexFile(context),\n isMain: true,\n },\n {\n relativePath: `${context.name}.starter.ts`,\n content: starterFile(context),\n },\n {\n relativePath: `${context.name}.docs.mdx`,\n content: docFile(context),\n },\n {\n relativePath: 'template/files/git-ignore.ts',\n content: gitIgnoreTemplate(),\n },\n\n {\n relativePath: 'template/files/workspace-config.ts',\n content: workspaceConfigTemplate(),\n },\n ];\n },\n config: {\n 'teambit.harmony/aspect': {},\n 'teambit.envs/envs': {\n env: 'teambit.harmony/aspect',\n },\n },\n};\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,oBAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,mBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAMM,eAAkC,GAAG;EAChDC,IAAI,EAAE,oBAAoB;EAC1BC,WAAW,EACT,4GAA4G;EAC9GC,aAAa,EAAGC,OAAyB,IAAK;IAC5C,OAAO,CACL;MACEC,YAAY,EAAE,UAAU;MACxBC,OAAO,EAAE,IAAAC,kBAAS,EAACH,OAAO,CAAC;MAC3BI,MAAM,EAAE;IACV,CAAC,EACD;MACEH,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,aAAY;MAC1CK,OAAO,EAAE,IAAAG,sBAAW,EAACL,OAAO;IAC9B,CAAC,EACD;MACEC,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,WAAU;MACxCK,OAAO,EAAE,IAAAI,kBAAO,EAACN,OAAO;IAC1B,CAAC,EACD;MACEC,YAAY,EAAE,8BAA8B;MAC5CC,OAAO,EAAE,IAAAK,iCAAiB,EAAC;IAC7B,CAAC,EAED;MACEN,YAAY,EAAE,oCAAoC;MAClDC,OAAO,EAAE,IAAAM,6CAAuB,EAAC;IACnC,CAAC,CACF;EACH,CAAC;EACDC,MAAM,EAAE;IACN,wBAAwB,EAAE,CAAC,CAAC;IAC5B,mBAAmB,EAAE;MACnBC,GAAG,EAAE;IACP;EACF;AACF,CAAC;AAACC,OAAA,CAAAf,eAAA,GAAAA,eAAA"}
|
@@ -140,7 +140,11 @@ function _generator() {
|
|
140
140
|
};
|
141
141
|
return data;
|
142
142
|
}
|
143
|
+
// import { ComponentGenerator } from './component-generator';
|
144
|
+
|
143
145
|
class WorkspaceGenerator {
|
146
|
+
// private componentGenerator?: ComponentGenerator;
|
147
|
+
|
144
148
|
constructor(workspaceName, options, template, aspectComponent) {
|
145
149
|
this.workspaceName = workspaceName;
|
146
150
|
this.options = options;
|
@@ -223,7 +227,8 @@ class WorkspaceGenerator {
|
|
223
227
|
defaultScope: this.options.defaultScope,
|
224
228
|
empty: this.options.empty,
|
225
229
|
aspectComponent: this.aspectComponent,
|
226
|
-
template: this.template
|
230
|
+
template: this.template,
|
231
|
+
skipGit: this.options.skipGit
|
227
232
|
};
|
228
233
|
}
|
229
234
|
|
@@ -248,6 +253,17 @@ class WorkspaceGenerator {
|
|
248
253
|
this.git = this.harmony.get(_git().default.id);
|
249
254
|
this.wsConfigFiles = this.harmony.get(_workspaceConfigFiles().default.id);
|
250
255
|
}
|
256
|
+
|
257
|
+
// WIP
|
258
|
+
// private async createComponentsFromRemote() {
|
259
|
+
// if (this.options.empty || !this.template.create) return
|
260
|
+
// const workspaceContext = this.getWorkspaceContext();
|
261
|
+
// const componentsToCreate = this.template.create(workspaceContext)
|
262
|
+
// await pMapSeries(componentsToCreate, async (componentToCreate) => {
|
263
|
+
// await ComponentGenerator.generate(componentToCreate);
|
264
|
+
// });
|
265
|
+
// }
|
266
|
+
|
251
267
|
async forkComponentsFromRemote() {
|
252
268
|
var _this$template, _this$template$import, _this$template2, _this$template2$fork;
|
253
269
|
if (this.options.empty) return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_bit","_execa","_pMapSeries","_ui","_logger","_workspace","_forking","_consumer","_importer","_compiler","_gitExecutable","_gitNotFound","_path","_git","_install","_workspaceConfigFiles","_generator","WorkspaceGenerator","constructor","workspaceName","options","template","aspectComponent","_defineProperty2","default","workspacePath","resolve","generate","fs","existsSync","Error","ensureDir","process","chdir","initGit","init","skipGit","writeWorkspaceFiles","reloadBitInWorkspaceDir","workspace","inInstallContext","setupGitBitmapMergeDriver","forkComponentsFromRemote","importComponentsFromRemote","clearCache","install","undefined","dedupe","import","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","updateExisting","compileComponents","wsConfigFiles","writeConfigFiles","err","_this$logger","logger","error","remove","gitExecutablePath","getGitExecutablePath","params","execa","exitCodeName","GitNotFound","git","setGitMergeDriver","global","buildUI","uiMain","harmony","get","UIAspect","id","createRuntime","getWorkspaceContext","name","defaultScope","empty","workspaceContext","templateFiles","generateFiles","Promise","all","map","templateFile","outputFile","join","relativePath","content","loadBit","WorkspaceAspect","InstallAspect","loggerMain","LoggerAspect","createLogger","GeneratorAspect","importer","ImporterAspect","forking","ForkingAspect","GitAspect","WorkspaceConfigFilesAspect","_this$template","_this$template$import","_this$template2","_this$template2$fork","componentsToFork","importComponents","call","fork","length","componentsToForkRestructured","targetName","path","env","config","sourceId","targetId","forkMultipleFromRemote","scope","refactor","_this$template3","_this$template3$impor","componentsToImport","pMapSeries","componentToImport","ids","installNpmPackages","writeToPath","bitMap","write","compiler","CompilerAspect","compileOnWorkspace","exports"],"sources":["workspace-generator.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { loadBit } from '@teambit/bit';\nimport { Harmony } from '@teambit/harmony';\nimport { Component } from '@teambit/component';\nimport execa from 'execa';\nimport pMapSeries from 'p-map-series';\nimport UIAspect, { UiMain } from '@teambit/ui';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { WorkspaceAspect, Workspace } from '@teambit/workspace';\nimport ForkingAspect, { ForkingMain } from '@teambit/forking';\nimport { init } from '@teambit/legacy/dist/api/consumer';\nimport ImporterAspect, { ImporterMain } from '@teambit/importer';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport getGitExecutablePath from '@teambit/legacy/dist/utils/git/git-executable';\nimport GitNotFound from '@teambit/legacy/dist/utils/git/exceptions/git-not-found';\nimport { resolve, join } from 'path';\nimport { ComponentID } from '@teambit/component-id';\nimport GitAspect, { GitMain } from '@teambit/git';\nimport { InstallAspect, InstallMain } from '@teambit/install';\nimport WorkspaceConfigFilesAspect, { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n\nimport { WorkspaceTemplate, WorkspaceContext } from './workspace-template';\nimport { NewOptions } from './new.cmd';\nimport { GeneratorAspect } from './generator.aspect';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string };\n\nexport class WorkspaceGenerator {\n private workspacePath: string;\n private harmony: Harmony;\n private workspace: Workspace;\n private install: InstallMain;\n private importer: ImporterMain;\n private logger?: Logger;\n private forking: ForkingMain;\n private git: GitMain;\n private wsConfigFiles: WorkspaceConfigFilesMain;\n\n constructor(\n private workspaceName: string,\n private options: NewOptions,\n private template: WorkspaceTemplate,\n private aspectComponent?: Component\n ) {\n this.workspacePath = resolve(this.workspaceName);\n }\n\n async generate(): Promise<string> {\n if (fs.existsSync(this.workspacePath)) {\n throw new Error(`unable to create a workspace at \"${this.workspaceName}\", this path already exist`);\n }\n await fs.ensureDir(this.workspacePath);\n try {\n process.chdir(this.workspacePath);\n await this.initGit();\n await init(this.workspacePath, this.options.skipGit, false, false, false, false, false, false, {});\n await this.writeWorkspaceFiles();\n await this.reloadBitInWorkspaceDir();\n // Setting the workspace to be in install context to prevent errors during the workspace generation\n // the workspace will be in install context until the end of the generation install process\n this.workspace.inInstallContext = true;\n await this.setupGitBitmapMergeDriver();\n await this.forkComponentsFromRemote();\n await this.importComponentsFromRemote();\n await this.workspace.clearCache();\n await this.install.install(undefined, {\n dedupe: true,\n import: false,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n updateExisting: false,\n });\n\n // compile the components again now that we have the dependencies installed\n await this.compileComponents(true);\n await this.wsConfigFiles.writeConfigFiles({});\n } catch (err: any) {\n this.logger?.error(`failed generating a new workspace, will delete the dir ${this.workspacePath}`, err);\n await fs.remove(this.workspacePath);\n throw err;\n }\n\n return this.workspacePath;\n }\n\n private async initGit() {\n if (this.options.skipGit) return;\n const gitExecutablePath = getGitExecutablePath();\n const params = ['init'];\n try {\n await execa(gitExecutablePath, params);\n } catch (err: any) {\n if (err.exitCodeName === 'ENOENT') {\n throw new GitNotFound(gitExecutablePath, err);\n }\n throw err;\n }\n }\n\n private async setupGitBitmapMergeDriver() {\n if (this.options.skipGit) return;\n await this.git.setGitMergeDriver({ global: false });\n }\n\n private async buildUI() {\n const uiMain = this.harmony.get<UiMain>(UIAspect.id);\n await uiMain.createRuntime({});\n }\n\n private getWorkspaceContext(): WorkspaceContext {\n return {\n name: this.workspaceName,\n defaultScope: this.options.defaultScope,\n empty: this.options.empty,\n aspectComponent: this.aspectComponent,\n template: this.template,\n };\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeWorkspaceFiles(): Promise<void> {\n const workspaceContext = this.getWorkspaceContext();\n const templateFiles = await this.template.generateFiles(workspaceContext);\n await Promise.all(\n templateFiles.map(async (templateFile) => {\n await fs.outputFile(join(this.workspacePath, templateFile.relativePath), templateFile.content);\n })\n );\n }\n\n private async reloadBitInWorkspaceDir() {\n this.harmony = await loadBit(this.workspacePath);\n this.workspace = this.harmony.get<Workspace>(WorkspaceAspect.id);\n this.install = this.harmony.get<InstallMain>(InstallAspect.id);\n const loggerMain = this.harmony.get<LoggerMain>(LoggerAspect.id);\n this.logger = loggerMain.createLogger(GeneratorAspect.id);\n this.importer = this.harmony.get<ImporterMain>(ImporterAspect.id);\n this.forking = this.harmony.get<ForkingMain>(ForkingAspect.id);\n this.git = this.harmony.get<GitMain>(GitAspect.id);\n this.wsConfigFiles = this.harmony.get<WorkspaceConfigFilesMain>(WorkspaceConfigFilesAspect.id);\n }\n\n private async forkComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToFork =\n this.template?.importComponents?.(workspaceContext) || this.template?.fork?.(workspaceContext) || [];\n if (!componentsToFork.length) return;\n const componentsToForkRestructured = componentsToFork.map(({ id, targetName, path, env, config }) => ({\n sourceId: id,\n targetId: targetName,\n path,\n env,\n config,\n }));\n await this.forking.forkMultipleFromRemote(componentsToForkRestructured, {\n scope: this.workspace.defaultScope,\n refactor: true,\n install: false,\n });\n }\n\n private async importComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToImport = this.template?.import?.(workspaceContext) || [];\n\n if (!componentsToImport.length) return;\n\n await pMapSeries(componentsToImport, async (componentToImport) => {\n await this.importer.import(\n {\n ids: [componentToImport.id],\n installNpmPackages: false,\n writeToPath: componentToImport.path,\n },\n []\n );\n });\n\n await this.workspace.bitMap.write();\n }\n\n private async compileComponents(clearCache = true) {\n if (clearCache) {\n await this.workspace.clearCache();\n }\n const compiler = this.harmony.get<CompilerMain>(CompilerAspect.id);\n await compiler.compileOnWorkspace();\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,KAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAA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CAACZ;MACjC,CAAC,EACD,EACF,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,IAAI,CAAC5E,SAAS,CAAC4F,MAAM,CAACC,KAAK,CAAC,CAAC;EACrC;EAEA,MAAchF,iBAAiBA,CAACR,UAAU,GAAG,IAAI,EAAE;IACjD,IAAIA,UAAU,EAAE;MACd,MAAM,IAAI,CAACL,SAAS,CAACK,UAAU,CAAC,CAAC;IACnC;IACA,MAAMyF,QAAQ,GAAG,IAAI,CAAC9D,OAAO,CAACC,GAAG,CAAe8D,0BAAc,CAAC5D,EAAE,CAAC;IAClE,MAAM2D,QAAQ,CAACE,kBAAkB,CAAC,CAAC;EACrC;AACF;AAACC,OAAA,CAAAvH,kBAAA,GAAAA,kBAAA"}
|
1
|
+
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_bit","_execa","_pMapSeries","_ui","_logger","_workspace","_forking","_consumer","_importer","_compiler","_gitExecutable","_gitNotFound","_path","_git","_install","_workspaceConfigFiles","_generator","WorkspaceGenerator","constructor","workspaceName","options","template","aspectComponent","_defineProperty2","default","workspacePath","resolve","generate","fs","existsSync","Error","ensureDir","process","chdir","initGit","init","skipGit","writeWorkspaceFiles","reloadBitInWorkspaceDir","workspace","inInstallContext","setupGitBitmapMergeDriver","forkComponentsFromRemote","importComponentsFromRemote","clearCache","install","undefined","dedupe","import","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","updateExisting","compileComponents","wsConfigFiles","writeConfigFiles","err","_this$logger","logger","error","remove","gitExecutablePath","getGitExecutablePath","params","execa","exitCodeName","GitNotFound","git","setGitMergeDriver","global","buildUI","uiMain","harmony","get","UIAspect","id","createRuntime","getWorkspaceContext","name","defaultScope","empty","workspaceContext","templateFiles","generateFiles","Promise","all","map","templateFile","outputFile","join","relativePath","content","loadBit","WorkspaceAspect","InstallAspect","loggerMain","LoggerAspect","createLogger","GeneratorAspect","importer","ImporterAspect","forking","ForkingAspect","GitAspect","WorkspaceConfigFilesAspect","_this$template","_this$template$import","_this$template2","_this$template2$fork","componentsToFork","importComponents","call","fork","length","componentsToForkRestructured","targetName","path","env","config","sourceId","targetId","forkMultipleFromRemote","scope","refactor","_this$template3","_this$template3$impor","componentsToImport","pMapSeries","componentToImport","ids","installNpmPackages","writeToPath","bitMap","write","compiler","CompilerAspect","compileOnWorkspace","exports"],"sources":["workspace-generator.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { loadBit } from '@teambit/bit';\nimport { Harmony } from '@teambit/harmony';\nimport { Component } from '@teambit/component';\nimport execa from 'execa';\nimport pMapSeries from 'p-map-series';\nimport UIAspect, { UiMain } from '@teambit/ui';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { WorkspaceAspect, Workspace } from '@teambit/workspace';\nimport ForkingAspect, { ForkingMain } from '@teambit/forking';\nimport { init } from '@teambit/legacy/dist/api/consumer';\nimport ImporterAspect, { ImporterMain } from '@teambit/importer';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport getGitExecutablePath from '@teambit/legacy/dist/utils/git/git-executable';\nimport GitNotFound from '@teambit/legacy/dist/utils/git/exceptions/git-not-found';\nimport { resolve, join } from 'path';\nimport { ComponentID } from '@teambit/component-id';\nimport GitAspect, { GitMain } from '@teambit/git';\nimport { InstallAspect, InstallMain } from '@teambit/install';\nimport WorkspaceConfigFilesAspect, { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n// import { ComponentGenerator } from './component-generator';\nimport { WorkspaceTemplate, WorkspaceContext } from './workspace-template';\nimport { NewOptions } from './new.cmd';\nimport { GeneratorAspect } from './generator.aspect';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string };\n\nexport class WorkspaceGenerator {\n private workspacePath: string;\n private harmony: Harmony;\n private workspace: Workspace;\n private install: InstallMain;\n private importer: ImporterMain;\n private logger?: Logger;\n private forking: ForkingMain;\n private git: GitMain;\n private wsConfigFiles: WorkspaceConfigFilesMain;\n // private componentGenerator?: ComponentGenerator;\n\n constructor(\n private workspaceName: string,\n private options: NewOptions,\n private template: WorkspaceTemplate,\n private aspectComponent?: Component\n ) {\n this.workspacePath = resolve(this.workspaceName);\n }\n\n async generate(): Promise<string> {\n if (fs.existsSync(this.workspacePath)) {\n throw new Error(`unable to create a workspace at \"${this.workspaceName}\", this path already exist`);\n }\n await fs.ensureDir(this.workspacePath);\n try {\n process.chdir(this.workspacePath);\n await this.initGit();\n await init(this.workspacePath, this.options.skipGit, false, false, false, false, false, false, {});\n await this.writeWorkspaceFiles();\n await this.reloadBitInWorkspaceDir();\n // Setting the workspace to be in install context to prevent errors during the workspace generation\n // the workspace will be in install context until the end of the generation install process\n this.workspace.inInstallContext = true;\n await this.setupGitBitmapMergeDriver();\n await this.forkComponentsFromRemote();\n await this.importComponentsFromRemote();\n await this.workspace.clearCache();\n await this.install.install(undefined, {\n dedupe: true,\n import: false,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n updateExisting: false,\n });\n\n // compile the components again now that we have the dependencies installed\n await this.compileComponents(true);\n await this.wsConfigFiles.writeConfigFiles({});\n } catch (err: any) {\n this.logger?.error(`failed generating a new workspace, will delete the dir ${this.workspacePath}`, err);\n await fs.remove(this.workspacePath);\n throw err;\n }\n\n return this.workspacePath;\n }\n\n private async initGit() {\n if (this.options.skipGit) return;\n const gitExecutablePath = getGitExecutablePath();\n const params = ['init'];\n try {\n await execa(gitExecutablePath, params);\n } catch (err: any) {\n if (err.exitCodeName === 'ENOENT') {\n throw new GitNotFound(gitExecutablePath, err);\n }\n throw err;\n }\n }\n\n private async setupGitBitmapMergeDriver() {\n if (this.options.skipGit) return;\n await this.git.setGitMergeDriver({ global: false });\n }\n\n private async buildUI() {\n const uiMain = this.harmony.get<UiMain>(UIAspect.id);\n await uiMain.createRuntime({});\n }\n\n private getWorkspaceContext(): WorkspaceContext {\n return {\n name: this.workspaceName,\n defaultScope: this.options.defaultScope,\n empty: this.options.empty,\n aspectComponent: this.aspectComponent,\n template: this.template,\n skipGit: this.options.skipGit,\n };\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeWorkspaceFiles(): Promise<void> {\n const workspaceContext = this.getWorkspaceContext();\n const templateFiles = await this.template.generateFiles(workspaceContext);\n await Promise.all(\n templateFiles.map(async (templateFile) => {\n await fs.outputFile(join(this.workspacePath, templateFile.relativePath), templateFile.content);\n })\n );\n }\n\n private async reloadBitInWorkspaceDir() {\n this.harmony = await loadBit(this.workspacePath);\n this.workspace = this.harmony.get<Workspace>(WorkspaceAspect.id);\n this.install = this.harmony.get<InstallMain>(InstallAspect.id);\n const loggerMain = this.harmony.get<LoggerMain>(LoggerAspect.id);\n this.logger = loggerMain.createLogger(GeneratorAspect.id);\n this.importer = this.harmony.get<ImporterMain>(ImporterAspect.id);\n this.forking = this.harmony.get<ForkingMain>(ForkingAspect.id);\n this.git = this.harmony.get<GitMain>(GitAspect.id);\n this.wsConfigFiles = this.harmony.get<WorkspaceConfigFilesMain>(WorkspaceConfigFilesAspect.id);\n }\n\n // WIP\n // private async createComponentsFromRemote() {\n // if (this.options.empty || !this.template.create) return\n // const workspaceContext = this.getWorkspaceContext();\n // const componentsToCreate = this.template.create(workspaceContext)\n // await pMapSeries(componentsToCreate, async (componentToCreate) => {\n // await ComponentGenerator.generate(componentToCreate);\n // });\n // }\n\n private async forkComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToFork =\n this.template?.importComponents?.(workspaceContext) || this.template?.fork?.(workspaceContext) || [];\n if (!componentsToFork.length) return;\n const componentsToForkRestructured = componentsToFork.map(({ id, targetName, path, env, config }) => ({\n sourceId: id,\n targetId: targetName,\n path,\n env,\n config,\n }));\n await this.forking.forkMultipleFromRemote(componentsToForkRestructured, {\n scope: this.workspace.defaultScope,\n refactor: true,\n install: false,\n });\n }\n\n private async importComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToImport = this.template?.import?.(workspaceContext) || [];\n\n if (!componentsToImport.length) return;\n\n await pMapSeries(componentsToImport, async (componentToImport) => {\n await this.importer.import(\n {\n ids: [componentToImport.id],\n installNpmPackages: false,\n writeToPath: componentToImport.path,\n },\n []\n );\n });\n\n await this.workspace.bitMap.write();\n }\n\n private async compileComponents(clearCache = true) {\n if (clearCache) {\n await this.workspace.clearCache();\n }\n const compiler = this.harmony.get<CompilerMain>(CompilerAspect.id);\n await compiler.compileOnWorkspace();\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,KAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,IAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,GAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,WAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,UAAA,YAAAA,CAAA;IA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,0BAA0BA,CAAA,EAAG;IAAA,IAAAgF,eAAA,EAAAC,qBAAA;IACzC,IAAI,IAAI,CAACxG,OAAO,CAAC2D,KAAK,EAAE;IACxB,MAAMC,gBAAgB,GAAG,IAAI,CAACJ,mBAAmB,CAAC,CAAC;IACnD,MAAMiD,kBAAkB,GAAG,EAAAF,eAAA,OAAI,CAACtG,QAAQ,cAAAsG,eAAA,wBAAAC,qBAAA,GAAbD,eAAA,CAAe3E,MAAM,cAAA4E,qBAAA,uBAArBA,qBAAA,CAAAd,IAAA,CAAAa,eAAA,EAAwB3C,gBAAgB,CAAC,KAAI,EAAE;IAE1E,IAAI,CAAC6C,kBAAkB,CAACb,MAAM,EAAE;IAEhC,MAAM,IAAAc,qBAAU,EAACD,kBAAkB,EAAE,MAAOE,iBAAiB,IAAK;MAChE,MAAM,IAAI,CAAC7B,QAAQ,CAAClD,MAAM,CACxB;QACEgF,GAAG,EAAE,CAACD,iBAAiB,CAACrD,EAAE,CAAC;QAC3BuD,kBAAkB,EAAE,KAAK;QACzBC,WAAW,EAAEH,iBAAiB,CAACZ;MACjC,CAAC,EACD,EACF,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,IAAI,CAAC5E,SAAS,CAAC4F,MAAM,CAACC,KAAK,CAAC,CAAC;EACrC;EAEA,MAAchF,iBAAiBA,CAACR,UAAU,GAAG,IAAI,EAAE;IACjD,IAAIA,UAAU,EAAE;MACd,MAAM,IAAI,CAACL,SAAS,CAACK,UAAU,CAAC,CAAC;IACnC;IACA,MAAMyF,QAAQ,GAAG,IAAI,CAAC9D,OAAO,CAACC,GAAG,CAAe8D,0BAAc,CAAC5D,EAAE,CAAC;IAClE,MAAM2D,QAAQ,CAACE,kBAAkB,CAAC,CAAC;EACrC;AACF;AAACC,OAAA,CAAAvH,kBAAA,GAAAA,kBAAA"}
|
@@ -1,49 +1,57 @@
|
|
1
1
|
import type { Component } from '@teambit/component';
|
2
2
|
import { ComponentConfig } from './component-template';
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
relativePath: string;
|
8
|
-
/**
|
9
|
-
* file content
|
10
|
-
*/
|
11
|
-
content: string;
|
12
|
-
}
|
13
|
-
export interface WorkspaceContext {
|
3
|
+
/**
|
4
|
+
* BaseWorkspaceOptions describes the foundational properties for workspaces.
|
5
|
+
*/
|
6
|
+
export interface BaseWorkspaceOptions {
|
14
7
|
/**
|
15
|
-
*
|
16
|
-
*
|
8
|
+
* The name of the workspace as provided by the user (e.g., `react-app`).
|
9
|
+
* This is also used as the directory name for the workspace.
|
17
10
|
*/
|
18
11
|
name: string;
|
19
12
|
/**
|
20
|
-
* default scope
|
21
|
-
*
|
13
|
+
* The default scope provided by the user.
|
14
|
+
* This is set in the workspace.jsonc and is utilized for components within the workspace.
|
22
15
|
*/
|
23
16
|
defaultScope?: string;
|
24
17
|
/**
|
25
|
-
* whether user
|
18
|
+
* Indicates whether the user has opted to avoid creating components (typically with a `--empty` flag).
|
26
19
|
*/
|
27
20
|
empty?: boolean;
|
28
21
|
/**
|
29
|
-
*
|
30
|
-
* useful
|
22
|
+
* Represents the aspect in the context where a remote aspect is imported (often via the `--aspect` flag).
|
23
|
+
* This is useful for obtaining the aspect-id and other related information.
|
31
24
|
*/
|
32
25
|
aspectComponent?: Component;
|
33
26
|
/**
|
34
|
-
* the template
|
27
|
+
* Represents the selected template to initialize or create the workspace.
|
35
28
|
*/
|
36
29
|
template: WorkspaceTemplate;
|
30
|
+
/**
|
31
|
+
* Flag to check if Git repository generation should be skipped.
|
32
|
+
*/
|
33
|
+
skipGit?: boolean;
|
34
|
+
/**
|
35
|
+
* Local path to the workspace template.
|
36
|
+
* Useful during the development of a workspace-template.
|
37
|
+
*/
|
38
|
+
loadFrom?: string;
|
37
39
|
}
|
38
|
-
|
40
|
+
/**
|
41
|
+
* WorkspaceContext represents foundational properties for a workspace context.
|
42
|
+
*/
|
43
|
+
export declare type WorkspaceContext = BaseWorkspaceOptions;
|
44
|
+
export interface WorkspaceFile {
|
39
45
|
/**
|
40
|
-
*
|
46
|
+
* relative path of the file within the workspace.
|
41
47
|
*/
|
42
|
-
|
48
|
+
relativePath: string;
|
43
49
|
/**
|
44
|
-
*
|
50
|
+
* file content
|
45
51
|
*/
|
46
|
-
|
52
|
+
content: string;
|
53
|
+
}
|
54
|
+
export interface ForkComponentInfo extends ImportComponentInfo {
|
47
55
|
/**
|
48
56
|
* a new component name. if not specified, use the original id (without the scope)
|
49
57
|
*/
|
@@ -73,11 +81,11 @@ export interface ImportComponentInfo {
|
|
73
81
|
/**
|
74
82
|
* path where to write the component
|
75
83
|
*/
|
76
|
-
path
|
84
|
+
path?: string;
|
77
85
|
}
|
78
86
|
export interface WorkspaceTemplate {
|
79
87
|
/**
|
80
|
-
* name of the workspace
|
88
|
+
* name of the workspace starter. for example: `react-workspace`.
|
81
89
|
*/
|
82
90
|
name: string;
|
83
91
|
/**
|
@@ -86,15 +94,15 @@ export interface WorkspaceTemplate {
|
|
86
94
|
*/
|
87
95
|
appName?: string;
|
88
96
|
/**
|
89
|
-
* short description of the
|
97
|
+
* short description of the starter. shown in the `bit starter` command when outside of bit-workspace.
|
90
98
|
*/
|
91
99
|
description?: string;
|
92
100
|
/**
|
93
|
-
* hide this
|
101
|
+
* hide this starter so that it is not listed with `bit starter`
|
94
102
|
*/
|
95
103
|
hidden?: boolean;
|
96
104
|
/**
|
97
|
-
*
|
105
|
+
* starter function for generating the template files,
|
98
106
|
*/
|
99
107
|
generateFiles(context: WorkspaceContext): Promise<WorkspaceFile[]>;
|
100
108
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["workspace-template.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { ComponentConfig } from './component-template';\n\
|
1
|
+
{"version":3,"names":[],"sources":["workspace-template.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { ComponentConfig } from './component-template';\n\n/**\n * BaseWorkspaceOptions describes the foundational properties for workspaces.\n */\nexport interface BaseWorkspaceOptions {\n /**\n * The name of the workspace as provided by the user (e.g., `react-app`).\n * This is also used as the directory name for the workspace.\n */\n name: string;\n\n /**\n * The default scope provided by the user.\n * This is set in the workspace.jsonc and is utilized for components within the workspace.\n */\n defaultScope?: string;\n\n /**\n * Indicates whether the user has opted to avoid creating components (typically with a `--empty` flag).\n */\n empty?: boolean;\n\n /**\n * Represents the aspect in the context where a remote aspect is imported (often via the `--aspect` flag).\n * This is useful for obtaining the aspect-id and other related information.\n */\n aspectComponent?: Component;\n\n /**\n * Represents the selected template to initialize or create the workspace.\n */\n template: WorkspaceTemplate;\n\n /**\n * Flag to check if Git repository generation should be skipped.\n */\n skipGit?: boolean;\n\n /**\n * Local path to the workspace template.\n * Useful during the development of a workspace-template.\n */\n loadFrom?: string;\n}\n\n/**\n * WorkspaceContext represents foundational properties for a workspace context.\n */\nexport type WorkspaceContext = BaseWorkspaceOptions;\n\nexport interface WorkspaceFile {\n /**\n * relative path of the file within the workspace.\n */\n relativePath: string;\n\n /**\n * file content\n */\n content: string;\n}\n\nexport interface ForkComponentInfo extends ImportComponentInfo {\n /**\n * a new component name. if not specified, use the original id (without the scope)\n */\n targetName?: string;\n /**\n * env to use for the component.\n */\n env?: string;\n\n /**\n * component config. gets saved in the .bitmap file and 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;\n}\n\n/**\n * @deprecated use ForkComponentInfo instead.\n */\nexport type ComponentToImport = ForkComponentInfo;\n\nexport interface ImportComponentInfo {\n /**\n * full component id\n */\n id: string;\n\n /**\n * path where to write the component\n */\n path?: string;\n}\n\nexport interface WorkspaceTemplate {\n /**\n * name of the workspace starter. for example: `react-workspace`.\n */\n name: string;\n\n /**\n * name of an app created in the workspace. for example: `my-app`.\n * This will be used to instruct the user to run `bit run <appName>` in the new workspace.\n */\n appName?: string;\n\n /**\n * short description of the starter. shown in the `bit starter` command when outside of bit-workspace.\n */\n description?: string;\n\n /**\n * hide this starter so that it is not listed with `bit starter`\n */\n hidden?: boolean;\n\n /**\n * starter function for generating the template files,\n */\n generateFiles(context: WorkspaceContext): Promise<WorkspaceFile[]>;\n\n /**\n * @deprecated use `fork()` or `import()` instead\n * this is working similarly to `fork()`\n */\n importComponents?: (context: WorkspaceContext) => ForkComponentInfo[];\n\n /**\n * import components into the new workspace, don't change their source code.\n */\n import?: (context: WorkspaceContext) => ImportComponentInfo[];\n\n /**\n * populate existing components into the new workspace and add them as new components.\n * change their source code and update the dependency names according to the new component names.\n */\n fork?: (context: WorkspaceContext) => ForkComponentInfo[];\n}\n"],"mappings":""}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/generator",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.1145",
|
4
4
|
"homepage": "https://bit.cloud/teambit/generator/generator",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.generator",
|
8
8
|
"name": "generator",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.1145"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"camelcase": "6.2.0",
|
@@ -22,25 +22,25 @@
|
|
22
22
|
"@teambit/component-id": "0.0.427",
|
23
23
|
"@teambit/harmony": "0.4.6",
|
24
24
|
"@teambit/bit-error": "0.0.402",
|
25
|
-
"@teambit/envs": "0.0.
|
26
|
-
"@teambit/logger": "0.0.
|
27
|
-
"@teambit/new-component-helper": "0.0.
|
28
|
-
"@teambit/tracker": "0.0.
|
29
|
-
"@teambit/workspace-config-files": "0.0.
|
30
|
-
"@teambit/workspace.modules.node-modules-linker": "0.0.
|
31
|
-
"@teambit/workspace": "0.0.
|
32
|
-
"@teambit/
|
33
|
-
"@teambit/
|
34
|
-
"@teambit/
|
35
|
-
"@teambit/
|
36
|
-
"@teambit/
|
37
|
-
"@teambit/
|
38
|
-
"@teambit/
|
39
|
-
"@teambit/
|
40
|
-
"@teambit/
|
41
|
-
"@teambit/
|
42
|
-
"@teambit/
|
43
|
-
"@teambit/
|
25
|
+
"@teambit/envs": "0.0.1145",
|
26
|
+
"@teambit/logger": "0.0.859",
|
27
|
+
"@teambit/new-component-helper": "0.0.549",
|
28
|
+
"@teambit/tracker": "0.0.176",
|
29
|
+
"@teambit/workspace-config-files": "0.0.125",
|
30
|
+
"@teambit/workspace.modules.node-modules-linker": "0.0.108",
|
31
|
+
"@teambit/workspace": "0.0.1145",
|
32
|
+
"@teambit/component": "0.0.1145",
|
33
|
+
"@teambit/cli": "0.0.766",
|
34
|
+
"@teambit/graphql": "0.0.1145",
|
35
|
+
"@teambit/aspect-loader": "0.0.1145",
|
36
|
+
"@teambit/bit": "0.2.38",
|
37
|
+
"@teambit/git": "0.0.50",
|
38
|
+
"@teambit/compiler": "0.0.1145",
|
39
|
+
"@teambit/forking": "0.0.549",
|
40
|
+
"@teambit/importer": "0.0.574",
|
41
|
+
"@teambit/install": "0.0.229",
|
42
|
+
"@teambit/ui": "0.0.1145",
|
43
|
+
"@teambit/config": "0.0.781"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@types/fs-extra": "9.0.7",
|
@@ -54,7 +54,7 @@
|
|
54
54
|
"@teambit/generator.aspect-docs.generator": "0.0.160"
|
55
55
|
},
|
56
56
|
"peerDependencies": {
|
57
|
-
"@teambit/legacy": "1.0.
|
57
|
+
"@teambit/legacy": "1.0.551",
|
58
58
|
"react": "^16.8.0 || ^17.0.0",
|
59
59
|
"react-dom": "^16.8.0 || ^17.0.0"
|
60
60
|
},
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { WorkspaceContext, Starter } from '../..';
|
2
|
+
import { workspaceConfig } from './template/files/workspace-config';
|
3
|
+
import { gitIgnore } from './template/files/git-ignore';
|
4
|
+
|
5
|
+
export const BasicWorkspaceStarter: Starter = {
|
6
|
+
name: 'basic',
|
7
|
+
description: 'a basic workspace',
|
8
|
+
generateFiles: async (context: WorkspaceContext) => {
|
9
|
+
return [
|
10
|
+
{
|
11
|
+
relativePath: 'workspace.jsonc',
|
12
|
+
content: await workspaceConfig(context),
|
13
|
+
},
|
14
|
+
{
|
15
|
+
relativePath: '.gitignore',
|
16
|
+
content: gitIgnore(),
|
17
|
+
},
|
18
|
+
];
|
19
|
+
},
|
20
|
+
};
|
21
|
+
|
22
|
+
export default BasicWorkspaceStarter;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { BasicWorkspaceStarter } from './basic.starter';
|
@@ -0,0 +1,110 @@
|
|
1
|
+
export function gitIgnore() {
|
2
|
+
return `# Bit
|
3
|
+
.bit
|
4
|
+
public
|
5
|
+
|
6
|
+
# Logs
|
7
|
+
logs
|
8
|
+
*.log
|
9
|
+
npm-debug.log*
|
10
|
+
yarn-debug.log*
|
11
|
+
yarn-error.log*
|
12
|
+
lerna-debug.log*
|
13
|
+
|
14
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
15
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
16
|
+
|
17
|
+
# Runtime data
|
18
|
+
pids
|
19
|
+
*.pid
|
20
|
+
*.seed
|
21
|
+
*.pid.lock
|
22
|
+
|
23
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
24
|
+
lib-cov
|
25
|
+
|
26
|
+
# Coverage directory used by tools like istanbul
|
27
|
+
coverage
|
28
|
+
*.lcov
|
29
|
+
|
30
|
+
# nyc test coverage
|
31
|
+
.nyc_output
|
32
|
+
|
33
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
34
|
+
.grunt
|
35
|
+
|
36
|
+
# Bower dependency directory (https://bower.io/)
|
37
|
+
bower_components
|
38
|
+
|
39
|
+
# node-waf configuration
|
40
|
+
.lock-wscript
|
41
|
+
|
42
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
43
|
+
build/Release
|
44
|
+
|
45
|
+
# Dependency directories
|
46
|
+
node_modules/
|
47
|
+
jspm_packages/
|
48
|
+
|
49
|
+
# TypeScript v1 declaration files
|
50
|
+
typings/
|
51
|
+
|
52
|
+
# TypeScript cache
|
53
|
+
*.tsbuildinfo
|
54
|
+
|
55
|
+
# Optional npm cache directory
|
56
|
+
.npm
|
57
|
+
|
58
|
+
# Optional eslint cache
|
59
|
+
.eslintcache
|
60
|
+
|
61
|
+
# Microbundle cache
|
62
|
+
.rpt2_cache/
|
63
|
+
.rts2_cache_cjs/
|
64
|
+
.rts2_cache_es/
|
65
|
+
.rts2_cache_umd/
|
66
|
+
|
67
|
+
# Optional REPL history
|
68
|
+
.node_repl_history
|
69
|
+
|
70
|
+
# Output of 'npm pack'
|
71
|
+
*.tgz
|
72
|
+
|
73
|
+
# Yarn Integrity file
|
74
|
+
.yarn-integrity
|
75
|
+
|
76
|
+
# dotenv environment variables file
|
77
|
+
.env
|
78
|
+
.env.test
|
79
|
+
|
80
|
+
# parcel-bundler cache (https://parceljs.org/)
|
81
|
+
.cache
|
82
|
+
|
83
|
+
# Next.js build output
|
84
|
+
.next
|
85
|
+
|
86
|
+
# Nuxt.js build / generate output
|
87
|
+
.nuxt
|
88
|
+
dist
|
89
|
+
|
90
|
+
# Gatsby files
|
91
|
+
.cache/
|
92
|
+
|
93
|
+
# vuepress build output
|
94
|
+
.vuepress/dist
|
95
|
+
|
96
|
+
# Serverless directories
|
97
|
+
.serverless/
|
98
|
+
|
99
|
+
# FuseBox cache
|
100
|
+
.fusebox/
|
101
|
+
|
102
|
+
# DynamoDB Local files
|
103
|
+
.dynamodb/
|
104
|
+
|
105
|
+
# TernJS port file
|
106
|
+
.tern-port
|
107
|
+
|
108
|
+
.history
|
109
|
+
`;
|
110
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';
|
2
|
+
import { WorkspaceContext } from '../../../..';
|
3
|
+
|
4
|
+
export async function workspaceConfig({ name, defaultScope }: WorkspaceContext) {
|
5
|
+
const configParsed = await getWorkspaceConfigTemplateParsed();
|
6
|
+
const packageManagerDefaultConfig = configParsed['teambit.dependencies/dependency-resolver'];
|
7
|
+
configParsed['teambit.workspace/workspace'].name = name;
|
8
|
+
configParsed['teambit.workspace/workspace'].defaultScope = defaultScope || 'org.scope';
|
9
|
+
configParsed['teambit.dependencies/dependency-resolver'] = {
|
10
|
+
...packageManagerDefaultConfig,
|
11
|
+
policy: {
|
12
|
+
dependencies: {
|
13
|
+
'@teambit/node.node': 'latest',
|
14
|
+
'@types/node': '16.18.44',
|
15
|
+
'@types/jest': '29.5.4',
|
16
|
+
},
|
17
|
+
},
|
18
|
+
};
|
19
|
+
|
20
|
+
delete configParsed['teambit.workspace/variants'];
|
21
|
+
|
22
|
+
configParsed['teambit.generator/generator'] = {
|
23
|
+
envs: [
|
24
|
+
'teambit.node/node',
|
25
|
+
// "teambit.angular/angular",
|
26
|
+
// "teambit.vue/vue",
|
27
|
+
// "teambit.react/react-env",
|
28
|
+
// "teambit.html/html-env"
|
29
|
+
],
|
30
|
+
};
|
31
|
+
|
32
|
+
return stringifyWorkspaceConfig(configParsed);
|
33
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
export const generateComponentFileContent = () => {
|
2
|
+
return `import { ComponentContext } from '@teambit/generator';
|
3
|
+
|
4
|
+
export const componentFile = (context: ComponentContext) => {
|
5
|
+
const { name, namePascalCase: Name } = context;
|
6
|
+
|
7
|
+
return {
|
8
|
+
relativePath: \`\${name}.tsx\`,
|
9
|
+
content: \`import type { ReactNode } from 'react';
|
10
|
+
|
11
|
+
export type \${Name}Props = {
|
12
|
+
children?: ReactNode;
|
13
|
+
};
|
14
|
+
|
15
|
+
export function \${Name}({ children }: \${Name}Props) {
|
16
|
+
return (
|
17
|
+
<div>
|
18
|
+
{children}
|
19
|
+
</div>
|
20
|
+
);
|
21
|
+
}
|
22
|
+
\`,
|
23
|
+
};
|
24
|
+
};
|
25
|
+
`;
|
26
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export const generateCompositionFileContent = () => {
|
2
|
+
return `import { ComponentContext } from '@teambit/generator';
|
3
|
+
|
4
|
+
export const compositionFile = (context: ComponentContext) => {
|
5
|
+
const { name, namePascalCase: Name } = context;
|
6
|
+
|
7
|
+
return {
|
8
|
+
relativePath: \`\${name}.composition.tsx\`,
|
9
|
+
content: \`import { \${Name} } from './\${name}';
|
10
|
+
|
11
|
+
export const Basic\${Name} = () => {
|
12
|
+
return (
|
13
|
+
<\${Name}>hello world!</\${Name}>
|
14
|
+
);
|
15
|
+
}
|
16
|
+
\`,
|
17
|
+
};
|
18
|
+
};
|
19
|
+
`;
|
20
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export const generateIndexFileContent = () => {
|
2
|
+
return `import { ComponentContext } from '@teambit/generator';
|
3
|
+
|
4
|
+
export const indexFile = (context: ComponentContext) => {
|
5
|
+
const { name, namePascalCase: Name } = context;
|
6
|
+
|
7
|
+
return {
|
8
|
+
relativePath: 'index.ts',
|
9
|
+
content: \`export { \${Name} } from './\${name}';
|
10
|
+
export type { \${Name}Props } from './\${name}';
|
11
|
+
\`,
|
12
|
+
};
|
13
|
+
};
|
14
|
+
`;
|
15
|
+
};
|