mirror of
https://github.com/CompeyDev/create-guilded-bot.git
synced 2024-12-12 12:50:35 +00:00
feat: initialize cli & dependency installation
This commit is contained in:
parent
8fda47196d
commit
df5ec67c3b
37 changed files with 276 additions and 473 deletions
|
@ -1 +0,0 @@
|
||||||
// do this someday
|
|
|
@ -3,8 +3,7 @@
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"apps/*",
|
"libs/*",
|
||||||
"apps/*/*",
|
|
||||||
"packages/*/*"
|
"packages/*/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
4
packages/bot/typescript/tsconfig.json
Normal file
4
packages/bot/typescript/tsconfig.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
}
|
||||||
|
|
10
packages/cli/lib/getPackageManager.ts
Normal file
10
packages/cli/lib/getPackageManager.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
export default function get(): string|null {
|
||||||
|
const userAgent = process.env.npm_config_user_agent
|
||||||
|
if (!userAgent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const manager= userAgent.split(" ")[0].split("/")[0];
|
||||||
|
|
||||||
|
return manager
|
||||||
|
}
|
44
packages/cli/lib/installDependencies.ts
Normal file
44
packages/cli/lib/installDependencies.ts
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import { spawn } from "child_process";
|
||||||
|
import { userInfo } from "os";
|
||||||
|
|
||||||
|
|
||||||
|
export default function install(packageManager: "npm" | "pnpm" | "yarn" | null, workingDirectory: string) {
|
||||||
|
const cmds = {
|
||||||
|
npm: {
|
||||||
|
command: "npm",
|
||||||
|
args: ["install"]
|
||||||
|
},
|
||||||
|
pnpm: {
|
||||||
|
command: "pnpm",
|
||||||
|
args: ["install"]
|
||||||
|
},
|
||||||
|
yarn: {
|
||||||
|
command: "yarn",
|
||||||
|
args: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(userInfo().shell)
|
||||||
|
switch (packageManager) {
|
||||||
|
case null:
|
||||||
|
const spawnedNPM = spawn(`${cmds.npm.command}`, cmds.npm.args, { cwd: workingDirectory, stdio: "inherit", shell: userInfo().shell })
|
||||||
|
|
||||||
|
spawnedNPM.stdout.on("data", (out) => {
|
||||||
|
console.log(`Installing dependencies using npm`)
|
||||||
|
console.log(`\rnpm :: ${out}`)
|
||||||
|
})
|
||||||
|
case "npm" || "pnpm" || "yarn":
|
||||||
|
const spawnedAny = spawn(`${cmds[packageManager].command}`, cmds[packageManager].args, { cwd: workingDirectory, stdio: "inherit", shell: userInfo().shell })
|
||||||
|
|
||||||
|
spawnedAny.stdout.on("data", (out) => {
|
||||||
|
console.log(`Installing dependencies using ${packageManager}`)
|
||||||
|
console.log(`\r${packageManager} :: ${out}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
spawnedAny.stderr.on("data", (err) => {
|
||||||
|
console.error(`\r${packageManager} error: ${err}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,21 +8,21 @@
|
||||||
"dev": "ts-node-dev src/index.ts",
|
"dev": "ts-node-dev src/index.ts",
|
||||||
"start": "ts-node src/index.ts"
|
"start": "ts-node src/index.ts"
|
||||||
},
|
},
|
||||||
"type": "module",
|
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"inquirer": "8.2.3",
|
||||||
|
"kleur": "^4.1.5"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/inquirer": "^9.0.3",
|
"@types/inquirer": "8.2.3",
|
||||||
"@types/node": "^18.11.9",
|
"@types/node": "^18.11.9",
|
||||||
"@types/prompt": "^1.1.4",
|
"@types/prompt": "^1.1.4",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
"ts-node-dev": "^2.0.0",
|
"ts-node-dev": "^2.0.0",
|
||||||
"tsconfig": "workspace:*",
|
"tsconfig": "workspace:*",
|
||||||
"tslib": "^2.4.1",
|
"tslib": "^2.4.1",
|
||||||
"typescript": "^4.9.3"
|
"typescript": "^4.9.3"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"inquirer": "^9.1.4",
|
|
||||||
"kleur": "^4.1.5"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
28
packages/cli/src/index.ts
Normal file
28
packages/cli/src/index.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import * as inquirer from "inquirer";
|
||||||
|
import getPackageManager from "../lib/getPackageManager";
|
||||||
|
import install from "../lib/installDependencies";
|
||||||
|
|
||||||
|
inquirer
|
||||||
|
.prompt([
|
||||||
|
{
|
||||||
|
type: 'list',
|
||||||
|
name: 'flavor',
|
||||||
|
message: 'Which flavor?',
|
||||||
|
choices: ['TypeScript', 'JavaScript'],
|
||||||
|
filter(val) {
|
||||||
|
return val.toLowerCase();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
.then((answers) => {
|
||||||
|
console.log(JSON.stringify(answers, null, ' '));
|
||||||
|
let packageManager = getPackageManager()
|
||||||
|
|
||||||
|
if (packageManager !== "npm"||"pnpm"||"yarn") {
|
||||||
|
packageManager = "npm"
|
||||||
|
}
|
||||||
|
|
||||||
|
install(packageManager as "npm"|"pnpm"|"yarn"|null, ".")
|
||||||
|
|
||||||
|
|
||||||
|
});
|
|
@ -1,4 +0,0 @@
|
||||||
import * as React from "react";
|
|
||||||
export const Button = () => {
|
|
||||||
return <button>Boop</button>;
|
|
||||||
};
|
|
|
@ -1,2 +0,0 @@
|
||||||
import * as React from "react";
|
|
||||||
export * from "./Button";
|
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"name": "ui",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"main": "./index.tsx",
|
|
||||||
"types": "./index.tsx",
|
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
|
||||||
"lint": "eslint *.ts*"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/react": "^18.0.17",
|
|
||||||
"@types/react-dom": "^18.0.6",
|
|
||||||
"eslint": "^7.32.0",
|
|
||||||
"eslint-config-custom": "workspace:*",
|
|
||||||
"react": "^18.2.0",
|
|
||||||
"tsconfig": "workspace:*",
|
|
||||||
"typescript": "^4.5.2"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "tsconfig/react-library.json",
|
|
||||||
"include": ["."],
|
|
||||||
"exclude": ["dist", "build", "node_modules"]
|
|
||||||
}
|
|
614
pnpm-lock.yaml
614
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,3 @@
|
||||||
packages:
|
packages:
|
||||||
- "apps/*"
|
- "libs/*"
|
||||||
- "apps/*/*"
|
|
||||||
- "packages/*"
|
- "packages/*"
|
||||||
|
|
Loading…
Reference in a new issue