typescript-virtual-container 0.1.0

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 (60) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +50 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.yml +31 -0
  3. package/.github/dependabot.yml +27 -0
  4. package/.github/pull_request_template.md +21 -0
  5. package/.github/workflows/create-pull-request.yml +83 -0
  6. package/.github/workflows/test-battery.yml +57 -0
  7. package/CHANGELOG.md +27 -0
  8. package/CODE_OF_CONDUCT.md +39 -0
  9. package/CONTRIBUTING.md +59 -0
  10. package/LICENSE +21 -0
  11. package/README.md +1283 -0
  12. package/SECURITY.md +33 -0
  13. package/biome.json +20 -0
  14. package/bun.lock +99 -0
  15. package/package.json +38 -0
  16. package/src/SSHMimic/client.ts +248 -0
  17. package/src/SSHMimic/commands/adduser.ts +22 -0
  18. package/src/SSHMimic/commands/cat.ts +16 -0
  19. package/src/SSHMimic/commands/cd.ts +20 -0
  20. package/src/SSHMimic/commands/clear.ts +7 -0
  21. package/src/SSHMimic/commands/curl.ts +27 -0
  22. package/src/SSHMimic/commands/deluser.ts +19 -0
  23. package/src/SSHMimic/commands/exit.ts +7 -0
  24. package/src/SSHMimic/commands/help.ts +9 -0
  25. package/src/SSHMimic/commands/helpers.ts +137 -0
  26. package/src/SSHMimic/commands/hostname.ts +7 -0
  27. package/src/SSHMimic/commands/htop.ts +13 -0
  28. package/src/SSHMimic/commands/index.ts +120 -0
  29. package/src/SSHMimic/commands/ls.ts +14 -0
  30. package/src/SSHMimic/commands/mkdir.ts +17 -0
  31. package/src/SSHMimic/commands/nano.ts +30 -0
  32. package/src/SSHMimic/commands/pwd.ts +7 -0
  33. package/src/SSHMimic/commands/rm.ts +26 -0
  34. package/src/SSHMimic/commands/su.ts +31 -0
  35. package/src/SSHMimic/commands/sudo.ts +90 -0
  36. package/src/SSHMimic/commands/touch.ts +20 -0
  37. package/src/SSHMimic/commands/tree.ts +11 -0
  38. package/src/SSHMimic/commands/wget.ts +33 -0
  39. package/src/SSHMimic/commands/who.ts +18 -0
  40. package/src/SSHMimic/commands/whoami.ts +7 -0
  41. package/src/SSHMimic/exec.ts +37 -0
  42. package/src/SSHMimic/hostKey.ts +21 -0
  43. package/src/SSHMimic/index.ts +203 -0
  44. package/src/SSHMimic/loginFormat.ts +10 -0
  45. package/src/SSHMimic/prompt.ts +14 -0
  46. package/src/SSHMimic/shell.ts +740 -0
  47. package/src/SSHMimic/users.ts +336 -0
  48. package/src/VirtualFileSystem.ts +420 -0
  49. package/src/index.ts +34 -0
  50. package/src/standalone.ts +14 -0
  51. package/src/types/commands.ts +98 -0
  52. package/src/types/streams.ts +32 -0
  53. package/src/types/tar-stream.d.ts +38 -0
  54. package/src/types/vfs.ts +81 -0
  55. package/src/vfs/archive.ts +74 -0
  56. package/src/vfs/internalTypes.ts +19 -0
  57. package/src/vfs/path.ts +74 -0
  58. package/src/vfs/snapshot.ts +84 -0
  59. package/src/vfs/tree.ts +34 -0
  60. package/tsconfig.json +31 -0
@@ -0,0 +1,50 @@
1
+ name: Bug report
2
+ description: Report a reproducible problem
3
+ labels: [bug]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for reporting a bug. Please fill out the details below.
9
+ - type: input
10
+ id: version
11
+ attributes:
12
+ label: Package version
13
+ placeholder: 1.0.0
14
+ validations:
15
+ required: true
16
+ - type: input
17
+ id: runtime
18
+ attributes:
19
+ label: Runtime and version
20
+ description: Node or Bun
21
+ placeholder: Node 20.12.0
22
+ validations:
23
+ required: true
24
+ - type: textarea
25
+ id: reproduction
26
+ attributes:
27
+ label: Reproduction steps
28
+ placeholder: |
29
+ 1. Start server with ...
30
+ 2. Run command ...
31
+ 3. Observe error ...
32
+ validations:
33
+ required: true
34
+ - type: textarea
35
+ id: expected
36
+ attributes:
37
+ label: Expected behavior
38
+ validations:
39
+ required: true
40
+ - type: textarea
41
+ id: actual
42
+ attributes:
43
+ label: Actual behavior
44
+ validations:
45
+ required: true
46
+ - type: textarea
47
+ id: logs
48
+ attributes:
49
+ label: Logs or stack trace
50
+ render: shell
@@ -0,0 +1,31 @@
1
+ name: Feature request
2
+ description: Suggest an improvement
3
+ labels: [enhancement]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for proposing an improvement.
9
+ - type: textarea
10
+ id: problem
11
+ attributes:
12
+ label: Problem statement
13
+ description: What problem are you trying to solve?
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: proposal
18
+ attributes:
19
+ label: Proposed solution
20
+ description: Describe the API or behavior you want.
21
+ validations:
22
+ required: true
23
+ - type: textarea
24
+ id: alternatives
25
+ attributes:
26
+ label: Alternatives considered
27
+ - type: textarea
28
+ id: impact
29
+ attributes:
30
+ label: Breaking change impact
31
+ description: Does this change public API behavior?
@@ -0,0 +1,27 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
7
+ time: "04:00"
8
+ timezone: "Europe/Paris"
9
+ open-pull-requests-limit: 20
10
+ rebase-strategy: "auto"
11
+ versioning-strategy: "increase-if-necessary"
12
+ # Exclude metric/analytics packages from version update PRs.
13
+ ignore:
14
+ - dependency-name: "*metrics*"
15
+ - dependency-name: "*analytics*"
16
+ groups:
17
+ patch-and-minor:
18
+ patterns:
19
+ - "*"
20
+ update-types:
21
+ - "minor"
22
+ - "patch"
23
+ major:
24
+ patterns:
25
+ - "*"
26
+ update-types:
27
+ - "major"
@@ -0,0 +1,21 @@
1
+ ## Summary
2
+
3
+ Describe what changed and why.
4
+
5
+ ## Type of change
6
+
7
+ - [ ] Bug fix
8
+ - [ ] New feature
9
+ - [ ] Breaking change
10
+ - [ ] Documentation update
11
+ - [ ] Refactor
12
+
13
+ ## Validation
14
+
15
+ - [ ] I ran bun format
16
+ - [ ] I ran bun check
17
+ - [ ] I tested the changed behavior locally
18
+
19
+ ## Notes for reviewers
20
+
21
+ Include anything reviewers should focus on (tradeoffs, edge cases, risks).
@@ -0,0 +1,83 @@
1
+ name: Auto Create Pull Request
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - 'dev'
7
+
8
+ jobs:
9
+ create-pull-request:
10
+ if: github.ref == 'refs/heads/dev'
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Validate pull request token
14
+ env:
15
+ AUTO_PR_TOKEN: ${{ secrets.AUTO_PR_TOKEN }}
16
+ run: |
17
+ if [ -z "$AUTO_PR_TOKEN" ]; then
18
+ echo "AUTO_PR_TOKEN is required to create pull requests from GitHub Actions. Use a PAT or GitHub App token with contents:write and pull-requests:write."
19
+ exit 1
20
+ fi
21
+
22
+ - name: Create pull request if none exists
23
+ uses: actions/github-script@v8
24
+ with:
25
+ github-token: ${{ secrets.AUTO_PR_TOKEN }}
26
+ script: |
27
+ const owner = context.repo.owner;
28
+ const repo = context.repo.repo;
29
+ const head = `${owner}:dev`;
30
+ const base = 'main';
31
+
32
+ // Check if there are commits between main and dev
33
+ const { data: comparison } = await github.rest.repos.compareCommits({
34
+ owner,
35
+ repo,
36
+ base: 'main',
37
+ head: 'dev',
38
+ }).catch(err => {
39
+ if (err.status === 404 && err.message.includes('No commits')) {
40
+ core.info('No commits between main and dev - skipping PR creation');
41
+ return { data: { ahead_by: 0 } };
42
+ }
43
+ throw err;
44
+ });
45
+
46
+ if (comparison.ahead_by === 0) {
47
+ core.info('Branches are identical - no pull request needed');
48
+ return;
49
+ }
50
+
51
+ const { data: existingPullRequests } = await github.rest.pulls.list({
52
+ owner,
53
+ repo,
54
+ state: 'open',
55
+ head,
56
+ base,
57
+ });
58
+
59
+ if (existingPullRequests.length > 0) {
60
+ core.info(`Pull request already exists: #${existingPullRequests[0].number}`);
61
+ return;
62
+ }
63
+
64
+ const { data: pullRequest } = await github.rest.pulls.create({
65
+ owner,
66
+ repo,
67
+ head: 'dev',
68
+ base,
69
+ title: 'chore: auto PR from dev to main',
70
+ body: [
71
+ 'This pull request was created automatically by GitHub Actions.',
72
+ '',
73
+ `- source branch: \`dev\``,
74
+ `- target branch: \`main\``,
75
+ `- triggered by commit \`${context.sha}\``,
76
+ ].join('\n'),
77
+ });
78
+
79
+ core.info(`Created pull request #${pullRequest.number}: ${pullRequest.html_url}`);
80
+
81
+ permissions:
82
+ contents: write
83
+ pull-requests: write
@@ -0,0 +1,57 @@
1
+ name: Test battery
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ - dev
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ typecheck:
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Setup Bun
21
+ uses: oven-sh/setup-bun@v1
22
+ with:
23
+ bun-version: latest
24
+
25
+ - name: Install dependencies
26
+ run: bun install
27
+
28
+ - name: Run typecheck
29
+ run: bun check
30
+
31
+ lint:
32
+ runs-on: ubuntu-latest
33
+
34
+ steps:
35
+ - name: Checkout repository
36
+ uses: actions/checkout@v4
37
+
38
+ - name: Setup Bun
39
+ uses: oven-sh/setup-bun@v1
40
+ with:
41
+ bun-version: latest
42
+
43
+ - name: Install dependencies
44
+ run: bun install
45
+
46
+ - name: Run lint
47
+ run: bun lint
48
+
49
+ test-battery:
50
+ needs:
51
+ - typecheck
52
+ - lint
53
+ runs-on: ubuntu-latest
54
+
55
+ steps:
56
+ - name: Test battery passed
57
+ run: echo "Typecheck, lint and tests succeeded."
package/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on Keep a Changelog.
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Added
10
+
11
+ - Governance and community files:
12
+ - LICENSE
13
+ - CONTRIBUTING.md
14
+ - SECURITY.md
15
+ - CODE_OF_CONDUCT.md
16
+ - GitHub issue and PR templates
17
+
18
+ ## [1.0.0] - 2026-04-14
19
+
20
+ ### Added
21
+
22
+ - In-memory SSH server with password authentication.
23
+ - Virtual filesystem with optional compression and tar.gz persistence.
24
+ - Virtual user management with sudoers and session tracking.
25
+ - Programmatic SshClient API.
26
+ - 20+ built-in shell commands.
27
+ - TypeScript-first API with exported types and JSDoc.
@@ -0,0 +1,39 @@
1
+ # Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to a positive environment include:
10
+
11
+ - Being respectful and inclusive
12
+ - Giving and receiving constructive feedback
13
+ - Focusing on what is best for the community
14
+ - Showing empathy toward other contributors
15
+
16
+ Examples of unacceptable behavior include:
17
+
18
+ - Harassment, insults, or discriminatory language
19
+ - Trolling or personal attacks
20
+ - Publishing private information without consent
21
+ - Any conduct that is inappropriate in a professional setting
22
+
23
+ ## Enforcement Responsibilities
24
+
25
+ Project maintainers are responsible for clarifying and enforcing standards and may remove, edit, or reject comments, commits, code, issues, and other contributions that are not aligned with this Code of Conduct.
26
+
27
+ ## Scope
28
+
29
+ This Code of Conduct applies within project spaces and in public spaces when an individual is officially representing the project.
30
+
31
+ ## Enforcement
32
+
33
+ If you experience or witness unacceptable behavior, report it through the repository maintainers.
34
+
35
+ Maintainers will review and investigate reports and respond in a way they deem appropriate to the circumstances.
36
+
37
+ ## Attribution
38
+
39
+ This document is inspired by the Contributor Covenant, version 2.1.
@@ -0,0 +1,59 @@
1
+ # Contributing
2
+
3
+ Thanks for contributing to typescript-virtual-container.
4
+
5
+ ## Development Setup
6
+
7
+ 1. Fork and clone the repository.
8
+ 2. Install dependencies:
9
+
10
+ ```bash
11
+ bun install
12
+ ```
13
+
14
+ 3. Run checks before opening a pull request:
15
+
16
+ ```bash
17
+ bun format
18
+ bun check
19
+ ```
20
+
21
+ ## Branch and Commit Style
22
+
23
+ - Create focused branches (example: feat/programmatic-client-timeout).
24
+ - Keep commits small and descriptive.
25
+ - Prefer conventional commit prefixes when possible:
26
+ - feat:
27
+ - fix:
28
+ - docs:
29
+ - refactor:
30
+ - test:
31
+ - chore:
32
+
33
+ ## Coding Guidelines
34
+
35
+ - Use TypeScript with explicit, readable types.
36
+ - Avoid introducing any without a strong reason.
37
+ - Preserve existing API behavior unless the change is intentional and documented.
38
+ - Keep command behavior deterministic for tests and CI use cases.
39
+
40
+ ## Pull Request Checklist
41
+
42
+ - I ran format and checks locally.
43
+ - I added or updated documentation for public behavior changes.
44
+ - I added tests for bug fixes or new behavior when applicable.
45
+ - I kept changes scoped to one objective.
46
+
47
+ ## Reporting Issues
48
+
49
+ When opening an issue, include:
50
+
51
+ - Package version
52
+ - Runtime (Node or Bun) and version
53
+ - Minimal reproduction steps
54
+ - Expected behavior and actual behavior
55
+
56
+ ## Security
57
+
58
+ Please do not open public issues for vulnerabilities.
59
+ See SECURITY.md for responsible disclosure details.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 itsrealfortune
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.