Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
init command fix for packages having name "." (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: Severin Ibarluzea <[email protected]>
  • Loading branch information
seveibar and Severin Ibarluzea authored Jun 24, 2024
1 parent bd6773d commit 433196f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/cmd-fns/init/get-generated-readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ export const getGeneratedReadme = ({
shouldHaveProjectGeneratedNotice?: boolean
}) => {
return `
# ${name}
# ${name.split("/").pop()?.split(".").pop()}
[![tscircuit version badge](https://registry-api.tscircuit.com/badges/view?package_name=${name
.replace("@", "")
.replace("/", ".")})](https://registry.tscircuit.com/${name.replace(
"@",
""
)})
.replace("@tsci/", "")
.replace("/", ".")})](https://registry.tscircuit.com/${name
.replace("@tsci/", "")
.replace(".", "/")})
${
shouldHaveProjectGeneratedNotice
Expand Down
9 changes: 7 additions & 2 deletions lib/cmd-fns/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getGeneratedReadme } from "./get-generated-readme"
import { getGeneratedTsconfig } from "./get-generated-tsconfig"
import { getGeneratedNpmrc } from "./get-generated-npmrc"
import { createOrModifyNpmrc } from "./create-or-modify-npmrc"
import prompts from "prompts"

export const initCmd = async (ctx: AppContext, args: any) => {
const params = z
Expand All @@ -39,9 +40,13 @@ export const initCmd = async (ctx: AppContext, args: any) => {
if (subName === ".") {
subName = Path.basename(Path.resolve(params.dir))
}
params.name = `@${myAccount.github_username}/${subName}`
params.name = `@tsci/${myAccount.github_username}.${subName}`
} catch (e: any) {
params.name = Path.basename(params.dir ?? ctx.cwd)
const { github_username, package_name } = await prompts([
{ type: "text", name: "github_username", message: "GitHub username" },
{ type: "text", name: "package_name", message: "Package name" },
])
params.name = `@tsci/${github_username}.${package_name}`
}
}

Expand Down

0 comments on commit 433196f

Please sign in to comment.