-
Notifications
You must be signed in to change notification settings - Fork 46
Support installing packages through tsci add just like bun add #1070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
50509a7
Update CLI usage in README
github-actions[bot] 5f85da4
Merge branch 'tscircuit:main' into main
MustafaMulla29 492474d
Update CLI usage in README
github-actions[bot] c490a34
Merge branch 'tscircuit:main' into main
MustafaMulla29 5c62216
Merge branch 'tscircuit:main' into main
MustafaMulla29 6bba9b4
Merge branch 'tscircuit:main' into main
MustafaMulla29 938f262
Merge branch 'tscircuit:main' into main
MustafaMulla29 bc929d9
Merge branch 'tscircuit:main' into main
MustafaMulla29 41b1684
Support installing packages through tsci add just like bun add
MustafaMulla29 516b6c0
fix type issue
MustafaMulla29 fff410a
revert readme
MustafaMulla29 33c1d4b
update function name
MustafaMulla29 031f929
add tests
MustafaMulla29 bb0004a
check node_modules dir in tests
MustafaMulla29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture" | ||
| import { test, expect } from "bun:test" | ||
| import { join } from "node:path" | ||
| import { existsSync } from "node:fs" | ||
|
|
||
| test("tsci add - adds regular npm package", async () => { | ||
| const { tmpDir, runCommand } = await getCliTestFixture() | ||
|
|
||
| // Create initial package.json | ||
| await Bun.write( | ||
| join(tmpDir, "package.json"), | ||
| JSON.stringify({ | ||
| name: "test-project", | ||
| dependencies: {}, | ||
| }), | ||
| ) | ||
|
|
||
| // Test adding a regular npm package | ||
| const { stdout } = await runCommand("tsci add zod") | ||
| expect(stdout).toContain("Adding zod") | ||
| expect(stdout).toContain("successfully") | ||
|
|
||
| // Verify package.json was updated | ||
| const pkgJson = JSON.parse( | ||
| await Bun.file(join(tmpDir, "package.json")).text(), | ||
| ) | ||
| expect(pkgJson.dependencies["zod"]).toBeDefined() | ||
|
|
||
| // Verify package was actually installed in node_modules | ||
| const nodeModulesPath = join(tmpDir, "node_modules", "zod") | ||
| expect(existsSync(nodeModulesPath)).toBe(true) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture" | ||
| import { test, expect } from "bun:test" | ||
| import { join } from "node:path" | ||
| import { existsSync } from "node:fs" | ||
|
|
||
| test("tsci add - adds package from GitHub URL", async () => { | ||
| const { tmpDir, runCommand } = await getCliTestFixture() | ||
|
|
||
| // Create initial package.json | ||
| await Bun.write( | ||
| join(tmpDir, "package.json"), | ||
| JSON.stringify({ | ||
| name: "test-project", | ||
| dependencies: {}, | ||
| }), | ||
| ) | ||
|
|
||
| // Test adding from GitHub URL | ||
| const { stdout } = await runCommand( | ||
| "tsci add https://github.com/lodash/lodash", | ||
| ) | ||
| expect(stdout).toContain("Adding https://github.com/lodash/lodash") | ||
| expect(stdout).toContain("successfully") | ||
|
|
||
| // Verify package.json was updated | ||
| const pkgJson = JSON.parse( | ||
| await Bun.file(join(tmpDir, "package.json")).text(), | ||
| ) | ||
| expect(pkgJson.dependencies["lodash"]).toBeDefined() | ||
MustafaMulla29 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Verify package was actually installed in node_modules | ||
| const nodeModulesPath = join(tmpDir, "node_modules", "lodash") | ||
| expect(existsSync(nodeModulesPath)).toBe(true) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture" | ||
| import { test, expect } from "bun:test" | ||
| import { join } from "node:path" | ||
| import { existsSync } from "node:fs" | ||
|
|
||
| test("tsci add - adds package with version", async () => { | ||
| const { tmpDir, runCommand } = await getCliTestFixture() | ||
|
|
||
| // Create initial package.json | ||
| await Bun.write( | ||
| join(tmpDir, "package.json"), | ||
| JSON.stringify({ | ||
| name: "test-project", | ||
| dependencies: {}, | ||
| }), | ||
| ) | ||
|
|
||
| // Test adding with version | ||
| const { stdout } = await runCommand("tsci add zod@3.22.0") | ||
| expect(stdout).toContain("Adding zod@3.22.0") | ||
| expect(stdout).toContain("successfully") | ||
|
|
||
| // Verify package.json was updated with specific version | ||
| const pkgJson = JSON.parse( | ||
| await Bun.file(join(tmpDir, "package.json")).text(), | ||
| ) | ||
| expect(pkgJson.dependencies["zod"]).toBe("3.22.0") | ||
|
|
||
| // Verify package was actually installed in node_modules | ||
| const nodeModulesPath = join(tmpDir, "node_modules", "zod") | ||
| expect(existsSync(nodeModulesPath)).toBe(true) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture" | ||
| import { test, expect } from "bun:test" | ||
| import { join } from "node:path" | ||
|
|
||
| test("tsci add - handles author/component format as tscircuit package", async () => { | ||
| const { tmpDir, runCommand } = await getCliTestFixture() | ||
|
|
||
| // Create initial package.json | ||
| await Bun.write( | ||
| join(tmpDir, "package.json"), | ||
| JSON.stringify({ | ||
| name: "test-project", | ||
| dependencies: {}, | ||
| }), | ||
| ) | ||
|
|
||
| // Test author/component format (should convert to @tsci/author.component) | ||
| const result = await runCommand("tsci add seveibar/soup") | ||
|
|
||
| // Should show it's trying to add @tsci/seveibar.soup | ||
| expect( | ||
| result.stdout.includes("@tsci/seveibar.soup") || | ||
| result.stderr.includes("@tsci/seveibar.soup"), | ||
| ).toBe(true) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture" | ||
| import { test, expect } from "bun:test" | ||
| import { join } from "node:path" | ||
| import { existsSync } from "node:fs" | ||
|
|
||
| test("tsci add - handles scoped packages", async () => { | ||
| const { tmpDir, runCommand } = await getCliTestFixture() | ||
|
|
||
| // Create initial package.json | ||
| await Bun.write( | ||
| join(tmpDir, "package.json"), | ||
| JSON.stringify({ | ||
| name: "test-project", | ||
| dependencies: {}, | ||
| }), | ||
| ) | ||
|
|
||
| // Test adding a scoped package | ||
| const { stdout } = await runCommand("tsci add @types/node") | ||
| expect(stdout).toContain("Adding @types/node") | ||
| expect(stdout).toContain("successfully") | ||
|
|
||
| // Verify package.json was updated | ||
| const pkgJson = JSON.parse( | ||
| await Bun.file(join(tmpDir, "package.json")).text(), | ||
| ) | ||
| expect(pkgJson.dependencies["@types/node"]).toBeDefined() | ||
|
|
||
| // Verify package was actually installed in node_modules | ||
| const nodeModulesPath = join(tmpDir, "node_modules", "@types", "node") | ||
| expect(existsSync(nodeModulesPath)).toBe(true) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture" | ||
| import { test, expect } from "bun:test" | ||
| import { join } from "node:path" | ||
|
|
||
| test("tsci add - handles author.component format as tscircuit package", async () => { | ||
| const { tmpDir, runCommand } = await getCliTestFixture() | ||
|
|
||
| // Create initial package.json | ||
| await Bun.write( | ||
| join(tmpDir, "package.json"), | ||
| JSON.stringify({ | ||
| name: "test-project", | ||
| dependencies: {}, | ||
| }), | ||
| ) | ||
|
|
||
| // Test author.component format (should convert to @tsci/author.component) | ||
| const result = await runCommand("tsci add seveibar.soup") | ||
|
|
||
| // Should show it's trying to add @tsci/seveibar.soup | ||
| expect( | ||
| result.stdout.includes("@tsci/seveibar.soup") || | ||
| result.stderr.includes("@tsci/seveibar.soup"), | ||
| ).toBe(true) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.