@teambit/workspace-starter 0.0.1
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/.npmignore +18 -0
- package/dist/exceptions/workspace-path-exists.d.ts +5 -0
- package/dist/exceptions/workspace-path-exists.js +22 -0
- package/dist/exceptions/workspace-path-exists.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/new.cmd.d.ts +29 -0
- package/dist/new.cmd.js +100 -0
- package/dist/new.cmd.js.map +1 -0
- package/dist/preview-1790978765250.js +7 -0
- package/dist/workspace-generator.d.ts +45 -0
- package/dist/workspace-generator.js +341 -0
- package/dist/workspace-generator.js.map +1 -0
- package/dist/workspace-starter.aspect.d.ts +2 -0
- package/dist/workspace-starter.aspect.js +18 -0
- package/dist/workspace-starter.aspect.js.map +1 -0
- package/dist/workspace-starter.main.runtime.d.ts +37 -0
- package/dist/workspace-starter.main.runtime.js +160 -0
- package/dist/workspace-starter.main.runtime.js.map +1 -0
- package/exceptions/workspace-path-exists.ts +7 -0
- package/package.json +72 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +46 -0
package/.npmignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
dist/tsconfig.tsbuildinfo
|
|
2
|
+
dist/tsconfig.json
|
|
3
|
+
/tsconfig.json
|
|
4
|
+
|
|
5
|
+
package-tar/
|
|
6
|
+
.bit-capsule-ready
|
|
7
|
+
/*.ts
|
|
8
|
+
artifacts/*
|
|
9
|
+
!artifacts/env-template
|
|
10
|
+
!artifacts/ui-bundle
|
|
11
|
+
!artifacts/preview-bundle
|
|
12
|
+
package-tar/
|
|
13
|
+
.bit-capsule-ready
|
|
14
|
+
/*.ts
|
|
15
|
+
artifacts/*
|
|
16
|
+
!artifacts/env-template
|
|
17
|
+
!artifacts/ui-bundle
|
|
18
|
+
!artifacts/preview-bundle
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WorkspaceStarterAspect } from './workspace-starter.aspect';
|
|
2
|
+
export type { WorkspaceStarterMain, GenerateWorkspaceTemplateResult } from './workspace-starter.main.runtime';
|
|
3
|
+
export type { NewOptions } from './new.cmd';
|
|
4
|
+
export default WorkspaceStarterAspect;
|
|
5
|
+
export { WorkspaceStarterAspect };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "WorkspaceStarterAspect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _workspaceStarter().WorkspaceStarterAspect;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
function _workspaceStarter() {
|
|
14
|
+
const data = require("./workspace-starter.aspect");
|
|
15
|
+
_workspaceStarter = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
var _default = exports.default = _workspaceStarter().WorkspaceStarterAspect;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_workspaceStarter","data","require","_default","exports","default","WorkspaceStarterAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceStarterAspect } from './workspace-starter.aspect';\n\nexport type { WorkspaceStarterMain, GenerateWorkspaceTemplateResult } from './workspace-starter.main.runtime';\nexport type { NewOptions } from './new.cmd';\nexport default WorkspaceStarterAspect;\nexport { WorkspaceStarterAspect };\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,kBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,iBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoE,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAIrDC,0CAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import type { BaseWorkspaceOptions } from '@teambit/generator';
|
|
3
|
+
import type { WorkspaceStarterMain } from './workspace-starter.main.runtime';
|
|
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 workspaceStarter;
|
|
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(workspaceStarter: WorkspaceStarterMain);
|
|
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
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
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(workspaceStarter) {
|
|
31
|
+
this.workspaceStarter = workspaceStarter;
|
|
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.workspaceStarter.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
|
|
@@ -0,0 +1 @@
|
|
|
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","workspaceStarter","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 { BaseWorkspaceOptions } from '@teambit/generator';\nimport type { WorkspaceStarterMain } from './workspace-starter.main.runtime';\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 workspaceStarter: WorkspaceStarterMain) {}\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.workspaceStarter.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;AACA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CA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AAE;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":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Component } from '@teambit/component';
|
|
2
|
+
import type { ComponentID } from '@teambit/component-id';
|
|
3
|
+
import type { WorkspaceTemplate, BitApi } from '@teambit/generator';
|
|
4
|
+
import type { NewOptions } from './new.cmd';
|
|
5
|
+
export type GenerateResult = {
|
|
6
|
+
id: ComponentID;
|
|
7
|
+
dir: string;
|
|
8
|
+
files: string[];
|
|
9
|
+
envId: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class WorkspaceGenerator {
|
|
12
|
+
private workspaceName;
|
|
13
|
+
private workspacePath;
|
|
14
|
+
private options;
|
|
15
|
+
private template;
|
|
16
|
+
private bitApi;
|
|
17
|
+
private aspectComponent?;
|
|
18
|
+
private harmony;
|
|
19
|
+
private workspace;
|
|
20
|
+
private install;
|
|
21
|
+
private importer;
|
|
22
|
+
private logger?;
|
|
23
|
+
private forking;
|
|
24
|
+
private git;
|
|
25
|
+
private wsConfigFiles;
|
|
26
|
+
private generator;
|
|
27
|
+
constructor(workspaceName: string, workspacePath: string, options: NewOptions & {
|
|
28
|
+
currentDir?: boolean;
|
|
29
|
+
}, template: WorkspaceTemplate, bitApi: BitApi, aspectComponent?: Component | undefined);
|
|
30
|
+
generate(): Promise<string>;
|
|
31
|
+
private initGit;
|
|
32
|
+
private setupGitBitmapMergeDriver;
|
|
33
|
+
private buildUI;
|
|
34
|
+
private getWorkspaceContext;
|
|
35
|
+
/**
|
|
36
|
+
* writes the generated template files to the default directory set in the workspace config
|
|
37
|
+
*/
|
|
38
|
+
private writeWorkspaceFiles;
|
|
39
|
+
private reloadBitInWorkspaceDir;
|
|
40
|
+
private installBeforeCreateComponentsIfNeeded;
|
|
41
|
+
private createComponentsFromRemote;
|
|
42
|
+
private forkComponentsFromRemote;
|
|
43
|
+
private importComponentsFromRemote;
|
|
44
|
+
private compileComponents;
|
|
45
|
+
}
|
|
@@ -0,0 +1,341 @@
|
|
|
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("@teambit/generator");
|
|
121
|
+
_generator = function () {
|
|
122
|
+
return data;
|
|
123
|
+
};
|
|
124
|
+
return data;
|
|
125
|
+
}
|
|
126
|
+
function _workspaceStarter() {
|
|
127
|
+
const data = require("./workspace-starter.aspect");
|
|
128
|
+
_workspaceStarter = function () {
|
|
129
|
+
return data;
|
|
130
|
+
};
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
134
|
+
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; }
|
|
135
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
136
|
+
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';
|
|
137
|
+
class WorkspaceGenerator {
|
|
138
|
+
constructor(workspaceName, workspacePath, options, template, bitApi, aspectComponent) {
|
|
139
|
+
this.workspaceName = workspaceName;
|
|
140
|
+
this.workspacePath = workspacePath;
|
|
141
|
+
this.options = options;
|
|
142
|
+
this.template = template;
|
|
143
|
+
this.bitApi = bitApi;
|
|
144
|
+
this.aspectComponent = aspectComponent;
|
|
145
|
+
_defineProperty(this, "harmony", void 0);
|
|
146
|
+
_defineProperty(this, "workspace", void 0);
|
|
147
|
+
_defineProperty(this, "install", void 0);
|
|
148
|
+
_defineProperty(this, "importer", void 0);
|
|
149
|
+
_defineProperty(this, "logger", void 0);
|
|
150
|
+
_defineProperty(this, "forking", void 0);
|
|
151
|
+
_defineProperty(this, "git", void 0);
|
|
152
|
+
_defineProperty(this, "wsConfigFiles", void 0);
|
|
153
|
+
_defineProperty(this, "generator", void 0);
|
|
154
|
+
}
|
|
155
|
+
async generate() {
|
|
156
|
+
await _fsExtra().default.ensureDir(this.workspacePath);
|
|
157
|
+
try {
|
|
158
|
+
process.chdir(this.workspacePath);
|
|
159
|
+
await this.initGit();
|
|
160
|
+
const agentType = this.options.agent || undefined;
|
|
161
|
+
await _hostInitializer().HostInitializerMain.init(this.workspacePath, this.options.skipGit, false, false, false, false, false, false, false, {}, undefined, agentType);
|
|
162
|
+
await this.writeWorkspaceFiles();
|
|
163
|
+
// Write agent instructions with skipGitCheck since bit new always creates a fresh workspace.
|
|
164
|
+
// When --skip-git is used, init() already wrote the file; hasExistingAgentFile() prevents a duplicate.
|
|
165
|
+
await _hostInitializer().HostInitializerMain.writeAgentInstructions(this.workspacePath, agentType, true);
|
|
166
|
+
await this.reloadBitInWorkspaceDir();
|
|
167
|
+
// Setting the workspace to be in install context to prevent errors during the workspace generation
|
|
168
|
+
// the workspace will be in install context until the end of the generation install process
|
|
169
|
+
this.workspace.inInstallContext = true;
|
|
170
|
+
await this.setupGitBitmapMergeDriver();
|
|
171
|
+
await this.forkComponentsFromRemote();
|
|
172
|
+
await this.installBeforeCreateComponentsIfNeeded();
|
|
173
|
+
await this.createComponentsFromRemote();
|
|
174
|
+
await this.importComponentsFromRemote();
|
|
175
|
+
await this.workspace.clearCache();
|
|
176
|
+
await this.install.install(undefined, {
|
|
177
|
+
dedupe: true,
|
|
178
|
+
import: false,
|
|
179
|
+
copyPeerToRuntimeOnRoot: true,
|
|
180
|
+
copyPeerToRuntimeOnComponents: false,
|
|
181
|
+
updateExisting: false
|
|
182
|
+
// This is not needed anymore since PR:
|
|
183
|
+
// keep it here for a while to make sure it doesn't break anything
|
|
184
|
+
// skip pruning here to prevent cases which it caused an error about
|
|
185
|
+
// tsconfig not found because the env location was changed
|
|
186
|
+
// skipPrune: true,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// compile the components again now that we have the dependencies installed
|
|
190
|
+
await this.compileComponents(true);
|
|
191
|
+
await this.wsConfigFiles.writeConfigFiles({});
|
|
192
|
+
} catch (err) {
|
|
193
|
+
this.logger?.error(`failed generating a new workspace, will delete the dir ${this.workspacePath}`, err);
|
|
194
|
+
await _fsExtra().default.remove(this.workspacePath);
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
197
|
+
return this.workspacePath;
|
|
198
|
+
}
|
|
199
|
+
async initGit() {
|
|
200
|
+
if (this.options.skipGit) return;
|
|
201
|
+
const gitExecutablePath = (0, _gitModules().getGitExecutablePath)();
|
|
202
|
+
const params = ['init'];
|
|
203
|
+
try {
|
|
204
|
+
await (0, _execa().default)(gitExecutablePath, params);
|
|
205
|
+
} catch (err) {
|
|
206
|
+
if (err.exitCodeName === 'ENOENT') {
|
|
207
|
+
throw new (_gitModules().GitNotFound)(gitExecutablePath, err);
|
|
208
|
+
}
|
|
209
|
+
throw err;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async setupGitBitmapMergeDriver() {
|
|
213
|
+
if (this.options.skipGit) return;
|
|
214
|
+
await this.git.setGitMergeDriver({
|
|
215
|
+
global: false
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
async buildUI() {
|
|
219
|
+
const uiMain = this.harmony.get(_ui().UIAspect.id);
|
|
220
|
+
await uiMain.createRuntime({});
|
|
221
|
+
}
|
|
222
|
+
getWorkspaceContext() {
|
|
223
|
+
return {
|
|
224
|
+
name: this.workspaceName,
|
|
225
|
+
defaultScope: this.options.defaultScope,
|
|
226
|
+
empty: this.options.empty,
|
|
227
|
+
aspectComponent: this.aspectComponent,
|
|
228
|
+
template: this.template,
|
|
229
|
+
skipGit: this.options.skipGit
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* writes the generated template files to the default directory set in the workspace config
|
|
235
|
+
*/
|
|
236
|
+
async writeWorkspaceFiles() {
|
|
237
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
238
|
+
const templateFiles = await this.template.generateFiles(workspaceContext);
|
|
239
|
+
await Promise.all(templateFiles.map(async templateFile => {
|
|
240
|
+
await _fsExtra().default.outputFile((0, _path().join)(this.workspacePath, templateFile.relativePath), templateFile.content);
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
async reloadBitInWorkspaceDir() {
|
|
244
|
+
this.harmony = await this.bitApi.loadBit(this.workspacePath);
|
|
245
|
+
this.workspace = this.harmony.get(_workspace().WorkspaceAspect.id);
|
|
246
|
+
this.install = this.harmony.get(_install().InstallAspect.id);
|
|
247
|
+
const loggerMain = this.harmony.get(_logger().LoggerAspect.id);
|
|
248
|
+
this.logger = loggerMain.createLogger(_workspaceStarter().WorkspaceStarterAspect.id);
|
|
249
|
+
this.importer = this.harmony.get(_importer().ImporterAspect.id);
|
|
250
|
+
this.forking = this.harmony.get(_forking().ForkingAspect.id);
|
|
251
|
+
this.git = this.harmony.get(_git().GitAspect.id);
|
|
252
|
+
this.wsConfigFiles = this.harmony.get(_workspaceConfigFiles().WorkspaceConfigFilesAspect.id);
|
|
253
|
+
this.generator = this.harmony.get(_generator().GeneratorAspect.id);
|
|
254
|
+
}
|
|
255
|
+
async installBeforeCreateComponentsIfNeeded() {
|
|
256
|
+
if (this.options.empty || !this.template.create) return;
|
|
257
|
+
const configuredEnvs = this.generator.getConfiguredEnvs();
|
|
258
|
+
if (!configuredEnvs.length) return;
|
|
259
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
260
|
+
const componentsToCreate = this.template.create(workspaceContext);
|
|
261
|
+
const aspectsForComponentsToCreate = (0, _lodash().compact)(componentsToCreate.map(componentToCreate => componentToCreate.aspect));
|
|
262
|
+
const needInstall = (0, _lodash().some)(aspectsForComponentsToCreate, aspect => {
|
|
263
|
+
return configuredEnvs.includes(aspect);
|
|
264
|
+
});
|
|
265
|
+
if (needInstall) {
|
|
266
|
+
this.logger?.console(`installing dependencies in workspace using to load components templates from the following envs: ${configuredEnvs.join(', ')}`);
|
|
267
|
+
await this.install.install(undefined, {
|
|
268
|
+
dedupe: true,
|
|
269
|
+
import: false,
|
|
270
|
+
copyPeerToRuntimeOnRoot: true,
|
|
271
|
+
copyPeerToRuntimeOnComponents: false,
|
|
272
|
+
updateExisting: false
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
async createComponentsFromRemote() {
|
|
277
|
+
if (this.options.empty || !this.template.create) return;
|
|
278
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
279
|
+
const componentsToCreate = this.template.create(workspaceContext);
|
|
280
|
+
await (0, _pMapSeries().default)(componentsToCreate, async componentToCreate => {
|
|
281
|
+
return this.generator.generateComponentTemplate([componentToCreate.componentName], componentToCreate.templateName, {
|
|
282
|
+
aspect: componentToCreate.aspect,
|
|
283
|
+
env: componentToCreate.env,
|
|
284
|
+
path: componentToCreate.path,
|
|
285
|
+
scope: componentToCreate.scope
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async forkComponentsFromRemote() {
|
|
290
|
+
if (this.options.empty) return;
|
|
291
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
292
|
+
const componentsToFork = this.template?.importComponents?.(workspaceContext) || this.template?.fork?.(workspaceContext) || [];
|
|
293
|
+
if (!componentsToFork.length) return;
|
|
294
|
+
const componentsToForkRestructured = componentsToFork.map(({
|
|
295
|
+
id,
|
|
296
|
+
targetName,
|
|
297
|
+
path,
|
|
298
|
+
env,
|
|
299
|
+
config,
|
|
300
|
+
targetScope
|
|
301
|
+
}) => ({
|
|
302
|
+
sourceId: id,
|
|
303
|
+
targetId: targetName,
|
|
304
|
+
targetScope,
|
|
305
|
+
path,
|
|
306
|
+
env,
|
|
307
|
+
config
|
|
308
|
+
}));
|
|
309
|
+
await this.forking.forkMultipleFromRemote(componentsToForkRestructured, {
|
|
310
|
+
scope: this.workspace.defaultScope,
|
|
311
|
+
refactor: true,
|
|
312
|
+
install: false,
|
|
313
|
+
compile: false
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
async importComponentsFromRemote() {
|
|
317
|
+
if (this.options.empty) return;
|
|
318
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
319
|
+
const componentsToImport = this.template?.import?.(workspaceContext) || [];
|
|
320
|
+
if (!componentsToImport.length) return;
|
|
321
|
+
await (0, _pMapSeries().default)(componentsToImport, async componentToImport => {
|
|
322
|
+
await this.importer.import({
|
|
323
|
+
ids: [componentToImport.id],
|
|
324
|
+
installNpmPackages: false,
|
|
325
|
+
writeConfigFiles: false,
|
|
326
|
+
writeToPath: componentToImport.path
|
|
327
|
+
}, []);
|
|
328
|
+
});
|
|
329
|
+
await this.workspace.bitMap.write('new');
|
|
330
|
+
}
|
|
331
|
+
async compileComponents(clearCache = true) {
|
|
332
|
+
if (clearCache) {
|
|
333
|
+
await this.workspace.clearCache();
|
|
334
|
+
}
|
|
335
|
+
const compiler = this.harmony.get(_compiler().CompilerAspect.id);
|
|
336
|
+
await compiler.compileOnWorkspace();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
exports.WorkspaceGenerator = WorkspaceGenerator;
|
|
340
|
+
|
|
341
|
+
//# sourceMappingURL=workspace-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_execa","_pMapSeries","_ui","_logger","_workspace","_forking","_importer","_compiler","_gitModules","_path","_lodash","_git","_install","_hostInitializer","_workspaceConfigFiles","_generator","_workspaceStarter","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","WorkspaceGenerator","constructor","workspaceName","workspacePath","options","template","bitApi","aspectComponent","generate","fs","ensureDir","process","chdir","initGit","agentType","agent","undefined","HostInitializerMain","init","skipGit","writeWorkspaceFiles","writeAgentInstructions","reloadBitInWorkspaceDir","workspace","inInstallContext","setupGitBitmapMergeDriver","forkComponentsFromRemote","installBeforeCreateComponentsIfNeeded","createComponentsFromRemote","importComponentsFromRemote","clearCache","install","dedupe","import","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","updateExisting","compileComponents","wsConfigFiles","writeConfigFiles","err","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","WorkspaceStarterAspect","importer","ImporterAspect","forking","ForkingAspect","GitAspect","WorkspaceConfigFilesAspect","generator","GeneratorAspect","create","configuredEnvs","getConfiguredEnvs","length","componentsToCreate","aspectsForComponentsToCreate","compact","componentToCreate","aspect","needInstall","some","includes","console","pMapSeries","generateComponentTemplate","componentName","templateName","env","path","scope","componentsToFork","importComponents","fork","componentsToForkRestructured","targetName","config","targetScope","sourceId","targetId","forkMultipleFromRemote","refactor","compile","componentsToImport","componentToImport","ids","installNpmPackages","writeToPath","bitMap","write","compiler","CompilerAspect","compileOnWorkspace","exports"],"sources":["workspace-generator.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport type { Harmony } from '@teambit/harmony';\nimport type { Component } from '@teambit/component';\nimport execa from 'execa';\nimport pMapSeries from 'p-map-series';\nimport type { UiMain } from '@teambit/ui';\nimport { UIAspect } from '@teambit/ui';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { ForkingMain } from '@teambit/forking';\nimport { ForkingAspect } from '@teambit/forking';\nimport type { ImporterMain } from '@teambit/importer';\nimport { ImporterAspect } from '@teambit/importer';\nimport type { CompilerMain } from '@teambit/compiler';\nimport { CompilerAspect } from '@teambit/compiler';\nimport { getGitExecutablePath, GitNotFound } from '@teambit/git.modules.git-executable';\nimport { join } from 'path';\nimport { compact, some } from 'lodash';\nimport type { ComponentID } from '@teambit/component-id';\nimport type { GitMain } from '@teambit/git';\nimport { GitAspect } from '@teambit/git';\nimport type { InstallMain } from '@teambit/install';\nimport { InstallAspect } from '@teambit/install';\nimport { HostInitializerMain } from '@teambit/host-initializer';\nimport type { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\nimport { WorkspaceConfigFilesAspect } from '@teambit/workspace-config-files';\n// import { ComponentGenerator } from './component-generator';\nimport type { WorkspaceTemplate, WorkspaceContext, BitApi, GeneratorMain } from '@teambit/generator';\nimport { GeneratorAspect } from '@teambit/generator';\nimport type { NewOptions } from './new.cmd';\nimport { WorkspaceStarterAspect } from './workspace-starter.aspect';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string };\n\nexport class WorkspaceGenerator {\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 generator: GeneratorMain;\n\n constructor(\n private workspaceName: string,\n private workspacePath: string,\n private options: NewOptions & { currentDir?: boolean },\n private template: WorkspaceTemplate,\n private bitApi: BitApi,\n private aspectComponent?: Component\n ) {}\n\n async generate(): Promise<string> {\n await fs.ensureDir(this.workspacePath);\n try {\n process.chdir(this.workspacePath);\n await this.initGit();\n const agentType = this.options.agent || undefined;\n await HostInitializerMain.init(\n this.workspacePath,\n this.options.skipGit,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n {},\n undefined,\n agentType\n );\n await this.writeWorkspaceFiles();\n // Write agent instructions with skipGitCheck since bit new always creates a fresh workspace.\n // When --skip-git is used, init() already wrote the file; hasExistingAgentFile() prevents a duplicate.\n await HostInitializerMain.writeAgentInstructions(this.workspacePath, agentType, true);\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.installBeforeCreateComponentsIfNeeded();\n await this.createComponentsFromRemote();\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 // This is not needed anymore since PR:\n // keep it here for a while to make sure it doesn't break anything\n // skip pruning here to prevent cases which it caused an error about\n // tsconfig not found because the env location was changed\n // skipPrune: true,\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 this.bitApi.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(WorkspaceStarterAspect.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 this.generator = this.harmony.get<GeneratorMain>(GeneratorAspect.id);\n }\n\n private async installBeforeCreateComponentsIfNeeded() {\n if (this.options.empty || !this.template.create) return;\n const configuredEnvs = this.generator.getConfiguredEnvs();\n if (!configuredEnvs.length) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToCreate = this.template.create(workspaceContext);\n const aspectsForComponentsToCreate = compact(\n componentsToCreate.map((componentToCreate) => componentToCreate.aspect)\n );\n const needInstall = some(aspectsForComponentsToCreate, (aspect) => {\n return configuredEnvs.includes(aspect);\n });\n if (needInstall) {\n this.logger?.console(\n `installing dependencies in workspace using to load components templates from the following envs: ${configuredEnvs.join(\n ', '\n )}`\n );\n await this.install.install(undefined, {\n dedupe: true,\n import: false,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n updateExisting: false,\n });\n }\n }\n\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 return this.generator.generateComponentTemplate(\n [componentToCreate.componentName],\n componentToCreate.templateName,\n {\n aspect: componentToCreate.aspect,\n env: componentToCreate.env,\n path: componentToCreate.path,\n scope: componentToCreate.scope,\n }\n );\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, targetScope }) => ({\n sourceId: id,\n targetId: targetName,\n targetScope,\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 compile: 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 writeConfigFiles: false,\n writeToPath: componentToImport.path,\n },\n []\n );\n });\n\n await this.workspace.bitMap.write('new');\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;AAGA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,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,MAAMmG,QAAQ,GAAG,IAAI,CAAC1E,OAAO,CAACC,GAAG,CAAe0E,0BAAc,CAACxE,EAAE,CAAC;IAClE,MAAMuE,QAAQ,CAACE,kBAAkB,CAAC,CAAC;EACrC;AACF;AAACC,OAAA,CAAApI,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WorkspaceStarterAspect = void 0;
|
|
7
|
+
function _harmony() {
|
|
8
|
+
const data = require("@teambit/harmony");
|
|
9
|
+
_harmony = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
const WorkspaceStarterAspect = exports.WorkspaceStarterAspect = _harmony().Aspect.create({
|
|
15
|
+
id: 'teambit.generator/workspace-starter'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=workspace-starter.aspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_harmony","data","require","WorkspaceStarterAspect","exports","Aspect","create","id"],"sources":["workspace-starter.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const WorkspaceStarterAspect = Aspect.create({\n id: 'teambit.generator/workspace-starter',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EAClDC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CLIMain } from '@teambit/cli';
|
|
2
|
+
import type { Workspace } from '@teambit/workspace';
|
|
3
|
+
import type { GeneratorMain } from '@teambit/generator';
|
|
4
|
+
import type { DeprecationMain } from '@teambit/deprecation';
|
|
5
|
+
import type { Logger, LoggerMain } from '@teambit/logger';
|
|
6
|
+
import type { NewOptions } from './new.cmd';
|
|
7
|
+
export type GenerateWorkspaceTemplateResult = {
|
|
8
|
+
workspacePath: string;
|
|
9
|
+
appName?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* creates new workspaces from the workspace templates (starters) registered to the generator ("bit new").
|
|
13
|
+
* it's separated from the generator because it uses aspects that themselves depend on the generator.
|
|
14
|
+
*/
|
|
15
|
+
export declare class WorkspaceStarterMain {
|
|
16
|
+
private generator;
|
|
17
|
+
private workspace;
|
|
18
|
+
private deprecation;
|
|
19
|
+
private logger;
|
|
20
|
+
constructor(generator: GeneratorMain, workspace: Workspace, deprecation: DeprecationMain, logger: Logger);
|
|
21
|
+
generateWorkspaceTemplate(workspaceName: string, templateName: string, options: NewOptions & {
|
|
22
|
+
aspect?: string;
|
|
23
|
+
currentDir?: boolean;
|
|
24
|
+
}): Promise<GenerateWorkspaceTemplateResult>;
|
|
25
|
+
private warnAboutDeprecation;
|
|
26
|
+
static slots: never[];
|
|
27
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
28
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
29
|
+
static provider([cli, generator, workspace, deprecation, loggerMain]: [
|
|
30
|
+
CLIMain,
|
|
31
|
+
GeneratorMain,
|
|
32
|
+
Workspace,
|
|
33
|
+
DeprecationMain,
|
|
34
|
+
LoggerMain
|
|
35
|
+
]): Promise<WorkspaceStarterMain>;
|
|
36
|
+
}
|
|
37
|
+
export default WorkspaceStarterMain;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WorkspaceStarterMain = 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 _path() {
|
|
15
|
+
const data = require("path");
|
|
16
|
+
_path = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _harmonyModules() {
|
|
22
|
+
const data = require("@teambit/harmony.modules.runtimes");
|
|
23
|
+
_harmonyModules = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _cli() {
|
|
29
|
+
const data = require("@teambit/cli");
|
|
30
|
+
_cli = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _workspace() {
|
|
36
|
+
const data = require("@teambit/workspace");
|
|
37
|
+
_workspace = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _generator() {
|
|
43
|
+
const data = require("@teambit/generator");
|
|
44
|
+
_generator = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _deprecation() {
|
|
50
|
+
const data = require("@teambit/deprecation");
|
|
51
|
+
_deprecation = function () {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
function _logger() {
|
|
57
|
+
const data = require("@teambit/logger");
|
|
58
|
+
_logger = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
function _bitError() {
|
|
64
|
+
const data = require("@teambit/bit-error");
|
|
65
|
+
_bitError = function () {
|
|
66
|
+
return data;
|
|
67
|
+
};
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
function _workspaceStarter() {
|
|
71
|
+
const data = require("./workspace-starter.aspect");
|
|
72
|
+
_workspaceStarter = function () {
|
|
73
|
+
return data;
|
|
74
|
+
};
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
function _new() {
|
|
78
|
+
const data = require("./new.cmd");
|
|
79
|
+
_new = function () {
|
|
80
|
+
return data;
|
|
81
|
+
};
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
84
|
+
function _workspaceGenerator() {
|
|
85
|
+
const data = require("./workspace-generator");
|
|
86
|
+
_workspaceGenerator = function () {
|
|
87
|
+
return data;
|
|
88
|
+
};
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
91
|
+
function _workspacePathExists() {
|
|
92
|
+
const data = require("./exceptions/workspace-path-exists");
|
|
93
|
+
_workspacePathExists = function () {
|
|
94
|
+
return data;
|
|
95
|
+
};
|
|
96
|
+
return data;
|
|
97
|
+
}
|
|
98
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
99
|
+
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; }
|
|
100
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
101
|
+
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); }
|
|
102
|
+
/**
|
|
103
|
+
* creates new workspaces from the workspace templates (starters) registered to the generator ("bit new").
|
|
104
|
+
* it's separated from the generator because it uses aspects that themselves depend on the generator.
|
|
105
|
+
*/
|
|
106
|
+
class WorkspaceStarterMain {
|
|
107
|
+
constructor(generator, workspace, deprecation, logger) {
|
|
108
|
+
this.generator = generator;
|
|
109
|
+
this.workspace = workspace;
|
|
110
|
+
this.deprecation = deprecation;
|
|
111
|
+
this.logger = logger;
|
|
112
|
+
}
|
|
113
|
+
async generateWorkspaceTemplate(workspaceName, templateName, options) {
|
|
114
|
+
if (this.workspace) {
|
|
115
|
+
throw new (_bitError().BitError)('Error: unable to generate a new workspace inside of an existing workspace');
|
|
116
|
+
}
|
|
117
|
+
const workspacePath = options.currentDir ? process.cwd() : (0, _path().resolve)(workspaceName);
|
|
118
|
+
if (!options.currentDir && _fsExtra().default.existsSync(workspacePath)) {
|
|
119
|
+
throw new (_workspacePathExists().WorkspacePathExists)(workspacePath);
|
|
120
|
+
}
|
|
121
|
+
const {
|
|
122
|
+
aspect: aspectId,
|
|
123
|
+
loadFrom
|
|
124
|
+
} = options;
|
|
125
|
+
const {
|
|
126
|
+
workspaceTemplate,
|
|
127
|
+
aspect
|
|
128
|
+
} = loadFrom ? await this.generator.findTemplateInOtherWorkspace(loadFrom, templateName, aspectId) : await this.generator.getWorkspaceTemplate(templateName, aspectId);
|
|
129
|
+
if (!workspaceTemplate) throw new (_bitError().BitError)(`template "${templateName}" was not found`);
|
|
130
|
+
const workspaceGenerator = new (_workspaceGenerator().WorkspaceGenerator)(workspaceName, workspacePath, options, workspaceTemplate, this.generator.getBitApi(), aspect);
|
|
131
|
+
await this.warnAboutDeprecation(aspect);
|
|
132
|
+
await workspaceGenerator.generate();
|
|
133
|
+
return {
|
|
134
|
+
workspacePath,
|
|
135
|
+
appName: workspaceTemplate.appName
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async warnAboutDeprecation(aspect) {
|
|
139
|
+
if (!aspect) return;
|
|
140
|
+
const deprecationInfo = await this.deprecation.getDeprecationInfo(aspect);
|
|
141
|
+
if (deprecationInfo.isDeprecate) {
|
|
142
|
+
const newStarterMsg = deprecationInfo.newId ? `, use "${deprecationInfo.newId.toString()}" instead` : '';
|
|
143
|
+
this.logger.consoleWarning(`the starter "${aspect?.id.toString()}" is deprecated${newStarterMsg}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
static async provider([cli, generator, workspace, deprecation, loggerMain]) {
|
|
147
|
+
const logger = loggerMain.createLogger(_workspaceStarter().WorkspaceStarterAspect.id);
|
|
148
|
+
const workspaceStarter = new WorkspaceStarterMain(generator, workspace, deprecation, logger);
|
|
149
|
+
cli.register(new (_new().NewCmd)(workspaceStarter));
|
|
150
|
+
return workspaceStarter;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.WorkspaceStarterMain = WorkspaceStarterMain;
|
|
154
|
+
_defineProperty(WorkspaceStarterMain, "slots", []);
|
|
155
|
+
_defineProperty(WorkspaceStarterMain, "dependencies", [_cli().CLIAspect, _generator().GeneratorAspect, _workspace().WorkspaceAspect, _deprecation().DeprecationAspect, _logger().LoggerAspect]);
|
|
156
|
+
_defineProperty(WorkspaceStarterMain, "runtime", _harmonyModules().MainRuntime);
|
|
157
|
+
_workspaceStarter().WorkspaceStarterAspect.addRuntime(WorkspaceStarterMain);
|
|
158
|
+
var _default = exports.default = WorkspaceStarterMain;
|
|
159
|
+
|
|
160
|
+
//# sourceMappingURL=workspace-starter.main.runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_harmonyModules","_cli","_workspace","_generator","_deprecation","_logger","_bitError","_workspaceStarter","_new","_workspaceGenerator","_workspacePathExists","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","WorkspaceStarterMain","constructor","generator","workspace","deprecation","logger","generateWorkspaceTemplate","workspaceName","templateName","options","BitError","workspacePath","currentDir","process","cwd","resolve","fs","existsSync","WorkspacePathExists","aspect","aspectId","loadFrom","workspaceTemplate","findTemplateInOtherWorkspace","getWorkspaceTemplate","workspaceGenerator","WorkspaceGenerator","getBitApi","warnAboutDeprecation","generate","appName","deprecationInfo","getDeprecationInfo","isDeprecate","newStarterMsg","newId","toString","consoleWarning","id","provider","cli","loggerMain","createLogger","WorkspaceStarterAspect","workspaceStarter","register","NewCmd","exports","CLIAspect","GeneratorAspect","WorkspaceAspect","DeprecationAspect","LoggerAspect","MainRuntime","addRuntime","_default"],"sources":["workspace-starter.main.runtime.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { resolve } from 'path';\nimport { MainRuntime } from '@teambit/harmony.modules.runtimes';\nimport type { CLIMain } from '@teambit/cli';\nimport { CLIAspect } from '@teambit/cli';\nimport type { Component } from '@teambit/component';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { GeneratorMain } from '@teambit/generator';\nimport { GeneratorAspect } from '@teambit/generator';\nimport type { DeprecationMain } from '@teambit/deprecation';\nimport { DeprecationAspect } from '@teambit/deprecation';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { WorkspaceStarterAspect } from './workspace-starter.aspect';\nimport { NewCmd } from './new.cmd';\nimport type { NewOptions } from './new.cmd';\nimport { WorkspaceGenerator } from './workspace-generator';\nimport { WorkspacePathExists } from './exceptions/workspace-path-exists';\n\nexport type GenerateWorkspaceTemplateResult = { workspacePath: string; appName?: string };\n\n/**\n * creates new workspaces from the workspace templates (starters) registered to the generator (\"bit new\").\n * it's separated from the generator because it uses aspects that themselves depend on the generator.\n */\nexport class WorkspaceStarterMain {\n constructor(\n private generator: GeneratorMain,\n private workspace: Workspace,\n private deprecation: DeprecationMain,\n private logger: Logger\n ) {}\n\n async generateWorkspaceTemplate(\n workspaceName: string,\n templateName: string,\n options: NewOptions & { aspect?: string; currentDir?: boolean }\n ): Promise<GenerateWorkspaceTemplateResult> {\n if (this.workspace) {\n throw new BitError('Error: unable to generate a new workspace inside of an existing workspace');\n }\n const workspacePath = options.currentDir ? process.cwd() : resolve(workspaceName);\n if (!options.currentDir && fs.existsSync(workspacePath)) {\n throw new WorkspacePathExists(workspacePath);\n }\n const { aspect: aspectId, loadFrom } = options;\n const { workspaceTemplate, aspect } = loadFrom\n ? await this.generator.findTemplateInOtherWorkspace(loadFrom, templateName, aspectId)\n : await this.generator.getWorkspaceTemplate(templateName, aspectId);\n\n if (!workspaceTemplate) throw new BitError(`template \"${templateName}\" was not found`);\n const workspaceGenerator = new WorkspaceGenerator(\n workspaceName,\n workspacePath,\n options,\n workspaceTemplate,\n this.generator.getBitApi(),\n aspect\n );\n await this.warnAboutDeprecation(aspect);\n await workspaceGenerator.generate();\n return { workspacePath, appName: workspaceTemplate.appName };\n }\n\n private async warnAboutDeprecation(aspect?: Component) {\n if (!aspect) return;\n const deprecationInfo = await this.deprecation.getDeprecationInfo(aspect);\n if (deprecationInfo.isDeprecate) {\n const newStarterMsg = deprecationInfo.newId ? `, use \"${deprecationInfo.newId.toString()}\" instead` : '';\n this.logger.consoleWarning(`the starter \"${aspect?.id.toString()}\" is deprecated${newStarterMsg}`);\n }\n }\n\n static slots = [];\n static dependencies = [CLIAspect, GeneratorAspect, WorkspaceAspect, DeprecationAspect, LoggerAspect];\n static runtime = MainRuntime;\n\n static async provider([cli, generator, workspace, deprecation, loggerMain]: [\n CLIMain,\n GeneratorMain,\n Workspace,\n DeprecationMain,\n LoggerMain,\n ]) {\n const logger = loggerMain.createLogger(WorkspaceStarterAspect.id);\n const workspaceStarter = new WorkspaceStarterMain(generator, workspace, deprecation, logger);\n cli.register(new NewCmd(workspaceStarter));\n return workspaceStarter;\n }\n}\n\nWorkspaceStarterAspect.addRuntime(WorkspaceStarterMain);\n\nexport default WorkspaceStarterMain;\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,MAAA;EAAA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CAACtD,oBAAoB,CAAC;AAAC,IAAAuD,QAAA,GAAAR,OAAA,CAAAlE,OAAA,GAEzCmB,oBAAoB","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/workspace-starter",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"componentId": {
|
|
6
|
+
"name": "workspace-starter",
|
|
7
|
+
"version": "0.0.1",
|
|
8
|
+
"scope": "teambit.generator"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"chalk": "4.1.2",
|
|
12
|
+
"execa": "2.1.0",
|
|
13
|
+
"fs-extra": "10.0.0",
|
|
14
|
+
"lodash": "4.17.21",
|
|
15
|
+
"p-map-series": "2.1.0",
|
|
16
|
+
"@teambit/cli": "0.0.1406",
|
|
17
|
+
"@teambit/component-id": "1.2.4",
|
|
18
|
+
"@teambit/git.modules.git-executable": "0.0.47",
|
|
19
|
+
"@teambit/harmony": "0.4.12",
|
|
20
|
+
"@teambit/host-initializer": "0.0.911",
|
|
21
|
+
"@teambit/logger": "0.0.1494",
|
|
22
|
+
"@teambit/bit-error": "0.0.404",
|
|
23
|
+
"@teambit/harmony.modules.runtimes": "0.0.1",
|
|
24
|
+
"@teambit/generator": "1.0.1200",
|
|
25
|
+
"@teambit/compiler": "1.0.1199",
|
|
26
|
+
"@teambit/component": "1.0.1199",
|
|
27
|
+
"@teambit/forking": "1.0.1199",
|
|
28
|
+
"@teambit/git": "1.0.1199",
|
|
29
|
+
"@teambit/importer": "1.0.1199",
|
|
30
|
+
"@teambit/install": "1.0.1199",
|
|
31
|
+
"@teambit/ui": "1.0.1199",
|
|
32
|
+
"@teambit/workspace-config-files": "1.0.1199",
|
|
33
|
+
"@teambit/workspace": "1.0.1199",
|
|
34
|
+
"@teambit/deprecation": "1.0.1199"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/fs-extra": "9.0.7",
|
|
38
|
+
"@types/lodash": "4.14.165",
|
|
39
|
+
"@teambit/harmony.envs.core-aspect-env": "2.1.1"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {},
|
|
42
|
+
"license": "Apache-2.0",
|
|
43
|
+
"optionalDependencies": {},
|
|
44
|
+
"peerDependenciesMeta": {},
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
48
|
+
"node": {
|
|
49
|
+
"require": "./dist/index.js"
|
|
50
|
+
},
|
|
51
|
+
"default": "./dist/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./dist/*": "./dist/*",
|
|
54
|
+
"./artifacts/*": "./artifacts/*"
|
|
55
|
+
},
|
|
56
|
+
"private": false,
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=16.0.0"
|
|
59
|
+
},
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "https://github.com/teambit/bit"
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"bit",
|
|
66
|
+
"bit-aspect",
|
|
67
|
+
"bit-core-aspect",
|
|
68
|
+
"components",
|
|
69
|
+
"collaboration",
|
|
70
|
+
"web"
|
|
71
|
+
]
|
|
72
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
|
30
|
+
declare module '*.otf' {
|
|
31
|
+
const value: any;
|
|
32
|
+
export = value;
|
|
33
|
+
}
|
|
34
|
+
declare module '*.woff' {
|
|
35
|
+
const value: any;
|
|
36
|
+
export = value;
|
|
37
|
+
}
|
|
38
|
+
declare module '*.woff2' {
|
|
39
|
+
const value: any;
|
|
40
|
+
export = value;
|
|
41
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// `reset-css` ships only `reset.css` (no `.d.ts`). TS6 refuses bare
|
|
45
|
+
// side-effect imports without declarations, so we declare the module here.
|
|
46
|
+
declare module 'reset-css';
|