@teambit/generator 1.0.1198 → 1.0.1200

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/generator",
3
- "version": "1.0.1198",
3
+ "version": "1.0.1200",
4
4
  "homepage": "https://bit.cloud/teambit/generator/generator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.generator",
8
8
  "name": "generator",
9
- "version": "1.0.1198"
9
+ "version": "1.0.1200"
10
10
  },
11
11
  "dependencies": {
12
12
  "camelcase": "6.2.0",
@@ -16,39 +16,30 @@
16
16
  "chalk": "4.1.2",
17
17
  "graphql-tag": "2.12.1",
18
18
  "lodash": "4.17.21",
19
- "execa": "2.1.0",
20
19
  "@teambit/bit-error": "0.0.404",
21
20
  "@teambit/component-id": "1.2.4",
22
21
  "@teambit/logger": "0.0.1494",
22
+ "@teambit/pkg.modules.component-package-name": "0.0.182",
23
+ "@teambit/workspace.modules.node-modules-linker": "0.0.408",
24
+ "@teambit/cli": "0.0.1406",
23
25
  "@teambit/harmony": "0.4.12",
24
26
  "@teambit/harmony.modules.runtimes": "0.0.1",
25
27
  "@teambit/legacy-bit-id": "1.1.3",
26
28
  "@teambit/legacy.constants": "0.0.46",
27
- "@teambit/git.modules.git-executable": "0.0.47",
29
+ "@teambit/legacy.consumer-config": "0.0.175",
30
+ "@teambit/legacy.scope": "0.0.175",
28
31
  "@teambit/git.modules.git-ignore": "1.0.2",
29
- "@teambit/envs": "1.0.1197",
30
- "@teambit/new-component-helper": "1.0.1197",
31
- "@teambit/pkg.modules.component-package-name": "0.0.181",
32
- "@teambit/tracker": "1.0.1197",
33
- "@teambit/workspace-config-files": "1.0.1197",
34
- "@teambit/workspace.modules.node-modules-linker": "0.0.407",
35
- "@teambit/workspace": "1.0.1197",
36
- "@teambit/component": "1.0.1197",
37
- "@teambit/cli": "0.0.1405",
38
- "@teambit/graphql": "1.0.1197",
39
- "@teambit/aspect-loader": "1.0.1197",
40
- "@teambit/deprecation": "1.0.1197",
41
- "@teambit/git": "1.0.1197",
42
- "@teambit/legacy.consumer-config": "0.0.174",
43
- "@teambit/legacy.scope": "0.0.174",
44
- "@teambit/scope": "1.0.1197",
45
- "@teambit/compiler": "1.0.1197",
46
- "@teambit/forking": "1.0.1197",
47
- "@teambit/host-initializer": "0.0.910",
48
- "@teambit/importer": "1.0.1197",
49
- "@teambit/install": "1.0.1197",
50
- "@teambit/ui": "1.0.1197",
51
- "@teambit/config": "0.0.1580"
32
+ "@teambit/config": "0.0.1581",
33
+ "@teambit/envs": "1.0.1199",
34
+ "@teambit/new-component-helper": "1.0.1199",
35
+ "@teambit/tracker": "1.0.1199",
36
+ "@teambit/workspace-config-files": "1.0.1199",
37
+ "@teambit/workspace": "1.0.1199",
38
+ "@teambit/component": "1.0.1199",
39
+ "@teambit/graphql": "1.0.1199",
40
+ "@teambit/aspect-loader": "1.0.1199",
41
+ "@teambit/git": "1.0.1199",
42
+ "@teambit/scope": "1.0.1199"
52
43
  },
53
44
  "devDependencies": {
54
45
  "@types/fs-extra": "9.0.7",
@@ -1,5 +0,0 @@
1
- import { BitError } from '@teambit/bit-error';
2
- export declare class WorkspacePathExists extends BitError {
3
- readonly path: string;
4
- constructor(path: string);
5
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WorkspacePathExists = void 0;
7
- function _bitError() {
8
- const data = require("@teambit/bit-error");
9
- _bitError = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- class WorkspacePathExists extends _bitError().BitError {
15
- constructor(path) {
16
- super(`unable to create a workspace at "${path}", this path already exists`);
17
- this.path = path;
18
- }
19
- }
20
- exports.WorkspacePathExists = WorkspacePathExists;
21
-
22
- //# sourceMappingURL=workspace-path-exists.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_bitError","data","require","WorkspacePathExists","BitError","constructor","path","exports"],"sources":["workspace-path-exists.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class WorkspacePathExists extends BitError {\n constructor(readonly path: string) {\n super(`unable to create a workspace at \"${path}\", this path already exists`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,mBAAmB,SAASC,oBAAQ,CAAC;EAChDC,WAAWA,CAAUC,IAAY,EAAE;IACjC,KAAK,CAAC,oCAAoCA,IAAI,6BAA6B,CAAC;IAAC,KAD1DA,IAAY,GAAZA,IAAY;EAEjC;AACF;AAACC,OAAA,CAAAJ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
package/dist/new.cmd.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { Command, CommandOptions } from '@teambit/cli';
2
- import type { GeneratorMain } from './generator.main.runtime';
3
- import type { BaseWorkspaceOptions } from './workspace-template';
4
- /**
5
- * NewOptions combines foundational properties with additional options for creating a workspace.
6
- */
7
- export type NewOptions = BaseWorkspaceOptions;
8
- export declare class NewCmd implements Command {
9
- private generator;
10
- name: string;
11
- description: string;
12
- extendedDescription: string;
13
- arguments: {
14
- name: string;
15
- description: string;
16
- }[];
17
- alias: string;
18
- loader: boolean;
19
- group: string;
20
- options: CommandOptions;
21
- constructor(generator: GeneratorMain);
22
- report([templateName, workspaceName]: [string, string], options: NewOptions & {
23
- standalone: boolean;
24
- env?: string;
25
- template?: string;
26
- aspect?: string;
27
- currentDir?: boolean;
28
- }): Promise<string>;
29
- }
package/dist/new.cmd.js DELETED
@@ -1,100 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NewCmd = void 0;
7
- function _cli() {
8
- const data = require("@teambit/cli");
9
- _cli = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _chalk() {
15
- const data = _interopRequireDefault(require("chalk"));
16
- _chalk = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
23
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
24
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
25
- /**
26
- * NewOptions combines foundational properties with additional options for creating a workspace.
27
- */
28
-
29
- class NewCmd {
30
- constructor(generator) {
31
- this.generator = generator;
32
- _defineProperty(this, "name", 'new <template-name> <workspace-name>');
33
- _defineProperty(this, "description", 'create a new Bit workspace from a template');
34
- _defineProperty(this, "extendedDescription", `initializes a new Bit workspace with pre-configured settings, environments, and optionally starter components.
35
- templates provide different setups for React, Angular, Node.js, or custom development workflows.
36
- installs dependencies and configures the workspace for immediate development.`);
37
- _defineProperty(this, "arguments", [{
38
- name: 'template-name',
39
- description: "the name of the workspace template (run 'bit templates' outside of a workspace to get a list of available workspace templates)"
40
- }, {
41
- name: 'workspace-name',
42
- description: 'the name for the new workspace and workspace directory that will be created'
43
- }]);
44
- _defineProperty(this, "alias", '');
45
- _defineProperty(this, "loader", true);
46
- _defineProperty(this, "group", 'workspace-setup');
47
- _defineProperty(this, "options", [['a', 'aspect <aspect-id>', 'id of the aspect that registered the template, mandatory for non-core aspects. helpful for core aspects in case of a name collision'], ['t', 'template <env-id>', 'id of the dev environment to use for the template. Alias for --env.'], ['', 'env <env-id>', 'id of the dev environment to use for the template. Alias -t'], ['d', 'default-scope <scope-name>', `set the default scope for the workspace. used in the generated workspace.jsonc`], ['', 'standalone', 'DEPRECATED. use --skip-git instead'], ['s', 'skip-git', 'skip generation of Git repository in the new workspace'], ['e', 'empty', "skip template's default component creation (relevant for templates that add components by default)"], ['', 'load-from <path-to-template>', 'local path to the workspace containing the template. Helpful during the development of a workspace-template'], ['c', 'current-dir', 'create the new workspace in current directory (default is to create a new directory, inside the current dir)'], ['', 'agent [type]', 'create an AI agent instructions file. options: claude, cursor, copilot (default: AGENTS.md)']]);
48
- }
49
- async report([templateName, workspaceName], options) {
50
- options.skipGit = options.skipGit ?? options.standalone;
51
- options.aspect = options.aspect ?? options.env ?? options.template;
52
- const {
53
- workspacePath,
54
- appName
55
- } = await this.generator.generateWorkspaceTemplate(workspaceName, templateName, options);
56
- return `
57
- ${(0, _cli().formatSuccessSummary)(`A new workspace has been created at '${workspacePath}'`)}
58
-
59
- Inside the directory '${workspaceName}' you can run various commands including:
60
-
61
- ${_chalk().default.yellow('bit start')}
62
- Starts the local dev server
63
-
64
- ${_chalk().default.yellow('bit install')}
65
- Installs any missing dependencies
66
-
67
- ${_chalk().default.yellow('bit status')}
68
- Shows the status of the components
69
-
70
- ${_chalk().default.yellow('bit compile')}
71
- Compiles the components
72
-
73
- ${_chalk().default.yellow('bit test')}
74
- Runs the tests on all your components
75
-
76
- ${_chalk().default.yellow('bit templates')}
77
- Shows all available component templates
78
-
79
- ${_chalk().default.yellow('bit help')}
80
- Shows all available commands
81
-
82
-
83
- ${_chalk().default.green.bold("Let's get started!")}
84
-
85
- ${getBottomSection(workspaceName, appName)}
86
- `;
87
- }
88
- }
89
- exports.NewCmd = NewCmd;
90
- function getBottomSection(workspaceName, appName) {
91
- const cdLine = _chalk().default.yellow(`cd ${workspaceName}`);
92
- const parts = [cdLine];
93
- if (appName) {
94
- parts.push(_chalk().default.yellow(` bit run ${appName}`));
95
- }
96
- parts.push(_chalk().default.yellow(` bit start`));
97
- return parts.join('\n');
98
- }
99
-
100
- //# sourceMappingURL=new.cmd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_cli","data","require","_chalk","_interopRequireDefault","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","NewCmd","constructor","generator","name","description","report","templateName","workspaceName","options","skipGit","standalone","aspect","env","template","workspacePath","appName","generateWorkspaceTemplate","formatSuccessSummary","chalk","yellow","green","bold","getBottomSection","exports","cdLine","parts","push","join"],"sources":["new.cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from '@teambit/cli';\nimport { formatSuccessSummary } from '@teambit/cli';\nimport chalk from 'chalk';\nimport type { GeneratorMain } from './generator.main.runtime';\nimport type { BaseWorkspaceOptions } from './workspace-template';\n\n/**\n * NewOptions combines foundational properties with additional options for creating a workspace.\n */\nexport type NewOptions = BaseWorkspaceOptions;\n\nexport class NewCmd implements Command {\n name = 'new <template-name> <workspace-name>';\n description = 'create a new Bit workspace from a template';\n extendedDescription = `initializes a new Bit workspace with pre-configured settings, environments, and optionally starter components.\ntemplates provide different setups for React, Angular, Node.js, or custom development workflows.\ninstalls dependencies and configures the workspace for immediate development.`;\n arguments = [\n {\n name: 'template-name',\n description:\n \"the name of the workspace template (run 'bit templates' outside of a workspace to get a list of available workspace templates)\",\n },\n {\n name: 'workspace-name',\n description: 'the name for the new workspace and workspace directory that will be created',\n },\n ];\n alias = '';\n loader = true;\n group = 'workspace-setup';\n options = [\n [\n 'a',\n 'aspect <aspect-id>',\n 'id of the aspect that registered the template, mandatory for non-core aspects. helpful for core aspects in case of a name collision',\n ],\n ['t', 'template <env-id>', 'id of the dev environment to use for the template. Alias for --env.'],\n ['', 'env <env-id>', 'id of the dev environment to use for the template. Alias -t'],\n [\n 'd',\n 'default-scope <scope-name>',\n `set the default scope for the workspace. used in the generated workspace.jsonc`,\n ],\n ['', 'standalone', 'DEPRECATED. use --skip-git instead'],\n ['s', 'skip-git', 'skip generation of Git repository in the new workspace'],\n [\n 'e',\n 'empty',\n \"skip template's default component creation (relevant for templates that add components by default)\",\n ],\n [\n '',\n 'load-from <path-to-template>',\n 'local path to the workspace containing the template. Helpful during the development of a workspace-template',\n ],\n [\n 'c',\n 'current-dir',\n 'create the new workspace in current directory (default is to create a new directory, inside the current dir)',\n ],\n ['', 'agent [type]', 'create an AI agent instructions file. options: claude, cursor, copilot (default: AGENTS.md)'],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain) {}\n\n async report(\n [templateName, workspaceName]: [string, string],\n options: NewOptions & {\n standalone: boolean;\n env?: string;\n template?: string;\n aspect?: string;\n currentDir?: boolean;\n }\n ) {\n options.skipGit = options.skipGit ?? options.standalone;\n options.aspect = options.aspect ?? options.env ?? options.template;\n const { workspacePath, appName } = await this.generator.generateWorkspaceTemplate(\n workspaceName,\n templateName,\n options\n );\n return `\n${formatSuccessSummary(`A new workspace has been created at '${workspacePath}'`)}\n\nInside the directory '${workspaceName}' you can run various commands including:\n\n ${chalk.yellow('bit start')}\n Starts the local dev server\n\n ${chalk.yellow('bit install')}\n Installs any missing dependencies\n\n ${chalk.yellow('bit status')}\n Shows the status of the components\n\n ${chalk.yellow('bit compile')}\n Compiles the components\n\n ${chalk.yellow('bit test')}\n Runs the tests on all your components\n\n ${chalk.yellow('bit templates')}\n Shows all available component templates\n\n ${chalk.yellow('bit help')}\n Shows all available commands\n\n\n${chalk.green.bold(\"Let's get started!\")}\n\n ${getBottomSection(workspaceName, appName)}\n `;\n }\n}\n\nfunction getBottomSection(workspaceName: string, appName: string | undefined) {\n const cdLine = chalk.yellow(`cd ${workspaceName}`);\n const parts = [cdLine];\n if (appName) {\n parts.push(chalk.yellow(` bit run ${appName}`));\n }\n parts.push(chalk.yellow(` bit start`));\n return parts.join('\\n');\n}\n"],"mappings":";;;;;;AACA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;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W,CAAC;AACjC;AACA;AACA,QAAQD,gBAAK,CAACC,MAAM,CAAC,aAAa,CAAC;AACnC;AACA;AACA,QAAQD,gBAAK,CAACC,MAAM,CAAC,YAAY,CAAC;AAClC;AACA;AACA,QAAQD,gBAAK,CAACC,MAAM,CAAC,aAAa,CAAC;AACnC;AACA;AACA,QAAQD,gBAAK,CAACC,MAAM,CAAC,UAAU,CAAC;AAChC;AACA;AACA,QAAQD,gBAAK,CAACC,MAAM,CAAC,eAAe,CAAC;AACrC;AACA;AACA,QAAQD,gBAAK,CAACC,MAAM,CAAC,UAAU,CAAC;AAChC;AACA;AACA;AACA,EAAED,gBAAK,CAACE,KAAK,CAACC,IAAI,CAAC,oBAAoB,CAAC;AACxC;AACA,QAAQC,gBAAgB,CAACf,aAAa,EAAEQ,OAAO,CAAC;AAChD,OAAO;EACL;AACF;AAACQ,OAAA,CAAAvB,MAAA,GAAAA,MAAA;AAED,SAASsB,gBAAgBA,CAACf,aAAqB,EAAEQ,OAA2B,EAAE;EAC5E,MAAMS,MAAM,GAAGN,gBAAK,CAACC,MAAM,CAAC,MAAMZ,aAAa,EAAE,CAAC;EAClD,MAAMkB,KAAK,GAAG,CAACD,MAAM,CAAC;EACtB,IAAIT,OAAO,EAAE;IACXU,KAAK,CAACC,IAAI,CAACR,gBAAK,CAACC,MAAM,CAAC,iBAAiBJ,OAAO,EAAE,CAAC,CAAC;EACtD;EACAU,KAAK,CAACC,IAAI,CAACR,gBAAK,CAACC,MAAM,CAAC,iBAAiB,CAAC,CAAC;EAC3C,OAAOM,KAAK,CAACE,IAAI,CAAC,IAAI,CAAC;AACzB","ignoreList":[]}
@@ -1,46 +0,0 @@
1
- import type { Component } from '@teambit/component';
2
- import type { ComponentID } from '@teambit/component-id';
3
- import type { WorkspaceTemplate } from './workspace-template';
4
- import type { NewOptions } from './new.cmd';
5
- import type { BitApi } from './generator.main.runtime';
6
- export type GenerateResult = {
7
- id: ComponentID;
8
- dir: string;
9
- files: string[];
10
- envId: string;
11
- };
12
- export declare class WorkspaceGenerator {
13
- private workspaceName;
14
- private workspacePath;
15
- private options;
16
- private template;
17
- private bitApi;
18
- private aspectComponent?;
19
- private harmony;
20
- private workspace;
21
- private install;
22
- private importer;
23
- private logger?;
24
- private forking;
25
- private git;
26
- private wsConfigFiles;
27
- private generator;
28
- constructor(workspaceName: string, workspacePath: string, options: NewOptions & {
29
- currentDir?: boolean;
30
- }, template: WorkspaceTemplate, bitApi: BitApi, aspectComponent?: Component | undefined);
31
- generate(): Promise<string>;
32
- private initGit;
33
- private setupGitBitmapMergeDriver;
34
- private buildUI;
35
- private getWorkspaceContext;
36
- /**
37
- * writes the generated template files to the default directory set in the workspace config
38
- */
39
- private writeWorkspaceFiles;
40
- private reloadBitInWorkspaceDir;
41
- private installBeforeCreateComponentsIfNeeded;
42
- private createComponentsFromRemote;
43
- private forkComponentsFromRemote;
44
- private importComponentsFromRemote;
45
- private compileComponents;
46
- }
@@ -1,334 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WorkspaceGenerator = void 0;
7
- function _fsExtra() {
8
- const data = _interopRequireDefault(require("fs-extra"));
9
- _fsExtra = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _execa() {
15
- const data = _interopRequireDefault(require("execa"));
16
- _execa = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _pMapSeries() {
22
- const data = _interopRequireDefault(require("p-map-series"));
23
- _pMapSeries = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _ui() {
29
- const data = require("@teambit/ui");
30
- _ui = function () {
31
- return data;
32
- };
33
- return data;
34
- }
35
- function _logger() {
36
- const data = require("@teambit/logger");
37
- _logger = function () {
38
- return data;
39
- };
40
- return data;
41
- }
42
- function _workspace() {
43
- const data = require("@teambit/workspace");
44
- _workspace = function () {
45
- return data;
46
- };
47
- return data;
48
- }
49
- function _forking() {
50
- const data = require("@teambit/forking");
51
- _forking = function () {
52
- return data;
53
- };
54
- return data;
55
- }
56
- function _importer() {
57
- const data = require("@teambit/importer");
58
- _importer = function () {
59
- return data;
60
- };
61
- return data;
62
- }
63
- function _compiler() {
64
- const data = require("@teambit/compiler");
65
- _compiler = function () {
66
- return data;
67
- };
68
- return data;
69
- }
70
- function _gitModules() {
71
- const data = require("@teambit/git.modules.git-executable");
72
- _gitModules = function () {
73
- return data;
74
- };
75
- return data;
76
- }
77
- function _path() {
78
- const data = require("path");
79
- _path = function () {
80
- return data;
81
- };
82
- return data;
83
- }
84
- function _lodash() {
85
- const data = require("lodash");
86
- _lodash = function () {
87
- return data;
88
- };
89
- return data;
90
- }
91
- function _git() {
92
- const data = require("@teambit/git");
93
- _git = function () {
94
- return data;
95
- };
96
- return data;
97
- }
98
- function _install() {
99
- const data = require("@teambit/install");
100
- _install = function () {
101
- return data;
102
- };
103
- return data;
104
- }
105
- function _hostInitializer() {
106
- const data = require("@teambit/host-initializer");
107
- _hostInitializer = function () {
108
- return data;
109
- };
110
- return data;
111
- }
112
- function _workspaceConfigFiles() {
113
- const data = require("@teambit/workspace-config-files");
114
- _workspaceConfigFiles = function () {
115
- return data;
116
- };
117
- return data;
118
- }
119
- function _generator() {
120
- const data = require("./generator.aspect");
121
- _generator = function () {
122
- return data;
123
- };
124
- return data;
125
- }
126
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
127
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
128
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
129
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // import { ComponentGenerator } from './component-generator';
130
- class WorkspaceGenerator {
131
- constructor(workspaceName, workspacePath, options, template, bitApi, aspectComponent) {
132
- this.workspaceName = workspaceName;
133
- this.workspacePath = workspacePath;
134
- this.options = options;
135
- this.template = template;
136
- this.bitApi = bitApi;
137
- this.aspectComponent = aspectComponent;
138
- _defineProperty(this, "harmony", void 0);
139
- _defineProperty(this, "workspace", void 0);
140
- _defineProperty(this, "install", void 0);
141
- _defineProperty(this, "importer", void 0);
142
- _defineProperty(this, "logger", void 0);
143
- _defineProperty(this, "forking", void 0);
144
- _defineProperty(this, "git", void 0);
145
- _defineProperty(this, "wsConfigFiles", void 0);
146
- _defineProperty(this, "generator", void 0);
147
- }
148
- async generate() {
149
- await _fsExtra().default.ensureDir(this.workspacePath);
150
- try {
151
- process.chdir(this.workspacePath);
152
- await this.initGit();
153
- const agentType = this.options.agent || undefined;
154
- await _hostInitializer().HostInitializerMain.init(this.workspacePath, this.options.skipGit, false, false, false, false, false, false, false, {}, undefined, agentType);
155
- await this.writeWorkspaceFiles();
156
- // Write agent instructions with skipGitCheck since bit new always creates a fresh workspace.
157
- // When --skip-git is used, init() already wrote the file; hasExistingAgentFile() prevents a duplicate.
158
- await _hostInitializer().HostInitializerMain.writeAgentInstructions(this.workspacePath, agentType, true);
159
- await this.reloadBitInWorkspaceDir();
160
- // Setting the workspace to be in install context to prevent errors during the workspace generation
161
- // the workspace will be in install context until the end of the generation install process
162
- this.workspace.inInstallContext = true;
163
- await this.setupGitBitmapMergeDriver();
164
- await this.forkComponentsFromRemote();
165
- await this.installBeforeCreateComponentsIfNeeded();
166
- await this.createComponentsFromRemote();
167
- await this.importComponentsFromRemote();
168
- await this.workspace.clearCache();
169
- await this.install.install(undefined, {
170
- dedupe: true,
171
- import: false,
172
- copyPeerToRuntimeOnRoot: true,
173
- copyPeerToRuntimeOnComponents: false,
174
- updateExisting: false
175
- // This is not needed anymore since PR:
176
- // keep it here for a while to make sure it doesn't break anything
177
- // skip pruning here to prevent cases which it caused an error about
178
- // tsconfig not found because the env location was changed
179
- // skipPrune: true,
180
- });
181
-
182
- // compile the components again now that we have the dependencies installed
183
- await this.compileComponents(true);
184
- await this.wsConfigFiles.writeConfigFiles({});
185
- } catch (err) {
186
- this.logger?.error(`failed generating a new workspace, will delete the dir ${this.workspacePath}`, err);
187
- await _fsExtra().default.remove(this.workspacePath);
188
- throw err;
189
- }
190
- return this.workspacePath;
191
- }
192
- async initGit() {
193
- if (this.options.skipGit) return;
194
- const gitExecutablePath = (0, _gitModules().getGitExecutablePath)();
195
- const params = ['init'];
196
- try {
197
- await (0, _execa().default)(gitExecutablePath, params);
198
- } catch (err) {
199
- if (err.exitCodeName === 'ENOENT') {
200
- throw new (_gitModules().GitNotFound)(gitExecutablePath, err);
201
- }
202
- throw err;
203
- }
204
- }
205
- async setupGitBitmapMergeDriver() {
206
- if (this.options.skipGit) return;
207
- await this.git.setGitMergeDriver({
208
- global: false
209
- });
210
- }
211
- async buildUI() {
212
- const uiMain = this.harmony.get(_ui().UIAspect.id);
213
- await uiMain.createRuntime({});
214
- }
215
- getWorkspaceContext() {
216
- return {
217
- name: this.workspaceName,
218
- defaultScope: this.options.defaultScope,
219
- empty: this.options.empty,
220
- aspectComponent: this.aspectComponent,
221
- template: this.template,
222
- skipGit: this.options.skipGit
223
- };
224
- }
225
-
226
- /**
227
- * writes the generated template files to the default directory set in the workspace config
228
- */
229
- async writeWorkspaceFiles() {
230
- const workspaceContext = this.getWorkspaceContext();
231
- const templateFiles = await this.template.generateFiles(workspaceContext);
232
- await Promise.all(templateFiles.map(async templateFile => {
233
- await _fsExtra().default.outputFile((0, _path().join)(this.workspacePath, templateFile.relativePath), templateFile.content);
234
- }));
235
- }
236
- async reloadBitInWorkspaceDir() {
237
- this.harmony = await this.bitApi.loadBit(this.workspacePath);
238
- this.workspace = this.harmony.get(_workspace().WorkspaceAspect.id);
239
- this.install = this.harmony.get(_install().InstallAspect.id);
240
- const loggerMain = this.harmony.get(_logger().LoggerAspect.id);
241
- this.logger = loggerMain.createLogger(_generator().GeneratorAspect.id);
242
- this.importer = this.harmony.get(_importer().ImporterAspect.id);
243
- this.forking = this.harmony.get(_forking().ForkingAspect.id);
244
- this.git = this.harmony.get(_git().GitAspect.id);
245
- this.wsConfigFiles = this.harmony.get(_workspaceConfigFiles().WorkspaceConfigFilesAspect.id);
246
- this.generator = this.harmony.get(_generator().GeneratorAspect.id);
247
- }
248
- async installBeforeCreateComponentsIfNeeded() {
249
- if (this.options.empty || !this.template.create) return;
250
- const configuredEnvs = this.generator.getConfiguredEnvs();
251
- if (!configuredEnvs.length) return;
252
- const workspaceContext = this.getWorkspaceContext();
253
- const componentsToCreate = this.template.create(workspaceContext);
254
- const aspectsForComponentsToCreate = (0, _lodash().compact)(componentsToCreate.map(componentToCreate => componentToCreate.aspect));
255
- const needInstall = (0, _lodash().some)(aspectsForComponentsToCreate, aspect => {
256
- return configuredEnvs.includes(aspect);
257
- });
258
- if (needInstall) {
259
- this.logger?.console(`installing dependencies in workspace using to load components templates from the following envs: ${configuredEnvs.join(', ')}`);
260
- await this.install.install(undefined, {
261
- dedupe: true,
262
- import: false,
263
- copyPeerToRuntimeOnRoot: true,
264
- copyPeerToRuntimeOnComponents: false,
265
- updateExisting: false
266
- });
267
- }
268
- }
269
- async createComponentsFromRemote() {
270
- if (this.options.empty || !this.template.create) return;
271
- const workspaceContext = this.getWorkspaceContext();
272
- const componentsToCreate = this.template.create(workspaceContext);
273
- await (0, _pMapSeries().default)(componentsToCreate, async componentToCreate => {
274
- return this.generator.generateComponentTemplate([componentToCreate.componentName], componentToCreate.templateName, {
275
- aspect: componentToCreate.aspect,
276
- env: componentToCreate.env,
277
- path: componentToCreate.path,
278
- scope: componentToCreate.scope
279
- });
280
- });
281
- }
282
- async forkComponentsFromRemote() {
283
- if (this.options.empty) return;
284
- const workspaceContext = this.getWorkspaceContext();
285
- const componentsToFork = this.template?.importComponents?.(workspaceContext) || this.template?.fork?.(workspaceContext) || [];
286
- if (!componentsToFork.length) return;
287
- const componentsToForkRestructured = componentsToFork.map(({
288
- id,
289
- targetName,
290
- path,
291
- env,
292
- config,
293
- targetScope
294
- }) => ({
295
- sourceId: id,
296
- targetId: targetName,
297
- targetScope,
298
- path,
299
- env,
300
- config
301
- }));
302
- await this.forking.forkMultipleFromRemote(componentsToForkRestructured, {
303
- scope: this.workspace.defaultScope,
304
- refactor: true,
305
- install: false,
306
- compile: false
307
- });
308
- }
309
- async importComponentsFromRemote() {
310
- if (this.options.empty) return;
311
- const workspaceContext = this.getWorkspaceContext();
312
- const componentsToImport = this.template?.import?.(workspaceContext) || [];
313
- if (!componentsToImport.length) return;
314
- await (0, _pMapSeries().default)(componentsToImport, async componentToImport => {
315
- await this.importer.import({
316
- ids: [componentToImport.id],
317
- installNpmPackages: false,
318
- writeConfigFiles: false,
319
- writeToPath: componentToImport.path
320
- }, []);
321
- });
322
- await this.workspace.bitMap.write('new');
323
- }
324
- async compileComponents(clearCache = true) {
325
- if (clearCache) {
326
- await this.workspace.clearCache();
327
- }
328
- const compiler = this.harmony.get(_compiler().CompilerAspect.id);
329
- await compiler.compileOnWorkspace();
330
- }
331
- }
332
- exports.WorkspaceGenerator = WorkspaceGenerator;
333
-
334
- //# sourceMappingURL=workspace-generator.js.map