-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Feat(create-myplop-config): add new command
version
, function `pa…
…ckageManager`
- Loading branch information
1 parent
a64f523
commit c6f5e4a
Showing
10 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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,14 @@ | ||
// import { packageManager } from "@/functions"; | ||
import { program } from "commander"; | ||
|
||
// const argTest = new Argument("<path>", "path to create the config in."); | ||
|
||
program | ||
.option("-d, --debug", "output extra debugging", false) | ||
// .addArgument(argTest) | ||
// .option("--y --yestoall", "package manager to use (npm, yarn, pnpm)", false) | ||
// .option("--manager <manager>", "package manager to use (npm, yarn, pnpm)", "npm") | ||
.action(async (opts: { debug: boolean; yestoall: boolean }) => { | ||
console.log("Hello world!"); | ||
console.log("Options: ", opts); | ||
}); |
This file contains 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,2 @@ | ||
export * from "./default"; | ||
export * from "./version"; |
This file contains 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,4 @@ | ||
import { version } from "@/../package.json"; | ||
import { program } from "commander"; | ||
|
||
program.version(version); |
This file contains 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 @@ | ||
export * from "./packageManager"; |
14 changes: 14 additions & 0 deletions
14
packages/create-myplop-config/src/functions/packageManager.ts
This file contains 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,14 @@ | ||
export type TpackageManagerSupport = (typeof packageManagersSupport)[number]; | ||
export const packageManagersSupport = ["npm", "yarn", "pnpm", "bun"] as const; | ||
|
||
export const packageManager = (() => { | ||
const userManager = process.env.npm_config_user_agent; | ||
|
||
const startWithSupport = (manager: TpackageManagerSupport) => userManager?.startsWith(manager); | ||
if (userManager === undefined) return "npm"; | ||
if (startWithSupport("pnpm")) return "pnpm"; | ||
if (startWithSupport("yarn")) return "yarn"; | ||
if (startWithSupport("bun")) return "bun"; | ||
|
||
throw new Error("Unsupported package manager"); | ||
})(); |
Empty file.
This file contains 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 |
---|---|---|
@@ -1 +1,4 @@ | ||
console.log("Hello from create-myplop-config"); | ||
import "@/cli"; | ||
import { program } from "commander"; | ||
|
||
program.parse(process.argv); |
This file contains 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 @@ | ||
export type { TpackageManagerSupport } from "@/functions/packageManager"; |