@teambit/workspace 0.0.751 → 0.0.754
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capsule.cmd.d.ts +2 -3
- package/dist/capsule.cmd.js +4 -6
- package/dist/capsule.cmd.js.map +1 -1
- package/dist/install.cmd.d.ts +0 -1
- package/dist/install.cmd.js +0 -1
- package/dist/install.cmd.js.map +1 -1
- package/dist/link/link.cmd.d.ts +1 -1
- package/dist/link/link.cmd.js +3 -5
- package/dist/link/link.cmd.js.map +1 -1
- package/dist/uninstall.cmd.d.ts +0 -1
- package/dist/uninstall.cmd.js +0 -1
- package/dist/uninstall.cmd.js.map +1 -1
- package/dist/update.cmd.d.ts +0 -1
- package/dist/update.cmd.js +0 -1
- package/dist/update.cmd.js.map +1 -1
- package/dist/watch/watch.cmd.d.ts +2 -3
- package/dist/watch/watch.cmd.js +15 -6
- package/dist/watch/watch.cmd.js.map +1 -1
- package/dist/watch/watcher.d.ts +27 -8
- package/dist/watch/watcher.js +136 -44
- package/dist/watch/watcher.js.map +1 -1
- package/install.cmd.tsx +0 -1
- package/link/link.cmd.ts +3 -3
- package/package-tar/teambit-workspace-0.0.754.tgz +0 -0
- package/package.json +31 -31
- package/{preview-1654313169583.js → preview-1654658836872.js} +2 -2
- package/uninstall.cmd.tsx +0 -1
- package/update.cmd.tsx +0 -1
- package/watch/watch.cmd.tsx +25 -6
- package/watch/watcher.ts +104 -40
- package/package-tar/teambit-workspace-0.0.751.tgz +0 -0
package/dist/capsule.cmd.d.ts
CHANGED
|
@@ -30,7 +30,6 @@ export declare class CapsuleListCmd implements Command {
|
|
|
30
30
|
private workspace;
|
|
31
31
|
name: string;
|
|
32
32
|
description: string;
|
|
33
|
-
shortDescription: string;
|
|
34
33
|
group: string;
|
|
35
34
|
alias: string;
|
|
36
35
|
options: CommandOptions;
|
|
@@ -49,7 +48,7 @@ export declare class CapsuleDeleteCmd implements Command {
|
|
|
49
48
|
private workspace;
|
|
50
49
|
name: string;
|
|
51
50
|
description: string;
|
|
52
|
-
|
|
51
|
+
extendedDescription: string;
|
|
53
52
|
group: string;
|
|
54
53
|
alias: string;
|
|
55
54
|
options: CommandOptions;
|
|
@@ -61,8 +60,8 @@ export declare class CapsuleDeleteCmd implements Command {
|
|
|
61
60
|
}
|
|
62
61
|
export declare class CapsuleCmd implements Command {
|
|
63
62
|
name: string;
|
|
64
|
-
shortDescription: string;
|
|
65
63
|
description: string;
|
|
64
|
+
extendedDescription: string;
|
|
66
65
|
alias: string;
|
|
67
66
|
group: string;
|
|
68
67
|
commands: Command[];
|
package/dist/capsule.cmd.js
CHANGED
|
@@ -100,7 +100,6 @@ class CapsuleListCmd {
|
|
|
100
100
|
this.workspace = workspace;
|
|
101
101
|
(0, _defineProperty2().default)(this, "name", 'list');
|
|
102
102
|
(0, _defineProperty2().default)(this, "description", `list all capsules`);
|
|
103
|
-
(0, _defineProperty2().default)(this, "shortDescription", 'list all capsules');
|
|
104
103
|
(0, _defineProperty2().default)(this, "group", 'capsules');
|
|
105
104
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
106
105
|
(0, _defineProperty2().default)(this, "options", [['j', 'json', 'json format']]);
|
|
@@ -143,8 +142,8 @@ class CapsuleDeleteCmd {
|
|
|
143
142
|
this.isolator = isolator;
|
|
144
143
|
this.workspace = workspace;
|
|
145
144
|
(0, _defineProperty2().default)(this, "name", 'delete');
|
|
146
|
-
(0, _defineProperty2().default)(this, "description", `delete capsules
|
|
147
|
-
(0, _defineProperty2().default)(this, "
|
|
145
|
+
(0, _defineProperty2().default)(this, "description", `delete capsules`);
|
|
146
|
+
(0, _defineProperty2().default)(this, "extendedDescription", `with no args, only workspace's capsules are deleted`);
|
|
148
147
|
(0, _defineProperty2().default)(this, "group", 'capsules');
|
|
149
148
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
150
149
|
(0, _defineProperty2().default)(this, "options", [['', 'scope-aspects', 'delete scope-aspects capsules'], ['a', 'all', 'delete all capsules for all workspaces and scopes']]);
|
|
@@ -172,9 +171,8 @@ exports.CapsuleDeleteCmd = CapsuleDeleteCmd;
|
|
|
172
171
|
class CapsuleCmd {
|
|
173
172
|
constructor() {
|
|
174
173
|
(0, _defineProperty2().default)(this, "name", 'capsule <sub-command>');
|
|
175
|
-
(0, _defineProperty2().default)(this, "
|
|
176
|
-
(0, _defineProperty2().default)(this, "
|
|
177
|
-
a capsule is a directory contains the component code, isolated from the workspace.
|
|
174
|
+
(0, _defineProperty2().default)(this, "description", 'manage capsules');
|
|
175
|
+
(0, _defineProperty2().default)(this, "extendedDescription", `a capsule is a directory contains the component code, isolated from the workspace.
|
|
178
176
|
normally, capsules are created during the build process, the component files are copied and the packages are installed
|
|
179
177
|
via the configured package-manager. the purpose is to compile/test them in isolation to make sure they will work for
|
|
180
178
|
other users after publishing/exporting them.`);
|
package/dist/capsule.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CapsuleCreateCmd","constructor","workspace","isolator","create","componentIds","baseDir","rootBaseDir","alwaysNew","id","installPackages","seedersOnly","Array","isArray","capsuleOptions","installOptions","includeFromNestedHosts","name","ids","resolveMultipleComponentIds","network","isolateComponents","capsules","graphCapsules","report","opts","capsuleOutput","map","capsule","chalk","bold","component","toString","path","join","title","length","green","json","c","CapsuleListCmd","list","workspaceCapsulesRootDir","scopeAspectsCapsulesRootDir","getCapsulesRootDirs","cyan","rootDirs","getCapsulesRootDir","scope","getAspectCapsulePath","CapsuleDeleteCmd","args","all","scopeAspects","capsuleBaseDirToDelete","capsuleBaseDir","deletedDir","deleteCapsules","CapsuleCmd"],"sources":["capsule.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { CapsuleList, IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';\nimport chalk from 'chalk';\n\nimport { Workspace } from '.';\n\ntype CreateOpts = {\n baseDir?: string;\n rootBaseDir?: string;\n alwaysNew?: boolean;\n seedersOnly?: boolean;\n id: string;\n installPackages?: boolean;\n};\n\nexport class CapsuleCreateCmd implements Command {\n name = 'create [componentIds...]';\n description = `create capsules`;\n group = 'capsules';\n alias = '';\n options = [\n [\n 'b',\n 'base-dir <name>',\n 'set base dir of all capsules (hashed to create the base dir inside the root dir - host path by default)',\n ],\n ['r', 'root-base-dir <name>', 'set root base dir of all capsules (absolute path to use as root dir)'],\n ['a', 'always-new', 'create new environment for capsule'],\n ['s', 'seeders-only', 'create capsules for the seeders only (not for the entire graph)'],\n ['i', 'id <name>', 'reuse capsule of certain name'],\n ['j', 'json', 'json format'],\n ['d', 'install-packages', 'install packages by the package-manager'],\n ['p', 'package-manager <name>', 'npm, yarn or pnpm, default to npm'],\n ] as CommandOptions;\n\n constructor(private workspace: Workspace, private isolator: IsolatorMain) {}\n\n async create(\n [componentIds = []]: [string[]],\n { baseDir, rootBaseDir, alwaysNew = false, id, installPackages = false, seedersOnly = false }: CreateOpts\n ): Promise<CapsuleList> {\n // @todo: why it is not an array?\n if (componentIds && !Array.isArray(componentIds)) componentIds = [componentIds];\n const capsuleOptions: IsolateComponentsOptions = {\n baseDir,\n rootBaseDir,\n installOptions: { installPackages },\n alwaysNew,\n seedersOnly,\n includeFromNestedHosts: true,\n name: id,\n };\n const ids = await this.workspace.resolveMultipleComponentIds(componentIds);\n const network = await this.isolator.isolateComponents(ids, capsuleOptions);\n const capsules = network.graphCapsules;\n return capsules;\n }\n\n async report([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n const capsuleOutput = capsules\n .map((capsule) => `${chalk.bold(capsule.component.id.toString())} - ${capsule.path}`)\n .join('\\n');\n const title = `${capsules.length} capsule(s) were created successfully`;\n return `${chalk.green(title)}\\n${capsuleOutput}`;\n }\n\n async json([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n return capsules.map((c) => ({\n id: c.component.id.toString(),\n path: c.path,\n }));\n }\n}\n\nexport class CapsuleListCmd implements Command {\n name = 'list';\n description = `list all capsules`;\n shortDescription = 'list all capsules';\n group = 'capsules';\n alias = '';\n options = [['j', 'json', 'json format']] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace) {}\n\n async report() {\n const list = await this.isolator.list(this.workspace.path);\n const { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir } = this.getCapsulesRootDirs();\n // TODO: improve output\n return chalk.green(`found ${chalk.cyan(list.capsules.length.toString())} capsule(s) for workspace: ${chalk.cyan(\n list.workspace\n )}\nworkspace capsules root-dir: ${chalk.cyan(workspaceCapsulesRootDir)}\nscope's aspects capsules root-dir: ${chalk.cyan(scopeAspectsCapsulesRootDir)}\nuse --json to get the list of all workspace capsules`);\n }\n\n async json() {\n const list = await this.isolator.list(this.workspace.path);\n const rootDirs = this.getCapsulesRootDirs();\n return { ...list, ...rootDirs };\n }\n\n private getCapsulesRootDirs() {\n const workspaceCapsulesRootDir = this.isolator.getCapsulesRootDir(this.workspace.path);\n const scopeAspectsCapsulesRootDir = this.isolator.getCapsulesRootDir(this.workspace.scope.getAspectCapsulePath());\n\n return { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir };\n }\n}\n\nexport class CapsuleDeleteCmd implements Command {\n name = 'delete';\n description = `delete capsules. with no args, only workspace's capsules are deleted`;\n shortDescription = `delete capsules`;\n group = 'capsules';\n alias = '';\n options = [\n ['', 'scope-aspects', 'delete scope-aspects capsules'],\n ['a', 'all', 'delete all capsules for all workspaces and scopes'],\n ] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace) {}\n\n async report(args: [], { all, scopeAspects }: { all: boolean; scopeAspects: boolean }) {\n const capsuleBaseDirToDelete = (): string | null => {\n if (all) return null;\n if (scopeAspects) return this.workspace.scope.getAspectCapsulePath();\n return this.workspace.path;\n };\n const capsuleBaseDir = capsuleBaseDirToDelete();\n const deletedDir = await this.isolator.deleteCapsules(capsuleBaseDir);\n return chalk.green(`the following capsules dir has been deleted ${chalk.bold(deletedDir)}`);\n }\n}\n\nexport class CapsuleCmd implements Command {\n name = 'capsule <sub-command>';\n shortDescription = 'manage capsules';\n description = `manage capsules.\na capsule is a directory contains the component code, isolated from the workspace.\nnormally, capsules are created during the build process, the component files are copied and the packages are installed\nvia the configured package-manager. the purpose is to compile/test them in isolation to make sure they will work for\nother users after publishing/exporting them.`;\n alias = '';\n group = 'capsules';\n commands: Command[] = [];\n options = [] as CommandOptions;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async report(args: [string]) {\n // it should never be here. Yargs throws an error before reaching this method.\n return `Please specify a sub-command`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAaO,MAAMA,gBAAN,CAA0C;EAoB/CC,WAAW,CAASC,SAAT,EAAuCC,QAAvC,EAA+D;IAAA,KAAtDD,SAAsD,GAAtDA,SAAsD;IAAA,KAAxBC,QAAwB,GAAxBA,QAAwB;IAAA,8CAnBnE,0BAmBmE;IAAA,qDAlB3D,iBAkB2D;IAAA,+CAjBlE,UAiBkE;IAAA,+CAhBlE,EAgBkE;IAAA,iDAfhE,CACR,CACE,GADF,EAEE,iBAFF,EAGE,yGAHF,CADQ,EAMR,CAAC,GAAD,EAAM,sBAAN,EAA8B,sEAA9B,CANQ,EAOR,CAAC,GAAD,EAAM,YAAN,EAAoB,oCAApB,CAPQ,EAQR,CAAC,GAAD,EAAM,cAAN,EAAsB,iEAAtB,CARQ,EASR,CAAC,GAAD,EAAM,WAAN,EAAmB,+BAAnB,CATQ,EAUR,CAAC,GAAD,EAAM,MAAN,EAAc,aAAd,CAVQ,EAWR,CAAC,GAAD,EAAM,kBAAN,EAA0B,yCAA1B,CAXQ,EAYR,CAAC,GAAD,EAAM,wBAAN,EAAgC,mCAAhC,CAZQ,CAegE;EAAE;;EAEhE,MAANC,MAAM,CACV,CAACC,YAA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OAAO,KAAK/C,SAAL,CAAe+B,IAAtB;IACD,CAJD;;IAKA,MAAMsB,cAAc,GAAGD,sBAAsB,EAA7C;IACA,MAAME,UAAU,GAAG,MAAM,KAAKrD,QAAL,CAAcsD,cAAd,CAA6BF,cAA7B,CAAzB;IACA,OAAO1B,gBAAA,CAAMQ,KAAN,CAAa,+CAA8CR,gBAAA,CAAMC,IAAN,CAAW0B,UAAX,CAAuB,EAAlF,CAAP;EACD;;AAtB8C;;;;AAyB1C,MAAME,UAAN,CAAoC;EAAA;IAAA,8CAClC,uBADkC;IAAA,0DAEtB,iBAFsB;IAAA,qDAG1B;AACjB;AACA;AACA;AACA,6CAP2C;IAAA,+CAQjC,EARiC;IAAA,+CASjC,UATiC;IAAA,kDAUnB,EAVmB;IAAA,iDAW/B,EAX+B;EAAA;;EAazC;EACY,MAANlC,MAAM,CAAC2B,IAAD,EAAiB;IAC3B;IACA,OAAQ,8BAAR;EACD;;AAjBwC"}
|
|
1
|
+
{"version":3,"names":["CapsuleCreateCmd","constructor","workspace","isolator","create","componentIds","baseDir","rootBaseDir","alwaysNew","id","installPackages","seedersOnly","Array","isArray","capsuleOptions","installOptions","includeFromNestedHosts","name","ids","resolveMultipleComponentIds","network","isolateComponents","capsules","graphCapsules","report","opts","capsuleOutput","map","capsule","chalk","bold","component","toString","path","join","title","length","green","json","c","CapsuleListCmd","list","workspaceCapsulesRootDir","scopeAspectsCapsulesRootDir","getCapsulesRootDirs","cyan","rootDirs","getCapsulesRootDir","scope","getAspectCapsulePath","CapsuleDeleteCmd","args","all","scopeAspects","capsuleBaseDirToDelete","capsuleBaseDir","deletedDir","deleteCapsules","CapsuleCmd"],"sources":["capsule.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { CapsuleList, IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';\nimport chalk from 'chalk';\n\nimport { Workspace } from '.';\n\ntype CreateOpts = {\n baseDir?: string;\n rootBaseDir?: string;\n alwaysNew?: boolean;\n seedersOnly?: boolean;\n id: string;\n installPackages?: boolean;\n};\n\nexport class CapsuleCreateCmd implements Command {\n name = 'create [componentIds...]';\n description = `create capsules`;\n group = 'capsules';\n alias = '';\n options = [\n [\n 'b',\n 'base-dir <name>',\n 'set base dir of all capsules (hashed to create the base dir inside the root dir - host path by default)',\n ],\n ['r', 'root-base-dir <name>', 'set root base dir of all capsules (absolute path to use as root dir)'],\n ['a', 'always-new', 'create new environment for capsule'],\n ['s', 'seeders-only', 'create capsules for the seeders only (not for the entire graph)'],\n ['i', 'id <name>', 'reuse capsule of certain name'],\n ['j', 'json', 'json format'],\n ['d', 'install-packages', 'install packages by the package-manager'],\n ['p', 'package-manager <name>', 'npm, yarn or pnpm, default to npm'],\n ] as CommandOptions;\n\n constructor(private workspace: Workspace, private isolator: IsolatorMain) {}\n\n async create(\n [componentIds = []]: [string[]],\n { baseDir, rootBaseDir, alwaysNew = false, id, installPackages = false, seedersOnly = false }: CreateOpts\n ): Promise<CapsuleList> {\n // @todo: why it is not an array?\n if (componentIds && !Array.isArray(componentIds)) componentIds = [componentIds];\n const capsuleOptions: IsolateComponentsOptions = {\n baseDir,\n rootBaseDir,\n installOptions: { installPackages },\n alwaysNew,\n seedersOnly,\n includeFromNestedHosts: true,\n name: id,\n };\n const ids = await this.workspace.resolveMultipleComponentIds(componentIds);\n const network = await this.isolator.isolateComponents(ids, capsuleOptions);\n const capsules = network.graphCapsules;\n return capsules;\n }\n\n async report([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n const capsuleOutput = capsules\n .map((capsule) => `${chalk.bold(capsule.component.id.toString())} - ${capsule.path}`)\n .join('\\n');\n const title = `${capsules.length} capsule(s) were created successfully`;\n return `${chalk.green(title)}\\n${capsuleOutput}`;\n }\n\n async json([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n return capsules.map((c) => ({\n id: c.component.id.toString(),\n path: c.path,\n }));\n }\n}\n\nexport class CapsuleListCmd implements Command {\n name = 'list';\n description = `list all capsules`;\n group = 'capsules';\n alias = '';\n options = [['j', 'json', 'json format']] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace) {}\n\n async report() {\n const list = await this.isolator.list(this.workspace.path);\n const { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir } = this.getCapsulesRootDirs();\n // TODO: improve output\n return chalk.green(`found ${chalk.cyan(list.capsules.length.toString())} capsule(s) for workspace: ${chalk.cyan(\n list.workspace\n )}\nworkspace capsules root-dir: ${chalk.cyan(workspaceCapsulesRootDir)}\nscope's aspects capsules root-dir: ${chalk.cyan(scopeAspectsCapsulesRootDir)}\nuse --json to get the list of all workspace capsules`);\n }\n\n async json() {\n const list = await this.isolator.list(this.workspace.path);\n const rootDirs = this.getCapsulesRootDirs();\n return { ...list, ...rootDirs };\n }\n\n private getCapsulesRootDirs() {\n const workspaceCapsulesRootDir = this.isolator.getCapsulesRootDir(this.workspace.path);\n const scopeAspectsCapsulesRootDir = this.isolator.getCapsulesRootDir(this.workspace.scope.getAspectCapsulePath());\n\n return { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir };\n }\n}\n\nexport class CapsuleDeleteCmd implements Command {\n name = 'delete';\n description = `delete capsules`;\n extendedDescription = `with no args, only workspace's capsules are deleted`;\n group = 'capsules';\n alias = '';\n options = [\n ['', 'scope-aspects', 'delete scope-aspects capsules'],\n ['a', 'all', 'delete all capsules for all workspaces and scopes'],\n ] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace) {}\n\n async report(args: [], { all, scopeAspects }: { all: boolean; scopeAspects: boolean }) {\n const capsuleBaseDirToDelete = (): string | null => {\n if (all) return null;\n if (scopeAspects) return this.workspace.scope.getAspectCapsulePath();\n return this.workspace.path;\n };\n const capsuleBaseDir = capsuleBaseDirToDelete();\n const deletedDir = await this.isolator.deleteCapsules(capsuleBaseDir);\n return chalk.green(`the following capsules dir has been deleted ${chalk.bold(deletedDir)}`);\n }\n}\n\nexport class CapsuleCmd implements Command {\n name = 'capsule <sub-command>';\n description = 'manage capsules';\n extendedDescription = `a capsule is a directory contains the component code, isolated from the workspace.\nnormally, capsules are created during the build process, the component files are copied and the packages are installed\nvia the configured package-manager. the purpose is to compile/test them in isolation to make sure they will work for\nother users after publishing/exporting them.`;\n alias = '';\n group = 'capsules';\n commands: Command[] = [];\n options = [] as CommandOptions;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async report(args: [string]) {\n // it should never be here. Yargs throws an error before reaching this method.\n return `Please specify a sub-command`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAaO,MAAMA,gBAAN,CAA0C;EAoB/CC,WAAW,CAASC,SAAT,EAAuCC,QAAvC,EAA+D;IAAA,KAAtDD,SAAsD,GAAtDA,SAAsD;IAAA,KAAxBC,QAAwB,GAAxBA,QAAwB;IAAA,8CAnBnE,0BAmBmE;IAAA,qDAlB3D,iBAkB2D;IAAA,+CAjBlE,UAiBkE;IAAA,+CAhBlE,EAgBkE;IAAA,iDAfhE,CACR,CACE,GADF,EAEE,iBAFF,EAGE,yGAHF,CADQ,EAMR,CAAC,GAAD,EAAM,sBAAN,EAA8B,sEAA9B,CANQ,EAOR,CAAC,GAAD,EAAM,YAAN,EAAoB,oCAApB,CAPQ,EAQR,CAAC,GAAD,EAAM,cAAN,EAAsB,iEAAtB,CARQ,EASR,CAAC,GAAD,EAAM,WAAN,EAAmB,+BAAnB,CATQ,EAUR,CAAC,GAAD,EAAM,MAAN,EAAc,aAAd,CAVQ,EAWR,CAAC,GAAD,EAAM,kBAAN,EAA0B,yCAA1B,CAXQ,EAYR,CAAC,GAAD,EAAM,wBAAN,EAAgC,mCAAhC,CAZQ,CAegE;EAAE;;EAEhE,MAANC,MAAM,CACV,CAACC,YAAY,GAAG,EAAhB,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,CAJD;;IAKA,MAAMsB,cAAc,GAAGD,sBAAsB,EAA7C;IACA,MAAME,UAAU,GAAG,MAAM,KAAKrD,QAAL,CAAcsD,cAAd,CAA6BF,cAA7B,CAAzB;IACA,OAAO1B,gBAAA,CAAMQ,KAAN,CAAa,+CAA8CR,gBAAA,CAAMC,IAAN,CAAW0B,UAAX,CAAuB,EAAlF,CAAP;EACD;;AAtB8C;;;;AAyB1C,MAAME,UAAN,CAAoC;EAAA;IAAA,8CAClC,uBADkC;IAAA,qDAE3B,iBAF2B;IAAA,6DAGlB;AACzB;AACA;AACA,6CAN2C;IAAA,+CAOjC,EAPiC;IAAA,+CAQjC,UARiC;IAAA,kDASnB,EATmB;IAAA,iDAU/B,EAV+B;EAAA;;EAYzC;EACY,MAANlC,MAAM,CAAC2B,IAAD,EAAiB;IAC3B;IACA,OAAQ,8BAAR;EACD;;AAhBwC"}
|
package/dist/install.cmd.d.ts
CHANGED
package/dist/install.cmd.js
CHANGED
|
@@ -47,7 +47,6 @@ class InstallCmd {
|
|
|
47
47
|
(0, _defineProperty2().default)(this, "description", 'install development workspace dependencies');
|
|
48
48
|
(0, _defineProperty2().default)(this, "alias", 'in');
|
|
49
49
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
50
|
-
(0, _defineProperty2().default)(this, "shortDescription", '');
|
|
51
50
|
(0, _defineProperty2().default)(this, "options", [['v', 'variants <variants>', 'add packages to specific variants'], ['t', 'type [lifecycleType]', '"runtime" (default) or "peer" (dev is not a valid option)'], ['u', 'update-existing [updateExisting]', 'update existing dependencies version and types'], ['', 'save-prefix [savePrefix]', 'set the prefix to use when adding dependency to workspace.jsonc'], ['', 'skip-dedupe [skipDedupe]', 'do not dedupe dependencies on installation'], ['', 'skip-import [skipImport]', 'do not import bit objects post installation'], ['', 'add-missing-peers [addMissingPeers]', 'install all missing peer dependencies']]);
|
|
52
51
|
}
|
|
53
52
|
|
package/dist/install.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["InstallCmd","constructor","workspace","logger","report","packages","options","startTime","Date","now","console","chalk","cyan","name","installOpts","variants","lifecycleType","addMissingPeers","type","dedupe","skipDedupe","import","skipImport","updateExisting","savePrefix","components","install","endTime","executionTime","calculateTime","toArray","length","toString","diff"],"sources":["install.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { WorkspaceDependencyLifecycleType } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport chalk from 'chalk';\n\nimport { Workspace, WorkspaceInstallOptions } from './workspace';\n\ntype InstallCmdOptions = {\n variants: string;\n type: WorkspaceDependencyLifecycleType;\n skipDedupe: boolean;\n skipImport: boolean;\n updateExisting: boolean;\n savePrefix: string;\n addMissingPeers: boolean;\n};\n\nexport default class InstallCmd implements Command {\n name = 'install [packages...]';\n description = 'install development workspace dependencies';\n alias = 'in';\n group = 'development';\n
|
|
1
|
+
{"version":3,"names":["InstallCmd","constructor","workspace","logger","report","packages","options","startTime","Date","now","console","chalk","cyan","name","installOpts","variants","lifecycleType","addMissingPeers","type","dedupe","skipDedupe","import","skipImport","updateExisting","savePrefix","components","install","endTime","executionTime","calculateTime","toArray","length","toString","diff"],"sources":["install.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { WorkspaceDependencyLifecycleType } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport chalk from 'chalk';\n\nimport { Workspace, WorkspaceInstallOptions } from './workspace';\n\ntype InstallCmdOptions = {\n variants: string;\n type: WorkspaceDependencyLifecycleType;\n skipDedupe: boolean;\n skipImport: boolean;\n updateExisting: boolean;\n savePrefix: string;\n addMissingPeers: boolean;\n};\n\nexport default class InstallCmd implements Command {\n name = 'install [packages...]';\n description = 'install development workspace dependencies';\n alias = 'in';\n group = 'development';\n options = [\n ['v', 'variants <variants>', 'add packages to specific variants'],\n ['t', 'type [lifecycleType]', '\"runtime\" (default) or \"peer\" (dev is not a valid option)'],\n ['u', 'update-existing [updateExisting]', 'update existing dependencies version and types'],\n ['', 'save-prefix [savePrefix]', 'set the prefix to use when adding dependency to workspace.jsonc'],\n ['', 'skip-dedupe [skipDedupe]', 'do not dedupe dependencies on installation'],\n ['', 'skip-import [skipImport]', 'do not import bit objects post installation'],\n ['', 'add-missing-peers [addMissingPeers]', 'install all missing peer dependencies'],\n ] as CommandOptions;\n\n constructor(\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * logger extension.\n */\n private logger: Logger\n ) {}\n\n async report([packages = []]: [string[]], options: InstallCmdOptions) {\n const startTime = Date.now();\n this.logger.console(`Resolving component dependencies for workspace: '${chalk.cyan(this.workspace.name)}'`);\n const installOpts: WorkspaceInstallOptions = {\n variants: options.variants,\n lifecycleType: options.addMissingPeers ? 'peer' : options.type,\n dedupe: !options.skipDedupe,\n import: !options.skipImport,\n updateExisting: options.updateExisting,\n savePrefix: options.savePrefix,\n addMissingPeers: options.addMissingPeers,\n };\n const components = await this.workspace.install(packages, installOpts);\n const endTime = Date.now();\n const executionTime = calculateTime(startTime, endTime);\n return `Successfully resolved dependencies for ${chalk.cyan(\n components.toArray().length.toString()\n )} component(s) in ${chalk.cyan(executionTime.toString())} seconds`;\n }\n}\n\nfunction calculateTime(startTime: number, endTime: number) {\n const diff = endTime - startTime;\n return diff / 1000;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAce,MAAMA,UAAN,CAAoC;EAejDC,WAAW;EACT;AACJ;AACA;EACYC,SAJC;EAMT;AACJ;AACA;EACYC,MATC,EAUT;IAAA,KANQD,SAMR,GANQA,SAMR;IAAA,KADQC,MACR,GADQA,MACR;IAAA,8CAxBK,uBAwBL;IAAA,qDAvBY,4CAuBZ;IAAA,+CAtBM,IAsBN;IAAA,+CArBM,aAqBN;IAAA,iDApBQ,CACR,CAAC,GAAD,EAAM,qBAAN,EAA6B,mCAA7B,CADQ,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,CAACK,OAAX,GAAqBC,MAArB,CAA4BC,QAA5B,EAD+C,CAE/C,oBAAmBrB,gBAAA,CAAMC,IAAN,CAAWgB,aAAa,CAACI,QAAd,EAAX,CAAqC,UAF1D;EAGD;;AA7CgD;;;;AAgDnD,SAASH,aAAT,CAAuBtB,SAAvB,EAA0CoB,OAA1C,EAA2D;EACzD,MAAMM,IAAI,GAAGN,OAAO,GAAGpB,SAAvB;EACA,OAAO0B,IAAI,GAAG,IAAd;AACD"}
|
package/dist/link/link.cmd.d.ts
CHANGED
package/dist/link/link.cmd.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.array.iterator.js");
|
|
8
6
|
|
|
9
7
|
require("core-js/modules/es.promise.js");
|
|
@@ -108,12 +106,12 @@ class LinkCommand {
|
|
|
108
106
|
this.docsDomain = docsDomain;
|
|
109
107
|
(0, _defineProperty2().default)(this, "name", 'link [ids...]');
|
|
110
108
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
111
|
-
(0, _defineProperty2().default)(this, "description",
|
|
112
|
-
(0, _defineProperty2().default)(this, "
|
|
109
|
+
(0, _defineProperty2().default)(this, "description", 'link components and core aspects');
|
|
110
|
+
(0, _defineProperty2().default)(this, "extendedDescription", void 0);
|
|
113
111
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
114
112
|
(0, _defineProperty2().default)(this, "private", false);
|
|
115
113
|
(0, _defineProperty2().default)(this, "options", [['j', 'json', 'return the output as JSON'], ['', 'verbose', 'verbose output'], ['r', 'rewire', 'Replace relative paths with module paths in code (e.g. "../foo" => "@bit/foo")'], ['', 'target <dir>', 'EXPERIMENTAL. link to an external directory (similar to npm-link) so other projects could use these components'], ['', 'skip-fetching-objects', 'skip fetch missing objects from remotes before linking']]);
|
|
116
|
-
this.
|
|
114
|
+
this.extendedDescription = `https://${this.docsDomain}/workspace/component-links`;
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
async report([ids], opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LinkCommand","constructor","workspace","logger","docsDomain","
|
|
1
|
+
{"version":3,"names":["LinkCommand","constructor","workspace","logger","docsDomain","extendedDescription","report","ids","opts","startTime","Date","now","linkResults","json","endTime","numOfComponents","legacyLinkResults","length","timeDiff","timeFormat","coreAspectsLinksWithMainAspect","coreAspectsLinks","teambitBitLink","unshift","numOfCoreAspects","title","name","coreLinks","CoreAspectsLinks","verbose","compsLinks","ComponentListLinks","componentListLinks","rewireRow","RewireRow","legacyCodemodResults","legacyLinkCodemodResults","nestedLinks","NestedComponentLinksLinks","nestedDepsInNmLinks","targetLinks","linkToDir","linkToDirResults","footer","console","chalk","cyan","linkOpts","legacyLink","rewire","linkCoreAspects","linkTeambitBit","target","fetchObject","skipFetchingObjects","link"],"sources":["link.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { LinkResults } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { timeFormat } from '@teambit/toolbox.time.time-format';\nimport chalk from 'chalk';\nimport { Workspace, WorkspaceLinkOptions } from '../workspace';\nimport { ComponentListLinks } from './component-list-links';\nimport { CoreAspectsLinks } from './core-aspects-links';\nimport { NestedComponentLinksLinks } from './nested-deps-in-nm-links';\nimport { RewireRow } from './rewire-row';\nimport { linkToDir } from './link-to-dir';\n\ntype LinkCommandOpts = {\n rewire: boolean;\n verbose: boolean;\n target: string;\n skipFetchingObjects?: boolean;\n};\nexport class LinkCommand implements Command {\n name = 'link [ids...]';\n alias = '';\n description = 'link components and core aspects';\n extendedDescription: string;\n group = 'development';\n private = false;\n options = [\n ['j', 'json', 'return the output as JSON'],\n ['', 'verbose', 'verbose output'],\n ['r', 'rewire', 'Replace relative paths with module paths in code (e.g. \"../foo\" => \"@bit/foo\")'],\n [\n '',\n 'target <dir>',\n 'EXPERIMENTAL. link to an external directory (similar to npm-link) so other projects could use these components',\n ],\n ['', 'skip-fetching-objects', 'skip fetch missing objects from remotes before linking'],\n ] as CommandOptions;\n\n constructor(\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * logger extension.\n */\n private logger: Logger,\n\n private docsDomain: string\n ) {\n this.extendedDescription = `https://${this.docsDomain}/workspace/component-links`;\n }\n\n async report([ids]: [string[]], opts: LinkCommandOpts) {\n const startTime = Date.now();\n const linkResults = await this.json([ids], opts);\n const endTime = Date.now();\n const numOfComponents = linkResults.legacyLinkResults?.length;\n const timeDiff = timeFormat(endTime - startTime);\n const coreAspectsLinksWithMainAspect = linkResults.coreAspectsLinks || [];\n if (linkResults.teambitBitLink) {\n coreAspectsLinksWithMainAspect.unshift(linkResults.teambitBitLink);\n }\n const numOfCoreAspects = coreAspectsLinksWithMainAspect.length;\n\n const title = `Linked ${numOfComponents} components and ${numOfCoreAspects} core aspects to node_modules for workspace: ${this.workspace.name}`;\n const coreLinks = CoreAspectsLinks({\n coreAspectsLinks: coreAspectsLinksWithMainAspect,\n verbose: opts.verbose,\n });\n const compsLinks = ComponentListLinks({ componentListLinks: linkResults.legacyLinkResults, verbose: opts.verbose });\n const rewireRow = RewireRow({ legacyCodemodResults: linkResults.legacyLinkCodemodResults });\n const nestedLinks = NestedComponentLinksLinks({\n nestedDepsInNmLinks: linkResults.nestedDepsInNmLinks,\n verbose: opts.verbose,\n });\n const targetLinks = linkToDir(linkResults.linkToDirResults);\n const footer = `Finished. ${timeDiff}`;\n return `${title}\\n${coreLinks}\\n${compsLinks}\\n${rewireRow}${nestedLinks}${targetLinks}${footer}`;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async json([ids]: [string[]], opts: LinkCommandOpts): Promise<LinkResults> {\n this.logger.console(\n `Linking components and core aspects to node_modules for workspaces: '${chalk.cyan(this.workspace.name)}'`\n );\n\n const linkOpts: WorkspaceLinkOptions = {\n legacyLink: true,\n rewire: opts.rewire,\n linkCoreAspects: true,\n linkTeambitBit: true,\n linkToDir: opts.target,\n fetchObject: !opts.skipFetchingObjects,\n };\n const linkResults = await this.workspace.link(linkOpts);\n return linkResults;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAQO,MAAMA,WAAN,CAAqC;EAmB1CC,WAAW;EACT;AACJ;AACA;EACYC,SAJC;EAMT;AACJ;AACA;EACYC,MATC,EAWDC,UAXC,EAYT;IAAA,KARQF,SAQR,GARQA,SAQR;IAAA,KAHQC,MAGR,GAHQA,MAGR;IAAA,KADQC,UACR,GADQA,UACR;IAAA,8CA9BK,eA8BL;IAAA,+CA7BM,EA6BN;IAAA,qDA5BY,kCA4BZ;IAAA;IAAA,+CA1BM,aA0BN;IAAA,iDAzBQ,KAyBR;IAAA,iDAxBQ,CACR,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CADQ,EAER,CAAC,EAAD,EAAK,SAAL,EAAgB,gBAAhB,CAFQ,EAGR,CAAC,GAAD,EAAM,QAAN,EAAgB,gFAAhB,CAHQ,EAIR,CACE,EADF,EAEE,cAFF,EAGE,gHAHF,CAJQ,EASR,CAAC,EAAD,EAAK,uBAAL,EAA8B,wDAA9B,CATQ,CAwBR;IACA,KAAKC,mBAAL,GAA4B,WAAU,KAAKD,UAAW,4BAAtD;EACD;;EAEW,MAANE,MAAM,CAAC,CAACC,GAAD,CAAD,EAAoBC,IA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AAA,EAAU7B,WAAW,CAAC8B,gBAAtB,CAApB;IACA,MAAMC,MAAM,GAAI,aAAYzB,QAAS,EAArC;IACA,OAAQ,GAAEO,KAAM,KAAIE,SAAU,KAAIG,UAAW,KAAIG,SAAU,GAAEI,WAAY,GAAEG,WAAY,GAAEG,MAAO,EAAhG;EACD,CA7DyC,CA+D1C;;;EACU,MAAJ9B,IAAI,CAAC,CAACN,GAAD,CAAD,EAAoBC,IAApB,EAAiE;IACzE,KAAKL,MAAL,CAAYyC,OAAZ,CACG,wEAAuEC,gBAAA,CAAMC,IAAN,CAAW,KAAK5C,SAAL,CAAewB,IAA1B,CAAgC,GAD1G;IAIA,MAAMqB,QAA8B,GAAG;MACrCC,UAAU,EAAE,IADyB;MAErCC,MAAM,EAAEzC,IAAI,CAACyC,MAFwB;MAGrCC,eAAe,EAAE,IAHoB;MAIrCC,cAAc,EAAE,IAJqB;MAKrCV,SAAS,EAAEjC,IAAI,CAAC4C,MALqB;MAMrCC,WAAW,EAAE,CAAC7C,IAAI,CAAC8C;IANkB,CAAvC;IAQA,MAAM1C,WAAW,GAAG,MAAM,KAAKV,SAAL,CAAeqD,IAAf,CAAoBR,QAApB,CAA1B;IACA,OAAOnC,WAAP;EACD;;AA/EyC"}
|
package/dist/uninstall.cmd.d.ts
CHANGED
package/dist/uninstall.cmd.js
CHANGED
|
@@ -32,7 +32,6 @@ class UninstallCmd {
|
|
|
32
32
|
(0, _defineProperty2().default)(this, "description", 'uninstall dependencies');
|
|
33
33
|
(0, _defineProperty2().default)(this, "alias", 'un');
|
|
34
34
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
35
|
-
(0, _defineProperty2().default)(this, "shortDescription", '');
|
|
36
35
|
(0, _defineProperty2().default)(this, "options", []);
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UninstallCmd","constructor","workspace","report","packages","uninstallDependencies"],"sources":["uninstall.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { Workspace } from './workspace';\n\nexport default class UninstallCmd implements Command {\n name = 'uninstall [packages...]';\n description = 'uninstall dependencies';\n alias = 'un';\n group = 'development';\n
|
|
1
|
+
{"version":3,"names":["UninstallCmd","constructor","workspace","report","packages","uninstallDependencies"],"sources":["uninstall.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { Workspace } from './workspace';\n\nexport default class UninstallCmd implements Command {\n name = 'uninstall [packages...]';\n description = 'uninstall dependencies';\n alias = 'un';\n group = 'development';\n options = [] as CommandOptions;\n\n constructor(\n /**\n * workspace extension.\n */\n private workspace: Workspace\n ) {}\n\n async report([packages = []]: [string[]]) {\n await this.workspace.uninstallDependencies(packages);\n return '';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIe,MAAMA,YAAN,CAAsC;EAOnDC,WAAW;EACT;AACJ;AACA;EACYC,SAJC,EAKT;IAAA,KADQA,SACR,GADQA,SACR;IAAA,8CAXK,yBAWL;IAAA,qDAVY,wBAUZ;IAAA,+CATM,IASN;IAAA,+CARM,aAQN;IAAA,iDAPQ,EAOR;EAAE;;EAEQ,MAANC,MAAM,CAAC,CAACC,QAAQ,GAAG,EAAZ,CAAD,EAA8B;IACxC,MAAM,KAAKF,SAAL,CAAeG,qBAAf,CAAqCD,QAArC,CAAN;IACA,OAAO,EAAP;EACD;;AAjBkD"}
|
package/dist/update.cmd.d.ts
CHANGED
package/dist/update.cmd.js
CHANGED
|
@@ -30,7 +30,6 @@ class UpdateCmd {
|
|
|
30
30
|
(0, _defineProperty2().default)(this, "description", 'update dependencies');
|
|
31
31
|
(0, _defineProperty2().default)(this, "alias", 'up');
|
|
32
32
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
33
|
-
(0, _defineProperty2().default)(this, "shortDescription", '');
|
|
34
33
|
(0, _defineProperty2().default)(this, "options", [['y', 'yes', 'automatically update all outdated packages']]);
|
|
35
34
|
}
|
|
36
35
|
|
package/dist/update.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UpdateCmd","constructor","workspace","report","args","options","updateDependencies","all","yes"],"sources":["update.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { Workspace } from './workspace';\n\ntype UpdateCmdOptions = {\n yes?: boolean;\n};\n\nexport default class UpdateCmd implements Command {\n name = 'update';\n description = 'update dependencies';\n alias = 'up';\n group = 'development';\n
|
|
1
|
+
{"version":3,"names":["UpdateCmd","constructor","workspace","report","args","options","updateDependencies","all","yes"],"sources":["update.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { Workspace } from './workspace';\n\ntype UpdateCmdOptions = {\n yes?: boolean;\n};\n\nexport default class UpdateCmd implements Command {\n name = 'update';\n description = 'update dependencies';\n alias = 'up';\n group = 'development';\n options = [['y', 'yes', 'automatically update all outdated packages']] as CommandOptions;\n\n constructor(\n /**\n * workspace extension.\n */\n private workspace: Workspace\n ) {}\n\n async report(args: [string[]], options: UpdateCmdOptions) {\n await this.workspace.updateDependencies({\n all: options.yes === true,\n });\n return '';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQe,MAAMA,SAAN,CAAmC;EAOhDC,WAAW;EACT;AACJ;AACA;EACYC,SAJC,EAKT;IAAA,KADQA,SACR,GADQA,SACR;IAAA,8CAXK,QAWL;IAAA,qDAVY,qBAUZ;IAAA,+CATM,IASN;IAAA,+CARM,aAQN;IAAA,iDAPQ,CAAC,CAAC,GAAD,EAAM,KAAN,EAAa,4CAAb,CAAD,CAOR;EAAE;;EAEQ,MAANC,MAAM,CAACC,IAAD,EAAmBC,OAAnB,EAA8C;IACxD,MAAM,KAAKH,SAAL,CAAeI,kBAAf,CAAkC;MACtCC,GAAG,EAAEF,OAAO,CAACG,GAAR,KAAgB;IADiB,CAAlC,CAAN;IAGA,OAAO,EAAP;EACD;;AAnB+C"}
|
|
@@ -25,8 +25,8 @@ export declare class WatchCommand implements Command {
|
|
|
25
25
|
onAll: (event: string, path: string) => void;
|
|
26
26
|
onStart: () => void;
|
|
27
27
|
onReady: (workspace: any, watchPathsSortByComponent: any, verbose: any) => void;
|
|
28
|
-
onChange: (
|
|
29
|
-
onAdd: (
|
|
28
|
+
onChange: (filePaths: string[], buildResults: OnComponentEventResult[], verbose: boolean, duration: any, failureMsg?: string | undefined) => void;
|
|
29
|
+
onAdd: (filePaths: string[], buildResults: OnComponentEventResult[], verbose: boolean, duration: any, failureMsg?: string | undefined) => void;
|
|
30
30
|
onUnlink: (p: any) => void;
|
|
31
31
|
onError: (err: any) => void;
|
|
32
32
|
};
|
|
@@ -34,7 +34,6 @@ export declare class WatchCommand implements Command {
|
|
|
34
34
|
description: string;
|
|
35
35
|
alias: string;
|
|
36
36
|
group: string;
|
|
37
|
-
shortDescription: string;
|
|
38
37
|
options: CommandOptions;
|
|
39
38
|
constructor(
|
|
40
39
|
/**
|
package/dist/watch/watch.cmd.js
CHANGED
|
@@ -99,22 +99,32 @@ class WatchCommand {
|
|
|
99
99
|
|
|
100
100
|
this.logger.console(_chalk().default.yellow(`Watching for component changes in workspace ${workspace.config.name} (${(0, _moment().default)().format('HH:mm:ss')})...\n`));
|
|
101
101
|
},
|
|
102
|
-
onChange: (
|
|
102
|
+
onChange: (filePaths, buildResults, verbose, duration, failureMsg) => {
|
|
103
|
+
const files = filePaths.join(', ');
|
|
103
104
|
clearOutdatedData();
|
|
104
105
|
|
|
105
106
|
if (!buildResults.length) {
|
|
106
|
-
|
|
107
|
+
failureMsg = failureMsg || `The files ${files} have been changed, but nothing to compile`;
|
|
108
|
+
this.logger.console(`${failureMsg}\n\n`);
|
|
107
109
|
return;
|
|
108
110
|
}
|
|
109
111
|
|
|
110
|
-
this.logger.console(`The file ${
|
|
112
|
+
this.logger.console(`The file(s) ${files} have been changed.\n\n`);
|
|
111
113
|
this.logger.console((0, _outputFormatter().formatCompileResults)(buildResults, verbose));
|
|
112
114
|
this.logger.console(`Finished. (${duration}ms)`);
|
|
113
115
|
this.logger.console(_chalk().default.yellow(`Watching for component changes (${(0, _moment().default)().format('HH:mm:ss')})...`));
|
|
114
116
|
},
|
|
115
|
-
onAdd: (
|
|
117
|
+
onAdd: (filePaths, buildResults, verbose, duration, failureMsg) => {
|
|
118
|
+
const files = filePaths.join(', ');
|
|
116
119
|
clearOutdatedData();
|
|
117
|
-
|
|
120
|
+
|
|
121
|
+
if (!buildResults.length) {
|
|
122
|
+
failureMsg = failureMsg || `The files ${files} have been added, but nothing to compile`;
|
|
123
|
+
this.logger.console(`${failureMsg}\n\n`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.logger.console(`The file(s) ${filePaths} have been added.\n\n`);
|
|
118
128
|
this.logger.console((0, _outputFormatter().formatCompileResults)(buildResults, verbose));
|
|
119
129
|
this.logger.console(`Finished. (${duration}ms)`);
|
|
120
130
|
this.logger.console(_chalk().default.yellow(`Watching for component changes (${(0, _moment().default)().format('HH:mm:ss')})...`));
|
|
@@ -130,7 +140,6 @@ class WatchCommand {
|
|
|
130
140
|
(0, _defineProperty2().default)(this, "description", 'watch a set of components');
|
|
131
141
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
132
142
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
133
|
-
(0, _defineProperty2().default)(this, "shortDescription", '');
|
|
134
143
|
(0, _defineProperty2().default)(this, "options", [['v', 'verbose', 'showing npm verbose output for inspection and prints stack trace'], ['', 'skip-pre-compilation', 'skip the compilation step before starting to watch'], ['t', 'check-types [string]', 'EXPERIMENTAL. show errors/warnings for types. options are [file, project] to investigate only changed file or entire project. defaults to project']]);
|
|
135
144
|
(0, _defineProperty2().default)(this, "eventsListener", event => {
|
|
136
145
|
switch (event.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WatchCommand","constructor","pubsub","logger","watcher","onAll","event","path","console","onStart","onReady","workspace","watchPathsSortByComponent","verbose","clearOutdatedData","formatWatchPathsSortByComponent","chalk","yellow","config","name","moment","format","onChange","
|
|
1
|
+
{"version":3,"names":["WatchCommand","constructor","pubsub","logger","watcher","onAll","event","path","console","onStart","onReady","workspace","watchPathsSortByComponent","verbose","clearOutdatedData","formatWatchPathsSortByComponent","chalk","yellow","config","name","moment","format","onChange","filePaths","buildResults","duration","failureMsg","files","join","length","formatCompileResults","onAdd","onUnlink","p","onError","err","type","CompilerErrorEvent","TYPE","data","error","registerToEvents","sub","CompilerAspect","id","eventsListener","report","cliArgs","watchCmdOpts","checkTypes","getCheckTypesEnum","undefined","CheckTypes","None","EntireProject","ChangedFile","Error","watchOpts","msgs","preCompile","skipPreCompilation","spawnTSServer","Boolean","watchAll","process","stdout","write"],"sources":["watch.cmd.tsx"],"sourcesContent":["import chalk from 'chalk';\nimport moment from 'moment';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport type { Logger } from '@teambit/logger';\nimport type { BitBaseEvent, PubsubMain } from '@teambit/pubsub';\n\n// import IDs and events\nimport { CompilerAspect, CompilerErrorEvent } from '@teambit/compiler';\n\nimport { Watcher, WatchOptions } from './watcher';\nimport { formatCompileResults, formatWatchPathsSortByComponent } from './output-formatter';\nimport { OnComponentEventResult } from '../on-component-events';\nimport { CheckTypes } from './check-types';\n\nexport type WatchCmdOpts = {\n verbose?: boolean;\n skipPreCompilation?: boolean;\n checkTypes?: string | boolean;\n};\n\nexport class WatchCommand implements Command {\n msgs = {\n onAll: (event: string, path: string) => this.logger.console(`Event: \"${event}\". Path: ${path}`),\n onStart: () => {},\n onReady: (workspace, watchPathsSortByComponent, verbose) => {\n clearOutdatedData();\n if (verbose) {\n this.logger.console(formatWatchPathsSortByComponent(watchPathsSortByComponent));\n }\n this.logger.console(\n chalk.yellow(\n `Watching for component changes in workspace ${workspace.config.name} (${moment().format('HH:mm:ss')})...\\n`\n )\n );\n },\n onChange: (\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration,\n failureMsg?: string\n ) => {\n const files = filePaths.join(', ');\n clearOutdatedData();\n if (!buildResults.length) {\n failureMsg = failureMsg || `The files ${files} have been changed, but nothing to compile`;\n this.logger.console(`${failureMsg}\\n\\n`);\n return;\n }\n this.logger.console(`The file(s) ${files} have been changed.\\n\\n`);\n this.logger.console(formatCompileResults(buildResults, verbose));\n this.logger.console(`Finished. (${duration}ms)`);\n this.logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`));\n },\n onAdd: (\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration,\n failureMsg?: string\n ) => {\n const files = filePaths.join(', ');\n clearOutdatedData();\n if (!buildResults.length) {\n failureMsg = failureMsg || `The files ${files} have been added, but nothing to compile`;\n this.logger.console(`${failureMsg}\\n\\n`);\n return;\n }\n this.logger.console(`The file(s) ${filePaths} have been added.\\n\\n`);\n this.logger.console(formatCompileResults(buildResults, verbose));\n this.logger.console(`Finished. (${duration}ms)`);\n this.logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`));\n },\n onUnlink: (p) => {\n this.logger.console(`file ${p} has been removed`);\n },\n onError: (err) => {\n this.logger.console(`Watcher error ${err}`);\n },\n };\n\n name = 'watch';\n description = 'watch a set of components';\n alias = '';\n group = 'development';\n options = [\n ['v', 'verbose', 'showing npm verbose output for inspection and prints stack trace'],\n ['', 'skip-pre-compilation', 'skip the compilation step before starting to watch'],\n [\n 't',\n 'check-types [string]',\n 'EXPERIMENTAL. show errors/warnings for types. options are [file, project] to investigate only changed file or entire project. defaults to project',\n ],\n ] as CommandOptions;\n\n constructor(\n /**\n * logger extension.\n */\n private pubsub: PubsubMain,\n\n /**\n * logger extension.\n */\n private logger: Logger,\n\n /**\n * watcher extension.\n */\n private watcher: Watcher\n ) {\n this.registerToEvents();\n }\n\n private registerToEvents() {\n this.pubsub.sub(CompilerAspect.id, this.eventsListener);\n }\n\n private eventsListener = (event: BitBaseEvent<any>) => {\n switch (event.type) {\n case CompilerErrorEvent.TYPE:\n this.logger.console(`Watcher error ${event.data.error}, 'error'`);\n break;\n default:\n }\n };\n\n async report(cliArgs: [], watchCmdOpts: WatchCmdOpts) {\n const { verbose, checkTypes } = watchCmdOpts;\n const getCheckTypesEnum = () => {\n switch (checkTypes) {\n case undefined:\n case false:\n return CheckTypes.None;\n case 'project':\n case true: // project is the default\n return CheckTypes.EntireProject;\n case 'file':\n return CheckTypes.ChangedFile;\n default:\n throw new Error(`check-types can be either \"file\" or \"project\". got \"${checkTypes}\"`);\n }\n };\n const watchOpts: WatchOptions = {\n msgs: this.msgs,\n verbose,\n preCompile: !watchCmdOpts.skipPreCompilation,\n spawnTSServer: Boolean(checkTypes), // if check-types is enabled, it must spawn the tsserver.\n checkTypes: getCheckTypesEnum(),\n };\n await this.watcher.watchAll(watchOpts);\n return 'watcher terminated';\n }\n}\n\n/**\n * with console.clear() all history is deleted from the console. this function preserver the history.\n */\nfunction clearOutdatedData() {\n process.stdout.write('\\x1Bc');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AANA;AAcO,MAAMA,YAAN,CAAsC;EA2E3CC,WAAW;EACT;AACJ;AACA;EACYC,MAJC;EAMT;AACJ;AACA;EACYC,MATC;EAWT;AACJ;AACA;EACYC,OAdC,EAeT;IAAA,KAXQF,MAWR,GAXQA,MAWR;IAAA,KANQC,MAMR,GANQA,MAMR;IAAA,KADQC,OACR,GADQA,OACR;IAAA,8CAzFK;MACLC,KAAK,EAAE,CAACC,KAAD,EAAgBC,IAAhB,KAAiC,KAAKJ,MAAL,CAAYK,OAAZ,CAAqB,WAAUF,KAA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nC,MAAL,CAAYK,OAAZ,CAAqB,iBAAgBF,KAAK,CAACiC,IAAN,CAAWC,KAAM,WAAtD;UACA;;QACF;MAJF;IAMD,CAfC;IACA,KAAKC,gBAAL;EACD;;EAEOA,gBAAgB,GAAG;IACzB,KAAKvC,MAAL,CAAYwC,GAAZ,CAAgBC,0BAAA,CAAeC,EAA/B,EAAmC,KAAKC,cAAxC;EACD;;EAWW,MAANC,MAAM,CAACC,OAAD,EAAcC,YAAd,EAA0C;IACpD,MAAM;MAAEnC,OAAF;MAAWoC;IAAX,IAA0BD,YAAhC;;IACA,MAAME,iBAAiB,GAAG,MAAM;MAC9B,QAAQD,UAAR;QACE,KAAKE,SAAL;QACA,KAAK,KAAL;UACE,OAAOC,wBAAA,CAAWC,IAAlB;;QACF,KAAK,SAAL;QACA,KAAK,IAAL;UAAW;UACT,OAAOD,wBAAA,CAAWE,aAAlB;;QACF,KAAK,MAAL;UACE,OAAOF,wBAAA,CAAWG,WAAlB;;QACF;UACE,MAAM,IAAIC,KAAJ,CAAW,uDAAsDP,UAAW,GAA5E,CAAN;MAVJ;IAYD,CAbD;;IAcA,MAAMQ,SAAuB,GAAG;MAC9BC,IAAI,EAAE,KAAKA,IADmB;MAE9B7C,OAF8B;MAG9B8C,UAAU,EAAE,CAACX,YAAY,CAACY,kBAHI;MAI9BC,aAAa,EAAEC,OAAO,CAACb,UAAD,CAJQ;MAIM;MACpCA,UAAU,EAAEC,iBAAiB;IALC,CAAhC;IAOA,MAAM,KAAK9C,OAAL,CAAa2D,QAAb,CAAsBN,SAAtB,CAAN;IACA,OAAO,oBAAP;EACD;;AApI0C;AAuI7C;AACA;AACA;;;;;AACA,SAAS3C,iBAAT,GAA6B;EAC3BkD,OAAO,CAACC,MAAR,CAAeC,KAAf,CAAqB,OAArB;AACD"}
|
package/dist/watch/watcher.d.ts
CHANGED
|
@@ -37,12 +37,37 @@ export declare class Watcher {
|
|
|
37
37
|
private verbose;
|
|
38
38
|
private multipleWatchers;
|
|
39
39
|
private fsWatcher;
|
|
40
|
+
private changedFilesPerComponent;
|
|
40
41
|
constructor(workspace: Workspace, pubsub: PubsubMain, trackDirs?: {
|
|
41
42
|
[dir: PathLinux]: ComponentID;
|
|
42
43
|
}, verbose?: boolean, multipleWatchers?: WatcherProcessData[]);
|
|
43
44
|
get consumer(): Consumer;
|
|
44
45
|
watchAll(opts: WatchOptions): Promise<unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* some actions trigger multiple files changes at (almost) the same time. e.g. "git pull".
|
|
48
|
+
* this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.
|
|
49
|
+
* the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).
|
|
50
|
+
* if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,
|
|
51
|
+
* it'll only add the file to `this.changedFilesPerComponent` prop.
|
|
52
|
+
* once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,
|
|
53
|
+
* indicating the next file-change to start a new execution.
|
|
54
|
+
*
|
|
55
|
+
* implementation wise, `lodash.debounce` doesn't help here, because:
|
|
56
|
+
* A) it doesn't return the results, unless "leading" option is true. here, it must be false, otherwise, it'll start
|
|
57
|
+
* the execution immediately.
|
|
58
|
+
* B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay
|
|
59
|
+
* other components undesirably.
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
45
62
|
private handleChange;
|
|
63
|
+
private sleep;
|
|
64
|
+
/**
|
|
65
|
+
* if a file was added/remove, once the component is loaded, it changes .bitmap, and then the
|
|
66
|
+
* entire cache is invalidated and the consumer is reloaded.
|
|
67
|
+
* when a file just changed, no need to reload the consumer, it is enough to just delete the
|
|
68
|
+
* component from the cache (both, workspace and consumer)
|
|
69
|
+
*/
|
|
70
|
+
private triggerCompChanges;
|
|
46
71
|
/**
|
|
47
72
|
* if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.
|
|
48
73
|
*/
|
|
@@ -52,15 +77,9 @@ export declare class Watcher {
|
|
|
52
77
|
private creatOnComponentRemovedEvent;
|
|
53
78
|
private creatOnComponentChangeEvent;
|
|
54
79
|
private creatOnComponentAddEvent;
|
|
55
|
-
private completeWatch;
|
|
56
80
|
private isComponentWatchedExternally;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* entire cache is invalidated and the consumer is reloaded.
|
|
60
|
-
* when a file just changed, no need to reload the consumer, it is enough to just delete the
|
|
61
|
-
* component from the cache (both, workspace and consumer)
|
|
62
|
-
*/
|
|
63
|
-
private getComponentIdAndClearItsCache;
|
|
81
|
+
private getComponentIdByPath;
|
|
82
|
+
private getRelativePathLinux;
|
|
64
83
|
private findTrackDirByFilePathRecursively;
|
|
65
84
|
private createWatcher;
|
|
66
85
|
setTrackDirs(): Promise<void>;
|