@teambit/isolator 0.0.0-12dd25ea8f04b7510e17abfd519dfcb7c64c42f8

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.
Files changed (46) hide show
  1. package/capsule/capsule.ts +138 -0
  2. package/capsule/container-exec.ts +31 -0
  3. package/capsule/container.ts +128 -0
  4. package/capsule/index.ts +3 -0
  5. package/dist/capsule/capsule.d.ts +75 -0
  6. package/dist/capsule/capsule.js +194 -0
  7. package/dist/capsule/capsule.js.map +1 -0
  8. package/dist/capsule/container-exec.d.ts +13 -0
  9. package/dist/capsule/container-exec.js +51 -0
  10. package/dist/capsule/container-exec.js.map +1 -0
  11. package/dist/capsule/container.d.ts +34 -0
  12. package/dist/capsule/container.js +153 -0
  13. package/dist/capsule/container.js.map +1 -0
  14. package/dist/capsule/index.d.ts +3 -0
  15. package/dist/capsule/index.js +47 -0
  16. package/dist/capsule/index.js.map +1 -0
  17. package/dist/capsule-list.d.ts +22 -0
  18. package/dist/capsule-list.js +100 -0
  19. package/dist/capsule-list.js.map +1 -0
  20. package/dist/esm.mjs +13 -0
  21. package/dist/index.d.ts +6 -0
  22. package/dist/index.js +85 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/isolator.aspect.d.ts +2 -0
  25. package/dist/isolator.aspect.js +20 -0
  26. package/dist/isolator.aspect.js.map +1 -0
  27. package/dist/isolator.composition.d.ts +1 -0
  28. package/dist/isolator.composition.js +29 -0
  29. package/dist/isolator.composition.js.map +1 -0
  30. package/dist/isolator.docs.md +41 -0
  31. package/dist/isolator.main.runtime.d.ts +280 -0
  32. package/dist/isolator.main.runtime.js +1167 -0
  33. package/dist/isolator.main.runtime.js.map +1 -0
  34. package/dist/network.d.ts +122 -0
  35. package/dist/network.js +182 -0
  36. package/dist/network.js.map +1 -0
  37. package/dist/preview-1752579919708.js +7 -0
  38. package/dist/symlink-dependencies-to-capsules.d.ts +6 -0
  39. package/dist/symlink-dependencies-to-capsules.js +61 -0
  40. package/dist/symlink-dependencies-to-capsules.js.map +1 -0
  41. package/esm.mjs +13 -0
  42. package/isolator.composition.tsx +7 -0
  43. package/isolator.docs.md +41 -0
  44. package/package.json +93 -0
  45. package/types/asset.d.ts +41 -0
  46. package/types/style.d.ts +42 -0
@@ -0,0 +1,138 @@
1
+ import { NodeFS } from '@teambit/any-fs';
2
+ import { Capsule as CapsuleTemplate, Console, Exec, State } from '@teambit/capsule';
3
+ import { Component } from '@teambit/component';
4
+ import filenamify from 'filenamify';
5
+ import { realpathSync } from 'fs';
6
+ import glob from 'glob';
7
+ import path from 'path';
8
+ import { v4 } from 'uuid';
9
+
10
+ import FsContainer, { BitExecOption } from './container';
11
+ import ContainerExec from './container-exec';
12
+
13
+ export default class Capsule extends CapsuleTemplate<Exec, NodeFS> {
14
+ private _wrkDir: string;
15
+ constructor(
16
+ /**
17
+ * container implementation the capsule is being executed within.
18
+ */
19
+ protected container: FsContainer,
20
+ /**
21
+ * the capsule's file system.
22
+ */
23
+ readonly fs: NodeFS,
24
+ /**
25
+ * console for controlling process streams as stdout, stdin and stderr.
26
+ */
27
+ readonly console: Console = new Console(),
28
+ /**
29
+ * capsule's state.
30
+ */
31
+ readonly state: State,
32
+ readonly component: Component
33
+ ) {
34
+ super(container, fs, console, state);
35
+ this._wrkDir = container.wrkDir;
36
+ }
37
+
38
+ /**
39
+ * @deprecated please use `this.path`
40
+ */
41
+ get wrkDir(): string {
42
+ return this.path;
43
+ }
44
+
45
+ get path(): string {
46
+ return realpathSync(this._wrkDir);
47
+ }
48
+
49
+ start(): Promise<any> {
50
+ return this.container.start();
51
+ }
52
+
53
+ async execNode(executable: string, args: any, exec: ContainerExec) {
54
+ return this.typedExec(
55
+ {
56
+ command: ['node', executable, ...(args.args || [])],
57
+ cwd: '',
58
+ },
59
+ exec
60
+ );
61
+ }
62
+
63
+ async typedExec(opts: BitExecOption, exec = new ContainerExec()) {
64
+ return this.container.exec(opts, exec);
65
+ }
66
+
67
+ outputFile(file: string, data: any, options?: any): Promise<any> {
68
+ return this.container.outputFile(file, data, options);
69
+ }
70
+
71
+ removePath(dir: string): Promise<any> {
72
+ return this.container.removePath(dir);
73
+ }
74
+
75
+ symlink(src: string, dest: string): Promise<any> {
76
+ return this.container.symlink(src, dest);
77
+ }
78
+
79
+ // TODO: refactor this crap and simplify capsule API
80
+ async execute(cmd: string, options?: Record<string, any> | null | undefined) {
81
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
82
+ const execResults = await this.exec({ command: cmd.split(' '), options });
83
+ let stdout = '';
84
+ let stderr = '';
85
+ return new Promise((resolve, reject) => {
86
+ execResults.stdout.on('data', (data: string) => {
87
+ stdout += data;
88
+ });
89
+ execResults.stdout.on('error', (error: string) => {
90
+ return reject(error);
91
+ });
92
+ // @ts-ignore
93
+ execResults.on('close', () => {
94
+ return resolve({ stdout, stderr });
95
+ });
96
+ execResults.stderr.on('error', (error: string) => {
97
+ return reject(error);
98
+ });
99
+ execResults.stderr.on('data', (data: string) => {
100
+ stderr += data;
101
+ });
102
+ });
103
+ }
104
+
105
+ /**
106
+ * @todo: fix.
107
+ * it skips the capsule fs because for some reason `capsule.fs.promises.readdir` doesn't work
108
+ * the same as `capsule.fs.readdir` and it doesn't have the capsule dir as pwd.
109
+ *
110
+ * returns the paths inside the capsule
111
+ */
112
+ getAllFilesPaths(dir = '.', options: { ignore?: string[] } = {}) {
113
+ const files = glob.sync('**', { cwd: path.join(this.path, dir), nodir: true, ...options });
114
+ return files.map((file) => path.join(dir, file));
115
+ }
116
+
117
+ static getCapsuleDirName(component: Component, config: { alwaysNew?: boolean; name?: string } = {}) {
118
+ return config.name || filenamify(component.id.toString(), { replacement: '_' });
119
+ }
120
+
121
+ static getCapsuleRootDir(component: Component, baseDir: string, config: { alwaysNew?: boolean; name?: string } = {}) {
122
+ return path.join(baseDir, Capsule.getCapsuleDirName(component, config));
123
+ }
124
+
125
+ static async createFromComponent(
126
+ component: Component,
127
+ baseDir: string,
128
+ config: { alwaysNew?: boolean } = {}
129
+ ): Promise<Capsule> {
130
+ // TODO: make this a static method and combine with ComponentCapsule
131
+ const capsuleDirName = Capsule.getCapsuleDirName(component, config);
132
+ const wrkDir = path.join(baseDir, config.alwaysNew ? `${capsuleDirName}_${v4()}` : capsuleDirName);
133
+ const container = new FsContainer(wrkDir);
134
+ const capsule = new Capsule(container, container.fs, new Console(), new State(), component);
135
+ await capsule.start();
136
+ return capsule;
137
+ }
138
+ }
@@ -0,0 +1,31 @@
1
+ import { DuplexBufferStream, Exec, ExecStatus } from '@teambit/capsule';
2
+ import { EventEmitter } from 'events';
3
+
4
+ export default class ContainerExec extends EventEmitter implements Exec {
5
+ constructor(private _code: number = 0) {
6
+ super();
7
+ }
8
+
9
+ stdout: DuplexBufferStream = new DuplexBufferStream();
10
+ stderr: DuplexBufferStream = new DuplexBufferStream();
11
+ stdin: DuplexBufferStream = new DuplexBufferStream();
12
+
13
+ setStatus(status: number): void {
14
+ this._code = status;
15
+ this.emit('close');
16
+ }
17
+
18
+ get code(): number {
19
+ return this._code;
20
+ }
21
+
22
+ inspect(): Promise<ExecStatus> {
23
+ return Promise.resolve({
24
+ running: true,
25
+ pid: 1,
26
+ });
27
+ }
28
+ abort(): Promise<void> {
29
+ throw new Error('Method not implemented.');
30
+ }
31
+ }
@@ -0,0 +1,128 @@
1
+ import { AnyFS, NodeFS } from '@teambit/any-fs';
2
+ import { Container, ContainerFactoryOptions, ContainerStatus, Exec, ExecOptions } from '@teambit/capsule';
3
+ import execa from 'execa';
4
+ import fs from 'fs-extra';
5
+ import * as path from 'path';
6
+ import { Stream } from 'stream';
7
+
8
+ import ContainerExec from './container-exec';
9
+
10
+ const debug = require('debug')('fs-container');
11
+
12
+ export interface BitExecOption extends ExecOptions {
13
+ cwd: string;
14
+ stdio?: 'pipe' | 'ipc' | 'ignore' | 'inherit' | Stream | number | undefined;
15
+ }
16
+ export interface BitContainerConfig extends ContainerFactoryOptions {
17
+ other?: string;
18
+ }
19
+
20
+ export default class FsContainer implements Container<Exec, AnyFS> {
21
+ id = 'FS Container';
22
+
23
+ fs: NodeFS = new NodeFS(this.wrkDir);
24
+
25
+ constructor(readonly wrkDir: string) {}
26
+
27
+ // TODO: do we need this?
28
+ public getPath() {
29
+ return this.wrkDir;
30
+ }
31
+
32
+ private composePath(pathToCompose) {
33
+ return path.join(this.getPath(), pathToCompose);
34
+ }
35
+
36
+ outputFile(file, data, options) {
37
+ const filePath = this.composePath(file);
38
+ debug(`writing file on ${filePath}`);
39
+ return fs.outputFile(filePath, data, options);
40
+ }
41
+
42
+ removePath(dir: string): Promise<any> {
43
+ const pathToRemove = this.composePath(dir);
44
+ return fs.remove(pathToRemove);
45
+ }
46
+
47
+ async symlink(src: string, dest: string): Promise<any> {
48
+ const srcPath = this.composePath(src);
49
+ const destPath = this.composePath(dest);
50
+ await fs.ensureDir(path.dirname(destPath));
51
+ return fs.ensureSymlink(srcPath, destPath);
52
+ }
53
+
54
+ async exec(execOptions: BitExecOption, exec = new ContainerExec()): Promise<ContainerExec> {
55
+ const cwd = execOptions.cwd ? this.composePath(execOptions.cwd) : this.getPath();
56
+ debug(`executing the following command: ${execOptions.command.join(' ')}, on cwd: ${cwd}`);
57
+ const subprocessP = execa.command(execOptions.command.join(' '), {
58
+ shell: true,
59
+ cwd,
60
+ stdio: ['ipc'],
61
+ });
62
+
63
+ // @TODO: FIX! This probably causes errors ad the promise is not handled properly!
64
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
65
+ subprocessP.on('message', function (msg: any) {
66
+ exec.emit('message', msg);
67
+ });
68
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
69
+ subprocessP.stderr?.pipe(exec.stderr);
70
+ subprocessP.stdout?.pipe(exec.stdout);
71
+ ['close', 'exit'].forEach(function (eventName: string) {
72
+ // @TODO: FIX! This probably causes errors ad the promise is not handled properly!
73
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
74
+ subprocessP.on(eventName, function (statusCode) {
75
+ exec.setStatus(statusCode);
76
+ });
77
+ });
78
+
79
+ return exec;
80
+ }
81
+
82
+ async execP(execOptions: BitExecOption): Promise<string> {
83
+ let hasError = false;
84
+ const exec = await this.exec(execOptions);
85
+ return new Promise((resolve, reject) => {
86
+ exec.stdout.on('error', () => {
87
+ hasError = true;
88
+ });
89
+ exec.on('close', () => {
90
+ if (hasError) reject(exec.stderr.getContents!(exec.stderr.size).toString());
91
+ resolve(exec.stdout.getContents!(exec.stdout.size).toString());
92
+ });
93
+ });
94
+ }
95
+
96
+ async terminal() {
97
+ const cwd = this.getPath();
98
+ return execa.command(process.env.SHELL || '/bin/zsh', { cwd, stdio: 'inherit' });
99
+ }
100
+
101
+ start(): Promise<void> {
102
+ return fs.ensureDir(this.wrkDir);
103
+ }
104
+ // @ts-ignore
105
+ async inspect(): Promise<ContainerStatus> {
106
+ // todo: probably not needed for this container
107
+ }
108
+ async pause(): Promise<void> {
109
+ // do nothing
110
+ }
111
+ async resume(): Promise<void> {
112
+ // do nothing
113
+ }
114
+ // eslint-disable-next-line
115
+ stop(ttl?: number | undefined): Promise<void> {
116
+ return fs.remove(this.wrkDir);
117
+ }
118
+ async destroy(): Promise<void> {
119
+ await this.stop();
120
+ }
121
+ log(): Promise<Exec> {
122
+ throw new Error('Method not implemented.');
123
+ }
124
+ on(event: string, fn: (data: any) => void): void {
125
+ return fn(event);
126
+ // throw new Error('Method not implemented.');
127
+ }
128
+ }
@@ -0,0 +1,3 @@
1
+ export { default as Capsule } from './capsule';
2
+ export { default as FsContainer } from './container';
3
+ export { default as ContainerExec } from './container-exec';
@@ -0,0 +1,75 @@
1
+ import { NodeFS } from '@teambit/any-fs';
2
+ import { Capsule as CapsuleTemplate, Console, Exec, State } from '@teambit/capsule';
3
+ import { Component } from '@teambit/component';
4
+ import FsContainer, { BitExecOption } from './container';
5
+ import ContainerExec from './container-exec';
6
+ export default class Capsule extends CapsuleTemplate<Exec, NodeFS> {
7
+ /**
8
+ * container implementation the capsule is being executed within.
9
+ */
10
+ protected container: FsContainer;
11
+ /**
12
+ * the capsule's file system.
13
+ */
14
+ readonly fs: NodeFS;
15
+ /**
16
+ * console for controlling process streams as stdout, stdin and stderr.
17
+ */
18
+ readonly console: Console;
19
+ /**
20
+ * capsule's state.
21
+ */
22
+ readonly state: State;
23
+ readonly component: Component;
24
+ private _wrkDir;
25
+ constructor(
26
+ /**
27
+ * container implementation the capsule is being executed within.
28
+ */
29
+ container: FsContainer,
30
+ /**
31
+ * the capsule's file system.
32
+ */
33
+ fs: NodeFS,
34
+ /**
35
+ * console for controlling process streams as stdout, stdin and stderr.
36
+ */
37
+ console: Console,
38
+ /**
39
+ * capsule's state.
40
+ */
41
+ state: State, component: Component);
42
+ /**
43
+ * @deprecated please use `this.path`
44
+ */
45
+ get wrkDir(): string;
46
+ get path(): string;
47
+ start(): Promise<any>;
48
+ execNode(executable: string, args: any, exec: ContainerExec): Promise<ContainerExec>;
49
+ typedExec(opts: BitExecOption, exec?: ContainerExec): Promise<ContainerExec>;
50
+ outputFile(file: string, data: any, options?: any): Promise<any>;
51
+ removePath(dir: string): Promise<any>;
52
+ symlink(src: string, dest: string): Promise<any>;
53
+ execute(cmd: string, options?: Record<string, any> | null | undefined): Promise<unknown>;
54
+ /**
55
+ * @todo: fix.
56
+ * it skips the capsule fs because for some reason `capsule.fs.promises.readdir` doesn't work
57
+ * the same as `capsule.fs.readdir` and it doesn't have the capsule dir as pwd.
58
+ *
59
+ * returns the paths inside the capsule
60
+ */
61
+ getAllFilesPaths(dir?: string, options?: {
62
+ ignore?: string[];
63
+ }): any;
64
+ static getCapsuleDirName(component: Component, config?: {
65
+ alwaysNew?: boolean;
66
+ name?: string;
67
+ }): string;
68
+ static getCapsuleRootDir(component: Component, baseDir: string, config?: {
69
+ alwaysNew?: boolean;
70
+ name?: string;
71
+ }): string;
72
+ static createFromComponent(component: Component, baseDir: string, config?: {
73
+ alwaysNew?: boolean;
74
+ }): Promise<Capsule>;
75
+ }
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _capsule() {
8
+ const data = require("@teambit/capsule");
9
+ _capsule = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _filenamify() {
15
+ const data = _interopRequireDefault(require("filenamify"));
16
+ _filenamify = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _fs() {
22
+ const data = require("fs");
23
+ _fs = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _glob() {
29
+ const data = _interopRequireDefault(require("glob"));
30
+ _glob = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _path() {
36
+ const data = _interopRequireDefault(require("path"));
37
+ _path = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _uuid() {
43
+ const data = require("uuid");
44
+ _uuid = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _container() {
50
+ const data = _interopRequireDefault(require("./container"));
51
+ _container = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
56
+ function _containerExec() {
57
+ const data = _interopRequireDefault(require("./container-exec"));
58
+ _containerExec = function () {
59
+ return data;
60
+ };
61
+ return data;
62
+ }
63
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
64
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
65
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
66
+ 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; }
67
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
68
+ 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); }
69
+ class Capsule extends _capsule().Capsule {
70
+ constructor(
71
+ /**
72
+ * container implementation the capsule is being executed within.
73
+ */
74
+ container,
75
+ /**
76
+ * the capsule's file system.
77
+ */
78
+ fs,
79
+ /**
80
+ * console for controlling process streams as stdout, stdin and stderr.
81
+ */
82
+ console = new (_capsule().Console)(),
83
+ /**
84
+ * capsule's state.
85
+ */
86
+ state, component) {
87
+ super(container, fs, console, state);
88
+ this.container = container;
89
+ this.fs = fs;
90
+ this.console = console;
91
+ this.state = state;
92
+ this.component = component;
93
+ _defineProperty(this, "_wrkDir", void 0);
94
+ this._wrkDir = container.wrkDir;
95
+ }
96
+
97
+ /**
98
+ * @deprecated please use `this.path`
99
+ */
100
+ get wrkDir() {
101
+ return this.path;
102
+ }
103
+ get path() {
104
+ return (0, _fs().realpathSync)(this._wrkDir);
105
+ }
106
+ start() {
107
+ return this.container.start();
108
+ }
109
+ async execNode(executable, args, exec) {
110
+ return this.typedExec({
111
+ command: ['node', executable, ...(args.args || [])],
112
+ cwd: ''
113
+ }, exec);
114
+ }
115
+ async typedExec(opts, exec = new (_containerExec().default)()) {
116
+ return this.container.exec(opts, exec);
117
+ }
118
+ outputFile(file, data, options) {
119
+ return this.container.outputFile(file, data, options);
120
+ }
121
+ removePath(dir) {
122
+ return this.container.removePath(dir);
123
+ }
124
+ symlink(src, dest) {
125
+ return this.container.symlink(src, dest);
126
+ }
127
+
128
+ // TODO: refactor this crap and simplify capsule API
129
+ async execute(cmd, options) {
130
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
131
+ const execResults = await this.exec({
132
+ command: cmd.split(' '),
133
+ options
134
+ });
135
+ let stdout = '';
136
+ let stderr = '';
137
+ return new Promise((resolve, reject) => {
138
+ execResults.stdout.on('data', data => {
139
+ stdout += data;
140
+ });
141
+ execResults.stdout.on('error', error => {
142
+ return reject(error);
143
+ });
144
+ // @ts-ignore
145
+ execResults.on('close', () => {
146
+ return resolve({
147
+ stdout,
148
+ stderr
149
+ });
150
+ });
151
+ execResults.stderr.on('error', error => {
152
+ return reject(error);
153
+ });
154
+ execResults.stderr.on('data', data => {
155
+ stderr += data;
156
+ });
157
+ });
158
+ }
159
+
160
+ /**
161
+ * @todo: fix.
162
+ * it skips the capsule fs because for some reason `capsule.fs.promises.readdir` doesn't work
163
+ * the same as `capsule.fs.readdir` and it doesn't have the capsule dir as pwd.
164
+ *
165
+ * returns the paths inside the capsule
166
+ */
167
+ getAllFilesPaths(dir = '.', options = {}) {
168
+ const files = _glob().default.sync('**', _objectSpread({
169
+ cwd: _path().default.join(this.path, dir),
170
+ nodir: true
171
+ }, options));
172
+ return files.map(file => _path().default.join(dir, file));
173
+ }
174
+ static getCapsuleDirName(component, config = {}) {
175
+ return config.name || (0, _filenamify().default)(component.id.toString(), {
176
+ replacement: '_'
177
+ });
178
+ }
179
+ static getCapsuleRootDir(component, baseDir, config = {}) {
180
+ return _path().default.join(baseDir, Capsule.getCapsuleDirName(component, config));
181
+ }
182
+ static async createFromComponent(component, baseDir, config = {}) {
183
+ // TODO: make this a static method and combine with ComponentCapsule
184
+ const capsuleDirName = Capsule.getCapsuleDirName(component, config);
185
+ const wrkDir = _path().default.join(baseDir, config.alwaysNew ? `${capsuleDirName}_${(0, _uuid().v4)()}` : capsuleDirName);
186
+ const container = new (_container().default)(wrkDir);
187
+ const capsule = new Capsule(container, container.fs, new (_capsule().Console)(), new (_capsule().State)(), component);
188
+ await capsule.start();
189
+ return capsule;
190
+ }
191
+ }
192
+ exports.default = Capsule;
193
+
194
+ //# sourceMappingURL=capsule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_capsule","data","require","_filenamify","_interopRequireDefault","_fs","_glob","_path","_uuid","_container","_containerExec","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Capsule","CapsuleTemplate","constructor","container","fs","console","Console","state","component","_wrkDir","wrkDir","path","realpathSync","start","execNode","executable","args","exec","typedExec","command","cwd","opts","ContainerExec","outputFile","file","options","removePath","dir","symlink","src","dest","execute","cmd","execResults","split","stdout","stderr","Promise","resolve","reject","on","error","getAllFilesPaths","files","glob","sync","join","nodir","map","getCapsuleDirName","config","name","filenamify","id","toString","replacement","getCapsuleRootDir","baseDir","createFromComponent","capsuleDirName","alwaysNew","v4","FsContainer","capsule","State","exports"],"sources":["capsule.ts"],"sourcesContent":["import { NodeFS } from '@teambit/any-fs';\nimport { Capsule as CapsuleTemplate, Console, Exec, State } from '@teambit/capsule';\nimport { Component } from '@teambit/component';\nimport filenamify from 'filenamify';\nimport { realpathSync } from 'fs';\nimport glob from 'glob';\nimport path from 'path';\nimport { v4 } from 'uuid';\n\nimport FsContainer, { BitExecOption } from './container';\nimport ContainerExec from './container-exec';\n\nexport default class Capsule extends CapsuleTemplate<Exec, NodeFS> {\n private _wrkDir: string;\n constructor(\n /**\n * container implementation the capsule is being executed within.\n */\n protected container: FsContainer,\n /**\n * the capsule's file system.\n */\n readonly fs: NodeFS,\n /**\n * console for controlling process streams as stdout, stdin and stderr.\n */\n readonly console: Console = new Console(),\n /**\n * capsule's state.\n */\n readonly state: State,\n readonly component: Component\n ) {\n super(container, fs, console, state);\n this._wrkDir = container.wrkDir;\n }\n\n /**\n * @deprecated please use `this.path`\n */\n get wrkDir(): string {\n return this.path;\n }\n\n get path(): string {\n return realpathSync(this._wrkDir);\n }\n\n start(): Promise<any> {\n return this.container.start();\n }\n\n async execNode(executable: string, args: any, exec: ContainerExec) {\n return this.typedExec(\n {\n command: ['node', executable, ...(args.args || [])],\n cwd: '',\n },\n exec\n );\n }\n\n async typedExec(opts: BitExecOption, exec = new ContainerExec()) {\n return this.container.exec(opts, exec);\n }\n\n outputFile(file: string, data: any, options?: any): Promise<any> {\n return this.container.outputFile(file, data, options);\n }\n\n removePath(dir: string): Promise<any> {\n return this.container.removePath(dir);\n }\n\n symlink(src: string, dest: string): Promise<any> {\n return this.container.symlink(src, dest);\n }\n\n // TODO: refactor this crap and simplify capsule API\n async execute(cmd: string, options?: Record<string, any> | null | undefined) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const execResults = await this.exec({ command: cmd.split(' '), options });\n let stdout = '';\n let stderr = '';\n return new Promise((resolve, reject) => {\n execResults.stdout.on('data', (data: string) => {\n stdout += data;\n });\n execResults.stdout.on('error', (error: string) => {\n return reject(error);\n });\n // @ts-ignore\n execResults.on('close', () => {\n return resolve({ stdout, stderr });\n });\n execResults.stderr.on('error', (error: string) => {\n return reject(error);\n });\n execResults.stderr.on('data', (data: string) => {\n stderr += data;\n });\n });\n }\n\n /**\n * @todo: fix.\n * it skips the capsule fs because for some reason `capsule.fs.promises.readdir` doesn't work\n * the same as `capsule.fs.readdir` and it doesn't have the capsule dir as pwd.\n *\n * returns the paths inside the capsule\n */\n getAllFilesPaths(dir = '.', options: { ignore?: string[] } = {}) {\n const files = glob.sync('**', { cwd: path.join(this.path, dir), nodir: true, ...options });\n return files.map((file) => path.join(dir, file));\n }\n\n static getCapsuleDirName(component: Component, config: { alwaysNew?: boolean; name?: string } = {}) {\n return config.name || filenamify(component.id.toString(), { replacement: '_' });\n }\n\n static getCapsuleRootDir(component: Component, baseDir: string, config: { alwaysNew?: boolean; name?: string } = {}) {\n return path.join(baseDir, Capsule.getCapsuleDirName(component, config));\n }\n\n static async createFromComponent(\n component: Component,\n baseDir: string,\n config: { alwaysNew?: boolean } = {}\n ): Promise<Capsule> {\n // TODO: make this a static method and combine with ComponentCapsule\n const capsuleDirName = Capsule.getCapsuleDirName(component, config);\n const wrkDir = path.join(baseDir, config.alwaysNew ? `${capsuleDirName}_${v4()}` : capsuleDirName);\n const container = new FsContainer(wrkDir);\n const capsule = new Capsule(container, container.fs, new Console(), new State(), component);\n await capsule.start();\n return capsule;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,IAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,GAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,MAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,KAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAQ,WAAA;EAAA,MAAAR,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O,CAAClD,KAAK,CAAC,CAAC;IACrB,OAAOkD,OAAO;EAChB;AACF;AAACE,OAAA,CAAAlG,OAAA,GAAAiC,OAAA","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import { DuplexBufferStream, Exec, ExecStatus } from '@teambit/capsule';
2
+ import { EventEmitter } from 'events';
3
+ export default class ContainerExec extends EventEmitter implements Exec {
4
+ private _code;
5
+ constructor(_code?: number);
6
+ stdout: DuplexBufferStream;
7
+ stderr: DuplexBufferStream;
8
+ stdin: DuplexBufferStream;
9
+ setStatus(status: number): void;
10
+ get code(): number;
11
+ inspect(): Promise<ExecStatus>;
12
+ abort(): Promise<void>;
13
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _capsule() {
8
+ const data = require("@teambit/capsule");
9
+ _capsule = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _events() {
15
+ const data = require("events");
16
+ _events = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ 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; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
+ 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); }
24
+ class ContainerExec extends _events().EventEmitter {
25
+ constructor(_code = 0) {
26
+ super();
27
+ this._code = _code;
28
+ _defineProperty(this, "stdout", new (_capsule().DuplexBufferStream)());
29
+ _defineProperty(this, "stderr", new (_capsule().DuplexBufferStream)());
30
+ _defineProperty(this, "stdin", new (_capsule().DuplexBufferStream)());
31
+ }
32
+ setStatus(status) {
33
+ this._code = status;
34
+ this.emit('close');
35
+ }
36
+ get code() {
37
+ return this._code;
38
+ }
39
+ inspect() {
40
+ return Promise.resolve({
41
+ running: true,
42
+ pid: 1
43
+ });
44
+ }
45
+ abort() {
46
+ throw new Error('Method not implemented.');
47
+ }
48
+ }
49
+ exports.default = ContainerExec;
50
+
51
+ //# sourceMappingURL=container-exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_capsule","data","require","_events","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ContainerExec","EventEmitter","constructor","_code","DuplexBufferStream","setStatus","status","emit","code","inspect","Promise","resolve","running","pid","abort","Error","exports","default"],"sources":["container-exec.ts"],"sourcesContent":["import { DuplexBufferStream, Exec, ExecStatus } from '@teambit/capsule';\nimport { EventEmitter } from 'events';\n\nexport default class ContainerExec extends EventEmitter implements Exec {\n constructor(private _code: number = 0) {\n super();\n }\n\n stdout: DuplexBufferStream = new DuplexBufferStream();\n stderr: DuplexBufferStream = new DuplexBufferStream();\n stdin: DuplexBufferStream = new DuplexBufferStream();\n\n setStatus(status: number): void {\n this._code = status;\n this.emit('close');\n }\n\n get code(): number {\n return this._code;\n }\n\n inspect(): Promise<ExecStatus> {\n return Promise.resolve({\n running: true,\n pid: 1,\n });\n }\n abort(): Promise<void> {\n throw new Error('Method not implemented.');\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAsC,SAAAG,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YA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