Skip to content

Commit

Permalink
🎉 Feat(create-myplop-config): add new command version, function `pa…
Browse files Browse the repository at this point in the history
…ckageManager`
  • Loading branch information
INeedJobToStartWork committed Feb 2, 2024
1 parent a64f523 commit c6f5e4a
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/create-myplop-config/config/webpack/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const __dirname = resolve();
const PATHOUT = resolve(__dirname, "lib");

export default merge(WebpackConfig, {
plugins: [
new CopyPlugin({
patterns: [{ from: resolve(__dirname, "./src/templates"), to: join(PATHOUT, "templates") }]
})
]
// plugins: [
// new CopyPlugin({
// patterns: [{ from: resolve(__dirname, "./src/templates"), to: join(PATHOUT, "templates") }]
// })
// ]
});
2 changes: 1 addition & 1 deletion packages/create-myplop-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"bin": {
"create-myplop-configBUILD": "./dist/index.cjs",
"create-myplop-configDIV": "./lib/index.cjs"
"create-myplop-configDEV": "./lib/index.cjs"
},
"scripts": {
"build": "webpack --config ./config/webpack/webpack.prod.js",
Expand Down
14 changes: 14 additions & 0 deletions packages/create-myplop-config/src/cli/default.ts
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 }) => {

Check warning on line 11 in packages/create-myplop-config/src/cli/default.ts

View workflow job for this annotation

GitHub Actions / Continuous-Integration

Async arrow function has no 'await' expression
console.log("Hello world!");
console.log("Options: ", opts);
});
2 changes: 2 additions & 0 deletions packages/create-myplop-config/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./default";
export * from "./version";
4 changes: 4 additions & 0 deletions packages/create-myplop-config/src/cli/version.ts
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);
1 change: 1 addition & 0 deletions packages/create-myplop-config/src/functions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./packageManager";
14 changes: 14 additions & 0 deletions packages/create-myplop-config/src/functions/packageManager.ts
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.
5 changes: 4 additions & 1 deletion packages/create-myplop-config/src/index.ts
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);
1 change: 1 addition & 0 deletions packages/create-myplop-config/src/utils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { TpackageManagerSupport } from "@/functions/packageManager";

0 comments on commit c6f5e4a

Please sign in to comment.