@teambit/generator 0.0.881 → 0.0.883
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-generator.js +1 -61
- package/dist/component-generator.js.map +1 -1
- package/dist/create.cmd.js +0 -13
- package/dist/create.cmd.js.map +1 -1
- package/dist/generator.aspect.js +0 -5
- package/dist/generator.aspect.js.map +1 -1
- package/dist/generator.composition.js +0 -6
- package/dist/generator.composition.js.map +1 -1
- package/dist/generator.graphql.js +4 -13
- package/dist/generator.graphql.js.map +1 -1
- package/dist/generator.main.runtime.js +8 -119
- package/dist/generator.main.runtime.js.map +1 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +1 -1
- package/dist/new.cmd.js +0 -18
- package/dist/new.cmd.js.map +1 -1
- package/dist/starter.plugin.js +0 -11
- package/dist/starter.plugin.js.map +1 -1
- package/dist/templates/component-generator/files/aspect-file.js +0 -1
- package/dist/templates/component-generator/files/aspect-file.js.map +1 -1
- package/dist/templates/component-generator/files/docs-file.js +0 -1
- package/dist/templates/component-generator/files/docs-file.js.map +1 -1
- package/dist/templates/component-generator/files/index.js +0 -1
- package/dist/templates/component-generator/files/index.js.map +1 -1
- package/dist/templates/component-generator/files/main-runtime.js +0 -1
- package/dist/templates/component-generator/files/main-runtime.js.map +1 -1
- package/dist/templates/component-generator/index.js +0 -13
- package/dist/templates/component-generator/index.js.map +1 -1
- package/dist/templates/starter/files/docs-file.js +0 -1
- package/dist/templates/starter/files/docs-file.js.map +1 -1
- package/dist/templates/starter/files/git-ignore-tpl.js +0 -1
- package/dist/templates/starter/files/git-ignore-tpl.js.map +1 -1
- package/dist/templates/starter/files/index.js +0 -1
- package/dist/templates/starter/files/index.js.map +1 -1
- package/dist/templates/starter/files/readme-tpl.js +0 -1
- package/dist/templates/starter/files/readme-tpl.js.map +1 -1
- package/dist/templates/starter/files/starter.js +0 -1
- package/dist/templates/starter/files/starter.js.map +1 -1
- package/dist/templates/starter/files/workspace-config-tpl.js +0 -1
- package/dist/templates/starter/files/workspace-config-tpl.js.map +1 -1
- package/dist/templates/starter/index.js +0 -19
- package/dist/templates/starter/index.js.map +1 -1
- package/dist/templates/workspace-generator/index.js +0 -11
- package/dist/templates/workspace-generator/index.js.map +1 -1
- package/dist/templates.cmd.js +4 -22
- package/dist/templates.cmd.js.map +1 -1
- package/dist/workspace-generator.js +3 -74
- package/dist/workspace-generator.js.map +1 -1
- package/package-tar/teambit-generator-0.0.883.tgz +0 -0
- package/package.json +14 -14
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-generator-0.0.881.tgz +0 -0
|
@@ -1,106 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.ComponentGenerator = void 0;
|
|
13
|
-
|
|
14
10
|
function _vinyl() {
|
|
15
11
|
const data = _interopRequireDefault(require("vinyl"));
|
|
16
|
-
|
|
17
12
|
_vinyl = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _fsExtra() {
|
|
25
18
|
const data = _interopRequireDefault(require("fs-extra"));
|
|
26
|
-
|
|
27
19
|
_fsExtra = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _pMapSeries() {
|
|
35
25
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
36
|
-
|
|
37
26
|
_pMapSeries = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _path() {
|
|
45
32
|
const data = _interopRequireDefault(require("path"));
|
|
46
|
-
|
|
47
33
|
_path = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
function _envs() {
|
|
55
39
|
const data = _interopRequireDefault(require("@teambit/envs"));
|
|
56
|
-
|
|
57
40
|
_envs = function () {
|
|
58
41
|
return data;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
return data;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
45
|
function _camelcase() {
|
|
65
46
|
const data = _interopRequireDefault(require("camelcase"));
|
|
66
|
-
|
|
67
47
|
_camelcase = function () {
|
|
68
48
|
return data;
|
|
69
49
|
};
|
|
70
|
-
|
|
71
50
|
return data;
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
function _bitError() {
|
|
75
53
|
const data = require("@teambit/bit-error");
|
|
76
|
-
|
|
77
54
|
_bitError = function () {
|
|
78
55
|
return data;
|
|
79
56
|
};
|
|
80
|
-
|
|
81
57
|
return data;
|
|
82
58
|
}
|
|
83
|
-
|
|
84
59
|
function _sources() {
|
|
85
60
|
const data = require("@teambit/legacy/dist/consumer/component/sources");
|
|
86
|
-
|
|
87
61
|
_sources = function () {
|
|
88
62
|
return data;
|
|
89
63
|
};
|
|
90
|
-
|
|
91
64
|
return data;
|
|
92
65
|
}
|
|
93
|
-
|
|
94
66
|
function _dataToPersist() {
|
|
95
67
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/sources/data-to-persist"));
|
|
96
|
-
|
|
97
68
|
_dataToPersist = function () {
|
|
98
69
|
return data;
|
|
99
70
|
};
|
|
100
|
-
|
|
101
71
|
return data;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
73
|
class ComponentGenerator {
|
|
105
74
|
constructor(workspace, componentIds, options, template, envs, newComponentHelper, aspectId) {
|
|
106
75
|
this.workspace = workspace;
|
|
@@ -111,21 +80,17 @@ class ComponentGenerator {
|
|
|
111
80
|
this.newComponentHelper = newComponentHelper;
|
|
112
81
|
this.aspectId = aspectId;
|
|
113
82
|
}
|
|
114
|
-
|
|
115
83
|
async generate() {
|
|
116
84
|
const dirsToDeleteIfFailed = [];
|
|
117
85
|
const generateResults = await (0, _pMapSeries().default)(this.componentIds, async componentId => {
|
|
118
86
|
try {
|
|
119
87
|
const componentPath = this.newComponentHelper.getNewComponentPath(componentId, this.options.path);
|
|
120
|
-
|
|
121
88
|
if (_fsExtra().default.existsSync(_path().default.join(this.workspace.path, componentPath))) {
|
|
122
89
|
throw new (_bitError().BitError)(`unable to create a component at "${componentPath}", this path already exist`);
|
|
123
90
|
}
|
|
124
|
-
|
|
125
91
|
if (await this.workspace.hasName(componentId.fullName)) {
|
|
126
92
|
throw new (_bitError().BitError)(`unable to create a component "${componentId.fullName}", a component with the same name already exist`);
|
|
127
93
|
}
|
|
128
|
-
|
|
129
94
|
dirsToDeleteIfFailed.push(componentPath);
|
|
130
95
|
return await this.generateOneComponent(componentId, componentPath);
|
|
131
96
|
} catch (err) {
|
|
@@ -136,11 +101,9 @@ class ComponentGenerator {
|
|
|
136
101
|
await this.workspace.bitMap.write();
|
|
137
102
|
return generateResults;
|
|
138
103
|
}
|
|
139
|
-
|
|
140
104
|
async deleteGeneratedComponents(dirs) {
|
|
141
105
|
await Promise.all(dirs.map(async dir => {
|
|
142
106
|
const absoluteDir = _path().default.join(this.workspace.path, dir);
|
|
143
|
-
|
|
144
107
|
try {
|
|
145
108
|
await _fsExtra().default.remove(absoluteDir);
|
|
146
109
|
} catch (err) {
|
|
@@ -151,10 +114,8 @@ class ComponentGenerator {
|
|
|
151
114
|
}
|
|
152
115
|
}));
|
|
153
116
|
}
|
|
154
|
-
|
|
155
117
|
async generateOneComponent(componentId, componentPath) {
|
|
156
118
|
var _config, _config$EnvsAspect$id;
|
|
157
|
-
|
|
158
119
|
const name = componentId.name;
|
|
159
120
|
const namePascalCase = (0, _camelcase().default)(name, {
|
|
160
121
|
pascalCase: true
|
|
@@ -178,15 +139,12 @@ class ComponentGenerator {
|
|
|
178
139
|
const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);
|
|
179
140
|
const envBeforeConfigChanges = this.envs.getEnv(component);
|
|
180
141
|
let config = this.template.config;
|
|
181
|
-
|
|
182
142
|
if (config && typeof config === 'function') {
|
|
183
143
|
config = config({
|
|
184
144
|
aspectId: this.aspectId
|
|
185
145
|
});
|
|
186
146
|
}
|
|
187
|
-
|
|
188
147
|
const templateEnv = (_config = config) === null || _config === void 0 ? void 0 : (_config$EnvsAspect$id = _config[_envs().default.id]) === null || _config$EnvsAspect$id === void 0 ? void 0 : _config$EnvsAspect$id.env;
|
|
189
|
-
|
|
190
148
|
if (config && templateEnv && hasEnvConfiguredOriginally) {
|
|
191
149
|
// remove the env we got from the template.
|
|
192
150
|
delete config[templateEnv];
|
|
@@ -194,37 +152,29 @@ class ComponentGenerator {
|
|
|
194
152
|
if (Object.keys(config[_envs().default.id]).length === 0) delete config[_envs().default.id];
|
|
195
153
|
if (Object.keys(config).length === 0) config = undefined;
|
|
196
154
|
}
|
|
197
|
-
|
|
198
155
|
const configWithEnv = await this.addEnvIfProvidedByFlag(config);
|
|
199
156
|
if (configWithEnv) this.workspace.bitMap.setEntireConfig(component.id, configWithEnv);
|
|
200
|
-
|
|
201
157
|
const getEnvData = () => {
|
|
202
158
|
var _config2, _config2$EnvsAspect$i;
|
|
203
|
-
|
|
204
159
|
const envFromFlag = this.options.env; // env entered by the user when running `bit create --env`
|
|
205
|
-
|
|
206
160
|
const envFromTemplate = (_config2 = config) === null || _config2 === void 0 ? void 0 : (_config2$EnvsAspect$i = _config2[_envs().default.id]) === null || _config2$EnvsAspect$i === void 0 ? void 0 : _config2$EnvsAspect$i.env;
|
|
207
|
-
|
|
208
161
|
if (envFromFlag) {
|
|
209
162
|
return {
|
|
210
163
|
envId: envFromFlag,
|
|
211
164
|
setBy: '--env flag'
|
|
212
165
|
};
|
|
213
166
|
}
|
|
214
|
-
|
|
215
167
|
if (envFromTemplate) {
|
|
216
168
|
return {
|
|
217
169
|
envId: envFromTemplate,
|
|
218
170
|
setBy: 'template'
|
|
219
171
|
};
|
|
220
172
|
}
|
|
221
|
-
|
|
222
173
|
return {
|
|
223
174
|
envId: envBeforeConfigChanges.id,
|
|
224
175
|
setBy: hasEnvConfiguredOriginally ? 'workspace variants' : '<default>'
|
|
225
176
|
};
|
|
226
177
|
};
|
|
227
|
-
|
|
228
178
|
const {
|
|
229
179
|
envId,
|
|
230
180
|
setBy
|
|
@@ -237,25 +187,18 @@ class ComponentGenerator {
|
|
|
237
187
|
envSetBy: setBy
|
|
238
188
|
};
|
|
239
189
|
}
|
|
240
|
-
|
|
241
190
|
async addEnvIfProvidedByFlag(config) {
|
|
242
191
|
var _config3, _config3$EnvsAspect$i;
|
|
243
|
-
|
|
244
192
|
const userEnv = this.options.env; // env entered by the user when running `bit create --env`
|
|
245
|
-
|
|
246
193
|
const templateEnv = (_config3 = config) === null || _config3 === void 0 ? void 0 : (_config3$EnvsAspect$i = _config3[_envs().default.id]) === null || _config3$EnvsAspect$i === void 0 ? void 0 : _config3$EnvsAspect$i.env;
|
|
247
|
-
|
|
248
194
|
if (!userEnv || userEnv === templateEnv) {
|
|
249
195
|
return config;
|
|
250
196
|
}
|
|
251
|
-
|
|
252
197
|
config = config || {};
|
|
253
|
-
|
|
254
198
|
if (templateEnv) {
|
|
255
199
|
// the component template has an env and the user wants a different env.
|
|
256
200
|
delete config[templateEnv];
|
|
257
201
|
}
|
|
258
|
-
|
|
259
202
|
const userEnvId = await this.workspace.resolveComponentId(userEnv);
|
|
260
203
|
const userEnvIdWithPotentialVersion = await this.workspace.resolveEnvIdWithPotentialVersionForConfig(userEnvId);
|
|
261
204
|
config[userEnvIdWithPotentialVersion] = {};
|
|
@@ -263,11 +206,10 @@ class ComponentGenerator {
|
|
|
263
206
|
config[_envs().default.id].env = userEnvId.toStringWithoutVersion();
|
|
264
207
|
return config;
|
|
265
208
|
}
|
|
209
|
+
|
|
266
210
|
/**
|
|
267
211
|
* writes the generated template files to the default directory set in the workspace config
|
|
268
212
|
*/
|
|
269
|
-
|
|
270
|
-
|
|
271
213
|
async writeComponentFiles(componentPath, templateFiles) {
|
|
272
214
|
const dataToPersist = new (_dataToPersist().default)();
|
|
273
215
|
const vinylFiles = templateFiles.map(templateFile => {
|
|
@@ -284,9 +226,7 @@ class ComponentGenerator {
|
|
|
284
226
|
await dataToPersist.persistAllToFS();
|
|
285
227
|
return results;
|
|
286
228
|
}
|
|
287
|
-
|
|
288
229
|
}
|
|
289
|
-
|
|
290
230
|
exports.ComponentGenerator = ComponentGenerator;
|
|
291
231
|
|
|
292
232
|
//# sourceMappingURL=component-generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentGenerator","constructor","workspace","componentIds","options","template","envs","newComponentHelper","aspectId","generate","dirsToDeleteIfFailed","generateResults","pMapSeries","componentId","componentPath","getNewComponentPath","path","fs","existsSync","join","BitError","hasName","fullName","push","generateOneComponent","err","deleteGeneratedComponents","bitMap","write","dirs","Promise","all","map","dir","absoluteDir","remove","code","name","namePascalCase","camelcase","pascalCase","nameCamelCase","files","generateFiles","mainFile","find","file","isMain","writeComponentFiles","addResults","track","rootDir","relativePath","componentName","defaultScope","scope","component","get","hasEnvConfiguredOriginally","hasEnvConfigured","envBeforeConfigChanges","getEnv","config","templateEnv","EnvsAspect","id","env","Object","keys","length","undefined","configWithEnv","addEnvIfProvidedByFlag","setEntireConfig","getEnvData","envFromFlag","envFromTemplate","envId","setBy","envSetBy","userEnv","userEnvId","resolveComponentId","userEnvIdWithPotentialVersion","resolveEnvIdWithPotentialVersionForConfig","toStringWithoutVersion","templateFiles","dataToPersist","DataToPersist","vinylFiles","templateFile","templateFileVinyl","Vinyl","base","contents","Buffer","from","content","AbstractVinyl","fromVinyl","results","v","addManyFiles","addBasePath","persistAllToFS"],"sources":["component-generator.ts"],"sourcesContent":["import Vinyl from 'vinyl';\nimport fs from 'fs-extra';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport camelcase from 'camelcase';\nimport { BitError } from '@teambit/bit-error';\nimport { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentTemplate, ComponentFile, ComponentConfig } from './component-template';\nimport { CreateOptions } from './create.cmd';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string; envSetBy: string };\n\nexport class ComponentGenerator {\n constructor(\n private workspace: Workspace,\n private componentIds: ComponentID[],\n private options: CreateOptions,\n private template: ComponentTemplate,\n private envs: EnvsMain,\n private newComponentHelper: NewComponentHelperMain,\n private aspectId: string\n ) {}\n\n async generate(): Promise<GenerateResult[]> {\n const dirsToDeleteIfFailed: string[] = [];\n const generateResults = await pMapSeries(this.componentIds, async (componentId) => {\n try {\n const componentPath = this.newComponentHelper.getNewComponentPath(componentId, this.options.path);\n if (fs.existsSync(path.join(this.workspace.path, componentPath))) {\n throw new BitError(`unable to create a component at \"${componentPath}\", this path already exist`);\n }\n if (await this.workspace.hasName(componentId.fullName)) {\n throw new BitError(\n `unable to create a component \"${componentId.fullName}\", a component with the same name already exist`\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();\n\n return generateResults;\n }\n\n private async deleteGeneratedComponents(dirs: string[]) {\n await Promise.all(\n dirs.map(async (dir) => {\n const absoluteDir = path.join(this.workspace.path, dir);\n try {\n await fs.remove(absoluteDir);\n } catch (err: any) {\n if (err.code !== 'ENOENT') {\n // if not exist, it's fine\n throw err;\n }\n }\n })\n );\n }\n\n private async generateOneComponent(componentId: ComponentID, componentPath: string): Promise<GenerateResult> {\n const name = componentId.name;\n const namePascalCase = camelcase(name, { pascalCase: true });\n const nameCamelCase = camelcase(name);\n const files = this.template.generateFiles({ name, namePascalCase, nameCamelCase, componentId });\n const mainFile = files.find((file) => file.isMain);\n await this.writeComponentFiles(componentPath, files);\n const addResults = await this.workspace.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope,\n });\n const component = await this.workspace.get(componentId);\n const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);\n const envBeforeConfigChanges = this.envs.getEnv(component);\n\n let config = this.template.config;\n if (config && typeof config === 'function') {\n config = config({ aspectId: this.aspectId });\n }\n\n const templateEnv = config?.[EnvsAspect.id]?.env;\n\n if (config && templateEnv && hasEnvConfiguredOriginally) {\n // remove the env we got from the template.\n delete config[templateEnv];\n delete config[EnvsAspect.id].env;\n if (Object.keys(config[EnvsAspect.id]).length === 0) delete config[EnvsAspect.id];\n if (Object.keys(config).length === 0) config = undefined;\n }\n\n const configWithEnv = await this.addEnvIfProvidedByFlag(config);\n if (configWithEnv) this.workspace.bitMap.setEntireConfig(component.id, configWithEnv);\n\n const getEnvData = () => {\n const envFromFlag = this.options.env; // env entered by the user when running `bit create --env`\n const envFromTemplate = config?.[EnvsAspect.id]?.env;\n if (envFromFlag) {\n return {\n envId: envFromFlag,\n setBy: '--env flag',\n };\n }\n if (envFromTemplate) {\n return {\n envId: envFromTemplate,\n setBy: 'template',\n };\n }\n return {\n envId: envBeforeConfigChanges.id,\n setBy: hasEnvConfiguredOriginally ? 'workspace variants' : '<default>',\n };\n };\n const { envId, setBy } = getEnvData();\n return {\n id: componentId,\n dir: componentPath,\n files: addResults.files,\n envId,\n envSetBy: setBy,\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 const userEnvId = await this.workspace.resolveComponentId(userEnv);\n const userEnvIdWithPotentialVersion = await this.workspace.resolveEnvIdWithPotentialVersionForConfig(userEnvId);\n config[userEnvIdWithPotentialVersion] = {};\n config[EnvsAspect.id] = config[EnvsAspect.id] || {};\n config[EnvsAspect.id].env = userEnvId.toStringWithoutVersion();\n return config;\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeComponentFiles(\n componentPath: string,\n templateFiles: ComponentFile[]\n ): Promise<PathOsBasedRelative[]> {\n const dataToPersist = new DataToPersist();\n const vinylFiles = templateFiles.map((templateFile) => {\n const templateFileVinyl = new Vinyl({\n base: componentPath,\n path: path.join(componentPath, templateFile.relativePath),\n contents: Buffer.from(templateFile.content),\n });\n return AbstractVinyl.fromVinyl(templateFileVinyl);\n });\n const results = vinylFiles.map((v) => v.path);\n dataToPersist.addManyFiles(vinylFiles);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n return results;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA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Aec,IAAzC;IACA,MAAMuE,aAAa,CAACiB,cAAd,EAAN;IACA,OAAOJ,OAAP;EACD;;AA9J6B"}
|
|
1
|
+
{"version":3,"names":["ComponentGenerator","constructor","workspace","componentIds","options","template","envs","newComponentHelper","aspectId","generate","dirsToDeleteIfFailed","generateResults","pMapSeries","componentId","componentPath","getNewComponentPath","path","fs","existsSync","join","BitError","hasName","fullName","push","generateOneComponent","err","deleteGeneratedComponents","bitMap","write","dirs","Promise","all","map","dir","absoluteDir","remove","code","name","namePascalCase","camelcase","pascalCase","nameCamelCase","files","generateFiles","mainFile","find","file","isMain","writeComponentFiles","addResults","track","rootDir","relativePath","componentName","defaultScope","scope","component","get","hasEnvConfiguredOriginally","hasEnvConfigured","envBeforeConfigChanges","getEnv","config","templateEnv","EnvsAspect","id","env","Object","keys","length","undefined","configWithEnv","addEnvIfProvidedByFlag","setEntireConfig","getEnvData","envFromFlag","envFromTemplate","envId","setBy","envSetBy","userEnv","userEnvId","resolveComponentId","userEnvIdWithPotentialVersion","resolveEnvIdWithPotentialVersionForConfig","toStringWithoutVersion","templateFiles","dataToPersist","DataToPersist","vinylFiles","templateFile","templateFileVinyl","Vinyl","base","contents","Buffer","from","content","AbstractVinyl","fromVinyl","results","v","addManyFiles","addBasePath","persistAllToFS"],"sources":["component-generator.ts"],"sourcesContent":["import Vinyl from 'vinyl';\nimport fs from 'fs-extra';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport camelcase from 'camelcase';\nimport { BitError } from '@teambit/bit-error';\nimport { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentTemplate, ComponentFile, ComponentConfig } from './component-template';\nimport { CreateOptions } from './create.cmd';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string; envSetBy: string };\n\nexport class ComponentGenerator {\n constructor(\n private workspace: Workspace,\n private componentIds: ComponentID[],\n private options: CreateOptions,\n private template: ComponentTemplate,\n private envs: EnvsMain,\n private newComponentHelper: NewComponentHelperMain,\n private aspectId: string\n ) {}\n\n async generate(): Promise<GenerateResult[]> {\n const dirsToDeleteIfFailed: string[] = [];\n const generateResults = await pMapSeries(this.componentIds, async (componentId) => {\n try {\n const componentPath = this.newComponentHelper.getNewComponentPath(componentId, this.options.path);\n if (fs.existsSync(path.join(this.workspace.path, componentPath))) {\n throw new BitError(`unable to create a component at \"${componentPath}\", this path already exist`);\n }\n if (await this.workspace.hasName(componentId.fullName)) {\n throw new BitError(\n `unable to create a component \"${componentId.fullName}\", a component with the same name already exist`\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();\n\n return generateResults;\n }\n\n private async deleteGeneratedComponents(dirs: string[]) {\n await Promise.all(\n dirs.map(async (dir) => {\n const absoluteDir = path.join(this.workspace.path, dir);\n try {\n await fs.remove(absoluteDir);\n } catch (err: any) {\n if (err.code !== 'ENOENT') {\n // if not exist, it's fine\n throw err;\n }\n }\n })\n );\n }\n\n private async generateOneComponent(componentId: ComponentID, componentPath: string): Promise<GenerateResult> {\n const name = componentId.name;\n const namePascalCase = camelcase(name, { pascalCase: true });\n const nameCamelCase = camelcase(name);\n const files = this.template.generateFiles({ name, namePascalCase, nameCamelCase, componentId });\n const mainFile = files.find((file) => file.isMain);\n await this.writeComponentFiles(componentPath, files);\n const addResults = await this.workspace.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope,\n });\n const component = await this.workspace.get(componentId);\n const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);\n const envBeforeConfigChanges = this.envs.getEnv(component);\n\n let config = this.template.config;\n if (config && typeof config === 'function') {\n config = config({ aspectId: this.aspectId });\n }\n\n const templateEnv = config?.[EnvsAspect.id]?.env;\n\n if (config && templateEnv && hasEnvConfiguredOriginally) {\n // remove the env we got from the template.\n delete config[templateEnv];\n delete config[EnvsAspect.id].env;\n if (Object.keys(config[EnvsAspect.id]).length === 0) delete config[EnvsAspect.id];\n if (Object.keys(config).length === 0) config = undefined;\n }\n\n const configWithEnv = await this.addEnvIfProvidedByFlag(config);\n if (configWithEnv) this.workspace.bitMap.setEntireConfig(component.id, configWithEnv);\n\n const getEnvData = () => {\n const envFromFlag = this.options.env; // env entered by the user when running `bit create --env`\n const envFromTemplate = config?.[EnvsAspect.id]?.env;\n if (envFromFlag) {\n return {\n envId: envFromFlag,\n setBy: '--env flag',\n };\n }\n if (envFromTemplate) {\n return {\n envId: envFromTemplate,\n setBy: 'template',\n };\n }\n return {\n envId: envBeforeConfigChanges.id,\n setBy: hasEnvConfiguredOriginally ? 'workspace variants' : '<default>',\n };\n };\n const { envId, setBy } = getEnvData();\n return {\n id: componentId,\n dir: componentPath,\n files: addResults.files,\n envId,\n envSetBy: setBy,\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 const userEnvId = await this.workspace.resolveComponentId(userEnv);\n const userEnvIdWithPotentialVersion = await this.workspace.resolveEnvIdWithPotentialVersionForConfig(userEnvId);\n config[userEnvIdWithPotentialVersion] = {};\n config[EnvsAspect.id] = config[EnvsAspect.id] || {};\n config[EnvsAspect.id].env = userEnvId.toStringWithoutVersion();\n return config;\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeComponentFiles(\n componentPath: string,\n templateFiles: ComponentFile[]\n ): Promise<PathOsBasedRelative[]> {\n const dataToPersist = new DataToPersist();\n const vinylFiles = templateFiles.map((templateFile) => {\n const templateFileVinyl = new Vinyl({\n base: componentPath,\n path: path.join(componentPath, templateFile.relativePath),\n contents: Buffer.from(templateFile.content),\n });\n return AbstractVinyl.fromVinyl(templateFileVinyl);\n });\n const results = vinylFiles.map((v) => v.path);\n dataToPersist.addManyFiles(vinylFiles);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n return results;\n }\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAQO,MAAMA,kBAAkB,CAAC;EAC9BC,WAAW,CACDC,SAAoB,EACpBC,YAA2B,EAC3BC,OAAsB,EACtBC,QAA2B,EAC3BC,IAAc,EACdC,kBAA0C,EAC1CC,QAAgB,EACxB;IAAA,KAPQN,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,YAA2B,GAA3BA,YAA2B;IAAA,KAC3BC,OAAsB,GAAtBA,OAAsB;IAAA,KACtBC,QAA2B,GAA3BA,QAA2B;IAAA,KAC3BC,IAAc,GAAdA,IAAc;IAAA,KACdC,kBAA0C,GAA1CA,kBAA0C;IAAA,KAC1CC,QAAgB,GAAhBA,QAAgB;EACvB;EAEH,MAAMC,QAAQ,GAA8B;IAC1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AGe,SAAS,CAACI,sBAAsB,EAAE;IAC9D,OAAOvB,MAAM;EACf;;EAEA;AACF;AACA;EACE,MAAcd,mBAAmB,CAC/BlC,aAAqB,EACrBwE,aAA8B,EACE;IAChC,MAAMC,aAAa,GAAG,KAAIC,wBAAa,GAAE;IACzC,MAAMC,UAAU,GAAGH,aAAa,CAACtD,GAAG,CAAE0D,YAAY,IAAK;MACrD,MAAMC,iBAAiB,GAAG,KAAIC,gBAAK,EAAC;QAClCC,IAAI,EAAE/E,aAAa;QACnBE,IAAI,EAAEA,eAAI,CAACG,IAAI,CAACL,aAAa,EAAE4E,YAAY,CAACtC,YAAY,CAAC;QACzD0C,QAAQ,EAAEC,MAAM,CAACC,IAAI,CAACN,YAAY,CAACO,OAAO;MAC5C,CAAC,CAAC;MACF,OAAOC,wBAAa,CAACC,SAAS,CAACR,iBAAiB,CAAC;IACnD,CAAC,CAAC;IACF,MAAMS,OAAO,GAAGX,UAAU,CAACzD,GAAG,CAAEqE,CAAC,IAAKA,CAAC,CAACrF,IAAI,CAAC;IAC7CuE,aAAa,CAACe,YAAY,CAACb,UAAU,CAAC;IACtCF,aAAa,CAACgB,WAAW,CAAC,IAAI,CAACrG,SAAS,CAACc,IAAI,CAAC;IAC9C,MAAMuE,aAAa,CAACiB,cAAc,EAAE;IACpC,OAAOJ,OAAO;EAChB;AACF;AAAC"}
|
package/dist/create.cmd.js
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.CreateCmd = void 0;
|
|
13
|
-
|
|
14
10
|
function _defineProperty2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
12
|
_defineProperty2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _chalk() {
|
|
25
18
|
const data = _interopRequireDefault(require("chalk"));
|
|
26
|
-
|
|
27
19
|
_chalk = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
class CreateCmd {
|
|
35
25
|
constructor(generator, docsDomain) {
|
|
36
26
|
this.generator = generator;
|
|
@@ -62,7 +52,6 @@ class CreateCmd {
|
|
|
62
52
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
63
53
|
(0, _defineProperty2().default)(this, "options", [['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`], ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`], ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'], ['e', 'env <string>', "set the component's environment. (overrides the env from variants and the template)"]]);
|
|
64
54
|
}
|
|
65
|
-
|
|
66
55
|
async report([templateName, componentNames], options) {
|
|
67
56
|
const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);
|
|
68
57
|
const title = `${results.length} component(s) were created`;
|
|
@@ -75,9 +64,7 @@ class CreateCmd {
|
|
|
75
64
|
const footer = `env configuration is according to workspace variants, template config or --env flag. learn more at https://${this.docsDomain}/envs/using-envs`;
|
|
76
65
|
return `${_chalk().default.green(title)}\n\n${componentsData}\n\n${footer}`;
|
|
77
66
|
}
|
|
78
|
-
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
exports.CreateCmd = CreateCmd;
|
|
82
69
|
|
|
83
70
|
//# sourceMappingURL=create.cmd.js.map
|
package/dist/create.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CreateCmd","constructor","generator","docsDomain","name","description","cmd","report","templateName","componentNames","options","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","envSetBy","join","footer","green"],"sources":["create.cmd.ts"],"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 env?: string;\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 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',\n description: \"creates a component named 'ui/button' using the 'react' template\",\n },\n {\n cmd: 'bit create react ui/button pages/register',\n description: \"creates two components, 'ui/button' and 'pages/register', using the 'react' template\",\n },\n {\n cmd: 'bit create react ui/button --scope my-org.my-scope',\n description:\n \"creates a component named 'ui/button' 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 --env teambit.community/envs/community-react@1.95.13',\n description:\n \"creates a component named 'ui/button' and sets it to use the 'community-react' env. \\n(the template's default env is 'teambit.react/react').\",\n },\n ];\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 ['e', 'env <string>', \"set the component's environment. (overrides the env from variants and the template)\"],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain, private docsDomain: string) {}\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} (set by ${result.envSetBy})\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants, template config or --env flag. learn more at https://${this.docsDomain}/envs/using-envs`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CreateCmd","constructor","generator","docsDomain","name","description","cmd","report","templateName","componentNames","options","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","envSetBy","join","footer","green"],"sources":["create.cmd.ts"],"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 env?: string;\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 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',\n description: \"creates a component named 'ui/button' using the 'react' template\",\n },\n {\n cmd: 'bit create react ui/button pages/register',\n description: \"creates two components, 'ui/button' and 'pages/register', using the 'react' template\",\n },\n {\n cmd: 'bit create react ui/button --scope my-org.my-scope',\n description:\n \"creates a component named 'ui/button' 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 --env teambit.community/envs/community-react@1.95.13',\n description:\n \"creates a component named 'ui/button' and sets it to use the 'community-react' env. \\n(the template's default env is 'teambit.react/react').\",\n },\n ];\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 ['e', 'env <string>', \"set the component's environment. (overrides the env from variants and the template)\"],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain, private docsDomain: string) {}\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} (set by ${result.envSetBy})\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants, template config or --env flag. learn more at https://${this.docsDomain}/envs/using-envs`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAWO,MAAMA,SAAS,CAAoB;EA6CxCC,WAAW,CAASC,SAAwB,EAAUC,UAAkB,EAAE;IAAA,KAAtDD,SAAwB,GAAxBA,SAAwB;IAAA,KAAUC,UAAkB,GAAlBA,UAAkB;IAAA,8CA5CjE,6CAA6C;IAAA,qDACtC,oEAAoE;IAAA,+CAC1E,EAAE;IAAA,gDACD,IAAI;IAAA,mDACD,CACV;MACEC,IAAI,EAAE,eAAe;MACrBC,WAAW,EACT;IACJ,CAAC,EACD;MACED,IAAI,EAAE,oBAAoB;MAC1BC,WAAW,EAAE;IACf,CAAC,CACF;IAAA,kDACU,CACT;MACEC,GAAG,EAAE,4BAA4B;MACjCD,WAAW,EAAE;IACf,CAAC,EACD;MACEC,GAAG,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
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.GeneratorAspect = void 0;
|
|
7
|
-
|
|
8
7
|
function _harmony() {
|
|
9
8
|
const data = require("@teambit/harmony");
|
|
10
|
-
|
|
11
9
|
_harmony = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
const GeneratorAspect = _harmony().Aspect.create({
|
|
19
15
|
id: 'teambit.generator/generator'
|
|
20
16
|
});
|
|
21
|
-
|
|
22
17
|
exports.GeneratorAspect = GeneratorAspect;
|
|
23
18
|
|
|
24
19
|
//# sourceMappingURL=generator.aspect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GeneratorAspect","Aspect","create","id"],"sources":["generator.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const GeneratorAspect = Aspect.create({\n id: 'teambit.generator/generator',\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["GeneratorAspect","Aspect","create","id"],"sources":["generator.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const GeneratorAspect = Aspect.create({\n id: 'teambit.generator/generator',\n});\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,eAAe,GAAGC,iBAAM,CAACC,MAAM,CAAC;EAC3CC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.Logo = void 0;
|
|
9
|
-
|
|
10
8
|
function _react() {
|
|
11
9
|
const data = _interopRequireDefault(require("react"));
|
|
12
|
-
|
|
13
10
|
_react = function () {
|
|
14
11
|
return data;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
return data;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
21
16
|
style: {
|
|
22
17
|
height: '100%',
|
|
@@ -29,7 +24,6 @@ const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
|
29
24
|
},
|
|
30
25
|
src: "https://static.bit.dev/extensions-icons/generator-new.svg"
|
|
31
26
|
}));
|
|
32
|
-
|
|
33
27
|
exports.Logo = Logo;
|
|
34
28
|
|
|
35
29
|
//# sourceMappingURL=generator.composition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["generator.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/generator-new.svg\" />\n </div>\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["generator.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/generator-new.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAG,CAAE;EAAC,GAAG,EAAC;AAA2D,EAAG,CAEhG;AAAC"}
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.generatorSchema = generatorSchema;
|
|
11
|
-
|
|
12
9
|
function _objectWithoutProperties2() {
|
|
13
10
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
14
|
-
|
|
15
11
|
_objectWithoutProperties2 = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _graphqlTag() {
|
|
23
17
|
const data = _interopRequireDefault(require("graphql-tag"));
|
|
24
|
-
|
|
25
18
|
_graphqlTag = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function generatorSchema(generator) {
|
|
33
24
|
return {
|
|
34
25
|
typeDefs: (0, _graphqlTag().default)`
|
|
@@ -66,10 +57,10 @@ function generatorSchema(generator) {
|
|
|
66
57
|
Mutation: {
|
|
67
58
|
createComponent: async (req, _ref) => {
|
|
68
59
|
let {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
name,
|
|
61
|
+
templateName
|
|
62
|
+
} = _ref,
|
|
63
|
+
options = (0, _objectWithoutProperties2().default)(_ref, ["name", "templateName"]);
|
|
73
64
|
const res = await generator.generateComponentTemplate([name], templateName, options);
|
|
74
65
|
return res.map(component => ({
|
|
75
66
|
id: component.id.toString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","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';\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 (\n req: any,\n {\n name,\n templateName,\n ...options\n }: { name: string; templateName: string; scope?: string; namespace?: string; aspect?: string }\n ) => {\n const res = await generator.generateComponentTemplate([name], templateName, 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":"
|
|
1
|
+
{"version":3,"names":["generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","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';\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 (\n req: any,\n {\n name,\n templateName,\n ...options\n }: { name: string; templateName: string; scope?: string; namespace?: string; aspect?: string }\n ) => {\n const res = await generator.generateComponentTemplate([name], templateName, 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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,SAASA,eAAe,CAACC,SAAwB,EAAU;EAChE,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAG,CAAC;AAClB;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,KAAK;IACDC,SAAS,EAAE;MACTC,QAAQ,EAAE;QACRC,eAAe,EAAE,OACfC,GAAQ,WAML;UAAA,IALH;cACEC,IAAI;cACJC;YAE2F,CAAC;YADzFC,OAAO;UAGZ,MAAMC,GAAG,GAAG,MAAMV,SAAS,CAACW,yBAAyB,CAAC,CAACJ,IAAI,CAAC,EAAEC,YAAY,EAAEC,OAAO,CAAC;UACpF,OAAOC,GAAG,CAACE,GAAG,CAAEC,SAAS,KAAM;YAC7BC,EAAE,EAAED,SAAS,CAACC,EAAE,CAACC,QAAQ,EAAE;YAC3BC,GAAG,EAAEH,SAAS,CAACG,GAAG;YAClBC,KAAK,EAAEJ,SAAS,CAACI;UACnB,CAAC,CAAC,CAAC;QACL;MACF,CAAC;MACDC,SAAS,EAAE;QACTC,SAAS,EAAE,YAAY;UACrB,OAAOnB,SAAS,CAACoB,aAAa,EAAE;QAClC;MACF,CAAC;MACDC,KAAK,EAAE;QACLrB,SAAS,EAAE,MAAMA;MACnB;IACF;EACF,CAAC;AACH"}
|